教育训练处考试制证系统后端
zhangf
2024-09-11 1a316551c8e46b793904090cfa84781bf77fef2a
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
<?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.exam.institutionalaccess.mapper.ThStudentBatchMapper">
    <insert id="insertBatch">
        INSERT INTO th_student_batch (uuid,idcard, name, sex, phone, auth_photo,train_org_name, institution_id, institution_name,
        industry,occupation,post,del_flag,create_time,update_time,create_by,update_by,finish_status,batch_uuid) VALUES
        <foreach collection="list" separator="," item="item">
            (#{item.uuid},#{item.idcard},#{item.name},#{item.sex},#{item.phone},#{item.authPhoto},#{item.trainOrgName},#{item.institutionId},#{item.institutionName},
            #{item.industry},#{item.occupation},#{item.post},#{item.delFlag},#{item.createTime},
            #{item.updateTime},#{item.createBy},#{item.updateBy},#{item.finishStatus},#{item.batchUuid})
        </foreach>
    </insert>
 
 
 
    <update id="updateBatch" parameterType="java.util.List" >
        <foreach collection="list" item="item" index="index" separator=";">
            UPDATE th_student_batch
            <set>
                <if test="item.uuid != null and item.uuid != ''" >
                    uuid = #{item.uuid},
                </if>
                <if test="item.name != null and item.name != ''" >
                    name = #{item.name},
                </if>
                <if test="item.idcard != null and item.idcard != ''" >
                    idcard = #{item.idcard},
                </if>
                <if test="item.sex != null" >
                    sex = #{item.sex},
                </if>
                <if test="item.phone != null and item.phone != ''" >
                    phone = #{item.phone},
                </if>
                <if test="item.authPhoto != null and item.authPhoto != ''" >
                    auth_photo = #{item.authPhoto},
                </if>
                <if test="item.trainOrgName != null and item.trainOrgName != ''" >
                    train_org_name = #{item.trainOrgName},
                </if>
                <if test="item.institutionId != null" >
                    institution_id = #{item.institutionId},
                </if>
                <if test="item.institutionName != null and item.institutionName != ''" >
                    institution_name = #{item.institutionName},
                </if>
                <if test="item.industry != null and item.industry != ''" >
                    industry = #{item.industry},
                </if>
                <if test="item.occupation != null and item.occupation != ''" >
                    occupation = #{item.occupation},
                </if>
                <if test="item.post != null and item.post != ''" >
                    post = #{item.post},
                </if>
                <if test="item.batchUuid != null and item.batchUuid != ''" >
                    batch_uuid = #{item.batchUuid},
                </if>
                <if test="item.delFlag != null" >
                    del_flag = #{item.delFlag},
                </if>
                <if test="item.finishStatus != null" >
                    finish_status = #{item.finishStatus},
                </if>
                <if test="item.updateBy != null and item.updateBy != ''" >
                    update_by = #{item.updateBy},
                </if>
                <if test="item.updateTime != null" >
                    update_time = #{item.updateTime}
                </if>
            </set>
            where id = #{item.id}
        </foreach>
    </update>
 
 
   <select id="statisticByCourseUuid" resultType="com.gkhy.exam.institutionalaccess.model.vo.ThStatisticStudentVO">
       SELECT
           c.course_uuid,
           count(s.idcard) as count
       FROM
           th_student_batch s
           INNER JOIN th_batch_course c ON s.batch_uuid = c.batch_uuid
       WHERE
           s.del_flag = 0
         AND c.del_flag = 0
       GROUP BY
           c.course_uuid
   </select>
 
    <select id="statisticByBatchUuid" resultType="com.gkhy.exam.institutionalaccess.model.vo.ThStatisticStudentVO">
        SELECT
            s.batch_uuid,
            count( s.idcard ) AS count
        FROM
            th_student_batch s
        WHERE
            s.del_flag = 0
        GROUP BY
            s.batch_uuid
    </select>
 
    <select id="getStudentBatchCourseVOByBatchUuid" resultType="com.gkhy.exam.institutionalaccess.model.vo.ThStudentBatchCourseVO">
        SELECT
            sb.idcard,
            sb.batch_uuid,
            sb.`name`,
            bc.course_uuid
        FROM
            th_student_batch sb
                INNER JOIN th_batch_course bc ON bc.batch_uuid = sb.batch_uuid
        WHERE
            sb.del_flag = 0
          AND bc.del_flag = 0
          AND sb.batch_uuid = #{batchUuid}
    </select>
 
    <update id="updateByBatchUuid">
        update th_student_batch set finish_status = 1 where batch_uuid = #{batchUuid}
    </update>
    <update id="updateFinishStatusByBatchUuid">
        update th_student_batch set finish_status = 1 where batch_uuid = #{batchUuid}
    </update>
 
    <select id="getStudentBatchVOByBatchUuid" resultType="com.gkhy.exam.institutionalaccess.model.vo.ThStudentBatchVO">
        select sb.*, b.batch_lesson_num from th_student_batch sb INNER JOIN th_batch b ON sb.batch_uuid = b.uuid where sb.del_flag = 0 and sb.batch_uuid = #{batchUuid}
    </select>
 
    <select id="getByIdCards" resultType="com.gkhy.exam.institutionalaccess.entity.ThStudentBatch" >
        select id,uuid,idcard, name, sex, phone, auth_photo,train_org_name, institution_id, institution_name,
        industry,occupation,post,finish_status,batch_uuid from th_student_batch where del_flag = 0 and idcard in
        <foreach collection="idcards" item="idcard" index ="index" open="(" close=")" separator=",">
            #{idcard}
        </foreach>
    </select>
    <select id="getStudentBatchVOByCourseUuid" resultType="com.gkhy.exam.institutionalaccess.model.vo.ThStudentBatchVO">
        SELECT
            sb.*,
            b.batch_lesson_num,
            bc.course_lesson_num
        FROM
            th_student_batch sb
                INNER JOIN th_batch b ON sb.batch_uuid = b.uuid
                INNER JOIN th_batch_course bc ON bc.batch_uuid = b.uuid
        WHERE
            sb.del_flag = 0
          AND bc.course_uuid = #{courseUuid}
    </select>
 
    <select id="getStatistic" resultType="com.gkhy.exam.institutionalaccess.model.vo.ThTrainVO">
        SELECT
        sb.institution_id,
        count( sb.institution_id ) studentCount,
        sum(case when sb.finish_status=1 then 1 else 0 end) finishCount
 
        FROM
        th_student_batch sb
        LEFT JOIN th_batch b ON sb.batch_uuid = b.uuid
        WHERE
        sb.del_flag = 0
        <if test="query.subjectCode != null and query.subjectCode != ''">
            and b.subject_code like concat(#{query.subjectCode}, '%')
        </if>
        <if test="query.trainOrgName != null and query.trainOrgName != ''">
            and b.train_org_name = #{query.trainOrgName}, '%')
        </if>
        <if test="query.startTime != null"><!-- 开始时间检索 -->
            and date_format(b.actual_start_time,'%y-%m-%d') &gt;= date_format(#{query.startTime},'%y-%m-%d')
        </if>
        <if test="query.endTime != null"><!-- 结束时间检索 -->
            and date_format(b.actual_start_time,'%y-%m-%d') &lt;= date_format(#{query.endTime},'%y-%m-%d')
        </if>
        GROUP BY
        sb.institution_id
    </select>
    <select id="getStatisticHaveExam" resultType="com.gkhy.exam.institutionalaccess.model.vo.ThTrainVO">
        SELECT
        sb.institution_id,
        count( sb.institution_id ) studentCount,
        sum(case when sb.finish_status=1 then 1 else 0 end) finishCount
 
        FROM
        th_student_batch sb
        LEFT JOIN th_batch b ON sb.batch_uuid = b.uuid
        WHERE
        sb.del_flag = 0
        AND b.have_exam = 1
        <if test="query.subjectCode != null and query.subjectCode != ''">
            and b.subject_code like concat(#{query.subjectCode}, '%')
        </if>
        <if test="query.trainOrgName != null and query.trainOrgName != ''">
            and b.train_org_name = #{query.trainOrgName}, '%')
        </if>
        <if test="query.startTime != null"><!-- 开始时间检索 -->
            and date_format(b.actual_start_time,'%y-%m-%d') &gt;= date_format(#{query.startTime},'%y-%m-%d')
        </if>
        <if test="query.endTime != null"><!-- 结束时间检索 -->
            and date_format(b.actual_start_time,'%y-%m-%d') &lt;= date_format(#{query.endTime},'%y-%m-%d')
        </if>
        GROUP BY
        sb.institution_id
    </select>
</mapper>