From d7b4075e7f56da4d91840b1fc7b41324bc17c6cf Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 15 Aug 2022 18:01:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=92=E5=B9=B6=E4=B8=BA=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ResourceServiceImpl.java | 84 ++++++++----------- 1 file changed, 34 insertions(+), 50 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java index f9fffcc7..5ffceab6 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java @@ -472,19 +472,15 @@ public class ResourceServiceImpl extends CrudServiceImpl { List 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()); - if (pingTOp_ <= 0) { - return 0l; - } - long pingTOp = (index.get("pin_top_time") == null) ? 0 : Long.parseLong(index.get("pin_top_time").toString()); - return pingTOp; - }).reversed() - .thenComparing(x -> { - Map index = (Map) x; - String string = (index.get("total") == null) ? "0" : index.get("total").toString(); - return Long.valueOf(string); - }, Comparator.reverseOrder()) + Map index = (Map) 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) { + return 0l + Long.valueOf(string); + } + long pingTOp = (index.get("pin_top_time") == null) ? 0 + Long.valueOf(string) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(string); + return pingTOp; + }).reversed() ).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList()); return temp; }).get(); @@ -493,19 +489,15 @@ public class ResourceServiceImpl extends CrudServiceImpl { List 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); - }) - .thenComparing(x -> { - Map index = (Map) x; - int pingTOp_ = (index.get("pin_top") == null) ? 0 : Integer.parseInt(index.get("pin_top").toString()); - if (pingTOp_ <= 0) { - return 0l; - } - long pingTOp = (index.get("pin_top_time") == null) ? 0 : Long.parseLong(index.get("pin_top_time").toString()); - return pingTOp; - }).reversed()).skip((pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList()); + Map index = (Map) 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) { + return 0l + Long.valueOf(string); + } + long pingTOp = (index.get("pin_top_time") == null) ? 0 + Long.valueOf(string) : Long.parseLong(index.get("pin_top_time").toString()) + Long.valueOf(string); + return pingTOp; + })).skip((pageNum - 1) * pageSize).limit(pageSize).map(x -> Long.valueOf(x.get("id").toString())).limit(pageSize).collect(Collectors.toList()); return temp; }).get(); break; @@ -513,33 +505,25 @@ public class ResourceServiceImpl extends CrudServiceImpl { - ResourceDTO index = (ResourceDTO) x; - return index.getTotal() == null ? 0L : index.getTotal(); - }).reversed() - .thenComparing(x -> { - ResourceDTO index = (ResourceDTO) x; - int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); - if (pinTop > 0) { - return index.getPinTopTime() == null ? new Date(0).getTime() + pinTop : index.getPinTopTime().getTime() + pinTop; - } else { - return new Date(0).getTime() + pinTop; - } - }).reversed() + ResourceDTO index = (ResourceDTO) x; + int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); + if (pinTop > 0) { + return index.getPinTopTime() == null ? new Date(0).getTime() + index.getTotal() : index.getPinTopTime().getTime() + index.getTotal(); + } else { + return new Date(0).getTime() + index.getTotal(); + } + }).reversed() ).collect(Collectors.toList())); } else { resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> { - ResourceDTO index = (ResourceDTO) x; - return index.getTotal() == null ? 0L : index.getTotal(); - }, Comparator.reverseOrder()) - .thenComparing(x -> { - ResourceDTO index = (ResourceDTO) x; - int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); - if (pinTop > 0) { - return index.getPinTopTime() == null ? new Date(0).getTime() + pinTop : index.getPinTopTime().getTime() + pinTop; - } else { - return new Date(0).getTime() + pinTop; - } - }, Comparator.reverseOrder()) + ResourceDTO index = (ResourceDTO) x; + int pinTop = index.getPinTop() == null ? 0 : index.getPinTop(); + if (pinTop > 0) { + return index.getPinTopTime() == null ? new Date(0).getTime() + index.getTotal() : index.getPinTopTime().getTime() + index.getTotal(); + } else { + return new Date(0).getTime() + index.getTotal(); + } + }) ).collect(Collectors.toList())); } customThreadPool.shutdown();