临时提交

结构优化
648540858 2024-01-29 20:48:19 +08:00
parent 70f3f3b431
commit 0688bb91d2
4 changed files with 30 additions and 31 deletions

View File

@ -31,7 +31,7 @@ public enum DeviceControlType {
/**
*
*/
ALARM("AlarmCmd","告警控制"),
ALARM("AlarmCmd","报警复位"),
/**
*
*/

View File

@ -123,6 +123,27 @@ public class GB28181ResourceServiceImpl implements IResourceService {
return false;
}
@Override
public void resetAlarm(CommonGbChannel commonGbChannel, Integer alarmMethod, Integer alarmType) {
CheckCommonGbChannelResult checkResult = checkCommonGbChannel(commonGbChannel);
if (checkResult.errorMsg != null) {
logger.warn("[资源类-国标28181] 报警处理失败: {}", checkResult.errorMsg);
return;
}
if (checkResult.device == null || checkResult.channel == null) {
logger.warn("[资源类-国标28181] 报警处理失败: 设备获取失败");
return;
}
try {
commander.alarmCmd(checkResult.device, alarmMethod, alarmType,
errorResult -> onError(request, errorResult),
okResult -> onOk(request, okResult));
} catch (InvalidArgumentException | SipException | ParseException e) {
logger.error("[命令发送失败] ", e);
}
}
@Override
public void streamOffline(String app, String streamId) {
// TODO

View File

@ -258,7 +258,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
}
/**
* ***
*
*/
private void handleAlarmCmd(CommonGbChannel commonGbChannel, Element rootElement, SIPRequest request) {
IResourceService resourceService = resourceServiceMap.get(commonGbChannel.getType());
@ -289,36 +289,9 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
}
}
logger.info("\r\n[报警]: alarmMethod {} alarmType {}", alarmMethod, alarmType);
logger.info("\r\n[报警复位]: alarmMethod {} alarmType {}", alarmMethod, alarmType);
resourceService.ptzControl(commonGbChannel, ptzCommand);
//告警方法
Integer alarmMethod = null;
//告警类型
Integer alarmType = null;
List<Element> info = rootElement.elements("Info");
if (info != null) {
for (Element element : info) {
String alarmMethodStr = getText(element, "AlarmMethod");
if (alarmMethodStr != null) {
alarmMethod = Integer.parseInt(alarmMethodStr);
}
String alarmTypeStr = getText(element, "AlarmType");
if (alarmTypeStr != null) {
alarmType = Integer.parseInt(alarmTypeStr);
}
}
}
try {
cmder.alarmCmd(device, alarmMethod, alarmType,
errorResult -> onError(request, errorResult),
okResult -> onOk(request, okResult));
} catch (InvalidArgumentException | SipException | ParseException e) {
logger.error("[命令发送失败] 告警消息: {}", e.getMessage());
}
resourceService.resetAlarm(commonGbChannel, alarmMethod, alarmType);
}
/**

View File

@ -46,4 +46,9 @@ public interface IResourceService {
*
*/
void startDownload(CommonGbChannel channel, Long startTime, Long stopTime, Integer downloadSpeed, IResourcePlayCallback playCallback);
/**
*
*/
void resetAlarm(CommonGbChannel commonGbChannel, Integer alarmMethod, Integer alarmType);
}