diff --git a/iot-access/access-api/pom.xml b/iot-access/access-api/pom.xml index 8426020..89d2f34 100644 --- a/iot-access/access-api/pom.xml +++ b/iot-access/access-api/pom.xml @@ -21,10 +21,24 @@ - junit - junit - 4.11 - test + com.njcn + common-core + ${project.version} + + + com.njcn + common-db + ${project.version} + + + com.njcn + common-microservice + ${project.version} + + + com.njcn + common-poi + ${project.version} 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/annotation/ParamName.java similarity index 91% rename from iot-access/access-api/src/main/java/com/njcn/access/param/ParamName.java rename to iot-access/access-api/src/main/java/com/njcn/access/annotation/ParamName.java index 97709a9..aa3910f 100644 --- 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/annotation/ParamName.java @@ -1,4 +1,4 @@ -package com.njcn.access.param; +package com.njcn.access.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; 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 index fbc0a3b..48202ba 100644 --- 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 @@ -14,19 +14,22 @@ public enum AccessResponseEnum { * A0301 ~ A0399 用于用户模块的枚举 *

*/ - NDID_NO_FIND("A0301", "与平台nDid匹配错误!"), + NDID_NO_FIND("A0301", "nDid在平台端未找到或者已接入"), MODEL_REPEAT("A0302", "模板重复,请勿重复录入!"), MODEL_NO_FIND("A0302", "模板不存在,请先录入模板数据!"), MESSAGE_TYPE_ERROR("A0303","报文消息类型Type错误!"), DEV_TYPE_ERROR("A0303","装置类型错误!"), + DEV_NOT_FIND("A0303","装置类型未找到!"), + DEV_MODEL_NOT_FIND("A0303","装置型号未找到!"), + DEV_IS_NOT_ZL("A0303","注册装置不是直连装置!"), - RESPONSE_ERROR("A0304","装置请求响应错误!"), + REGISTER_RESPONSE_ERROR("A0304","装置注册,装置侧应答失败!"), DEV_TYPE_NOT_FIND("A0305","装置类型未找到,需要录入!"), - NO_RECEIVE_FROM_DEV("A0306","未收到装置注册响应,请核查!"), + REGISTER_ERROR("A0306","装置注册失败!"), DICT_MISSING("A0307","字典数据缺失!"), EPD_DICT_MISSING("A0307","Epd字典数据缺失!"), @@ -42,6 +45,9 @@ public enum AccessResponseEnum { INSET_DICT_MISSING("A0307","InSet字典数据缺失!"), CTRL_DICT_MISSING("A0307","Ctrl字典数据缺失!"), + MODEL_MISS("A0308","模板信息缺失!"), + MODEL_VERSION_ERROR("A0308","询问装置模板信息错误"), + ; private final String code; diff --git a/iot-access/access-api/src/main/java/com/njcn/access/param/DevAccessParam.java b/iot-access/access-api/src/main/java/com/njcn/access/param/DevAccessParam.java new file mode 100644 index 0000000..46d815f --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/param/DevAccessParam.java @@ -0,0 +1,71 @@ +package com.njcn.access.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/7/5 16:25 + */ +@Data +public class DevAccessParam implements Serializable { + + @ApiModelProperty("项目id") + @NotNull(message = "项目id不能为空") + private String projectId; + + @ApiModelProperty("区域") + private String area; + + @ApiModelProperty("拓扑图id") + @NotNull(message = "拓扑图id不能为空") + private String topologyDiagram; + + @ApiModelProperty("设备识别码") + @NotNull(message = "设备识别码不能为空") + private String nDid; + + @ApiModelProperty("监测点集合") + @NotNull(message = "监测点集合不能为空") + private List list; + + @Data + public static class LineParam { + + @ApiModelProperty("监测点名称") + @NotNull(message = "监测点名称不能为空") + private String name; + + @ApiModelProperty("安装位置") + @NotNull(message = "安装位置不能为空") + private String position; + + @ApiModelProperty("电压等级") + @NotNull(message = "电压等级不能为空") + private String volGrade; + + @ApiModelProperty("PT变比") + @NotNull(message = "PT变比不能为空") + private String ptRatio; + + @ApiModelProperty("CT变比") + @NotNull(message = "CT变比不能为空") + private String ctRatio; + + @ApiModelProperty("中心点经度") + @NotNull(message = "中心点经度不能为空") + private Double lng; + + @ApiModelProperty("中心点纬度") + @NotNull(message = "中心点纬度不能为空") + private Double lat; + } + +} 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 index a650d8f..229c140 100644 --- 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 @@ -1,6 +1,6 @@ package com.njcn.access.pojo.dto; -import com.njcn.access.param.ParamName; +import com.njcn.access.annotation.ParamName; import lombok.Data; import java.io.Serializable; 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 index 25dcd39..569309c 100644 --- 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 @@ -1,8 +1,7 @@ package com.njcn.access.pojo.dto; import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; -import com.njcn.access.param.ParamName; -import io.swagger.annotations.ApiModelProperty; +import com.njcn.access.annotation.ParamName; import lombok.Data; import javax.validation.constraints.NotNull; 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 index 31f81dc..e96b0c4 100644 --- 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 @@ -1,8 +1,11 @@ package com.njcn.access.pojo.dto; import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.List; @@ -12,16 +15,43 @@ import java.util.List; * * @author xuyang * @version 1.0.0 - * @createTime 2023/4/10 10:54 + * @createTime 2023/7/5 11:26 */ @Data public class ModelDto implements Serializable { - @SerializedName("DevCfg") - @NotNull(message = "设备配置序列,不为空") - private List devCfg; + @SerializedName("Mid") + @ApiModelProperty("报文ID,在请求报文中该值为请求ID") + @NotNull(message = "报文ID不能为空") + private Integer mid; - @SerializedName("DevModInfo") - @NotNull(message = "设备模板信息序列,不为空") - private List devMod; + @SerializedName("Did") + @ApiModelProperty("设备唯一标识lDid,填入0代表nDid") + @NotBlank(message = "设备唯一标识lDid不能为空") + private String did; + + @SerializedName("Pri") + @ApiModelProperty("报文处理的优先级") + @NotNull(message = "报文处理的优先级不能为空") + private Integer pri; + + @SerializedName("Type") + @ApiModelProperty("消息类型") + @NotNull(message = "消息类型不能为空") + private String type; + + @SerializedName("Msg") + @ApiModelProperty("报文内容") + private Msg msg; + + @Data + public static class Msg { + @SerializedName("DevCfg") + @ApiModelProperty("设备配置序列") + private List devCfg; + + @SerializedName("DevModInfo") + @ApiModelProperty("设备模板信息序列") + private List devMod; + } } diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/param/ReqAndResParam.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/ReqAndResDto.java similarity index 89% rename from iot-access/access-api/src/main/java/com/njcn/access/pojo/param/ReqAndResParam.java rename to iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/ReqAndResDto.java index 96f115f..521ffd5 100644 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/param/ReqAndResParam.java +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/ReqAndResDto.java @@ -1,4 +1,4 @@ -package com.njcn.access.pojo.param; +package com.njcn.access.pojo.dto; import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; import io.swagger.annotations.ApiModelProperty; @@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.io.Serializable; +import java.util.List; /** * 类的介绍: @@ -17,7 +18,7 @@ import java.io.Serializable; * @createTime 2023/4/20 14:05 */ @Data -public class ReqAndResParam implements Serializable { +public class ReqAndResDto implements Serializable { @SerializedName("Mid") @ApiModelProperty("报文ID,在请求报文中该值为请求ID") @@ -48,7 +49,7 @@ public class ReqAndResParam implements Serializable { */ @Data @EqualsAndHashCode(callSuper = true) - public static class Req extends ReqAndResParam { + public static class Req extends ReqAndResDto { @SerializedName("Expire") @ApiModelProperty("此报文过期的相对时间,单位秒,该字段为-1时表示永不过期.控制类报文接收者超时处理按此时间") @NotNull(message = "报文过期的相对时间不能为空") @@ -60,10 +61,11 @@ public class ReqAndResParam implements Serializable { */ @Data @EqualsAndHashCode(callSuper = true) - public static class Res extends ReqAndResParam { + public static class Res extends ReqAndResDto { @SerializedName("Code") @ApiModelProperty("标识应答的返回码") @NotNull(message = "状态码不能为空") private Integer code; } + } 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 index 03743a7..8b89f97 100644 --- 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 @@ -38,17 +38,8 @@ public class StsDto implements Serializable { @NotNull(message = "当前值,不为空") private Integer curSts; - @SerializedName("ClassID") - @NotNull(message = "数据分类,不为空") - private String classId; - @SerializedName("TranRule") @NotNull(message = "上送规则,不为空") @ApiModelProperty("变化:change 周期:period") private String tranRule; - - //todo 不确定是否还有这个字段先保留 - @SerializedName("GroupId") - @NotNull(message = "数据分组组号,不为空") - private List groupId; } diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ApfDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ApfDto.java new file mode 100644 index 0000000..056ac95 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ApfDto.java @@ -0,0 +1,45 @@ +package com.njcn.access.pojo.dto.devModel; + +import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/7/3 15:15 + */ +@Data +public class ApfDto implements Serializable { + + @SerializedName("OpAttr") + @NotNull(message = "读写操作属性,不为空") + private String opAttr; + + @SerializedName("Name") + @NotNull(message = "数据名称,不为空") + private String name; + + @SerializedName("IDX") + @NotNull(message = "数据编号,不为空") + private Integer idx; + + @SerializedName("Type") + @NotNull(message = "数据类型,不为空") + private String type; + + @SerializedName("Unit") + @ApiModelProperty("单位") + private String unit; + + @SerializedName("StatMethod") + @ApiModelProperty("数据统计方法(max,min,avg,cp95)") + private List statMethod; + +} 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 deleted file mode 100644 index b504f01..0000000 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/CfgDto.java +++ /dev/null @@ -1,63 +0,0 @@ -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/ClDevDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ClDevDto.java index f6da881..3f8272c 100644 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ClDevDto.java +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/ClDevDto.java @@ -28,7 +28,7 @@ public class ClDevDto implements Serializable { @SerializedName("DataList") @NotEmpty(message = "数据模型列表,不可为空") - private List dataList; + private List dataList; @SerializedName("DataSet") @NotEmpty(message = "数据集序列,不可为空") diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevModDataListDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevModDataListDto.java deleted file mode 100644 index 27d6cfc..0000000 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevModDataListDto.java +++ /dev/null @@ -1,77 +0,0 @@ -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 lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.io.Serializable; -import java.util.List; - -/** - * 类的介绍: - * - * @author xuyang - * @version 1.0.0 - * @createTime 2023/5/16 15:27 - */ -@Data -public class DevModDataListDto implements Serializable { - - @SerializedName("SoftInfo") - @NotEmpty(message = "软件信息,不可为空") - private SoftInfoDto softInfoDto; - - @SerializedName("LdevInfo") - @NotEmpty(message = "设备信息,不可为空") - private List lDevInfoDto; - - @SerializedName("Epd") - @NotEmpty(message = "电能数据,不可为空") - private List epdDto; - - @SerializedName("Pqd") - @NotEmpty(message = "电能质量数据,不可为空") - private List pqdDto; - - @SerializedName("Bmd") - @NotEmpty(message = "基础测量数据,不可为空") - private List bmdDto; - - @SerializedName("Evt") - @NotEmpty(message = "事件,不可为空") - private List evtDto; - - @SerializedName("Alm") - @NotEmpty(message = "告警,不可为空") - private List almDto; - - @SerializedName("Sts") - @NotEmpty(message = "状态,不可为空") - private List stsDto; - - @SerializedName("Di") - @NotEmpty(message = "开入,不可为空") - private List diDto; - - @SerializedName("Do") - @NotEmpty(message = "开出,不可为空") - private List doDto; - - @SerializedName("Parm") - @NotEmpty(message = "参数,不可为空") - private List parmDto; - - @SerializedName("Set") - @NotEmpty(message = "定值,不可为空") - private List setDto; - - @SerializedName("InSet") - @NotEmpty(message = "内部定值,不可为空") - private List inSetDto; - - @SerializedName("Ctrl") - @NotEmpty(message = "控制,不可为空") - private List ctrlDto; - -} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevModDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevModDto.java deleted file mode 100644 index 929248c..0000000 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/DevModDto.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.njcn.access.pojo.dto.devModel; - -import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.io.Serializable; -import java.util.List; - -/** - * 类的介绍: - * - * @author xuyang - * @version 1.0.0 - * @createTime 2023/5/4 10:00 - */ -@Data -public class DevModDto implements Serializable { - - @SerializedName("Version") - @NotEmpty(message = "直连装置/网关版本号,不可为空") - private String version; - - @SerializedName("Time") - @NotEmpty(message = "创建或最后修改时间,不可为空") - private String time; - - @SerializedName("DevType") - @NotEmpty(message = "设备型号,不可为空") - private String devType; - - @SerializedName("DataList") - @NotEmpty(message = "数据模型列表,不可为空") - private List dataList; - - @SerializedName("DataSet") - @NotEmpty(message = "数据集,不可为空") - private List dataSetDtoList; - - @SerializedName("Cldev") - @ApiModelProperty(value = "逻辑子设备序列") - private List clDevDtoList; -} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/NetDevModDataListDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/NetDevModDataListDto.java deleted file mode 100644 index afd90d8..0000000 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/NetDevModDataListDto.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.njcn.access.pojo.dto.devModel; - -import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import java.io.Serializable; - -/** - * 类的介绍: - * - * @author xuyang - * @version 1.0.0 - * @createTime 2023/5/16 15:27 - */ -@Data -public class NetDevModDataListDto implements Serializable { - - @SerializedName("SoftInfo") - @NotEmpty(message = "软件信息,不可为空") - private SoftInfoDto softInfoDto; - - @SerializedName("PrjInfo") - @NotEmpty(message = "工程信息,不可为空") - private PrjInfoDto prjInfoDto; - -} 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 deleted file mode 100644 index 92b2e6c..0000000 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/devModel/NetDevModDto.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.njcn.access.pojo.dto.devModel; - -import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -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("Version") - @NotEmpty(message = "直连装置/网关版本号,不可为空") - private String version; - - @SerializedName("Time") - @NotEmpty(message = "创建或最后修改时间,不可为空") - private String time; - - @SerializedName("DevType") - @NotEmpty(message = "设备型号,不可为空") - private String devType; - - @SerializedName("DataList") - @NotEmpty(message = "数据模型列表,不可为空") - private List dataList; -} 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 index a613c69..f340c2d 100644 --- 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 @@ -1,10 +1,13 @@ 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 io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotEmpty; import java.io.Serializable; +import java.util.List; /** * 类的介绍: @@ -16,12 +19,88 @@ import java.io.Serializable; @Data public class TemplateDto implements Serializable { - @SerializedName("NetDevMod") - @NotEmpty(message = "直连装置/网关信息描述表,不为空") - private NetDevModDto netDevModDto; + @SerializedName("Version") + @NotEmpty(message = "版本号,不可为空") + private String version; - @SerializedName("DevMod") - @NotEmpty(message = "逻辑设备数据模板说明,不为空") - private DevModDto devModDto; + @SerializedName("Time") + @NotEmpty(message = "创建或最后修改时间,不可为空") + private String time; + + @SerializedName("DevType") + @NotEmpty(message = "设备型号,不可为空") + private String devType; + + @SerializedName("DataList") + @NotEmpty(message = "数据模型列表,不可为空") + private List dataList; + + @SerializedName("DataSet") + @NotEmpty(message = "数据集,不可为空") + private List dataSet; + + @SerializedName("Cldev") + @ApiModelProperty(value = "逻辑子设备序列") + private List clDevDtoList; + + @SerializedName("SoftInfo") + @NotEmpty(message = "软件信息,不可为空") + private List softInfoDto; + + @SerializedName("LdevInfo") + @NotEmpty(message = "设备信息,不可为空") + private List lDevInfoDto; + + @SerializedName("Apf") + @NotEmpty(message = "谐波治理设备Apf,不可为空") + private List apfDto; + + @SerializedName("Epd") + @ApiModelProperty("电能数据") + private List epdDto; + + @SerializedName("Pqd") + @ApiModelProperty("电能质量数据") + private List pqdDto; + + @SerializedName("Bmd") + @ApiModelProperty("基础测量数据") + private List bmdDto; + + @SerializedName("Evt") + @ApiModelProperty("事件") + private List evtDto; + + @SerializedName("Alm") + @ApiModelProperty("告警") + private List almDto; + + @SerializedName("Sts") + @ApiModelProperty("状态") + private List stsDto; + + @SerializedName("Di") + @ApiModelProperty("开入") + private List diDto; + + @SerializedName("Do") + @ApiModelProperty("开出") + private List doDto; + + @SerializedName("Parm") + @ApiModelProperty("参数") + private List parmDto; + + @SerializedName("Set") + @ApiModelProperty("定值") + private List setDto; + + @SerializedName("InSet") + @ApiModelProperty("内部定值") + private List inSetDto; + + @SerializedName("Ctrl") + @ApiModelProperty("控制") + private List ctrlDto; } diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/heart/HeartBeatDto.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/heart/HeartBeatDto.java index 1e0b501..c37a135 100644 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/heart/HeartBeatDto.java +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/dto/heart/HeartBeatDto.java @@ -1,6 +1,6 @@ package com.njcn.access.pojo.dto.heart; -import com.njcn.access.param.ParamName; +import com.njcn.access.annotation.ParamName; import lombok.Data; import java.io.Serializable; diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/MessageParam.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/param/MessageParam.java similarity index 84% rename from iot-access/access-api/src/main/java/com/njcn/access/pojo/MessageParam.java rename to iot-access/access-api/src/main/java/com/njcn/access/pojo/param/MessageParam.java index 90a8226..7b4b763 100644 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/MessageParam.java +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/param/MessageParam.java @@ -1,4 +1,4 @@ -package com.njcn.access.pojo; +package com.njcn.access.pojo.param; import lombok.Data; diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsAlmPO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsAlmPO.java deleted file mode 100644 index bd88151..0000000 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsAlmPO.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.njcn.access.pojo.po; - -import com.baomidou.mybatisplus.annotation.TableName; -import com.github.jeffreyning.mybatisplus.anno.MppMultiId; -import com.njcn.db.bo.BaseEntity; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - *

- * 设备告警数据表 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@TableName("cs_alm") -@Deprecated -public class CsAlmPO extends BaseEntity { - - private static final long serialVersionUID = 1L; - - /** - * id - */ - private String id; - - /** - * 读写操作属性:“r” - */ - private String opAttr; - - /** - * 告警事件名称 - */ - @MppMultiId(value = "name") - private String name; - - /** - * 告警事件编号 - */ - private Integer idx; - - /** - * 告警事件类别“1”“2” - */ - private String type; - - /** - * 别名 - */ - private String anotherName; - - /** - * 数据分类,唯一类别 - */ - private String classId; - - -} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsBmdPO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsBmdPO.java deleted file mode 100644 index 771e712..0000000 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsBmdPO.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.njcn.access.pojo.po; - -import com.baomidou.mybatisplus.annotation.TableName; -import com.github.jeffreyning.mybatisplus.anno.MppMultiId; -import lombok.Data; - -/** - *

- * - *

- * - * @author xuyang - * @since 2023-05-11 - */ -@Data -@TableName("cs_bmd") -@Deprecated -public class CsBmdPO { - - private static final long serialVersionUID = 1L; - - private String id; - - @MppMultiId(value = "name") - private String name; - - private String anotherName; - - private Integer idx; - - private String type; - - private String unit; - - @MppMultiId(value = "phase") - private String phase; - - private String classId; - - private String statMethod; - - private String tranRule; - - private String opAttr; - -} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsCtrlPO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsCtrlPO.java deleted file mode 100644 index 99be484..0000000 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsCtrlPO.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.njcn.access.pojo.po; - -import com.baomidou.mybatisplus.annotation.TableName; -import com.github.jeffreyning.mybatisplus.anno.MppMultiId; -import com.njcn.db.bo.BaseEntity; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import javax.naming.Name; - -/** - *

- * 控制表 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@TableName("cs_ctrl") -@Deprecated -public class CsCtrlPO extends BaseEntity { - - private static final long serialVersionUID = 1L; - - /** - * id - */ - private String id; - - /** - * 读写操作属性:“r” - */ - private String opAttr; - - /** - * 参数名称 - */ - @MppMultiId(value = "name") - private String name; - - /** - * 别名 - */ - private String anotherName; - - /** - * 参数编号 - */ - private Integer idx; - - /** - * 下发数据类型 “string”“float”“enum” - */ - private String type; - - /** - * 是否需遥控校验 “1”“0” - */ - private Integer remoteControlCheck; - - /** - * 是否支持自动控制 “1”“0” - */ - private Integer auto; - - /** - * 设置最大值 - */ - private Integer maxNum; - - /** - * 设置最小值 - */ - private Integer minNum; - - /** - * 参数为enum可设置的所有值序列 - */ - private String ctlValue; - - /** - * 参数string可设置字符串的长度上限 - */ - private Integer strlen; - - /** - * 是否加密,“1”“0” - */ - private Integer encode; - - /** - * 数据分类,唯一类别 - */ - private String classId; - - -} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsDiPO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsDiPO.java deleted file mode 100644 index 0b7d6c7..0000000 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsDiPO.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.njcn.access.pojo.po; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.github.jeffreyning.mybatisplus.anno.MppMultiId; -import com.njcn.db.bo.BaseEntity; -import java.io.Serializable; -import java.time.LocalDateTime; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; - -/** - *

- * 开入表 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@TableName("cs_di") -@Deprecated -public class CsDiPO extends BaseEntity { - - private static final long serialVersionUID = 1L; - - /** - * Id - */ - private String id; - - /** - * 读写操作属性:“r” - */ - private String opAttr; - - /** - * 开入信号名称 - */ - @MppMultiId(value = "name") - private String name; - - /** - * 开入编号 - */ - private Integer idx; - - /** - * 是否存储“1”“0” - */ - private Integer storeFlag; - - /** - * 当前值“1”“0” - */ - private Integer curSts; - - /** - * 数据分类,唯一类别 - */ - private String classId; - - /** - * 数据是否上送 “1”“0” - */ - private Integer tranFlag; - - /** - * 上送规则 变化:“change”周期:“period” - */ - private String tranRule; - - /** - * 别名 - */ - private String anotherName; - - -} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsDoPO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsDoPO.java deleted file mode 100644 index dcd613d..0000000 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsDoPO.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.njcn.access.pojo.po; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.github.jeffreyning.mybatisplus.anno.MppMultiId; -import com.njcn.db.bo.BaseEntity; -import java.io.Serializable; -import java.time.LocalDateTime; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; - -/** - *

- * 开出表 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@TableName("cs_do") -@Deprecated -public class CsDoPO extends BaseEntity { - - private static final long serialVersionUID = 1L; - - /** - * Id - */ - private String id; - - /** - * 读写操作属性:“r” - */ - private String opAttr; - - /** - * 开出信号名称 - */ - @MppMultiId(value = "name") - private String name; - - /** - * DO编号 - */ - private Integer idx; - - /** - * 当前值/设定值“1”“0” - */ - private Integer curSts; - - /** - * 是否可远程控制 “1”“0” - */ - private Integer ctlSts; - - /** - * 创建用户 - */ - private String createBy; - - /** - * 创建时间 - */ - private LocalDateTime createTime; - - /** - * 更新用户 - */ - private String updateBy; - - /** - * 更新时间 - */ - private LocalDateTime updateTime; - - /** - * 别名 - */ - private String anotherName; - - /** - * 数据分类,唯一类别 - */ - private String classId; - - -} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsEpdPqdPO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsEpdPqdPO.java deleted file mode 100644 index f1e2f41..0000000 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsEpdPqdPO.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.njcn.access.pojo.po; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.github.jeffreyning.mybatisplus.anno.MppMultiId; -import lombok.Data; - -/** - *

- * - *

- * - * @author xuyang - * @since 2023-05-11 - */ -@Data -@TableName("cs_epd_pqd") -@Deprecated -public class CsEpdPqdPO { - - private static final long serialVersionUID = 1L; - - @MppMultiId(value = "name") - private String name; - - @MppMultiId(value = "phase") - private String phase; - - @TableField(value = "id") - private String id; - - @TableField(value = "another_name") - private String anotherName; - - @TableField(value = "idx") - private Integer idx; - - @TableField(value = "type") - private String type; - - @TableField(value = "unit") - private String unit; - - @TableField(value = "harm_start") - private Integer harmStart; - - @TableField(value = "harm_end") - private Integer harmEnd; - - @TableField(value = "class_id") - private String classId; - - @TableField(value = "stat_method") - private String statMethod; - - @TableField(value = "op_attr") - private String opAttr; - -} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsEvtPO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsEvtPO.java deleted file mode 100644 index 31ddaac..0000000 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsEvtPO.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.njcn.access.pojo.po; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.github.jeffreyning.mybatisplus.anno.MppMultiId; -import com.njcn.db.bo.BaseEntity; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.time.LocalDateTime; - -/** - *

- * 事件表 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@TableName("cs_evt") -@Deprecated -public class CsEvtPO extends BaseEntity { - - private static final long serialVersionUID = 1L; - - /** - * id - */ - private String id; - - /** - * 读写操作属性:“r” - */ - private String opAttr; - - /** - * 事件信息名称 - */ - @MppMultiId(value = "name") - private String name; - - /** - * 事件编号 - */ - private Integer idx; - - /** - * 事件类别“1”“2” - */ - private String type; - - /** - * 创建用户 - */ - private String createBy; - - /** - * 创建时间 - */ - private LocalDateTime createTime; - - /** - * 更新用户 - */ - private String updateBy; - - /** - * 更新时间 - */ - private LocalDateTime updateTime; - - /** - * 别名 - */ - private String anotherName; - - /** - * 数据分类,唯一类别 - */ - private String classId; - - -} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsLineModel.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsLineModel.java new file mode 100644 index 0000000..171b775 --- /dev/null +++ b/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsLineModel.java @@ -0,0 +1,62 @@ +package com.njcn.access.pojo.po; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.njcn.db.bo.BaseEntity; +import java.io.Serializable; +import java.time.LocalDateTime; + +import lombok.Data; +import lombok.Getter; +import lombok.Setter; + +/** + *

+ * 监测点模板表 + *

+ * + * @author xuyang + * @since 2023-07-05 + */ +@Data +@TableName("cs_line_model") +public class CsLineModel { + + private static final long serialVersionUID = 1L; + + /** + * 监测点id + */ + private String lineId; + + /** + * 模板id + */ + private String pid; + + /** + * 监测点默认名称 + */ + private String name; + + /** + * 安装位置 + */ + private String position; + + /** + * 电压等级 + */ + private String volGrade; + + /** + * PT变比 + */ + private String ptRatio; + + /** + * CT变比 + */ + private String ctRatio; + + +} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsParmPO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsParmPO.java deleted file mode 100644 index 64a79ef..0000000 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsParmPO.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.njcn.access.pojo.po; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.github.jeffreyning.mybatisplus.anno.MppMultiId; -import com.njcn.db.bo.BaseEntity; -import java.io.Serializable; -import java.time.LocalDateTime; - -import lombok.Data; -import lombok.Getter; -import lombok.Setter; - -/** - *

- * 参数表 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -@Data -@TableName("cs_parm") -@Deprecated -public class CsParmPO extends BaseEntity { - - private static final long serialVersionUID = 1L; - - private String id; - - /** - * 读写操作属性:“r” - */ - private String opAttr; - - /** - * 参数名称 - */ - @MppMultiId(value = "name") - private String name; - - /** - * 别名 - */ - private String anotherName; - - /** - * 参数编号 - */ - private Integer idx; - - /** - * 系统参数:“sys”运行参数:“run” 功能参数:“fun” - */ - private String type; - - /** - * 参数数据类型 “string”“float”“enum” - */ - private String dataType; - - /** - * 是否可修改 “1”“0” - */ - private Integer modifyFlag; - - /** - * 设置最大值 - */ - private Integer maxNum; - - /** - * 设置最小值 - */ - private Integer minNum; - - /** - * 参数为enum可设置的所有值序列 - */ - private String setValue; - - /** - * 参数string可设置字符串的长度上限 - */ - private Integer strlen; - - /** - * 参数缺省值 - */ - private String defaultValue; - - /** - * 数据分类,唯一类别 - */ - private String classId; - - -} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsSetPO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsSetPO.java deleted file mode 100644 index 0027a76..0000000 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsSetPO.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.njcn.access.pojo.po; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.github.jeffreyning.mybatisplus.anno.MppMultiId; -import com.njcn.db.bo.BaseEntity; -import java.io.Serializable; -import java.time.LocalDateTime; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; - -/** - *

- * 设备定值数据表 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@TableName("cs_set") -@Deprecated -public class CsSetPO extends BaseEntity { - - private static final long serialVersionUID = 1L; - - /** - * id - */ - private String id; - - /** - * 读写操作属性:“r” - */ - private String opAttr; - - /** - * 参数名称 - */ - @MppMultiId(value = "name") - private String name; - - /** - * 别名 - */ - private String anotherName; - - /** - * 参数编号 - */ - private Integer idx; - - /** - * 定值数据类型 “hex”“number” - */ - private String dataType; - - /** - * 设置最大值 - */ - private Integer maxNum; - - /** - * 设置最小值 - */ - private Integer minNum; - - /** - * 定值缺省值 - */ - private String defaultValue; - - /** - * 数据分类,唯一类别 - */ - private String classId; - - /** - * 创建用户 - */ - private String createBy; - - /** - * 创建时间 - */ - private LocalDateTime createTime; - - /** - * 更新用户 - */ - private String updateBy; - - /** - * 更新时间 - */ - private LocalDateTime updateTime; - - -} diff --git a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsStsPO.java b/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsStsPO.java deleted file mode 100644 index d585b5a..0000000 --- a/iot-access/access-api/src/main/java/com/njcn/access/pojo/po/CsStsPO.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.njcn.access.pojo.po; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.github.jeffreyning.mybatisplus.anno.MppMultiId; -import com.njcn.db.bo.BaseEntity; -import java.io.Serializable; -import java.time.LocalDateTime; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; - -/** - *

- * 状态表 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@TableName("cs_sts") -@Deprecated -public class CsStsPO extends BaseEntity { - - private static final long serialVersionUID = 1L; - - /** - * id - */ - private String id; - - /** - * 读写操作属性:“r” - */ - private String opAttr; - - /** - * 状态名称 - */ - @MppMultiId(value = "name") - private String name; - - /** - * 状态编号 - */ - private Integer idx; - - /** - * 是否存储“1”“0” - */ - private Integer storeFlag; - - /** - * 当前值“1”“0” - */ - private Integer curSts; - - /** - * 数据分类,唯一类别 - */ - private String classId; - - /** - * 上送规则 变化:“change”周期:“period” - */ - private String tranRule; - - /** - * 别名 - */ - private String anotherName; - - -} diff --git a/iot-access/access-boot/pom.xml b/iot-access/access-boot/pom.xml index 721dc4c..37e6154 100644 --- a/iot-access/access-boot/pom.xml +++ b/iot-access/access-boot/pom.xml @@ -23,16 +23,6 @@ com.njcn access-api - 1.0.0 - - - com.njcn - algorithm-api - ${project.version} - - - com.njcn - cs-system-api ${project.version} @@ -40,6 +30,34 @@ system-api ${project.version} + + com.njcn + cs-device-api + ${project.version} + + + com.njcn + common-web + ${project.version} + + + com.njcn + common-oss + ${project.version} + + + com.njcn + common-swagger + ${project.version} + + + com.baomidou + dynamic-datasource-spring-boot-starter + + + org.springframework.kafka + spring-kafka + diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/AccessBootApplication.java b/iot-access/access-boot/src/main/java/com/njcn/access/AccessBootApplication.java index 8e76c47..aea9d0b 100644 --- a/iot-access/access-boot/src/main/java/com/njcn/access/AccessBootApplication.java +++ b/iot-access/access-boot/src/main/java/com/njcn/access/AccessBootApplication.java @@ -1,6 +1,5 @@ package com.njcn.access; -import com.github.jeffreyning.mybatisplus.conf.EnableMPP; import lombok.extern.slf4j.Slf4j; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; @@ -17,7 +16,6 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @MapperScan("com.njcn.**.mapper") @EnableFeignClients(basePackages = "com.njcn") @SpringBootApplication(scanBasePackages = "com.njcn") -@EnableMPP public class AccessBootApplication { public static void main(String[] args) { 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 deleted file mode 100644 index 1f30ab6..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/config/SwaggerConfig.java +++ /dev/null @@ -1,91 +0,0 @@ -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 deleted file mode 100644 index 91cc5f5..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/controller/AccessController.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.njcn.access.controller; - -import com.njcn.web.controller.BaseController; -import io.swagger.annotations.Api; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * 类的介绍: - * - * @author xuyang - * @version 1.0.0 - * @createTime 2023/5/16 13:58 - */ -@Slf4j -@RestController -@RequestMapping("/devAccess") -@RequiredArgsConstructor -@Api(tags = "装置接入") -public class AccessController extends BaseController { - - - - - - - - - - -} 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/CsDevModelController.java similarity index 59% rename from iot-access/access-boot/src/main/java/com/njcn/access/controller/DevModelController.java rename to iot-access/access-boot/src/main/java/com/njcn/access/controller/CsDevModelController.java index 01cda2d..47674d3 100644 --- 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/CsDevModelController.java @@ -1,20 +1,21 @@ package com.njcn.access.controller; import com.njcn.access.pojo.param.DevModelParam; -import com.njcn.access.service.IDevModelService; +import com.njcn.access.service.ICsDevModelService; 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.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -23,27 +24,26 @@ import org.springframework.web.bind.annotation.RestController; * * @author xuyang * @version 1.0.0 - * @createTime 2023/4/10 10:26 + * @createTime 2023/7/3 15:31 */ @Slf4j @RestController -@RequestMapping("/devModel") +@RequestMapping("/analyzeModel") +@Api(tags = "模板解析") @AllArgsConstructor -@Validated -@Api(tags = "装置模板录入") -public class DevModelController extends BaseController { +public class CsDevModelController extends BaseController { - private final IDevModelService devModelService; + private final ICsDevModelService csDevModelService; - @PostMapping("/add") @OperateInfo(info = LogEnum.BUSINESS_COMMON) - @ApiOperation("装置录入模板") - public HttpResult add(DevModelParam devModelParam){ - log.info("装置录入模板文件"); - String methodDescribe = getMethodDescribe("add"); - LogUtil.njcnDebug(log, "{},装置录入模板文件", methodDescribe); - devModelService.add(devModelParam); + @PostMapping("/addModel") + @ApiOperation("新增设备模板") + @ApiImplicitParam(name = "devModelParam", value = "设备模板参数", required = true) + public HttpResult addModel(@RequestBody @Validated DevModelParam devModelParam){ + String methodDescribe = getMethodDescribe("addModel"); + csDevModelService.addModel(devModelParam); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } + } diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsDeviceController.java b/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsDeviceController.java new file mode 100644 index 0000000..e6031ad --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsDeviceController.java @@ -0,0 +1,65 @@ +package com.njcn.access.controller; + +import com.njcn.access.param.DevAccessParam; +import com.njcn.access.service.ICsDeviceService; +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.web.controller.BaseController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +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.*; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/7/4 11:23 + */ +@Slf4j +@RestController +@RequestMapping("/device") +@Api(tags = "设备注册接入") +@AllArgsConstructor +@Validated +public class CsDeviceController extends BaseController { + + private final ICsDeviceService csDeviceService; + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/register") + @ApiOperation("设备注册") + @ApiImplicitParam(name = "nDid", value = "设备识别码", required = true) + public HttpResult devRegister(@RequestParam String nDid){ + csDeviceService.devRegister(nDid); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, "设备MQTT通讯状态!"); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/model") + @ApiOperation("获取装置模板信息") + @ApiImplicitParam(name = "nDid", value = "设备识别码", required = true) + public HttpResult getModel(@RequestParam String nDid){ + String methodDescribe = getMethodDescribe("getModel"); + Object object = csDeviceService.getModel(nDid); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, object, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/access") + @ApiOperation("设备接入") + @ApiImplicitParam(name = "devAccessParam", value = "接入参数", required = true) + public HttpResult devAccess(@RequestBody @Validated DevAccessParam devAccessParam){ + String methodDescribe = getMethodDescribe("getModel"); + csDeviceService.devAccess(devAccessParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } + +} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsNetDevController.java b/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsLineModelController.java similarity index 59% rename from iot-access/access-boot/src/main/java/com/njcn/access/controller/CsNetDevController.java rename to iot-access/access-boot/src/main/java/com/njcn/access/controller/CsLineModelController.java index 73c03fc..f259ded 100644 --- a/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsNetDevController.java +++ b/iot-access/access-boot/src/main/java/com/njcn/access/controller/CsLineModelController.java @@ -2,7 +2,7 @@ package com.njcn.access.controller; import io.swagger.annotations.Api; -import lombok.RequiredArgsConstructor; +import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.RequestMapping; @@ -11,18 +11,20 @@ import com.njcn.web.controller.BaseController; /** *

- * 联网设备表 前端控制器 + * 监测点模板表 前端控制器 *

* * @author xuyang - * @since 2023-05-17 + * @since 2023-07-05 */ -@RestController -@RequestMapping("/csNetDev") -@RequiredArgsConstructor -@Api(tags = "网关管理") @Slf4j -public class CsNetDevController extends BaseController { +@RestController +@RequestMapping("/csLineModel") +@Api(tags = "监测点模板") +@AllArgsConstructor +public class CsLineModelController extends BaseController { + + } diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/controller/KafkaController.java b/iot-access/access-boot/src/main/java/com/njcn/access/controller/KafkaController.java index 9242d94..d3b7404 100644 --- a/iot-access/access-boot/src/main/java/com/njcn/access/controller/KafkaController.java +++ b/iot-access/access-boot/src/main/java/com/njcn/access/controller/KafkaController.java @@ -1,54 +1,54 @@ -package com.njcn.access.controller; - -import com.njcn.access.pojo.MessageParam; -import com.njcn.web.controller.BaseController; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import lombok.extern.slf4j.Slf4j; -import org.apache.kafka.clients.consumer.ConsumerRecord; -import org.springframework.kafka.annotation.KafkaListener; -import org.springframework.kafka.core.KafkaTemplate; -import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.validation.Valid; - -/** - * 类的介绍: - * - * @author xuyang - * @version 1.0.0 - * @createTime 2023/4/18 13:53 - */ -@Slf4j -@RestController -@RequestMapping("/test") -@Api(value = "TestController", tags = {"测试 API"}) -public class KafkaController extends BaseController { - - @Resource - private KafkaTemplate kafkaTemplate; - - @PostMapping("/kafka/sendMessage") - @ApiOperation(value = "发送kafka告警消息") - public void sendKafkaMessage(@Valid @ApiParam("参数") @RequestBody MessageParam param) { - kafkaTemplate.send(param.getTopic(), param.getMessage()); - } - - @Component - public class KafkaConsumer { - // 消费监听 - @KafkaListener(topics = {"topic2"}) - public void onMessage1(ConsumerRecord record){ - // 消费的哪个topic、partition的消息,打印出消息内容 - System.out.println("简单消费:"+record.topic()+"-"+record.partition()+"-"+record.value()); - } - } - - -} +//package com.njcn.access.controller; +// +//import com.njcn.access.pojo.param.MessageParam; +//import com.njcn.web.controller.BaseController; +//import io.swagger.annotations.Api; +//import io.swagger.annotations.ApiOperation; +//import io.swagger.annotations.ApiParam; +//import lombok.extern.slf4j.Slf4j; +//import org.apache.kafka.clients.consumer.ConsumerRecord; +//import org.springframework.kafka.annotation.KafkaListener; +//import org.springframework.kafka.core.KafkaTemplate; +//import org.springframework.stereotype.Component; +//import org.springframework.web.bind.annotation.PostMapping; +//import org.springframework.web.bind.annotation.RequestBody; +//import org.springframework.web.bind.annotation.RequestMapping; +//import org.springframework.web.bind.annotation.RestController; +// +//import javax.annotation.Resource; +//import javax.validation.Valid; +// +///** +// * 类的介绍: +// * +// * @author xuyang +// * @version 1.0.0 +// * @createTime 2023/4/18 13:53 +// */ +//@Slf4j +//@RestController +//@RequestMapping("/test") +//@Api(value = "TestController", tags = {"测试 API"}) +//public class KafkaController extends BaseController { +// +// @Resource +// private KafkaTemplate kafkaTemplate; +// +// @PostMapping("/kafka/sendMessage") +// @ApiOperation(value = "发送kafka告警消息") +// public void sendKafkaMessage(@Valid @ApiParam("参数") @RequestBody MessageParam param) { +// kafkaTemplate.send(param.getTopic(), param.getMessage()); +// } +// +// @Component +// public class KafkaConsumer { +// // 消费监听 +// @KafkaListener(topics = {"topic2"}) +// public void onMessage1(ConsumerRecord record){ +// // 消费的哪个topic、partition的消息,打印出消息内容 +// System.out.println("简单消费:"+record.topic()+"-"+record.partition()+"-"+record.value()); +// } +// } +// +// +//} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/controller/RegisterController.java b/iot-access/access-boot/src/main/java/com/njcn/access/controller/RegisterController.java deleted file mode 100644 index ac8698c..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/controller/RegisterController.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.njcn.access.controller; - -import com.njcn.access.enums.AccessResponseEnum; -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.apache.poi.ss.formula.functions.T; -import org.springframework.web.bind.annotation.*; - -import java.util.Arrays; -import java.util.Optional; - -/** - * 类的介绍: - * - * @author xuyang - * @version 1.0.0 - * @createTime 2023/3/31 9:12 - */ -@Slf4j -@RestController -@RequestMapping("/devRegister") -@RequiredArgsConstructor -@Api(tags = "装置注册") -public class RegisterController 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/TopicController.java b/iot-access/access-boot/src/main/java/com/njcn/access/controller/TopicController.java deleted file mode 100644 index 59e1386..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/controller/TopicController.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.njcn.access.controller; - -import com.njcn.access.service.ICsTopicService; -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.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * 类的介绍: - * - * @author xuyang - * @version 1.0.0 - * @createTime 2023/5/12 10:28 - */ -@Slf4j -@RestController -@RequestMapping("/topic") -@RequiredArgsConstructor -@Api(tags = "装置主题") -public class TopicController extends BaseController { - - private final ICsTopicService csTopicService; - - @PostMapping("/ask") - @OperateInfo(info = LogEnum.BUSINESS_COMMON) - @ApiOperation("平台询问装置支持主题") - @ApiImplicitParam(name = "nDid", value = "网关识别码", required = true) - public HttpResult ask(@RequestParam String nDid){ - String methodDescribe = getMethodDescribe("ask"); - LogUtil.njcnDebug(log, "{},平台询问装置支持主题,请求的nDid为:{}", methodDescribe, nDid); - csTopicService.askDevTopic(nDid); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); - } - -} 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 index 1d3d049..a7775f6 100644 --- 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 @@ -1,5 +1,6 @@ package com.njcn.access.handler; +import com.alibaba.excel.util.CollectionUtils; import com.alibaba.nacos.shaded.com.google.gson.Gson; import com.github.tocrhz.mqtt.annotation.MqttSubscribe; import com.github.tocrhz.mqtt.annotation.NamedValue; @@ -10,22 +11,17 @@ import com.njcn.access.enums.AccessResponseEnum; import com.njcn.access.enums.TypeEnum; import com.njcn.access.pojo.dto.DevModInfoDto; import com.njcn.access.pojo.dto.ModelDto; -import com.njcn.access.pojo.dto.TopicDto; +import com.njcn.access.pojo.dto.ReqAndResDto; import com.njcn.access.pojo.dto.heart.HeartBeatDto; -import com.njcn.access.pojo.param.ReqAndResParam; -import com.njcn.access.pojo.po.CsTopicPO; -import com.njcn.access.service.ICsTopicService; -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.access.pojo.po.CsLineModel; +import com.njcn.access.service.ICsLineModelService; +import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.utils.PubUtils; +import com.njcn.csdevice.api.DevModelFeignClient; +import com.njcn.csdevice.api.EquipmentFeignClient; +import com.njcn.csdevice.pojo.po.CsDevModelPO; import com.njcn.redis.utils.RedisUtil; import com.njcn.system.api.DicDataFeignClient; -import com.njcn.system.enums.DicDataEnum; -import com.njcn.system.pojo.po.DictData; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.eclipse.paho.client.mqttv3.MqttMessage; @@ -33,11 +29,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import javax.validation.ConstraintViolation; import javax.validation.Validator; import java.nio.charset.StandardCharsets; -import java.time.Instant; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; /** * @author hongawen @@ -49,52 +45,52 @@ import java.util.*; @AllArgsConstructor public class MqttMessageHandler { - private final EquipmentFeignClient equipmentFeignClient; - private final DevModelFeignClient devModelFeignClient; + private final EquipmentFeignClient equipmentFeignClient; + private final DicDataFeignClient dicDataFeignClient; + private final ICsLineModelService csLineModelService; + private final MqttPublisher publisher; private final RedisUtil redisUtil; - private final ICsTopicService csTopicService; - @Autowired Validator validator; - @MqttSubscribe(value = "/Dev/Topic/{edgeId}",qos = 1) - @Transactional(rollbackFor = Exception.class) - public void devTopic(String topic, MqttMessage message, @NamedValue("edgeId") String nDid, @Payload String payload){ - Gson gson = new Gson(); - ReqAndResParam.Res res = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), ReqAndResParam.Res.class); - //检验传递的参数是否准确 - Set> validate = validator.validate(res); - validate.forEach(constraintViolation -> { - System.out.println(constraintViolation.getMessage()); - }); - if (Objects.equals(res.getCode(),AccessEnum.SUCCESS.getCode())){ - if (Objects.equals(res.getType(), TypeEnum.TYPE_1.getCode())){ - List list = new ArrayList<>(); - //fixme 这边获取数据需要调整 - Map> map = (Map>)res.getMsg(); - List topicList = map.get("Topic"); - topicList.forEach(item->{ - CsTopicPO csTopicPo = new CsTopicPO(); - csTopicPo.setNdid(nDid); - csTopicPo.setTopic(item); - csTopicPo.setType(0); - list.add(csTopicPo); - }); - csTopicService.addList(list); - } else { - log.info(AccessResponseEnum.MESSAGE_TYPE_ERROR.getMessage()); - } - } else { - log.info(AccessResponseEnum.RESPONSE_ERROR.getMessage()); - } - } +// @MqttSubscribe(value = "/Dev/Topic/{edgeId}",qos = 1) +// @Transactional(rollbackFor = Exception.class) +// public void devTopic(String topic, MqttMessage message, @NamedValue("edgeId") String nDid, @Payload String payload){ +// Gson gson = new Gson(); +// ReqAndResParam.Res res = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), ReqAndResParam.Res.class); +// //检验传递的参数是否准确 +// Set> validate = validator.validate(res); +// validate.forEach(constraintViolation -> { +// System.out.println(constraintViolation.getMessage()); +// }); +// if (Objects.equals(res.getCode(),AccessEnum.SUCCESS.getCode())){ +// if (Objects.equals(res.getType(), TypeEnum.TYPE_1.getCode())){ +// List list = new ArrayList<>(); +// //fixme 这边获取数据需要调整 +// Map> map = (Map>)res.getMsg(); +// List topicList = map.get("Topic"); +// topicList.forEach(item->{ +// CsTopicPO csTopicPo = new CsTopicPO(); +// csTopicPo.setNdid(nDid); +// csTopicPo.setTopic(item); +// csTopicPo.setType(0); +// list.add(csTopicPo); +// }); +// csTopicService.addList(list); +// } else { +// log.info(AccessResponseEnum.MESSAGE_TYPE_ERROR.getMessage()); +// } +// } else { +// log.info(AccessResponseEnum.RESPONSE_ERROR.getMessage()); +// } +// } /** * 装置注册应答 @@ -108,31 +104,26 @@ public class MqttMessageHandler { @Transactional(rollbackFor = Exception.class) public void devOperation(String topic, MqttMessage message, @NamedValue("edgeId") String nDid, @Payload String payload){ log.info("收到注册应答响应--->" + nDid); - //这边用redis缓存来判断是否接收响应 - redisUtil.saveByKeyWithExpire(nDid,true,5L); Gson gson = new Gson(); - ReqAndResParam.Res res = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), ReqAndResParam.Res.class); - //检验传递的参数是否准确 - Set> validate = validator.validate(res); - validate.forEach(constraintViolation -> { - System.out.println(constraintViolation.getMessage()); - }); + ReqAndResDto.Res res = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), ReqAndResDto.Res.class); if (Objects.equals(res.getCode(),AccessEnum.SUCCESS.getCode())){ if (Objects.equals(res.getType(),TypeEnum.TYPE_17.getCode())){ equipmentFeignClient.updateStatusBynDid(nDid, AccessEnum.REGISTERED.getCode()); //询问模板数据 - ReqAndResParam.Req reqAndResParam = new ReqAndResParam.Req(); + ReqAndResDto.Req reqAndResParam = new ReqAndResDto.Req(); reqAndResParam.setMid(1); reqAndResParam.setDid("0"); reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode()); reqAndResParam.setType(TypeEnum.TYPE_3.getCode()); reqAndResParam.setExpire(-1); publisher.send("/Pfm/DevCmd/V1/"+nDid,new Gson().toJson(reqAndResParam),1,false); + //这边用redis缓存来判断是否接收响应 + redisUtil.saveByKey(nDid,AccessEnum.SUCCESS.getCode()); } else { log.info(AccessResponseEnum.MESSAGE_TYPE_ERROR.getMessage()); } } else { - log.info(AccessResponseEnum.RESPONSE_ERROR.getMessage()); + log.info(AccessResponseEnum.REGISTER_RESPONSE_ERROR.getMessage()); } } @@ -151,50 +142,31 @@ public class MqttMessageHandler { public void devModelOperation(String topic, MqttMessage message, @NamedValue("version") String version, @NamedValue("edgeId") 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().getDevModel(); - String dictCode = dicDataFeignClient.getDicDataById(devType).getData().getCode(); - //直连设备处理 - if (Objects.equals(dictCode, DicDataEnum.CONNECT_DEV.getCode())){ - List list = modelDto.getDevMod(); - list.forEach(item->{ - DictData dicData = dicDataFeignClient.getDicDataByCode(item.getDevType()).getData(); - CsDevModelQueryListParm csDevModelQueryListParm = new CsDevModelQueryListParm(); - if (Objects.isNull(dicData)) { - log.info(AccessResponseEnum.DEV_TYPE_NOT_FIND.getMessage()); - 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(AccessResponseEnum.MODEL_NO_FIND.getMessage()); - } else { - ReqAndResParam.Req reqAndResParam = new ReqAndResParam.Req(); - reqAndResParam.setMid(1); - reqAndResParam.setDid("0"); - reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode()); - reqAndResParam.setType(TypeEnum.TYPE_5.getCode()); - reqAndResParam.setExpire(-1); - publisher.send("/Pfm/DevCmd/"+version+"/"+nDid,new Gson().toJson(reqAndResParam),1,false); - //将装置状态改为接入 - equipmentFeignClient.updateStatusBynDid(nDid, AccessEnum.ACCESS.getCode()); - //设置心跳时间,超时改为掉线 - redisUtil.saveByKeyWithExpire("MQTT:" + nDid,Instant.now().toEpochMilli(),180L); - } - }); - } - //网关处理 生成报文下发给装置,装置响应版本 - else if (Objects.equals(dictCode, DicDataEnum.GATEWAY_DEV.getCode())){ - //todo 处理待定 - System.out.println("网关设备判断"); - } - } else { - log.info(AccessResponseEnum.NDID_NO_FIND.getMessage()); + List list = modelDto.getMsg().getDevMod(); + if (CollectionUtils.isEmpty(list)){ + log.error(AccessResponseEnum.MODEL_VERSION_ERROR.getMessage()); + throw new BusinessException(AccessResponseEnum.MODEL_VERSION_ERROR); } + //校验前置传递的装置模板库中是否存在 + list.forEach(item->{ + CsDevModelPO po = devModelFeignClient.findModel(item.getDevType(),item.getVersionNo(),item.getVersionDate()).getData(); + if (Objects.isNull(po)){ + log.error(AccessResponseEnum.MODEL_NO_FIND.getMessage()); + throw new BusinessException(AccessResponseEnum.MODEL_NO_FIND); + } + }); + //fixme 这边先写死模板id,后期要选择电能质量的模板来确定监测点个数 + String modelId = "1"; + List lineList = csLineModelService.getMonitorNumByModelId(modelId); + String key = "LINE" + nDid; + //存储监测点模板信息,用于界面回显 + redisUtil.saveByKey(key,lineList); + //存储模板id + //todo 这边也是要调整的 + String key2 = "MODEL" + nDid; + redisUtil.saveByKey(key2,modelId); + redisUtil.delete(nDid); + } @@ -210,7 +182,7 @@ public class MqttMessageHandler { @Transactional(rollbackFor = Exception.class) public void devHeartBeat(String topic, MqttMessage message, @NamedValue("version") String version, @NamedValue("edgeId") String nDid, @Payload String payload) { //响应请求 - ReqAndResParam.Req reqAndResParam = new ReqAndResParam.Req(); + ReqAndResDto.Req reqAndResParam = new ReqAndResDto.Req(); HeartBeatDto heartBeatDto = new HeartBeatDto(); heartBeatDto.setTime(System.currentTimeMillis()/1000); reqAndResParam.setMid(1); @@ -221,7 +193,7 @@ public class MqttMessageHandler { reqAndResParam.setMsg(heartBeatDto); publisher.send("/Dev/PfmRsp/"+version+"/"+nDid,PubUtils.obj2json(reqAndResParam),1,false); //处理业务逻辑 - ReqAndResParam.Res res = PubUtils.json2obj(new String(message.getPayload(), StandardCharsets.UTF_8), ReqAndResParam.Res.class); + ReqAndResDto.Res res = PubUtils.json2obj(new String(message.getPayload(), StandardCharsets.UTF_8), ReqAndResDto.Res.class); Object object = res.getMsg(); if (!Objects.isNull(object)){ List abnormalList = new ArrayList<>(); diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsAlmMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsAlmMapper.java deleted file mode 100644 index fcd5169..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsAlmMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.njcn.access.mapper; - -import com.github.jeffreyning.mybatisplus.base.MppBaseMapper; -import com.njcn.access.pojo.po.CsAlmPO; - -/** - *

- * 设备告警数据表 Mapper 接口 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface CsAlmMapper extends MppBaseMapper { - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsBmdMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsBmdMapper.java deleted file mode 100644 index 58cfb40..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsBmdMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.njcn.access.mapper; - -import com.github.jeffreyning.mybatisplus.base.MppBaseMapper; -import com.njcn.access.pojo.po.CsBmdPO; - -/** - *

- * Mapper 接口 - *

- * - * @author xuyang - * @since 2023-05-11 - */ -public interface CsBmdMapper extends MppBaseMapper { - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsCtrlMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsCtrlMapper.java deleted file mode 100644 index aec6242..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsCtrlMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.njcn.access.mapper; - -import com.github.jeffreyning.mybatisplus.base.MppBaseMapper; -import com.njcn.access.pojo.po.CsCtrlPO; - -/** - *

- * 控制表 Mapper 接口 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface CsCtrlMapper extends MppBaseMapper { - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsDataArrayMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsDataArrayMapper.java deleted file mode 100644 index 35254ce..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsDataArrayMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.njcn.access.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.njcn.access.pojo.po.CsDataArrayPO; - -/** - *

- * 详细数据表 Mapper 接口 - *

- * - * @author xuyang - * @since 2023-05-23 - */ -public interface CsDataArrayMapper extends BaseMapper { - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsDataSetMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsDataSetMapper.java deleted file mode 100644 index 3191c79..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsDataSetMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.njcn.access.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.njcn.access.pojo.po.CsDataSetPO; - -/** - *

- * 数据集表 Mapper 接口 - *

- * - * @author xuyang - * @since 2023-05-23 - */ -public interface CsDataSetMapper extends BaseMapper { - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsDiMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsDiMapper.java deleted file mode 100644 index 031198b..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsDiMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.njcn.access.mapper; - -import com.github.jeffreyning.mybatisplus.base.MppBaseMapper; -import com.njcn.access.pojo.po.CsDiPO; - -/** - *

- * 开入表 Mapper 接口 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface CsDiMapper extends MppBaseMapper { - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsDoMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsDoMapper.java deleted file mode 100644 index be0c5f7..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsDoMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.njcn.access.mapper; - -import com.github.jeffreyning.mybatisplus.base.MppBaseMapper; -import com.njcn.access.pojo.po.CsDoPO; - -/** - *

- * 开出表 Mapper 接口 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface CsDoMapper extends MppBaseMapper { - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsEpdPqdMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsEpdPqdMapper.java deleted file mode 100644 index e539a7e..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsEpdPqdMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.njcn.access.mapper; - -import com.github.jeffreyning.mybatisplus.base.MppBaseMapper; -import com.njcn.access.pojo.po.CsEpdPqdPO; - -/** - *

- * Mapper 接口 - *

- * - * @author xuyang - * @since 2023-05-11 - */ -public interface CsEpdPqdMapper extends MppBaseMapper { - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsEvtMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsEvtMapper.java deleted file mode 100644 index 7d8b97d..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsEvtMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.njcn.access.mapper; - -import com.github.jeffreyning.mybatisplus.base.MppBaseMapper; -import com.njcn.access.pojo.po.CsEvtPO; - -/** - *

- * 事件表 Mapper 接口 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface CsEvtMapper extends MppBaseMapper { - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsEvtParmMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsEvtParmMapper.java deleted file mode 100644 index c30f07d..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsEvtParmMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.njcn.access.mapper; - -import com.github.jeffreyning.mybatisplus.base.MppBaseMapper; -import com.njcn.access.pojo.po.CsEvtParmPO; - -/** - *

- * 事件参数表 Mapper 接口 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface CsEvtParmMapper extends MppBaseMapper { - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsLineModelMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsLineModelMapper.java new file mode 100644 index 0000000..58470e1 --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsLineModelMapper.java @@ -0,0 +1,16 @@ +package com.njcn.access.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.njcn.access.pojo.po.CsLineModel; + +/** + *

+ * 监测点模板表 Mapper 接口 + *

+ * + * @author xuyang + * @since 2023-07-05 + */ +public interface CsLineModelMapper extends BaseMapper { + +} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsNetDevMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsNetDevMapper.java deleted file mode 100644 index 84dff10..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsNetDevMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.njcn.access.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.njcn.access.pojo.po.CsNetDevPO; - -/** - *

- * 联网设备表 Mapper 接口 - *

- * - * @author xuyang - * @since 2023-05-17 - */ -public interface CsNetDevMapper extends BaseMapper { - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsParmMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsParmMapper.java deleted file mode 100644 index 8d6043e..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsParmMapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.njcn.access.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.github.jeffreyning.mybatisplus.base.MppBaseMapper; -import com.njcn.access.pojo.po.CsParmPO; - -/** - *

- * 参数表 Mapper 接口 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface CsParmMapper extends MppBaseMapper { - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsPrjInfoMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsPrjInfoMapper.java deleted file mode 100644 index c2500dd..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsPrjInfoMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.njcn.access.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.njcn.access.pojo.po.CsPrjInfoPO; - -/** - *

- * 工程信息表 Mapper 接口 - *

- * - * @author xuyang - * @since 2023-05-17 - */ -public interface CsPrjInfoMapper extends BaseMapper { - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsSetMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsSetMapper.java deleted file mode 100644 index 1ed0d06..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsSetMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.njcn.access.mapper; - -import com.github.jeffreyning.mybatisplus.base.MppBaseMapper; -import com.njcn.access.pojo.po.CsSetPO; - -/** - *

- * 设备定值数据表 Mapper 接口 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface CsSetMapper extends MppBaseMapper { - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsSoftInfoMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsSoftInfoMapper.java deleted file mode 100644 index b524991..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsSoftInfoMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.njcn.access.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.njcn.access.pojo.po.CsSoftInfoPO; - -/** - *

- * 系统软件表 Mapper 接口 - *

- * - * @author xuyang - * @since 2023-05-17 - */ -public interface CsSoftInfoMapper extends BaseMapper { - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsStsMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsStsMapper.java deleted file mode 100644 index 1563dff..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsStsMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.njcn.access.mapper; - -import com.github.jeffreyning.mybatisplus.base.MppBaseMapper; -import com.njcn.access.pojo.po.CsStsPO; - -/** - *

- * 状态表 Mapper 接口 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface CsStsMapper extends MppBaseMapper { - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsTopicMapper.java b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsTopicMapper.java deleted file mode 100644 index 6a481e3..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/CsTopicMapper.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.njcn.access.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.njcn.access.pojo.po.CsTopicPO; -import org.apache.ibatis.annotations.Mapper; - -/** - *

- * Mapper 接口 - *

- * - * @author xuyang - * @since 2023-05-12 - */ -@Mapper -public interface CsTopicMapper extends BaseMapper { - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/mapping/CsEpdPqdMapper.xml b/iot-access/access-boot/src/main/java/com/njcn/access/mapper/mapping/CsEpdPqdMapper.xml deleted file mode 100644 index 2f88bd5..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/mapper/mapping/CsEpdPqdMapper.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - 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 deleted file mode 100644 index 7ccdbc8..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/IAccessService.java +++ /dev/null @@ -1,16 +0,0 @@ -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/ICsAlmService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsAlmService.java deleted file mode 100644 index 07d9c6c..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsAlmService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.njcn.access.service; - -import com.njcn.access.pojo.po.CsAlmPO; - -import java.util.List; - -/** - *

- * 设备告警数据表 服务类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface ICsAlmService { - - void saveData(List list); - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsBmdService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsBmdService.java deleted file mode 100644 index 2f7a525..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsBmdService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.njcn.access.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.njcn.access.pojo.po.CsBmdPO; -import com.njcn.access.pojo.po.CsEpdPqdPO; - -import java.util.List; - -/** - *

- * 服务类 - *

- * - * @author xuyang - * @since 2023-05-11 - */ -public interface ICsBmdService { - - void saveData(List list); - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsCtrlService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsCtrlService.java deleted file mode 100644 index 3f6f3c0..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsCtrlService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.njcn.access.service; - -import com.njcn.access.pojo.po.CsCtrlPO; - -import java.util.List; - -/** - *

- * 控制表 服务类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface ICsCtrlService { - - void saveData(List list); - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDataArrayService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDataArrayService.java deleted file mode 100644 index 37c34a5..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDataArrayService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.njcn.access.service; - -import com.njcn.access.pojo.po.CsDataArrayPO; - -import java.util.List; - -/** - *

- * 详细数据表 服务类 - *

- * - * @author xuyang - * @since 2023-05-23 - */ -public interface ICsDataArrayService { - - void saveData(List list); - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDataSetService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDataSetService.java deleted file mode 100644 index 1f0a45c..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDataSetService.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.njcn.access.service; - -import com.njcn.access.pojo.po.CsDataSetPO; - -/** - *

- * 数据集表 服务类 - *

- * - * @author xuyang - * @since 2023-05-23 - */ -public interface ICsDataSetService { - - CsDataSetPO addOne(CsDataSetPO csDataSetPo); - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDevModelService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDevModelService.java new file mode 100644 index 0000000..1a539fd --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDevModelService.java @@ -0,0 +1,21 @@ +package com.njcn.access.service; + +import com.njcn.access.pojo.param.DevModelParam; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/7/3 15:39 + */ + +public interface ICsDevModelService { + + /** + * 解析模板文件->入库 + * @param devModelParam + */ + void addModel(DevModelParam devModelParam); + +} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDeviceService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDeviceService.java new file mode 100644 index 0000000..45afbc6 --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDeviceService.java @@ -0,0 +1,33 @@ +package com.njcn.access.service; + +import com.njcn.access.param.DevAccessParam; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/7/4 13:43 + */ + +public interface ICsDeviceService { + + /** + * 直连设备注册 + * @param nDid 设备识别码 + */ + void devRegister(String nDid); + + /** + * MQTT连接成功,获取装置所用的模板信息 + * @param nDid + */ + Object getModel(String nDid); + + /** + * MQTT连接成功,获取装置所用的模板信息 + * @param devAccessParam + */ + void devAccess(DevAccessParam devAccessParam); + +} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDiService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDiService.java deleted file mode 100644 index f27102f..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDiService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.njcn.access.service; - -import com.njcn.access.pojo.po.CsDiPO; - -import java.util.List; - -/** - *

- * 开入表 服务类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface ICsDiService { - - void saveData(List list); - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDoService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDoService.java deleted file mode 100644 index ebc9521..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsDoService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.njcn.access.service; - -import com.njcn.access.pojo.po.CsDoPO; - -import java.util.List; - -/** - *

- * 开出表 服务类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface ICsDoService { - - void saveData(List list); - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsEpdPqdService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsEpdPqdService.java deleted file mode 100644 index 220212a..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsEpdPqdService.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.njcn.access.service; - -import com.njcn.access.pojo.po.CsEpdPqdPO; - -import java.util.List; - -/** - *

- * 服务类 - *

- * - * @author xuyang - * @since 2023-05-11 - */ -public interface ICsEpdPqdService { - - void saveData(List list); - -// CsEpdPqdPO findOne(Integer idx); -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsEvtParmService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsEvtParmService.java deleted file mode 100644 index 27b17a8..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsEvtParmService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.njcn.access.service; - -import com.njcn.access.pojo.po.CsEvtParmPO; - -import java.util.List; - -/** - *

- * 事件参数表 服务类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface ICsEvtParmService { - - boolean saveData(List list); - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsEvtService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsEvtService.java deleted file mode 100644 index c9b1892..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsEvtService.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.njcn.access.service; - -import com.njcn.access.pojo.po.CsEvtPO; - -import java.util.List; -import java.util.Map; - -/** - *

- * 事件表 服务类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface ICsEvtService { - - Map saveData(List list); - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsLineModelService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsLineModelService.java new file mode 100644 index 0000000..234b525 --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsLineModelService.java @@ -0,0 +1,24 @@ +package com.njcn.access.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.access.pojo.po.CsLineModel; + +import java.util.List; + +/** + *

+ * 监测点模板表 服务类 + *

+ * + * @author xuyang + * @since 2023-07-05 + */ +public interface ICsLineModelService extends IService { + + /** + * 获取模板下监测点个数 + * @param id 模板Id + */ + List getMonitorNumByModelId(String id); + +} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsNetDevService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsNetDevService.java deleted file mode 100644 index a45038d..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsNetDevService.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.njcn.access.service; - -import com.njcn.access.pojo.po.CsNetDevPO; - -/** - *

- * 联网设备表 服务类 - *

- * - * @author xuyang - * @since 2023-05-17 - */ -public interface ICsNetDevService { - - boolean saveData(CsNetDevPO csNetDevPo); - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsParmService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsParmService.java deleted file mode 100644 index 21f84c1..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsParmService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.njcn.access.service; - -import com.njcn.access.pojo.po.CsParmPO; - -import java.util.List; - -/** - *

- * 参数表 服务类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface ICsParmService { - - void saveData(List list); - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsPrjInfoService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsPrjInfoService.java deleted file mode 100644 index f16296a..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsPrjInfoService.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.njcn.access.service; - -import com.njcn.access.pojo.po.CsPrjInfoPO; -import com.njcn.access.pojo.po.CsSoftInfoPO; - -/** - *

- * 工程信息表 服务类 - *

- * - * @author xuyang - * @since 2023-05-17 - */ -public interface ICsPrjInfoService { - - CsPrjInfoPO saveData(CsPrjInfoPO csPrjInfoPO); - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsSetService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsSetService.java deleted file mode 100644 index 3d6cd30..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsSetService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.njcn.access.service; - -import com.njcn.access.pojo.po.CsSetPO; - -import java.util.List; - -/** - *

- * 设备定值数据表 服务类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface ICsSetService { - - void saveData(List list); - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsSoftInfoService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsSoftInfoService.java deleted file mode 100644 index e05bfe2..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsSoftInfoService.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.njcn.access.service; - -import com.njcn.access.pojo.po.CsSoftInfoPO; - -/** - *

- * 系统软件表 服务类 - *

- * - * @author xuyang - * @since 2023-05-17 - */ -public interface ICsSoftInfoService { - - CsSoftInfoPO saveData(CsSoftInfoPO csSoftInfoPo); - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsStsService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsStsService.java deleted file mode 100644 index c134d08..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsStsService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.njcn.access.service; - -import com.njcn.access.pojo.po.CsStsPO; - -import java.util.List; - -/** - *

- * 状态表 服务类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -public interface ICsStsService { - - void saveData(List list); - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsTopicService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsTopicService.java deleted file mode 100644 index cbbf9a9..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/ICsTopicService.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.njcn.access.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.njcn.access.pojo.po.CsTopicPO; - -import java.util.List; - -/** - *

- * 服务类 - *

- * - * @author xuyang - * @since 2023-05-12 - */ -public interface ICsTopicService { - - void askDevTopic(String nDid); - - boolean addList(List list); - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/IDataArrayService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/IDataArrayService.java deleted file mode 100644 index 5a31eec..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/IDataArrayService.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.njcn.access.service; - -/** - * @author xy - */ -public interface IDataArrayService { -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/IDataSetService.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/IDataSetService.java deleted file mode 100644 index 68edb3a..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/IDataSetService.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.njcn.access.service; - -/** - * @author xy - */ -public interface IDataSetService { - - void add(); -} 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 deleted file mode 100644 index a8e8cae..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/IDevModelService.java +++ /dev/null @@ -1,18 +0,0 @@ -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 模板文件参数 - */ - void add(DevModelParam devModelParam); -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDevModelServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDevModelServiceImpl.java new file mode 100644 index 0000000..3ce81ba --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDevModelServiceImpl.java @@ -0,0 +1,44 @@ +package com.njcn.access.service.impl; + +import com.alibaba.nacos.shaded.com.google.gson.Gson; +import com.njcn.access.pojo.dto.devModel.TemplateDto; +import com.njcn.access.pojo.param.DevModelParam; +import com.njcn.access.service.ICsDevModelService; +import com.njcn.access.utils.JsonUtil; +import com.njcn.oss.constant.OssPath; +import com.njcn.oss.utils.FileStorageUtil; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.io.IOException; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/7/3 15:40 + */ +@Service +@AllArgsConstructor +public class CsDevModelServiceImpl implements ICsDevModelService { + + private final FileStorageUtil fileStorageUtil; + + @Override + public void addModel(DevModelParam devModelParam) { + String json = null; + try { + json = JsonUtil.convertStreamToString(devModelParam.getFile().getInputStream()); + Gson gson = new Gson(); + TemplateDto templateDto = gson.fromJson(json, TemplateDto.class); + //模板文件存入文件服务器 + //String filePath = fileStorageUtil.uploadMultipart(devModelParam.getFile(), OssPath.DEV_MODEL + devModelParam.getDevType() + "_"); + String filePath = ""; + System.out.println("templateDto==:" + templateDto); + } catch (IOException e) { + e.printStackTrace(); + } + } + +} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java new file mode 100644 index 0000000..61eabf0 --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java @@ -0,0 +1,212 @@ +package com.njcn.access.service.impl; + +import cn.hutool.core.util.IdUtil; +import com.github.tocrhz.mqtt.publisher.MqttPublisher; +import com.njcn.access.enums.AccessEnum; +import com.njcn.access.enums.AccessResponseEnum; +import com.njcn.access.enums.TypeEnum; +import com.njcn.access.param.DevAccessParam; +import com.njcn.access.pojo.dto.AccessDto; +import com.njcn.access.pojo.dto.ReqAndResDto; +import com.njcn.access.service.ICsDeviceService; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.common.utils.PubUtils; +import com.njcn.csdevice.api.*; +import com.njcn.csdevice.pojo.param.CsDevModelRelationAddParm; +import com.njcn.csdevice.pojo.param.CsLedgerParam; +import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO; +import com.njcn.csdevice.pojo.po.CsDeviceUserPO; +import com.njcn.csdevice.pojo.po.CsLinePO; +import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO; +import com.njcn.redis.utils.RedisUtil; +import com.njcn.system.api.DicDataFeignClient; +import com.njcn.system.api.DictTreeFeignClient; +import com.njcn.system.enums.DicDataEnum; +import com.njcn.system.pojo.po.SysDicTreePO; +import com.njcn.web.utils.RequestUtil; +import lombok.AllArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * 类的介绍: + * + * @author xuyang + * @version 1.0.0 + * @createTime 2023/7/4 13:43 + */ +@Service +@AllArgsConstructor +public class CsDeviceServiceImpl implements ICsDeviceService { + + private static final Logger logger = LoggerFactory.getLogger(CsDeviceServiceImpl.class); + + private final EquipmentFeignClient equipmentFeignClient; + + private final DictTreeFeignClient dictTreeFeignClient; + + private final DicDataFeignClient dicDataFeignClient; + + private final CsLedgerFeignClient csLedgerFeignClient; + + private final CsLineFeignClient csLineFeignClient; + + private final CsLineTopologyFeignClient csLineTopologyFeignClient; + + private final DevModelRelationFeignClient devModelRelationFeignClient; + + private final CsDeviceUserFeignClient csDeviceUserFeignClient; + + private final MqttPublisher publisher; + + private final RedisUtil redisUtil; + + @Override + @Transactional(rollbackFor = {Exception.class}) + public void devRegister(String nDid) { + //1.判断nDid是否存在 + CsEquipmentDeliveryVO csEquipmentDeliveryVO = equipmentFeignClient.queryEquipmentByndid(nDid).getData(); + if (Objects.isNull(csEquipmentDeliveryVO.getNdid())){ + throw new BusinessException(AccessResponseEnum.NDID_NO_FIND); + } + //2.判断设备是否是直连设备 + SysDicTreePO sysDicTreePo = dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevType()).getData(); + if (Objects.isNull(sysDicTreePo)){ + throw new BusinessException(AccessResponseEnum.DEV_NOT_FIND); + } + String code = sysDicTreePo.getCode(); + if (!Objects.equals(code, DicDataEnum.CONNECT_DEV.getCode())){ + throw new BusinessException(AccessResponseEnum.DEV_IS_NOT_ZL); + } + //3.MQTT询问装置用的模板,并判断库中是否存在模板 + //存在则建立关系;不存在则告警出来 + SysDicTreePO dictData = dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevModel()).getData(); + if (Objects.isNull(dictData)){ + throw new BusinessException(AccessResponseEnum.DEV_MODEL_NOT_FIND); + } + String devModel = dictData.getCode(); + zhiLianRegister(nDid,devModel); + try { + Thread.sleep(1000); + //这边使用redis缓存来判断装置是否连接MQTT或者是否出现异常 + if (Objects.isNull(redisUtil.getObjectByKey(nDid))){ + logger.error("装置注册失败,请核查!"); + throw new BusinessException(AccessResponseEnum.REGISTER_ERROR); + } + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + @Override + public Object getModel(String nDid) { + Object model = null; + try { + Thread.sleep(1000); + String key = "LINE" + nDid; + model = redisUtil.getObjectByKey(key); + if (Objects.isNull(model)){ + throw new BusinessException(AccessResponseEnum.MODEL_MISS); + } + } catch (InterruptedException e) { + e.printStackTrace(); + } + return model; + } + + @Override + @Transactional(rollbackFor = {Exception.class}) + public void devAccess(DevAccessParam devAccessParam) { + try { + CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(devAccessParam.getNDid()).getData(); + List csLinePoList = new ArrayList<>(); + List appLineTopologyDiagramPoList = new ArrayList<>(); + //1.录入装置台账信息 + CsLedgerParam csLedgerParam = new CsLedgerParam(); + csLedgerParam.setId(vo.getId()); + csLedgerParam.setPid(devAccessParam.getProjectId()); + csLedgerParam.setName(vo.getName()); + csLedgerParam.setLevel(2); + csLedgerParam.setSort(0); + csLedgerFeignClient.add(csLedgerParam); + //2.监测点表录入关系 + devAccessParam.getList().forEach(item->{ + String id = IdUtil.fastSimpleUUID(); + CsLinePO po = new CsLinePO(); + po.setLineId(id); + po.setName(item.getName()); + po.setPosition(item.getPosition()); + po.setVolGrade(item.getVolGrade()); + //todo 目前ct、pt数据不确定 后期补 + //po.setPtRatio(item.getPtRatio()); + //po.setCtRatio(item.getCtRatio()); + po.setStatus(1); + csLinePoList.add(po); + CsLedgerParam param = new CsLedgerParam(); + param.setId(id); + param.setPid(vo.getId()); + param.setName(item.getName()); + param.setLevel(3); + param.setSort(0); + csLedgerFeignClient.add(param).getData(); + AppLineTopologyDiagramPO appLineTopologyDiagramPo = new AppLineTopologyDiagramPO(); + appLineTopologyDiagramPo.setId(devAccessParam.getTopologyDiagram()); + appLineTopologyDiagramPo.setLineId(id); + appLineTopologyDiagramPo.setLat(item.getLat()); + appLineTopologyDiagramPo.setLng(item.getLng()); + appLineTopologyDiagramPo.setStatus("1"); + appLineTopologyDiagramPoList.add(appLineTopologyDiagramPo); + }); + csLineFeignClient.addLineList(csLinePoList); + //3.监测点拓扑图表录入关系 + csLineTopologyFeignClient.addList(appLineTopologyDiagramPoList); + //4.新增装置-模板关系 + String modelId = redisUtil.getObjectByKey("MODEL" + devAccessParam.getNDid()).toString(); + CsDevModelRelationAddParm csDevModelRelationAddParm = new CsDevModelRelationAddParm(); + csDevModelRelationAddParm.setDevId(vo.getId()); + csDevModelRelationAddParm.setModelId(modelId); + devModelRelationFeignClient.addDevModelRelation(csDevModelRelationAddParm); + redisUtil.delete("MODEL" + devAccessParam.getNDid()); + //5.修改装置状态 + equipmentFeignClient.updateStatusBynDid(devAccessParam.getNDid(), AccessEnum.ACCESS.getCode()); + //6.设置心跳时间,超时改为掉线 + redisUtil.saveByKeyWithExpire("MQTT:" + devAccessParam.getNDid(), Instant.now().toEpochMilli(),180L); + //7.绑定装置和人的关系 + CsDeviceUserPO po = new CsDeviceUserPO(); + po.setPrimaryUserId(RequestUtil.getUserIndex()); + po.setSubUserId(RequestUtil.getUserIndex()); + po.setDeviceId(vo.getId()); + csDeviceUserFeignClient.add(Collections.singletonList(po)); + //8.删除redis监测点模板信息 + redisUtil.delete("LINE" + devAccessParam.getNDid()); + //todo 9.记录操作日志 + } catch (Exception e) { + throw new BusinessException(CommonResponseEnum.FAIL); + } + } + + + public void zhiLianRegister(String nDid,String devType) { + ReqAndResDto.Req reqAndResParam = new ReqAndResDto.Req(); + reqAndResParam.setMid(1); + reqAndResParam.setDid("0"); + reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode()); + reqAndResParam.setType(TypeEnum.TYPE_2.getCode()); + reqAndResParam.setExpire(-1); + AccessDto accessDto = new AccessDto(); + accessDto.setNDid(nDid); + accessDto.setDevType(devType); + reqAndResParam.setMsg(accessDto); + publisher.send("/Pfm/Reg/"+nDid, PubUtils.obj2json(reqAndResParam),1,false); + } + +} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsLineModelServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsLineModelServiceImpl.java new file mode 100644 index 0000000..feae297 --- /dev/null +++ b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsLineModelServiceImpl.java @@ -0,0 +1,27 @@ +package com.njcn.access.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.access.mapper.CsLineModelMapper; +import com.njcn.access.pojo.po.CsLineModel; +import com.njcn.access.service.ICsLineModelService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + *

+ * 监测点模板表 服务实现类 + *

+ * + * @author xuyang + * @since 2023-07-05 + */ +@Service +public class CsLineModelServiceImpl extends ServiceImpl implements ICsLineModelService { + + @Override + public List getMonitorNumByModelId(String id) { + return this.lambdaQuery().eq(CsLineModel::getPid,id).list(); + } + +} 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 deleted file mode 100644 index 7b2e520..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/AccessServiceImpl.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.alibaba.csp.sentinel.util.TimeUtil; -import com.github.tocrhz.mqtt.publisher.MqttPublisher; -import com.njcn.access.enums.AccessEnum; -import com.njcn.access.enums.AccessResponseEnum; -import com.njcn.access.enums.TypeEnum; -import com.njcn.access.handler.MqttMessageHandler; -import com.njcn.access.pojo.dto.AccessDto; -import com.njcn.access.pojo.param.ReqAndResParam; -import com.njcn.access.service.IAccessService; -import com.njcn.algorithm.api.CsEdDataFeignClient; -import com.njcn.algorithm.api.EquipmentFeignClient; -import com.njcn.algorithm.pojo.vo.CsEdDataVO; -import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO; -import com.njcn.common.pojo.enums.response.CommonResponseEnum; -import com.njcn.common.pojo.exception.BusinessException; -import com.njcn.common.pojo.response.HttpResult; -import com.njcn.common.utils.HttpResultUtil; -import com.njcn.common.utils.PubUtils; -import com.njcn.redis.utils.RedisUtil; -import com.njcn.system.api.DicDataFeignClient; -import com.njcn.system.enums.DicDataEnum; -import lombok.AllArgsConstructor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -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; - - private final CsEdDataFeignClient csEdDataFeignClient; - - private final DicDataFeignClient dicDataFeignClient; - - private final RedisUtil redisUtil; - - @Override - public void add(String nDid) { - CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData(); - if (Objects.isNull(vo.getNdid())){ - logger.error("平台侧无此网关信息,请先录入!"); - throw new BusinessException(AccessResponseEnum.NDID_NO_FIND); - } else { - HttpResult result = csEdDataFeignClient.findByDevTypeId(vo.getDevModel()); - String typeId = result.getData().getType(); - if(Objects.isNull(typeId)) { - logger.error("平台侧无此装置类型,请先录入!"); - throw new BusinessException(AccessResponseEnum.DEV_TYPE_NOT_FIND); - } else { - String type = dicDataFeignClient.getDicDataById(typeId).getData().getCode(); - if (Objects.equals(DicDataEnum.GATEWAY_DEV.getCode(),type)) { - //处理网关设备 - System.out.println("网关"); - } else if (Objects.equals(DicDataEnum.CONNECT_DEV.getCode(),type)) { - //处理直连设备 - zhiLianRegister(nDid,vo.getDevModel()); - } else { - logger.error("请求注册的装置类型错误(不是网关或者直连设备),请核查!"); - throw new BusinessException(AccessResponseEnum.DEV_TYPE_ERROR); - } - } - } - try { - Thread.sleep(2000); - //这边使用redis缓存来判断装置是否连接MQTT - if(Objects.isNull(redisUtil.getObjectByKey(nDid))) { - logger.error("未收到装置注册响应,请核查!"); - throw new BusinessException(AccessResponseEnum.NO_RECEIVE_FROM_DEV); - } - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - public void zhiLianRegister(String nDid,String devType) { - ReqAndResParam.Req reqAndResParam = new ReqAndResParam.Req(); - reqAndResParam.setMid(1); - reqAndResParam.setDid("0"); - reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode()); - reqAndResParam.setType(TypeEnum.TYPE_2.getCode()); - reqAndResParam.setExpire(-1); - AccessDto accessDto = new AccessDto(); - accessDto.setNDid(nDid); - accessDto.setDevType(devType); - reqAndResParam.setMsg(accessDto); - publisher.send("/platform/register/"+nDid, PubUtils.obj2json(reqAndResParam),1,false); - } -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsAlmServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsAlmServiceImpl.java deleted file mode 100644 index a659eb4..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsAlmServiceImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; -import com.njcn.access.mapper.CsAlmMapper; -import com.njcn.access.pojo.po.CsAlmPO; -import com.njcn.access.service.ICsAlmService; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - *

- * 设备告警数据表 服务实现类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -@Service -public class CsAlmServiceImpl extends MppServiceImpl implements ICsAlmService { - - @Override - public void saveData(List list) { - this.saveOrUpdateBatchByMultiId(list,100); - } -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsBmdServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsBmdServiceImpl.java deleted file mode 100644 index f65cacc..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsBmdServiceImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; -import com.njcn.access.mapper.CsBmdMapper; -import com.njcn.access.pojo.po.CsBmdPO; -import com.njcn.access.service.ICsBmdService; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - *

- * 服务实现类 - *

- * - * @author xuyang - * @since 2023-05-11 - */ -@Service -public class CsBmdServiceImpl extends MppServiceImpl implements ICsBmdService { - - @Override - public void saveData(List list) { - this.saveOrUpdateBatchByMultiId(list,100); - } -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsCtrlServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsCtrlServiceImpl.java deleted file mode 100644 index 80af66c..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsCtrlServiceImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; -import com.njcn.access.mapper.CsCtrlMapper; -import com.njcn.access.pojo.po.CsCtrlPO; -import com.njcn.access.service.ICsCtrlService; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - *

- * 控制表 服务实现类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -@Service -public class CsCtrlServiceImpl extends MppServiceImpl implements ICsCtrlService { - - @Override - public void saveData(List list) { - this.saveOrUpdateBatchByMultiId(list,100); - } -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsDataArrayServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsDataArrayServiceImpl.java deleted file mode 100644 index 9f6bf96..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsDataArrayServiceImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.njcn.access.mapper.CsDataArrayMapper; -import com.njcn.access.pojo.po.CsDataArrayPO; -import com.njcn.access.service.ICsDataArrayService; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - *

- * 详细数据表 服务实现类 - *

- * - * @author xuyang - * @since 2023-05-23 - */ -@Service -public class CsDataArrayServiceImpl extends ServiceImpl implements ICsDataArrayService { - - @Override - public void saveData(List list) { - this.saveBatch(list,100); - } -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsDataSetServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsDataSetServiceImpl.java deleted file mode 100644 index 44394df..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsDataSetServiceImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.njcn.access.mapper.CsDataSetMapper; -import com.njcn.access.pojo.po.CsDataSetPO; -import com.njcn.access.service.ICsDataSetService; -import org.springframework.stereotype.Service; - -/** - *

- * 数据集表 服务实现类 - *

- * - * @author xuyang - * @since 2023-05-23 - */ -@Service -public class CsDataSetServiceImpl extends ServiceImpl implements ICsDataSetService { - - @Override - public CsDataSetPO addOne(CsDataSetPO csDataSetPo) { - this.save(csDataSetPo); - return csDataSetPo; - } -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsDiServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsDiServiceImpl.java deleted file mode 100644 index 71987e5..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsDiServiceImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; -import com.njcn.access.mapper.CsDiMapper; -import com.njcn.access.pojo.po.CsDiPO; -import com.njcn.access.service.ICsDiService; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - *

- * 开入表 服务实现类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -@Service -public class CsDiServiceImpl extends MppServiceImpl implements ICsDiService { - - @Override - public void saveData(List list) { - this.saveOrUpdateBatchByMultiId(list,100); - } -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsDoServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsDoServiceImpl.java deleted file mode 100644 index db9b867..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsDoServiceImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; -import com.njcn.access.mapper.CsDoMapper; -import com.njcn.access.pojo.po.CsDoPO; -import com.njcn.access.service.ICsDoService; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - *

- * 开出表 服务实现类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -@Service -public class CsDoServiceImpl extends MppServiceImpl implements ICsDoService { - - @Override - public void saveData(List list) { - this.saveOrUpdateBatchByMultiId(list,100); - } -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsEpdPqdServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsEpdPqdServiceImpl.java deleted file mode 100644 index 353c1d2..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsEpdPqdServiceImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; -import com.njcn.access.enums.AccessResponseEnum; -import com.njcn.access.mapper.CsEpdPqdMapper; -import com.njcn.access.pojo.po.CsEpdPqdPO; -import com.njcn.access.service.ICsEpdPqdService; -import com.njcn.common.pojo.exception.BusinessException; -import org.springframework.stereotype.Service; - -import java.util.List; -import java.util.Objects; - -/** - *

- * 服务实现类 - *

- * - * @author xuyang - * @since 2023-05-11 - */ -@Service -public class CsEpdPqdServiceImpl extends MppServiceImpl implements ICsEpdPqdService { - - @Override - public void saveData(List list) { - this.saveOrUpdateBatchByMultiId(list,100); - } - -// @Override -// public CsEpdPqdPO findOne(Integer idx) { -// LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); -// lambdaQueryWrapper.eq(CsEpdPqdPO::getClassId, DataType.POWER_DATA).eq(CsEpdPqdPO::getIdx,idx); -// CsEpdPqdPO csEpdPqdPo = this.baseMapper.selectOne(lambdaQueryWrapper); -// if (Objects.isNull(csEpdPqdPo)) { -// throw new BusinessException(AccessResponseEnum.DICT_MISSING); -// } -// return csEpdPqdPo; -// } -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsEvtParmServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsEvtParmServiceImpl.java deleted file mode 100644 index c6a1eb2..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsEvtParmServiceImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; -import com.njcn.access.mapper.CsEvtParmMapper; -import com.njcn.access.pojo.po.CsEvtParmPO; -import com.njcn.access.service.ICsEvtParmService; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - *

- * 事件参数表 服务实现类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -@Service -public class CsEvtParmServiceImpl extends MppServiceImpl implements ICsEvtParmService { - - @Override - public boolean saveData(List list) { - return this.saveOrUpdateBatchByMultiId(list,1000); - } -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsEvtServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsEvtServiceImpl.java deleted file mode 100644 index 2406b26..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsEvtServiceImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; -import com.njcn.access.mapper.CsEvtMapper; -import com.njcn.access.pojo.po.CsEvtPO; -import com.njcn.access.service.ICsEvtService; -import org.springframework.stereotype.Service; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - *

- * 事件表 服务实现类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -@Service -public class CsEvtServiceImpl extends MppServiceImpl implements ICsEvtService { - - @Override - public Map saveData(List list) { - this.saveOrUpdateBatchByMultiId(list,100); - List nameList = list.stream().map(CsEvtPO::getName).collect(Collectors.toList()); - LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper(); - lambdaQueryWrapper.in(CsEvtPO::getName,nameList); - List list1 = this.baseMapper.selectList(lambdaQueryWrapper); - Map map = new HashMap<>(); - list1.forEach(item->{ - map.put(item.getName(),item.getId()); - }); - return map; - } - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsNetDevServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsNetDevServiceImpl.java deleted file mode 100644 index 21391f5..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsNetDevServiceImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.njcn.access.enums.AccessResponseEnum; -import com.njcn.access.mapper.CsNetDevMapper; -import com.njcn.access.pojo.po.CsNetDevPO; -import com.njcn.access.service.ICsNetDevService; -import com.njcn.common.pojo.exception.BusinessException; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; - -import java.util.Objects; - -/** - *

- * 联网设备表 服务实现类 - *

- * - * @author xuyang - * @since 2023-05-17 - */ -@Service -public class CsNetDevServiceImpl extends ServiceImpl implements ICsNetDevService { - - @Override - public boolean saveData(CsNetDevPO csNetDevPo) { - LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper(); - lambdaQueryWrapper.eq(CsNetDevPO::getDevType,csNetDevPo.getDevType()) - .eq(CsNetDevPO::getTime,csNetDevPo.getTime()) - .eq(CsNetDevPO::getVersion,csNetDevPo.getVersion()) - .eq(CsNetDevPO::getStatus,1); - CsNetDevPO po = this.baseMapper.selectOne(lambdaQueryWrapper); - if (!Objects.isNull(po)){ - throw new BusinessException(AccessResponseEnum.MODEL_REPEAT); - } - return this.save(csNetDevPo); - } -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsParmServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsParmServiceImpl.java deleted file mode 100644 index f1e1959..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsParmServiceImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; -import com.njcn.access.mapper.CsParmMapper; -import com.njcn.access.pojo.po.CsParmPO; -import com.njcn.access.service.ICsParmService; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - *

- * 参数表 服务实现类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -@Service -public class CsParmServiceImpl extends MppServiceImpl implements ICsParmService { - - @Override - public void saveData(List list) { - this.saveOrUpdateBatchByMultiId(list,100); - } -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsPrjInfoServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsPrjInfoServiceImpl.java deleted file mode 100644 index 280f1d3..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsPrjInfoServiceImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.njcn.access.mapper.CsPrjInfoMapper; -import com.njcn.access.pojo.po.CsPrjInfoPO; -import com.njcn.access.service.ICsPrjInfoService; -import org.springframework.stereotype.Service; - -/** - *

- * 工程信息表 服务实现类 - *

- * - * @author xuyang - * @since 2023-05-17 - */ -@Service -public class CsPrjInfoServiceImpl extends ServiceImpl implements ICsPrjInfoService { - - @Override - public CsPrjInfoPO saveData(CsPrjInfoPO csPrjInfoPo) { - this.save(csPrjInfoPo); - return csPrjInfoPo; - } -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsSetServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsSetServiceImpl.java deleted file mode 100644 index fdddfd8..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsSetServiceImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; -import com.njcn.access.mapper.CsSetMapper; -import com.njcn.access.pojo.po.CsSetPO; -import com.njcn.access.service.ICsSetService; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - *

- * 设备定值数据表 服务实现类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -@Service -public class CsSetServiceImpl extends MppServiceImpl implements ICsSetService { - - @Override - public void saveData(List list) { - this.saveOrUpdateBatchByMultiId(list,100); - } -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsSoftInfoServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsSoftInfoServiceImpl.java deleted file mode 100644 index f83b24e..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsSoftInfoServiceImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.njcn.access.mapper.CsSoftInfoMapper; -import com.njcn.access.pojo.po.CsSoftInfoPO; -import com.njcn.access.service.ICsSoftInfoService; -import org.springframework.stereotype.Service; - -/** - *

- * 系统软件表 服务实现类 - *

- * - * @author xuyang - * @since 2023-05-17 - */ -@Service -public class CsSoftInfoServiceImpl extends ServiceImpl implements ICsSoftInfoService { - - @Override - public CsSoftInfoPO saveData(CsSoftInfoPO entity) { - this.save(entity); - return entity; - } -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsStsServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsStsServiceImpl.java deleted file mode 100644 index e98484a..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsStsServiceImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; -import com.njcn.access.mapper.CsStsMapper; -import com.njcn.access.pojo.po.CsStsPO; -import com.njcn.access.service.ICsStsService; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - *

- * 状态表 服务实现类 - *

- * - * @author xuyang - * @since 2023-05-19 - */ -@Service -public class CsStsServiceImpl extends MppServiceImpl implements ICsStsService { - - @Override - public void saveData(List list) { - this.saveOrUpdateBatchByMultiId(list,100); - } -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsTopicServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsTopicServiceImpl.java deleted file mode 100644 index fbdf5e0..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/CsTopicServiceImpl.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.tocrhz.mqtt.publisher.MqttPublisher; -import com.njcn.access.enums.AccessEnum; -import com.njcn.access.enums.TypeEnum; -import com.njcn.access.mapper.CsTopicMapper; -import com.njcn.access.pojo.param.ReqAndResParam; -import com.njcn.access.pojo.po.CsTopicPO; -import com.njcn.access.service.ICsTopicService; -import com.njcn.algorithm.api.EquipmentFeignClient; -import com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO; -import com.njcn.common.utils.PubUtils; -import lombok.AllArgsConstructor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -import java.util.List; -import java.util.Objects; - -/** - *

- * 服务实现类 - *

- * - * @author xuyang - * @since 2023-05-12 - */ -@Service -@AllArgsConstructor -public class CsTopicServiceImpl extends ServiceImpl implements ICsTopicService { - - private static final Logger logger = LoggerFactory.getLogger(CsTopicServiceImpl.class); - - private final MqttPublisher publisher; - - private final EquipmentFeignClient equipmentFeignClient; - - @Override - public void askDevTopic(String nDid) { - CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData(); - if (Objects.isNull(vo)){ - logger.error("平台侧无此网关信息,请先录入!"); - return; - } - ReqAndResParam.Req reqAndResParam = new ReqAndResParam.Req(); - reqAndResParam.setMid(1); - reqAndResParam.setDid("0"); - reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode()); - reqAndResParam.setType(TypeEnum.TYPE_1.getCode()); - reqAndResParam.setExpire(-1); - reqAndResParam.setMsg(null); - publisher.send("/Pfm/Topic/"+nDid, PubUtils.obj2json(reqAndResParam),1,false); - } - - @Override - public boolean addList(List list) { - return this.saveOrUpdateBatch(list,100); - } -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/DataArrayServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/DataArrayServiceImpl.java deleted file mode 100644 index 4794f1d..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/DataArrayServiceImpl.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.njcn.access.service.IDataArrayService; -import org.springframework.stereotype.Service; - -/** - * 类的介绍: - * - * @author xuyang - * @version 1.0.0 - * @createTime 2023/4/18 11:06 - */ -@Service -public class DataArrayServiceImpl implements IDataArrayService { - - - -} diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/DataSetServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/DataSetServiceImpl.java deleted file mode 100644 index 28681e5..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/DataSetServiceImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import com.njcn.access.service.IDataSetService; -import org.springframework.stereotype.Service; - -/** - * 类的介绍: - * - * @author xuyang - * @version 1.0.0 - * @createTime 2023/4/18 11:06 - */ -@Service -public class DataSetServiceImpl implements IDataSetService { - @Override - public void add() { - - } -} 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 deleted file mode 100644 index ab592d7..0000000 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/serviceImpl/DevModelServiceImpl.java +++ /dev/null @@ -1,638 +0,0 @@ -package com.njcn.access.service.serviceImpl; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.date.DatePattern; -import com.alibaba.nacos.shaded.com.google.gson.Gson; -import com.njcn.access.enums.AccessResponseEnum; -import com.njcn.access.enums.TypeEnum; -import com.njcn.access.pojo.dto.data.*; -import com.njcn.access.pojo.dto.devModel.*; -import com.njcn.access.pojo.param.DevModelParam; -import com.njcn.access.pojo.po.*; -import com.njcn.access.service.*; -import com.njcn.access.utils.JsonUtil; -import com.njcn.algorithm.api.CsDictFeignClient; -import com.njcn.algorithm.api.DevModelFeignClient; -import com.njcn.algorithm.pojo.dto.CsDictDTO; -import com.njcn.algorithm.pojo.param.CsDevModelAddParm; -import com.njcn.algorithm.pojo.po.CsDevModelPO; -import com.njcn.common.pojo.exception.BusinessException; -import com.njcn.oss.utils.FileStorageUtil; -import com.njcn.system.api.DicDataFeignClient; -import com.njcn.system.api.EpdFeignClient; -import com.njcn.system.enums.DicDataEnum; -import com.njcn.system.pojo.param.EleEpdPqdParam; -import com.njcn.system.pojo.po.DictData; -import com.njcn.system.pojo.po.EleEpdPqd; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; -import org.springframework.beans.BeanUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; - -import java.io.IOException; -import java.sql.SQLOutput; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * 类的介绍: - * - * @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; - - private final CsDictFeignClient csDictFeignClient; - - private final ICsNetDevService csNetDevService; - - private final ICsSoftInfoService csSoftInfoService; - - private final ICsPrjInfoService csPrjInfoService; - - private final ICsEpdPqdService csEpdPqdService; - - private final ICsBmdService csBmdService; - - private final ICsEvtService csEvtService; - - private final ICsEvtParmService csEvtParmService; - - private final ICsAlmService csAlmService; - - private final ICsStsService csStsService; - - private final ICsDiService csDiService; - - private final ICsDoService csDoService; - - private final ICsParmService csParmService; - - private final ICsCtrlService csCtrlService; - - private final ICsSetService csSetService; - - private final ICsDataSetService csDataSetService; - - private final ICsDataArrayService csDataArrayService; - - private final EpdFeignClient epdFeignClient; - - @Override - @Transactional(rollbackFor = Exception.class) - public void add(DevModelParam devModelParam) { - String json = null; - try { - json = JsonUtil.convertStreamToString(devModelParam.getFile().getInputStream()); - Gson gson = new Gson(); - TemplateDto templateDto = gson.fromJson(json, TemplateDto.class); - //新增网关信息描述表 -// insertNetDevMod(templateDto.getNetDevModDto()); - //模板文件存入文件服务器 - //String filePath = fileStorageUtil.uploadMultipart(devModelParam.getFile(), OssPath.DEV_MODEL + devModelParam.getDevType() + "_"); - String filePath = ""; - //新增设备数据模板 - insertDevMod(templateDto.getDevModDto(),filePath); - - - } catch (IOException e) { - log.error("文件转成json出现异常"); - e.getMessage(); - } - } - - /** - * 新增直连设备、网关模板信息 - */ - public void insertNetDevMod(NetDevModDto netDevModDto) { - SoftInfoDto softInfoDto = netDevModDto.getDataList().get(0).getSoftInfoDto(); - PrjInfoDto prjInfoDto = netDevModDto.getDataList().get(0).getPrjInfoDto(); - CsNetDevPO csNetDevPo = new CsNetDevPO(); - BeanUtils.copyProperties(netDevModDto,csNetDevPo); - csNetDevPo.setTime(LocalDate.parse(netDevModDto.getTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN))); - csNetDevPo.setStatus(1); - if (!Objects.isNull(softInfoDto)){ - CsSoftInfoPO csSoftInfoPo = new CsSoftInfoPO(); - BeanUtils.copyProperties(softInfoDto,csSoftInfoPo); - csSoftInfoPo.setAppDate(LocalDateTime.parse(softInfoDto.getAppDate(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN))); - String softInfoId = csSoftInfoService.saveData(csSoftInfoPo).getId(); - csNetDevPo.setSoftInfoId(softInfoId); - } - if (!Objects.isNull(prjInfoDto)){ - CsPrjInfoPO csPrjInfoPo = new CsPrjInfoPO(); - BeanUtils.copyProperties(prjInfoDto,csPrjInfoPo); - String prjInfoId = csPrjInfoService.saveData(csPrjInfoPo).getId(); - csNetDevPo.setPrjInfoId(prjInfoId); - } - csNetDevService.saveData(csNetDevPo); - } - - /** - * 新增数据模板(装置类型分类) - */ - public void insertDevMod(DevModDto devModDto,String filePath) { -// String devType = devModDto.getDevType(); -// String version = devModDto.getVersion(); -// String time = devModDto.getTime(); -// CsDevModelPO csDevModelPo = devModelFeignClient.findModel(devType,version,time).getData(); -// if (!Objects.isNull(csDevModelPo)){ -// throw new BusinessException(AccessResponseEnum.MODEL_REPEAT); -// } -// /**录入基础模板数据*/ -// CsDevModelAddParm csDevModelAddParm = new CsDevModelAddParm(); -// csDevModelAddParm.setDevType(devType); -// csDevModelAddParm.setName(devType); -// csDevModelAddParm.setVersionNo(version); -// csDevModelAddParm.setVersionDate(LocalDateTime.parse(time, DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN))); -// csDevModelAddParm.setFilePath(filePath); -// SoftInfoDto softInfoDto = devModDto.getDataList().get(0).getSoftInfoDto(); -// //录入系统软件表 -// if (!Objects.isNull(softInfoDto)){ -// CsSoftInfoPO csSoftInfoPo = new CsSoftInfoPO(); -// BeanUtils.copyProperties(softInfoDto,csSoftInfoPo); -// csSoftInfoPo.setAppDate(LocalDateTime.parse(softInfoDto.getAppDate(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN))); -// String softInfoId = csSoftInfoService.saveData(csSoftInfoPo).getId(); -// csDevModelAddParm.setSoftInfoId(softInfoId); -// } -// devModelFeignClient.addDevModel(csDevModelAddParm); -// /**录入数据模型列表*/ - //录入EPD - List epdDto = devModDto.getDataList().get(0).getEpdDto(); - if (!CollectionUtils.isEmpty(epdDto)){ - DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.EPD.getCode()).getData(); - if (StringUtils.isBlank(dictData.getId())){ - throw new BusinessException(AccessResponseEnum.EPD_DICT_MISSING); - } - insertEpdPqd(epdDto,dictData); - } - //录入PQD - List pqdDto = devModDto.getDataList().get(0).getPqdDto(); - if (!CollectionUtils.isEmpty(pqdDto)){ - DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.PQD.getCode()).getData(); - if (StringUtils.isBlank(dictData.getId())){ - throw new BusinessException(AccessResponseEnum.PQD_DICT_MISSING); - } - insertEpdPqd(pqdDto,dictData); - } - //录入Bmd - List bmdDto = devModDto.getDataList().get(0).getBmdDto(); - if (!CollectionUtils.isEmpty(bmdDto)){ - DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.BMD.getCode()).getData(); - if (StringUtils.isBlank(dictData.getId())){ - throw new BusinessException(AccessResponseEnum.BMD_DICT_MISSING); - } - insertBmd(bmdDto,dictData); - } - //录入Evt - List evtDto = devModDto.getDataList().get(0).getEvtDto(); - if (!CollectionUtils.isEmpty(evtDto)){ - DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.EVT.getCode()).getData(); - if (StringUtils.isBlank(dictData.getId())){ - throw new BusinessException(AccessResponseEnum.Evt_DICT_MISSING); - } - insertEvt(evtDto,dictData); - } - //录入Alm - List almDto = devModDto.getDataList().get(0).getAlmDto(); - if (!CollectionUtils.isEmpty(almDto)){ - DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.ALM.getCode()).getData(); - if (StringUtils.isBlank(dictData.getId())){ - throw new BusinessException(AccessResponseEnum.ALM_DICT_MISSING); - } - insertAlm(almDto,dictData); - } - //录入Sts - List stsDto = devModDto.getDataList().get(0).getStsDto(); - if (!CollectionUtils.isEmpty(stsDto)){ - DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.STS.getCode()).getData(); - if (StringUtils.isBlank(dictData.getId())){ - throw new BusinessException(AccessResponseEnum.STS_DICT_MISSING); - } - insertSts(stsDto,dictData); - } - //录入Di - List diDto = devModDto.getDataList().get(0).getDiDto(); - if (!CollectionUtils.isEmpty(diDto)){ - DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.DI.getCode()).getData(); - if (StringUtils.isBlank(dictData.getId())){ - throw new BusinessException(AccessResponseEnum.DI_DICT_MISSING); - } - insertDi(diDto,dictData); - } - //录入Do - List doDto = devModDto.getDataList().get(0).getDoDto(); - if (!CollectionUtils.isEmpty(doDto)){ - DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.DO.getCode()).getData(); - if (StringUtils.isBlank(dictData.getId())){ - throw new BusinessException(AccessResponseEnum.DO_DICT_MISSING); - } - insertDo(doDto,dictData); - } - //录入Parm - List parmDto = devModDto.getDataList().get(0).getParmDto(); - if (!CollectionUtils.isEmpty(parmDto)){ - DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.PARM.getCode()).getData(); - if (StringUtils.isBlank(dictData.getId())){ - throw new BusinessException(AccessResponseEnum.PARM_DICT_MISSING); - } - insertParm(parmDto,dictData); - } - //录入Set - List setDto = devModDto.getDataList().get(0).getSetDto(); - if (!CollectionUtils.isEmpty(setDto)){ - DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.SET.getCode()).getData(); - if (StringUtils.isBlank(dictData.getId())){ - throw new BusinessException(AccessResponseEnum.SET_DICT_MISSING); - } - insertSet(setDto,dictData); - } - //录入InSet - List inSetDto = devModDto.getDataList().get(0).getInSetDto(); - if (!CollectionUtils.isEmpty(inSetDto)){ - DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.INSET.getCode()).getData(); - if (StringUtils.isBlank(dictData.getId())){ - throw new BusinessException(AccessResponseEnum.INSET_DICT_MISSING); - } - insertInSet(inSetDto,dictData); - } - //录入Ctrl - List ctrlDto = devModDto.getDataList().get(0).getCtrlDto(); - if (!CollectionUtils.isEmpty(ctrlDto)){ - DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.CTRL.getCode()).getData(); - if (StringUtils.isBlank(dictData.getId())){ - throw new BusinessException(AccessResponseEnum.CTRL_DICT_MISSING); - } - insertCtrl(ctrlDto,dictData); - } - - -// /**录入数据集*/ -// List dataSetDtoList = devModDto.getDataSetDtoList(); -// if (!CollectionUtils.isEmpty(dataSetDtoList)){ -// insertDataSet(dataSetDtoList,"60b55915717c0cfd8935e04633657034"); -// } -// /**录入逻辑子设备序列*/ -// List clDevDtoList = devModDto.getClDevDtoList(); - } - - /** - * EPD、PQD字典录入 - */ - public void insertEpdPqd(List epdPqdDto,DictData dictData) { - List dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData(); - List paramList = epdPqdDto.stream().map(item->{ - EleEpdPqdParam param = new EleEpdPqdParam(); - BeanUtils.copyProperties(item,param); - if (Objects.isNull(item.getPhase())){ - param.setPhase("M"); - } - if (!CollectionUtils.isEmpty(item.getStatMethod())){ - param.setStatMethod(item.getStatMethod().stream().map(String::valueOf).collect(Collectors.joining(","))); - } - param.setShowName(item.getName()); - param.setDataType(dictData.getId()); - param.setClassId(dictData.getValue()); - param.setSort(0); - param.setSystemType(""); - return param; - }).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(dictList)){ - //两个集合取差集 - paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList()); - } - if (!CollectionUtils.isEmpty(paramList)){ - epdFeignClient.addByModel(paramList); - } - } - - /** - * Bmd字典录入 - */ - public void insertBmd(List bmdDto,DictData dictData) { - List dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData(); - List paramList = bmdDto.stream().map(item->{ - EleEpdPqdParam param = new EleEpdPqdParam(); - BeanUtils.copyProperties(item,param); - if (Objects.isNull(item.getPhase())){ - param.setPhase("M"); - } - if (!CollectionUtils.isEmpty(item.getStatMethod())){ - param.setStatMethod(item.getStatMethod().stream().map(String::valueOf).collect(Collectors.joining(","))); - } - param.setShowName(item.getName()); - param.setDataType(dictData.getId()); - param.setClassId(dictData.getValue()); - param.setSort(0); - param.setSystemType(""); - return param; - }).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(dictList)){ - //两个集合取差集 - paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList()); - } - if (!CollectionUtils.isEmpty(paramList)){ - epdFeignClient.addByModel(paramList); - } - } - - /** - * Evt字典录入 - */ - public void insertEvt(List evtDto,DictData dictData) { - Map> map = new HashMap<>(); - List dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData(); - List paramList = evtDto.stream().map(item->{ - EleEpdPqdParam param = new EleEpdPqdParam(); - BeanUtils.copyProperties(item,param); - param.setPhase("M"); - param.setShowName(item.getName()); - param.setDataType(dictData.getId()); - param.setClassId(dictData.getValue()); - param.setSort(0); - param.setSystemType(""); - map.put(item.getName(),item.getParam()); - return param; - }).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(dictList)){ - //两个集合取差集 - paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList()); - } - if (!CollectionUtils.isEmpty(paramList)){ - List evtParmList = new ArrayList<>(); - Map map2 = epdFeignClient.addEvt(paramList).getData(); - paramList.forEach(item->{ - List list = map.get(item.getName()); - if (!CollectionUtils.isEmpty(list)){ - list.forEach(item2->{ - CsEvtParmPO csEvtParmPo = new CsEvtParmPO(); - BeanUtils.copyProperties(item2,csEvtParmPo); - csEvtParmPo.setPid(map2.get(item.getName())); - evtParmList.add(csEvtParmPo); - }); - } - }); - csEvtParmService.saveData(evtParmList); - } - } - - /** - * Alm字典录入 - */ - public void insertAlm(List almDto,DictData dictData) { - List dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData(); - List paramList = almDto.stream().map(item->{ - EleEpdPqdParam param = new EleEpdPqdParam(); - BeanUtils.copyProperties(item,param); - param.setPhase("M"); - param.setShowName(item.getName()); - param.setDataType(dictData.getId()); - param.setClassId(dictData.getValue()); - param.setSort(0); - param.setSystemType(""); - return param; - }).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(dictList)){ - //两个集合取差集 - paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList()); - } - if (!CollectionUtils.isEmpty(paramList)){ - epdFeignClient.addByModel(paramList); - } - } - - /** - * Sts字典录入 - */ - public void insertSts(List stsDto,DictData dictData) { - List dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData(); - List paramList = stsDto.stream().map(item->{ - EleEpdPqdParam param = new EleEpdPqdParam(); - BeanUtils.copyProperties(item,param); - param.setPhase("M"); - param.setShowName(item.getName()); - param.setDataType(dictData.getId()); - param.setClassId(dictData.getValue()); - param.setSort(0); - param.setSystemType(""); - return param; - }).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(dictList)){ - //两个集合取差集 - paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList()); - } - if (!CollectionUtils.isEmpty(paramList)){ - epdFeignClient.addByModel(paramList); - } - } - - /** - * Di字典录入 - */ - public void insertDi(List diDto,DictData dictData) { - List dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData(); - List paramList = diDto.stream().map(item->{ - EleEpdPqdParam param = new EleEpdPqdParam(); - BeanUtils.copyProperties(item,param); - param.setPhase("M"); - param.setShowName(item.getName()); - param.setDataType(dictData.getId()); - param.setClassId(dictData.getValue()); - param.setSort(0); - param.setSystemType(""); - return param; - }).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(dictList)){ - //两个集合取差集 - paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList()); - } - if (!CollectionUtils.isEmpty(paramList)){ - epdFeignClient.addByModel(paramList); - } - } - - /** - * Do字典录入 - */ - public void insertDo(List doDto,DictData dictData) { - List dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData(); - List paramList = doDto.stream().map(item->{ - EleEpdPqdParam param = new EleEpdPqdParam(); - BeanUtils.copyProperties(item,param); - param.setPhase("M"); - param.setShowName(item.getName()); - param.setDataType(dictData.getId()); - param.setClassId(dictData.getValue()); - param.setSort(0); - param.setSystemType(""); - return param; - }).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(dictList)){ - //两个集合取差集 - paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList()); - } - if (!CollectionUtils.isEmpty(paramList)){ - epdFeignClient.addByModel(paramList); - } - } - - /** - * Parm字典录入 - */ - public void insertParm(List parmDto,DictData dictData) { - List dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData(); - List paramList = parmDto.stream().map(item->{ - EleEpdPqdParam param = new EleEpdPqdParam(); - BeanUtils.copyProperties(item,param); - if (!CollectionUtils.isEmpty(item.getSetValue())){ - param.setSetValue(item.getSetValue().stream().map(String::valueOf).collect(Collectors.joining(","))); - } - param.setPhase("M"); - param.setShowName(item.getName()); - param.setDataType(dictData.getId()); - param.setClassId(dictData.getValue()); - param.setSort(0); - param.setSystemType(""); - return param; - }).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(dictList)){ - //两个集合取差集 - paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList()); - } - if (!CollectionUtils.isEmpty(paramList)){ - epdFeignClient.addByModel(paramList); - } - } - - /** - * Set字典录入 - */ - public void insertSet(List setDto,DictData dictData) { - List dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData(); - List paramList = setDto.stream().map(item->{ - EleEpdPqdParam param = new EleEpdPqdParam(); - BeanUtils.copyProperties(item,param); - param.setPhase("M"); - param.setShowName(item.getName()); - param.setDataType(dictData.getId()); - param.setClassId(dictData.getValue()); - param.setSort(0); - param.setSystemType(""); - return param; - }).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(dictList)){ - //两个集合取差集 - paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList()); - } - if (!CollectionUtils.isEmpty(paramList)){ - epdFeignClient.addByModel(paramList); - } - } - - /** - * InSet字典录入 - */ - public void insertInSet(List inSetDto,DictData dictData) { - List dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData(); - List paramList = inSetDto.stream().map(item->{ - EleEpdPqdParam param = new EleEpdPqdParam(); - BeanUtils.copyProperties(item,param); - param.setPhase("M"); - param.setShowName(item.getName()); - param.setDataType(dictData.getId()); - param.setClassId(dictData.getValue()); - param.setSort(0); - param.setSystemType(""); - return param; - }).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(dictList)){ - //两个集合取差集 - paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList()); - } - if (!CollectionUtils.isEmpty(paramList)){ - epdFeignClient.addByModel(paramList); - } - } - - /** - * Ctrl字典录入 - */ - public void insertCtrl(List ctrlDto,DictData dictData) { - List dictList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData(); - List paramList = ctrlDto.stream().map(item->{ - EleEpdPqdParam param = new EleEpdPqdParam(); - BeanUtils.copyProperties(item,param); - if (!CollectionUtils.isEmpty(item.getCtlValue())){ - param.setSetValue(item.getCtlValue().stream().map(String::valueOf).collect(Collectors.joining(","))); - } - param.setPhase("M"); - param.setShowName(item.getName()); - param.setDataType(dictData.getId()); - param.setClassId(dictData.getValue()); - param.setSort(0); - param.setSystemType(""); - return param; - }).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(dictList)){ - //两个集合取差集 - paramList = paramList.stream().filter(item->!dictList.stream().map(item2->item2.getName()+"-"+item2.getPhase()+"-"+item2.getDataType()).collect(Collectors.toList()).contains(item.getName()+"-"+item.getPhase()+"-"+item.getDataType())).collect(Collectors.toList()); - } - if (!CollectionUtils.isEmpty(paramList)){ - epdFeignClient.addByModel(paramList); - } - } - - /** - * DataSet录入 - */ - public void insertDataSet(List dataSetDtoList,String pid) { - dataSetDtoList.forEach(item->{ - CsDataSetPO csDataSetPo = new CsDataSetPO(); - BeanUtils.copyProperties(item,csDataSetPo); - CsDictDTO csDictDTO = csDictFeignClient.getOwnAndFatherData(item.getName()).getData(); - csDataSetPo.setAnotherName(csDictDTO.getName()); - if (csDictDTO.getName().contains("Rt")){ - csDataSetPo.setDataType("实时数据"); - } else if (csDictDTO.getName().contains("Stat")){ - csDataSetPo.setDataType("统计数据"); - } - csDataSetPo.setPid(pid); - csDataSetService.addOne(csDataSetPo); - List dataArrayDto = item.getDataArrayDtoList(); - if (!CollectionUtils.isEmpty(dataArrayDto)){ - insertDataArray(dataArrayDto,csDataSetPo.getId()); - } - }); - } - - /** - * DataArray录入 - */ - public void insertDataArray(List dataArrayDto,String pid) { - List list = new ArrayList<>(); - dataArrayDto.forEach(item->{ - int sort = 0; - CsDataArrayPO csDataArrayPo = new CsDataArrayPO(); - csDataArrayPo.setPid(pid); - list.add(csDataArrayPo); - }); - csDataArrayService.saveData(list); - } - -} diff --git a/iot-access/access-boot/src/main/resources/bootstrap.yml b/iot-access/access-boot/src/main/resources/bootstrap.yml index 59097cf..eb8c195 100644 --- a/iot-access/access-boot/src/main/resources/bootstrap.yml +++ b/iot-access/access-boot/src/main/resources/bootstrap.yml @@ -6,7 +6,7 @@ microservice: sentinel: url: @sentinel.url@ gateway: - url: + url: @gateway.url@ server: port: 10301 #feign接口开启服务熔断降级处理 diff --git a/iot-access/pom.xml b/iot-access/pom.xml index a3c1748..c1c64ac 100644 --- a/iot-access/pom.xml +++ b/iot-access/pom.xml @@ -22,137 +22,8 @@ UTF-8 - 1.7 - 1.7 + 8 + 8 - - - junit - junit - 4.11 - test - - - - com.baomidou - mybatis-plus-boot-starter - ${mybatis-plus.version} - - - com.baomidou - mybatis-plus-generator - ${mybatis-plus-generator.version} - - - com.github.jeffreyning - mybatisplus-plus - ${mybatis-plus.jeffreyning.version} - - - org.apache.velocity - velocity-engine-core - ${velocity.version} - - - com.njcn - common-db - ${project.version} - - - com.njcn - common-web - ${project.version} - - - com.njcn - common-oss - ${project.version} - - - com.njcn - common-core - ${project.version} - - - com.njcn - common-redis - 1.0.0 - compile - - - 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 - - - - org.springframework.kafka - spring-kafka - ${kafka.version} - - - - - - - - - maven-clean-plugin - 3.1.0 - - - - maven-resources-plugin - 3.0.2 - - - maven-compiler-plugin - 3.8.0 - - - maven-surefire-plugin - 2.22.1 - - - maven-jar-plugin - 3.0.2 - - - maven-install-plugin - 2.5.2 - - - maven-deploy-plugin - 2.8.2 - - - - maven-site-plugin - 3.7.1 - - - maven-project-info-reports-plugin - 3.0.0 - - - - diff --git a/pom.xml b/pom.xml index 3dfcec1..b1a4df3 100644 --- a/pom.xml +++ b/pom.xml @@ -201,11 +201,6 @@ mybatis-plus-generator ${mybatis-plus-generator.version} - - com.github.jeffreyning - mybatisplus-plus - ${mybatis-plus.jeffreyning.version} - org.apache.velocity velocity-engine-core