优化异常处理
This commit is contained in:
@@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.vmanager.gb28181.MobilePosition;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
||||
@@ -10,6 +11,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
||||
import com.genersoft.iot.vmp.service.IDeviceService;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||
import com.github.pagehelper.util.StringUtil;
|
||||
|
||||
@@ -136,13 +138,9 @@ public class MobilePositionController {
|
||||
@Parameter(name = "expires", description = "订阅超时时间", required = true)
|
||||
@Parameter(name = "interval", description = "上报时间间隔", required = true)
|
||||
@GetMapping("/subscribe/{deviceId}")
|
||||
public String positionSubscribe(@PathVariable String deviceId,
|
||||
public void positionSubscribe(@PathVariable String deviceId,
|
||||
@RequestParam String expires,
|
||||
@RequestParam String interval) {
|
||||
String msg = ((expires.equals("0")) ? "取消" : "") + "订阅设备" + deviceId + "的移动位置";
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(msg);
|
||||
}
|
||||
|
||||
if (StringUtil.isEmpty(interval)) {
|
||||
interval = "5";
|
||||
@@ -151,13 +149,8 @@ public class MobilePositionController {
|
||||
device.setSubscribeCycleForMobilePosition(Integer.parseInt(expires));
|
||||
device.setMobilePositionSubmissionInterval(Integer.parseInt(interval));
|
||||
deviceService.updateDevice(device);
|
||||
String result = msg;
|
||||
if (deviceService.removeMobilePositionSubscribe(device)) {
|
||||
result += ",成功";
|
||||
} else {
|
||||
result += ",失败";
|
||||
if (!deviceService.removeMobilePositionSubscribe(device)) {
|
||||
throw new ControllerException(ErrorCode.ERROR100);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,20 +56,14 @@ public class DeviceControl {
|
||||
@Operation(summary = "远程启动控制命令")
|
||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||
@GetMapping("/teleboot/{deviceId}")
|
||||
public String teleBootApi(@PathVariable String deviceId) {
|
||||
public void teleBootApi(@PathVariable String deviceId) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("设备远程启动API调用");
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
boolean sucsess = cmder.teleBootCmd(device);
|
||||
if (sucsess) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("DeviceID", deviceId);
|
||||
json.put("Result", "OK");
|
||||
return json.toJSONString();
|
||||
} else {
|
||||
logger.warn("设备远程启动API调用失败!");
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备远程启动API调用失败!");
|
||||
if (!cmder.teleBootCmd(device)) {
|
||||
logger.warn("设备远程启动API调用失败!");
|
||||
throw new ControllerException(ErrorCode.ERROR100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ public class PlatformController {
|
||||
@Parameter(name = "serverGBId", description = "上级平台的国标编号")
|
||||
@DeleteMapping("/delete/{serverGBId}")
|
||||
@ResponseBody
|
||||
public String deletePlatform(@PathVariable String serverGBId) {
|
||||
public void deletePlatform(@PathVariable String serverGBId) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("删除上级平台API调用");
|
||||
@@ -278,9 +278,7 @@ public class PlatformController {
|
||||
dynamicTask.stop(key);
|
||||
// 删除缓存的订阅信息
|
||||
subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId());
|
||||
if (deleteResult) {
|
||||
return null;
|
||||
} else {
|
||||
if (!deleteResult) {
|
||||
throw new ControllerException(ErrorCode.ERROR100);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user