From 4d46a2bda9d7c7008d5542fcb1bdde4ffcb5fa09 Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期四, 04 九月 2025 10:49:36 +0800 Subject: [PATCH] 保养规范修改导入与返回值 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamMaintenanceStandardController.java | 122 +++++++++++++++++++++++++++++++++++++++- 1 files changed, 117 insertions(+), 5 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 0d7d06e..59099a6 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 @@ -7,11 +7,13 @@ import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +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.system.base.controller.JeecgController; +import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.eam.constant.BusinessCodeConst; import org.jeecg.modules.eam.constant.MaintenanceStandardStatusEnum; @@ -47,8 +49,6 @@ private IEamMaintenanceStandardService eamMaintenanceStandardService; @Autowired private ISysBusinessCodeRuleService businessCodeRuleService; - @Autowired - private IEamEquipmentService eamEquipmentService; /** * 娴佺▼鍚姩,淇濆瓨瀵瑰簲鐨勬暟鎹� @@ -59,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); } @@ -286,7 +291,7 @@ 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()) { successCount++; } else { @@ -318,17 +323,49 @@ // 缁熻瀵煎叆缁撴灉 int successCount = 0; int failureCount = 0; + Result<?> importResult = new Result<>(); + + // 鐢ㄤ簬鏀堕泦鎵�鏈夋湭鎵惧埌鐨勮澶囩紪鐮� + List<String> allNotFoundCodes = new ArrayList<>(); for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { MultipartFile file = entity.getValue(); String fileName = file.getOriginalFilename(); - Result<?> importResult=eamMaintenanceStandardService.importMaintenanceStandard(file, "SECOND"); + importResult = eamMaintenanceStandardService.importMaintenanceStandard(file, "SECOND", null); + if (importResult.isSuccess()) { + // 妫�鏌ユ槸鍚﹀寘鍚儴鍒嗘垚鍔熶俊鎭� + String message = importResult.getMessage(); + if (message.contains("浠ヤ笅璁惧缂栫爜鏈壘鍒帮細")) { + // 鎻愬彇鏈壘鍒扮殑璁惧缂栫爜 + String notFoundPart = message.substring(message.indexOf("浠ヤ笅璁惧缂栫爜鏈壘鍒�") + 9); + allNotFoundCodes.addAll(Arrays.asList(notFoundPart.split(", "))); + + // 淇敼涓洪儴鍒嗘垚鍔熸秷鎭� + importResult.setMessage(message.substring(0, message.indexOf("锛涗絾"))); + } successCount++; } else { results.put(fileName, importResult.getMessage()); failureCount++; } + } + + // 濡傛灉鏈夋湭鎵惧埌鐨勮澶囩紪鐮侊紝娣诲姞鍒版渶缁堢粨鏋� + if (!allNotFoundCodes.isEmpty()) { + String notFoundMsg = "浠ヤ笅璁惧缂栫爜鏈壘鍒�" + String.join(", ", allNotFoundCodes); + if (successCount > 0) { + // 閮ㄥ垎鎴愬姛 + return Result.ok("閮ㄥ垎瀵煎叆鎴愬姛锛屾垚鍔熸枃浠舵暟锛�" + successCount + + "锛屽け璐ユ枃浠舵暟锛�" + failureCount + "锛�" + notFoundMsg); + } else { + // 鍏ㄩ儴澶辫触 + return Result.error("瀵煎叆澶辫触锛�" + notFoundMsg); + } + } + + if (successCount == 1) { + return importResult; } // 鏋勫缓鏈�缁堝搷搴� @@ -353,17 +390,50 @@ // 缁熻瀵煎叆缁撴灉 int successCount = 0; int failureCount = 0; + Result<?> importResult = new Result<>(); + + // 鐢ㄤ簬鏀堕泦鎵�鏈夋湭鎵惧埌鐨勮澶囩紪鐮� + List<String> allNotFoundCodes = new ArrayList<>(); for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { MultipartFile file = entity.getValue(); String fileName = file.getOriginalFilename(); - Result<?> importResult= eamMaintenanceStandardService.importMaintenanceStandard(file, "THIRD"); + // 淇锛氫笁淇濆鍏ュ簲璇ヤ娇鐢�"THIRD"绫诲瀷 + importResult = eamMaintenanceStandardService.importMaintenanceStandard(file, "THIRD", null); + if (importResult.isSuccess()) { + // 妫�鏌ユ槸鍚﹀寘鍚儴鍒嗘垚鍔熶俊鎭� + String message = importResult.getMessage(); + if (message.contains("浠ヤ笅璁惧缂栫爜鏈壘鍒帮細")) { + // 鎻愬彇鏈壘鍒扮殑璁惧缂栫爜 + String notFoundPart = message.substring(message.indexOf("浠ヤ笅璁惧缂栫爜鏈壘鍒�") + 9); + allNotFoundCodes.addAll(Arrays.asList(notFoundPart.split(", "))); + + // 淇敼涓洪儴鍒嗘垚鍔熸秷鎭� + importResult.setMessage(message.substring(0, message.indexOf("锛涗絾"))); + } successCount++; } else { results.put(fileName, importResult.getMessage()); failureCount++; } + } + + // 濡傛灉鏈夋湭鎵惧埌鐨勮澶囩紪鐮侊紝娣诲姞鍒版渶缁堢粨鏋� + if (!allNotFoundCodes.isEmpty()) { + String notFoundMsg = "浠ヤ笅璁惧缂栫爜鏈壘鍒�" + String.join(", ", allNotFoundCodes); + if (successCount > 0) { + // 閮ㄥ垎鎴愬姛 + return Result.ok("閮ㄥ垎瀵煎叆鎴愬姛锛屾垚鍔熸枃浠舵暟锛�" + successCount + + "锛屽け璐ユ枃浠舵暟锛�" + failureCount + "锛�" + notFoundMsg); + } else { + // 鍏ㄩ儴澶辫触 + return Result.error("瀵煎叆澶辫触锛�" + notFoundMsg); + } + } + + if (successCount == 1) { + return importResult; } // 鏋勫缓鏈�缁堝搷搴� @@ -375,6 +445,48 @@ } } + /** + * 鍗囩増瀵煎叆 + */ + @PostMapping(value = "/importUpgrade") + public Result<?> importUpgrade(String id, MultipartFile file) { + EamMaintenanceStandard eamMaintenanceStandard = eamMaintenanceStandardService.getById(id); + if (eamMaintenanceStandard == null) { + return Result.error("璇烽�夋嫨闇�瑕佸崌鐗堢殑淇濆吇鏍囧噯"); + } else { + Result<?> importResult; + switch (eamMaintenanceStandard.getMaintenanceCategory()) { + case "POINT_INSPECTION": + // 鐐规鍗囩増瀵煎叆 + importResult = eamMaintenanceStandardService.importPointInspectionExcel(file, id); + break; + case "SECOND_MAINTENANCE": + // 浜屼繚鍗囩増瀵煎叆 + importResult = eamMaintenanceStandardService.importMaintenanceStandard(file, "SECOND", id); + break; + case "THIRD_MAINTENANCE": + // 涓変繚鍗囩増瀵煎叆 + importResult = eamMaintenanceStandardService.importMaintenanceStandard(file, "THIRD", id); + break; + default: + return Result.error("涓嶆敮鎸佺殑淇濆吇绫诲瀷"); + } + + // 澶勭悊鍗囩増瀵煎叆涓殑璁惧鏈壘鍒版儏鍐� + if (importResult.isSuccess()) { + String message = importResult.getMessage(); + if (message.contains("浠ヤ笅璁惧缂栫爜鏈壘鍒帮細")) { + // 鎻愬彇鏈壘鍒扮殑璁惧缂栫爜 + String notFoundPart = message.substring(message.indexOf("浠ヤ笅璁惧缂栫爜鏈壘鍒�") + 9); + return Result.error("鍗囩増瀵煎叆澶辫触锛�" + notFoundPart); + } + return importResult; + } else { + return importResult; + } + } + } + private Result<?> getResult(Map<String, String> results, int fileCount, int successCount, int failureCount) { List<String> response = new ArrayList<>(); response.add("鎬绘枃浠舵暟锛�" + fileCount); -- Gitblit v1.9.3