| | |
| | | import com.ruoyi.system.service.ISysTaskEmergencyService; |
| | | import com.ruoyi.system.service.ITaskAttachmentSyncService; |
| | | import com.ruoyi.system.service.IMapService; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.system.event.TaskCreatedEvent; |
| | | import com.ruoyi.system.event.TaskAssignedEvent; |
| | | import com.ruoyi.system.event.TaskStatusChangedEvent; |
| | |
| | | |
| | | @Autowired(required = false) |
| | | private IMapService mapService; |
| | | |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | |
| | | /** |
| | | * 查询任务管理 |
| | |
| | | } |
| | | } |
| | | |
| | | // 3. 检查执行人是否全部就绪(受配置开关控制) |
| | | String readyCheckEnabled = configService.selectConfigByKey("task.assignee.ready.check.enabled"); |
| | | if ("true".equalsIgnoreCase(readyCheckEnabled)) { |
| | | assignees = task.getAssignees(); |
| | | if (assignees != null && !assignees.isEmpty()) { |
| | | boolean allReady = assignees.stream() |
| | | .allMatch(a -> "1".equals(a.getIsReady())); |
| | | if (!allReady) { |
| | | Map<String, Object> conflict = new HashMap<>(); |
| | | conflict.put("type", "assigneeReady"); |
| | | conflict.put("message", "存在未就绪的执行人,请等待所有执行人点击就绪后再出车"); |
| | | conflicts.add(conflict); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 返回结果 |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("valid", conflicts.isEmpty()); |
| | |
| | | |
| | | return com.ruoyi.common.core.domain.AjaxResult.success(result); |
| | | } |
| | | |
| | | /** |
| | | * 执行人点击就绪 |
| | | * |
| | | * @param taskId 任务ID |
| | | * @param userId 用户ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public com.ruoyi.common.core.domain.AjaxResult setAssigneeReady(Long taskId, Long userId) { |
| | | // 1. 查询执行人关联信息 |
| | | List<SysTaskAssignee> assignees = sysTaskAssigneeMapper.selectSysTaskAssigneeByTaskId(taskId); |
| | | SysTaskAssignee targetAssignee = assignees.stream() |
| | | .filter(a -> a.getUserId().equals(userId)) |
| | | .findFirst() |
| | | .orElse(null); |
| | | |
| | | if (targetAssignee == null) { |
| | | return com.ruoyi.common.core.domain.AjaxResult.error("您不是该任务的执行人"); |
| | | } |
| | | |
| | | // 2. 更新就绪状态 |
| | | targetAssignee.setIsReady("1"); |
| | | targetAssignee.setReadyTime(new Date()); |
| | | targetAssignee.setUpdateBy(SecurityUtils.getUsername()); |
| | | targetAssignee.setUpdateTime(new Date()); |
| | | |
| | | sysTaskAssigneeMapper.updateSysTaskAssignee(targetAssignee); |
| | | |
| | | // 3. 检查是否所有执行人都已就绪 |
| | | boolean allReady = assignees.stream() |
| | | .allMatch(a -> a.getUserId().equals(userId) || "1".equals(a.getIsReady())); |
| | | |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("allReady", allReady); |
| | | result.put("message", "就绪成功"); |
| | | |
| | | return com.ruoyi.common.core.domain.AjaxResult.success(result); |
| | | } |
| | | |
| | | /** |
| | | * 取消执行人就绪 |
| | | * |
| | | * @param taskId 任务ID |
| | | * @param userId 用户ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public com.ruoyi.common.core.domain.AjaxResult cancelAssigneeReady(Long taskId, Long userId) { |
| | | // 查询执行人关联信息 |
| | | List<SysTaskAssignee> assignees = sysTaskAssigneeMapper.selectSysTaskAssigneeByTaskId(taskId); |
| | | SysTaskAssignee targetAssignee = assignees.stream() |
| | | .filter(a -> a.getUserId().equals(userId)) |
| | | .findFirst() |
| | | .orElse(null); |
| | | |
| | | if (targetAssignee == null) { |
| | | return com.ruoyi.common.core.domain.AjaxResult.error("您不是该任务的执行人"); |
| | | } |
| | | |
| | | // 更新就绪状态 |
| | | targetAssignee.setIsReady("0"); |
| | | targetAssignee.setReadyTime(null); |
| | | targetAssignee.setUpdateBy(SecurityUtils.getUsername()); |
| | | targetAssignee.setUpdateTime(new Date()); |
| | | |
| | | sysTaskAssigneeMapper.updateSysTaskAssignee(targetAssignee); |
| | | |
| | | return com.ruoyi.common.core.domain.AjaxResult.success("已取消就绪"); |
| | | } |
| | | |
| | | } |