From ada06626c3f81258e01837d09a10135f8ec3232f Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期六, 28 三月 2026 16:06:30 +0800
Subject: [PATCH] refactor: 生产报工参数与投入表分离

---
 src/main/resources/mapper/production/ProductOrderMapper.xml |   78 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/src/main/resources/mapper/production/ProductOrderMapper.xml b/src/main/resources/mapper/production/ProductOrderMapper.xml
index 4cd3372..5f8d566 100644
--- a/src/main/resources/mapper/production/ProductOrderMapper.xml
+++ b/src/main/resources/mapper/production/ProductOrderMapper.xml
@@ -151,4 +151,82 @@
         ORDER BY pp.apply_no
 
     </select>
+    <select id="finishedPage" resultType="com.ruoyi.quality.dto.FinishedPageDto">
+        select * from
+            (select po.id productOrderId,
+                    po.status,
+                    po.nps_no,
+                    sku.material_code,
+                    pm.product_name,
+                    sku.model,
+                    po.strength,
+                    po.quantity needQuantity,
+                    sum(ppo.quantity) qualifiedQuantity,
+                    sum(ppo.scrap_qty) unqualifiedQuantity,
+                    sum(ppo.quantity+ppo.scrap_qty) quantity
+            from product_order po
+            LEFT JOIN product_material_sku sku ON po.product_material_sku_id = sku.id
+            LEFT JOIN product_material pm ON sku.product_id = pm.id
+            LEFT JOIN production_product_main ppm ON ppm.product_order_id = po.id
+            LEFT JOIN production_product_output ppo ON ppo.product_main_id = ppm.id
+            group by po.id ,
+                    po.status,
+                    po.nps_no,
+                    sku.material_code,
+                    pm.product_name,
+                    sku.model,
+                    po.strength,
+                    po.quantity
+            order by po.id desc )A
+        <where>
+            <if test="c.npsNo != null and c.npsNo != ''">
+                AND A.nps_no LIKE CONCAT('%', #{c.npsNo}, '%')
+            </if>
+            <if test="c.productName != null and c.productName != ''">
+                AND A.product_name LIKE CONCAT('%', #{c.productName}, '%')
+            </if>
+            <if test="c.materialCode != null and c.materialCode != ''">
+                AND A.material_code LIKE CONCAT('%', #{c.materialCode}, '%')
+            </if>
+            <if test="c.model != null and c.model != ''">
+                AND A.model LIKE CONCAT('%', #{c.model}, '%')
+            </if>
+            <if test="c.strength != null and c.strength != ''">
+                AND A.strength = #{c.strength}
+            </if>
+        </where>
+    </select>
+    <select id="finishedRatio" resultType="com.ruoyi.quality.dto.FinishedRatioDto">
+        select A.material_code,
+               product_name,
+               model,
+               unit,
+               actualInputQuantity,
+               actualOutputQuantity,
+               actualInputQuantity / actualOutputQuantity actualInputOutputRatio,
+               unit_quantity standardInputOutputRatio,
+               (actualInputQuantity / actualOutputQuantity - unit_quantity)/unit_quantity  deviationRate
+        from (select
+               sku.material_code,
+               pm.product_name,
+               sku.model,
+               ppi.unit,
+               pos.unit_quantity,
+               sum(ppi.quantity) actualInputQuantity,
+               sum(ppo.quantity+ppo.scrap_qty) actualOutputQuantity
+        from   production_product_input ppi
+        left join production_product_main ppm on ppm.id=ppi.product_main_id
+        left join production_product_output ppo on ppm.id=ppo.product_main_id
+        left join product_material_sku sku ON ppi.product_id = sku.id
+        left join product_material pm ON sku.product_id = pm.id
+        left join production_order_structure pos ON pos.product_model_id = ppi.product_id
+        where ppm.product_order_id = #{productOrderId}
+        and pos.order_id = #{productOrderId}
+        group by sku.material_code,
+                 pm.product_name,
+                 sku.model,
+                 pos.unit_quantity,
+                 ppi.unit)A
+        
+    </select>
 </mapper>

--
Gitblit v1.9.3