临时提交

This commit is contained in:
lin
2025-07-07 09:30:04 +08:00
parent 51cd14e02e
commit 51759535fc
11 changed files with 943 additions and 41 deletions

View File

@@ -14,7 +14,7 @@ public class FrontEndControlCodeForAuxiliary implements IFrontEndControlCode {
}
/**
* 辅助开关控制指令: 1为开 2为关 3为设置自动扫描右边界 4为设置自动扫描速度
* 辅助开关控制指令: 1为开 2为关
*/
@Getter
@Setter

View File

@@ -27,6 +27,13 @@ public class FrontEndControlCodeForPreset implements IFrontEndControlCode {
@Setter
private Integer presetId;
/**
* 预置位名称
*/
@Getter
@Setter
private String presetName;
@Override
public String encode() {

View File

@@ -14,7 +14,7 @@ public class FrontEndControlCodeForScan implements IFrontEndControlCode {
}
/**
* 预置位指令: 1为开始自动扫描 2为设置自动扫描左边界 3为设置自动扫描右边界 4为设置自动扫描速度
* 预置位指令: 1为开始自动扫描 2为设置自动扫描左边界 3为设置自动扫描右边界 4为设置自动扫描速度 5为停止自动扫描
*/
@Getter
@Setter

View File

@@ -14,7 +14,7 @@ public class FrontEndControlCodeForTour implements IFrontEndControlCode {
}
/**
* 巡航指令: 1为加入巡航点 2为删除一个巡航点 3为设置巡航速度 4为设置巡航停留时间 5为开始巡航
* 巡航指令: 1为加入巡航点 2为删除一个巡航点 3为设置巡航速度 4为设置巡航停留时间 5为开始巡航 6为开始巡航
*/
@Getter
@Setter

View File

@@ -0,0 +1,27 @@
package com.genersoft.iot.vmp.gb28181.bean;
import lombok.Getter;
import lombok.Setter;
public class FrontEndControlCodeForWiper implements IFrontEndControlCode {
private final FrontEndControlType type = FrontEndControlType.AUXILIARY;
@Override
public FrontEndControlType getType() {
return type;
}
/**
* 辅助开关控制指令: 1为开 2为关
*/
@Getter
@Setter
private Integer code;
@Override
public String encode() {
return "";
}
}

View File

@@ -41,7 +41,7 @@ import java.util.List;
@RestController
@Slf4j
@RequestMapping(value = "/api/common/channel")
public class CommonChannelController {
public class ChannelController {
@Autowired
private IRedisCatchStorage redisCatchStorage;

View File

@@ -0,0 +1,601 @@
package com.genersoft.iot.vmp.gb28181.controller;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.security.JwtUtils;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelControlService;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.async.DeferredResult;
import java.util.List;
@Tag(name = "全局通道前端控制")
@RestController
@Slf4j
@RequestMapping(value = "/api/common/channel/front-end")
public class ChannelFrontEndController {
@Autowired
private IGbChannelService channelService;
@Autowired
private IGbChannelControlService channelControlService;
@Operation(summary = "云台控制", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "command", description = "控制指令,允许值: left, right, up, down, upleft, upright, downleft, downright, zoomin, zoomout, stop", required = true)
@Parameter(name = "panSpeed", description = "水平速度(0-100)", required = true)
@Parameter(name = "tiltSpeed", description = "垂直速度(0-100)", required = true)
@Parameter(name = "zoomSpeed", description = "缩放速度(0-100)", required = true)
@GetMapping("/ptz")
public DeferredResult<WVPResult<String>> ptz(Integer channelId, String command, Integer panSpeed, Integer tiltSpeed, Integer zoomSpeed){
if (log.isDebugEnabled()) {
log.debug("[通用通道]云台控制 API调用channelId{} command{} panSpeed{} tiltSpeed{} zoomSpeed{}",channelId, command, panSpeed, tiltSpeed, zoomSpeed);
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
if (panSpeed == null) {
panSpeed = 50;
}else if (panSpeed < 0 || panSpeed > 100) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "panSpeed 为 0-100的数字");
}
if (tiltSpeed == null) {
tiltSpeed = 50;
}else if (tiltSpeed < 0 || tiltSpeed > 100) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "tiltSpeed 为 0-100的数字");
}
if (zoomSpeed == null) {
zoomSpeed = 50;
}else if (zoomSpeed < 0 || zoomSpeed > 100) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "zoomSpeed 为 0-100的数字");
}
FrontEndControlCodeForPTZ controlCode = new FrontEndControlCodeForPTZ();
controlCode.setPanSpeed(panSpeed);
controlCode.setTiltSpeed(tiltSpeed);
controlCode.setZoomSpeed(zoomSpeed);
switch (command){
case "left":
controlCode.setPan(0);
break;
case "right":
controlCode.setPan(1);
break;
case "up":
controlCode.setTilt(0);
break;
case "down":
controlCode.setTilt(1);
break;
case "upleft":
controlCode.setPan(0);
controlCode.setTilt(0);
break;
case "upright":
controlCode.setTilt(0);
controlCode.setPan(1);
break;
case "downleft":
controlCode.setPan(0);
controlCode.setTilt(1);
break;
case "downright":
controlCode.setTilt(1);
controlCode.setPan(1);
break;
case "zoomin":
controlCode.setZoom(1);
break;
case "zoomout":
controlCode.setZoom(0);
break;
default:
break;
}
DeferredResult<WVPResult<String>> result = new DeferredResult<>();
result.onTimeout(()->{
WVPResult<String> wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "请求超时");
result.setResult(wvpResult);
});
channelControlService.ptz(channel, controlCode, (code, msg, data) -> {
WVPResult<String> wvpResult = new WVPResult<>();
wvpResult.setCode(code);
wvpResult.setMsg(msg);
wvpResult.setData(data);
result.setResult(wvpResult);
});
return result;
}
@Operation(summary = "光圈控制", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "command", description = "控制指令,允许值: in, out, stop", required = true)
@Parameter(name = "speed", description = "光圈速度(0-100)", required = true)
@GetMapping("/fi/iris")
public DeferredResult<WVPResult<String>> iris(Integer channelId, String command, Integer speed){
if (log.isDebugEnabled()) {
log.debug("[通用通道]光圈控制 API调用channelId{} command{} speed{} ",channelId, command, speed);
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
if (speed == null) {
speed = 50;
}else if (speed < 0 || speed > 100) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "speed 为 0-100的数字");
}
FrontEndControlCodeForFI controlCode = new FrontEndControlCodeForFI();
controlCode.setIrisSpeed(speed);
switch (command){
case "in":
controlCode.setIris(1);
break;
case "out":
controlCode.setIris(0);
break;
default:
break;
}
DeferredResult<WVPResult<String>> result = new DeferredResult<>();
result.onTimeout(()->{
WVPResult<String> wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "请求超时");
result.setResult(wvpResult);
});
ErrorCallback<String> callback = (code, msg, data) -> {
WVPResult<String> wvpResult = new WVPResult<>();
wvpResult.setCode(code);
wvpResult.setMsg(msg);
wvpResult.setData(data);
result.setResult(wvpResult);
};
channelControlService.fi(channel, controlCode, callback);
return result;
}
@Operation(summary = "聚焦控制", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "command", description = "控制指令,允许值: near, far, stop", required = true)
@Parameter(name = "speed", description = "聚焦速度(0-100)", required = true)
@GetMapping("/fi/focus")
public DeferredResult<WVPResult<String>> focus(Integer channelId, String command, Integer speed){
if (log.isDebugEnabled()) {
log.debug("[通用通道]聚焦控制 API调用channelId{} command{} speed{} ", channelId, command, speed);
}
if (speed == null) {
speed = 50;
}else if (speed < 0 || speed > 100) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "speed 为 0-100的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
FrontEndControlCodeForFI controlCode = new FrontEndControlCodeForFI();
controlCode.setFocusSpeed(speed);
switch (command){
case "near":
controlCode.setFocus(0);
break;
case "far":
controlCode.setFocus(1);
break;
default:
break;
}
DeferredResult<WVPResult<String>> result = new DeferredResult<>();
result.onTimeout(()->{
WVPResult<String> wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "请求超时");
result.setResult(wvpResult);
});
ErrorCallback<String> callback = (code, msg, data) -> {
WVPResult<String> wvpResult = new WVPResult<>();
wvpResult.setCode(code);
wvpResult.setMsg(msg);
wvpResult.setData(data);
result.setResult(wvpResult);
};
channelControlService.fi(channel, controlCode, callback);
return result;
}
@Operation(summary = "查询预置位", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@GetMapping("/preset/query")
public DeferredResult<WVPResult<List<Preset>>> queryPreset(Integer channelId) {
if (log.isDebugEnabled()) {
log.debug("[通用通道] 预置位查询API调用, {}", channelId);
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
DeferredResult<WVPResult<List<Preset>>> result = new DeferredResult<>();
result.onTimeout(()->{
WVPResult<List<Preset>> wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "请求超时");
result.setResult(wvpResult);
});
ErrorCallback<List<Preset>> callback = (code, msg, data) -> {
WVPResult<List<Preset>> wvpResult = new WVPResult<>();
wvpResult.setCode(code);
wvpResult.setMsg(msg);
wvpResult.setData(data);
result.setResult(wvpResult);
};
channelControlService.queryPreset(channel, callback);
return result;
}
private DeferredResult<WVPResult<String>> controlPreset(Integer channelId, FrontEndControlCodeForPreset controlCode) {
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
DeferredResult<WVPResult<String>> result = new DeferredResult<>();
result.onTimeout(()->{
WVPResult<String> wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "请求超时");
result.setResult(wvpResult);
});
ErrorCallback<String> callback = (code, msg, data) -> {
WVPResult<String> wvpResult = new WVPResult<>();
wvpResult.setCode(code);
wvpResult.setMsg(msg);
wvpResult.setData(data);
result.setResult(wvpResult);
};
channelControlService.preset(channel, controlCode, callback);
return result;
}
@Operation(summary = "预置位指令-设置预置位", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "presetId", description = "预置位编号", required = true)
@Parameter(name = "presetName", description = "预置位名称", required = true)
@GetMapping("/preset/add")
public DeferredResult<WVPResult<String>> addPreset(Integer channelId, Integer presetId, String presetName) {
FrontEndControlCodeForPreset controlCode = new FrontEndControlCodeForPreset();
controlCode.setCode(1);
controlCode.setPresetId(presetId);
controlCode.setPresetName(presetName);
return controlPreset(channelId, controlCode);
}
@Operation(summary = "预置位指令-调用预置位", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "presetId", description = "预置位编号(1-100)", required = true)
@GetMapping("/preset/call")
public DeferredResult<WVPResult<String>> callPreset(Integer channelId, Integer presetId) {
FrontEndControlCodeForPreset controlCode = new FrontEndControlCodeForPreset();
controlCode.setCode(2);
controlCode.setPresetId(presetId);
return controlPreset(channelId, controlCode);
}
@Operation(summary = "预置位指令-删除预置位", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "presetId", description = "预置位编号(1-100)", required = true)
@GetMapping("/preset/delete")
public DeferredResult<WVPResult<String>> deletePreset(Integer channelId, Integer presetId) {
FrontEndControlCodeForPreset controlCode = new FrontEndControlCodeForPreset();
controlCode.setCode(3);
controlCode.setPresetId(presetId);
return controlPreset(channelId, controlCode);
}
private DeferredResult<WVPResult<String>> tourControl(Integer channelId, FrontEndControlCodeForTour controlCode) {
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
DeferredResult<WVPResult<String>> result = new DeferredResult<>();
result.onTimeout(()->{
WVPResult<String> wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "请求超时");
result.setResult(wvpResult);
});
ErrorCallback<String> callback = (code, msg, data) -> {
WVPResult<String> wvpResult = new WVPResult<>();
wvpResult.setCode(code);
wvpResult.setMsg(msg);
wvpResult.setData(data);
result.setResult(wvpResult);
};
channelControlService.tour(channel, controlCode, callback);
return result;
}
@Operation(summary = "巡航指令-加入巡航点", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "tourId", description = "巡航组号", required = true)
@Parameter(name = "presetId", description = "预置位编号", required = true)
@GetMapping("/tour/point/add")
public DeferredResult<WVPResult<String>> addTourPoint(Integer channelId, Integer tourId, Integer presetId) {
FrontEndControlCodeForTour controlCode = new FrontEndControlCodeForTour();
controlCode.setCode(1);
controlCode.setPresetId(presetId);
controlCode.setTourId(tourId);
return tourControl(channelId, controlCode);
}
@Operation(summary = "巡航指令-删除一个巡航点", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "tourId", description = "巡航组号(1-100)", required = true)
@Parameter(name = "presetId", description = "预置位编号(0-100, 为0时删除整个巡航)", required = true)
@GetMapping("/tour/point/delete")
public DeferredResult<WVPResult<String>> deleteCruisePoint(Integer channelId, Integer tourId, Integer presetId) {
FrontEndControlCodeForTour controlCode = new FrontEndControlCodeForTour();
controlCode.setCode(2);
controlCode.setPresetId(presetId);
controlCode.setTourId(tourId);
return tourControl(channelId, controlCode);
}
@Operation(summary = "巡航指令-设置巡航速度", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "tourId", description = "巡航组号(0-100)", required = true)
@Parameter(name = "speed", description = "巡航速度(1-4095)", required = true)
@GetMapping("/tour/speed")
public DeferredResult<WVPResult<String>> setCruiseSpeed(Integer channelId, Integer tourId, Integer speed) {
FrontEndControlCodeForTour controlCode = new FrontEndControlCodeForTour();
controlCode.setCode(3);
controlCode.setTourSpeed(speed);
controlCode.setTourId(tourId);
return tourControl(channelId, controlCode);
}
@Operation(summary = "巡航指令-设置巡航停留时间", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "tourId", description = "巡航组号", required = true)
@Parameter(name = "time", description = "巡航停留时间(1-4095)", required = true)
@GetMapping("/tour/time")
public DeferredResult<WVPResult<String>> setCruiseTime(Integer channelId, Integer tourId, Integer time) {
FrontEndControlCodeForTour controlCode = new FrontEndControlCodeForTour();
controlCode.setCode(4);
controlCode.setTourTime(time);
controlCode.setTourId(tourId);
return tourControl(channelId, controlCode);
}
@Operation(summary = "巡航指令-开始巡航", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "tourId", description = "巡航组号)", required = true)
@GetMapping("/tour/start")
public DeferredResult<WVPResult<String>> startCruise(Integer channelId, Integer tourId) {
FrontEndControlCodeForTour controlCode = new FrontEndControlCodeForTour();
controlCode.setCode(5);
controlCode.setTourId(tourId);
return tourControl(channelId, controlCode);
}
@Operation(summary = "巡航指令-停止巡航", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "tourId", description = "巡航组号", required = true)
@GetMapping("/tour/stop")
public DeferredResult<WVPResult<String>> stopCruise(Integer channelId, Integer tourId) {
FrontEndControlCodeForTour controlCode = new FrontEndControlCodeForTour();
controlCode.setCode(6);
controlCode.setTourId(tourId);
return tourControl(channelId, controlCode);
}
private DeferredResult<WVPResult<String>> scanControl(Integer channelId, FrontEndControlCodeForScan controlCode) {
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
DeferredResult<WVPResult<String>> result = new DeferredResult<>();
result.onTimeout(()->{
WVPResult<String> wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "请求超时");
result.setResult(wvpResult);
});
ErrorCallback<String> callback = (code, msg, data) -> {
WVPResult<String> wvpResult = new WVPResult<>();
wvpResult.setCode(code);
wvpResult.setMsg(msg);
wvpResult.setData(data);
result.setResult(wvpResult);
};
channelControlService.scan(channel, controlCode, callback);
return result;
}
@Operation(summary = "扫描指令-开始自动扫描", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "scanId", description = "扫描组号(0-100)", required = true)
@GetMapping("/scan/start")
public DeferredResult<WVPResult<String>> startScan(Integer channelId, Integer scanId) {
FrontEndControlCodeForScan controlCode = new FrontEndControlCodeForScan();
controlCode.setCode(1);
controlCode.setScanId(scanId);
return scanControl(channelId, controlCode);
}
@Operation(summary = "扫描指令-停止自动扫描", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "scanId", description = "扫描组号(0-100)", required = true)
@GetMapping("/scan/stop")
public DeferredResult<WVPResult<String>> stopScan(Integer channelId, Integer scanId) {
FrontEndControlCodeForScan controlCode = new FrontEndControlCodeForScan();
controlCode.setCode(5);
controlCode.setScanId(scanId);
return scanControl(channelId, controlCode);
}
@Operation(summary = "扫描指令-设置自动扫描左边界", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "scanId", description = "扫描组号(0-100)", required = true)
@GetMapping("/scan/set/left")
public DeferredResult<WVPResult<String>> setScanLeft(Integer channelId, Integer scanId) {
FrontEndControlCodeForScan controlCode = new FrontEndControlCodeForScan();
controlCode.setCode(2);
controlCode.setScanId(scanId);
return scanControl(channelId, controlCode);
}
@Operation(summary = "扫描指令-设置自动扫描右边界", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "scanId", description = "扫描组号(0-100)", required = true)
@GetMapping("/scan/set/right")
public DeferredResult<WVPResult<String>> setScanRight(Integer channelId, Integer scanId) {
FrontEndControlCodeForScan controlCode = new FrontEndControlCodeForScan();
controlCode.setCode(3);
controlCode.setScanId(scanId);
return scanControl(channelId, controlCode);
}
@Operation(summary = "扫描指令-设置自动扫描速度", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "scanId", description = "扫描组号(0-100)", required = true)
@Parameter(name = "speed", description = "自动扫描速度(1-4095)", required = true)
@GetMapping("/scan/set/speed")
public DeferredResult<WVPResult<String>> setScanSpeed(Integer channelId, Integer scanId, Integer speed) {
FrontEndControlCodeForScan controlCode = new FrontEndControlCodeForScan();
controlCode.setCode(4);
controlCode.setScanId(scanId);
controlCode.setScanSpeed(speed);
return scanControl(channelId, controlCode);
}
@Operation(summary = "辅助开关控制指令-雨刷控制", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "command", description = "控制指令,允许值: on, off", required = true)
@GetMapping("/wiper")
public DeferredResult<WVPResult<String>> wiper(Integer channelId, String command){
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
FrontEndControlCodeForWiper controlCode = new FrontEndControlCodeForWiper();
switch (command){
case "on":
controlCode.setCode(1);
break;
case "off":
controlCode.setCode(2);
break;
default:
break;
}
DeferredResult<WVPResult<String>> result = new DeferredResult<>();
result.onTimeout(()->{
WVPResult<String> wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "请求超时");
result.setResult(wvpResult);
});
ErrorCallback<String> callback = (code, msg, data) -> {
WVPResult<String> wvpResult = new WVPResult<>();
wvpResult.setCode(code);
wvpResult.setMsg(msg);
wvpResult.setData(data);
result.setResult(wvpResult);
};
channelControlService.wiper(channel, controlCode, callback);
return result;
}
@Operation(summary = "辅助开关控制指令", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "command", description = "控制指令,允许值: on, off", required = true)
@Parameter(name = "auxiliaryId", description = "开关编号", required = true)
@GetMapping("/auxiliary")
public DeferredResult<WVPResult<String>> auxiliarySwitch(Integer channelId, String command, Integer auxiliaryId){
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
FrontEndControlCodeForAuxiliary controlCode = new FrontEndControlCodeForAuxiliary();
controlCode.setAuxiliaryId(auxiliaryId);
switch (command){
case "on":
controlCode.setCode(1);
break;
case "off":
controlCode.setCode(2);
break;
default:
break;
}
DeferredResult<WVPResult<String>> result = new DeferredResult<>();
result.onTimeout(()->{
WVPResult<String> wvpResult = WVPResult.fail(ErrorCode.ERROR100.getCode(), "请求超时");
result.setResult(wvpResult);
});
ErrorCallback<String> callback = (code, msg, data) -> {
WVPResult<String> wvpResult = new WVPResult<>();
wvpResult.setCode(code);
wvpResult.setMsg(msg);
wvpResult.setData(data);
result.setResult(wvpResult);
};
channelControlService.auxiliary(channel, controlCode, callback);
return result;
}
}

View File

@@ -1,16 +1,21 @@
package com.genersoft.iot.vmp.gb28181.service;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.FrontEndControlCodeForPTZ;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
import java.util.List;
public interface IGbChannelControlService {
void ptz(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback);
void fi(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback);
void preset(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback);
void tour(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback);
void scan(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback);
void auxiliary(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback);
void fi(CommonGBChannel channel, FrontEndControlCodeForFI frontEndControlCode, ErrorCallback<String> callback);
void preset(CommonGBChannel channel, FrontEndControlCodeForPreset frontEndControlCode, ErrorCallback<String> callback);
void queryPreset(CommonGBChannel channel, FrontEndControlCodeForPreset frontEndControlCode, ErrorCallback<String> callback);
void tour(CommonGBChannel channel, FrontEndControlCodeForTour frontEndControlCode, ErrorCallback<String> callback);
void scan(CommonGBChannel channel, FrontEndControlCodeForScan frontEndControlCode, ErrorCallback<String> callback);
void wiper(CommonGBChannel channel, FrontEndControlCodeForWiper controlCode, ErrorCallback<String> callback);
void auxiliary(CommonGBChannel channel, FrontEndControlCodeForAuxiliary frontEndControlCode, ErrorCallback<String> callback);
void queryPreset(CommonGBChannel channel, ErrorCallback<List<Preset>> callback);
}

