diff --git a/src/main/java/club/joylink/xiannccda/dto/fq/FaultQueryNcc.java b/src/main/java/club/joylink/xiannccda/dto/fq/FaultQueryNcc.java index 3b0c4ed..e681c76 100644 --- a/src/main/java/club/joylink/xiannccda/dto/fq/FaultQueryNcc.java +++ b/src/main/java/club/joylink/xiannccda/dto/fq/FaultQueryNcc.java @@ -1,9 +1,12 @@ package club.joylink.xiannccda.dto.fq; import club.joylink.xiannccda.entity.FaultQuery; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.google.common.collect.Lists; import java.security.PublicKey; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -18,15 +21,25 @@ public class FaultQueryNcc { public FaultQueryNcc(String typeName, List fqList) { this.nccTypeName = typeName; - Map> dataMapList = fqList.stream().collect(Collectors.groupingBy(FaultQuery::getFaultDriverShower, Collectors.mapping(FaultQuery::getResultMsg, Collectors.toList()))); + Map> dataMapList = fqList.stream().collect(Collectors.groupingBy(FaultQuery::getFaultDriverShower, Collectors.collectingAndThen(Collectors.toList(), lists -> { + lists.sort(Comparator.comparingLong(FaultQuery::getId)); + return lists; + }))); List tl = Lists.newArrayList(); dataMapList.forEach((k, v) -> { - tl.add(new NccData(k, v)); + NccData nd = new NccData(k, v.stream().map(FaultQuery::getResultMsg).collect(Collectors.toList())); + nd.setOrderId(v.get(0).getId()); + tl.add(nd); }); + this.orderId = fqList.get(0).getId(); + + tl.sort(Comparator.comparingLong(NccData::getOrderId)); this.nccData = tl; } private String nccTypeName; + @JsonIgnore + private Long orderId; private List nccData; @Data @@ -42,6 +55,8 @@ public class FaultQueryNcc { this.datas = datas; } + @JsonIgnore + private Long orderId; private String action; private List datas; } diff --git a/src/main/java/club/joylink/xiannccda/repository/impl/FaultQueryRepository.java b/src/main/java/club/joylink/xiannccda/repository/impl/FaultQueryRepository.java index e766987..8996770 100644 --- a/src/main/java/club/joylink/xiannccda/repository/impl/FaultQueryRepository.java +++ b/src/main/java/club/joylink/xiannccda/repository/impl/FaultQueryRepository.java @@ -85,6 +85,7 @@ public class FaultQueryRepository extends ServiceImpl { nccList.add(new FaultQueryNcc(k, v)); }); + Collections.sort(nccList, Comparator.comparingLong(FaultQueryNcc::getOrderId)); return nccList; }