zhangf
2024-07-24 790c2ba4a0b46edf191e3bac84931f796bd42b8f
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
<?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 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>
 
</mapper>