<?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.gkhy.safePlatform.safeCheck.repository.SafeCheckWorkRepository" >
|
<resultMap id="BaseResultMap" type="com.gkhy.safePlatform.safeCheck.entity.SafeCheckWork" >
|
<id column="id" property="id" />
|
<result column="uuid" property="uuid"/>
|
<result column="delete_status" property="deleteStatus" />
|
<result column="work_type" property="workType" />
|
<result column="work_status" property="workStatus"/>
|
<result column="unit_id" property="unitId" />
|
<result column="unit_uuid" property="unitUuid" />
|
<result column="exec_classgroup_id" property="execClassgroupId" />
|
<result column="exec_dep_id" property="execDepId" />
|
<result column="check_cycle" property="checkCycle" />
|
<result column="check_cycle_unit" property="checkCycleUnit" />
|
<result column="notice_time" property="noticeTime" />
|
<result column="notice_time_unit" property="noticeTimeUnit" />
|
<result column="valid_time" property="validTime" />
|
<result column="valid_time_unit" property="validTimeUnit" />
|
<result column="next_notice_time" property="nextNoticeTime" />
|
<result column="next_check_time" property="nextCheckTime" />
|
<result column="last_check_time" property="lastCheckTime" />
|
<result column="first_start_time" property="firstStartTime" />
|
</resultMap>
|
|
<sql id="allWorkFields">
|
id,
|
uuid,
|
delete_status,
|
work_type,
|
work_status,
|
unit_id,
|
unit_uuid,
|
exec_classgroup_id,
|
exec_dep_id,
|
check_cycle,
|
check_cycle_unit,
|
notice_time,
|
notice_time_unit,
|
valid_time,
|
valid_time_unit,
|
next_notice_time,
|
next_check_time,
|
last_check_time,
|
first_start_time
|
</sql>
|
<select id="getWorkByTaskUnitId" resultMap="BaseResultMap">
|
select
|
<include refid="allWorkFields"></include>
|
from safe_check_work
|
where unit_id = #{taskUnitId} and delete_status = #{deleteStatus}
|
</select>
|
|
|
<select id="findActiveWorkListByTime" resultMap="BaseResultMap">
|
select
|
<include refid="allWorkFields"></include>
|
from safe_check_work
|
<where>
|
delete_status = 0
|
<if test="startTime != null">
|
and next_notice_time >= #{startTime}
|
</if>
|
<if test="endTime != null">
|
and next_notice_time <= #{endTime}
|
</if>
|
<if test="status != null">
|
and work_status = #{status}
|
</if>
|
</where>
|
</select>
|
|
<select id="getWorkById" resultType="com.gkhy.safePlatform.safeCheck.entity.SafeCheckWork">
|
select
|
<include refid="allWorkFields"></include>
|
from safe_check_work
|
<where>
|
delete_status = 0
|
<if test="workId != null">
|
and id = #{workId}
|
</if>
|
</where>
|
</select>
|
|
<select id="findFaildScheduleList" resultType="com.gkhy.safePlatform.safeCheck.entity.SafeCheckWork">
|
select
|
<include refid="allWorkFields"></include>
|
from safe_check_work
|
<where>
|
delete_status = 0
|
<if test="nowTime != null">
|
and next_notice_time <= #{nowTime}
|
</if>
|
and work_status in (#{openStatus},#{dispatchingStatus})
|
</where>
|
</select>
|
|
<select id="getWorkByIdAndWorkStatus" resultType="com.gkhy.safePlatform.safeCheck.entity.SafeCheckWork">
|
select
|
<include refid="allWorkFields"></include>
|
from safe_check_work
|
where id = #{workId} and work_status = #{status} and delete_status = 0
|
</select>
|
|
|
<update id="deleteWorkById">
|
update safe_check_work set
|
delete_status = #{work.deleteStatus}
|
<where>
|
id = #{work.id}
|
<if test="workStatus != null and workStatus.size >0 ">
|
<foreach collection="workStatus" open="and work_status in(" close=")" item="workStatus" separator=",">
|
#{workStatus}
|
</foreach>
|
</if>
|
</where>
|
</update>
|
|
|
<update id="updateWorkStatusById">
|
update safe_check_work set
|
work_status = #{work.workStatus}
|
where id = #{work.id} and delete_status = #{status}
|
</update>
|
|
<update id="updateWorkInfoById">
|
update safe_check_work
|
<set>
|
<if test="work.workType != null">
|
work_type = #{work.workType},
|
</if>
|
<if test="work.workStatus != null">
|
work_status = #{work.workStatus},
|
</if>
|
<if test="work.execClassgroupId != null">
|
exec_classgroup_id = #{work.execClassgroupId},
|
</if>
|
<if test="work.execDepId != null ">
|
exec_dep_id = #{work.execDepId},
|
</if>
|
<if test="work.firstStartTime != null">
|
first_start_time = #{work.firstStartTime},
|
</if>
|
<if test="work.nextNoticeTime != null">
|
next_notice_time = #{work.nextNoticeTime},
|
</if>
|
<if test="work.nextCheckTime != null">
|
next_check_time = #{work.nextCheckTime},
|
</if>
|
<if test="work.checkCycle != null">
|
check_cycle = #{work.checkCycle},
|
</if>
|
<if test="work.checkCycleUnit != null">
|
check_cycle_unit = #{work.checkCycleUnit},
|
</if>
|
<if test="work.noticeTime != null">
|
notice_time = #{work.noticeTime},
|
</if>
|
<if test="work.noticeTimeUnit != null">
|
notice_time_unit = #{work.noticeTimeUnit},
|
</if>
|
<if test="work.validTime != null">
|
valid_time = #{work.validTime},
|
</if>
|
<if test="work.validTimeUnit != null">
|
valid_time_unit = #{work.validTimeUnit},
|
</if>
|
</set>
|
where id = #{work.id} and delete_status = #{status}
|
</update>
|
|
<update id="resetWorkStatus">
|
update safe_check_work
|
<set>
|
<if test="work.nextNoticeTime != null">
|
next_notice_time = #{work.nextNoticeTime},
|
</if>
|
<if test="work.nextCheckTime != null">
|
next_check_time = #{work.nextCheckTime},
|
</if>
|
<if test="work.lastCheckTime != null">
|
last_check_time = #{work.lastCheckTime},
|
</if>
|
<if test="newStatus != null">
|
work_status = #{newStatus},
|
</if>
|
</set>
|
where id = #{work.id} and delete_status = 0
|
</update>
|
|
</mapper>
|