diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java b/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java index 8b40785..956c491 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java @@ -157,6 +157,18 @@ public class WcsIntegrationController { } } + /** + * 获取指定层数下各个位置的可用状态 - rqrq + * @param params {site, palletId, layer} + * @return 各位置可用状态 + */ + @PostMapping(value="/getAvailablePositionsForLayer") + @ResponseBody + public R getAvailablePositionsForLayer(@RequestBody Map params) throws Exception { + Map result = wcsIntegrationService.getAvailablePositionsForLayer(params); + return R.ok().put("data", result); + } + // ==================== 运输任务相关接口 - AI制作 ==================== /** diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java b/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java index 72a93a7..4b77bc4 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java @@ -324,4 +324,10 @@ public interface WcsIntegrationMapper { */ void updatePalletTypeAndAutoSort(@Param("site") String site, @Param("palletId") String palletId, @Param("palletType") String palletType, @Param("autoSort") String autoSort); + + /** + * 获取指定层已占用的位置列表 - rqrq + */ + List getOccupiedPositionsByLayer(@Param("site") String site, @Param("palletId") String palletId, + @Param("layer") Integer layer); } diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java b/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java index 31b4118..ec7cb93 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java @@ -114,4 +114,11 @@ public interface WcsIntegrationService { * @param params 包含site和palletId */ void completePalletAssembly(Map params) throws Exception; + + /** + * 获取指定层数下各个位置的可用状态 - rqrq + * @param params {site, palletId, layer} + * @return 包含positions(位置列表)、availablePositions(可用位置)、maxLayer(最大层数)、isMixed(是否混装) + */ + Map getAvailablePositionsForLayer(Map params) throws Exception; } diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java b/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java index 3ebc0ed..0f93d5e 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java @@ -262,28 +262,33 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { System.out.println("旧记录已删除,准备扫入新栈板" + palletId); } - // 3. 获取栈板类型信息和maxLayer + // 3. 获取栈板类型信息和maxLayer、wcsSoreType - rqrq com.gaotao.modules.warehouse.entity.PalletData palletInfo = wcsIntegrationMapper.getPalletInfoWithTypeDetails(site, palletId); String palletType = palletInfo.getPalletType(); Integer maxLayer = palletInfo.getMaxLayer() != null ? palletInfo.getMaxLayer() : 0; - - // 4. 根据maxLayer进行不同的校验 - if (maxLayer > 0) { - // maxLayer > 0:有层数托盘(9宫格、4宫格等) - // 每个位置每层只能放一个东西 - - // 检查该位置该层是否已有东西 暂时注掉 - // List> existingDetails = wcsIntegrationMapper.getPalletDetails(site, palletId, position, layer); - // if (!existingDetails.isEmpty()) { - // throw new Exception("该位置第" + layer + "层已有物料,每层只能放一个物料"); - // } - } else { - // maxLayer = 0:混装托盘 - // 只能选第1层,但可以放多个东西 - if (layer != 1) { - throw new Exception("混装托盘只能使用第1层"); + Integer wcsSoreType = palletInfo.getWcsSoreType() != null ? palletInfo.getWcsSoreType() : 0; + if (layer > 1) { + // 检查该位置的第1层到第layer-1层是否都有物料 - rqrq + List existingLayers = wcsIntegrationMapper.getLayersByPosition(site, palletId, position); + + // 检查每一层是否都有物料 - rqrq + for (int i = 1; i < layer; i++) { + if (!existingLayers.contains(i)) { + throw new Exception("该位置第" + i + "层没有物料,不能放置第" + layer + "层,防止物品悬空"); + } } - // 允许同一位置同一层放多个东西,不做校验 + } + // 4. 根据maxLayer和wcsSoreType进行不同的校验 - rqrq + if(wcsSoreType == 1) { + // wcsSoreType = 1:气胀轴自动分拣(9宫格、4宫格),每个位置每层只能放一个东西 + List> existingDetails = wcsIntegrationMapper.getPalletDetails(site, palletId, position, layer); + if (!existingDetails.isEmpty()) { + throw new Exception("该位置第" + layer + "层已有物料,气胀轴分拣托盘每层只能放一个物料"); + } + } else if (wcsSoreType == 2) { + // wcsSoreType = 2:抱箱自动分拣(底4箱+上3箱等),每层可以放多个东西 + } else { + // wcsSoreType = 0或其他:允许放多个 } // 5. 保存栈板明细 @@ -404,13 +409,27 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { throw new Exception("标签不在当前栈板中"); } - // 获取栈板类型信息和maxLayer + // 获取栈板类型信息和maxLayer、wcsSoreType - rqrq com.gaotao.modules.warehouse.entity.PalletData palletInfo = wcsIntegrationMapper.getPalletInfoWithTypeDetails(site, palletId); Integer maxLayer = palletInfo.getMaxLayer() != null ? palletInfo.getMaxLayer() : 0; - - // 根据maxLayer进行不同的校验 - if (maxLayer > 0) { - // maxLayer > 0:有层数托盘,每个位置每层只能放一个东西 + Integer wcsSoreType = palletInfo.getWcsSoreType() != null ? palletInfo.getWcsSoreType() : 0; + + // 根据maxLayer和wcsSoreType进行不同的校验 - rqrq + if (maxLayer == 0) { + // maxLayer = 0:不限高托盘,需要校验下层是否都有物料,防止悬空 - rqrq + if (newLayer > 1) { + // 检查目标位置的第1层到第newLayer-1层是否都有物料 - rqrq + List existingLayers = wcsIntegrationMapper.getLayersByPosition(site, palletId, newPosition); + + // 检查每一层是否都有物料(排除当前标签原来的层) - rqrq + for (int i = 1; i < newLayer; i++) { + if (!existingLayers.contains(i)) { + throw new Exception("目标位置第" + i + "层没有物料,不能移动到第" + newLayer + "层,防止物品悬空"); + } + } + } + } else if (wcsSoreType == 1) { + // wcsSoreType = 1:气胀轴自动分拣托盘,每个位置每层只能放一个东西 // 检查目标位置的目标层是否已有其他东西(排除当前标签) List> existingDetails = wcsIntegrationMapper.getPalletDetails(site, palletId, newPosition, newLayer); @@ -421,12 +440,10 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { if (hasOtherItem) { throw new Exception("目标位置第" + newLayer + "层已有其他物料,每层只能放一个物料"); } + } else if (wcsSoreType == 2) { + // wcsSoreType = 2:抱箱自动分拣(底4箱+上3箱等),每层可以放多个东西 } else { - // maxLayer = 0:混装托盘,只能选第1层 - if (newLayer != 1) { - throw new Exception("混装托盘只能使用第1层"); - } - // 允许同一位置同一层放多个东西,不做校验 + // wcsSoreType = 0或其他:允许放多个 } // 执行位置更新 @@ -1031,4 +1048,67 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { System.out.println("完成组托完成 - AI制作"); } + + @Override + public Map getAvailablePositionsForLayer(Map params) throws Exception { + System.out.println("开始获取指定层数下各位置可用状态 - rqrq,params=" + params); + + String site = (String) params.get("site"); + String palletId = (String) params.get("palletId"); + Integer layer = params.get("layer") != null ? Integer.valueOf(params.get("layer").toString()) : 1; + + if (!StringUtils.hasText(site) || !StringUtils.hasText(palletId)) { + throw new Exception("参数不能为空"); + } + + // 1. 获取栈板类型信息 - rqrq + com.gaotao.modules.warehouse.entity.PalletData palletInfo = wcsIntegrationMapper.getPalletInfoWithTypeDetails(site, palletId); + if (palletInfo == null) { + throw new Exception("栈板不存在"); + } + + Integer maxLayer = palletInfo.getMaxLayer() != null ? palletInfo.getMaxLayer() : 0; + Integer wcsSoreType = palletInfo.getWcsSoreType() != null ? palletInfo.getWcsSoreType() : 0; + String palletType = palletInfo.getPalletType(); + + // 2. 获取该托盘类型的所有位置 - rqrq + List allPositions = wcsIntegrationMapper.getPalletTypePositions(site, palletType); + + // 3. 判断是否混装托盘 - rqrq + boolean isMixed = (maxLayer == 0); + + // 4. 获取该层已占用的位置 - rqrq + List occupiedPositions = new ArrayList<>(); + + if (wcsSoreType == 1) { + // 气胀轴自动分拣:每层每个位置只能放一个,查询该层已占用的位置 - rqrq + occupiedPositions = wcsIntegrationMapper.getOccupiedPositionsByLayer(site, palletId, layer); + } else if (wcsSoreType == 2 || wcsSoreType == 0) { + // 抱箱自动分拣或混装:每层可以放多个,所以所有位置都可用 - rqrq + occupiedPositions = new ArrayList<>(); + } + + // 5. 计算可用位置 - rqrq + List availablePositions = new ArrayList<>(); + for (String position : allPositions) { + if (!occupiedPositions.contains(position)) { + availablePositions.add(position); + } + } + + // 6. 返回结果 - rqrq + Map result = new HashMap<>(); + result.put("positions", allPositions); // 所有位置 + result.put("availablePositions", availablePositions); // 可用位置 + result.put("occupiedPositions", occupiedPositions); // 已占用位置 + result.put("maxLayer", maxLayer); // 最大层数 + result.put("isMixed", isMixed); // 是否混装 + result.put("wcsSoreType", wcsSoreType); // 存储类型 + + System.out.println("获取位置可用状态完成 - 总位置数: " + allPositions.size() + + ", 可用: " + availablePositions.size() + + ", 已占用: " + occupiedPositions.size() + " - rqrq"); + + return result; + } } diff --git a/src/main/java/com/gaotao/modules/warehouse/entity/PalletData.java b/src/main/java/com/gaotao/modules/warehouse/entity/PalletData.java index c2dc777..8cbf16e 100644 --- a/src/main/java/com/gaotao/modules/warehouse/entity/PalletData.java +++ b/src/main/java/com/gaotao/modules/warehouse/entity/PalletData.java @@ -40,6 +40,7 @@ public class PalletData extends Pallet { /** * WCS存储类型(从pallet_type表查询) + * 0=人工/混装, 1=气胀轴自动分拣(每层只能放1个), 2=抱箱自动分拣(每层可以放多个) */ private Integer wcsSoreType; diff --git a/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml b/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml index b79408b..acb652c 100644 --- a/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml +++ b/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml @@ -719,4 +719,14 @@ AND is_deleted = '0' + + + \ No newline at end of file