This commit is contained in:
wangliwen 2022-05-11 17:25:21 +08:00
parent d6b9fa0677
commit 5b1c97b802
5 changed files with 47 additions and 3 deletions

View File

@ -73,7 +73,8 @@ public class CensusController {
@GetMapping(value = "/whole_amount")
@ApiOperation("平台整体情况")
public Result<List<Map<String, Object>>> wholeAmount() {
List<Map<String, Object>> result = new ArrayList<>();
List<Map<String, Object>> result = Collections.synchronizedList(new ArrayList<>());
CompletableFuture<Void> resourceAmount = CompletableFuture.supplyAsync(() -> { // 获取资源汇聚总量
List<Map<String, Object>> dbAmount = resourceService.getAmountGroupByType();
Long sum = dbAmount.stream().mapToLong(index -> Long.valueOf(index.get("amount").toString())).sum();
@ -97,7 +98,7 @@ public class CensusController {
});
});
CompletableFuture<Void> applyAmount = CompletableFuture.supplyAsync(() -> { // 获取平台用户总数
CompletableFuture<Void> applyAmount = CompletableFuture.supplyAsync(() -> { // 资源申请量
return tAbilityApplicationService.countApplyAll();
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
@ -107,7 +108,29 @@ public class CensusController {
}
});
});
CompletableFuture<Void> all = CompletableFuture.allOf(resourceAmount, userAmount, applyAmount);
CompletableFuture<Void> deptAmount = CompletableFuture.supplyAsync(() -> { // 覆盖部门量
return resourceService.countAllDept();
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "覆盖部门量");
}
});
});
CompletableFuture<Void> pvAmount = CompletableFuture.supplyAsync(() -> { // 平台访问量
return 0;
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
put("amount", sum);
put("type", "平台访问量");
}
});
});
CompletableFuture<Void> all = CompletableFuture.allOf(resourceAmount, userAmount, applyAmount, deptAmount, pvAmount);
all.join();
return new Result<List<Map<String, Object>>>().ok(result);
}

View File

@ -46,4 +46,10 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
*/
@MapKey("type")
List<Map<String, Object>> getAmountGroupByType();
/**
* 介入部门数目
* @return
*/
Long countAllDept();
}

View File

@ -40,4 +40,6 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
Object selectRecommend();
List<Map<String, Object>> getAmountGroupByType();
Long countAllDept();
}

View File

@ -257,4 +257,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
List<Map<String, Object>> amountInfo = resourceDao.getAmountGroupByType();
return amountInfo;
}
@Override
public Long countAllDept() {
return baseDao.countAllDept();
}
}

View File

@ -318,4 +318,12 @@
GROUP BY
type
</select>
<select id="countAllDept" resultType="java.lang.Long">
SELECT
COUNT( DISTINCT dept_id )
FROM
tb_data_resource
WHERE
del_flag = 0
</select>
</mapper>