From 3ca99a04cff5dc72a8f1a4b4448ca592f915237f Mon Sep 17 00:00:00 2001
From: cuilei <ray_tsu1@163.com>
Date: 星期六, 09 八月 2025 17:47:28 +0800
Subject: [PATCH] 生产管控 排产功能接口调整

---
 src/main/java/org/jeecg/modules/mes/service/impl/MesProductionWorkOrderServiceImpl.java |   28 ++++++++++++++
 src/main/java/org/jeecg/modules/mes/controller/MesProductionWorkOrderController.java    |   29 ++++++++------
 src/main/java/org/jeecg/modules/mes/mapper/MesProductionWorkOrderMapper.java            |    7 +++
 src/main/java/org/jeecg/modules/mes/mapper/xml/MesProductionWorkOrderMapper.xml         |   10 +++++
 src/main/java/org/jeecg/modules/mes/service/IMesProductionWorkOrderService.java         |    5 ++
 5 files changed, 67 insertions(+), 12 deletions(-)

diff --git a/src/main/java/org/jeecg/modules/mes/controller/MesProductionWorkOrderController.java b/src/main/java/org/jeecg/modules/mes/controller/MesProductionWorkOrderController.java
index d712a21..cbe9993 100644
--- a/src/main/java/org/jeecg/modules/mes/controller/MesProductionWorkOrderController.java
+++ b/src/main/java/org/jeecg/modules/mes/controller/MesProductionWorkOrderController.java
@@ -1,10 +1,14 @@
 package org.jeecg.modules.mes.controller;
 
 import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -17,6 +21,7 @@
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.TranslateDictTextUtils;
 import org.jeecg.modules.mes.dto.MesProductionWorkOrderRepublishRequest;
 import org.jeecg.modules.mes.dto.MesProductionWorkScheduleRequest;
 import org.jeecg.modules.mes.entity.MesProductionWorkOrder;
@@ -44,6 +49,10 @@
 public class MesProductionWorkOrderController extends JeecgController<MesProductionWorkOrder, IMesProductionWorkOrderService> {
     @Autowired
     private IMesProductionWorkOrderService mesProductionWorkOrderService;
+    @Autowired
+    private ObjectMapper objectMapper;
+    @Autowired
+    private TranslateDictTextUtils translateDictTextUtils;
 
     /**
      * 鍒嗛〉鍒楄〃鏌ヨ
@@ -57,22 +66,14 @@
     //@AutoLog(value = "鎺掍骇宸ュ崟-鍒嗛〉鍒楄〃鏌ヨ")
     @ApiOperation(value = "鎺掍骇宸ュ崟-鍒嗛〉鍒楄〃鏌ヨ", notes = "鎺掍骇宸ュ崟-鍒嗛〉鍒楄〃鏌ヨ")
     @GetMapping(value = "/list")
-    public Result<IPage<MesProductionWorkOrder>> queryPageList(MesProductionWorkOrder mesProductionWorkOrder,
+    public Result<IPage<?>> queryPageList(MesProductionWorkOrder mesProductionWorkOrder,
                                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                HttpServletRequest req) {
         Map<String, String[]> parameterMap = req.getParameterMap();
         QueryWrapper<MesProductionWorkOrder> queryWrapper = QueryGenerator.initQueryWrapper(mesProductionWorkOrder, parameterMap);
-        String[] startDates = parameterMap.get("startDate");
-        String[] endDates = parameterMap.get("endDate");
-        if (startDates != null && startDates.length > 0) {
-            queryWrapper.ge("work_order_date", startDates[0]);
-        }
-        if (endDates != null && endDates.length > 0) {
-            queryWrapper.le("work_order_date", endDates[0]);
-        }
         Page<MesProductionWorkOrder> page = new Page<MesProductionWorkOrder>(pageNo, pageSize);
-        IPage<MesProductionWorkOrder> pageList = mesProductionWorkOrderService.page(page, queryWrapper);
+        IPage<MesProductionWorkOrder> pageList = mesProductionWorkOrderService.queryPageList(page, parameterMap);
         return Result.OK(pageList);
     }
 
@@ -99,8 +100,12 @@
         if (!validatePlan(mesProductionWorkOrderList)) {
             return Result.error("鎺掍骇璁″垝涓嶅悎鐞嗭紝淇濆瓨澶辫触锛�");
         }
-        mesProductionWorkOrderList.forEach(item -> item.setWorkOrderStatus(ProductionWorkOrderStatus.NEW.name()));
-        mesProductionWorkOrderService.saveBatch(mesProductionWorkOrderList);
+        mesProductionWorkOrderList.forEach(item -> {
+            if (Objects.isNull(item.getId())) {
+                item.setWorkOrderStatus(ProductionWorkOrderStatus.NEW.name());
+            }
+        });
+        mesProductionWorkOrderService.saveOrUpdateBatch(mesProductionWorkOrderList);
         return Result.OK("娣诲姞鎴愬姛锛�");
     }
 
diff --git a/src/main/java/org/jeecg/modules/mes/mapper/MesProductionWorkOrderMapper.java b/src/main/java/org/jeecg/modules/mes/mapper/MesProductionWorkOrderMapper.java
index 688c511..4e24e14 100644
--- a/src/main/java/org/jeecg/modules/mes/mapper/MesProductionWorkOrderMapper.java
+++ b/src/main/java/org/jeecg/modules/mes/mapper/MesProductionWorkOrderMapper.java
@@ -2,6 +2,11 @@
 
 import java.util.List;
 
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.mes.entity.MesProductionWorkOrder;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -14,4 +19,6 @@
  */
 public interface MesProductionWorkOrderMapper extends BaseMapper<MesProductionWorkOrder> {
 
+    IPage<MesProductionWorkOrder> queryPageList(Page<MesProductionWorkOrder> page,
+                                                @Param(Constants.WRAPPER) Wrapper<MesProductionWorkOrder> queryWrapper);
 }
diff --git a/src/main/java/org/jeecg/modules/mes/mapper/xml/MesProductionWorkOrderMapper.xml b/src/main/java/org/jeecg/modules/mes/mapper/xml/MesProductionWorkOrderMapper.xml
index 82f9149..7fc05d7 100644
--- a/src/main/java/org/jeecg/modules/mes/mapper/xml/MesProductionWorkOrderMapper.xml
+++ b/src/main/java/org/jeecg/modules/mes/mapper/xml/MesProductionWorkOrderMapper.xml
@@ -2,4 +2,14 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.mes.mapper.MesProductionWorkOrderMapper">
 
+    <select id="queryPageList" resultType="org.jeecg.modules.mes.entity.MesProductionWorkOrder">
+        SELECT
+            t1.*,
+            t2.factory_code factoryCode,
+            t3.shift_code shiftCode
+        FROM mes_production_work_order t1
+        LEFT JOIN base_factory t2 ON t1.factory_id = t2.id
+        LEFT JOIN base_shift t3 ON t1.shift_id = t3.id
+        ${ew.customSqlSegment}
+    </select>
 </mapper>
\ No newline at end of file
diff --git a/src/main/java/org/jeecg/modules/mes/service/IMesProductionWorkOrderService.java b/src/main/java/org/jeecg/modules/mes/service/IMesProductionWorkOrderService.java
index 3e00fd7..9ba50b0 100644
--- a/src/main/java/org/jeecg/modules/mes/service/IMesProductionWorkOrderService.java
+++ b/src/main/java/org/jeecg/modules/mes/service/IMesProductionWorkOrderService.java
@@ -1,10 +1,13 @@
 package org.jeecg.modules.mes.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.mes.dto.MesProductionWorkScheduleRequest;
 import org.jeecg.modules.mes.entity.MesProductionWorkOrder;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 鎺掍骇宸ュ崟
@@ -15,4 +18,6 @@
 public interface IMesProductionWorkOrderService extends IService<MesProductionWorkOrder> {
 
     List<MesProductionWorkOrder> schedule(MesProductionWorkScheduleRequest request);
+
+    IPage<MesProductionWorkOrder> queryPageList(Page<MesProductionWorkOrder> page, Map<String, String[]> parameterMap);
 }
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 51adc5b..407a954 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
@@ -2,6 +2,10 @@
 
 import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+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.jeecg.common.constant.CommonConstant;
 import org.jeecg.modules.base.entity.Factory;
@@ -99,4 +103,28 @@
         }
         return newProductionWorkOrderList;
     }
+
+    @Override
+    public IPage<MesProductionWorkOrder> queryPageList(Page<MesProductionWorkOrder> page, Map<String, String[]> parameterMap) {
+        QueryWrapper<MesProductionWorkOrder> queryWrapper = Wrappers.query();
+        String[] factoryIds = parameterMap.get("factoryId");
+        if (factoryIds != null && factoryIds.length > 0) {
+            queryWrapper.eq("t1.factory_id", factoryIds[0]);
+        }
+        String[] startDates = parameterMap.get("startDate");
+        String[] endDates = parameterMap.get("endDate");
+        if (startDates != null && startDates.length > 0) {
+            queryWrapper.ge("t1.work_order_date", startDates[0]);
+        }
+        if (endDates != null && endDates.length > 0) {
+            queryWrapper.le("t1.work_order_date", endDates[0]);
+        }
+        String[] workOrderStatuses = parameterMap.get("workOrderStatus");
+        if (workOrderStatuses != null && workOrderStatuses.length > 0) {
+            queryWrapper.eq("t1.work_order_status", workOrderStatuses[0]);
+        }
+        queryWrapper.eq("t1.del_flag", CommonConstant.DEL_FLAG_0);
+        queryWrapper.orderByAsc("t1.work_order_date");
+        return this.baseMapper.queryPageList(page, queryWrapper);
+    }
 }

--
Gitblit v1.9.3