智慧保安后台管理-外网项目备份
guoshilong
2023-12-19 934b32c0af147ef324736c835e0e877962e893fe
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
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
<?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="org.springblade.modules.exam.mapper.ExamScoreMapper">
 
    <!--考试成绩分页信息-正式考试-->
    <select id="selectExamScorePage" resultType="org.springblade.modules.exam.vo.ExamScoreVO">
        SELECT
        es.id,es.theory_grade theoryGrade,ifnull(learn_grade,-1) learnGrade,es.user_id userId,es.exam_id examId,
        es.exam_time examTime,all_grade allGrade,exam_end_time examEndTime,qualified,es.candidate_no candidateNo,
        ke.exam_name examName,
        sa.is_exam isExam,
        bu.real_name securityName,company,bu.account,bu.securitynumber as securityNumber,
        bd.dept_name companyName from
        exam_score es
        left join
        ksxt_exam ke
        on
        ke.id = es.exam_id
        left join
        blade_user bu
        on
        es.user_id = bu.id
        left join
        blade_dept bd
        on
        bd.id = bu.dept_id
        left join
        sys_apply sa
        on
        sa.id = es.apply_id
        where
        1=1 and es.is_deleted = 0
        and (sa.is_exam = 2 or sa.is_exam = 3)
        <if test="examScore.examName!=null and  examScore.examName!=''">
            and ke.exam_name like concat('%', #{examScore.examName},'%')
        </if>
        <if test="examScore.companyName!=null and  examScore.companyName!=''">
            and bd.dept_name like concat('%', #{examScore.companyName},'%')
        </if>
        <if test="examScore.securityName!=null and  examScore.securityName!=''">
            and bu.real_name like concat('%', #{examScore.securityName},'%')
        </if>
        <if test="examScore.account!=null and  examScore.account!=''">
            and bu.account like concat('%', #{examScore.account},'%')
        </if>
        <if test="examScore.userId!=null and  examScore.userId!=''">
            and es.user_id = #{examScore.userId}
        </if>
        <if test="examScore.deptId!=null and  examScore.deptId!=''">
            and bd.id = #{examScore.deptId}
        </if>
        <if test="examScore.isExam!=null and  examScore.isExam!=''">
            and sa.is_exam = #{examScore.isExam}
        </if>
        <if test="examScore.examType!=null and  examScore.examType!=''">
            and ke.exam_type = #{examScore.examType}
        </if>
        <if test="examScore.candidateNo!=null and  examScore.candidateNo!=''">
            and es.candidate_no = #{examScore.candidateNo}
        </if>
        <if test="examScore.qualified!=null">
            and es.qualified = #{examScore.qualified}
        </if>
    </select>
 
 
    <!--考试成绩分页信息-培训考试-->
    <select id="selectTrainExamScorePage" resultType="org.springblade.modules.exam.vo.ExamScoreVO">
        SELECT
            es.id,es.theory_grade theoryGrade,ifnull(learn_grade,-1) learnGrade,es.user_id userId,es.exam_id examId,
            es.exam_time examTime,all_grade allGrade,exam_end_time examEndTime,qualified,es.candidate_no candidateNo,
            ke.exam_name examName,date_format(ke.start_time,'%Y-%m-%d') startTime,date_format(ke.end_time,'%Y-%m-%d %H:%i:%s') endTime,
            str.is_exam isExam,
            bu.real_name securityName,company,bu.account,bu.sex,bu.paper_time paperTime,bu.securitynumber securityNumber,bu.avatar,
            bd.dept_name companyName,bu.user_type isPaper,bud.unit_name unitName
        from
            exam_score es
        left join ksxt_exam ke on ke.id = es.exam_id
        left join blade_user bu on es.user_id = bu.id
        left join blade_user_detail bud on bud.user_id = bu.id
        left join blade_dept bd on bd.id = bu.dept_id
        left join sys_information si on si.departmentid = bd.id
        left join sys_jurisdiction sj on sj.id = si.jurisdiction
        left join sys_training_registration str on str.id = es.apply_id
        where 1=1 and es.is_deleted = 0
        and (str.is_exam = 2 or str.is_exam = 3 or str.is_exam = 4 or str.is_exam = 5)
        <if test="examScore.examName!=null and  examScore.examName!=''">
            and ke.exam_name like concat('%', #{examScore.examName},'%')
        </if>
        <if test="examScore.companyName!=null and  examScore.companyName!=''">
            and bd.dept_name like concat('%', #{examScore.companyName},'%')
        </if>
        <if test="examScore.unitName!=null and  examScore.unitName!=''">
            and bud.unit_name like concat('%', #{examScore.unitName},'%')
        </if>
        <if test="examScore.securityName!=null and  examScore.securityName!=''">
            and bu.real_name like concat('%', #{examScore.securityName},'%')
        </if>
        <if test="examScore.account!=null and  examScore.account!=''">
            and bu.account like concat('%', #{examScore.account},'%')
        </if>
        <if test="examScore.trainUnitId!=null">
            and str.training_unit_id = #{examScore.trainUnitId}
        </if>
        <if test="examScore.userId!=null and  examScore.userId!=''">
            and es.user_id = #{examScore.userId}
        </if>
        <if test="examScore.jurisdiction!=null and examScore.jurisdiction!='' and examScore.jurisdiction!='1372091709474910209'">
            and (sj.id=#{examScore.jurisdiction} or sj.parent_id = #{examScore.jurisdiction})
        </if>
        <if test="examScore.deptId!=null and  examScore.deptId!=''">
            and bd.id = #{examScore.deptId}
        </if>
        <if test="examScore.isExam!=null and  examScore.isExam!=''">
            and str.is_exam = #{examScore.isExam}
        </if>
        <if test="examScore.examType!=null and  examScore.examType!=''">
            and ke.exam_type = #{examScore.examType}
        </if>
        <if test="examScore.examId!=null">
            and es.exam_id = #{examScore.examId}
        </if>
        <if test="examScore.isPaper==6">
            and bu.user_type = #{examScore.isPaper}
        </if>
        <if test="examScore.isPaper==7">
            and (bu.user_type = #{examScore.isPaper} or bu.user_type is null)
        </if>
        <if test="examScore.isAvatar==1">
            and bu.avatar is not null and bu.avatar!=""
        </if>
        <if test="examScore.isAvatar==2">
            and (bu.avatar is null or bu.avatar="")
        </if>
        <if test="examScore.candidateNo!=null and  examScore.candidateNo!=''">
            and es.candidate_no = #{examScore.candidateNo}
        </if>
        <if test="examScore.qualified!=null">
            and es.qualified = #{examScore.qualified}
        </if>
        <if test="examScore.examDate!=null  and examScore.examDate!=''">
            and date_format(ke.start_time,'%Y-%m-%d') = #{examScore.examDate}
        </if>
        <if test="examScore.sortName!=null and examScore.sortName!='' and examScore.sortName!='companyName'">
            ORDER BY es.${examScore.sortName} ${examScore.sort},es.id desc
        </if>
        <if test="examScore.sortName=='companyName'">
            ORDER BY bd.dept_name ${examScore.sort},es.id desc
        </if>
        <if test="examScore.sortName==null or examScore.sortName==''">
            order by es.id desc
        </if>
    </select>
 
    <!--考试成绩详情信息-->
    <select id="selectExamScoreInfo" resultType="org.springblade.modules.exam.vo.ExamScoreVO">
        SELECT
            id,candidate_no candidateNo,theory_grade theoryGrade,ifnull(learn_grade,-1) learnGrade,all_grade,
            exam_name examName,security_name securityName,exam_type examType,company,exam_time examTime,
            all_score allScore,exam_end_time examEndTime,qualified
        FROM
            exam_score
        WHERE
            1=1 and is_deleted = 0
        <if test="examScore.id!=null">
            and id = #{examScore.id}
        </if>
    </select>
 
 
    <!--考试成绩详情信息-->
<!--    <select id="scoreStatistics" resultType="java.util.HashMap">-->
<!--        SELECT * FROM(SELECT-->
<!--        COUNT( CASE WHEN theory_grade &lt; 60 THEN 1 END ) AS 'bhg',-->
<!--        COUNT( CASE WHEN theory_grade >= 60 AND theory_grade &lt; 80 THEN 1 END ) AS 'hg',-->
<!--        COUNT( CASE WHEN theory_grade >= 80 AND theory_grade &lt; 90 THEN 1 END ) AS 'lh',-->
<!--        COUNT( CASE WHEN theory_grade >= 90 THEN 1 END ) AS 'yx'-->
<!--        FROM-->
<!--        exam_score exam-->
<!--        LEFT JOIN blade_user user ON exam.user_id = user.id-->
<!--        WHERE 1 = 1-->
<!--        <if test="jurisdiction!=null and jurisdiction=='' and jurisdiction!='1123598813738675201'">-->
<!--             AND user.jurisdiction = #{jurisdiction}-->
<!--        </if>-->
<!--        <if test="deptid!=null and deptid==''">-->
<!--            AND user.dept_id = #{deptid}-->
<!--        </if>-->
<!--        ) a UNION ALL-->
<!--        SELECT * FROM( SELECT-->
<!--        COUNT( CASE WHEN learn_grade &lt; 60 THEN 1 END ) AS 'bhg',-->
<!--        COUNT( CASE WHEN learn_grade >= 60 AND learn_grade &lt; 80 THEN 1 END ) AS 'hg',-->
<!--        COUNT( CASE WHEN learn_grade >= 80 AND learn_grade &lt; 90 THEN 1 END ) AS 'lh',-->
<!--        COUNT( CASE WHEN learn_grade >= 90 THEN 1 END ) AS 'yx'-->
<!--        FROM-->
<!--        exam_score exam-->
<!--        LEFT JOIN blade_user user ON exam.user_id = user.id-->
<!--        WHERE 1 = 1-->
<!--        <if test="jurisdiction!=null and jurisdiction=='' and jurisdiction!='1123598813738675201'">-->
<!--            AND user.jurisdiction = #{jurisdiction}-->
<!--        </if>-->
<!--        <if test="deptid!=null and deptid==''">-->
<!--            AND user.dept_id = #{deptid}-->
<!--        </if>-->
<!--        ) b-->
<!--    </select>-->
 
    <!--考试成绩详情信息 理论-->
    <select id="scoreStatistics" resultType="java.util.HashMap">
        SELECT
        theory_grade as fs,
        COUNT( * ) AS count
        FROM
        exam_score exam
        LEFT JOIN blade_user user
        ON exam.user_id = user.id
        left join
        sys_information si
        on
        si.departmentid = user.dept_id
        left join
        sys_jurisdiction sj
        on
        sj.id = si.jurisdiction
        WHERE 1 = 1 and exam.is_deleted = 0 AND theory_grade is not null
        <if test="jurisdiction!=null and jurisdiction=='' and jurisdiction!='1372091709474910209'">
            and (sj.id = #{jurisdiction} or sj.parent_id = #{jurisdiction})
        </if>
        <if test="deptid!=null and deptid!=''">
            AND user.dept_id = #{deptid}
        </if>
        GROUP BY
        exam.theory_grade
    </select>
    <!--考试成绩详情信息 实操-->
    <select id="scoreStatisticssc" resultType="java.util.HashMap">
        SELECT
        learn_grade as fs,
        COUNT( * ) AS count
        FROM
        exam_score exam
        LEFT JOIN blade_user user
        ON exam.user_id = user.id
        left join
        sys_information si
        on
        si.departmentid = user.dept_id
        left join
        sys_jurisdiction sj
        on
        sj.id = si.jurisdiction
        WHERE 1 = 1 and exam.is_deleted = 0
        AND learn_grade is not null
        <if test="jurisdiction!=null and jurisdiction=='' and jurisdiction!='1372091709474910209'">
            and (sj.id = #{jurisdiction} or sj.parent_id = #{jurisdiction})
        </if>
        <if test="deptid!=null and deptid!=''">
            AND user.dept_id = #{deptid}
        </if>
        GROUP BY
        exam.learn_grade
    </select>
 
    <!--根据用户身份证号查询考试成绩-->
    <select id="getExamScoreInfoByIdCardNo" resultType="org.springblade.modules.exam.entity.ExamScore">
        select
            es.*
        from
            exam_score es
        left join
            blade_user bu
        on
            bu.id = es.user_id
        left join
            ksxt_exam ke
        on
            ke.id = es.exam_id
        where
            bu.cardid = #{idCardNo}
            and es.is_deleted = 0
            and DATE_FORMAT(ke.start_time,'%Y-%m-%d') = #{startTime}
    </select>
 
    <!--修改成绩信息-->
    <update id="updateByIdAndQualifiee">
        update exam_score set qualified = #{examScore.qualified} where id = #{examScore.id}
    </update>
 
    <select id="scorePage"  resultType="org.springblade.modules.exam.vo.ExamScoreVO">
        SELECT
        exam.*,
        user.jurisdiction,user.real_name securityName,bud.unit_name unitName,
        ke.exam_name examName,sis.enterpriseName trainingUnitName,ke.start_time examStartTime
        FROM
        exam_score exam
        left join blade_user user on exam.user_id = user.id
        left join blade_user_detail bud on bud.user_id = user.id
        left join sys_information si on si.departmentid = user.dept_id
        left join sys_jurisdiction sj on sj.id = si.jurisdiction
        left join ksxt_exam ke on exam.exam_id = ke.id
        left join sys_training_registration str on str.id = exam.apply_id
        left join sys_information sis on sis.departmentid = str.training_unit_id
        WHERE 1 = 1
        and ke.exam_type = 2 and exam.is_deleted = 0
        <if test="examScore.jurisdiction!=null and examScore.jurisdiction!='' and examScore.jurisdiction!='1372091709474910209'">
            and (sj.id = #{examScore.jurisdiction} or sj.parent_id = #{examScore.jurisdiction})
        </if>
        <if test="examScore.unitName!=null and  examScore.unitName!=''">
            and bud.unit_name like concat('%', #{examScore.unitName},'%')
        </if>
        <if test="examScore.securityName!=null and examScore.securityName!=''">
            AND user.real_name like concat('%',#{examScore.securityName},'%')
        </if>
        <if test="examScore.trainingUnitName!=null and examScore.trainingUnitName!=''">
            AND sis.enterpriseName like concat('%',#{examScore.trainingUnitName},'%')
        </if>
        <if test="examScore.deptId!=null and examScore.deptId!=''">
            AND user.dept_id = #{examScore.deptId}
        </if>
        <if test="examScore.month!=null and examScore.month!=''">
            AND date_format(ke.start_time,'%Y-%m') = #{examScore.month}
        </if>
        <if test="examScore.qualified!=null">
            AND exam.qualified = #{examScore.qualified}
        </if>
    </select>
 
    <!--查询所有考试不合格的数据(取准考证号)-->
    <select id="getDisqualificationExamInfo" resultType="org.springblade.modules.exam.entity.ExamScore">
        select * from exam_score where qualified = 1 and is_deleted = 0
    </select>
 
 
    <!--根据准考证号查询培训信息-->
    <select id="getTrainInfo" resultType="org.springblade.modules.training.entity.TrainingRegistration">
        select * from sys_training_registration where 1=1
        <if test="trainingRegistration.candidateNo!=null and trainingRegistration.candidateNo!=''">
            and is_exam = 2
            and candidate_no = #{trainingRegistration.candidateNo}
        </if>
        <if test="trainingRegistration.id!=null">
            and id = #{trainingRegistration.id}
        </if>
    </select>
 
    <!--查询所有无成绩的数据-->
    <select id="getNoScoreInfo" resultType="org.springblade.modules.exam.entity.ExamScore">
        select * from exam_score where theory_grade is null and is_deleted = 0
    </select>
 
    <!--查询所有无成绩的数据-->
    <select id="getLheoryGradeLess60" resultType="org.springblade.modules.exam.entity.ExamScore">
        select * from exam_score where all_grade &lt; 30 and is_deleted = 0
    </select>
 
    <!--导出-按条件查询成绩数据-模拟考试-->
    <select id="getExamScoreList" resultType="org.springblade.modules.exam.excel.ExportExamScoreExcel">
        SELECT
        ke.exam_name examName,
        bu.real_name securityName,bu.cardid idCardNo,bu.securitynumber as securityNumber,
        bd.dept_name companyName,
        es.exam_time examTime,exam_end_time examEndTime,es.candidate_no candidateNo,
        es.theory_grade theoryGrade,
        case when es.learn_grade=0 then '合格'
            when es.learn_grade=1 then '不合格'
        end as learnGrade,
        case when es.qualified=0 then '合格'
            when es.qualified=1 then '不合格'
            when es.qualified=2 then '暂未录入实操成绩'
        end as qualified,
        bud.marriage_status marriageStatus,bud.sign_level signLevel,bud.unit_name unitName,
        bud.permanent_residence_address permanentResidenceAddress,bud.dwell_address dwellAddress,
        bud.member_of_family memberOfFamily,bud.work_experience workExperience,bud.education_experience educationExperience,
        bud.acceptance_police_unit acceptancePoliceUnit,bud.acceptance_person acceptancePerson,bud.acceptance_time acceptanceTime
        from exam_score es
        left join ksxt_exam ke on ke.id = es.exam_id
        left join blade_user bu on es.user_id = bu.id and bu.is_deleted = 0
        left join blade_user_detail bud on bud.user_id = bu.id and bud.is_deleted = 0
        left join blade_dept bd on bd.id = bu.dept_id
        left join sys_training_registration str on str.id = es.apply_id
        left join sys_information si on si.departmentid = bd.id
        left join sys_jurisdiction sj on sj.id = si.jurisdiction
        where
        1=1 and es.is_deleted = 0
        and (str.is_exam = 2 or str.is_exam = 3 or str.is_exam = 4 or str.is_exam = 5)
        <if test="examScore.examName!=null and  examScore.examName!='' and examScore.examName!='undefined'">
            and ke.exam_name like concat('%', #{examScore.examName},'%')
        </if>
        <if test="examScore.companyName!=null and  examScore.companyName!=''">
            and bd.dept_name like concat('%', #{examScore.companyName},'%')
        </if>
        <if test="examScore.unitName!=null and  examScore.unitName!=''">
            and bud.unit_name like concat('%', #{examScore.unitName},'%')
        </if>
        <if test="examScore.securityName!=null and  examScore.securityName!=''">
            and bu.real_name like concat('%', #{examScore.securityName},'%')
        </if>
        <if test="examScore.isPaper==6">
            and bu.user_type = #{examScore.isPaper}
        </if>
        <if test="examScore.isPaper==7">
            and (bu.user_type = #{examScore.isPaper} or bu.user_type is null)
        </if>
        <if test="examScore.account!=null and  examScore.account!=''">
            and bu.account like concat('%', #{examScore.account},'%')
        </if>
        <if test="examScore.trainUnitId!=null">
            and str.training_unit_id = #{examScore.trainUnitId}
        </if>
        <if test="examScore.userId!=null and  examScore.userId!=''">
            and es.user_id = #{examScore.userId}
        </if>
        <if test="examScore.examId!=null and examScore.examId!='undefined'">
            and es.exam_id = #{examScore.examId}
        </if>
        <if test="examScore.deptId!=null and  examScore.deptId!=''">
            and bd.id = #{examScore.deptId}
        </if>
        <if test="examScore.isExam!=null and  examScore.isExam!=''">
            and str.is_exam = #{examScore.isExam}
        </if>
        <if test="examScore.isAvatar==1">
            and bu.avatar is not null and bu.avatar!=""
        </if>
        <if test="examScore.isAvatar==2">
            and (bu.avatar is null or bu.avatar="")
        </if>
        <if test="examScore.examType!=null and  examScore.examType!=''">
            and ke.exam_type = #{examScore.examType}
        </if>
        <if test="examScore.candidateNo!=null and  examScore.candidateNo!=''">
            and es.candidate_no = #{examScore.candidateNo}
        </if>
        <if test="examScore.qualified!=null">
            and es.qualified = #{examScore.qualified}
        </if>
        <if test="examScore.examDate!=null  and examScore.examDate!=''">
            and date_format(ke.start_time,'%Y-%m-%d') = #{examScore.examDate}
        </if>
        <if test="examScore.jurisdiction!=null and examScore.jurisdiction!='' and examScore.jurisdiction!='1372091709474910209'">
            and (sj.id=#{examScore.jurisdiction} or sj.parent_id = #{examScore.jurisdiction})
        </if>
        <if test="examScore.sortName!=null and examScore.sortName!='' and examScore.sortName!='companyName'">
            ORDER BY es.${examScore.sortName} ${examScore.sort},es.id desc
        </if>
        <if test="examScore.sortName=='companyName'">
            ORDER BY bd.dept_name ${examScore.sort},es.id desc
        </if>
        <if test="examScore.sortName==null or examScore.sortName==''">
            order by es.id desc
        </if>
    </select>
 
    <!--导出-按条件查询成绩数据-模拟考试-->
    <select id="getExamStatisInfo" resultType="org.springblade.modules.exam.vo.ExamSocreStatis">
        select m.id name, IFNULL(b,0) hgnum,IFNULL(c,0) bhgnum from
        (
          select 1 as id union
            select 2 union
            select 3 union
            select 4 union
            select 5 union
            select 6 union
            select 7 union
            select 8 union
            select 9 union
            select 10 union
            select 11 union
            select 12
        ) m
        left join
         (
            SELECT MONTH
                ( ke.start_time ) a,
                count(*) b
            FROM
                exam_score es
                left join sys_training_registration str on str.id = es.apply_id
                left join ksxt_exam ke on ke.id = es.exam_id
                left join blade_user bu on bu.id = es.user_id
                left join blade_dept bd on bd.id = bu.dept_id
                left join sys_information si on bd.id = si.departmentid
                left join sys_jurisdiction sj on si.jurisdiction = sj.id
            WHERE
                qualified = 0
                and es.is_deleted = 0
                and training_unit_id = #{information.departmentid}
                and YEAR ( ke.start_time ) = YEAR ( now() )
                <if test="information.deptid!=null and information.deptid!=''">
                    and bu.dept_id = #{information.deptid}
                </if>
                <if test="information.jurisdiction!=null and information.jurisdiction!='' and information.jurisdiction!='1372091709474910209'">
                    and (sj.id = #{information.jurisdiction} or sj.parent_id = #{information.jurisdiction})
                </if>
            GROUP BY
                MONTH ( ke.start_time )
            ) n ON m.id = n.a
            left join
         (
            SELECT MONTH
                ( ke.start_time ) a,
                count(*) c
            FROM
                exam_score es
                left join sys_training_registration str on str.id = es.apply_id
                left join ksxt_exam ke on ke.id = es.exam_id
                left join blade_user bu on bu.id = es.user_id
                left join blade_dept bd on bd.id = bu.dept_id
                left join sys_information si on bd.id = si.departmentid
                left join sys_jurisdiction sj on si.jurisdiction = sj.id
            WHERE
                qualified = 1
                and es.is_deleted = 0
                and training_unit_id = #{information.departmentid}
                and YEAR ( ke.start_time ) = YEAR ( now() )
                <if test="information.deptid!=null and information.deptid!=''">
                    and bu.dept_id = #{information.deptid}
                </if>
                <if test="information.jurisdiction!=null and information.jurisdiction!='' and information.jurisdiction!='1372091709474910209'">
                    and (sj.id = #{information.jurisdiction} or sj.parent_id = #{information.jurisdiction})
                </if>
            GROUP BY
                MONTH ( ke.start_time )
            ) i ON m.id = i.a
        ORDER BY
            id
    </select>
    <select id="getList" resultType="org.springblade.modules.exam.vo.ExamScoreVO">
    SELECT * FROM (
        SELECT
        es.id,es.theory_grade theoryGrade,ifnull(learn_grade,-1) learnGrade,es.user_id userId,es.exam_id examId,
        es.exam_time examTime,all_grade allGrade,exam_end_time examEndTime,qualified,es.candidate_no candidateNo,
        ke.exam_name examName,date_format(ke.start_time,'%Y-%m-%d') startTime,date_format(ke.end_time,'%Y-%m-%d %H:%i:%s') endTime,
        str.is_exam isExam,
        bu.real_name securityName,company,bu.account,bu.sex,bu.paper_time paperTime,bu.securitynumber securityNumber,bu.avatar,
        bd.dept_name companyName,bd.id as deptId,bu.user_type isPaper,bud.unit_name unitName,
        CASE WHEN ssir.id IS NULL THEN
        '未签到' ELSE '已签到'
        END AS state
        from
        exam_score es
        left join ksxt_exam ke on ke.id = es.exam_id
        left join blade_user bu on es.user_id = bu.id
        left join blade_user_detail bud on bud.user_id = bu.id
        left join blade_dept bd on bd.id = bu.dept_id
        left join sys_information si on si.departmentid = bd.id
        left join sys_jurisdiction sj on sj.id = si.jurisdiction
        left join sys_training_registration str on str.id = es.apply_id
        LEFT JOIN sys_sign_in_records ssir ON ssir.candidate_no = str.candidate_no
        where 1=1 and es.is_deleted = 0
        and (str.is_exam = 2 or str.is_exam = 3 or str.is_exam = 4 or str.is_exam = 5)
        <if test="examScore.examName!=null and  examScore.examName!=''">
            and ke.exam_name like concat('%', #{examScore.examName},'%')
        </if>
        <if test="examScore.companyName!=null and  examScore.companyName!=''">
            and bd.dept_name like concat('%', #{examScore.companyName},'%')
        </if>
        <if test="examScore.unitName!=null and  examScore.unitName!=''">
            and bud.unit_name like concat('%', #{examScore.unitName},'%')
        </if>
        <if test="examScore.securityName!=null and  examScore.securityName!=''">
            and bu.real_name like concat('%', #{examScore.securityName},'%')
        </if>
        <if test="examScore.account!=null and  examScore.account!=''">
            and bu.account like concat('%', #{examScore.account},'%')
        </if>
        <if test="examScore.trainUnitId!=null">
            and str.training_unit_id = #{examScore.trainUnitId}
        </if>
        <if test="examScore.userId!=null and  examScore.userId!=''">
            and es.user_id = #{examScore.userId}
        </if>
        <if test="examScore.jurisdiction!=null and examScore.jurisdiction!='' and examScore.jurisdiction!='1372091709474910209'">
            and (sj.id=#{examScore.jurisdiction} or sj.parent_id = #{examScore.jurisdiction})
        </if>
        <if test="examScore.deptId!=null and  examScore.deptId!=''">
            and bd.id = #{examScore.deptId}
        </if>
        <if test="examScore.isExam!=null and  examScore.isExam!=''">
            and str.is_exam = #{examScore.isExam}
        </if>
        <if test="examScore.examType!=null and  examScore.examType!=''">
            and ke.exam_type = #{examScore.examType}
        </if>
        <if test="examScore.examId!=null">
            and es.exam_id = #{examScore.examId}
        </if>
        <if test="examScore.isPaper==6">
            and bu.user_type = #{examScore.isPaper}
        </if>
        <if test="examScore.isPaper==7">
            and (bu.user_type = #{examScore.isPaper} or bu.user_type is null)
        </if>
        <if test="examScore.isAvatar==1">
            and bu.avatar is not null and bu.avatar!=""
        </if>
        <if test="examScore.isAvatar==2">
            and (bu.avatar is null or bu.avatar="")
        </if>
        <if test="examScore.candidateNo!=null and  examScore.candidateNo!=''">
            and es.candidate_no = #{examScore.candidateNo}
        </if>
        <if test="examScore.qualified!=null">
            and es.qualified = #{examScore.qualified}
        </if>
        <if test="examScore.examDate!=null  and examScore.examDate!=''">
            and date_format(ke.start_time,'%Y-%m-%d') = #{examScore.examDate}
        </if>
        <if test="examScore.sortName!=null and examScore.sortName!='' and examScore.sortName!='companyName'">
            ORDER BY es.${examScore.sortName} ${examScore.sort},es.id desc
        </if>
        <if test="examScore.sortName=='companyName'">
            ORDER BY bd.dept_name ${examScore.sort},es.id desc
        </if>
        <if test="examScore.sortName==null or examScore.sortName==''">
            order by es.id desc
        </if>
        ) result WHERE 1=1
        <if test="examScore.state != null and examScore.state !='' ">
            AND result.state = #{examScore.state}
        </if>
 
 
 
 
 
    </select>
 
 
</mapper>