From 174cc2a8aa52f00334e0e9a3a0ea91b2e3e7acd3 Mon Sep 17 00:00:00 2001
From: chenlu <1320612696@qq.com>
Date: 星期四, 30 十月 2025 16:20:41 +0800
Subject: [PATCH] 修改次破报表翻页汇总不正确问题

---
 north-glass-erp/src/main/resources/mapper/pp/Report.xml |  282 +++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 249 insertions(+), 33 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 478a5e9..ddce89e 100644
--- a/north-glass-erp/src/main/resources/mapper/pp/Report.xml
+++ b/north-glass-erp/src/main/resources/mapper/pp/Report.xml
@@ -107,6 +107,8 @@
         <result column="glassNumber" property="glassNumber"/>
         <result column="child_width" property="childWidth"/>
         <result column="child_height" property="childHeight"/>
+        <result column="this_process" property="thisProcess"/>
+        <result column="creator" property="creator"/>
     </resultMap>
 
     <resultMap id="teamOutputMap" type="com.example.erp.dto.pp.TeamOutputDTO">
@@ -271,18 +273,20 @@
                ogd.glass_child,
                rw.this_process,
                JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) AS code,
-               CONCAT(rw.process_id,'/',GROUP_CONCAT(distinct dd.technology_number SEPARATOR '')) as process_id
+               CONCAT(rw.process_id,'/',GROUP_CONCAT(distinct dd.technology_number SEPARATOR '')) as process_id,
+               rw.creator,
+               rw.reporting_work_id
         from
             sd.`order` as o left join sd.order_detail as od on o.order_id=od.order_id
                              left join sd.order_glass_detail as ogd on ogd.order_id=od.order_id and ogd.order_number=od.order_number
-                             left join reporting_work as rw on rw.order_id=o.order_id
-                             left join damage_details as dd on dd.reporting_work_id=rw.reporting_work_id and dd.order_number=ogd.order_number
+                             left join pp.reporting_work as rw on rw.order_id=o.order_id
+                             left join pp.damage_details as dd on dd.reporting_work_id=rw.reporting_work_id and dd.order_number=ogd.order_number
             and dd.technology_number=ogd.technology_number
         where date(rw.reporting_work_time) >= #{startDate}
           and date(rw.reporting_work_time) &lt;= #{endDate}
           and rw.this_worn_quantity > 0
           and dd.available = 0
-          and reviewed_state != 2
+          and reviewed_state >-1
           and rw.this_process != dd.responsible_process
         and o.create_order>0
         <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
@@ -315,6 +319,91 @@
         <if test="crossProcessBreakingDTO.responsiblePersonnel != null and crossProcessBreakingDTO.responsiblePersonnel != ''">
             and dd.responsible_personnel regexp #{crossProcessBreakingDTO.responsiblePersonnel}
         </if>
