| | |
| | | <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="taskStatusList != null and taskStatusList != ''"> and t.task_status in |
| | | <foreach collection="taskStatusList.split(',')" item="status" open="(" separator="," close=")"> |
| | | #{status} |
| | | </foreach> |
| | | </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)"> |
| | |
| | | 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, |
| | |
| | | <if test="actualEndTime != null">actual_end_time = #{actualEndTime},</if> |
| | | <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="updateTime != null">update_time = #{updateTime},</if> |
| | | <if test="updateBy != null">update_by = #{updateBy},</if> |
| | |
| | | #{taskId} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <!-- 根据联系人电话和创建日期查询任务数量 --> |
| | | <select id="countTaskByPhoneAndDate" resultType="int"> |
| | | select count(1) |
| | | from sys_task t |
| | | inner join sys_task_emergency e on t.task_id = e.task_id |
| | | where t.del_flag = '0' |
| | | and e.patient_phone = #{phone} |
| | | and DATE(t.create_time) = #{createDate} |
| | | </select> |
| | | |
| | | <!-- 查询车辆在指定时间范围内的任务列表 --> |
| | | <select id="selectVehicleTasksInTimeRange" parameterType="map" resultMap="SysTaskResult"> |
| | | select t.task_id, t.task_code, t.task_type, t.task_status, |
| | | t.departure_address, t.destination_address, |
| | | t.actual_start_time, t.actual_end_time, |
| | | t.planned_start_time, t.planned_end_time, |
| | | t.estimated_distance, |
| | | tv.vehicle_id |
| | | 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 ('CANCELLED') |
| | | and ( |
| | | <!-- 实际时间有值时,使用实际时间判断重叠 --> |
| | | (t.actual_start_time is not null and t.actual_end_time is not null |
| | | and t.actual_start_time <= #{endTime} and t.actual_end_time >= #{startTime}) |
| | | or |
| | | <!-- 实际开始时间有值但未结束时,使用当前时间作为结束时间 --> |
| | | (t.actual_start_time is not null and t.actual_end_time is null |
| | | and t.actual_start_time <= #{endTime}) |
| | | or |
| | | <!-- 实际时间都为空时,使用计划时间判断重叠 --> |
| | | (t.actual_start_time is null and t.actual_end_time is null |
| | | and t.planned_start_time <= #{endTime} and t.planned_end_time >= #{startTime}) |
| | | ) |
| | | order by t.actual_start_time, t.planned_start_time |
| | | </select> |
| | | </mapper> |