郑永安
2023-06-19 7a6abd05683528032687c75e80e0bd2030a3e46c
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
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
<?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.gkhy.safePlatform.specialWork.repository.WorkApplyInfoRepository" >
    <resultMap id="WorkApplyInfo" type="com.gkhy.safePlatform.specialWork.entity.WorkApplyInfo" >
        <id column="id" property="id" jdbcType="BIGINT" />
        <result column="eid" property="eid" jdbcType="BIGINT"/>
        <result column="dep_id" property="depId" jdbcType="BIGINT"/>
        <result column="dep_name" property="depName" jdbcType="VARCHAR"/>
        <result column="apply_uid" property="applyUid" jdbcType="BIGINT"/>
        <result column="apply_uname" property="applyUname" jdbcType="VARCHAR"/>
        <result column="work_permit_no" property="workPermitNo" jdbcType="VARCHAR"/>
        <result column="work_type" property="workType" jdbcType="TINYINT"/>
        <result column="work_level" property="workLevel" jdbcType="TINYINT"/>
        <result column="work_content" property="workContent" jdbcType="VARCHAR"/>
        <result column="work_location" property="workLocation" jdbcType="VARCHAR"/>
        <result column="hazard_identification" property="hazardIdentification" jdbcType="VARCHAR"/>
        <result column="work_detail_id" property="workDetailId" jdbcType="BIGINT"/>
        <result column="status" property="status" jdbcType="TINYINT"/>
        <result column="approval_step" property="approvalStep" jdbcType="INTEGER"/>
        <result column="apply_time" property="applyTime" jdbcType="TIMESTAMP"/>
        <result column="operator_uid" property="operatorUid" jdbcType="TINYINT"/>
        <result column="operator_uname" property="operatorUname" jdbcType="VARCHAR"/>
        <result column="exp_start_time" property="expStartTime" jdbcType="TIMESTAMP"/>
        <result column="exp_end_time" property="expEndTime" jdbcType="TIMESTAMP"/>
        <result column="gmt_create" property="gmtCreate" jdbcType="TIMESTAMP"/>
        <result column="gmt_modified" property="gmtModified" jdbcType="TIMESTAMP"/>
        <result column="ma_base_id" property="maBaseId" jdbcType="BIGINT"/>
        <result column="material_status" property="materialStatus" jdbcType="TINYINT"/>
    </resultMap>
 
    <resultMap id="WorkApplyInfoBO" type="com.gkhy.safePlatform.specialWork.model.bo.WorkApplyPendingInfoBO" >
        <id column="id" property="workApplyId" jdbcType="BIGINT" />
        <result column="eid" property="eid" jdbcType="BIGINT"/>
        <result column="dep_id" property="depId" jdbcType="BIGINT"/>
        <result column="dep_name" property="depName" jdbcType="VARCHAR"/>
        <result column="apply_uid" property="applyUid" jdbcType="BIGINT"/>
        <result column="apply_uname" property="applyUname" jdbcType="VARCHAR"/>
        <result column="work_permit_no" property="workPermitNo" jdbcType="VARCHAR"/>
        <result column="work_type" property="workType" jdbcType="TINYINT"/>
        <result column="work_level" property="workLevel" jdbcType="TINYINT"/>
        <result column="work_content" property="workContent" jdbcType="VARCHAR"/>
        <result column="work_location" property="workLocation" jdbcType="VARCHAR"/>
        <result column="hazard_identification" property="hazardIdentification" jdbcType="VARCHAR"/>
        <result column="work_detail_id" property="workDetailId" jdbcType="BIGINT"/>
        <result column="status" property="status" jdbcType="TINYINT"/>
        <result column="approval_step" property="approvalStep" jdbcType="INTEGER"/>
        <result column="apply_time" property="applyTime" jdbcType="TIMESTAMP"/>
        <result column="operator_uid" property="operatorUid" jdbcType="TINYINT"/>
        <result column="operator_uname" property="operatorUname" jdbcType="VARCHAR"/>
        <result column="exp_start_time" property="expStartTime" jdbcType="TIMESTAMP"/>
        <result column="exp_end_time" property="expEndTime" jdbcType="TIMESTAMP"/>
        <result column="gmt_create" property="gmtCreate" jdbcType="TIMESTAMP"/>
        <result column="gmt_modified" property="gmtModified" jdbcType="TIMESTAMP"/>
        <result column="step_id" property="stepId" jdbcType="BIGINT"/>
        <result column="step_type" property="stepType" jdbcType="TINYINT"/>
        <result column="step_approval_result" property="stepApprovalResult" jdbcType="TINYINT"/>
        <result column="step_serial" property="stepSerial" jdbcType="INTEGER"/>
        <result column="step_start_approval_time" property="stepStartApprovalTime" jdbcType="TIMESTAMP"/>
        <result column="step_finish_approval_time" property="stepFinishApprovalTime" jdbcType="TIMESTAMP"/>
        <result column="step_exp_finish_approval_time" property="stepExpFinishApprovalTime" jdbcType="TIMESTAMP"/>
        <result column="pre_step_id" property="preStepId" jdbcType="BIGINT"/>
        <result column="next_step_id" property="nextStepId" jdbcType="BIGINT"/>
        <result column="is_contain_item" property="containItem" jdbcType="TINYINT"/>
        <result column="unit_id" property="unitId" jdbcType="BIGINT"/>
        <result column="unit_approval_uid" property="unitApprovalUid" jdbcType="BIGINT"/>
        <result column="unit_approval_uname" property="unitApprovalUname" jdbcType="VARCHAR"/>
        <result column="unit_result" property="unitResult" jdbcType="TINYINT"/>
        <result column="unit_approval_start_time" property="unitApprovalStartTime" jdbcType="TIMESTAMP"/>
        <result column="unit_approval_end_time" property="unitApprovalEndTime" jdbcType="TIMESTAMP"/>
        <result column="unit_approval_actual_time" property="unitApprovalActualTime" jdbcType="TIMESTAMP"/>
        <result column="unit_fill_content" property="unitFillContent" jdbcType="VARCHAR"/>
        <result column="material_status" property="materialStatus" jdbcType="TINYINT"/>
 
    </resultMap>
 
 
    <resultMap id="WorkApplyReportableDO" type="com.gkhy.safePlatform.specialWork.entity.WorkApplyReportableDO">
        <result column="id" property="id" />
        <result column="work_type" property="workType" />
        <result column="work_level" property="workLevel" />
        <result column="work_permit_no" property="workPermitNo" />
        <result column="work_content" property="workContent" />
        <result column="work_location" property="workLocation" />
        <result column="exp_start_time" property="expStartTime" />
        <result column="exp_end_time" property="expEndTime" />
        <result column="hazard_identification" property="hazardIdentification" />
        <result column="status" property="status" />
    </resultMap>
 
    <insert id="insertWorkApplyInfo"
            parameterType="com.gkhy.safePlatform.specialWork.entity.WorkApplyInfo">
        insert
        into  work_apply
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="depId != null">
                dep_id,
            </if>
            <if test="applyUid != null">
                apply_uid,
            </if>
            <if test="workType != null">
                work_type,
            </if>
            <if test="workLevel != null">
                work_level,
            </if>
            <if test="status != null">
                status,
            </if>
            <if test="approvalStep != null">
                approval_step,
            </if>
            <if test="applyTime != null">
                apply_time,
            </if>
            <if test="expStartTime != null">
                exp_start_time,
            </if>
            <if test="expEndTime != null">
                exp_end_time,
            </if>
            <if test="gmtCreate != null">
                gmt_create,
            </if>
            <if test="approvalStepId != null">
                approval_step_id,
            </if>
            <if test="operatorUname != null">
                operator_uname,
            </if>
            <if test="applyUname != null">
                apply_uname,
            </if>
            <if test="depName != null">
                dep_name,
            </if>
            <if test="operatorUid != null">
                operator_uid,
            </if>
            <if test="workPermitNo != null">
                work_permit_no,
            </if>
            <if test="workContent != null">
                work_content,
            </if>
            <if test="workLocation != null">
                work_location,
            </if>
            <if test="hazardIdentification != null">
                hazard_identification,
            </if>
            <if test="workDetailId != null">
                work_detail_id,
            </if>
            <if test="maBaseId != null">
                ma_base_id,
            </if>
            <if test="materialStatus != null">
                material_status,
            </if>
 
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id},
            </if>
            <if test="depId != null">
                #{depId},
            </if>
            <if test="applyUid != null">
                #{applyUid},
            </if>
            <if test="workType != null">
                #{workType},
            </if>
            <if test="workLevel != null">
                #{workLevel},
            </if>
            <if test="status != null">
                #{status},
            </if>
            <if test="approvalStep != null">
                #{approvalStep},
            </if>
            <if test="applyTime != null">
                #{applyTime},
            </if>
            <if test="expStartTime != null">
                #{expStartTime},
            </if>
            <if test="expEndTime != null">
                #{expEndTime},
            </if>
            <if test="gmtCreate != null">
                #{gmtCreate},
            </if>
            <if test="approvalStepId != null">
                #{approvalStepId},
            </if>
            <if test="operatorUname != null">
                #{operatorUname},
            </if>
            <if test="applyUname != null">
                #{applyUname},
            </if>
            <if test="depName != null">
                #{depName},
            </if>
            <if test="operatorUid != null">
                #{operatorUid},
            </if>
            <if test="workPermitNo != null">
                #{workPermitNo},
            </if>
            <if test="workContent != null">
                #{workContent},
            </if>
            <if test="workLocation != null">
                #{workLocation},
            </if>
            <if test="hazardIdentification != null">
                #{hazardIdentification},
            </if>
            <if test="workDetailId != null">
                #{workDetailId},
            </if>
            <if test="maBaseId != null">
                #{maBaseId},
            </if>
            <if test="materialStatus != null">
                #{materialStatus},
            </if>
        </trim>
 
    </insert>
    <update id="updateStatusById">
        update work_apply
        set status = #{status}
        where id = #{workApplyId}
 
    </update>
    <update id="updateApprovalStepIdById">
        update work_apply
        set approval_step_id = #{nextStepId}
        where id = #{workApplyId}
 
    </update>
 
    <update id="updateApprovalStepIdToNull">
        update work_apply
        set approval_step_id = null
        where  id = #{workApplyId}
    </update>
 
    <select id="listWorkApplyInfoByPage"
            parameterType="com.gkhy.safePlatform.specialWork.model.query.db.WorkApplyApplyingPageDBQuery"
            resultMap="WorkApplyInfo">
        select
        workApply.id,
        workApply.eid,
        workApply.dep_id,
        workApply.dep_name,
        workApply.apply_uid,
        workApply.apply_uname,
        workApply.work_type,
        workApply.work_level,
        workApply.status,
        workApply.approval_step,
        workApply.approval_step_id,
        workApply.apply_time,
        workApply.exp_start_time,
        workApply.exp_end_time,
        workApply.gmt_create,
        workApply.gmt_modified,
        workApply.work_permit_no,
        workApply.operator_uid,
        workApply.operator_uname,
        workApply.operator_certificate,
        workApply.work_content,
        workApply.work_location,
        workApply.hazard_identification,
        workApply.work_detail_id,
        workApply.material_status
        from work_apply as workApply
        <where>
            <if test="query.status != null">
                and workApply.status = #{query.status}
            </if>
            <if test="query.workType != null">
                and workApply.work_type = #{query.workType}
            </if>
            <if test="query.applyUid != null">
                and workApply.apply_uid = #{query.applyUid}
            </if>
        </where>
        order by workApply.gmt_create desc
 
 
 
    </select>
    <select id="listPendingWorkApplyInfo"
            parameterType="com.gkhy.safePlatform.specialWork.model.query.db.WorkApplyPendingPageDBQuery"
            resultMap="WorkApplyInfoBO">
        select
        workApply.id,
        workApply.eid,
        workApply.dep_id,
        workApply.dep_name,
        workApply.apply_uid,
        workApply.apply_uname,
        workApply.work_type,
        workApply.work_level,
        workApply.status,
        workApply.approval_step,
        workApply.approval_step_id,
        workApply.apply_time,
        workApply.exp_start_time,
        workApply.exp_end_time,
        workApply.gmt_create,
        workApply.gmt_modified,
        workApply.work_permit_no,
        workApply.operator_uid,
        workApply.operator_uname,
        workApply.operator_certificate,
        workApply.work_content,
        workApply.work_location,
        workApply.hazard_identification,
        workApply.work_detail_id,
        workApply.material_status,
        ruleStep.id step_id,
        ruleStep.type step_type,
        ruleStep.approval_result step_approval_result,
        ruleStep.step_serial step_serial,
        ruleStep.start_approval_time step_start_approval_time,
        ruleStep.finish_approval_time step_finish_approval_time,
        ruleStep.exp_finish_approval_time step_exp_finish_approval_time,
        ruleStep.pre_step_id,
        ruleStep.next_step_id,
        ruleStep.is_contain_item,
        ruleUnit.id unit_id,
        ruleUnit.approval_uid unit_approval_uid,
        ruleUnit.approval_uname unit_approval_uname,
        ruleUnit.result unit_result,
        ruleUnit.approval_start_time unit_approval_start_time,
        ruleUnit.approval_end_time unit_approval_end_time,
        ruleUnit.approval_actual_time unit_approval_actual_time,
        ruleUnit.fill_content unit_fill_content
        from work_apply as workApply
        inner join work_approval_step as ruleStep  on ruleStep.id = workApply.approval_step_id
        inner join work_approval_unit as ruleUnit on ruleUnit.step_id = ruleStep.id  and ruleUnit.approval_uid = #{query.approvalUid}
        <where>
            status != 7
            <if test="query.status != null">
              and  workApply.status = #{query.status}
            </if>
            <if test="query.workType != null">
              and  workApply.work_type = #{query.workType}
            </if>
            <if test="query.applyUname != null">
              and  workApply.apply_uname like concat("%",#{query.applyUname},"%")
            </if>
        </where>
        order by workApply.gmt_create desc
 
 
 
    </select>
    <select id="getWorkApprovalByApprovalUid"
            resultMap="WorkApplyInfo">
        select
        workApply.id,
        workApply.eid,
        workApply.dep_id,
        workApply.dep_name,
        workApply.apply_uid,
        workApply.apply_uname,
        workApply.work_type,
        workApply.work_level,
        workApply.status,
        workApply.approval_step,
        workApply.approval_step_id,
        workApply.apply_time,
        workApply.exp_start_time,
        workApply.exp_end_time,
        workApply.gmt_create,
        workApply.gmt_modified,
        workApply.work_permit_no,
        workApply.operator_uid,
        workApply.operator_uname,
        workApply.operator_certificate,
        workApply.work_content,
        workApply.work_location,
        workApply.hazard_identification,
        workApply.material_status
        from work_apply as workApply
        inner join work_approval_step as ruleStep  on ruleStep.id = workApply.approval_step_id
        inner join work_approval_unit as ruleUnit on ruleUnit.step_id = ruleStep.id  and ruleUnit.approval_uid = #{approvalUid}
        where workApply.id = #{workApplyId}
 
    </select>
    <select id="countWorkApplyInfo" resultType="java.lang.Integer">
        select count(0)
        from work_apply
    </select>
    <select id="listReportableWorkApply"
            resultMap="WorkApplyReportableDO">
        select
        workApply.id,
        workApply.work_permit_no,
        workApply.work_type,
        workApply.work_level,
        workApply.work_content,
        workApply.work_location,
        workApply.exp_start_time,
        workApply.exp_end_time,
        workApply.hazard_identification,
        workApply.status
        from work_apply as workApply
        where workApply.status = #{query.status}
        and workApply.exp_start_time &lt; #{query.now}
        and workApply.exp_end_time  &gt; #{query.now}
        <if test="query.workPermitNo != null and query.workPermitNo != ''">
            and workApply.work_permit_no like concat("%",#{query.workPermitNo},"%")
        </if>
        <if test="query.workType != null">
            and workApply.work_type =  #{query.workType}
        </if>
    </select>
    <select id="listAllWorkApplyByPage"
            resultMap="WorkApplyInfo">
        select
        workApply.id,
        workApply.eid,
        workApply.dep_id,
        workApply.dep_name,
        workApply.apply_uid,
        workApply.apply_uname,
        workApply.work_type,
        workApply.work_level,
        workApply.status,
        workApply.approval_step,
        workApply.approval_step_id,
        workApply.apply_time,
        workApply.exp_start_time,
        workApply.exp_end_time,
        workApply.gmt_create,
        workApply.gmt_modified,
        workApply.work_permit_no,
        workApply.operator_uid,
        workApply.operator_uname,
        workApply.operator_certificate,
        workApply.work_content,
        workApply.work_location,
        workApply.hazard_identification,
        workApply.work_detail_id,
        workApply.material_status
        from work_apply as workApply
        <where>
            <if test="query.status != null">
                and workApply.status = #{query.status}
            </if>
            <if test="query.workType != null">
                and workApply.work_type = #{query.workType}
            </if>
            <if test="query.workLevel != null">
                and workApply.work_level = #{query.workLevel}
            </if>
            <if test="query.applyDepId != null">
                and workApply.dep_id = #{query.applyDepId}
            </if>
            <if test="query.applyStartTime != null">
                and workApply.apply_time &gt; #{query.applyStartTime}
            </if>
            <if test="query.applyEndTime != null">
                and workApply.apply_time &lt; #{query.applyEndTime}
            </if>
        </where>
        order by workApply.gmt_create desc
 
    </select>
    <select id="getWorkApplyCountByDep" resultType="com.gkhy.safePlatform.specialWork.entity.WorkApplyCountDO">
        select count(1) as count,dep_id,work_type from work_apply where DATE(gmt_create)  = curdate() GROUP BY dep_id,work_type;
    </select>
 
</mapper>