From 82bd97c5a0e05c936f62acf28ac4969b351b6d59 Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期三, 03 九月 2025 10:15:10 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10105/r/ERP_override

---
 north-glass-erp/src/main/resources/mapper/pp/Report.xml |   52 ++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/north-glass-erp/src/main/resources/mapper/pp/Report.xml b/north-glass-erp/src/main/resources/mapper/pp/Report.xml
index 112b922..dbb333b 100644
--- a/north-glass-erp/src/main/resources/mapper/pp/Report.xml
+++ b/north-glass-erp/src/main/resources/mapper/pp/Report.xml
@@ -3214,31 +3214,59 @@
             IFNULL(dd.breakageQuantity,0) as breakageQuantity,
             rw.completedArea,
             IFNULL(dd.breakageArea,0) as breakageArea,
-            CONCAT(ROUND(TRUNCATE(rw.completedQuantity/(rw.completedQuantity + IFNULL(dd.breakageArea,0)),2)*100), '%') as finished
+            CONCAT(ROUND(TRUNCATE(rw.completedArea/(rw.completedArea + IFNULL(dd.breakageArea,0)),2)*100), '%') as finished
         from
             (
-                select rw.this_process,SUM(rwd.completed_quantity) as completedQuantity
-                     ,ROUND(SUM((rwd.child_width) * (rwd.child_height) * rwd.completed_quantity / 1000000), 2) as completedArea
-                from reporting_work rw
-                         LEFT JOIN reporting_work_detail rwd on rwd.reporting_work_id = rw.reporting_work_id
+                select
+                    tb.process as this_process,
+                    SUM(tb.completedQuantity) as completedQuantity,
+                    ROUND(SUM(completedArea),2) as completedArea
+                from (
+                         SELECT
+                             rw.process_id,
+                             rw.this_process                                   AS process,
+                             rw.teams_groups_name                               AS teamsGroupsName,
+                             rwd.order_number                                   AS orderNumber,
+                             MAX(bd.nickname)                                   AS nickname,
+                             /* 浠呭綋 nickname 涓虹┖鏃舵墠鏄剧ず technology_number锛屽惁鍒欎负 NULL */
+                             MIN(CASE WHEN bd.nickname IS NULL THEN rwd.technology_number ELSE NULL END) AS technologyNumber,
+                             COALESCE((rwd.completed_quantity), 0)           AS completedQuantity,
+                             ROUND(COALESCE((rwd.child_width * rwd.child_height * rwd.completed_quantity),0)/1000000, 2)
+                                 AS completedArea
+                         FROM reporting_work rw
+                                  LEFT JOIN reporting_work_detail rwd
+                                            ON rwd.reporting_work_id = rw.reporting_work_id
+                                  LEFT JOIN sd.basic_data bd
+                                            ON bd.basic_name = rw.this_process
 
-                where   rw.reporting_work_time &gt;= #{selectTime1}
-                  AND rw.reporting_work_time &lt; #{selectTime2}
-                  AND rw.reviewed_state >= 0
-                GROUP BY rw.this_process
+                         WHERE rw.reporting_work_time &gt;= #{selectTime1}
+                           AND rw.reporting_work_time &lt; #{selectTime2}
+                           AND rw.reviewed_state &gt;= 0
+                         GROUP BY
+                             rw.reporting_work_id,
+                             rw.process_id,
+                             rw.this_process,
+                             rw.teams_groups_name,
+                             rwd.order_number,
+                             CASE WHEN bd.nickname IS NULL THEN rwd.technology_number ELSE NULL END
+                         ORDER BY rw.process_id,
+                                  rw.this_process, rw.teams_groups_name, rwd.order_number,
+                                  CASE WHEN bd.nickname IS NULL THEN rwd.technology_number ELSE NULL END
+                     ) as tb
+                GROUP BY tb.process
             ) as rw
                 left join
             (
                 select dd.responsible_process,sum(dd.breakage_quantity) as breakageQuantity
                      ,ROUND(SUM((rwd.child_width) * (rwd.child_height) * dd.breakage_quantity / 1000000), 2) as breakageArea
                 from reporting_work rw left join damage_details dd on dd.reporting_work_id = rw.reporting_work_id
-                                       LEFT JOIN reporting_work_detail rwd on rwd.reporting_work_id = dd.reporting_work_id
-                                                 and rwd.order_number = dd.order_number and rwd.technology_number  = dd.technology_number
+                                       LEFT JOIN reporting_work_detail rwd on rwd.reporting_work_id = dd.reporting_work_id and rwd.order_number = dd.order_number and rwd.technology_number  = dd.technology_number
                 where rw.reporting_work_time &gt;= #{selectTime1}
                   AND rw.reporting_work_time &lt; #{selectTime2}
-                  AND rw.reviewed_state >= 0 and dd.available =0
+                  AND rw.reviewed_state &gt;= 0 and dd.available =0
                 GROUP BY dd.responsible_process
             ) as dd on  rw.this_process = dd.responsible_process
 
+
     </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0