| | |
| | | //处理附件 |
| | | List<CommonFile> commonFiles = commonFileMapper.selectList(new LambdaQueryWrapper<CommonFile>() |
| | | .in(CommonFile::getCommonId, ids) |
| | | .in(CommonFile::getType, Arrays.asList(FileNameType.INSPECTION.getValue(), FileNameType.INSPECTION_PRODUCTION_BEFORE.getValue(), FileNameType.INSPECTION_PRODUCTION_AFTER.getValue()))); |
| | | .eq(CommonFile::getType, FileNameType.INSPECTION.getValue())); |
| | | if(commonFiles == null){ |
| | | commonFiles = new ArrayList<>(); |
| | | } |
| | |
| | | |
| | | dto.setDateStr(inspectionTask.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | |
| | | // 初始化三个附件列表,按commonId和type过滤 |
| | | // 初始化附件列表 |
| | | Long taskId = inspectionTask.getId(); |
| | | dto.setCommonFileList(finalCommonFiles.stream() |
| | | .filter(commonFile -> commonFile.getCommonId().equals(taskId) && commonFile.getType().equals(FileNameType.INSPECTION.getValue())) |
| | | .collect(Collectors.toList())); |
| | | dto.setCommonFileListAfter(finalCommonFiles.stream() |
| | | .filter(commonFile -> commonFile.getCommonId().equals(taskId) && commonFile.getType().equals(FileNameType.INSPECTION_PRODUCTION_AFTER.getValue())) |
| | | .collect(Collectors.toList())); |
| | | dto.setCommonFileListBefore(finalCommonFiles.stream() |
| | | .filter(commonFile -> commonFile.getCommonId().equals(taskId) && commonFile.getType().equals(FileNameType.INSPECTION_PRODUCTION_BEFORE.getValue())) |
| | | .filter(commonFile -> commonFile.getCommonId().equals(taskId)) |
| | | .collect(Collectors.toList())); |
| | | |
| | | // 计算状态:已过期 > 巡检中 > 待巡检 |
| | |
| | | |
| | | /** |
| | | * 计算巡检任务状态 |
| | | * 优先级:已完成巡检 > 巡检中(已过期) > 巡检中 > 已过期 > 待巡检 |
| | | * @param inspectionTask 巡检任务 |
| | | * @param timingTaskMap 定时任务Map |
| | | * @param now 当前时间 |
| | | * @return 状态:COMPLETED-已完成巡检,IN_PROGRESS_EXPIRED-巡检中(已过期),IN_PROGRESS-巡检中,EXPIRED-已过期,PENDING-待巡检 |
| | | * @return COMPLETED-已完成巡检,EXPIRED-已过期,PENDING-待巡检 |
| | | */ |
| | | private String calculateStatus(InspectionTask inspectionTask, Map<Long, TimingTask> timingTaskMap, LocalDateTime now) { |
| | | if(inspectionTask.getTimingTaskId() == null){ |
| | |
| | | } |
| | | } |
| | | |
| | | // 1. 判断是否已完成巡检(三个异常字段都不为null) |
| | | if (inspectionTask.getHasExceptionBefore() != null |
| | | && inspectionTask.getHasExceptionAfter() != null |
| | | && inspectionTask.getHasExceptionIssue() != null) { |
| | | // 1. 判断是否已完成巡检 |
| | | if (inspectionTask.getHasException() != null) { |
| | | return "COMPLETED"; |
| | | } |
| | | |
| | | // 2. 判断是否巡检中(任一异常字段不为null) |
| | | if (inspectionTask.getHasExceptionBefore() != null |
| | | || inspectionTask.getHasExceptionAfter() != null |
| | | || inspectionTask.getHasExceptionIssue() != null) { |
| | | return isExpired ? "IN_PROGRESS_EXPIRED" : "IN_PROGRESS"; |
| | | } |
| | | |
| | | // 3. 已过期 |
| | |
| | | * 处理附件删除逻辑:对比原有附件和传入的附件,删除被移除的附件 |
| | | */ |
| | | private void handleFileDeletion(Long taskId, InspectionTaskDto inspectionTaskDto) { |
| | | // 查询原有的三种类型附件 |
| | | List<CommonFile> existingFiles = commonFileMapper.selectList(new LambdaQueryWrapper<CommonFile>() |
| | | .eq(CommonFile::getCommonId, taskId) |
| | | .in(CommonFile::getType, Arrays.asList( |
| | | FileNameType.INSPECTION.getValue(), |
| | | FileNameType.INSPECTION_PRODUCTION_BEFORE.getValue(), |
| | | FileNameType.INSPECTION_PRODUCTION_AFTER.getValue()))); |
| | | .eq(CommonFile::getType, FileNameType.INSPECTION.getValue())); |
| | | |
| | | if (CollectionUtils.isEmpty(existingFiles)) { |
| | | return; |
| | |
| | | Set<Long> submittedFileIds = new HashSet<>(); |
| | | if (inspectionTaskDto.getCommonFileList() != null) { |
| | | inspectionTaskDto.getCommonFileList().stream() |
| | | .map(CommonFile::getId) |
| | | .filter(Objects::nonNull) |
| | | .forEach(submittedFileIds::add); |
| | | } |
| | | if (inspectionTaskDto.getCommonFileListBefore() != null) { |
| | | inspectionTaskDto.getCommonFileListBefore().stream() |
| | | .map(CommonFile::getId) |
| | | .filter(Objects::nonNull) |
| | | .forEach(submittedFileIds::add); |
| | | } |
| | | if (inspectionTaskDto.getCommonFileListAfter() != null) { |
| | | inspectionTaskDto.getCommonFileListAfter().stream() |
| | | .map(CommonFile::getId) |
| | | .filter(Objects::nonNull) |
| | | .forEach(submittedFileIds::add); |
| | |
| | | return 0; |
| | | } |
| | | commonFileService.deleteByBusinessIds(Arrays.asList(ids),FileNameType.INSPECTION.getValue()); |
| | | commonFileService.deleteByBusinessIds(Arrays.asList(ids),FileNameType.INSPECTION_PRODUCTION_BEFORE.getValue()); |
| | | commonFileService.deleteByBusinessIds(Arrays.asList(ids),FileNameType.INSPECTION_PRODUCTION_AFTER.getValue()); |
| | | return inspectionTaskMapper.deleteBatchIds(Arrays.asList(ids)); |
| | | } |
| | | |