From e5211965063b5bbd1cfcf2b9ae91e18cc9b0e3ae Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期一, 19 八月 2024 14:14:31 +0800
Subject: [PATCH] 修改工程钢化标签打印

---
 north-glass-erp/src/main/resources/mapper/pp/FolwCard.xml |  532 ++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 366 insertions(+), 166 deletions(-)

diff --git a/north-glass-erp/src/main/resources/mapper/pp/FolwCard.xml b/north-glass-erp/src/main/resources/mapper/pp/FolwCard.xml
index 7626cb4..9ff0452 100644
--- a/north-glass-erp/src/main/resources/mapper/pp/FolwCard.xml
+++ b/north-glass-erp/src/main/resources/mapper/pp/FolwCard.xml
@@ -217,7 +217,7 @@
             sd.order_glass_detail as ogd left join flow_card as fc
                 on ogd.order_id = fc.order_id and ogd.order_number = fc.order_number
         set ogd.splitting_status=0
-        where ogd.order_id = #{orderId}
+        where fc.process_id = #{processId}
 
     </update>
 
@@ -225,7 +225,7 @@
     <update id="deleteFlowCardMp">
         delete
         from flow_card as fc
-        where fc.order_id = left(#{processId}, 10)
+        where fc.process_id = #{processId}
     </update>
 
     <!--    鍒嗘灦鏂板鏄庣粏鏌ヨ-->
@@ -442,7 +442,7 @@
     <delete id="deleteReportingWork">
         delete
         from sd.order_process_detail
-        where order_id = left(#{processId}, 10)
+        where process_id = #{processId}
     </delete>
 
     <select id="selectPrintFlowCardMp">
@@ -472,9 +472,7 @@
 
     <select id="selectPrintMp">
         select *
-        from (
-
-        (select fc.id,
+        from ((select fc.id,
                       fc.order_id,
                       fc.process_id,
                       o.customer_name,
@@ -507,10 +505,12 @@
                                           ogds.child_height
                                    from sd.order_glass_detail as ogds
                                    where ogds.order_id = #{orderId}
-                                   GROUP BY order_id, order_number, ogds.glass_child,process,ogds.child_width,ogds.child_height) as ogdss
+                                   GROUP BY order_id, order_number, ogds.glass_child, process, ogds.child_width,
+                                            ogds.child_height) as ogdss
                                   on fc.order_id = ogdss.order_id and ogdss.order_number = fc.order_number
                where fc.order_id = #{orderId}
-               GROUP BY fc.process_id, ogdss.concatenated_glass_child,ogdss.processed_part,ogdss.child_width,ogdss.child_height
+               GROUP BY fc.process_id, ogdss.concatenated_glass_child, ogdss.processed_part, ogdss.child_width,
+                        ogdss.child_height
                order by fc.process_id, ogdss.technology_number)
 
               UNION
@@ -543,7 +543,7 @@
                                           ogds.order_number,
                                           GROUP_CONCAT(ogds.technology_number SEPARATOR '') AS technology_number,
                                           ogds.glass_child,
-                                          GROUP_CONCAT(ogds.glass_child SEPARATOR ' ')      AS concatenated_glass_child,
+                                          GROUP_CONCAT(ogds.glass_child SEPARATOR '+')      AS concatenated_glass_child,
                                           SUBSTRING(process, LOCATE('澶硅兌', process))       AS processed_part
                                    from sd.order_glass_detail as ogds
                                    where ogds.order_id = #{orderId}
@@ -581,7 +581,7 @@
                                           ogds.order_number,
                                           GROUP_CONCAT(pds.glass_sort SEPARATOR '')           AS technology_number,
                                           ogds.glass_child,
-                                          GROUP_CONCAT(ogds.glass_child SEPARATOR ' ')        AS concatenated_glass_child,
+                                          GROUP_CONCAT(ogds.glass_child SEPARATOR '+')        AS concatenated_glass_child,
                                           SUBSTRING(pds.process, LOCATE('涓┖', pds.process)) AS processed_part
                                    from sd.order_glass_detail as ogds
                                             left join sd.order_detail as ods
@@ -597,8 +597,8 @@
                order by fc.process_id)) AS combined_results
         where process is not null
           and process != ""
-        GROUP BY order_id,process_id,technology_number,process
-        order by order_id,process_id,length(technology_number)
+        GROUP BY order_id, process_id, technology_number, process
+        order by order_id, process_id, length(technology_number)
     </select>
 
     <select id="getPrimaryList">
@@ -615,7 +615,8 @@
                sum(od.weight)                                  as weight,
                #{technologyNumber}                             as technologyNumber,
                concat(fc.process_id, '/', #{technologyNumber}) as processIdNumber,
-               concat('瀵瑰簲鎴戝徃鍗曞彿',o.batch)                                         AS otherRemarks
+               concat('瀵瑰簲鎴戝徃鍗曞彿', o.batch)                 AS otherRemarks,
+               ''                                              as qrcode
         from flow_card as fc
                  left join sd.order_glass_detail as ogd
                            on fc.order_id = ogd.order_id and fc.order_number = ogd.order_number and
@@ -641,15 +642,15 @@
 
     <select id="getDetailList">
         select fc.order_number,
-               concat(round(ogd.child_width), "*", round(ogd.child_height)) as child_width,
+               concat(round(ogd.child_width), "*", round(ogd.child_height))   as child_width,
                fc.quantity,
-               round(ogd.total_area, 2)                                     as total_area,
+               round(ogd.total_area, 2)                                       as total_area,
                od.perimeter,
                od.bend_radius,
-               concat(IFNULL(od.processing_note,''), IFNULL(od.remarks,''))                       as remarks,
+               concat(IFNULL(od.processing_note, ''), IFNULL(od.remarks, '')) as remarks,
                od.other_columns,
-               round(ogd.child_width)                                       as width,
-               round(ogd.child_height)                                      as height,
+               round(ogd.child_width)                                         as width,
+               round(ogd.child_height)                                        as height,
                pd.separation,
                fc.technology_number
         from flow_card as fc
@@ -659,8 +660,10 @@
                  left join sd.order_detail as od on od.order_id = fc.order_id and od.order_number = fc.order_number
                  left join sd.product_detail as pd
                            on pd.prod_id = od.product_id and pd.glass_sort = ogd.technology_number
-                 left join flow_card_sort as fcs on fcs.process_id = fc.process_id and fcs.order_number = fc.order_number and fcs.technology_number = fc.technology_number
-            and fcs.process=#{process}
+                 left join flow_card_sort as fcs
+                           on fcs.process_id = fc.process_id and fcs.order_number = fc.order_number and
+                              fcs.technology_number = fc.technology_number
+                               and fcs.process = #{process}
         where fc.process_id = #{processId}
           and position(fc.technology_number in #{technologyNumber})
         group by fc.process_id, fc.order_number
@@ -719,6 +722,37 @@
         order by opd.stock_id
     </select>
 
+    <select id="getPrintLabel2">
+        select o.order_id,
+               c.customer_abbreviation as customer_name,
+               o.project,
+               od.building_number,
+               od.processing_note,
+               ogd.child_width         as width,
+               ogd.child_height        as height,
+               ogd.glass_child,
+               ogd.process,
+               e.type_name,
+               opd.stock_id,
+               od.quantity,
+               od.other_columns,
+               od.bend_radius,
+               opd.heat_layout_id,
+               opd.heat_layout_sort
+        from pp.optimize_detail opd
+                 left join sd.`order` o on SUBSTR(opd.process_id, 1, 10) = o.order_id
+                 left join sd.order_detail od
+                           on SUBSTR(opd.process_id, 1, 10) = od.order_id and opd.order_sort = od.order_number
+                 left join sd.order_glass_detail ogd
+                           on SUBSTR(opd.process_id, 1, 10) = ogd.order_id and opd.order_sort = ogd.order_number and
+                              opd.layer = ogd.technology_number
+                 left join sd.product p on od.product_id = p.id
+                 left join sd.basic_glass_type e on e.type_id = p.type_id
+                 left join sd.customer c on c.id = o.customer_id
+        where opd.project_no = #{projectNo}
+        order by opd.heat_layout_id, opd.heat_layout_sort desc
+    </select>
+
     <select id="getPrintLabel1">
         select o.order_id,
                o.project,
@@ -760,21 +794,23 @@
                ogd.child_height,
                fc.quantity,
                ROUND(ogd.child_width * ogd.child_height * fc.quantity / 1000000, 2) as area,
-               ifnull(fcs.sort,'') as sort,
+               ifnull(fcs.sort, '')                                                 as sort,
                ogd.glass_child,
-               #{process} as process,
-               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')) AS glassNumber
+               #{process}                                                           as process,
+               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01'))                AS glassNumber
         FROM flow_card AS fc
                  LEFT JOIN sd.order_glass_detail AS ogd ON fc.order_id = ogd.order_id
             AND fc.order_number = ogd.order_number
             AND fc.technology_number = ogd.technology_number
-        left join flow_card_sort as fcs on fcs.process_id = fc.process_id and fcs.order_number = fc.order_number and fcs.technology_number = fc.technology_number
-            and fcs.process=#{process}
-        left join sd.order_detail as od on od.order_id = fc.order_id and od.order_number = fc.order_number
+                 left join flow_card_sort as fcs
+                           on fcs.process_id = fc.process_id and fcs.order_number = fc.order_number and
+                              fcs.technology_number = fc.technology_number
+                               and fcs.process = #{process}
+                 left join sd.order_detail as od on od.order_id = fc.order_id and od.order_number = fc.order_number
         where fc.process_id = #{processId}
           and position(fc.technology_number in #{technologyNumber})
-
-        order by IF(fc.sort != NULL or fc.sort != '', fc.sort, fc.order_number)
+        GROUP BY fc.process_id,fc.order_number,fc.technology_number
+        order by IF(fcs.sort != NULL or fcs.sort != '', fcs.sort, fc.order_number)
     </select>
 
     <update id="printSortMp">
@@ -1009,12 +1045,12 @@
                ROUND(ogd.child_width * ogd.child_height * fc.quantity / 1000000, 2) as area,
                fc.sort,
                ogd.process,
-               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')) AS glassNumber
+               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01'))                AS glassNumber
         FROM flow_card AS fc
                  LEFT JOIN sd.order_glass_detail AS ogd ON fc.order_id = ogd.order_id
             AND fc.order_number = ogd.order_number
             AND fc.technology_number = ogd.technology_number
-        left join sd.order_detail as od on fc.order_id = od.order_id and fc.order_number = od.order_number
+                 left join sd.order_detail as od on fc.order_id = od.order_id and fc.order_number = od.order_number
         where fc.order_id = #{orderId}
         order by IF(fc.sort != NULL or fc.sort != '', fc.sort, fc.technology_number)
     </select>
@@ -1041,7 +1077,7 @@
                sum(od.weight)                                  as weight,
                #{technologyNumber}                             as technologyNumber,
                concat(fc.process_id, '/', #{technologyNumber}) as processIdNumber,
-               concat('瀵瑰簲鎴戝徃鍗曞彿',o.batch)                                         AS otherRemarks
+               concat('瀵瑰簲鎴戝徃鍗曞彿', o.batch)                 AS otherRemarks
         from flow_card as fc
                  left join sd.order_glass_detail as ogd
                            on fc.order_id = ogd.order_id and fc.order_number = ogd.order_number and
@@ -1108,15 +1144,15 @@
 
     <select id="getDetailListLike">
         select fc.order_number,
-               concat(round(ogd.child_width), "*", round(ogd.child_height)) as child_width,
+               concat(round(ogd.child_width), "*", round(ogd.child_height))   as child_width,
                fc.quantity,
-               round(ogd.total_area, 2)                                     as total_area,
+               round(ogd.total_area, 2)                                       as total_area,
                od.perimeter,
                od.bend_radius,
-               concat(IFNULL(od.processing_note,''), IFNULL(od.remarks,''))                       as remarks,
+               concat(IFNULL(od.processing_note, ''), IFNULL(od.remarks, '')) as remarks,
                od.other_columns,
-               round(ogd.child_width)                                       as width,
-               round(ogd.child_height)                                      as height,
+               round(ogd.child_width)                                         as width,
+               round(ogd.child_height)                                        as height,
                pd.separation,
                fc.technology_number
         from flow_card as fc
@@ -1126,8 +1162,10 @@
                  left join sd.order_detail as od on od.order_id = fc.order_id and od.order_number = fc.order_number
                  left join sd.product_detail as pd
                            on pd.prod_id = od.product_id and pd.glass_sort = ogd.technology_number
-                 left join flow_card_sort as fcs on fcs.process_id = fc.process_id and fcs.order_number = fc.order_number and fcs.technology_number = fc.technology_number
-            and fcs.process=#{process}
+                 left join flow_card_sort as fcs
+                           on fcs.process_id = fc.process_id and fcs.order_number = fc.order_number and
+                              fcs.technology_number = fc.technology_number
+                               and fcs.process = #{process}
         where fc.process_id = #{processId}
           and position(fc.technology_number in #{technologyNumber})
         group by fc.process_id, fc.order_number, fc.technology_number
@@ -1178,15 +1216,15 @@
 
     <select id="getDetailListRefund">
         select fc.order_number,
-               concat(round(ogd.child_width), "*", round(ogd.child_height)) as child_width,
-               (pl.patch_num)                                               as quantity,
-               round(ogd.total_area, 2)                                     as total_area,
+               concat(round(ogd.child_width), "*", round(ogd.child_height))   as child_width,
+               (pl.patch_num)                                                 as quantity,
+               round(ogd.total_area, 2)                                       as total_area,
                od.perimeter,
                od.bend_radius,
-               concat(IFNULL(od.processing_note,''), IFNULL(od.remarks,''))                       as remarks,
+               concat(IFNULL(od.processing_note, ''), IFNULL(od.remarks, '')) as remarks,
                od.other_columns,
-               round(ogd.child_width)                                       as width,
-               round(ogd.child_height)                                      as height,
+               round(ogd.child_width)                                         as width,
+               round(ogd.child_height)                                        as height,
                pd.separation,
                fc.technology_number
         from flow_card as fc
@@ -1224,7 +1262,7 @@
                dd.breakage_reason,
                dd.responsible_process,
                dd.responsible_team,
-               concat('瀵瑰簲鎴戝徃鍗曞彿',o.batch)                                         AS otherRemarks
+               concat('瀵瑰簲鎴戝徃鍗曞彿', o.batch)                 AS otherRemarks
         from flow_card as fc
                  left join sd.order_glass_detail as ogd
                            on fc.order_id = ogd.order_id and fc.order_number = ogd.order_number and
@@ -1259,15 +1297,15 @@
 
     <select id="getDetailListLikeRefund">
         select fc.order_number,
-               concat(round(ogd.child_width), "*", round(ogd.child_height)) as child_width,
-               pl.patch_num                                                 as quantity,
-               round(ogd.total_area, 2)                                     as total_area,
+               concat(round(ogd.child_width), "*", round(ogd.child_height))   as child_width,
+               pl.patch_num                                                   as quantity,
+               round(ogd.total_area, 2)                                       as total_area,
                od.perimeter,
                od.bend_radius,
-               concat(IFNULL(od.processing_note,''), IFNULL(od.remarks,''))                       as remarks,
+               concat(IFNULL(od.processing_note, ''), IFNULL(od.remarks, '')) as remarks,
                od.other_columns,
-               round(ogd.child_width)                                       as width,
-               round(ogd.child_height)                                      as height,
+               round(ogd.child_width)                                         as width,
+               round(ogd.child_height)                                        as height,
                pd.separation,
                fc.technology_number
         from flow_card as fc
@@ -1300,7 +1338,12 @@
                round(SUM(ogd.total_area), 2)                   as gross_area,
                sum(od.weight)                                  as weight,
                #{technologyNumber}                             as technologyNumber,
-               concat(fc.process_id, '/', #{technologyNumber}) as processIdNumber
+               concat(fc.process_id, '/', #{technologyNumber}) as processIdNumber,
+               dd.breakage_type,
+               dd.breakage_reason,
+               dd.responsible_process,
+               dd.responsible_team,
+               concat('瀵瑰簲鎴戝徃鍗曞彿', o.batch)                 AS otherRemarks
         from flow_card as fc
                  left join sd.order_glass_detail as ogd
                            on fc.order_id = ogd.order_id and fc.order_number = ogd.order_number and
@@ -1322,9 +1365,14 @@
                               ogdc.technology_number = ogd.technology_number
                  left join rework as pl on pl.process_id = fc.process_id and pl.order_sort = fc.order_number and
                                            pl.technology_number = fc.technology_number
+                 left join pp.reporting_work as rw on rw.order_id = fc.order_id and rw.process_id = fc.process_id
+                 left join pp.damage_details as dd
+                           on rw.reporting_work_id = dd.reporting_work_id and dd.order_number = fc.order_number and
+                              dd.technology_number = fc.technology_number
         where fc.process_id = #{processId}
           and fc.order_number = #{orderNumber}
           and fc.technology_number = #{technologyNumber}
+          and rw.reporting_work_id = #{reportingWorkId}
         group by fc.process_id, fc.technology_number
     </select>
 
@@ -1484,8 +1532,10 @@
                  left join sd.order_glass_detail ogd
                            on ogd.order_id = o.order_id and ogd.order_number = od.order_number and
                               ogd.technology_number = fc.technology_number
-                 left join flow_card_sort as fcs on fcs.process_id = fc.process_id and fcs.order_number = fc.order_number and fcs.technology_number = fc.technology_number
-            and fcs.process=#{process}
+                 left join flow_card_sort as fcs
+                           on fcs.process_id = fc.process_id and fcs.order_number = fc.order_number and
+                              fcs.technology_number = fc.technology_number
+                               and fcs.process = #{process}
         where fc.process_id = #{processId}
           and position(fc.technology_number in #{technologyNumber})
         group by od.order_number, ogd.technology_number, ogd.child_width, ogd.child_height
@@ -1702,127 +1752,127 @@
 
     <select id="selectPrintAllMp">
         select *
-        from ( (select fc.id,
-                       fc.order_id,
-                       fc.process_id,
-                       o.customer_name,
-                       o.project,
-                       ogd.technology_number,
-                       ogd.glass_address,
-                       sum(od.quantity)         as quantity,
-                       sum(ogd.total_area)      as total_area,
-                       od.product_name,
-                       ogd.glass_child,
-                       fc.founder,
-                       date(fc.splitFrame_time) as splitFrame_time,
-                    /* if(fc.print_status=0,'鏈墦鍗�','宸叉墦鍗�') as  print_status*/
-                       fc.print_status,
-                       ogd.process
-                from flow_card as fc
-                         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 = fc.order_id and od.order_number = fc.order_number
-                         left join sd.`order` as o on o.order_id = fc.order_id
-                where fc.order_id = #{orderId}
-                GROUP BY fc.process_id, ogd.technology_number
-                order by fc.process_id, ogd.technology_number)
+        from ((select fc.id,
+                      fc.order_id,
+                      fc.process_id,
+                      o.customer_name,
+                      o.project,
+                      ogd.technology_number,
+                      ogd.glass_address,
+                      sum(fc.quantity)                                                          as quantity,
+                      round(sum(ogd.child_width * ogd.child_height * fc.quantity / 1000000), 2) as total_area,
+                      od.product_name,
+                      ogd.glass_child,
+                      fc.founder,
+                      date(fc.splitFrame_time)                                                  as splitFrame_time,
+                   /* if(fc.print_status=0,'鏈墦鍗�','宸叉墦鍗�') as  print_status*/
+                      fc.print_status,
+                      ogd.process
+               from flow_card as fc
+                        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 = fc.order_id and od.order_number = fc.order_number
+                        left join sd.`order` as o on o.order_id = fc.order_id
+               where fc.order_id = #{orderId}
+               GROUP BY fc.process_id, ogd.technology_number
+               order by fc.process_id, ogd.technology_number)
 
-                 UNION
+              UNION
 
-                 (select fc.id,
-                         fc.order_id,
-                         fc.process_id,
-                         o.customer_name,
-                         o.project,
-                         ogdss.technology_number,
-                         ogd.glass_address,
-                         ROUND(sum(fc.quantity) / (count(DISTINCT fc.technology_number))) as quantity,
-                         sum(ogd.total_area)                                              as total_area,
-                         # SUM(ogd.child_width*child_height*fc.quantity/(count(DISTINCT ogd.technology_number))) as total_area,
-                         od.product_name,
-                         ogdss.concatenated_glass_child                                   as glass_child,
-                         fc.founder,
-                         date(fc.splitFrame_time)                                         as splitFrame_time,
-                         fc.print_status,
-                         processed_part                                                   as process
+              (select fc.id,
+                      fc.order_id,
+                      fc.process_id,
+                      o.customer_name,
+                      o.project,
+                      ogdss.technology_number,
+                      ogd.glass_address,
+                      ROUND(sum(fc.quantity) / (count(DISTINCT fc.technology_number))) as quantity,
+                      sum(ogd.total_area)                                              as total_area,
+                      # SUM(ogd.child_width*child_height*fc.quantity/(count(DISTINCT ogd.technology_number))) as total_area,
+                      od.product_name,
+                      ogdss.concatenated_glass_child                                   as glass_child,
+                      fc.founder,
+                      date(fc.splitFrame_time)                                         as splitFrame_time,
+                      fc.print_status,
+                      processed_part                                                   as process
 
-                  from flow_card as fc
-                           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 = fc.order_id and od.order_number = fc.order_number
-                           left join sd.`order` as o on o.order_id = fc.order_id
-                           left join (select ogds.order_id,
-                                             ogds.order_number,
-                                             GROUP_CONCAT(ogds.technology_number SEPARATOR '') AS technology_number,
-                                             ogds.glass_child,
-                                             GROUP_CONCAT(ogds.glass_child SEPARATOR ' ')      AS concatenated_glass_child,
-                                             SUBSTRING(process, LOCATE('澶硅兌', process))       AS processed_part
-                                      from sd.order_glass_detail as ogds
-                                      where ogds.order_id = #{orderId}
-                                        and LOCATE('澶硅兌', ogds.process) > 0
-                                      GROUP BY order_id, order_number, ogds.group) as ogdss
-                                     on fc.order_id = ogdss.order_id and ogdss.order_number = fc.order_number
-                  where fc.order_id = #{orderId}
-                  GROUP BY fc.process_id, ogdss.technology_number
-                  order by fc.process_id)
-                 UNION
-                 (select fc.id,
-                         fc.order_id,
-                         fc.process_id,
-                         o.customer_name,
-                         o.project,
-                         ogdss.technology_number,
-                         ogd.glass_address,
-                         ROUND(sum(fc.quantity) / (count(DISTINCT fc.technology_number))) as quantity,
-                         sum(ogd.total_area)                                              as total_area,
-                         od.product_name,
-                         ogdss.concatenated_glass_child                                   as glass_child,
-                         fc.founder,
-                         date(fc.splitFrame_time)                                         as splitFrame_time,
-                         fc.print_status,
-                         processed_part                                                   as process
+               from flow_card as fc
+                        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 = fc.order_id and od.order_number = fc.order_number
+                        left join sd.`order` as o on o.order_id = fc.order_id
+                        left join (select ogds.order_id,
+                                          ogds.order_number,
+                                          GROUP_CONCAT(ogds.technology_number SEPARATOR '') AS technology_number,
+                                          ogds.glass_child,
+                                          GROUP_CONCAT(ogds.glass_child SEPARATOR '+')      AS concatenated_glass_child,
+                                          SUBSTRING(process, LOCATE('澶硅兌', process))       AS processed_part
+                                   from sd.order_glass_detail as ogds
+                                   where ogds.order_id = #{orderId}
+                                     and LOCATE('澶硅兌', ogds.process) > 0
+                                   GROUP BY order_id, order_number, ogds.group) as ogdss
+                                  on fc.order_id = ogdss.order_id and ogdss.order_number = fc.order_number
+               where fc.order_id = #{orderId}
+               GROUP BY fc.process_id, ogdss.technology_number
+               order by fc.process_id)
+              UNION
+              (select fc.id,
+                      fc.order_id,
+                      fc.process_id,
+                      o.customer_name,
+                      o.project,
+                      ogdss.technology_number,
+                      ogd.glass_address,
+                      ROUND(sum(fc.quantity) / (count(DISTINCT fc.technology_number))) as quantity,
+                      sum(ogd.total_area)                                              as total_area,
+                      od.product_name,
+                      ogdss.concatenated_glass_child                                   as glass_child,
+                      fc.founder,
+                      date(fc.splitFrame_time)                                         as splitFrame_time,
+                      fc.print_status,
+                      processed_part                                                   as process
 
-                  from flow_card as fc
-                           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 = fc.order_id and od.order_number = fc.order_number
-                           left join sd.`order` as o on o.order_id = fc.order_id
-                           left join (select ogds.order_id,
-                                             ogds.order_number,
-                                             GROUP_CONCAT(pds.glass_sort SEPARATOR '')           AS technology_number,
-                                             ogds.glass_child,
-                                             GROUP_CONCAT(ogds.glass_child SEPARATOR ' ')        AS concatenated_glass_child,
-                                             SUBSTRING(pds.process, LOCATE('涓┖', pds.process)) AS processed_part
-                                      from sd.order_glass_detail as ogds
-                                               left join sd.order_detail as ods
-                                                         on ods.order_id = ogds.order_id and ods.order_number = ogds.order_number
-                                               left join sd.product_detail as pds on pds.prod_id = ods.product_id and
-                                                                                     pds.glass_sort =
-                                                                                     ogds.technology_number
-                                      where ogds.order_id = #{orderId}
-                                      GROUP BY order_id, order_number) as ogdss
-                                     on fc.order_id = ogdss.order_id and ogdss.order_number = fc.order_number
-                  where fc.order_id = #{orderId}
-                  GROUP BY fc.process_id
-                  order by fc.process_id)) AS combined_results
+               from flow_card as fc
+                        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 = fc.order_id and od.order_number = fc.order_number
+                        left join sd.`order` as o on o.order_id = fc.order_id
+                        left join (select ogds.order_id,
+                                          ogds.order_number,
+                                          GROUP_CONCAT(pds.glass_sort SEPARATOR '')           AS technology_number,
+                                          ogds.glass_child,
+                                          GROUP_CONCAT(ogds.glass_child SEPARATOR '+')        AS concatenated_glass_child,
+                                          SUBSTRING(pds.process, LOCATE('涓┖', pds.process)) AS processed_part
+                                   from sd.order_glass_detail as ogds
+                                            left join sd.order_detail as ods
+                                                      on ods.order_id = ogds.order_id and ods.order_number = ogds.order_number
+                                            left join sd.product_detail as pds on pds.prod_id = ods.product_id and
+                                                                                  pds.glass_sort =
+                                                                                  ogds.technology_number
+                                   where ogds.order_id = #{orderId}
+                                   GROUP BY order_id, order_number) as ogdss
+                                  on fc.order_id = ogdss.order_id and ogdss.order_number = fc.order_number
+               where fc.order_id = #{orderId}
+               GROUP BY fc.process_id
+               order by fc.process_id)) AS combined_results
         where process is not null
           and process != ""
-        GROUP BY order_id,process_id,technology_number,process
-        order by order_id,process_id,length(technology_number)
+        GROUP BY order_id, process_id, technology_number, process
+        order by order_id, process_id, length(technology_number)
     </select>
 
     <insert id="printAddSortMp">
-        insert into flow_card_sort (process_id,order_number,technology_number,process,sort,create_time)
-        values (#{processId},#{orderNumber},#{technologyNumber},#{process},#{sort},now())
+        insert into flow_card_sort (process_id, order_number, technology_number, process, sort, create_time)
+        values (#{processId}, #{orderNumber}, #{technologyNumber}, #{process}, #{sort}, now())
     </insert>
     <select id="printAddSortCountMp">
-        select
-        count(*)
+        select count(*)
         from flow_card_sort
         where process_id = #{processId}
           and order_number = #{orderNumber}
@@ -1852,7 +1902,8 @@
                sum(od.weight)                                  as weight,
                #{technologyNumber}                             as technologyNumber,
                concat(fc.process_id, '/', #{technologyNumber}) as processIdNumber,
-               concat('瀵瑰簲鎴戝徃鍗曞彿',o.batch)                                         AS otherRemarks
+               concat('瀵瑰簲鎴戝徃鍗曞彿', o.batch)                 AS otherRemarks,
+               fc.technology_number                            as qrcode
         from flow_card as fc
                  left join sd.order_glass_detail as ogd
                            on fc.order_id = ogd.order_id and fc.order_number = ogd.order_number and
@@ -1873,6 +1924,155 @@
                               ogdc.technology_number = ogd.technology_number
         where fc.process_id = #{processId}
           and position(fc.technology_number in #{technologyNumber})
-        group by fc.process_id limit 1
+        group by fc.process_id
+        limit 1
+    </select>
+
+    <select id="selectPrintDetailsMp">
+        select fc.id,
+               fc.order_id,
+               fc.process_id,
+               o.customer_name,
+               o.project,
+               ogd.technology_number,
+               ogd.glass_address,
+               (fc.quantity)                                                          as quantity,
+               round((ogd.child_width * ogd.child_height * fc.quantity / 1000000), 2) as total_area,
+               od.product_name,
+               ogd.glass_child,
+               fc.founder,
+               date(fc.splitFrame_time)                                               as splitFrame_time,
+            /* if(fc.print_status=0,'鏈墦鍗�','宸叉墦鍗�') as  print_status*/
+               fc.print_status,
+               ogd.process,
+               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01'))                  AS glassNumber,
+               od.order_number
+        from flow_card as fc
+                 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 = fc.order_id and od.order_number = fc.order_number
+                 left join sd.`order` as o on o.order_id = fc.order_id
+        where fc.order_id = #{orderId}
+        GROUP BY fc.process_id, od.order_number
+        order by fc.process_id, od.order_number
+    </select>
+
+    <select id="getPrintCustomDataDetails">
+        select o.order_id                                            as orderId,
+               project,
+               customer_id                                           as customerId,
+               o.customer_name                                       as customerName,
+               order_type                                            as orderType,
+               order_classify                                        as orderClassify,
+               batch,
+               o.icon,
+               pack_type                                             as packType,
+               delivery_date                                         as deliveryDate,
+               al_type                                               as alType,
+               money,
+               contract_id                                           as contractId,
+               customer_batch                                           customerBatch,
+               contacts,
+               delivery_address                                      as deliveryAddress,
+               od.processing_note                                    as processingNote,
+               width,
+               height,
+               od.quantity,
+               od.order_number                                       as orderNumber,
+               fc.technology_number                                  as technologyNumber,
+               od.building_number                                    as buildingNumber,
+               od.product_name                                       as productName,
+               od.edging_type                                        as edgingType,
+               p.remarks,
+               c.customer_abbreviation                               as customerAbbreviation,
+               p.product_abbreviation                                as productAbbreviation,
+               fc.process_id                                         as processId,
+               o.create_time                                         as createTime,
+               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')) AS glassNumber,
+               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S02')) AS figureNumber,
+               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S03')) AS colourCeramicGlaze,
+               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S04')) AS remarks1,
+               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S05')) AS remarks2,
+               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S06')) AS remarks3,
+               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S07')) AS remarks4,
+               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S08')) AS remarks5,
+               p.remarks                                             as filmNumber,
+               od.bend_radius                                        as bendRadius,
+               od.other_columns,
+               ogd.glass_child                                       as glassChild,
+               ogd.glass_address                                     as glassAddress,
+               JSON_UNQUOTE(JSON_EXTRACT(pd.separation, '$.color'))  AS color
+        from sd.order as o
+                 left join sd.order_detail as od on o.order_id = od.order_id
+                 left join flow_card as fc on o.order_id = fc.order_id and
+                                              od.order_number = fc.order_number
+                 left join sd.product as p on p.id = od.product_id
+                 left join sd.customer as c on c.id = o.customer_id
+                 left join sd.product_detail as pd on pd.prod_id = p.id and pd.sort_num = od.order_number and
+                                                      pd.glass_sort = fc.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
+        where fc.process_id = #{processId}
+          and fc.order_number = #{orderNumber}
+        group by fc.process_id, od.order_number, width, height
+        order by fc.process_id
+    </select>
+
+    <select id="selectUserMp">
+        select role_id
+        from erp_user_info.`user` as u
+                 left join erp_user_info.user_role as ur on u.id = ur.user_id
+        where u.login_name = #{userId}
+    </select>
+
+    <select id="selectSortTableMp">
+        select fcs.sort,
+               process_id,
+               fcs.order_number,
+               fcs.technology_number,
+               JSON_UNQUOTE(JSON_EXTRACT(od.other_columns, '$.S01')) AS glassNumber,
+               fcs.process
+        from flow_card_sort as fcs
+                 left join sd.order_detail as od
+                           on od.order_id = left(fcs.process_id, 10) and od.order_number = fcs.order_number
+        where LEFT(fcs.process_id, 10) = #{orderId}
+        GROUP BY process_id,
+                 fcs.order_number,
+                 fcs.technology_number,
+                 fcs.process
+        ORDER BY fcs.sort,process_id,
+                 fcs.order_number,
+                 fcs.technology_number
+    </select>
+
+    <select id="countFlowCard">
+        select count(distinct process_id) from flow_card where order_id = #{orderId}
+    </select>
+
+    <select id="remakList">
+        SELECT
+            JSON_UNQUOTE(JSON_EXTRACT(other_columns, '$.S01')) AS S01,
+            JSON_UNQUOTE(JSON_EXTRACT(other_columns, '$.S04')) AS S02,
+            JSON_UNQUOTE(JSON_EXTRACT(other_columns, '$.S05')) AS S03,
+            JSON_UNQUOTE(JSON_EXTRACT(other_columns, '$.S06')) AS S04,
+            JSON_UNQUOTE(JSON_EXTRACT(other_columns, '$.S07')) AS S05
+        FROM flow_card as fc left join sd.order_detail as od on  fc.order_id = od.order_id
+        and fc.order_number = od.order_number
+        WHERE fc.process_id=#{processId}
+        GROUP BY fc.order_number
+    </select>
+
+    <select id="selectMaxFlowCard">
+        select ifnull((select fc.process_id
+                       from sd.order_detail as od
+                                left join sd.order_glass_detail as ogd
+                                          on od.order_id = ogd.order_id and od.order_number = ogd.order_number
+                                left join flow_card as fc on fc.order_id=od.order_id and fc.order_number=od.order_number and fc.technology_number=ogd.technology_number
+                       where od.order_id = #{orderId}
+                         and ogd.production_id = #{productionId}
+                       GROUP BY od.order_number
+                       order by fc.process_id desc LIMIT 1),'') as process_id
     </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0