能力共享方-应用领域接口;能力申请方-应用领域;
This commit is contained in:
parent
da1cc12fe9
commit
d9026207e1
|
@ -1,5 +1,6 @@
|
||||||
package io.renren.common.controller;
|
package io.renren.common.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import io.renren.common.annotation.LogOperation;
|
import io.renren.common.annotation.LogOperation;
|
||||||
import io.renren.common.utils.Result;
|
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.renren.modules.sys.service.SysUserService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -175,7 +177,69 @@ public class CensusController {
|
||||||
return new Result().ok(resourceService.selectSourceDepartmentStatistics());
|
return new Result().ok(resourceService.selectSourceDepartmentStatistics());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/provideDeptTopN")
|
||||||
|
@ApiOperation("部门共享能力topN")
|
||||||
|
@LogOperation("部门共享能力topN")
|
||||||
|
public Result<List<Map<String, Object>>> provideDeptTopN(Integer n) {
|
||||||
|
List<Map> temp = resourceService.selectDeptProvideCount(n == null ? 24 : n);
|
||||||
|
List<Map<String, Object>> result = Collections.synchronizedList(new ArrayList<>());
|
||||||
|
List<CompletableFuture> completableFutures =
|
||||||
|
temp.stream().mapToLong(index -> Long.valueOf(index.get("dept_id").toString())).mapToObj(deptId -> {
|
||||||
|
CompletableFuture<Void> task =
|
||||||
|
CompletableFuture.supplyAsync(() -> { // 获取资源汇聚总量
|
||||||
|
List<String> db = resourceService.selectDeptProvide(deptId);
|
||||||
|
Set<String> 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<String, Object>() {
|
||||||
|
{
|
||||||
|
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<List<Map<String, Object>>>().ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/applyDeptTopN")
|
||||||
|
@ApiOperation("部门申请量能力topN")
|
||||||
|
@LogOperation("部门申请量能力topN")
|
||||||
|
public Result<List<Map<String, Object>>> applyDeptTopN(Integer n) {
|
||||||
|
List<Map> temp = tAbilityApplicationService.selectDeptApplyCount(n == null ? 24 : n);
|
||||||
|
List<Map<String, Object>> result = Collections.synchronizedList(new ArrayList<>());
|
||||||
|
List<CompletableFuture> completableFutures =
|
||||||
|
temp.stream().mapToLong(index -> Long.valueOf(index.get("dept_id").toString())).mapToObj(deptId -> {
|
||||||
|
CompletableFuture<Void> task =
|
||||||
|
CompletableFuture.supplyAsync(() -> { // 获取资源汇聚总量
|
||||||
|
List<String> db = tAbilityApplicationService.selectDeptApply(deptId);
|
||||||
|
Set<String> 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<String, Object>() {
|
||||||
|
{
|
||||||
|
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<List<Map<String, Object>>>().ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,11 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 能力申请表单
|
* 能力申请表单
|
||||||
*
|
*
|
||||||
* @author Mark sunlightcs@gmail.com
|
* @author Mark sunlightcs@gmail.com
|
||||||
* @since 3.0 2022-04-13
|
* @since 3.0 2022-04-13
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface TAbilityApplicationDao extends BaseDao<TAbilityApplicationEntity> {
|
public interface TAbilityApplicationDao extends BaseDao<TAbilityApplicationEntity> {
|
||||||
void updateInstanceId(String instanceId, Long id);
|
void updateInstanceId(String instanceId, Long id);
|
||||||
|
@ -24,4 +24,14 @@ public interface TAbilityApplicationDao extends BaseDao<TAbilityApplicationEntit
|
||||||
Long countApplyAll();
|
Long countApplyAll();
|
||||||
|
|
||||||
List<Map<String, Object>> getAmountGroupByType();
|
List<Map<String, Object>> getAmountGroupByType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请量前n位部门
|
||||||
|
*
|
||||||
|
* @param n
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Map> selectDeptApplyCount(Integer n);
|
||||||
|
|
||||||
|
List<String> selectDeptApply(Long deptId);
|
||||||
}
|
}
|
|
@ -30,4 +30,8 @@ public interface TAbilityApplicationService extends CrudService<TAbilityApplicat
|
||||||
Long countApplyAll();
|
Long countApplyAll();
|
||||||
|
|
||||||
List<Map<String, Object>> getAmountGroupByType();
|
List<Map<String, Object>> getAmountGroupByType();
|
||||||
|
|
||||||
|
List<Map> selectDeptApplyCount(Integer n);
|
||||||
|
|
||||||
|
List<String> selectDeptApply(Long deptId);
|
||||||
}
|
}
|
|
@ -63,5 +63,15 @@ public class TAbilityApplicationServiceImpl extends CrudServiceImpl<TAbilityAppl
|
||||||
return baseDao.getAmountGroupByType();
|
return baseDao.getAmountGroupByType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map> selectDeptApplyCount(Integer n) {
|
||||||
|
return baseDao.selectDeptApplyCount(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> selectDeptApply(Long deptId) {
|
||||||
|
return baseDao.selectDeptApply(deptId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -49,6 +49,7 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 介入部门数目
|
* 介入部门数目
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Long countAllDept();
|
Long countAllDept();
|
||||||
|
@ -68,4 +69,13 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
|
||||||
List<Map> selectDeptTypeCount();
|
List<Map> selectDeptTypeCount();
|
||||||
|
|
||||||
List<Map> selectDeptTotalCount();
|
List<Map> selectDeptTotalCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询前n 个能力类型多的部门
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Map> selectDeptProvideCount(Integer n);
|
||||||
|
|
||||||
|
List<String> selectDeptProvide(Long deptId);
|
||||||
}
|
}
|
|
@ -51,4 +51,8 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
|
||||||
|
|
||||||
Object selectSourceDepartmentStatistics();
|
Object selectSourceDepartmentStatistics();
|
||||||
|
|
||||||
|
List<Map> selectDeptProvideCount(Integer n);
|
||||||
|
|
||||||
|
List<String> selectDeptProvide(Long deptId);
|
||||||
|
|
||||||
}
|
}
|
|
@ -417,4 +417,14 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
resultMap.put("deptTotalCount", map1);
|
resultMap.put("deptTotalCount", map1);
|
||||||
return resultMap;
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map> selectDeptProvideCount(Integer n) {
|
||||||
|
return baseDao.selectDeptProvideCount(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> selectDeptProvide(Long deptId) {
|
||||||
|
return baseDao.selectDeptProvide(deptId);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -44,4 +44,59 @@
|
||||||
GROUP BY
|
GROUP BY
|
||||||
tbr.type
|
tbr.type
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectDeptApplyCount" resultType="java.util.Map">
|
||||||
|
SELECT
|
||||||
|
COUNT( DISTINCT tda.attr_value ),
|
||||||
|
any_value ( temp.dept_id ) dept_id
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
sys_user.dept_id,
|
||||||
|
t_ability_application.`user`,
|
||||||
|
t_ability_application.resource_id,
|
||||||
|
t_ability_application.approve_status,
|
||||||
|
t_ability_application.id
|
||||||
|
FROM
|
||||||
|
t_ability_application,
|
||||||
|
tb_data_resource,
|
||||||
|
sys_user
|
||||||
|
WHERE
|
||||||
|
t_ability_application.resource_id = tb_data_resource.id
|
||||||
|
AND sys_user.id = t_ability_application.user_id
|
||||||
|
AND sys_user.dept_id IS NOT NULL
|
||||||
|
) temp
|
||||||
|
INNER JOIN tb_data_attr tda ON temp.resource_id = tda.data_resource_id
|
||||||
|
AND tda.attr_type = '应用领域'
|
||||||
|
AND tda.del_flag = 0
|
||||||
|
AND temp.approve_status = '通过'
|
||||||
|
GROUP BY
|
||||||
|
temp.dept_id
|
||||||
|
LIMIT #{n}
|
||||||
|
</select>
|
||||||
|
<select id="selectDeptApply" resultType="java.lang.String">
|
||||||
|
SELECT DISTINCT
|
||||||
|
( tda.attr_value )
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
sys_user.dept_id,
|
||||||
|
t_ability_application.`user`,
|
||||||
|
t_ability_application.resource_id,
|
||||||
|
t_ability_application.approve_status,
|
||||||
|
t_ability_application.id
|
||||||
|
FROM
|
||||||
|
t_ability_application,
|
||||||
|
tb_data_resource,
|
||||||
|
sys_user
|
||||||
|
WHERE
|
||||||
|
t_ability_application.resource_id = tb_data_resource.id
|
||||||
|
AND sys_user.id = t_ability_application.user_id
|
||||||
|
AND sys_user.dept_id IS NOT NULL
|
||||||
|
AND t_ability_application.approve_status = '通过'
|
||||||
|
AND sys_user.dept_id = #{deptId}
|
||||||
|
) temp
|
||||||
|
INNER JOIN tb_data_attr tda ON temp.resource_id = tda.data_resource_id
|
||||||
|
AND tda.attr_type = '应用领域'
|
||||||
|
AND tda.del_flag = 0
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -466,32 +466,32 @@
|
||||||
|
|
||||||
<select id="selectDeptCount" resultType="java.lang.Integer">
|
<select id="selectDeptCount" resultType="java.lang.Integer">
|
||||||
SELECT
|
SELECT
|
||||||
COUNT( 1 )
|
COUNT( 1 )
|
||||||
FROM
|
FROM
|
||||||
( SELECT DISTINCT dept_id FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 AND dept_id IS NOT NULL ) temp
|
( SELECT DISTINCT dept_id FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 AND dept_id IS NOT NULL ) temp
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectDeptTypeCount" resultType="java.util.Map">
|
<select id="selectDeptTypeCount" resultType="java.util.Map">
|
||||||
SELECT IFNULL(COUNT(deptId),0) AS "count",
|
SELECT IFNULL(COUNT(deptId),0) AS "count",
|
||||||
type
|
type
|
||||||
FROM (
|
FROM (
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
tbr.dept_id AS "deptId",
|
tbr.dept_id AS "deptId",
|
||||||
(CASE sd.type
|
(CASE sd.type
|
||||||
WHEN 1 THEN
|
WHEN 1 THEN
|
||||||
'省级'
|
'省级'
|
||||||
WHEN 2 THEN
|
WHEN 2 THEN
|
||||||
'市级'
|
'市级'
|
||||||
WHEN 3 THEN
|
WHEN 3 THEN
|
||||||
'区级'
|
'区级'
|
||||||
WHEN 4 THEN
|
WHEN 4 THEN
|
||||||
'企业' ELSE '其他'
|
'企业' ELSE '其他'
|
||||||
END ) AS "type"
|
END ) AS "type"
|
||||||
FROM
|
FROM
|
||||||
sys_dept sd
|
sys_dept sd
|
||||||
RIGHT JOIN tb_data_resource tbr ON tbr.dept_id = sd.id
|
RIGHT JOIN tb_data_resource tbr ON tbr.dept_id = sd.id
|
||||||
WHERE
|
WHERE
|
||||||
1 = 1
|
1 = 1
|
||||||
AND del_flag = 0
|
AND del_flag = 0
|
||||||
AND dept_id IS NOT NULL) temp GROUP BY type
|
AND dept_id IS NOT NULL) temp GROUP BY type
|
||||||
</select>
|
</select>
|
||||||
|
@ -505,14 +505,14 @@
|
||||||
SELECT
|
SELECT
|
||||||
(
|
(
|
||||||
CASE
|
CASE
|
||||||
WHEN ( COUNT( id ) BETWEEN 0 AND 5 ) THEN
|
WHEN ( COUNT( id ) BETWEEN 0 AND 5 ) THEN
|
||||||
'0'
|
'0'
|
||||||
WHEN ( COUNT( id ) BETWEEN 5 AND 10 ) THEN
|
WHEN ( COUNT( id ) BETWEEN 5 AND 10 ) THEN
|
||||||
'5'
|
'5'
|
||||||
WHEN ( COUNT( id ) BETWEEN 10 AND 15 ) THEN
|
WHEN ( COUNT( id ) BETWEEN 10 AND 15 ) THEN
|
||||||
'10'
|
'10'
|
||||||
WHEN ( COUNT( id ) BETWEEN 15 AND 20 ) THEN
|
WHEN ( COUNT( id ) BETWEEN 15 AND 20 ) THEN
|
||||||
'15' ELSE '20'
|
'15' ELSE '20'
|
||||||
END
|
END
|
||||||
) AS "type"
|
) AS "type"
|
||||||
FROM
|
FROM
|
||||||
|
@ -526,5 +526,32 @@
|
||||||
GROUP BY
|
GROUP BY
|
||||||
type
|
type
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectDeptProvideCount" resultType="java.util.Map">
|
||||||
|
SELECT
|
||||||
|
COUNT(
|
||||||
|
DISTINCT any_value ( tda.attr_value )) count,
|
||||||
|
any_value ( tdr.dept_id ) dept_id
|
||||||
|
FROM
|
||||||
|
tb_data_attr tda
|
||||||
|
INNER JOIN tb_data_resource tdr ON tda.data_resource_id = tdr.id
|
||||||
|
AND tdr.dept_id IS NOT NULL
|
||||||
|
WHERE
|
||||||
|
tda.attr_type = '应用领域'
|
||||||
|
GROUP BY
|
||||||
|
tdr.dept_id
|
||||||
|
ORDER BY
|
||||||
|
count DESC
|
||||||
|
LIMIT #{n}
|
||||||
|
</select>
|
||||||
|
<select id="selectDeptProvide" resultType="java.lang.String">
|
||||||
|
SELECT DISTINCT
|
||||||
|
tda.attr_value
|
||||||
|
FROM
|
||||||
|
tb_data_attr tda
|
||||||
|
INNER JOIN tb_data_resource tdr ON tda.data_resource_id = tdr.id
|
||||||
|
AND tdr.dept_id = #{deptId}
|
||||||
|
WHERE
|
||||||
|
tda.attr_type = '应用领域'
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue