From 9f19d3a24f8474bf6f9eb9401888c44b34b381e6 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期四, 21 十一月 2024 14:29:50 +0800
Subject: [PATCH] 第一次改动(检验任务与样品关联,附件与样品关联,报告与样品关联)

---
 inspect-server/src/main/resources/mapper/InsOrderMapper.xml |  170 ++++++++++++++++++++++++--------------------------------
 1 files changed, 72 insertions(+), 98 deletions(-)

diff --git a/inspect-server/src/main/resources/mapper/InsOrderMapper.xml b/inspect-server/src/main/resources/mapper/InsOrderMapper.xml
index c11b952..5db1f71 100644
--- a/inspect-server/src/main/resources/mapper/InsOrderMapper.xml
+++ b/inspect-server/src/main/resources/mapper/InsOrderMapper.xml
@@ -14,6 +14,7 @@
         <result property="appointed" column="appointed" jdbcType="TIMESTAMP"/>
         <result property="state" column="state" jdbcType="INTEGER"/>
         <result property="remark" column="remark" jdbcType="VARCHAR"/>
+        <result property="rule" column="rule" jdbcType="VARCHAR"/>
         <result property="otcCode" column="otc_code" jdbcType="VARCHAR"/>
         <result property="createUser" column="create_user" jdbcType="INTEGER"/>
         <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
@@ -72,6 +73,7 @@
         CONCAT(ROUND(approved_product_counts.approved_count / total_product_counts.total_count * 100, 2), '%') AS
         insProgress,
         GROUP_CONCAT(DISTINCT isa.sample_code SEPARATOR '锛�') AS sample_code,
+        GROUP_CONCAT(DISTINCT isa.motor_number SEPARATOR '锛�') AS motor_number,
         GROUP_CONCAT(DISTINCT isa.sample SEPARATOR ' ') AS sample_name,
         GROUP_CONCAT(DISTINCT isa.model SEPARATOR ' ') AS sample_model,
         u.name
@@ -122,31 +124,6 @@
         <result column="name" property="name"/>
         <result column="create_time" property="create_time"/>
     </resultMap>
-    <select id="selectInsOrderParameter" resultType="com.yuanchu.mom.pojo.InsOrder">
-        select *
-        from (
-        select
-        id,
-        appointed,
-        user_id,
-        create_user,
-        otc_code,
-        code,
-        custom,
-        update_user,
-        update_time,
-        type,
-        entrust_code,
-        company,
-        remark,
-        create_time,
-        state
-        from ins_order
-        ) a
-        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
-            ${ew.customSqlSegment}
-        </if>
-    </select>
     <select id="getLaboratoryCode" resultType="java.lang.String">
         select laboratory_number
         from laboratory
@@ -180,39 +157,48 @@
         A.inspection_item,
         A.company,
         A.`name`,
-        COUNT(1) num,
-        SUM(A.price) price,
-        SUM(A.cost) cost
-        FROM
-        (SELECT
-        i.id,
+        COUNT(1)     num,
+        ROUND(SUM(A.price),2) price
+        FROM (SELECT i.id,
         i.entrust_code,
         i.create_time,
         isa.sample,
-        isa.sample_code,
         isa.model,
-        c.price,
-        c.cost,
-        c.inspection_item,
+        ins_sample_id,
+        sum(c.price * times)                                   price,
+        GROUP_CONCAT(distinct c.inspection_item SEPARATOR ',') inspection_item,
         i.company,
-        u.`name`,
-        i.create_user,
-        c.ins_sample_id
-        FROM
-        ins_order i
+        u.`name`
+        FROM ins_order i
         LEFT JOIN ins_sample isa ON isa.ins_order_id = i.id
         LEFT JOIN `user` u ON u.id = i.user_id
         left join custom cus on cus.id = u.company
-        LEFT JOIN (select SUM(b.price) price, sum(b.man_hour) cost,b.ins_sample_id,
-        GROUP_CONCAT(b.inspection_item2
-        SEPARATOR ',')
-        inspection_item from (select * ,
-        GROUP_CONCAT(CONCAT(inspection_item,'@',inspection_item_subclass) SEPARATOR ',')inspection_item2 from
-        ins_product where state = 1 and ins_result is not null and ins_result!=2 and template_id IS NOT NULL GROUP BY ins_sample_id,man_hour_group) b GROUP
-        BY b.ins_sample_id) c ON c.ins_sample_id = isa.id
-        where (<!--i.state = 1 or i.state = 3 or -->i.state = 4) and c.ins_sample_id IS not NULL)A
-        GROUP BY
-        A.id,
+        LEFT JOIN (select ip.ins_sample_id,
+        ip.inspection_item,
+        ip.inspection_item_subclass,
+        ip.price,
+        sum(aowh.output_work_time) times
+        from ins_product ip
+        left join auxiliary_output_working_hours aowh on ip.id = aowh.ins_product_id
+        where state = 1
+        and ins_result is not null
+        and ins_result != 2
+        and template_id IS NOT NULL
+        group by ip.ins_sample_id,
+        ip.inspection_item,
+        ip.inspection_item_subclass,
+        ip.price) c ON c.ins_sample_id = isa.id
+        where (i.state = 4)
+        and c.ins_sample_id IS not NULL
+        group by i.id,
+        i.entrust_code,
+        i.create_time,
+        isa.sample,
+        isa.model,
+        i.company,
+        ins_sample_id,
+        u.`name`) A
+        GROUP BY A.id,
         A.entrust_code,
         A.create_time,
         A.sample,
