<?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 b.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') >= date_format(#{query.startTime},'%y-%m-%d')
|
</if>
|
<if test="query.endTime != null"><!-- 结束时间检索 -->
|
and date_format(b.actual_start_time,'%y-%m-%d') <= 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') >= date_format(#{query.startTime},'%y-%m-%d')
|
</if>
|
<if test="query.endTime != null"><!-- 结束时间检索 -->
|
and date_format(b.actual_start_time,'%y-%m-%d') <= date_format(#{query.endTime},'%y-%m-%d')
|
</if>
|
GROUP BY
|
sb.institution_id
|
</select>
|
</mapper>
|