<?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.qianwen.smartman.modules.tpm.mapper.MaintainPlanMapper">
|
<!-- 查询保养日期为当前日的保养计划 -->
|
<select id="getPlan" resultType="com.qianwen.smartman.modules.tpm.vo.MaintainPlanVO">
|
SELECT id AS id,
|
code AS code
|
FROM blade_maintain_plan
|
WHERE is_deleted = 0
|
AND plan_status = 1
|
AND DATE_FORMAT(maintain_date, '%Y-%m-%d') = DATE_FORMAT(
|
NOW(),
|
'%Y-%m-%d')
|
</select>
|
|
<select id="export" resultType="com.qianwen.smartman.modules.tpm.vo.excel.MaintainPlanExcel">
|
SELECT plan.code AS code,
|
plan.device_code AS deviceCode,
|
plan.device_name AS deviceName,
|
plan.device_type_name AS deviceTypeName,
|
plan.project_name AS projectName,
|
plan.pre_maintain_time AS preMaintainTime,
|
plan.interval_time AS intervalTime,
|
plan.maintain_date AS maintaindate
|
FROM blade_maintain_plan plan
|
WHERE plan.is_deleted = 0
|
<if test="tenantId != null and tenantId != ''">
|
AND plan.tenant_id = #{tenantId}
|
</if>
|
<if test="maintainPlanExportDTO.deviceTypeId != null">
|
AND plan.device_type_id = #{maintainPlanExportDTO.deviceTypeId}
|
</if>
|
|
<if test="maintainPlanExportDTO.deviceId != null">
|
AND plan.device_id = #{maintainPlanExportDTO.deviceId}
|
</if>
|
|
<if test="maintainPlanExportDTO.isAuto != null">
|
AND plan.is_auto = #{maintainPlanExportDTO.isAuto}
|
</if>
|
|
<if test="maintainPlanExportDTO.keyWord != null and maintainPlanExportDTO.keyWord != ''">
|
AND (plan.code like concat(#{maintainPlanExportDTO.keyWord},'%')
|
OR plan.device_code like concat(#{maintainPlanExportDTO.keyWord},'%')
|
OR plan.device_name like concat(#{maintainPlanExportDTO.keyWord},'%')
|
)
|
</if>
|
<if test="maintainPlanExportDTO.planStatusList != null and maintainPlanExportDTO.planStatusList.size >0">
|
AND plan.plan_status in
|
<foreach collection="maintainPlanExportDTO.planStatusList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
ORDER BY plan.create_time DESC,plan.id desc
|
</select>
|
|
<select id="maintainPlanStatisticsNum" resultType="com.qianwen.smartman.modules.tpm.vo.MaintainStatisticsVO">
|
SELECT
|
IFNULL(SUM(
|
CASE WHEN DATE_FORMAT( NOW(), '%Y-%m-%d' ) <![CDATA[ > ]]> DATE_FORMAT( maintain_date, '%Y-%m-%d' )
|
AND
|
plan_status = 2
|
THEN 1 ELSE 0 END ),0) AS delayNum,
|
IFNULL(SUM(
|
CASE WHEN ( DATE_FORMAT( NOW(), '%Y-%m-%d' )= DATE_FORMAT( maintain_date, '%Y-%m-%d' ) AND plan_status = 2 )
|
OR plan_status = 3 THEN
|
1 ELSE 0 END),0) AS todayNum,
|
IFNULL(SUM(
|
CASE WHEN DATE_FORMAT( NOW(), '%Y-%m-%d' ) <![CDATA[ >= ]]>
|
<if test="_databaseId == 'mysql' ">
|
DATE_FORMAT( date_sub( maintain_date, INTERVAL pre_warning_days DAY ),'%Y-%m-%d' )
|
</if>
|
<if test="_databaseId == 'dm' ">
|
DATE_FORMAT( DATEADD(DAY, -pre_warning_days, maintain_date),'%Y-%m-%d' )
|
</if>
|
AND DATE_FORMAT( NOW(), '%Y-%m-%d' )<![CDATA[ < ]]> DATE_FORMAT( maintain_date, '%Y-%m-%d' ) AND
|
plan_status = 1 THEN
|
1 ELSE 0 END),0) AS warningNum
|
FROM
|
blade_maintain_plan
|
WHERE
|
is_deleted = 0
|
<if test="tenantId != null and tenantId != ''">
|
AND tenant_id = #{tenantId}
|
</if>
|
</select>
|
|
<sql id="selectFromMaintainPlan">
|
plan
|
.
|
id
|
AS id,
|
plan.code AS code, plan.device_id AS deviceId, plan.device_code AS deviceCode, plan.device_name AS deviceName,plan.device_type_id AS deviceTypeId,plan.device_type_name AS deviceTypeName,
|
plan.project_id AS pojectId,plan.project_code AS projectCode,plan.project_name AS projectName,plan.maintain_date AS maintainDate,plan.pre_warning_days AS preWarningDays,plan.plan_status AS planStatus,
|
plan.is_auto AS isAuto,plan.interval_time AS intervalTime,plan.pre_maintain_time AS preMaintainTime,plan.remark as remark,plan.maintain_nature as maintainNature
|
FROM blade_maintain_plan plan
|
WHERE plan.is_deleted = 0
|
</sql>
|
|
<select id="pageMaintainPlanExpire" resultType="com.qianwen.smartman.modules.tpm.vo.MaintainPlanExpireVO">
|
SELECT
|
<include refid="selectFromMaintainPlan"/>
|
AND
|
DATE_FORMAT( NOW(), '%Y-%m-%d' ) <![CDATA[ > ]]> DATE_FORMAT( maintain_date, '%Y-%m-%d' )
|
AND
|
plan_status = 2
|
<if test="tenantId != null and tenantId != ''">
|
AND plan.tenant_id = #{tenantId}
|
</if>
|
<if test="maintainPlanExpireQueryVO.code != null and maintainPlanExpireQueryVO.code != ''">
|
AND plan.code like concat(#{maintainPlanExpireQueryVO.code},'%')
|
</if>
|
<if test="maintainPlanExpireQueryVO.deviceCode != null and maintainPlanExpireQueryVO.deviceCode != ''">
|
AND plan.device_code like concat(#{maintainPlanExpireQueryVO.deviceCode},'%')
|
</if>
|
<if test="maintainPlanExpireQueryVO.deviceName != null and maintainPlanExpireQueryVO.deviceName != ''">
|
AND plan.device_name like concat(#{maintainPlanExpireQueryVO.deviceName},'%')
|
</if>
|
<if test="maintainPlanExpireQueryVO.projectName != null and maintainPlanExpireQueryVO.projectName != ''">
|
AND plan.project_name like concat(#{maintainPlanExpireQueryVO.projectName},'%')
|
</if>
|
<if test="maintainPlanExpireQueryVO.isAuto != null">
|
AND plan.is_auto = #{maintainPlanExpireQueryVO.isAuto}
|
</if>
|
ORDER BY plan.maintain_date ASC
|
</select>
|
|
<select id="pageMaintainPlanToday" resultType="com.qianwen.smartman.modules.tpm.vo.MaintainPlanExpireVO">
|
SELECT
|
<include refid="selectFromMaintainPlan"/>
|
AND
|
((DATE_FORMAT( NOW(), '%Y-%m-%d' ) = DATE_FORMAT( maintain_date, '%Y-%m-%d' )
|
AND plan_status = 2)
|
OR plan_status = 3)
|
<if test="tenantId != null and tenantId != ''">
|
AND plan.tenant_id = #{tenantId}
|
</if>
|
<if test="maintainPlanExpireQueryVO.code != null and maintainPlanExpireQueryVO.code != ''">
|
AND plan.code like concat(#{maintainPlanExpireQueryVO.code},'%')
|
</if>
|
<if test="maintainPlanExpireQueryVO.deviceCode != null and maintainPlanExpireQueryVO.deviceCode != ''">
|
AND plan.device_code like concat(#{maintainPlanExpireQueryVO.deviceCode},'%')
|
</if>
|
<if test="maintainPlanExpireQueryVO.deviceName != null and maintainPlanExpireQueryVO.deviceName != ''">
|
AND plan.device_name like concat(#{maintainPlanExpireQueryVO.deviceName},'%')
|
</if>
|
<if test="maintainPlanExpireQueryVO.projectName != null and maintainPlanExpireQueryVO.projectName != ''">
|
AND plan.project_name like concat(#{maintainPlanExpireQueryVO.projectName},'%')
|
</if>
|
<if test="maintainPlanExpireQueryVO.isAuto != null">
|
AND plan.is_auto = #{maintainPlanExpireQueryVO.isAuto}
|
</if>
|
ORDER BY plan.maintain_date ASC
|
</select>
|
|
<select id="pageMaintainPlanWarning" resultType="com.qianwen.smartman.modules.tpm.vo.MaintainPlanExpireVO">
|
SELECT
|
<include refid="selectFromMaintainPlan"/>
|
AND
|
<if test="_databaseId == 'mysql' ">
|
(DATE_FORMAT( NOW(), '%Y-%m-%d' ) <![CDATA[ >= ]]>
|
DATE_FORMAT(date_sub( maintain_date, INTERVAL pre_warning_days DAY ),'%Y-%m-%d'))
|
</if>
|
<if test="_databaseId == 'dm' ">
|
(TO_DATE(NOW(), 'YYYY-MM-DD') <![CDATA[ >= ]]>
|
TO_DATE(DATEADD(DAY, -pre_warning_days, maintain_date),'YYYY-MM-DD'))
|
</if>
|
AND
|
<if test="_databaseId == 'mysql' ">
|
(DATE_FORMAT( NOW(), '%Y-%m-%d' )<![CDATA[ < ]]> DATE_FORMAT( maintain_date, '%Y-%m-%d'))
|
</if>
|
<if test="_databaseId == 'dm' ">
|
(TO_DATE(NOW(), 'YYYY-MM-DD') <![CDATA[ < ]]> TO_DATE(maintain_date, 'YYYY-MM-DD'))
|
</if>
|
AND
|
plan_status = 1
|
<if test="tenantId != null and tenantId != ''">
|
AND plan.tenant_id = #{tenantId}
|
</if>
|
<if test="maintainPlanExpireQueryVO.code != null and maintainPlanExpireQueryVO.code != ''">
|
AND plan.code like concat(#{maintainPlanExpireQueryVO.code},'%')
|
</if>
|
<if test="maintainPlanExpireQueryVO.deviceCode != null and maintainPlanExpireQueryVO.deviceCode != ''">
|
AND plan.device_code like concat(#{maintainPlanExpireQueryVO.deviceCode},'%')
|
</if>
|
<if test="maintainPlanExpireQueryVO.deviceName != null and maintainPlanExpireQueryVO.deviceName != ''">
|
AND plan.device_name like concat(#{maintainPlanExpireQueryVO.deviceName},'%')
|
</if>
|
<if test="maintainPlanExpireQueryVO.projectName != null and maintainPlanExpireQueryVO.projectName != ''">
|
AND plan.project_name like concat(#{maintainPlanExpireQueryVO.projectName},'%')
|
</if>
|
<if test="maintainPlanExpireQueryVO.isAuto != null">
|
AND plan.is_auto = #{maintainPlanExpireQueryVO.isAuto}
|
</if>
|
ORDER BY plan.maintain_date ASC
|
</select>
|
|
</mapper>
|