From b9e4e2edbb3767ee347a91d2238544ae736b53c0 Mon Sep 17 00:00:00 2001
From: chenlu <1320612696@qq.com>
Date: 星期二, 22 七月 2025 10:29:27 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10105/r/ERP_override

---
 north-glass-erp/src/main/resources/mapper/pp/GlassOptimize.xml |  654 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 601 insertions(+), 53 deletions(-)

diff --git a/north-glass-erp/src/main/resources/mapper/pp/GlassOptimize.xml b/north-glass-erp/src/main/resources/mapper/pp/GlassOptimize.xml
index e26a46c..afbd97d 100644
--- a/north-glass-erp/src/main/resources/mapper/pp/GlassOptimize.xml
+++ b/north-glass-erp/src/main/resources/mapper/pp/GlassOptimize.xml
@@ -41,6 +41,8 @@
         <result property="thickness" column="thickness"/>
         <result property="type" column="type"/>
         <result property="state" column="state"/>
+        <result property="temperingState" column="Tempering state"/>
+        <result property="optimizeState" column="Optimize state"/>
         <result property="quantity" column="quantity"/>
         <result property="area" column="area"/>
         <result property="processCardQuantity" column="process Card Quantity"/>
@@ -93,37 +95,45 @@
 
     <!--绗竴娆′紭鍖栨煡璇�-->
     <select id="firstOptimization">
-        ( SELECT
-              c.project_no,
-              d.child_width as 'width',
-              d.child_height as 'height',
-              c.quantity,
-              o.shape,
-              concat( c.process_id, '-', c.technology_number ) AS 'process_id',
-              c.technology_number,
-              d.glass_child,
-              o.product_name,
-              o.price,
-              o.remarks,
-              o.building_number,
-              round( d.area * c.quantity, 4 ) as 'area',
-              c.order_number,
-              d.icon,
-              op.project_name
-          FROM
-              pp.flow_card c
-                  LEFT JOIN sd.order_detail o ON c.order_id = o.order_id
-                  AND c.order_number = o.order_number
-                  LEFT JOIN sd.order_glass_detail d ON c.order_id = d.order_id
-                  AND c.order_number = d.order_number
-                  AND c.technology_number = d.technology_number
-                  INNER JOIN pp.optimize_project AS op ON op.project_no = c.project_no
-          WHERE
-              c.project_no IS NOT NULL
-            and c.project_no = #{projectNo}
-          ORDER BY
-              c.process_id,
-              c.order_number
+        (SELECT
+             c.project_no,
+             d.child_width as 'width',
+             d.child_height as 'height',
+             c.quantity,
+             o.shape,
+             concat( c.process_id, '-', c.technology_number ) AS 'process_id',
+             c.process_id AS 'process_ids',
+             c.technology_number as layer,
+             c.layers_number as total_layer,
+             d.glass_child,
+             o.product_name,
+             o.price,
+             o.remarks,
+             o.building_number,
+             round( d.area * c.quantity, 4 ) as 'area',
+             c.order_number,
+             d.icon,
+             op.project_name,
+             0 as patch_state,
+             a.id as rackNo
+         FROM
+             pp.flow_card c
+                 LEFT JOIN sd.order_detail o ON c.order_id = o.order_id
+                 AND c.order_number = o.order_number
+                 LEFT JOIN sd.order_glass_detail d ON c.order_id = d.order_id
+                 AND c.order_number = d.order_number
+                 AND c.technology_number = d.technology_number
+                 INNER JOIN pp.optimize_project AS op ON op.project_no = c.project_no
+                 left join
+             (select (@row_number := @row_number + 1) as id,process_id as process_id,technology_number as technology_number from (select process_id,technology_number from pp.flow_card tt where project_no =#{projectNo} group by process_id,technology_number) tt,(select @row_number := 0) as t) a
+             on a.process_id=c.process_id and a.technology_number=c.technology_number
+         WHERE
+             c.project_no IS NOT NULL
+           and c.project_no = #{projectNo}
+         ORDER BY
+             a.id,
+             c.process_id,
+             c.order_number
         ) union
         (
             SELECT
@@ -133,7 +143,9 @@
                 c.patch_num as quantity,
                 o.shape,
                 concat( c.process_id, '-', c.technology_number ) AS 'process_id',
-                c.technology_number,
+                c.process_id AS 'process_ids',
+                c.technology_number as layer,
+                fc.layers_number as total_layer,
                 d.glass_child,
                 o.product_name,
                 o.price,
@@ -142,7 +154,9 @@
                 round( d.area * c.patch_num, 4 ) as 'area',
                 c.order_sort as order_number,
                 d.icon,
-                op.project_name
+                op.project_name,
+                1 as patch_state,
+                a.id as rackNo
             FROM
                 pp.patch_log c
                     LEFT JOIN sd.order_detail o ON c.order_id = o.order_id
@@ -151,26 +165,33 @@
                     AND c.order_sort = d.order_number
                     AND c.technology_number = d.technology_number
                     INNER JOIN pp.optimize_project AS op ON op.project_no = c.project_no
+                    LEFT JOIN pp.flow_card fc ON c.process_id = fc.process_id and fc.technology_number=c.technology_number
+                    left join
+                    (select (@row_number := @row_number + 1) as id,process_id as process_id,technology_number as technology_number from (select process_id,technology_number from pp.flow_card tt where project_no =#{projectNo} group by process_id,technology_number) tt,(select @row_number := 0) as t) a
+            on a.process_id=c.process_id and a.technology_number=c.technology_number
             WHERE
                 c.project_no IS NOT NULL
               and c.project_no = #{projectNo}
             ORDER BY
+                a.id,
                 c.process_id,
                 c.order_sort)
     </select>
 
 
-    <!--绗竴娆′紭鍖栨煡璇�-->
+    <!--浼樺寲鏌ヨ-->
     <select id="analogComputationOptimization">
         SELECT
             h.project_no,
-            h.layout_id,
+            h.layout_id as rackNo,
             h.width AS width,
             h.height AS height,
             count( 1 ) AS quantity,
             o.shape,
             concat( h.process_id, '-', h.layer ) AS 'process_id',
+            h.process_id as process_ids,
             h.layer,
+            c.layers_number as total_layer,
             d.glass_child,
             o.product_name,
             o.price,
@@ -179,7 +200,8 @@
             round( d.area * count( 1 ), 4 ) AS 'area',
             c.order_number,
             d.icon,
-            o.price
+            o.price,
+            h.patch_state
         from
             pp.`optimize_heat_detail` h
                 LEFT JOIN pp.flow_card c ON h.process_id = c.process_id
@@ -217,13 +239,64 @@
             h.layout_id;
     </select>
 
+
+    <select id="getOptimizeDetail">
+        SELECT
+            h.project_no,
+            h.heat_layout_id as rackNo,
+            h.o_width AS width,
+            h.o_height AS height,
+            (h.height-h.o_height)/2 as shortGrind1,
+            (h.height-h.o_height)/2 as shortGrind2,
+            (h.width-h.o_width)/2 as longGrind2,
+            (h.width-h.o_width)/2  as longGrind1,
+            count( 1 ) AS quantity,
+            o.shape,
+            concat( h.process_id, '-', h.layer ) AS 'process_id',
+            h.process_id as process_ids,
+            h.layer,
+            h.total_layer as total_layer,
+            d.glass_child,
+            o.product_name,
+            o.price,
+            o.remarks,
+            o.building_number,
+            round( d.area * count( 1 ), 4 ) AS 'area',
+            c.order_number,
+            d.icon,
+            o.price,
+            h.patch_state
+        from
+            pp.`optimize_detail` h
+                LEFT JOIN pp.flow_card c ON h.process_id = c.process_id
+                AND h.layer = c.technology_number
+                AND h.order_sort = c.order_number
+                LEFT JOIN sd.order_detail o ON c.order_id = o.order_id
+                AND c.order_number = o.order_number
+                LEFT JOIN sd.order_glass_detail d ON c.order_id = d.order_id
+                AND c.order_number = d.order_number
+                AND c.technology_number = d.technology_number
+        WHERE
+            h.project_no =#{projectNo}
+        GROUP BY
+            h.project_no,
+            h.heat_layout_id,
+            h.width,
+            h.height,
+            h.process_id,
+            h.layer,
+            c.order_number
+        ORDER BY
+            h.heat_layout_id;
+    </select>
+
     <!--宸ョ▼淇℃伅娴佺▼鍗�-->
     <select id="getProcessCardMp">
         SELECT
             fc.process_id,
             fc.order_number,
             fc.quantity,
-            CONCAT(fc.technology_number, '/', COUNT(fc.technology_number)) AS layer,
+            CONCAT(fc.technology_number, '/', COUNT(fc.layers_number)) AS layer,
             so.project,
             CONCAT(sd.child_width, ' 脳 ', sd.child_height) AS sizes
         FROM
@@ -263,6 +336,8 @@
             i.id AS id,
             i.producer AS producer,
             i.available_quantity-i.plan_quantity AS available_quantity,
+            null as processingQuantity,
+            1 as materialType,
             JSON_EXTRACT(s.json, '$.width') AS width,
             JSON_EXTRACT(s.json, '$.height') AS height,
             JSON_EXTRACT(s.json, '$.thickness') AS thickness,
@@ -284,6 +359,73 @@
                 )
         ORDER BY
             `i`.`available_quantity` DESC ;
+    </select>
+
+    <!--浣欐枡淇℃伅-->
+    <select id="surplusMaterialsMp">
+        SELECT
+            i.id AS id,
+            '' AS producer,
+            i.quantity AS available_quantity,
+            null as processingQuantity,
+            0 as materialType,
+            i.width,
+            i.height,
+            i.thickness,
+            i.colour AS name,
+            i.colour
+        FROM  mm.surplus_materials as i
+        WHERE
+            i.quantity>0 and i.colour=#{model} and i.thickness=#{thickness}
+        ORDER BY
+            i.quantity DESC ;
+    </select>
+
+    <!--搴撳瓨浣欐枡淇℃伅-->
+    <select id="materialStoreSurplusMp">
+        (SELECT
+            i.id AS id,
+            i.producer AS producer,
+            i.available_quantity-i.plan_quantity AS available_quantity,
+            null as processingQuantity,
+            1 as materialType,
+            JSON_EXTRACT(s.json, '$.width') AS width,
+            JSON_EXTRACT(s.json, '$.height') AS height,
+            JSON_EXTRACT(s.json, '$.thickness') AS thickness,
+            JSON_EXTRACT(s.json, '$.name') AS name,
+            JSON_EXTRACT(s.json, '$.model') AS model
+        FROM  mm.material_inventory as `i`
+                  LEFT JOIN  mm.material_store  as s ON (
+            (
+                `i`.`material_code` = `s`.`id`
+                )
+            )
+        WHERE
+            (
+                    (`s`.`type` = '鍘熺墖')
+                    AND (`i`.`optimize_state` = 1)
+                    AND (`i`.`available_quantity`-i.plan_quantity > 0)
+                    AND JSON_EXTRACT(s.json, '$.thickness') = #{thickness}
+                    AND JSON_EXTRACT(s.json, '$.model') = #{model}
+                )
+        ORDER BY
+            `i`.`available_quantity` DESC) union
+        (SELECT
+            i.id AS id,
+            '' AS producer,
+            i.quantity AS available_quantity,
+            null as processingQuantity,
+            0 as materialType,
+            i.width,
+            i.height,
+            i.thickness,
+            i.colour AS name,
+            i.colour
+        FROM  mm.surplus_materials as i
+        WHERE
+            i.quantity>0 and i.colour=#{model} and i.thickness=#{thickness}
+        ORDER BY
+            i.quantity DESC );
     </select>
 
 
@@ -403,7 +545,7 @@
                鏁伴噺 as quantity,
                褰㈢姸 as shape,
                椤圭洰 as project,
-               鍗曠墖鍚嶇О as glass_child,
+               浜у搧鍚嶇О as glass_child,
                闈㈢Н as area,
                GlassType as glassType,
                patch_state
@@ -419,7 +561,7 @@
                鏁伴噺 as quantity,
                褰㈢姸 as shape,
                椤圭洰 as project,
-               鍗曠墖鍚嶇О as glass_child,
+               浜у搧鍚嶇О as glass_child,
                闈㈢Н as area,
                GlassType as glassType,
                patch_state
@@ -435,7 +577,7 @@
                鏁伴噺 as quantity,
                褰㈢姸 as shape,
                椤圭洰 as project,
-               鍗曠墖鍚嶇О as glass_child,
+               浜у搧鍚嶇О as glass_child,
                闈㈢Н as area,
                GlassType as glassType,
                patch_state
@@ -470,6 +612,8 @@
                p.`glass_thickness`                   AS `Thickness`,
                p.`type`                              AS `Type`,
                p.`state`                             AS `State`,
+               p.`tempering_state`                    AS `Tempering state`,
+               p.`optimize_state`                     AS `Optimize state`,
                p.`glass_total`                       AS `Quantity`,
                p.`glass_total_area`                  AS `Area`,
                p.`process_qty`                       AS `Process Card Quantity`,
@@ -488,7 +632,8 @@
                `p`.`update_time`                     AS `Modify time`
         from pp.optimize_project as p
                  left join pp.optimize_admin as a on p.creater = a.Id
-        where (`p`.`state` > 1)
+        where (`p`.`state` > 0)
+            and (tempering_state>0 or optimize_state>0)
             and DATE (`p`.`create_time`) BETWEEN #{startSelectTime} AND #{endSelectTime}
         <if test="optimizeProjectMange.projectNumber != null and optimizeProjectMange.projectNumber != ''">
             and p.project_no regexp #{optimizeProjectMange.projectNumber}
@@ -502,6 +647,20 @@
     <update id="updateProjectStateMp">
         update pp.optimize_project as p
         set p.state = #{state}
+        where p.project_no = #{projectNumber}
+    </update>
+
+    <!--淇敼妯℃嫙璁$畻宸ョ▼鐘舵��-->
+    <update id="updateProjectTemperingStateMp">
+        update pp.optimize_project as p
+        set p.tempering_state = #{states}
+        where p.project_no = #{projectNumber}
+    </update>
+
+    <!--淇敼浼樺寲宸ョ▼鐘舵��-->
+    <update id="updateProjectOptimizeStateMp">
+        update pp.optimize_project as p
+        set p.optimize_state = #{states}
         where p.project_no = #{projectNumber}
     </update>
 
@@ -526,6 +685,32 @@
         where project_no = #{projectNumber}
     </delete>
 
+    <delete id="deleteOptimizeLayout">
+        delete from pp.optimize_layout
+        where project_no = #{projectNumber}
+    </delete>
+
+    <delete id="deleteOptimizeProjectFile">
+        delete from pp.optimize_project_file
+        where project_no = #{projectNumber}
+    </delete>
+
+    <update id="updateOptimizeUse">
+        update pp.optimize_use set state=0
+        where project_no = #{projectNumber}
+    </update>
+
+    <select id="selectOptimizeDetailById">
+        select * from pp.optimize_detail
+        where project_no = #{projectNumber} and process_id= #{processId} and layer= #{layer} and order_sort= #{orderSort}
+          and heat_layout_id is null limit 0,1;
+    </select>
+
+    <select id="selectOptimizeHeatDetail">
+        select * from pp.optimize_heat_detail
+        where project_no = #{projectNumber}
+    </select>
+
     <select id="getProjectListMp">
         SELECT
             p.id,
@@ -542,7 +727,8 @@
             p.remark,
             a.name,
             p.create_time,
-            p.update_time
+            p.update_time,
+            p.optimize_state
         FROM
             (
                 pp.optimize_project p
@@ -550,7 +736,7 @@
                     p.creater = a.Id
                     )))
         WHERE
-            ( p.state = 1 )
+            ( p.state = 1 ) and p.tempering_state=0 and optimize_state=0
         ORDER BY
             p.create_time DESC,
             p.project_no
@@ -644,6 +830,7 @@
                  `g`.`area`,
                  `g`.`icon`
     </select>
+
 
     <select id="selectComputeDetailMpPatchState">
         select `l`.`order_id`                           AS order_id,
@@ -772,6 +959,13 @@
         group by process_id,technology_number
     </select>
 
+    <select id="selectPatchLogState">
+        select
+            count(*)
+        from pp.patch_log
+        where process_id=#{processId} and technology_number=#{technologyNumber} and order_sort=#{orderNumber} and project_no=#{projectNo}
+    </select>
+
     <update id="updateProjectMp">
         update pp.optimize_project set project_name=#{projectNmae},glass_total=#{sumQuantity},glass_total_area= #{sumArea},
                                        type=#{type},process_qty=#{processIdCount},process_cards=#{processId} where project_no=#{projectId}
@@ -786,7 +980,7 @@
 
 
     <insert id="addSimulation" parameterType="map">
-        <foreach collection="projectdetail.data[0].glass_details" item="glass">
+        <foreach collection="projectdetail" item="glass">
             INSERT INTO pp.optimize_heat_detail (
             project_no,
             process_id,
@@ -832,9 +1026,56 @@
             );
         </foreach>
     </insert>
+
+    <insert id="insertOptimizeHeatDetail">
+            INSERT INTO pp.optimize_heat_detail (
+            project_no,
+            process_id,
+            width,
+            height,
+            x_axis,
+            y_axis,
+            rotate_angle,
+            creater,
+            create_time,
+            update_time,
+            patch_state,
+            layer,
+            order_sort,
+            layout_id,
+            sort,
+            glass_id,
+            pair_width,
+            pair_height,
+            intRemark,
+            strRemark
+            ) VALUES (
+            #{projectId},
+            #{processId},
+            #{width},
+            #{height},
+            0,
+            0,
+            0,
+            #{username},
+            NOW(),
+            NOW(),
+            #{patchState},
+            #{technologyNumber},
+            #{orderNumber},
+            0,
+            #{index},
+            null,
+            #{width},
+            #{height},
+            null,
+            null
+            );
+    </insert>
+
     <!--妯℃嫙璁$畻缁撴灉淇濆瓨-->
     <insert id="addratioResult" parameterType="map">
-        <foreach collection="projectdetail.data[0].ratioResult" item="glass">
+        <foreach collection="ratioResult" item="glass">
             INSERT INTO pp.optimize_heat_layout (
             project_no,
             layout_id,
@@ -859,11 +1100,142 @@
         </foreach>
     </insert>
 
+    <!--浼樺寲灏忕墖淇濆瓨-->
+    <insert id="addOptimizeDetail" parameterType="map">
+        <foreach collection="object" item="glass">
+            INSERT INTO pp.optimize_detail (
+            project_no,
+            process_id,
+            layer,
+            total_layer,
+            order_sort,
+            stock_id,
+            polys_id,
+            o_width,
+            o_height,
+            width,
+            height,
+            x_axis,
+            y_axis,
+            patch_state,
+            mark_icon
+            ) VALUES (
+            #{projectId},
+            #{glass.processId},
+            #{glass.layer},
+            #{glass.totalLayer},
+            #{glass.orderSort},
+            #{glass.stockSort},
+            #{glass.polySort},
+            #{glass.realWidth},
+            #{glass.realHeight},
+            #{glass.width},
+            #{glass.height},
+            #{glass.x},
+            #{glass.y},
+            #{glass.patchState},
+            #{glass.markIcon}
+            );
+        </foreach>
+    </insert>
+
+    <!--浼樺寲缁撴灉json鏍煎紡淇濆瓨-->
+    <insert id="addOptimizeProjectFile" >
+            INSERT INTO pp.optimize_project_file (
+            project_no,
+            type,
+            content,
+            create_time,
+            creater
+            ) VALUES (
+            #{projectId},
+            "浼樺寲缁撴灉",
+            #{object},
+            now(),
+            #{name}
+            );
+    </insert>
+
+    <!--浼樺寲鍘熺墖淇濆瓨-->
+    <insert id="addOptimizeLayout" parameterType="map">
+        <foreach collection="object " item="glass">
+            INSERT INTO pp.optimize_layout (
+            project_no,
+            stock_id,
+            width,
+            height,
+            usage_rate,
+            stock_code,
+            up_trim,
+            down_trim,
+            left_trim,
+            right_trim,
+            glass_count,
+            glass_area,
+            create_time
+            ) VALUES (
+            #{projectId},
+            #{glass.stockId},
+            #{glass.width},
+            #{glass.height},
+            #{glass.usageRate},
+            #{glass.stockCode},
+            #{glass.upTrim},
+            #{glass.downTrim},
+            #{glass.leftTrim},
+            #{glass.rightTrim},
+            #{glass.glassCount},
+            #{glass.glassArea},
+            now()
+            );
+        </foreach>
+    </insert>
+
+    <!--浼樺寲鍘熺墖淇濆瓨-->
+    <insert id="addOptimizeUse" parameterType="map">
+        <foreach collection="object " item="glass">
+            INSERT INTO pp.optimize_use (
+            project_no,
+            raw_stock_code,
+            type,
+            width,
+            height,
+            use_count,
+            not_use_count,
+            state,
+            left_trim,
+            down_trim,
+            right_trim,
+            up_trim,
+            creater,
+            create_time
+            ) VALUES (
+            #{projectId},
+            #{glass.stockCode},
+                      1,
+            #{glass.width},
+            #{glass.height},
+            #{glass.count},
+            #{glass.count},
+                      1,
+            #{glass.leftTrim},
+            #{glass.downTrim},
+            #{glass.rightTrim},
+            #{glass.upTrim},
+            #{name},
+            now()
+            );
+        </foreach>
+    </insert>
+
+
     <!--妯℃嫙璁$畻宸ョ▼鏇存柊-->
     <update id="addratioProjectResult" parameterType="map">
         UPDATE pp.optimize_project
         SET
-            state = 10,
+            tempering_state = 1,
+            furnaces_qty=#{resultSum[0]},
+            load_rate=#{resultSum[1]},
             chaos_pct = #{inputValues.chaos_pct},
             max_load_pct = #{inputValues.max_load_pct},
             max_area=#{inputValues.max_area},
@@ -871,22 +1243,28 @@
             load_width=#{inputValues.load_width},
             load_length=#{inputValues.load_length},
             x_space=#{inputValues.x_space},
-            y_space=#{inputValues.y_space},
-            load_rate=#{inputValues.load_rate}
+            y_space=#{inputValues.y_space}
         WHERE
             project_no = #{inputValues.project_no}
 
     </update>
+
 <!--浼樺寲璁剧疆淇濆瓨-->
     <update id="optimizeParmsSave">
         update erp_user_info.user as u
-        set u.optimize_parms = #{jsonString}
+        set u.optimize_parms = #{jsonString} where user_name=#{username}
     </update>
 
     <update id="updateOptimizeResult">
         update pp.optimize_project_file as u
         set u.content = #{jsonString}
         where  u.project_no=#{processId} and type='浼樺寲缁撴灉'
+    </update>
+
+    <update id="updateOptimizeDetail">
+        update pp.optimize_detail
+        set heat_layout_id=#{layoutId},heat_layout_sort=#{sort},glass_id=concat(process_id,'|',#{layoutId},'|',#{sort})
+        where id=#{id};
     </update>
 
 
@@ -905,7 +1283,7 @@
                JSON_EXTRACT( oc.config_detail, '$.load_length' ) as load_length,
                JSON_EXTRACT( oc.config_detail, '$.x_space' ) as x_space,
                JSON_EXTRACT( oc.config_detail, '$.y_space' ) as y_space
-        from pp.optimize_admin oa left join pp.optimize_config oc on oa.h_id=oc.id where name='admin'
+        from pp.optimize_admin oa where config_type=1 and creater=#{username}
     </select>
 
     <select id="getEdgeTrimming">
@@ -915,7 +1293,7 @@
                JSON_EXTRACT( oc.config_detail, '$.down_trim' ) as downTrim,
                JSON_EXTRACT( oc.config_detail, '$.auto_fill_trim' ) as autoFillTrim,
                JSON_EXTRACT( oc.config_detail, '$.quick_trim' ) as quickTrim
-        from  pp.optimize_config oc where config_type=5
+        from  pp.optimize_config oc where config_type=5 and creater=#{username}
     </select>
 
     <select id="getGrindingTrimming">
@@ -926,11 +1304,181 @@
                JSON_EXTRACT( oc.config_detail, '$.auto_fill_edge' ) as autoFillEdge,
                JSON_EXTRACT( oc.config_detail, '$.quick_edge' ) as quickEdge,
                 JSON_EXTRACT( oc.config_detail, '$.min_auto_lenght' ) as minAutoLenght
-        from  pp.optimize_config oc where config_type=4
+        from  pp.optimize_config oc where config_type=4 and creater=#{username}
     </select>
 
     <update id="updateOptimizeConfig">
         UPDATE pp.optimize_config set config_detail=#{json},create_time=now()
-        where config_type=#{type}
+        where config_type=#{type} and creater=#{username}
     </update>
+
+    <select id="simulatedTypesettingUsingOpt">
+        SELECT
+              c.project_no,
+              d.child_width as 'width',
+              d.child_height as 'height',
+              c.quantity,
+              o.shape,
+              concat( c.process_id, '-', c.technology_number ) AS 'process_id',
+              c.technology_number,
+              d.glass_child,
+              o.product_name,
+              o.price,
+              o.remarks,
+              o.building_number,
+              round( d.area * c.quantity, 4 ) as 'area',
+              c.order_number,
+              d.icon,
+              op.project_name
+          FROM
+              pp.flow_card c
+                  LEFT JOIN sd.order_detail o ON c.order_id = o.order_id
+                  AND c.order_number = o.order_number
+                  LEFT JOIN sd.order_glass_detail d ON c.order_id = d.order_id
+                  AND c.order_number = d.order_number
+                  AND c.technology_number = d.technology_number
+                  INNER JOIN pp.optimize_project AS op ON op.project_no = c.project_no
+          WHERE
+              c.project_no IS NOT NULL
+            and c.process_id IN
+            <foreach item="item" index="index" collection="processId" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+            and c.technology_number IN
+            <foreach item="item" index="index" collection="technologyNumber" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+          ORDER BY
+              c.process_id,
+              c.order_number
+    </select>
+
+    <select id="getFlowCardListSimulated">
+        SELECT 娴佺▼鍗″彿 as process_id,
+               灞� as technology_number,
+               鎬诲眰鏁� as TotalFloors,
+               瑙勬牸 as TotalNumber,
+               鏁伴噺 as quantity,
+               褰㈢姸 as shape,
+               椤圭洰 as project,
+               浜у搧鍚嶇О as glass_child,
+               闈㈢Н as area,
+               GlassType as glassType,
+               patch_state
+        FROM pp.v_optimize_process_normal where
+                CONCAT( JSON_UNQUOTE( JSON_EXTRACT( GlassType, '$.thickness' )), JSON_UNQUOTE( JSON_EXTRACT( GlassType, '$.color' )) )= #{optionVal}
+        order by deliveryDate desc
+    </select>
+
+
+
+
+
+
+
+    <!--妯℃嫙璁$畻鏌ヨ娴佺▼鍗$涓夋柟-->
+    <select id="selectProjectComputeMpThirdParty">
+        select
+            process_id as processId,
+            layer as technologyNumber,
+            total_layer as total_layers,
+            filmsid as TotalNumber,
+            sum(glass_total) as total_num,
+            product_name as glass_child,
+            0 as tempering,
+            0 as allow_rotate,
+            0 as curtain_wall,
+            0 as priority_level,
+            1 as is_must
+        from pp.other_flow_card where project_no = #{projectNo} group by process_id,layer
+    </select>
+
+    <!--妯℃嫙璁$畻娴佺▼鍗¤鎯呯涓夋柟-->
+    <select id="selectComputeDetailMpThirdParty">
+        select
+            process_id as process_id,
+            width as width,
+            height as height,
+            width as maxwidth,
+            height as maxheight,
+            order_number as order_number,
+            glass_total as quantity,
+            layer as technology_number,
+            0 as patch_state
+        from pp.other_flow_card where process_id = #{processId} and layer=#{technologyNumber}
+    </select>
+
+    <!--绗竴娆′紭鍖栨煡璇�-->
+    <select id="firstOptimizationThirdParty">
+        select
+            project_no,
+            concat( process_id, '-', layer ) AS process_id,
+            width,
+            height,
+            layer,
+            glass_total as quantity,
+            product_name,
+            order_number
+        from pp.other_flow_card where project_no = #{projectNo}
+    </select>
+
+    <select id="analogComputationOptimizationThirdParty">
+        SELECT
+            h.project_no,
+            h.layout_id,
+            h.width AS width,
+            h.height AS height,
+            count( 1 ) AS quantity,
+            concat( h.process_id, '-', h.layer ) AS 'process_id',
+            h.layer,
+            c.order_number
+        from
+            pp.`optimize_heat_detail` h
+                LEFT JOIN pp.other_flow_card c ON h.process_id = c.process_id
+                AND h.layer = c.technology_number
+                AND h.order_sort = c.order_number
+        WHERE
+            h.project_no = #{projectNo}
+        GROUP BY
+            h.project_no,
+            h.layout_id,
+            h.width,
+            h.height,
+            h.process_id,
+            h.layer,
+            c.quantity,
+            c.order_number
+        ORDER BY
+            LENGTH( h.layout_id ),
+            h.layout_id;
+    </select>
+
+    <!--宸ョ▼淇℃伅娴佺▼鍗�-->
+    <select id="getProcessCardMpThirdParty">
+        SELECT
+            fc.process_id,
+            fc.order_number,
+            fc.glass_total as quantity,
+            CONCAT(fc.layer, '/', COUNT(fc.total_layer)) AS layer,
+            CONCAT(fc.width, ' 脳 ', fc.height) AS sizes
+        FROM
+            pp.other_flow_card AS fc
+        WHERE
+            fc.project_no = #{projectNo}
+        GROUP BY
+            fc.layer,
+            fc.order_number
+    </select>
+
+    <delete id="deleteOptimizeDetailThirdParty">
+        delete from pp.other_flow_card
+        where project_no = #{projectNumber}
+    </delete>
+
+
+
+
+
+
+
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0