648540858
2022-02-27 e94b99d11c46246532edc93cd25cbf8c0b88f03f
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
@@ -10,8 +10,10 @@
import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTree;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -25,6 +27,7 @@
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
import java.util.List;
import java.util.UUID;
@Api(tags = "国标设备查询", value = "国标设备查询")
@@ -150,7 +153,8 @@
      Device device = storager.queryVideoDevice(deviceId);
      String key = DeferredResultHolder.CALLBACK_CMD_CATALOG + deviceId;
      String uuid = UUID.randomUUID().toString();
      DeferredResult<ResponseEntity<Device>> result = new DeferredResult<ResponseEntity<Device>>(15*1000L);
      // 默认超时时间为30分钟
      DeferredResult<ResponseEntity<Device>> result = new DeferredResult<ResponseEntity<Device>>(30*60*1000L);
      result.onTimeout(()->{
         logger.warn("设备[{}]通道信息同步超时", deviceId);
         // 释放rtpserver
@@ -163,6 +167,7 @@
         wvpResult.setMsg("更新超时");
         msg.setData(wvpResult);
         resultHolder.invokeAllResult(msg);
      });
      // 等待其他相同请求返回时一起返回
      if (resultHolder.exist(key, null)) {
@@ -207,7 +212,6 @@
      boolean isSuccess = storager.delete(deviceId);
      if (isSuccess) {
         redisCatchStorage.clearCatchByDeviceId(deviceId);
         redisCatchStorage.removeDevice(deviceId);
         JSONObject json = new JSONObject();
         json.put("deviceId", deviceId);
         return new ResponseEntity<>(json.toString(),HttpStatus.OK);
@@ -315,7 +319,8 @@
         if (!StringUtils.isEmpty(device.getCharset())) deviceInStore.setCharset(device.getCharset());
         if (!StringUtils.isEmpty(device.getMediaServerId())) deviceInStore.setMediaServerId(device.getMediaServerId());
         if (deviceInStore.getSubscribeCycleForCatalog() <=0 && device.getSubscribeCycleForCatalog() > 0) {
         if ((deviceInStore.getSubscribeCycleForCatalog() <=0 && device.getSubscribeCycleForCatalog() > 0)
               || deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) {
            deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
            // 开启订阅
            deviceService.addCatalogSubscribe(deviceInStore);
@@ -429,5 +434,9 @@
      return result;
   }
   @GetMapping("/{deviceId}/tree")
   @ApiOperation(value = "通道树形结构", notes = "通道树形结构")
   public WVPResult<List<DeviceChannelTree>> tree(@PathVariable String deviceId) {
      return WVPResult.Data(storager.tree(deviceId));
   }
}