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/ProductOrderMapper.xml |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/main/resources/mapper/production/ProductOrderMapper.xml b/src/main/resources/mapper/production/ProductOrderMapper.xml
index 6b993bf..f8d10e0 100644
--- a/src/main/resources/mapper/production/ProductOrderMapper.xml
+++ b/src/main/resources/mapper/production/ProductOrderMapper.xml
@@ -110,4 +110,14 @@
         WHERE create_time &gt;= #{startDate} AND create_time &lt;= #{endDate}
           AND complete_quantity &lt; quantity
     </select>
+
+    <update id="addCompleteQtyIfNotExceed">
+        update product_order
+        set
+            complete_quantity = complete_quantity + #{delta},
+            start_time = ifnull(start_time, now()),
+            end_time = case when (complete_quantity + #{delta}) = quantity then now() else end_time end
+        where id = #{id}
+          and (complete_quantity + #{delta}) <![CDATA[ <= ]]> quantity
+    </update>
 </mapper>

--
Gitblit v1.9.3