From c2ad2126d6f8423e0a5e6e20bbb91ef6bb1cffc0 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期一, 25 五月 2026 13:26:27 +0800
Subject: [PATCH] fix(approve): 修复审批流程为空时的异常处理

---
 src/main/resources/mapper/production/ProductWorkOrderMapper.xml |   65 ++++++++++++++++++++++++++++++--
 1 files changed, 60 insertions(+), 5 deletions(-)

diff --git a/src/main/resources/mapper/production/ProductWorkOrderMapper.xml b/src/main/resources/mapper/production/ProductWorkOrderMapper.xml
index 6e7e06c..2c47577 100644
--- a/src/main/resources/mapper/production/ProductWorkOrderMapper.xml
+++ b/src/main/resources/mapper/production/ProductWorkOrderMapper.xml
@@ -12,20 +12,29 @@
         <result column="work_order_no" property="workOrderNo"/>
         <result column="status" property="status"/>
         <result column="tenant_id" property="tenantId"/>
-        <result column="actual_end_time" property="planStartTime"/>
+        <result column="plan_start_time" property="planStartTime"/>
         <result column="plan_end_time" property="planEndTime"/>
         <result column="actual_start_time" property="actualStartTime"/>
-        <result column="actualEndTime" property="actualEndTime"/>
+        <result column="actual_end_time" property="actualEndTime"/>
     </resultMap>
 
     <select id="pageProductWorkOrder" resultType="com.ruoyi.production.dto.ProductWorkOrderDto">
         SELECT
         pwo.*,
-        pp.NAME as processName,
+        CASE pp.type
+            WHEN 1 THEN '鍔犲伐'
+            WHEN 2 THEN '鍒澘鍐疯姱鍒朵綔'
+            WHEN 3 THEN '绠¤矾缁勫'
+            WHEN 4 THEN '缃愪綋杩炴帴鍙婅皟璇�'
+            WHEN 5 THEN '娴嬭瘯鎵撳帇'
+            WHEN 6 THEN '鍏朵粬'
+            ELSE pp.NAME
+        END as processName,
         pm.model,
         pm.unit,
         p.product_name AS productName,
         po.nps_no AS productOrderNpsNo,
+        pp.salary_quota,
         ROUND(pwo.complete_quantity / pwo.plan_quantity * 100, 2) AS completionStatus,
         CASE
         WHEN pwo.work_order_no LIKE 'FG%' THEN '杩斿伐杩斾慨'
@@ -43,16 +52,33 @@
                and pwo.work_order_no like concat('%',#{c.workOrderNo},'%')
             </if>
             <if test="c.planStartTime != null and c.planEndTime != null">
-                and DATE(pwo.create_time) between #{c.planStartTime} and #{c.planEndTime}
+                and pwo.create_time <![CDATA[ >= ]]> #{c.planStartTime}
+                and pwo.create_time <![CDATA[ <= ]]> #{c.planEndTime}
             </if>
             <if test="c.productOrderId != null and c.productOrderId != ''">
                and pwo.product_order_id = #{c.productOrderId}
+            </if>
+            <if test="c.type != null and c.type == 2 and c.currentUserId != null">
+                and exists (
+                    select 1
+                    from product_work_order_rapporteur pwor
+                    where pwor.work_order_id = pwo.id
+                      and pwor.user_id = #{c.currentUserId}
+                )
             </if>
     </select>
     <select id="getProductWorkOrderFlowCard" resultType="com.ruoyi.production.dto.ProductWorkOrderDto">
         SELECT
         pwo.*,
-        pp.NAME as processName,
+        CASE pp.type
+            WHEN 1 THEN '鍔犲伐'
+            WHEN 2 THEN '鍒澘鍐疯姱鍒朵綔'
+            WHEN 3 THEN '绠¤矾缁勫'
+            WHEN 4 THEN '缃愪綋杩炴帴鍙婅皟璇�'
+            WHEN 5 THEN '娴嬭瘯鎵撳帇'
+            WHEN 6 THEN '鍏朵粬'
+            ELSE pp.NAME
+        END as processName,
         pm.model,
         pm.unit,
         p.product_name AS productName,
@@ -76,4 +102,33 @@
                 p.product_name,
                 po.nps_no
     </select>
+    <select id="selectWorkOrderStartStats" resultType="com.ruoyi.production.dto.ProductWorkOrderDto">
+        SELECT
+            id,
+            actual_start_time AS planStartTime,
+            plan_quantity
+        FROM
+            product_work_order
+        WHERE
+            actual_start_time &gt;= #{startDate}
+            AND actual_start_time &lt;= #{endDate}
+    </select>
+    <select id="selectMax" resultType="com.ruoyi.production.pojo.ProductWorkOrder">
+        SELECT SUBSTRING(work_order_no, 3) as work_order_no
+        FROM product_work_order
+        WHERE SUBSTRING(work_order_no, 3) like concat(#{datePrefix},'%')
+        order by work_order_no  desc
+        limit 1
+        ;
+    </select>
+
+    <update id="addCompleteQtyIfNotExceed">
+        update product_work_order
+        set
+            complete_quantity = complete_quantity + #{delta},
+            actual_start_time = ifnull(actual_start_time, now()),
+            actual_end_time = case when (complete_quantity + #{delta}) = plan_quantity then now() else actual_end_time end
+        where id = #{id}
+          and (complete_quantity + #{delta}) <![CDATA[ <= ]]> plan_quantity
+    </update>
 </mapper>

--
Gitblit v1.9.3