From 413a7e27886bcc87bbd8aaf995f09dbe82cb17e7 Mon Sep 17 00:00:00 2001
From: guoyujie <guoyujie@ng.com>
Date: 星期二, 06 五月 2025 14:56:08 +0800
Subject: [PATCH] Merge branch 'master' of http://bore.pub:10439/r/ERP_override

---
 north-glass-erp/src/main/resources/mapper/pp/GlassOptimize.xml |  242 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 237 insertions(+), 5 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..f6f616d 100644
--- a/north-glass-erp/src/main/resources/mapper/pp/GlassOptimize.xml
+++ b/north-glass-erp/src/main/resources/mapper/pp/GlassOptimize.xml
@@ -223,7 +223,7 @@
             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
@@ -284,6 +284,67 @@
                 )
         ORDER BY
             `i`.`available_quantity` DESC ;
+    </select>
+
+    <!--浣欐枡淇℃伅-->
+    <select id="surplusMaterialsMp">
+        SELECT
+            i.id AS id,
+            '' AS producer,
+            i.quantity AS available_quantity,
+            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,
+            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,
+            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>
 
 
@@ -525,6 +586,17 @@
         delete from pp.optimize_detail
         where project_no = #{projectNumber}
     </delete>
+
+    <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
@@ -786,7 +858,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,
@@ -834,7 +906,7 @@
     </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,
@@ -864,6 +936,8 @@
         UPDATE pp.optimize_project
         SET
             state = 10,
+            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,8 +945,7 @@
             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}
 
@@ -887,6 +960,12 @@
         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>
 
 
@@ -933,4 +1012,157 @@
         UPDATE pp.optimize_config set config_detail=#{json},create_time=now()
         where config_type=#{type}
     </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="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