| | |
| | | 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.*; |
| | |
| | | @Autowired |
| | | private ISysTaskAttachmentService sysTaskAttachmentService; |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private SysUserMapper sysUserMapper; |
| | | private ISysDeptService deptService; |
| | | |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Autowired(required = false) |
| | | private IMapService mapService; |
| | |
| | | @Override |
| | | public Boolean dispatchSyncEvent(Long taskId) { |
| | | SysTask task= sysTaskMapper.selectSysTaskByTaskId(taskId); |
| | | SysUser user= sysUserMapper.selectUserById(task.getCreatorId()); |
| | | 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); |
| | | } |
| | | /** |
| | | * 查询任务管理 |
| | | * |
| | |
| | | public SysTask selectSysTaskByTaskId(Long taskId) { |
| | | SysTask task = sysTaskMapper.selectSysTaskByTaskId(taskId); |
| | | if (task != null) { |
| | | |
| | | // 加载急救转运扩展信息 |
| | | if ("EMERGENCY_TRANSFER".equals(task.getTaskType())) { |
| | | SysTaskEmergency emergencyInfo = sysTaskEmergencyMapper.selectSysTaskEmergencyByTaskId(taskId); |
| | |
| | | public List<SysTask> selectSysTaskList(TaskQueryVO 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; |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | // 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); |
| | |
| | | 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(); |
| | |
| | | task.setUpdateTime(DateUtils.getNowDate()); |
| | | task.setRemark(createVO.getRemark()); |
| | | task.setDelFlag("0"); |
| | | |
| | | task.setIsHeadPush(isTaskHeaderPush(userId,task.getDeptId())?"1":"0"); |
| | | |
| | | // 设置地址和坐标信息 |
| | | setAddressAndCoordinatesFromVO(task, createVO); |
| | |
| | | task.setUpdateBy(userName); |
| | | task.setRemark(createVO.getRemark()); |
| | | task.setDelFlag("0"); |
| | | |
| | | Boolean isHeadPush=this.isTaskHeaderPush(userId, deptId); |
| | | if(isHeadPush){ |
| | | task.setIsHeadPush("1"); |
| | | }else{ |
| | | task.setIsHeadPush("0"); |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | task.setUpdateTime(updateVO.getUpdateTime() != null ? updateVO.getUpdateTime() : DateUtils.getNowDate()); |
| | | task.setRemark(updateVO.getRemark()); |
| | | |
| | | |
| | | |
| | | // 设置通用地址和坐标信息 |
| | | task.setDepartureAddress(updateVO.getDepartureAddress()); |
| | | task.setDestinationAddress(updateVO.getDestinationAddress()); |
| | |
| | | // 如果更新了部门ID |
| | | if (updateVO.getDeptId() != null) { |
| | | task.setDeptId(updateVO.getDeptId()); |
| | | }else{ |
| | | task.setDeptId(oldTask.getDeptId()); |
| | | } |
| | | |
| | | // 如果更新了任务编号 |
| | | if (updateVO.getTaskCode() != null) { |
| | | task.setTaskCode(updateVO.getTaskCode()); |
| | | } |
| | | |
| | | //设置总部推送 |
| | | task.setIsHeadPush(this.isTaskHeaderPush(oldTask.getCreatorId(), task.getDeptId())?"1":"0"); |
| | | // 自动获取出发地GPS坐标(如果更新了地址但缺失坐标) |
| | | if (updateVO.getDepartureAddress() != null && |
| | | (updateVO.getDepartureLongitude() == null || updateVO.getDepartureLatitude() == null) && |
| | |
| | | task.setAssigneeName(assigneeInfo.getUserName()); |
| | | } |
| | | // 用于跟踪是否需要重新同步(车辆、人员、地址、成交价变更) |
| | | boolean needResync = false; |
| | | boolean needResync = true; |
| | | int result = sysTaskMapper.updateSysTask(task); |
| | | |
| | | |
| | |
| | | userId, userName); |
| | | } |
| | | |
| | | if(result > 0 && oldTask.getTaskStatus().equals(TaskStatus.PENDING.getCode()) && updateVO.getAssignees() != null && !updateVO.getAssignees().isEmpty() && dispatchOrderId>0L){ |
| | | if(result > 0 && oldTask.getTaskStatus().equals(TaskStatus.PENDING.getCode()) |
| | | && updateVO.getAssignees() != null |
| | | && !updateVO.getAssignees().isEmpty() |
| | | && LongUtil.isNotEmpty(dispatchOrderId)){ |
| | | |
| | | this.sendTaskAssigneeEvent(updateVO,oldTask,userId,userName); |
| | | } |
| | |
| | | Long userId, String userName, Long deptId, Date createTime, Date updateTime) { |
| | | // log.info("开始更新任务 ServiceOrdID: {} , dispatchOrdId:{}", serviceOrderId,dispatchOrderId); |
| | | // 通过旧系统服务单ID查找任务 |
| | | // 获取旧任务信息,用于判断地址是否变更 |
| | | |
| | | |
| | | 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()); |
| | | } |
| | |
| | | if(updateVO.getActualEndTime() != null) { |
| | | task.setActualEndTime(updateVO.getActualEndTime()); |
| | | } |
| | | if(deptId!=null){ |
| | | task.setDeptId(deptId); |
| | | } |
| | | |
| | | |
| | | // task.setAssigneeId(updateVO.getAssigneeId()); |
| | | task.setUpdateBy(userName); |
| | | task.setUpdateTime(DateUtils.getNowDate()); |
| | |
| | | |
| | | |
| | | // 设置地址和坐标信息 |
| | | 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.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 { |
| | |
| | | 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 { |
| | |
| | | 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); |
| | |
| | | dispatchOrderId = emergency.getLegacyDispatchOrdId(); |
| | | } |
| | | |
| | | if(updateVO.getTaskStatus()!=null && updateVO.getTaskStatus().equals(TaskStatus.PENDING.getCode()) && updateVO.getAssignees()!=null && !updateVO.getAssignees().isEmpty() && dispatchOrderId>0L){ |
| | | 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); |
| | | } |
| | | |
| | |
| | | if(task.getTaskStatus()!=null && task.getTaskStatus().equals(TaskStatus.PENDING.getCode())){ |
| | | //如果没有分配人员,且没有调度单,不是广州总公司的就需要发送通知跟进 |
| | | if(LongUtil.isEmpty(dispatchOrderId)){ |
| | | if(!task.getDeptId().equals(DeptUtil.GUANGZHOU_DEPT_ID) && task.getAssignees().isEmpty()){ |
| | | if(!task.getDeptId().equals(DeptUtil.GUANGZHOU_DEPT_ID) && (task.getAssignees()==null || task.getAssignees().isEmpty())){ |
| | | //发送通知 |
| | | eventPublisher.publishEvent(new TaskOnlyServerOrderSyncEvent(this, taskId, taskCode)); |
| | | |
| | |
| | | public List<SysTask> selectMyTasks(Long userId) { |
| | | List<SysTask> list = sysTaskMapper.selectMyTasks(userId); |
| | | list.stream().forEach(task -> { |
| | | |
| | | if(task.getTaskType().equals("EMERGENCY_TRANSFER")){ |
| | | task.setEmergencyInfo(sysTaskEmergencyMapper.selectSysTaskEmergencyByTaskId(task.getTaskId())); |
| | | } |