From ed6f35069824d71ee6da599a328d865eb0c58550 Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期四, 25 四月 2024 09:16:26 +0800
Subject: [PATCH] Merge branch 'master' of https://gitee.com/a1536384743/erp_-override

---
 north-glass-erp/src/main/resources/mapper/pp/ReportingWork.xml |   59 ++++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/north-glass-erp/src/main/resources/mapper/pp/ReportingWork.xml b/north-glass-erp/src/main/resources/mapper/pp/ReportingWork.xml
index 9689a44..8d19a0f 100644
--- a/north-glass-erp/src/main/resources/mapper/pp/ReportingWork.xml
+++ b/north-glass-erp/src/main/resources/mapper/pp/ReportingWork.xml
@@ -310,7 +310,10 @@
     </select>
     <select id="selectGlassProcessNum" resultType="java.lang.Integer">
         select
-              d.reporting_work_num-b.reporting_work_num-b.broken_num+ifnull(c.patchNumSum,0)
+        if((d.reporting_work_num_count+ifnull(c.reworkNumSum,0)-b.reporting_work_num_count-b.broken_num)&lt; 0,
+           0,
+           (d.reporting_work_num_count+ifnull(c.reworkNumSum,0)-b.reporting_work_num_count-b.broken_num)
+            )
         from flow_card as a
         left join sd.order_process_detail as b
         on
@@ -321,13 +324,22 @@
             and b.process_id = a.process_id
         left join sd.order_process_detail as d
             on d.id=b.id-1
-        left join (select sum(patch_num) as patchNumSum,order_sort,technology_number,process_id
-                   from patch_log
-                   group by reporting_work_id,order_sort,technology_number) as c
-        on
-            c.process_id = a.process_id
-            and c.order_sort = a.order_number
-            and c.technology_number = a.technology_number
+        left join (SELECT
+                       sum(rw.rework_num) as 'reworkNumSum',
+                       rw.process_id,rw.order_sort,rw.technology_number,
+                       rwk.this_process
+                   from
+                       rework as rw
+                           LEFT JOIN
+                       reporting_work as rwk
+                       on rw.reporting_work_id =rwk.reporting_work_id
+                   where rwk.this_process=#{thisProcess}
+                     and rw.review_status=1
+                     and rw.process_id = SUBSTR(#{processId} from 1 for 14)
+                   GROUP BY rw.process_id,rw.order_sort,rw.technology_number) as c
+                  on c.process_id = a.process_id
+                      and c.order_sort = a.order_number
+                      and c.technology_number = a.technology_number
 
         where
             a.process_id=SUBSTR(#{processId} from 1 for 14)
@@ -371,10 +383,12 @@
             d.child_width,
             d.child_height,
             e.shape,
-            a.completed_quantity+a.breakage_quantity as 'quantity', -- 鍙姤宸ユ暟
-            a.completed_quantity as 'completedQuantity', -- 瀹屽伐鏁�
-            a.breakage_quantity as 'breakageQuantity', -- 鐮存崯鏁�
-            f.completed_quantity as thisQuantitySum ,-- 鏈伐搴忓畬宸ュ拰
+            if(ifnull(a.completed_quantity+a.breakage_quantity,0)=0,
+                c.quantity-ifnull(a.completed_quantity+a.breakage_quantity,0),
+                ifnull(a.completed_quantity+a.breakage_quantity,0)) as 'quantity', -- 鍙姤宸ユ暟
+            ifnull(a.completed_quantity,0) as 'completedQuantity', -- 瀹屽伐鏁�
+            ifnull(a.breakage_quantity,0) as 'breakageQuantity', -- 鐮存崯鏁�
+            ifnull(f.completed_quantity,0) as thisQuantitySum ,-- 鏈伐搴忓畬宸ュ拰
             if(c.quantity-f.completed_quantity = 0 ,true,false) as saveFlag,
             <if test="nextProcess != null and nextProcess != ''">  -- 闈炴渶鍚庝竴閬撳伐搴�
                 ifnull(g.completed_quantity,0) as nextQuantitySum,  -- 鍚庡伐搴忓凡瀹屾垚
@@ -399,13 +413,16 @@
                 as minQuantity -- 淇敼鏈�灏忔暟
             </if>
             -- e.thisQuantitySum
-        from
-            reporting_work_detail as a
-            left join reporting_work as b
-                on  a.reporting_work_id = b.reporting_work_id
-            left join  flow_card as c
-                on c.process_id = b.process_id
-                and c.technology_number = a.technology_number
+        from reporting_work as b
+
+        right join  flow_card as c
+        on c.process_id = b.process_id
+
+        left join reporting_work_detail as a
+        on  a.reporting_work_id = b.reporting_work_id
+        and c.order_number=a.order_number
+        and c.technology_number = a.technology_number
+
             left join  sd.order_glass_detail as d
                 on d.order_id = c.order_id
                 and c.order_number = d.order_number
@@ -449,7 +466,8 @@
                   and g.order_number = a.order_number
                   and g.technology_number = a.technology_number
         </if>
-        where a.reporting_work_id = #{reportingWorkId}
+        where b.reporting_work_id = #{reportingWorkId}
+        GROUP BY c.order_number
     </select>
 <select id="selectReportingWorkMp" resultMap="reportingWorkMap">
         select rw.reporting_work_id,
@@ -562,7 +580,6 @@
         select process
         from sd.order_process_detail
         where process_id = #{processId}
-          and order_number = 1
           and technology_number = 1
         order by id desc
         LIMIT 1

--
Gitblit v1.8.0