From 40bf019f0b348378385ed0a819b5b06e1708d558 Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期六, 09 八月 2025 00:19:37 +0800
Subject: [PATCH] 工作流代码

---
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamMaintenanceStandardController.java |  134 ++++++++++++++++++++++----------------------
 1 files changed, 68 insertions(+), 66 deletions(-)

diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamMaintenanceStandardController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamMaintenanceStandardController.java
index cfc3b53..001f12d 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamMaintenanceStandardController.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamMaintenanceStandardController.java
@@ -6,26 +6,24 @@
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.constant.CommonConstant;
-import org.jeecg.common.exception.JeecgBootException;
+
 import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.eam.constant.BusinessCodeConst;
-import org.jeecg.modules.eam.constant.MaintenanceCategoryEnum;
+
 import org.jeecg.modules.eam.constant.MaintenanceStandardStatusEnum;
 import org.jeecg.modules.eam.entity.EamMaintenanceStandard;
-import org.jeecg.modules.eam.entity.EamMaintenanceStandardDetail;
+
 import org.jeecg.modules.eam.request.EamMaintenanceStandardRequest;
 import org.jeecg.modules.eam.service.IEamEquipmentService;
 import org.jeecg.modules.eam.service.IEamMaintenanceStandardService;
 import org.jeecg.modules.eam.vo.EamMaintenanceStandardVo;
 import org.jeecg.modules.system.service.ISysBusinessCodeRuleService;
-import org.jeecgframework.poi.excel.ExcelImportUtil;
-import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -33,10 +31,8 @@
 import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
 import java.util.*;
-import java.util.stream.Collectors;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * @Description: 淇濆吇鏍囧噯
@@ -53,8 +49,6 @@
     private IEamMaintenanceStandardService eamMaintenanceStandardService;
     @Autowired
     private ISysBusinessCodeRuleService businessCodeRuleService;
-    @Autowired
-    private IEamEquipmentService eamEquipmentService;
 
     /**
      * 娴佺▼鍚姩,淇濆瓨瀵瑰簲鐨勬暟鎹�
@@ -65,6 +59,11 @@
     @ApiOperation(value = "淇濆吇鏍囧噯-娴佺▼鍚姩淇濆瓨瀵瑰簲鐨勬暟鎹�", notes = "淇濆吇鏍囧噯-娴佺▼鍚姩淇濆瓨瀵瑰簲鐨勬暟鎹�")
     @GetMapping(value = "/saveEamMaintenanceStandardProcess")
     public Result<?> saveEamMaintenanceStandardProcess(String id) {
+        // 鏍¢獙棰嗗彇鏉冮檺
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        if (!BusinessCodeConst.PCR0002.equals(user.getPost())) {
+            return Result.error("濉姤澶辫触,娌℃湁濉姤鏉冮檺锛�,闇�缁翠慨宸ユ彁浜�");
+        }
         return eamMaintenanceStandardService.saveEamMaintenanceStandardProcess(id);
     }
 
@@ -239,14 +238,17 @@
     @DeleteMapping(value = "/deleteBatch")
     public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
         List<String> list = Arrays.asList(ids.split(","));
+        AtomicInteger i = new AtomicInteger();
         list.forEach(id -> {
             EamMaintenanceStandard entity = eamMaintenanceStandardService.getById(id);
-            if (entity != null) {
+            if (entity != null&&entity.getStandardStatus().equals(MaintenanceStandardStatusEnum.WAIT_SUBMIT.name())) {
+                //鍙垹闄ょ姸鎬佷负寰呮彁浜ょ殑
+                i.getAndIncrement();
                 entity.setDelFlag(CommonConstant.DEL_FLAG_1);
                 eamMaintenanceStandardService.updateById(entity);
             }
         });
-        return Result.OK("鎵归噺鍒犻櫎鎴愬姛锛�");
+        return Result.OK("鎵归噺鍒犻櫎鎴愬姛,宸插垹闄ょ姸鎬佷负寰呮彁浜ょ殑淇濆吇鏍囧噯锛屽垹闄ゆ暟閲忎负"+i);
     }
 
     /**
@@ -289,32 +291,17 @@
             for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
                 MultipartFile file = entity.getValue();
                 String fileName = file.getOriginalFilename();
-
-                Result<?> importResult = eamMaintenanceStandardService.importPointInspectionExcel(file);
-
+                Result<?> importResult=eamMaintenanceStandardService.importPointInspectionExcel(file,null);
                 if (importResult.isSuccess()) {
-                    results.put(fileName, "鎴愬姛: " + importResult.getMessage());
                     successCount++;
                 } else {
-                    results.put(fileName, "澶辫触: " + importResult.getMessage());
+                    results.put(fileName, importResult.getMessage());
                     failureCount++;
                 }
             }
 
-            // 鏋勫缓鍝嶅簲
-            Map<String, Object> response = new HashMap<>();
-            response.put("results", results);
-            response.put("totalFiles", fileMap.size());
-            response.put("successCount", successCount);
-            response.put("failureCount", failureCount);
-
-            if (failureCount == 0) {
-                return Result.ok("鎵�鏈夌偣妫�鏂囦欢瀵煎叆鎴愬姛"+response);
-            } else if (successCount == 0) {
-                return Result.error("鎵�鏈夌偣妫�鏂囦欢瀵煎叆澶辫触", response);
-            } else {
-                return Result.error("閮ㄥ垎鐐规鏂囦欢瀵煎叆澶辫触", response);
-            }
+            // 鏋勫缓鏈�缁堝搷搴�
+            return getResult(results, fileMap.size(), successCount, failureCount);
 
         } catch (Exception e) {
             log.error("鐐规瀵煎叆澶勭悊寮傚父", e);
@@ -340,30 +327,17 @@
             for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
                 MultipartFile file = entity.getValue();
                 String fileName = file.getOriginalFilename();
-
-                Result<?> importResult = eamMaintenanceStandardService.importMaintenanceStandard(file, "SECOND");
-
+                Result<?> importResult=eamMaintenanceStandardService.importMaintenanceStandard(file, "SECOND",null);
                 if (importResult.isSuccess()) {
-                    results.put(fileName, "鎴愬姛: " + importResult.getMessage());
                     successCount++;
                 } else {
-                    results.put(fileName, "澶辫触: " + importResult.getMessage());
+                    results.put(fileName, importResult.getMessage());
                     failureCount++;
                 }
             }
 
             // 鏋勫缓鏈�缁堝搷搴�
-            Map<String, Object> response = new HashMap<>();
-            response.put("results", results);
-            response.put("totalFiles", fileMap.size());
-            response.put("successCount", successCount);
-            response.put("failureCount", failureCount);
-
-            if (failureCount > 0) {
-                return Result.error("閮ㄥ垎鏂囦欢瀵煎叆澶辫触", response);
-            }
-
-            return Result.ok("鎵�鏈夋枃浠跺鍏ユ垚鍔�"+response);
+            return getResult(results, fileMap.size(), successCount, failureCount);
 
         } catch (Exception e) {
             log.error("瀵煎叆澶勭悊寮傚父", e);
@@ -388,30 +362,17 @@
             for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
                 MultipartFile file = entity.getValue();
                 String fileName = file.getOriginalFilename();
-
-                Result<?> importResult = eamMaintenanceStandardService.importMaintenanceStandard(file, "THIRD");
-
+                Result<?> importResult= eamMaintenanceStandardService.importMaintenanceStandard(file, "THIRD",null);
                 if (importResult.isSuccess()) {
-                    results.put(fileName, "鎴愬姛: " + importResult.getMessage());
                     successCount++;
                 } else {
-                    results.put(fileName, "澶辫触: " + importResult.getMessage());
+                    results.put(fileName, importResult.getMessage());
                     failureCount++;
                 }
             }
 
             // 鏋勫缓鏈�缁堝搷搴�
-            Map<String, Object> response = new HashMap<>();
-            response.put("results", results);
-            response.put("totalFiles", fileMap.size());
-            response.put("successCount", successCount);
-            response.put("failureCount", failureCount);
-
-            if (failureCount > 0) {
-                return Result.error("閮ㄥ垎鏂囦欢瀵煎叆澶辫触", response);
-            }
-
-            return Result.ok("鎵�鏈夋枃浠跺鍏ユ垚鍔�"+response);
+            return getResult(results, fileMap.size(), successCount, failureCount);
 
         } catch (Exception e) {
             log.error("瀵煎叆澶勭悊寮傚父", e);
@@ -419,4 +380,45 @@
         }
     }
 
+    /**
+     * 鍗囩増瀵煎叆
+     * @param id,file
+     * @return
+     */
+    @ApiOperation(value = "鍗囩増瀵煎叆", notes = "鍗囩増瀵煎叆")
+    @PostMapping(value = "/importUpgrade")
+    public Result<?> importUpgrade(String id,MultipartFile file) {
+        EamMaintenanceStandard eamMaintenanceStandard=eamMaintenanceStandardService.getById(id);
+        if (eamMaintenanceStandard==null) {
+            return Result.error("璇烽�夋嫨闇�瑕佸崌鐗堢殑淇濆吇鏍囧噯");
+        }else {
+            switch (eamMaintenanceStandard.getMaintenanceCategory()){
+                case "POINT_INSPECTION":
+                    //鐐规鍗囩増瀵煎叆
+                    return eamMaintenanceStandardService.importPointInspectionExcel(file,id);
+                case "SECOND_MAINTENANCE":
+                    //浜屼繚鍗囩増瀵煎叆
+                    return eamMaintenanceStandardService.importMaintenanceStandard(file, "SECOND",id);
+                case "THIRD_MAINTENANCE":
+                    //涓変繚鍗囩増瀵煎叆
+                    return eamMaintenanceStandardService.importMaintenanceStandard(file, "THIRD",id);
+                default:
+                    break;
+            }
+        }
+        return Result.error("鍗囩増瀵煎叆澶辫触");
+    }
+
+    private Result<?> getResult(Map<String, String> results, int fileCount, int successCount, int failureCount) {
+        List<String> response = new ArrayList<>();
+        response.add("鎬绘枃浠舵暟锛�" + fileCount);
+        response.add("鎴愬姛鏁帮細" + successCount);
+        response.add("澶辫触鏁帮細" + failureCount);
+        if (failureCount > 0) {
+            response.add("閿欒淇℃伅锛�" + results.values());
+            return Result.error("閮ㄥ垎鏂囦欢瀵煎叆澶辫触锛�" + response);
+        }
+        return Result.ok("鎵�鏈夋枃浠跺鍏ユ垚鍔燂細" + response);
+    }
+
 }

--
Gitblit v1.9.3