<?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)<0,'已逾期', IF(TIMESTAMPDIFF(day,NOW(),disabled_time)>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 < 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>