临时提交

结构优化
648540858 2023-12-27 15:32:43 +08:00
parent 66f32d799d
commit 456ef2c5e4
3 changed files with 31 additions and 25 deletions

View File

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

View File

@ -691,7 +691,7 @@ public class SIPCommander implements ISIPCommander {
*
* @param device
* @param channelId
* @param recordCmdStr Record / StopRecord
* @param record Record / StopRecord
*/
@Override
public void recordCmd(Device device, String channelId, boolean record, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
@ -748,7 +748,7 @@ public class SIPCommander implements ISIPCommander {
* /
*
* @param device
* @param guardCmdStr "SetGuard"/"ResetGuard"
* @param setGuard "SetGuard"/"ResetGuard"
*/
@Override
public void guardCmd(Device device, boolean setGuard, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
@ -843,10 +843,10 @@ public class SIPCommander implements ISIPCommander {
* @param channelId id
* @param enabled 使1 = 0 =
* @param resetTime 使:(s)
* @param presetIndex 使0~255
* @param presetId 使0~255
*/
@Override
public void homePositionCmd(Device device, String channelId, String enabled, String resetTime, String presetIndex, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
public void homePositionCmd(Device device, String channelId, boolean enabled, String resetTime, Integer presetId, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
StringBuffer cmdXml = new StringBuffer(200);
String charset = device.getCharset();
@ -860,26 +860,24 @@ public class SIPCommander implements ISIPCommander {
cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
}
cmdXml.append("<HomePosition>\r\n");
if (NumericUtil.isInteger(enabled) && (!enabled.equals("0"))) {
if (enabled) {
cmdXml.append("<Enabled>1</Enabled>\r\n");
if (NumericUtil.isInteger(resetTime)) {
cmdXml.append("<ResetTime>" + resetTime + "</ResetTime>\r\n");
} else {
cmdXml.append("<ResetTime>0</ResetTime>\r\n");
}
if (NumericUtil.isInteger(presetIndex)) {
cmdXml.append("<PresetIndex>" + presetIndex + "</PresetIndex>\r\n");
if (presetId != null) {
cmdXml.append("<PresetIndex>" + presetId + "</PresetIndex>\r\n");
} else {
cmdXml.append("<PresetIndex>0</PresetIndex>\r\n");
}
} else {
}else {
cmdXml.append("<Enabled>0</Enabled>\r\n");
}
cmdXml.append("</HomePosition>\r\n");
cmdXml.append("</Control>\r\n");
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent,okEvent);
}

View File

@ -14,7 +14,6 @@ import com.genersoft.iot.vmp.gb28181.bean.Device;
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.ISIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import io.swagger.v3.oas.annotations.Operation;
@ -71,9 +70,10 @@ public class DeviceControl {
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "command", description = "控制命令可选值start手动录像stop停止手动录像", required = true)
@GetMapping("/record/{deviceId}/{channelId}/{command}")
public DeferredResult<ResponseEntity<String>> recordApi(@PathVariable String deviceId, @PathVariable String channelId,
@PathVariable String command) {
@GetMapping("/record/{deviceId}/{channelId}")
public DeferredResult<ResponseEntity<String>> recordApi(@PathVariable String deviceId,
@PathVariable String channelId,
String command) {
if (logger.isDebugEnabled()) {
logger.debug("开始/停止录像API调用");
}
@ -125,8 +125,8 @@ public class DeviceControl {
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "command", description = "控制命令可选值start布防stop撤防", required = true)
@GetMapping("/guard/{deviceId}/{command}")
public DeferredResult<String> guardApi(@PathVariable String deviceId, @PathVariable String command) {
@GetMapping("/guard/{deviceId}")
public DeferredResult<String> guardApi(@PathVariable String deviceId, String command) {
if (logger.isDebugEnabled()) {
logger.debug("布防/撤防API调用");
}
@ -250,13 +250,13 @@ public class DeviceControl {
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "command", description = "控制命令: start-开启看守位 stop-关闭看守位", required = true)
@Parameter(name = "presetIndex", description = "调用预置位编号, 取值范围为-255")
@Parameter(name = "presetId", description = "调用预置位编号, 取值范围为-255")
@Parameter(name = "resetTime", description = "自动归位时间间隔,单位:秒(s)")
@GetMapping("/home_position/{deviceId}/{command}")
@GetMapping("/home_position/{deviceId}")
public DeferredResult<String> homePositionApi(@PathVariable String deviceId,
@PathVariable String command,
String command,
@RequestParam(required = false) String resetTime,
@RequestParam(required = false) String presetIndex,
@RequestParam(required = false) Integer presetId,
String channelId) {
if (logger.isDebugEnabled()) {
logger.debug("报警复位API调用");
@ -267,8 +267,16 @@ public class DeviceControl {
if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), deviceId + "不存在");
}
boolean enabled;
if (command.equalsIgnoreCase("start")) {
enabled = true;
}else if (command.equalsIgnoreCase("stop")) {
enabled = false;
}else {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "command参数不是规定值");
}
try {
cmder.homePositionCmd(device, channelId, enabled, resetTime, presetIndex, event -> {
cmder.homePositionCmd(device, channelId, enabled, resetTime, presetId, event -> {
RequestMessage msg = new RequestMessage();
msg.setId(uuid);
msg.setKey(key);