From 2494e3538d2ca2003f250b3f75283a9444442068 Mon Sep 17 00:00:00 2001 From: huliguo <2023611923@qq.com> Date: 星期一, 18 八月 2025 14:28:35 +0800 Subject: [PATCH] 增加导出条件 --- guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TaskDetailMapper.xml | 69 ++++++++++++++++++++++++++++++---- 1 files changed, 61 insertions(+), 8 deletions(-) diff --git a/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TaskDetailMapper.xml b/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TaskDetailMapper.xml index 845c041..8f9a604 100644 --- a/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TaskDetailMapper.xml +++ b/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/TaskDetailMapper.xml @@ -9,15 +9,30 @@ b.`name`, b.type, a.status, + ifnull(c.num, 0) as vehicleNum, DATE_FORMAT(a.execution_time, '%Y-%m-%d %H:%i:%s') as executionTime from t_task_detail a left join t_patrol_task b on (a.patrol_task_id = b.id) + left join (select task_detail_id, count(1) as num from t_task_detail_vehicles group by task_detail_id) c on (a.id = c.task_detail_id) where a.del_flag = 0 <if test="null != item.code and '' != item.code"> and a.code like CONCAT('%', #{item.code}, '%') </if> - <if test="null != item.status"> - and a.status = #{item.status} + + <if test="null != item.status and item.status.size() > 0"> + and a.status in + <foreach collection="item.status" item="item" index="index" open="(" separator="," close=")"> + #{item} + </foreach> + </if> + <if test="null != item.type"> + and b.type = #{item.type} + </if> + <if test="null != item.name and '' != item.name"> + and b.name like CONCAT('%', #{item.name}, '%') + </if> + <if test="null != item.startTime and null != item.endTime"> + and a.execution_time between #{item.startTime} and #{item.endTime} </if> order by a.execution_time desc </select> @@ -35,6 +50,7 @@ ifnull(e.num, 0) as offlineNum, ifnull(f.num, 0) as normalNum, ifnull(g.num, 0) as abnormalNum, + ROUND(ifnull(((ifnull(e.num, 0) + ifnull(f.num, 0) + ifnull(g.num, 0)) / ifnull(c.num, 0) * 100), 0), 2) as schedule, if(h.num > 0, 0, 1) as authStatus from t_task_detail a left join t_patrol_task b on (a.patrol_task_id = b.id) @@ -43,13 +59,30 @@ left join (select task_detail_id, count(1) as num from t_task_detail_vehicles where `status` = 4 group by task_detail_id) e on (a.id = e.task_detail_id) left join (select task_detail_id, count(1) as num from t_task_detail_vehicles where `status` = 3 group by task_detail_id) f on (a.id = f.task_detail_id) left join (select task_detail_id, count(1) as num from t_task_detail_vehicles where `status` = 5 group by task_detail_id) g on (a.id = g.task_detail_id) - left join (select task_detail_id, count(1) as num from t_task_detail_vehicles_channel where artificial_status = 1 group by task_detail_id) h on (a.id = h.task_detail_id) + left join (select task_detail_id, count(1) as num from t_task_detail_vehicles_channel + where artificial_status = 1 + <if test="null != item.sysStatus"> + and sys_status = #{item.sysStatus} + </if> + group by task_detail_id) h on (a.id = h.task_detail_id) where a.del_flag = 0 <if test="null != item.code and '' != item.code"> and a.code like CONCAT('%', #{item.code}, '%') </if> - <if test="null != item.status"> - and a.status = #{item.status} + <if test="null != item.status and item.status.size() > 0"> + and a.status in + <foreach collection="item.status" item="item" index="index" open="(" separator="," close=")"> + #{item} + </foreach> + </if> + <if test="null != item.type"> + and b.type = #{item.type} + </if> + <if test="null != item.name and '' != item.name"> + and b.name like CONCAT('%', #{item.name}, '%') + </if> + <if test="null != item.startTime and null != item.endTime"> + and a.execution_time between #{item.startTime} and #{item.endTime} </if> order by a.execution_time desc </select> @@ -57,6 +90,7 @@ <select id="getDownloadTaskRecord" resultType="map"> select + c.id, c.`name`, if(c.type = 1, '定时任务', '实时任务') as taskType, DATE_FORMAT(b.execution_time, '%Y-%m-%d %H:%i:%s') as executionTime, @@ -74,7 +108,7 @@ from t_task_detail_vehicles a left join t_task_detail b on (a.task_detail_id = b.id) left join t_patrol_task c on (a.patrol_task_id = c.id) - left join t_task_detail_vehicles_channel d on (a.id = d.task_detail_vehicles_id and d.video_channel = 1) + left join t_task_detail_vehicles_channel d on (a.id = d.task_detail_vehicles_id) left join sys_user e on (d.artificial_user_id = e.id) where b.del_flag = 0 <if test="null != ids and ids.size() > 0"> @@ -86,8 +120,27 @@ <if test="null != code and '' != code"> and b.code like CONCAT('%', #{code}, '%') </if> - <if test="null != status"> - and b.status = #{status} + <if test="null != status and status.size() > 0"> + and b.status in + <foreach collection="status" item="item" index="index" open="(" separator="," close=")"> + #{item} + </foreach> </if> + <if test="null != sysStatus"> + and d.sys_status = #{sysStatus} + </if> + <if test="null != type"> + and c.type = #{type} + </if> + <if test="null != typeName and '' != typeName"> + and c.name like CONCAT('%', #{typeName}, '%') + </if> + <if test="startTime != null"> + and b.execution_time >= #{startTime} + </if> + <if test="endTime != null"> + and b.execution_time < #{endTime} + </if> + order by b.execution_time desc </select> </mapper> \ No newline at end of file -- Gitblit v1.7.1