资源数目统计
This commit is contained in:
parent
cd7831e68c
commit
105b6b536c
|
@ -0,0 +1,68 @@
|
|||
package io.renren.common.controller;
|
||||
|
||||
|
||||
import io.renren.common.utils.Result;
|
||||
import io.renren.modules.resource.service.ResourceService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 统计
|
||||
*/
|
||||
@Api(tags = "全局统计中心")
|
||||
@RestController
|
||||
@RequestMapping("/census/center")
|
||||
public class CensusController {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(CensusController.class);
|
||||
|
||||
@Autowired
|
||||
private ResourceService resourceService;
|
||||
|
||||
@Value("${census.type}")
|
||||
private String[] censusTypes; // 大数据局名称
|
||||
|
||||
|
||||
/**
|
||||
* 获取各类资源数目
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/resource_amount")
|
||||
@ApiOperation("各类资源数目")
|
||||
public Result<List<Map<String, Object>>> resourceAmount() {
|
||||
List<Map<String, Object>> dbAmount = resourceService.getAmountGroupByType();
|
||||
List<String> temp = dbAmount.stream().map(index -> index.get("type").toString()).collect(Collectors.toList());
|
||||
Arrays.stream(censusTypes).filter(index -> !temp.contains(index)).forEach(index -> { // 数据库内不存在的资源类型
|
||||
Map<String, Object> nullMap = new HashMap<String, Object>() {
|
||||
{
|
||||
put("amount", 0);
|
||||
put("type", index);
|
||||
}
|
||||
};
|
||||
dbAmount.add(nullMap);
|
||||
});
|
||||
Long sum = dbAmount.stream().mapToLong(index -> Long.valueOf(index.get("amount").toString())).sum();
|
||||
Map<String, Object> sumMap = new HashMap<String, Object>() {
|
||||
{
|
||||
put("amount", sum);
|
||||
put("type", "资源汇聚总量");
|
||||
}
|
||||
};
|
||||
dbAmount.add(sumMap);
|
||||
return new Result<List<Map<String, Object>>>().ok(dbAmount);
|
||||
}
|
||||
}
|
|
@ -6,6 +6,8 @@ import io.renren.modules.activiti.dto.ProcessInstanceDTO;
|
|||
import io.renren.modules.activiti.dto.TaskDTO;
|
||||
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
|
||||
import io.renren.modules.processForm.service.TAbilityApplicationService;
|
||||
import io.renren.modules.resource.dto.ResourceDTO;
|
||||
import io.renren.modules.resource.service.ResourceService;
|
||||
import io.renren.modules.resourceMountApply.dto.TResourceMountApplyDTO;
|
||||
import io.renren.modules.resourceMountApply.service.TResourceMountApplyService;
|
||||
import io.renren.modules.security.user.SecurityUser;
|
||||
|
@ -72,6 +74,8 @@ public class ActHistoryService {
|
|||
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
@Autowired
|
||||
private ResourceService resourceService;
|
||||
|
||||
@Autowired
|
||||
private TAbilityApplicationService tAbilityApplicationService;
|
||||
|
@ -267,6 +271,12 @@ public class ActHistoryService {
|
|||
if (resourceMountApplyDTO != null) {
|
||||
dto.setName(resourceMountApplyDTO.getResourceDTO().getName());
|
||||
dto.setResourceId(resourceMountApplyDTO.getResourceDTO().getId().toString());
|
||||
} else {
|
||||
ResourceDTO resourceDTO = resourceService.get(Long.valueOf(dto.getBusinessKey()));
|
||||
if (resourceDTO != null) {
|
||||
dto.setName(resourceDTO.getName());
|
||||
dto.setResourceId(resourceDTO.getId().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package io.renren.modules.resource.dao;
|
|||
import io.renren.common.dao.BaseDao;
|
||||
import io.renren.modules.resource.dto.ResourceDTO;
|
||||
import io.renren.modules.resource.entity.ResourceEntity;
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
@ -37,4 +38,12 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
|
|||
@Param("orderType") String orderType);
|
||||
|
||||
List<Map> selectApplyArea(Long userId);
|
||||
|
||||
/**
|
||||
* 获取各类资源数目
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@MapKey("type")
|
||||
List<Map<String, Object>> getAmountGroupByType();
|
||||
}
|
|
@ -7,6 +7,7 @@ import io.renren.modules.resource.entity.AttrEntity;
|
|||
import io.renren.modules.resource.entity.ResourceEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 资源表
|
||||
|
@ -38,4 +39,5 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
|
|||
|
||||
Object selectRecommend();
|
||||
|
||||
List<Map<String, Object>> getAmountGroupByType();
|
||||
}
|
|
@ -251,4 +251,10 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getAmountGroupByType() {
|
||||
List<Map<String, Object>> amountInfo = resourceDao.getAmountGroupByType();
|
||||
return amountInfo;
|
||||
}
|
||||
}
|
|
@ -77,6 +77,7 @@ public class ShiroConfig {
|
|||
*/
|
||||
filterMap.put("/upload", "anon");
|
||||
filterMap.put("/upload/**", "anon");
|
||||
filterMap.put("/census/center/**", "anon"); // 全局各类统计
|
||||
|
||||
filterMap.put("/**", "oauth2");
|
||||
shiroFilter.setFilterChainDefinitionMap(filterMap);
|
||||
|
|
|
@ -39,4 +39,6 @@ public interface SysUserDao extends BaseDao<SysUserEntity> {
|
|||
* @return
|
||||
*/
|
||||
SysUserEntity getByDeptIdAndRoleId(@Param("deptId") Long deptId, @Param("roleId") Long roleId);
|
||||
|
||||
Long countAllUser();
|
||||
}
|
|
@ -48,4 +48,11 @@ public interface SysUserService extends BaseService<SysUserEntity> {
|
|||
|
||||
SysUserDTO getByDeptIdAndRoleId(Long deptId, Long roleId);
|
||||
|
||||
/**
|
||||
* 统计所有有效的用户
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Long countAllUser();
|
||||
|
||||
}
|
||||
|
|
|
@ -167,4 +167,14 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
return ConvertUtils.sourceToTarget(entity, SysUserDTO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计所有有效的用户
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Long countAllUser() {
|
||||
return baseDao.countAllUser();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
big_date:
|
||||
name: 青岛市大数据发展管理局
|
||||
assignee_role_name: 部门审批人
|
||||
# 需要进行统计数目的资源 type
|
||||
census:
|
||||
type: 组件服务,应用资源,基础设施,数据资源,知识库
|
||||
# Tomcat
|
||||
server:
|
||||
tomcat:
|
||||
|
|
|
@ -104,14 +104,19 @@
|
|||
IFNULL(trc.collectCount, 0) AS "collectCount",
|
||||
IFNULL(sd.name, '暂无部门信息') AS "deptName",
|
||||
IFNULL(trc2.isCollect, 'false') AS "isCollect",
|
||||
(IFNULL(tdr.visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(taa.applyCount, 0)+ IFNULL(trc.collectCount, 0)) AS total
|
||||
(IFNULL(tdr.visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(taa.applyCount, 0)+ IFNULL(trc.collectCount, 0)) AS
|
||||
total
|
||||
FROM
|
||||
tb_data_resource tdr
|
||||
LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id
|
||||
LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trs ON tdr.id = trs.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect" FROM tb_resource_collection WHERE
|
||||
LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP
|
||||
BY resource_id ) trs ON tdr.id = trs.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =
|
||||
0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
|
||||
= 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect"
|
||||
FROM tb_resource_collection WHERE
|
||||
1 = 1
|
||||
AND del_flag = 0
|
||||
AND user_id = #{dto.creator}
|
||||
|
@ -174,9 +179,12 @@
|
|||
(IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)+ IFNULL(collectCount,0)) AS total
|
||||
FROM
|
||||
tb_data_resource tdr
|
||||
LEFT JOIN ( SELECT resource_id, SUM(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trs ON tdr.id = trs.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, SUM(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP
|
||||
BY resource_id ) trs ON tdr.id = trs.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =
|
||||
0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
|
||||
= 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
|
||||
WHERE
|
||||
1 = 1
|
||||
AND tdr.del_flag = 0
|
||||
|
@ -203,13 +211,18 @@
|
|||
FROM
|
||||
tb_data_resource tdr
|
||||
LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id
|
||||
LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trs ON tdr.id = trs.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect" FROM tb_resource_collection WHERE
|
||||
LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP
|
||||
BY resource_id ) trs ON tdr.id = trs.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =
|
||||
0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
|
||||
= 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect"
|
||||
FROM tb_resource_collection WHERE
|
||||
1 = 1 AND del_flag = 0 AND user_id = #{userId}
|
||||
GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, user_id, ( CASE approve_status WHEN '通过' THEN 'true' ELSE 'false' END ) AS "applyState" FROM t_ability_application WHERE
|
||||
LEFT JOIN ( SELECT resource_id, user_id, ( CASE approve_status WHEN '通过' THEN 'true' ELSE 'false' END ) AS
|
||||
"applyState" FROM t_ability_application WHERE
|
||||
1 = 1 AND del_flag = 0 AND user_id = #{userId}
|
||||
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
|
||||
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
|
||||
|
@ -230,13 +243,18 @@
|
|||
(IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)+ IFNULL(collectCount,0)) AS total
|
||||
FROM
|
||||
tb_data_resource tdr
|
||||
LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trs ON tdr.id = trs.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect" FROM tb_resource_collection WHERE
|
||||
LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP
|
||||
BY resource_id ) trs ON tdr.id = trs.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =
|
||||
0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
|
||||
= 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect"
|
||||
FROM tb_resource_collection WHERE
|
||||
1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
|
||||
GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id
|
||||
LEFT JOIN ( SELECT resource_id, user_id, ( CASE approve_status WHEN '通过' THEN 'true' ELSE 'false' END ) AS "applyState" FROM t_ability_application WHERE
|
||||
LEFT JOIN ( SELECT resource_id, user_id, ( CASE approve_status WHEN '通过' THEN 'true' ELSE 'false' END ) AS
|
||||
"applyState" FROM t_ability_application WHERE
|
||||
1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
|
||||
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
|
||||
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
|
||||
|
@ -288,4 +306,16 @@
|
|||
WHERE
|
||||
temp.total != 0
|
||||
</select>
|
||||
|
||||
<select id="getAmountGroupByType" resultType="java.util.Map">
|
||||
SELECT
|
||||
COUNT( id ) AS amount,
|
||||
type AS type
|
||||
FROM
|
||||
tb_data_resource
|
||||
WHERE
|
||||
del_flag = 0
|
||||
GROUP BY
|
||||
type
|
||||
</select>
|
||||
</mapper>
|
|
@ -65,5 +65,13 @@
|
|||
AND t2.dept_id = #{deptId}
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="countAllUser" resultType="java.lang.Long">
|
||||
SELECT
|
||||
COUNT( id )
|
||||
FROM
|
||||
sys_user
|
||||
WHERE
|
||||
`status` = 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue