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 | 45 | |
| 46 | 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 | 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 | 2 | |
| 3 | 3 | import com.alibaba.fastjson2.JSONObject; |
| 4 | 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 | 11 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 7 | 12 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; |
| 8 | 13 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; |
| 9 | -import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; | |
| 10 | 14 | import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; |
| 11 | 15 | import com.genersoft.iot.vmp.service.IDeviceChannelService; |
| 12 | 16 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 13 | 17 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 14 | 18 | import com.genersoft.iot.vmp.utils.DateUtil; |
| 15 | -import com.genersoft.iot.vmp.utils.GpsUtil; | |
| 16 | 19 | import gov.nist.javax.sip.message.SIPRequest; |
| 17 | 20 | import org.dom4j.DocumentException; |
| 18 | 21 | import org.dom4j.Element; |
| ... | ... | @@ -56,6 +59,9 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar |
| 56 | 59 | @Autowired |
| 57 | 60 | private IDeviceChannelService deviceChannelService; |
| 58 | 61 | |
| 62 | + @Autowired | |
| 63 | + private DeferredResultHolder resultHolder; | |
| 64 | + | |
| 59 | 65 | @Override |
| 60 | 66 | public void afterPropertiesSet() throws Exception { |
| 61 | 67 | responseMessageHandler.addHandler(cmdType, this); |
| ... | ... | @@ -121,8 +127,15 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar |
| 121 | 127 | if (userSetting.getSavePositionHistory()) { |
| 122 | 128 | storager.insertMobilePosition(mobilePosition); |
| 123 | 129 | } |
| 130 | + | |
| 124 | 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 | 139 | // 发送redis消息。 通知位置信息的变化 |
| 127 | 140 | JSONObject jsonObject = new JSONObject(); |
| 128 | 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 | 102 | public DeferredResult<MobilePosition> realTimePosition(@PathVariable String deviceId) { |
| 103 | 103 | Device device = storager.queryVideoDevice(deviceId); |
| 104 | 104 | String uuid = UUID.randomUUID().toString(); |
| 105 | - String key = DeferredResultHolder.CALLBACK_CMD_MOBILEPOSITION + deviceId; | |
| 105 | + String key = DeferredResultHolder.CALLBACK_CMD_MOBILE_POSITION + deviceId; | |
| 106 | 106 | try { |
| 107 | 107 | cmder.mobilePostitionQuery(device, event -> { |
| 108 | 108 | RequestMessage msg = new RequestMessage(); | ... | ... |