能力统计-资源图谱

This commit is contained in:
dinggang 2022-05-24 19:49:37 +08:00
parent 9129b115ff
commit b1e9fd607e
8 changed files with 408 additions and 5 deletions

View File

@ -214,6 +214,33 @@ public class CensusController {
);
return new Result<List<Map<String, Object>>>().ok(result);
}
@GetMapping("/capabilityShareCapabilitySet")
@ApiOperation("资源图谱-能力共享方-能力集")
@LogOperation("资源图谱-能力共享方-能力集")
public Result capabilitySharePartyCapabilitySet() {
return new Result().ok(resourceService.capabilitySharePartyCapabilitySet());
}
@GetMapping("/selectResourceListByDept")
@ApiOperation("资源图谱-能力共享方-能力集-根据部门查能力")
@LogOperation("资源图谱-能力共享方-能力集-根据部门查能力")
public Result selectResourceListByDept(Long deptId) {
return new Result().ok(resourceService.selectResourceListByDept(deptId));
}
@GetMapping("/competencyApplicantCompetencySet")
@ApiOperation("资源图谱-能力申请方-能力集")
@LogOperation("资源图谱-能力申请方-能力集")
public Result competencyApplicantCompetencySet() {
return new Result().ok(resourceService.competencyApplicantCompetencySet());
}
@GetMapping("/selectResourceListByApplyDept")
@ApiOperation("资源图谱-能力申请方-能力集-根据部门查能力")
@LogOperation("资源图谱-能力申请方-能力集-根据部门查能力")
public Result selectResourceListByApplyDept(Long deptId) {
return new Result().ok(resourceService.selectResourceListByApplyDept(deptId));
}
@GetMapping("/applyDeptTopN")
@ApiOperation("部门申请量能力topN")
@ -248,6 +275,25 @@ public class CensusController {
);
return new Result<List<Map<String, Object>>>().ok(result);
}
@GetMapping("/capabilitySharingPartyCapabilityType")
@ApiOperation("资源图谱-能力共享方-能力类型")
@LogOperation("资源图谱-能力共享方-能力类型")
public Result capabilitySharingPartyCapabilityType() {
return new Result().ok(resourceService.capabilitySharingPartyCapabilityType());
}
@GetMapping("/competencyApplicantCapabilityType")
@ApiOperation("资源图谱-能力申请方-能力类型")
@LogOperation("资源图谱-能力申请方-能力类型")
public Result competencyApplicantCapabilityType() {
return new Result().ok(resourceService.competencyApplicantCapabilityType());
}
@GetMapping("/capabilityTypeCapabilitySet")
@ApiOperation("资源图谱-能力类型-能力集")
@LogOperation("资源图谱-能力类型-能力集")
public Result capabilityTypeCapabilitySet() {
return new Result().ok(resourceService.capabilityTypeCapabilitySet());
}
}

View File

@ -49,7 +49,6 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
/**
* 介入部门数目
*
* @return
*/
Long countAllDept();
@ -78,4 +77,26 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
List<Map> selectDeptProvideCount(Integer n);
List<String> selectDeptProvide(Long deptId);
List<Long> selectMaxDeptIds();
List<Map> selectByDeptId(@Param("deptId") Long deptId);
List<Map> selectDeptCountList();
List<Long> selectMaxApplyDeptIds();
List<Map> selectByApplyDeptId(Long aLong);
List<Map> selectApplyDeptCountList();
List<Map<String, Object>> selectDeptTypeCountList();
List<Map<String, Object>> selectApplyDeptTypeCountList();
List<String> selectMaxType();
List<Map> selectByType(@Param("type") String s);
List<Map> selectTypeCountList();
}

View File

@ -55,4 +55,18 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
List<String> selectDeptProvide(Long deptId);
Object capabilitySharePartyCapabilitySet();
Object selectResourceListByDept(Long deptId);
Object competencyApplicantCompetencySet();
Object selectResourceListByApplyDept(Long deptId);
Object capabilitySharingPartyCapabilityType();
Object competencyApplicantCapabilityType();
Object capabilityTypeCapabilitySet();
}

View File

