From 8a2dc6031e3f08d47514b202461d49faa53b5641 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Sun, 7 Apr 2024 22:06:41 +0800 Subject: [PATCH] =?UTF-8?q?1078-=E5=AE=9E=E7=8E=B0=E4=BA=91=E5=8F=B0?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/jt1078/config/JT1078Controller.java | 43 +++++--- .../vmp/jt1078/service/Ijt1078Service.java | 6 ++ .../service/impl/jt1078ServiceImpl.java | 97 +++++++++++++++++++ 3 files changed, 132 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/config/JT1078Controller.java b/src/main/java/com/genersoft/iot/vmp/jt1078/config/JT1078Controller.java index 88466c89e..c65c83e7a 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/config/JT1078Controller.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/config/JT1078Controller.java @@ -32,13 +32,7 @@ import java.net.URL; import java.text.ParseException; import java.util.List; -/** - * curl http://localhost:18080/api/jt1078/start/live/18864197066/1 - * - * @author QingtaiJiang - * @date 2023/4/27 18:12 - * @email qingtaij@163.com - */ + @ConditionalOnProperty(value = "jt1078.enable", havingValue = "true") @RestController @RequestMapping("/api/jt1078") @@ -278,13 +272,6 @@ public class JT1078Controller { service.deleteDeviceByDeviceId(deviceId); } - /*** - * 云台控制 - * @param deviceId 设备id - * @param channelId 通道id - * @param command 控制指令 - */ - @Operation(summary = "云台控制", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true) @@ -300,5 +287,33 @@ public class JT1078Controller { service.ptzControl(deviceId, channelId, command, speed); } + @Operation(summary = "补光灯开关", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "deviceId", description = "设备国标编号", required = true) + @Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true) + @Parameter(name = "command", description = "控制指令,允许值: on off", required = true) + @PostMapping("/fill-light") + public void fillLight(String deviceId, String channelId, String command){ + + if (ObjectUtils.isEmpty(channelId)) { + channelId = "1"; + } + logger.info("[1078-补光灯开关] deviceId:{}, channelId:{}, command: {}", deviceId, channelId, command); + service.supplementaryLight(deviceId, channelId, command); + } + + @Operation(summary = "雨刷开关", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "deviceId", description = "设备国标编号", required = true) + @Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true) + @Parameter(name = "command", description = "控制指令,允许值: on off", required = true) + @PostMapping("/wiper") + public void wiper(String deviceId, String channelId, String command){ + + if (ObjectUtils.isEmpty(channelId)) { + channelId = "1"; + } + logger.info("[1078-雨刷开关] deviceId:{}, channelId:{}, command: {}", deviceId, channelId, command); + service.wiper(deviceId, channelId, command); + } + } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/service/Ijt1078Service.java b/src/main/java/com/genersoft/iot/vmp/jt1078/service/Ijt1078Service.java index 3ac24c7e7..55d0574a3 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/service/Ijt1078Service.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/service/Ijt1078Service.java @@ -34,4 +34,10 @@ public interface Ijt1078Service { List getRecordList(String deviceId, String channelId, String startTime, String endTime); void stopPlayback(String deviceId, String channelId); + + void ptzControl(String deviceId, String channelId, String command, int speed); + + void supplementaryLight(String deviceId, String channelId, String command); + + void wiper(String deviceId, String channelId, String command); } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java index ef483060d..cc391783d 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/service/impl/jt1078ServiceImpl.java @@ -391,4 +391,101 @@ public class jt1078ServiceImpl implements Ijt1078Service { } } + @Override + public void ptzControl(String deviceId, String channelId, String command, int speed) { + // 发送停止命令 + + switch (command) { + case "left": + case "right": + case "up": + case "down": + case "stop": + J9301 j9301 = new J9301(); + j9301.setChannel(Integer.parseInt(channelId)); + switch (command) { + case "left": + j9301.setDirection(3); + j9301.setSpeed(speed); + break; + case "right": + j9301.setDirection(4); + j9301.setSpeed(speed); + break; + case "up": + j9301.setDirection(1); + j9301.setSpeed(speed); + break; + case "down": + j9301.setDirection(2); + j9301.setSpeed(speed); + break; + case "stop": + j9301.setDirection(0); + j9301.setSpeed(0); + break; + } + jt1078Template.ptzRotate(deviceId, j9301, 6); + break; + + case "zoomin": + case "zoomout": + J9306 j9306 = new J9306(); + j9306.setChannel(Integer.parseInt(channelId)); + if (command.equals("zoomin")) { + j9306.setZoom(0); + }else { + j9306.setZoom(1); + } + jt1078Template.ptzZoom(deviceId, j9306, 6); + break; + case "irisin": + case "irisout": + J9303 j9303 = new J9303(); + j9303.setChannel(Integer.parseInt(channelId)); + if (command.equals("irisin")) { + j9303.setIris(0); + }else { + j9303.setIris(1); + } + jt1078Template.ptzIris(deviceId, j9303, 6); + break; + case "focusnear": + case "focusfar": + J9302 j9302 = new J9302(); + j9302.setChannel(Integer.parseInt(channelId)); + if (command.equals("focusfar")) { + j9302.setFocalDirection(0); + }else { + j9302.setFocalDirection(1); + } + jt1078Template.ptzFocal(deviceId, j9302, 6); + break; + + } + } + + @Override + public void supplementaryLight(String deviceId, String channelId, String command) { + J9305 j9305 = new J9305(); + j9305.setChannel(Integer.parseInt(channelId)); + if (command.equalsIgnoreCase("on")) { + j9305.setOn(1); + }else { + j9305.setOn(0); + } + jt1078Template.ptzSupplementaryLight(deviceId, j9305, 6); + } + + @Override + public void wiper(String deviceId, String channelId, String command) { + J9304 j9304 = new J9304(); + j9304.setChannel(Integer.parseInt(channelId)); + if (command.equalsIgnoreCase("on")) { + j9304.setOn(1); + }else { + j9304.setOn(0); + } + jt1078Template.ptzWiper(deviceId, j9304, 6); + } }