From d5101ccfeadd623a2c65094e3c4d88995de2a6ba Mon Sep 17 00:00:00 2001 From: xuyang <748613696@qq.com> Date: Tue, 18 Apr 2023 08:52:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=89=A9=E6=8E=A5=E5=85=A5?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iot-access/access-api/pom.xml | 22 +++ .../njcn/access/enums/AccessResponseEnum.java | 29 ++++ .../java/com/njcn/access/param/ParamName.java | 18 +++ .../com/njcn/access/pojo/dto/AccessDto.java | 23 ++++ .../com/njcn/access/pojo/dto/DevCfgDto.java | 24 ++++ .../com/njcn/access/pojo/dto/DevModelDto.java | 30 +++++ .../com/njcn/access/pojo/dto/ModelDto.java | 24 ++++ .../com/njcn/access/pojo/dto/PublicDto.java | 28 ++++ .../njcn/access/pojo/dto/PublicParamDTO.java | 44 ++++++ .../com/njcn/access/pojo/dto/RegisterDTO.java | 53 ++++++++ .../access/pojo/dto/RegisterParamDTO.java | 57 ++++++++ .../com/njcn/access/pojo/dto/data/AlmDto.java | 28 ++++ .../njcn/access/pojo/dto/data/CtrlDto.java | 48 +++++++ .../com/njcn/access/pojo/dto/data/DiDto.java | 23 ++++ .../com/njcn/access/pojo/dto/data/DoDto.java | 29 ++++ .../njcn/access/pojo/dto/data/EpdPqdDto.java | 46 +++++++ .../com/njcn/access/pojo/dto/data/EvtDto.java | 30 +++++ .../access/pojo/dto/data/EvtParamDto.java | 31 +++++ .../com/njcn/access/pojo/dto/data/MdDto.java | 43 ++++++ .../com/njcn/access/pojo/dto/data/ParDto.java | 49 +++++++ .../com/njcn/access/pojo/dto/data/StsDto.java | 36 +++++ .../njcn/access/pojo/dto/devModel/CfgDto.java | 63 +++++++++ .../access/pojo/dto/devModel/CpuInfoDTO.java | 31 +++++ .../pojo/dto/devModel/DataArrayDto.java | 24 ++++ .../access/pojo/dto/devModel/DataDto.java | 19 +++ .../access/pojo/dto/devModel/DataSetDTO.java | 42 ++++++ .../pojo/dto/devModel/DevCfgDetailDto.java | 31 +++++ .../access/pojo/dto/devModel/DevInfoDTO.java | 34 +++++ .../pojo/dto/devModel/DevModDetailDto.java | 82 ++++++++++++ .../access/pojo/dto/devModel/DiskInfoDTO.java | 26 ++++ .../access/pojo/dto/devModel/MemInfoDTO.java | 25 ++++ .../pojo/dto/devModel/NetDevModDto.java | 64 +++++++++ .../access/pojo/dto/devModel/ParamDto.java | 26 ++++ .../access/pojo/dto/devModel/SoftInfoDTO.java | 35 +++++ .../pojo/dto/devModel/TemplateDetailDto.java | 27 ++++ .../access/pojo/dto/devModel/TemplateDto.java | 37 +++++ .../njcn/access/pojo/param/DevModelParam.java | 28 ++++ iot-access/access-boot/pom.xml | 26 +++- .../com/njcn/access/config/SwaggerConfig.java | 91 +++++++++++++ .../access/controller/AccessController.java | 49 +++++++ .../access/controller/DevModelController.java | 48 +++++++ .../access/handler/MqttMessageHandler.java | 126 ++++++++++++++++++ .../njcn/access/mapper/DataGroupMapper.xml | 17 +++ .../njcn/access/service/IAccessService.java | 16 +++ .../njcn/access/service/IDevModelService.java | 18 +++ .../serviceImpl/AccessServiceImpl.java | 54 ++++++++ .../serviceImpl/DevModelServiceImpl.java | 114 ++++++++++++++++ .../java/com/njcn/access/utils/JsonUtil.java | 94 +++++++++++++ .../src/main/resources/bootstrap.yml | 1 - iot-access/pom.xml | 4 +- pom.xml | 19 ++- 51 files changed, 1968 insertions(+), 18 deletions(-) create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/enums/AccessResponseEnum.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/param/ParamName.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/AccessDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/DevCfgDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/DevModelDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/ModelDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/PublicDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/PublicParamDTO.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/RegisterDTO.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/RegisterParamDTO.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/AlmDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/CtrlDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/DiDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/DoDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/EpdPqdDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/EvtDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/EvtParamDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/MdDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/ParDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/StsDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/CfgDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/CpuInfoDTO.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DataArrayDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DataDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DataSetDTO.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevCfgDetailDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevInfoDTO.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevModDetailDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DiskInfoDTO.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/MemInfoDTO.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/NetDevModDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ParamDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/SoftInfoDTO.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/TemplateDetailDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/TemplateDto.java create mode 100644 iot-access/access-api/src/main/java/com/njcn/access/pojo/param/DevModelParam.java create mode 100644 iot-access/access-boot/src/main/java/com/njcn/access/config/SwaggerConfig.java create mode 100644 iot-access/access-boot/src/main/java/com/njcn/access/controller/AccessController.java create mode 100644 iot-access/access-boot/src/main/java/com/njcn/access/controller/DevModelController.java create mode 100644 iot-access/access-boot/src/main/java/com/njcn/access/handler/MqttMessageHandler.java create mode 100644 iot-access/access-boot/src/main/java/com/njcn/access/mapper/DataGroupMapper.xml create mode 100644 iot-access/access-boot/src/main/java/com/njcn/access/service/IAccessService.java create mode 100644 iot-access/access-boot/src/main/java/com/njcn/access/service/IDevModelService.java create mode 100644 iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/AccessServiceImpl.java create mode 100644 iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/DevModelServiceImpl.java create mode 100644 iot-access/access-boot/src/main/java/com/njcn/access/utils/JsonUtil.java diff --git a/iot-access/access-api/pom.xml b/iot-access/access-api/pom.xml index 8426020..231cf31 100644 --- a/iot-access/access-api/pom.xml +++ b/iot-access/access-api/pom.xml @@ -26,6 +26,28 @@ 4.11 test + + org.projectlombok + lombok + + + com.google.code.gson + gson + 2.8.9 + + + org.springframework + spring-web + + + com.njcn + common-swagger + ${project.version} + + + com.alibaba.nacos + nacos-client + diff --git a/iot-access/access-api/src/main/java/com/njcn/access/enums/AccessResponseEnum.java b/iot-access/access-api/src/main/java/com/njcn/access/enums/AccessResponseEnum.java new file mode 100644 index 0000000..9709c00 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/enums/AccessResponseEnum.java @@ -0,0 +1,29 @@ +package com.njcn.access.enums; + +import lombok.Getter; + +/** + * @author xuyang + * @version 1.0.0 + * @date 2023年04月17日 10:50 + */ +@Getter +public enum AccessResponseEnum { + + /** + * A0301 ~ A0399 用于用户模块的枚举 + *

+ */ + MODEL_REPEAT("A0301", "模板重复,请勿重复录入!"), + ; + + private final String code; + + private final String message; + + AccessResponseEnum(String code, String message) { + this.code = code; + this.message = message; + } + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/param/ParamName.java b/iot-access/access-api/src/main/java/com/njcn/access/param/ParamName.java new file mode 100644 index 0000000..97709a9 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/param/ParamName.java @@ -0,0 +1,18 @@ +package com.njcn.access.param; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 序列化时,调整实体返回名称 + * @author 徐扬 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER}) +public @interface ParamName { + + String value() default ""; + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/AccessDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/AccessDto.java new file mode 100644 index 0000000..57dbb78 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/AccessDto.java @@ -0,0 +1,23 @@ +package com.njcn.access.pojo.dto; + +import com.njcn.access.param.ParamName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/3/31 14:04 + */ +@Data +public class AccessDto implements Serializable { + + @ParamName("NDID") + private String nDid; + + @ParamName("dev_type") + private String devType; +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/DevCfgDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/DevCfgDto.java new file mode 100644 index 0000000..d28ced2 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/DevCfgDto.java @@ -0,0 +1,24 @@ +package com.njcn.access.pojo.dto; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/4/10 10:47 + */ +@Data +public class DevCfgDto implements Serializable { + + @SerializedName("DID") + private String did; + + @SerializedName("DevType") + private String devType; + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/DevModelDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/DevModelDto.java new file mode 100644 index 0000000..8d7b555 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/DevModelDto.java @@ -0,0 +1,30 @@ +package com.njcn.access.pojo.dto; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/4/10 10:14 + */ +@Data +public class DevModelDto implements Serializable { + + @SerializedName("DevType") + private String devType; + + @SerializedName("Version") + private String versionNo; + + @SerializedName("Time") + private String versionDate; + + @SerializedName("Crc") + private String crc; + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/ModelDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/ModelDto.java new file mode 100644 index 0000000..d326cfc --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/ModelDto.java @@ -0,0 +1,24 @@ +package com.njcn.access.pojo.dto; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/4/10 10:54 + */ +@Data +public class ModelDto implements Serializable { + + @SerializedName("DevCfg") + private List devCfg; + + @SerializedName("DevMod") + private List devMod; +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/PublicDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/PublicDto.java new file mode 100644 index 0000000..e815037 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/PublicDto.java @@ -0,0 +1,28 @@ +package com.njcn.access.pojo.dto; + +import com.njcn.access.param.ParamName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/3/31 14:04 + */ +@Data +public class PublicDto implements Serializable { + + private String mid; + + @ParamName("NDID") + private String nDid; + + private Long timestamp; + + private String type; + + private AccessDto param; +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/PublicParamDTO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/PublicParamDTO.java new file mode 100644 index 0000000..1e44c00 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/PublicParamDTO.java @@ -0,0 +1,44 @@ +package com.njcn.access.pojo.dto; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/12 19:18 + */ +@Data +public class PublicParamDTO implements Serializable { + + /** + * 在请求报文中该值为请求 ID,在设备主动上报数据的报文中该字段可不填写 + */ + @SerializedName("mid") + private Integer mid; + + @SerializedName("userId") + private String userId; + + @SerializedName("deviceId") + private String deviceId; + + @SerializedName("timestamp") + private String timestamp; + + /** + * 报文处理的优先级 + */ + @SerializedName("level") + private Integer level; + + @SerializedName("type") + private String type; + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/RegisterDTO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/RegisterDTO.java new file mode 100644 index 0000000..f4143eb --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/RegisterDTO.java @@ -0,0 +1,53 @@ +package com.njcn.access.pojo.dto; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/11 14:36 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class RegisterDTO extends PublicParamDTO implements Serializable { + + /** + * 请求参数 + */ + @Data + @EqualsAndHashCode(callSuper = true) + public static class RegisterRequest extends RegisterDTO implements Serializable{ + + @SerializedName("expire") + private Integer expire; + + @SerializedName("param") + private RegisterParamDTO.RegisterParamRequest param; + } + + /** + * 应答参数 + */ + @Data + @EqualsAndHashCode(callSuper = true) + public static class RegisterResponse extends RegisterDTO implements Serializable{ + + @SerializedName("code") + private Integer code; + + @SerializedName("msg") + private String msg; + + @SerializedName("param") + private RegisterParamDTO.RegisterParamResponse param; + } + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/RegisterParamDTO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/RegisterParamDTO.java new file mode 100644 index 0000000..2558198 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/RegisterParamDTO.java @@ -0,0 +1,57 @@ +package com.njcn.access.pojo.dto; + + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.List; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/11 14:58 + */ +@Data +public class RegisterParamDTO implements Serializable { + + @SerializedName("NDID") + private String nDid; + + @SerializedName("DID") + private List did; + + /** + * 请求参数 + */ + @Data + @EqualsAndHashCode(callSuper = true) + public static class RegisterParamRequest extends RegisterParamDTO implements Serializable{ + @SerializedName("type") + private Integer type; + } + + /** + * 应答参数 + */ + @Data + @EqualsAndHashCode(callSuper = true) + public static class RegisterParamResponse extends RegisterParamDTO implements Serializable{ + @SerializedName("res") + private Integer res; + + @SerializedName("type") + private Integer resType; + + @SerializedName("NDID") + private String nDid; + + @SerializedName("DEV_TYPE") + private String dev_type; + + } + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/AlmDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/AlmDto.java new file mode 100644 index 0000000..a1117ae --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/AlmDto.java @@ -0,0 +1,28 @@ +package com.njcn.access.pojo.dto.data; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/13 14:45 + */ +@Data +public class AlmDto implements Serializable { + + @SerializedName("Name") + private String name; + + @SerializedName("IDX") + private Integer idx; + + @SerializedName("Type") + private String type; + + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/CtrlDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/CtrlDto.java new file mode 100644 index 0000000..3c1b162 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/CtrlDto.java @@ -0,0 +1,48 @@ +package com.njcn.access.pojo.dto.data; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/13 15:06 + */ +@Data +public class CtrlDto implements Serializable { + + @SerializedName("Name") + private String name; + + @SerializedName("IDX") + private Integer idx; + + @SerializedName("Type") + private String type; + + @SerializedName("Check") + private Integer remoteCheck; + + @SerializedName("Auto") + private Integer auto; + + @SerializedName("MaxNum") + private Integer maxNum; + + @SerializedName("MinNum") + private Integer minNum; + + @SerializedName("Ctlvalue") + private List ctlValue; + + @SerializedName("Strlen") + private Integer strLen; + + @SerializedName("Encode") + private Integer encode; +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/DiDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/DiDto.java new file mode 100644 index 0000000..c25d045 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/DiDto.java @@ -0,0 +1,23 @@ +package com.njcn.access.pojo.dto.data; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/13 14:57 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class DiDto extends StsDto implements Serializable { + + @SerializedName("TranFlag") + private Integer tranFlag; + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/DoDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/DoDto.java new file mode 100644 index 0000000..e2b3835 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/DoDto.java @@ -0,0 +1,29 @@ +package com.njcn.access.pojo.dto.data; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/13 14:59 + */ +@Data +public class DoDto implements Serializable { + + @SerializedName("Name") + private String name; + + @SerializedName("IDX") + private Integer idx; + + @SerializedName("CurSts") + private Integer curSts; + + @SerializedName("CtlSts") + private Integer ctlSts; +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/EpdPqdDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/EpdPqdDto.java new file mode 100644 index 0000000..3d521f5 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/EpdPqdDto.java @@ -0,0 +1,46 @@ +package com.njcn.access.pojo.dto.data; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/13 14:27 + */ +@Data +public class EpdPqdDto implements Serializable { + + @SerializedName("Name") + private String name; + + @SerializedName("IDX") + private Integer idx; + + @SerializedName("Type") + private String type; + + @SerializedName("Phase") + private String phase; + + @SerializedName("Unit") + private String unit; + + @SerializedName("HarmStart") + private String harmStart; + + @SerializedName("HarmEnd") + private String harmEnd; + + @SerializedName("ClassID") + private String classId; + + @SerializedName("StatMethod") + private List statMethod; + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/EvtDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/EvtDto.java new file mode 100644 index 0000000..43a2587 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/EvtDto.java @@ -0,0 +1,30 @@ +package com.njcn.access.pojo.dto.data; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/13 14:40 + */ +@Data +public class EvtDto implements Serializable { + + @SerializedName("Name") + private String name; + + @SerializedName("IDX") + private Integer idx; + + @SerializedName("Type") + private String type; + + @SerializedName("Parm") + private List param; +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/EvtParamDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/EvtParamDto.java new file mode 100644 index 0000000..d34d724 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/EvtParamDto.java @@ -0,0 +1,31 @@ +package com.njcn.access.pojo.dto.data; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/13 14:41 + */ +@Data +public class EvtParamDto implements Serializable { + + @SerializedName("Name") + private String name; + + @SerializedName("Type") + private String type; + + @SerializedName("Unit") + private String unit; + + @SerializedName("Data") + private String data; + + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/MdDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/MdDto.java new file mode 100644 index 0000000..ad2185b --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/MdDto.java @@ -0,0 +1,43 @@ +package com.njcn.access.pojo.dto.data; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/13 14:48 + */ +@Data +public class MdDto implements Serializable { + + @SerializedName("Name") + private String name; + + @SerializedName("IDX") + private Integer idx; + + @SerializedName("Type") + private String type; + + @SerializedName("Unit") + private String unit; + + @SerializedName("Phase") + private String phase; + + @SerializedName("ClassID") + private String classId; + + @SerializedName("StatMethod") + private List statMethod; + + @SerializedName("TranRule") + private String tranRule; + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/ParDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/ParDto.java new file mode 100644 index 0000000..61dfd52 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/ParDto.java @@ -0,0 +1,49 @@ +package com.njcn.access.pojo.dto.data; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/13 15:02 + */ +@Data +public class ParDto implements Serializable { + + @SerializedName("Name") + private String name; + + @SerializedName("IDX") + private Integer idx; + + @SerializedName("Type") + private String type; + + @SerializedName("DataType") + private String dataType; + + @SerializedName("ModifyFlag") + private Integer modifyFlag; + + @SerializedName("MaxNum") + private Integer maxNum; + + @SerializedName("MinNum") + private Integer minNum; + + @SerializedName("SetValue") + private List setValue; + + @SerializedName("Strlen") + private Integer strLen; + + @SerializedName("DefaultValue") + private String defaultValue; + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/StsDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/StsDto.java new file mode 100644 index 0000000..fd067b9 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/data/StsDto.java @@ -0,0 +1,36 @@ +package com.njcn.access.pojo.dto.data; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/13 14:52 + */ +@Data +public class StsDto implements Serializable { + + @SerializedName("Name") + private String name; + + @SerializedName("IDX") + private Integer idx; + + @SerializedName("StoreFlag") + private Integer storeFlag; + + @SerializedName("CurSts") + private Integer curSts; + + @SerializedName("ClassID") + private String classId; + + @SerializedName("TranRule") + private String tranRule; + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/CfgDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/CfgDto.java new file mode 100644 index 0000000..49233e6 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/CfgDto.java @@ -0,0 +1,63 @@ +package com.njcn.access.pojo.dto.devModel; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/4/10 16:35 + */ +@Data +public class CfgDto implements Serializable { + + @SerializedName("DevModName") + private String name; + + @SerializedName("DevModVersion") + private String version; + + @SerializedName("DevModTime") + private String time; + + @SerializedName("ID") + private String id; + + @SerializedName("DevType") + private String type; + + @SerializedName("DevApp") + private String devApp; + + @SerializedName("DevInfo") + private DevInfoDTO devInfo; + + @SerializedName("Province") + private String province; + + @SerializedName("City") + private String city; + + @SerializedName("County") + private String county; + + @SerializedName("Address") + private String address; + + @SerializedName("Position") + private String position; + + @SerializedName("LineNum") + private Integer lineNum; + + @SerializedName("FileFrameLength") + private Integer fileFrameLength; + + @SerializedName("FileFrameTimeout") + private Integer fileFrameTimeout; + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/CpuInfoDTO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/CpuInfoDTO.java new file mode 100644 index 0000000..96e79d6 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/CpuInfoDTO.java @@ -0,0 +1,31 @@ +package com.njcn.access.pojo.dto.devModel; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/13 12:09 + */ +@Data +public class CpuInfoDTO implements Serializable { + + @SerializedName("CpuCore") + private Integer cpuCore; + + @SerializedName("CpuFreq") + private Float cpuFreq; + + @SerializedName("Arch") + private String arch; + + @SerializedName("CpuLmt") + private Float cpuLmt; +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DataArrayDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DataArrayDto.java new file mode 100644 index 0000000..ea2044a --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DataArrayDto.java @@ -0,0 +1,24 @@ +package com.njcn.access.pojo.dto.devModel; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/13 15:18 + */ +@Data +public class DataArrayDto implements Serializable { + + @SerializedName("Type") + private String type; + + @SerializedName("IDX") + private Integer idx; + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DataDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DataDto.java new file mode 100644 index 0000000..6afa128 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DataDto.java @@ -0,0 +1,19 @@ +package com.njcn.access.pojo.dto.devModel; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/4/10 16:20 + */ +@Data +public class DataDto implements Serializable { + @SerializedName("TEMPLATE") + private TemplateDetailDto template; +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DataSetDTO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DataSetDTO.java new file mode 100644 index 0000000..a8b3d03 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DataSetDTO.java @@ -0,0 +1,42 @@ +package com.njcn.access.pojo.dto.devModel; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/13 14:21 + */ +@Data +public class DataSetDTO implements Serializable { + + @SerializedName("Name") + private String name; + + @SerializedName("IDX") + private Integer idx; + + @SerializedName("DataType") + private String dataType; + + @SerializedName("StartTime") + private String startTime; + + @SerializedName("Period") + private Integer period; + + @SerializedName("StoreFlag") + private Integer storeFlag; + + @SerializedName("DataArray") + private List dataArray; + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevCfgDetailDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevCfgDetailDto.java new file mode 100644 index 0000000..dff9214 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevCfgDetailDto.java @@ -0,0 +1,31 @@ +package com.njcn.access.pojo.dto.devModel; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/4/10 16:26 + */ +@Data +public class DevCfgDetailDto implements Serializable { + + @SerializedName("Name") + private String name; + + @SerializedName("Version") + private String version; + + @SerializedName("Time") + private String time; + + @SerializedName("Cfg") + private List cfg; + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevInfoDTO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevInfoDTO.java new file mode 100644 index 0000000..e2e8541 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevInfoDTO.java @@ -0,0 +1,34 @@ +package com.njcn.access.pojo.dto.devModel; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/13 12:08 + */ +@Data +public class DevInfoDTO implements Serializable { + + @SerializedName("DevType") + private String devType; + + @SerializedName("DevName") + private String devName; + + @SerializedName("MsgInfo") + private String msgInfo; + + @SerializedName("DevStatus") + private String devStatus; + + @SerializedName("HardVer") + private String hardVer; +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevModDetailDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevModDetailDto.java new file mode 100644 index 0000000..0999af4 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevModDetailDto.java @@ -0,0 +1,82 @@ +package com.njcn.access.pojo.dto.devModel; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import com.njcn.access.pojo.dto.data.*; +import com.njcn.access.pojo.dto.data.ParDto; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/4/10 16:26 + */ +@Data +public class DevModDetailDto implements Serializable { + + @SerializedName("Name") + private String name; + + @SerializedName("Version") + private String version; + + @SerializedName("Time") + private String time; + + @SerializedName("IDX") + private Integer idx; + + @SerializedName("DevType") + private String devType; + + @SerializedName("DataList") + private List dataList; + + @SerializedName("DataSet") + private List dataSet; + + @SerializedName("IClk") + private String iclk; + + @SerializedName("EClk") + private String eclk; + + @SerializedName("LineNum") + private Integer lineNum; + + @SerializedName("EPD") + private List epd; + + @SerializedName("PQD") + private List pqd; + + @SerializedName("EVT") + private List evt; + + @SerializedName("ALM") + private List alm; + + @SerializedName("MD") + private List md; + + @SerializedName("STS") + private List sts; + + @SerializedName("DI") + private List di; + + @SerializedName("DO") + private List doDTO; + + @SerializedName("Param") + private List param; + + @SerializedName("CTRL") + private List ctrl; + + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DiskInfoDTO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DiskInfoDTO.java new file mode 100644 index 0000000..2c86f48 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DiskInfoDTO.java @@ -0,0 +1,26 @@ +package com.njcn.access.pojo.dto.devModel; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; +import java.io.Serializable; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/13 12:09 + */ +@Data +public class DiskInfoDTO implements Serializable { + + @SerializedName("DiskPhy") + private Float diskPhy; + + @SerializedName("DiskUsePhy") + private Float diskUsePhy; + + @SerializedName("DiskLmt") + private Float diskLmt; + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/MemInfoDTO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/MemInfoDTO.java new file mode 100644 index 0000000..dff7022 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/MemInfoDTO.java @@ -0,0 +1,25 @@ +package com.njcn.access.pojo.dto.devModel; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; +import java.io.Serializable; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/13 12:09 + */ +@Data +public class MemInfoDTO implements Serializable { + + @SerializedName("MemPhy") + private Float memPhy; + + @SerializedName("MemVirt") + private Float memVirt; + + @SerializedName("MemLmt") + private Float memLmt; +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/NetDevModDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/NetDevModDto.java new file mode 100644 index 0000000..a122176 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/NetDevModDto.java @@ -0,0 +1,64 @@ +package com.njcn.access.pojo.dto.devModel; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/4/10 16:25 + */ +@Data +public class NetDevModDto implements Serializable { + + @SerializedName("Name") + private String name; + + @SerializedName("Version") + private String version; + + @SerializedName("Time") + private String time; + + @SerializedName("DevName") + private String devName; + + @SerializedName("DevType") + private String devType; + + @SerializedName("NetType") + private String netType; + + @SerializedName("NDID") + private String nDid; + + @SerializedName("DevTopicVer") + private String devTopicVer; + + @SerializedName("Uid") + private String uid; + + @SerializedName("CUid") + private List cUid; + + @SerializedName("DevInfo") + private DevInfoDTO devInfoDTO; + + @SerializedName("CpuInfo") + private CpuInfoDTO cpuInfoDTO; + + @SerializedName("MemInfo") + private MemInfoDTO memInfoDTO; + + @SerializedName("DiskInfo") + private DiskInfoDTO diskInfoDTO; + + @SerializedName("SoftInfo") + private SoftInfoDTO softInfoDTO; + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ParamDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ParamDto.java new file mode 100644 index 0000000..84c706a --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ParamDto.java @@ -0,0 +1,26 @@ +package com.njcn.access.pojo.dto.devModel; + + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/4/10 16:18 + */ +@Data +public class ParamDto implements Serializable { + + @SerializedName("Data_Type") + private String dataType; + + @SerializedName("Data_Array") + private List dataArray; + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/SoftInfoDTO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/SoftInfoDTO.java new file mode 100644 index 0000000..f9c9186 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/SoftInfoDTO.java @@ -0,0 +1,35 @@ +package com.njcn.access.pojo.dto.devModel; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; +import java.io.Serializable; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2022/3/13 12:09 + */ +@Data +public class SoftInfoDTO implements Serializable { + + @SerializedName("OsName") + private String osName; + + @SerializedName("OsVersion") + private String osVersion; + + @SerializedName("AppVersion") + private String appVersion; + + @SerializedName("AppDate") + private String appDate; + + @SerializedName("AppCheck") + private String appCheck; + + @SerializedName("Softupdate") + private String softUpdate; + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/TemplateDetailDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/TemplateDetailDto.java new file mode 100644 index 0000000..52c1bd8 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/TemplateDetailDto.java @@ -0,0 +1,27 @@ +package com.njcn.access.pojo.dto.devModel; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/4/10 16:22 + */ +@Data +public class TemplateDetailDto implements Serializable { + + @SerializedName("NetDevMod") + private NetDevModDto netDevModDto; + + @SerializedName("DevCfg") + private DevCfgDetailDto devCfgDetailDto; + + @SerializedName("DevMod") + private List devModDetailDto; +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/TemplateDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/TemplateDto.java new file mode 100644 index 0000000..2a0208f --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/TemplateDto.java @@ -0,0 +1,37 @@ +package com.njcn.access.pojo.dto.devModel; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/4/10 16:16 + */ +@Data +public class TemplateDto implements Serializable { + + @SerializedName("mid") + private Integer mid; + + @SerializedName("deviceId") + private String deviceId; + + @SerializedName("timestamp") + private String timestamp; + + @SerializedName("type") + private String type; + + @SerializedName("param") + private ParamDto param; + + @SerializedName("code") + private Integer code; + + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/param/DevModelParam.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/param/DevModelParam.java new file mode 100644 index 0000000..915cb33 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/param/DevModelParam.java @@ -0,0 +1,28 @@ +package com.njcn.access.pojo.param; + + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; + +import javax.validation.constraints.NotNull; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/4/10 13:56 + */ +@Data +public class DevModelParam { + + @ApiModelProperty(value = "模板文件") + @NotNull(message="模板文件不能为空!") + private MultipartFile file; + + @ApiModelProperty(value = "装置类型") + @NotNull(message="装置类型不能为空!") + private String devType; + +} diff --git a/iot-access/access-boot/pom.xml b/iot-access/access-boot/pom.xml index d921655..18af8cb 100644 --- a/iot-access/access-boot/pom.xml +++ b/iot-access/access-boot/pom.xml @@ -20,6 +20,11 @@ + + com.njcn + access-api + 1.0.0 + com.njcn common-web @@ -27,7 +32,7 @@ com.njcn - common-swagger + common-oss ${project.version} @@ -42,14 +47,25 @@ com.njcn - common-poi + common-redis + 1.0.0 + compile + + + com.njcn + algorithm-api ${project.version} com.njcn - common-redis - 1.0.0 - compile + system-api + ${project.version} + + + + org.springframework.kafka + spring-kafka + ${kafka.version} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/config/SwaggerConfig.java b/iot-access/access-boot/src/main/java/com/njcn/access/config/SwaggerConfig.java new file mode 100644 index 0000000..1f30ab6 --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/config/SwaggerConfig.java @@ -0,0 +1,91 @@ +package com.njcn.access.config; + +import com.google.common.collect.Lists; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.OAuthBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.*; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spi.service.contexts.SecurityContext; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import java.util.ArrayList; +import java.util.List; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/4/3 9:03 + */ +@Configuration +public class SwaggerConfig { + + @Value("${microservice.gateway.url}") + private String gatewayUrl; + + @Bean + public Docket createRestApi() { + + List grantTypes = new ArrayList<>(); + String passwordTokenUrl = "http://" + gatewayUrl + "/pqs-auth/oauth/token"; + ResourceOwnerPasswordCredentialsGrant resourceOwnerPasswordCredentialsGrant = new ResourceOwnerPasswordCredentialsGrant(passwordTokenUrl); + grantTypes.add(resourceOwnerPasswordCredentialsGrant); + OAuth oAuth = new OAuthBuilder().name("oauth2").grantTypes(grantTypes).build(); + //schemas + List securitySchemes = Lists.newArrayList(oAuth); + return new Docket(DocumentationType.SWAGGER_2) + .groupName("物联网注册服务") + .apiInfo(apiInfo()) + .enable(true) + .select() + .apis(RequestHandlerSelectors.basePackage("com.njcn.access.controller")) + .paths(PathSelectors.any()) + .build() + .securityContexts(securityContexts()) + .securitySchemes(securitySchemes); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("物接入") + .description("物接入接口文档") + .version("1.0") + .contact(contact()) + .build(); + } + + private List securityContexts() { + List securityContexts = new ArrayList<>(); + securityContexts.add( + SecurityContext.builder() + .securityReferences(defaultAuth()) + .forPaths(PathSelectors.ant("/**")) + .build()); + return securityContexts; + } + + List defaultAuth() { + //scope方位 + List scopes = new ArrayList<>(); + scopes.add(new AuthorizationScope("read", "read resources")); + scopes.add(new AuthorizationScope("write", "write resources")); + scopes.add(new AuthorizationScope("reads", "read all resources")); + scopes.add(new AuthorizationScope("writes", "write all resources")); + SecurityReference securityReference = new SecurityReference("oauth2", scopes.toArray(new AuthorizationScope[]{})); + List securityReferences = new ArrayList<>(); + securityReferences.add(securityReference); + return securityReferences; + } + + private Contact contact() { + return new Contact("灿能系统组", "", "13914774158@163.com"); + } + +} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/controller/AccessController.java b/iot-access/access-boot/src/main/java/com/njcn/access/controller/AccessController.java new file mode 100644 index 0000000..27810d1 --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/controller/AccessController.java @@ -0,0 +1,49 @@ +package com.njcn.access.controller; + +import com.njcn.access.service.IAccessService; +import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.enums.common.LogEnum; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.common.utils.HttpResultUtil; +import com.njcn.common.utils.LogUtil; +import com.njcn.web.controller.BaseController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/3/31 9:12 + */ +@Slf4j +@RestController +@RequestMapping("/devAccess") +@RequiredArgsConstructor +@Api(tags = "装置接入") +public class AccessController extends BaseController { + + private final IAccessService accessService; + + @PostMapping("/add") + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @ApiOperation("平台发起注册") + @ApiImplicitParam(name = "nDid", value = "网关识别码", required = true) + public HttpResult add(@RequestParam String nDid){ + log.info("设备向装置侧发起注册请求,请求的nDid为:" + nDid); + String methodDescribe = getMethodDescribe("add"); + LogUtil.njcnDebug(log, "{},设备向装置侧发起注册请求,请求的nDid为:{}", methodDescribe, nDid); + accessService.add(nDid); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } + + + +} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/controller/DevModelController.java b/iot-access/access-boot/src/main/java/com/njcn/access/controller/DevModelController.java new file mode 100644 index 0000000..21fb463 --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/controller/DevModelController.java @@ -0,0 +1,48 @@ +package com.njcn.access.controller; + +import com.njcn.access.pojo.param.DevModelParam; +import com.njcn.access.service.IDevModelService; +import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.enums.common.LogEnum; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.common.utils.HttpResultUtil; +import com.njcn.common.utils.LogUtil; +import com.njcn.web.controller.BaseController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/4/10 10:26 + */ +@Slf4j +@RestController +@RequestMapping("/devModel") +@AllArgsConstructor +@Validated +@Api(tags = "装置模板录入") +public class DevModelController extends BaseController { + + private final IDevModelService devModelService; + + @PostMapping("/add") + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @ApiOperation("装置录入模板") + public HttpResult add(DevModelParam devModelParam){ + log.info("装置录入模板文件"); + String methodDescribe = getMethodDescribe("add"); + LogUtil.njcnDebug(log, "{},装置录入模板文件", methodDescribe); + return devModelService.add(devModelParam); + } + +} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/handler/MqttMessageHandler.java b/iot-access/access-boot/src/main/java/com/njcn/access/handler/MqttMessageHandler.java new file mode 100644 index 0000000..763c654 --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/handler/MqttMessageHandler.java @@ -0,0 +1,126 @@ +package com.njcn.access.handler; + +import com.alibaba.nacos.shaded.com.google.gson.Gson; +import com.github.tocrhz.mqtt.annotation.MqttSubscribe; +import com.github.tocrhz.mqtt.annotation.NamedValue; +import com.github.tocrhz.mqtt.annotation.Payload; +import com.github.tocrhz.mqtt.publisher.MqttPublisher; +import com.njcn.access.pojo.dto.*; +import com.njcn.algorithm.api.DevModelFeignClient; +import com.njcn.algorithm.api.EquipmentFeignClient; +import com.njcn.algorithm.pojo.param.CsDevModelQueryListParm; +import com.njcn.algorithm.pojo.vo.CsDevModelPageVO; +import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.redis.utils.RedisUtil; +import com.njcn.system.api.DicDataFeignClient; +import com.njcn.system.pojo.po.DictData; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.eclipse.paho.client.mqttv3.MqttMessage; +import org.springframework.stereotype.Component; + +import java.nio.charset.StandardCharsets; +import java.time.Instant; +import java.util.List; +import java.util.Objects; + +/** + * @author hongawen + * @version 1.0.0 + * @date 2022年03月23日 09:41 + */ +@Slf4j +@Component +@AllArgsConstructor +public class MqttMessageHandler { + + private final EquipmentFeignClient equipmentFeignClient; + + private final DevModelFeignClient devModelFeignClient; + + private final DicDataFeignClient dicDataFeignClient; + + private final MqttPublisher publisher; + + private final RedisUtil redisUtil; + + /** + * 接收装置接入响应 + * 1.收到注册信息,修改装置出厂表,装置的状态,调整为注册;然后开始接入流程 + * 2.询问当前装置类型的模板。有则完成接入;没有则告警出来,需要人工手动上传模板信息 + * @param topic + * @param message + * @param payload + */ + @MqttSubscribe(value = "/device/register/{nDid}",qos = 1) + public void devOperation(String topic, MqttMessage message, @NamedValue("nDid") String nDid, @Payload String payload){ + Gson gson = new Gson(); + RegisterDTO.RegisterResponse registerDTO = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), RegisterDTO.RegisterResponse.class); + if (registerDTO.getCode() == 200){ + //todo 调整装置出厂表状态 + + + PublicDto publicDto = new PublicDto(); + publicDto.setMid(Long.toString(Instant.now().toEpochMilli())); + publicDto.setNDid(nDid); + publicDto.setTimestamp(Instant.now().toEpochMilli()); + publicDto.setType("CMD_DEV_DATA"); + AccessDto accessDto = new AccessDto(); + accessDto.setNDid(nDid); + accessDto.setDevType(registerDTO.getParam().getDev_type()); + publicDto.setParam(accessDto); + publisher.send("/platform/devcmd/"+nDid,new Gson().toJson(publicDto),1,false); + } + } + + /** + * 装置类型模板相应 + * 1.判断网关的类型 + * 2.直联设备的DevCfg和DevMod是以直联设备为准,上送平台端,平台端保存。通过校验DevMod模板信息来从平台端模板池中选取对应的模板,如果找不到匹配模板需告警提示人工干预处理。 + * 3.平台端需读取装置的DevMod来判断网关支持的设备模板(包含设备型号和模板版本),根据app提交的接入子设备DID匹配数据模板(型号及版本),生成DevCfg下发给网关,网关根据下发信息生成就地设备点表。 + * @param topic + * @param message + * @param nDid + * @param payload + */ + @MqttSubscribe(value = "/device/devack/{nDid}",qos = 1) + public void devModelOperation(String topic, MqttMessage message, @NamedValue("nDid") String nDid, @Payload String payload){ + Gson gson = new Gson(); + ModelDto modelDto = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), ModelDto.class); + HttpResult pojo = equipmentFeignClient.queryEquipmentByndid(nDid); + if (!Objects.isNull(pojo)){ + String devType = pojo.getData().getDevType(); + if (Objects.equals(devType,"直连设备")){ + List list = modelDto.getDevMod(); + list.forEach(item->{ + //todo 根据条件查询库中是否有符合条件的数据 + DictData dicData = dicDataFeignClient.getDicDataByCode(item.getDevType()).getData(); + CsDevModelQueryListParm csDevModelQueryListParm = new CsDevModelQueryListParm(); + if (Objects.isNull(dicData)) { + log.info("新增模板失败,获取装置类型字典数据为空,请先录入装置类型!"); + return; + } else { + csDevModelQueryListParm.setDevType( dicData.getId()); + } + csDevModelQueryListParm.setVersionNo(item.getVersionNo()); + csDevModelQueryListParm.setVersionDate(item.getVersionDate()); + CsDevModelPageVO csDevModelPageVO = devModelFeignClient.queryDevModelOne(csDevModelQueryListParm).getData(); + if (Objects.isNull(csDevModelPageVO)){ + log.info("模板不存在,请先录入模板数据!"); + return; + } else { + //todo 录入装置和模板的关系表 + System.out.println("录入装置和模板的关系表"); + } + }); + } else if (Objects.equals(devType,"网关")){ + //todo 处理待定 + System.out.println("网关设备判断"); + } + } else { + log.info("通过nDid未找到相关装置信息"); + } + } + +} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/DataGroupMapper.xml b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/DataGroupMapper.xml new file mode 100644 index 0000000..93f656e --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/DataGroupMapper.xml @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/IAccessService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/IAccessService.java new file mode 100644 index 0000000..7ccdbc8 --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/service/IAccessService.java @@ -0,0 +1,16 @@ +package com.njcn.access.service; + +/** + * @author 徐扬 + */ +public interface IAccessService { + + /** + * 设备注册(1.判断此装置是否完成出厂设置 2.判断此装置是否能正常通讯) + * 1.根据nDid获取装置的信息(设备型号、网关识别码) + * 2.发送MQTT信息给装置 + * 3.装置响应则修改装置状态;3分钟未响应则生成告警信息 + * @param nDid 网关识别码 + */ + void add(String nDid); +} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/IDevModelService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/IDevModelService.java new file mode 100644 index 0000000..283a972 --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/service/IDevModelService.java @@ -0,0 +1,18 @@ +package com.njcn.access.service; + +import com.njcn.access.pojo.param.DevModelParam; +import com.njcn.common.pojo.response.HttpResult; + +/** + * @author xy + */ +public interface IDevModelService { + + /** + * 直连装置录入模板信息 + * 1.解析模板文件,将数据录入库中 + * 2.将文件上传至文件服务器保存起来,先以装置型号-版本号-时间作为名称名称 + * @param devModelParam 模板文件参数 + */ + HttpResult add(DevModelParam devModelParam); +} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/AccessServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/AccessServiceImpl.java new file mode 100644 index 0000000..fc8bef7 --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/AccessServiceImpl.java @@ -0,0 +1,54 @@ +package com.njcn.access.service.serviceImpl; + +import com.alibaba.nacos.shaded.com.google.gson.Gson; +import com.github.tocrhz.mqtt.publisher.MqttPublisher; +import com.njcn.access.pojo.dto.AccessDto; +import com.njcn.access.pojo.dto.PublicDto; +import com.njcn.access.service.IAccessService; +import com.njcn.algorithm.api.EquipmentFeignClient; +import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO; +import com.njcn.common.pojo.response.HttpResult; +import lombok.AllArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import java.time.Instant; +import java.util.Objects; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/3/31 9:21 + */ +@Service +@AllArgsConstructor +public class AccessServiceImpl implements IAccessService { + + private static final Logger logger = LoggerFactory.getLogger(AccessServiceImpl.class); + + private final MqttPublisher publisher; + + private final EquipmentFeignClient equipmentFeignClient; + + @Override + public void add(String nDid) { + CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData(); + if (Objects.isNull(vo)){ + logger.error("平台侧无此网关信息,请先录入!"); + return; + } + PublicDto publicDto = new PublicDto(); + publicDto.setMid(Long.toString(Instant.now().toEpochMilli())); + publicDto.setNDid(nDid); + publicDto.setTimestamp(Instant.now().toEpochMilli()); + publicDto.setType("CMD_DEV_REGISTER"); + AccessDto accessDto = new AccessDto(); + accessDto.setNDid(nDid); + accessDto.setDevType(vo.getDevModel()); + publicDto.setParam(accessDto); + publisher.send("/platform/register/"+nDid,new Gson().toJson(publicDto),1,false); + } +} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/DevModelServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/DevModelServiceImpl.java new file mode 100644 index 0000000..f16b964 --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/DevModelServiceImpl.java @@ -0,0 +1,114 @@ +package com.njcn.access.service.serviceImpl; + +import com.alibaba.nacos.shaded.com.google.gson.Gson; +import com.njcn.access.enums.AccessResponseEnum; +import com.njcn.access.pojo.dto.devModel.*; +import com.njcn.access.pojo.param.DevModelParam; +import com.njcn.access.service.IDevModelService; +import com.njcn.access.utils.JsonUtil; +import com.njcn.algorithm.api.DevModelFeignClient; +import com.njcn.algorithm.pojo.param.CsDevModelAddParm; +import com.njcn.algorithm.pojo.param.CsDevModelQueryListParm; +import com.njcn.algorithm.pojo.vo.CsDevModelPageVO; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.common.utils.HttpResultUtil; +import com.njcn.oss.constant.OssPath; +import com.njcn.oss.utils.FileStorageUtil; +import com.njcn.system.api.DicDataFeignClient; +import com.njcn.system.pojo.po.DictData; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.List; +import java.util.Objects; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/4/10 10:37 + */ +@Slf4j +@Service +@AllArgsConstructor +public class DevModelServiceImpl implements IDevModelService { + + private final FileStorageUtil fileStorageUtil; + + private final DevModelFeignClient devModelFeignClient; + + private final DicDataFeignClient dicDataFeignClient; + + @Override + @Transactional(rollbackFor = Exception.class) + public HttpResult add(DevModelParam devModelParam) { + String json = null; + try { + json = JsonUtil.convertStreamToString(devModelParam.getFile().getInputStream()); + + Gson gson = new Gson(); + TemplateDto templateDto = gson.fromJson(json, TemplateDto.class); + ParamDto pojo = templateDto.getParam(); + //网关模板 + NetDevModDto po1 = pojo.getDataArray().get(0).getTemplate().getNetDevModDto(); + //装置信息模板 + DevCfgDetailDto po2 = pojo.getDataArray().get(0).getTemplate().getDevCfgDetailDto(); + //装置数据模板 + List po3 = pojo.getDataArray().get(0).getTemplate().getDevModDetailDto(); + + String name = po3.get(0).getName(); + String version = po3.get(0).getVersion(); + String time = po3.get(0).getTime(); + String devType = po3.get(0).getDevType(); + String devTypeId = ""; + + DictData dicData = dicDataFeignClient.getDicDataByCode(devType).getData(); + if (Objects.isNull(dicData)) { + log.info("新增模板失败,获取装置类型字典数据为空,请先录入装置类型!"); + return HttpResultUtil.assembleResult(CommonResponseEnum.NO_DATA.getCode(), null, "获取装置类型字典数据为空!"); + } else { + devTypeId = dicData.getId(); + } + CsDevModelQueryListParm csDevModelQueryListParm = new CsDevModelQueryListParm(); + csDevModelQueryListParm.setDevType(devTypeId); + csDevModelQueryListParm.setVersionNo(version); + csDevModelQueryListParm.setVersionDate(time); + csDevModelQueryListParm.setName(name); + CsDevModelPageVO vo = devModelFeignClient.queryDevModelOne(csDevModelQueryListParm).getData(); + if (!Objects.isNull(vo)){ + log.info("新增模板失败,新增的模板在库中存在!"); + return HttpResultUtil.assembleResult(AccessResponseEnum.MODEL_REPEAT.getCode(), null, AccessResponseEnum.MODEL_REPEAT.getMessage()); + } else { + CsDevModelAddParm csDevModelAddParm = new CsDevModelAddParm(); + csDevModelAddParm.setName(name); + csDevModelAddParm.setDevType(devTypeId); + csDevModelAddParm.setVersionNo(version); + csDevModelAddParm.setVersionDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(time)); + String filePath = fileStorageUtil.uploadMultipart(devModelParam.getFile(), OssPath.DEV_MODEL + devModelParam.getDevType() + "_"); + log.info("文件路径为:" + filePath); + csDevModelAddParm.setFilePath(filePath); + //新增cs_dev_model表数据 + devModelFeignClient.addDevModel(csDevModelAddParm); + //新增cs_data_set + + //新增cs_data_array + + + } + } catch (IOException e) { + log.error("文件转成json出现异常"); + e.getMessage(); + } catch (ParseException e) { + log.error("时间转换出现异常"); + e.getMessage(); + } + return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), null, CommonResponseEnum.SUCCESS.getMessage()); + } +} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/utils/JsonUtil.java b/iot-access/access-boot/src/main/java/com/njcn/access/utils/JsonUtil.java new file mode 100644 index 0000000..d003cb7 --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/utils/JsonUtil.java @@ -0,0 +1,94 @@ +package com.njcn.access.utils; + +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Random; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/4/10 16:03 + */ +public class JsonUtil { + + /** + * @param jsonString 要保存的JSON串 + * @param filePath 保存到的文件路径 + * @param fileName 文件名称 + * @return + */ + //保存json 文件 + public static boolean createJsonFile(String jsonString, String filePath, String fileName) { + // 标记文件生成是否成功 + boolean flag = true; + // 拼接文件完整路径 + String fullPath = filePath + File.separator + fileName + ".json"; + // 生成json格式文件 + try { + // 保证创建一个新文件 + File file = new File(fullPath); + // 如果父目录不存在,创建父目录 + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + // 如果已存在,删除旧文件 + if (file.exists()) { + file.delete(); + } + file.createNewFile(); + // 格式化json字符串 + //jsonString = JsonFormatTool.formatJson2(jsonString); + // 将格式化后的字符串写入文件 + Writer write = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8); + write.write(jsonString); + write.flush(); + write.close(); + } catch (Exception e) { + flag = false; + e.printStackTrace(); + } + // 返回是否成功的标记 + return flag; + } + + /** + * 生成随机文件名:当前年月日时分秒+五位随机数 + * @return + */ + public static String getRandomFileName() { + SimpleDateFormat simpleDateFormat; + simpleDateFormat = new SimpleDateFormat("yyyyMMdd"); + Date date = new Date(); + String str = simpleDateFormat.format(date); + Random random = new Random(); + // 获取5位随机数 + int ranNum = (int) (random.nextDouble() * (99999 - 10000 + 1)) + 10000; + // 当前时间 + return ranNum + str; + } + + public static String convertStreamToString(InputStream inputStream){ + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + StringBuilder sb = new StringBuilder(); + String line = null; + try { + while ((line = reader.readLine()) != null) { + sb.append(line); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return sb.toString(); + } + +} \ No newline at end of file diff --git a/iot-access/access-boot/src/main/resources/bootstrap.yml b/iot-access/access-boot/src/main/resources/bootstrap.yml index 31c96c0..0a68b15 100644 --- a/iot-access/access-boot/src/main/resources/bootstrap.yml +++ b/iot-access/access-boot/src/main/resources/bootstrap.yml @@ -36,7 +36,6 @@ spring: main: allow-bean-definition-overriding: true - #项目日志的配置 logging: config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml diff --git a/iot-access/pom.xml b/iot-access/pom.xml index 9ed7a61..151b06f 100644 --- a/iot-access/pom.xml +++ b/iot-access/pom.xml @@ -13,8 +13,8 @@ pom iot-access - - http://www.example.com + 物接入模块 + access-api access-boot diff --git a/pom.xml b/pom.xml index 439c7c8..3dfcec1 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ - 192.168.1.18 + 192.168.1.13 192.168.1.139 @@ -40,7 +40,7 @@ ${middle.server.url}:18848 - 9a99958c-ed20-439a-8504-0544cea8e520 + 415a1c87-33aa-47bd-8e25-13cc456c87ed ${middle.server.url}:8080 @@ -98,6 +98,7 @@ 4.8.1 8.2.1 1.7.0-Hoxton + 2.9.6 @@ -123,14 +124,6 @@ pom import - - - com.huaweicloud - spring-cloud-huawei-dependencies - ${spring-cloud-huawei.version} - pom - import - @@ -352,6 +345,12 @@ dynamic-datasource-spring-boot-starter ${dynamic-datasource.version} + + + org.springframework.kafka + spring-kafka + ${kafka.version} +