TTrainCourseMapper.xml 13.8 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
1 2 3 4 5
<?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.zehong.system.mapper.TTrainCourseMapper">
6

耿迪迪's avatar
耿迪迪 committed
7 8 9 10
    <resultMap type="TTrainCourse" id="TTrainCourseResult">
        <result property="courseId"    column="course_id"    />
        <result property="courseName"    column="course_name"    />
        <result property="courseType"    column="course_type"    />
11
        <result property="planName"    column="plan_name"    />
耿迪迪's avatar
耿迪迪 committed
12 13
        <result property="courseConent"    column="course_conent"    />
        <result property="status"    column="status"    />
14
        <result property="personnelType"    column="personnel_type"    />
耿迪迪's avatar
耿迪迪 committed
15 16 17 18 19 20 21 22
        <result property="releaseTime"    column="release_time"    />
        <result property="enclosure"    column="enclosure"    />
        <result property="video"    column="video"    />
        <result property="qualifiedNum"    column="qualified_num"    />
        <result property="topicNum"    column="topic_num"    />
        <result property="createTime"    column="create_time"    />
        <result property="createUser"    column="create_user"    />
        <result property="isDel"    column="is_del"    />
耿迪迪's avatar
耿迪迪 committed
23 24 25 26
        <result property="dataKind"    column="data_kind"    />
        <result property="testStartTime"    column="test_start_time"    />
        <result property="testEndTime"    column="test_end_time"    />
        <result property="testPersons"    column="test_persons"    />
27
        <result property="duration"  column="duration"    />
28 29 30
        <result property="multipleChoiceScore"  column="multiple_choice_score"    />
        <result property="singleChoiceScore"  column="single_choice_score"    />
        <result property="judgmentScore"  column="judgment_score"    />
31
        <result property="isVeriftyFace"    column="is_verifty_face"    />
耿迪迪's avatar
耿迪迪 committed
32 33
    </resultMap>

耿迪迪's avatar
耿迪迪 committed
34 35 36 37
    <resultMap id="StatisticsTrainCourseResult" type="StatisticsTrainCourse">
        <result property="courseId"    column="course_id"    />
        <result property="courseName"    column="course_name"    />
        <result property="releaseTime"    column="release_time"    />
耿迪迪's avatar
耿迪迪 committed
38
        <result property="dataKind"    column="data_kind"    />
耿迪迪's avatar
耿迪迪 committed
39 40 41 42 43 44
        <result property="count"    column="count"    />
        <result property="test"    column="test"    />
        <result property="pass"    column="pass"    />
        <result property="rate"    column="rate"    />
    </resultMap>

耿迪迪's avatar
耿迪迪 committed
45
    <sql id="selectTTrainCourseVo">
46
        select multiple_choice_score,single_choice_score,judgment_score,course_id, course_name, course_type, course_conent, status,personnel_type, release_time, enclosure, video, qualified_num, topic_num, create_time, create_user, is_del, data_kind, test_start_time, test_end_time, test_persons,duration,is_verifty_face from t_train_course
耿迪迪's avatar
耿迪迪 committed
47 48 49
    </sql>

    <select id="selectTTrainCourseList" parameterType="TTrainCourse" resultMap="TTrainCourseResult">
50 51 52
        select c.*,p.plan_name from t_train_course c
        LEFT JOIN t_train_plan p on p.plan_id = c.course_type

53
        <where>
