From 9fb7246fec6a216c8a922e3c0ed009a60aeb2bfc Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期日, 24 四月 2022 14:52:01 +0800
Subject: [PATCH] Merge pull request #449 from hotcoffie/wvp-28181-2.0
---
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java | 49 ++++++++++++++++++++++++++++---------------------
1 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java
index 8d5a37f..7d11b15 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java
@@ -3,14 +3,14 @@
import java.util.List;
import java.util.UUID;
-import javax.sip.message.Response;
-
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.service.IDeviceService;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
+import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.util.StringUtil;
import io.swagger.annotations.Api;
@@ -42,13 +42,16 @@
private final static Logger logger = LoggerFactory.getLogger(MobilePositionController.class);
@Autowired
- private IVideoManagerStorager storager;
+ private IVideoManagerStorage storager;
@Autowired
private SIPCommander cmder;
@Autowired
private DeferredResultHolder resultHolder;
+
+ @Autowired
+ private IDeviceService deviceService;
/**
* 鏌ヨ鍘嗗彶杞ㄨ抗
@@ -63,13 +66,14 @@
@ApiImplicitParam(name = "start", value = "寮�濮嬫椂闂�", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "end", value = "缁撴潫鏃堕棿", required = true, dataTypeClass = String.class),
})
- @GetMapping("/history/{deviceId}")
- public ResponseEntity<List<MobilePosition>> positions(@PathVariable String deviceId,
- @RequestParam(required = false) String start,
- @RequestParam(required = false) String end) {
- if (logger.isDebugEnabled()) {
- logger.debug("鏌ヨ璁惧" + deviceId + "鐨勫巻鍙茶建杩�");
- }
+ @GetMapping("/history/{deviceId}/{channelId}")
+ public ResponseEntity<WVPResult<List<MobilePosition>>> positions(@PathVariable String deviceId,
+ @PathVariable String channelId,
+ @RequestParam(required = false) String start,
+ @RequestParam(required = false) String end) {
+// if (logger.isDebugEnabled()) {
+// logger.debug("鏌ヨ璁惧" + deviceId + "鐨勫巻鍙茶建杩�");
+// }
if (StringUtil.isEmpty(start)) {
start = null;
@@ -77,9 +81,11 @@
if (StringUtil.isEmpty(end)) {
end = null;
}
-
- List<MobilePosition> result = storager.queryMobilePositions(deviceId, start, end);
- return new ResponseEntity<>(result, HttpStatus.OK);
+ WVPResult<List<MobilePosition>> wvpResult = new WVPResult<>();
+ wvpResult.setCode(0);
+ List<MobilePosition> result = storager.queryMobilePositions(deviceId, channelId, start, end);
+ wvpResult.setData(result);
+ return new ResponseEntity<>(wvpResult, HttpStatus.OK);
}
/**
@@ -93,9 +99,9 @@
})
@GetMapping("/latest/{deviceId}")
public ResponseEntity<MobilePosition> latestPosition(@PathVariable String deviceId) {
- if (logger.isDebugEnabled()) {
- logger.debug("鏌ヨ璁惧" + deviceId + "鐨勬渶鏂颁綅缃�");
- }
+// if (logger.isDebugEnabled()) {
+// logger.debug("鏌ヨ璁惧" + deviceId + "鐨勬渶鏂颁綅缃�");
+// }
MobilePosition result = storager.queryLatestPosition(deviceId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@@ -115,11 +121,10 @@
String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_MOBILEPOSITION + deviceId;
cmder.mobilePostitionQuery(device, event -> {
- Response response = event.getResponse();
RequestMessage msg = new RequestMessage();
msg.setId(uuid);
msg.setKey(key);
- msg.setData(String.format("鑾峰彇绉诲姩浣嶇疆淇℃伅澶辫触锛岄敊璇爜锛� %s, %s", response.getStatusCode(), response.getReasonPhrase()));
+ msg.setData(String.format("鑾峰彇绉诲姩浣嶇疆淇℃伅澶辫触锛岄敊璇爜锛� %s, %s", event.statusCode, event.msg));
resultHolder.invokeResult(msg);
});
DeferredResult<ResponseEntity<MobilePosition>> result = new DeferredResult<ResponseEntity<MobilePosition>>(5*1000L);
@@ -162,9 +167,11 @@
interval = "5";
}
Device device = storager.queryVideoDevice(deviceId);
-
+ device.setSubscribeCycleForMobilePosition(Integer.parseInt(expires));
+ device.setMobilePositionSubmissionInterval(Integer.parseInt(interval));
+ storager.updateDevice(device);
String result = msg;
- if (cmder.mobilePositionSubscribe(device, Integer.parseInt(expires), Integer.parseInt(interval))) {
+ if (deviceService.removeMobilePositionSubscribe(device)) {
result += "锛屾垚鍔�";
} else {
result += "锛屽け璐�";
--
Gitblit v1.8.0