Merge branch 'dev'

This commit is contained in:
wangliwen 2022-10-17 13:11:40 +08:00
commit f8241322ef
4 changed files with 210 additions and 124 deletions

View File

@ -91,6 +91,10 @@ public class TbDeviceApplyServiceImpl extends CrudServiceImpl<TbDeviceApplyDao,
params.put("states", stateList);
List<TbDeviceApplyDTO> dtoList = tbDeviceApplyDao.queryList(params);
List<TbDeviceApplyDTO> result = dtoList.stream().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList());
result.stream().forEach(it -> {
it.setTbDeviceDTO(tbDeviceService.get(it.getDeviceId()));
it.setAuditorName(sysUserService.get(it.getAuditor()).getRealName());
});
return new PageData(result, dtoList.size());
}
}

View File

@ -478,34 +478,31 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
switch (orderType.toUpperCase()) {
case "DESC": // total 倒序
ids = customThreadPool.submit(() -> {
List<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast)
.sorted(Comparator.comparing(x -> {
Map index = (Map) x;
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();
if (pingTOp_ <= 0) {
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);
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());
List<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
Map index = (Map) x;
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();
if (pingTOp_ <= 0) {
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);
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());
return temp;
}).get();
break;
case "ASC": // total 升序
ids = customThreadPool.submit(() -> {
List<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast)
.sorted(Comparator.comparing(x -> {
Map index = (Map) x;
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();
if (pingTOp_ <= 0) {
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);
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());
List<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
Map index = (Map) x;
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();
if (pingTOp_ <= 0) {
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);
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());
return temp;
}).get();
break;
@ -513,32 +510,30 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resourceDTOS = resourceDao.selectDTOPage(resourceDTO, null, null, null, null, ids);
if ("DESC".equals(orderType)) {
resourceDTOS = resourceDTOS.stream().sorted(Comparator.comparing(x -> {
ResourceDTO index = (ResourceDTO) x;
int pinTop = index.getPinTop() == null ? 0 : index.getPinTop();
long index_;
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_ % 1000;
} else {
index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal()));
}
return index_ == 0 ? -1 : index_;
}).reversed()
).collect(Collectors.toList());
ResourceDTO index = (ResourceDTO) x;
int pinTop = index.getPinTop() == null ? 0 : index.getPinTop();
long index_;
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_ % 1000;
} else {
index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal()));
}
return index_ == 0 ? -1 : index_;
}).reversed()).collect(Collectors.toList());
} else {
resourceDTOS = resourceDTOS.stream().sorted(Comparator.comparing(x -> {
ResourceDTO index = x;
int pinTop = index.getPinTop() == null ? 0 : index.getPinTop();
long index_;
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_ % 1000;
} else {
index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal()));
}
return index_ == 0 ? -1 : index_;
})
).collect(Collectors.toList());
ResourceDTO index = x;
int pinTop = index.getPinTop() == null ? 0 : index.getPinTop();
long index_;
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_ % 1000;
} else {
index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal()));
}
return index_ == 0 ? -1 : index_;
})).collect(Collectors.toList());
}
customThreadPool.shutdown();
} else { // 非总体评价排序时
@ -693,11 +688,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
public Object selectNewest(JSONObject jsonObject) {
IPage<ResourceEntity> page = new Page<>(jsonObject.getIntValue("pageNum"), jsonObject.getIntValue("pageSize"));
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type"))
.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag())
.ne("type", "知识库")
.ne("type", "赋能案例")
.orderByDesc("create_date");
queryWrapper.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type")).eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()).ne("type", "知识库").ne("type", "赋能案例").orderByDesc("create_date");
IPage<ResourceEntity> resourceEntityIPage = resourceDao.selectPage(page, queryWrapper);
IPage<ResourceDTO> resourceDTOIPage = new Page<>();
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()));
//区级要根据行政区划多加一层结构
List<CompletableFuture> tasks =
listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).map(item -> {
CompletableFuture task = CompletableFuture.runAsync(() -> {
HashMap<String, Object> map = new HashMap<>();
map.put("type", item.getKey());
Integer integer = resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type"));
map.put("total", integer);
item.getValue().forEach(item1 -> {
item1.remove("type");
item1.remove("regionSort");
});
map.put("dataList", item.getValue());
if (integer != 0) {
resultList.add(map);
}
}, executor);
return task;
}).collect(Collectors.toList());
List<CompletableFuture> tasks = listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).map(item -> {
CompletableFuture task = CompletableFuture.runAsync(() -> {
HashMap<String, Object> map = new HashMap<>();
map.put("type", item.getKey());
Integer integer = resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type"));
map.put("total", integer);
item.getValue().forEach(item1 -> {
item1.remove("type");
item1.remove("regionSort");
});
map.put("dataList", item.getValue());
if (integer != 0) {
resultList.add(map);
}
}, executor);
return task;
}).collect(Collectors.toList());
CompletableFuture.allOf(tasks.toArray(new CompletableFuture[tasks.size()])).join();
Optional<List<Map<String, Object>>> areaList = Optional.ofNullable(listMap.get("区级"));
@ -1115,8 +1105,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override
public Object getApplyCameraList(Long instanceId) {
QueryWrapper<TAbilityApplicationEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("instance_id", instanceId)
.eq("approve_status", "通过");
queryWrapper.eq("instance_id", instanceId).eq("approve_status", "通过");
List<TAbilityApplicationEntity> applicationEntities = tAbilityApplicationDao.selectList(queryWrapper);
ArrayList cameraList = new ArrayList();
applicationEntities.forEach(index -> {
@ -1919,8 +1908,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resourceIds.add(Long.parseLong(abilityApplicationDTO1.getResourceId()));
} else {
TResourceMountApplyDTO resourceMountApplyDTO = tResourceMountApplyService.get(Long.valueOf(his.getBusinessKey()));
if (resourceMountApplyDTO != null && resourceMountApplyDTO.getResourceDTO() != null
&& resourceMountApplyDTO.getResourceDTO().getId() != null) {
if (resourceMountApplyDTO != null && resourceMountApplyDTO.getResourceDTO() != null && resourceMountApplyDTO.getResourceDTO().getId() != null) {
resourceIds.add(resourceMountApplyDTO.getResourceDTO().getId());
if (resourceMountApplyDTO.getResourceId() != null) {
ResourceDTO resourceDTO = get(resourceMountApplyDTO.getResourceId());
@ -2069,23 +2057,56 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override
public Object selectDeptDetailTypeCountList(Map 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()));
ArrayList<Map> resultList = new ArrayList<>();
Map<String, List<Map<String, Object>>> typeCountListMap = // 市级部门
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<>();
typeCountListMap.forEach((k, v) -> {
HashMap<Object, 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);
});
resultList = resultList.stream().map(index -> {
if (typeCountListMap.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息
index.put("count", typeCountListMap.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum());
typeCountListMap.get(index.get("dept_id").toString()).stream().forEach(count -> {
index.put(count.get("type").toString(), count.get("count"));
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());
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;
for (Integer count : countMap.values()) {
total += count;
@ -2098,6 +2119,56 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
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
public Object selectCensusResourceTable(Map params) {
return resourceDao.selectCensusResourceTable(params);

View File

@ -18,7 +18,7 @@
</resultMap>
<select id="getDeviceDTOList" resultMap="deviceDTO">
select td.*, IFNULL(tda.state,1) as state from tb_device td left join tb_device_apply tda on td.id=tda.device_id
select td.*, IFNULL(ANY_VALUE(tda.state),1) as state from tb_device td left join tb_device_apply tda on td.id=tda.device_id
<if test="userId != null and userId != ''">
and tda.creator = #{userId}
</if>

View File

@ -722,10 +722,10 @@
</select>
<select id="selectDeptCount" resultType="java.lang.Integer">
<!-- SELECT
COUNT( 1 )
FROM
( SELECT DISTINCT dept_id FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 AND dept_id IS NOT NULL ) temp -->
<!-- SELECT
COUNT( 1 )
FROM
( 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>
@ -759,7 +759,8 @@
(
SELECT DISTINCT
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
sys_dept sd
WHERE
@ -1790,6 +1791,9 @@
SELECT
COUNT( tdr.id ) AS "count",
sd.NAME AS "deptName",
sd.id AS "dept_id",
sd.type AS "deptType",
sd.district AS "district",
(CASE tdr.type
WHEN '应用资源' THEN 'yyzy'
WHEN '智能算法' THEN 'znsf'
@ -1834,8 +1838,8 @@
<select id="selectCensusResourceTable" resultType="java.util.Map">
SELECT sd.name AS deptName, tdr.name AS resourceName, tdr.type, tdr.create_date AS createDate,
if(tdr.del_flag=0, '审核通过', '审核中') AS approveStatus, trma.instance_id AS applyNumber
FROM (SELECT IF(d.type='组件服务', A.attr_value, d.type) AS type, d.id, d.del_flag, d.dept_id, d.create_date,
CASE WHEN (tdr.del_flag=0 OR tdr.del_flag=5) THEN '通过' WHEN tdr.del_flag=6 THEN '不通过' ELSE '审核中' END AS approveStatus, trma.instance_id AS applyNumber
FROM (SELECT IF(d.type='组件服务', a.attr_value, d.type) AS type, d.id, d.del_flag, d.dept_id, d.create_date,
d.name
FROM tb_data_resource d LEFT JOIN tb_data_attr a ON d.id=a.data_resource_id AND a.attr_type='组件类型' AND
a.del_flag=0
@ -1845,13 +1849,16 @@
WHERE 1=1 AND tdr.dept_id=sd.id
<choose>
<when test="approveStatus != null and approveStatus == '通过'">
AND tdr.del_flag = 0
AND tdr.del_flag in (0, 5)
</when>
<when test="approveStatus != null and approveStatus == '审核中'">
AND tdr.del_flag in (2, 3)
AND tdr.del_flag not in (0, 1, 5, 6)
</when>
<when test="approveStatus != null and approveStatus == '不通过'">
AND tdr.del_flag=6
</when>
<otherwise>
AND tdr.del_flag in (0, 2, 3)
AND tdr.del_flag != 1
</otherwise>
</choose>
<if test="deptId != null and deptId != ''">
@ -1904,14 +1911,6 @@
AND su.dept_id = sd.id
AND taa.resource_id = tdr.id
AND dept.id = tdr.dept_id
<!--<choose>
<when test="approveStatus != null and approveStatus != ''">
AND taa.approve_status = #{approveStatus}
</when>
<otherwise>
AND taa.approve_status != '不通过'
</otherwise>
</choose> -->
<if test="approveStatus != null and approveStatus != ''">
AND taa.approve_status = #{approveStatus}
</if>
@ -1925,22 +1924,34 @@
AND SUBSTR(taa.create_date, 1, 10) BETWEEN #{startDate} AND #{endDate}
</if>
<if test="type == null or type == '' or type == '会议室'">
UNION ALL
UNION ALL
SELECT
tmb.dept AS 'deptName',
tm.`name` AS 'resourceName',
'青岛市大数据发展管理局' AS 'resourceDeptName',
'会议室' AS 'type',
tm.create_date AS 'createDate',
CASE tmb.state WHEN 1 THEN '申请中' WHEN 2 THEN '通过' WHEN 3 THEN '不通过' ELSE '申请中' END AS 'approveStatus',
'' AS 'applyNumber'
FROM
t_meetingroom_book tmb,
t_meetingroom tm
WHERE
tmb.room_id = tm.id
SELECT
tmb.dept AS 'deptName',
tm.`name` AS 'resourceName',
'青岛市大数据发展管理局' AS 'resourceDeptName',
'会议室' AS 'type',
tm.create_date AS 'createDate',
CASE tmb.state WHEN 1 THEN '审核中' WHEN 2 THEN '通过' WHEN 3 THEN '不通过' ELSE '审核中' END AS 'approveStatus',
'' AS 'applyNumber'
FROM
t_meetingroom_book tmb,
t_meetingroom tm
WHERE
tmb.room_id = tm.id
<choose>
<when test="approveStatus != null and approveStatus == '通过'">
AND tmb.state=2
</when>
<when test="approveStatus != null and approveStatus == '不通过'">
AND tmb.state=3
</when>
<when test="approveStatus != null and approveStatus == '审核中'">
AND tmb.state not in (2, 3)
</when>
</choose>
</if>
ORDER BY createDate DESC
</select>