+        <if test="crossProcessBreakingDTO.creator != null and crossProcessBreakingDTO.creator != ''">
+            and rw.creator regexp #{crossProcessBreakingDTO.creator}
+        </if>
+        <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
+            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') regexp #{crossProcessBreakingDTO.code}
+        </if>
+        <if test="crossProcessBreakingDTO.reportingWorkId != null and crossProcessBreakingDTO.reportingWorkId != ''">
+            and rw.reporting_work_id regexp #{crossProcessBreakingDTO.reportingWorkId}
+        </if>
+        GROUP BY dd.id
+        order by dd.id desc
+        limit #{offset},#{pageSize}
+    </select>
+
+    <select id="getNotProcessBreaking" resultMap="damageDetailsTableMap">
+        select rw.reporting_work_id,
+        rw.reporting_work_time,
+        dd.responsible_process,
+        dd.responsible_team,
+        dd.breakage_type,
+        dd.breakage_reason,
+        dd.responsible_personnel,
+        ROUND((dd.breakage_quantity))                                                   as breakage_quantity,
+        round(ogd.child_width * ogd.child_height * (dd.breakage_quantity) / 1000000, 2) as area,
+        rw.this_process,
+        o.project,
+        o.order_id,
+        ogd.glass_child,
+        rw.this_process,
+        JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) AS code,
+        CONCAT(rw.process_id,'/',GROUP_CONCAT(distinct dd.technology_number SEPARATOR '')) as process_id,
+        rw.creator,
+        rw.reporting_work_id
+        from
+        sd.`order` as o left join sd.order_detail as od on o.order_id=od.order_id
+        left join sd.order_glass_detail as ogd on ogd.order_id=od.order_id and ogd.order_number=od.order_number
+        left join pp.reporting_work as rw on rw.order_id=o.order_id
+        left join pp.damage_details as dd on dd.reporting_work_id=rw.reporting_work_id and dd.order_number=ogd.order_number
+        and dd.technology_number=ogd.technology_number
+        where date(rw.reporting_work_time) >= #{startDate}
+        and date(rw.reporting_work_time) &lt;= #{endDate}
+        and rw.this_worn_quantity > 0
+        and dd.available = 0
+        and reviewed_state >-1
+        and rw.this_process = dd.responsible_process
+        and o.create_order>0
+        <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
+            and JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) regexp #{crossProcessBreakingDTO.code}
+        </if>
+        <if test="crossProcessBreakingDTO.processId != null and crossProcessBreakingDTO.processId != ''">
+            and rw.process_id regexp #{crossProcessBreakingDTO.processId}
+        </if>
+        <if test="crossProcessBreakingDTO.thisProcess != null and crossProcessBreakingDTO.thisProcess != ''">
+            and rw.this_process regexp #{crossProcessBreakingDTO.thisProcess}
+        </if>
+        <if test="crossProcessBreakingDTO.responsibleProcess != null and crossProcessBreakingDTO.responsibleProcess != ''">
+            and dd.responsible_process regexp #{crossProcessBreakingDTO.responsibleProcess}
+        </if>
+        <if test="crossProcessBreakingDTO.responsibleTeam != null and crossProcessBreakingDTO.responsibleTeam != ''">
+            and dd.responsible_team regexp #{crossProcessBreakingDTO.responsibleTeam}
+        </if>
+        <if test="crossProcessBreakingDTO.glassChild != null and crossProcessBreakingDTO.glassChild != ''">
+            and ogd.glass_child regexp #{crossProcessBreakingDTO.glassChild}
+        </if>
+        <if test="crossProcessBreakingDTO.breakageType != null and crossProcessBreakingDTO.breakageType != ''">
+            and dd.breakage_type regexp #{crossProcessBreakingDTO.breakageType}
+        </if>
+        <if test="crossProcessBreakingDTO.project != null and crossProcessBreakingDTO.project != ''">
+            and o.project regexp #{crossProcessBreakingDTO.project}
+        </if>
+        <if test="crossProcessBreakingDTO.orderId != null and crossProcessBreakingDTO.orderId != ''">
+            and o.order_id regexp #{crossProcessBreakingDTO.orderId}
+        </if>
+        <if test="crossProcessBreakingDTO.responsiblePersonnel != null and crossProcessBreakingDTO.responsiblePersonnel != ''">
+            and dd.responsible_personnel regexp #{crossProcessBreakingDTO.responsiblePersonnel}
+        </if>
+        <if test="crossProcessBreakingDTO.creator != null and crossProcessBreakingDTO.creator != ''">
+            and rw.creator regexp #{crossProcessBreakingDTO.creator}
+        </if>
+        <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
+            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') regexp #{crossProcessBreakingDTO.code}
+        </if>
+        <if test="crossProcessBreakingDTO.reportingWorkId != null and crossProcessBreakingDTO.reportingWorkId != ''">
+            and rw.reporting_work_id regexp #{crossProcessBreakingDTO.reportingWorkId}
+        </if>
         GROUP BY dd.id
         order by dd.id desc
         limit #{offset},#{pageSize}
