Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-07-05 18:23:23 +08:00
commit 8a2fa967e2
1 changed files with 6 additions and 6 deletions

View File

@ -59,7 +59,8 @@ import java.util.stream.Collectors;
@RequestMapping("/resource") @RequestMapping("/resource")
@Api(tags = "资源表") @Api(tags = "资源表")
public class ResourceController { 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}") @Value("${big_date.name}")
private String bigDateDeptName; // 大数据局名称 private String bigDateDeptName; // 大数据局名称
@ -165,7 +166,6 @@ public class ResourceController {
*/ */
@GetMapping("/updateTest") @GetMapping("/updateTest")
public Result<String> updateTest() { public Result<String> updateTest() {
final ExecutorService executor = Executors.newFixedThreadPool(cpuNUm);
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
List<Long> ids = jdbcTemplate.queryForList("SELECT id FROM tb_data_resource", Long.class); List<Long> ids = jdbcTemplate.queryForList("SELECT id FROM tb_data_resource", Long.class);
ids.stream().forEach(id -> { ids.stream().forEach(id -> {
@ -268,16 +268,16 @@ public class ResourceController {
Optional<SysDeptDTO> deptDTO = Optional.ofNullable(sysDeptService.getByName(bigDateDeptName)); Optional<SysDeptDTO> deptDTO = Optional.ofNullable(sysDeptService.getByName(bigDateDeptName));
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
EasyExcel.read(file, new ResourceExcelImportListener(0, dept, resourceService, deptDTO.get().getId())).sheet(0).headRowNumber(1).doReadSync(); EasyExcel.read(file, new ResourceExcelImportListener(0, dept, resourceService, deptDTO.get().getId())).sheet(0).headRowNumber(1).doReadSync();
}); }, executor);
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
EasyExcel.read(file, new ResourceExcelImportListener(1, dept, resourceService, deptDTO.get().getId())).sheet(1).headRowNumber(1).doReadSync(); EasyExcel.read(file, new ResourceExcelImportListener(1, dept, resourceService, deptDTO.get().getId())).sheet(1).headRowNumber(1).doReadSync();
}); }, executor);
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
EasyExcel.read(file, new ResourceExcelImportListener(2, dept, resourceService, deptDTO.get().getId())).sheet(2).headRowNumber(1).doReadSync(); EasyExcel.read(file, new ResourceExcelImportListener(2, dept, resourceService, deptDTO.get().getId())).sheet(2).headRowNumber(1).doReadSync();
}); }, executor);
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
EasyExcel.read(file, new ResourceExcelImportListener(3, dept, resourceService, deptDTO.get().getId())).sheet(3).headRowNumber(1).doReadSync(); EasyExcel.read(file, new ResourceExcelImportListener(3, dept, resourceService, deptDTO.get().getId())).sheet(3).headRowNumber(1).doReadSync();
}); }, executor);
} catch (IOException e) { } catch (IOException e) {
return new Result<String>().error(e.getMessage()); return new Result<String>().error(e.getMessage());
} }