<?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.pqs9300.mapper.technical.TechnicalInfoMapper'>
    <select id="getTechnicalInfo" resultType="com.pqs9300.pojo.technical.TechnicalInfo">
        SELECT
        supe.SUP_INDEX supIndex,
        supe.name supName,
        users.NAME userName,
        supe.CREATE_TIME creatTime,
        depts.DEPTSNAME deptName,
        supe.type supType,
        supe.MODIFY_TIME modifyTime,
        supe.SUP_DESCRIBE supDescribe,
        supe.PROGRESS progress
        FROM
        THS_SUPERVISE supe,
        pqs_user users,
        PQS_DEPTS depts
        WHERE
        supe.CREATE_USER = users.USER_INDEX
        AND supe.DEPTS = depts.DEPTS_INDEX
        and supe.MODIFY_TIME between #{startTime} and #{endTime}
        and supe.PROGRESS in
        <foreach collection="progress" item="item" index="index" open="("
                 separator="," close=")">
            #{item}
        </foreach>
        and supe.type in
        <foreach collection="supType" item="item" index="index" open="("
                 separator="," close=")">
            #{item}
        </foreach>
        order by supe.MODIFY_TIME desc
    </select>

    <update id="getStartSwitch">
        <foreach collection="list" item="item" index="index" open="begin" close="; end;" separator=";">
            update THS_SUPERVISE set PROGRESS = 1 where SUP_INDEX = #{item}
        </foreach>
    </update>

    <select id="getTransactionDataByDepts" resultType="com.pqs9300.pojo.technical.TechnicalInfo">
        select
        t1.SUP_INDEX supIndex,
        t1.name supName,
        t3.NAME userName,
        t1.CREATE_TIME creatTime,
        t2.DEPTSNAME deptName,
        t1.type supType,
        t1.MODIFY_TIME modifyTime,
        t1.SUP_DESCRIBE supDescribe,
        t1.PROGRESS progress
        from
        THS_SUPERVISE t1,pqs_depts t2,pqs_user t3
        where
        t1.up_user is null
        and t1.MODIFY_TIME between #{startTime} and #{endTime}
        and	t1.depts in
        <foreach collection="deptsIndexs" separator="," open="(" close=")" item="deptsIndex">
            #{deptsIndex}
        </foreach>
        and t1.depts=t2.depts_index
        and t1.create_user=t3.user_index
        <if test="type != 2">
            and t1.type=#{type}
        </if>
        <if test="progress != 7">
            and t1.progress=#{progress}
        </if>
    </select>
    <select id="getTransactionDataByUserIndex" resultType="com.pqs9300.pojo.technical.TechnicalInfo">
        select
        t1.SUP_INDEX supIndex,
        t1.name supName,
        t3.NAME userName,
        t1.CREATE_TIME creatTime,
        t2.DEPTSNAME deptName,
        t1.type supType,
        t1.MODIFY_TIME modifyTime,
        t1.SUP_DESCRIBE supDescribe,
        t1.PROGRESS progress
        from
        THS_SUPERVISE t1,pqs_depts t2,pqs_user t3
        where
        t1.up_user is not null
        and t1.MODIFY_TIME between #{startTime} and #{endTime}
        and	t1.up_user = #{userIndex}
        and t1.depts=t2.depts_index
        and t1.create_user=t3.user_index
        <if test="type != 2">
            and t1.type=#{type}
        </if>
        <if test="progress != 7">
            and t1.progress=#{progress}
        </if>
    </select>
</mapper>