@ -24,6 +24,7 @@ import io.renren.modules.resourceCollection.dao.ResourceCollectionDao;
import io.renren.modules.resourceScore.dao.ResourceScoreDao;
import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.security.user.UserDetail;
import io.renren.modules.sys.dao.SysDeptDao;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -62,6 +63,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Autowired
private ResourceBrowseDao resourceBrowseDao;
@Autowired
private SysDeptDao sysDeptDao;
@Override
public QueryWrapper<ResourceEntity> getWrapper(Map<String, Object> params) {
QueryWrapper<ResourceEntity> wrapper = new QueryWrapper<>();
@ -427,4 +431,91 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
public List<String> selectDeptProvide(Long deptId) {
return baseDao.selectDeptProvide(deptId);
}
@Override
public Object capabilitySharePartyCapabilitySet() {
HashMap<String, Object> resultMap = new HashMap<>();
List<Long> deptIds = resourceDao.selectMaxDeptIds();
List<Map> resourceList = resourceDao.selectByDeptId(deptIds.get(0));
HashMap<String, Object> maxdeptMap = new HashMap<>();
maxdeptMap.put("resourceList", resourceList);
maxdeptMap.put("deptName", sysDeptDao.selectById(deptIds.get(0)).getName());
maxdeptMap.put("deptId", deptIds.get(0));
resultMap.put("maxDept", maxdeptMap);
List<Map> deptList = resourceDao.selectDeptCountList();
resultMap.put("deptList", deptList);
return resultMap;
}
@Override
public Object selectResourceListByDept(Long deptId) {
return resourceDao.selectByDeptId(deptId);
}
@Override
public Object competencyApplicantCompetencySet() {
HashMap<String, Object> resultMap = new HashMap<>();
List<Long> deptIds = resourceDao.selectMaxApplyDeptIds();
List<Map> resourceList = resourceDao.selectByApplyDeptId(deptIds.get(0));
HashMap<String, Object> maxdeptMap = new HashMap<>();
maxdeptMap.put("resourceList", resourceList);
maxdeptMap.put("deptName", sysDeptDao.selectById(deptIds.get(0)).getName());
maxdeptMap.put("deptId", deptIds.get(0));
resultMap.put("maxDept", maxdeptMap);
List<Map> deptList = resourceDao.selectApplyDeptCountList();
resultMap.put("deptList", deptList);
return resultMap;
}
@Override
public Object selectResourceListByApplyDept(Long deptId) {
return resourceDao.selectByApplyDeptId(deptId);
}
@Override
public Object capabilitySharingPartyCapabilityType() {
List<Map<String, Object>> typeCountListByDept = resourceDao.selectDeptTypeCountList();
Map<String, List<Map<String, Object>>> typeCountListMap = typeCountListByDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString()));
ArrayList<Map> resultList = new ArrayList<>();
typeCountListMap.forEach((k,v) -> {
HashMap<Object, Object> map = new HashMap<>();
map.put("name", k);
v.forEach(item -> {
map.put(item.get("type").toString(), item.get("count"));
});
resultList.add(map);
});
return resultList;
}
@Override
public Object competencyApplicantCapabilityType() {
List<Map<String, Object>> typeCountListByApplyDept = resourceDao.selectApplyDeptTypeCountList();
Map<String, List<Map<String, Object>>> typeCountListMap = typeCountListByApplyDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString()));
ArrayList<Map> resultList = new ArrayList<>();
typeCountListMap.forEach((k,v) -> {
HashMap<Object, Object> map = new HashMap<>();
map.put("name", k);
v.forEach(item -> {
map.put(item.get("type").toString(), item.get("count"));
});
resultList.add(map);
});
return resultList;
}
@Override
public Object capabilityTypeCapabilitySet() {
HashMap<String, Object> resultMap = new HashMap<>();
List<String> types = resourceDao.selectMaxType();
List<Map> resourceList = resourceDao.selectByType(types.get(0));
HashMap<String, Object> maxdeptMap = new HashMap<>();
maxdeptMap.put("resourceList", resourceList);
maxdeptMap.put("typeName", types.get(0));
resultMap.put("maxDept", maxdeptMap);
List<Map> deptList = resourceDao.selectTypeCountList();
resultMap.put("typeList", deptList);
return resultMap;
}
}

View File

