From a3a378220071a82cd877c2eecffd5c3d68899043 Mon Sep 17 00:00:00 2001
From: deslrey <deslre0381@gmail.com>
Date: 星期六, 10 一月 2026 14:45:25 +0800
Subject: [PATCH] 委托下单,新增批号、零件描述、供应商名称保存及查询

---
 inspect-server/src/main/resources/mapper/InsSampleMapper.xml |  322 ++++++++++++++++++++---------------------------------
 1 files changed, 121 insertions(+), 201 deletions(-)

diff --git a/inspect-server/src/main/resources/mapper/InsSampleMapper.xml b/inspect-server/src/main/resources/mapper/InsSampleMapper.xml
index 2d4f4b6..ff26f13 100644
--- a/inspect-server/src/main/resources/mapper/InsSampleMapper.xml
+++ b/inspect-server/src/main/resources/mapper/InsSampleMapper.xml
@@ -193,8 +193,22 @@
         ira.temp_url_pdf,
         iiq.is_copper,
         iiq.is_split_order,
-        iiq.update_batch_no,
-        iiq.part_desc,
+
+        CASE
+        WHEN io.ifs_inventory_id IS NOT NULL THEN iiq.update_batch_no
+        ELSE io.update_batch_no
+        END AS update_batch_no,
+
+        CASE
+        WHEN io.ifs_inventory_id IS NOT NULL THEN iiq.part_desc
+        ELSE io.part_desc
+        END AS part_desc,
+
+        CASE
+        WHEN io.ifs_inventory_id IS NOT NULL THEN iiq.supplier_name
+        ELSE io.supplier_name
+        END AS supplier_name,
+
         iiq.material_prop AS material_prop
         FROM
         ins_order io
@@ -229,9 +243,11 @@
 
         WHERE io.state = 1
         AND io.send_time IS NOT NULL
