From be7082f5e21aaab0ef541d9a78ced7eaebcfb1f7 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期四, 25 十一月 2021 15:33:25 +0800 Subject: [PATCH] 优化多线程参数 --- src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java index f1c85cd..5b33826 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java @@ -22,6 +22,8 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import java.util.UUID; + @Api(tags = "鍥芥爣褰曞儚") @CrossOrigin @RestController @@ -54,15 +56,21 @@ } Device device = storager.queryVideoDevice(deviceId); - cmder.recordInfoQuery(device, channelId, startTime, endTime); // 鎸囧畾瓒呮椂鏃堕棿 1鍒嗛挓30绉� - DeferredResult<ResponseEntity<RecordInfo>> result = new DeferredResult<ResponseEntity<RecordInfo>>(90*1000L); + DeferredResult<ResponseEntity<RecordInfo>> result = new DeferredResult<>(90*1000L); + String uuid = UUID.randomUUID().toString(); + String key = DeferredResultHolder.CALLBACK_CMD_RECORDINFO + deviceId + channelId; + RequestMessage msg = new RequestMessage(); + msg.setId(uuid); + msg.setKey(key); + cmder.recordInfoQuery(device, channelId, startTime, endTime, (eventResult -> { + msg.setData("鏌ヨ褰曞儚澶辫触, status: " + eventResult.statusCode + ", message: " + eventResult.msg ); + resultHolder.invokeResult(msg); + })); + // 褰曞儚鏌ヨ浠hannelId浣滀负deviceId鏌ヨ - resultHolder.put(DeferredResultHolder.CALLBACK_CMD_RECORDINFO+channelId, result); + resultHolder.put(key, uuid, result); result.onTimeout(()->{ - RequestMessage msg = new RequestMessage(); - msg.setDeviceId(deviceId); - msg.setType(DeferredResultHolder.CALLBACK_CMD_RECORDINFO); msg.setData("timeout"); resultHolder.invokeResult(msg); }); -- Gitblit v1.8.0