feat(wms): 调整货位编码生成逻辑以支持楼层差异化策略

- 修改默认层数为2层当层数未指定时
- 校验行数和列数必须为正整数
- 校验层数必须为正整数
- 重新组织循环结构以优先遍历层再行列
- 第二层货位行数减一以适应特殊布局需求
- 调整编码格式为 行-列-层 的组合方式
- 列号统一补零为两位数格式
This commit is contained in:
2025-12-08 11:15:22 +08:00
parent 59951b77c3
commit e616d79603

View File

@@ -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<String> 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);
}
}