Compare commits

..

3 Commits

Author SHA1 Message Date
wangliwen 8d8238d7e6 Merge branch 'master' into docker_package 2023-01-05 09:44:42 +08:00
wangliwen 2f2558a849 Merge branch 'dev' 2023-01-05 09:44:34 +08:00
wangliwen f05d6e6965 异步减少环比用时 2023-01-05 09:44:26 +08:00
1 changed files with 27 additions and 13 deletions

View File

@ -42,6 +42,7 @@ import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -645,8 +646,8 @@ public class CensusController {
// TODO 同比环比 // TODO 同比环比
@GetMapping("/similitude") @GetMapping("/similitude")
@ApiOperation("资源数量环比") // @ApiOperation("资源数量环比")
@LogOperation("资源数量环比") // @LogOperation("资源数量环比")
@ApiImplicitParams({}) @ApiImplicitParams({})
public Result similitude() { public Result similitude() {
long countApply = tAbilityApplicationService.countApplyAll(); // 资源申请量 long countApply = tAbilityApplicationService.countApplyAll(); // 资源申请量
@ -712,17 +713,30 @@ public class CensusController {
} }
@GetMapping("/similitude_dept") @GetMapping("/similitude_dept")
@ApiOperation("部门资源数量环比") // @ApiOperation("部门资源数量环比")
@LogOperation("部门资源数量环比") // @LogOperation("部门资源数量环比")
@ApiImplicitParams({}) @ApiImplicitParams({})
public Result similitudeDept() { public Result similitudeDept() {
List<HashMap<String, Object>> resultList1 = (List<HashMap<String, Object>>) resourceService.selectApplyDeptDetailTypeCountList(new HashMap() {{ List<HashMap<String, Object>> resultList1 = new ArrayList<>();
List<HashMap<String, Object>> resultList2 = new ArrayList<>();
try {
resultList1 = CompletableFuture.supplyAsync(() -> {
return (List<HashMap<String, Object>>) resourceService.selectApplyDeptDetailTypeCountList(new HashMap() {{
put("snapshot", true); put("snapshot", true);
}}); // 能力申请统计原始数据 }}); // 能力申请统计原始数据
}, executor).get();
List<HashMap<String, Object>> resultList2 = (List<HashMap<String, Object>>) resourceService.selectDeptDetailTypeCountList(new HashMap() {{ resultList2 = CompletableFuture.supplyAsync(() -> {
return (List<HashMap<String, Object>>) resourceService.selectDeptDetailTypeCountList(new HashMap() {{
put("snapshot", true); put("snapshot", true);
}}); // 能力上架统计原始数据 }}); // 能力上架统计原始数据
}, executor).get();
} catch (InterruptedException e) {
logger.error("", e);
throw new RuntimeException(e);
} catch (ExecutionException e) {
logger.error("", e);
throw new RuntimeException(e);
}
Integer county_apply_sum = resultList1.stream().filter(index -> index.containsKey("level") && "county".equals(index.get("level").toString())) Integer county_apply_sum = resultList1.stream().filter(index -> index.containsKey("level") && "county".equals(index.get("level").toString()))
.mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 区申请总量 .mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 区申请总量
@ -813,7 +827,7 @@ public class CensusController {
add(new LinkedHashMap<String, Object>() {{ add(new LinkedHashMap<String, Object>() {{
put("tip", "区市部门"); put("tip", "区市部门");
put("level", "county"); put("level", "county");
put("dept_count", sysDeptService.countByType(3)); put("dept_count", sysDeptService.countByType(3).longValue());
put("apply_sum", county_apply_sum); put("apply_sum", county_apply_sum);
put("resource_sum", county_resource_sum); put("resource_sum", county_resource_sum);
put("resource_weekly_change", finalCounty_resource_weekly_change); put("resource_weekly_change", finalCounty_resource_weekly_change);
@ -824,7 +838,7 @@ public class CensusController {
add(new LinkedHashMap<String, Object>() {{ add(new LinkedHashMap<String, Object>() {{
put("tip", "市级部门"); put("tip", "市级部门");
put("level", "municipal"); put("level", "municipal");
put("dept_count", sysDeptService.countByType(2)); put("dept_count", sysDeptService.countByType(2).longValue());
put("apply_sum", municipal_apply_sum); put("apply_sum", municipal_apply_sum);
put("resource_sum", municipal_resource_sum); put("resource_sum", municipal_resource_sum);
put("resource_weekly_change", finalMunicipal_resource_weekly_change); put("resource_weekly_change", finalMunicipal_resource_weekly_change);