View File

@@ -1,43 +1,65 @@
package com.genersoft.iot.vmp.gb28181.service.impl;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.FrontEndControlCodeForPTZ;
import com.genersoft.iot.vmp.common.enums.ChannelDataType;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelControlService;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Slf4j
public class GbChannelControlServiceImpl implements IGbChannelControlService {
@Override
public void ptz(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback) {
log.info("[通用通道] 云台控制, 通道: {}", channel.getGbId());
log.info("[通用通道] 云台控制, 通道: {}", channel.getGbDeviceId());
if (channel.getDataType() == ChannelDataType.GB28181.value) {
}else if()
}
@Override
public void preset(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback) {
log.info("[通用通道] 预置位, 通道: {}", channel.getGbId());
public void preset(CommonGBChannel channel, FrontEndControlCodeForPreset frontEndControlCode, ErrorCallback<String> callback) {
log.info("[通用通道] 预置位, 通道: {}", channel.getGbDeviceId());
}
@Override
public void fi(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback) {
log.info("[通用通道] FI指令 通道: {}", channel.getGbId());
public void fi(CommonGBChannel channel, FrontEndControlCodeForFI frontEndControlCode, ErrorCallback<String> callback) {
log.info("[通用通道] FI指令 通道: {}", channel.getGbDeviceId());
}
@Override
public void tour(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback) {
public void tour(CommonGBChannel channel, FrontEndControlCodeForTour frontEndControlCode, ErrorCallback<String> callback) {
}
@Override
public void scan(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback) {
public void scan(CommonGBChannel channel, FrontEndControlCodeForScan frontEndControlCode, ErrorCallback<String> callback) {
}
@Override
public void auxiliary(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback) {
public void auxiliary(CommonGBChannel channel, FrontEndControlCodeForAuxiliary frontEndControlCode, ErrorCallback<String> callback) {
}
@Override
public void queryPreset(CommonGBChannel channel, FrontEndControlCodeForPreset frontEndControlCode, ErrorCallback<String> callback) {
}
@Override
public void wiper(CommonGBChannel channel, FrontEndControlCodeForWiper controlCode, ErrorCallback<String> callback) {
}
@Override
public void queryPreset(CommonGBChannel channel, ErrorCallback<List<Preset>> callback) {
}
}

View File

@@ -173,7 +173,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
}));
break;
case FI:
channelControlService.fi(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> {
channelControlService.fi(channel, (FrontEndControlCodeForFI) frontEndControlCode, ((code, msg, data) -> {
try {
responseAck(request, code, msg);
} catch (InvalidArgumentException | SipException | ParseException exception) {
@@ -182,7 +182,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
}));
break;
case PRESET:
channelControlService.preset(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> {
channelControlService.preset(channel, (FrontEndControlCodeForPreset) frontEndControlCode, ((code, msg, data) -> {
try {
responseAck(request, code, msg);
} catch (InvalidArgumentException | SipException | ParseException exception) {
@@ -191,7 +191,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
}));
break;
case TOUR:
channelControlService.tour(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> {
channelControlService.tour(channel, (FrontEndControlCodeForTour) frontEndControlCode, ((code, msg, data) -> {
try {
responseAck(request, code, msg);
} catch (InvalidArgumentException | SipException | ParseException exception) {
@@ -200,7 +200,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
}));
break;
case SCAN:
channelControlService.scan(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> {
channelControlService.scan(channel, (FrontEndControlCodeForScan) frontEndControlCode, ((code, msg, data) -> {
try {
responseAck(request, code, msg);
} catch (InvalidArgumentException | SipException | ParseException exception) {
@@ -209,7 +209,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
}));
break;
case AUXILIARY:
channelControlService.auxiliary(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> {
channelControlService.auxiliary(channel, (FrontEndControlCodeForAuxiliary) frontEndControlCode, ((code, msg, data) -> {
try {
responseAck(request, code, msg);
} catch (InvalidArgumentException | SipException | ParseException exception) {