From 6bab142343375e744e46f2042aa3b0fedea70b06 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 19 五月 2026 23:32:55 +0800
Subject: [PATCH] fix: 设备巡检修改

---
 src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java |   55 ++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 42 insertions(+), 13 deletions(-)

diff --git a/src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java b/src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java
index 1c4b48a..bb18e52 100644
--- a/src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java
+++ b/src/main/java/com/ruoyi/inspectiontask/service/impl/InspectionTaskServiceImpl.java
@@ -122,10 +122,10 @@
                         SysUser::getNickName,
                         (existing, replacement) -> existing));
 
-        //澶勭悊闄勪欢
+        //澶勭悊闄勪欢 - 鍙煡璇㈠贰妫�闄勪欢锛坱ype=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<>();
         }
@@ -158,20 +158,11 @@
 
             dto.setDateStr(inspectionTask.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
 
-            // 鍒濆鍖栦笁涓檮浠跺垪琛�
+            // 璁剧疆闄勪欢鍒楄〃 - 缁熶竴浣跨敤 commonFileList
             List<CommonFile> taskFiles = finalCommonFiles.stream()
                     .filter(commonFile -> Objects.equals(commonFile.getCommonId(), inspectionTask.getId()))
                     .collect(Collectors.toList());
-            dto.setCommonFileList(taskFiles.stream()
-                    .filter(commonFile -> Objects.equals(commonFile.getType(), FileNameType.INSPECTION.getValue()))
-                    .collect(Collectors.toList()));
-            dto.setCommonFileListAfter(taskFiles.stream()
-                    .filter(commonFile -> Objects.equals(commonFile.getType(), FileNameType.INSPECTION_PRODUCTION_AFTER.getValue()))
-                    .collect(Collectors.toList()));
-            dto.setCommonFileListBefore(taskFiles.stream()
-                    .filter(commonFile -> Objects.equals(commonFile.getType(), FileNameType.INSPECTION_PRODUCTION_BEFORE.getValue()))
-                    .collect(Collectors.toList()));
-
+            dto.setCommonFileList(taskFiles);
 
             return dto;
         }).collect(Collectors.toList());
@@ -212,6 +203,25 @@
         BeanUtils.copyProperties(inspectionTaskDto, inspectionTask);
         inspectionTask.setRegistrantId(SecurityUtils.getLoginUser().getUserId());
         inspectionTask.setRegistrant(SecurityUtils.getLoginUser().getUsername());
+
+        // 澶勭悊寮傚父鐘舵�佽浆鎹細hasException -> inspectionStatus
+        // hasException = null -> 0(鏈贰妫�), false -> 1(姝e父), 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);
@@ -224,6 +234,25 @@
 
     @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) {

--
Gitblit v1.9.3