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();