TSafeCheckTask.xml 3.78 KB
Newer Older
Rensq's avatar
Rensq committed
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
<?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.testor.module.safeCheck.dao.TSafeCheckTaskDao">
    <!-- 开启二级缓存 -->
    <!-- <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/> -->
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.testor.module.safeCheck.model.domain.TSafeCheckTask">
                <id column="id" property="id"/>
                <id column="plan_id" property="planId"/>
                <id column="process_id" property="processId"/>
                <id column="process_status" property="processStatus"/>
                <id column="is_overdue" property="isOverdue"/>
                <id column="checker_id" property="checkerId"/>
                <id column="start_time" property="startTime"/>
                <id column="end_time" property="endTime"/>
                <id column="complete_time" property="completeTime"/>
    </resultMap>

    <select id="pageList" resultType="com.testor.module.safeCheck.model.domain.TSafeCheckTask">
        SELECT
            tsct.*,
            tso.org_name AS orgName,
        tsdd.dict_value as checkTypeName
        FROM
            t_safe_check_task AS tsct
                LEFT JOIN
            t_sys_org AS tso ON tso.org_id = tsct.org_id
                LEFT JOIN
            t_safe_check_person_arrange AS tscpa ON tscpa.check_person_id = tsct.check_person_id
                LEFT JOIN
            t_sys_user AS tsu ON tsu.user_id = tscpa.user_id
                left join
            t_sys_dict_data as tsdd on tsdd.dict_data_id = tsct.check_type
        <where>
            tsct.org_id IN
            <foreach item="id" collection="param.orgIdList" open="(" separator="," close=")">
                #{id}
            </foreach>
            <if test="param.checkPeople!=null and param.checkPeople != ''">
               and tsu.user_name like concat('%',#{param.checkPeople},'%')
            </if>
            <if test="param.name !=null and param.name != ''">
                and tsct.name like concat('%',#{param.name},'%')
            </if>
            <if test="param.taskStatus != null and param.taskStatus != ''">
                <choose>
                    <!-- NOT_STARTED -->
                    <when test="param.taskStatus ==  0 ">
                        AND tsct.start_time &gt;= NOW()
                    </when>
                    <!-- COMPLETED -->
                    <when test="param.taskStatus ==  2 ">
                        AND tsct.complete_time IS NOT NULL
                    </when>
                    <when test="param.taskStatus ==  1 ">
                        AND tsct.start_time &lt;= NOW()
                        AND tsct.complete_time IS  NULL
                    </when>
                </choose>
            </if>
        <if test="param.startTime !=null">
            and tsct.start_time &gt;= #{param.startTime}
        </if>
        <if test="param.endTime !=null">
            and tsct.start_time &lt;= #{param.endTime}
        </if>
        <if test="param.isOverdue!=null and param.isOverdue!= '' and  param.isOverdue == 1 ">
           and ((tsct.complete_time is null and tsct.end_time &lt;= NOW()) or tsct.is_overdue = '1' )
        </if>
        <if test="param.isOverdue!=null and param.isOverdue!= '' and param.isOverdue == 0 ">
            and  ((tsct.complete_time is null and tsct.end_time &gt;= NOW()) or (tsct.complete_time is not null and tsct.end_time >= tsct.complete_time) )
        </if>
        <if test="param.checkType != null and param.checkType != ''">
            and tsct.check_type = #{param.checkType}
        </if>
        </where>
        GROUP BY
            tsct.id, tso.org_name,tsdd.dict_value
        order by create_date desc


    </select>
</mapper>