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 9c5fb80..584a9a3 100644 --- a/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java @@ -907,4 +907,29 @@ public interface WcsIntegrationMapper { @Param("taskNo") String taskNo, @Param("status") String status); + // ==================== 配送任务创建相关方法 - rqrq ==================== + + /** + * @Description 查询栈板物料的预约信息(关联pallet_detail和handling_unit)- rqrq + * @param site 工厂编码 + * @param palletId 栈板编码 + * @return 物料预约信息列表(包含serialNo、reserveFlag、reserveOrderRef1/2/3) + * @author rqrq + * @date 2025/11/14 + */ + List> getPalletMaterialReserveInfo(@Param("site") String site, @Param("palletId") String palletId); + + /** + * @Description 根据notify_no和item_no查询申请单信息 - rqrq + * @param site 工厂编码 + * @param notifyNo 申请单号 + * @param itemNo 行号 + * @return 订单信息(包含productionArea、orderType) + * @author rqrq + * @date 2025/11/14 + */ + Map getOrderInfoByNotifyAndItem(@Param("site") String site, + @Param("notifyNo") String notifyNo, + @Param("itemNo") String itemNo); + } diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/service/DeliveryTaskService.java b/src/main/java/com/gaotao/modules/automatedWarehouse/service/DeliveryTaskService.java new file mode 100644 index 0000000..e5c8f49 --- /dev/null +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/service/DeliveryTaskService.java @@ -0,0 +1,20 @@ +package com.gaotao.modules.automatedWarehouse.service; + +/** + * @Description 配送任务服务接口 - rqrq + * @Author rqrq + * @Date 2025/11/14 + */ +public interface DeliveryTaskService { + + /** + * @Description 创建配送任务(根据栈板物料自动判断目标点位)- rqrq + * @Title createDeliveryTaskByPallet + * @param site 工厂编码 + * @param palletId 栈板编码 + * @author rqrq + * @date 2025/11/14 + */ + void createDeliveryTaskByPallet(String site, String palletId) ; +} + 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 2fe54ee..4f69d70 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 @@ -9,6 +9,7 @@ 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.warehouse.entity.Pallet; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -37,6 +38,8 @@ public class AutoSortServiceImpl implements AutoSortService { private AutoTaskService autoTaskService; @Autowired private com.gaotao.modules.notify.mapper.NewIssureMapper newIssureMapper; + @Autowired + private DeliveryTaskService deliveryTaskService; /** * @Description 增量明细数据类(内部使用)- rqrq @@ -290,6 +293,9 @@ public class AutoSortServiceImpl implements AutoSortService { // 11. 更新空栈板标记 - rqrq wcsIntegrationMapper.updatePalletEmptyFlag(callback.getSite(), targetPalletId, "N", username); + /* ============================================================ + * 12. 创建配送任务(旧逻辑已注释,使用新的公共服务)- rqrq 2025/11/14 + * ============================================================ // 12. 创建配送任务(从查询到的申请单明细中获取任务信息)- rqrq if (!notifyDetails.isEmpty()) { // 取第一条明细的任务信息作为配送任务的源单信息 - rqrq @@ -333,7 +339,14 @@ public class AutoSortServiceImpl implements AutoSortService { firstDetail.getTaskRef(), firstDetail.getTaskItem(), targetArea); } else { log.info("未查询到申请单明细,无法创建配送任务(缺少源单信息)- rqrq"); - } + } + ============================================================ */ + + // 12. 创建配送任务(使用新的公共服务,根据栈板物料自动判断目标点位)- rqrq 2025/11/14 + + deliveryTaskService.createDeliveryTaskByPallet(callback.getSite(), callback.getPalletId()); + + // 13. 更新回调记录状态为已完成 - rqrq wcsCallbackPalletScanMapper.updateProcessStatus(callback.getId(), "COMPLETED", "成功处理" + incrementalDetails.size() + "条增量数据"); diff --git a/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/DeliveryTaskServiceImpl.java b/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/DeliveryTaskServiceImpl.java new file mode 100644 index 0000000..a5de33b --- /dev/null +++ b/src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/DeliveryTaskServiceImpl.java @@ -0,0 +1,178 @@ +package com.gaotao.modules.automatedWarehouse.service.impl; + +import com.gaotao.modules.automatedWarehouse.entity.ScheduleDeliveryTask; +import com.gaotao.modules.automatedWarehouse.mapper.WcsIntegrationMapper; +import com.gaotao.modules.automatedWarehouse.service.AutoTaskService; +import com.gaotao.modules.automatedWarehouse.service.DeliveryTaskService; +import com.gaotao.modules.warehouse.entity.Pallet; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.List; +import java.util.Map; + +/** + * @Description 配送任务服务实现类 - rqrq + * @Author rqrq + * @Date 2025/11/14 + */ +@Slf4j +@Service +public class DeliveryTaskServiceImpl implements DeliveryTaskService { + + @Autowired + private WcsIntegrationMapper wcsIntegrationMapper; + + @Autowired + private AutoTaskService autoTaskService; + + /** + * @Description 创建配送任务(根据栈板物料自动判断目标点位)- rqrq + * @Title createDeliveryTaskByPallet + * @param site 工厂编码 + * @param palletId 栈板编码 + * @author rqrq + * @date 2025/11/14 + */ + @Override + public void createDeliveryTaskByPallet(String site, String palletId) { + log.info("开始创建配送任务 - rqrq,site={}, palletId={}", site, palletId); + + // 1. 参数校验 - rqrq + if (!StringUtils.hasText(site)) { + throw new RuntimeException("站点不能为空"); + } + if (!StringUtils.hasText(palletId)) { + throw new RuntimeException("栈板编码不能为空"); + } + + // 2. 查询栈板信息 - rqrq + Pallet pallet = wcsIntegrationMapper.getPalletByCode(site, palletId); + if (pallet == null) { + throw new RuntimeException("栈板不存在:" + palletId); + } + log.info("查询到栈板信息 - rqrq:locationCode={}", pallet.getLocationCode()); + + // 3. 查询栈板物料的预约信息(关联pallet_detail和handling_unit)- rqrq + List> palletMaterialReserveList = wcsIntegrationMapper.getPalletMaterialReserveInfo(site, palletId); + + if (palletMaterialReserveList == null || palletMaterialReserveList.isEmpty()) { + log.warn("栈板没有物料或物料没有预约信息,使用默认缓存位 - rqrq:palletId={}", palletId); + createDeliveryTask(site, palletId, pallet.getLocationCode(), "Z104", null, null); + return; + } + + log.info("查询到栈板物料预约信息 - rqrq:{}条", palletMaterialReserveList.size()); + + // 4. 选取reserve_flag='Y'的第一个条码 - rqrq + Map reservedMaterial = null; + for (Map material : palletMaterialReserveList) { + String reserveFlag = (String) material.get("reserveFlag"); + if ("Y".equals(reserveFlag)) { + reservedMaterial = material; + log.info("找到预约物料 - rqrq:serialNo={}, reserveOrderRef1={}, reserveOrderRef2={}", + material.get("serialNo"), material.get("reserveOrderRef1"), material.get("reserveOrderRef2")); + break; + } + } + + // 5. 如果没有预约物料,使用默认缓存位 - rqrq + if (reservedMaterial == null) { + log.warn("栈板没有预约物料,使用默认缓存位 - rqrq:palletId={}", palletId); + createDeliveryTask(site, palletId, pallet.getLocationCode(), "Z104", null, null); + return; + } + + String reserveOrderRef1 = (String) reservedMaterial.get("reserveOrderRef1"); + String reserveOrderRef2 = (String) reservedMaterial.get("reserveOrderRef2"); + + // 6. 查询SOIssueNotifyOrderList表获取production_area和order_type - rqrq + Map orderInfo = wcsIntegrationMapper.getOrderInfoByNotifyAndItem( + site, reserveOrderRef1, reserveOrderRef2); + + if (orderInfo == null) { + log.warn("未查询到申请单信息,使用默认缓存位 - rqrq:notifyNo={}, itemNo={}", + reserveOrderRef1, reserveOrderRef2); + createDeliveryTask(site, palletId, pallet.getLocationCode(), "Z104", null, null); + return; + } + + String productionArea = (String) orderInfo.get("productionArea"); + String orderType = (String) orderInfo.get("orderType"); + + log.info("查询到订单信息 - rqrq:productionArea={}, orderType={}", productionArea, orderType); + + // 7. 判断目标点位 - rqrq + String targetArea; + + // 7.1 如果order_type是shoporder,直接去Z104(缓存位)- rqrq + if ("shoporder".equalsIgnoreCase(orderType)) { + targetArea = "Z104"; + log.info("订单类型为shoporder,目标区域=Z104(缓存位)- rqrq"); + } else { + // 7.2 其他订单类型,先判断production_area是否有空闲站点 - rqrq + if (!StringUtils.hasText(productionArea)) { + log.warn("production_area为空,使用默认缓存位 - rqrq"); + targetArea = "Z104"; + } else { + // 查询目标区域是否有空闲站点 - rqrq + String freeStation = wcsIntegrationMapper.findFirstFreeStationByAreaId(productionArea); + + if (StringUtils.hasText(freeStation)) { + // 有空闲站点,使用production_area - rqrq + targetArea = productionArea; + log.info("目标区域有空闲站点 - rqrq:productionArea={}, freeStation={}", productionArea, freeStation); + } else { + // 没有空闲站点,去Z104(缓存位)- rqrq + targetArea = "Z104"; + log.info("目标区域无空闲站点,使用缓存位 - rqrq:productionArea={}, targetArea=Z104", productionArea); + } + } + } + + // 8. 创建配送任务 - rqrq + createDeliveryTask(site, palletId, pallet.getLocationCode(), targetArea, + reserveOrderRef1, reserveOrderRef2); + + log.info("创建配送任务完成 - rqrq:palletId={}, targetArea={}", palletId, targetArea); + } + + /** + * @Description 创建配送任务(内部方法)- rqrq + * @param site 工厂编码 + * @param palletId 栈板编码 + * @param fromLocation 起始位置 + * @param toArea 目标区域 + * @param sourceBillNo 源单号(可为空) + * @param sourceLineId 源单行号(可为空) + * @author rqrq + * @date 2025/11/14 + */ + private void createDeliveryTask(String site, String palletId, String fromLocation, + String toArea, String sourceBillNo, String sourceLineId) { + ScheduleDeliveryTask scheduleDeliveryTask = new ScheduleDeliveryTask(); + scheduleDeliveryTask.setSite(site); + scheduleDeliveryTask.setPalletId(palletId); + scheduleDeliveryTask.setFromLocation(fromLocation); + scheduleDeliveryTask.setToArea(toArea); + scheduleDeliveryTask.setUsername("SYS_WMS"); + + // 设置源单信息(如果有)- rqrq + if (StringUtils.hasText(sourceBillNo)) { + scheduleDeliveryTask.setSourceBillNo(sourceBillNo); + } + if (StringUtils.hasText(sourceLineId)) { + try { + scheduleDeliveryTask.setSourceLineId(Long.valueOf(sourceLineId)); + } catch (NumberFormatException e) { + log.warn("sourceLineId转换失败 - rqrq:sourceLineId={}", sourceLineId); + } + } + + autoTaskService.scheduleDeliveryTask(scheduleDeliveryTask); + log.info("调用配送任务调度成功 - rqrq:palletId={}, toArea={}", palletId, toArea); + } +} + 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 ad155a3..038c79f 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 @@ -8,6 +8,7 @@ import com.gaotao.modules.automatedWarehouse.entity.CallPalletRequestDto; import com.gaotao.common.utils.AgvClientUtil; import java.util.Arrays; import com.gaotao.modules.automatedWarehouse.mapper.WcsIntegrationMapper; +import com.gaotao.modules.automatedWarehouse.service.DeliveryTaskService; import com.gaotao.modules.automatedWarehouse.service.WcsIntegrationService; import com.gaotao.modules.base.entity.PalletType; import com.gaotao.modules.handlingunit.entity.HandlingUnit; @@ -43,7 +44,8 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { private com.gaotao.modules.automatedWarehouse.service.AutoTaskService autoTaskService; @Autowired private com.gaotao.modules.notify.mapper.NewIssureMapper newIssureMapper; - + @Autowired + private DeliveryTaskService deliveryTaskService; @org.springframework.beans.factory.annotation.Value("${custom.wcs-url}") private String wcsUrl; @Override @@ -1993,85 +1995,85 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService { log.info("获取栈板当前所在站点 - rqrq,fromLocation={}", fromLocation); // 查询栈板明细,关联handling_unit的reserve_order_ref,判断目标区域 - rqrq - String targetArea = "Z104"; // 默认目标区域 - rqrq - try { - // 1. 查询pallet_detail的所有serial_no - rqrq - List palletDetails = wcsIntegrationMapper.getPalletDetailsData(site, palletId); - - if (!palletDetails.isEmpty()) { - // 2. 提取所有serial_no - rqrq - List serialNos = palletDetails.stream() - .map(PalletDetailData::getSerialNo) - .collect(Collectors.toList()); - - log.info("栈板明细数量 - rqrq:{}条", serialNos.size()); - - // 3. 通过serial_no查询handling_unit的reserve_order_ref1和reserve_order_ref2 - rqrq - List reserveInfoList = - wcsIntegrationMapper.getReserveOrderRefsBySerialNos(site, serialNos); - - if (!reserveInfoList.isEmpty()) { - // 取第一条reserve_order_ref1(notify_no)和reserve_order_ref2(item_no)不为空的记录 - rqrq - HandlingUnitReserveInfo firstReserve = - reserveInfoList.stream() - .filter(r -> r.getReserveOrderRef1() != null && !r.getReserveOrderRef1().isEmpty() - && r.getReserveOrderRef2() != null && !r.getReserveOrderRef2().isEmpty()) - .findFirst() - .orElse(null); - - if (firstReserve != null) { - String notifyNo = firstReserve.getReserveOrderRef1(); - String itemNo = firstReserve.getReserveOrderRef2(); - log.info("关联到预约信息 - rqrq:notify_no={}, item_no={}", notifyNo, itemNo); - - // 4. 根据site和notify_no查询SOIssueNotifyOrderList的fgpart_no - rqrq - String fgPartNo = newIssureMapper.getFgPartNoWithNotifyNoItemNo( - site, - notifyNo, - new BigDecimal(itemNo) - ); - if(fgPartNo==null||"".equals(fgPartNo)) { - targetArea = "Z109"; // 成品包装区 - rqrq - log.info("检测到订单是发货单,所以去成品包装区 - rqrq"); - } - if (fgPartNo != null &&!"".equals(fgPartNo)&& (fgPartNo.startsWith("3")||fgPartNo.startsWith("7"))) { - // fgpart_no包含"-"说明是分切订单,目标区域是分切房Z112 - rqrq - targetArea = "Z112"; - log.info("检测到分切订单 - rqrq:fgPartNo={},目标区域=Z112(分切房)", fgPartNo); - } else { - log.info("普通订单 - rqrq:fgPartNo={},目标区域=Z104", fgPartNo); - } - - } else { - log.info("未关联到有效的预约信息(reserve_order_ref为空),使用默认区域Z104 - rqrq"); - } - } else { - log.info("栈板明细未关联到预约信息,使用默认区域Z104 - rqrq"); - } - } else { - log.info("栈板无明细,使用默认区域Z104 - rqrq"); - } - } catch (Exception e) { - log.error("查询预约信息和fgpart_no失败,使用默认区域Z104 - rqrq:{}", e.getMessage()); - e.printStackTrace(); - } - - // 构建ScheduleDeliveryTask参数 - rqrq - ScheduleDeliveryTask deliveryTask = new ScheduleDeliveryTask(); - deliveryTask.setSite(site); - deliveryTask.setPalletId(palletId); - deliveryTask.setFromLocation(fromLocation); - deliveryTask.setToArea(targetArea); // 使用根据fgpart_no判断的目标区域 - rqrq - deliveryTask.setUsername(username); - deliveryTask.setPriority(1); - deliveryTask.setPalletType(pallet.getPalletType()); - - log.info("调用scheduleDeliveryTask - rqrq,参数:site={}, palletId={}, fromLocation={}, toArea={}, username={}", - site, palletId, fromLocation, targetArea, username); - - // 调用scheduleDeliveryTask创建预约送货任务 - rqrq - autoTaskService.scheduleDeliveryTask(deliveryTask); - +// String targetArea = "Z104"; // 默认目标区域 - rqrq +// try { +// // 1. 查询pallet_detail的所有serial_no - rqrq +// List palletDetails = wcsIntegrationMapper.getPalletDetailsData(site, palletId); +// +// if (!palletDetails.isEmpty()) { +// // 2. 提取所有serial_no - rqrq +// List serialNos = palletDetails.stream() +// .map(PalletDetailData::getSerialNo) +// .collect(Collectors.toList()); +// +// log.info("栈板明细数量 - rqrq:{}条", serialNos.size()); +// +// // 3. 通过serial_no查询handling_unit的reserve_order_ref1和reserve_order_ref2 - rqrq +// List reserveInfoList = +// wcsIntegrationMapper.getReserveOrderRefsBySerialNos(site, serialNos); +// +// if (!reserveInfoList.isEmpty()) { +// // 取第一条reserve_order_ref1(notify_no)和reserve_order_ref2(item_no)不为空的记录 - rqrq +// HandlingUnitReserveInfo firstReserve = +// reserveInfoList.stream() +// .filter(r -> r.getReserveOrderRef1() != null && !r.getReserveOrderRef1().isEmpty() +// && r.getReserveOrderRef2() != null && !r.getReserveOrderRef2().isEmpty()) +// .findFirst() +// .orElse(null); +// +// if (firstReserve != null) { +// String notifyNo = firstReserve.getReserveOrderRef1(); +// String itemNo = firstReserve.getReserveOrderRef2(); +// log.info("关联到预约信息 - rqrq:notify_no={}, item_no={}", notifyNo, itemNo); +// +// // 4. 根据site和notify_no查询SOIssueNotifyOrderList的fgpart_no - rqrq +// String fgPartNo = newIssureMapper.getFgPartNoWithNotifyNoItemNo( +// site, +// notifyNo, +// new BigDecimal(itemNo) +// ); +// if(fgPartNo==null||"".equals(fgPartNo)) { +// targetArea = "Z109"; // 成品包装区 - rqrq +// log.info("检测到订单是发货单,所以去成品包装区 - rqrq"); +// } +// if (fgPartNo != null &&!"".equals(fgPartNo)&& (fgPartNo.startsWith("3")||fgPartNo.startsWith("7"))) { +// // fgpart_no包含"-"说明是分切订单,目标区域是分切房Z112 - rqrq +// targetArea = "Z112"; +// log.info("检测到分切订单 - rqrq:fgPartNo={},目标区域=Z112(分切房)", fgPartNo); +// } else { +// log.info("普通订单 - rqrq:fgPartNo={},目标区域=Z104", fgPartNo); +// } +// +// } else { +// log.info("未关联到有效的预约信息(reserve_order_ref为空),使用默认区域Z104 - rqrq"); +// } +// } else { +// log.info("栈板明细未关联到预约信息,使用默认区域Z104 - rqrq"); +// } +// } else { +// log.info("栈板无明细,使用默认区域Z104 - rqrq"); +// } +// } catch (Exception e) { +// log.error("查询预约信息和fgpart_no失败,使用默认区域Z104 - rqrq:{}", e.getMessage()); +// e.printStackTrace(); +// } +// +// // 构建ScheduleDeliveryTask参数 - rqrq +// ScheduleDeliveryTask deliveryTask = new ScheduleDeliveryTask(); +// deliveryTask.setSite(site); +// deliveryTask.setPalletId(palletId); +// deliveryTask.setFromLocation(fromLocation); +// deliveryTask.setToArea(targetArea); // 使用根据fgpart_no判断的目标区域 - rqrq +// deliveryTask.setUsername(username); +// deliveryTask.setPriority(1); +// deliveryTask.setPalletType(pallet.getPalletType()); +// +// log.info("调用scheduleDeliveryTask - rqrq,参数:site={}, palletId={}, fromLocation={}, toArea={}, username={}", +// site, palletId, fromLocation, targetArea, username); +// +// // 调用scheduleDeliveryTask创建预约送货任务 - rqrq +// autoTaskService.scheduleDeliveryTask(deliveryTask); + deliveryTaskService.createDeliveryTaskByPallet(site, palletId); log.info("预约送货任务创建成功 - rqrq"); // 更新pallet_detail的wcs_flag为1 - 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 c5ac06a..01b2fe3 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 @@ -6,6 +6,7 @@ import com.gaotao.modules.api.service.WmsMessageService; import com.gaotao.modules.automatedWarehouse.entity.*; import com.gaotao.modules.automatedWarehouse.mapper.WcsIntegrationMapper; import com.gaotao.modules.automatedWarehouse.service.AutoTaskService; +import com.gaotao.modules.automatedWarehouse.service.DeliveryTaskService; import com.gaotao.modules.automatedWarehouse.service.WcsIntegrationService; import com.gaotao.modules.automatedWarehouse.service.WcsTaskService; import com.gaotao.modules.handlingunit.entity.HandlingUnit; @@ -32,7 +33,8 @@ import java.util.stream.Collectors; public class WcsTaskServiceImpl implements WcsTaskService { @Autowired private PalletService palletService; - + @Autowired + private DeliveryTaskService deliveryTaskService; @Autowired private WcsIntegrationService wcsIntegrationService; @Autowired @@ -385,53 +387,55 @@ public class WcsTaskServiceImpl implements WcsTaskService { .anyMatch(r -> r.getReserveOrderRef1() != null && !r.getReserveOrderRef1().isEmpty()); if (hasReservePart) { - System.out.println("栈板{}有预留物料,准备创建配送任务和更新out_wcs_flag - rqrq"+callbackTask.getPalletId()); - - // 判断目标区域(根据fgpart_no是否包含"-")- rqrq - String targetArea = "Z104"; // 默认缓存区 - rqrq - try { - // 取第一条有效的notify_no - rqrq - HandlingUnitReserveInfo firstReserve = reserveInfoList.stream() - .filter(r -> r.getReserveOrderRef1() != null && !r.getReserveOrderRef1().isEmpty() - && r.getReserveOrderRef2() != null && !r.getReserveOrderRef2().isEmpty()) - .findFirst() - .orElse(null); - - if (firstReserve != null) { - String notifyNo = firstReserve.getReserveOrderRef1(); - String itemNo = firstReserve.getReserveOrderRef2(); - - // 查询fgpart_no判断是否分切订单 - rqrq - String fgPartNo = newIssureMapper.getFgPartNoWithNotifyNoItemNo( - callbackTask.getSite(), notifyNo, new BigDecimal(itemNo)); - - if(fgPartNo==null||"".equals(fgPartNo)) { - targetArea = "Z109"; // 成品包装区 - rqrq - log.info("检测到订单是发货单,所以去成品包装区 - rqrq"); - } - if (fgPartNo != null &&!"".equals(fgPartNo)&& (fgPartNo.startsWith("3")||fgPartNo.startsWith("7"))) { - // fgpart_no包含"-"说明是分切订单,目标区域是分切房Z112 - rqrq - targetArea = "Z112"; - log.info("检测到分切订单 - rqrq:fgPartNo={},目标区域=Z112(分切房)", fgPartNo); - } else { - log.info("普通订单 - rqrq:fgPartNo={},目标区域=Z104", fgPartNo); - } - } - } catch (Exception ex) { - System.err.println("查询fgpart_no失败,使用默认区域Z104 - rqrq:" + ex.getMessage()); - } - - // 创建配送任务 - rqrq - ScheduleDeliveryTask scheduleDeliveryTask = new ScheduleDeliveryTask(); - scheduleDeliveryTask.setSite(callbackTask.getSite()); - scheduleDeliveryTask.setPalletId(callbackTask.getPalletId()); - scheduleDeliveryTask.setFromLocation(callbackTask.getToStation()); - scheduleDeliveryTask.setToArea(targetArea); - scheduleDeliveryTask.setUsername("SYS_WMS"); - autoTaskService.scheduleDeliveryTask(scheduleDeliveryTask); - System.out.println("栈板{}没有预约任务且有预留物料,自动移库到目标区域{} - rqrq"+ - callbackTask.getPalletId()+ targetArea); - + deliveryTaskService.createDeliveryTaskByPallet(callbackTask.getSite(), callbackTask.getPalletId()); +// try { +// System.out.println("栈板{}有预留物料,准备创建配送任务和更新out_wcs_flag - rqrq"+callbackTask.getPalletId()); +// +// // 判断目标区域(根据fgpart_no是否包含"-")- rqrq +// String targetArea = "Z104"; // 默认缓存区 - rqrq +// try { +// // 取第一条有效的notify_no - rqrq +// HandlingUnitReserveInfo firstReserve = reserveInfoList.stream() +// .filter(r -> r.getReserveOrderRef1() != null && !r.getReserveOrderRef1().isEmpty() +// && r.getReserveOrderRef2() != null && !r.getReserveOrderRef2().isEmpty()) +// .findFirst() +// .orElse(null); +// +// if (firstReserve != null) { +// String notifyNo = firstReserve.getReserveOrderRef1(); +// String itemNo = firstReserve.getReserveOrderRef2(); +// +// // 查询fgpart_no判断是否分切订单 - rqrq +// String fgPartNo = newIssureMapper.getFgPartNoWithNotifyNoItemNo( +// callbackTask.getSite(), notifyNo, new BigDecimal(itemNo)); +// +// if(fgPartNo==null||"".equals(fgPartNo)) { +// targetArea = "Z109"; // 成品包装区 - rqrq +// log.info("检测到订单是发货单,所以去成品包装区 - rqrq"); +// } +// if (fgPartNo != null &&!"".equals(fgPartNo)&& (fgPartNo.startsWith("3")||fgPartNo.startsWith("7"))) { +// // fgpart_no包含"-"说明是分切订单,目标区域是分切房Z112 - rqrq +// targetArea = "Z112"; +// log.info("检测到分切订单 - rqrq:fgPartNo={},目标区域=Z112(分切房)", fgPartNo); +// } else { +// log.info("普通订单 - rqrq:fgPartNo={},目标区域=Z104", fgPartNo); +// } +// } +// } catch (Exception ex) { +// System.err.println("查询fgpart_no失败,使用默认区域Z104 - rqrq:" + ex.getMessage()); +// } +// +// // 创建配送任务 - rqrq +// ScheduleDeliveryTask scheduleDeliveryTask = new ScheduleDeliveryTask(); +// scheduleDeliveryTask.setSite(callbackTask.getSite()); +// scheduleDeliveryTask.setPalletId(callbackTask.getPalletId()); +// scheduleDeliveryTask.setFromLocation(callbackTask.getToStation()); +// scheduleDeliveryTask.setToArea(targetArea); +// scheduleDeliveryTask.setUsername("SYS_WMS"); +// autoTaskService.scheduleDeliveryTask(scheduleDeliveryTask); +// System.out.println("栈板{}没有预约任务且有预留物料,自动移库到目标区域{} - rqrq"+ +// callbackTask.getPalletId()+ targetArea); +// // 更新SOIssueNotifyOrderMaterialList_detail的out_wcs_flag以及wms_order_task状态 - rqrq try { log.info("开始批量更新栈板{}的申请单和任务状态 - rqrq", callbackTask.getPalletId()); diff --git a/src/main/resources/mapper/automatedWarehouse/KitTransportMapper.xml b/src/main/resources/mapper/automatedWarehouse/KitTransportMapper.xml index 6954ada..6d5d643 100644 --- a/src/main/resources/mapper/automatedWarehouse/KitTransportMapper.xml +++ b/src/main/resources/mapper/automatedWarehouse/KitTransportMapper.xml @@ -17,7 +17,7 @@ AND ol.push_wms_flag = 'Y' AND ol.transport_flag = 'N' AND ol.production_area IS NOT NULL - AND ol.production_area != '' and ol.fgpart_no is not null and ol.fgpart_no not like '%-%' + AND ol.production_area != '' ORDER BY ol.notify_no, ol.item_no diff --git a/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml b/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml index d589841..4ed568b 100644 --- a/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml +++ b/src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml @@ -1702,4 +1702,31 @@ WHERE site = #{site} AND task_no = #{taskNo} + + + + + + \ No newline at end of file