From 1d79edf66f93a6f3b8264f07fcc9a6ccf2675408 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: Tue, 4 Nov 2025 21:56:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A7=E4=BD=8D=E5=88=86=E9=85=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/WmsMessageServiceImpl.java | 35 +++++++------------ .../service/impl/AutoTaskServiceImpl.java | 25 +++++++------ .../impl/WcsIntegrationServiceImpl.java | 12 ++----- .../service/impl/WcsTaskServiceImpl.java | 10 ++++-- .../task/WcsTaskScheduler.java | 6 ++-- 5 files changed, 40 insertions(+), 48 deletions(-) diff --git a/src/main/java/com/gaotao/modules/api/service/impl/WmsMessageServiceImpl.java b/src/main/java/com/gaotao/modules/api/service/impl/WmsMessageServiceImpl.java index 48079d2..6c7a362 100644 --- a/src/main/java/com/gaotao/modules/api/service/impl/WmsMessageServiceImpl.java +++ b/src/main/java/com/gaotao/modules/api/service/impl/WmsMessageServiceImpl.java @@ -569,36 +569,27 @@ public class WmsMessageServiceImpl implements WmsMessageService { pallet.setLocationCode(request.getToStation()); pallet.setWcsLocation(request.getToStation()); - palletMapper.updateLocationWithPalletId(pallet.getSite(),pallet.getPalletId(),pallet.getLocationCode(),pallet.getWcsLocation()); + // palletMapper.updateLocationWithPalletId(pallet.getSite(),pallet.getPalletId(),pallet.getLocationCode(),pallet.getWcsLocation()); //如果更新wcs库位 //这里插入逻辑 // 检查该站点是否还有其他栈板,如果没有则更新站点状态为空闲 - rqrq(改用手写SQL避免锁表) - long otherPalletCount = palletMapper.countOtherPalletsByLocation( - request.getSite(), currentLocationCode, request.getPalletId()); - - if (otherPalletCount == 0) { - // 没有其他栈板在该站点,更新站点状态为空闲 - log.info("站点 {} 无其他栈板,更新状态为空闲", currentLocationCode); - wcsIntegrationMapper.updateAgvStationStatus(currentLocationCode, 0, "空闲"); - } else { - log.info("站点 {} 还有 {} 个其他栈板,保持站点状态", currentLocationCode, otherPalletCount); - } + // long otherPalletCount = palletMapper.countOtherPalletsByLocation( + // request.getSite(), currentLocationCode, request.getPalletId()); + // + // if (otherPalletCount == 0) { + // // 没有其他栈板在该站点,更新站点状态为空闲 + // log.info("站点 {} 无其他栈板,更新状态为空闲", currentLocationCode); + // wcsIntegrationMapper.updateAgvStationStatus(currentLocationCode, 0, "空闲"); + // } else { + // log.info("站点 {} 还有 {} 个其他栈板,保持站点状态", currentLocationCode, otherPalletCount); + // } String fromWarehouseId; String fromLocationId; - //如果是*说明在立库里,需要查询里面料的当前位置 - // if(currentStation.getLocationCode().equals("*")){ - // List palletDetail2 = getPalletDetails(request.getSite(), request.getPalletId()); - // List checkPart= handlingUnitService.getHandlingUnitsBySiteAndUnid(palletDetail2.getFirst().getSite(),palletDetail2.getFirst().getSerialNo()); - // if(checkPart.size()==0){ - // throw new RuntimeException("栈板明细列表的条码号在WMS不存在,数据有问题"); - // } - // fromWarehouseId = checkPart.getFirst().getWarehouseId(); - // fromLocationId = checkPart.getFirst().getLocationId(); - // }else { + fromWarehouseId = currentStation.getWarehouseCode(); fromLocationId = currentStation.getLocationCode(); - // } + if(fromWarehouseId.equals(request.getToWarehouseId())&&fromLocationId.equals(request.getToLocationId())){ return "托盘无需执行移库操作:" + request.getPalletId(); } diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AutoTaskServiceImpl.java b/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AutoTaskServiceImpl.java index 0196a0c..28b9d11 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AutoTaskServiceImpl.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AutoTaskServiceImpl.java @@ -58,13 +58,6 @@ public class AutoTaskServiceImpl implements AutoTaskService { if(!StringUtils.hasText(inData.getStationCode())){ throw new RuntimeException("参数验证失败:站点编码不能为空"); } - Integer getAgvStationStatus= wcsIntegrationMapper.getAgvStationStatus(inData.getStationCode()); - if(getAgvStationStatus==null){ - throw new RuntimeException("参数验证失败:站点编码不存在"); - } - if(getAgvStationStatus!=0){ - throw new RuntimeException("参数验证失败:站点不是空闲状态"); - } // 如果指定了栈板,验证栈板是否已有未完成任务 - rqrq if(StringUtils.hasText(inData.getPalletId())){ @@ -114,11 +107,21 @@ public class AutoTaskServiceImpl implements AutoTaskService { // detail.setActionType("生成AGV任务"); // detail.setStatus("成功"); - // 保存运输任务到数据库 + // 使用乐观锁尝试占用站点 - rqrq + int lockResult = wcsIntegrationMapper.updateAgvStationStatusWithLock( + inData.getStationCode(), + 0, // expectedStatusDb - 期望当前是空闲 + 2, // newStatusDb - 更新为待放货 + "待放货" + ); + + if(lockResult == 0){ + throw new RuntimeException("站点【" + inData.getStationCode() + "】已被占用,无法创建预约任务"); + } + + // 保存运输任务到数据库 - rqrq wcsIntegrationMapper.insertTransportTask(task); - - // 更新目标站点状态为"待放货" - wcsIntegrationMapper.updateAgvStationStatus(inData.getStationCode(), 2, "待放货"); + // wcsIntegrationMapper.insertWmsTransportTaskDetail(detail); } 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 6d83e6c..4da5ce0 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 @@ -2310,16 +2310,8 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { } System.out.println("自动分配站点成功 - rqrq,stationCode=" + finalTargetStation); } else { - // 指定站点:校验站点是否空闲 - rqrq - System.out.println("校验指定站点是否空闲 - rqrq,stationCode=" + finalTargetStation); - Integer stationStatus = wcsIntegrationMapper.getAgvStationStatus(finalTargetStation); - if (stationStatus == null) { - throw new RuntimeException("站点【" + finalTargetStation + "】不存在"); - } - if (stationStatus != 0) { - throw new RuntimeException("站点【" + finalTargetStation + "】不是空闲状态(status_db=" + stationStatus + ")"); - } - System.out.println("站点校验通过,站点空闲 - rqrq"); + // 指定站点:站点状态校验交给autoNeedPalletTask的乐观锁处理 - rqrq + System.out.println("使用指定站点 - rqrq,stationCode=" + finalTargetStation); } // 4. 第二步:创建预约取盘任务(autoNeedPalletTask)- rqrq System.out.println("开始创建预约取盘任务 - rqrq"); diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsTaskServiceImpl.java b/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsTaskServiceImpl.java index 34c28f6..63179ed 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsTaskServiceImpl.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsTaskServiceImpl.java @@ -10,6 +10,7 @@ import com.gaotao.modules.automatedWarehouse.service.WcsIntegrationService; import com.gaotao.modules.automatedWarehouse.service.WcsTaskService; import com.gaotao.modules.handlingunit.entity.HandlingUnit; import com.gaotao.modules.notify.mapper.NewIssureMapper; +import com.gaotao.modules.warehouse.dao.PalletMapper; import com.gaotao.modules.warehouse.entity.Pallet; import com.gaotao.modules.warehouse.service.PalletService; @@ -48,6 +49,8 @@ public class WcsTaskServiceImpl implements WcsTaskService { @Autowired private NewIssureMapper newIssureMapper; + @Autowired + private PalletMapper palletMapper; @Override public List getPendingWcsCallbackTasks(String site) { @@ -106,13 +109,16 @@ public class WcsTaskServiceImpl implements WcsTaskService { WareHouseTransferRequest request = buildWareHouseTransferRequest(callbackTask); request.setUsername("sys_wms"); result = wmsMessageService.doWareHouseForPallet(request); - // 更新托盘状态 - rqrq if ("入库".equals(callbackTask.getTransTypeDesc())) { updateOrderTaskStatusForInbound(callbackTask); + palletMapper.updateLocationWithPalletId(request.getSite(),request.getPalletId(),request.getToStation(),request.getToStation()); + wcsIntegrationMapper.updatePalletCallingFlag(callbackTask.getSite(), callbackTask.getPalletId(), "N", "SYS_WMS"); } else { - wcsIntegrationMapper.updatePalletWcsLocation(callbackTask.getSite(), callbackTask.getPalletId(), null); + palletMapper.updateLocationWithPalletId(request.getSite(),request.getPalletId(),"Virtual_AS",null); + + // wcsIntegrationMapper.updatePalletWcsLocation(callbackTask.getSite(), callbackTask.getPalletId(), null); wcsIntegrationMapper.updatePalletCallingFlag(callbackTask.getSite(), callbackTask.getPalletId(), "Y", "SYS_WMS"); } } else if ("取货通知".equals(callbackTask.getTransTypeDesc())) { diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/task/WcsTaskScheduler.java b/src/main/java/com/gaotao/modules/automatedWarehouse/task/WcsTaskScheduler.java index 17167e1..de24747 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/task/WcsTaskScheduler.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/task/WcsTaskScheduler.java @@ -52,9 +52,9 @@ public class WcsTaskScheduler { @Scheduled(fixedDelay = 2684) public void scheduleWcsTaskProcessing() { // 检查定时任务开关 - if (!enabled) { - return; - } + // if (!enabled) { + // return; + // } log.info("=== 开始处理WCS入库/出库相关业务 ===");