。。。
This commit is contained in:
parent
8138361207
commit
46de17be45
|
@ -136,24 +136,34 @@ public class CensusControllerV2 {
|
||||||
return new Result().ok(result);
|
return new Result().ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/applicationNum")
|
@GetMapping("/districtResourceRank")
|
||||||
@ApiOperation("应用资源区县市排名")
|
@ApiOperation("应用资源区县市排名")
|
||||||
@LogOperation("应用资源数量统计")
|
@LogOperation("应用资源数量统计")
|
||||||
public Result<List<Map<String, Object>>> districtResourceRank() {
|
public Result<List<Map<String, Object>>> districtResourceRank() {
|
||||||
List<Map<String, Object>> result = Collections.synchronizedList(new ArrayList<>());
|
List<Map<String, Object>> result = Collections.synchronizedList(new ArrayList<>());
|
||||||
List<Map<String, Object>> district = jdbcTemplate.queryForList("SELECT * FROM sys_dept WHERE type = 2");
|
List<Map<String, Object>> district = jdbcTemplate.queryForList("SELECT * FROM sys_dept WHERE type = 2");
|
||||||
// Map<String, List<Map<String, Object>>> listMap
|
List<Map<String, Long>> listMap =
|
||||||
// =
|
|
||||||
district.stream().map(index -> {
|
district.stream().map(index -> {
|
||||||
Map<String, Long> re = new LinkedHashMap<>();
|
Map<String, Long> re = new LinkedHashMap<>();
|
||||||
Long count = jdbcTemplate.queryForObject(String.format("SELECT COUNT(id) FROM tb_data_resource WHERE dept_id = %s AND type = '应用资源' AND del_flag = 0;", index.get("id").toString()), Long.class);
|
String sql = String.format("SELECT COUNT(id) FROM tb_data_resource WHERE dept_id = %s AND type = '应用资源' AND del_flag = 0;", index.get("id").toString());
|
||||||
|
logger.info(sql);
|
||||||
|
Long count = jdbcTemplate.queryForObject(sql, Long.class);
|
||||||
if (!"0".equals(index.get("pid").toString())) { // 有上级部门
|
if (!"0".equals(index.get("pid").toString())) { // 有上级部门
|
||||||
re.put(index.get("pid").toString(), count);
|
re.put(index.get("pid").toString(), count);
|
||||||
} else {
|
} else {
|
||||||
re.put(index.get("id").toString(), count);
|
re.put(index.get("id").toString(), count);
|
||||||
}
|
}
|
||||||
return re;
|
return re;
|
||||||
}).distinct().collect(Collectors.groupingBy(m -> m.keySet().stream().findFirst().get()));
|
}).distinct().collect(Collectors.toList());
|
||||||
|
Map<String, List<Map<String, Long>>> i =
|
||||||
|
listMap.stream().collect(Collectors.groupingBy(m -> m.keySet().stream().findFirst().toString()));
|
||||||
|
result = i.keySet().stream().map(index -> {
|
||||||
|
Map<String, Object> re = new LinkedHashMap<>();
|
||||||
|
re.put("deptId", index);
|
||||||
|
re.put("count", i.get(index).stream().mapToLong(index_ -> index_.values().stream().mapToLong(count_ -> count_).sum()).sum());
|
||||||
|
return re;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
return new Result().ok(result);
|
return new Result().ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue