648540858
2022-09-09 221f99c764b51c3cd284c6e5a41492c26c5c7ffc
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java
@@ -21,6 +21,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
@@ -62,7 +63,7 @@
   @Parameter(name = "expiration", description = "到期时间")
   @Parameter(name = "heartBeatInterval", description = "心跳间隔")
   @Parameter(name = "heartBeatCount", description = "心跳计数")
   public DeferredResult<ResponseEntity<String>> homePositionApi(@PathVariable String deviceId,
   public DeferredResult<String> homePositionApi(@PathVariable String deviceId,
                                                                  String channelId,
                                                                @RequestParam(required = false) String name,
                                                @RequestParam(required = false) String expiration,
@@ -81,7 +82,7 @@
         msg.setData(String.format("设备配置操作失败,错误码: %s, %s", event.statusCode, event.msg));
         resultHolder.invokeResult(msg);
      });
        DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(3 * 1000L);
        DeferredResult<String> result = new DeferredResult<String>(3 * 1000L);
      result.onTimeout(() -> {
         logger.warn(String.format("设备配置操作超时, 设备未返回应答指令"));
         // 释放rtpserver
@@ -111,13 +112,13 @@
   @Parameter(name = "channelId", description = "通道国标编号", required = true)
   @Parameter(name = "configType", description = "配置类型")
   @GetMapping("/query/{deviceId}/{configType}")
    public DeferredResult<ResponseEntity<String>> configDownloadApi(@PathVariable String deviceId,
    public DeferredResult<String> configDownloadApi(@PathVariable String deviceId,
                                                                @PathVariable String configType,
                                                                @RequestParam(required = false) String channelId) {
      if (logger.isDebugEnabled()) {
         logger.debug("设备状态查询API调用");
      }
      String key = DeferredResultHolder.CALLBACK_CMD_CONFIGDOWNLOAD + (StringUtils.isEmpty(channelId) ? deviceId : channelId);
      String key = DeferredResultHolder.CALLBACK_CMD_CONFIGDOWNLOAD + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId);
      String uuid = UUID.randomUUID().toString();
      Device device = storager.queryVideoDevice(deviceId);
      cmder.deviceConfigQuery(device, channelId, configType, event -> {
@@ -127,7 +128,7 @@
         msg.setData(String.format("获取设备配置失败,错误码: %s, %s", event.statusCode, event.msg));
         resultHolder.invokeResult(msg);
      });
        DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String >> (3 * 1000L);
        DeferredResult<String> result = new DeferredResult<String > (3 * 1000L);
      result.onTimeout(()->{
         logger.warn(String.format("获取设备配置超时"));
         // 释放rtpserver