@@ -323,19 +412,20 @@
     <select id="getProcessBreakingTotal">
         select CEILING(count(dd.id) / #{pageSize}) as 'pageTotal',
                count(distinct dd.id)               as 'total'
-        from damage_details as dd
-                 left join reporting_work as rw
+        from pp.damage_details as dd
+                 left join pp.reporting_work as rw
                            on rw.reporting_work_id = dd.reporting_work_id
                  left join sd.order as o
                            on rw.order_id = o.order_id
                  left join sd.order_glass_detail as ogd
                            on ogd.order_id = o.order_id and ogd.order_number = dd.order_number
                                and ogd.technology_number and dd.technology_number
+        left join sd.order_detail as od on o.order_id = od.order_id and od.order_number=ogd.order_number
         where date(rw.reporting_work_time) >= #{startDate}
           and date(rw.reporting_work_time) &lt;= #{endDate}
           and rw.this_worn_quantity > 0
           and dd.available = 0
-          and reviewed_state != 2
+          and rw.reviewed_state>=0
           and rw.this_process != dd.responsible_process
         <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
             and JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) regexp #{crossProcessBreakingDTO.code}
@@ -366,6 +456,66 @@
         </if>
         <if test="crossProcessBreakingDTO.responsiblePersonnel != null and crossProcessBreakingDTO.responsiblePersonnel != ''">
             and dd.responsible_personnel regexp #{crossProcessBreakingDTO.responsiblePersonnel}
+        </if>
+        <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
+            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') regexp #{crossProcessBreakingDTO.code}
+        </if>
+        <if test="crossProcessBreakingDTO.reportingWorkId != null and crossProcessBreakingDTO.reportingWorkId != ''">
+            and rw.reporting_work_id regexp #{crossProcessBreakingDTO.reportingWorkId}
+        </if>
+        order by dd.id desc
+    </select>
+
+    <select id="getNotProcessBreakingTotal">
+        select CEILING(count(dd.id) / #{pageSize}) as 'pageTotal',
+        count(distinct dd.id)               as 'total'
+        from pp.damage_details as dd
+        left join pp.reporting_work as rw
+        on rw.reporting_work_id = dd.reporting_work_id
+        left join sd.order as o
+        on rw.order_id = o.order_id
+        left join sd.order_glass_detail as ogd
+        on ogd.order_id = o.order_id and ogd.order_number = dd.order_number
+        and ogd.technology_number and dd.technology_number
+        left join sd.order_detail as od on o.order_id = od.order_id and od.order_number=ogd.order_number
+        where date(rw.reporting_work_time) >= #{startDate}
+        and date(rw.reporting_work_time) &lt;= #{endDate}
+        and rw.this_worn_quantity > 0
+        and dd.available = 0
+        and reviewed_state != 2
+        and rw.this_process = dd.responsible_process
+        <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
+            and JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) regexp #{crossProcessBreakingDTO.code}
+        </if>
+        <if test="crossProcessBreakingDTO.processId != null and crossProcessBreakingDTO.processId != ''">
+            and rw.process_id regexp #{crossProcessBreakingDTO.processId}
+        </if>
+        <if test="crossProcessBreakingDTO.thisProcess != null and crossProcessBreakingDTO.thisProcess != ''">
+            and rw.this_process regexp #{crossProcessBreakingDTO.thisProcess}
+        </if>
+        <if test="crossProcessBreakingDTO.responsibleProcess != null and crossProcessBreakingDTO.responsibleProcess != ''">
+            and dd.responsible_process regexp #{crossProcessBreakingDTO.responsibleProcess}
+        </if>
+        <if test="crossProcessBreakingDTO.responsibleTeam != null and crossProcessBreakingDTO.responsibleTeam != ''">
+            and dd.responsible_team regexp #{crossProcessBreakingDTO.responsibleTeam}
+        </if>
+        <if test="crossProcessBreakingDTO.glassChild != null and crossProcessBreakingDTO.glassChild != ''">
+            and ogd.glass_child regexp #{crossProcessBreakingDTO.glassChild}
+        </if>
+        <if test="crossProcessBreakingDTO.breakageType != null and crossProcessBreakingDTO.breakageType != ''">
+            and dd.breakage_type regexp #{crossProcessBreakingDTO.breakageType}
+        </if>
+        <if test="crossProcessBreakingDTO.project != null and crossProcessBreakingDTO.project != ''">
+            and o.project regexp #{crossProcessBreakingDTO.project}
+        </if>
+        <if test="crossProcessBreakingDTO.orderId != null and crossProcessBreakingDTO.orderId != ''">
+            and o.order_id regexp #{crossProcessBreakingDTO.orderId}
+        </if>
+        <if test="crossProcessBreakingDTO.responsiblePersonnel != null and crossProcessBreakingDTO.responsiblePersonnel != ''">
+            and dd.responsible_personnel regexp #{crossProcessBreakingDTO.responsiblePersonnel}
+        </if>
+        <if test="crossProcessBreakingDTO.code != null and crossProcessBreakingDTO.code != ''">
+            and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') regexp #{crossProcessBreakingDTO.code}
         </if>
         order by dd.id desc
     </select>
