diff --git a/klp-wms/src/main/java/com/klp/service/impl/WmsActualWarehouseServiceImpl.java b/klp-wms/src/main/java/com/klp/service/impl/WmsActualWarehouseServiceImpl.java index b72927b8..8a0bf387 100644 --- a/klp-wms/src/main/java/com/klp/service/impl/WmsActualWarehouseServiceImpl.java +++ b/klp-wms/src/main/java/com/klp/service/impl/WmsActualWarehouseServiceImpl.java @@ -56,20 +56,27 @@ public class WmsActualWarehouseServiceImpl implements IWmsActualWarehouseService Integer layers = bo.getLayerCount(); String prefix = bo.getPrefix(); Long parentId = bo.getParentId(); - if (rows == null || cols == null || layers == null || rows < 1 || cols < 1 || layers < 1) { - throw new ServiceException("行/列/层必须为正整数"); + if (layers == null) { + layers = 2; + } + if (rows == null || cols == null || rows < 1 || cols < 1) { + throw new ServiceException("行/列必须为正整数"); + } + if (layers < 1) { + throw new ServiceException("层必须为正整数"); } if (StringUtils.isBlank(prefix)) { throw new ServiceException("前缀不能为空"); } - // 预生成候选编码 List codes = new ArrayList<>(rows * cols * layers); - for (int c = 1; c <= cols; c++) { - for (int r = 1; r <= rows; r++) { - String rStr = r < 10 ? ("0" + r) : String.valueOf(r); - for (int l = 1; l <= layers; l++) { - String code = prefix + c + rStr + '-' + l; + for (int l = 1; l <= layers; l++) { + int rowsForLayer = (l == 2) ? Math.max(rows - 1, 1) : rows; + for (int c = 1; c <= cols; c++) { + for (int r = 1; r <= rowsForLayer; r++) { + // 列号补两位(01/02...) + String cStr = c < 10 ? ("0" + c) : String.valueOf(c); + String code = prefix + r + '-' + cStr + '-' + l; codes.add(code); } }