智慧保安后台管理-外网-验收版本
Administrator
2021-09-06 acd596c0facc60389ee6344bf97d3963895d55ba
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
<?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,
        ke.exam_name examName,
        sa.is_exam isExam,
        bu.real_name securityName,company,bu.account,
        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 (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,
            ke.exam_name examName,
            str.is_exam isExam,
            bu.real_name securityName,company,bu.account,
            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_training_registration str
        on
        str.id = es.apply_id
        where
        1=1
        and (str.is_exam = 2 or str.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.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.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.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="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
        <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
        WHERE 1 = 1 AND theory_grade is not null
        <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>
        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
        WHERE 1 = 1 AND learn_grade is not null
        <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>
        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
        where
            bu.cardid = #{idCardNo}
            and es.exam_id = #{examId}
    </select>
 
    <!--修改成绩信息-->
    <update id="updateByIdAndQualifiee">
        update exam_score set qualified = #{examScore.qualified} where id = #{examScore.id}
    </update>
</mapper>