@@ -621,12 +771,15 @@
         ogd.glass_child,
         ogd.child_width,
         ogd.child_height,
-        ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') AS glassNumber
+        ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') AS glassNumber,
+        rw.this_process,
+        rw.creator,
+        rw.reporting_work_id
         FROM
         sd.ORDER AS o
         LEFT JOIN sd.order_glass_detail AS ogd ON ogd.order_id = o.order_id
-        LEFT JOIN reporting_work AS rw ON rw.order_id = o.order_id
-        LEFT JOIN damage_details AS dd ON dd.reporting_work_id = rw.reporting_work_id
+        LEFT JOIN pp.reporting_work AS rw ON rw.order_id = o.order_id
+        LEFT JOIN pp.damage_details AS dd ON dd.reporting_work_id = rw.reporting_work_id
         AND dd.order_number = ogd.order_number
         AND dd.technology_number = ogd.technology_number
         left join sd.order_detail as od on o.order_id = od.order_id and od.order_number=ogd.order_number
@@ -671,6 +824,15 @@
         <if test="damageReportDTO.glassNumber != null and damageReportDTO.glassNumber != ''">
             and ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') regexp #{damageReportDTO.glassNumber}
         </if>
+        <if test="damageReportDTO.thisProcess != null and damageReportDTO.thisProcess != ''">
+            and rw.this_process regexp #{damageReportDTO.thisProcess}
+        </if>
+        <if test="damageReportDTO.creator != null and damageReportDTO.creator != ''">
+            and rw.creator regexp #{damageReportDTO.creator}
+        </if>
+        <if test="damageReportDTO.reportingWorkId != null and damageReportDTO.reportingWorkId != ''">
+            and rw.reporting_work_id regexp #{damageReportDTO.reportingWorkId}
+        </if>
         GROUP BY
         dd.id
         limit #{offset},#{pageSize};
@@ -683,14 +845,14 @@
         FROM
         sd.ORDER AS o
         LEFT JOIN sd.order_glass_detail AS ogd ON ogd.order_id = o.order_id
-        LEFT JOIN reporting_work AS rw ON rw.order_id = o.order_id
-        LEFT JOIN damage_details AS dd ON dd.reporting_work_id = rw.reporting_work_id
+        LEFT JOIN pp.reporting_work AS rw ON rw.order_id = o.order_id
+        LEFT JOIN pp.damage_details AS dd ON dd.reporting_work_id = rw.reporting_work_id
         AND dd.order_number = ogd.order_number
         AND dd.technology_number = ogd.technology_number
         WHERE
         rw.reporting_work_time >= #{selectTime1}
         AND rw.reporting_work_time &lt;  #{selectTime2}
-        AND dd.available = 0
+        AND dd.available = 0 and rw.reviewed_state>=0
         <if test="damageReportDTO.orderId != null and damageReportDTO.orderId != ''">
             and o.order_id regexp #{damageReportDTO.orderId}
         </if>
@@ -1060,7 +1222,12 @@
                rw.this_process,
                o.project,
                o.order_id,
