资源数目统计

This commit is contained in:
wangliwen 2022-05-11 15:31:48 +08:00
parent cd7831e68c
commit 105b6b536c
12 changed files with 272 additions and 116 deletions

View File

@ -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);
}
}

View File

@ -6,6 +6,8 @@ import io.renren.modules.activiti.dto.ProcessInstanceDTO;
import io.renren.modules.activiti.dto.TaskDTO; import io.renren.modules.activiti.dto.TaskDTO;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO; import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.processForm.service.TAbilityApplicationService; 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.dto.TResourceMountApplyDTO;
import io.renren.modules.resourceMountApply.service.TResourceMountApplyService; import io.renren.modules.resourceMountApply.service.TResourceMountApplyService;
import io.renren.modules.security.user.SecurityUser; import io.renren.modules.security.user.SecurityUser;
@ -72,6 +74,8 @@ public class ActHistoryService {
@Autowired @Autowired
private SysUserService sysUserService; private SysUserService sysUserService;
@Autowired
private ResourceService resourceService;
@Autowired @Autowired
private TAbilityApplicationService tAbilityApplicationService; private TAbilityApplicationService tAbilityApplicationService;
@ -267,6 +271,12 @@ public class ActHistoryService {
if (resourceMountApplyDTO != null) { if (resourceMountApplyDTO != null) {
dto.setName(resourceMountApplyDTO.getResourceDTO().getName()); dto.setName(resourceMountApplyDTO.getResourceDTO().getName());
dto.setResourceId(resourceMountApplyDTO.getResourceDTO().getId().toString()); 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());
}
} }
} }
} }

View File

@ -3,6 +3,7 @@ package io.renren.modules.resource.dao;
import io.renren.common.dao.BaseDao; import io.renren.common.dao.BaseDao;
import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.entity.ResourceEntity; import io.renren.modules.resource.entity.ResourceEntity;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -10,11 +11,11 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* 资源表 * 资源表
* *
* @author dg * @author dg
* @since 1.0 2022-04-13 * @since 1.0 2022-04-13
*/ */
@Mapper @Mapper
public interface ResourceDao extends BaseDao<ResourceEntity> { public interface ResourceDao extends BaseDao<ResourceEntity> {
@ -28,13 +29,21 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
List<ResourceDTO> selectMostPopular(Map<String, Object> selectMap); List<ResourceDTO> selectMostPopular(Map<String, Object> selectMap);
ResourceDTO selectDTOById(@Param("id") Long id,@Param("userId") Long userId); ResourceDTO selectDTOById(@Param("id") Long id, @Param("userId") Long userId);
List<ResourceDTO> selectDTOPage(@Param("dto")ResourceDTO resourceDTO, List<ResourceDTO> selectDTOPage(@Param("dto") ResourceDTO resourceDTO,
@Param("pageNum") Integer pageNum, @Param("pageNum") Integer pageNum,
@Param("pageSize") Integer pageSize, @Param("pageSize") Integer pageSize,
@Param("orderField")String orderField, @Param("orderField") String orderField,
@Param("orderType") String orderType); @Param("orderType") String orderType);
List<Map> selectApplyArea(Long userId); List<Map> selectApplyArea(Long userId);
/**
* 获取各类资源数目
*
* @return
*/
@MapKey("type")
List<Map<String, Object>> getAmountGroupByType();
} }

View File

@ -7,11 +7,12 @@ import io.renren.modules.resource.entity.AttrEntity;
import io.renren.modules.resource.entity.ResourceEntity; import io.renren.modules.resource.entity.ResourceEntity;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 资源表 * 资源表
* *
* @author dg * @author dg
* @since 1.0 2022-04-13 * @since 1.0 2022-04-13
*/ */
public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO> { public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO> {
@ -38,4 +39,5 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
Object selectRecommend(); Object selectRecommend();
List<Map<String, Object>> getAmountGroupByType();
} }

View File

@ -251,4 +251,10 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
} }
return null; return null;
} }
@Override
public List<Map<String, Object>> getAmountGroupByType() {
List<Map<String, Object>> amountInfo = resourceDao.getAmountGroupByType();
return amountInfo;
}
} }

View File

@ -77,6 +77,7 @@ public class ShiroConfig {
*/ */
filterMap.put("/upload", "anon"); filterMap.put("/upload", "anon");
filterMap.put("/upload/**", "anon"); filterMap.put("/upload/**", "anon");
filterMap.put("/census/center/**", "anon"); // 全局各类统计
filterMap.put("/**", "oauth2"); filterMap.put("/**", "oauth2");
shiroFilter.setFilterChainDefinitionMap(filterMap); shiroFilter.setFilterChainDefinitionMap(filterMap);

View File

@ -39,4 +39,6 @@ public interface SysUserDao extends BaseDao<SysUserEntity> {
* @return * @return
*/ */
SysUserEntity getByDeptIdAndRoleId(@Param("deptId") Long deptId, @Param("roleId") Long roleId); SysUserEntity getByDeptIdAndRoleId(@Param("deptId") Long deptId, @Param("roleId") Long roleId);
Long countAllUser();
} }

View File

@ -48,4 +48,11 @@ public interface SysUserService extends BaseService<SysUserEntity> {
SysUserDTO getByDeptIdAndRoleId(Long deptId, Long roleId); SysUserDTO getByDeptIdAndRoleId(Long deptId, Long roleId);
/**
* 统计所有有效的用户
*
* @return
*/
Long countAllUser();
} }

View File

@ -167,4 +167,14 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
return ConvertUtils.sourceToTarget(entity, SysUserDTO.class); return ConvertUtils.sourceToTarget(entity, SysUserDTO.class);
} }
/**
* 统计所有有效的用户
*
* @return
*/
@Override
public Long countAllUser() {
return baseDao.countAllUser();
}
} }

View File

@ -2,6 +2,9 @@
big_date: big_date:
name: 青岛市大数据发展管理局 name: 青岛市大数据发展管理局
assignee_role_name: 部门审批人 assignee_role_name: 部门审批人
# 需要进行统计数目的资源 type
census:
type: 组件服务,应用资源,基础设施,数据资源,知识库
# Tomcat # Tomcat
server: server:
tomcat: tomcat:

View File

