zhuo
2025-04-03 eb975b40828b3a930fb38b75c739a7385b14ee12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.basic.mapper.StructureItemParameterMapper">
    <sql id="selectStandardTree">
        sample    sample2,
               inspection_item,
               inspection_item_en,
               inspection_item_subclass,
               inspection_item_subclass_en,
               inspection_item_class,
               inspection_item_class_en,
               method,
               son_laboratory,
               unit,
               ask_tell  tell,
               ask,
               price,
               man_hour,
               man_hour_group,
               man_day,
               inspection_item_type,
               inspection_value_type,
               bsm,
               template_id,
               laboratory,
               checkout_number,
               section,
               dic,
               0         state,
        #{trees}
        tree,
        id
        structure_item_parameter_id,
        radius_list,
        rates
    </sql>
 
    <delete id="removeNoSample">
        delete
        from structure_item_parameter
        where sample like concat('%', #{sample}, '%')
    </delete>
    <select id="selectItemParameterList" resultType="com.ruoyi.basic.pojo.StructureItemParameter">
        select * from (select A.id,
        inspection_item,
        inspection_item_en,
        inspection_item_subclass,
        inspection_item_subclass_en,
        laboratory,
        unit,
        price,
        man_hour,
        man_hour_group,
        inspection_item_type,
        checkout_number,
        section,
        A.create_user,
        A.update_user,
        A.create_time,
        A.update_time,
        method,
        man_day,
        bsm,
        sample,
        inspection_value_type,
        dic,
        template_id,
        son_laboratory,
        ask,
        ask_tell,
        inspection_item_class,
        inspection_item_class_en,
        code,
        radius_list,
        rates
        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>)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="itemClass" javaType="List"/>
    </resultMap>
    <resultMap id="itemClass" type="map">
        <result property="name" column="item_class"/>
        <collection property="children" resultMap="item" javaType="List"/>
    </resultMap>
    <resultMap id="item" type="map">
        <result property="name" column="inspection_item"/>
        <collection property="children" resultMap="itemSubClass" javaType="List"/>
    </resultMap>
    <resultMap id="itemSubClass" type="map">
        <id property="id" column="id"/>
        <result property="name" column="subclass"/>
    </resultMap>
    <select id="getInsProduction" resultMap="getInsProductions">
        select distinct id,
                        CASE
                            WHEN INSTR(sample, ',') > 0 THEN
                                SUBSTRING_INDEX(SUBSTRING_INDEX(sample, '","', 1), '"', -1)
                            when sample = '[""]' then '*'
                            ELSE
                                TRIM(BOTH '["]' FROM SUBSTRING_INDEX(REPLACE(sample, '[["', ''), '"]]', 1))
                            END
                                                              as sample,
                        inspection_item,
                        case
                            when inspection_item_subclass is null or inspection_item_subclass = '' then inspection_item
                            else inspection_item_subclass end as subclass,
                        case
                            when inspection_item_class is null or inspection_item_class = '' then inspection_item
                            else inspection_item_class end as item_class
        from structure_item_parameter
    </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.ruoyi.basic.dto.TestItemDto">
        <result column="sId" property="id"/>
        <result column="sName" property="name"/>
        <collection property="children" resultMap="productDto"/>
    </resultMap>
    <resultMap id="productDto" type="com.ruoyi.basic.dto.ProductDto">
        <result column="pId" property="id"/>
        <result column="pName" property="name"/>
    </resultMap>
 
    <select id="selectItemParameterBySample" resultType="com.ruoyi.basic.pojo.StructureItemParameter">
        select *
        from structure_item_parameter
        where (
        sample is NULL
        OR sample = ''
        or sample = '[]'
        OR sample LIKE CONCAT('%', #{sample}, '%')
        )
        order by id asc
    </select>
 
    <select id="getItemTreeProduct" 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
        WHERE sto.object_type = #{objectType}
    </select>
</mapper>