From fe33646ee6e2d1e57f2b51812e94983a0e9efb04 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 14 十二月 2025 16:51:28 +0800
Subject: [PATCH] feat: 修复统计
---
ruoyi-system/src/main/resources/mapper/system/SysTaskMapper.xml | 50 ++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysTaskMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysTaskMapper.xml
index d8abfba..18aa0a0 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysTaskMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysTaskMapper.xml
@@ -88,16 +88,36 @@
<if test="taskStatus != null and taskStatus != ''"> and t.task_status = #{taskStatus}</if>
<if test="vehicleNo != null and vehicleNo != ''"> and v.vehicle_no like concat('%', #{vehicleNo}, '%')</if>
<!-- 缁煎悎鏌ヨ锛氬綋鍓嶇敤鎴锋墍鍦ㄦ満鏋� OR 褰撳墠鐢ㄦ埛鍒涘缓 OR 鍒嗛厤缁欏綋鍓嶇敤鎴� -->
- <if test="(creatorId != null and creatorId != 0) or (assigneeId != null and assigneeId != 0) or (deptId != null and deptId != 0)">
+ <if test="(creatorId != null and creatorId != 0) or (assigneeId != null and assigneeId != 0) or (deptId != null and deptId != 0) or (deptIds != null and deptIds.size() > 0)">
and (
- <if test="deptId != null and deptId != 0">t.dept_id = #{deptId}</if>
- <if test="creatorId != null and creatorId != 0">
+ <!-- 鏌ヨ鎸囧畾鍒嗗叕鍙稿強鍏舵墍鏈夊瓙閮ㄩ棬鐨勪换鍔� -->
+ <if test="deptId != null and deptId != 0">
+ (t.dept_id = #{deptId} OR t.dept_id IN (
+ SELECT dept_id FROM sys_dept
+ WHERE del_flag = '0' AND find_in_set(#{deptId}, ancestors)
+ ))
+ </if>
+ <!-- 鏌ヨ澶氫釜鍒嗗叕鍙稿強鍏舵墍鏈夊瓙閮ㄩ棬鐨勪换鍔� -->
+ <if test="deptIds != null and deptIds.size() > 0">
<if test="deptId != null and deptId != 0"> or </if>
+ (
+ <foreach collection="deptIds" item="branchDeptId" separator=" OR ">
+ (t.dept_id = #{branchDeptId} OR t.dept_id IN (
+ SELECT dept_id FROM sys_dept
+ WHERE del_flag = '0' AND find_in_set(#{branchDeptId}, ancestors)
+ ))
+ </foreach>
+ )
+ </if>
+ <if test="creatorId != null and creatorId != 0">
+ <if test="(deptId != null and deptId != 0) or (deptIds != null and deptIds.size() > 0)"> or </if>
t.creator_id = #{creatorId}
</if>
<if test="assigneeId != null and assigneeId != 0">
- <if test="(deptId != null and deptId != 0) or (creatorId != null and creatorId != 0)"> or </if>
- t.assignee_id = #{assigneeId}
+ <if test="(deptId != null and deptId != 0) or (deptIds != null and deptIds.size() > 0) or (creatorId != null and creatorId != 0)"> or </if>
+ t.task_id IN (
+ SELECT task_id FROM sys_task_assignee WHERE user_id = #{assigneeId}
+ )
</if>
)
</if>
@@ -145,7 +165,12 @@
<select id="selectMyTasks" parameterType="Long" resultMap="SysTaskResult">
<include refid="selectSysTaskVo"/>
- where t.del_flag = '0' and (t.creator_id = #{userId} or t.assignee_id = #{userId})
+ where t.del_flag = '0' and (
+ t.creator_id = #{userId}
+ OR t.task_id IN (
+ SELECT task_id FROM sys_task_assignee WHERE user_id = #{userId}
+ )
+ )
order by
CASE t.task_status
WHEN 'PENDING' THEN 1
@@ -161,6 +186,19 @@
t.create_time desc
</select>
+ <select id="selectTaskByVehicleIdAndDate" resultMap="SysTaskResult">
+ select tv.task_id, t.actual_start_time,
+ IFNULL(t.actual_end_time, NOW()) as actual_end_time
+ from sys_task_vehicle tv
+ inner join sys_task t on tv.task_id = t.task_id
+ where tv.vehicle_id = #{vehicleId}
+ and t.del_flag = '0'
+ and (
+ (t.actual_start_time <= #{endTime} and (t.actual_end_time is null or t.actual_end_time >= #{startTime}))
+ )
+ order by t.actual_start_time
+ </select>
+
<select id="selectTaskStatistics" resultType="TaskStatisticsVO">
select
count(*) as totalTasks,
--
Gitblit v1.9.1