From 96145842195fa9e886dceb895f75539968d02888 Mon Sep 17 00:00:00 2001 From: lin <648540858@qq.com> Date: Thu, 31 Jul 2025 19:05:07 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=94=A8=E9=80=9A=E9=81=93=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E9=A2=84=E7=BD=AE=E4=BD=8D=E8=B0=83=E7=94=A8=EF=BC=8C?= =?UTF-8?q?=E5=88=A0=E9=99=A4=EF=BC=8C=20=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ChannelFrontEndController.java | 4 -- .../impl/SourcePTZServiceForGbImpl.java | 42 +++++-------------- web/src/api/commonChannel.js | 5 ++- .../views/common/channelPlayer/ptzPreset.vue | 18 ++++++-- 4 files changed, 27 insertions(+), 42 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/ChannelFrontEndController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/ChannelFrontEndController.java index e3ff2aa29..564a6f9b2 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/ChannelFrontEndController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/ChannelFrontEndController.java @@ -184,7 +184,6 @@ public class ChannelFrontEndController { } @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) @@ -237,7 +236,6 @@ public class ChannelFrontEndController { } @Operation(summary = "查询预置位", security = @SecurityRequirement(name = JwtUtils.HEADER)) - @Parameter(name = "channelId", description = "通道国标编号", required = true) @GetMapping("/preset/query") public DeferredResult>> queryPreset(Integer channelId) { @@ -298,7 +296,6 @@ public class ChannelFrontEndController { @Parameter(name = "presetName", description = "预置位名称", required = true) @GetMapping("/preset/add") public DeferredResult> addPreset(Integer channelId, Integer presetId, String presetName) { - FrontEndControlCodeForPreset controlCode = new FrontEndControlCodeForPreset(); controlCode.setCode(1); controlCode.setPresetId(presetId); @@ -308,7 +305,6 @@ public class ChannelFrontEndController { } @Operation(summary = "预置位指令-调用预置位", security = @SecurityRequirement(name = JwtUtils.HEADER)) - @Parameter(name = "channelId", description = "通道国标编号", required = true) @Parameter(name = "presetId", description = "预置位编号(1-100)", required = true) @GetMapping("/preset/call") diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/SourcePTZServiceForGbImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/SourcePTZServiceForGbImpl.java index f355c2067..179c5be5c 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/SourcePTZServiceForGbImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/SourcePTZServiceForGbImpl.java @@ -1,7 +1,6 @@ package com.genersoft.iot.vmp.gb28181.service.impl; import com.genersoft.iot.vmp.common.enums.ChannelDataType; -import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.service.IPTZService; import com.genersoft.iot.vmp.gb28181.service.ISourcePTZService; @@ -20,26 +19,6 @@ public class SourcePTZServiceForGbImpl implements ISourcePTZService { @Autowired private IPTZService ptzService; - public void frontEndCommand(CommonGBChannel channel, Integer cmdCode, Integer parameter1, Integer parameter2, Integer combindCode2){ - - if (parameter1 == null || parameter1 < 0 || parameter1 > 100) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "parameter1 为 0-255的数字"); - } - // 返回转换为国标定义的范围 - parameter1 = (int)(parameter1/100D* 255); - if (parameter2 == null || parameter2 < 0 || parameter2 > 100) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "parameter2 为 0-255的数字"); - } - // 返回转换为国标定义的范围 - parameter2 = (int)(parameter2/100D* 255); - if (combindCode2 == null || combindCode2 < 0 || combindCode2 > 100) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "combindCode2 为 0-15的数字"); - } - combindCode2 = (int)(combindCode2/100D* 16); - ptzService.frontEndCommand(channel, cmdCode, parameter1, parameter2, combindCode2); - } - - @Override public void ptz(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback callback) { try { @@ -70,11 +49,11 @@ public class SourcePTZServiceForGbImpl implements ISourcePTZService { cmdCode = cmdCode | 1 << 4; } } - panSpeed = frontEndControlCode.getPanSpeed(); - titleSpeed = frontEndControlCode.getTiltSpeed(); - zoomSpeed = frontEndControlCode.getZoomSpeed(); + panSpeed = (int)(frontEndControlCode.getPanSpeed()/100D* 255); + titleSpeed = (int)(frontEndControlCode.getTiltSpeed()/100D* 255);; + zoomSpeed = (int)(frontEndControlCode.getZoomSpeed()/100D* 16); } - frontEndCommand(channel, cmdCode, panSpeed, titleSpeed, zoomSpeed); + ptzService.frontEndCommand(channel, cmdCode, panSpeed, titleSpeed, zoomSpeed); callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), null); }catch (Exception e) { log.error("[云台控制失败] ", e); @@ -102,9 +81,8 @@ public class SourcePTZServiceForGbImpl implements ISourcePTZService { if (frontEndControlCode.getPresetId() != null) { parameter2 = frontEndControlCode.getPresetId(); } - } - frontEndCommand(channel, cmdCode, parameter1, parameter2, parameter3); + ptzService.frontEndCommand(channel, cmdCode, parameter1, parameter2, parameter3); callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), null); }catch (Exception e) { log.error("[预置位控制失败] ", e); @@ -147,7 +125,7 @@ public class SourcePTZServiceForGbImpl implements ISourcePTZService { irisSpeed = frontEndControlCode.getIrisSpeed(); } } - frontEndCommand(channel, cmdCode, focusSpeed, irisSpeed, parameter3); + ptzService.frontEndCommand(channel, cmdCode, focusSpeed, irisSpeed, parameter3); callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), null); }catch (Exception e) { log.error("[云台控制失败] ", e); @@ -187,7 +165,7 @@ public class SourcePTZServiceForGbImpl implements ISourcePTZService { } } - frontEndCommand(channel, cmdCode, parameter1, parameter2, parameter3); + ptzService.frontEndCommand(channel, cmdCode, parameter1, parameter2, parameter3); callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), null); }catch (Exception e) { log.error("[巡航控制失败] ", e); @@ -226,7 +204,7 @@ public class SourcePTZServiceForGbImpl implements ISourcePTZService { } } } - frontEndCommand(channel, cmdCode, parameter1, parameter2, parameter3); + ptzService.frontEndCommand(channel, cmdCode, parameter1, parameter2, parameter3); callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), null); }catch (Exception e) { log.error("[巡航控制失败] ", e); @@ -255,7 +233,7 @@ public class SourcePTZServiceForGbImpl implements ISourcePTZService { } } } - frontEndCommand(channel, cmdCode, parameter1, parameter2, parameter3); + ptzService.frontEndCommand(channel, cmdCode, parameter1, parameter2, parameter3); callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), null); }catch (Exception e) { log.error("[辅助开关失败] ", e); @@ -282,7 +260,7 @@ public class SourcePTZServiceForGbImpl implements ISourcePTZService { } } } - frontEndCommand(channel, cmdCode, parameter1, parameter2, parameter3); + ptzService.frontEndCommand(channel, cmdCode, parameter1, parameter2, parameter3); callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), null); }catch (Exception e) { log.error("[雨刷开关失败] ", e); diff --git a/web/src/api/commonChannel.js b/web/src/api/commonChannel.js index ff32d17db..5f9cdb103 100644 --- a/web/src/api/commonChannel.js +++ b/web/src/api/commonChannel.js @@ -402,13 +402,14 @@ export function stopCruise({ channelId, cruiseId }) { }) } -export function addPreset({ channelId, presetId }) { +export function addPreset({ channelId, presetId, presetName }) { return request({ method: 'get', url: '/api/common/channel/front-end/preset/add', params: { channelId: channelId, - presetId: presetId + presetId: presetId, + presetName: presetName } }) } diff --git a/web/src/views/common/channelPlayer/ptzPreset.vue b/web/src/views/common/channelPlayer/ptzPreset.vue index 08851ef39..ca4e0dd81 100644 --- a/web/src/views/common/channelPlayer/ptzPreset.vue +++ b/web/src/views/common/channelPlayer/ptzPreset.vue @@ -50,7 +50,7 @@ export default { }, methods: { getPresetList: function() { - this.$store.dispatch('commonChanel/queryPreset', [this.channelId]) + this.$store.dispatch('commonChanel/queryPreset', this.channelId) .then(data => { this.presetList = data // 防止出现表格错位 @@ -73,7 +73,11 @@ export default { spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }) - this.$store.dispatch('commonChanel/addPreset', [this.channelId, this.ptzPresetId]) + this.$store.dispatch('commonChanel/addPreset', { + channelId: this.channelId, + presetId: this.ptzPresetId, + presetName: this.ptzPresetId + }) .then(data => { setTimeout(() => { this.inputVisible = false @@ -99,7 +103,10 @@ export default { }, gotoPreset: function(preset) { console.log(preset) - this.$store.dispatch('commonChanel/callPreset', [this.channelId, preset.presetId]) + this.$store.dispatch('commonChanel/callPreset', { + channelId: this.channelId, + presetId: preset.presetId + }) .then(data => { this.$message({ showClose: true, @@ -128,7 +135,10 @@ export default { spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }) - this.$store.dispatch('commonChanel/deletePreset', [this.channelId, preset.presetId]) + this.$store.dispatch('commonChanel/deletePreset', { + channelId: this.channelId, + presetId: preset.presetId + }) .then(data => { setTimeout(() => { this.getPresetList()