From ffde4dbf79a70128c01c3e5193f1b40f022be39a Mon Sep 17 00:00:00 2001
From: cuilei <ray_tsu1@163.com>
Date: 星期五, 29 八月 2025 16:05:16 +0800
Subject: [PATCH] 排产工单生成排产计划接口调整

---
 src/main/java/org/jeecg/modules/mes/service/impl/MesProductionWorkOrderServiceImpl.java |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/jeecg/modules/mes/service/impl/MesProductionWorkOrderServiceImpl.java b/src/main/java/org/jeecg/modules/mes/service/impl/MesProductionWorkOrderServiceImpl.java
index e871cce..83314ea 100644
--- a/src/main/java/org/jeecg/modules/mes/service/impl/MesProductionWorkOrderServiceImpl.java
+++ b/src/main/java/org/jeecg/modules/mes/service/impl/MesProductionWorkOrderServiceImpl.java
@@ -7,6 +7,7 @@
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.commons.lang.StringUtils;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.system.vo.LoginUser;
@@ -18,8 +19,11 @@
 import org.jeecg.modules.base.service.ILineSideWarehouseService;
 import org.jeecg.modules.base.service.IShiftGroupService;
 import org.jeecg.modules.base.service.IShiftService;
+import org.jeecg.modules.lsw.entity.LswMaterial;
 import org.jeecg.modules.lsw.entity.LswMaterialInventory;
+import org.jeecg.modules.lsw.enums.MaterialCategoryEnum;
 import org.jeecg.modules.lsw.service.ILswMaterialInventoryService;
+import org.jeecg.modules.lsw.service.ILswMaterialService;
 import org.jeecg.modules.lsw.vo.LswMaterialInventoryVo;
 import org.jeecg.modules.mes.dto.MesProductionWorkScheduleRequest;
 import org.jeecg.modules.mes.entity.MesKittingCompletenessCheck;
@@ -67,6 +71,8 @@
     @Autowired
     private IPmsProcessBillMaterialsDetailService pmsProcessBillMaterialsDetailService;
     @Autowired
+    private ILswMaterialService lswMaterialService;
+    @Autowired
     private ILswMaterialInventoryService lswMaterialInventoryService;
     @Autowired
     private ILineSideWarehouseService lineSideWarehouseService;
@@ -95,6 +101,16 @@
                 .limit(ChronoUnit.DAYS.between(startDate, endDate) + 1)
                 .collect(Collectors.toList());
         List<MesProductionWorkOrder> newProductionWorkOrderList = CollectionUtil.newArrayList();
+        String materialNumber = request.getMaterialNumber();
+        BigDecimal planQuantity = request.getPlanQuantity();
+        if (StringUtils.isNotBlank(materialNumber)) {
+            LswMaterial material = lswMaterialService.list(new LambdaQueryWrapper<LswMaterial>()
+                            .eq(LswMaterial::getMaterialNumber, materialNumber)
+                            .eq(LswMaterial::getDelFlag, CommonConstant.DEL_FLAG_0)
+                            .eq(LswMaterial::getMaterialStatus, CommonConstant.STATUS_1))
+                    .stream().findFirst().orElse(null);
+            request.setMaterialName(Objects.requireNonNull(material).getMaterialName());
+        }
 
         for (LocalDate date : dateRange) {
             for (String shiftId : shiftGroupMap.keySet()) {
@@ -117,7 +133,10 @@
                             .setShiftName(shiftNameMap.get(shiftId).getShiftName())
                             .setGroupId(shiftGroup.getId())
                             .setGroupName(shiftGroup.getGroupName())
-                            .setWorkOrderDate(workOrderDate);
+                            .setWorkOrderDate(workOrderDate)
+                            .setMaterialNumber(StringUtils.isNotBlank(materialNumber) ? materialNumber : "")
+                            .setMaterialName(StringUtils.isNotBlank(materialNumber) ? request.getMaterialName() : "")
+                            .setPlanQuantity(Objects.nonNull(planQuantity) ? planQuantity : null);
 
                     newProductionWorkOrderList.add(mesProductionWorkOrder);
                 }
@@ -128,7 +147,10 @@
             MesProductionWorkOrder mesProductionWorkOrder = new MesProductionWorkOrder()
                     .setFactoryId(factory.getId())
                     .setFactoryCode(factory.getFactoryCode())
-                    .setFactoryName(factory.getFactoryName());
+                    .setFactoryName(factory.getFactoryName())
+                    .setMaterialNumber(StringUtils.isNotBlank(materialNumber) ? materialNumber : "")
+                    .setMaterialName(StringUtils.isNotBlank(materialNumber) ? request.getMaterialName() : "")
+                    .setPlanQuantity(Objects.nonNull(planQuantity) ? planQuantity : null);;
             newProductionWorkOrderList.add(mesProductionWorkOrder);
         }
         return newProductionWorkOrderList;

--
Gitblit v1.9.3