RenSheJuMapper.xml 15.2 KB
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 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
<?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.subsidy.mapper.RenSheJuMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.subsidy.model.CertCompanyMappingDO">
        <id column="id" property="id" />
        <result column="create_date" property="createDate" />
        <result column="update_date" property="updateDate" />
        <result column="delete_date" property="deleteDate" />
        <result column="company_id" property="companyId" />
        <result column="cert_id" property="certId" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, company_id, cert_id
    </sql>

    <select id="classBaseInfo" parameterType="long" resultType="com.subsidy.vo.renshe.ClassBaseInfoVO">
        SELECT
            t2.id  AS downCode,
            t2.class_code,
            t2.class_name AS shortName,
            ROUND( sum( t7.vod_length )/ 60 ) AS learnHour,
            FLOOR( sum( t7.vod_length )/ 2700 ) AS courseHour,
            REPLACE ( unix_timestamp( t2.start_date ), '.', '' )/ 1000 AS startDate,
            REPLACE ( unix_timestamp( t2.end_date ), '.', '' )/ 1000 AS endDate,
            t3.area_name AS areaName,
            t3.company_name AS trainingName,
            t3.company_code AS trainingCode
        FROM
            class_dict t2
            LEFT JOIN company_dict t3 ON t2.company_id = t3.id
            LEFT JOIN course_dict t4 ON t2.course_id = t4.id
            LEFT JOIN course_content t5 ON t4.id = t5.course_id
            LEFT JOIN content_vod_mapping t6 ON t5.id = t6.content_id
            LEFT JOIN vod_dict t7 ON t6.vod_id = t7.id
        WHERE
            t2.id = #{classId}
            AND t2.delete_date IS NULL
            AND t3.delete_date IS NULL
            AND t4.delete_date IS NULL
            AND t5.delete_date IS NULL
            AND t6.delete_date IS NULL
            AND t7.delete_date IS NULL
    </select>

    <select id="classMembers" parameterType="long" resultType="com.subsidy.vo.renshe.MemberVO">
        SELECT
            t2.user_name as name,
            t2.telephone as phone,
            t2.id_card as identity
        FROM
            class_member_mapping t
            LEFT JOIN member t2 ON t.member_id = t2.id
        WHERE
            t.class_id = #{classId}
            AND t.delete_date IS NULL
            AND t2.delete_date IS NULL
    </select>

    <select id="classChapters" parameterType="long" resultType="com.subsidy.dto.renshe.ChapterList2">
        SELECT
            t7.id AS chapterCode,
            IFNULL( t6.vod_alias_name, t7.vod_name ) as chapterName,
            ROUND( t7.vod_length / 60 ) as chapterTime,
            0 as isExam,
            120 as examTime
        FROM
            class_dict t2
            LEFT JOIN course_dict t4 ON t2.course_id = t4.id
            LEFT JOIN course_content t5 ON t4.id = t5.course_id
            LEFT JOIN content_vod_mapping t6 ON t5.id = t6.content_id
            LEFT JOIN vod_dict t7 ON t6.vod_id = t7.id
        WHERE
            t2.id = #{classId}
            AND t2.delete_date IS NULL
            AND t4.delete_date IS NULL
            AND t5.delete_date IS NULL
            AND t6.delete_date IS NULL
            AND t7.delete_date IS NULL
        ORDER BY
            t5.order_no,
            t6.order_no,
            t7.order_no
    </select>

    <select id="newClasses" resultType="long">
        SELECT DISTINCT
            t1.id
        FROM
            class_dict t1
        WHERE
            DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
            AND t1.delete_date IS NULL
            and t1.class_code is not NULL
    </select>

    <select id="dailyStudyInfo" resultType="com.subsidy.vo.renshe.DailyStudyInfoVO">
        SELECT
            t2.class_id as downCode,
            t2.member_id,
            t4.user_name as studentName,
            t4.telephone as phone,
            t4.id_card as identity,
            t2.learnTime,
            t2.playTime,
            t5.loginTime
        FROM
            (
            SELECT
                t1.class_id,
                t1.member_id,
                sum( t1.play_length ) AS learnTime,
                sum( t1.play_length + t1.suspend_length ) AS playTime
            FROM
                vod_play_history t1
            WHERE
                DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
                AND t1.delete_date IS NULL
            GROUP BY
                t1.class_id,
                t1.member_id
            ) t2
            LEFT JOIN class_dict t3 ON t2.class_id = t3.id
            LEFT JOIN member t4 ON t2.member_id = t4.id
            LEFT JOIN (
            SELECT
              t3.user_id,
              login - logout AS loginTime
            FROM
                (
                SELECT
                    user_id,
                    sum(
                    unix_timestamp( t1.create_date )) AS login
                FROM
                    opr_mem_dict t1
                WHERE
                    DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
                    AND t1.delete_date IS NULL
                    AND opr_type = "登出"
                    AND result = 1
                    GROUP BY user_id
                ) t3
                LEFT JOIN (
                SELECT
                    user_id,
                    sum(
                    unix_timestamp( t1.create_date )) AS logout
                FROM
                    opr_mem_dict t1
                WHERE
                    DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
                    AND t1.delete_date IS NULL
                    AND opr_type = "登录"
                    AND result = 1
                    GROUP BY user_id
                ) t2 ON t3.user_id = t2.user_id
            ) t5 ON t4.id = t5.user_id
    </select>


    <select id="dailyActivities" resultType="com.subsidy.vo.renshe.DailyActivitiesVO">
        SELECT
            t1.`status` as access,
	        unix_timestamp( t1.create_date )*1000  as activityTime,
	        t1.check_type
        FROM
            activity_detection t1
        WHERE
            DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
            AND t1.delete_date IS NULL
            AND t1.member_id = #{memberId}
            AND t1.class_id = #{classId}
    </select>

    <select id="examActivities" resultType="com.subsidy.vo.renshe.ExamActivitiesVO">
        SELECT
            t1.result AS access,
            UNIX_TIMESTAMP( t1.create_date )* 1000 AS activityTime
        FROM
            image_check_record t1
        WHERE
            class_id =#{classId}
            AND DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
            AND t1.paper_id IS NOT NULL
            AND t1.member_id=#{memberId}
    </select>

    <select id="dailyStayLength" parameterType="long" resultType="long">
            SELECT
        login - logout
    FROM
        (
        SELECT
            user_id,
            sum(
            unix_timestamp( t1.create_date )) AS login
        FROM
            opr_mem_dict t1
        WHERE
            DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
            AND t1.delete_date IS NULL
            AND t1.user_id = #{memberId}
            AND opr_type = "登出"
            AND result = 1
        ) t3
        LEFT JOIN (
        SELECT
            user_id,
            sum(
            unix_timestamp( t1.create_date )) AS logout
        FROM
            opr_mem_dict t1
        WHERE
            DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
            AND t1.delete_date IS NULL
            AND t1.user_id = #{memberId}
            AND opr_type = "登录"
        AND result = 1
        ) t2 ON t3.user_id = t2.user_id
    </select>

    <select id="loginRecords" parameterType="long" resultType="com.subsidy.model.OprMemDictDO">
        SELECT
            *
        FROM
            opr_mem_dict t
        WHERE
            user_id = #{memberId}
            AND t.result = 1
            AND t.delete_date IS NULL
            AND opr_type = "登录"
            AND DATE_FORMAT( DATE_ADD( create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT(
                NOW(),
            '%Y-%m-%d'
            )
    </select>

    <select id="loginOutRecords" parameterType="long" resultType="com.subsidy.model.OprMemDictDO">
         SELECT
            *
        FROM
            opr_mem_dict t
        WHERE
            user_id = #{memberId}
            AND t.result = 1
            AND t.delete_date IS NULL
            AND opr_type = "登出"
            AND DATE_FORMAT( DATE_ADD( create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT(
                NOW(),
            '%Y-%m-%d'
            )
    </select>

    <select id="dailyStudyRecords" resultType="com.subsidy.dto.renshe.ChapterList3">
        SELECT
            t2.id as chapterCode,
            t.play_length AS chapterTime,
            t.play_length + t.suspend_length AS pauseTime,
            unix_timestamp(subdate( t.create_date, INTERVAL t.play_length SECOND ))*1000 AS startTime,
            unix_timestamp(t.create_date)*1000 AS endTime
        FROM
            vod_play_history t
            LEFT JOIN vod_dict t2 ON t.vod_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t.member_id = #{memberId}
            AND t.create_date BETWEEN DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%s' )
            AND DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%s' )
            and t.class_id = #{classId}
    </select>

    <select id="dailyExamBasic" resultType="com.subsidy.vo.renshe.DailyExamBasicVO">
        SELECT
            t3.id as downCode,
            t2.id as memberId,
            t3.class_code,
            t2.user_name AS studentName,
            t2.telephone AS phone,
            t2.id_card AS identity,
        IF
            ( t1.result = "合格", 0, 1 ) AS access,
            unix_timestamp( t1.create_date )- unix_timestamp( t1.start_date ) AS examTime
        FROM
            exercise_done_result t1
            LEFT JOIN member t2 ON t1.member_id = t2.id
            LEFT JOIN class_dict t3 ON t1.class_id = t3.id
        WHERE
            DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
    </select>

    <select id="classVodName" parameterType="string" resultType="string">
        SELECT
             t7.id AS chapterCode
            FROM
             class_dict t2
             LEFT JOIN course_dict t4 ON t2.course_id = t4.id
             LEFT JOIN course_content t5 ON t4.id = t5.course_id
             LEFT JOIN content_vod_mapping t6 ON t5.id = t6.content_id
             LEFT JOIN vod_dict t7 ON t6.vod_id = t7.id
            WHERE
             t2.id = #{classId}
             AND t2.delete_date IS NULL
             AND t4.delete_date IS NULL
             AND t5.delete_date IS NULL
             AND t6.delete_date IS NULL
             AND t7.delete_date IS NULL
            ORDER BY
             t5.order_no desc,
             t6.order_no desc,
             t7.order_no desc
             limit 1
    </select>

    <select id="dailyExerciseDone" resultType="com.subsidy.model.ExerciseDoneResultDO">
          SELECT
            *
        FROM
            exercise_done_result t
        WHERE
            t.delete_date IS NULL
            AND t.member_id = #{memberId}
            AND t.create_date BETWEEN DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%s' )
            AND DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%s' )
    </select>

    <select id="dailyAnswer" resultType="com.subsidy.vo.renshe.DailyAnswerVO">
        SELECT
            t1.id,
            t1.ask_id,
            t2.id AS downCode,
            t3.id_card AS identity,
            UNIX_TIMESTAMP( t1.create_date )*1000 AS answer,
            UNIX_TIMESTAMP( t1.update_date )*1000 AS question
        FROM
            answering_question t1
            LEFT JOIN class_dict t2 ON t1.class_id = t2.id
            LEFT JOIN member t3 ON t1.ask_id = t3.id
        WHERE
            DATE_FORMAT( DATE_ADD( t1.update_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
            AND t1.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t3.delete_date IS NULL
    </select>

    <select id="checkClassIds" resultType="long">
       SELECT
         distinct class_id
        FROM
         image_check_record
        WHERE
         delete_date IS NULL
         AND DATE_FORMAT( DATE_ADD( update_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT(
          NOW(),
         '%Y-%m-%d'
         )
    </select>

    <select id="classImageChecks" parameterType="long" resultType="com.subsidy.vo.renshe.ClassImageChecksVO">
      SELECT
         t1.member_id,
         t1.photo AS image,
         t2.telephone AS phone,
         t2.user_name AS studentName,
         t2.id_card AS identity,
         UNIX_TIMESTAMP( t1.update_date)*1000 AS activityTime
        FROM
         class_member_mapping t1
         LEFT JOIN member t2 ON t1.member_id = t2.id
        WHERE
         class_id = #{classId}
         AND t1.delete_date IS NULL
         and t2.delete_date is null
         AND DATE_FORMAT( DATE_ADD( t1.update_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT(
          NOW(),
         '%Y-%m-%d'
         )
    </select>

    <select id="passExamCheck" parameterType="long" resultType="com.subsidy.vo.renshe.ClassImageChecksVO">
        SELECT
             t1.member_id,
             t1.photo AS image,
             t2.user_name AS studentName,
             t2.id_card AS identity,
             t2.telephone AS phone,
             UNIX_TIMESTAMP( t1.create_date )* 1000 AS activityTime
            FROM
             image_check_record t1
             LEFT JOIN member t2 ON t1.member_id = t2.id
            WHERE
             class_id = #{classId}
             AND DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
             AND t1.paper_id IS NOT NULL
             AND t1.result = 1
    </select>

    <select id="studyCheck" parameterType="long" resultType="com.subsidy.vo.renshe.ClassImageChecksVO">
        SELECT
             t1.class_id,
             t1.member_id,
             t1.photo AS image,
             t2.user_name AS studentName,
             t2.id_card AS identity,
             t2.telephone AS phone,
             UNIX_TIMESTAMP( t1.create_date )* 1000 AS activityTime
            FROM
             image_check_record t1
             LEFT JOIN member t2 ON t1.member_id = t2.id
            WHERE
             class_id = #{classId}
             AND DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
             AND t1.paper_id IS NULL
             AND t1.result = 1
             and t1.member_id
            GROUP BY t1.class_id,t1.member_id
            ORDER BY t1.create_date desc
    </select>


</mapper>