catalog 异常处理
This commit is contained in:
parent
405e29c15b
commit
47f6edc667
@ -1,5 +1,7 @@
|
|||||||
package cn.skcks.docking.gb28181.common.json;
|
package cn.skcks.docking.gb28181.common.json;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
|
||||||
public class JsonException extends Exception{
|
public class JsonException extends Exception{
|
||||||
public JsonException(String message){
|
public JsonException(String message){
|
||||||
super(message);
|
super(message);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package cn.skcks.docking.gb28181.service.catalog;
|
package cn.skcks.docking.gb28181.service.catalog;
|
||||||
|
|
||||||
|
import cn.skcks.docking.gb28181.common.json.JsonException;
|
||||||
|
import cn.skcks.docking.gb28181.common.json.JsonResponse;
|
||||||
import cn.skcks.docking.gb28181.config.sip.SipConfig;
|
import cn.skcks.docking.gb28181.config.sip.SipConfig;
|
||||||
import cn.skcks.docking.gb28181.constant.CmdType;
|
import cn.skcks.docking.gb28181.constant.CmdType;
|
||||||
import cn.skcks.docking.gb28181.core.sip.message.request.SipRequestBuilder;
|
import cn.skcks.docking.gb28181.core.sip.message.request.SipRequestBuilder;
|
||||||
@ -7,6 +9,7 @@ import cn.skcks.docking.gb28181.core.sip.message.subscribe.GenericSubscribe;
|
|||||||
import cn.skcks.docking.gb28181.core.sip.message.subscribe.SipSubscribe;
|
import cn.skcks.docking.gb28181.core.sip.message.subscribe.SipSubscribe;
|
||||||
import cn.skcks.docking.gb28181.core.sip.service.SipService;
|
import cn.skcks.docking.gb28181.core.sip.service.SipService;
|
||||||
import cn.skcks.docking.gb28181.orm.mybatis.dynamic.model.DockingDevice;
|
import cn.skcks.docking.gb28181.orm.mybatis.dynamic.model.DockingDevice;
|
||||||
|
import cn.skcks.docking.gb28181.orm.mybatis.dynamic.model.DockingDeviceChannel;
|
||||||
import cn.skcks.docking.gb28181.service.device.DeviceChannelService;
|
import cn.skcks.docking.gb28181.service.device.DeviceChannelService;
|
||||||
import cn.skcks.docking.gb28181.service.docking.device.cache.DockingDeviceCacheService;
|
import cn.skcks.docking.gb28181.service.docking.device.cache.DockingDeviceCacheService;
|
||||||
import cn.skcks.docking.gb28181.sip.manscdp.catalog.query.CatalogQueryDTO;
|
import cn.skcks.docking.gb28181.sip.manscdp.catalog.query.CatalogQueryDTO;
|
||||||
@ -23,6 +26,7 @@ import javax.sip.SipProvider;
|
|||||||
import javax.sip.message.Request;
|
import javax.sip.message.Request;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -41,6 +45,11 @@ public class CatalogService {
|
|||||||
CompletableFuture<List<CatalogItemDTO>> result = new CompletableFuture<>();
|
CompletableFuture<List<CatalogItemDTO>> result = new CompletableFuture<>();
|
||||||
result.completeOnTimeout(Collections.emptyList(), 60, TimeUnit.SECONDS);
|
result.completeOnTimeout(Collections.emptyList(), 60, TimeUnit.SECONDS);
|
||||||
DockingDevice device = deviceCacheService.getDevice(gbDeviceId);
|
DockingDevice device = deviceCacheService.getDevice(gbDeviceId);
|
||||||
|
if (device == null) {
|
||||||
|
log.info("未能找到 编码为 => {} 的设备", gbDeviceId);
|
||||||
|
result.completeExceptionally(new JsonException("未找到设备 " + gbDeviceId));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
SipProvider provider = sipService.getProvider(device.getTransport(), device.getLocalIp());
|
SipProvider provider = sipService.getProvider(device.getTransport(), device.getLocalIp());
|
||||||
MessageRequestBuilder requestBuilder = MessageRequestBuilder.builder()
|
MessageRequestBuilder requestBuilder = MessageRequestBuilder.builder()
|
||||||
.localIp(device.getLocalIp())
|
.localIp(device.getLocalIp())
|
||||||
|
@ -55,17 +55,16 @@ public class RecordService {
|
|||||||
public DeferredResult<JsonResponse<List<RecordInfoItemVO>>> requestRecordInfo(String deviceId, String channelId, long timeout, Date date) {
|
public DeferredResult<JsonResponse<List<RecordInfoItemVO>>> requestRecordInfo(String deviceId, String channelId, long timeout, Date date) {
|
||||||
log.info("查询 设备 => {} {} 的历史媒体记录, 超时时间 {} 秒", deviceId, DateUtil.formatDate(date), timeout);
|
log.info("查询 设备 => {} {} 的历史媒体记录, 超时时间 {} 秒", deviceId, DateUtil.formatDate(date), timeout);
|
||||||
DeferredResult<JsonResponse<List<RecordInfoItemVO>>> result = new DeferredResult<>(TimeUnit.SECONDS.toMillis(timeout));
|
DeferredResult<JsonResponse<List<RecordInfoItemVO>>> result = new DeferredResult<>(TimeUnit.SECONDS.toMillis(timeout));
|
||||||
|
|
||||||
DockingDevice device = deviceService.getDevice(deviceId);
|
DockingDevice device = deviceService.getDevice(deviceId);
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
log.info("未能找到 编码为 => {} 的设备", deviceId);
|
log.info("未能找到 编码为 => {} 的设备", deviceId);
|
||||||
result.setResult(JsonResponse.error(null, "未找到设备"));
|
result.setResult(JsonResponse.error("未找到设备"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
Optional<DockingDeviceChannel> deviceChannel = deviceChannelService.getDeviceChannel(deviceId, channelId);
|
Optional<DockingDeviceChannel> deviceChannel = deviceChannelService.getDeviceChannel(deviceId, channelId);
|
||||||
if(deviceChannel.isEmpty()){
|
if(deviceChannel.isEmpty()){
|
||||||
log.info("未能找到 设备编码为 => {}, 通道 => {} 的信息", deviceId, channelId);
|
log.info("未能找到 设备编码为 => {}, 通道 => {} 的信息", deviceId, channelId);
|
||||||
result.setResult(JsonResponse.error(null, "未找到通道信息"));
|
result.setResult(JsonResponse.error("未找到通道信息"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user