+
         <if test="materialProp != null and materialProp != ''">
             AND iiq.material_prop LIKE CONCAT('%', #{materialProp}, '%')
         </if>
+
         <if test="sonLaboratory != null and sonLaboratory != ''">
             AND ip.son_laboratory = #{sonLaboratory}
         </if>
@@ -265,106 +281,6 @@
         </if>
         ORDER BY send_time ASC
     </select>
-
-<!--    <select id="findInsSampleAndOrder" resultType="com.ruoyi.inspect.vo.InsOrderPlanVO">-->
-<!--        select * from(select * from(-->
-<!--        SELECT-->
-<!--        a.*,ios.ins_state,ios.verify_tell,verify_user-->
-<!--        FROM-->
-<!--        (-->
-<!--        SELECT-->
-<!--        io.id,-->
-<!--        io.entrust_code,-->
-<!--        io.type,-->
-<!--        io.appointed,-->
-<!--        io.send_time,-->
-<!--        io.order_type,-->
-<!--        case when-->
-<!--        io.type_source = 0-->
-<!--        then io.sample_view-->
-<!--        else io.sample end sample,-->
-<!--        GROUP_CONCAT(DISTINCT isa.model SEPARATOR ' ') AS sample_model,-->
-<!--        userName,-->
-<!--        checkName,-->
-<!--        ip.son_laboratory,-->
-<!--        io.ins_time,-->
-<!--        io.laboratory,-->
-<!--        io.type_source,-->
-<!--        io.ifs_inventory_id,-->
-<!--        ira.id ins_report_id,-->
-<!--        ira.url,-->
-<!--        ira.url_s,-->
-<!--        ira.temp_url_pdf,-->
-<!--        iiq.is_copper,-->
-<!--        iiq.is_split_order,-->
-<!--        iiq.update_batch_no,-->
-<!--        iiq.part_desc,-->
-<!--        iiq.material_prop AS material_prop-->
-<!--        FROM-->
-<!--        ins_order io-->
-<!--        LEFT JOIN ins_sample isa ON isa.ins_order_id = io.id-->
-<!--        LEFT JOIN ins_report ira ON ira.ins_order_id = io.id-->
-
-<!--        LEFT JOIN ifs_inventory_quantity iiq-->
-<!--        ON iiq.id = io.ifs_inventory_id-->
-<!--        <if test="materialProp != null and materialProp != ''">-->
-<!--            AND iiq.material_prop LIKE CONCAT('%', #{materialProp}, '%')-->
-<!--        </if>-->
-
-<!--        LEFT JOIN (-->
-<!--        SELECT ins_sample_id,GROUP_CONCAT( DISTINCT uu.name SEPARATOR ',') AS userName-->
-<!--        FROM ins_sample_user u LEFT JOIN user uu ON u.user_id = uu.id-->
-<!--        WHERE u.state=0-->
-<!--        <if test="sonLaboratory!= null and sonLaboratory != ''">-->
-<!--            and son_laboratory=#{sonLaboratory}-->
-<!--        </if>-->
-<!--        GROUP BY ins_sample_id-->
-<!--        ORDER BY ins_sample_id-->
-<!--        ) isu ON isu.ins_sample_id = io.id-->
-<!--        LEFT JOIN (-->
-<!--        SELECT ins_sample_id,uu.name checkName-->
-<!--        FROM ins_sample_user u LEFT JOIN user uu ON u.user_id = uu.id-->
-<!--        WHERE u.state=1-->
-<!--        <if test="sonLaboratory!= null and sonLaboratory != ''">-->
-<!--            and son_laboratory=#{sonLaboratory}-->
-<!--        </if>-->
-<!--        GROUP BY ins_sample_id-->
-<!--        ORDER BY ins_sample_id-->
-<!--        )isu2 ON isu2.ins_sample_id = io.id-->
-<!--        LEFT JOIN ins_product ip ON ip.ins_sample_id = isa.id-->
-<!--        WHERE io.state = 1 and send_time is not null-->
-<!--        <if test="isCheck != null">-->
-<!--            <if test="userName !=null and userName!=''">-->
-<!--                and checkName like CONCAT ('%', #{userName},'%')-->
-<!--            </if>-->
-<!--        </if>-->
-<!--        <if test="isCheck == null">-->
-<!--            <if test="userName !=null and userName!=''">-->
-<!--                and userName like CONCAT ('%', #{userName},'%')-->
-<!--            </if>-->
-<!--        </if>-->
-<!--        <if test="sonLaboratory!= null and sonLaboratory != ''">-->
-<!--            and ip.son_laboratory = #{sonLaboratory}-->
-<!--        </if>-->
-<!--        GROUP BY-->
-<!--        ip.son_laboratory,-->
-<!--        io.id-->
-<!--        ) a-->
-<!--        LEFT JOIN ins_order_state ios ON ios.ins_order_id = a.id AND ios.laboratory = a.son_laboratory-->
-<!--        ORDER BY-->
-<!--        a.type DESC,-->
-<!--        a.id-->
-<!--        ) b-->
-<!--        where ins_state is not null-->
-<!--        <if test="laboratory!=null and laboratory!=''">-->
-<!--            and laboratory=#{laboratory}-->
-<!--        </if>-->
-<!--        )A-->
-<!--        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">-->
-<!--            ${ew.customSqlSegment}-->
-<!--        </if>-->
-<!--        ORDER BY send_time asc-->
-<!--    </select>-->
 
     <select id="inspectionOrderDetailsTaskSwitching" resultType="com.ruoyi.inspect.vo.InsOrderPlanTaskSwitchVo">
         select * from(
@@ -402,7 +318,7 @@
         LEFT JOIN user ON isu.user_id = user.id
         WHERE
         io.state = 1
---         # AND io.ins_state != 5
+        -- # AND io.ins_state != 5
         and send_time is not null
         <if test="userId !=null and userId!=''">
             and (isu.user_id = #{userId} OR isu.user_id is NULL )
@@ -437,59 +353,60 @@
 
     <select id="selectSampleProductListByOrderId" resultMap="sampleDto">
         select isa.*,
-               ip.id          ip_id,
-               inspection_item,
-               inspection_item_en,
-               inspection_item_class,
-               inspection_item_class_en,
-               inspection_item_subclass,
-               inspection_item_subclass_en,
-               ip.factory     ip_factory,
-               ip.laboratory  ip_laboratory,
-               ip.sample_type ip_sample_type,
-               ip.sample      ip_sample,
-               ip.model       ip_model,
-               son_laboratory,
-               ip.unit        ip_unit,
-               price,
-               man_hour,
-               man_hour_group,
-               inspection_item_type,
-               inspection_value_type,
-               device_group,
-               checkout_number,
-               section,
-               value_type,
-               method,
-               man_day,
-               bsm,
-               ask,
-               tell,
-               `last_value`,
-               ip.ins_result  ip_ins_result,
-               state,
-               ins_sample_id,
-               ip.create_user ip_create_user,
-               ip.update_user ip_update_user,
-               ip.create_time ip_create_time,
-               ip.update_time ip_update_time,
-               template_id,
-               ipr.ins_value,
-               ipr.com_value,
-               ipr.equip_value,
-               ip.method_s
+        ip.id ip_id,
+        inspection_item,
+        inspection_item_en,
+        inspection_item_class,
+        inspection_item_class_en,
+        inspection_item_subclass,
+        inspection_item_subclass_en,
+        ip.factory ip_factory,
+        ip.laboratory ip_laboratory,
+        ip.sample_type ip_sample_type,
+        ip.sample ip_sample,
+        ip.model ip_model,
+        son_laboratory,
+        ip.unit ip_unit,
+        price,
+        man_hour,
+        man_hour_group,
+        inspection_item_type,
+        inspection_value_type,
+        device_group,
+        checkout_number,
+        section,
+        value_type,
+        method,
+        man_day,
+        bsm,
+        ask,
+        tell,
+        `last_value`,
+        ip.ins_result ip_ins_result,
+        state,
+        ins_sample_id,
+        ip.create_user ip_create_user,
+        ip.update_user ip_update_user,
+        ip.create_time ip_create_time,
+        ip.update_time ip_update_time,
+        template_id,
+        ipr.ins_value,
+        ipr.com_value,
+        ipr.equip_value,
+        ip.method_s
         from ins_sample isa
-                 left join ins_product ip on isa.id = ip.ins_sample_id
-                 left join ins_product_result ipr on ip.id = ipr.ins_product_id
+        left join ins_product ip on isa.id = ip.ins_sample_id
+        left join ins_product_result ipr on ip.id = ipr.ins_product_id
         where ins_order_id = #{id}
-          and state = 1
---           and ins_fiber_id is null
---           and ins_fibers_id is null
-          and <!--isa.sample_code NOT REGEXP '/'-->
-            isa.id in(select id1 from (select is2.id id1 ,ip.id from ins_sample is2 left join ins_product ip on is2.id = ip.ins_sample_id where ip.id is not null)s )
+        and state = 1
+        -- and ins_fiber_id is null
+        -- and ins_fibers_id is null
+        and <!--isa.sample_code NOT REGEXP '/'-->
+        isa.id in(select id1 from (select is2.id id1 ,ip.id from ins_sample is2 left join ins_product ip on is2.id =
+        ip.ins_sample_id where ip.id is not null)s )
         order by ip.sort asc,
-            case when man_hour_group is NULL then 1
-        when man_hour_group ='' then 1  else 0 end,
+        case when man_hour_group is NULL then 1
+        when man_hour_group ='' then 1 else 0 end,
         CASE
         WHEN man_hour_group REGEXP '^[0-9]' THEN CAST(man_hour_group AS UNSIGNED) -- 濡傛灉浠ユ暟瀛楀紑澶达紝鍒欐寜鐓ф暟瀛楀ぇ灏忔帓搴�
         WHEN man_hour_group REGEXP '[0-9]+' THEN CAST(SUBSTRING(man_hour_group, 2)AS UNSIGNED) END -- 鎻愬彇瀛楁瘝鍚庨潰鐨勬暟瀛楅儴鍒�
@@ -562,27 +479,24 @@
         limit 1
     </select>
     <select id="selectInsOrder" resultType="map">
-        SELECT
-            ifs.order_no AS orderNo,
-            ifs.supplier_id AS supplierId,
-            ifs.supplier_name AS supplierName,
-            ifs.part_no AS partNo,
-            ifs.qty_arrived AS qtyArrived,
-            ifs.receiver_date AS receiverDate,
-            ifs.update_batch_no AS updateBatchNo,
-            ifs.part_desc AS partDesc,
-            io.send_time AS sendTime,
-            ifs.declare_user declareUser,
-            ifs.id inventoryQuantityId,
-            ifs.buy_unit_meas buyUnitMeas,
-            io.test_quantity testQuantity,
-            ifs.buy_unit_meas buyUnitMeas,
-            ifs.declare_date declareDate
-        FROM
-            ifs_inventory_quantity ifs
-                LEFT JOIN ins_order io ON ifs.id = io.ifs_inventory_id
-        WHERE
-            io.id = #{id}
+        SELECT ifs.order_no        AS orderNo,
+               ifs.supplier_id     AS supplierId,
+               ifs.supplier_name   AS supplierName,
+               ifs.part_no         AS partNo,
+               ifs.qty_arrived     AS qtyArrived,
+               ifs.receiver_date   AS receiverDate,
+               ifs.update_batch_no AS updateBatchNo,
+               ifs.part_desc       AS partDesc,
+               io.send_time        AS sendTime,
+               ifs.declare_user       declareUser,
+               ifs.id                 inventoryQuantityId,
+               ifs.buy_unit_meas      buyUnitMeas,
+               io.test_quantity       testQuantity,
+               ifs.buy_unit_meas      buyUnitMeas,
+               ifs.declare_date       declareDate
+        FROM ifs_inventory_quantity ifs
+                 LEFT JOIN ins_order io ON ifs.id = io.ifs_inventory_id
+        WHERE io.id = #{id}
     </select>
     <select id="selectSampleProductListByOrderId2" resultMap="sampleDto">
         select isa.*,
@@ -637,24 +551,28 @@
           and state = 1
           and ip.is_binding != 1
         order by ip.sort asc,
-            case when man_hour_group is NULL then 1
-                      when man_hour_group ='' then 1  else 0 end,
+                 case
+                     when man_hour_group is NULL then 1
+                     when man_hour_group = '' then 1
+                     else 0 end,
                  CASE
                      WHEN man_hour_group REGEXP '^[0-9]' THEN CAST(man_hour_group AS UNSIGNED) -- 濡傛灉浠ユ暟瀛楀紑澶达紝鍒欐寜鐓ф暟瀛楀ぇ灏忔帓搴�
-                     WHEN man_hour_group REGEXP '[0-9]+' THEN CAST(SUBSTRING(man_hour_group, 2)AS UNSIGNED) END -- 鎻愬彇瀛楁瘝鍚庨潰鐨勬暟瀛楅儴鍒�
-                ,id asc
+                     WHEN man_hour_group REGEXP '[0-9]+'
+                         THEN CAST(SUBSTRING(man_hour_group, 2) AS UNSIGNED) END -- 鎻愬彇瀛楁瘝鍚庨潰鐨勬暟瀛楅儴鍒�
+                , id asc
     </select>
 
     <select id="getInsProduct1" resultMap="product">
-        select <include refid="getInsProducSql"/>
+        select
+        <include refid="getInsProducSql"/>
         from ins_product ip
-                 left join ins_product_result ipr on ip.id = ipr.ins_product_id
+        left join ins_product_result ipr on ip.id = ipr.ins_product_id
         where ins_sample_id = #{id}
-          and state = 1
-          and ip.son_laboratory = #{laboratory}
-          and ins_fiber_id is null
-          and ins_fibers_id is null
-          and standard_method_list_id is not null
+        and state = 1
+        and ip.son_laboratory = #{laboratory}
+        and ins_fiber_id is null
+        and ins_fibers_id is null
+        and standard_method_list_id is not null
         /* 鐢电紗閰嶇疆鏍囪瘑 */
         <if test="cableTag == null or cableTag == ''">
             and ip.cable_tag is null
@@ -673,7 +591,8 @@
     </select>
 
     <select id="getInsProduct6" resultMap="product">
-        select <include refid="getInsProducSql"/>
+        select
+        <include refid="getInsProducSql"/>
         from ins_product ip
         left join ins_product_result ipr on ip.id = ipr.ins_product_id
         where ins_sample_id = #{id}
@@ -707,7 +626,7 @@
                    WHEN COUNT(ip.last_value) = 0 THEN '0'
                    WHEN COUNT(CASE WHEN ip.last_value = '' OR ip.last_value IS NULL THEN 1 END) = 0 THEN '2'
                    ELSE '2'
-                   END AS status
+                   END AS   status
         from ins_product ip
         where ins_sample_id = #{id}
           and state = 1
@@ -726,7 +645,7 @@
                    WHEN COUNT(ip.last_value) = 0 THEN '0'
                    WHEN COUNT(CASE WHEN ip.last_value = '' OR ip.last_value IS NULL THEN 1 END) = 0 THEN '2'
                    ELSE '1'
-                   END AS status
+                   END AS          status
         from ins_product ip
         where ins_sample_id = #{id}
           and state = 1
@@ -741,20 +660,20 @@
     <!-- 鏌ョ湅閲嶅鏍囪瘑 -->
     <select id="getRepetitionTag" resultType="java.util.Map">
         select ip.repetition_tag repetitionTag,
-               CASE
-                   WHEN COUNT(ip.last_value) = 0 THEN '0'
-                   WHEN COUNT(CASE WHEN ip.last_value = '' OR ip.last_value IS NULL THEN 1 END) = 0 THEN '2'
-                   ELSE '1'
-                   END AS status,
-               GROUP_CONCAT(DISTINCT ip.radius SEPARATOR '锛�') AS radius
+        CASE
+        WHEN COUNT(ip.last_value) = 0 THEN '0'
+        WHEN COUNT(CASE WHEN ip.last_value = '' OR ip.last_value IS NULL THEN 1 END) = 0 THEN '2'
+        ELSE '1'
+        END AS status,
+        GROUP_CONCAT(DISTINCT ip.radius SEPARATOR '锛�') AS radius
         from ins_product ip
         where ins_sample_id = #{id}
-          and state = 1
-          and ip.son_laboratory = #{laboratory}
-          and ins_fiber_id is null
-          and ins_fibers_id is null
-          and standard_method_list_id is not null
-          and ip.repetition_tag is not null
+        and state = 1
+        and ip.son_laboratory = #{laboratory}
+        and ins_fiber_id is null
+        and ins_fibers_id is null
+        and standard_method_list_id is not null
+        and ip.repetition_tag is not null
         /* 鐢电紗閰嶇疆鏍囪瘑 */
         <if test="cableTag == null or cableTag == ''">
             and ip.cable_tag is null
@@ -795,7 +714,8 @@
 
     <!-- 鏌ヨ妫�楠岄」妫�楠岀粨鏋� -->
     <select id="selectProductResult" resultMap="product">
-        select <include refid="getInsProducSql"/>
+        select
+        <include refid="getInsProducSql"/>
         from ins_product ip
         left join ins_product_result ipr on ip.id = ipr.ins_product_id
         where ip.id in

--
Gitblit v1.9.3