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 6045f93..fe69dac 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java @@ -124,4 +124,32 @@ public class WcsIntegrationController { return R.error(e.getMessage()); } } + + /** + * 获取编辑位置时的层数选项(排除指定标签) - AI制作 + */ + @PostMapping(value="/getLayersForEdit") + @ResponseBody + public R getLayersForEdit(@RequestBody Map params) { + try { + List layers = wcsIntegrationService.getLayersForEdit(params); + return R.ok().put("layers", layers); + } catch (Exception e) { + return R.error(e.getMessage()); + } + } + + /** + * 更新栈板明细位置 - AI制作 + */ + @PostMapping(value="/updatePalletDetailPosition") + @ResponseBody + public R updatePalletDetailPosition(@RequestBody Map params) { + try { + wcsIntegrationService.updatePalletDetailPosition(params); + return R.ok(); + } catch (Exception e) { + return R.error(e.getMessage()); + } + } } 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 003c70c..f10a3c0 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java @@ -70,6 +70,19 @@ public interface WcsIntegrationMapper { * 根据标签查找栈板信息 - AI制作 */ Map findPalletByLabel(@Param("site") String site, @Param("serialNo") String serialNo); + + /** + * 获取指定位置已占用的层数(排除指定标签) - AI制作 + */ + List getOccupiedLayersExcludeSerial(@Param("site") String site, @Param("palletId") String palletId, + @Param("position") String position, @Param("excludeSerialNo") String excludeSerialNo); + + /** + * 更新栈板明细位置 - AI制作 + */ + void updatePalletDetailPosition(@Param("site") String site, @Param("palletId") String palletId, + @Param("serialNo") String serialNo, @Param("newPosition") String newPosition, + @Param("newLayer") Integer newLayer, @Param("updatedBy") String updatedBy); /** * 删除栈板明细 - AI制作 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 d8a45eb..d82eec7 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java @@ -37,4 +37,14 @@ public interface WcsIntegrationService { * 删除栈板明细(扫出) - AI制作 */ void deletePalletDetail(Map params) throws Exception; + + /** + * 获取编辑位置时的层数选项(排除指定标签) - AI制作 + */ + List getLayersForEdit(Map params) throws Exception; + + /** + * 更新栈板明细位置 - AI制作 + */ + void updatePalletDetailPosition(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 0f75b91..4a582f8 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 @@ -21,6 +21,7 @@ import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; import java.util.stream.IntStream; +import java.util.stream.Collectors; @Service public class WcsIntegrationServiceImpl implements WcsIntegrationService { @@ -262,4 +263,109 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { wcsIntegrationMapper.deletePalletDetail(site, palletId, serialNo); } + + @Override + public List getLayersForEdit(Map params) throws Exception { + String site = (String) params.get("site"); + String palletId = (String) params.get("palletId"); + String position = (String) params.get("position"); + String excludeSerialNo = (String) params.get("excludeSerialNo"); + + if (!StringUtils.hasText(site) || !StringUtils.hasText(palletId) || + !StringUtils.hasText(position) || !StringUtils.hasText(excludeSerialNo)) { + throw new Exception("参数不能为空"); + } + + // 获取当前位置的已占用层数(排除指定标签) + List occupiedLayers = wcsIntegrationMapper.getOccupiedLayersExcludeSerial(site, palletId, position, excludeSerialNo); + + // 获取栈板类型信息以确定最大层数 + Map palletInfo = wcsIntegrationMapper.getPalletInfo(site, palletId); + if (palletInfo == null) { + throw new Exception("栈板不存在"); + } + + + + // 生成可选层数:已占用层数 + 下一层 + List availableLayers = new ArrayList<>(); + + // 添加下一层(如果不超过最大层数) + if (occupiedLayers.isEmpty()) { + availableLayers.add(1); // 如果没有占用层,可以选择第1层 + } else { + int maxOccupied = occupiedLayers.stream().mapToInt(Integer::intValue).max().orElse(0); + for (int i = 0; i params) throws Exception { + String site = (String) params.get("site"); + String palletId = (String) params.get("palletId"); + String serialNo = (String) params.get("serialNo"); + String newPosition = (String) params.get("newPosition"); + Integer newLayer = null; + + if (params.get("newLayer") != null) { + newLayer = Integer.valueOf(params.get("newLayer").toString()); + } + + if (!StringUtils.hasText(site) || !StringUtils.hasText(palletId) || + !StringUtils.hasText(serialNo) || !StringUtils.hasText(newPosition) || newLayer == null) { + throw new Exception("参数不能为空"); + } + + // 验证标签是否在当前栈板中 + Map currentDetail = wcsIntegrationMapper.findPalletByLabel(site, serialNo); + if (currentDetail == null || !palletId.equals(currentDetail.get("palletId"))) { + throw new Exception("标签不在当前栈板中"); + } + + + + // 层级校验:如果目标层数 > 1,检查前一层是否完整 + if (newLayer > 1) { + // 获取栈板类型信息 + Map palletInfo = wcsIntegrationMapper.getPalletInfo(site, palletId); + String palletType = (String) palletInfo.get("pallet_type"); + + List> areaInfo = wcsIntegrationMapper.getPalletTypeAreaInfo(site, palletType); + int totalPositions = areaInfo.size(); + + // 检查前一层是否所有位置都有数据(排除当前移动的标签) + List> layerStatistics = wcsIntegrationMapper.getPalletLayerStatistics(site, palletId, newLayer - 1); + + // 排除当前标签后,检查前一层各位置是否都有数据 + int currentLayer = (Integer) currentDetail.get("layer"); + String currentPosition = (String) currentDetail.get("position"); + + int expectedCount = totalPositions; + if (currentLayer == newLayer - 1) { + expectedCount--; // 如果当前标签在前一层,需要减1 + } + + int actualCount = layerStatistics.size(); + if (currentLayer == newLayer - 1) { + actualCount--; // 排除当前标签 + } + + if (actualCount < expectedCount) { + throw new Exception("第" + (newLayer - 1) + "层未满,无法移动到第" + newLayer + "层"); + } + } + + // 执行位置更新 + String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); + wcsIntegrationMapper.updatePalletDetailPosition(site, palletId, serialNo, newPosition, newLayer, username); + } } diff --git a/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml b/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml index b899715..23f365b 100644 --- a/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml +++ b/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml @@ -142,4 +142,25 @@ WHERE site = #{site} AND pallet_id = #{palletId} AND serial_no = #{serialNo} + + + + + + UPDATE pallet_detail + SET position = #{newPosition}, + layer = #{newLayer} + WHERE site = #{site} + AND pallet_id = #{palletId} + AND serial_no = #{serialNo} + + \ No newline at end of file