| | |
| | | } else { |
| | | sysUserMap = new HashMap<>(); |
| | | } |
| | | //巡检人ids |
| | | List<String> inspectorIds = entityPage.getRecords().stream().map(InspectionTask::getInspectorId).collect(Collectors.toList()); |
| | | |
| | | //获取所有不重复的用户ID |
| | | Set<Long> allUserIds = entityPage.getRecords().stream() |
| | | .map(InspectionTask::getInspectorId) // 获取"2,3"这样的字符串 |
| | |
| | | SysUser::getNickName, |
| | | (existing, replacement) -> existing)); |
| | | |
| | | //处理附件 |
| | | //处理附件 - 只查询巡检附件(type=20) |
| | | 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()))); |
| | | .in(CommonFile::getType, Arrays.asList(FileNameType.INSPECTION.getValue()))); |
| | | if(commonFiles == null){ |
| | | commonFiles = new ArrayList<>(); |
| | | } |
| | |
| | | |
| | | dto.setDateStr(inspectionTask.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | |
| | | // 初始化三个附件列表 |
| | | dto.setCommonFileList(finalCommonFiles.stream().filter(commonFile -> commonFile.getType().equals(FileNameType.INSPECTION.getValue())).collect(Collectors.toList())); |
| | | dto.setCommonFileListAfter(finalCommonFiles.stream().filter(commonFile -> commonFile.getType().equals(FileNameType.INSPECTION_PRODUCTION_AFTER.getValue())).collect(Collectors.toList())); |
| | | dto.setCommonFileListBefore(finalCommonFiles.stream().filter(commonFile -> commonFile.getType().equals(FileNameType.INSPECTION_PRODUCTION_BEFORE.getValue())).collect(Collectors.toList())); |
| | | |
| | | // 设置附件列表 - 统一使用 commonFileList |
| | | List<CommonFile> taskFiles = finalCommonFiles.stream() |
| | | .filter(commonFile -> Objects.equals(commonFile.getCommonId(), inspectionTask.getId())) |
| | | .collect(Collectors.toList()); |
| | | dto.setCommonFileList(taskFiles); |
| | | |
| | | return dto; |
| | | }).collect(Collectors.toList()); |
| | |
| | | BeanUtils.copyProperties(inspectionTaskDto, inspectionTask); |
| | | inspectionTask.setRegistrantId(SecurityUtils.getLoginUser().getUserId()); |
| | | inspectionTask.setRegistrant(SecurityUtils.getLoginUser().getUsername()); |
| | | |
| | | // 处理异常状态转换:hasException -> inspectionStatus |
| | | // hasException = null -> 0(未巡检), false -> 1(正常), true -> 2(异常) |
| | | Boolean hasException = inspectionTaskDto.getHasException(); |
| | | if (hasException != null) { |
| | | inspectionTask.setInspectionStatus(hasException ? 2 : 1); |
| | | // 如果有异常描述,设置异常描述 |
| | | if (hasException && inspectionTaskDto.getInspectionRemark() != null) { |
| | | inspectionTask.setInspectionRemark(inspectionTaskDto.getInspectionRemark()); |
| | | } |
| | | } else { |
| | | inspectionTask.setInspectionStatus(0); |
| | | } |
| | | |
| | | // 重新巡检时,重置验收状态 |
| | | inspectionTask.setAcceptStatus(0); |
| | | inspectionTask.setInspectionAcceptorId(null); |
| | | inspectionTask.setInspectionAcceptor(null); |
| | | |
| | | int i; |
| | | if (Objects.isNull(inspectionTaskDto.getId())) { |
| | | i = inspectionTaskMapper.insert(inspectionTask); |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int acceptInspectionTask(Long id, Integer acceptStatus) { |
| | | InspectionTask task = inspectionTaskMapper.selectById(id); |
| | | if (task == null) { |
| | | throw new RuntimeException("任务不存在"); |
| | | } |
| | | if (task.getInspectionStatus() == null || task.getInspectionStatus() == 0) { |
| | | throw new RuntimeException("该任务尚未巡检,无法验收"); |
| | | } |
| | | task.setInspectionAcceptorId(SecurityUtils.getLoginUser().getUserId()); |
| | | task.setInspectionAcceptor(SecurityUtils.getLoginUser().getUser().getNickName()); |
| | | task.setAcceptStatus(acceptStatus); |
| | | |
| | | // 如果是退回(2),考虑到可能是重新巡检,可以保留之前的巡检记录但状态变为退回 |
| | | // APP端会根据 acceptStatus == 2 来放开巡检按钮 |
| | | return inspectionTaskMapper.updateById(task); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int delByIds(Long[] ids) { |
| | | // 检查参数 |
| | | if (ids == null || ids.length == 0) { |