调整设备控制相关的接口
parent
c5eca3ca0e
commit
3da6444baa
|
@ -0,0 +1,34 @@
|
||||||
|
package com.genersoft.iot.vmp.gb28181.bean;
|
||||||
|
|
||||||
|
import com.genersoft.iot.vmp.gb28181.utils.MessageElement;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "拉框放大/缩小控制参数")
|
||||||
|
public class DragZoomParam {
|
||||||
|
|
||||||
|
@MessageElement("Length")
|
||||||
|
@Schema(description = "播放窗口长度像素值(必选)")
|
||||||
|
protected Integer length;
|
||||||
|
|
||||||
|
@MessageElement("Width")
|
||||||
|
@Schema(description = "播放窗口宽度像素值(必选)")
|
||||||
|
protected Integer width;
|
||||||
|
|
||||||
|
@MessageElement("MidPointX")
|
||||||
|
@Schema(description = "拉框中心的横轴坐标像素值(必选)")
|
||||||
|
protected Integer midPointX;
|
||||||
|
|
||||||
|
@MessageElement("MidPointY")
|
||||||
|
@Schema(description = "拉框中心的纵轴坐标像素值(必选)")
|
||||||
|
protected Integer midPointY;
|
||||||
|
|
||||||
|
@MessageElement("LengthX")
|
||||||
|
@Schema(description = "拉框长度像素值(必选)")
|
||||||
|
protected Integer lengthX;
|
||||||
|
|
||||||
|
@MessageElement("LengthY")
|
||||||
|
@Schema(description = "拉框宽度像素值(必选)")
|
||||||
|
protected Integer lengthY;
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package com.genersoft.iot.vmp.gb28181.bean;
|
package com.genersoft.iot.vmp.gb28181.bean;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.gb28181.utils.MessageElement;
|
import com.genersoft.iot.vmp.gb28181.utils.MessageElement;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备信息查询响应
|
* 设备信息查询响应
|
||||||
|
@ -9,6 +10,7 @@ import com.genersoft.iot.vmp.gb28181.utils.MessageElement;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @date 2022/6/28 14:55
|
* @date 2022/6/28 14:55
|
||||||
*/
|
*/
|
||||||
|
@Data
|
||||||
public class DragZoomRequest {
|
public class DragZoomRequest {
|
||||||
/**
|
/**
|
||||||
* 序列号
|
* 序列号
|
||||||
|
@ -20,124 +22,9 @@ public class DragZoomRequest {
|
||||||
private String deviceId;
|
private String deviceId;
|
||||||
|
|
||||||
@MessageElement(value = "DragZoomIn")
|
@MessageElement(value = "DragZoomIn")
|
||||||
private DragZoom dragZoomIn;
|
private DragZoomParam dragZoomIn;
|
||||||
|
|
||||||
@MessageElement(value = "DragZoomOut")
|
@MessageElement(value = "DragZoomOut")
|
||||||
private DragZoom dragZoomOut;
|
private DragZoomParam dragZoomOut;
|
||||||
|
|
||||||
/**
|
|
||||||
* 基本参数
|
|
||||||
*/
|
|
||||||
public static class DragZoom {
|
|
||||||
/**
|
|
||||||
* 播放窗口长度像素值
|
|
||||||
*/
|
|
||||||
@MessageElement("Length")
|
|
||||||
protected Integer length;
|
|
||||||
/**
|
|
||||||
* 播放窗口宽度像素值
|
|
||||||
*/
|
|
||||||
@MessageElement("Width")
|
|
||||||
protected Integer width;
|
|
||||||
/**
|
|
||||||
* 拉框中心的横轴坐标像素值
|
|
||||||
*/
|
|
||||||
@MessageElement("MidPointX")
|
|
||||||
protected Integer midPointX;
|
|
||||||
/**
|
|
||||||
* 拉框中心的纵轴坐标像素值
|
|
||||||
*/
|
|
||||||
@MessageElement("MidPointY")
|
|
||||||
protected Integer midPointY;
|
|
||||||
/**
|
|
||||||
* 拉框长度像素值
|
|
||||||
*/
|
|
||||||
@MessageElement("LengthX")
|
|
||||||
protected Integer lengthX;
|
|
||||||
/**
|
|
||||||
* 拉框宽度像素值
|
|
||||||
*/
|
|
||||||
@MessageElement("LengthY")
|
|
||||||
protected Integer lengthY;
|
|
||||||
|
|
||||||
public Integer getLength() {
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLength(Integer length) {
|
|
||||||
this.length = length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getWidth() {
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWidth(Integer width) {
|
|
||||||
this.width = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getMidPointX() {
|
|
||||||
return midPointX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMidPointX(Integer midPointX) {
|
|
||||||
this.midPointX = midPointX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getMidPointY() {
|
|
||||||
return midPointY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMidPointY(Integer midPointY) {
|
|
||||||
this.midPointY = midPointY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getLengthX() {
|
|
||||||
return lengthX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLengthX(Integer lengthX) {
|
|
||||||
this.lengthX = lengthX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getLengthY() {
|
|
||||||
return lengthY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLengthY(Integer lengthY) {
|
|
||||||
this.lengthY = lengthY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSn() {
|
|
||||||
return sn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSn(String sn) {
|
|
||||||
this.sn = sn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDeviceId() {
|
|
||||||
return deviceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDeviceId(String deviceId) {
|
|
||||||
this.deviceId = deviceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DragZoom getDragZoomIn() {
|
|
||||||
return dragZoomIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDragZoomIn(DragZoom dragZoomIn) {
|
|
||||||
this.dragZoomIn = dragZoomIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DragZoom getDragZoomOut() {
|
|
||||||
return dragZoomOut;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDragZoomOut(DragZoom dragZoomOut) {
|
|
||||||
this.dragZoomOut = dragZoomOut;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,9 +66,8 @@ public class DeviceConfig {
|
||||||
"SVAC编码配置:SVACEncodeConfig, " +
|
"SVAC编码配置:SVACEncodeConfig, " +
|
||||||
"SVAC解码配置:SVACDecodeConfig。" +
|
"SVAC解码配置:SVACDecodeConfig。" +
|
||||||
"可同时查询多个配置类型,各类型以“/”分隔,")
|
"可同时查询多个配置类型,各类型以“/”分隔,")
|
||||||
@GetMapping("/query/{deviceId}/{configType}")
|
@GetMapping("/query")
|
||||||
public DeferredResult<WVPResult<Object>> configDownloadApi(@PathVariable String deviceId,
|
public DeferredResult<WVPResult<Object>> configDownloadApi(String deviceId,String configType,
|
||||||
@PathVariable String configType,
|
|
||||||
@RequestParam(required = false) String channelId) {
|
@RequestParam(required = false) String channelId) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("设备配置查询请求API调用");
|
log.debug("设备配置查询请求API调用");
|
||||||
|
|
|
@ -44,50 +44,44 @@ public class DeviceControl {
|
||||||
deviceService.teleboot(device);
|
deviceService.teleboot(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 录像控制命令API接口
|
|
||||||
*
|
|
||||||
* @param deviceId 设备ID
|
|
||||||
* @param recordCmdStr Record:手动录像,StopRecord:停止手动录像
|
|
||||||
* @param channelId 通道编码(可选)
|
|
||||||
*/
|
|
||||||
@Operation(summary = "录像控制", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
@Operation(summary = "录像控制", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||||
@Parameter(name = "channelId", description = "通道国标编号", required = true)
|
@Parameter(name = "channelId", description = "通道国标编号", required = true)
|
||||||
@Parameter(name = "recordCmdStr", description = "命令, 可选值:Record(手动录像),StopRecord(停止手动录像)", required = true)
|
@Parameter(name = "recordCmdStr", description = "命令, 可选值:Record(手动录像),StopRecord(停止手动录像)", required = true)
|
||||||
@GetMapping("/record/{deviceId}/{recordCmdStr}")
|
@GetMapping("/record")
|
||||||
public DeferredResult<WVPResult<String>> recordApi(@PathVariable String deviceId,
|
public DeferredResult<WVPResult<String>> recordApi(String deviceId, String recordCmdStr, String channelId) {
|
||||||
@PathVariable String recordCmdStr, String channelId) {
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("开始/停止录像API调用");
|
log.debug("开始/停止录像API调用");
|
||||||
}
|
}
|
||||||
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
||||||
Assert.notNull(device, "设备不存在");
|
Assert.notNull(device, "设备不存在");
|
||||||
DeferredResult<WVPResult<String>> result = deviceService.record(device, channelId, recordCmdStr);
|
DeferredResult<WVPResult<String>> deferredResult = new DeferredResult<>();
|
||||||
result.onTimeout(() -> {
|
|
||||||
log.warn("[开始/停止录像] 操作超时, 设备未返回应答指令, {}", deviceId);
|
deviceService.record(device, channelId, recordCmdStr, (code, msg, data) -> {
|
||||||
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
deferredResult.setResult(new WVPResult<>(code, msg, data));
|
||||||
});
|
});
|
||||||
return result;
|
deferredResult.onTimeout(() -> {
|
||||||
|
log.warn("[开始/停止录像] 操作超时, 设备未返回应答指令, {}", deviceId);
|
||||||
|
deferredResult.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
||||||
|
});
|
||||||
|
return deferredResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Operation(summary = "布防/撤防", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
* 报警布防/撤防命令API接口
|
|
||||||
*
|
|
||||||
* @param deviceId 设备ID
|
|
||||||
* @param guardCmdStr SetGuard:布防,ResetGuard:撤防
|
|
||||||
*/
|
|
||||||
@Operation(summary = "布防/撤防命令", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
|
||||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||||
@Parameter(name = "guardCmdStr", description = "命令, 可选值:SetGuard(布防),ResetGuard(撤防)", required = true)
|
@Parameter(name = "guardCmdStr", description = "命令, 可选值:SetGuard(布防),ResetGuard(撤防)", required = true)
|
||||||
@GetMapping("/guard/{deviceId}/{guardCmdStr}")
|
@GetMapping("/guard")
|
||||||
public DeferredResult<WVPResult<String>> guardApi(@PathVariable String deviceId, @PathVariable String guardCmdStr) {
|
public DeferredResult<WVPResult<String>> guardApi(String deviceId, String guardCmdStr) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("布防/撤防API调用");
|
log.debug("布防/撤防API调用");
|
||||||
}
|
}
|
||||||
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
||||||
Assert.notNull(device, "设备不存在");
|
Assert.notNull(device, "设备不存在");
|
||||||
DeferredResult<WVPResult<String>> result = deviceService.guard(device, guardCmdStr);
|
DeferredResult<WVPResult<String>> result = new DeferredResult<>();
|
||||||
|
deviceService.guard(device, guardCmdStr, (code, msg, data) -> {
|
||||||
|
result.setResult(new WVPResult<>(code, msg, data));
|
||||||
|
});
|
||||||
result.onTimeout(() -> {
|
result.onTimeout(() -> {
|
||||||
log.warn("[布防/撤防] 操作超时, 设备未返回应答指令, {}", deviceId);
|
log.warn("[布防/撤防] 操作超时, 设备未返回应答指令, {}", deviceId);
|
||||||
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
||||||
|
@ -95,20 +89,24 @@ public class DeviceControl {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 报警复位API接口
|
|
||||||
*
|
|
||||||
* @param deviceId 设备ID
|
|
||||||
* @param alarmMethod 报警方式(可选)
|
|
||||||
* @param alarmType 报警类型(可选)
|
|
||||||
*/
|
|
||||||
@Operation(summary = "报警复位", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
@Operation(summary = "报警复位", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||||
@Parameter(name = "channelId", description = "通道国标编号", required = true)
|
@Parameter(name = "channelId", description = "通道国标编号", required = true)
|
||||||
@Parameter(name = "alarmMethod", description = "报警方式")
|
@Parameter(name = "alarmMethod", description = "报警方式, 报警方式条件(可选),取值0为全部,1为电话报警,2为设备报警,3为短信报警,4为\n" +
|
||||||
@Parameter(name = "alarmType", description = "报警类型")
|
"GPS报警,5为视频报警,6为设备故障报警,7其他报警;可以为直接组合如12为电话报警或设备报警")
|
||||||
@GetMapping("/reset_alarm/{deviceId}")
|
@Parameter(name = "alarmType", description = "报警类型, " +
|
||||||
public DeferredResult<WVPResult<String>> resetAlarmApi(@PathVariable String deviceId, String channelId,
|
"报警类型。" +
|
||||||
|
"报警方式为2时,不携带 AlarmType为默认的报警设备报警," +
|
||||||
|
"携带 AlarmType取值及对应报警类型如下:" +
|
||||||
|
"1-视频丢失报警;2-设备防拆报警;3-存储设备磁盘满报警;4-设备高温报警;5-设备低温报警。" +
|
||||||
|
"报警方式为5时,取值如下:" +
|
||||||
|
"1-人工视频报警;2-运动目标检测报警;3-遗留物检测报警;4-物体移除检测报警;5-绊线检测报警;" +
|
||||||
|
"6-入侵检测报警;7-逆行检测报警;8-徘徊检测报警;9-流量统计报警;10-密度检测报警;" +
|
||||||
|
"11-视频异常检测报警;12-快速移动报警。" +
|
||||||
|
"报警方式为6时,取值如下:" +
|
||||||
|
"1-存储设备磁盘故障报警;2-存储设备风扇故障报警")
|
||||||
|
@GetMapping("/reset_alarm")
|
||||||
|
public DeferredResult<WVPResult<String>> resetAlarm(String deviceId, String channelId,
|
||||||
@RequestParam(required = false) String alarmMethod,
|
@RequestParam(required = false) String alarmMethod,
|
||||||
@RequestParam(required = false) String alarmType) {
|
@RequestParam(required = false) String alarmType) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
|
@ -116,7 +114,10 @@ public class DeviceControl {
|
||||||
}
|
}
|
||||||
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
||||||
Assert.notNull(device, "设备不存在");
|
Assert.notNull(device, "设备不存在");
|
||||||
DeferredResult<WVPResult<String>> result = deviceService.resetAlarm(device, channelId, alarmMethod, alarmType);
|
DeferredResult<WVPResult<String>> result = new DeferredResult<>();
|
||||||
|
deviceService.resetAlarm(device, channelId, alarmMethod, alarmType, (code, msg, data) -> {
|
||||||
|
result.setResult(new WVPResult<>(code, msg, data));
|
||||||
|
});
|
||||||
result.onTimeout(() -> {
|
result.onTimeout(() -> {
|
||||||
log.warn("[布防/撤防] 操作超时, 设备未返回应答指令, {}", deviceId);
|
log.warn("[布防/撤防] 操作超时, 设备未返回应答指令, {}", deviceId);
|
||||||
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
||||||
|
@ -124,18 +125,11 @@ public class DeviceControl {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 强制关键帧API接口
|
|
||||||
*
|
|
||||||
* @param deviceId 设备ID
|
|
||||||
* @param channelId 通道ID
|
|
||||||
*/
|
|
||||||
@Operation(summary = "强制关键帧", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
@Operation(summary = "强制关键帧", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||||
@Parameter(name = "channelId", description = "通道国标编号")
|
@Parameter(name = "channelId", description = "通道国标编号")
|
||||||
@GetMapping("/i_frame/{deviceId}")
|
@GetMapping("/i_frame")
|
||||||
public void iFrame(@PathVariable String deviceId,
|
public void iFrame(String deviceId, @RequestParam(required = false) String channelId) {
|
||||||
@RequestParam(required = false) String channelId) {
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("强制关键帧API调用");
|
log.debug("强制关键帧API调用");
|
||||||
}
|
}
|
||||||
|
@ -144,15 +138,6 @@ public class DeviceControl {
|
||||||
deviceService.iFrame(device, channelId);
|
deviceService.iFrame(device, channelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 看守位控制命令API接口
|
|
||||||
*
|
|
||||||
* @param deviceId 设备ID
|
|
||||||
* @param enabled 看守位使能1:开启,0:关闭
|
|
||||||
* @param resetTime 自动归位时间间隔(可选)
|
|
||||||
* @param presetIndex 调用预置位编号(可选)
|
|
||||||
* @param channelId 通道编码(可选)
|
|
||||||
*/
|
|
||||||
@Operation(summary = "看守位控制", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
@Operation(summary = "看守位控制", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||||
@Parameter(name = "channelId", description = "通道国标编号", required = true)
|
@Parameter(name = "channelId", description = "通道国标编号", required = true)
|
||||||
|
@ -168,7 +153,10 @@ public class DeviceControl {
|
||||||
}
|
}
|
||||||
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
||||||
Assert.notNull(device, "设备不存在");
|
Assert.notNull(device, "设备不存在");
|
||||||
DeferredResult<WVPResult<String>> result = deviceService.homePosition(device, channelId, enabled, resetTime, presetIndex);
|
DeferredResult<WVPResult<String>> result = new DeferredResult<>();
|
||||||
|
deviceService.homePosition(device, channelId, enabled, resetTime, presetIndex, (code, msg, data) -> {
|
||||||
|
result.setResult(new WVPResult<>(code, msg, data));
|
||||||
|
});
|
||||||
result.onTimeout(() -> {
|
result.onTimeout(() -> {
|
||||||
log.warn("[看守位控制] 操作超时, 设备未返回应答指令, {}", deviceId);
|
log.warn("[看守位控制] 操作超时, 设备未返回应答指令, {}", deviceId);
|
||||||
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
||||||
|
@ -176,55 +164,39 @@ public class DeviceControl {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 拉框放大
|
|
||||||
* @param deviceId 设备id
|
|
||||||
* @param channelId 通道id
|
|
||||||
* @param length 播放窗口长度像素值
|
|
||||||
* @param width 播放窗口宽度像素值
|
|
||||||
* @param midpointx 拉框中心的横轴坐标像素值
|
|
||||||
* @param midpointy 拉框中心的纵轴坐标像素值
|
|
||||||
* @param lengthx 拉框长度像素值
|
|
||||||
* @param lengthy 拉框宽度像素值
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Operation(summary = "拉框放大", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
@Operation(summary = "拉框放大", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||||
@Parameter(name = "channelId", description = "通道国标编号", required = true)
|
@Parameter(name = "channelId", description = "通道国标编号", required = true)
|
||||||
@Parameter(name = "length", description = "播放窗口长度像素值", required = true)
|
@Parameter(name = "length", description = "播放窗口长度像素值", required = true)
|
||||||
|
@Parameter(name = "width", description = "播放窗口宽度像素值", required = true)
|
||||||
@Parameter(name = "midpointx", description = "拉框中心的横轴坐标像素值", required = true)
|
@Parameter(name = "midpointx", description = "拉框中心的横轴坐标像素值", required = true)
|
||||||
@Parameter(name = "midpointy", description = "拉框中心的纵轴坐标像素值", required = true)
|
@Parameter(name = "midpointy", description = "拉框中心的纵轴坐标像素值", required = true)
|
||||||
@Parameter(name = "lengthx", description = "拉框长度像素值", required = true)
|
@Parameter(name = "lengthx", description = "拉框长度像素值", required = true)
|
||||||
@Parameter(name = "lengthy", description = "lengthy", required = true)
|
@Parameter(name = "lengthy", description = "拉框宽度像素值", required = true)
|
||||||
@GetMapping("drag_zoom/zoom_in")
|
@GetMapping("drag_zoom/zoom_in")
|
||||||
public void dragZoomIn(@RequestParam String deviceId,
|
public DeferredResult<WVPResult<String>> dragZoomIn(@RequestParam String deviceId, String channelId,
|
||||||
@RequestParam(required = false) String channelId,
|
|
||||||
@RequestParam int length,
|
@RequestParam int length,
|
||||||
@RequestParam int width,
|
@RequestParam int width,
|
||||||
@RequestParam int midpointx,
|
@RequestParam int midpointx,
|
||||||
@RequestParam int midpointy,
|
@RequestParam int midpointy,
|
||||||
@RequestParam int lengthx,
|
@RequestParam int lengthx,
|
||||||
@RequestParam int lengthy) throws RuntimeException {
|
@RequestParam int lengthy) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug(String.format("设备拉框放大 API调用,deviceId:%s ,channelId:%s ,length:%d ,width:%d ,midpointx:%d ,midpointy:%d ,lengthx:%d ,lengthy:%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy));
|
log.debug(String.format("设备拉框放大 API调用,deviceId:%s ,channelId:%s ,length:%d ,width:%d ,midpointx:%d ,midpointy:%d ,lengthx:%d ,lengthy:%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy));
|
||||||
}
|
}
|
||||||
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
||||||
Assert.notNull(device, "设备不存在");
|
Assert.notNull(device, "设备不存在");
|
||||||
deviceService.dragZoomIn(device, channelId, length, width, midpointx, midpointy, lengthx,lengthy);
|
DeferredResult<WVPResult<String>> result = new DeferredResult<>();
|
||||||
|
deviceService.dragZoomIn(device, channelId, length, width, midpointx, midpointy, lengthx,lengthy, (code, msg, data) -> {
|
||||||
|
result.setResult(new WVPResult<>(code, msg, data));
|
||||||
|
});
|
||||||
|
result.onTimeout(() -> {
|
||||||
|
log.warn("[设备拉框放大] 操作超时, 设备未返回应答指令, {}", deviceId);
|
||||||
|
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
||||||
|
});
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 拉框缩小
|
|
||||||
* @param deviceId 设备id
|
|
||||||
* @param channelId 通道id
|
|
||||||
* @param length 播放窗口长度像素值
|
|
||||||
* @param width 播放窗口宽度像素值
|
|
||||||
* @param midpointx 拉框中心的横轴坐标像素值
|
|
||||||
* @param midpointy 拉框中心的纵轴坐标像素值
|
|
||||||
* @param lengthx 拉框长度像素值
|
|
||||||
* @param lengthy 拉框宽度像素值
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Operation(summary = "拉框缩小", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
@Operation(summary = "拉框缩小", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
|
||||||
@Parameter(name = "channelId", description = "通道国标编号")
|
@Parameter(name = "channelId", description = "通道国标编号")
|
||||||
|
@ -235,7 +207,7 @@ public class DeviceControl {
|
||||||
@Parameter(name = "lengthx", description = "拉框长度像素值", required = true)
|
@Parameter(name = "lengthx", description = "拉框长度像素值", required = true)
|
||||||
@Parameter(name = "lengthy", description = "拉框宽度像素值", required = true)
|
@Parameter(name = "lengthy", description = "拉框宽度像素值", required = true)
|
||||||
@GetMapping("/drag_zoom/zoom_out")
|
@GetMapping("/drag_zoom/zoom_out")
|
||||||
public void dragZoomOut(@RequestParam String deviceId,
|
public DeferredResult<WVPResult<String>> dragZoomOut(@RequestParam String deviceId,
|
||||||
@RequestParam(required = false) String channelId,
|
@RequestParam(required = false) String channelId,
|
||||||
@RequestParam int length,
|
@RequestParam int length,
|
||||||
@RequestParam int width,
|
@RequestParam int width,
|
||||||
|
@ -249,6 +221,14 @@ public class DeviceControl {
|
||||||
}
|
}
|
||||||
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
||||||
Assert.notNull(device, "设备不存在");
|
Assert.notNull(device, "设备不存在");
|
||||||
deviceService.dragZoomOut(device, channelId, length, width, midpointx, midpointy, lengthx,lengthy);
|
DeferredResult<WVPResult<String>> result = new DeferredResult<>();
|
||||||
|
deviceService.dragZoomOut(device, channelId, length, width, midpointx, midpointy, lengthx,lengthy, (code, msg, data) -> {
|
||||||
|
result.setResult(new WVPResult<>(code, msg, data));
|
||||||
|
});
|
||||||
|
result.onTimeout(() -> {
|
||||||
|
log.warn("[设备拉框放大] 操作超时, 设备未返回应答指令, {}", deviceId);
|
||||||
|
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
||||||
|
});
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,6 @@ import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
|
||||||
import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
|
import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
|
||||||
import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask;
|
import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask;
|
||||||
import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask;
|
import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask;
|
||||||
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.SIPCommander;
|
|
||||||
import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcService;
|
import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcService;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||||
|
@ -29,9 +26,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.compress.utils.IOUtils;
|
import org.apache.commons.compress.utils.IOUtils;
|
||||||
import org.apache.ibatis.annotations.Options;
|
import org.apache.ibatis.annotations.Options;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -39,17 +34,13 @@ import org.springframework.web.context.request.async.DeferredResult;
|
||||||
|
|
||||||
import javax.servlet.ServletOutputStream;
|
import javax.servlet.ServletOutputStream;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.sip.InvalidArgumentException;
|
|
||||||
import javax.sip.SipException;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Tag(name = "国标设备查询", description = "国标设备查询")
|
@Tag(name = "国标设备查询", description = "国标设备查询")
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
|
@ -63,12 +54,6 @@ public class DeviceQuery {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IInviteStreamService inviteStreamService;
|
private IInviteStreamService inviteStreamService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SIPCommander cmder;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private DeferredResultHolder resultHolder;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IDeviceService deviceService;
|
private IDeviceService deviceService;
|
||||||
|
@ -318,8 +303,10 @@ public class DeviceQuery {
|
||||||
}
|
}
|
||||||
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
||||||
Assert.notNull(device, "设备不存在");
|
Assert.notNull(device, "设备不存在");
|
||||||
|
DeferredResult<WVPResult<String>> result = new DeferredResult<>();
|
||||||
DeferredResult<WVPResult<String>> result = deviceService.deviceStatus(device);
|
deviceService.deviceStatus(device, (code, msg, data) -> {
|
||||||
|
result.setResult(new WVPResult<>(code, msg, data));
|
||||||
|
});
|
||||||
result.onTimeout(() -> {
|
result.onTimeout(() -> {
|
||||||
log.warn("[设备状态查询] 操作超时, 设备未返回应答指令, {}", deviceId);
|
log.warn("[设备状态查询] 操作超时, 设备未返回应答指令, {}", deviceId);
|
||||||
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
||||||
|
@ -359,8 +346,10 @@ public class DeviceQuery {
|
||||||
}
|
}
|
||||||
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
Device device = deviceService.getDeviceByDeviceId(deviceId);
|
||||||
Assert.notNull(device, "设备不存在");
|
Assert.notNull(device, "设备不存在");
|
||||||
|
DeferredResult<WVPResult<String>> result = new DeferredResult<>();
|
||||||
DeferredResult<WVPResult<String>> result = deviceService.deviceStatus(device);
|
deviceService.deviceStatus(device, (code, msg, data) -> {
|
||||||
|
result.setResult(new WVPResult<>(code, msg, data));
|
||||||
|
});
|
||||||
result.onTimeout(() -> {
|
result.onTimeout(() -> {
|
||||||
log.warn("[设备报警查询] 操作超时, 设备未返回应答指令, {}", deviceId);
|
log.warn("[设备报警查询] 操作超时, 设备未返回应答指令, {}", deviceId);
|
||||||
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
||||||
|
|
|
@ -9,7 +9,6 @@ import com.genersoft.iot.vmp.service.bean.ErrorCallback;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
|
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import org.springframework.web.context.request.async.DeferredResult;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -178,21 +177,21 @@ public interface IDeviceService {
|
||||||
|
|
||||||
void teleboot(Device device);
|
void teleboot(Device device);
|
||||||
|
|
||||||
DeferredResult<WVPResult<String>> record(Device device, String channelId, String recordCmdStr);
|
void record(Device device, String channelId, String recordCmdStr, ErrorCallback<String> callback);
|
||||||
|
|
||||||
DeferredResult<WVPResult<String>> guard(Device device, String guardCmdStr);
|
void guard(Device device, String guardCmdStr, ErrorCallback<String> callback);
|
||||||
|
|
||||||
DeferredResult<WVPResult<String>> resetAlarm(Device device, String channelId, String alarmMethod, String alarmType);
|
void resetAlarm(Device device, String channelId, String alarmMethod, String alarmType, ErrorCallback<String> callback);
|
||||||
|
|
||||||
void iFrame(Device device, String channelId);
|
void iFrame(Device device, String channelId);
|
||||||
|
|
||||||
DeferredResult<WVPResult<String>> homePosition(Device device, String channelId, Boolean enabled, Integer resetTime, Integer presetIndex);
|
void homePosition(Device device, String channelId, Boolean enabled, Integer resetTime, Integer presetIndex, ErrorCallback<String> callback);
|
||||||
|
|
||||||
void dragZoomIn(Device device, String channelId, int length, int width, int midpointx, int midpointy, int lengthx, int lengthy);
|
void dragZoomIn(Device device, String channelId, int length, int width, int midpointx, int midpointy, int lengthx, int lengthy, ErrorCallback<String> callback);
|
||||||
|
|
||||||
void dragZoomOut(Device device, String channelId, int length, int width, int midpointx, int midpointy, int lengthx, int lengthy);
|
void dragZoomOut(Device device, String channelId, int length, int width, int midpointx, int midpointy, int lengthx, int lengthy, ErrorCallback<String> callback);
|
||||||
|
|
||||||
DeferredResult<WVPResult<String>> deviceStatus(Device device);
|
void deviceStatus(Device device, ErrorCallback<String> callback);
|
||||||
|
|
||||||
void updateDeviceHeartInfo(Device device);
|
void updateDeviceHeartInfo(Device device);
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||||
// deviceChannelMapper.offlineByDeviceId(deviceId);
|
// deviceChannelMapper.offlineByDeviceId(deviceId);
|
||||||
// 离线释放所有ssrc
|
// 离线释放所有ssrc
|
||||||
List<SsrcTransaction> ssrcTransactions = sessionManager.getSsrcTransactionByDeviceId(deviceId);
|
List<SsrcTransaction> ssrcTransactions = sessionManager.getSsrcTransactionByDeviceId(deviceId);
|
||||||
if (ssrcTransactions != null && ssrcTransactions.size() > 0) {
|
if (ssrcTransactions != null && !ssrcTransactions.isEmpty()) {
|
||||||
for (SsrcTransaction ssrcTransaction : ssrcTransactions) {
|
for (SsrcTransaction ssrcTransaction : ssrcTransactions) {
|
||||||
mediaServerService.releaseSsrc(ssrcTransaction.getMediaServerId(), ssrcTransaction.getSsrc());
|
mediaServerService.releaseSsrc(ssrcTransaction.getMediaServerId(), ssrcTransaction.getSsrc());
|
||||||
mediaServerService.closeRTPServer(ssrcTransaction.getMediaServerId(), ssrcTransaction.getStream());
|
mediaServerService.closeRTPServer(ssrcTransaction.getMediaServerId(), ssrcTransaction.getStream());
|
||||||
|
@ -662,6 +662,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||||
sipCommander.deviceBasicConfigCmd(device, basicParam, callback);
|
sipCommander.deviceBasicConfigCmd(device, basicParam, callback);
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
log.error("[命令发送失败] 设备配置: {}", e.getMessage());
|
log.error("[命令发送失败] 设备配置: {}", e.getMessage());
|
||||||
|
callback.run(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage(), null);
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage());
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -679,6 +680,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||||
sipCommander.deviceConfigQuery(device, channelId, configType, callback);
|
sipCommander.deviceConfigQuery(device, channelId, configType, callback);
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
log.error("[命令发送失败] 获取设备配置: {}", e.getMessage());
|
log.error("[命令发送失败] 获取设备配置: {}", e.getMessage());
|
||||||
|
callback.run(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage(), null);
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage());
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -698,70 +700,55 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeferredResult<WVPResult<String>> record(Device device, String channelId, String recordCmdStr) {
|
public void record(Device device, String channelId, String recordCmdStr, ErrorCallback<String> callback) {
|
||||||
|
|
||||||
if (!userSetting.getServerId().equals(device.getServerId())) {
|
if (!userSetting.getServerId().equals(device.getServerId())) {
|
||||||
WVPResult<String> result = redisRpcService.recordControl(device.getServerId(), device, channelId, recordCmdStr);
|
WVPResult<String> result = redisRpcService.recordControl(device.getServerId(), device, channelId, recordCmdStr);
|
||||||
DeferredResult<WVPResult<String>> deferredResult = new DeferredResult<>(3 * 1000L);
|
callback.run(result.getCode(), result.getMsg(), result.getData());
|
||||||
deferredResult.setResult(result);
|
return;
|
||||||
return deferredResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DeferredResult<WVPResult<String>> result = new DeferredResult<>(3 * 1000L);
|
|
||||||
try {
|
try {
|
||||||
sipCommander.recordCmd(device, channelId, recordCmdStr, event -> {
|
sipCommander.recordCmd(device, channelId, recordCmdStr, callback);
|
||||||
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), String.format("开始/停止录像操作失败,错误码: %s, %s", event.statusCode, event.msg)));
|
|
||||||
},null);
|
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
log.error("[命令发送失败] 开始/停止录像: {}", e.getMessage());
|
log.error("[命令发送失败] 开始/停止录像: {}", e.getMessage());
|
||||||
|
callback.run(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage(), null);
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage());
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeferredResult<WVPResult<String>> guard(Device device, String guardCmdStr) {
|
public void guard(Device device, String guardCmdStr, ErrorCallback<String> callback) {
|
||||||
if (!userSetting.getServerId().equals(device.getServerId())) {
|
if (!userSetting.getServerId().equals(device.getServerId())) {
|
||||||
WVPResult<String> result = redisRpcService.guard(device.getServerId(), device, guardCmdStr);
|
WVPResult<String> result = redisRpcService.guard(device.getServerId(), device, guardCmdStr);
|
||||||
DeferredResult<WVPResult<String>> deferredResult = new DeferredResult<>(3 * 1000L);
|
callback.run(result.getCode(), result.getMsg(), result.getData());
|
||||||
deferredResult.setResult(result);
|
return;
|
||||||
return deferredResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DeferredResult<WVPResult<String>> result = new DeferredResult<>(3 * 1000L);
|
|
||||||
try {
|
try {
|
||||||
sipCommander.guardCmd(device, guardCmdStr, event -> {
|
sipCommander.guardCmd(device, guardCmdStr, callback);
|
||||||
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), String.format("布防/撤防操作失败,错误码: %s, %s", event.statusCode, event.msg)));
|
|
||||||
},null);
|
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
log.error("[命令发送失败] 布防/撤防操作: {}", e.getMessage());
|
log.error("[命令发送失败] 布防/撤防操作: {}", e.getMessage());
|
||||||
|
callback.run(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage(), null);
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage());
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeferredResult<WVPResult<String>> resetAlarm(Device device, String channelId, String alarmMethod, String alarmType) {
|
public void resetAlarm(Device device, String channelId, String alarmMethod, String alarmType, ErrorCallback<String> callback) {
|
||||||
if (!userSetting.getServerId().equals(device.getServerId())) {
|
if (!userSetting.getServerId().equals(device.getServerId())) {
|
||||||
WVPResult<String> result = redisRpcService.resetAlarm(device.getServerId(), device, channelId, alarmMethod, alarmType);
|
WVPResult<String> result = redisRpcService.resetAlarm(device.getServerId(), device, channelId, alarmMethod, alarmType);
|
||||||
DeferredResult<WVPResult<String>> deferredResult = new DeferredResult<>(3 * 1000L);
|
callback.run(result.getCode(), result.getMsg(), result.getData());
|
||||||
deferredResult.setResult(result);
|
return;
|
||||||
return deferredResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DeferredResult<WVPResult<String>> result = new DeferredResult<>(3 * 1000L);
|
|
||||||
try {
|
try {
|
||||||
sipCommander.alarmCmd(device, alarmMethod, alarmType, event -> {
|
sipCommander.alarmCmd(device, alarmMethod, alarmType, callback);
|
||||||
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), String.format("操作失败,错误码: %s, %s", event.statusCode, event.msg)));
|
|
||||||
},null);
|
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
log.error("[命令发送失败] 布防/撤防操作: {}", e.getMessage());
|
log.error("[命令发送失败] 布防/撤防操作: {}", e.getMessage());
|
||||||
|
callback.run(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage(), null);
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage());
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -780,29 +767,24 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeferredResult<WVPResult<String>> homePosition(Device device, String channelId, Boolean enabled, Integer resetTime, Integer presetIndex) {
|
public void homePosition(Device device, String channelId, Boolean enabled, Integer resetTime, Integer presetIndex, ErrorCallback<String> callback) {
|
||||||
if (!userSetting.getServerId().equals(device.getServerId())) {
|
if (!userSetting.getServerId().equals(device.getServerId())) {
|
||||||
WVPResult<String> result = redisRpcService.homePosition(device.getServerId(), device, channelId, enabled, resetTime, presetIndex);
|
WVPResult<String> result = redisRpcService.homePosition(device.getServerId(), device, channelId, enabled, resetTime, presetIndex);
|
||||||
DeferredResult<WVPResult<String>> deferredResult = new DeferredResult<>(3 * 1000L);
|
callback.run(result.getCode(), result.getMsg(), result.getData());
|
||||||
deferredResult.setResult(result);
|
return;
|
||||||
return deferredResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DeferredResult<WVPResult<String>> result = new DeferredResult<>(3 * 1000L);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sipCommander.homePositionCmd(device, channelId, enabled, resetTime, presetIndex, event -> {
|
sipCommander.homePositionCmd(device, channelId, enabled, resetTime, presetIndex, callback);
|
||||||
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), String.format("操作失败,错误码: %s, %s", event.statusCode, event.msg)));
|
|
||||||
},null);
|
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
log.error("[命令发送失败] 看守位控制: {}", e.getMessage());
|
log.error("[命令发送失败] 看守位控制: {}", e.getMessage());
|
||||||
|
callback.run(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage(), null);
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dragZoomIn(Device device, String channelId, int length, int width, int midpointx, int midpointy, int lengthx, int lengthy) {
|
public void dragZoomIn(Device device, String channelId, int length, int width, int midpointx, int midpointy, int lengthx, int lengthy, ErrorCallback<String> callback) {
|
||||||
if (!userSetting.getServerId().equals(device.getServerId())) {
|
if (!userSetting.getServerId().equals(device.getServerId())) {
|
||||||
redisRpcService.dragZoomIn(device.getServerId(), device, channelId, length, width, midpointx, midpointy, lengthx, lengthy);
|
redisRpcService.dragZoomIn(device.getServerId(), device, channelId, length, width, midpointx, midpointy, lengthx, lengthy);
|
||||||
return;
|
return;
|
||||||
|
@ -818,15 +800,16 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||||
cmdXml.append("<LengthY>" + lengthy+ "</LengthY>\r\n");
|
cmdXml.append("<LengthY>" + lengthy+ "</LengthY>\r\n");
|
||||||
cmdXml.append("</DragZoomIn>\r\n");
|
cmdXml.append("</DragZoomIn>\r\n");
|
||||||
try {
|
try {
|
||||||
sipCommander.dragZoomCmd(device, channelId, cmdXml.toString());
|
sipCommander.dragZoomCmd(device, channelId, cmdXml.toString(), callback);
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
log.error("[命令发送失败] 拉框放大: {}", e.getMessage());
|
log.error("[命令发送失败] 拉框放大: {}", e.getMessage());
|
||||||
|
callback.run(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage(), null);
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dragZoomOut(Device device, String channelId, int length, int width, int midpointx, int midpointy, int lengthx, int lengthy) {
|
public void dragZoomOut(Device device, String channelId, int length, int width, int midpointx, int midpointy, int lengthx, int lengthy, ErrorCallback<String> callback) {
|
||||||
if (!userSetting.getServerId().equals(device.getServerId())) {
|
if (!userSetting.getServerId().equals(device.getServerId())) {
|
||||||
redisRpcService.dragZoomOut(device.getServerId(), device, channelId, length, width, midpointx, midpointy, lengthx, lengthy);
|
redisRpcService.dragZoomOut(device.getServerId(), device, channelId, length, width, midpointx, midpointy, lengthx, lengthy);
|
||||||
return;
|
return;
|
||||||
|
@ -842,32 +825,30 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||||
cmdXml.append("<LengthY>" + lengthy+ "</LengthY>\r\n");
|
cmdXml.append("<LengthY>" + lengthy+ "</LengthY>\r\n");
|
||||||
cmdXml.append("</DragZoomOut>\r\n");
|
cmdXml.append("</DragZoomOut>\r\n");
|
||||||
try {
|
try {
|
||||||
sipCommander.dragZoomCmd(device, channelId, cmdXml.toString());
|
sipCommander.dragZoomCmd(device, channelId, cmdXml.toString(), callback);
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
log.error("[命令发送失败] 拉框放大: {}", e.getMessage());
|
log.error("[命令发送失败] 拉框放大: {}", e.getMessage());
|
||||||
|
callback.run(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage(), null);
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeferredResult<WVPResult<String>> deviceStatus(Device device) {
|
public void deviceStatus(Device device, ErrorCallback<String> callback) {
|
||||||
|
|
||||||
if (!userSetting.getServerId().equals(device.getServerId())) {
|
if (!userSetting.getServerId().equals(device.getServerId())) {
|
||||||
WVPResult<String> result = redisRpcService.deviceStatus(device.getServerId(), device);
|
WVPResult<String> result = redisRpcService.deviceStatus(device.getServerId(), device);
|
||||||
DeferredResult<WVPResult<String>> deferredResult = new DeferredResult<>(3 * 1000L);
|
callback.run(result.getCode(), result.getMsg(), result.getData());
|
||||||
deferredResult.setResult(result);
|
return;
|
||||||
return deferredResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DeferredResult<WVPResult<String>> result = new DeferredResult<>(2*1000L);
|
DeferredResult<WVPResult<String>> result = new DeferredResult<>(2*1000L);
|
||||||
try {
|
try {
|
||||||
sipCommander.deviceStatusQuery(device, event -> {
|
sipCommander.deviceStatusQuery(device, callback);
|
||||||
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), String.format("操作失败,错误码: %s, %s", event.statusCode, event.msg)));
|
|
||||||
});
|
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
log.error("[命令发送失败] 获取设备状态: {}", e.getMessage());
|
log.error("[命令发送失败] 获取设备状态: {}", e.getMessage());
|
||||||
|
callback.run(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage(), null);
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,13 +75,11 @@ public class SIPSender {
|
||||||
CSeqHeader cSeqHeader = (CSeqHeader) message.getHeader(CSeqHeader.NAME);
|
CSeqHeader cSeqHeader = (CSeqHeader) message.getHeader(CSeqHeader.NAME);
|
||||||
String key = callIdHeader.getCallId() + cSeqHeader.getSeqNumber();
|
String key = callIdHeader.getCallId() + cSeqHeader.getSeqNumber();
|
||||||
SipEvent sipEvent = SipEvent.getInstance(key, eventResult -> {
|
SipEvent sipEvent = SipEvent.getInstance(key, eventResult -> {
|
||||||
log.info("success");
|
|
||||||
sipSubscribe.removeSubscribe(key);
|
sipSubscribe.removeSubscribe(key);
|
||||||
if(okEvent != null) {
|
if(okEvent != null) {
|
||||||
okEvent.response(eventResult);
|
okEvent.response(eventResult);
|
||||||
}
|
}
|
||||||
}, (eventResult -> {
|
}, (eventResult -> {
|
||||||
log.info("eror");
|
|
||||||
sipSubscribe.removeSubscribe(key);
|
sipSubscribe.removeSubscribe(key);
|
||||||
if (errorEvent != null) {
|
if (errorEvent != null) {
|
||||||
errorEvent.response(eventResult);
|
errorEvent.response(eventResult);
|
||||||
|
|
|
@ -182,7 +182,7 @@ public interface ISIPCommander {
|
||||||
* @param channelId 预览通道
|
* @param channelId 预览通道
|
||||||
* @param recordCmdStr 录像命令:Record / StopRecord
|
* @param recordCmdStr 录像命令:Record / StopRecord
|
||||||
*/
|
*/
|
||||||
void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
void recordCmd(Device device, String channelId, String recordCmdStr, ErrorCallback<String> callback) throws InvalidArgumentException, SipException, ParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 远程启动控制命令
|
* 远程启动控制命令
|
||||||
|
@ -196,7 +196,7 @@ public interface ISIPCommander {
|
||||||
*
|
*
|
||||||
* @param device 视频设备
|
* @param device 视频设备
|
||||||
*/
|
*/
|
||||||
void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
void guardCmd(Device device, String guardCmdStr, ErrorCallback<String> callback) throws InvalidArgumentException, SipException, ParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报警复位命令
|
* 报警复位命令
|
||||||
|
@ -205,7 +205,7 @@ public interface ISIPCommander {
|
||||||
* @param alarmMethod 报警方式(可选)
|
* @param alarmMethod 报警方式(可选)
|
||||||
* @param alarmType 报警类型(可选)
|
* @param alarmType 报警类型(可选)
|
||||||
*/
|
*/
|
||||||
void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
void alarmCmd(Device device, String alarmMethod, String alarmType, ErrorCallback<String> callback) throws InvalidArgumentException, SipException, ParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 强制关键帧命令,设备收到此命令应立刻发送一个IDR帧
|
* 强制关键帧命令,设备收到此命令应立刻发送一个IDR帧
|
||||||
|
@ -219,7 +219,7 @@ public interface ISIPCommander {
|
||||||
* 看守位控制命令
|
* 看守位控制命令
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void homePositionCmd(Device device, String channelId, Boolean enabled, Integer resetTime, Integer presetIndex, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
void homePositionCmd(Device device, String channelId, Boolean enabled, Integer resetTime, Integer presetIndex, ErrorCallback<String> callback) throws InvalidArgumentException, SipException, ParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备配置命令
|
* 设备配置命令
|
||||||
|
@ -238,7 +238,7 @@ public interface ISIPCommander {
|
||||||
*
|
*
|
||||||
* @param device 视频设备
|
* @param device 视频设备
|
||||||
*/
|
*/
|
||||||
void deviceStatusQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
void deviceStatusQuery(Device device, ErrorCallback<String> callback) throws InvalidArgumentException, SipException, ParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询设备信息
|
* 查询设备信息
|
||||||
|
@ -338,7 +338,7 @@ public interface ISIPCommander {
|
||||||
* @param channelId 通道id
|
* @param channelId 通道id
|
||||||
* @param cmdString 前端控制指令串
|
* @param cmdString 前端控制指令串
|
||||||
*/
|
*/
|
||||||
void dragZoomCmd(Device device, String channelId, String cmdString) throws InvalidArgumentException, SipException, ParseException;
|
void dragZoomCmd(Device device, String channelId, String cmdString, ErrorCallback<String> callback) throws InvalidArgumentException, SipException, ParseException;
|
||||||
|
|
||||||
|
|
||||||
void playbackControlCmd(Device device, DeviceChannel channel, String stream, String content, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, InvalidArgumentException, ParseException;
|
void playbackControlCmd(Device device, DeviceChannel channel, String stream, String content, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, InvalidArgumentException, ParseException;
|
||||||
|
|
|
@ -681,13 +681,16 @@ public class SIPCommander implements ISIPCommander {
|
||||||
* @param recordCmdStr 录像命令:Record / StopRecord
|
* @param recordCmdStr 录像命令:Record / StopRecord
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
|
public void recordCmd(Device device, String channelId, String recordCmdStr, ErrorCallback<String> callback) throws InvalidArgumentException, SipException, ParseException {
|
||||||
|
final String cmdType = "DeviceControl";
|
||||||
|
final int sn = (int) ((Math.random() * 9 + 1) * 100000);
|
||||||
|
|
||||||
StringBuffer cmdXml = new StringBuffer(200);
|
StringBuffer cmdXml = new StringBuffer(200);
|
||||||
String charset = device.getCharset();
|
String charset = device.getCharset();
|
||||||
cmdXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
|
cmdXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
|
||||||
cmdXml.append("<Control>\r\n");
|
cmdXml.append("<Control>\r\n");
|
||||||
cmdXml.append("<CmdType>DeviceControl</CmdType>\r\n");
|
cmdXml.append("<CmdType>" + cmdType + "</CmdType>\r\n");
|
||||||
cmdXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n");
|
cmdXml.append("<SN>" + sn + "</SN>\r\n");
|
||||||
if (ObjectUtils.isEmpty(channelId)) {
|
if (ObjectUtils.isEmpty(channelId)) {
|
||||||
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
||||||
} else {
|
} else {
|
||||||
|
@ -696,10 +699,14 @@ public class SIPCommander implements ISIPCommander {
|
||||||
cmdXml.append("<RecordCmd>" + recordCmdStr + "</RecordCmd>\r\n");
|
cmdXml.append("<RecordCmd>" + recordCmdStr + "</RecordCmd>\r\n");
|
||||||
cmdXml.append("</Control>\r\n");
|
cmdXml.append("</Control>\r\n");
|
||||||
|
|
||||||
|
MessageEvent<String> messageEvent = MessageEvent.getInstance(cmdType, sn + "", channelId, 1000L, callback);
|
||||||
|
messageSubscribe.addSubscribe(messageEvent);
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
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);
|
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, eventResult -> {
|
||||||
|
messageSubscribe.removeSubscribe(messageEvent.getKey());
|
||||||
|
callback.run(ErrorCode.ERROR100.getCode(), "失败," + eventResult.msg, null);
|
||||||
|
},null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -733,22 +740,29 @@ public class SIPCommander implements ISIPCommander {
|
||||||
* @param guardCmdStr "SetGuard"/"ResetGuard"
|
* @param guardCmdStr "SetGuard"/"ResetGuard"
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
|
public void guardCmd(Device device, String guardCmdStr, ErrorCallback<String> callback) throws InvalidArgumentException, SipException, ParseException {
|
||||||
|
|
||||||
|
String cmdType = "DeviceControl";
|
||||||
|
int sn = (int) ((Math.random() * 9 + 1) * 100000);
|
||||||
|
|
||||||
StringBuffer cmdXml = new StringBuffer(200);
|
StringBuffer cmdXml = new StringBuffer(200);
|
||||||
String charset = device.getCharset();
|
String charset = device.getCharset();
|
||||||
cmdXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
|
cmdXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
|
||||||
cmdXml.append("<Control>\r\n");
|
cmdXml.append("<Control>\r\n");
|
||||||
cmdXml.append("<CmdType>DeviceControl</CmdType>\r\n");
|
cmdXml.append("<CmdType>" + cmdType + "</CmdType>\r\n");
|
||||||
cmdXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n");
|
cmdXml.append("<SN>" + sn + "</SN>\r\n");
|
||||||
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
||||||
cmdXml.append("<GuardCmd>" + guardCmdStr + "</GuardCmd>\r\n");
|
cmdXml.append("<GuardCmd>" + guardCmdStr + "</GuardCmd>\r\n");
|
||||||
cmdXml.append("</Control>\r\n");
|
cmdXml.append("</Control>\r\n");
|
||||||
|
|
||||||
|
MessageEvent<String> messageEvent = MessageEvent.getInstance(cmdType, sn + "", device.getDeviceId(), 1000L, callback);
|
||||||
|
messageSubscribe.addSubscribe(messageEvent);
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
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);
|
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, eventResult -> {
|
||||||
|
messageSubscribe.removeSubscribe(messageEvent.getKey());
|
||||||
|
callback.run(ErrorCode.ERROR100.getCode(), "失败," + eventResult.msg, null);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -757,14 +771,17 @@ public class SIPCommander implements ISIPCommander {
|
||||||
* @param device 视频设备
|
* @param device 视频设备
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
|
public void alarmCmd(Device device, String alarmMethod, String alarmType, ErrorCallback<String> callback) throws InvalidArgumentException, SipException, ParseException {
|
||||||
|
|
||||||
|
String cmdType = "DeviceControl";
|
||||||
|
int sn = (int) ((Math.random() * 9 + 1) * 100000);
|
||||||
|
|
||||||
StringBuffer cmdXml = new StringBuffer(200);
|
StringBuffer cmdXml = new StringBuffer(200);
|
||||||
String charset = device.getCharset();
|
String charset = device.getCharset();
|
||||||
cmdXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
|
cmdXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
|
||||||
cmdXml.append("<Control>\r\n");
|
cmdXml.append("<Control>\r\n");
|
||||||
cmdXml.append("<CmdType>DeviceControl</CmdType>\r\n");
|
cmdXml.append("<CmdType>" + cmdType + "</CmdType>\r\n");
|
||||||
cmdXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n");
|
cmdXml.append("<SN>" + sn + "</SN>\r\n");
|
||||||
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
||||||
cmdXml.append("<AlarmCmd>ResetAlarm</AlarmCmd>\r\n");
|
cmdXml.append("<AlarmCmd>ResetAlarm</AlarmCmd>\r\n");
|
||||||
if (!ObjectUtils.isEmpty(alarmMethod) || !ObjectUtils.isEmpty(alarmType)) {
|
if (!ObjectUtils.isEmpty(alarmMethod) || !ObjectUtils.isEmpty(alarmType)) {
|
||||||
|
@ -781,10 +798,14 @@ public class SIPCommander implements ISIPCommander {
|
||||||
}
|
}
|
||||||
cmdXml.append("</Control>\r\n");
|
cmdXml.append("</Control>\r\n");
|
||||||
|
|
||||||
|
MessageEvent<String> messageEvent = MessageEvent.getInstance(cmdType, sn + "", device.getDeviceId(), 1000L, callback);
|
||||||
|
messageSubscribe.addSubscribe(messageEvent);
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
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);
|
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, eventResult -> {
|
||||||
|
messageSubscribe.removeSubscribe(messageEvent.getKey());
|
||||||
|
callback.run(ErrorCode.ERROR100.getCode(), "失败," + eventResult.msg, null);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -826,19 +847,21 @@ public class SIPCommander implements ISIPCommander {
|
||||||
* @param presetIndex 调用预置位编号,开启看守位时使用,取值范围0~255
|
* @param presetIndex 调用预置位编号,开启看守位时使用,取值范围0~255
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void homePositionCmd(Device device, String channelId, Boolean enabled, Integer resetTime, Integer presetIndex, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
|
public void homePositionCmd(Device device, String channelId, Boolean enabled, Integer resetTime, Integer presetIndex, ErrorCallback<String> callback) throws InvalidArgumentException, SipException, ParseException {
|
||||||
|
|
||||||
|
String cmdType = "DeviceControl";
|
||||||
|
int sn = (int) ((Math.random() * 9 + 1) * 100000);
|
||||||
|
|
||||||
StringBuffer cmdXml = new StringBuffer(200);
|
StringBuffer cmdXml = new StringBuffer(200);
|
||||||
String charset = device.getCharset();
|
String charset = device.getCharset();
|
||||||
cmdXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
|
cmdXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
|
||||||
cmdXml.append("<Control>\r\n");
|
cmdXml.append("<Control>\r\n");
|
||||||
cmdXml.append("<CmdType>DeviceControl</CmdType>\r\n");
|
cmdXml.append("<CmdType>" + cmdType + "</CmdType>\r\n");
|
||||||
cmdXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n");
|
cmdXml.append("<SN>" + sn + "</SN>\r\n");
|
||||||
if (ObjectUtils.isEmpty(channelId)) {
|
if (ObjectUtils.isEmpty(channelId)) {
|
||||||
cmdXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
channelId = device.getDeviceId();
|
||||||
} else {
|
|
||||||
cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
|
|
||||||
}
|
}
|
||||||
|
cmdXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
|
||||||
cmdXml.append("<HomePosition>\r\n");
|
cmdXml.append("<HomePosition>\r\n");
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
cmdXml.append("<Enabled>1</Enabled>\r\n");
|
cmdXml.append("<Enabled>1</Enabled>\r\n");
|
||||||
|
@ -850,10 +873,14 @@ public class SIPCommander implements ISIPCommander {
|
||||||
cmdXml.append("</HomePosition>\r\n");
|
cmdXml.append("</HomePosition>\r\n");
|
||||||
cmdXml.append("</Control>\r\n");
|
cmdXml.append("</Control>\r\n");
|
||||||
|
|
||||||
|
MessageEvent<String> messageEvent = MessageEvent.getInstance(cmdType, sn + "", channelId, 1000L, callback);
|
||||||
|
messageSubscribe.addSubscribe(messageEvent);
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
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);
|
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, eventResult -> {
|
||||||
|
messageSubscribe.removeSubscribe(messageEvent.getKey());
|
||||||
|
callback.run(ErrorCode.ERROR100.getCode(), "失败," + eventResult.msg, null);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -909,7 +936,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
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, eventResult -> {
|
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, eventResult -> {
|
||||||
callback.run(ErrorCode.ERROR100.getCode(), "消息发送失败", null);
|
messageSubscribe.removeSubscribe(messageEvent.getKey());
|
||||||
|
callback.run(ErrorCode.ERROR100.getCode(), "失败," + eventResult.msg, null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -919,22 +947,29 @@ public class SIPCommander implements ISIPCommander {
|
||||||
* @param device 视频设备
|
* @param device 视频设备
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deviceStatusQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException {
|
public void deviceStatusQuery(Device device, ErrorCallback<String> callback) throws InvalidArgumentException, SipException, ParseException {
|
||||||
|
|
||||||
|
String cmdType = "DeviceStatus";
|
||||||
|
int sn = (int) ((Math.random() * 9 + 1) * 100000);
|
||||||
|
|
||||||
String charset = device.getCharset();
|
String charset = device.getCharset();
|
||||||
StringBuffer catalogXml = new StringBuffer(200);
|
StringBuffer catalogXml = new StringBuffer(200);
|
||||||
catalogXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
|
catalogXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
|
||||||
catalogXml.append("<Query>\r\n");
|
catalogXml.append("<Query>\r\n");
|
||||||
catalogXml.append("<CmdType>DeviceStatus</CmdType>\r\n");
|
catalogXml.append("<CmdType>" + cmdType + "</CmdType>\r\n");
|
||||||
catalogXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n");
|
catalogXml.append("<SN>" + sn + "</SN>\r\n");
|
||||||
catalogXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
catalogXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
||||||
catalogXml.append("</Query>\r\n");
|
catalogXml.append("</Query>\r\n");
|
||||||
|
|
||||||
|
MessageEvent<String> messageEvent = MessageEvent.getInstance(cmdType, sn + "", device.getDeviceId(), 1000L, callback);
|
||||||
|
messageSubscribe.addSubscribe(messageEvent);
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
||||||
|
|
||||||
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
|
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, eventResult -> {
|
||||||
|
messageSubscribe.removeSubscribe(messageEvent.getKey());
|
||||||
|
callback.run(ErrorCode.ERROR100.getCode(), "失败," + eventResult.msg, null);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1110,7 +1145,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
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, eventResult -> {
|
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, eventResult -> {
|
||||||
callback.run(ErrorCode.ERROR100.getCode(), "消息发送失败", null);
|
messageSubscribe.removeSubscribe(messageEvent.getKey());
|
||||||
|
callback.run(ErrorCode.ERROR100.getCode(), "失败," + eventResult.msg, null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1276,14 +1312,17 @@ public class SIPCommander implements ISIPCommander {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dragZoomCmd(Device device, String channelId, String cmdString) throws InvalidArgumentException, SipException, ParseException {
|
public void dragZoomCmd(Device device, String channelId, String cmdString, ErrorCallback<String> callback) throws InvalidArgumentException, SipException, ParseException {
|
||||||
|
|
||||||
|
String cmdType = "DeviceControl";
|
||||||
|
int sn = (int) ((Math.random() * 9 + 1) * 100000);
|
||||||
|
|
||||||
StringBuffer dragXml = new StringBuffer(200);
|
StringBuffer dragXml = new StringBuffer(200);
|
||||||
String charset = device.getCharset();
|
String charset = device.getCharset();
|
||||||
dragXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
|
dragXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
|
||||||
dragXml.append("<Control>\r\n");
|
dragXml.append("<Control>\r\n");
|
||||||
dragXml.append("<CmdType>DeviceControl</CmdType>\r\n");
|
dragXml.append("<CmdType>" + cmdType + "</CmdType>\r\n");
|
||||||
dragXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n");
|
dragXml.append("<SN>" + sn + "</SN>\r\n");
|
||||||
if (ObjectUtils.isEmpty(channelId)) {
|
if (ObjectUtils.isEmpty(channelId)) {
|
||||||
dragXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
dragXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
|
||||||
} else {
|
} else {
|
||||||
|
@ -1292,8 +1331,10 @@ public class SIPCommander implements ISIPCommander {
|
||||||
dragXml.append(cmdString);
|
dragXml.append(cmdString);
|
||||||
dragXml.append("</Control>\r\n");
|
dragXml.append("</Control>\r\n");
|
||||||
|
|
||||||
|
MessageEvent<String> messageEvent = MessageEvent.getInstance(cmdType, sn + "", channelId, 1000L, callback);
|
||||||
|
messageSubscribe.addSubscribe(messageEvent);
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, dragXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, dragXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
||||||
log.debug("拉框信令: " + request.toString());
|
|
||||||
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request);
|
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
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.IMessageHandler;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.control.ControlMessageHandler;
|
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.control.ControlMessageHandler;
|
||||||
|
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||||
import gov.nist.javax.sip.message.SIPRequest;
|
import gov.nist.javax.sip.message.SIPRequest;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dom4j.Element;
|
import org.dom4j.Element;
|
||||||
|
@ -175,7 +176,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
try {
|
try {
|
||||||
cmder.fronEndCmd(device, deviceChannel.getDeviceId(), cmdString,
|
cmder.fronEndCmd(device, deviceChannel.getDeviceId(), cmdString,
|
||||||
errorResult -> onError(request, errorResult),
|
errorResult -> onError(request, errorResult),
|
||||||
okResult -> onOk(request, okResult));
|
okResult -> onOk(request));
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
log.error("[命令发送失败] 云台/前端: {}", e.getMessage());
|
log.error("[命令发送失败] 云台/前端: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -270,7 +271,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
private void handleDragZoom(CommonGBChannel channel, Element rootElement, SIPRequest request, DeviceControlType type) {
|
private void handleDragZoom(CommonGBChannel channel, Element rootElement, SIPRequest request, DeviceControlType type) {
|
||||||
if (channel.getDataType() != ChannelDataType.GB28181.value) {
|
if (channel.getDataType() != ChannelDataType.GB28181.value) {
|
||||||
// 只支持国标的云台控制
|
// 只支持国标的云台控制
|
||||||
log.warn("[INFO 消息] 只支持国标的拉框控制, 通道ID: {}", channel.getGbId());
|
log.warn("[deviceControl-DragZoom] 只支持国标的拉框控制, 通道ID: {}", channel.getGbId());
|
||||||
try {
|
try {
|
||||||
responseAck(request, Response.FORBIDDEN, "");
|
responseAck(request, Response.FORBIDDEN, "");
|
||||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||||
|
@ -282,7 +283,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
Device device = deviceService.getDevice(channel.getDataDeviceId());
|
Device device = deviceService.getDevice(channel.getDataDeviceId());
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
// 不存在则回复404
|
// 不存在则回复404
|
||||||
log.warn("[INFO 消息] 通道所属设备不存在, 通道ID: {}", channel.getGbId());
|
log.warn("[deviceControl-DragZoom] 通道所属设备不存在, 通道ID: {}", channel.getGbId());
|
||||||
try {
|
try {
|
||||||
responseAck(request, Response.NOT_FOUND, "device not found");
|
responseAck(request, Response.NOT_FOUND, "device not found");
|
||||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||||
|
@ -293,7 +294,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
|
|
||||||
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(channel.getGbId());
|
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(channel.getGbId());
|
||||||
if (deviceChannel == null) {
|
if (deviceChannel == null) {
|
||||||
log.warn("[deviceControl] 未找到设备原始通道, 设备: {}({}),通道编号:{}", device.getName(),
|
log.warn("[deviceControl-DragZoom] 未找到设备原始通道, 设备: {}({}),通道编号:{}", device.getName(),
|
||||||
device.getDeviceId(), channel.getGbId());
|
device.getDeviceId(), channel.getGbId());
|
||||||
try {
|
try {
|
||||||
responseAck(request, Response.NOT_FOUND, "channel not found");
|
responseAck(request, Response.NOT_FOUND, "channel not found");
|
||||||
|
@ -306,7 +307,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
deviceChannel.getName(), deviceChannel.getDeviceId());
|
deviceChannel.getName(), deviceChannel.getDeviceId());
|
||||||
try {
|
try {
|
||||||
DragZoomRequest dragZoomRequest = loadElement(rootElement, DragZoomRequest.class);
|
DragZoomRequest dragZoomRequest = loadElement(rootElement, DragZoomRequest.class);
|
||||||
DragZoomRequest.DragZoom dragZoom = dragZoomRequest.getDragZoomIn();
|
DragZoomParam dragZoom = dragZoomRequest.getDragZoomIn();
|
||||||
if (dragZoom == null) {
|
if (dragZoom == null) {
|
||||||
dragZoom = dragZoomRequest.getDragZoomOut();
|
dragZoom = dragZoomRequest.getDragZoomOut();
|
||||||
}
|
}
|
||||||
|
@ -319,7 +320,9 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
cmdXml.append("<LengthX>" + dragZoom.getLengthX() + "</LengthX>\r\n");
|
cmdXml.append("<LengthX>" + dragZoom.getLengthX() + "</LengthX>\r\n");
|
||||||
cmdXml.append("<LengthY>" + dragZoom.getLengthY() + "</LengthY>\r\n");
|
cmdXml.append("<LengthY>" + dragZoom.getLengthY() + "</LengthY>\r\n");
|
||||||
cmdXml.append("</" + type.getVal() + ">\r\n");
|
cmdXml.append("</" + type.getVal() + ">\r\n");
|
||||||
cmder.dragZoomCmd(device, deviceChannel.getDeviceId(), cmdXml.toString());
|
cmder.dragZoomCmd(device, deviceChannel.getDeviceId(), cmdXml.toString(), (code, msg, data) -> {
|
||||||
|
|
||||||
|
});
|
||||||
responseAck(request, Response.OK);
|
responseAck(request, Response.OK);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("[命令发送失败] 拉框控制: {}", e.getMessage());
|
log.error("[命令发送失败] 拉框控制: {}", e.getMessage());
|
||||||
|
@ -371,9 +374,13 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
HomePositionRequest homePosition = loadElement(rootElement, HomePositionRequest.class);
|
HomePositionRequest homePosition = loadElement(rootElement, HomePositionRequest.class);
|
||||||
//获取整个消息主体,我们只需要修改请求头即可
|
//获取整个消息主体,我们只需要修改请求头即可
|
||||||
HomePositionRequest.HomePosition info = homePosition.getHomePosition();
|
HomePositionRequest.HomePosition info = homePosition.getHomePosition();
|
||||||
cmder.homePositionCmd(device, deviceChannel.getDeviceId(), !"0".equals(info.getEnabled()), Integer.parseInt(info.getResetTime()), Integer.parseInt(info.getPresetIndex()),
|
cmder.homePositionCmd(device, deviceChannel.getDeviceId(), !"0".equals(info.getEnabled()), Integer.parseInt(info.getResetTime()), Integer.parseInt(info.getPresetIndex()), (code, msg, data) -> {
|
||||||
errorResult -> onError(request, errorResult),
|
if (code == ErrorCode.SUCCESS.getCode()) {
|
||||||
okResult -> onOk(request, okResult));
|
onOk(request);
|
||||||
|
}else {
|
||||||
|
onError(request, code, msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("[命令发送失败] 看守位设置: {}", e.getMessage());
|
log.error("[命令发送失败] 看守位设置: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -417,9 +424,13 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
cmder.alarmCmd(device, alarmMethod, alarmType,
|
cmder.alarmCmd(device, alarmMethod, alarmType, (code, msg, data) -> {
|
||||||
errorResult -> onError(request, errorResult),
|
if (code == ErrorCode.SUCCESS.getCode()) {
|
||||||
okResult -> onOk(request, okResult));
|
onOk(request);
|
||||||
|
}else {
|
||||||
|
onError(request, code, msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
log.error("[命令发送失败] 告警消息: {}", e.getMessage());
|
log.error("[命令发送失败] 告警消息: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -469,9 +480,13 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
//获取整个消息主体,我们只需要修改请求头即可
|
//获取整个消息主体,我们只需要修改请求头即可
|
||||||
String cmdString = getText(rootElement, type.getVal());
|
String cmdString = getText(rootElement, type.getVal());
|
||||||
try {
|
try {
|
||||||
cmder.recordCmd(device, deviceChannel.getDeviceId(), cmdString,
|
cmder.recordCmd(device, deviceChannel.getDeviceId(), cmdString, (code, msg, data) -> {
|
||||||
errorResult -> onError(request, errorResult),
|
if (code == ErrorCode.SUCCESS.getCode()) {
|
||||||
okResult -> onOk(request, okResult));
|
onOk(request);
|
||||||
|
}else {
|
||||||
|
onError(request, code, msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
log.error("[命令发送失败] 录像控制: {}", e.getMessage());
|
log.error("[命令发送失败] 录像控制: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -506,40 +521,47 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
//获取整个消息主体,我们只需要修改请求头即可
|
//获取整个消息主体,我们只需要修改请求头即可
|
||||||
String cmdString = getText(rootElement, type.getVal());
|
String cmdString = getText(rootElement, type.getVal());
|
||||||
try {
|
try {
|
||||||
cmder.guardCmd(device, cmdString,
|
cmder.guardCmd(device, cmdString,(code, msg, data) -> {
|
||||||
errorResult -> onError(request, errorResult),
|
if (code == ErrorCode.SUCCESS.getCode()) {
|
||||||
okResult -> onOk(request, okResult));
|
onOk(request);
|
||||||
|
}else {
|
||||||
|
onError(request, code, msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
log.error("[命令发送失败] 布防/撤防命令: {}", e.getMessage());
|
log.error("[命令发送失败] 布防/撤防命令: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误响应处理
|
* 错误响应处理
|
||||||
*
|
*
|
||||||
* @param request 请求
|
|
||||||
* @param eventResult 响应结构
|
|
||||||
*/
|
*/
|
||||||
private void onError(SIPRequest request, SipSubscribe.EventResult eventResult) {
|
private void onError(SIPRequest request, Integer code, String msg) {
|
||||||
// 失败的回复
|
// 失败的回复
|
||||||
try {
|
try {
|
||||||
responseAck(request, eventResult.statusCode, eventResult.msg);
|
responseAck(request, code, msg);
|
||||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||||
log.error("[命令发送失败] 回复: {}", e.getMessage());
|
log.error("[命令发送失败] 回复: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onError(SIPRequest request, SipSubscribe.EventResult errorResult) {
|
||||||
|
onError(request, errorResult.statusCode, errorResult.msg);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 成功响应处理
|
* 成功响应处理
|
||||||
*
|
*
|
||||||
* @param request 请求
|
* @param request 请求
|
||||||
* @param eventResult 响应结构
|
|
||||||
*/
|
*/
|
||||||
private void onOk(SIPRequest request, SipSubscribe.EventResult eventResult) {
|
private void onOk(SIPRequest request) {
|
||||||
// 成功的回复
|
// 成功的回复
|
||||||
try {
|
try {
|
||||||
responseAck(request, eventResult.statusCode);
|
responseAck(request, Response.OK);
|
||||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||||
log.error("[命令发送失败] 回复: {}", e.getMessage());
|
log.error("[命令发送失败] 回复: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.context.request.async.DeferredResult;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@ -176,16 +175,9 @@ public class RedisRpcDeviceController extends RpcController {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DeferredResult<WVPResult<String>> deferredResult = deviceService.record(device, channelId, recordCmdStr);
|
deviceService.record(device, channelId, recordCmdStr, (code, msg, data) -> {
|
||||||
deferredResult.onCompletion(() ->{
|
|
||||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||||
response.setBody(deferredResult.getResult());
|
response.setBody(new WVPResult<>(code, msg, data));
|
||||||
// 手动发送结果
|
|
||||||
sendResponse(response);
|
|
||||||
});
|
|
||||||
deferredResult.onTimeout(() -> {
|
|
||||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
|
||||||
response.setBody(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
|
||||||
// 手动发送结果
|
// 手动发送结果
|
||||||
sendResponse(response);
|
sendResponse(response);
|
||||||
});
|
});
|
||||||
|
@ -212,17 +204,9 @@ public class RedisRpcDeviceController extends RpcController {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DeferredResult<WVPResult<String>> deferredResult = deviceService.guard(device, guardCmdStr);
|
deviceService.guard(device, guardCmdStr, (code, msg, data) -> {
|
||||||
deferredResult.onCompletion(() ->{
|
|
||||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||||
response.setBody(deferredResult.getResult());
|
response.setBody(new WVPResult<>(code, msg, data));
|
||||||
// 手动发送结果
|
|
||||||
sendResponse(response);
|
|
||||||
});
|
|
||||||
deferredResult.onTimeout(() -> {
|
|
||||||
log.warn("[布防/撤防]操作超时, 设备未返回应答指令");
|
|
||||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
|
||||||
response.setBody(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
|
||||||
// 手动发送结果
|
// 手动发送结果
|
||||||
sendResponse(response);
|
sendResponse(response);
|
||||||
});
|
});
|
||||||
|
@ -251,17 +235,9 @@ public class RedisRpcDeviceController extends RpcController {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DeferredResult<WVPResult<String>> deferredResult = deviceService.resetAlarm(device, channelId, alarmMethod, alarmType);
|
deviceService.resetAlarm(device, channelId, alarmMethod, alarmType, (code, msg, data) -> {
|
||||||
deferredResult.onCompletion(() ->{
|
|
||||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||||
response.setBody(deferredResult.getResult());
|
response.setBody(new WVPResult<>(code, msg, data));
|
||||||
// 手动发送结果
|
|
||||||
sendResponse(response);
|
|
||||||
});
|
|
||||||
deferredResult.onTimeout(() -> {
|
|
||||||
log.warn("[报警重置] 操作超时, 设备未返回应答指令");
|
|
||||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
|
||||||
response.setBody(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
|
||||||
// 手动发送结果
|
// 手动发送结果
|
||||||
sendResponse(response);
|
sendResponse(response);
|
||||||
});
|
});
|
||||||
|
@ -316,17 +292,9 @@ public class RedisRpcDeviceController extends RpcController {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DeferredResult<WVPResult<String>> deferredResult = deviceService.homePosition(device, channelId, enabled, resetTime, presetIndex);
|
deviceService.homePosition(device, channelId, enabled, resetTime, presetIndex, (code, msg, data) -> {
|
||||||
deferredResult.onCompletion(() ->{
|
|
||||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||||
response.setBody(deferredResult.getResult());
|
response.setBody(new WVPResult<>(code, msg, data));
|
||||||
// 手动发送结果
|
|
||||||
sendResponse(response);
|
|
||||||
});
|
|
||||||
deferredResult.onTimeout(() -> {
|
|
||||||
log.warn("[看守位控制] 操作超时, 设备未返回应答指令");
|
|
||||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
|
||||||
response.setBody(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
|
||||||
// 手动发送结果
|
// 手动发送结果
|
||||||
sendResponse(response);
|
sendResponse(response);
|
||||||
});
|
});
|
||||||
|
@ -359,7 +327,12 @@ public class RedisRpcDeviceController extends RpcController {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
deviceService.dragZoomIn(device, channelId, length, width, midpointx, midpointy, lengthx, lengthy);
|
deviceService.dragZoomIn(device, channelId, length, width, midpointx, midpointy, lengthx, lengthy, (code, msg, data) -> {
|
||||||
|
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||||
|
response.setBody(new WVPResult<>(code, msg, data));
|
||||||
|
// 手动发送结果
|
||||||
|
sendResponse(response);
|
||||||
|
});
|
||||||
}catch (ControllerException e) {
|
}catch (ControllerException e) {
|
||||||
response.setStatusCode(e.getCode());
|
response.setStatusCode(e.getCode());
|
||||||
response.setBody(WVPResult.fail(ErrorCode.ERROR100.getCode(), e.getMsg()));
|
response.setBody(WVPResult.fail(ErrorCode.ERROR100.getCode(), e.getMsg()));
|
||||||
|
@ -389,7 +362,12 @@ public class RedisRpcDeviceController extends RpcController {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
deviceService.dragZoomOut(device, channelId, length, width, midpointx, midpointy, lengthx, lengthy);
|
deviceService.dragZoomOut(device, channelId, length, width, midpointx, midpointy, lengthx, lengthy, (code, msg, data) -> {
|
||||||
|
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||||
|
response.setBody(new WVPResult<>(code, msg, data));
|
||||||
|
// 手动发送结果
|
||||||
|
sendResponse(response);
|
||||||
|
});
|
||||||
}catch (ControllerException e) {
|
}catch (ControllerException e) {
|
||||||
response.setStatusCode(e.getCode());
|
response.setStatusCode(e.getCode());
|
||||||
response.setBody(WVPResult.fail(ErrorCode.ERROR100.getCode(), e.getMsg()));
|
response.setBody(WVPResult.fail(ErrorCode.ERROR100.getCode(), e.getMsg()));
|
||||||
|
@ -411,17 +389,9 @@ public class RedisRpcDeviceController extends RpcController {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DeferredResult<WVPResult<String>> deferredResult = deviceService.deviceStatus(device);
|
deviceService.deviceStatus(device, (code, msg, data) -> {
|
||||||
deferredResult.onCompletion(() ->{
|
|
||||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||||
response.setBody(deferredResult.getResult());
|
response.setBody(new WVPResult<>(code, msg, data));
|
||||||
// 手动发送结果
|
|
||||||
sendResponse(response);
|
|
||||||
});
|
|
||||||
deferredResult.onTimeout(() -> {
|
|
||||||
log.warn("[获取设备状态] 操作超时, 设备未返回应答指令");
|
|
||||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
|
||||||
response.setBody(WVPResult.fail(ErrorCode.ERROR100.getCode(), "操作超时, 设备未应答"));
|
|
||||||
// 手动发送结果
|
// 手动发送结果
|
||||||
sendResponse(response);
|
sendResponse(response);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue