资源数目统计
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;
|
||||
|
||||
|
@ -10,11 +11,11 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 资源表
|
||||
*
|
||||
* @author dg
|
||||
* @since 1.0 2022-04-13
|
||||
*/
|
||||
* 资源表
|
||||
*
|
||||
* @author dg
|
||||
* @since 1.0 2022-04-13
|
||||
*/
|
||||
@Mapper
|
||||
public interface ResourceDao extends BaseDao<ResourceEntity> {
|
||||
|
||||
|
@ -28,13 +29,21 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
|
|||
|
||||
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("pageSize") Integer pageSize,
|
||||
@Param("orderField")String orderField,
|
||||
@Param("orderField") String orderField,
|
||||
@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:
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
SET del_flag = 1,
|
||||
update_date = NOW()
|
||||
WHERE 1 = 1
|
||||
AND id IN
|
||||
AND id IN
|
||||
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
|
@ -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}
|
||||
|
@ -121,18 +126,18 @@
|
|||
WHERE 1 = 1
|
||||
AND tdr.type = #{dto.type}
|
||||
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},'%')
|
||||
</if>
|
||||
<if test="dto.districtId != null and dto.districtId != ''" >
|
||||
AND tdr.district_id = #{dto.districtId}
|
||||
<if test="dto.districtId != null and dto.districtId != ''">
|
||||
AND tdr.district_id = #{dto.districtId}
|
||||
</if>
|
||||
<if test="dto.deptId != null and dto.deptId != ''" >
|
||||
AND tdr.dept_id = #{dto.deptId}
|
||||
<if test="dto.deptId != null and dto.deptId != ''">
|
||||
AND tdr.dept_id = #{dto.deptId}
|
||||
</if>
|
||||
<if test="dto.infoList.size > 0">
|
||||
AND
|
||||
tda.data_resource_id IN (
|
||||
tda.data_resource_id IN (
|
||||
SELECT data_resource_id
|
||||
FROM (
|
||||
SELECT tb.data_resource_id
|
||||
|
@ -153,102 +158,115 @@
|
|||
|
||||
<select id="selectTypeCount" resultType="java.util.Map">
|
||||
SELECT
|
||||
type,
|
||||
count(id) AS "count"
|
||||
type,
|
||||
count(id) AS "count"
|
||||
FROM tb_data_resource
|
||||
WHERE 1 = 1
|
||||
AND del_flag = 0
|
||||
<if test="deptId != null and deptId != ''">
|
||||
AND del_flag = 0
|
||||
<if test="deptId != null and deptId != ''">
|
||||
AND dept_id = #{deptId}
|
||||
</if>
|
||||
</if>
|
||||
GROUP BY type
|
||||
ORDER BY type
|
||||
</select>
|
||||
|
||||
<select id="selectMostPopular" resultType="io.renren.modules.resource.dto.ResourceDTO">
|
||||
SELECT
|
||||
tdr.*,
|
||||
IFNULL(trs.score, 0 ) AS "score",
|
||||
IFNULL(taa.applyCount, 0 ) AS "applyCount",
|
||||
IFNULL(trc.collectCount, 0) AS "collectCount",
|
||||
(IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)+ IFNULL(collectCount,0)) AS total
|
||||
tdr.*,
|
||||
IFNULL(trs.score, 0 ) AS "score",
|
||||
IFNULL(taa.applyCount, 0 ) AS "applyCount",
|
||||
IFNULL(trc.collectCount, 0) AS "collectCount",
|
||||
(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
|
||||
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
|
||||
WHERE
|
||||
1 = 1
|
||||
AND tdr.del_flag = 0
|
||||
<if test="type != null and type != ''">
|
||||
AND tdr.type = #{type}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
AND tdr.name LIKE CONCAT('%',#{name},'%')
|
||||
</if>
|
||||
1 = 1
|
||||
AND tdr.del_flag = 0
|
||||
<if test="type != null and type != ''">
|
||||
AND tdr.type = #{type}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
AND tdr.name LIKE CONCAT('%',#{name},'%')
|
||||
</if>
|
||||
ORDER BY ${orderFiled} ${orderType}
|
||||
LIMIT ${pageNum}, ${pageSize}
|
||||
</select>
|
||||
|
||||
<select id="selectDTOById" resultMap="resourceDTO">
|
||||
SELECT
|
||||
tdr.*,
|
||||
tda.*,
|
||||
IFNULL(trs.score, 0 ) AS "score",
|
||||
IFNULL(taa.applyCount, 0 ) AS "applyCount",
|
||||
IFNULL(trc.collectCount, 0) AS "collectCount",
|
||||
sd.name as "deptName",
|
||||
IFNULL(trc2.isCollect, 'false') AS "isCollect",
|
||||
IFNULL(taa2.applyState, 'false') AS "applyState"
|
||||
tdr.*,
|
||||
tda.*,
|
||||
IFNULL(trs.score, 0 ) AS "score",
|
||||
IFNULL(taa.applyCount, 0 ) AS "applyCount",
|
||||
IFNULL(trc.collectCount, 0) AS "collectCount",
|
||||
sd.name as "deptName",
|
||||
IFNULL(trc2.isCollect, 'false') AS "isCollect",
|
||||
IFNULL(taa2.applyState, 'false') AS "applyState"
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
<!-- AND tdr.del_flag = 0-->
|
||||
AND tdr.id = #{id}
|
||||
<!-- AND tdr.del_flag = 0-->
|
||||
AND tdr.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectDTOPage" resultType="io.renren.modules.resource.dto.ResourceDTO">
|
||||
SELECT
|
||||
tdr.*,
|
||||
IFNULL(trs.score, 0 ) AS "score",
|
||||
IFNULL(taa.applyCount, 0 ) AS "applyCount",
|
||||
IFNULL(trc.collectCount, 0) AS "collectCount",
|
||||
sd.name AS "deptName",
|
||||
IFNULL(trc2.isCollect, 'false') AS "isCollect",
|
||||
IFNULL(taa2.applyState, 'false') AS "applyState",
|
||||
tdr.*,
|
||||
IFNULL(trs.score, 0 ) AS "score",
|
||||
IFNULL(taa.applyCount, 0 ) AS "applyCount",
|
||||
IFNULL(trc.collectCount, 0) AS "collectCount",
|
||||
sd.name AS "deptName",
|
||||
IFNULL(trc2.isCollect, 'false') AS "isCollect",
|
||||
IFNULL(taa2.applyState, 'false') AS "applyState",
|
||||
(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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
AND tdr.del_flag = 0
|
||||
<if test="dto.name != null and dto.name != ''" >
|
||||
AND tdr.del_flag = 0
|
||||
<if test="dto.name != null and dto.name != ''">
|
||||
AND tdr.name LIKE CONCAT('%',#{dto.name},'%')
|
||||
</if>
|
||||
<if test="dto.type != null and dto.type != ''" >
|
||||
<if test="dto.type != null and dto.type != ''">
|
||||
AND tdr.type = #{dto.type}
|
||||
</if>
|
||||
<if test="dto.districtId != null and dto.districtId != ''" >
|
||||
<if test="dto.districtId != null and dto.districtId != ''">
|
||||
AND tdr.district_id = #{dto.districtId}
|
||||
</if>
|
||||
ORDER BY ${orderField} ${orderType}
|
||||
|
@ -257,35 +275,47 @@
|
|||
|
||||
<select id="selectApplyArea" resultType="java.util.Map">
|
||||
SELECT
|
||||
*
|
||||
*
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
attr_value,
|
||||
IFNULL( COUNT( trc.id ), 0 ) AS "colCount",
|
||||
IFNULL( COUNT( taa.id ), 0 ) AS "aplCount",
|
||||
(
|
||||
IFNULL( COUNT( trc.id ), 0 ) + IFNULL( COUNT( taa.id ), 0 )) AS total
|
||||
FROM
|
||||
tb_data_attr tda
|
||||
LEFT JOIN tb_resource_collection trc ON tda.data_resource_id = trc.resource_id
|
||||
AND trc.del_flag = 0
|
||||
AND trc.user_id = #{userId}
|
||||
LEFT JOIN t_ability_application taa ON tda.data_resource_id = taa.resource_id
|
||||
AND taa.del_flag = 0
|
||||
AND taa.user_id = #{userId}
|
||||
(
|
||||
SELECT
|
||||
attr_value,
|
||||
IFNULL( COUNT( trc.id ), 0 ) AS "colCount",
|
||||
IFNULL( COUNT( taa.id ), 0 ) AS "aplCount",
|
||||
(
|
||||
IFNULL( COUNT( trc.id ), 0 ) + IFNULL( COUNT( taa.id ), 0 )) AS total
|
||||
FROM
|
||||
tb_data_attr tda
|
||||
LEFT JOIN tb_resource_collection trc ON tda.data_resource_id = trc.resource_id
|
||||
AND trc.del_flag = 0
|
||||
AND trc.user_id = #{userId}
|
||||
LEFT JOIN t_ability_application taa ON tda.data_resource_id = taa.resource_id
|
||||
AND taa.del_flag = 0
|
||||
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
|
||||
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>
|
||||
</mapper>
|
|
@ -6,10 +6,10 @@
|
|||
<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
|
||||
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
|
||||
</if>
|
||||
where t1.super_admin = 0
|
||||
where t1.super_admin = 0
|
||||
<if test="username != null and username.trim() != ''">
|
||||
and t1.username like #{username}
|
||||
</if>
|
||||
|
@ -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