From ebede85283906f52dd45d0755d22140538038ac3 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期五, 27 十二月 2024 13:27:47 +0800
Subject: [PATCH] 完成6.6供应商模块

---
 cnas-server/src/main/resources/mapper/StructureItemParameterMapper.xml |  129 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 116 insertions(+), 13 deletions(-)

diff --git a/cnas-server/src/main/resources/mapper/StructureItemParameterMapper.xml b/cnas-server/src/main/resources/mapper/StructureItemParameterMapper.xml
index 4999d55..57616e4 100644
--- a/cnas-server/src/main/resources/mapper/StructureItemParameterMapper.xml
+++ b/cnas-server/src/main/resources/mapper/StructureItemParameterMapper.xml
@@ -3,27 +3,29 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.yuanchu.mom.mapper.StructureItemParameterMapper">
-
-
+    <delete id="removeNoSample">
+        delete
+        from structure_item_parameter
+        where sample like concat('%', #{sample}, '%')
+    </delete>
     <select id="selectItemParameterList" resultType="com.yuanchu.mom.pojo.StructureItemParameter">
-        select id,
+        select * from (select A.id,
         inspection_item,
-        inspection_item_classify,
+        inspection_item_en,
         inspection_item_subclass,
+        inspection_item_subclass_en,
         laboratory,
         unit,
         price,
         man_hour,
         man_hour_group,
         inspection_item_type,
-        device_group,
         checkout_number,
         section,
-        value_type,
-        create_user,
-        update_user,
-        create_time,
-        update_time,
+        A.create_user,
+        A.update_user,
+        A.create_time,
+        A.update_time,
         method,
         man_day,
         bsm,
@@ -33,10 +35,111 @@
         template_id,
         son_laboratory,
         ask,
-        ask_tell
-        from structure_item_parameter
+        ask_tell,
+        inspection_item_class,
+        inspection_item_class_en,
+        code
+        from (select *,
+        CASE
+        WHEN INSTR(sample, ',') > 0 THEN
+        SUBSTRING_INDEX(SUBSTRING_INDEX(sample, '","', 1), '"', -1)
+        when sample = '[""]' then null
+        when sample = '[]' then null
+        ELSE
+        TRIM(BOTH '["]' FROM SUBSTRING_INDEX(REPLACE(sample, '[["', ''), '"]]', 1))
+        END AS samples
+        from structure_item_parameter) A
+        left join structure_test_object sto on samples = specimen_name
         <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
             ${ew.customSqlSegment}
-        </if>
+        </if>)B
+        order by CASE
+        WHEN code IS NULL THEN 1
+        ELSE 0
+        END,
+        CAST(code AS UNSIGNED),
+        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
     </select>
+
+    <resultMap id="getInsProductions" type="map">
+        <result property="name" column="sample"/>
+        <collection property="children" resultMap="seProInsListByIdmaps" javaType="List"/>
+    </resultMap>
+    <resultMap id="seProInsListByIdmaps" type="map">
+        <result property="name" column="inspection_item"/>
+        <collection property="children" resultMap="seProInsListByIdmaps2" javaType="List"/>
+    </resultMap>
+    <resultMap id="seProInsListByIdmaps2" type="map">
+        <id property="id" column="id"/>
+        <result property="name" column="subclass"/>
+    </resultMap>
+    <select id="getInsProduction" resultMap="getInsProductions">
+        WITH expanded_sample AS (
+            SELECT
+                id,
+                CASE
+                    WHEN INSTR(sample, '","') > 0 THEN
+                        SUBSTRING_INDEX(SUBSTRING_INDEX(sample, '","', 1), '"', -1)
+                    when sample = '[]' then '*'
+                    WHEN INSTR(sample, '"],["') > 0 THEN
+                        TRIM(BOTH '["]' FROM SUBSTRING_INDEX(SUBSTRING_INDEX(sample, '"],["', 1), '"', -1))
+                    ELSE
+                        TRIM(BOTH '["]' FROM SUBSTRING_INDEX(REPLACE(sample, '[["', ''), '"]]', 1))
+                    END
+                        AS component1,
+                CASE
+                    WHEN INSTR(sample, '"],["') > 0 THEN
+                        TRIM(BOTH '["]' FROM SUBSTRING_INDEX(SUBSTRING_INDEX(sample, '"],["', -1), '"', 1))
+                    ELSE
+                        NULL
+                    END AS component2,
+                inspection_item,
+                CASE
+                    WHEN inspection_item_subclass IS NULL THEN inspection_item
+                    ELSE inspection_item_subclass
+                    END AS subclass
+            FROM
+                structure_item_parameter
+        )
+        SELECT
+            id,
+            CASE
+                WHEN component1 IS NOT NULL THEN component1
+                ELSE '*'
+                END AS sample,
+            inspection_item,
+            subclass
+        FROM
+            expanded_sample
+        UNION ALL
+        SELECT
+            id,
+            component2 AS sample,
+            inspection_item,
+            subclass
+        FROM
+            expanded_sample
+        WHERE
+            component2 IS NOT NULL;
+    </select>
+    <select id="getItemTree" resultMap="itemDto">
+        select sto.id sId, sto.specimen_name sName, p.id pId, p.name pName
+        from structure_test_object sto
+                 left join product p on p.object_id = sto.id
+    </select>
+
+    <resultMap id="itemDto" type="com.yuanchu.mom.dto.TestItemDto">
+        <result column="sId" property="id"/>
+        <result column="sName" property="name"/>
+        <collection property="children" resultMap="productDto"/>
+    </resultMap>
+    <resultMap id="productDto" type="com.yuanchu.mom.dto.ProductDto">
+        <result column="pId" property="id"/>
+        <result column="pName" property="name"/>
+    </resultMap>
 </mapper>

--
Gitblit v1.9.3