-               ogd.glass_child
+               ogd.glass_child,
+               rw.this_process,
+               JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) AS code,
+               CONCAT(rw.process_id,'/',GROUP_CONCAT(distinct dd.technology_number SEPARATOR '')) as process_id,
+               rw.creator,
+               rw.reporting_work_id
         from damage_details as dd
                  left join reporting_work as rw
                            on rw.reporting_work_id = dd.reporting_work_id
@@ -1069,12 +1236,50 @@
                  left join sd.order_glass_detail as ogd
                            on ogd.order_id = o.order_id and ogd.order_number = dd.order_number
                                and ogd.technology_number and dd.technology_number
+                 left join sd.order_detail as od on o.order_id = od.order_id and od.order_number=ogd.order_number
         where date(rw.reporting_work_time) >= #{dates[0]}
           and date(rw.reporting_work_time) &lt;= #{dates[1]}
           and rw.this_worn_quantity > 0
           and dd.available = 0
           and reviewed_state != 2
           and rw.this_process != dd.responsible_process
+        GROUP BY dd.id
+        order by dd.id desc
+    </select>
+
+    <select id="exportNotCrossProcessBreakingMp">
+        select rw.reporting_work_id,
+               rw.reporting_work_time,
+               dd.responsible_process,
+               dd.responsible_team,
+               dd.breakage_type,
+               dd.breakage_reason,
+               ROUND((dd.breakage_quantity))                                                   as breakage_quantity,
+               round(ogd.child_width * ogd.child_height * (dd.breakage_quantity) / 1000000, 2) as area,
+               rw.this_process,
+               o.project,
+               o.order_id,
+               ogd.glass_child,
+               rw.this_process,
+               JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) AS code,
+               CONCAT(rw.process_id,'/',GROUP_CONCAT(distinct dd.technology_number SEPARATOR '')) as process_id,
+               rw.creator,
+               rw.reporting_work_id
+        from damage_details as dd
+                 left join reporting_work as rw
+                           on rw.reporting_work_id = dd.reporting_work_id
+                 left join sd.order as o
+                           on rw.order_id = o.order_id
+                 left join sd.order_glass_detail as ogd
+                           on ogd.order_id = o.order_id and ogd.order_number = dd.order_number
+                               and ogd.technology_number and dd.technology_number
+                 left join sd.order_detail as od on o.order_id = od.order_id and od.order_number=ogd.order_number
+        where date(rw.reporting_work_time) >= #{dates[0]}
+          and date(rw.reporting_work_time) &lt;= #{dates[1]}
+          and rw.this_worn_quantity > 0
+          and dd.available = 0
+          and reviewed_state != 2
+          and rw.this_process = dd.responsible_process
         GROUP BY dd.id
         order by dd.id desc
     </select>
@@ -1097,13 +1302,18 @@
                IFNULL(dd.responsible_personnel, '')                                          as personnel,
                ogd.glass_child,
                ogd.child_width,
