total 排序将置顶放前面
This commit is contained in:
parent
4000c2d30e
commit
42d7d1a27c
|
@ -474,10 +474,10 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
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);
|
||||
return 0l + Long.valueOf(total) == 0 ? -1 : Long.valueOf(total);
|
||||
}
|
||||
long pingTOp = (index.get("pin_top_time") == null) ? 0 + Long.valueOf(total) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(total);
|
||||
return pingTOp;
|
||||
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;
|
||||
}).reversed()
|
||||
).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList());
|
||||
return temp;
|
||||
|
@ -487,7 +487,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
ids = customThreadPool.submit(() -> {
|
||||
List<Long> temp = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast)
|
||||
.sorted(Comparator.comparing(x -> {
|
||||
Map index = (Map) x;
|
||||
Map index = x;
|
||||
int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString());
|
||||
String string = (index.get("total") == null) ? "0" : index.get("total").toString();
|
||||
if (pingTOp_ <= 0) {
|
||||
|
@ -502,27 +502,33 @@ 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 -> {
|
||||
resourceDTOS = resourceDTOS.stream().sorted(Comparator.comparing(x -> {
|
||||
ResourceDTO index = (ResourceDTO) x;
|
||||
int pinTop = index.getPinTop() == null ? 0 : index.getPinTop();
|
||||
long index_;
|
||||
if (pinTop > 0) {
|
||||
return index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? 0L : index.getTotal()) : index.getPinTopTime().getTime() + +(index.getTotal() == null ? 0L : 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;
|
||||
} else {
|
||||
return (index.getTotal() == null ? 0L : index.getTotal());
|
||||
index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal()));
|
||||
}
|
||||
return index_ == 0 ? -1 : index_;
|
||||
}).reversed()
|
||||
).collect(Collectors.toList()));
|
||||
).collect(Collectors.toList());
|
||||
} else {
|
||||
resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> {
|
||||
ResourceDTO index = (ResourceDTO) x;
|
||||
resourceDTOS = resourceDTOS.stream().sorted(Comparator.comparing(x -> {
|
||||
ResourceDTO index = x;
|
||||
int pinTop = index.getPinTop() == null ? 0 : index.getPinTop();
|
||||
long index_;
|
||||
if (pinTop > 0) {
|
||||
return index.getPinTopTime() == null ? new Date(0).getTime() + (index.getTotal() == null ? 0L : index.getTotal()) : index.getPinTopTime().getTime() + (index.getTotal() == null ? 0L : 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;
|
||||
} else {
|
||||
return new Date(0).getTime() + (index.getTotal() == null ? 0L : index.getTotal());
|
||||
index_ = (index.getTotal() == null ? -1L : (index.getTotal() == 0 ? -1 : index.getTotal()));
|
||||
}
|
||||
return index_ == 0 ? -1 : index_;
|
||||
})
|
||||
).collect(Collectors.toList()));
|
||||
).collect(Collectors.toList());
|
||||
}
|
||||
customThreadPool.shutdown();
|
||||
} else { // 非总体评价排序时
|
||||
|
|
|
@ -138,7 +138,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
|
||||
LEFT JOIN sys_region sr ON sd.district = sr.id
|
||||
|
@ -423,7 +424,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
|
||||
LEFT JOIN sys_region sr ON sd.district = sr.id
|
||||
|
@ -485,7 +487,7 @@
|
|||
<select id="selectDTOPageSpecilTotal" resultType="java.util.Map">
|
||||
SELECT
|
||||
tdr.id,
|
||||
tdr.total AS total,
|
||||
IFNULL(tdr.total,0) AS total,
|
||||
tdr.pin_top,
|
||||
UNIX_TIMESTAMP(tdr.pin_top_time) AS pin_top_time
|
||||
FROM
|
||||
|
@ -607,7 +609,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",
|
||||
|
@ -641,7 +644,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
|
||||
|
@ -679,7 +683,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
|
||||
|
@ -1509,7 +1514,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}))
|
||||
|
@ -1519,39 +1524,39 @@
|
|||
</select>
|
||||
<select id="selectAppList" resultType="java.util.Map">
|
||||
SELECT
|
||||
tdr.id,
|
||||
tdr.`name`,
|
||||
sd.name AS "deptName",
|
||||
sd.sort AS "deptSort",
|
||||
sd.type AS "deptType",
|
||||
sr.sort AS "regionSort",
|
||||
tdr.visitor
|
||||
tdr.id,
|
||||
tdr.`name`,
|
||||
sd.name AS "deptName",
|
||||
sd.sort AS "deptSort",
|
||||
sd.type AS "deptType",
|
||||
sr.sort AS "regionSort",
|
||||
tdr.visitor
|
||||
FROM
|
||||
tb_data_resource tdr
|
||||
tb_data_resource tdr
|
||||
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
|
||||
LEFT JOIN sys_region sr ON sd.district = sr.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
|
||||
sd.type, sr.sort, sd.sort, tdr.dept_id, tdr.visitor DESC, tdr.id DESC
|
||||
sd.type, sr.sort, sd.sort, tdr.dept_id, tdr.visitor DESC, tdr.id DESC
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue