From 0fc0cd6e418ef7808e22716dbf14ff12e1d73ea5 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 2 May 2024 06:25:09 +0800 Subject: [PATCH] =?UTF-8?q?1078-=E4=BC=98=E5=8C=96=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/conf/SpringDocConfig.java | 10 +++++- .../vmp/jt1078/bean/JTPhoneBookContact.java | 4 +-- .../jt1078/controller/JT1078Controller.java | 36 ++++++++++--------- .../controller/bean/SetPhoneBookParam.java | 2 +- .../iot/vmp/jt1078/proc/response/J8103.java | 2 +- .../iot/vmp/jt1078/proc/response/J8401.java | 10 ++++-- .../iot/vmp/jt1078/proc/response/J9101.java | 2 +- .../iot/vmp/jt1078/proc/response/J9201.java | 6 ++-- .../iot/vmp/jt1078/proc/response/J9206.java | 18 +++++----- .../service/impl/jt1078ServiceImpl.java | 4 ++- 10 files changed, 57 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java index 0a472f826..8128c8cdd 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/SpringDocConfig.java @@ -48,7 +48,7 @@ public class SpringDocConfig { public GroupedOpenApi publicApi() { return GroupedOpenApi.builder() .group("1. 全部") - .packagesToScan("com.genersoft.iot.vmp.vmanager") + .packagesToScan("com.genersoft.iot.vmp.vmanager", "com.genersoft.iot.vmp.jt1078.controller") .build(); } @@ -91,4 +91,12 @@ public class SpringDocConfig { .packagesToScan("com.genersoft.iot.vmp.vmanager.user") .build(); } + + @Bean + public GroupedOpenApi publicApi7() { + return GroupedOpenApi.builder() + .group("6. 部标设备") + .packagesToScan("com.genersoft.iot.vmp.jt1078.controller") + .build(); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPhoneBookContact.java b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPhoneBookContact.java index 7b606d820..7bfad559c 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPhoneBookContact.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/bean/JTPhoneBookContact.java @@ -21,9 +21,9 @@ public class JTPhoneBookContact { public ByteBuf encode(){ ByteBuf buffer = Unpooled.buffer(); buffer.writeByte(sign); - buffer.writeByte(phoneNumber.getBytes().length); + buffer.writeByte(phoneNumber.getBytes(Charset.forName("GBK")).length); buffer.writeCharSequence(phoneNumber, Charset.forName("GBK")); - buffer.writeByte(contactName.getBytes().length); + buffer.writeByte(contactName.getBytes(Charset.forName("GBK")).length); buffer.writeCharSequence(contactName, Charset.forName("GBK")); return buffer; } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/controller/JT1078Controller.java b/src/main/java/com/genersoft/iot/vmp/jt1078/controller/JT1078Controller.java index f0fbd3123..d5c74c6a0 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/controller/JT1078Controller.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/controller/JT1078Controller.java @@ -17,6 +17,7 @@ import com.github.pagehelper.PageInfo; 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 org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -34,6 +35,7 @@ import java.util.List; @ConditionalOnProperty(value = "jt1078.enable", havingValue = "true") @RestController +@Tag(name = "部标设备") @RequestMapping("/api/jt1078") public class JT1078Controller { @@ -233,7 +235,7 @@ public class JT1078Controller { service.stopPlayback(deviceId, channelId); } - @Operation(summary = "分页查询部标设备", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "1078-分页查询部标设备", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "page", description = "当前页", required = true) @Parameter(name = "count", description = "每页查询数量", required = true) @Parameter(name = "query", description = "查询内容") @@ -256,7 +258,7 @@ public class JT1078Controller { - @Operation(summary = "新增设备", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "1078-新增设备", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "device", description = "设备", required = true) @PostMapping("/device/add") public void addDevice(JTDevice device){ @@ -271,7 +273,7 @@ public class JT1078Controller { service.deleteDeviceByDeviceId(deviceId); } - @Operation(summary = "云台控制", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "1078-云台控制", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "channelId", description = "通道国标编号, 一般为从1开始的数字", required = true) @Parameter(name = "command", description = "控制指令,允许值: left, right, up, down, zoomin, zoomout, irisin, irisout, focusnear, focusfar, stop", required = true) @@ -286,7 +288,7 @@ public class JT1078Controller { service.ptzControl(deviceId, channelId, command, speed); } - @Operation(summary = "补光灯开关", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "1078-补光灯开关", 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) @@ -300,7 +302,7 @@ public class JT1078Controller { service.supplementaryLight(deviceId, channelId, command); } - @Operation(summary = "雨刷开关", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "1078-雨刷开关", 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) @@ -314,7 +316,7 @@ public class JT1078Controller { service.wiper(deviceId, channelId, command); } - @Operation(summary = "查询终端参数", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "1078-查询终端参数", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备国标编号", required = true) @GetMapping("/config") public JTDeviceConfig config(String deviceId, String[] params){ @@ -323,7 +325,7 @@ public class JT1078Controller { return service.queryConfig(deviceId, params, null); } - @Operation(summary = "设置终端参数", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "1078-设置终端参数", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备编号", required = true) @Parameter(name = "config", description = "终端参数", required = true) @PostMapping("/set-config") @@ -342,7 +344,7 @@ public class JT1078Controller { service.connectionControl(control.getDeviceId(), control.getControl()); } - @Operation(summary = "终端控制-复位", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "1078-终端控制-复位", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备编号", required = true) @PostMapping("/control/reset") public void resetControl(String deviceId){ @@ -351,7 +353,7 @@ public class JT1078Controller { service.resetControl(deviceId); } - @Operation(summary = "终端控制-恢复出厂设置", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "1078-终端控制-恢复出厂设置", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备编号", required = true) @PostMapping("/control/factory-reset") public void factoryResetControl(String deviceId){ @@ -360,7 +362,7 @@ public class JT1078Controller { service.factoryResetControl(deviceId); } - @Operation(summary = "查询终端属性", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "1078-查询终端属性", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备编号", required = true) @GetMapping("/attribute") public JTDeviceAttribute attribute(String deviceId){ @@ -369,7 +371,7 @@ public class JT1078Controller { return service.attribute(deviceId); } - @Operation(summary = "查询位置信息", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "1078-查询位置信息", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备编号", required = true) @GetMapping("/position-info") public JTPositionBaseInfo queryPositionInfo(String deviceId){ @@ -378,7 +380,7 @@ public class JT1078Controller { return service.queryPositionInfo(deviceId); } - @Operation(summary = "临时位置跟踪控制", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "1078-临时位置跟踪控制", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备编号", required = true) @Parameter(name = "timeInterval", description = "时间间隔,单位为秒,时间间隔为0 时停止跟踪,停止跟踪无需带后继字段", required = true) @Parameter(name = "validityPeriod", description = "位置跟踪有效期, 单位为秒,终端在接收到位置跟踪控制消息后,在有效期截止时间之前依据消息中的时间间隔发送位置汇报", required = true) @@ -389,7 +391,7 @@ public class JT1078Controller { service.tempPositionTrackingControl(deviceId, timeInterval, validityPeriod); } - @Operation(summary = "人工确认报警消息", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "1078-人工确认报警消息", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备编号", required = true) @Parameter(name = "timeInterval", description = "时间间隔,单位为秒,时间间隔为0 时停止跟踪,停止跟踪无需带后继字段", required = true) @Parameter(name = "validityPeriod", description = "位置跟踪有效期, 单位为秒,终端在接收到位置跟踪控制消息后,在有效期截止时间之前依据消息中的时间间隔发送位置汇报", required = true) @@ -400,7 +402,7 @@ public class JT1078Controller { service.confirmationAlarmMessage(param.getDeviceId(), param.getAlarmPackageNo(), param.getAlarmMessageType()); } - @Operation(summary = "链路检测", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "1078-链路检测", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备编号", required = true) @GetMapping("/link-detection") public WVPResult linkDetection(String deviceId){ @@ -416,7 +418,7 @@ public class JT1078Controller { } } - @Operation(summary = "文本信息下发", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "1078-文本信息下发", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "textMessageParam", description = "文本信息下发参数", required = true) @PostMapping("/text-msg") public WVPResult textMessage(@RequestBody TextMessageParam textMessageParam){ @@ -432,7 +434,7 @@ public class JT1078Controller { } } - @Operation(summary = "电话回拨", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "1078-电话回拨", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备编号", required = true) @Parameter(name = "sign", description = "标志: 0:普通通话,1:监听", required = true) @Parameter(name = "phoneNumber", description = "电话号码", required = true) @@ -450,7 +452,7 @@ public class JT1078Controller { } } - @Operation(summary = "设置电话本", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Operation(summary = "1078-设置电话本", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "setPhoneBookParam", description = "设置电话本参数", required = true) @PostMapping("/set-phone-book") public WVPResult setPhoneBook(@RequestBody SetPhoneBookParam setPhoneBookParam){ diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/controller/bean/SetPhoneBookParam.java b/src/main/java/com/genersoft/iot/vmp/jt1078/controller/bean/SetPhoneBookParam.java index fb8d361cf..3ededc0c5 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/controller/bean/SetPhoneBookParam.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/controller/bean/SetPhoneBookParam.java @@ -14,7 +14,7 @@ public class SetPhoneBookParam { @Schema(description = "设置类型:\n" + "0: 删除终端上所有存储的联系人,\n" + - "1: 表示更新电话本$ 删除终端中已有全部联系人并追加消 息中的联系人,\n" + + "1: 表示更新电话本, 删除终端中已有全部联系人并追加消息中的联系人,\n" + "2: 表示追加电话本,\n" + "3: 表示修改电话本$以联系人为索引") private int type; diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8103.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8103.java index 3ed463ecb..33e72e50b 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8103.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8103.java @@ -69,7 +69,7 @@ public class J8103 extends Rs { case "String": field.setAccessible(true); String stringVal = (String)field.get(config); - buffer.writeByte(stringVal.getBytes().length); + buffer.writeByte(stringVal.getBytes(Charset.forName("GBK")).length); buffer.writeCharSequence(stringVal, Charset.forName("GBK")); continue; case "Integer": diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8401.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8401.java index 010a101a1..31a356283 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8401.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J8401.java @@ -32,9 +32,13 @@ public class J8401 extends Rs { public ByteBuf encode() { ByteBuf buffer = Unpooled.buffer(); buffer.writeByte(type); - buffer.writeByte(phoneBookContactList.size()); - for (JTPhoneBookContact jtPhoneBookContact : phoneBookContactList) { - buffer.writeBytes(jtPhoneBookContact.encode()); + if (phoneBookContactList != null && !phoneBookContactList.isEmpty()) { + buffer.writeByte(phoneBookContactList.size()); + for (JTPhoneBookContact jtPhoneBookContact : phoneBookContactList) { + buffer.writeBytes(jtPhoneBookContact.encode()); + } + }else { + buffer.writeByte(0); } return buffer; } diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9101.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9101.java index 203cb09ff..07b055569 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9101.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9101.java @@ -42,7 +42,7 @@ public class J9101 extends Rs { @Override public ByteBuf encode() { ByteBuf buffer = Unpooled.buffer(); - buffer.writeByte(ip.getBytes().length); + buffer.writeByte(ip.getBytes(Charset.forName("GBK")).length); buffer.writeCharSequence(ip, Charset.forName("GBK")); buffer.writeShort(tcpPort); buffer.writeShort(udpPort); diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9201.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9201.java index 8a66f3544..9a5835036 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9201.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9201.java @@ -6,6 +6,8 @@ import io.netty.buffer.ByteBufUtil; import io.netty.buffer.Unpooled; import io.netty.util.CharsetUtil; +import java.nio.charset.Charset; + /** * 回放请求 * @@ -51,8 +53,8 @@ public class J9201 extends Rs { @Override public ByteBuf encode() { ByteBuf buffer = Unpooled.buffer(); - buffer.writeByte(ip.getBytes().length); - buffer.writeCharSequence(ip, CharsetUtil.UTF_8); + buffer.writeByte(ip.getBytes(Charset.forName("GBK")).length); + buffer.writeCharSequence(ip, Charset.forName("GBK")); buffer.writeShort(tcpPort); buffer.writeShort(udpPort); buffer.writeByte(channel); diff --git a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9206.java b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9206.java index f00f25b24..060f81657 100644 --- a/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9206.java +++ b/src/main/java/com/genersoft/iot/vmp/jt1078/proc/response/J9206.java @@ -6,6 +6,8 @@ import io.netty.buffer.ByteBufUtil; import io.netty.buffer.Unpooled; import io.netty.util.CharsetUtil; +import java.nio.charset.Charset; + /** * 文件上传指令 * @@ -58,15 +60,15 @@ public class J9206 extends Rs { public ByteBuf encode() { ByteBuf buffer = Unpooled.buffer(); - buffer.writeByte(serverIp.getBytes().length); - buffer.writeCharSequence(serverIp, CharsetUtil.UTF_8); + buffer.writeByte(serverIp.getBytes(Charset.forName("GBK")).length); + buffer.writeCharSequence(serverIp, Charset.forName("GBK")); buffer.writeByte(port); - buffer.writeByte(user.getBytes().length); - buffer.writeCharSequence(user, CharsetUtil.UTF_8); - buffer.writeByte(password.getBytes().length); - buffer.writeCharSequence(password, CharsetUtil.UTF_8); - buffer.writeByte(path.getBytes().length); - buffer.writeCharSequence(path, CharsetUtil.UTF_8); + buffer.writeByte(user.getBytes(Charset.forName("GBK")).length); + buffer.writeCharSequence(user, Charset.forName("GBK")); + buffer.writeByte(password.getBytes(Charset.forName("GBK")).length); + buffer.writeCharSequence(password, Charset.forName("GBK")); + buffer.writeByte(path.getBytes(Charset.forName("GBK")).length); + buffer.writeCharSequence(path, Charset.forName("GBK")); buffer.writeByte(channelId); buffer.writeBytes(ByteBufUtil.decodeHexDump(startTime)); buffer.writeBytes(ByteBufUtil.decodeHexDump(endTime)); 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 efed1edb8..553af8b2c 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 @@ -595,7 +595,9 @@ public class jt1078ServiceImpl implements Ijt1078Service { public int setPhoneBook(String deviceId, int type, List phoneBookContactList) { J8401 j8401 = new J8401(); j8401.setType(type); - j8401.setPhoneBookContactList(phoneBookContactList); + if (phoneBookContactList != null) { + j8401.setPhoneBookContactList(phoneBookContactList); + } return (int)jt1078Template.setPhoneBook(deviceId, j8401, 6); } }