-               ogd.child_height
+               ogd.child_height,
+               ifnull(JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')),'') AS glassNumber,
+               rw.this_process,
+               rw.creator,
+               rw.reporting_work_id
         FROM sd.ORDER AS o
                  LEFT JOIN sd.order_glass_detail AS ogd ON ogd.order_id = o.order_id
                  LEFT JOIN reporting_work AS rw ON rw.order_id = o.order_id
                  LEFT JOIN damage_details AS dd ON dd.reporting_work_id = rw.reporting_work_id
             AND dd.order_number = ogd.order_number
             AND dd.technology_number = ogd.technology_number
+            left join sd.order_detail as od on o.order_id = od.order_id and od.order_number=ogd.order_number
         WHERE rw.reporting_work_time >= #{dates[0]}
           and rw.reporting_work_time &lt;= #{dates[1]}
           AND dd.available = 0 and rw.reviewed_state>=0
@@ -1428,6 +1638,7 @@
         rw.this_process,
         rw.teams_groups_name,
         o.project,
+        o.order_id,
         rw.process_id,
         fc.order_number,
         MAX(ogd.child_width)  AS width,
@@ -1447,10 +1658,10 @@
         END AS workProcessName,
         o.batch
         FROM
-        reporting_work AS rw
-        LEFT JOIN reporting_work_detail AS rwd
+        pp.reporting_work AS rw
+        LEFT JOIN pp.reporting_work_detail AS rwd
         ON rwd.reporting_work_id = rw.reporting_work_id
-        LEFT JOIN flow_card AS fc
+        LEFT JOIN pp.flow_card AS fc
         ON fc.order_id = rw.order_id
         AND fc.process_id = rw.process_id
         AND fc.order_number = rwd.order_number
@@ -1496,6 +1707,9 @@
         </if>
         <if test="teamOutputDTO.deviceName != null and teamOutputDTO.deviceName != ''">
             AND rw.device_name REGEXP #{teamOutputDTO.deviceName}
+        </if>
+        <if test="teamOutputDTO.batch != null and teamOutputDTO.batch != ''">
+            AND o.batch REGEXP #{teamOutputDTO.batch}
         </if>
 
         <choose>
@@ -1620,8 +1834,8 @@
         od.product_name,
         JSON_UNQUOTE( JSON_EXTRACT( od.other_columns, '$.S01' )) AS code
         FROM
-        reporting_work as rw left join reporting_work_detail as rwd on rwd.reporting_work_id=rw.reporting_work_id
-        left join flow_card as fc on fc.order_id=rw.order_id and fc.process_id=rw.process_id  and fc.order_number=rwd.order_number and fc.technology_number=rwd.technology_number
+        pp.reporting_work as rw left join pp.reporting_work_detail as rwd on rwd.reporting_work_id=rw.reporting_work_id
+        left join pp.flow_card as fc on fc.order_id=rw.order_id and fc.process_id=rw.process_id  and fc.order_number=rwd.order_number and fc.technology_number=rwd.technology_number
         left join sd.order_glass_detail as ogd on ogd.order_id=fc.order_id and ogd.order_number=fc.order_number and ogd.technology_number=fc.technology_number
         left join sd.order_detail as od  on od.order_id=ogd.order_id and od.order_number=ogd.order_number
         left join sd.`order` as o on o.order_id=od.order_id
@@ -1644,7 +1858,9 @@
         <if test="teamOutputDTO.edgingType != null and teamOutputDTO.edgingType != ''">
             and od.edging_type regexp #{teamOutputDTO.edgingType}
         </if>
-
+        <if test="teamOutputDTO.batch != null and teamOutputDTO.batch != ''">
+            AND o.batch REGEXP #{teamOutputDTO.batch}
+        </if>
         <choose>
             <when test="laminating == ''">
                 GROUP BY
@@ -2164,7 +2380,7 @@
             SUM(odpd.reporting_work_num) AS completeNum,
             ROUND(SUM(ogd.child_width * ogd.child_height * odpd.reporting_work_num) / 1000000, 2) AS completeArea,
             SUM(fc.quantity - odpd.reporting_work_num) AS incompleteNum,
-            ROUND(SUM(ogd.child_width * ogd.child_height * (fc.quantity - odpd.reporting_work_num)) / 1000000, 2) AS incompleteArea
+            ROUND(SUM(ogd.child_width * ogd.child_height * (CAST(fc.quantity AS SIGNED) - CAST(odpd.reporting_work_num AS SIGNED))) / 1000000, 2) AS incompleteArea
         FROM sd.order_detail AS od
                  LEFT JOIN sd.order_glass_detail AS ogd
                            ON od.order_id = ogd.order_id
@@ -2187,7 +2403,7 @@
           AND o.create_time &lt;  #{selectTime2}
           and position(#{orderId} in od.order_id)
           and position(#{inputProject} in o.project)
-          AND fc.quantity - odpd.reporting_work_num > 0;
+          AND CAST(fc.quantity AS SIGNED) - CAST(odpd.reporting_work_num AS SIGNED)>0;
 
     </select>
 
@@ -2198,8 +2414,8 @@
         FROM
             sd.ORDER AS o
                 LEFT JOIN sd.order_glass_detail AS ogd ON ogd.order_id = o.order_id
-                LEFT JOIN reporting_work AS rw ON rw.order_id = o.order_id
-                LEFT JOIN damage_details AS dd ON dd.reporting_work_id = rw.reporting_work_id
+                LEFT JOIN pp.reporting_work AS rw ON rw.order_id = o.order_id
+                LEFT JOIN pp.damage_details AS dd ON dd.reporting_work_id = rw.reporting_work_id
                 AND dd.order_number = ogd.order_number
                 AND dd.technology_number = ogd.technology_number
                 LEFT JOIN sd.order_detail AS od ON o.order_id = od.order_id
@@ -2276,10 +2492,10 @@
         END AS workProcessName,
         o.batch
         FROM
-        reporting_work AS rw
-        LEFT JOIN reporting_work_detail AS rwd
+        pp.reporting_work AS rw
+        LEFT JOIN pp.reporting_work_detail AS rwd
         ON rwd.reporting_work_id = rw.reporting_work_id
-        LEFT JOIN flow_card AS fc
+        LEFT JOIN pp.flow_card AS fc
         ON fc.order_id = rw.order_id
         AND fc.process_id = rw.process_id
         AND fc.order_number = rwd.order_number
@@ -2326,7 +2542,9 @@
         <if test="teamOutputDTO.deviceName != null and teamOutputDTO.deviceName != ''">
             AND rw.device_name REGEXP #{teamOutputDTO.deviceName}
         </if>
-
+        <if test="teamOutputDTO.batch != null and teamOutputDTO.batch != ''">
+            AND o.batch REGEXP #{teamOutputDTO.batch}
+        </if>
         <choose>
             <when test="laminating == ''">
                 GROUP BY
@@ -2904,7 +3122,6 @@
                                         AND cb.technology_number = b.technology_number
                              where a.processing_card>0
                                and a.warehousing!=2
-                                and (c.quantity-b.reporting_work_num)>0
                              GROUP BY  b.process_id, b.order_number,
                                  b.technology_number) as f
                                 LEFT JOIN sd.order_process_detail as e
@@ -2995,7 +3212,6 @@
         AND cb.technology_number = b.technology_number
         where a.processing_card>0
         and a.warehousing!=2
-        and (c.quantity-b.reporting_work_num)>0
         GROUP BY  b.process_id, b.order_number,
         b.technology_number) as f
         LEFT JOIN sd.order_process_detail as e
@@ -3297,7 +3513,7 @@
         ROUND(ogd.child_width * ogd.child_height * odpd.reporting_work_num / 1000000,
         2)                                                             as completeArea,
         fc.quantity - odpd.reporting_work_num - ifnull(fc.termination_quantity,0)      as incompleteNum,
-        ROUND(ogd.child_width * ogd.child_height * (fc.quantity - odpd.reporting_work_num- ifnull(fc.termination_quantity,0)) / 1000000,
+        ROUND(ogd.child_width * ogd.child_height * (CAST(fc.quantity AS SIGNED) - CAST(odpd.reporting_work_num AS SIGNED)- ifnull(fc.termination_quantity,0)) / 1000000,
         2)                                                             as incompleteArea,
         od.product_name
 
@@ -3323,7 +3539,7 @@
           AND o.create_time &lt;  #{selectTime2}
           and position(#{orderId} in od.order_id)
           and position(#{inputProject} in o.project)
-        and GREATEST(fc.quantity - odpd.reporting_work_num, 0)>0
+        and CAST(fc.quantity AS SIGNED) - CAST(odpd.reporting_work_num AS SIGNED)>0
         and fc.quantity-ifnull(fc.termination_quantity,0)>0
         GROUP BY fc.process_id, fc.order_number, fc.technology_number
         order by fc.process_id, fc.order_number, fc.technology_number

--
Gitblit v1.8.0