李林
2024-03-22 53da067c76ca7d4406b57c1a78565bd7b990868d
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.yuanchu.mom.mapper.InsSampleMapper">
 
    <resultMap id="BaseResultMap" type="com.yuanchu.mom.pojo.InsSample">
        <id property="id" column="id" jdbcType="INTEGER"/>
        <result property="insResult" column="ins_result" jdbcType="INTEGER"/>
        <result property="insOrderId" column="ins_order_id" jdbcType="INTEGER"/>
        <result property="joinModel" column="join_model" jdbcType="VARCHAR"/>
        <result property="joinName" column="join_name" jdbcType="VARCHAR"/>
        <result property="sampleCode" column="sample_code" jdbcType="VARCHAR"/>
        <result property="factory" column="factory" jdbcType="VARCHAR"/>
        <result property="laboratory" column="laboratory" jdbcType="VARCHAR"/>
        <result property="sampleType" column="sample_type" jdbcType="VARCHAR"/>
        <result property="sample" column="sample" jdbcType="VARCHAR"/>
        <result property="model" column="model" jdbcType="VARCHAR"/>
        <result property="isLeave" column="is_leave" jdbcType="INTEGER"/>
        <result property="insState" column="ins_state" jdbcType="INTEGER"/>
        <result property="sendTime" column="send_time" jdbcType="TIMESTAMP"/>
        <result property="joinNum" column="join_num" jdbcType="INTEGER"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <result property="appointed" column="appointed" jdbcType="TIMESTAMP"/>
        <result property="createUser" column="create_user" jdbcType="INTEGER"/>
        <result property="updateUser" column="update_user" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
    </resultMap>
 
    <select id="findInsSampleAndOrder" resultType="com.yuanchu.mom.vo.InsOrderPlanVO">
        select * from(
        SELECT
        *
        FROM
        (
        SELECT
        io.id,
        io.entrust_code,
        io.type,
        io.appointed,
        io.send_time,
        io.sample_type,
        isu.user_id,
        ip.son_laboratory,
        io.ins_state,
        io.ins_result
        FROM
        ins_order io
        LEFT JOIN ins_sample isa ON isa.ins_order_id = io.id
        LEFT JOIN ( SELECT * FROM ins_sample_user GROUP BY ins_sample_id, user_id ) isu ON isu.ins_sample_id = io.id
        LEFT JOIN ins_product ip ON ip.ins_sample_id = isa.id
        WHERE
        io.state = 1
        AND io.ins_state != 5
        and send_time is not null
        GROUP BY
        ip.son_laboratory,
        io.id
        ) a
        where a.user_id = #{userId} OR a.user_id is NULL
        ORDER BY
        a.user_id DESC,
        a.type DESC,
        a.id
        ) b
        <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
            ${ew.customSqlSegment}
        </if>
    </select>
 
    <select id="selectSampleProductListByOrderId" resultMap="sampleDto">
        select isa.*,
               ip.id,
               inspection_item,
               inspection_item_classify,
               inspection_item_subclass,
               ip.factory,
               ip.laboratory,
               ip.sample_type,
               ip.sample,
               ip.model,
               son_laboratory,
               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,
               `last_value`,
               ip.ins_result,
               state,
               ins_sample_id,
               ip.create_user,
               ip.update_user,
               ip.create_time,
               ip.update_time,
               template_id
        from ins_sample isa
                 left join ins_product ip on isa.id = ip.ins_sample_id
        where ins_order_id = #{id}
    </select>
 
    <resultMap id="sampleDto" type="com.yuanchu.mom.dto.SampleProductDto">
        <id property="id" column="id" jdbcType="INTEGER"/>
        <result property="insResult" column="ins_result" jdbcType="INTEGER"/>
        <result property="insOrderId" column="ins_order_id" jdbcType="INTEGER"/>
        <result property="joinModel" column="join_model" jdbcType="VARCHAR"/>
        <result property="joinName" column="join_name" jdbcType="VARCHAR"/>
        <result property="sampleCode" column="sample_code" jdbcType="VARCHAR"/>
        <result property="factory" column="factory" jdbcType="VARCHAR"/>
        <result property="laboratory" column="laboratory" jdbcType="VARCHAR"/>
        <result property="sampleType" column="sample_type" jdbcType="VARCHAR"/>
        <result property="sample" column="sample" jdbcType="VARCHAR"/>
        <result property="model" column="model" jdbcType="VARCHAR"/>
        <result property="isLeave" column="is_leave" jdbcType="INTEGER"/>
        <result property="insState" column="ins_state" jdbcType="INTEGER"/>
        <result property="sendTime" column="send_time" jdbcType="TIMESTAMP"/>
        <result property="joinNum" column="join_num" jdbcType="INTEGER"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <result property="appointed" column="appointed" jdbcType="TIMESTAMP"/>
        <result property="createUser" column="create_user" jdbcType="INTEGER"/>
        <result property="updateUser" column="update_user" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="standardMethodListId" column="standard_method_list_id"/>
        <result property="unit" column="unit"/>
        <collection property="insProduct" resultMap="product"/>
    </resultMap>
 
    <resultMap id="product" type="com.yuanchu.mom.pojo.InsProduct">
        <id property="id" column="ip.id" jdbcType="INTEGER"/>
        <result property="inspectionItem" column="inspection_item" jdbcType="VARCHAR"/>
        <result property="inspectionItemClassify" column="inspection_item_classify" jdbcType="VARCHAR"/>
        <result property="inspectionItemSubclass" column="inspection_item_subclass" jdbcType="VARCHAR"/>
        <result property="factory" column="ip.factory" jdbcType="VARCHAR"/>
        <result property="laboratory" column="ip.laboratory" jdbcType="VARCHAR"/>
        <result property="sampleType" column="ip.sample_type" jdbcType="VARCHAR"/>
        <result property="sample" column="ip.sample" jdbcType="VARCHAR"/>
        <result property="model" column="ip.model" jdbcType="VARCHAR"/>
        <result property="sonLaboratory" column="son_laboratory" jdbcType="VARCHAR"/>
        <result property="unit" column="ip.unit" jdbcType="VARCHAR"/>
        <result property="price" column="price" jdbcType="DECIMAL"/>
        <result property="manHour" column="man_hour" jdbcType="DOUBLE"/>
        <result property="manHourGroup" column="man_hour_group" jdbcType="VARCHAR"/>
        <result property="inspectionItemType" column="inspection_item_type" jdbcType="VARCHAR"/>
        <result property="inspectionValueType" column="inspection_value_type" jdbcType="VARCHAR"/>
        <result property="deviceGroup" column="device_group" jdbcType="VARCHAR"/>
        <result property="checkoutNumber" column="checkout_number" jdbcType="INTEGER"/>
        <result property="section" column="section" jdbcType="VARCHAR"/>
        <result property="valueType" column="value_type" jdbcType="VARCHAR"/>
        <result property="method" column="method" jdbcType="VARCHAR"/>
        <result property="manDay" column="man_day" jdbcType="INTEGER"/>
        <result property="bsm" column="bsm" jdbcType="VARCHAR"/>
        <result property="ask" column="ask" jdbcType="VARCHAR"/>
        <result property="lastValue" column="last_value" jdbcType="VARCHAR"/>
        <result property="insResult" column="ip.ins_result" jdbcType="INTEGER"/>
        <result property="state" column="state" jdbcType="INTEGER"/>
        <result property="insSampleId" column="ins_sample_id" jdbcType="INTEGER"/>
        <result property="createUser" column="ip.create_user" jdbcType="INTEGER"/>
        <result property="updateUser" column="ip.update_user" jdbcType="INTEGER"/>
        <result property="createTime" column="ip.create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="ip.update_time" jdbcType="TIMESTAMP"/>
        <result property="templateId" column="ip.template_id" jdbcType="INTEGER"/>
    </resultMap>
</mapper>