diff --git a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java index 9fc6b568..f6f151bb 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java @@ -59,7 +59,8 @@ import java.util.stream.Collectors; @RequestMapping("/resource") @Api(tags = "资源表") public class ResourceController { - private Integer cpuNUm = Runtime.getRuntime().availableProcessors(); + private static Integer cpuNUm = Runtime.getRuntime().availableProcessors(); + private static final ExecutorService executor = Executors.newFixedThreadPool(cpuNUm); @Value("${big_date.name}") private String bigDateDeptName; // 大数据局名称 @@ -165,7 +166,6 @@ public class ResourceController { */ @GetMapping("/updateTest") public Result updateTest() { - final ExecutorService executor = Executors.newFixedThreadPool(cpuNUm); CompletableFuture.runAsync(() -> { List ids = jdbcTemplate.queryForList("SELECT id FROM tb_data_resource", Long.class); ids.stream().forEach(id -> { @@ -268,16 +268,16 @@ public class ResourceController { Optional deptDTO = Optional.ofNullable(sysDeptService.getByName(bigDateDeptName)); CompletableFuture.runAsync(() -> { EasyExcel.read(file, new ResourceExcelImportListener(0, dept, resourceService, deptDTO.get().getId())).sheet(0).headRowNumber(1).doReadSync(); - }); + }, executor); CompletableFuture.runAsync(() -> { EasyExcel.read(file, new ResourceExcelImportListener(1, dept, resourceService, deptDTO.get().getId())).sheet(1).headRowNumber(1).doReadSync(); - }); + }, executor); CompletableFuture.runAsync(() -> { EasyExcel.read(file, new ResourceExcelImportListener(2, dept, resourceService, deptDTO.get().getId())).sheet(2).headRowNumber(1).doReadSync(); - }); + }, executor); CompletableFuture.runAsync(() -> { EasyExcel.read(file, new ResourceExcelImportListener(3, dept, resourceService, deptDTO.get().getId())).sheet(3).headRowNumber(1).doReadSync(); - }); + }, executor); } catch (IOException e) { return new Result().error(e.getMessage()); }