优化云台控制相关接口定义

结构优化
648540858 2023-12-27 18:36:14 +08:00
parent 456ef2c5e4
commit 5ce562aea1
5 changed files with 20 additions and 8 deletions

View File

@ -224,7 +224,7 @@ public interface ISIPCommander {
* @param resetTime 使:(s)
* @param presetId 使0~255
*/
void homePositionCmd(Device device, String channelId, boolean enabled, String resetTime, Integer presetId, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
void homePositionCmd(Device device, String channelId, boolean enabled, Integer resetTime, Integer presetId, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
/**
*

View File

@ -846,7 +846,7 @@ public class SIPCommander implements ISIPCommander {
* @param presetId 使0~255
*/
@Override
public void homePositionCmd(Device device, String channelId, boolean enabled, String resetTime, Integer presetId, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
public void homePositionCmd(Device device, String channelId, boolean enabled, Integer resetTime, Integer presetId, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
StringBuffer cmdXml = new StringBuffer(200);
String charset = device.getCharset();
@ -862,7 +862,7 @@ public class SIPCommander implements ISIPCommander {
cmdXml.append("<HomePosition>\r\n");
if (enabled) {
cmdXml.append("<Enabled>1</Enabled>\r\n");
if (NumericUtil.isInteger(resetTime)) {
if (resetTime != null) {
cmdXml.append("<ResetTime>" + resetTime + "</ResetTime>\r\n");
} else {
cmdXml.append("<ResetTime>0</ResetTime>\r\n");

View File

@ -264,7 +264,12 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
HomePositionRequest homePosition = loadElement(rootElement, HomePositionRequest.class);
//获取整个消息主体,我们只需要修改请求头即可
HomePositionRequest.HomePosition info = homePosition.getHomePosition();
cmder.homePositionCmd(device, channelId, info.getEnabled(), info.getResetTime(), info.getPresetIndex(),
if (info.getEnabled() == null) {
return;
}
cmder.homePositionCmd(device, channelId, info.getEnabled().equals("1"),
info.getResetTime() != null ? Integer.parseInt(info.getResetTime()): null,
info.getPresetIndex() != null ? Integer.parseInt(info.getPresetIndex()): null,
errorResult -> onError(request, errorResult),
okResult -> onOk(request, okResult));
} catch (Exception e) {

View File

@ -154,18 +154,19 @@ public class DeviceServiceImpl implements IDeviceService {
logger.error("[命令发送失败] 查询设备信息: {}", e.getMessage());
}
sync(device);
// TODO 如果设备下的通道级联到了其他平台那么需要发送事件或者notify给上级平台
List<Integer> ids = deviceChannelMapper.getCommonChannelIdList(device.getDeviceId());
if (!ids.isEmpty()) {
commonGbChannelService.onlineForList(ids);
}
}
}else {
if (deviceChannelMapper.queryAllChannels(device.getDeviceId()).size() == 0) {
logger.info("[设备上线]: {}通道数为0,查询通道信息", device.getDeviceId());
sync(device);
}
deviceMapper.update(device);
redisCatchStorage.updateDevice(device);
}
}
// 上线添加订阅
@ -207,6 +208,12 @@ public class DeviceServiceImpl implements IDeviceService {
}
String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + deviceId;
dynamicTask.stop(registerExpireTaskKey);
if (device.isOnLine()) {
List<Integer> ids = deviceChannelMapper.getCommonChannelIdList(device.getDeviceId());
if (!ids.isEmpty()) {
commonGbChannelService.offlineForList(ids);
}
}
device.setOnLine(false);
redisCatchStorage.updateDevice(device);
deviceMapper.update(device);

View File

@ -255,7 +255,7 @@ public class DeviceControl {
@GetMapping("/home_position/{deviceId}")
public DeferredResult<String> homePositionApi(@PathVariable String deviceId,
String command,
@RequestParam(required = false) String resetTime,
@RequestParam(required = false) Integer resetTime,
@RequestParam(required = false) Integer presetId,
String channelId) {
if (logger.isDebugEnabled()) {