@@ -338,11 +324,6 @@
         from `center-lims`.enums
         where value = #{value}
     </select>
-    <select id="getStandardMethodCode" resultType="java.lang.String">
-        select code
-        from `center-lims`.standard_method
-        where id = #{id}
-    </select>
     <select id="selLaboratoryCode" resultType="java.lang.String">
         select laboratory_code
         from laboratory
@@ -368,63 +349,56 @@
         A.inspection_item,
         A.company,
         A.`name`,
-        production,
-        engineering,
-        COUNT(1) num,
-        SUM(A.price) price,
-        SUM(A.cost) cost
-        FROM
-        (SELECT
-        i.id,
+        COUNT(1)     num,
+        ROUND(SUM(A.price),2) price
+        FROM (SELECT i.id,
         i.entrust_code,
         i.create_time,
         isa.sample,
-        isa.sample_code,
         isa.model,
-        c.price,
-        c.cost,
-        c.inspection_item,
+        ins_sample_id,
+        sum(c.price * times)                                   price,
+        GROUP_CONCAT(distinct c.inspection_item SEPARATOR ',') inspection_item,
         i.company,
-        u.`name`,
-        i.create_user,
-        c.ins_sample_id,
-        production,
-        engineering
-        FROM
-        ins_order i
+        u.`name`
+        FROM ins_order i
         LEFT JOIN ins_sample isa ON isa.ins_order_id = i.id
         LEFT JOIN `user` u ON u.id = i.user_id
         left join custom cus on cus.id = u.company
-        LEFT JOIN (select SUM(b.price) price, sum(b.man_hour) cost,b.ins_sample_id,
-        GROUP_CONCAT(b.inspection_item2
-        SEPARATOR ',')
-        inspection_item from (select * ,
-        GROUP_CONCAT(CONCAT(inspection_item,'@',inspection_item_subclass) SEPARATOR ',')inspection_item2 from
-        ins_product where state = 1 and ins_result is not null and ins_result!=2 and template_id IS NOT NULL GROUP BY ins_sample_id,man_hour_group) b GROUP
-        BY b.ins_sample_id) c ON c.ins_sample_id = isa.id
-        where (<!--i.state = 1 or i.state = 3 or -->i.state = 4) and c.ins_sample_id IS not NULL)A
-        GROUP BY
-        A.id,
+        LEFT JOIN (select ip.ins_sample_id,
+        ip.inspection_item,
+        ip.inspection_item_subclass,
+        ip.price,
+        sum(aowh.output_work_time) times
+        from ins_product ip
+        left join auxiliary_output_working_hours aowh on ip.id = aowh.ins_product_id
+        where state = 1
+        and ins_result is not null
+        and ins_result != 2
+        and template_id IS NOT NULL
+        group by ip.ins_sample_id,
+        ip.inspection_item,
+        ip.inspection_item_subclass,
+        ip.price) c ON c.ins_sample_id = isa.id
+        where (i.state = 4)
+        and c.ins_sample_id IS not NULL
+        group by i.id,
+        i.entrust_code,
+        i.create_time,
+        isa.sample,
+        isa.model,
+        i.company,
+        ins_sample_id,
+        u.`name`) A
+        GROUP BY A.id,
         A.entrust_code,
         A.create_time,
         A.sample,
         A.model,
         A.inspection_item,
         A.company,
-        A.`name`,
-        production,
-        engineering
-        ORDER BY
-        A.id,
-        A.entrust_code,
-        A.create_time,
-        A.sample,
-        A.model,
-        A.inspection_item,
-        A.company,
-        A.`name`,
-        production,
-        engineering) B
+        A.`name`
+        ) B
         <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
             ${ew.customSqlSegment}
         </if>

--
Gitblit v1.9.3