@ -89,7 +89,7 @@
SET del_flag = 1, SET del_flag = 1,
update_date = NOW() update_date = NOW()
WHERE 1 = 1 WHERE 1 = 1
AND id IN AND id IN
<foreach collection="ids" item="item" open="(" separator="," close=")"> <foreach collection="ids" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
@ -104,14 +104,19 @@
IFNULL(trc.collectCount, 0) AS "collectCount", IFNULL(trc.collectCount, 0) AS "collectCount",
IFNULL(sd.name, '暂无部门信息') AS "deptName", IFNULL(sd.name, '暂无部门信息') AS "deptName",
IFNULL(trc2.isCollect, 'false') AS "isCollect", 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 FROM
tb_data_resource tdr tb_data_resource tdr
LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id 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, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP
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 BY resource_id ) trs ON tdr.id = trs.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, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect" FROM tb_resource_collection WHERE 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 1 = 1
AND del_flag = 0 AND del_flag = 0
AND user_id = #{dto.creator} AND user_id = #{dto.creator}
@ -121,18 +126,18 @@
WHERE 1 = 1 WHERE 1 = 1
AND tdr.type = #{dto.type} AND tdr.type = #{dto.type}
AND tdr.del_flag = 0 AND tdr.del_flag = 0
<if test="dto.name != null and dto.name != ''" > <if test="dto.name != null and dto.name != ''">
AND tdr.name like CONCAT('%',#{dto.name},'%') AND tdr.name like CONCAT('%',#{dto.name},'%')
</if> </if>
<if test="dto.districtId != null and dto.districtId != ''" > <if test="dto.districtId != null and dto.districtId != ''">
AND tdr.district_id = #{dto.districtId} AND tdr.district_id = #{dto.districtId}
</if> </if>
<if test="dto.deptId != null and dto.deptId != ''" > <if test="dto.deptId != null and dto.deptId != ''">
AND tdr.dept_id = #{dto.deptId} AND tdr.dept_id = #{dto.deptId}
</if> </if>
<if test="dto.infoList.size > 0"> <if test="dto.infoList.size > 0">
AND AND
tda.data_resource_id IN ( tda.data_resource_id IN (
SELECT data_resource_id SELECT data_resource_id
FROM ( FROM (
SELECT tb.data_resource_id SELECT tb.data_resource_id
@ -153,102 +158,115 @@
<select id="selectTypeCount" resultType="java.util.Map"> <select id="selectTypeCount" resultType="java.util.Map">
SELECT SELECT
type, type,
count(id) AS "count" count(id) AS "count"
FROM tb_data_resource FROM tb_data_resource
WHERE 1 = 1 WHERE 1 = 1
AND del_flag = 0 AND del_flag = 0
<if test="deptId != null and deptId != ''"> <if test="deptId != null and deptId != ''">
AND dept_id = #{deptId} AND dept_id = #{deptId}
</if> </if>
GROUP BY type GROUP BY type
ORDER BY type ORDER BY type
</select> </select>
<select id="selectMostPopular" resultType="io.renren.modules.resource.dto.ResourceDTO"> <select id="selectMostPopular" resultType="io.renren.modules.resource.dto.ResourceDTO">
SELECT SELECT
tdr.*, tdr.*,
IFNULL(trs.score, 0 ) AS "score", IFNULL(trs.score, 0 ) AS "score",
IFNULL(taa.applyCount, 0 ) AS "applyCount", IFNULL(taa.applyCount, 0 ) AS "applyCount",
IFNULL(trc.collectCount, 0) AS "collectCount", IFNULL(trc.collectCount, 0) AS "collectCount",
(IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)+ IFNULL(collectCount,0)) AS total (IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)+ IFNULL(collectCount,0)) AS total
FROM FROM
tb_data_resource tdr 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, SUM(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP
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 BY resource_id ) trs ON tdr.id = trs.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, 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 WHERE
1 = 1 1 = 1
AND tdr.del_flag = 0 AND tdr.del_flag = 0
<if test="type != null and type != ''"> <if test="type != null and type != ''">
AND tdr.type = #{type} AND tdr.type = #{type}
</if> </if>
<if test="name != null and name != ''"> <if test="name != null and name != ''">
AND tdr.name LIKE CONCAT('%',#{name},'%') AND tdr.name LIKE CONCAT('%',#{name},'%')
</if> </if>
ORDER BY ${orderFiled} ${orderType} ORDER BY ${orderFiled} ${orderType}
LIMIT ${pageNum}, ${pageSize} LIMIT ${pageNum}, ${pageSize}
</select> </select>
<select id="selectDTOById" resultMap="resourceDTO"> <select id="selectDTOById" resultMap="resourceDTO">
SELECT SELECT
tdr.*, tdr.*,
tda.*, tda.*,
IFNULL(trs.score, 0 ) AS "score", IFNULL(trs.score, 0 ) AS "score",
IFNULL(taa.applyCount, 0 ) AS "applyCount", IFNULL(taa.applyCount, 0 ) AS "applyCount",
IFNULL(trc.collectCount, 0) AS "collectCount", IFNULL(trc.collectCount, 0) AS "collectCount",
sd.name as "deptName", sd.name as "deptName",
IFNULL(trc2.isCollect, 'false') AS "isCollect", IFNULL(trc2.isCollect, 'false') AS "isCollect",
IFNULL(taa2.applyState, 'false') AS "applyState" IFNULL(taa2.applyState, 'false') AS "applyState"
FROM FROM
tb_data_resource tdr tb_data_resource tdr
LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id 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, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP
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 BY resource_id ) trs ON tdr.id = trs.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, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect" FROM tb_resource_collection WHERE 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
1 = 1 AND del_flag = 0 AND user_id = #{userId} LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id = 0 GROUP BY resource_id ) trc ON tdr.id = trc.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 COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect"
1 = 1 AND del_flag = 0 AND user_id = #{userId} FROM tb_resource_collection WHERE
GROUP BY id) taa2 ON tdr.id = taa2.resource_id 1 = 1 AND del_flag = 0 AND user_id = #{userId}
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id 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
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
WHERE 1 = 1 WHERE 1 = 1
<!-- AND tdr.del_flag = 0--> <!-- AND tdr.del_flag = 0-->
AND tdr.id = #{id} AND tdr.id = #{id}
</select> </select>
<select id="selectDTOPage" resultType="io.renren.modules.resource.dto.ResourceDTO"> <select id="selectDTOPage" resultType="io.renren.modules.resource.dto.ResourceDTO">
SELECT SELECT
tdr.*, tdr.*,
IFNULL(trs.score, 0 ) AS "score", IFNULL(trs.score, 0 ) AS "score",
IFNULL(taa.applyCount, 0 ) AS "applyCount", IFNULL(taa.applyCount, 0 ) AS "applyCount",
IFNULL(trc.collectCount, 0) AS "collectCount", IFNULL(trc.collectCount, 0) AS "collectCount",
sd.name AS "deptName", sd.name AS "deptName",
IFNULL(trc2.isCollect, 'false') AS "isCollect", IFNULL(trc2.isCollect, 'false') AS "isCollect",
IFNULL(taa2.applyState, 'false') AS "applyState", IFNULL(taa2.applyState, 'false') AS "applyState",
(IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)+ IFNULL(collectCount,0)) AS total (IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)+ IFNULL(collectCount,0)) AS total
FROM FROM
tb_data_resource tdr 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, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP
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 BY resource_id ) trs ON tdr.id = trs.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, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect" FROM tb_resource_collection WHERE 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
1 = 1 AND del_flag = 0 AND user_id = #{dto.creator} LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id = 0 GROUP BY resource_id ) trc ON tdr.id = trc.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 COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect"
1 = 1 AND del_flag = 0 AND user_id = #{dto.creator} FROM tb_resource_collection WHERE
GROUP BY id) taa2 ON tdr.id = taa2.resource_id 1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id 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
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
WHERE 1 = 1 WHERE 1 = 1
AND tdr.del_flag = 0 AND tdr.del_flag = 0
<if test="dto.name != null and dto.name != ''" > <if test="dto.name != null and dto.name != ''">
AND tdr.name LIKE CONCAT('%',#{dto.name},'%') AND tdr.name LIKE CONCAT('%',#{dto.name},'%')
</if> </if>
<if test="dto.type != null and dto.type != ''" > <if test="dto.type != null and dto.type != ''">
AND tdr.type = #{dto.type} AND tdr.type = #{dto.type}
</if> </if>
<if test="dto.districtId != null and dto.districtId != ''" > <if test="dto.districtId != null and dto.districtId != ''">
AND tdr.district_id = #{dto.districtId} AND tdr.district_id = #{dto.districtId}
</if> </if>
ORDER BY ${orderField} ${orderType} ORDER BY ${orderField} ${orderType}
@ -257,35 +275,47 @@
<select id="selectApplyArea" resultType="java.util.Map"> <select id="selectApplyArea" resultType="java.util.Map">
SELECT SELECT
* *
FROM FROM
( (
SELECT SELECT
attr_value, attr_value,
IFNULL( COUNT( trc.id ), 0 ) AS "colCount", IFNULL( COUNT( trc.id ), 0 ) AS "colCount",
IFNULL( COUNT( taa.id ), 0 ) AS "aplCount", IFNULL( COUNT( taa.id ), 0 ) AS "aplCount",
( (
IFNULL( COUNT( trc.id ), 0 ) + IFNULL( COUNT( taa.id ), 0 )) AS total IFNULL( COUNT( trc.id ), 0 ) + IFNULL( COUNT( taa.id ), 0 )) AS total
FROM FROM
tb_data_attr tda tb_data_attr tda
LEFT JOIN tb_resource_collection trc ON tda.data_resource_id = trc.resource_id LEFT JOIN tb_resource_collection trc ON tda.data_resource_id = trc.resource_id
AND trc.del_flag = 0 AND trc.del_flag = 0
AND trc.user_id = #{userId} AND trc.user_id = #{userId}
LEFT JOIN t_ability_application taa ON tda.data_resource_id = taa.resource_id LEFT JOIN t_ability_application taa ON tda.data_resource_id = taa.resource_id
AND taa.del_flag = 0 AND taa.del_flag = 0
AND taa.user_id = #{userId} AND taa.user_id = #{userId}
WHERE
1 = 1
AND tda.attr_type = '应用领域'
AND tda.del_flag = 0
AND ( attr_value != '' AND attr_value IS NOT NULL )
GROUP BY
attr_value
ORDER BY
total DESC
) temp
WHERE WHERE
temp.total != 0 1 = 1
AND tda.attr_type = '应用领域'
AND tda.del_flag = 0
AND ( attr_value != '' AND attr_value IS NOT NULL )
GROUP BY
attr_value
ORDER BY
total DESC
) temp
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> </select>
</mapper> </mapper>

View File

@ -6,10 +6,10 @@
<select id="getList" resultType="io.renren.modules.sys.entity.SysUserEntity"> <select id="getList" resultType="io.renren.modules.sys.entity.SysUserEntity">
select t1.*, (select t2.name from sys_dept t2 where t2.id=t1.dept_id) deptName select t1.*, (select t2.name from sys_dept t2 where t2.id=t1.dept_id) deptName
from sys_user t1 from sys_user t1
<if test = "postId != null and postId.trim() != '' "> <if test="postId != null and postId.trim() != '' ">
left join sys_user_post t3 on t1.id = t3.user_id left join sys_user_post t3 on t1.id = t3.user_id
</if> </if>
where t1.super_admin = 0 where t1.super_admin = 0
<if test="username != null and username.trim() != ''"> <if test="username != null and username.trim() != ''">
and t1.username like #{username} and t1.username like #{username}
</if> </if>
@ -65,5 +65,13 @@
AND t2.dept_id = #{deptId} AND t2.dept_id = #{deptId}
LIMIT 1 LIMIT 1
</select> </select>
<select id="countAllUser" resultType="java.lang.Long">
SELECT
COUNT( id )
FROM
sys_user
WHERE
`status` = 1
</select>
</mapper> </mapper>