From 331774943b7af3c42719574336ba4b49986d0b1a 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: Sat, 18 Oct 2025 00:50:45 +0800 Subject: [PATCH] =?UTF-8?q?call=E6=96=99=E8=87=B3=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WcsIntegrationController.java | 15 ++ .../mapper/WcsIntegrationMapper.java | 23 ++++ .../service/WcsIntegrationService.java | 9 ++ .../impl/WcsIntegrationServiceImpl.java | 130 ++++++++++++++++++ .../WcsIntegrationMapper.xml | 55 ++++++++ 5 files changed, 232 insertions(+) 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 f7b68ed..d7d3a2c 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java @@ -429,6 +429,21 @@ public class WcsIntegrationController { return R.ok(); } + /** + * @Description Call料到指定位置(Call料+预约取盘到指定区域/站点)- rqrq + * @Title callOutToStation + * @param request Call料到指定位置请求参数 + * @return R + * @author rqrq + * @date 2025/10/17 + */ + @PostMapping(value="/callOutToStation") + @ResponseBody + public R callOutToStation(@RequestBody CallOutToStationRequestDto request) { + wcsIntegrationService.callOutToStation(request); + return R.ok(); + } + // ==================== 手工移动托盘相关方法 - rqrq ==================== /** 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 adebec2..eb41c73 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java @@ -577,4 +577,27 @@ public interface WcsIntegrationMapper { int updateTransportTaskWithLock(@Param("taskNo") String taskNo, @Param("newStatus") String newStatus, @Param("palletId") String palletId, @Param("fromLocation") String fromLocation, @Param("oldWmsStatus") String oldWmsStatus, @Param("newWmsStatus") String newWmsStatus); + + /** + * @Description 根据栈板ID和sourceType查询最新的OrderTask(按创建时间倒序)- rqrq + * @param site 工厂编码 + * @param palletId 栈板编码 + * @param sourceType 来源类型(如:手工Call料) + * @return 最新的OrderTask + * @author rqrq + * @date 2025/10/17 + */ + WmsOrderTask findLatestOrderTaskByPallet(@Param("site") String site, @Param("palletId") String palletId, @Param("sourceType") String sourceType); + + /** + * @Description 根据栈板ID更新最新的TransportTask的source_bill_no和source_line_id - rqrq + * @param site 工厂编码 + * @param palletId 栈板编码 + * @param sourceBillNo 来源单据号 + * @param sourceLineId 来源单据行号 + * @author rqrq + * @date 2025/10/17 + */ + void updateTransportTaskSourceInfo(@Param("site") String site, @Param("palletId") String palletId, + @Param("sourceBillNo") String sourceBillNo, @Param("sourceLineId") Integer sourceLineId); } 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 c193e31..6f95bbd 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java @@ -282,4 +282,13 @@ public interface WcsIntegrationService { */ void removeAllPalletDetails(CancelWcsPalletData data); + /** + * @Description Call料到指定位置(Call料+预约取盘到指定区域/站点)- rqrq + * @Title callOutToStation + * @param request Call料到指定位置请求参数 + * @author rqrq + * @date 2025/10/17 + */ + void callOutToStation(CallOutToStationRequestDto request) ; + } 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 272d140..b85a6a8 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 @@ -37,6 +37,8 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { private WcsApiService wcsApiService; @Autowired private AgvClientUtil agvClientUtil; + @Autowired + private com.gaotao.modules.automatedWarehouse.service.AutoTaskService autoTaskService; @Override public List palletListForPartNo(PartPalletData inData){ // inData.setWarehouseId(Pallet.likuWarehouseId); @@ -2065,4 +2067,132 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { System.out.println("移出全部物料完成 - rqrq"); } + /** + * @Description Call料到指定位置(Call料+预约取盘到指定区域/站点)- rqrq + * @param request Call料到指定位置请求参数 + * @author rqrq + * @date 2025/10/17 + */ + @Override + @Transactional + public void callOutToStation(CallOutToStationRequestDto request) { + System.out.println("开始Call料到指定位置 - rqrq,palletId=" + request.getPalletId() + + ", targetArea=" + request.getTargetArea() + ", targetStation=" + request.getTargetStation()); + + String site = request.getSite(); + String palletId = request.getPalletId(); + String targetArea = request.getTargetArea(); + String targetStation = request.getTargetStation(); + String username = request.getUsername(); + + // 1. 校验必填参数 - rqrq + if (palletId == null || palletId.trim().isEmpty()) { + throw new RuntimeException("栈板编码不能为空"); + } + if (targetArea == null || targetArea.trim().isEmpty()) { + throw new RuntimeException("目标区域不能为空"); + } + + // 2. 确定目标站点(自动分配或指定站点)- rqrq + String finalTargetStation = targetStation; + if (finalTargetStation == null || finalTargetStation.trim().isEmpty()) { + // 自动分配:根据区域查找第一个空闲站点 - rqrq + System.out.println("自动分配站点 - rqrq,targetArea=" + targetArea); + finalTargetStation = wcsIntegrationMapper.findFirstFreeStationByAreaId(targetArea); + if (finalTargetStation == null || finalTargetStation.trim().isEmpty()) { + throw new RuntimeException("目标区域【" + targetArea + "】没有空闲站点"); + } + 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"); + } + // 4. 第二步:创建预约取盘任务(autoNeedPalletTask)- rqrq + System.out.println("开始创建预约取盘任务 - rqrq"); + com.gaotao.modules.api.entity.NeedPalletTask needPalletTask = + new com.gaotao.modules.api.entity.NeedPalletTask(); + needPalletTask.setSite(site); + needPalletTask.setPalletId(palletId); // 指定栈板ID - rqrq + needPalletTask.setPalletType(null); // 已知栈板,不需要托盘类型 - rqrq + needPalletTask.setStationCode(finalTargetStation); + needPalletTask.setUsername(username); + + autoTaskService.autoNeedPalletTask(needPalletTask); + System.out.println("预约取盘任务创建成功 - rqrq"); + + System.out.println("Call料到指定位置完成 - rqrq"); + + // 3. 第一步:执行原来的Call料方法(callPalletFromWcsNew)- rqrq + System.out.println("开始执行Call料 - rqrq"); + WmsLabelAndPalletData palletData = new WmsLabelAndPalletData(); + palletData.setSite(site); + palletData.setPalletId(palletId); + palletData.setPartNo(request.getPartNo()); + palletData.setQty(request.getQty()); + palletData.setBatchNo(request.getBatchNo()); + + List palletList = new java.util.ArrayList<>(); + palletList.add(palletData); + + + + Map callResult = this.callPalletFromWcsNew(palletList); + Integer failedCount = (Integer) callResult.get("failedCount"); + + if (failedCount != null && failedCount > 0) { + // Call料失败 - rqrq + @SuppressWarnings("unchecked") + List failedReasons = (List) callResult.get("failedReasons"); + String errorMsg = failedReasons != null && !failedReasons.isEmpty() ? + failedReasons.get(0) : "Call料失败"; + System.out.println("Call料失败 - rqrq:" + errorMsg); + throw new RuntimeException("Call料失败:" + errorMsg); + } + + System.out.println("Call料成功 - rqrq"); + + // 5. 第三步:查询Call料后生成的OrderTask,并更新TransportTask的来源单据信息 - rqrq + System.out.println("开始关联OrderTask和TransportTask - rqrq"); + try { + // 查询最新的OrderTask(手工Call料生成的)- rqrq + WmsOrderTask latestOrderTask = wcsIntegrationMapper.findLatestOrderTaskByPallet( + site, + palletId, + "手工Call料" + ); + + if (latestOrderTask != null) { + System.out.println("查询到OrderTask - rqrq,taskNo=" + latestOrderTask.getTaskNo() + + ", itemNo=" + latestOrderTask.getItemNo()); + + // 更新TransportTask的source_bill_no和source_line_id - rqrq + wcsIntegrationMapper.updateTransportTaskSourceInfo( + site, + palletId, + latestOrderTask.getTaskNo(), + latestOrderTask.getItemNo() + ); + + System.out.println("已更新TransportTask的来源单据信息 - rqrq,sourceBillNo=" + + latestOrderTask.getTaskNo() + ", sourceLineId=" + latestOrderTask.getItemNo()); + } else { + System.out.println("警告:未找到对应的OrderTask - rqrq"); + } + } catch (Exception e) { + // 这步失败不影响整体流程,只记录日志 - rqrq + System.out.println("关联OrderTask和TransportTask失败 - rqrq:" + e.getMessage()); + } + + System.out.println("Call料到指定位置完成 - rqrq"); + + } + } diff --git a/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml b/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml index cee8489..1061580 100644 --- a/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml +++ b/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml @@ -1162,5 +1162,60 @@ WHERE task_no = #{taskNo} AND (wms_status = #{oldWmsStatus} OR wms_status IS NULL) + + + + + + + UPDATE wms_transport_task + SET source_bill_no = #{sourceBillNo}, + source_line_id = #{sourceLineId}, + updated_time = GETDATE() + WHERE id = ( + SELECT TOP 1 id + FROM wms_transport_task + WHERE site = #{site} + AND pallet_id = #{palletId} + AND source_type = '预约取托盘' + ORDER BY created_time DESC + ) + \ No newline at end of file