buhuazhen
14 小时以前 b801ae3807276a960b205bf2e51b1f934cd605ac
feat 设备巡检 调整为一次性完成
已修改4个文件
66 ■■■■ 文件已修改
src/main/java/com/ruoyi/common/enums/FileNameType.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/inspectiontask/dto/InspectionTaskDto.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/inspectiontask/pojo/InspectionTask.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/common/enums/FileNameType.java
@@ -12,9 +12,7 @@
    ApproveNode(7),  //协同审批节点审核
    ApproveProcess(8),//协同审批主数据
    SHIP(9),//发货台账
    INSPECTION_PRODUCTION_BEFORE(10),
    INSPECTION_PRODUCTION_AFTER(11),
    INSPECTION(12);//巡检 生产前
    INSPECTION(10);//巡检
    private final int value;
src/main/java/com/ruoyi/inspectiontask/dto/InspectionTaskDto.java
@@ -20,9 +20,7 @@
//    private List<StorageAttachment> attachments;
    private List<String> tempFileIds;
    private List<CommonFile> commonFileList; //生产中
    private List<CommonFile> commonFileListAfter;  //生产后
    private List<CommonFile> commonFileListBefore; //生产前
    private List<CommonFile> commonFileList;
    /**
     * 要求的执行时间(来自定时任务的nextExecutionTime)
src/main/java/com/ruoyi/inspectiontask/pojo/InspectionTask.java
@@ -98,12 +98,6 @@
    @ApiModelProperty(value = "关联定时任务ID")
    private Long timingTaskId;
    @ApiModelProperty(value = "生产前是否存在异常")
    private Boolean hasExceptionBefore;
    @ApiModelProperty(value = "生产中是否存在异常")
    private Boolean hasExceptionAfter;
    @ApiModelProperty(value = "生产后是否存在异常")
    private Boolean hasExceptionIssue;
    @ApiModelProperty(value = "是否存在异常")
    private Boolean hasException;
}
src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java
@@ -134,7 +134,7 @@
        //处理附件
        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<>();
        }
@@ -181,16 +181,10 @@
            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()));
            // 计算状态:已过期 > 巡检中 > 待巡检
@@ -239,11 +233,10 @@
    /**
     * 计算巡检任务状态
     * 优先级:已完成巡检 > 巡检中(已过期) > 巡检中 > 已过期 > 待巡检
     * @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){
@@ -258,18 +251,9 @@
            }
        }
        // 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. 已过期
@@ -305,13 +289,9 @@
     * 处理附件删除逻辑:对比原有附件和传入的附件,删除被移除的附件
     */
    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;
@@ -321,18 +301,6 @@
        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);
@@ -358,8 +326,6 @@
            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));
    }