You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
3.4 KiB
XML

<?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.op.device.mapper.DeviceTaskMapper">
<select id="getPlans" resultType="com.op.device.domain.EquPlan">
select ep.plan_workshop planWorkshop,
ep.plan_code planCode,
ep.plan_name planName,
ep.plan_loop planLoop,
ep.plan_loop_type planLoopType,
ep.plan_loop_start planLoopStart,
ep.plan_loop_end planLoopEnd,
ep.plan_restrict planRestrict,
ep.plan_type planType,
ep.plan_outsource planOutsource,
ep.calculation_rule calculationRule,
ep.shut_down as 'shutDown',
ep.upkeep,
ep.work_person workPerson,
ep.work_outsourcing_unit workOutsourcingUnit,
ep.work_connection workConnection,
ep.work_reason workReason,
ep.plan_code planCode,
epe.equipment_code equipmentCode,
epe.equipment_name equipmentName,
epe.id planEquId
from equ_plan ep
left join equ_plan_equ epe on ep.plan_code = epe.plan_code
where ep.del_flag = '0' and epe.del_flag = '0' and ep.plan_status = '0'
and epe.equipment_code in ( select be.equipment_code from base_equipment be where be.del_flag = '0' )
and ep.plan_type = #{planType}
and CONVERT(varchar(10),GETDATE(), 120) >= CONVERT(varchar(10),ep.plan_loop_start, 120)
<if test='planType=="inspection" or planType=="maintenance" '>
and CONVERT(varchar(10),ep.plan_loop_end, 120) >= CONVERT(varchar(10),GETDATE(), 120)
</if>
</select>
<select id="getNewTaskOrder" resultType="com.op.device.domain.EquOrder">
select top 1 order_code orderCode,
create_time createTime
<if test="planLoopType=='day'">, DATEDIFF (day, create_time, GETDATE()) days </if>
<if test="planLoopType=='week'">, DATEDIFF (week, create_time, GETDATE()) days </if>
<if test="planLoopType=='month'">, DATEDIFF (month, create_time, GETDATE()) days </if>
<if test="planLoopType=='season'">, DATEDIFF (month, create_time, GETDATE())/3 days </if>
<if test="planLoopType=='year'">, DATEDIFF (year, create_time, GETDATE()) days </if>
from equ_order
where plan_type = #{planType} and plan_code = #{planCode} and equipment_code = #{equipmentCode}
order by create_time desc
</select>
<select id="getNewTaskOrder0" resultType="com.op.device.domain.EquOrder">
select top 1 order_code orderCode,
order_start orderStart,
<if test='planLoopType=="day"'> DATEDIFF (day, order_start, GETDATE()) days </if>
<if test='planLoopType=="week"'> DATEDIFF (week, order_start, GETDATE()) days </if>
<if test='planLoopType=="month"'> DATEDIFF (month, order_start, GETDATE()) days </if>
<if test='planLoopType=="season"'> DATEDIFF (month, order_start, GETDATE())/3 days </if>
<if test='planLoopType=="year"'> DATEDIFF (year, order_start, GETDATE()) days </if>
from equ_order
where plan_type = #{planType} and plan_code = #{planCode} and equipment_code = #{equipmentCode}
order by create_time desc
</select>
</mapper>