From f595d1fc19019f30bb1ee8729eb50aab8999f50f Mon Sep 17 00:00:00 2001
From: chenlu <1320612696@qq.com>
Date: 星期四, 07 三月 2024 13:46:42 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/ERP_override

---
 north-glass-erp/.idea/dataSources.local.xml                                          |    2 
 north-glass-erp/src/main/resources/mapper/pp/ReworkMapper.xml                        |    2 
 north-glass-erp/target/classes/mapper/pp/ReworkMapper.xml                            |    2 
 north-glass-erp/target/classes/mapper/pp/PatchLogMapper.xml                          |    9 ++++
 north-glass-erp/src/main/java/com/example/erp/service/pp/ReworkService.java          |    2 +
 north-glass-erp/src/main/resources/mapper/pp/PatchLogMapper.xml                      |    9 ++++
 north-glass-erp/src/main/java/com/example/erp/mapper/pp/PatchLogMapper.java          |    2 +
 north-glass-erp/src/main/java/com/example/erp/service/pp/ReplenishService.java       |   47 +++++++++++++++--------
 north-glass-erp/src/main/java/com/example/erp/controller/pp/ReplenishController.java |    2 
 9 files changed, 55 insertions(+), 22 deletions(-)

diff --git a/north-glass-erp/.idea/dataSources.local.xml b/north-glass-erp/.idea/dataSources.local.xml
index 3fa20a7..0c4acb4 100644
--- a/north-glass-erp/.idea/dataSources.local.xml
+++ b/north-glass-erp/.idea/dataSources.local.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
-  <component name="dataSourceStorageLocal" created-in="IU-232.9559.62">
+  <component name="dataSourceStorageLocal" created-in="IU-232.8660.185">
     <data-source name="@localhost [2]" uuid="165c5447-d19a-4aaf-af5f-cee92ae696c2">
       <database-info product="MySQL" version="8.0.22" jdbc-version="4.2" driver-name="MySQL Connector/J" driver-version="mysql-connector-java-8.0.25 (Revision: 08be9e9b4cba6aa115f9b27b215887af40b159e0)" dbms="MYSQL" exact-version="8.0.22" exact-driver-version="8.0">
         <extra-name-characters>#@</extra-name-characters>
diff --git a/north-glass-erp/src/main/java/com/example/erp/controller/pp/ReplenishController.java b/north-glass-erp/src/main/java/com/example/erp/controller/pp/ReplenishController.java
index cf35d80..5ec9220 100644
--- a/north-glass-erp/src/main/java/com/example/erp/controller/pp/ReplenishController.java
+++ b/north-glass-erp/src/main/java/com/example/erp/controller/pp/ReplenishController.java
@@ -50,7 +50,7 @@
         }
     }
 
