优化预置位设置
parent
974e822f84
commit
67507e64b2
|
@ -2,15 +2,15 @@ package com.genersoft.iot.vmp.gb28181.bean;
|
|||
|
||||
public class PresetItem {
|
||||
|
||||
private int presetID;
|
||||
private int presetId;
|
||||
private String presetName;
|
||||
|
||||
public int getPresetID() {
|
||||
return presetID;
|
||||
public int getPresetId() {
|
||||
return presetId;
|
||||
}
|
||||
|
||||
public void setPresetID(int presetID) {
|
||||
this.presetID = presetID;
|
||||
public void setPresetId(int presetID) {
|
||||
this.presetId = presetID;
|
||||
}
|
||||
|
||||
public String getPresetName() {
|
||||
|
|
|
@ -3,8 +3,6 @@ package com.genersoft.iot.vmp.gb28181.session;
|
|||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
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.impl.SIPCommanderFroPlatform;
|
||||
import com.genersoft.iot.vmp.service.IDeviceChannelService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -64,7 +62,7 @@ public class PresetDataCatch {
|
|||
}
|
||||
if (!presetItemList.isEmpty()) {
|
||||
for (PresetItem presetItem : presetItemList) {
|
||||
presetData.getPresetItems().put(presetItem.getPresetID(), presetItem);
|
||||
presetData.getPresetItems().put(presetItem.getPresetId(), presetItem);
|
||||
}
|
||||
}
|
||||
// presetData.getPresetItems().sort((a, b) ->{
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PresetQuerySipReq;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.session.PresetDataCatch;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
||||
|
@ -8,7 +7,6 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
|||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler;
|
||||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||
import gov.nist.javax.sip.message.SIPRequest;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.Element;
|
||||
|
@ -118,7 +116,7 @@ public class PresetQueryResponseMessageHandler extends SIPRequestProcessorParent
|
|||
String name = itemOne.getName();
|
||||
String textTrim = itemOne.getTextTrim();
|
||||
if ("PresetID".equalsIgnoreCase(name)) {
|
||||
presetItem.setPresetID(Integer.parseInt(textTrim));
|
||||
presetItem.setPresetId(Integer.parseInt(textTrim));
|
||||
} else {
|
||||
presetItem.setPresetName(textTrim);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
|||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
@ -154,6 +155,9 @@ public class PtzController {
|
|||
logger.debug("设备预置位查询API调用");
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
if (device == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), deviceId + "不存在");
|
||||
}
|
||||
int sn = SipUtils.getNewSn();
|
||||
String msgId = sn + "";
|
||||
String key = DeferredResultHolder.CALLBACK_CMD_PRESETQUERY + sn;
|
||||
|
@ -187,4 +191,40 @@ public class PtzController {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
@Operation(summary = "预置位控制")
|
||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||
@Parameter(name = "channelId", description = "通道国标编号", required = true)
|
||||
@Parameter(name = "command", description = "控制指令 允许值: set, goto, delete", required = true)
|
||||
@Parameter(name = "presetId", description = "预置位编号", required = true)
|
||||
@GetMapping("/preset/control/{deviceId}/{channelId}")
|
||||
public void presetControlApi(@PathVariable String deviceId, @PathVariable String channelId,
|
||||
String command, int presetId) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("设备预置位控制API调用");
|
||||
}
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
if (device == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), deviceId + "不存在");
|
||||
}
|
||||
int cmdCode = 0;
|
||||
switch (command){
|
||||
case "set":
|
||||
cmdCode = 129;
|
||||
break;
|
||||
case "goto":
|
||||
cmdCode = 130;
|
||||
break;
|
||||
case "delete":
|
||||
cmdCode = 131;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
try {
|
||||
cmder.frontEndCmd(device, channelId, cmdCode, 0, presetId, 2);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
logger.error("[命令发送失败] 云台控制: {}", e.getMessage());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue