双重预防项目-国泰新华二开定制版
SZH
2022-08-20 f9f0687195e0fe349185437d22c495d74c8d4a20
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
<?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.project.tr.report.mapper.ReportMapper">
    <resultMap type="Report" id="deptDangers">
        <id property="reportId" column="report_id"/>
        <result property="reportName" column="report_name"/>
        <collection property="dangers" ofType="Danger" resultMap="dangers"/>
    </resultMap>
    <resultMap type="Danger" id="dangers">
        <id property="dangerId" column="danger_id"/>
        <result property="dangerLevel" column="danger_level"/>
        <result property="dangerName" column="danger_name"/>
        <result property="stage" column="stage"/>
        <result property="count" column="count"/>
        <result property="checkTime" column="check_time"/>
        <result property="rectifyStatus" column="rectify_status"/>
        <result property="rectifyUserName" column="rectify_user_name"/>
        <result property="dangerDescription" column="danger_description"/>
        <result property="whetherDanger" column="whether_danger"/>
    </resultMap>
    <resultMap type="DangerByTime" id="dangerByTime">
        <result property="dateTime" column="date_time"/>
        <result property="dangerLevel" column="danger_level"/>
        <result property="count" column="count"/>
    </resultMap>
    <resultMap type="RiskDomain" id="riskResult">
        <result property="count" column="count"/>
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="riskColor" column="risk_color"/>
        <result property="regionName" column="region_name"/>
        <result property="deptName" column="dept_name"/>
        <result property="parentId" column="parent_id"/>
        <result property="ancestors" column="ancestors"/>
    </resultMap>
    <select id="selectPublicityDanger" parameterType="long" resultMap="dangers">
        SELECT
        thdcp.register_create_time check_time,
        thdcp.danger_name danger_name,
        thdcp.rectify_status rectify_status,
        thdcp.danger_level danger_level,
        thdcp.rectify_user_name rectify_user_name,
        thdcp.danger_description danger_description
        FROM
        tr_hidden_danger_check_point thdcp
        LEFT JOIN
        sys_user su
        ON
        thdcp.rectify_user_id = su.user_id
        WHERE
        su.company_id = #{companyId}
        and
        thdcp.whether_danger = 1
    </select>
 
    <select id="selectPublicityRisk" parameterType="long" resultMap="riskResult">
        SELECT
        trcp.check_point_id id,
        trcp.evaluation_after_fengxianse risk_color,
        trl.risk_list_name name,
        tr.region_name region_name,
        sd.dept_name dept_name
        FROM
        tr_risk_check_point trcp
        LEFT JOIN
        tr_risk_evaluation_plan trep
        ON
        trcp.plan_id = trep.plan_id
        LEFT JOIN
        tr_risk_list trl
        ON
        trep.evaluation_risk_id = trl.risk_list_id
        LEFT JOIN
        tr_region tr
        ON
        trl.region_id = tr.region_id
        LEFT JOIN
        sys_dept sd
        ON
        trl.dept_id = sd.dept_id
        WHERE
        trep.company_id = #{companyId}
        AND
        trcp.review_status = 2
    </select>
    <select id="selectTroubleAcceptCount" parameterType="long" resultType="int">
        SELECT
        COUNT(1)
        FROM
        tr_hidden_danger_check_point
        WHERE
        accept_user_id = #{userId}
        AND
        accept_status = 0
    </select>
    <select id="selectTroubleRectifyCount" parameterType="long" resultType="int">
        SELECT
        COUNT(1)
        FROM
        tr_hidden_danger_check_point
        WHERE
        rectify_user_id = #{userId}
        AND
        rectify_status = 0
    </select>
    <select id="selectTroubleExamineCount" parameterType="long" resultType="int">
        SELECT
        COUNT(1)
        FROM
        tr_hidden_danger_check_point
        WHERE
        examine_user_id = #{userId}
        AND
        examine_status = 0
    </select>
    <select id="selectTroubleReportCount" parameterType="long" resultType="int">
        SELECT
        count(1)
        FROM
        tr_hidden_danger_check_point
        WHERE
        danger_sources = 2
        AND
        ((judge_user_id = #{userId} and (report_status = 0)))
 
    </select>
    <select id="selectTroubleCheckCount" parameterType="long" resultType="int">
        SELECT
        count(1)
        FROM
        tr_hidden_danger_check
        WHERE
        check_user_id = #{userId}
        AND
        plan_execute_status = 0
    </select>
    <select id="selectRiskReviewCount" parameterType="long" resultType="int">
        SELECT
        COUNT(1)
        FROM
        tr_risk_check_point
        WHERE
        review_user_id = #{userId}
        AND
        review_status = 1
        AND
        evaluation_status = 2
    </select>
    <select id="selectRiskEvaluationCount" parameterType="long" resultType="int">
        SELECT
        COUNT(1)
        FROM
        tr_risk_check_point
        WHERE
        evaluation_user_id = #{userId}
        AND
        evaluation_status = 1
    </select>
    <select id="selectRiskIdentityCount" resultType="int">
        SELECT
        count(1)
        FROM
        tr_risk_evaluation_plan
        WHERE
        company_id = #{companyId}
        AND
        stage_status = 2
        AND
        identify_status = 1
        AND
        identify_user_id = #{userId}
        AND
        plan_status = 2
    </select>
    <select id="selectDangerByRegion"  parameterType="long" resultMap="deptDangers">
        SELECT
        tr.region_id report_id,
        tr.region_name report_name,
        thdcp.id danger_id,
        thdcp.danger_level danger_level,
        thdcp.danger_name danger_name,
        thdcp.stage stage,
        thdcp.whether_danger,
        thdcp.rectify_user_name
        FROM
        tr_region tr
        LEFT JOIN
        tr_hidden_danger_check thdc
        ON
        tr.region_id = thdc.danger_place_id
        LEFT JOIN
        tr_hidden_danger_check_point thdcp
        ON
        thdcp.check_id = thdc.check_id
        WHERE
        tr.company_id = #{companyId} and tr.ancestors != '0'
        and
        tr.del_flag = '0'
    </select>
 
 
    <select id="selectDangerByRegionByCompanyId147"  parameterType="long" resultMap="deptDangers">
        SELECT
        tr.region_id report_id,
        tr.region_name report_name,
        thdcp.id danger_id,
        thdcp.danger_level danger_level,
        thdcp.danger_name danger_name,
        thdcp.stage stage,
        thdcp.whether_danger,
        thdcp.rectify_user_name
        FROM
        (SELECT region_id, parent_id, ancestors, region_name, order_num,
                leader, phone, email, status, del_flag, create_by, create_time,
                region_type,
                company_unified_social_credit_code, company_business_license,
                company_registered_address_of_business_license, company_scale, company_number_of_employees,
                company_established, company_area, company_registered_capital, company_total_assets,
                company_actual_income_of_the_previous_year, company_annual_profit, company_economic_type,
                company_industry, company_legal_representative, company_corporate_position, company_legal_person_phone,
                company_corporate_office_phone, company_person_in_charge_of_rectification, company_rectifier_phone,
                company_organizer, company_group_company_name, company_security_function, company_postal_code,
                company_introduction, company_other
        from  tr_region where parent_id = 1215 and  company_id = 147)  as tr
        LEFT JOIN
        tr_hidden_danger_check thdc
        ON
        tr.region_id = thdc.danger_place_id
        LEFT JOIN
        tr_hidden_danger_check_point thdcp
        ON
        thdcp.check_id = thdc.check_id
        WHERE
        tr.company_id = #{companyId} and tr.ancestors != '0'
        and
        tr.del_flag = '0'
    </select>
 
 
    <select id="selectRiskPoint" resultMap="riskResult">
        SELECT
        COUNT(1) count,
        trt.risk_type_id id,
        trt.risk_type_name name,
        trcp.evaluation_after_fengxianse risk_color
        FROM
        tr_risk_type trt
        LEFT JOIN
        tr_risk_list trl
        ON
        <if test="riskType == 1">trt.risk_type_id = trl.risk_list_device_type</if>
        <if test="riskType == 2">trt.risk_type_id = trl.risk_list_work_type</if>
        <if test="riskType == 3">trt.risk_type_id = trl.risk_list_crafts_type</if>
        LEFT JOIN
        tr_risk_evaluation_plan trep
        ON
        trl.risk_list_id = trep.evaluation_risk_id
        LEFT JOIN
        tr_risk_check_point trcp
        ON
        trep.plan_id = trcp.plan_id
        WHERE
        trt.risk_type_type = #{riskType}
        AND
        trt.company_id = #{companyId}
        AND
        trcp.review_status = 2
        GROUP BY
        trt.risk_type_id
        ORDER BY
        trt.risk_type_id
        ASC
    </select>
    <select id="selectRiskTrend" parameterType="long" resultMap="riskResult">
        SELECT
        COUNT(1) count,
        trcp.check_point_id id,
        DATE_FORMAT(trcp.create_time, '%Y') name,
        trcp.evaluation_after_fengxianse risk_color
        FROM
        tr_risk_check_point trcp
        WHERE
        trcp.plan_id
        in
        (
        SELECT
        trep.plan_id
        FROM
        sys_dept sd
        LEFT JOIN
        tr_risk_list trl
        ON
        sd.dept_id = trl.dept_id
        LEFT JOIN
        tr_risk_evaluation_plan trep
        ON
        trl.risk_list_id = trep.evaluation_risk_id
        WHERE
        sd.company_id = #{companyId}
        )
        AND
        trcp.review_status = 2
        GROUP BY
        DATE_FORMAT(trcp.create_time, '%Y'),
        trcp.evaluation_after_fengxianse
        ORDER BY
        DATE_FORMAT(trcp.create_time, '%Y')
        ASC
    </select>
    <select id="selectRiskByRegion" parameterType="long" resultMap="riskResult">
        SELECT
        COUNT(1) count,
        tr.region_id id,
        tr.parent_id,
        tr.ancestors,
        tr.region_name name,
        trcp.evaluation_after_fengxianse risk_color
        FROM
        tr_region tr
        LEFT JOIN
        tr_risk_list trl
        ON
        tr.region_id = trl.region_id
        LEFT JOIN
        tr_risk_evaluation_plan trep
        ON
        trl.risk_list_id = trep.evaluation_risk_id
        LEFT JOIN
        tr_risk_check_point trcp
        ON
        trep.plan_id = trcp.plan_id
        WHERE
        tr.company_id = #{companyId} and tr.ancestors != '0'
        and
        tr.del_flag = '0'
        AND
        trcp.review_status = 2
        GROUP BY
        tr.region_id,trcp.evaluation_after_fengxianse
        ORDER BY
        tr.region_id
        ASC
    </select>
    <select id="selectRegion" parameterType="long" resultMap="riskResult">
        SELECT
        region_id id,
        region_name name
        FROM
        tr_region
        WHERE
        parent_id = (SELECT region_id FROM tr_region WHERE company_id = #{companyId} and ancestors = '0')
        and
        del_flag = '0'
        ORDER BY
        region_id
        ASC
    </select>
    <select id="selectRiskByDept" parameterType="long" resultMap="riskResult">
        SELECT
        COUNT(1) count,
        sd.dept_id id,
        sd.dept_name name,
        trcp.evaluation_after_fengxianse risk_color
        FROM
        sys_dept sd
        LEFT JOIN
        tr_risk_list trl
        ON
        sd.dept_id = trl.dept_id
        LEFT JOIN
        tr_risk_evaluation_plan trep
        ON
        trl.risk_list_id = trep.evaluation_risk_id
        LEFT JOIN
        tr_risk_check_point trcp
        ON
        trep.plan_id = trcp.plan_id
        WHERE
        sd.company_id = #{companyId}
        AND
        trcp.review_status = 2
        GROUP BY
        sd.dept_id,trcp.evaluation_after_fengxianse
        ORDER BY
        sd.dept_id
        ASC
    </select>
    <select id="selectDept" parameterType="long" resultMap="riskResult">
        SELECT
        dept_id id,
        dept_name name
        FROM
        sys_dept
        WHERE
        company_id = #{companyId} and parent_id != 0
        ORDER BY
        dept_id
        ASC
    </select>
    <select id="selectDangersByMonths" resultMap="dangerByTime">
        SELECT
        DATE_FORMAT(register_create_time, '%Y-%m') date_time,
        count(1) count,
        danger_level
        FROM
        tr_hidden_danger_check_point
        WHERE
        register_create_time > DATE_FORMAT(#{date}, '%Y-%m')
        and
        whether_danger = 1
        AND
        rectify_user_id in (SELECT user_id FROM sys_user WHERE company_id = #{companyId})
        GROUP BY DATE_FORMAT(register_create_time, '%Y-%m'),
        danger_level
        ORDER BY
        DATE_FORMAT(register_create_time, '%Y-%m') ASC
    </select>
    <select id="selectDangersByYear" parameterType="long" resultMap="dangerByTime">
        SELECT
        DATE_FORMAT(register_create_time, '%Y') date_time,
        count(1) count,
        danger_level
        FROM
        tr_hidden_danger_check_point
        WHERE
        rectify_user_id in (SELECT user_id FROM sys_user WHERE company_id = #{companyId})
        and
        whether_danger = 1
        GROUP BY DATE_FORMAT(register_create_time, '%Y'),
        danger_level
        ORDER BY
        DATE_FORMAT(register_create_time, '%Y'),danger_level ASC
    </select>
    <select id="selectDeptDangers" parameterType="long" resultMap="deptDangers">
        SELECT
        sd.dept_id report_id,
        sd.dept_name report_name,
        thdcp.id danger_id,
        thdcp.danger_level danger_level,
        thdcp.danger_name danger_name,
        thdcp.stage stage,
        thdcp.whether_danger,
        thdcp.rectify_user_name
        FROM
        sys_dept sd
        LEFT JOIN tr_hidden_danger_check thdc
        ON sd.dept_id = thdc.danger_dept_id
        LEFT JOIN tr_hidden_danger_check_point thdcp
        ON thdcp.check_id = thdc.check_id
        WHERE
        sd.company_id = #{companyId} and sd.parent_id != 0
    </select>
    <select id="selectTroubleTypeDangers" parameterType="long" resultMap="deptDangers">
        SELECT
        thtt.hidden_trouble_type_id report_id,
        thtt.hidden_trouble_name report_name,
        thdcp.id danger_id,
        thdcp.danger_level danger_level,
        thdcp.danger_name danger_name,
        thdcp.stage stage,
        thdcp.whether_danger,
        thdcp.rectify_user_name
        FROM
        tr_hidden_trouble_type thtt
        LEFT JOIN
        tr_hidden_danger_check_point thdcp
        ON
        thtt.hidden_trouble_type_id = thdcp.trouble_type_id
        WHERE
        thtt.company_id = #{companyId}
    </select>
 
</mapper>