-    @ApiOperation("璁㈠崟璋冩嫧鎺ュ彛")
+    @ApiOperation("琛ョ墖瀹℃牳鎺ュ彛")
     @PostMapping("/updateReplenish")
     public Result updateReplenish( @RequestBody Map<String,Object> object){
         if(replenishService.updateReplenish(object)){
diff --git a/north-glass-erp/src/main/java/com/example/erp/mapper/pp/PatchLogMapper.java b/north-glass-erp/src/main/java/com/example/erp/mapper/pp/PatchLogMapper.java
index dac814c..e284bb8 100644
--- a/north-glass-erp/src/main/java/com/example/erp/mapper/pp/PatchLogMapper.java
+++ b/north-glass-erp/src/main/java/com/example/erp/mapper/pp/PatchLogMapper.java
@@ -26,6 +26,8 @@
 
     Boolean updateReplenish(@Param("patchLog") PatchLog patchLog ,  @Param("userName") String userName);
 
+    Boolean updateOrderProcessDetail(@Param("patchLog") PatchLog patchLog );
+
     List<Map<String,Object>> getSelectReplenish(@Param("offset") Integer offset, @Param("pageSize") Integer pageSiz);
 
 
diff --git a/north-glass-erp/src/main/java/com/example/erp/service/pp/ReplenishService.java b/north-glass-erp/src/main/java/com/example/erp/service/pp/ReplenishService.java
index 956c65e..be57c41 100644
--- a/north-glass-erp/src/main/java/com/example/erp/service/pp/ReplenishService.java
+++ b/north-glass-erp/src/main/java/com/example/erp/service/pp/ReplenishService.java
@@ -11,6 +11,7 @@
 import com.example.erp.service.userInfo.SysErrorService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.text.SimpleDateFormat;
@@ -20,6 +21,7 @@
 
 @Service
 @DS("pp")
+@Transactional(rollbackFor = Exception.class)
 public class ReplenishService {
     @Autowired
     PatchLogMapper patchMapper;
@@ -97,24 +99,37 @@
 
     public Boolean updateReplenish(Map<String,Object> object) {
         boolean saveState = true;
-
-        String userName = "";
-        String userId = "";
-        if (object.get("userName") != null) {
-            userName = object.get("userName").toString();
-        }
-        if (object.get("userId") != null) {
-            userId = object.get("userId").toString();
-        }
-        //鑾峰彇瀵硅薄闆嗗悎寰幆杩涜鏂板淇敼
-        List<PatchLog> patchLoglist = JSONArray.parseArray(JSONObject.toJSONString(object.get("patchLog")), PatchLog.class);
-        if (!patchLoglist.isEmpty()){
-            for (PatchLog patchLog : patchLoglist) {
-                //瀹℃牳
-                patchMapper.updateReplenish(patchLog,userName);
+        Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
+        try {
+            String userName = "";
+            String userId = "";
+            if (object.get("userName") != null) {
+                userName = object.get("userName").toString();
             }
-        }
+            if (object.get("userId") != null) {
+                userId = object.get("userId").toString();
+            }
+            //鑾峰彇瀵硅薄闆嗗悎寰幆杩涜鏂板淇敼
+            List<PatchLog> patchLoglist = JSONArray.parseArray(JSONObject.toJSONString(object.get("patchLog")), PatchLog.class);
+            if (!patchLoglist.isEmpty()){
+                for (PatchLog patchLog : patchLoglist) {
+                    //瀹℃牳
+                    patchMapper.updateReplenish(patchLog,userName);
+                    //淇敼灏忕墖娴佺▼鍗℃暟閲�
+                    patchMapper.updateOrderProcessDetail(patchLog);
+                }
+            }
 
+        } catch (Exception e) {
+            TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
+            //灏嗗紓甯镐紶鍏ユ暟鎹簱
+            SysError sysError = new SysError();
+            sysError.setError(e.toString());
+            sysError.setFunc("saveOrder");
+            sysErrorService.insert(sysError);
+            saveState = false;
+
+        }
 
         return saveState;
 
diff --git a/north-glass-erp/src/main/java/com/example/erp/service/pp/ReworkService.java b/north-glass-erp/src/main/java/com/example/erp/service/pp/ReworkService.java
index a4132da..1dd2231 100644
--- a/north-glass-erp/src/main/java/com/example/erp/service/pp/ReworkService.java
+++ b/north-glass-erp/src/main/java/com/example/erp/service/pp/ReworkService.java
@@ -14,6 +14,7 @@
 import com.example.erp.service.userInfo.SysErrorService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.text.SimpleDateFormat;
@@ -23,6 +24,7 @@
 
 @Service
 @DS("pp")
+@Transactional(rollbackFor = Exception.class)
 public class ReworkService {
     @Autowired
     ReworkMapper reworkMapper;
diff --git a/north-glass-erp/src/main/resources/mapper/pp/PatchLogMapper.xml b/north-glass-erp/src/main/resources/mapper/pp/PatchLogMapper.xml
index e820534..ed17915 100644
--- a/north-glass-erp/src/main/resources/mapper/pp/PatchLogMapper.xml
+++ b/north-glass-erp/src/main/resources/mapper/pp/PatchLogMapper.xml
@@ -88,6 +88,13 @@
         update pp.patch_log set reviewer=#{userName},review_status=1,update_time=now() where id=#{patchLog.id}
     </update>
 
+    <update id="updateOrderProcessDetail"  >
+        update sd.order_process_detail set reporting_work_num=reporting_work_num-#{patchLog.patchNum} where order_id=#{patchLog.orderId} and
+        order_number=#{patchLog.orderSort} and technology_number=#{patchLog.technologyNumber} and id <![CDATA[<]]> (select a.opdid from(select id as opdid from
+        sd.order_process_detail opd where opd.order_id=#{patchLog.orderId} and opd.order_number=#{patchLog.orderSort} and opd.technology_number=#{patchLog.technologyNumber}
+        and process=#{patchLog.patchProcesses}) as a)
+    </update>
+
     <update id="updateDamageDetails"  >
         update pp.damage_details set quantity=quantity+#{patchLog.patchNum},patch_status=1 where id=#{patchLog.reviewer}
     </update>
@@ -129,7 +136,7 @@
                  left join (select * from sd.order_glass_detail group by order_id,order_number) as ogd
                            on rw.order_id = ogd.order_id and dd.order_number = ogd.order_number
 
-        where  dd.breakage_quantity-dd.quantity>0 and dd.available=0
+        where  dd.breakage_quantity-dd.quantity>0 and dd.available=0 and (dd.responsible_process=rw.this_process or (dd.responsible_process!=rw.this_process and dd.qualityIns_status=1))
 
     </select>
 
diff --git a/north-glass-erp/src/main/resources/mapper/pp/ReworkMapper.xml b/north-glass-erp/src/main/resources/mapper/pp/ReworkMapper.xml
index 4cdcf04..c0921dc 100644
--- a/north-glass-erp/src/main/resources/mapper/pp/ReworkMapper.xml
+++ b/north-glass-erp/src/main/resources/mapper/pp/ReworkMapper.xml
@@ -98,7 +98,7 @@
                  left join (select * from sd.order_glass_detail group by order_id,order_number) as ogd
                            on rw.order_id = ogd.order_id and dd.order_number = ogd.order_number
 
-        where  dd.breakage_quantity-dd.quantity>0 and dd.available=1
+        where  dd.breakage_quantity-dd.quantity>0 and dd.available=1 and dd.qualityIns_status=1
 
     </select>
 
diff --git a/north-glass-erp/target/classes/mapper/pp/PatchLogMapper.xml b/north-glass-erp/target/classes/mapper/pp/PatchLogMapper.xml
index e820534..ed17915 100644
--- a/north-glass-erp/target/classes/mapper/pp/PatchLogMapper.xml
+++ b/north-glass-erp/target/classes/mapper/pp/PatchLogMapper.xml
@@ -88,6 +88,13 @@
         update pp.patch_log set reviewer=#{userName},review_status=1,update_time=now() where id=#{patchLog.id}
     </update>
 
+    <update id="updateOrderProcessDetail"  >
+        update sd.order_process_detail set reporting_work_num=reporting_work_num-#{patchLog.patchNum} where order_id=#{patchLog.orderId} and
+        order_number=#{patchLog.orderSort} and technology_number=#{patchLog.technologyNumber} and id <![CDATA[<]]> (select a.opdid from(select id as opdid from
+        sd.order_process_detail opd where opd.order_id=#{patchLog.orderId} and opd.order_number=#{patchLog.orderSort} and opd.technology_number=#{patchLog.technologyNumber}
+        and process=#{patchLog.patchProcesses}) as a)
+    </update>
+
     <update id="updateDamageDetails"  >
         update pp.damage_details set quantity=quantity+#{patchLog.patchNum},patch_status=1 where id=#{patchLog.reviewer}
     </update>
@@ -129,7 +136,7 @@
                  left join (select * from sd.order_glass_detail group by order_id,order_number) as ogd
                            on rw.order_id = ogd.order_id and dd.order_number = ogd.order_number
 
-        where  dd.breakage_quantity-dd.quantity>0 and dd.available=0
+        where  dd.breakage_quantity-dd.quantity>0 and dd.available=0 and (dd.responsible_process=rw.this_process or (dd.responsible_process!=rw.this_process and dd.qualityIns_status=1))
 
     </select>
 
diff --git a/north-glass-erp/target/classes/mapper/pp/ReworkMapper.xml b/north-glass-erp/target/classes/mapper/pp/ReworkMapper.xml
index 4cdcf04..c0921dc 100644
--- a/north-glass-erp/target/classes/mapper/pp/ReworkMapper.xml
+++ b/north-glass-erp/target/classes/mapper/pp/ReworkMapper.xml
@@ -98,7 +98,7 @@
                  left join (select * from sd.order_glass_detail group by order_id,order_number) as ogd
                            on rw.order_id = ogd.order_id and dd.order_number = ogd.order_number
 
-        where  dd.breakage_quantity-dd.quantity>0 and dd.available=1
+        where  dd.breakage_quantity-dd.quantity>0 and dd.available=1 and dd.qualityIns_status=1
 
     </select>
 

--
Gitblit v1.8.0