|
|
<?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.inspect.taskstatus.mapper.PatrolTaskStatusMapper">
|
|
|
|
|
|
<resultMap type="PatrolTaskStatus" id="PatrolTaskStatusResult">
|
|
|
<result property="lineId" column="line_id"/>
|
|
|
<result property="taskPatrolledId" column="task_patrolled_id"/>
|
|
|
<result property="taskName" column="task_name"/>
|
|
|
<result property="taskCode" column="task_code"/>
|
|
|
<result property="taskState" column="task_state"/>
|
|
|
<result property="planStartTime" column="plan_start_time"/>
|
|
|
<result property="startTime" column="start_time"/>
|
|
|
<result property="taskProgress" column="task_progress"/>
|
|
|
<result property="taskEstimatedTime" column="task_estimated_time"/>
|
|
|
<result property="description" column="description"/>
|
|
|
<result property="posType" column="pos_type"/>
|
|
|
<result property="code" column="code"/>
|
|
|
<result property="pos" column="pos"/>
|
|
|
<result property="patrolType" column="patrol_type"/>
|
|
|
<result property="endTime" column="end_time"/>
|
|
|
<result property="execType" column="exec_type"/>
|
|
|
<result property="beginTime" column="beginTime"/>
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectPatrolTaskStatusVo">
|
|
|
select line_id,
|
|
|
task_patrolled_id,
|
|
|
end_time,
|
|
|
patrol_type,
|
|
|
task_name,
|
|
|
task_code,
|
|
|
task_state,
|
|
|
plan_start_time,
|
|
|
start_time,
|
|
|
task_progress,
|
|
|
task_estimated_time,
|
|
|
description,
|
|
|
pos_type,
|
|
|
code,
|
|
|
pos,
|
|
|
exec_type
|
|
|
from patrol_task_status
|
|
|
</sql>
|
|
|
|
|
|
<select id="selectPatrolTaskStatusCount" parameterType="PatrolTaskStatus" resultMap="PatrolTaskStatusResult">
|
|
|
select a.* from patrol_task_status a
|
|
|
<where>
|
|
|
|
|
|
<if test="taskCode != null and taskCode != ''">and a.task_code = #{taskCode}</if>
|
|
|
<if test="taskState != null and taskState != ''">and a.task_state = #{taskState}</if>
|
|
|
<if test="description != null and description != ''">and a.description != #{description}</if>
|
|
|
<if test="startTime != null ">
|
|
|
and date_format(a.start_time,'%y%m') = date_format(#{startTime},'%y%m')
|
|
|
</if>
|
|
|
|
|
|
<if test="beginTime != null ">
|
|
|
and date_format(a.start_time,'%y%m%d') = date_format(#{beginTime},'%y%m%d')
|
|
|
</if>
|
|
|
|
|
|
</where>
|
|
|
</select>
|
|
|
|
|
|
<select id="selectPatrolTaskStatusList" parameterType="PatrolTaskStatus" resultMap="PatrolTaskStatusResult">
|
|
|
SELECT
|
|
|
a.line_id,
|
|
|
a.task_patrolled_id,
|
|
|
a.task_name,
|
|
|
a.task_code,
|
|
|
a.task_state,
|
|
|
a.plan_start_time,
|
|
|
a.start_time,
|
|
|
a.task_progress,
|
|
|
a.task_estimated_time,
|
|
|
a.description,
|
|
|
a.pos_type,
|
|
|
a.code,
|
|
|
a.pos,
|
|
|
a.end_time,
|
|
|
b.type as patrol_type,
|
|
|
b.execution_status as exec_type from patrol_task_status a
|
|
|
LEFT JOIN patrol_task b on a.task_code=b.task_code
|
|
|
<where>
|
|
|
<if test="taskPatrolledId != null and taskPatrolledId != ''">and a.task_patrolled_id = #{taskPatrolledId}
|
|
|
</if>
|
|
|
<choose>
|
|
|
<!-- 当taskName和areaTaskName都有值时 -->
|
|
|
<when test="taskName != null and taskName != '' and areaTaskName != null and areaTaskName != ''">
|
|
|
and (a.task_name like concat('%', #{taskName}, '%')
|
|
|
or a.task_name like concat('%', #{areaTaskName}, '%'))
|
|
|
</when>
|
|
|
<otherwise>
|
|
|
<!-- 只有一个参数有值时 -->
|
|
|
<if test="taskName != null and taskName != ''">
|
|
|
and a.task_name like concat('%', #{taskName}, '%')
|
|
|
</if>
|
|
|
<if test="areaTaskName != null and areaTaskName != ''">
|
|
|
and a.task_name like concat('%', #{areaTaskName}, '%')
|
|
|
</if>
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
<if test="taskCode != null and taskCode != ''">and a.task_code = #{taskCode}</if>
|
|
|
<if test="taskState != null and taskState != ''">and a.task_state = #{taskState}</if>
|
|
|
<if test="planStartTime != null ">and a.plan_start_time = #{planStartTime}</if>
|
|
|
<if test="startTime != null ">
|
|
|
and date_format(a.start_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d')
|
|
|
</if>
|
|
|
<if test="createTime != null ">and date_format(a.create_time,'%y%m%d') =
|
|
|
date_format(#{createTime},'%y%m%d')
|
|
|
</if>
|
|
|
<if test="taskProgress != null and taskProgress != ''">and a.task_progress = #{taskProgress}</if>
|
|
|
<if test="taskEstimatedTime != null and taskEstimatedTime != ''">and a.task_estimated_time =
|
|
|
#{taskEstimatedTime}
|
|
|
</if>
|
|
|
<if test="description != null and description != ''">and a.description = #{description}</if>
|
|
|
<if test="posType != null and posType != ''">and a.pos_type = #{posType}</if>
|
|
|
<if test="code != null and code != ''">and a.code = #{code}</if>
|
|
|
<if test="pos != null and pos != ''">and a.pos = #{pos}</if>
|
|
|
<if test="patrolType != null and patrolType != ''">and b.type = #{patrolType}</if>
|
|
|
<if test="beginTime != null and beginTime != ''">
|
|
|
and date_format(a.start_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
|
|
</if>
|
|
|
<if test="endTime != null and endTime != ''">
|
|
|
and date_format(a.start_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
|
|
</if>
|
|
|
</where>
|
|
|
ORDER BY line_id desc
|
|
|
</select>
|
|
|
|
|
|
<resultMap type="TaskCount" id="TaskCountResult">
|
|
|
<result property="callName" column="callName"/>
|
|
|
<result property="descName" column="descName"/>
|
|
|
<result property="count" column="count"/>
|
|
|
<result property="completeName" column="completeName"/>
|
|
|
</resultMap>
|
|
|
|
|
|
<select id="selectCountList" parameterType="PatrolTaskStatus" resultMap="TaskCountResult">
|
|
|
<!-- select count(*) as count ,start_time as callName,max(task_name) as descName ,
|
|
|
sum(case when task_state= 1 then 1 else 0 end)as total ,
|
|
|
convert(sum(case when task_state= 1 then 1 else 0 end)/count(*) *100 ,decimal(15,2)) as completeName
|
|
|
from patrol_task_status
|
|
|
<where>
|
|
|
<if test="beginTime != null and beginTime != ''">
|
|
|
and date_format(start_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
|
|
</if>
|
|
|
<if test="endTime != null and endTime != ''">
|
|
|
and date_format(start_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
|
|
</if>
|
|
|
</where>
|
|
|
GROUP BY start_time-->
|
|
|
|
|
|
SELECT
|
|
|
count( * ) AS count,
|
|
|
max( a.task_name ) AS descName,
|
|
|
sum( CASE WHEN a.task_state = 1 THEN 1 ELSE 0 END ) AS total,
|
|
|
CONVERT (sum( CASE WHEN a.task_state = 1 THEN 1 ELSE 0 END ) / count( * ) * 100,DECIMAL ( 15, 2 ) ) AS completeName
|
|
|
,
|
|
|
a.asd AS callName
|
|
|
FROM
|
|
|
( SELECT task_name,task_state,start_time, date_format( start_time, '%Y-%m-%d' ) AS asd FROM patrol_task_status )
|
|
|
a
|
|
|
<where>
|
|
|
<if test="beginTime != null and beginTime != ''">
|
|
|
and date_format(a.start_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
|
|
</if>
|
|
|
<if test="endTime != null and endTime != ''">
|
|
|
and date_format(a.start_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
|
|
</if>
|
|
|
</where>
|
|
|
GROUP BY
|
|
|
a.asd
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
<select id="selectCountListByDate" parameterType="PatrolTaskStatus" resultMap="TaskCountResult">
|
|
|
SELECT d.callName,d.descName,CONCAT(d.total,' / ',d.count) as count ,d.completeName FROM (SELECT
|
|
|
count( * ) AS count,
|
|
|
max( a.task_name ) AS descName,
|
|
|
sum( CASE WHEN a.task_state = 1 THEN 1 ELSE 0 END ) AS total,
|
|
|
CONVERT (
|
|
|
sum( CASE WHEN a.task_state = 1 THEN 1 ELSE 0 END ) / count( * ) * 100,
|
|
|
DECIMAL ( 15, 2 )
|
|
|
) AS completeName,
|
|
|
a.asd AS callName
|
|
|
FROM
|
|
|
( SELECT task_name, task_state, start_time, date_format( start_time, '%Y-%m-%d' ) AS asd FROM patrol_task_status
|
|
|
) a
|
|
|
<where>
|
|
|
<if test="beginTime != null and beginTime != ''">
|
|
|
and date_format(a.start_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
|
|
</if>
|
|
|
<if test="endTime != null and endTime != ''">
|
|
|
and date_format(a.start_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
|
|
</if>
|
|
|
</where>
|
|
|
GROUP BY
|
|
|
a.asd,a.task_name) d
|
|
|
</select>
|
|
|
|
|
|
<select id="selectPatrolTaskStatusByLineId" parameterType="Long" resultMap="PatrolTaskStatusResult">
|
|
|
<include refid="selectPatrolTaskStatusVo"/>
|
|
|
where line_id = #{lineId}
|
|
|
</select>
|
|
|
|
|
|
<select id="selectPatrolTaskStatusByTaskPatrolledId" parameterType="String" resultMap="PatrolTaskStatusResult">
|
|
|
<include refid="selectPatrolTaskStatusVo"/>
|
|
|
where task_patrolled_id = #{taskPatrolledId}
|
|
|
</select>
|
|
|
|
|
|
<select id="selectPatrolTaskStatusListByTaskPatrolledIds"
|
|
|
resultMap="PatrolTaskStatusResult">
|
|
|
<include refid="selectPatrolTaskStatusVo"/>
|
|
|
where task_patrolled_id in
|
|
|
<foreach collection="taskPatrolledIds" item="taskPatrolledId" open="(" separator="," close=")">
|
|
|
#{taskPatrolledId}
|
|
|
</foreach>
|
|
|
</select>
|
|
|
|
|
|
<insert id="insertPatrolTaskStatus" parameterType="PatrolTaskStatus" useGeneratedKeys="true" keyProperty="lineId">
|
|
|
insert into patrol_task_status
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
<if test="taskPatrolledId != null">task_patrolled_id,</if>
|
|
|
<if test="taskName != null">task_name,</if>
|
|
|
<if test="taskCode != null">task_code,</if>
|
|
|
<if test="taskState != null">task_state,</if>
|
|
|
<if test="planStartTime != null">plan_start_time,</if>
|
|
|
<if test="startTime != null">start_time,</if>
|
|
|
<if test="taskProgress != null">task_progress,</if>
|
|
|
<if test="taskEstimatedTime != null">task_estimated_time,</if>
|
|
|
<if test="description != null">description,</if>
|
|
|
<if test="posType != null">pos_type,</if>
|
|
|
<if test="code != null">code,</if>
|
|
|
<if test="pos != null">pos,</if>
|
|
|
<if test="patrolType != null">patrol_type,</if>
|
|
|
<if test="endTime != null">end_time,</if>
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
<if test="execType != null">exec_type,</if>
|
|
|
</trim>
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
<if test="taskPatrolledId != null">#{taskPatrolledId},</if>
|
|
|
<if test="taskName != null">#{taskName},</if>
|
|
|
<if test="taskCode != null">#{taskCode},</if>
|
|
|
<if test="taskState != null">#{taskState},</if>
|
|
|
<if test="planStartTime != null">#{planStartTime},</if>
|
|
|
<if test="startTime != null">#{startTime},</if>
|
|
|
<if test="taskProgress != null">#{taskProgress},</if>
|
|
|
<if test="taskEstimatedTime != null">#{taskEstimatedTime},</if>
|
|
|
<if test="description != null">#{description},</if>
|
|
|
<if test="posType != null">#{posType},</if>
|
|
|
<if test="code != null">#{code},</if>
|
|
|
<if test="pos != null">#{pos},</if>
|
|
|
<if test="patrolType != null">#{patrolType},</if>
|
|
|
<if test="endTime != null">#{endTime},</if>
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
<if test="execType != null">#{execType},</if>
|
|
|
</trim>
|
|
|
</insert>
|
|
|
|
|
|
<update id="updatePatrolTaskStatus" parameterType="PatrolTaskStatus">
|
|
|
update patrol_task_status
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
<if test="taskPatrolledId != null">task_patrolled_id = #{taskPatrolledId},</if>
|
|
|
<if test="taskName != null">task_name = #{taskName},</if>
|
|
|
<if test="taskCode != null">task_code = #{taskCode},</if>
|
|
|
<if test="taskState != null">task_state = #{taskState},</if>
|
|
|
<if test="planStartTime != null">plan_start_time = #{planStartTime},</if>
|
|
|
<!--<if test="startTime != null">start_time = #{startTime},</if>-->
|
|
|
<if test="taskProgress != null">task_progress = #{taskProgress},</if>
|
|
|
<if test="taskEstimatedTime != null">task_estimated_time = #{taskEstimatedTime},</if>
|
|
|
<if test="description != null and description != ''">description = #{description},</if>
|
|
|
<if test="posType != null">pos_type = #{posType},</if>
|
|
|
<if test="code != null">code = #{code},</if>
|
|
|
<if test="pos != null">pos = #{pos},</if>
|
|
|
<if test="patrolType != null">patrol_type = #{patrolType},</if>
|
|
|
<if test="endTime != null">end_time = #{endTime},</if>
|
|
|
</trim>
|
|
|
where line_id = #{lineId}
|
|
|
</update>
|
|
|
|
|
|
<update id="updatePatrolTaskStatusOfTaskProgress" parameterType="PatrolTaskStatus">
|
|
|
update patrol_task_status
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
<if test="taskProgress != null">task_progress = #{taskProgress},</if>
|
|
|
</trim>
|
|
|
where line_id = #{lineId}
|
|
|
</update>
|
|
|
|
|
|
<update id="updatePatrolTaskStatusRunning" parameterType="PatrolTaskStatus">
|
|
|
update patrol_task_status
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
<if test="taskProgress != null">task_progress = #{taskProgress},</if>
|
|
|
<if test="taskState != null">task_state = #{taskState},</if>
|
|
|
</trim>
|
|
|
where line_id = #{lineId}
|
|
|
</update>
|
|
|
|
|
|
<update id="updatePatrolTaskStatusOfTaskState" parameterType="PatrolTaskStatus">
|
|
|
update patrol_task_status
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
<if test="taskState != null">task_state = #{taskState},</if>
|
|
|
</trim>
|
|
|
where line_id = #{lineId}
|
|
|
</update>
|
|
|
|
|
|
<update id="updatePatrolTaskStatusOfTaskStateAndEndTime" parameterType="PatrolTaskStatus">
|
|
|
update patrol_task_status
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
<if test="taskState != null">task_state = #{taskState},</if>
|
|
|
<if test="endTime != null">end_time = #{endTime},</if>
|
|
|
</trim>
|
|
|
where line_id = #{lineId}
|
|
|
</update>
|
|
|
|
|
|
<delete id="deletePatrolTaskStatusByLineId" parameterType="Long">
|
|
|
delete
|
|
|
from patrol_task_status
|
|
|
where line_id = #{lineId}
|
|
|
</delete>
|
|
|
|
|
|
<delete id="deletePatrolTaskStatusByLineIds" parameterType="String">
|
|
|
delete from patrol_task_status where line_id in
|
|
|
<foreach item="lineId" collection="array" open="(" separator="," close=")">
|
|
|
#{lineId}
|
|
|
</foreach>
|
|
|
</delete>
|
|
|
</mapper>
|