total排序时,置顶优于total
This commit is contained in:
parent
42f5f3e46a
commit
ce881d43de
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
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);
|
||||
}).reversed()).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList());
|
||||
}, 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;
|
||||
|
@ -493,12 +530,27 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> {
|
||||
ResourceDTO index = (ResourceDTO) x;
|
||||
return index.getTotal() == null ? 0L : index.getTotal();
|
||||
}).reversed()).collect(Collectors.toList()));
|
||||
}, 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;
|
||||
ResourceDTO index = (ResourceDTO) x;
|
||||
return index.getTotal() == null ? 0L : index.getTotal();
|
||||
})).collect(Collectors.toList()));
|
||||
}).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 { // 非总体评价排序时
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue