From 8aa956fed9950c75b7115e44e01b9d41b9241b82 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期四, 10 七月 2025 10:51:23 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamMaintenanceStandardController.java | 96 ++++++++++++++++-------------------------------- 1 files changed, 32 insertions(+), 64 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..0d7d06e 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,22 @@ 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.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.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 +29,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: 淇濆吇鏍囧噯 @@ -239,14 +233,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 +286,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); 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 +322,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"); 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 +357,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"); 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 +375,16 @@ } } + 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