54 55 56 57 58 59 60 61 62 63
            <if test="courseName != null  and courseName != ''"> and c.course_name like concat('%', #{courseName}, '%')</if>
            <if test="courseType != null "> and c.course_type = #{courseType}</if>
            <if test="courseConent != null  and courseConent != ''"> and c.course_conent = #{courseConent}</if>
            <if test="status != null "> and c.status = #{status}</if>
            <if test="enclosure != null  and enclosure != ''"> and c.enclosure = #{enclosure}</if>
            <if test="video != null  and video != ''"> and c.video = #{video}</if>
            <if test="qualifiedNum != null "> and c.qualified_num = #{qualifiedNum}</if>
            <if test="topicNum != null "> and c.topic_num = #{topicNum}</if>
            <if test="createUser != null  and createUser != ''"> and c.create_user = #{createUser}</if>
            <if test="isDel != null "> and c.is_del = #{isDel}</if>
耿迪迪's avatar
耿迪迪 committed
64
            <if test="dataKind != null  and dataKind != ''"> and data_kind = #{dataKind}</if>
吴卿华's avatar
吴卿华 committed
65
            <if test="dataKind == null  and dataKind != ''"> and data_kind != '1'</if>
耿迪迪's avatar
耿迪迪 committed
66 67 68
            <if test="testStartTime != null "> and test_start_time = #{testStartTime}</if>
            <if test="testEndTime != null "> and test_end_time = #{testEndTime}</if>
            <if test="testPersons != null  and testPersons != ''"> and test_persons = #{testPersons}</if>
耿迪迪's avatar
耿迪迪 committed
69 70
        </where>
    </select>
71

耿迪迪's avatar
耿迪迪 committed
72 73 74 75 76 77 78 79 80 81 82 83
    <select id="selectTTrainCourseById" parameterType="Long" resultMap="TTrainCourseResult">
        <include refid="selectTTrainCourseVo"/>
        where course_id = #{courseId}
    </select>

    <insert id="insertTTrainCourse" parameterType="TTrainCourse" useGeneratedKeys="true" keyProperty="courseId">
        insert into t_train_course
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="courseName != null">course_name,</if>
            <if test="courseType != null">course_type,</if>
            <if test="courseConent != null">course_conent,</if>
            <if test="status != null">status,</if>
84
            <if test="personnelType != null">personnel_type,</if>
耿迪迪's avatar
耿迪迪 committed
85 86 87 88 89 90 91 92
            <if test="releaseTime != null">release_time,</if>
            <if test="enclosure != null">enclosure,</if>
            <if test="video != null">video,</if>
            <if test="qualifiedNum != null">qualified_num,</if>
            <if test="topicNum != null">topic_num,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createUser != null">create_user,</if>
            <if test="isDel != null">is_del,</if>
耿迪迪's avatar
耿迪迪 committed
93 94 95 96
            <if test="dataKind != null">data_kind,</if>
            <if test="testStartTime != null">test_start_time,</if>
            <if test="testEndTime != null">test_end_time,</if>
            <if test="testPersons != null">test_persons,</if>
97
            <if test="duration != null">duration,</if>
98 99 100
            <if test="multipleChoiceScore != null">multiple_choice_score,</if>
            <if test="singleChoiceScore != null">single_choice_score,</if>
            <if test="judgmentScore != null">judgment_score,</if>
101 102
            <if test="isVeriftyFace != null">is_verifty_face,</if>
        </trim>
耿迪迪's avatar
耿迪迪 committed
103 104 105 106 107
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="courseName != null">#{courseName},</if>
            <if test="courseType != null">#{courseType},</if>
            <if test="courseConent != null">#{courseConent},</if>
            <if test="status != null">#{status},</if>
108
            <if test="personnelType != null">#{personnelType},</if>
耿迪迪's avatar
耿迪迪 committed
109 110 111 112 113 114 115 116
            <if test="releaseTime != null">#{releaseTime},</if>
            <if test="enclosure != null">#{enclosure},</if>
            <if test="video != null">#{video},</if>
            <if test="qualifiedNum != null">#{qualifiedNum},</if>
            <if test="topicNum != null">#{topicNum},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createUser != null">#{createUser},</if>
            <if test="isDel != null">#{isDel},</if>
耿迪迪's avatar
耿迪迪 committed
117 118 119 120
            <if test="dataKind != null">#{dataKind},</if>
            <if test="testStartTime != null">#{testStartTime},</if>
            <if test="testEndTime != null">#{testEndTime},</if>
            <if test="testPersons != null">#{testPersons},</if>
121
            <if test="duration != null">#{duration},</if>
122 123 124
            <if test="multipleChoiceScore != null">#{multipleChoiceScore},</if>
            <if test="singleChoiceScore != null">#{singleChoiceScore},</if>
            <if test="judgmentScore != null">#{judgmentScore},</if>
125 126
            <if test="isVeriftyFace != null">#{isVeriftyFace},</if>
        </trim>
耿迪迪's avatar
耿迪迪 committed
127 128 129 130 131 132 133 134 135
    </insert>

    <update id="updateTTrainCourse" parameterType="TTrainCourse">
        update t_train_course
        <trim prefix="SET" suffixOverrides=",">
            <if test="courseName != null">course_name = #{courseName},</if>
            <if test="courseType != null">course_type = #{courseType},</if>
            <if test="courseConent != null">course_conent = #{courseConent},</if>
            <if test="status != null">status = #{status},</if>
136
            <if test="personnelType != null">personnel_type = #{personnelType},</if>
耿迪迪's avatar
耿迪迪 committed
137 138 139 140 141 142 143 144
            <if test="releaseTime != null">release_time = #{releaseTime},</if>
            <if test="enclosure != null">enclosure = #{enclosure},</if>
            <if test="video != null">video = #{video},</if>
            <if test="qualifiedNum != null">qualified_num = #{qualifiedNum},</if>
            <if test="topicNum != null">topic_num = #{topicNum},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createUser != null">create_user = #{createUser},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
耿迪迪's avatar
耿迪迪 committed
145 146 147 148
            <if test="dataKind != null">data_kind = #{dataKind},</if>
            <if test="testStartTime != null">test_start_time = #{testStartTime},</if>
            <if test="testEndTime != null">test_end_time = #{testEndTime},</if>
            <if test="testPersons != null">test_persons = #{testPersons},</if>
149
            <if test="duration != null">duration = #{duration},</if>
150 151 152
            <if test="multipleChoiceScore != null">multiple_choice_score = #{multipleChoiceScore},</if>
            <if test="singleChoiceScore != null">single_choice_score = #{singleChoiceScore},</if>
            <if test="judgmentScore != null">judgment_score = #{judgmentScore},</if>
153
            <if test="isVeriftyFace != null">is_verifty_face = #{isVeriftyFace},</if>
耿迪迪's avatar
耿迪迪 committed
154 155 156 157 158 159 160 161 162
        </trim>
        where course_id = #{courseId}
    </update>

    <delete id="deleteTTrainCourseById" parameterType="Long">
        delete from t_train_course where course_id = #{courseId}
    </delete>

    <delete id="deleteTTrainCourseByIds" parameterType="String">
163
        delete from t_train_course where course_id in
耿迪迪's avatar
耿迪迪 committed
164 165 166 167 168
        <foreach item="courseId" collection="array" open="(" separator="," close=")">
            #{courseId}
        </foreach>
    </delete>
    <insert id="insertUserCourse">
169
        INSERT INTO t_train_user_course(user_id,course_id,personnel_type,create_time) VALUES
耿迪迪's avatar
耿迪迪 committed
170
        <foreach collection="userIds" separator="," item="item">
171
            (#{item},#{courseId},#{personnelType},NOW())
耿迪迪's avatar
耿迪迪 committed
172 173 174
        </foreach>
    </insert>
    <select id="userCourseList" resultType="com.zehong.system.domain.vo.UserCourseVo">
175
        SELECT uc.user_course_id AS userCourseId,uc.state ,uc.examination_time AS examinationTime,uc.train_state AS trainState,c.is_verifty_face AS isVeriftyFace,
176
        uc.`examination_result` AS examinationResult,uc.`create_time` AS createTime,c.test_start_time as testStartTime,c.test_end_time as testEndTime,
177
        c.`course_name` AS courseName, c.`topic_num` AS topicNum,c.`release_time` AS releaseTime,c.data_kind as dataKind,c.personnel_type as personnelType,
吴卿华's avatar
吴卿华 committed
178 179
        p.`plan_name` AS courseType,c.course_id as courseId,c.qualified_num as qualifiedNum,c.multiple_choice_score as multipleChoiceScore,
        c.judgment_score as judgmentScore,c.single_choice_score as singleChoiceScore
耿迪迪's avatar
耿迪迪 committed
180 181 182
        FROM t_train_user_course uc
        LEFT JOIN t_train_course c ON c.`course_id` = uc.`course_id`
        LEFT JOIN t_train_plan p ON p.`plan_id` = c.`course_type`
183
        WHERE uc.user_id = #{userId} and uc.personnel_type =#{personnelType}
耿迪迪's avatar
耿迪迪 committed
184 185 186 187 188 189 190 191 192 193 194
        <if test="type!=null and type == 1">
            and uc.state !=2
        </if>
        <if test="type!=null and type == 2">
            and uc.state = 2
        </if>
        <if test="type!=null and type == 3">
            and uc.state !=0
            order by uc.examination_time desc
        </if>
    </select>
耿迪迪's avatar
耿迪迪 committed
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209

    <select id="statisticsTrainCourse" parameterType="StatisticsTrainCourse" resultMap="StatisticsTrainCourseResult">
        SELECT
          course.course_id,
          course.course_name,
          course.release_time,
          course.data_kind,
          COUNT(user.user_course_id)AS count,
          SUM(case when user.state > 0 then 1 else 0 end)AS test,
          SUM(case when user.state = 2 then 1 else 0 end)AS pass,
          ROUND(SUM(case when user.state = 2 then 1 else 0 end)/COUNT(user.user_course_id)*100)AS rate
        FROM
            t_train_course course
        INNER JOIN t_train_user_course user ON course.course_id = user.course_id
        <where>
耿迪迪's avatar
耿迪迪 committed
210 211 212 213
            course.status = '1' AND course.is_del = '0' AND course.personnel_type = '1'
            <if test="courseName != null  and courseName != ''"> and course.course_name like concat('%', #{courseName}, '%')</if>
            <if test="dataKind != null  and dataKind != ''"> and course.data_kind = #{dataKind}</if>
            <if test="releaseTimeBegin != null  and releaseTimeBegin != '' and releaseTimeEnd != null  and releaseTimeEnd != ''"> and course.release_time BETWEEN #{releaseTimeBegin} AND #{releaseTimeEnd}</if>
耿迪迪's avatar
耿迪迪 committed
214 215 216
        </where>
        GROUP BY course.course_id
    </select>
吴卿华's avatar
吴卿华 committed
217 218 219 220 221 222 223 224 225 226 227 228 229 230


    <select id="userCourseLists" resultType="com.zehong.system.domain.vo.UserCourseVo">
        SELECT uc.user_course_id AS userCourseId,uc.finish_duration AS finishDuration,uc.state ,uc.examination_time AS examinationTime,uc.train_state AS trainState,
        uc.`examination_result` AS examinationResult,uc.`create_time` AS createTime,c.test_start_time as testStartTime,c.test_end_time as testEndTime,
        c.`course_name` AS courseName, c.`topic_num` AS topicNum,c.`release_time` AS releaseTime,c.data_kind as dataKind,c.personnel_type as personnelType,
        p.`plan_name` AS courseType,c.course_id as courseId,c.qualified_num as qualifiedNum,c.multiple_choice_score as multipleChoiceScore,
        c.judgment_score as judgmentScore,c.single_choice_score as singleChoiceScore
        FROM t_train_user_course uc
        LEFT JOIN t_train_course c ON c.`course_id` = uc.`course_id`
        LEFT JOIN t_train_plan p ON p.`plan_id` = c.`course_type`
        WHERE uc.user_id = #{staffId} and uc.personnel_type ='1'
        and data_kind=#{dataKind}
    </select>
231
</mapper>