|
@@ -273,6 +273,172 @@ public class RealTimePreviewVideoController {
|
|
|
}
|
|
}
|
|
|
return Result.error("请求失败");
|
|
return Result.error("请求失败");
|
|
|
}
|
|
}
|
|
|
|
|
+ @ApiOperation(value = "云台镜头控制",notes = "控制云台镜头的变焦、变倍及光圈大小\n" +
|
|
|
|
|
+ "命令command=1时,云台会开启动作,不调command=0会一直转动\n" +
|
|
|
|
|
+ "异步发送操作指令到设备端,需开启动作与停止动作间隔一定时间,保证顺序执行\n" +
|
|
|
|
|
+ "不推荐多用户同时操作同一个设备,多用户操作以最后一次操作为准")
|
|
|
|
|
+ @PostMapping("/getOperateCamera")
|
|
|
|
|
+ public Result getOperateCamera(CameraControlRequest request){
|
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
+ String jsonParams = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ jsonParams = objectMapper.writeValueAsString(request);
|
|
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
|
|
+ log.error("JSON序列化失败: {}", e);
|
|
|
|
|
+ return Result.error("请求失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ String authorization = redisTemplate
|
|
|
|
|
+ .opsForValue()
|
|
|
|
|
+ .get("Authorization:" + iccConfigProperty.getUsername());
|
|
|
|
|
+ // 创建请求体
|
|
|
|
|
+ RequestBody body = RequestBody.create(jsonParams, JSON);
|
|
|
|
|
+ // 构建请求
|
|
|
|
|
+ Request requestHttp = new Request.Builder()
|
|
|
|
|
+ .url("https://" + iccConfigProperty.getHost() + "/evo-apigw/admin/API/DMS/Ptz/OperateCamera")
|
|
|
|
|
+ .addHeader("Authorization", authorization)
|
|
|
|
|
+ .post(body)
|
|
|
|
|
+ .build();
|
|
|
|
|
+ // 发送请求
|
|
|
|
|
+ try (Response response = httpClient.newCall(requestHttp).execute()) {
|
|
|
|
|
+ if (!response.isSuccessful()) {
|
|
|
|
|
+ return Result.error("请求失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ ResponseBody responseBody = response.body();
|
|
|
|
|
+ if (responseBody != null) {
|
|
|
|
|
+ String responseString = responseBody.string();
|
|
|
|
|
+ JsonNode rootNode = objectMapper.readTree(responseString);
|
|
|
|
|
+ JsonNode success = rootNode.path("success");
|
|
|
|
|
+ if("true".equals(success.asText())) {
|
|
|
|
|
+ JsonNode dataNode = rootNode.path("data");
|
|
|
|
|
+ if (dataNode != null) {
|
|
|
|
|
+ return Result.ok(dataNode);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return Result.ok(null);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ JsonNode code = rootNode.path("code");
|
|
|
|
|
+ if("1001".equals(code.asText())){
|
|
|
|
|
+ return Result.error("返回失败");
|
|
|
|
|
+ }else {
|
|
|
|
|
+ return Result.error("云台镜头控制失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ log.error("请求失败: {}", e);
|
|
|
|
|
+ }
|
|
|
|
|
+ return Result.error("请求失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ @ApiOperation(value = "云台镜头控制",notes = "控制云台进行上下左右等八个方向的移动 命令command=1时,云台会开启动作,不调command=0会一直转动\n" +
|
|
|
|
|
+ "异步发送操作指令到设备端,需开启动作与停止动作间隔一定时间,保证顺序执行\n" +
|
|
|
|
|
+ "不推荐多用户同时操作同一个设备,多用户操作以最后一次操作为准")
|
|
|
|
|
+ @PostMapping("/getOperateDirect")
|
|
|
|
|
+ public Result getOperateDirect(OperateDirectRequest request){
|
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
+ String jsonParams = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ jsonParams = objectMapper.writeValueAsString(request);
|
|
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
|
|
+ log.error("JSON序列化失败: {}", e);
|
|
|
|
|
+ return Result.error("请求失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ String authorization = redisTemplate
|
|
|
|
|
+ .opsForValue()
|
|
|
|
|
+ .get("Authorization:" + iccConfigProperty.getUsername());
|
|
|
|
|
+ // 创建请求体
|
|
|
|
|
+ RequestBody body = RequestBody.create(jsonParams, JSON);
|
|
|
|
|
+ // 构建请求
|
|
|
|
|
+ Request requestHttp = new Request.Builder()
|
|
|
|
|
+ .url("https://" + iccConfigProperty.getHost() + "/evo-apigw/admin/API/DMS/Ptz/OperateDirect")
|
|
|
|
|
+ .addHeader("Authorization", authorization)
|
|
|
|
|
+ .post(body)
|
|
|
|
|
+ .build();
|
|
|
|
|
+ // 发送请求
|
|
|
|
|
+ try (Response response = httpClient.newCall(requestHttp).execute()) {
|
|
|
|
|
+ if (!response.isSuccessful()) {
|
|
|
|
|
+ return Result.error("请求失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ ResponseBody responseBody = response.body();
|
|
|
|
|
+ if (responseBody != null) {
|
|
|
|
|
+ String responseString = responseBody.string();
|
|
|
|
|
+ JsonNode rootNode = objectMapper.readTree(responseString);
|
|
|
|
|
+ JsonNode success = rootNode.path("success");
|
|
|
|
|
+ if("true".equals(success.asText())) {
|
|
|
|
|
+ JsonNode dataNode = rootNode.path("data");
|
|
|
|
|
+ if (dataNode != null) {
|
|
|
|
|
+ return Result.ok(dataNode);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return Result.ok(null);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ JsonNode code = rootNode.path("code");
|
|
|
|
|
+ if("1001".equals(code.asText())){
|
|
|
|
|
+ return Result.error("返回失败");
|
|
|
|
|
+ }else {
|
|
|
|
|
+ return Result.error("云台方向控制失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ log.error("请求失败: {}", e);
|
|
|
|
|
+ }
|
|
|
|
|
+ return Result.error("请求失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ @ApiOperation(value = "云台功能控制",notes = "控制云台的巡航、循迹及灯光等功能 命令command=1时,云台会开启动作,不调command=0会一直转动\n" +
|
|
|
|
|
+ "异步发送操作指令到设备端,需开启动作与停止动作间隔一定时间,保证顺序执行\n" +
|
|
|
|
|
+ "不推荐多用户同时操作同一个设备,多用户操作以最后一次操作为准")
|
|
|
|
|
+ @PostMapping("/getOperateFunction")
|
|
|
|
|
+ public Result getOperateFunction(OperateDirectRequest request){
|
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
+ String jsonParams = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ jsonParams = objectMapper.writeValueAsString(request);
|
|
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
|
|
+ log.error("JSON序列化失败: {}", e);
|
|
|
|
|
+ return Result.error("请求失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ String authorization = redisTemplate
|
|
|
|
|
+ .opsForValue()
|
|
|
|
|
+ .get("Authorization:" + iccConfigProperty.getUsername());
|
|
|
|
|
+ // 创建请求体
|
|
|
|
|
+ RequestBody body = RequestBody.create(jsonParams, JSON);
|
|
|
|
|
+ // 构建请求
|
|
|
|
|
+ Request requestHttp = new Request.Builder()
|
|
|
|
|
+ .url("https://" + iccConfigProperty.getHost() + "/evo-apigw/admin/API/DMS/Ptz/OperateFunction")
|
|
|
|
|
+ .addHeader("Authorization", authorization)
|
|
|
|
|
+ .post(body)
|
|
|
|
|
+ .build();
|
|
|
|
|
+ // 发送请求
|
|
|
|
|
+ try (Response response = httpClient.newCall(requestHttp).execute()) {
|
|
|
|
|
+ if (!response.isSuccessful()) {
|
|
|
|
|
+ return Result.error("请求失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ ResponseBody responseBody = response.body();
|
|
|
|
|
+ if (responseBody != null) {
|
|
|
|
|
+ String responseString = responseBody.string();
|
|
|
|
|
+ JsonNode rootNode = objectMapper.readTree(responseString);
|
|
|
|
|
+ JsonNode success = rootNode.path("success");
|
|
|
|
|
+ if("true".equals(success.asText())) {
|
|
|
|
|
+ JsonNode dataNode = rootNode.path("data");
|
|
|
|
|
+ if (dataNode != null) {
|
|
|
|
|
+ return Result.ok(dataNode);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return Result.ok(null);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ JsonNode code = rootNode.path("code");
|
|
|
|
|
+ if("1001".equals(code.asText())){
|
|
|
|
|
+ return Result.error("返回失败");
|
|
|
|
|
+ }else {
|
|
|
|
|
+ return Result.error("云台功能控制失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ log.error("请求失败: {}", e);
|
|
|
|
|
+ }
|
|
|
|
|
+ return Result.error("请求失败");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
public String DateToTimeStamp(String dateTimeString){
|
|
public String DateToTimeStamp(String dateTimeString){
|
|
|
// 定义日期格式
|
|
// 定义日期格式
|