total排序时,置顶优于total

This commit is contained in:
wangliwen 2022-08-15 15:08:20 +08:00
parent 42f5f3e46a
commit ce881d43de
3 changed files with 98 additions and 37 deletions

View File

@ -257,6 +257,8 @@ public class ResourceController {
if ("f".equals(source)) {
dto.setDelFlag(2); // 来自前端页面 走审批流程
}
dto.setPinTop(0);
dto.setPinTopTime(new Date(0));
logger.info(dto.toString());
resourceService.insertWithAttrs(dto);

View File

@ -471,17 +471,54 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
case "DESC": // total 倒序
ids = customThreadPool.submit(() -> {
List<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
Map index = (Map) x;
String string = (index.get("total") == null) ? "0" : index.get("total").toString();
return Long.valueOf(string);
}).reversed()).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList());
// Map index = (Map) x;
// String string = (index.get("total") == null) ? "0" : index.get("total").toString();
// return Long.valueOf(string);
Map index = (Map) x;
int pingTOp = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString());
return pingTOp;
}, Comparator.reverseOrder())
.thenComparing(x -> {
// Map index = (Map) x;
// int pingTOp = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString());
// return pingTOp;
Map index = (Map) x;
long pingTOp = (index.get("pin_top_time") == null) ? 0 : Long.parseLong(index.get("pin_top_time").toString());
return pingTOp;
}, Comparator.reverseOrder()).thenComparing(x -> {
// Map index = (Map) x;
// long pingTOp = (index.get("pin_top_time") == null) ? 0 : Long.parseLong(index.get("pin_top_time").toString());
// return pingTOp;
Map index = (Map) x;
String string = (index.get("total") == null) ? "0" : index.get("total").toString();
return Long.valueOf(string);
}, Comparator.reverseOrder())
).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 -> {
String string = (x.get("total") == null) ? "0" : x.get("total").toString();
// Map index = (Map) x;
// String string = (index.get("total") == null) ? "0" : index.get("total").toString();
// return Long.valueOf(string);
Map index = (Map) x;
int pingTOp = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString());
return pingTOp;
}, Comparator.reverseOrder()).thenComparing(x -> {
// Map index = (Map) x;
// int pingTOp = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString());
// return pingTOp;
Map index = (Map) x;
long pingTOp = (index.get("pin_top_time") == null) ? 0 : Long.parseLong(index.get("pin_top_time").toString());
return pingTOp;
}, Comparator.reverseOrder()).thenComparing(x -> {
// Map index = (Map) x;
// long pingTOp = (index.get("pin_top_time") == null) ? 0 : Long.parseLong(index.get("pin_top_time").toString());
// return pingTOp;
Map index = (Map) x;
String string = (index.get("total") == null) ? "0" : index.get("total").toString();
return Long.valueOf(string);
})).skip((pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList());
return temp;
@ -491,14 +528,29 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resourceDTOS = resourceDao.selectDTOPage(resourceDTO, null, null, null, null, ids);
if ("DESC".equals(orderType)) {
resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> {
ResourceDTO index = (ResourceDTO) x;
return index.getTotal() == null ? 0L : index.getTotal();
}).reversed()).collect(Collectors.toList()));
ResourceDTO index = (ResourceDTO) x;
return index.getTotal() == null ? 0L : index.getTotal();
}, Comparator.reverseOrder())
.thenComparing(x -> {
ResourceDTO index = (ResourceDTO) x;
return index.getPinTop() == null ? 0 : index.getPinTop();
}, Comparator.reverseOrder()).thenComparing(x -> {
ResourceDTO index = (ResourceDTO) x;
return index.getPinTopTime() == null ? new Date(0) : index.getPinTopTime();
}, Comparator.reverseOrder())
).collect(Collectors.toList()));
} else {
resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> {
ResourceDTO index = x;
return index.getTotal() == null ? 0L : index.getTotal();
})).collect(Collectors.toList()));
ResourceDTO index = (ResourceDTO) x;
return index.getTotal() == null ? 0L : index.getTotal();
}).thenComparing(x -> {
ResourceDTO index = (ResourceDTO) x;
return index.getPinTop() == null ? 0 : index.getPinTop();
}, Comparator.reverseOrder())
.thenComparing(x -> {
ResourceDTO index = (ResourceDTO) x;
return index.getPinTopTime() == null ? new Date(0) : index.getPinTopTime();
}, Comparator.reverseOrder())).collect(Collectors.toList()));
}
customThreadPool.shutdown();
} else { // 非总体评价排序时
@ -1924,7 +1976,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
case TSINGTAO_XHA:
break;
break;
case TSINGTAO: {
CompletableFuture<Void> dataResourceCount = CompletableFuture.runAsync(() -> { //数据资源
//青岛市局数据资源
@ -1941,7 +1993,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
CompletableFuture<Void> infrastructureCount = CompletableFuture.runAsync(() -> { //基础设施
HashMap<Object, Object> queryMap = new HashMap<>();
queryMap.put("cameraName",keyWorld);
queryMap.put("cameraName", keyWorld);
Integer countNew = cameraChannelMapper.selectByParentIdCountNew(queryMap, null, "");
resultList.add(new HashMap<String, Object>() {
{

View File

@ -132,7 +132,8 @@
AND user_id = #{dto.creator}
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
LEFT JOIN ( SELECT resource_id, COUNT( approve_status ) approve_status FROM t_ability_application WHERE 1 = 1
AND del_flag = 0 AND user_id = #{dto.creator} AND approve_status = '通过' GROUP BY resource_id ) taa3 ON tdr.id =
AND del_flag = 0 AND user_id = #{dto.creator} AND approve_status = '通过' GROUP BY resource_id ) taa3 ON tdr.id
=
taa3.resource_id
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
WHERE 1 = 1
@ -414,7 +415,8 @@
AND user_id = #{dto.creator}
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
LEFT JOIN ( SELECT resource_id, COUNT( approve_status ) approve_status FROM t_ability_application WHERE 1 = 1
AND del_flag = 0 AND user_id = #{dto.creator} AND approve_status = '通过' GROUP BY resource_id ) taa3 ON tdr.id =
AND del_flag = 0 AND user_id = #{dto.creator} AND approve_status = '通过' GROUP BY resource_id ) taa3 ON tdr.id
=
taa3.resource_id
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
WHERE 1 = 1
@ -475,7 +477,9 @@
<select id="selectDTOPageSpecilTotal" resultType="java.util.Map">
SELECT
tdr.id,
tdr.total AS total
tdr.total AS total,
tdr.pin_top,
tdr.UNIX_TIMESTAMP(pin_top_time) AS pin_top_time
FROM
tb_data_resource tdr
WHERE
@ -595,7 +599,8 @@
FROM
(
SELECT
( 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",
sd.NAME AS "deptName",
IFNULL( tdr.deptCount, 0 ) AS "deptCount",
sd.id AS "deptId",
@ -628,7 +633,8 @@
FROM
(
SELECT
( 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",
IFNULL( tdr.deptCount, 0 ) AS "deptCount"
FROM
sys_dept sd
@ -666,7 +672,8 @@
FROM
(
SELECT
( 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",
IFNULL( tdr.deptCount, 0) AS "deptCount",
IFNULL(sr.name, '暂无该地区') AS "districtName"
FROM
@ -1496,7 +1503,7 @@
<select id="resourceInstallationOrDataResourceDetails" parameterType="java.util.Map" resultType="java.util.Map">
SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName
FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id
FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id
WHERE a.type = #{resourceType} AND a.del_flag = 0
<if test="id != '0'.toString()">
AND (b.ID = #{id} OR INSTR(b.pids,#{id}))
@ -1506,34 +1513,34 @@
</select>
<select id="selectAppList" resultType="java.util.Map">
SELECT
tdr.id,
tdr.`name`,
sd.name AS "deptName"
tdr.id,
tdr.`name`,
sd.name AS "deptName"
FROM
tb_data_resource tdr
tb_data_resource tdr
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
WHERE
1 = 1
AND tdr.type = '应用资源'
AND tdr.del_flag = 0
<if test=" type != null and type != ''">
AND sd.type = #{type}
</if>
1 = 1
AND tdr.type = '应用资源'
AND tdr.del_flag = 0
<if test=" type != null and type != ''">
AND sd.type = #{type}
</if>
ORDER BY
tdr.visitor
tdr.visitor
LIMIT ${pageNum}, 9
</select>
<select id="selectPicByResId" resultType="java.lang.String">
SELECT
tda.attr_value
tda.attr_value
FROM
tb_data_attr tda
LEFT JOIN tb_data_resource tdr ON tda.data_resource_id = tdr.id
tb_data_attr tda
LEFT JOIN tb_data_resource tdr ON tda.data_resource_id = tdr.id
WHERE
tda.attr_type = '应用图片'
AND tdr.id = #{id}
AND tda.del_flag = 0
tda.attr_type = '应用图片'
AND tdr.id = #{id}
AND tda.del_flag = 0
</select>
<select id="selectTypeCountByName" resultType="java.util.Map">
SELECT