| | |
| | | import com.genersoft.iot.vmp.conf.DynamicTask; |
| | | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| | | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| | | import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; |
| | | import com.genersoft.iot.vmp.gb28181.bean.SyncStatus; |
| | | import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; |
| | | import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; |
| | | import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask; |
| | | import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeHandlerTask; |
| | | import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask; |
| | | 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 org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.context.request.async.DeferredResult; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.UUID; |
| | | import javax.sip.DialogState; |
| | | import java.util.*; |
| | | |
| | | @Api(tags = "国标设备查询", value = "国标设备查询") |
| | | @SuppressWarnings("rawtypes") |
| | |
| | | |
| | | @Autowired |
| | | private DynamicTask dynamicTask; |
| | | |
| | | @Autowired |
| | | private SubscribeHolder subscribeHolder; |
| | | |
| | | /** |
| | | * 使用ID查询国标设备 |
| | |
| | | logger.debug("设备通道信息同步API调用,deviceId:" + deviceId); |
| | | } |
| | | Device device = storager.queryVideoDevice(deviceId); |
| | | SyncStatus syncStatus = deviceService.getChannelSyncStatus(deviceId); |
| | | boolean status = deviceService.isSyncRunning(deviceId); |
| | | // 已存在则返回进度 |
| | | if (syncStatus != null && syncStatus.getErrorMsg() == null) { |
| | | if (status) { |
| | | WVPResult<SyncStatus> wvpResult = new WVPResult<>(); |
| | | wvpResult.setCode(0); |
| | | wvpResult.setData(syncStatus); |
| | | SyncStatus channelSyncStatus = deviceService.getChannelSyncStatus(deviceId); |
| | | wvpResult.setData(channelSyncStatus); |
| | | return wvpResult; |
| | | } |
| | | SyncStatus syncStatusReady = new SyncStatus(); |
| | | deviceService.setChannelSyncReady(deviceId); |
| | | cmder.catalogQuery(device, event -> { |
| | | String errorMsg = String.format("同步通道失败,错误码: %s, %s", event.statusCode, event.msg); |
| | | deviceService.setChannelSyncEnd(deviceId, errorMsg); |
| | | }); |
| | | deviceService.sync(device); |
| | | |
| | | WVPResult<SyncStatus> wvpResult = new WVPResult<>(); |
| | | wvpResult.setCode(0); |
| | | wvpResult.setMsg("开始同步"); |
| | |
| | | } |
| | | return wvpResult; |
| | | } |
| | | |
| | | @GetMapping("/{deviceId}/subscribe_info") |
| | | @ApiOperation(value = "获取设备的订阅状态", notes = "获取设备的订阅状态") |
| | | public WVPResult<Map<String, String>> getSubscribeInfo(@PathVariable String deviceId) { |
| | | Set<String> allKeys = dynamicTask.getAllKeys(); |
| | | Map<String, String> dialogStateMap = new HashMap<>(); |
| | | for (String key : allKeys) { |
| | | if (key.startsWith(deviceId)) { |
| | | ISubscribeTask subscribeTask = (ISubscribeTask)dynamicTask.get(key); |
| | | DialogState dialogState = subscribeTask.getDialogState(); |
| | | if (dialogState == null) { |
| | | continue; |
| | | } |
| | | if (subscribeTask instanceof CatalogSubscribeTask) { |
| | | dialogStateMap.put("catalog", dialogState.toString()); |
| | | }else if (subscribeTask instanceof MobilePositionSubscribeTask) { |
| | | dialogStateMap.put("mobilePosition", dialogState.toString()); |
| | | } |
| | | } |
| | | } |
| | | WVPResult<Map<String, String>> wvpResult = new WVPResult<>(); |
| | | wvpResult.setCode(0); |
| | | wvpResult.setData(dialogStateMap); |
| | | return wvpResult; |
| | | } |
| | | } |