<?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="jnpf.limsMapper.LimsSxtQuyangJihuaMapper">
|
|
<!-- 结果映射 -->
|
<resultMap id="BaseResultMap" type="jnpf.limsEntity.LimsSxtQuyangJihuaEntity">
|
<id column="f_id" property="id"/>
|
<result column="jihua_mingcheng" property="jihuaMingcheng"/>
|
<result column="yangpin_leixing" property="yangpinLeixing"/>
|
<result column="suoshu_chejian" property="suoshuChejian"/>
|
<result column="zhidingren" property="zhidingren"/>
|
<result column="kaishi_shijian" property="kaishiShijian"/>
|
<result column="yangpin_mingcheng" property="yangpinMingcheng"/>
|
<result column="jieshu_shijian" property="jieshuShijian"/>
|
<result column="jihua_zhouqi_leixing" property="jihuaZhouqiLeixing"/>
|
<result column="jihua_zhouqi_jiange" property="jihuaZhouqiJiange"/>
|
<result column="jiahua_jiange_danwei" property="jiahuaJiangeDanwei"/>
|
<result column="biz_sign" property="bizSign"/>
|
<result column="biz_status" property="bizStatus"/>
|
<result column="plan_status" property="planStatus"/>
|
<result column="f_tenant_id" property="fTenantId"/>
|
<result column="f_flow_id" property="fFlowId"/>
|
<result column="f_version" property="fVersion"/>
|
<result column="f_flow_task_id" property="fFlowTaskId"/>
|
<result column="f_flow_state" property="fFlowState"/>
|
<result column="f_delete_mark" property="fDeleteMark"/>
|
<result column="f_delete_time" property="fDeleteTime"/>
|
<result column="f_delete_user_id" property="fDeleteUserId"/>
|
<result column="f_creator_time" property="fCreatorTime"/>
|
<result column="f_creator_user_id" property="fCreatorUserId"/>
|
<result column="f_last_modify_time" property="fLastModifyTime"/>
|
<result column="f_last_modify_user_id" property="fLastModifyUserId"/>
|
<result column="yangpin_leixing_mingcheng" property="yangpinLeixingMingcheng"/>
|
</resultMap>
|
|
<!-- 查询指定日期的计划 -->
|
<select id="selectDailyJihua" resultMap="BaseResultMap">
|
SELECT *
|
FROM lims_sxt_quyang_jihua
|
WHERE f_delete_mark = 0
|
AND f_flow_state = 2
|
AND plan_status IN ('available', 'terminating')
|
AND DATE(kaishi_shijian) <= #{day}
|
AND DATE(jieshu_shijian) >= #{day}
|
AND (
|
CASE jihua_zhouqi_leixing
|
WHEN 'daily' THEN
|
DATEDIFF(#{day}, DATE(kaishi_shijian)) % (CAST(jihua_zhouqi_jiange AS UNSIGNED) + 1) = 0
|
|
WHEN 'weekly' THEN
|
WEEKDAY(#{day}) = WEEKDAY(DATE(kaishi_shijian))
|
AND FLOOR(DATEDIFF(#{day}, DATE(kaishi_shijian)) / 7) % (CAST(jihua_zhouqi_jiange AS UNSIGNED) + 1) = 0
|
|
WHEN 'monthly' THEN
|
(
|
DAY(#{day}) = DAY(DATE(kaishi_shijian))
|
OR
|
(
|
DAY(DATE(kaishi_shijian)) = DAY(LAST_DAY(DATE(kaishi_shijian)))
|
AND #{day} = LAST_DAY(#{day})
|
)
|
)
|
AND PERIOD_DIFF(
|
DATE_FORMAT(#{day}, '%Y%m'),
|
DATE_FORMAT(DATE(kaishi_shijian), '%Y%m')
|
) % (CAST(jihua_zhouqi_jiange AS UNSIGNED) + 1) = 0
|
|
WHEN 'quarterly' THEN
|
(
|
DAY(#{day}) = DAY(DATE(kaishi_shijian))
|
OR
|
(
|
DAY(DATE(kaishi_shijian)) = DAY(LAST_DAY(DATE(kaishi_shijian)))
|
AND #{day} = LAST_DAY(#{day})
|
)
|
)
|
AND PERIOD_DIFF(
|
DATE_FORMAT(#{day}, '%Y%m'),
|
DATE_FORMAT(DATE(kaishi_shijian), '%Y%m')
|
) % ((CAST(jihua_zhouqi_jiange AS UNSIGNED) + 1) * 3) = 0
|
|
WHEN 'yearly' THEN
|
(
|
DATE_FORMAT(#{day}, '%m-%d') = DATE_FORMAT(DATE(kaishi_shijian), '%m-%d')
|
OR
|
(
|
MONTH(DATE(kaishi_shijian)) = 2
|
AND DAY(DATE(kaishi_shijian)) = 29
|
AND MONTH(#{day}) = 2
|
AND DAY(#{day}) = 28
|
AND NOT (YEAR(#{day}) % 4 = 0 AND (YEAR(#{day}) % 100 != 0 OR YEAR(#{day}) % 400 = 0))
|
)
|
)
|
AND (YEAR(#{day}) - YEAR(DATE(kaishi_shijian))) % (CAST(jihua_zhouqi_jiange AS UNSIGNED) + 1) = 0
|
|
ELSE 0
|
END
|
)
|
ORDER BY kaishi_shijian ASC
|
</select>
|
|
</mapper>
|