This commit is contained in:
wangliwen 2022-08-15 16:50:52 +08:00
parent a8cd7f8436
commit 4b308ed69f
1 changed files with 17 additions and 34 deletions

View File

@ -472,11 +472,6 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
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;
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; 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());
if (pingTOp_ <= 0) { if (pingTOp_ <= 0) {
@ -484,7 +479,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
} }
long pingTOp = (index.get("pin_top_time") == null) ? 0 : Long.parseLong(index.get("pin_top_time").toString()); long pingTOp = (index.get("pin_top_time") == null) ? 0 : Long.parseLong(index.get("pin_top_time").toString());
return pingTOp; return pingTOp;
}, Comparator.reverseOrder()) }).reversed()
.thenComparing(x -> { .thenComparing(x -> {
Map index = (Map) x; Map index = (Map) x;
String string = (index.get("total") == null) ? "0" : index.get("total").toString(); String string = (index.get("total") == null) ? "0" : index.get("total").toString();
@ -498,11 +493,6 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
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;
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; 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());
if (pingTOp_ <= 0) { if (pingTOp_ <= 0) {
@ -510,7 +500,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
} }
long pingTOp = (index.get("pin_top_time") == null) ? 0 : Long.parseLong(index.get("pin_top_time").toString()); long pingTOp = (index.get("pin_top_time") == null) ? 0 : Long.parseLong(index.get("pin_top_time").toString());
return pingTOp; return pingTOp;
}, Comparator.reverseOrder()) }).reversed()
.thenComparing(x -> { .thenComparing(x -> {
Map index = (Map) x; Map index = (Map) x;
String string = (index.get("total") == null) ? "0" : index.get("total").toString(); String string = (index.get("total") == null) ? "0" : index.get("total").toString();
@ -524,8 +514,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
if ("DESC".equals(orderType)) { if ("DESC".equals(orderType)) {
resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> { resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> {
ResourceDTO index = (ResourceDTO) x; ResourceDTO index = (ResourceDTO) x;
return index.getPinTop() == null ? 0 : index.getPinTop(); return index.getTotal() == null ? 0L : index.getTotal();
}).reversed() }, Comparator.reverseOrder())
.thenComparing(x -> { .thenComparing(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();
@ -535,29 +525,22 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
return new Date(0).getTime() + pinTop; return new Date(0).getTime() + pinTop;
} }
}).reversed() }).reversed()
.thenComparing(x -> {
ResourceDTO index = (ResourceDTO) x;
return index.getTotal() == null ? 0L : index.getTotal();
}, Comparator.reverseOrder())
).collect(Collectors.toList())); ).collect(Collectors.toList()));
} else { } else {
resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> { resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> {
ResourceDTO index = (ResourceDTO) x; ResourceDTO index = (ResourceDTO) x;
return index.getPinTop() == null ? 0 : index.getPinTop(); return index.getTotal() == null ? 0L : index.getTotal();
}).reversed() }, Comparator.reverseOrder())
.thenComparing(x -> { .thenComparing(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();
if (pinTop > 0) { if (pinTop > 0) {
return index.getPinTopTime() == null ? new Date(0).getTime() : index.getPinTopTime().getTime(); return index.getPinTopTime() == null ? new Date(0).getTime() + pinTop : index.getPinTopTime().getTime() + pinTop;
} else { } else {
return new Date(0).getTime(); return new Date(0).getTime() + pinTop;
} }
}).reversed() }, Comparator.reverseOrder())
.thenComparing(x -> { ).collect(Collectors.toList()));
ResourceDTO index = (ResourceDTO) x;
return index.getTotal() == null ? 0L : index.getTotal();
})).collect(Collectors.toList()));
} }
customThreadPool.shutdown(); customThreadPool.shutdown();
} else { // 非总体评价排序时 } else { // 非总体评价排序时