From 1b73f772423ed1481fb963e5394645c6bc767af8 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, 6 Dec 2025 15:42:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AutoSortServiceImpl.java | 113 +++++++++++++++++- 1 file changed, 109 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AutoSortServiceImpl.java b/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AutoSortServiceImpl.java index 9756950..6350311 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AutoSortServiceImpl.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AutoSortServiceImpl.java @@ -3,20 +3,28 @@ package com.gaotao.modules.automatedWarehouse.service.impl; import com.alibaba.fastjson2.JSONObject; import com.gaotao.modules.api.entity.PalletStationDetailVo; import com.gaotao.modules.api.entity.PalletStationVo; +import com.gaotao.modules.api.entity.PartTypeEnum; import com.gaotao.modules.api.entity.PushPalletDetailDto; +import com.gaotao.modules.api.service.WcsApiService; import com.gaotao.modules.automatedWarehouse.entity.*; import com.gaotao.modules.automatedWarehouse.mapper.WcsCallbackPalletScanMapper; import com.gaotao.modules.automatedWarehouse.mapper.WcsIntegrationMapper; import com.gaotao.modules.automatedWarehouse.service.AutoSortService; import com.gaotao.modules.automatedWarehouse.service.AutoTaskService; import com.gaotao.modules.automatedWarehouse.service.DeliveryTaskService; +import com.gaotao.modules.sys.entity.SysUserEntity; +import com.gaotao.modules.trans.entity.TransNoControl; +import com.gaotao.modules.trans.service.TransNoControlService; import com.gaotao.modules.warehouse.entity.Pallet; +import com.gaotao.modules.warehouse.service.PalletOperationLogService; import lombok.extern.slf4j.Slf4j; +import org.apache.shiro.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; +import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; @@ -28,10 +36,12 @@ import java.util.stream.Collectors; @Slf4j @Service public class AutoSortServiceImpl implements AutoSortService { - + @Autowired + private PalletOperationLogService palletOperationLogService; @Autowired private WcsCallbackPalletScanMapper wcsCallbackPalletScanMapper; - + @Autowired + private WcsApiService wcsApiService; @Autowired private WcsIntegrationMapper wcsIntegrationMapper; @Autowired @@ -42,7 +52,8 @@ public class AutoSortServiceImpl implements AutoSortService { private DeliveryTaskService deliveryTaskService; @Autowired private com.gaotao.modules.warehouse.service.HandlingUnitOperationLogService handlingUnitOperationLogService; - + @Autowired + private TransNoControlService transNoService; /** * @Description 增量明细数据类(内部使用)- rqrq */ @@ -156,7 +167,42 @@ public class AutoSortServiceImpl implements AutoSortService { throw new RuntimeException("栈板不存在:" + callback.getPalletId()); } wcsCallbackPalletScanMapper.updateProcessStatus(callback.getId(), "COMPLETED", "无增量数据"); - //碰到异常订单 如果没有明细 直接回库 --和左工沟通过 + //碰到异常订单 如果没有明细 直接组盘回库 --和左工沟通过 + + // 生成入库任务编号 - rqrq + TransNoControl transData = transNoService.getTransNo(callback.getSite(), "WOT", 10); + Date currentTime = new Date(); + + // 创建入库任务记录 - rqrq + WmsOrderTask orderTask = new WmsOrderTask(); + orderTask.setSite(callback.getSite()); + orderTask.setTaskNo(transData.getNewTransNo()); + orderTask.setItemNo(1); + orderTask.setSourceType("空托盘入库"); // 设置为空托盘入库 - rqrq + orderTask.setSourceBillNo(""); + orderTask.setSourceLineId(0L); + orderTask.setPartNo(""); + orderTask.setQty(BigDecimal.ZERO); + orderTask.setBatchNo(""); + orderTask.setSerialNo(""); + orderTask.setFromLocation("无"); + orderTask.setToLocation("无"); + orderTask.setPalletId(callback.getPalletId()); + orderTask.setAgvCode(""); + orderTask.setPriority(1); + orderTask.setStatus("已创建"); + orderTask.setWmsSendTime(currentTime); + orderTask.setCreatedBy("SYS_WMS"); + orderTask.setCreatedTime(currentTime); + orderTask.setUpdatedTime(currentTime); + orderTask.setFinishQty(BigDecimal.ZERO); + + // 保存任务记录 - rqrq + wcsIntegrationMapper.insertOrderTask(orderTask); + System.out.println("空托盘入库任务已创建 - rqrq,taskNo=" + orderTask.getTaskNo()); + pushEmptyPalletDetail(callback.getSite(), callback.getPalletId(), orderTask.getTaskNo(), orderTask.getItemNo(),1); + + ScheduleDeliveryTask scheduleDeliveryTask = new ScheduleDeliveryTask(); scheduleDeliveryTask.setSite(callback.getSite()); scheduleDeliveryTask.setPalletId(callback.getPalletId()); @@ -426,5 +472,64 @@ public class AutoSortServiceImpl implements AutoSortService { throw new RuntimeException("处理WCS自动拣选回调失败:" + e.getMessage(), e); } } + + + private void pushEmptyPalletDetail(String site, String palletId, String taskNo, Integer itemNo,Integer count) { + System.out.println("开始推送空托盘数据到WCS - rqrq,palletId=" + palletId + ", taskNo=" + taskNo); + + // 获取栈板信息(包含pallet_type表关联数据)- rqrq + com.gaotao.modules.warehouse.entity.PalletData palletInfo = wcsIntegrationMapper.getPalletInfoWithTypeDetails(site, palletId); + String locationCode = palletInfo.getLocationCode(); + if(locationCode == null||locationCode.isEmpty()){ + locationCode="D1"; + } + // 从pallet表关联pallet_type获取WCS相关字段 - rqrq + Integer wcsPalletType = palletInfo.getWcsPalletType() != null ? palletInfo.getWcsPalletType() : 1; + Integer wcsBasePalletType = palletInfo.getWcsBasePalletType() != null ? palletInfo.getWcsBasePalletType() : 1; + Integer soreType = palletInfo.getWcsSoreType(); + if (palletInfo.getSoreType() != null) { + soreType = palletInfo.getSoreType(); + } + String autoSort = palletInfo.getAutoSort(); + boolean isAutoSort = "Y".equals(autoSort); + + // 更新栈板calling_flag为Y - rqrq + String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); + wcsIntegrationMapper.updatePalletCallingFlag(site, palletId, "Y", "空托组盘", username); + palletOperationLogService.logPalletOperation(palletId, site,"调用托盘","空托组盘","是否调用","N","Y",username,""); + + // 构建推送数据 - rqrq + PushPalletDetailDto inData = new PushPalletDetailDto(); + + // 设置物料类型 - rqrq + if ("A01".equals(palletInfo.getPalletFamily())) { + inData.setPartType(PartTypeEnum.fromCode(2)); + } else if ("A02".equals(palletInfo.getPalletFamily())) { + inData.setPartType(PartTypeEnum.fromCode(1)); + } else if ("A03".equals(palletInfo.getPalletFamily())) { + inData.setPartType(PartTypeEnum.fromCode(0)); + } else { + inData.setPartType(PartTypeEnum.fromCode(3)); + } + inData.setCount(count); + // rqrq - 所有字符串字段赋值时trim去除空格,防止WCS接口识别失败 + inData.setSite(site != null ? site.trim() : null); + inData.setTaskNo(taskNo != null ? taskNo.trim() : null); + inData.setItemNo(itemNo); + inData.setPalletBarcode(palletId != null ? palletId.trim() : null); + inData.setPalletType(wcsPalletType); + inData.setBasePalletType(wcsBasePalletType); + inData.setCommonUsed(false); // 空托盘没有常用料标记 - rqrq + inData.setAutoSort(isAutoSort); + inData.setSoreType(soreType); + inData.setAssemblyPosition(locationCode != null ? locationCode.trim() : null); + inData.setEndFlag(true); // 空托盘直接结束组盘 - rqrq + inData.setCargoInfos(new ArrayList<>()); // 空托盘没有货物信息,传null - rqrq + + // 调用WCS推送接口(不修改此方法)- rqrq + wcsApiService.pushZuPanApi(inData); + + System.out.println("推送空托盘数据到WCS完成 - rqrq"); + } }