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.
257 lines
14 KiB
XML
257 lines
14 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.aucma.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, cron_expression 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 != null and 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>
|
|
order by create_time desc
|
|
</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, a.cron_expression,
|
|
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_id = #{planMaintId}
|
|
</select>
|
|
|
|
<insert id="insertDmsPlanMaint" parameterType="DmsPlanMaint">
|
|
<selectKey keyProperty="planMaintId" resultType="long" order="BEFORE">
|
|
SELECT HAIWEI.SEQ_DMS_PLAN_MAINT.NEXTVAL FROM DUAL
|
|
</selectKey>
|
|
insert into dms_plan_maint
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="planMaintId != null">plan_maint_id,</if>
|
|
<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>
|
|
<if test="cronExpression != null and cronExpression != ''">cron_expression,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="planMaintId != null">#{planMaintId,jdbcType=NUMERIC},</if>
|
|
<if test="planMaintCode != null and planMaintCode != ''">#{planMaintCode},</if>
|
|
<if test="maintLevel != null">#{maintLevel,jdbcType=NUMERIC},</if>
|
|
<if test="maintGroup != null">#{maintGroup},</if>
|
|
<if test="maintSupervisor != null">#{maintSupervisor},</if>
|
|
<if test="maintTime != null">#{maintTime},</if>
|
|
<if test="timeLimit != null">#{timeLimit,jdbcType=NUMERIC},</if>
|
|
<if test="jobId != null">#{jobId,jdbcType=NUMERIC},</if>
|
|
<if test="cyclePeriod != null">#{cyclePeriod,jdbcType=NUMERIC},</if>
|
|
<if test="maintStatus != null">#{maintStatus,jdbcType=NUMERIC},</if>
|
|
<if test="createMethod != null">#{createMethod,jdbcType=NUMERIC},</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>
|
|
<if test="cronExpression != null and cronExpression != ''">#{cronExpression},</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>
|
|
<if test="cronExpression != null and cronExpression != ''">cron_expression = #{cronExpression},</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 all
|
|
<foreach item="item" index="index" collection="list">
|
|
into dms_plan_maint_detail(
|
|
plan_maint_detail_id, plan_maint_id, device_id, maint_station_id, maint_standard_id,
|
|
operation_description, is_flag, remark, create_by, create_time, update_by, update_time
|
|
) values (
|
|
HAIWEI.SEQ_DMS_PLAN_MAINT_DETAIL.NEXTVAL,
|
|
#{item.planMaintId},
|
|
#{item.deviceId},
|
|
#{item.maintStationId},
|
|
#{item.maintStandardId},
|
|
#{item.operationDescription},
|
|
#{item.isFlag},
|
|
#{item.remark},
|
|
#{item.createBy},
|
|
#{item.createTime},
|
|
#{item.updateBy},
|
|
#{item.updateTime}
|
|
)
|
|
</foreach>
|
|
select 1 from dual
|
|
</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, a.cron_expression,
|
|
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,
|
|
a.cron_expression
|
|
from dms_plan_maint a
|
|
where a.plan_maint_id = #{planMaintId}
|
|
</select>
|
|
|
|
<!-- 查询待执行的保养计划列表 -->
|
|
<select id="selectPendingMaintPlans" 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,
|
|
a.cron_expression
|
|
FROM dms_plan_maint a
|
|
WHERE (a.is_flag = 0 OR a.is_flag IS NULL)
|
|
AND a.maint_time <= TRUNC(SYSDATE) + 1
|
|
</select>
|
|
|
|
<!-- 更新保养计划的下次执行时间 -->
|
|
<update id="updatePlanNextTime">
|
|
UPDATE dms_plan_maint
|
|
SET maint_time = #{maintTime}, update_time = SYSDATE
|
|
WHERE plan_maint_id = #{planMaintId}
|
|
</update>
|
|
|
|
<!-- 锁定计划行,避免并发重复生成工单 -->
|
|
<select id="lockPlanById" resultType="java.lang.Long">
|
|
<!-- FOR UPDATE: 对同一 plan_maint_id 的并发任务形成串行执行 -->
|
|
SELECT plan_maint_id
|
|
FROM dms_plan_maint
|
|
WHERE plan_maint_id = #{planMaintId}
|
|
FOR UPDATE
|
|
</select>
|
|
|
|
</mapper>
|