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
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
<?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.yifu.cloud.plus.v1.yifu.archives.mapper.TRiskMonitorMapper">
<resultMap id="tRiskMonitorMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TRiskMonitor">
<id property="id" column="ID"/>
<result property="deptId" column="DEPT_ID"/>
<result property="departNo" column="DEPART_NO"/>
<result property="departName" column="DEPART_NAME"/>
<result property="stopFlag" column="STOP_FLAG"/>
<result property="businessPrimaryType" column="BUSINESS_PRIMARY_TYPE"/>
<result property="businessSecondType" column="BUSINESS_SECOND_TYPE"/>
<result property="businessThirdType" column="BUSINESS_THIRD_TYPE"/>
<result property="customerName" column="CUSTOMER_NAME"/>
<result property="customerNo" column="CUSTOMER_NO"/>
<result property="secondIndicatorBelong" column="SECOND_INDICATOR_BELONG"/>
<result property="lineType" column="LINE_TYPE"/>
<result property="buBelong" column="BU_BELONG"/>
<result property="isRisk" column="IS_RISK"/>
<result property="riskType" column="RISK_TYPE"/>
<result property="projectNum" column="PROJECT_NUM"/>
<result property="unproContractNum" column="UNPRO_CONTRACT_NUM"/>
<result property="proContractNum" column="PRO_CONTRACT_NUM"/>
<result property="unproInsuranceNum" column="UNPRO_INSURANCE_NUM"/>
<result property="proInsuranceNum" column="PRO_INSURANCE_NUM"/>
<result property="unproSocialNum" column="UNPRO_SOCIAL_NUM"/>
<result property="proSocialNum" column="PRO_SOCIAL_NUM"/>
<result property="unproFundNum" column="UNPRO_FUND_NUM"/>
<result property="proFundNum" column="PRO_FUND_NUM"/>
<result property="unproSalaryNum" column="UNPRO_SALARY_NUM"/>
<result property="proSalaryNum" column="PRO_SALARY_NUM"/>
<result property="lastSalaryTime" column="LAST_SALARY_TIME"/>
<result property="deleteFlag" column="DELETE_FLAG"/>
<result property="createBy" column="CREATE_BY"/>
<result property="createName" column="CREATE_NAME"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="updateBy" column="UPDATE_BY"/>
<result property="updateTime" column="UPDATE_TIME"/>
</resultMap>
<resultMap id="tRiskMonitorExportMap" type="com.yifu.cloud.plus.v1.yifu.archives.vo.TRiskMonitorVo">
<result property="departNo" column="DEPART_NO"/>
<result property="departName" column="DEPART_NAME"/>
<result property="stopFlag" column="STOP_FLAG"/>
<result property="businessPrimaryType" column="BUSINESS_PRIMARY_TYPE"/>
<result property="businessSecondType" column="BUSINESS_SECOND_TYPE"/>
<result property="businessThirdType" column="BUSINESS_THIRD_TYPE"/>
<result property="customerName" column="CUSTOMER_NAME"/>
<result property="customerNo" column="CUSTOMER_NO"/>
<result property="secondIndicatorBelong" column="SECOND_INDICATOR_BELONG"/>
<result property="lineType" column="LINE_TYPE"/>
<result property="buBelong" column="BU_BELONG"/>
<result property="isRisk" column="IS_RISK"/>
<result property="riskType" column="RISK_TYPE"/>
<result property="projectNum" column="PROJECT_NUM"/>
<result property="unproContractNum" column="UNPRO_CONTRACT_NUM"/>
<result property="proContractNum" column="PRO_CONTRACT_NUM"/>
<result property="unproInsuranceNum" column="UNPRO_INSURANCE_NUM"/>
<result property="proInsuranceNum" column="PRO_INSURANCE_NUM"/>
<result property="unproSocialNum" column="UNPRO_SOCIAL_NUM"/>
<result property="proSocialNum" column="PRO_SOCIAL_NUM"/>
<result property="unproFundNum" column="UNPRO_FUND_NUM"/>
<result property="proFundNum" column="PRO_FUND_NUM"/>
<result property="unproSalaryNum" column="UNPRO_SALARY_NUM"/>
<result property="proSalaryNum" column="PRO_SALARY_NUM"/>
<result property="lastSalaryTime" column="LAST_SALARY_TIME"/>
</resultMap>
<sql id="Base_Column_List">
a.ID,
a.DEPT_ID,
a.DEPART_NO,
a.DEPART_NAME,
a.STOP_FLAG,
a.BUSINESS_PRIMARY_TYPE,
a.BUSINESS_SECOND_TYPE,
a.BUSINESS_THIRD_TYPE,
a.CUSTOMER_NAME,
a.CUSTOMER_NO,
a.SECOND_INDICATOR_BELONG,
a.LINE_TYPE,
a.BU_BELONG,
a.IS_RISK,
substring(a.risk_type,1,CHAR_LENGTH(a.risk_type) -2) risk_type,
a.PROJECT_NUM,
a.UNPRO_CONTRACT_NUM,
a.PRO_CONTRACT_NUM,
a.UNPRO_INSURANCE_NUM,
a.PRO_INSURANCE_NUM,
a.UNPRO_SOCIAL_NUM,
a.PRO_SOCIAL_NUM,
a.UNPRO_FUND_NUM,
a.PRO_FUND_NUM,
a.UNPRO_SALARY_NUM,
a.PRO_SALARY_NUM,
a.LAST_SALARY_TIME,
a.DELETE_FLAG,
a.CREATE_BY,
a.CREATE_NAME,
a.CREATE_TIME,
a.UPDATE_BY,
a.UPDATE_TIME
</sql>
<select id="getTRiskMonitorPage" resultMap="tRiskMonitorMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_risk_monitor a
<where>
a.DELETE_FLAG = '0'
<include refid="tRiskMonitor_where"/>
</where>
</select>
<!--tRiskMonitor简单分页查询-->
<sql id="tRiskMonitor_where">
<if test="tRiskMonitor != null">
<if test="tRiskMonitor.id != null and tRiskMonitor.id.trim() != ''">
AND a.ID = #{tRiskMonitor.id}
</if>
<if test="tRiskMonitor.departNo != null and tRiskMonitor.departNo.trim() != ''">
AND a.DEPART_NO = #{tRiskMonitor.departNo}
</if>
<if test="tRiskMonitor.departName != null and tRiskMonitor.departName.trim() != ''">
AND a.DEPART_NAME like concat('%',#{tRiskMonitor.departName},'%')
</if>
<if test="tRiskMonitor.stopFlag != null and tRiskMonitor.stopFlag.trim() != ''">
AND a.STOP_FLAG = #{tRiskMonitor.stopFlag}
</if>
<if test="tRiskMonitor.businessPrimaryType != null and tRiskMonitor.businessPrimaryType.trim() != ''">
AND a.BUSINESS_PRIMARY_TYPE = #{tRiskMonitor.businessPrimaryType}
</if>
<if test="tRiskMonitor.businessSecondType != null and tRiskMonitor.businessSecondType.trim() != ''">
AND a.BUSINESS_SECOND_TYPE = #{tRiskMonitor.businessSecondType}
</if>
<if test="tRiskMonitor.businessThirdType != null and tRiskMonitor.businessThirdType.trim() != ''">
AND a.BUSINESS_THIRD_TYPE = #{tRiskMonitor.businessThirdType}
</if>
<if test="tRiskMonitor.customerName != null and tRiskMonitor.customerName.trim() != ''">
AND a.CUSTOMER_NAME = #{tRiskMonitor.customerName}
</if>
<if test="tRiskMonitor.customerNo != null and tRiskMonitor.customerNo.trim() != ''">
AND a.CUSTOMER_NO = #{tRiskMonitor.customerNo}
</if>
<if test="tRiskMonitor.secondIndicatorBelong != null and tRiskMonitor.secondIndicatorBelong.trim() != ''">
AND a.SECOND_INDICATOR_BELONG like concat('%',#{tRiskMonitor.secondIndicatorBelong},'%')
</if>
<if test="tRiskMonitor.lineType != null and tRiskMonitor.lineType.trim() != ''">
AND a.LINE_TYPE = #{tRiskMonitor.lineType}
</if>
<if test="tRiskMonitor.buBelong != null and tRiskMonitor.buBelong.trim() != ''">
AND a.BU_BELONG = #{tRiskMonitor.buBelong}
</if>
<if test="tRiskMonitor.isRisk != null and tRiskMonitor.isRisk.trim() != ''">
AND a.IS_RISK = #{tRiskMonitor.isRisk}
</if>
<if test="tRiskMonitor.riskType != null and tRiskMonitor.riskType.trim() != ''">
AND a.RISK_TYPE regexp #{tRiskMonitor.riskType}
</if>
<if test="tRiskMonitor.projectNumStart != null">
AND a.PROJECT_NUM <![CDATA[ >= ]]> #{tRiskMonitor.projectNumStart}
</if>
<if test="tRiskMonitor.projectNumEnd != null">
AND a.PROJECT_NUM <![CDATA[ <= ]]> #{tRiskMonitor.projectNumEnd}
</if>
<if test="tRiskMonitor.authSql != null and tRiskMonitor.authSql.trim() != ''">
${tRiskMonitor.authSql}
</if>
</if>
</sql>
<select id="getTRiskMonitorExportCount" resultType="java.lang.Long">
SELECT
count(1)
FROM t_risk_monitor a
<where>
a.DELETE_FLAG = '0'
<include refid="tRiskMonitor_where"/>
</where>
</select>
<!--tRiskMonitor导出查询-->
<select id="getRiskMonitorExportList" resultMap="tRiskMonitorExportMap">
SELECT
a.DEPART_NAME,
a.DEPART_NO,
CASE WHEN a.STOP_FLAG=0 THEN "正常"
WHEN a.STOP_FLAG =1 THEN "停止合作"
WHEN a.STOP_FLAG =2 THEN "已冻结"
ELSE a.STOP_FLAG END as STOP_FLAG,
a.SECOND_INDICATOR_BELONG,
CASE WHEN a.IS_RISK=0 THEN "是"
WHEN a.IS_RISK =1 THEN "否"
ELSE a.IS_RISK END as IS_RISK,
substring(a.risk_type,1,CHAR_LENGTH(a.risk_type) -2) risk_type,
a.PROJECT_NUM,
a.UNPRO_CONTRACT_NUM,
a.PRO_CONTRACT_NUM,
a.UNPRO_INSURANCE_NUM,
a.PRO_INSURANCE_NUM,
a.UNPRO_SOCIAL_NUM,
a.PRO_SOCIAL_NUM,
a.UNPRO_FUND_NUM,
a.PRO_FUND_NUM,
a.UNPRO_SALARY_NUM,
a.PRO_SALARY_NUM,
a.LAST_SALARY_TIME,
a.CUSTOMER_NAME,
a.CUSTOMER_NO,
a.BUSINESS_PRIMARY_TYPE,
a.BUSINESS_SECOND_TYPE,
a.BUSINESS_THIRD_TYPE,
a.LINE_TYPE,
a.BU_BELONG
FROM t_risk_monitor a
<where>
a.DELETE_FLAG = '0'
<include refid="tRiskMonitor_where"/>
</where>
<if test="tRiskMonitor.limitStart != null">
limit #{tRiskMonitor.limitStart},#{tRiskMonitor.limitEnd}
</if>
</select>
<!--tRiskMonitor批量生成-->
<select id="selectRiskMonitorList" resultMap="tRiskMonitorMap">
SELECT
A.id AS DEPT_ID,
a.STOP_FLAG,
a.DEPART_NAME,
a.DEPART_NO,
ifnull( a.SECOND_INDICATOR_BELONG, '' ) SECOND_INDICATOR_BELONG,
a.CUSTOMER_NAME,
a.CUSTOMER_NO,
ifnull( a.BUSINESS_SECOND_TYPE, '' ) BUSINESS_SECOND_TYPE,
ifnull( a.BUSINESS_PRIMARY_TYPE, '' ) BUSINESS_PRIMARY_TYPE,
ifnull( a.BUSINESS_THIRD_TYPE, '' ) BUSINESS_THIRD_TYPE,
ifnull( a.BU_BELONG, '' ) BU_BELONG,
ifnull( a.LINE_TYPE, '' ) LINE_TYPE,
CONCAT(
IF
( ifnull( pro.countPer, 0 ) > ifnull( q.onContractNum, 0 ), '合同漏签 / ', '' ),
IF
( ifnull( ht.countContract, 0 ) - ifnull( q.onContractNum, 0 ) > 0, '合同漏减 / ', '' ),
IF
( ifnull( pro.countPer, 0 ) > ifnull( r.onInsuranceNum, 0 ), '商险漏买 / ', '' ),
IF
( ifnull( sx.countInsurance, 0 ) - ifnull( r.onInsuranceNum, 0 ) > 0, '商险多买 / ', '' ),
IF
( ifnull( pro.countPer, 0 ) > ifnull( w.onSocialNum, 0 ), '社保漏买 / ', '' ),
IF
( ifnull( so.countSocial, 0 ) - ifnull( w.onSocialNum, 0 ) > 0, '社保多买 / ', '' ),
IF
( ifnull( pro.countPer, 0 ) > ifnull( e.onFundNum, 0 ), '公积金漏买 / ', '' ),
IF
( ifnull( fu.countFund, 0 ) - ifnull( e.onFundNum, 0 ) > 0, '公积金多买 / ', '' ),
IF
( ifnull( pro.countPer, 0 ) > ifnull( t.onSalaryNum, 0 ), '工资漏发 / ', '' ),
IF
( ifnull( sa.countSalary, 0 ) - ifnull( t.onSalaryNum, 0 ) > 0, '工资多发 / ', '' )
) RISK_TYPE,
IF
(
length(
CONCAT(
IF
( ifnull( pro.countPer, 0 ) > ifnull( q.onContractNum, 0 ), '合同漏签 / ', '' ),
IF
( ifnull( ht.countContract, 0 ) - ifnull( q.onContractNum, 0 ) > 0, '合同漏减 / ', '' ),
IF
( ifnull( pro.countPer, 0 ) > ifnull( r.onInsuranceNum, 0 ), '商险漏买 / ', '' ),
IF
( ifnull( sx.countInsurance, 0 ) - ifnull( r.onInsuranceNum, 0 ) > 0, '商险多买 / ', '' ),
IF
( ifnull( pro.countPer, 0 ) > ifnull( w.onSocialNum, 0 ), '社保漏买 / ', '' ),
IF
( ifnull( so.countSocial, 0 ) - ifnull( w.onSocialNum, 0 ) > 0, '社保多买 / ', '' ),
IF
( ifnull( pro.countPer, 0 ) > ifnull( e.onFundNum, 0 ), '公积金漏买 / ', '' ),
IF
( ifnull( fu.countFund, 0 ) - ifnull( e.onFundNum, 0 ) > 0, '公积金多买 / ', '' ),
IF
( ifnull( pro.countPer, 0 ) > ifnull( t.onSalaryNum, 0 ), '工资漏发 / ', '' ),
IF
( ifnull( sa.countSalary, 0 ) - ifnull( t.onSalaryNum, 0 ) > 0, '工资多发 / ', '' )
)) > 0,
'0',
'1'
) IS_RISK,
ifnull( q.onContractNum, 0 ) PRO_CONTRACT_NUM,
ifnull( w.onSocialNum, 0 ) PRO_SOCIAL_NUM,
ifnull( e.onFundNum, 0 ) PRO_FUND_NUM,
ifnull( r.onInsuranceNum, 0 ) PRO_INSURANCE_NUM,
ifnull( t.onSalaryNum, 0 ) PRO_SALARY_NUM,
ifnull( ht.countContract, 0 ) - ifnull( q.onContractNum, 0 ) UNPRO_CONTRACT_NUM,
ifnull( so.countSocial, 0 ) - ifnull( w.onSocialNum, 0 ) UNPRO_SOCIAL_NUM,
ifnull( fu.countFund, 0 ) - ifnull( e.onFundNum, 0 ) UNPRO_FUND_NUM,
ifnull( sx.countInsurance, 0 ) - ifnull( r.onInsuranceNum, 0 ) UNPRO_INSURANCE_NUM,
ifnull( sa.countSalary, 0 ) - ifnull( t.onSalaryNum, 0 ) UNPRO_SALARY_NUM,
ifnull( DATE_FORMAT( sa.CREATE_TIME, '%Y-%m-%d %H:%i:%s' ), '' ) LAST_SALARY_TIME,
ifnull( pro.countPer, 0 ) PROJECT_NUM,
'1' create_by,
'超管' create_name,
'1' UPDATE_BY
FROM
t_settle_domain a
LEFT JOIN (
SELECT
a.DEPT_NO,
count( DISTINCT a.EMP_IDCARD ) AS countContract
FROM
t_employee_contract_info a
WHERE
a.IN_USE = '0'
AND a.DELETE_FLAG = 0
AND (CONTRACT_END >= CURDATE() or (ifnull(CONTRACT_END,-1) = -1 and a.CONTRACT_TYPE = '2'))
AND length(
ifnull(a.DEPT_NO, '')) > 0
GROUP BY
a.DEPT_NO
) ht ON a.DEPART_NO = ht.DEPT_NO
LEFT JOIN (
SELECT
a.SETTLE_DOMAIN_CODE,
count( DISTINCT a.EMP_IDCARD ) AS countSocial
FROM
mvp_social.t_social_fund_info a
WHERE
a.SOCIAL_STATUS IN ( '3', '4', '9', '12' )
AND length(
ifnull( a.SETTLE_DOMAIN_CODE, '')) > 0
GROUP BY
a.SETTLE_DOMAIN_CODE
) so ON so.SETTLE_DOMAIN_CODE = a.DEPART_NO
LEFT JOIN (
SELECT
a.SETTLE_DOMAIN_CODE,
count( DISTINCT a.EMP_IDCARD ) AS countFund
FROM
mvp_social.t_social_fund_info a
WHERE
a.fund_STATUS IN ( '3', '8' )
AND length(
ifnull( a.SETTLE_DOMAIN_CODE, '')) > 0
GROUP BY
a.SETTLE_DOMAIN_CODE
) fu ON fu.SETTLE_DOMAIN_CODE = a.DEPART_NO
LEFT JOIN (
SELECT
a.DEPT_NO,
count( DISTINCT a.EMP_IDCARD_NO ) AS countInsurance
FROM
mvp_insurances.t_insurance_detail a
WHERE
a.IS_USE = 0
AND IS_EFFECT = 0
AND a.IS_OVERDUE = 0
AND a.DELETE_FLAG = 0
AND length(
ifnull( a.DEPT_NO, '')) > 0
GROUP BY
a.DEPT_NO
) sx ON a.DEPART_NO = sx.DEPT_NO
LEFT JOIN (
SELECT
count( DISTINCT acc.EMP_IDCARD ) AS countSalary,
lll.CREATE_TIME,
lll.DEPT_NO
FROM
mvp_salary.t_salary_standard lll
LEFT JOIN mvp_salary.t_salary_account acc ON lll.id = acc.SALARY_FORM_ID
AND acc.DELETE_FLAG = 0
WHERE
lll.id IN (
SELECT
b.id
FROM
(
SELECT
a.DEPT_NO,
a.id,
max( a.CREATE_TIME ) CREATE_TIME
FROM
mvp_salary.t_salary_standard a
WHERE
a.DELETE_FLAG = 0
AND length(
ifnull( a.DEPT_NO, '')) > 0
GROUP BY
a.DEPT_NO
) hh
INNER JOIN mvp_salary.t_salary_standard b ON hh.DEPT_NO = b.DEPT_NO
AND hh.CREATE_TIME = b.CREATE_TIME
)
GROUP BY
lll.id
) sa ON a.DEPART_NO = sa.DEPT_NO
LEFT JOIN (
SELECT
a.DEPT_NO,
a.EMP_IDCARD,
count( DISTINCT a.EMP_IDCARD ) countPer
FROM
t_employee_project a
WHERE
a.PROJECT_STATUS = 0
AND a.DELETE_FLAG = '0'
GROUP BY
a.DEPT_NO
) pro ON a.DEPART_NO = pro.DEPT_NO
LEFT JOIN (
SELECT
a.DEPT_NO,
count( DISTINCT a.EMP_IDCARD ) onContractNum
FROM
t_employee_contract_info a
INNER JOIN t_employee_project jj ON a.EMP_IDCARD = jj.EMP_IDCARD
AND a.DEPT_NO = jj.DEPT_NO
AND jj.PROJECT_STATUS = 0
AND jj.DELETE_FLAG = '0'
WHERE
a.IN_USE = '0'
AND (CONTRACT_END >= CURDATE() or (ifnull(CONTRACT_END,-1) = -1 and a.CONTRACT_TYPE = '2'))
AND a.DELETE_FLAG = 0
AND length(
ifnull( a.DEPT_NO, '')) > 0
GROUP BY
a.DEPT_NO
) q ON a.DEPART_NO = q.DEPT_NO
LEFT JOIN (
SELECT
a.SETTLE_DOMAIN_CODE,
count( DISTINCT a.EMP_IDCARD ) onSocialNum
FROM
mvp_social.t_social_fund_info a
INNER JOIN t_employee_project jj ON a.EMP_IDCARD = jj.EMP_IDCARD
AND a.SETTLE_DOMAIN_CODE = jj.DEPT_NO
AND jj.PROJECT_STATUS = 0
AND jj.DELETE_FLAG = '0'
WHERE
a.SOCIAL_STATUS IN ( '3', '4', '9', '12' )
AND length(
ifnull( a.SETTLE_DOMAIN_CODE, '')) > 0
GROUP BY
a.SETTLE_DOMAIN_CODE
) w ON a.DEPART_NO = w.SETTLE_DOMAIN_CODE
LEFT JOIN (
SELECT
a.SETTLE_DOMAIN_CODE,
count( DISTINCT a.EMP_IDCARD ) onFundNum
FROM
mvp_social.t_social_fund_info a
INNER JOIN t_employee_project jj ON a.EMP_IDCARD = jj.EMP_IDCARD
AND a.SETTLE_DOMAIN_CODE = jj.DEPT_NO
AND jj.PROJECT_STATUS = 0
AND jj.DELETE_FLAG = '0'
WHERE
a.fund_STATUS IN ( '3', '8' )
AND length(
ifnull( a.SETTLE_DOMAIN_CODE, '')) > 0
GROUP BY
a.SETTLE_DOMAIN_CODE
) e ON a.DEPART_NO = e.SETTLE_DOMAIN_CODE
LEFT JOIN (
SELECT
a.DEPT_NO,
count( DISTINCT a.EMP_IDCARD_NO ) onInsuranceNum
FROM
mvp_insurances.t_insurance_detail a
INNER JOIN t_employee_project jj ON a.EMP_IDCARD_NO = jj.EMP_IDCARD
AND a.DEPT_NO = jj.DEPT_NO
AND jj.PROJECT_STATUS = 0
AND jj.DELETE_FLAG = '0'
WHERE
a.IS_USE = 0
AND IS_EFFECT = 0
AND a.IS_OVERDUE = 0
AND a.DELETE_FLAG = 0
AND length(
ifnull( a.DEPT_NO, '')) > 0
GROUP BY
a.DEPT_NO
) r ON a.DEPART_NO = r.DEPT_NO
LEFT JOIN (
SELECT
count( DISTINCT acc.EMP_IDCARD ) AS onSalaryNum,
lll.DEPT_NO
FROM
mvp_salary.t_salary_standard lll
LEFT JOIN mvp_salary.t_salary_account acc ON lll.id = acc.SALARY_FORM_ID
AND acc.DELETE_FLAG = 0
INNER JOIN t_employee_project jj ON acc.EMP_IDCARD = jj.EMP_IDCARD
AND lll.DEPT_NO = jj.DEPT_NO
AND jj.PROJECT_STATUS = 0
AND jj.DELETE_FLAG = '0'
WHERE
lll.id IN (
SELECT
b.id
FROM
(
SELECT
a.DEPT_NO,
a.id,
max( a.CREATE_TIME ) CREATE_TIME
FROM
mvp_salary.t_salary_standard a
WHERE
a.DELETE_FLAG = 0
AND length(
ifnull( a.DEPT_NO, '')) > 0
GROUP BY
a.DEPT_NO
) hh
INNER JOIN mvp_salary.t_salary_standard b ON hh.DEPT_NO = b.DEPT_NO
AND hh.CREATE_TIME = b.CREATE_TIME
)
GROUP BY
lll.DEPT_NO,
lll.id
) t ON a.DEPART_NO = t.DEPT_NO
WHERE
a.DELETE_FLAG = '0'
GROUP BY
a.DEPART_NO
</select>
<select id="getTRiskMonitorPer" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.RiskMonitorPerVo">
SELECT
count(1) as deptNum,
sum(if(IS_RISK = '0',1,0)) as riskDeptNum,
concat(round(sum(if(IS_RISK = '0',1,0)) *100/count(1),2),'%') riskDeptPer,
sum(if(PROJECT_NUM > PRO_INSURANCE_NUM,1,0)) as riskInsuraceNum,
concat(round(sum(if(PROJECT_NUM > PRO_INSURANCE_NUM,1,0))*100/count(1),2),'%') riskInsuracePer
FROM
t_risk_monitor a
where
a.DELETE_FLAG = '0' and a.STOP_FLAG = '0'
<if test="tRiskMonitor.authSql != null and tRiskMonitor.authSql.trim() != ''">
${tRiskMonitor.authSql}
</if>
</select>
<!--删除所有监控数据-->
<update id="deleteAllRiskMonitorInfo">
TRUNCATE t_risk_monitor
</update>
</mapper>