TContingencyPlan.xml 4.84 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 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
<?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.emergency.dao.TContingencyPlanDao">
    <!-- 开启二级缓存 -->
    <!-- <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/> -->
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.testor.module.emergency.model.vo.TContingencyPlanVO">
        <id column="plan_name" property="planName"/>
        <id column="plan_type_key" property="planTypeKey"/>
        <id column="accident_key" property="accidentKey"/>
        <id column="revise_time" property="reviseTime"/>
        <id column="disabled_time" property="disabledTime"/>
        <id column="id" property="id"/>
        <id column="org_id" property="orgId"/>
        <id column="planStatus" property="planStatus"/>
    </resultMap>
    <select id="pageList" resultType="com.testor.module.emergency.model.vo.TContingencyPlanVO" databaseId="mysql">
        SELECT
        a.plan_name,
        a.plan_type_key,
        a.accident_key,
        a.revise_time,
        a.disabled_time,
        a.id,
        a.org_id,
        a.planStatus,
        a.create_date,
        a.status,
        b.org_name
        FROM (
        SELECT
        plan_name,
        plan_type_key,
        accident_key,
        revise_time,
        disabled_time,
        id,
        org_id,
        create_date,
        status,
        IF(TIMESTAMPDIFF(day,NOW(),disabled_time)&lt;0,'已逾期',
        IF(TIMESTAMPDIFF(day,NOW(),disabled_time)&gt;30,'正常','即将逾期')) planStatus
        FROM t_contingency_plan
        ) a
        LEFT JOIN t_sys_org b ON a.org_id = b.org_id

        <where>
            a.status = 0
            and a.org_id in
            (select org.org_id from t_sys_org org where org.parent_ids like '%,${param.orgId}%' or org.org_id = '${param.orgId}')

            <if test="param.orgIdList != null">
                and a.org_id in
                <foreach collection="param.orgIdList" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>

            <if test="param.planTypeKey != null and param.planTypeKey !='' ">
                and a.plan_type_key = #{param.planTypeKey}
            </if>
            <if test="param.planStatus != null and param.planStatus !='' ">
                and a.planStatus = #{param.planStatus}
            </if>
            <if test="param.planName != null and param.planName !='' ">
                and a.plan_name like concat('%',#{param.planName},'%')
            </if>
            <if test="param.startTime != null and param.endTime != null">
                and a.revise_time  between #{param.startTime} AND #{param.endTime}
            </if>
        </where>
        ORDER BY   a.revise_time desc
    </select>
    <select id="pageList" resultType="com.testor.module.emergency.model.vo.TContingencyPlanVO" databaseId="kingbase">
        SELECT
        a.plan_name,
        a.plan_type_key,
        a.accident_key,
        a.revise_time,
        a.disabled_time,
        a.id,
        a.org_id,
        a.planStatus,
        a.create_date,
        a.status,
        b.org_name
        FROM (
        SELECT
        plan_name,
        plan_type_key,
        accident_key,
        revise_time,
        disabled_time,
        id,
        org_id,
        create_date,
        status,
        CASE
        WHEN disabled_time &lt; NOW() THEN '已逾期'
        WHEN disabled_time > NOW() + INTERVAL '30 days' THEN '正常'
        ELSE '即将逾期'
        END AS planStatus
        FROM t_contingency_plan
        ) a
        LEFT JOIN t_sys_org b ON a.org_id = b.org_id

        <where>
            a.status = 0
            and a.org_id in
            (select org.org_id from t_sys_org org where org.parent_ids like '%,${param.orgId}%' or org.org_id = '${param.orgId}')

            <if test="param.orgIdList != null">
                and a.org_id in
                <foreach collection="param.orgIdList" index="index" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>

            <if test="param.planTypeKey != null and param.planTypeKey !='' ">
                and a.plan_type_key = #{param.planTypeKey}
            </if>
            <if test="param.planStatus != null and param.planStatus !='' ">
                and a.planStatus = #{param.planStatus}
            </if>
            <if test="param.planName != null and param.planName !='' ">
                and a.plan_name like concat('%',#{param.planName},'%')
            </if>
            <if test="param.startTime != null and param.endTime != null">
                and a.revise_time  between #{param.startTime} AND #{param.endTime}
            </if>
        </where>
        ORDER BY   a.revise_time desc
    </select>

</mapper>