diff --git a/renren-admin/src/main/java/io/renren/common/controller/CensusController.java b/renren-admin/src/main/java/io/renren/common/controller/CensusController.java index 717dad48..6c4cf907 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/CensusController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/CensusController.java @@ -1,5 +1,6 @@ package io.renren.common.controller; +import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONObject; import io.renren.common.annotation.LogOperation; import io.renren.common.utils.Result; @@ -9,6 +10,7 @@ import io.renren.modules.resourceBrowse.service.ResourceBrowseService; import io.renren.modules.sys.service.SysUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -175,7 +177,69 @@ public class CensusController { return new Result().ok(resourceService.selectSourceDepartmentStatistics()); } + @GetMapping("/provideDeptTopN") + @ApiOperation("部门共享能力topN") + @LogOperation("部门共享能力topN") + public Result>> provideDeptTopN(Integer n) { + List temp = resourceService.selectDeptProvideCount(n == null ? 24 : n); + List> result = Collections.synchronizedList(new ArrayList<>()); + List completableFutures = + temp.stream().mapToLong(index -> Long.valueOf(index.get("dept_id").toString())).mapToObj(deptId -> { + CompletableFuture task = + CompletableFuture.supplyAsync(() -> { // 获取资源汇聚总量 + List db = resourceService.selectDeptProvide(deptId); + Set type = + db.stream().flatMap(index_ -> Arrays.stream(index_.split(";"))).filter(index_ -> StringUtils.isNotEmpty(index_)).collect(Collectors.toSet()); + return type; + }).thenAccept(type -> { + result.add(new HashMap() { + { + put("provide", type); + put("deptId", deptId); + } + }); + }); + return task; + }).collect(Collectors.toList()); + CompletableFuture.allOf(completableFutures.toArray(new CompletableFuture[completableFutures.size()])).join(); + result.sort(Comparator.comparing(x -> + ObjectUtil.length(x.get("provide")) + ) + ); + return new Result>>().ok(result); + } + @GetMapping("/applyDeptTopN") + @ApiOperation("部门申请量能力topN") + @LogOperation("部门申请量能力topN") + public Result>> applyDeptTopN(Integer n) { + List temp = tAbilityApplicationService.selectDeptApplyCount(n == null ? 24 : n); + List> result = Collections.synchronizedList(new ArrayList<>()); + List completableFutures = + temp.stream().mapToLong(index -> Long.valueOf(index.get("dept_id").toString())).mapToObj(deptId -> { + CompletableFuture task = + CompletableFuture.supplyAsync(() -> { // 获取资源汇聚总量 + List db = tAbilityApplicationService.selectDeptApply(deptId); + Set type = + db.stream().flatMap(index_ -> Arrays.stream(index_.split(";"))).filter(index_ -> StringUtils.isNotEmpty(index_)).collect(Collectors.toSet()); + return type; + }).thenAccept(type -> { + result.add(new HashMap() { + { + put("provide", type); + put("deptId", deptId); + } + }); + }); + return task; + }).collect(Collectors.toList()); + CompletableFuture.allOf(completableFutures.toArray(new CompletableFuture[completableFutures.size()])).join(); + result.sort(Comparator.comparing(x -> + ObjectUtil.length(x.get("provide")) + ) + ); + return new Result>>().ok(result); + } } diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/dao/TAbilityApplicationDao.java b/renren-admin/src/main/java/io/renren/modules/processForm/dao/TAbilityApplicationDao.java index b62a4387..4cf88a82 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/dao/TAbilityApplicationDao.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/dao/TAbilityApplicationDao.java @@ -8,11 +8,11 @@ import java.util.List; import java.util.Map; /** -* 能力申请表单 -* -* @author Mark sunlightcs@gmail.com -* @since 3.0 2022-04-13 -*/ + * 能力申请表单 + * + * @author Mark sunlightcs@gmail.com + * @since 3.0 2022-04-13 + */ @Mapper public interface TAbilityApplicationDao extends BaseDao { void updateInstanceId(String instanceId, Long id); @@ -24,4 +24,14 @@ public interface TAbilityApplicationDao extends BaseDao> getAmountGroupByType(); + + /** + * 申请量前n位部门 + * + * @param n + * @return + */ + List selectDeptApplyCount(Integer n); + + List selectDeptApply(Long deptId); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/service/TAbilityApplicationService.java b/renren-admin/src/main/java/io/renren/modules/processForm/service/TAbilityApplicationService.java index dd08c153..71883906 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/service/TAbilityApplicationService.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/service/TAbilityApplicationService.java @@ -30,4 +30,8 @@ public interface TAbilityApplicationService extends CrudService> getAmountGroupByType(); + + List selectDeptApplyCount(Integer n); + + List selectDeptApply(Long deptId); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/service/impl/TAbilityApplicationServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/processForm/service/impl/TAbilityApplicationServiceImpl.java index 7875a249..de78a8ae 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/service/impl/TAbilityApplicationServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/service/impl/TAbilityApplicationServiceImpl.java @@ -63,5 +63,15 @@ public class TAbilityApplicationServiceImpl extends CrudServiceImpl selectDeptApplyCount(Integer n) { + return baseDao.selectDeptApplyCount(n); + } + + @Override + public List selectDeptApply(Long deptId) { + return baseDao.selectDeptApply(deptId); + } + } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java b/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java index d19a4e5a..ba0af651 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java @@ -49,6 +49,7 @@ public interface ResourceDao extends BaseDao { /** * 介入部门数目 + * * @return */ Long countAllDept(); @@ -68,4 +69,13 @@ public interface ResourceDao extends BaseDao { List selectDeptTypeCount(); List selectDeptTotalCount(); + + /** + * 查询前n 个能力类型多的部门 + * + * @return + */ + List selectDeptProvideCount(Integer n); + + List selectDeptProvide(Long deptId); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java b/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java index 9bb4a453..1ef95915 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java @@ -51,4 +51,8 @@ public interface ResourceService extends CrudService selectDeptProvideCount(Integer n); + + List selectDeptProvide(Long deptId); + } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java index 68859572..f9ed4701 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java @@ -417,4 +417,14 @@ public class ResourceServiceImpl extends CrudServiceImpl selectDeptProvideCount(Integer n) { + return baseDao.selectDeptProvideCount(n); + } + + @Override + public List selectDeptProvide(Long deptId) { + return baseDao.selectDeptProvide(deptId); + } } \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/processForm/TAbilityApplicationDao.xml b/renren-admin/src/main/resources/mapper/processForm/TAbilityApplicationDao.xml index d5b638d2..2095674a 100644 --- a/renren-admin/src/main/resources/mapper/processForm/TAbilityApplicationDao.xml +++ b/renren-admin/src/main/resources/mapper/processForm/TAbilityApplicationDao.xml @@ -44,4 +44,59 @@ GROUP BY tbr.type + + \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index 9701565a..9e5889a5 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -466,32 +466,32 @@ @@ -505,14 +505,14 @@ SELECT ( CASE - WHEN ( COUNT( id ) BETWEEN 0 AND 5 ) THEN - '0' - WHEN ( COUNT( id ) BETWEEN 5 AND 10 ) THEN - '5' - WHEN ( COUNT( id ) BETWEEN 10 AND 15 ) THEN - '10' - WHEN ( COUNT( id ) BETWEEN 15 AND 20 ) THEN - '15' ELSE '20' + WHEN ( COUNT( id ) BETWEEN 0 AND 5 ) THEN + '0' + WHEN ( COUNT( id ) BETWEEN 5 AND 10 ) THEN + '5' + WHEN ( COUNT( id ) BETWEEN 10 AND 15 ) THEN + '10' + WHEN ( COUNT( id ) BETWEEN 15 AND 20 ) THEN + '15' ELSE '20' END ) AS "type" FROM @@ -526,5 +526,32 @@ GROUP BY type + + \ No newline at end of file