1、修改 能力统计列表和详情-所有详情展示的sql语句,统计以当前部门为准,不包含其下级部门

This commit is contained in:
yitonglei 2022-07-07 15:59:58 +08:00
parent 7c5362464e
commit 6b5c67f60e
3 changed files with 50 additions and 57 deletions

View File

@ -162,11 +162,11 @@ public class CensusControllerV3 {
@ApiImplicitParam(name = "resourceType", value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String")
})
public Result<List<Map<String, Object>>> assemblerScoreInfo(@ApiIgnore @RequestParam Map<String, Object> params) {
Object[] args = {params.get("resourceType"), params.get("id"), params.get("id")};
Object[] args = {params.get("resourceType"), params.get("id")};
List<Map<String, Object>> maps = jdbcTemplate.queryForList("SELECT COUNT(a.score) as scoreNum,a.score FROM tb_resource_score a INNER JOIN tb_data_resource b\n" +
"ON a.resource_id = b.id INNER JOIN sys_dept c ON b.dept_id = c.id\n" +
"WHERE a.del_flag = 0 AND a.score is not null AND b.type = ? AND b.del_flag = 0\n" +
"AND c.id = ? OR INSTR(c.pids,?) GROUP BY a.score", args);
" ON a.resource_id = b.id \n" +
" WHERE a.del_flag = 0 AND a.score is not null AND b.type = ? AND b.dept_id = ? AND b.del_flag = 0\n" +
" GROUP BY a.score", args);
return new Result<List<Map<String, Object>>>().ok(maps);
}
@ -188,16 +188,13 @@ public class CensusControllerV3 {
@ApiImplicitParam(name = "resourceType", value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String")
})
public Result<List<Map<String, Object>>> assemblerCaredTopInfo(@ApiIgnore @RequestParam Map<String, Object> params) {
Object[] args = {params.get("id"), params.get("id"), params.get("resourceType")};
Object[] args = { params.get("resourceType"),params.get("id")};
List<Map<String, Object>> maps = jdbcTemplate.queryForList("SELECT a.resource_id,b.name,COUNT(a.id) AS resourceCarNum FROM tb_resource_car a \n" +
" INNER JOIN tb_data_resource b ON a.resource_id = b.id\n" +
" INNER JOIN sys_dept c ON b.dept_id = c.id\n" +
" WHERE (c.id = ? OR INSTR(c.pids,?)) AND b.type = ?\n" +
" AND a.del_flag = 0\n" +
" GROUP BY a.resource_id,b.name \n" +
" ORDER BY COUNT(a.id) DESC\n" +
" LIMIT 5", args);
" INNER JOIN tb_data_resource b ON a.resource_id = b.id\n" +
" WHERE b.type = ? AND b.dept_id = ? AND b.del_flag =0 \n" +
" AND a.del_flag = 0 GROUP BY a.resource_id,b.name \n" +
" ORDER BY COUNT(a.id) DESC LIMIT 5", args);
return new Result<List<Map<String, Object>>>().ok(maps);
}
@ -211,11 +208,10 @@ public class CensusControllerV3 {
@ApiImplicitParam(name = "resourceType", value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String")
})
public Result<List<Map<String, Object>>> assemblerUsedInfo(@ApiIgnore @RequestParam Map<String, Object> params) {
Object[] ps = {params.get("id"), params.get("id"), params.get("resourceType")};
Object[] ps = {params.get("resourceType"),params.get("id") };
List<Map<String, Object>> maps = jdbcTemplate.queryForList("SELECT count(b.attr_value) as nums,b.attr_value FROM tb_data_resource a INNER JOIN tb_data_attr b ON a.id = b.data_resource_id\n" +
"INNER JOIN sys_dept c ON a.dept_id = c.id \n" +
"WHERE a.del_flag = 0 AND b.del_flag = 0 AND (c.id = ? OR INSTR(c.pids,?)) and a.type = ? and b.attr_type = '组件类型'\n" +
"GROUP BY b.attr_value", ps);
" WHERE a.type = ? and a.del_flag = 0 AND a.dept_id = ? and b.attr_type = '组件类型' AND b.del_flag = 0\n" +
" GROUP BY b.attr_value", ps);
return new Result<List<Map<String, Object>>>().ok(maps);
}
@ -257,18 +253,16 @@ public class CensusControllerV3 {
@ApiImplicitParam(name = "resourceType", value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String")
})
public Result<List<Map<String, Object>>> assemblerUseInfo(@ApiIgnore @RequestParam Map<String, Object> params) {
Object[] ps = {params.get("id"), params.get("id"), params.get("resourceType")};
Object[] ps = {params.get("id"),params.get("resourceType")};
List<Map<String, Object>> maps = jdbcTemplate.queryForList("SELECT COUNT(n.id) AS num,n.attr_value FROM\n" +
"(\n" +
"\tSELECT DISTINCT(c.id) AS id,c.name FROM \n" +
"\t(\n" +
"\t\tSELECT a.id FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id \n" +
"\t\tWHERE a.del_flag = 0 AND a.type='应用资源' AND (b.id = ? OR INSTR(b.pids,?))\n" +
"\t) a \n" +
"\tINNER JOIN tb_data_resource_rel b ON a.id = b.key_id INNER JOIN tb_data_resource c ON b.reference_id = c.id\n" +
"\tWHERE b.del_flag = 0 AND c.type = ? AND c.del_flag = 0 \n" +
"\t \n" +
") m INNER JOIN tb_data_attr n ON m.id = n.data_resource_id WHERE n.del_flag = 0 AND n.attr_type = '组件类型' GROUP BY n.attr_value", ps);
" (\n" +
" SELECT DISTINCT(c.id) AS id,c.name FROM \n" +
" (\n" +
" SELECT a.id FROM tb_data_resource a WHERE a.del_flag = 0 AND a.type='应用资源' AND a.dept_id = ?\n" +
" ) a \n" +
" INNER JOIN tb_data_resource_rel b ON a.id = b.key_id INNER JOIN tb_data_resource c ON b.reference_id = c.id\n" +
" WHERE b.del_flag = 0 AND c.type = ? AND c.del_flag = 0 \n" +
" ) m INNER JOIN tb_data_attr n ON m.id = n.data_resource_id WHERE n.del_flag = 0 AND n.attr_type = '组件类型' GROUP BY n.attr_value", ps);
return new Result<List<Map<String, Object>>>().ok(maps);
}
@ -278,13 +272,12 @@ public class CensusControllerV3 {
@LogOperation("应用贡献组件数量分布(算法、图层、开发、业务)")
@ApiImplicitParam(name = "id", value = "部门的id", paramType = "query", required = true, dataType = "long")
public Result<List<Map<String, Object>>> assemblerUseProjectInfo(Long id) {
Object[] ps = {id, id};
Object[] ps = {id};
List<Map<String, Object>> maps = jdbcTemplate.queryForList("SELECT count(c.id) as num,c.attr_value FROM \n" +
"(SELECT a.id,a.name FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id WHERE (b.id = ? OR INSTR(b.pids,?))\n" +
"AND a.type = '应用资源' AND a.del_flag = 0) a \n" +
"INNER JOIN tb_data_resource_rel b ON a.id = b.key_id \n" +
"INNER JOIN tb_data_attr c ON b.reference_id = c.data_resource_id\n" +
"WHERE c.attr_type = '应用类型' AND b.del_flag = 0 AND c.del_flag = 0 group by c.attr_value ", ps);
" (SELECT a.id,a.name FROM tb_data_resource a WHERE a.type = '应用资源' AND a.dept_id = ? AND a.del_flag = 0) a \n" +
" INNER JOIN tb_data_resource_rel b ON a.id = b.key_id \n" +
" INNER JOIN tb_data_attr c ON b.reference_id = c.data_resource_id\n" +
" WHERE c.attr_type = '应用类型' AND b.del_flag = 0 AND c.del_flag = 0 group by c.attr_value ", ps);
return new Result<List<Map<String, Object>>>().ok(maps);
}
@ -313,18 +306,17 @@ public class CensusControllerV3 {
@ApiImplicitParam(name = "resourceType", value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String")
})
public Result<List<Map<String, Object>>> assemblerUseScoreTopInfo(@ApiIgnore @RequestParam Map<String, Object> params) {
Object[] ps = {params.get("resourceType"), params.get("id"), params.get("id")};
Object[] ps = {params.get("id"), params.get("resourceType")};
List<Map<String, Object>> maps = jdbcTemplate.queryForList("SELECT SUM(IFNULL(b.score,0)) as score,a.name FROM \n" +
"(\n" +
"\tSELECT DISTINCT(c.id) AS id,c.name FROM \n" +
"\t\t(\n" +
"\t\t\tSELECT a.id FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id \n" +
"\t\t\tWHERE a.del_flag = 0 AND a.type='应用资源' AND (b.id = ? OR INSTR(b.pids,?))\n" +
"\t\t) a \n" +
"\t\tINNER JOIN tb_data_resource_rel b ON a.id = b.key_id INNER JOIN tb_data_resource c ON b.reference_id = c.id\n" +
"\t\tWHERE b.del_flag = 0 AND c.type = ? AND c.del_flag = 0 \n" +
")\ta \n" +
"INNER JOIN tb_resource_score b ON a.id = b.resource_id AND b.del_flag = 0 GROUP BY a.name ORDER BY score DESC LIMIT 5", ps);
" (\n" +
" SELECT DISTINCT(c.id) AS id,c.name FROM \n" +
" (\n" +
" SELECT a.id FROM tb_data_resource a WHERE a.del_flag = 0 AND a.type='应用资源' AND a.dept_id = ?\n" +
" ) a \n" +
" INNER JOIN tb_data_resource_rel b ON a.id = b.key_id INNER JOIN tb_data_resource c ON b.reference_id = c.id\n" +
" WHERE b.del_flag = 0 AND c.type = ? AND c.del_flag = 0 \n" +
" ) a \n" +
" INNER JOIN tb_resource_score b ON a.id = b.resource_id AND b.del_flag = 0 GROUP BY a.name ORDER BY score DESC LIMIT 5", ps);
return new Result<List<Map<String, Object>>>().ok(maps);
}
@ -382,13 +374,13 @@ public class CensusControllerV3 {
@ApiImplicitParam(name = "resourceType", value = "资源类型(组件服务、应用资源、基础设施、数据资源、知识库)", paramType = "query", dataType = "String")
})
public Result<List<Map<String, Object>>> applicationReleaseCapabilitySet(@ApiIgnore @RequestParam Map<String, Object> params) {
Object[] ps = {params.get("resourceType"), params.get("id"), params.get("id")};
Object[] ps = {params.get("resourceType"), params.get("id")};
List<Map<String, Object>> result = jdbcTemplate.queryForList("select m.attr_value as publisher,count(m.id) as num from \n" +
"(\n" +
"SELECT a.id,substring_index( a.attr_value, ';', b.help_topic_id +1 ),substring_index( substring_index( a.attr_value, ';', b.help_topic_id+1 ), ';',- 1 ) AS attr_value FROM \n" +
"(\n" +
"select a.id,c.attr_value from tb_data_resource a inner join sys_dept b on a.dept_id = b.id inner join tb_data_attr c \n" +
"on a.id = c.data_resource_id where a.del_flag = 0 and a.type = ? and (b.id = ? or instr(b.pids,?)) and c.attr_type = '发布端' and c.del_flag = 0\n" +
"on a.id = c.data_resource_id where a.del_flag = 0 and a.type = ? and b.id = ? and c.attr_type = '发布端' and c.del_flag = 0\n" +
"and c.attr_value is not null\n" +
") a\n" +
"INNER JOIN mysql.help_topic b ON b.help_topic_id < ( length( a.attr_value ) - length( REPLACE ( a.attr_value, ';', '' ) ) +1 )\n" +
@ -403,10 +395,12 @@ public class CensusControllerV3 {
@LogOperation("贡献组件分别被多少应用使用")
@ApiImplicitParam(name = "id", value = "部门id", paramType = "query", required = true, dataType = "long")
public Result<List<Map<String, Object>>> applicationUsedCapabilityNum(Long id) {
Object[] ps = {id, id};
List<Map<String, Object>> maps = jdbcTemplate.queryForList("SELECT COUNT(distinct(a.key_id)) as appNum,c.attr_value FROM (\n" +
"SELECT a.key_id ,a.reference_id FROM tb_data_resource_rel a INNER JOIN tb_data_resource b ON a.key_id = b.id INNER JOIN sys_dept c on b.dept_id = c.id WHERE a.del_flag = 0 AND (c.id = ? OR INSTR(c.pids,?)) ORDER BY a.key_id \n" +
") a \n" +
Object[] ps = {id};
List<Map<String, Object>> maps = jdbcTemplate.queryForList("SELECT COUNT(distinct(a.key_id)) as appNum,c.attr_value FROM \n" +
"\t(\n" +
"\t\tSELECT a.key_id ,a.reference_id FROM tb_data_resource_rel a INNER JOIN tb_data_resource b ON a.key_id = b.id WHERE a.del_flag = 0 \n" +
"\t\tAND b.dept_id = ? ORDER BY a.key_id \n" +
" ) a\n" +
"INNER JOIN tb_data_resource b ON a.reference_id = b.id INNER JOIN tb_data_attr c ON a.reference_id = c.data_resource_id \n" +
"WHERE c.attr_type = '组件类型' GROUP BY c.attr_value", ps);

View File

@ -1583,9 +1583,10 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override
public List<Map<String, Object>> assemblerCarDetail(Map<String, Object> params) {
List<Map<String, Object>> result = new ArrayList<>();
Object[] ps = {params.get("resourceType"), params.get("id"), params.get("id"), (Integer.parseInt(params.get("page").toString()) - 1) * Integer.parseInt(params.get("limit").toString()), Integer.parseInt(params.get("limit").toString())};
result = jdbcTemplate.queryForList("SELECT a.* FROM tb_resource_car a INNER JOIN sys_user b ON a.creator = b.id INNER JOIN sys_dept c ON b.dept_id = c.id INNER JOIN tb_data_resource d ON a.resource_id = d.id WHERE a.del_flag = 0 " +
"AND d.type = ? AND (c.id = ? OR INSTR(c.pids,?)) ORDER BY a.create_date DESC LIMIT ?,?", ps);
Object[] ps = {params.get("resourceType"), params.get("id"), (Integer.parseInt(params.get("page").toString()) - 1) * Integer.parseInt(params.get("limit").toString()), Integer.parseInt(params.get("limit").toString())};
result = jdbcTemplate.queryForList("SELECT a.* FROM tb_resource_car a INNER JOIN sys_user b ON a.creator = b.id " +
"INNER JOIN tb_data_resource d ON a.resource_id = d.id WHERE a.del_flag = 0 AND d.type = ? AND " +
"d.dept_id = ? AND d.del_flag = 0 ORDER BY a.create_date DESC LIMIT ?,?", ps);
return result;
}

View File

@ -1046,8 +1046,7 @@
COUNT( tdav.data_resource_id ) AS total
FROM
(SELECT a.* FROM tb_data_attr a INNER JOIN tb_data_resource c ON a.data_resource_id = c.id
INNER JOIN sys_dept b ON c.dept_id = b.id WHERE c.type =
#{resourceType} AND (b.id = #{id} OR INSTR(b.pids,#{id})) AND c.del_flag = 0) tdav
WHERE c.type = #{resourceType} AND c.dept_id = #{id} AND c.del_flag = 0) tdav
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value,
';', '' ) ) + 1 )
WHERE
@ -1068,8 +1067,7 @@
(
SELECT DISTINCT(c.id) AS id FROM
(
SELECT a.id FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id
WHERE a.del_flag = 0 AND a.type='应用资源' AND (b.id = #{id} OR INSTR(b.pids,#{id}))
SELECT a.id FROM tb_data_resource a WHERE a.del_flag = 0 AND a.type='应用资源' AND a.dept_id = #{id}
) a
INNER JOIN tb_data_resource_rel b ON a.id = b.key_id INNER JOIN tb_data_resource c ON b.reference_id = c.id
WHERE b.del_flag = 0 AND c.type = #{resourceType} AND c.del_flag = 0