...
This commit is contained in:
parent
079c3b4eb4
commit
6eb4596a66
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue