Commit f4960b2618f8f19f3bcbdda9683ec051f16949de
1 parent
f3388dd5
修复移动位置获取接口超时 #857
Showing
3 changed files
with
18 additions
and
5 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java
| @@ -45,7 +45,7 @@ public class DeferredResultHolder { | @@ -45,7 +45,7 @@ public class DeferredResultHolder { | ||
| 45 | 45 | ||
| 46 | public static final String UPLOAD_FILE_CHANNEL = "UPLOAD_FILE_CHANNEL"; | 46 | public static final String UPLOAD_FILE_CHANNEL = "UPLOAD_FILE_CHANNEL"; |
| 47 | 47 | ||
| 48 | - public static final String CALLBACK_CMD_MOBILEPOSITION = "CALLBACK_MOBILEPOSITION"; | 48 | + public static final String CALLBACK_CMD_MOBILE_POSITION = "CALLBACK_CMD_MOBILE_POSITION"; |
| 49 | 49 | ||
| 50 | public static final String CALLBACK_CMD_PRESETQUERY = "CALLBACK_PRESETQUERY"; | 50 | public static final String CALLBACK_CMD_PRESETQUERY = "CALLBACK_PRESETQUERY"; |
| 51 | 51 |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java
| @@ -2,17 +2,20 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.respon | @@ -2,17 +2,20 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.respon | ||
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson2.JSONObject; | 3 | import com.alibaba.fastjson2.JSONObject; |
| 4 | import com.genersoft.iot.vmp.conf.UserSetting; | 4 | import com.genersoft.iot.vmp.conf.UserSetting; |
| 5 | -import com.genersoft.iot.vmp.gb28181.bean.*; | 5 | +import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 6 | +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | ||
| 7 | +import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; | ||
| 8 | +import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | ||
| 9 | +import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | ||
| 10 | +import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; | ||
| 6 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; | 11 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 7 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; | 12 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; |
| 8 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; | 13 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; |
| 9 | -import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; | ||
| 10 | import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; | 14 | import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; |
| 11 | import com.genersoft.iot.vmp.service.IDeviceChannelService; | 15 | import com.genersoft.iot.vmp.service.IDeviceChannelService; |
| 12 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 16 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 13 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | 17 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 14 | import com.genersoft.iot.vmp.utils.DateUtil; | 18 | import com.genersoft.iot.vmp.utils.DateUtil; |
| 15 | -import com.genersoft.iot.vmp.utils.GpsUtil; | ||
| 16 | import gov.nist.javax.sip.message.SIPRequest; | 19 | import gov.nist.javax.sip.message.SIPRequest; |
| 17 | import org.dom4j.DocumentException; | 20 | import org.dom4j.DocumentException; |
| 18 | import org.dom4j.Element; | 21 | import org.dom4j.Element; |
| @@ -56,6 +59,9 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar | @@ -56,6 +59,9 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar | ||
| 56 | @Autowired | 59 | @Autowired |
| 57 | private IDeviceChannelService deviceChannelService; | 60 | private IDeviceChannelService deviceChannelService; |
| 58 | 61 | ||
| 62 | + @Autowired | ||
| 63 | + private DeferredResultHolder resultHolder; | ||
| 64 | + | ||
| 59 | @Override | 65 | @Override |
| 60 | public void afterPropertiesSet() throws Exception { | 66 | public void afterPropertiesSet() throws Exception { |
| 61 | responseMessageHandler.addHandler(cmdType, this); | 67 | responseMessageHandler.addHandler(cmdType, this); |
| @@ -121,8 +127,15 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar | @@ -121,8 +127,15 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar | ||
| 121 | if (userSetting.getSavePositionHistory()) { | 127 | if (userSetting.getSavePositionHistory()) { |
| 122 | storager.insertMobilePosition(mobilePosition); | 128 | storager.insertMobilePosition(mobilePosition); |
| 123 | } | 129 | } |
| 130 | + | ||
| 124 | storager.updateChannelPosition(deviceChannel); | 131 | storager.updateChannelPosition(deviceChannel); |
| 125 | 132 | ||
| 133 | + String key = DeferredResultHolder.CALLBACK_CMD_MOBILE_POSITION + device.getDeviceId(); | ||
| 134 | + RequestMessage msg = new RequestMessage(); | ||
| 135 | + msg.setKey(key); | ||
| 136 | + msg.setData(mobilePosition); | ||
| 137 | + resultHolder.invokeAllResult(msg); | ||
| 138 | + | ||
| 126 | // 发送redis消息。 通知位置信息的变化 | 139 | // 发送redis消息。 通知位置信息的变化 |
| 127 | JSONObject jsonObject = new JSONObject(); | 140 | JSONObject jsonObject = new JSONObject(); |
| 128 | jsonObject.put("time", mobilePosition.getTime()); | 141 | jsonObject.put("time", mobilePosition.getTime()); |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java
| @@ -102,7 +102,7 @@ public class MobilePositionController { | @@ -102,7 +102,7 @@ public class MobilePositionController { | ||
| 102 | public DeferredResult<MobilePosition> realTimePosition(@PathVariable String deviceId) { | 102 | public DeferredResult<MobilePosition> realTimePosition(@PathVariable String deviceId) { |
| 103 | Device device = storager.queryVideoDevice(deviceId); | 103 | Device device = storager.queryVideoDevice(deviceId); |
| 104 | String uuid = UUID.randomUUID().toString(); | 104 | String uuid = UUID.randomUUID().toString(); |
| 105 | - String key = DeferredResultHolder.CALLBACK_CMD_MOBILEPOSITION + deviceId; | 105 | + String key = DeferredResultHolder.CALLBACK_CMD_MOBILE_POSITION + deviceId; |
| 106 | try { | 106 | try { |
| 107 | cmder.mobilePostitionQuery(device, event -> { | 107 | cmder.mobilePostitionQuery(device, event -> { |
| 108 | RequestMessage msg = new RequestMessage(); | 108 | RequestMessage msg = new RequestMessage(); |