Browse Source

fix: 控制接口优化
1. 修复普通用户因为设备id与国标id不一致导致的异常

kindring 1 year ago
parent
commit
c043f63165

+ 5 - 2
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java

@@ -382,6 +382,8 @@ public class PlayController {
             );
             return deferredResult;
         }
+        // 适应旧api, 用于sip异步交互 key
+        deviceId = device.getDeviceId();
 
         RequestMessage msg = new RequestMessage();
         // 返回invite信息给设备
@@ -406,6 +408,7 @@ public class PlayController {
             resultHolder.invokeAllResult(msg);
         } else {
             logger.info("[语音广播] 分配的流媒体服务器为 {}", mediaServerItem.getId());
+            String finalDeviceId = deviceId;
             playService.openBroadcast(
                     mediaServerItem,
                     device,
@@ -426,7 +429,7 @@ public class PlayController {
 
                             BroadcastItem broadcastItem = new BroadcastItem();
                             broadcastItem.setMediaId(mediaServerItem.getId());
-                            broadcastItem.setDeviceId(deviceId);
+                            broadcastItem.setDeviceId(finalDeviceId);
                             broadcastItem.setApp(app);
                             broadcastItem.setStream(stream);
                             broadcastItem.setRecv_stream("recv_" + stream);
@@ -464,7 +467,7 @@ public class PlayController {
                             );
                             //存储invite信息和request信息至redis中
                             gbStore.addBroadcastStore(
-                                    "broadcast_" + deviceId,
+                                    "broadcast_" + finalDeviceId,
                                     broadcastItem
                             );
 

+ 3 - 2
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java

@@ -96,7 +96,8 @@ public class PlaybackController {
             result.setResult(WVPResult.fail(ErrorCode.ERROR400, "接口调用失败, 没有权限或者无法找到设备"));
             return result;
         }
-
+        // 适应旧api, 用于sip异步交互 key
+        deviceId = device.getDeviceId();
         String uuid = UUID.randomUUID().toString();
         String key = DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId;
         DeferredResult<WVPResult<StreamContent>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
@@ -106,7 +107,7 @@ public class PlaybackController {
 
         RequestMessage msg = new RequestMessage();
         msg.setKey(key);
-		msg.setId(uuid);
+        msg.setId(uuid);
 
 		playService.playBack(deviceId, channelId, startTime, endTime, null,
 				playBackResult->{

+ 2 - 0
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java

@@ -275,6 +275,8 @@ public class PtzController {
             result.setResult(WVPResult.fail(ErrorCode.ERROR100, "无法找到设备"));
             return result;
         }
+        // 适应旧api, 用于sip异步交互 key
+        deviceId = device.getDeviceId();
 
         String uuid = UUID.randomUUID().toString();
         // 此处一开始使用的是channelId,但是发现有些设备没有channelId,所以改成deviceId

+ 20 - 18
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java

@@ -74,24 +74,26 @@ public class GBRecordController {
     @GetMapping("/query/{deviceId}/{channelId}")
     public DeferredResult<WVPResult<RecordInfo>> recordinfo(@PathVariable String deviceId, @PathVariable String channelId, String startTime, String endTime) {
 
-        logger.info("[设备录像查询] {}-{}", deviceId, channelId);
-        Device device = deviceHelper.getDevice(deviceId, null);
-        DeferredResult<WVPResult<RecordInfo>> result = new DeferredResult<>();
-        if (device == null) {
-            // 无权限
-            result.setResult(WVPResult.fail(ErrorCode.ERROR403, "无法操控此设备"));
-            return result;
-        }
-
-        // 时间转换
-        if (!DateUtil.verification(startTime, DateUtil.formatter)) {
-            result.setResult(
-                    WVPResult.fail(ErrorCode.ERROR100, "startTime error, format is " + DateUtil.PATTERN)
-            );
-            return result;
-        }
-        if (!DateUtil.verification(endTime, DateUtil.formatter)) {
-            result.setResult(
+		logger.info("[设备录像查询] {}-{}", deviceId, channelId);
+		Device device = deviceHelper.getDevice(deviceId, null);
+		DeferredResult<WVPResult<RecordInfo>> result = new DeferredResult<>();
+		if (device == null) {
+			// 无权限
+			result.setResult(WVPResult.fail(ErrorCode.ERROR403, "无法操控此设备"));
+			return result;
+		}
+		// 适应旧api, 用于sip异步交互 key
+		deviceId = device.getDeviceId();
+
+		// 时间转换
+		if (!DateUtil.verification(startTime, DateUtil.formatter)) {
+			result.setResult(
+					WVPResult.fail(ErrorCode.ERROR100, "startTime error, format is " + DateUtil.PATTERN)
+			);
+			return result;
+		}
+		if (!DateUtil.verification(endTime, DateUtil.formatter)) {
+			result.setResult(
                     WVPResult.fail(ErrorCode.ERROR100, "endTime error, format is " + DateUtil.PATTERN)
             );
             return result;