<?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.hw.dms.mapper.DmsPlanMaintMapper" >
<resultMap type= "DmsPlanMaint" id= "DmsPlanMaintResult" >
<result property= "planMaintId" column= "plan_maint_id" />
<result property= "planMaintCode" column= "plan_maint_code" />
<result property= "maintLevel" column= "maint_level" />
<result property= "maintGroup" column= "maint_group" />
<result property= "maintSupervisor" column= "maint_supervisor" />
<result property= "maintTime" column= "maint_time" />
<result property= "jobId" column= "job_id" />
<result property= "timeLimit" column= "time_limit" />
<result property= "cyclePeriod" column= "cycle_period" />
<result property= "maintStatus" column= "maint_status" />
<result property= "createMethod" column= "create_method" />
<result property= "isFlag" column= "is_flag" />
<result property= "remark" column= "remark" />
<result property= "createBy" column= "create_by" />
<result property= "createTime" column= "create_time" />
<result property= "updateBy" column= "update_by" />
<result property= "updateTime" column= "update_time" />
<result property= "cronExpression" column= "cron_expression" />
</resultMap>
<resultMap id= "DmsPlanMaintDmsPlanMaintDetailResult" type= "DmsPlanMaint" extends= "DmsPlanMaintResult" >
<collection property= "dmsPlanMaintDetailList" notNullColumn= "sub_plan_maint_detail_id" javaType= "java.util.List" resultMap= "DmsPlanMaintDetailResult" />
</resultMap>
<resultMap type= "DmsPlanMaintDetail" id= "DmsPlanMaintDetailResult" >
<result property= "planMaintDetailId" column= "sub_plan_maint_detail_id" />
<result property= "planMaintId" column= "sub_plan_maint_id" />
<result property= "deviceId" column= "sub_device_id" />
<result property= "maintStationId" column= "sub_maint_station_id" />
<result property= "maintStandardId" column= "sub_maint_standard_id" />
<result property= "operationDescription" column= "sub_operation_description" />
<result property= "isFlag" column= "sub_is_flag" />
<result property= "remark" column= "sub_remark" />
<result property= "createBy" column= "sub_create_by" />
<result property= "createTime" column= "sub_create_time" />
<result property= "updateBy" column= "sub_update_by" />
<result property= "updateTime" column= "sub_update_time" />
</resultMap>
<sql id= "selectDmsPlanMaintVo" >
select plan_maint_id, plan_maint_code, maint_level, maint_group, maint_supervisor, maint_time,job_id,time_limit, cycle_period, maint_status, create_method, is_flag, remark, create_by, create_time, update_by, update_time from dms_plan_maint
</sql>
<select id= "selectDmsPlanMaintList" parameterType= "DmsPlanMaint" resultMap= "DmsPlanMaintResult" >
<include refid= "selectDmsPlanMaintVo" />
<where >
<if test= "planMaintId !=null and planMaintId !=''" > and plan_maint_id=#{planMaintId}</if>
<if test= "planMaintCode != null and planMaintCode != ''" > and plan_maint_code = #{planMaintCode}</if>
<if test= "maintLevel != null " > and maint_level = #{maintLevel}</if>
<if test= "maintGroup != null and maintGroup != ''" > and maint_group = #{maintGroup}</if>
<if test= "maintSupervisor != null and maintSupervisor != ''" > and maint_supervisor = #{maintSupervisor}</if>
<if test= "params.beginTime != null and params.endTime != null" > and maint_time between #{params.beginTime} and #{params.endTime}</if>
<if test= "cyclePeriod != null " > and cycle_period = #{cyclePeriod}</if>
<if test= "maintStatus != null " > and maint_status = #{maintStatus}</if>
<if test= "createMethod != null " > and create_method = #{createMethod}</if>
<if test= "isFlag != null " > and is_flag = #{isFlag}</if>
</where>
</select>
<select id= "selectDmsPlanMaintByPlanMaintId" parameterType= "Long" resultMap= "DmsPlanMaintDmsPlanMaintDetailResult" >
select a.plan_maint_id, a.plan_maint_code, a.maint_level, a.maint_group, a.maint_supervisor, a.maint_time,a.time_limit,a.job_id, a.cycle_period, a.maint_status, a.create_method, a.is_flag, a.remark, a.create_by, a.create_time, a.update_by, a.update_time,
b.plan_maint_detail_id as sub_plan_maint_detail_id, b.plan_maint_id as sub_plan_maint_id, b.device_id as sub_device_id, b.maint_station_id as sub_maint_station_id, b.maint_standard_id as sub_maint_protocol, b.operation_description as sub_operation_description, b.is_flag as sub_is_flag, b.remark as sub_remark, b.create_by as sub_create_by, b.create_time as sub_create_time, b.update_by as sub_update_by, b.update_time as sub_update_time
from dms_plan_maint a
left join dms_plan_maint_detail b on b.plan_maint_id = a.plan_maint_id
where a.plan_maint_id = #{planMaintId}
</select>
<insert id= "insertDmsPlanMaint" parameterType= "DmsPlanMaint" useGeneratedKeys= "true" keyProperty= "planMaintId" >
insert into dms_plan_maint
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "planMaintCode != null and planMaintCode != ''" > plan_maint_code,</if>
<if test= "maintLevel != null" > maint_level,</if>
<if test= "maintGroup != null" > maint_group,</if>
<if test= "maintSupervisor != null" > maint_supervisor,</if>
<if test= "maintTime != null" > maint_time,</if>
<if test= "timeLimit != null" > time_limit,</if>
<if test= "jobId != null" > job_id,</if>
<if test= "cyclePeriod != null" > cycle_period,</if>
<if test= "maintStatus != null" > maint_status,</if>
<if test= "createMethod != null" > create_method,</if>
<if test= "isFlag != null" > is_flag,</if>
<if test= "remark != null" > remark,</if>
<if test= "createBy != null" > create_by,</if>
<if test= "createTime != null" > create_time,</if>
<if test= "updateBy != null" > update_by,</if>
<if test= "updateTime != null" > update_time,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "planMaintCode != null and planMaintCode != ''" > #{planMaintCode},</if>
<if test= "maintLevel != null" > #{maintLevel},</if>
<if test= "maintGroup != null" > #{maintGroup},</if>
<if test= "maintSupervisor != null" > #{maintSupervisor},</if>
<if test= "maintTime != null" > #{maintTime},</if>
<if test= "timeLimit != null" > #{timeLimit},</if>
<if test= "jobId != null" > #{jobId},</if>
<if test= "cyclePeriod != null" > #{cyclePeriod},</if>
<if test= "maintStatus != null" > #{maintStatus},</if>
<if test= "createMethod != null" > #{createMethod},</if>
<if test= "isFlag != null" > #{isFlag},</if>
<if test= "remark != null" > #{remark},</if>
<if test= "createBy != null" > #{createBy},</if>
<if test= "createTime != null" > #{createTime},</if>
<if test= "updateBy != null" > #{updateBy},</if>
<if test= "updateTime != null" > #{updateTime},</if>
</trim>
</insert>
<update id= "updateDmsPlanMaint" parameterType= "DmsPlanMaint" >
update dms_plan_maint
<trim prefix= "SET" suffixOverrides= "," >
<if test= "planMaintCode != null and planMaintCode != ''" > plan_maint_code = #{planMaintCode},</if>
<if test= "maintLevel != null" > maint_level = #{maintLevel},</if>
<if test= "maintGroup != null" > maint_group = #{maintGroup},</if>
<if test= "maintSupervisor != null" > maint_supervisor = #{maintSupervisor},</if>
<if test= "maintTime != null" > maint_time = #{maintTime},</if>
<if test= "timeLimit != null" > time_limit = #{timeLimit},</if>
<if test= "jobId != null" > job_id = #{jobId},</if>
<if test= "cyclePeriod != null" > cycle_period = #{cyclePeriod},</if>
<if test= "maintStatus != null" > maint_status = #{maintStatus},</if>
<if test= "createMethod != null" > create_method = #{createMethod},</if>
<if test= "isFlag != null" > is_flag = #{isFlag},</if>
<if test= "remark != null" > remark = #{remark},</if>
<if test= "createBy != null" > create_by = #{createBy},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
<if test= "updateBy != null" > update_by = #{updateBy},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
</trim>
where plan_maint_id = #{planMaintId}
</update>
<delete id= "deleteDmsPlanMaintByPlanMaintId" parameterType= "Long" >
delete from dms_plan_maint where plan_maint_id = #{planMaintId}
</delete>
<delete id= "deleteDmsPlanMaintByPlanMaintIds" parameterType= "String" >
delete from dms_plan_maint where plan_maint_id in
<foreach item= "planMaintId" collection= "array" open= "(" separator= "," close= ")" >
#{planMaintId}
</foreach>
</delete>
<delete id= "deleteDmsPlanMaintDetailByPlanMaintIds" parameterType= "String" >
delete from dms_plan_maint_detail where plan_maint_id in
<foreach item= "planMaintId" collection= "array" open= "(" separator= "," close= ")" >
#{planMaintId}
</foreach>
</delete>
<delete id= "deleteDmsPlanMaintDetailByPlanMaintId" parameterType= "Long" >
delete from dms_plan_maint_detail where plan_maint_id = #{planMaintId}
</delete>
<insert id= "batchDmsPlanMaintDetail" >
insert into dms_plan_maint_detail( plan_maint_detail_id, plan_maint_id, device_id, maint_station_id, maint_protocol, operation_description, is_flag, remark, create_by, create_time, update_by, update_time) values
<foreach item= "item" index= "index" collection= "list" separator= "," >
( #{item.planMaintDetailId}, #{item.planMaintId}, #{item.deviceId}, #{item.maintStationId}, #{item.maintProtocol}, #{item.operationDescription}, #{item.isFlag}, #{item.remark}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
</foreach>
</insert>
<select id= "selectDmsPlanMaintJoinByPlanMaintCode" parameterType= "String" resultMap= "DmsPlanMaintDmsPlanMaintDetailResult" >
select a.plan_maint_id, a.plan_maint_code, a.maint_level, a.maint_group, a.maint_supervisor, a.maint_time,a.time_limit,a.job_id, a.cycle_period, a.maint_status, a.create_method, a.is_flag, a.remark, a.create_by, a.create_time, a.update_by, a.update_time,
b.plan_maint_detail_id as sub_plan_maint_detail_id, b.plan_maint_id as sub_plan_maint_id, b.device_id as sub_device_id, b.maint_station_id as sub_maint_station_id, b.maint_standard_id as sub_maint_standard_id, b.operation_description as sub_operation_description, b.is_flag as sub_is_flag, b.remark as sub_remark, b.create_by as sub_create_by, b.create_time as sub_create_time, b.update_by as sub_update_by, b.update_time as sub_update_time
from dms_plan_maint a
left join dms_plan_maint_detail b on b.plan_maint_id = a.plan_maint_id
where a.plan_maint_code = #{planMaintCode}
</select>
<select id= "selectPlanMaintJoinJobByPlanMaintId" parameterType= "Long" resultMap= "DmsPlanMaintResult" >
select a.plan_maint_id, a.plan_maint_code, a.maint_level, a.maint_group, a.maint_supervisor, a.maint_time,a.time_limit,a.job_id, a.cycle_period, a.maint_status, a.create_method, a.is_flag, a.remark, a.create_by, a.create_time, a.update_by, a.update_time,
sj.cron_expression
from dms_plan_maint a
left join sys_job sj on a.job_id = sj.job_id
where a.plan_maint_id = #{planMaintId}
</select>
</mapper>