HIQDUCS-100 的处理

This commit is contained in:
wangliwen 2022-10-17 13:09:46 +08:00
parent b1376f4646
commit ce11e658ff
2 changed files with 172 additions and 96 deletions

View File

@ -478,34 +478,31 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
switch (orderType.toUpperCase()) { switch (orderType.toUpperCase()) {
case "DESC": // total 倒序 case "DESC": // total 倒序
ids = customThreadPool.submit(() -> { ids = customThreadPool.submit(() -> {
List<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast) List<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
.sorted(Comparator.comparing(x -> { Map index = (Map) x;
Map index = (Map) x; int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString());
int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString()); String total = (index.get("total") == null) ? "0" : index.get("total").toString();
String total = (index.get("total") == null) ? "0" : index.get("total").toString(); if (pingTOp_ <= 0) {
if (pingTOp_ <= 0) { return 0l + Long.valueOf(total) == 0 ? -1 : Long.valueOf(total);
return 0l + Long.valueOf(total) == 0 ? -1 : Long.valueOf(total); }
} long pingTOp = (index.get("pin_top_time") == null) ? 0 + (Long.valueOf(total) == 0 ? -1 : Long.valueOf(total)) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(total);
long pingTOp = (index.get("pin_top_time") == null) ? 0 + (Long.valueOf(total) == 0 ? -1 : Long.valueOf(total)) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(total); return (pingTOp % 1000) == 0 ? -1 : pingTOp % 1000;
return (pingTOp % 1000) == 0 ? -1 : pingTOp % 1000; }).reversed()).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList());
}).reversed()
).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList());
return temp; return temp;
}).get(); }).get();
break; break;
case "ASC": // total 升序 case "ASC": // total 升序
ids = customThreadPool.submit(() -> { ids = customThreadPool.submit(() -> {
List<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast) List<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
.sorted(Comparator.comparing(x -> { Map index = (Map) x;
Map index = (Map) x; int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString());
int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString()); String total = (index.get("total") == null) ? "0" : index.get("total").toString();
String total = (index.get("total") == null) ? "0" : index.get("total").toString(); if (pingTOp_ <= 0) {
if (pingTOp_ <= 0) { return 0l + Long.valueOf(total) == 0 ? -1 : Long.valueOf(total);
return 0l + Long.valueOf(total) == 0 ? -1 : Long.valueOf(total); }
} long pingTOp = (index.get("pin_top_time") == null) ? 0 + (Long.valueOf(total) == 0 ? -1 : Long.valueOf(total)) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(total);
long pingTOp = (index.get("pin_top_time") == null) ? 0 + (Long.valueOf(total) == 0 ? -1 : Long.valueOf(total)) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(total); return (pingTOp % 1000) == 0 ? -1 : pingTOp % 1000;
return (pingTOp % 1000) == 0 ? -1 : pingTOp % 1000; })).skip((pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList());
})).skip((pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList());
return temp; return temp;
}).get(); }).get();
break; break;
@ -513,32 +510,30 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resourceDTOS = resourceDao.selectDTOPage(resourceDTO, null, null, null, null, ids); resourceDTOS = resourceDao.selectDTOPage(resourceDTO, null, null, null, null, ids);
if ("DESC".equals(orderType)) { if ("DESC".equals(orderType)) {
resourceDTOS = resourceDTOS.stream().sorted(Comparator.comparing(x -> { resourceDTOS = resourceDTOS.stream().sorted(Comparator.comparing(x -> {
ResourceDTO index = (ResourceDTO) x; ResourceDTO index = (ResourceDTO) x;
int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); int pinTop = index.getPinTop() == null ? 0 : index.getPinTop();
long index_; long index_;
if (pinTop > 0) { if (pinTop > 0) {
index_ = index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? -1L : index.getTotal()) : index.getPinTopTime().getTime() + (index.getTotal() == null ? -1L : index.getTotal()); index_ = index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? -1L : index.getTotal()) : index.getPinTopTime().getTime() + (index.getTotal() == null ? -1L : index.getTotal());
index_ = index_ % 1000; index_ = index_ % 1000;
} else { } else {
index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal())); index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal()));
} }
return index_ == 0 ? -1 : index_; return index_ == 0 ? -1 : index_;
}).reversed() }).reversed()).collect(Collectors.toList());
).collect(Collectors.toList());
} else { } else {
resourceDTOS = resourceDTOS.stream().sorted(Comparator.comparing(x -> { resourceDTOS = resourceDTOS.stream().sorted(Comparator.comparing(x -> {
ResourceDTO index = x; ResourceDTO index = x;
int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); int pinTop = index.getPinTop() == null ? 0 : index.getPinTop();
long index_; long index_;
if (pinTop > 0) { if (pinTop > 0) {
index_ = index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? -1L : index.getTotal()) : index.getPinTopTime().getTime() + (index.getTotal() == null ? -1L : index.getTotal()); index_ = index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? -1L : index.getTotal()) : index.getPinTopTime().getTime() + (index.getTotal() == null ? -1L : index.getTotal());
index_ = index_ % 1000; index_ = index_ % 1000;
} else { } else {
index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal())); index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal()));
} }
return index_ == 0 ? -1 : index_; return index_ == 0 ? -1 : index_;
}) })).collect(Collectors.toList());
).collect(Collectors.toList());
} }
customThreadPool.shutdown(); customThreadPool.shutdown();
} else { // 非总体评价排序时 } else { // 非总体评价排序时
@ -693,11 +688,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
public Object selectNewest(JSONObject jsonObject) { public Object selectNewest(JSONObject jsonObject) {
IPage<ResourceEntity> page = new Page<>(jsonObject.getIntValue("pageNum"), jsonObject.getIntValue("pageSize")); IPage<ResourceEntity> page = new Page<>(jsonObject.getIntValue("pageNum"), jsonObject.getIntValue("pageSize"));
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type")) queryWrapper.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type")).eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()).ne("type", "知识库").ne("type", "赋能案例").orderByDesc("create_date");
.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag())
.ne("type", "知识库")
.ne("type", "赋能案例")
.orderByDesc("create_date");
IPage<ResourceEntity> resourceEntityIPage = resourceDao.selectPage(page, queryWrapper); IPage<ResourceEntity> resourceEntityIPage = resourceDao.selectPage(page, queryWrapper);
IPage<ResourceDTO> resourceDTOIPage = new Page<>(); IPage<ResourceDTO> resourceDTOIPage = new Page<>();
resourceDTOIPage.setPages(resourceEntityIPage.getPages()); resourceDTOIPage.setPages(resourceEntityIPage.getPages());
@ -819,24 +810,23 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
} }
Map<String, List<Map<String, Object>>> listMap = typeMapList.stream().collect(Collectors.groupingBy(m -> m.get("type").toString())); Map<String, List<Map<String, Object>>> listMap = typeMapList.stream().collect(Collectors.groupingBy(m -> m.get("type").toString()));
//区级要根据行政区划多加一层结构 //区级要根据行政区划多加一层结构
List<CompletableFuture> tasks = List<CompletableFuture> tasks = listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).map(item -> {
listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).map(item -> { CompletableFuture task = CompletableFuture.runAsync(() -> {
CompletableFuture task = CompletableFuture.runAsync(() -> { HashMap<String, Object> map = new HashMap<>();
HashMap<String, Object> map = new HashMap<>(); map.put("type", item.getKey());
map.put("type", item.getKey()); Integer integer = resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type"));
Integer integer = resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type")); map.put("total", integer);
map.put("total", integer); item.getValue().forEach(item1 -> {
item.getValue().forEach(item1 -> { item1.remove("type");
item1.remove("type"); item1.remove("regionSort");
item1.remove("regionSort"); });
}); map.put("dataList", item.getValue());
map.put("dataList", item.getValue()); if (integer != 0) {
if (integer != 0) { resultList.add(map);
resultList.add(map); }
} }, executor);
}, executor); return task;
return task; }).collect(Collectors.toList());
}).collect(Collectors.toList());
CompletableFuture.allOf(tasks.toArray(new CompletableFuture[tasks.size()])).join(); CompletableFuture.allOf(tasks.toArray(new CompletableFuture[tasks.size()])).join();
Optional<List<Map<String, Object>>> areaList = Optional.ofNullable(listMap.get("区级")); Optional<List<Map<String, Object>>> areaList = Optional.ofNullable(listMap.get("区级"));
@ -1115,8 +1105,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override @Override
public Object getApplyCameraList(Long instanceId) { public Object getApplyCameraList(Long instanceId) {
QueryWrapper<TAbilityApplicationEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<TAbilityApplicationEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("instance_id", instanceId) queryWrapper.eq("instance_id", instanceId).eq("approve_status", "通过");
.eq("approve_status", "通过");
List<TAbilityApplicationEntity> applicationEntities = tAbilityApplicationDao.selectList(queryWrapper); List<TAbilityApplicationEntity> applicationEntities = tAbilityApplicationDao.selectList(queryWrapper);
ArrayList cameraList = new ArrayList(); ArrayList cameraList = new ArrayList();
applicationEntities.forEach(index -> { applicationEntities.forEach(index -> {
@ -1919,8 +1908,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resourceIds.add(Long.parseLong(abilityApplicationDTO1.getResourceId())); resourceIds.add(Long.parseLong(abilityApplicationDTO1.getResourceId()));
} else { } else {
TResourceMountApplyDTO resourceMountApplyDTO = tResourceMountApplyService.get(Long.valueOf(his.getBusinessKey())); TResourceMountApplyDTO resourceMountApplyDTO = tResourceMountApplyService.get(Long.valueOf(his.getBusinessKey()));
if (resourceMountApplyDTO != null && resourceMountApplyDTO.getResourceDTO() != null if (resourceMountApplyDTO != null && resourceMountApplyDTO.getResourceDTO() != null && resourceMountApplyDTO.getResourceDTO().getId() != null) {
&& resourceMountApplyDTO.getResourceDTO().getId() != null) {
resourceIds.add(resourceMountApplyDTO.getResourceDTO().getId()); resourceIds.add(resourceMountApplyDTO.getResourceDTO().getId());
if (resourceMountApplyDTO.getResourceId() != null) { if (resourceMountApplyDTO.getResourceId() != null) {
ResourceDTO resourceDTO = get(resourceMountApplyDTO.getResourceId()); ResourceDTO resourceDTO = get(resourceMountApplyDTO.getResourceId());
@ -2069,23 +2057,56 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override @Override
public Object selectDeptDetailTypeCountList(Map params) { public Object selectDeptDetailTypeCountList(Map params) {
List<Map<String, Object>> typeCountListByDept = resourceDao.selectDeptDetailTypeCountList(params); List<Map<String, Object>> typeCountListByDept = resourceDao.selectDeptDetailTypeCountList(params);
Map<String, List<Map<String, Object>>> typeCountListMap = typeCountListByDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString())); Map<String, List<Map<String, Object>>> typeCountListMap = // 市级部门
ArrayList<Map> resultList = new ArrayList<>(); typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("2")).collect(Collectors.groupingBy(m -> m.get("dept_id").toString()));
List<HashMap<String, Object>> resultList = getDeptTemp1();
resultList.addAll(getDeptTemp2());
Map<String, Integer> countMap = new HashMap<>(); Map<String, Integer> countMap = new HashMap<>();
typeCountListMap.forEach((k, v) -> { resultList = resultList.stream().map(index -> {
HashMap<Object, Object> map = new HashMap<>(); if (typeCountListMap.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息
map.put("count", v.stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); index.put("count", typeCountListMap.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum());
map.put("name", k); typeCountListMap.get(index.get("dept_id").toString()).stream().forEach(count -> {
v.forEach(item -> { index.put(count.get("type").toString(), count.get("count"));
map.put(item.get("type").toString(), item.get("count")); if (countMap.containsKey(count.get("type"))) {
if (countMap.containsKey(item.get("type"))) { countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type")));
countMap.replace(item.get("type").toString(), Integer.parseInt(item.get("count").toString()) + countMap.get(item.get("type"))); } else {
} else { countMap.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString()));
countMap.put(item.get("type").toString(), Integer.parseInt(item.get("count").toString())); }
} });
}); }
resultList.add(map); return index;
}); }).collect(Collectors.toList());
Map<String, List<Map<String, Object>>> typeCountListMap1 = // 区级部门
typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("3")).collect(Collectors.groupingBy(m -> m.get("district").toString()));
resultList = resultList.stream().map(index -> {
if (typeCountListMap1.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息
index.put("count", typeCountListMap1.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum());
typeCountListMap1.get(index.get("dept_id").toString()).stream().forEach(count -> {
index.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + Integer.parseInt(index.getOrDefault(count.get("type").toString(), "0").toString()));
if (countMap.containsKey(count.get("type"))) {
countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type")));
} else {
countMap.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString()));
}
});
}
return index;
}).collect(Collectors.toList());
// typeCountListMap.forEach((k, v) -> {
// HashMap<String, Object> map = new HashMap<>();
// map.put("count", v.stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum());
// map.put("name", k);
// v.forEach(item -> {
// map.put(item.get("type").toString(), item.get("count"));
// if (countMap.containsKey(item.get("type"))) {
// countMap.replace(item.get("type").toString(), Integer.parseInt(item.get("count").toString()) + countMap.get(item.get("type")));
// } else {
// countMap.put(item.get("type").toString(), Integer.parseInt(item.get("count").toString()));
// }
// });
// resultList.add(map);
// });
Integer total = 0; Integer total = 0;
for (Integer count : countMap.values()) { for (Integer count : countMap.values()) {
total += count; total += count;
@ -2098,6 +2119,56 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
return resultList; return resultList;
} }
/**
* @return 返回市级部门的初级构造
*/
private List<HashMap<String, Object>> getDeptTemp1() {
List<HashMap<String, Object>> resultList;
List<Map<String, Object>> maps = jdbcTemplate.queryForList("SELECT id,`name`,type,pid,district FROM sys_dept WHERE type = 2 ORDER BY sys_dept.sort;");
resultList = maps.stream().map(index -> {
HashMap<String, Object> map = new HashMap<>();
map.put("count", 0); //
map.put("name", index.get("name").toString());
map.put("dept_id", index.get("id").toString());
map.put("yyzy", "0");
map.put("znsf", "0");
map.put("tcfw", "0");
map.put("kfzj", "0");
map.put("ywzj", "0");
map.put("jcss", "0");
map.put("zsk", "0");
map.put("sjzy", "0");
return map;
}).collect(Collectors.toList());
return resultList;
}
/**
* 获取区的初级构造
*
* @return
*/
private List<HashMap<String, Object>> getDeptTemp2() {
List<HashMap<String, Object>> resultList;
List<Map<String, Object>> maps = jdbcTemplate.queryForList("SELECT id,`name` FROM sys_region WHERE tree_level = 3 AND leaf = 0 ORDER BY sort;");
resultList = maps.stream().map(index -> {
HashMap<String, Object> map = new HashMap<>();
map.put("count", 0); //
map.put("name", index.get("name").toString());
map.put("dept_id", index.get("id").toString());
map.put("yyzy", "0");
map.put("znsf", "0");
map.put("tcfw", "0");
map.put("kfzj", "0");
map.put("ywzj", "0");
map.put("jcss", "0");
map.put("zsk", "0");
map.put("sjzy", "0");
return map;
}).collect(Collectors.toList());
return resultList;
}
@Override @Override
public Object selectCensusResourceTable(Map params) { public Object selectCensusResourceTable(Map params) {
return resourceDao.selectCensusResourceTable(params); return resourceDao.selectCensusResourceTable(params);

View File

@ -722,10 +722,10 @@
</select> </select>
<select id="selectDeptCount" resultType="java.lang.Integer"> <select id="selectDeptCount" resultType="java.lang.Integer">
<!-- SELECT <!-- SELECT
COUNT( 1 ) COUNT( 1 )
FROM FROM
( SELECT DISTINCT dept_id FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 AND dept_id IS NOT NULL ) temp --> ( SELECT DISTINCT dept_id FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 AND dept_id IS NOT NULL ) temp -->
SELECT COUNT(id) FROM sys_dept WHERE name != '访客部门' SELECT COUNT(id) FROM sys_dept WHERE name != '访客部门'
</select> </select>
@ -759,7 +759,8 @@
( (
SELECT DISTINCT SELECT DISTINCT
sd.id AS "deptId", sd.id AS "deptId",
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type" ( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS
"type"
FROM FROM
sys_dept sd sys_dept sd
WHERE WHERE
@ -1790,6 +1791,9 @@
SELECT SELECT
COUNT( tdr.id ) AS "count", COUNT( tdr.id ) AS "count",
sd.NAME AS "deptName", sd.NAME AS "deptName",
sd.id AS "dept_id",
sd.type AS "deptType",
sd.district AS "district",
(CASE tdr.type (CASE tdr.type
WHEN '应用资源' THEN 'yyzy' WHEN '应用资源' THEN 'yyzy'
WHEN '智能算法' THEN 'znsf' WHEN '智能算法' THEN 'znsf'
@ -1934,7 +1938,8 @@
'青岛市大数据发展管理局' AS 'resourceDeptName', '青岛市大数据发展管理局' AS 'resourceDeptName',
'会议室' AS 'type', '会议室' AS 'type',
tm.create_date AS 'createDate', tm.create_date AS 'createDate',
CASE tmb.state WHEN 1 THEN '申请中' WHEN 2 THEN '通过' WHEN 3 THEN '不通过' ELSE '申请中' END AS 'approveStatus', CASE tmb.state WHEN 1 THEN '申请中' WHEN 2 THEN '通过' WHEN 3 THEN '不通过' ELSE '申请中' END AS
'approveStatus',
'' AS 'applyNumber' '' AS 'applyNumber'
FROM FROM
t_meetingroom_book tmb, t_meetingroom_book tmb,