Commit 3710135e authored by 耿迪迪's avatar 耿迪迪

管线巡线任务统计及管线统计

parent 105f6f76
...@@ -66,9 +66,53 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -66,9 +66,53 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 需求变更修改 2025-10-30 --> <!-- 需求变更修改 2025-10-30 -->
<select id="selectTPipeTaskPointInspectList" parameterType="TPipeTaskInspect" resultMap="TPipeTaskInspectResult"> <select id="selectTPipeTaskPointInspectList" parameterType="TPipeTaskInspect" resultMap="TPipeTaskInspectResult">
SELECT SELECT
orderInspect.* pipeInspect.id,
FROM( pipeInspect.task_id,
<include refid="selectTPipeTaskInspectVo"/> pipeInspect.user_id,
pipeInspect.point,
pipeInspect.longitude,
pipeInspect.latitude,
pipeInspect.STATUS,
pipeInspect.create_time,
pipeInspect.content,
pipeInspect.danger,
pipeInspect.imgurl,
pipe.pipe_name,
point.title AS point_title,
point.longitude AS pointLongitude,
point.latitude AS pointLatitude,
us.nick_name AS inspector,
point.pipe_id
FROM
(SELECT t.*
FROM t_pipe_task_inspect t
JOIN (
SELECT `point`, MAX(create_time) AS max_time
FROM t_pipe_task_inspect
WHERE `task_id` = #{taskId} and create_time IS NOT NULL
GROUP BY `point`
) AS sub_t
ON t.`point` = sub_t.`point`
AND t.create_time = sub_t.max_time
WHERE t.`task_id` = #{taskId}
UNION ALL
SELECT t.*
FROM t_pipe_task_inspect t
WHERE t.create_time IS NULL
AND t.`point` NOT IN (
SELECT `point`
FROM t_pipe_task_inspect
WHERE `task_id` = #{taskId} AND create_time IS NOT NULL
GROUP BY `point`
)
AND t.`task_id` = #{taskId}
GROUP BY t.`point`
) pipeInspect
LEFT JOIN t_pipe_point `point` ON point.id = pipeInspect.point
LEFT JOIN t_pipe_info pipe ON pipe.pipe_id = point.pipe_id
LEFT JOIN sys_user us ON us.user_id = pipeInspect.user_id
<where> <where>
<if test="taskId != null "> and pipeInspect.task_id = #{taskId}</if> <if test="taskId != null "> and pipeInspect.task_id = #{taskId}</if>
<if test="userId != null "> and pipeInspect.user_id = #{userId}</if> <if test="userId != null "> and pipeInspect.user_id = #{userId}</if>
...@@ -81,7 +125,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -81,7 +125,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="danger != null "> and pipeInspect.danger = #{danger}</if> <if test="danger != null "> and pipeInspect.danger = #{danger}</if>
</where> </where>
ORDER BY pipeInspect.create_time DESC ORDER BY pipeInspect.create_time DESC
)orderInspect GROUP BY orderInspect.point
</select> </select>
<select id="selectPipeDistance" parameterType="TPipeTaskInspect" resultMap="TPipeTaskInspectResult"> <select id="selectPipeDistance" parameterType="TPipeTaskInspect" resultMap="TPipeTaskInspectResult">
......
...@@ -12,6 +12,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -12,6 +12,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="adminId" column="admin_id" /> <result property="adminId" column="admin_id" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="taskEndTime" column="task_end_time" /> <result property="taskEndTime" column="task_end_time" />
<association property="finishRate"
column="id"
select="selectFinishRateByTaskId"
javaType="String"/>
</resultMap> </resultMap>
<sql id="selectTPipeTaskVo"> <sql id="selectTPipeTaskVo">
...@@ -23,13 +27,61 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -23,13 +27,61 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
t.admin_id, t.admin_id,
t.create_time, t.create_time,
t.task_end_time, t.task_end_time,
u.nick_name AS nickName, u.nick_name AS nickName
(select CONCAT(ROUND(SUM(IF(pi.status = 1,1,0))/COUNT(1)*100),'%') from t_pipe_task_inspect pi where pi.task_id = t.id) as finishRate
FROM FROM
t_pipe_task t t_pipe_task t
LEFT JOIN sys_user u ON u.user_id = t.admin_id LEFT JOIN sys_user u ON u.user_id = t.admin_id
</sql> </sql>
<select id="selectFinishRateByTaskId" resultType="String">
SELECT
CONCAT(ROUND(SUM(IF(pipeInspect.status = 1, 1, 0))/COUNT(1)*100),'%')
FROM
(
SELECT
inspect.status,
inspect.task_id
FROM
t_pipe_task_inspect inspect
JOIN (
SELECT
`point`,
MAX(create_time) AS max_time
FROM
t_pipe_task_inspect
WHERE
`task_id` = #{taskId} and create_time IS NOT NULL
GROUP BY
`point`
) AS sub_t ON inspect.`point` = sub_t.`point`
AND inspect.create_time = sub_t.max_time
WHERE
inspect.`task_id` = #{taskId}
UNION ALL
SELECT
inspect.status,
inspect.task_id
FROM
t_pipe_task_inspect inspect
WHERE
inspect.create_time IS NULL
AND inspect.`point` NOT IN (
SELECT
`point`
FROM
t_pipe_task_inspect
WHERE
`task_id` = #{taskId} AND create_time IS NOT NULL
GROUP BY
`point`
)
AND inspect.`task_id` = #{taskId}
GROUP BY
inspect.`point`
) pipeInspect
GROUP BY pipeInspect.task_id
</select>
<select id="selectTPipeTaskList" parameterType="TPipeTask" resultMap="TPipeTaskResult"> <select id="selectTPipeTaskList" parameterType="TPipeTask" resultMap="TPipeTaskResult">
<include refid="selectTPipeTaskVo"/> <include refid="selectTPipeTaskVo"/>
<where> <where>
...@@ -153,43 +205,76 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -153,43 +205,76 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 需求变更修改 2025-10-30 --> <!-- 需求变更修改 2025-10-30 -->
<select id="selectTaskInspectStatisticsByPipe" parameterType="TaskInspectStatisticsByPipVo" resultType="java.util.Map"> <select id="selectTaskInspectStatisticsByPipe" parameterType="TaskInspectStatisticsByPipVo" resultType="java.util.Map">
SELECT SELECT
SUM(IF(point.status = 1, 1, 0)) AS finishPointNum, SUM(IF(pipeInspect.status = 1, 1, 0)) AS finishPointNum,
COUNT(1) AS totalPointNum, COUNT(1) AS totalPointNum,
point.userId, (
point.taskId, SELECT
point.inspector, GROUP_CONCAT(DISTINCT pti.user_id)
point.pipeId, FROM
point.pipeName t_pipe_task_inspect pti
FROM( WHERE
pti.task_id = #{taskId}
) AS userId,
pipeInspect.task_id as taskId,
(
SELECT SELECT
orderInspect.status, GROUP_CONCAT(DISTINCT sy.nick_name)
GROUP_CONCAT(orderInspect.user_id)AS userId, FROM
orderInspect.id AS taskId, t_pipe_task_inspect pti
GROUP_CONCAT(orderInspect.nick_name)AS inspector, LEFT JOIN sys_user sy ON sy.user_id = pti.user_id
orderInspect.pipe_id AS pipeId, WHERE
orderInspect.pipe_name AS pipeName pti.task_id = #{taskId}
FROM( ) AS inspector,
point.pipe_id as pipeId,
pipe.pipe_name as pipeName
FROM
(
SELECT SELECT
inspect.status, t.*
inspect.user_id,
inspect.point,
task.id,
us.nick_name,
point.pipe_id,
pipe.pipe_name
FROM FROM
t_pipe_task task t_pipe_task_inspect t
LEFT JOIN t_pipe_task_inspect inspect ON inspect.task_id = task.id JOIN (
LEFT JOIN t_pipe_point point ON point.id = inspect.point SELECT
`point`,
MAX(create_time) AS max_time
FROM
t_pipe_task_inspect
WHERE
`task_id` = #{taskId} and create_time IS NOT NULL
GROUP BY
`point`
) AS sub_t ON t.`point` = sub_t.`point`
AND t.create_time = sub_t.max_time
WHERE
t.`task_id` = #{taskId}
UNION ALL
SELECT
t.*
FROM
t_pipe_task_inspect t
WHERE
t.create_time IS NULL
AND t.`point` NOT IN (
SELECT
`point`
FROM
t_pipe_task_inspect
WHERE
`task_id` = #{taskId} AND create_time IS NOT NULL
GROUP BY
`point`
)
AND t.`task_id` = #{taskId}
GROUP BY
t.`point`
) pipeInspect
LEFT JOIN t_pipe_point `point` ON point.id = pipeInspect.point
LEFT JOIN t_pipe_info pipe ON pipe.pipe_id = point.pipe_id LEFT JOIN t_pipe_info pipe ON pipe.pipe_id = point.pipe_id
LEFT JOIN sys_user us ON us.user_id = inspect.user_id LEFT JOIN sys_user us ON us.user_id = pipeInspect.user_id
<where> <where>
task.id = #{taskId} AND inspect.status NOT IN (2)
<if test="inspector != null and inspector != ''">and us.nick_name like concat('%',#{inspector},'%')</if> <if test="inspector != null and inspector != ''">and us.nick_name like concat('%',#{inspector},'%')</if>
<if test="pipeName != null and pipeName != ''">and pipe.pipe_name like concat('%',#{pipeName},'%')</if> <if test="pipeName != null and pipeName != ''">and pipe.pipe_name like concat('%',#{pipeName},'%')</if>
</where> </where>
ORDER BY inspect.create_time DESC GROUP BY point.pipe_id
)orderInspect GROUP BY orderInspect.point
)point GROUP BY point.pipeId
</select> </select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment