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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
<?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.mapper.TaskMapper">
<resultMap id="BaseResultMap" type="com.ruoyi.domain.Task">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="systemReviewTaskId" column="system_review_task_id" jdbcType="BIGINT"/>
<result property="carReviewTaskId" column="car_review_task_id" jdbcType="BIGINT"/>
<result property="modelTestTaskId" column="model_test_task_id" jdbcType="BIGINT"/>
<result property="taskStatus" column="task_status" jdbcType="VARCHAR"/>
<result property="runStatus" column="run_status" jdbcType="VARCHAR"/>
<result property="taskNo" column="task_no" jdbcType="VARCHAR"/>
<result property="taskName" column="task_name" jdbcType="VARCHAR"/>
<result property="confidentialityLevel" column="confidentiality_level" jdbcType="VARCHAR"/>
<result property="productName" column="product_name" jdbcType="VARCHAR"/>
<result property="productModel" column="product_model" jdbcType="VARCHAR"/>
<result property="entrustedUnit" column="entrusted_unit" jdbcType="VARCHAR"/>
<result property="entrustedUnitAddress" column="entrusted_unit_address" jdbcType="VARCHAR"/>
<result property="entrustedUnitPhone" column="entrusted_unit_phone" jdbcType="VARCHAR"/>
<result property="entrustedUnitCode" column="entrusted_unit_code" jdbcType="VARCHAR"/>
<result property="vehicleSampleInformation" column="vehicle_sample_information" jdbcType="VARCHAR"/>
<result property="partSampleInformation" column="part_sample_information" jdbcType="VARCHAR"/>
<result property="taskInitiatorId" column="task_initiator_id" jdbcType="BIGINT"/>
<result property="taskInitiator" column="task_initiator" jdbcType="VARCHAR"/>
<result property="taskInitiatorDept" column="task_initiator_dept" jdbcType="VARCHAR"/>
<result property="taskBeginTime" column="task_begin_time" jdbcType="TIMESTAMP"/>
<result property="taskEndTime" column="task_end_time" jdbcType="TIMESTAMP"/>
<result property="leaderId" column="leader_id" jdbcType="BIGINT"/>
<result property="leader" column="leader" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="standardId" column="standard_id" jdbcType="BIGINT"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="standardNo" column="standard_no" jdbcType="VARCHAR"/>
<result property="file" column="file" jdbcType="VARCHAR"/>
<result property="taskList" column="task_list" jdbcType="VARCHAR"/>
<result property="pointer" column="pointer" jdbcType="BIGINT"/>
<result property="maxPointer" column="max_pointer" jdbcType="BIGINT"/>
<result property="pictureUrl" column="picture_url" jdbcType="VARCHAR"/>
</resultMap>
<resultMap id="ResponseMap" type="com.ruoyi.web.response.TaskFindResponse">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="systemReviewTaskId" column="system_review_task_id" jdbcType="BIGINT"/>
<result property="carReviewTaskId" column="car_review_task_id" jdbcType="BIGINT"/>
<result property="modelTestTaskId" column="model_test_task_id" jdbcType="BIGINT"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="taskNo" column="task_no" jdbcType="VARCHAR"/>
<result property="taskName" column="task_name" jdbcType="VARCHAR"/>
<result property="productModel" column="product_model" jdbcType="VARCHAR"/>
<result property="taskStatus" column="task_status" jdbcType="VARCHAR"/>
<result property="runStatus" column="run_status" jdbcType="VARCHAR"/>
<result property="taskBeginTime" column="task_begin_time" jdbcType="TIMESTAMP"/>
<result property="taskEndTime" column="task_end_time" jdbcType="TIMESTAMP"/>
<result property="systemTaskBeginTime" column="system_task_begin_time" jdbcType="TIMESTAMP"/>
<result property="systemTaskEndTime" column="system_task_end_time" jdbcType="TIMESTAMP"/>
<result property="carTaskBeginTime" column="car_task_begin_time" jdbcType="TIMESTAMP"/>
<result property="carTaskEndTime" column="car_task_end_time" jdbcType="TIMESTAMP"/>
<result property="leaderId" column="leader_id" jdbcType="BIGINT"/>
<result property="leader" column="leader" jdbcType="VARCHAR"/>
<result property="reviewStatus" column="review_status" jdbcType="VARCHAR"/>
<result property="carReviewStatus" column="car_review_status" jdbcType="VARCHAR"/>
<result property="testStatus" column="test_status" jdbcType="VARCHAR"/>
<result property="testBeginTime" column="test_begin_time" jdbcType="TIMESTAMP"/>
<result property="testEndTime" column="test_end_time" jdbcType="TIMESTAMP"/>
<result property="standardNo" column="standard_no" jdbcType="BIGINT"/>
<result property="taskList" column="task_list" jdbcType="BIGINT"/>
<result property="pointer" column="pointer" jdbcType="BIGINT"/>
</resultMap>
<select id="findList" parameterType="com.ruoyi.web.request.TaskListRequest" resultMap="BaseResultMap">
SELECT id, system_review_task_id, car_review_task_id,
task_status,task_no,task_name,confidentiality_level,
product_name,product_model,
entrusted_unit,entrusted_unit_address,entrusted_unit_phone,
entrusted_unit_code,vehicle_sample_information,part_sample_information,
task_initiator_id,task_initiator,task_initiator_dept,
task_begin_time,task_end_time,create_time,
leader_id,leader,standard_id,name,
standard_no,file
FROM t_task
<where>
<if test="taskBeginTime != null and taskBeginTime != ''">
task_begin_time = #{taskBeginTime}
</if>
<if test="taskStatus != null and taskStatus != ''">
task_status = #{taskStatus}
</if>
</where>
order by create_time desc
</select>
<select id="findPending" parameterType="com.ruoyi.web.request.TaskFindPendingRequest" resultMap="ResponseMap">
SELECT t.id, t.system_review_task_id, t.car_review_task_id,t.model_test_task_id,
t.task_no,t.task_name,t.task_status,t.run_status,t.name,
t.leader_id,t.leader,
t.task_begin_time,
t.product_model,
t.standard_no,
t.task_list,
t.pointer,
srt.task_begin_time system_task_begin_time,
srt.task_end_time system_task_end_time,
srt.task_status review_status,
crt.task_begin_time car_task_begin_time,
crt.task_end_time car_task_end_time,
crt.task_status car_review_status,
mtt.task_begin_time test_begin_time,
mtt.task_end_time test_end_time,
mtt.task_status test_status,
mtt.test_scheme_id testSchemeId
FROM t_task t
left join t_system_review_task srt on t.system_review_task_id = srt.id
left join t_car_review_task crt on t.car_review_task_id = crt.id
left join t_model_test_task mtt on t.model_test_task_id = mtt.id
<where>
t.id IN (
SELECT task_id FROM t_task_user_relation WHERE user_id = #{userId}
)
and t.task_status IN ("NEW","PENDING")
<if test="request.standardId != null and request.standardId != ''">
and t.standard_id = #{request.standardId}
</if>
<if test="request.taskNo != null and request.taskNo != ''">
and t.task_no like concat('%',#{request.taskNo},'%')
</if>
<if test="request.taskName != null and request.taskName != ''">
and t.task_name like concat('%',#{request.taskName},'%')
</if>
<if test="request.productModel != null and request.productModel != ''">
and t.product_model like concat('%',#{request.productModel},'%')
</if>
<if test="request.inspectionItem != null and request.inspectionItem != ''">
and t.task_list like concat('%',#{request.inspectionItem},'%')
</if>
</where>
order by t.create_time desc
</select>
<select id="findFinish" parameterType="com.ruoyi.web.request.TaskFindFinishRequest" resultType="com.ruoyi.domain.Task">
SELECT t.id, t.system_review_task_id, t.car_review_task_id,t.model_test_task_id,
t.task_no,t.task_name,t.task_status,t.name,
t.product_model,
t.standard_no,
t.task_list,
t.leader_id,t.leader,
t.task_begin_time,t.task_end_time
FROM t_task t
<where>
t.task_status IN ("FINISH")
<if test="standardId != null and standardId != ''">
and t.standard_id = #{standardId}
</if>
<if test="taskNo != null and taskNo != ''">
and t.task_no like concat('%',#{taskNo},'%')
</if>
<if test="taskName != null and taskName != ''">
and t.task_name like concat('%',#{taskName},'%')
</if>
<if test="productModel != null and productModel != ''">
and t.product_model like concat('%',#{productModel},'%')
</if>
<if test="inspectionItem != null and inspectionItem != ''">
and t.task_list like concat('%',#{inspectionItem},'%')
</if>
</where>
order by t.task_begin_time desc
</select>
<select id="findByCarReviewTaskId" resultType="java.lang.Long">
SELECT id
FROM t_task
WHERE car_review_task_id = #{carReviewId}
</select>
<select id="findBySystemReviewTaskId" resultType="java.lang.Long">
SELECT id
FROM t_task
WHERE system_review_task_id = #{systemReviewId}
</select>
<select id="findByUserId" resultMap="ResponseMap">
SELECT t.id, t.system_review_task_id, t.car_review_task_id,t.model_test_task_id,
t.task_no,t.task_name,t.task_status,t.run_status,t.name,
t.product_model,
t.leader_id,t.leader,
t.task_begin_time,
t.task_end_time,
t.standard_no,
t.task_list,
t.pointer,
srt.task_begin_time system_task_begin_time,
srt.task_end_time system_task_end_time,
srt.task_status review_status,
crt.task_begin_time car_task_begin_time,
crt.task_end_time car_task_end_time,
crt.task_status car_review_status,
mtt.task_begin_time test_begin_time,
mtt.task_end_time test_end_time,
mtt.task_status test_status,
mtt.test_scheme_id testSchemeId
FROM t_task t
left join t_system_review_task srt on t.system_review_task_id = srt.id
left join t_car_review_task crt on t.car_review_task_id = crt.id
left join t_model_test_task mtt on t.model_test_task_id = mtt.id
<where>
and t.task_initiator_id = #{userId}
and t.task_status not in ("TEMPORARILY")
<if test="request.standardId != null and request.standardId != ''">
and t.standard_id = #{request.standardId}
</if>
<if test="request.taskNo != null and request.taskNo != ''">
and t.task_no like concat('%',#{request.taskNo},'%')
</if>
<if test="request.taskName != null and request.taskName != ''">
and t.task_name like concat('%',#{request.taskName},'%')
</if>
<if test="request.productModel != null and request.productModel != ''">
and t.product_model like concat('%',#{request.productModel},'%')
</if>
<if test="request.inspectionItem != null and request.inspectionItem != ''">
and t.task_list like concat('%',#{request.inspectionItem},'%')
</if>
<if test="request.taskStatus != null and request.taskStatus != ''">
and t.task_status = #{request.taskStatus}
</if>
</where>
order by t.create_time desc
</select>
<select id="findUserFinish" parameterType="com.ruoyi.web.request.TaskFindFinishRequest" resultType="com.ruoyi.domain.Task">
SELECT t.id, t.system_review_task_id, t.car_review_task_id,t.model_test_task_id,
t.task_no,t.task_name,t.task_status,t.name,
t.standard_no,
t.product_model,
t.task_list,
t.leader_id,t.leader,
t.task_begin_time,t.task_end_time
FROM t_task t
<where>
t.id IN (
SELECT task_id FROM t_task_user_relation WHERE user_id = #{userId}
)
and t.task_status = 'FINISH'
<if test="request.standardId != null and request.standardId != ''">
and t.standard_id = #{request.standardId}
</if>
<if test="request.taskNo != null and request.taskNo != ''">
and t.task_no like concat('%',#{request.taskNo},'%')
</if>
<if test="request.taskName != null and request.taskName != ''">
and t.task_name like concat('%',#{request.taskName},'%')
</if>
<if test="request.productModel != null and request.productModel != ''">
and t.product_model like concat('%',#{request.productModel},'%')
</if>
<if test="request.inspectionItem != null and request.inspectionItem != ''">
and t.task_list like concat('%',#{request.inspectionItem},'%')
</if>
</where>
order by t.task_begin_time desc
</select>
<select id="getByUserIdTemporary" resultType="com.ruoyi.domain.Task">
SELECT id, system_review_task_id, car_review_task_id,model_test_task_id,
task_status,run_status,task_no,task_name,confidentiality_level,
product_name,product_model,
entrusted_unit,entrusted_unit_address,entrusted_unit_phone,
entrusted_unit_code,vehicle_sample_information,part_sample_information,
task_initiator_id,task_initiator,task_initiator_dept,
task_begin_time,task_end_time,create_time,
leader_id,leader,standard_id,name,
standard_no,file,task_list
FROM t_task
WHERE task_initiator_id = #{userId} and task_status = 'TEMPORARILY'
</select>
<select id="getBySubtaskId" resultType="com.ruoyi.domain.Task">
SELECT id, system_review_task_id, car_review_task_id,model_test_task_id,
task_status,run_status,task_no,task_name,confidentiality_level,
product_name,product_model,
entrusted_unit,entrusted_unit_address,entrusted_unit_phone,
entrusted_unit_code,vehicle_sample_information,part_sample_information,
task_initiator_id,task_initiator,task_initiator_dept,
task_begin_time,task_end_time,create_time,
leader_id,leader,standard_id,name,
standard_no,file,task_list
FROM t_task
WHERE system_review_task_id = #{subId} OR car_review_task_id = #{subId} OR model_test_task_id = #{subId}
</select>
<select id="findTaskName" resultType="java.lang.Long">
select COUNT(*) sum from t_task
where task_name = #{taskName}
</select>
<select id="selectEnterpriseFileData" resultType="com.ruoyi.domain.vo.EnterpriseFilePdfVO">
select
t.task_initiator_dept inspectionCenterName,
concat(s.standard_no, ' ', s.name) inspectionBasis,
t.task_list inspectionItem,
DATE_FORMAT(t.create_time, '%Y-%m-%d') createTime,
t.entrusted_unit clientName
from
t_task t
left join t_standard s on t.standard_id = s.id
where t.id = #{taskId}
</select>
<select id="selectInspectionReportData" resultType="com.ruoyi.domain.vo.InspectionReportPdfVO">
select
t.id AS reportNumber,
t.product_name AS productName,
t.product_model AS productModel,
t.entrusted_unit AS entrustedUnit,
t.entrusted_unit_address AS clientAddress,
t.entrusted_unit_phone AS entrustedUnitTelephone,
t.entrusted_unit_code AS clientPostalCode,
SUBSTRING_INDEX(GROUP_CONCAT(s.sample_name), ',', 1) AS sampleName,
t.product_model AS typeSpecification,
DATE_FORMAT(t.task_begin_time, '%Y年%m月%d日') AS taskBeginTime,
DATE_FORMAT(t.task_end_time, '%Y年%m月%d日') AS taskEndTime,
concat(st.standard_no, ' ', st.name) AS inspectionBasis,
SUBSTRING_INDEX(GROUP_CONCAT(distinct ae.enterprise_name), ',', 1) AS productionEnterprise,
SUBSTRING_INDEX(GROUP_CONCAT(s.sample_sender), ',', 1) AS sampleSender,
SUBSTRING_INDEX(GROUP_CONCAT(distinct DATE_FORMAT(s.delivery_date, '%Y-%m-%d')), ',', 1) AS sampleDeliveryDate,
sum(CASE WHEN s.flag = '0' THEN 1 ELSE 0 END) AS sampleQuantity,
CONVERT(sum(CASE WHEN s.flag = '0' THEN s.number_of_samples ELSE 0 END), UNSIGNED) AS sampleSum,
GROUP_CONCAT(distinct DATE_FORMAT(s.manufacture_date, '%Y-%m-%d')) AS sampleDeliveryDate,
t.product_model AS vehicleModel,
t.id AS taskNumber,
GROUP_CONCAT(distinct s.sample_number) AS sampleNumberSummary,
GROUP_CONCAT(distinct s.identification_code) AS vehicleIdentificationNumber,
t.task_list AS inspectionItem,
DATE_FORMAT(t.create_time, '%Y-%m-%d') AS productionDate,
GROUP_CONCAT(distinct s.trademark) AS brandImage,
GROUP_CONCAT(s.sample_photos) AS samplePhotos,
d.address AS inspectionCenterAddress,
d.phone AS inspectionCenterTelephone,
d.postcode AS inspectionCenterPostcode,
d.dept_name AS inspectionCenterName
from
t_task t
left join t_task_sample_relation tsr on t.id = tsr.task_id
left join t_sample s on tsr.sample_id = s.id
left join t_automobile_enterprise ae on s.manufacturing_enterprise_id = ae.id
left join t_standard st on t.standard_id = st.id
left join sys_user u on t.task_initiator_id = u.user_id
left join sys_dept d on u.dept_id = d.dept_id
where t.id = #{taskId}
group by t.id
</select>
<select id="findByName" resultType="com.ruoyi.domain.Task">
SELECT id, system_review_task_id, car_review_task_id,model_test_task_id,
task_status,run_status,task_no,task_name,confidentiality_level,
product_name,product_model,
entrusted_unit,entrusted_unit_address,entrusted_unit_phone,
entrusted_unit_code,vehicle_sample_information,part_sample_information,
task_initiator_id,task_initiator,task_initiator_dept,
task_begin_time,task_end_time,create_time,
leader_id,leader,standard_id,name,
standard_no,file,task_list
FROM t_task
WHERE task_name = #{taskName}
</select>
<select id="findByTaskList" resultType="com.ruoyi.web.response.TaskScenarioResponse">
SELECT COUNT(*) num, task_id as taskId FROM t_task_scenario_relation
WHERE task_id IN
<foreach item="item" collection="responses" open="(" separator="," close=")">
#{item.id}
</foreach>
GROUP BY task_id
</select>
<select id="findByUserIdList" resultType="com.ruoyi.web.response.UserNameResponse">
SELECT s.user_id userId, s.nick_name name, sd.dept_name deptName
FROM sys_user s
LEFT JOIN sys_dept sd ON s.dept_id = sd.dept_id
WHERE s.user_id IN
<foreach item="item" collection="responses" open="(" separator="," close=")">
#{item.leaderId}
</foreach>
</select>
<select id="findByRelation" resultType="com.ruoyi.web.response.UserNameResponse">
SELECT s.user_id userId, s.nick_name name, sd.dept_name deptName
FROM sys_user s
LEFT JOIN sys_dept sd ON s.dept_id = sd.dept_id
WHERE s.user_id IN
<foreach item="item" collection="relation" open="(" separator="," close=")">
#{item.userId}
</foreach>
</select>
<select id="findByFinishTaskList" resultType="com.ruoyi.web.response.UserNameResponse">
SELECT s.user_id userId, s.nick_name name, sd.dept_name deptName
FROM sys_user s
LEFT JOIN sys_dept sd ON s.dept_id = sd.dept_id
WHERE s.user_id IN
<foreach item="item" collection="taskList" open="(" separator="," close=")">
#{item.leaderId}
</foreach>
</select>
<select id="selectTestConclusion" parameterType="java.lang.Long" resultType="com.ruoyi.domain.vo.TestConclusionVO">
select
srt.task_result AS systemReviewTaskResult,
DATE_FORMAT(srt.task_end_time, '%Y-%m-%d') AS systemReviewTaskDate,
crt.task_result AS carReviewTaskResult,
DATE_FORMAT(crt.task_end_time, '%Y-%m-%d') AS carReviewTaskDate,
mtt.task_result AS modelTestTaskResult,
DATE_FORMAT(mtt.task_end_time, '%Y-%m-%d') AS modelTestTaskDate
from
t_task t
left join t_system_review_task srt on t.system_review_task_id = srt.id
left join t_car_review_task crt on t.car_review_task_id = crt.id
left join t_model_test_task mtt on t.model_test_task_id = mtt.id
where
t.id = #{taskId}
</select>
<select id="selectInspectionPersonnelById" parameterType="java.lang.Long" resultType="com.ruoyi.domain.vo.InspectionPersonnelVO">
select
su.nick_name AS principal,
GROUP_CONCAT(distinct u.nick_name) AS inspectionPersonnel,
DATE_FORMAT(mtt.task_end_time, '%Y-%m-%d') AS inspectionDate
from
t_task t
left join t_task_user_relation tur on t.id = tur.task_id
left join sys_user u on tur.user_id = u.user_id
left join sys_user su on t.leader_id = su.user_id
left join t_model_test_task mtt on t.model_test_task_id = mtt.id
where
t.id = #{taskId}
group by t.id
</select>
<select id="taskStateDistribution" resultType="com.ruoyi.web.response.TaskStateDistributionResponse">
select task_status, count(*) number from t_task
where task_status not in ("TEMPORARILY")
group by task_status
</select>
<select id="entrustedUnitDistribution" resultType="com.ruoyi.web.response.EntrustedUnitResponse">
select
entrusted_unit,
count(*) number
from
t_task
where
task_status not in ("TEMPORARILY")
group by entrusted_unit
</select>
</mapper>