wlzboy
19 小时以前 10354e63eb3298beb9ebcc029dd9f48d8936a272
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTaskServiceImpl.java
@@ -8,8 +8,11 @@
import java.net.URL;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.*;
import com.ruoyi.system.domain.vo.*;
import com.ruoyi.system.event.*;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.service.*;
import com.ruoyi.system.utils.TaskCodeGenerator;
@@ -18,10 +21,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.GpsDistanceUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.system.domain.SysTask;
@@ -33,9 +32,6 @@
import com.ruoyi.system.domain.SysTaskAssignee;
import com.ruoyi.system.domain.enums.TaskStatus;
import com.ruoyi.system.domain.VehicleInfo;
import com.ruoyi.system.event.TaskCreatedEvent;
import com.ruoyi.system.event.TaskAssignedEvent;
import com.ruoyi.system.event.TaskStatusChangedEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -82,8 +78,13 @@
    @Autowired
    private ISysTaskAttachmentService sysTaskAttachmentService;
    @Autowired
    private SysUserMapper sysUserMapper;
    private ISysDeptService deptService;
    @Autowired
    private ISysUserService userService;
    @Autowired(required = false)
    private IMapService mapService;
@@ -100,6 +101,19 @@
    @Autowired
    private ISysTaskVehicleService sysTaskVehicleService;
    @Override
    public Boolean dispatchSyncEvent(Long taskId) {
        SysTask task= sysTaskMapper.selectSysTaskByTaskId(taskId);
        SysUser user= userService.selectUserById(task.getCreatorId());
        Integer oaUser=user.getOaUserId();
        SysTaskEmergency emergency = sysTaskEmergencyMapper.selectSysTaskEmergencyByTaskId(taskId);
        eventPublisher.publishEvent(new TaskDispatchSyncEvent(this, taskId, task.getTaskCode(),emergency.getLegacyServiceOrdId(), emergency.getLegacyDispatchOrdId(),oaUser));
        return true;
    }
    private Long getBranchCompanyId(Long userId) {
       return userService.getBranchCompanyIdByUserId(userId);
    }
    /**
     * 查询任务管理
     * 
@@ -110,6 +124,7 @@
    public SysTask selectSysTaskByTaskId(Long taskId) {
        SysTask task = sysTaskMapper.selectSysTaskByTaskId(taskId);
        if (task != null) {
            // 加载急救转运扩展信息
            if ("EMERGENCY_TRANSFER".equals(task.getTaskType())) {
                SysTaskEmergency emergencyInfo = sysTaskEmergencyMapper.selectSysTaskEmergencyByTaskId(taskId);
@@ -132,7 +147,90 @@
     */
    @Override
    public List<SysTask> selectSysTaskList(TaskQueryVO queryVO) {
        return sysTaskMapper.selectSysTaskList(queryVO);
        List<SysTask> tasks= sysTaskMapper.selectSysTaskList(queryVO);
        tasks.forEach(task -> {
            if ("EMERGENCY_TRANSFER".equals(task.getTaskType())) {
                SysTaskEmergency emergencyInfo = sysTaskEmergencyMapper.selectSysTaskEmergencyByTaskId(task.getTaskId());
                task.setEmergencyInfo(emergencyInfo);
            }
        });
        return tasks;
    }
    /**
     * 设置任务是总部推送的标记
     * @param taskCreatorId 任务创建人的用户ID
     * @param taskDeptId 任务中的归属机构ID
     */
    @Override
    public Boolean isTaskHeaderPush(Long taskCreatorId,Long taskDeptId){
        if(LongUtil.isEmpty(taskCreatorId))return false;
        if(LongUtil.isEmpty(taskDeptId))return false ;
        Long createrDeptId = getBranchCompanyId(taskCreatorId);
        if(createrDeptId !=null && !taskDeptId.equals(createrDeptId) && createrDeptId.equals(DeptUtil.GUANGZHOU_DEPT_ID)){
            //广州总部推送的任务
           return true;
        }else{
            return false;
        }
    }
    /**
     * 根据任务编号、调度单编号或服务单编号查询任务列表
     *
     * @param queryVO 任务查询对象
     * @param taskCode 任务编号
     * @return 任务管理集合
     */
    @Override
    public List<SysTask> selectSysTaskListByMultiCode(TaskQueryVO queryVO, String taskCode) {
        // Create a new query object without the taskCode filter
        TaskQueryVO newQuery = new TaskQueryVO();
        // Copy all properties except taskCode
        try {
            org.springframework.beans.BeanUtils.copyProperties(queryVO, newQuery, "taskCode");
        } catch (Exception e) {
            // If copy fails, manually copy the important fields
            newQuery.setTaskType(queryVO.getTaskType());
            newQuery.setTaskStatus(queryVO.getTaskStatus());
            newQuery.setVehicleNo(queryVO.getVehicleNo());
            newQuery.setCreatorId(queryVO.getCreatorId());
            newQuery.setAssigneeId(queryVO.getAssigneeId());
            newQuery.setDeptId(queryVO.getDeptId());
            newQuery.setDeptIds(queryVO.getDeptIds());
            newQuery.setPlannedStartTimeBegin(queryVO.getPlannedStartTimeBegin());
            newQuery.setPlannedStartTimeEnd(queryVO.getPlannedStartTimeEnd());
            newQuery.setPlannedEndTimeBegin(queryVO.getPlannedEndTimeBegin());
            newQuery.setPlannedEndTimeEnd(queryVO.getPlannedEndTimeEnd());
            newQuery.setOverdue(queryVO.getOverdue());
        }
        // Get all tasks matching the other criteria
        List<SysTask> allTasks = sysTaskMapper.selectSysTaskList(newQuery);
        allTasks.stream().forEach(task -> {
            if ("EMERGENCY_TRANSFER".equals(task.getTaskType())) {
                SysTaskEmergency emergencyInfo = sysTaskEmergencyMapper.selectSysTaskEmergencyByTaskId(task.getTaskId());
                task.setEmergencyInfo(emergencyInfo);
            }
        });
        return allTasks.stream().filter(task -> {
            if (task.getTaskCode() != null && task.getTaskCode().contains(taskCode)) {
                return true;
            }
            if ("EMERGENCY_TRANSFER".equals(task.getTaskType()) && task.getEmergencyInfo() != null) {
                String dispatchCode = task.getEmergencyInfo().getDispatchCode();
                String serviceCode = task.getEmergencyInfo().getServiceCode();
                return (dispatchCode != null && dispatchCode.contains(taskCode)) ||
                        (serviceCode != null && serviceCode.contains(taskCode));
            }
            return false;
        }).collect(Collectors.toList());
    }
    /**
@@ -167,6 +265,8 @@
        task.setUpdateTime(DateUtils.getNowDate());
        task.setRemark(createVO.getRemark());
        task.setDelFlag("0");
        task.setIsHeadPush(isTaskHeaderPush(userId,task.getDeptId())?"1":"0");
        
        // 设置地址和坐标信息
        setAddressAndCoordinatesFromVO(task, createVO);
@@ -215,10 +315,7 @@
            ));
        }
        
        // 发布任务分配事件
        if (result > 0 && createVO.getAssignees() != null && !createVO.getAssignees().isEmpty()) {
            this.sendTaskAssigneeEvent(createVO,task,SecurityUtils.getUserId(),SecurityUtils.getUsername());
        }
        
        // 异步同步急救转运任务到旧系统
        if (result > 0 && "EMERGENCY_TRANSFER".equals(createVO.getTaskType()) && legacySystemSyncService != null) {
@@ -248,7 +345,7 @@
     */
    @Override
    @Transactional
    public int insertTask(TaskCreateVO createVO,String serviceOrderId,String dispatchOrderId, String serviceOrdNo, Long userId,String userName, Long deptId, Date createTime, Date updateTime) {
    public int insertTask(TaskCreateVO createVO,Long serviceOrderId,Long dispatchOrderId, String serviceOrdNo, Long userId,String userName, Long deptId, Date createTime, Date updateTime) {
        SysTask task = new SysTask();
        if(createVO.getTaskCode()!=null){
            task.setTaskCode(createVO.getTaskCode());
@@ -274,6 +371,13 @@
        task.setRemark(createVO.getRemark());
        task.setDelFlag("0");
        Boolean isHeadPush=this.isTaskHeaderPush(userId, deptId);
        if(isHeadPush){
            task.setIsHeadPush("1");
        }else{
            task.setIsHeadPush("0");
        }
        
        // 设置地址和坐标信息
@@ -282,8 +386,8 @@
        if (createVO.getTransferTime() != null) {
            task.setPlannedStartTime(createVO.getTransferTime());
        }
        if (createVO.getTransferDistance() != null) {
            task.setEstimatedDistance(createVO.getTransferDistance());
        if (createVO.getDistance() != null) {
            task.setEstimatedDistance(createVO.getDistance());
        }
        if (createVO.getPlannedStartTime() != null) {
            task.setPlannedStartTime(createVO.getPlannedStartTime());
@@ -341,12 +445,10 @@
            ));
        }
        
        // 发布任务分配事件
        if (result > 0 && createVO.getAssignees() != null && !createVO.getAssignees().isEmpty()) {
            this.sendTaskAssigneeEvent(createVO,task,userId,userName);
        }
        if(result>0) {
            this.sendEmeryTaskProcess(task, dispatchOrderId);
        }
        
        return result;
    }
@@ -379,14 +481,13 @@
    @Override
    @Transactional
    public int updateSysTask(TaskUpdateVO updateVO, Boolean updateFromLegacy) {
        SysTask oldTask = sysTaskMapper.selectSysTaskByTaskId(updateVO.getTaskId());
        if (oldTask == null) {
        SysTask task = sysTaskMapper.selectSysTaskByTaskId(updateVO.getTaskId());
        if (task == null) {
            throw new RuntimeException("任务不存在");
        }
        Long userId = SecurityUtils.getUserId();
        String userName = SecurityUtils.getUsername();
        SysTask task = new SysTask();
        task.setTaskId(updateVO.getTaskId());
        task.setTaskDescription(updateVO.getTaskDescription());
        task.setPlannedStartTime(updateVO.getPlannedStartTime());
@@ -395,23 +496,16 @@
        task.setUpdateBy(userName);
        task.setUpdateTime(updateVO.getUpdateTime() != null ? updateVO.getUpdateTime() : DateUtils.getNowDate());
        task.setRemark(updateVO.getRemark());
        
        // 设置通用地址和坐标信息
        task.setDepartureAddress(updateVO.getDepartureAddress());
        task.setDestinationAddress(updateVO.getDestinationAddress());
        task.setDepartureLongitude(updateVO.getDepartureLongitude());
        task.setDepartureLatitude(updateVO.getDepartureLatitude());
        task.setDestinationLongitude(updateVO.getDestinationLongitude());
        task.setDestinationLatitude(updateVO.getDestinationLatitude());
        
        // 设置预计距离
        if (updateVO.getEstimatedDistance() != null) {
            task.setEstimatedDistance(updateVO.getEstimatedDistance());
        } else if (updateVO.getTransferDistance() != null) {
            // 兼容急救转运字段
            task.setEstimatedDistance(updateVO.getTransferDistance());
        } else if (updateVO.getDistance() != null) {
            // 兼容福祉车字段
            // 兼容急救转运字段
            task.setEstimatedDistance(updateVO.getDistance());
        }
        
@@ -419,17 +513,18 @@
        if (updateVO.getDeptId() != null) {
            task.setDeptId(updateVO.getDeptId());
        }
        // 如果更新了任务编号
        if (updateVO.getTaskCode() != null) {
            task.setTaskCode(updateVO.getTaskCode());
        }
        Boolean hasSetDepartureFlag=false;
        //设置总部推送
        task.setIsHeadPush(this.isTaskHeaderPush(task.getCreatorId(), task.getDeptId())?"1":"0");
        // 自动获取出发地GPS坐标(如果更新了地址但缺失坐标)
        if (updateVO.getDepartureAddress() != null && 
            (updateVO.getDepartureLongitude() == null || updateVO.getDepartureLatitude() == null) && 
            mapService != null) {
            if (!updateVO.getDepartureAddress().equals(oldTask.getDepartureAddress())) {
            if (!updateVO.getDepartureAddress().equals(task.getDepartureAddress())) {
                try {
                    Map<String, Double> coords = mapService.geocoding(
                        updateVO.getDepartureAddress(),
@@ -438,6 +533,7 @@
                    if (coords != null) {
                        task.setDepartureLongitude(BigDecimal.valueOf(coords.get("lng")));
                        task.setDepartureLatitude(BigDecimal.valueOf(coords.get("lat")));
                        hasSetDepartureFlag = true;
//                        log.info("出发地GPS坐标自动获取成功: {}, {}", coords.get("lng"), coords.get("lat"));
                    }
                } catch (Exception e) {
@@ -445,12 +541,20 @@
                }
            }
        }
        // 设置通用地址和坐标信息
        task.setDepartureAddress(updateVO.getDepartureAddress());
        if(!hasSetDepartureFlag) {
            task.setDepartureLongitude(updateVO.getDepartureLongitude());
            task.setDepartureLatitude(updateVO.getDepartureLatitude());
        }
        Boolean hasSetDestinationFlag=false;
        // 自动获取目的地GPS坐标(如果更新了地址但缺失坐标)
        if (updateVO.getDestinationAddress() != null && 
            (updateVO.getDestinationLongitude() == null || updateVO.getDestinationLatitude() == null) && 
            mapService != null) {
            if (!updateVO.getDestinationAddress().equals(oldTask.getDestinationAddress())) {
            if (!updateVO.getDestinationAddress().equals(task.getDestinationAddress())) {
                try {
                    Map<String, Double> coords = mapService.geocoding(
                        updateVO.getDestinationAddress(),
@@ -459,6 +563,7 @@
                    if (coords != null) {
                        task.setDestinationLongitude(BigDecimal.valueOf(coords.get("lng")));
                        task.setDestinationLatitude(BigDecimal.valueOf(coords.get("lat")));
                        hasSetDestinationFlag = true;
//                        log.info("目的地GPS坐标自动获取成功: {}, {}", coords.get("lng"), coords.get("lat"));
                    }
                } catch (Exception e) {
@@ -466,8 +571,19 @@
                }
            }
        }
        task.setDestinationAddress(updateVO.getDestinationAddress());
        if(!hasSetDestinationFlag) {
            task.setDestinationLongitude(updateVO.getDestinationLongitude());
            task.setDestinationLatitude(updateVO.getDestinationLatitude());
        }
        if(updateVO.getAssignees()!=null && !updateVO.getAssignees().isEmpty()){
           TaskCreateVO.AssigneeInfo assigneeInfo= updateVO.getAssignees().get(0);
            task.setAssigneeId(assigneeInfo.getUserId());
            task.setAssigneeName(assigneeInfo.getUserName());
        }
        // 用于跟踪是否需要重新同步(车辆、人员、地址、成交价变更)
        boolean needResync = false;
        boolean needResync = true;
        int result = sysTaskMapper.updateSysTask(task);
        
@@ -481,7 +597,8 @@
                needResync = true;
            }
        }
        // 更新执行人员(检测人员变更)
        if (result > 0 && updateVO.getAssignees() != null) {
            boolean assigneesChanged = sysTaskAssigneeService.updateTaskAssignees(
@@ -491,41 +608,54 @@
                needResync = true;
            }
        }
        Long dispatchOrderId=0L;
        // 更新急救转运扩展信息(检测地址和成交价变更)
        if (result > 0 && "EMERGENCY_TRANSFER".equals(oldTask.getTaskType())) {
        if (result > 0 && "EMERGENCY_TRANSFER".equals(task.getTaskType())) {
            SysTaskEmergency oldEmergency = sysTaskEmergencyMapper.selectSysTaskEmergencyByTaskId(updateVO.getTaskId());
            sysEmergencyTaskService.updateEmergencyInfoFromUpdateVO(oldEmergency, updateVO, userName);
            sysEmergencyTaskService.markNeedResyncIfNecessary(updateVO.getTaskId(), oldTask, updateVO, updateFromLegacy);
          dispatchOrderId=  oldEmergency.getLegacyDispatchOrdId();
            markNeedSync(task,updateVO);
        }
        
        // 更新福祉车扩展信息
        if (result > 0 && "WELFARE".equals(oldTask.getTaskType())) {
        if (result > 0 && "WELFARE".equals(task.getTaskType())) {
            if (updateVO.getPassenger() != null || updateVO.getStartAddress() != null || updateVO.getEndAddress() != null) {
                sysWelfareTaskService.updateWelfareInfo(updateVO.getTaskId(), updateVO, userName);
            }
        }
        
        // 如果是急救转运任务且有变更,标记需要重新同步
        if (result > 0 && "EMERGENCY_TRANSFER".equals(oldTask.getTaskType()) && needResync && !updateFromLegacy) {
            sysEmergencyTaskService.markNeedResyncIfNecessary(updateVO.getTaskId(), oldTask, updateVO, updateFromLegacy);
        }
        
        // 记录操作日志
        if (result > 0) {
            recordTaskLog(updateVO.getTaskId(), "UPDATE", "更新任务",
                buildTaskDescription(oldTask), buildTaskDescription(task),
                buildTaskDescription(task), buildTaskDescription(task),
                userId, userName);
        }
        if(result > 0 && oldTask.getTaskStatus().equals(TaskStatus.PENDING.getCode()) && updateVO.getAssignees() != null && !updateVO.getAssignees().isEmpty()){
        if(result > 0 && task.getTaskStatus().equals(TaskStatus.PENDING.getCode())
                && updateVO.getAssignees() != null
                && !updateVO.getAssignees().isEmpty()
                && LongUtil.isNotEmpty(dispatchOrderId)){
            this.sendTaskAssigneeEvent(updateVO,oldTask,userId,userName);
            this.sendTaskAssigneeEvent(updateVO,task,userId,userName);
        }
        return result;
    }
    private void markNeedSync(SysTask sysTask,TaskUpdateVO updateVO){
        // 如果是急救转运任务且有变更,标记需要重新同步
        if ( "EMERGENCY_TRANSFER".equals(sysTask.getTaskType()) ) {
            sysEmergencyTaskService.markNeedResyncIfNecessary(updateVO.getTaskId(), sysTask, updateVO, true);
            eventPublisher.publishEvent(new TaskUpdateEvent(this,sysTask.getTaskId(),
                    sysTask.getTaskCode(),sysTask.getTaskType()));
        }
    }
    /**
     * 更新任务(用于旧系统同步)
     * 
@@ -541,15 +671,17 @@
     * @return 结果
     */
    @Override
    public int updateTask(TaskUpdateVO updateVO, String serviceOrderId, String dispatchOrderId, String serviceOrdNo,
    public int updateTask(TaskUpdateVO updateVO, Long serviceOrderId, Long dispatchOrderId, String serviceOrdNo,
                         Long userId, String userName, Long deptId, Date createTime, Date updateTime) {
//        log.info("开始更新任务 ServiceOrdID: {} , dispatchOrdId:{}", serviceOrderId,dispatchOrderId);
        // 通过旧系统服务单ID查找任务
        SysTaskEmergency taskEmergency = sysTaskEmergencyMapper.selectByLegacyServiceOrdId(Long.parseLong(serviceOrderId));
        // 获取旧任务信息,用于判断地址是否变更
        SysTaskEmergency taskEmergency = sysTaskEmergencyMapper.selectByLegacyServiceOrdId(serviceOrderId);
        Long taskId = taskEmergency.getTaskId();
        SysTask task = sysTaskMapper.selectSysTaskByTaskId(taskId);
        updateVO.setTaskId(taskId);
        SysTask task = new SysTask();
        task.setTaskId(taskId);
        if(updateVO.getTaskStatus()!=null){
            task.setTaskStatus(updateVO.getTaskStatus());
        }
@@ -562,20 +694,24 @@
        if(updateVO.getActualEndTime() != null) {
            task.setActualEndTime(updateVO.getActualEndTime());
        }
        task.setAssigneeId(updateVO.getAssigneeId());
        if(deptId!=null){
            task.setDeptId(deptId);
        }
//        task.setAssigneeId(updateVO.getAssigneeId());
        task.setUpdateBy(userName);
        task.setUpdateTime(DateUtils.getNowDate());
        task.setRemark(updateVO.getRemark());
        
        // 设置地址和坐标信息
        task.setDepartureAddress(updateVO.getDepartureAddress());
        task.setDestinationAddress(updateVO.getDestinationAddress());
        task.setDepartureLongitude(updateVO.getDepartureLongitude());
        task.setDepartureLatitude(updateVO.getDepartureLatitude());
        task.setDestinationLongitude(updateVO.getDestinationLongitude());
        task.setDestinationLatitude(updateVO.getDestinationLatitude());
        if(updateVO.getAssignees()!=null && !updateVO.getAssignees().isEmpty()){
            TaskCreateVO.AssigneeInfo assigneeInfo= updateVO.getAssignees().get(0);
            task.setAssigneeId(assigneeInfo.getUserId());
            task.setAssigneeName(assigneeInfo.getUserName());
        }
        // 如果更新了部门ID
        if (updateVO.getDeptId() != null) {
            task.setDeptId(updateVO.getDeptId());
@@ -585,13 +721,18 @@
        if (updateVO.getTaskCode() != null) {
            task.setTaskCode(updateVO.getTaskCode());
        }
        // 获取旧任务信息,用于判断地址是否变更
        SysTask oldTask = sysTaskMapper.selectSysTaskByTaskId(taskId);
//        task.setDepartureLongitude(updateVO.getDepartureLongitude());
//        task.setDepartureLatitude(updateVO.getDepartureLatitude());
//        task.setDestinationLongitude(updateVO.getDestinationLongitude());
//        task.setDestinationLatitude(updateVO.getDestinationLatitude());
        Boolean modifyOutLongLat = false;
        // 自动获取出发地GPS坐标(如果地址变更且缺失坐标)
        if (oldTask != null && updateVO.getDepartureAddress() != null
            && !updateVO.getDepartureAddress().equals(oldTask.getDepartureAddress())
        if (task != null && updateVO.getDepartureAddress() != null
            && !updateVO.getDepartureAddress().equals(task.getDepartureAddress())
            && (updateVO.getDepartureLongitude() == null || updateVO.getDepartureLatitude() == null)
            && mapService != null) {
            try {
@@ -602,16 +743,23 @@
                if (coords != null) {
                    task.setDepartureLongitude(BigDecimal.valueOf(coords.get("lng")));
                    task.setDepartureLatitude(BigDecimal.valueOf(coords.get("lat")));
                    modifyOutLongLat = true;
//                    log.info("出发地GPS坐标自动获取成功: {}, {}", coords.get("lng"), coords.get("lat"));
                }
            } catch (Exception e) {
                log.error("自动获取出发地GPS坐标失败", e);
            }
        }
        task.setDepartureAddress(updateVO.getDepartureAddress());
        if(!modifyOutLongLat){
            task.setDepartureLongitude(updateVO.getDepartureLongitude());
            task.setDepartureLatitude(updateVO.getDepartureLatitude());
        }
        Boolean modifyInLongLat = false;
        // 自动获取目的地GPS坐标(如果地址变更且缺失坐标)
        if (oldTask != null && updateVO.getDestinationAddress() != null
            && !updateVO.getDestinationAddress().equals(oldTask.getDestinationAddress())
        if (task != null && updateVO.getDestinationAddress() != null
            && !updateVO.getDestinationAddress().equals(task.getDestinationAddress())
            && (updateVO.getDestinationLongitude() == null || updateVO.getDestinationLatitude() == null)
            && mapService != null) {
            try {
@@ -622,11 +770,17 @@
                if (coords != null) {
                    task.setDestinationLongitude(BigDecimal.valueOf(coords.get("lng")));
                    task.setDestinationLatitude(BigDecimal.valueOf(coords.get("lat")));
                    modifyInLongLat = true;
//                    log.info("目的地GPS坐标自动获取成功: {}, {}", coords.get("lng"), coords.get("lat"));
                }
            } catch (Exception e) {
                log.error("自动获取目的地GPS坐标失败", e);
            }
        }
        task.setDestinationAddress(updateVO.getDestinationAddress());
        if(!modifyInLongLat){
            task.setDestinationLongitude(updateVO.getDestinationLongitude());
            task.setDestinationLatitude(updateVO.getDestinationLatitude());
        }
        
        int result = sysTaskMapper.updateSysTask(task);
@@ -646,16 +800,14 @@
//            log.info("更新执行人员 ServiceOrdID:{},dispatchOrderId:{}",serviceOrderId,dispatchOrderId);
            sysTaskAssigneeService.updateTaskAssignees(taskId, updateVO.getAssignees(), userName);
        }
        // 更新急救转运扩展信息
        if (result > 0) {
            // 更新旧系统ID
            if (serviceOrderId != null) {
                taskEmergency.setLegacyServiceOrdId(Long.parseLong(serviceOrderId));
            }
            if (dispatchOrderId != null) {
                taskEmergency.setLegacyDispatchOrdId(Long.parseLong(dispatchOrderId));
                taskEmergency.setLegacyDispatchOrdId(Long.parseLong(dispatchOrderId));
            taskEmergency.setLegacyServiceOrdId(serviceOrderId);
            if (LongUtil.isNotEmpty(dispatchOrderId)) {
                taskEmergency.setLegacyDispatchOrdId(dispatchOrderId);
                taskEmergency.setDispatchSyncStatus(2);
                taskEmergency.setDispatchSyncTime(new Date());
                taskEmergency.setDispatchSyncErrorMsg("旧系统同步过来");
@@ -665,23 +817,42 @@
            }
            taskEmergency.setUpdateTime(DateUtils.getNowDate());
            Boolean hasEmergencyInfo = updateVO.getHospitalOut() != null || updateVO.getHospitalIn() != null || updateVO.getPatient() != null;
//            log.info("更新转运任务信息 serviceOrdID:{},dispatchOrderId:{} hasEmergencyInfo:{}",serviceOrderId,
//                    dispatchOrderId,hasEmergencyInfo);
            Boolean hasEmergencyInfo = updateVO.getHospitalOut() != null || updateVO.getHospitalIn() != null || updateVO.getPatient() != null
                    || updateVO.getPrice() != null || updateVO.getDistance() != null;
            // 使用TaskCreateVO的字段来更新急救转运信息
            if (hasEmergencyInfo) {
                sysEmergencyTaskService.updateEmergencyInfoFromCreateVO(taskEmergency, updateVO, userName);
            }
           SysTaskEmergency emergency= sysEmergencyTaskService.selectSysTaskEmergencyByTaskId(taskId);
            dispatchOrderId = emergency.getLegacyDispatchOrdId();
        }
        if(updateVO.getTaskStatus()!=null && updateVO.getTaskStatus().equals(TaskStatus.PENDING.getCode()) && updateVO.getAssignees()!=null && !updateVO.getAssignees().isEmpty()){
        if(updateVO.getTaskStatus()!=null
                && updateVO.getTaskStatus().equals(TaskStatus.PENDING.getCode())
                && updateVO.getAssignees()!=null && !updateVO.getAssignees().isEmpty()
                && LongUtil.isNotEmpty(dispatchOrderId)){
            this.sendTaskAssigneeEvent(updateVO,task,userId,userName);
        }
        return result;
    }
    private void sendEmeryTaskProcess(SysTask task,Long dispatchOrderId){
        Long taskId = task.getTaskId();
        String taskCode = task.getShowTaskCode();
        if(task.getTaskStatus()!=null && task.getTaskStatus().equals(TaskStatus.PENDING.getCode())){
            //如果没有分配人员,且没有调度单,不是广州总公司的就需要发送通知跟进
            if(LongUtil.isEmpty(dispatchOrderId)){
                if(!task.getDeptId().equals(DeptUtil.GUANGZHOU_DEPT_ID) && (task.getAssignees()==null  || task.getAssignees().isEmpty())){
                    //发送通知
                    eventPublisher.publishEvent(new TaskOnlyServerOrderSyncEvent(this, taskId, taskCode));
                }
            }
        }
    }
    /**
     * 批量删除任务管理
     * 
@@ -1026,7 +1197,14 @@
     */
    @Override
    public List<SysTask> selectMyTasks(Long userId) {
        return sysTaskMapper.selectMyTasks(userId);
        List<SysTask> list = sysTaskMapper.selectMyTasks(userId);
        list.stream().forEach(task -> {
            if(task.getTaskType().equals("EMERGENCY_TRANSFER")){
                task.setEmergencyInfo(sysTaskEmergencyMapper.selectSysTaskEmergencyByTaskId(task.getTaskId()));
            }
        });
        return list;
    }
    /**
@@ -1263,8 +1441,8 @@
        if (createVO.getTransferTime() != null) {
            task.setPlannedStartTime(createVO.getTransferTime());
        }
        if (createVO.getTransferDistance() != null) {
            task.setEstimatedDistance(createVO.getTransferDistance());
        if (createVO.getDistance() != null) {
            task.setEstimatedDistance(createVO.getDistance());
        }
        
        // 设置福祉车特定信息