From fd8aa3dbc95088851fafc88c8543dbfd895bb7b0 Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Wed, 23 Aug 2023 10:32:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=86=E5=8F=B2=E5=AA=92=E4=BD=93=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=9F=A5=E8=AF=A2=20=E6=B7=BB=E5=8A=A0=E6=8E=92?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../docking/gb28181/service/record/RecordService.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/record/RecordService.java b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/record/RecordService.java index bd32e0a..0ea931f 100644 --- a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/record/RecordService.java +++ b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/record/RecordService.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; @Slf4j @Service @@ -113,7 +114,7 @@ public class RecordService { public void onComplete() { schedule[0].cancel(true); subscribe.getRecordInfoSubscribe().delPublisher(key); - result.setResult(JsonResponse.success(list)); + result.setResult(JsonResponse.success(sortedRecordList(list))); log.debug("订阅结束 => {}", key); } }; @@ -121,10 +122,14 @@ public class RecordService { subscribe.getRecordInfoSubscribe().addSubscribe(key, subscriber); result.onTimeout(()->{ - result.setResult(JsonResponse.success(list,"查询超时, 结果可能不完整")); + result.setResult(JsonResponse.success(sortedRecordList(list),"查询超时, 结果可能不完整")); subscribe.getRecordInfoSubscribe().delPublisher(key); }); return result; } + + private List sortedRecordList(List list){ + return list.stream().sorted((a,b)-> DateUtil.compare(a.getStartTime(),b.getStartTime())).collect(Collectors.toList()); + } }