@ -17,7 +17,7 @@ import java.util.Map;
@Mapper
public interface ResourceBrowseDao extends BaseDao<ResourceBrowseEntity> {
Integer selectDayAvg(@Param("days") Long days);
Long selectDayAvg(@Param("days") Long days);
Integer selectDayMax();

View File

@ -83,4 +83,4 @@ mybatis-plus:
#系统上线日期,用于统计能力浏览记录
system:
startDay: 2022-01-01
startDay: 2022-04-01

View File

@ -554,4 +554,234 @@
tda.attr_type = '应用领域'
</select>
<select id="selectMaxDeptIds" resultType="java.lang.Long">
SELECT
dept_id
FROM
(
SELECT
COUNT( id ) AS "count",
dept_id
FROM
tb_data_resource
WHERE
1 = 1
AND del_flag = 0
AND dept_id IS NOT NULL
GROUP BY
dept_id
) temp1
WHERE
temp1.count = (
SELECT
MAX( count ) AS "total"
FROM
(
SELECT
COUNT( id ) AS "count",
dept_id
FROM
tb_data_resource
WHERE
1 = 1
AND del_flag = 0
AND dept_id IS NOT NULL
GROUP BY
dept_id
) temp2
)
</select>
<select id="selectByDeptId" resultType="java.util.Map">
SELECT id,
name
FROM tb_data_resource
WHERE 1 = 1
AND del_flag = 0
AND dept_id = #{deptId}
</select>
<select id="selectDeptCountList" resultType="java.util.Map">
SELECT
sd.id AS "deptId",
sd.NAME AS "deptName",
COUNT( tdr.id ) AS "total"
FROM
tb_data_resource tdr,
sys_dept sd
WHERE
1 = 1
AND tdr.del_flag = 0
AND tdr.dept_id = sd.id
GROUP BY tdr.dept_id
ORDER BY total DESC
</select>
<select id="selectMaxApplyDeptIds" resultType="java.lang.Long">
SELECT
dept_id
FROM
(
SELECT
COUNT( taa.id ) AS "count",
su.dept_id
FROM
t_ability_application taa,
sys_user su
WHERE
1 = 1
AND taa.user_id = su.id
AND taa.user_id IS NOT NULL
GROUP BY
su.dept_id
) temp1
WHERE
temp1.count = (
SELECT
MAX( count ) AS "total"
FROM
(
SELECT
COUNT( taa.id ) AS "count",
su.dept_id
FROM
t_ability_application taa,
sys_user su
WHERE
1 = 1
AND taa.user_id = su.id
AND taa.user_id IS NOT NULL
GROUP BY
su.dept_id
) temp2
)
</select>
<select id="selectByApplyDeptId" resultType="java.util.Map">
SELECT tdr.id,
tdr.name
FROM t_ability_application taa, tb_data_resource tdr, sys_user su
WHERE 1 = 1
AND tdr.del_flag = 0
AND su.id = taa.user_id
AND taa.resource_id = tdr.id
AND su.dept_id = #{deptId}
</select>
<select id="selectApplyDeptCountList" resultType="java.util.Map">
SELECT
sd.id AS "deptId",
sd.NAME AS "deptName",
COUNT( taa.resource_id ) AS "total"
FROM
t_ability_application taa,
sys_user su,
sys_dept sd
WHERE
1 = 1
AND su.id = taa.user_id
AND su.dept_id = sd.id
GROUP BY
sd.id
ORDER BY
total DESC
</select>
<select id="selectDeptTypeCountList" resultType="java.util.Map">
SELECT
COUNT( tdr.id ) AS "count",
sd.NAME AS "deptName",
(CASE tdr.type
WHEN '应用资源' THEN 'yyzy'
WHEN '组件服务' THEN 'zjfw'
WHEN '基础设施' THEN 'jcss'
WHEN '知识库' THEN 'zsk'
WHEN '数据资源' THEN 'sjzy'
ELSE 'yyzy' END)AS "type"
FROM
tb_data_resource tdr,
sys_dept sd
WHERE
1 = 1
AND tdr.del_flag = 0
AND tdr.dept_id = sd.id
GROUP BY
tdr.dept_id,
tdr.type
</select>
<select id="selectApplyDeptTypeCountList" resultType="java.util.Map">
SELECT
COUNT( taa.resource_id ) AS "count",
sd.NAME AS "deptName",
(
CASE
tdr.type
WHEN '应用资源' THEN
'yyzy'
WHEN '组件服务' THEN
'zjfw'
WHEN '基础设施' THEN
'jcss'
WHEN '知识库' THEN
'zsk'
WHEN '数据资源' THEN
'sjzy' ELSE 'yyzy'
END
) AS "type"
FROM
tb_data_resource tdr,
sys_dept sd,
sys_user su,
t_ability_application taa
WHERE
1 = 1
AND tdr.del_flag = 0
AND taa.user_id = su.id
AND su.dept_id = sd.id
AND taa.resource_id = tdr.id
GROUP BY
sd.id,
tdr.type
</select>
<select id="selectMaxType" resultType="java.lang.String">
SELECT
type
FROM
( SELECT COUNT( id ) AS "count", type FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 GROUP BY type ) temp1
WHERE
temp1.count = (
SELECT
MAX( count ) AS "total"
FROM
( SELECT COUNT( id ) AS "count", type FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 GROUP BY type ) temp2
)
</select>
<select id="selectByType" resultType="java.util.Map">
SELECT id,
name
FROM tb_data_resource
WHERE 1 = 1
AND del_flag = 0
AND type = #{type}
</select>
<select id="selectTypeCountList" resultType="java.util.Map">
SELECT
tdr.type,
COUNT( tdr.id ) AS "total"
FROM
tb_data_resource tdr
WHERE
1 = 1
AND tdr.del_flag = 0
GROUP BY
tdr.type
ORDER BY
total DESC
</select>
</mapper>

View File

@ -16,7 +16,8 @@
<result property="note2" column="note2"/>
<result property="note3" column="note3"/>
</resultMap>
<select id="selectDayAvg" resultType="java.lang.Integer">
<select id="selectDayAvg" resultType="java.lang.Long">
SELECT IFNULL(COUNT(id), 0) / ${days}
FROM tb_resource_browse
WHERE 1 = 1
@ -46,7 +47,7 @@
WHERE
1 = 1
AND state = 0
AND create_date BETWEEN ${startDate} AND ${endDate}
AND SUBSTR(create_date, 1, 10) BETWEEN ${startDate} AND ${endDate}
GROUP BY
SUBSTR(create_date, 1, 10)
</select>