From a078404eb2ee0da4f8b956478d4864f4776b11e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=B8=E7=86=9F=E5=90=B4=E5=BD=A6=E7=A5=96?= Date: Wed, 24 Dec 2025 12:10:44 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=98=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WcsIntegrationController.java | 28 ++- .../service/WcsIntegrationService.java | 4 +- .../impl/WcsIntegrationServiceImpl.java | 167 +++++++++++++++++- 3 files changed, 192 insertions(+), 7 deletions(-) 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 881bf26..ee45206 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java @@ -97,7 +97,20 @@ public class WcsIntegrationController { .put("palletType", result.get("palletType")) .put("locationCode", result.get("locationCode")) .put("palletId", result.get("palletId")); - + + } + + @PostMapping(value="/checkPalletExistsNoPDControl") + @ResponseBody + public R checkPalletExistsNoPDControl(@RequestBody Map params) { + + Map result = wcsIntegrationService.checkPalletExistsNoPDControl(params); + return R.ok() + .put("positions", result.get("positions")) + .put("palletType", result.get("palletType")) + .put("locationCode", result.get("locationCode")) + .put("palletId", result.get("palletId")); + } /** @@ -817,4 +830,17 @@ public class WcsIntegrationController { .put("failedPalletIds", result.get("failedPalletIds")) .put("failedReasons", result.get("failedReasons")); } + + + @PostMapping(value="/scanAndCallPalletForPandian") + @ResponseBody + public R scanAndCallPalletForPandian(@RequestBody WmsLabelAndPalletData data) throws Exception { + Map result = wcsIntegrationService.scanAndCallPalletForPandian(data); + return R.ok() + .put("totalCount", result.get("totalCount")) + .put("successCount", result.get("successCount")) + .put("failedCount", result.get("failedCount")) + .put("failedPalletIds", result.get("failedPalletIds")) + .put("failedReasons", result.get("failedReasons")); + } } 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 37c53dd..d6f533e 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java @@ -26,7 +26,7 @@ public interface WcsIntegrationService { * 检查栈板是否存在并获取位置信息 - AI制作 */ Map checkPalletExists(Map params) ; - + Map checkPalletExistsNoPDControl(Map params) ; /** * @Description 简单查询栈板信息(无任何校验)- rqrq * @Title getPalletInfoSimple @@ -396,5 +396,5 @@ public interface WcsIntegrationService { * @date 2025/12/08 */ Map scanAndCallPalletForHetuo(WmsLabelAndPalletData data); - + Map scanAndCallPalletForPandian(WmsLabelAndPalletData data); } 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 124080c..3df0363 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 @@ -1,6 +1,7 @@ package com.gaotao.modules.automatedWarehouse.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.gaotao.common.utils.CountModeChecker; import com.gaotao.modules.api.apiData.CheckInventoryExistsRequest; import com.gaotao.modules.api.entity.*; import com.gaotao.modules.api.service.WcsApiService; @@ -66,10 +67,16 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { private HandlingUnitOperationLogService handlingUnitOperationLogService; @Autowired private com.gaotao.modules.handlingunit.dao.HandlingUnitMapper handlingUnitMapper; // rqrq - 用于批量取消预留 + + @Autowired + private CountModeChecker countModeChecker; + @org.springframework.beans.factory.annotation.Value("${custom.wcs-url}") private String wcsUrl; @Override public List palletListForPartNo(PartPalletData inData){ + //如果当前site是盘点模式就不允许操作 + countModeChecker.checkNotInCountMode(inData.getSite()); // inData.setWarehouseId(Pallet.likuWarehouseId); return wcsIntegrationMapper.palletListForPartNo(inData); } @@ -173,6 +180,8 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { */ @Override public Map callPalletFromWcsNew(List data) { + //如果当前site是盘点模式就不允许操作 + countModeChecker.checkNotInCountMode(data.getFirst().getSite()); System.out.println("开始直接Call栈板出库 - rqrq,栈板数量=" + data.size()); String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); @@ -315,7 +324,8 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { public Map checkPalletExists(Map params) { String site = (String) params.get("site"); String palletId = (String) params.get("palletId"); - + //如果当前site是盘点模式就不允许操作 + countModeChecker.checkNotInCountMode(site); // 如果最后一位是R或L,则去掉 - rqrq String originalPalletId = palletId; if (palletId != null && palletId.length() > 0) { @@ -356,7 +366,50 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { result.put("palletId", palletId); return result; } + @Override + public Map checkPalletExistsNoPDControl(Map params) { + String site = (String) params.get("site"); + String palletId = (String) params.get("palletId"); + // 如果最后一位是R或L,则去掉 - rqrq + String originalPalletId = palletId; + if (palletId != null && palletId.length() > 0) { + char lastChar = palletId.charAt(palletId.length() - 1); + if (lastChar == 'R' || lastChar == 'L' || lastChar == 'r' || lastChar == 'l') { + palletId = palletId.substring(0, palletId.length() - 1); + System.out.println("栈板码最后一位是R或L,已自动去除 - rqrq,原始=" + originalPalletId + ", 处理后=" + palletId); + } + } + + if (!StringUtils.hasText(site) || !StringUtils.hasText(palletId)) { + throw new RuntimeException("参数不能为空"); + } + + // 检查栈板是否存在 + Map palletInfo = wcsIntegrationMapper.getPalletInfo(site, palletId); + if (palletInfo == null) { + throw new RuntimeException("栈板不存在"); + } + + // 检查栈板是否正在被调用 + String callingFlag = (String) palletInfo.get("calling_flag"); + if ("Y".equals(callingFlag)) { + // if ("Y".equals(callingFlag)&&!BufferZoneConfig.BUFFER_Station_ID.getValue().equals(palletInfo.get("locationCode"))) { + String remark = (String) palletInfo.get("remark"); + throw new RuntimeException("栈板正在被调用中,无法进行打托操作,最近一次调用备注:" + (remark != null ? remark : "无")); + } + + // 获取栈板类型的位置信息 + String palletType = (String) palletInfo.get("pallet_type"); + String locationCode = (String) palletInfo.get("location_code"); + List positions = wcsIntegrationMapper.getPalletTypePositions(site, palletType); + Map result = new HashMap<>(); + result.put("positions", positions); + result.put("palletType", palletType); + result.put("locationCode", locationCode); // 添加栈板位置信息 + result.put("palletId", palletId); + return result; + } @Override public Map getPalletInfoSimple(Map params) { System.out.println("开始简单查询栈板信息(无校验)- rqrq"); @@ -1682,7 +1735,8 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { String site = (String) params.get("site"); String palletId = (String) params.get("palletId"); - + //如果当前site是盘点模式就不允许操作 + countModeChecker.checkNotInCountMode(site); // 校验参数 - rqrq if (!StringUtils.hasText(site)) { throw new RuntimeException("站点不能为空"); @@ -2375,7 +2429,8 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { public CheckPalletResult checkPalletWcsStatus(CancelWcsPalletData data) { String site = data.getSite(); String palletId = data.getPalletId(); - + //如果当前site是盘点模式就不允许操作 + countModeChecker.checkNotInCountMode(site); // 如果最后一位是R或L,则去掉 - rqrq String originalPalletId = palletId; if (palletId != null && palletId.length() > 0) { @@ -3168,7 +3223,8 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { @Override public Map scanAndCallPalletForHetuo(WmsLabelAndPalletData data) { System.out.println("开始扫描托盘并Call料出库 - rqrq,site=" + data.getSite() + ", palletId=" + data.getPalletId()); - + //如果当前site是盘点模式就不允许操作 + countModeChecker.checkNotInCountMode(data.getSite()); // 1. 参数校验 - rqrq if (!StringUtils.hasText(data.getSite())) { throw new RuntimeException("工厂编码不能为空"); @@ -3207,4 +3263,107 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { System.out.println("扫描托盘并Call料出库完成 - rqrq,结果:" + result); return result; } + + + @Override + public Map scanAndCallPalletForPandian(WmsLabelAndPalletData data) { + System.out.println("开始扫描托盘并Call料出库 - rqrq,site=" + data.getSite() + ", palletId=" + data.getPalletId()); + + // 1. 参数校验 - rqrq + if (!StringUtils.hasText(data.getSite())) { + throw new RuntimeException("工厂编码不能为空"); + } + if (!StringUtils.hasText(data.getPalletId())) { + throw new RuntimeException("托盘编码不能为空"); + } + + // 2. 查询托盘信息(只用pallet_id + site查询pallet表)- rqrq + Pallet pallet = wcsIntegrationMapper.getPalletForHetuoScan(data.getSite(), data.getPalletId()); + + // 3. 校验托盘是否存在 - rqrq + if (pallet == null) { + throw new RuntimeException("托盘不存在:" + data.getPalletId()); + } + + // 4. 校验wcs_location是否为null - rqrq + if (!StringUtils.hasText(pallet.getWcsLocation())) { + throw new RuntimeException("该托盘不在立库"); + } + + // 5. 校验calling_flag是否为Y - rqrq + if ("Y".equals(pallet.getCallingFlag())) { + String remark = pallet.getRemark() != null ? pallet.getRemark() : "无"; + throw new RuntimeException("栈板在调用中,最近一次调用备注:" + remark); + } + + // 6. 校验通过,构建参数调用callPalletFromWcsNew - rqrq + System.out.println("托盘校验通过,准备Call料出库 - rqrq"); + List palletList = new ArrayList<>(); + palletList.add(data); + + // 7. 调用现有的callPalletFromWcsNew方法执行下达 - rqrq + Map result = callPalletFromWcsNewInPandian(palletList); + + System.out.println("扫描托盘并Call料出库完成 - rqrq,结果:" + result); + return result; + } + + public Map callPalletFromWcsNewInPandian(List data) { + + System.out.println("开始直接Call栈板出库 - rqrq,栈板数量=" + data.size()); + + String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); + Date currentTime = new Date(); + + // 记录失败的栈板信息 - rqrq + List failedPalletIds = new ArrayList<>(); + List failedReasons = new ArrayList<>(); + int successCount = 0; + + // 循环处理每个栈板 - rqrq + for (int i = 0; i < data.size(); i++) { + WmsLabelAndPalletData item = data.get(i); + String palletId = item.getPalletId(); + boolean isFirstPallet = (i == 0); // 判断是否是第一个栈板 - rqrq + + try { + System.out.println("处理栈板:" + palletId + " - rqrq"); + + // 调用单个栈板处理方法(每个栈板独立事务)- rqrq + processSinglePallet(item, username, currentTime); + + successCount++; + System.out.println("栈板Call成功:" + palletId + " - rqrq"); + + } catch (Exception e) { + // 记录失败信息 - rqrq + String errorMsg = e.getMessage(); + System.out.println("栈板Call失败:" + palletId + ",原因:" + errorMsg + " - rqrq"); + + // 如果是第一个栈板且是超时错误,直接抛出异常,不再处理后续栈板 - rqrq + if (isFirstPallet && errorMsg != null && errorMsg.contains("超时")) { + System.out.println("第一个栈板调用超时,终止后续处理 - rqrq"); + throw new RuntimeException("无法连接到立库系统,请检查WCS服务是否正常"); + } + + failedPalletIds.add(palletId); + failedReasons.add(errorMsg); + + // 继续处理下一个栈板 - rqrq + continue; + } + } + + System.out.println("Call栈板出库完成 - rqrq,总数=" + data.size() + ",成功=" + successCount + ",失败=" + failedPalletIds.size()); + + // 返回结果 - rqrq + Map result = new HashMap<>(); + result.put("totalCount", data.size()); + result.put("successCount", successCount); + result.put("failedCount", failedPalletIds.size()); + result.put("failedPalletIds", failedPalletIds); + result.put("failedReasons", failedReasons); + + return result; + } }