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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<?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="cn.wise.sc.cement.business.mapper.EntrustMapper">
<sql id="where">
<where>
and e.is_delete = 1
<if test="params.startDate != null and params.startDate != ''">
and DATE(e.entrust_date) >= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and DATE(e.entrust_date) <= #{params.endDate}
</if>
<if test="params.status != null">
and e.status = #{params.status}
</if>
<if test="params.reportStatus != null">
and e.status <![CDATA[>=]]> #{params.reportStatus}
</if>
<if test="params.clientName != null and params.clientName != ''">
and c.name like concat('%', #{params.clientName}, '%')
</if>
<if test="params.projectName != null and params.projectName != ''">
and p.name like concat('%', #{params.projectName}, '%')
</if>
<if test="params.projectCode != null and params.projectCode != ''">
and p.code like concat('%', #{params.projectCode}, '%')
</if>
<if test="params.userId != null">
and e.user_id = #{params.userId}
</if>
<if test="params.projectType != null and params.projectType != ''">
and e.project_type = #{params.projectType}
</if>
<if test="params.isUrgent != null">
and e.is_urgent = #{params.isUrgent}
</if>
</where>
</sql>
<select id="getPage" resultType="cn.wise.sc.cement.business.model.vo.EntrustVo">
select e.*, c.name as clientName, su.name as userName,
(
CASE e.status
WHEN 0 THEN '未评审'
WHEN 1 THEN '已通过'
WHEN 2 THEN '未通过'
WHEN 3 THEN '样品处理中'
WHEN 4 THEN '样品处理完成'
WHEN 5 THEN '样品检测中'
WHEN 6 THEN '样品检测完成'
WHEN 7 THEN '校核中'
WHEN 8 THEN '校核完成'
ELSE ''
END
) as statusValue
from entrust e
left join project p on p.id = e.project_id
left join client c on c.id = e.client_id
left join sys_user su on su.id = e.user_id
<include refid="where"/>
order by e.is_urgent desc, e.update_time desc
</select>
<select id="exportList" resultType="java.util.HashMap">
SELECT
(@i:=@i+1) as 序号,
e.id as entrustId,
IF(ISNULL(e.entrust_code),'',e.entrust_code) as 委托编号,
(
CASE e.is_urgent
WHEN 0 THEN '不加急'
WHEN 1 THEN '加急'
ELSE NULL
END
) as 是否加急,
IF(ISNULL(e.project_name),'',e.project_name) as 项目名称,
IF(ISNULL(e.project_code),'',e.project_code) as 项目编号,
IF(ISNULL(su.name),'',su.name) su.name as 委托人,
IF(ISNULL(c.name),'',c.name) c.name as 委托单位,
IF(ISNULL(e.entrust_date),'',e.entrust_date) as 委托日期,
IF(ISNULL(e.sample_num),'',e.sample_num) as 样品数量,
(
CASE e.status
WHEN 0 THEN '未评审'
WHEN 1 THEN '已通过'
WHEN 2 THEN '未通过'
WHEN 3 THEN '样品处理中'
WHEN 4 THEN '样品处理完成'
WHEN 5 THEN '样品检测中'
WHEN 6 THEN '样品检测完成'
WHEN 7 THEN '校核中'
WHEN 8 THEN '校核完成'
ELSE ''
END
) as 状态
from entrust e
left join project p on p.id = e.project_id
left join client c on c.id = e.client_id
left join sys_user su on su.id = e.user_id
,(select @i:=0)aa
<include refid="where"/>
order by 序号,e.is_urgent desc, e.update_time desc
</select>
<select id="getDetail" resultType="cn.wise.sc.cement.business.model.vo.EntrustVo">
select e.*,
(
CASE e.status
WHEN 0 THEN '未评审'
WHEN 1 THEN '已通过'
WHEN 2 THEN '未通过'
WHEN 3 THEN '样品处理中'
WHEN 4 THEN '样品处理完成'
WHEN 5 THEN '样品检测中'
WHEN 6 THEN '样品检测完成'
WHEN 7 THEN '校核中'
WHEN 8 THEN '校核完成'
ELSE ''
END
) as statusValue,
p.name as projectName, c.name as clientName, su.name as userName,
su.phone as userPhone, su.fax as userFax
from entrust e
left join project p on p.id = e.project_id
left join client c on c.id = e.client_id
left join sys_user su on su.id = e.user_id
where e.id = #{id}
</select>
<select id="getSampleHandlePage" resultType="cn.wise.sc.cement.business.model.vo.EntrustVo">
select e.id as id, e.entrust_code as entrustCode, e.sample_num as sampleNum,e.entrust_date as entrustDate,
e.status,
(
CASE e.status
WHEN 0 THEN '未评审'
WHEN 1 THEN '已通过'
WHEN 2 THEN '未通过'
WHEN 3 THEN '样品处理中'
WHEN 4 THEN '样品处理完成'
WHEN 5 THEN '样品检测中'
WHEN 6 THEN '样品检测完成'
WHEN 7 THEN '校核中'
WHEN 8 THEN '校核完成'
ELSE ''
END
) as statusValue,
p.id as projectId, p.name as projectName, p.code as projectCode,
su.name as userName
from sample_handle t
left join sys_user su on su.id = t.user_id
left join sample s on s.id = t.sample_id
left join entrust e on e.id = s.entrust_id
left join project p on p.id = e.project_id
where 1=1
<if test="params.userId != null">
and t.user_id = #{params.userId}
</if>
<if test="params.projectCode != null and params.projectCode != ''">
and p.code like concat('%', #{params.projectCode}, '%')
</if>
group by e.id
order by e.update_time desc
</select>
<select id="getSampleDistributionPage" resultType="cn.wise.sc.cement.business.model.vo.EntrustVo">
select e.id as id, e.entrust_code as entrustCode, e.sample_num as sampleNum,e.entrust_date as entrustDate,
e.status,
(
CASE e.status
WHEN 0 THEN '未评审'
WHEN 1 THEN '已通过'
WHEN 2 THEN '未通过'
WHEN 3 THEN '样品处理中'
WHEN 4 THEN '样品处理完成'
WHEN 5 THEN '样品检测中'
WHEN 6 THEN '样品检测完成'
WHEN 7 THEN '校核中'
WHEN 8 THEN '校核完成'
ELSE ''
END
) as statusValue,
p.id as projectId, p.name as projectName, p.code as projectCode,
su.name as userName
from sample_distribution t
left join sys_user su on su.id = t.user_id
left join sample s on s.id = t.sample_id
left join entrust e on e.id = s.entrust_id
left join project p on p.id = e.project_id
where 1=1
<if test="params.userId != null">
and t.user_id = #{params.userId}
</if>
<if test="params.projectCode != null and params.projectCode != ''">
and p.code like concat('%', #{params.projectCode}, '%')
</if>
<if test="params.projectName != null and params.projectName != ''">
and p.name like concat('%', #{params.projectName}, '%')
</if>
GROUP BY e.id
order by e.update_time desc
</select>
<!--数据校核分页列表-->
<select id="getCheckPage" resultType="cn.wise.sc.cement.business.model.vo.EntrustVo">
select e.*, p.name as projectName, c.name as clientName, su.name as userName,
(
CASE e.status
WHEN 0 THEN '未评审'
WHEN 1 THEN '已通过'
WHEN 2 THEN '未通过'
WHEN 3 THEN '样品处理中'
WHEN 4 THEN '样品处理完成'
WHEN 5 THEN '样品检测中'
WHEN 6 THEN '样品检测完成'
WHEN 7 THEN '校核中'
WHEN 8 THEN '校核完成'
ELSE ''
END
) as statusValue
from entrust e
left join project p on p.id = e.project_id
left join client c on c.id = e.client_id
left join sys_user su on su.id = e.user_id
<include refid="checkWhere"/>
order by e.update_time desc
</select>
<select id="getReportDetail" resultType="cn.wise.sc.cement.business.entity.EntrustReport">
SELECT e.id,e.project_name,e.send_name,e.client_id,e.entrust_code,e.project_type,sscct.* FROM entrust e
RIGHT JOIN
(SELECT id,entrust_id,team_ids,method_numbers,name,scct.check_id,
scct.equipment_name,scct.user_id,create_time as send_time,scct.equipment_id FROM sample s
RIGHT JOIN
(SELECT check_id,equipment_name,sample_id,user_id,equipment_id FROM sample_check_team sct
RIGHT JOIN
(SELECT entrust_id,id FROM sample_check WHERE entrust_id = #{entrustId}) sc
ON sct.check_id = sc.id ) scct
ON s.id = scct.sample_id) sscct
ON sscct.entrust_id = e.id
WHERE e.id IS NOT NULL
</select>
<select id="getQualityDetail" resultType="cn.wise.sc.cement.business.entity.QualityDetail">
SELECT s.sample_name,s.cement_code,s.sample_form,s.sample_code,esscct.* FROM (SELECT
sscct.*,client_id,entrust_code,project_name,sample_num,send_name,send_phone,create_time FROM entrust e
RIGHT JOIN
(SELECT count_result as input_result,sample_id,entrust_id,team_group_name,team_group_id,user_id FROM
sample_check sc
RIGHT JOIN
(SELECT * FROM sample_check_team) sct
ON sct.check_id = sc.id WHERE sc.entrust_id = #{entrustId}) sscct
ON e.id = sscct.entrust_id) esscct
LEFT JOIN
(SELECT name as sample_name,id,cement_code,sample_form,sample_code FROM sample) s
ON esscct.sample_id = s.id
</select>
<sql id="checkWhere">
<where>
and e.is_delete = 1 and e.status >= 6
<if test="params.startDate != null and params.startDate != ''">
and DATE(e.entrust_date) >= #{params.startDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and DATE(e.entrust_date) <= #{params.endDate}
</if>
<if test="params.status != null">
and e.status = #{params.status}
</if>
<if test="params.clientId != null">
and e.client_id = #{params.clientId}
</if>
<if test="params.projectName != null and params.projectName != ''">
and p.name like concat('%', #{params.projectName}, '%')
</if>
<if test="params.projectCode != null and params.projectCode != ''">
and p.code like concat('%', #{params.projectCode}, '%')
</if>
<if test="params.userId != null">
and e.user_id = #{params.userId}
</if>
</where>
</sql>
</mapper>