From 08f95b2f159b56fa3bd4f4b348855989de8aa456 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期四, 18 十二月 2025 21:48:18 +0800
Subject: [PATCH] feat: vehicle
---
ruoyi-system/src/main/resources/mapper/system/SysTaskMapper.xml | 179 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 164 insertions(+), 15 deletions(-)
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysTaskMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysTaskMapper.xml
index 359443d..6fb4112 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysTaskMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysTaskMapper.xml
@@ -12,6 +12,11 @@
<result property="taskDescription" column="task_description" />
<result property="departureAddress" column="departure_address" />
<result property="destinationAddress" column="destination_address" />
+ <result property="departureLongitude" column="departure_longitude" />
+ <result property="departureLatitude" column="departure_latitude" />
+ <result property="destinationLongitude" column="destination_longitude" />
+ <result property="destinationLatitude" column="destination_latitude" />
+ <result property="estimatedDistance" column="estimated_distance" />
<result property="plannedStartTime" column="planned_start_time" />
<result property="plannedEndTime" column="planned_end_time" />
<result property="actualStartTime" column="actual_start_time" />
@@ -25,21 +30,55 @@
<result property="updateBy" column="update_by" />
<result property="remark" column="remark" />
<result property="delFlag" column="del_flag" />
+ <result property="legacySynced" column="legacy_synced" />
<result property="creatorName" column="creator_name" />
<result property="assigneeName" column="assignee_name" />
<result property="deptName" column="dept_name" />
+ <result property="vehicleNo" column="vehicle_no" />
+ <result property="isHeadPush" column="is_head_push" />
+ <collection property="assignedVehicles" ofType="SysTaskVehicle">
+ <result property="id" column="tv_id" />
+ <result property="taskId" column="tv_task_id" />
+ <result property="vehicleId" column="tv_vehicle_id" />
+ <result property="vehicleNo" column="tv_vehicle_no" />
+ <result property="vehicleType" column="tv_vehicle_type" />
+ <result property="vehicleBrand" column="tv_vehicle_brand" />
+ <result property="vehicleModel" column="tv_vehicle_model" />
+ <result property="assignTime" column="tv_assign_time" />
+ <result property="assignBy" column="tv_assign_by" />
+ <result property="status" column="tv_status" />
+ <result property="remark" column="tv_remark" />
+ </collection>
</resultMap>
<sql id="selectSysTaskVo">
select t.task_id, t.task_code, t.task_type, t.task_status, t.task_description,
- t.departure_address, t.destination_address, t.planned_start_time, t.planned_end_time,
+ t.departure_address, t.destination_address, t.departure_longitude, t.departure_latitude,
+ t.destination_longitude, t.destination_latitude, t.estimated_distance,
+ t.planned_start_time, t.planned_end_time,
t.actual_start_time, t.actual_end_time, t.creator_id, t.assignee_id, t.dept_id,
- t.create_time, t.update_time, t.create_by, t.update_by, t.remark, t.del_flag,
- u1.nick_name as creator_name, u2.nick_name as assignee_name, d.dept_name
+ t.create_time, t.update_time, t.create_by, t.update_by, t.remark, t.del_flag, t.legacy_synced,
+ t.is_head_push,
+ u1.nick_name as creator_name, u2.nick_name as assignee_name, d.dept_name,
+ (
+ select v2.vehicle_no
+ from sys_task_vehicle tv2
+ left join tb_vehicle_info v2 on tv2.vehicle_id = v2.vehicle_id
+ where tv2.task_id = t.task_id
+ order by tv2.assign_time asc
+ limit 1
+ ) as vehicle_no,
+ tv.id as tv_id, tv.task_id as tv_task_id, tv.vehicle_id as tv_vehicle_id,
+ v.vehicle_no as tv_vehicle_no, v.vehicle_type as tv_vehicle_type,
+ v.vehicle_brand as tv_vehicle_brand, v.vehicle_model as tv_vehicle_model,
+ tv.assign_time as tv_assign_time, tv.assign_by as tv_assign_by,
+ tv.status as tv_status, tv.remark as tv_remark
from sys_task t
left join sys_user u1 on t.creator_id = u1.user_id
left join sys_user u2 on t.assignee_id = u2.user_id
left join sys_dept d on t.dept_id = d.dept_id
+ left join sys_task_vehicle tv on t.task_id = tv.task_id
+ left join tb_vehicle_info v on tv.vehicle_id = v.vehicle_id
</sql>
<select id="selectSysTaskList" parameterType="TaskQueryVO" resultMap="SysTaskResult">
@@ -49,16 +88,59 @@
<if test="taskCode != null and taskCode != ''"> and t.task_code like concat('%', #{taskCode}, '%')</if>
<if test="taskType != null and taskType != ''"> and t.task_type = #{taskType}</if>
<if test="taskStatus != null and taskStatus != ''"> and t.task_status = #{taskStatus}</if>
- <if test="creatorId != null "> and t.creator_id = #{creatorId}</if>
- <if test="assigneeId != null "> and t.assignee_id = #{assigneeId}</if>
- <if test="deptId != null "> and t.dept_id = #{deptId}</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) or (deptIds != null and deptIds.size() > 0)">
+ and (
+ <!-- 鏌ヨ鎸囧畾鍒嗗叕鍙稿強鍏舵墍鏈夊瓙閮ㄩ棬鐨勪换鍔� -->
+ <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 (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>
<if test="plannedStartTimeBegin != null "> and t.planned_start_time >= #{plannedStartTimeBegin}</if>
<if test="plannedStartTimeEnd != null "> and t.planned_start_time <= #{plannedStartTimeEnd}</if>
<if test="plannedEndTimeBegin != null "> and t.planned_end_time >= #{plannedEndTimeBegin}</if>
<if test="plannedEndTimeEnd != null "> and t.planned_end_time <= #{plannedEndTimeEnd}</if>
<if test="overdue != null and overdue == true"> and t.planned_end_time < now() and t.task_status != 'COMPLETED'</if>
</where>
- order by t.create_time desc
+ order by
+ CASE t.task_status
+ WHEN 'PENDING' THEN 1
+ WHEN 'DEPARTING' THEN 2
+ WHEN 'ARRIVED' THEN 3
+ WHEN 'RETURNING' THEN 4
+ WHEN 'IN_PROGRESS' THEN 5
+ WHEN 'COMPLETED' THEN 6
+ WHEN 'CANCELLED' THEN 7
+ ELSE 8
+ END,
+ t.create_time desc
</select>
<select id="selectSysTaskByTaskId" parameterType="Long" resultMap="SysTaskResult">
@@ -71,6 +153,12 @@
where t.task_code = #{taskCode} and t.del_flag = '0'
</select>
+ <select id="selectMaxTaskCodeByDatePrefix" parameterType="String" resultType="String">
+ select max(task_code)
+ from sys_task
+ where task_code like concat(#{datePrefix}, '%')
+ </select>
+
<select id="selectOverdueTasks" resultMap="SysTaskResult">
<include refid="selectSysTaskVo"/>
where t.del_flag = '0' and t.planned_end_time < now() and t.task_status != 'COMPLETED'
@@ -79,8 +167,38 @@
<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})
- order by t.create_time desc
+ 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
+ WHEN 'DEPARTING' THEN 2
+ WHEN 'ARRIVED' THEN 3
+ WHEN 'RETURNING' THEN 4
+ WHEN 'IN_PROGRESS' THEN 5
+ WHEN 'COMPLETED' THEN 6
+ WHEN 'CANCELLED' THEN 7
+ ELSE 8
+ END,
+ t.update_time desc,
+ 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">
@@ -106,6 +224,11 @@
<if test="taskDescription != null">task_description,</if>
<if test="departureAddress != null">departure_address,</if>
<if test="destinationAddress != null">destination_address,</if>
+ <if test="departureLongitude != null">departure_longitude,</if>
+ <if test="departureLatitude != null">departure_latitude,</if>
+ <if test="destinationLongitude != null">destination_longitude,</if>
+ <if test="destinationLatitude != null">destination_latitude,</if>
+ <if test="estimatedDistance != null">estimated_distance,</if>
<if test="plannedStartTime != null">planned_start_time,</if>
<if test="plannedEndTime != null">planned_end_time,</if>
<if test="actualStartTime != null">actual_start_time,</if>
@@ -113,8 +236,9 @@
<if test="creatorId != null">creator_id,</if>
<if test="assigneeId != null">assignee_id,</if>
<if test="deptId != null">dept_id,</if>
+ <if test="isHeadPush != null">is_head_push,</if>
<if test="createTime != null">create_time,</if>
- <if test="updateTime != null">update_time,</if>
+ update_time,
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
<if test="remark != null">remark,</if>
@@ -127,6 +251,11 @@
<if test="taskDescription != null">#{taskDescription},</if>
<if test="departureAddress != null">#{departureAddress},</if>
<if test="destinationAddress != null">#{destinationAddress},</if>
+ <if test="departureLongitude != null">#{departureLongitude},</if>
+ <if test="departureLatitude != null">#{departureLatitude},</if>
+ <if test="destinationLongitude != null">#{destinationLongitude},</if>
+ <if test="destinationLatitude != null">#{destinationLatitude},</if>
+ <if test="estimatedDistance != null">#{estimatedDistance},</if>
<if test="plannedStartTime != null">#{plannedStartTime},</if>
<if test="plannedEndTime != null">#{plannedEndTime},</if>
<if test="actualStartTime != null">#{actualStartTime},</if>
@@ -134,8 +263,9 @@
<if test="creatorId != null">#{creatorId},</if>
<if test="assigneeId != null">#{assigneeId},</if>
<if test="deptId != null">#{deptId},</if>
+ <if test="isHeadPush != null">#{isHeadPush},</if>
<if test="createTime != null">#{createTime},</if>
- <if test="updateTime != null">#{updateTime},</if>
+ now(),
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="remark != null">#{remark},</if>
@@ -152,6 +282,11 @@
<if test="taskDescription != null">task_description = #{taskDescription},</if>
<if test="departureAddress != null">departure_address = #{departureAddress},</if>
<if test="destinationAddress != null">destination_address = #{destinationAddress},</if>
+ <if test="departureLongitude != null">departure_longitude = #{departureLongitude},</if>
+ <if test="departureLatitude != null">departure_latitude = #{departureLatitude},</if>
+ <if test="destinationLongitude != null">destination_longitude = #{destinationLongitude},</if>
+ <if test="destinationLatitude != null">destination_latitude = #{destinationLatitude},</if>
+ <if test="estimatedDistance != null">estimated_distance = #{estimatedDistance},</if>
<if test="plannedStartTime != null">planned_start_time = #{plannedStartTime},</if>
<if test="plannedEndTime != null">planned_end_time = #{plannedEndTime},</if>
<if test="actualStartTime != null">actual_start_time = #{actualStartTime},</if>
@@ -159,6 +294,7 @@
<if test="creatorId != null">creator_id = #{creatorId},</if>
<if test="assigneeId != null">assignee_id = #{assigneeId},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
+ <if test="isHeadPush != null">is_head_push = #{isHeadPush},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
@@ -172,7 +308,7 @@
task_status = #{taskStatus},
<if test="actualStartTime != null">actual_start_time = #{actualStartTime},</if>
<if test="actualEndTime != null">actual_end_time = #{actualEndTime},</if>
- update_time = now(),
+ update_time = #{updateTime},
update_by = #{updateBy}
where task_id = #{taskId}
</update>
@@ -180,17 +316,30 @@
<update id="assignTask" parameterType="SysTask">
update sys_task set
assignee_id = #{assigneeId},
- update_time = now(),
+ update_time = #{updateTime},
update_by = #{updateBy}
where task_id = #{taskId}
</update>
+ <select id="selectActiveTasksByVehicleId" parameterType="Long" resultMap="SysTaskResult">
+ select t.task_id, t.task_code, t.task_type, t.task_status, t.task_description,
+ t.departure_address, t.destination_address,
+ t.planned_start_time, t.actual_start_time,
+ t.create_time, t.update_time
+ from sys_task t
+ inner join sys_task_vehicle tv on t.task_id = tv.task_id
+ where tv.vehicle_id = #{vehicleId}
+ and t.del_flag = '0'
+ and t.task_status not in ('PENDING', 'COMPLETED', 'CANCELLED')
+ order by t.create_time desc
+ </select>
+
<delete id="deleteSysTaskByTaskId" parameterType="Long">
- update sys_task set del_flag = '2' where task_id = #{taskId}
+ update sys_task set del_flag = '2', update_time = now() where task_id = #{taskId}
</delete>
<delete id="deleteSysTaskByTaskIds" parameterType="String">
- update sys_task set del_flag = '2' where task_id in
+ update sys_task set del_flag = '2', update_time = now() where task_id in
<foreach item="taskId" collection="array" open="(" separator="," close=")">
#{taskId}
</foreach>
--
Gitblit v1.9.1