模板解析功能提交
This commit is contained in:
@@ -26,28 +26,6 @@
|
||||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-swagger</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-client</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -20,11 +20,14 @@ public enum AccessResponseEnum {
|
||||
MODEL_NO_FIND("A0302", "模板不存在,请先录入模板数据!"),
|
||||
|
||||
MESSAGE_TYPE_ERROR("A0303","报文消息类型Type错误!"),
|
||||
DEV_TYPE_ERROR("A0303","装置类型错误!"),
|
||||
|
||||
RESPONSE_ERROR("A0304","装置请求响应错误!"),
|
||||
|
||||
DEV_TYPE_NOT_FIND("A0305","装置类型未找到,需要录入!"),
|
||||
|
||||
NO_RECEIVE_FROM_DEV("A0306","未收到装置注册响应,请核查!"),
|
||||
|
||||
|
||||
;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class AlmDto implements Serializable {
|
||||
@NotNull(message = "告警事件名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("Idx")
|
||||
@SerializedName("IDX")
|
||||
@NotNull(message = "告警事件编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class BmdDto implements Serializable {
|
||||
@NotNull(message = "数据名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("Idx")
|
||||
@SerializedName("IDX")
|
||||
@NotNull(message = "数据编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class CtrlDto implements Serializable {
|
||||
@NotNull(message = "控制名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("Idx")
|
||||
@SerializedName("IDX")
|
||||
@NotNull(message = "控制编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class CtrlDto implements Serializable {
|
||||
|
||||
@SerializedName("Ctlvalue")
|
||||
@ApiModelProperty("参数为enum时可设置的所有值序列")
|
||||
private Integer ctlValue;
|
||||
private List<String> ctlValue;
|
||||
|
||||
@SerializedName("Strlen")
|
||||
@ApiModelProperty("参数string可设置字符串的长度上限")
|
||||
|
||||
@@ -24,7 +24,7 @@ public class DoDto implements Serializable {
|
||||
@NotNull(message = "开出信号名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("Idx")
|
||||
@SerializedName("IDX")
|
||||
@NotNull(message = "DO编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class EpdPqdDto implements Serializable {
|
||||
@NotNull(message = "数据名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("Idx")
|
||||
@SerializedName("IDX")
|
||||
@NotNull(message = "数据编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class EvtDto implements Serializable {
|
||||
@NotNull(message = "事件信息名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("Idx")
|
||||
@SerializedName("IDX")
|
||||
@NotNull(message = "事件编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ParmDto implements Serializable {
|
||||
@NotNull(message = "参数名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("Idx")
|
||||
@SerializedName("IDX")
|
||||
@NotNull(message = "参数编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class SetDto implements Serializable {
|
||||
@NotNull(message = "参数名称,不为空")
|
||||
private String name;
|
||||
|
||||
@SerializedName("Idx")
|
||||
@SerializedName("IDX")
|
||||
@NotNull(message = "参数编号,不为空")
|
||||
private Integer idx;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ClDevDto implements Serializable {
|
||||
|
||||
@SerializedName("DataList")
|
||||
@NotEmpty(message = "数据模型列表,不可为空")
|
||||
private List<DataArrayDto> dataList;
|
||||
private List<DevModDataListDto> dataList;
|
||||
|
||||
@SerializedName("DataSet")
|
||||
@NotEmpty(message = "数据集序列,不可为空")
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
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> lDevInfoDto;
|
||||
|
||||
@SerializedName("Epd")
|
||||
@NotEmpty(message = "电能数据,不可为空")
|
||||
private List<EpdPqdDto> epdDto;
|
||||
|
||||
@SerializedName("Pqd")
|
||||
@NotEmpty(message = "电能质量数据,不可为空")
|
||||
private List<EpdPqdDto> pqdDto;
|
||||
|
||||
@SerializedName("Bmd")
|
||||
@NotEmpty(message = "基础测量数据,不可为空")
|
||||
private List<BmdDto> bmdDto;
|
||||
|
||||
@SerializedName("Evt")
|
||||
@NotEmpty(message = "事件,不可为空")
|
||||
private List<EvtDto> evtDto;
|
||||
|
||||
@SerializedName("Alm")
|
||||
@NotEmpty(message = "告警,不可为空")
|
||||
private List<AlmDto> almDto;
|
||||
|
||||
@SerializedName("Sts")
|
||||
@NotEmpty(message = "状态,不可为空")
|
||||
private List<StsDto> stsDto;
|
||||
|
||||
@SerializedName("Di")
|
||||
@NotEmpty(message = "开入,不可为空")
|
||||
private List<DiDto> diDto;
|
||||
|
||||
@SerializedName("Do")
|
||||
@NotEmpty(message = "开出,不可为空")
|
||||
private List<DoDto> doDto;
|
||||
|
||||
@SerializedName("Parm")
|
||||
@NotEmpty(message = "参数,不可为空")
|
||||
private List<ParmDto> parmDto;
|
||||
|
||||
@SerializedName("Set")
|
||||
@NotEmpty(message = "定值,不可为空")
|
||||
private List<SetDto> setDto;
|
||||
|
||||
@SerializedName("InSet")
|
||||
@NotEmpty(message = "内部定值,不可为空")
|
||||
private List<InSetDto> inSetDto;
|
||||
|
||||
@SerializedName("Ctrl")
|
||||
@NotEmpty(message = "控制,不可为空")
|
||||
private List<CtrlDto> ctrlDto;
|
||||
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class DevModDto implements Serializable {
|
||||
|
||||
@SerializedName("DataList")
|
||||
@NotEmpty(message = "数据模型列表,不可为空")
|
||||
private List<Object> dataList;
|
||||
private List<DevModDataListDto> dataList;
|
||||
|
||||
@SerializedName("DataSet")
|
||||
@NotEmpty(message = "数据集,不可为空")
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.io.Serializable;
|
||||
* @createTime 2023/5/4 10:04
|
||||
*/
|
||||
@Data
|
||||
public class LdevInfoDto implements Serializable {
|
||||
public class LDevInfoDto implements Serializable {
|
||||
|
||||
@SerializedName("OpAttr")
|
||||
@NotEmpty(message = "读写操作属性,不可为空")
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.access.pojo.dto.devModel;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
import 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;
|
||||
|
||||
}
|
||||
@@ -31,5 +31,5 @@ public class NetDevModDto implements Serializable {
|
||||
|
||||
@SerializedName("DataList")
|
||||
@NotEmpty(message = "数据模型列表,不可为空")
|
||||
private List<Object> dataList;
|
||||
private List<NetDevModDataListDto> dataList;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
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:30
|
||||
*/
|
||||
@Data
|
||||
public class PrjInfoDto implements Serializable {
|
||||
|
||||
@SerializedName("OpAttr")
|
||||
@NotEmpty(message = "读写操作属性不可为空")
|
||||
private String opAttr;
|
||||
|
||||
@SerializedName("Province")
|
||||
@NotEmpty(message = "安装区域省,不可为空")
|
||||
private String province;
|
||||
|
||||
@SerializedName("City")
|
||||
@NotEmpty(message = "安装区域市,不可为空")
|
||||
private String city;
|
||||
|
||||
@SerializedName("County")
|
||||
@NotEmpty(message = "安装区域县或区,不可为空")
|
||||
private String county;
|
||||
|
||||
@SerializedName("Address")
|
||||
@NotEmpty(message = "安装地址(厂区或变电站),不可为空")
|
||||
private String address;
|
||||
|
||||
@SerializedName("Position")
|
||||
@NotEmpty(message = "安装位置,不可为空")
|
||||
private String position;
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.access.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@@ -19,6 +20,7 @@ public class CsBmdPO {
|
||||
|
||||
private String id;
|
||||
|
||||
@MppMultiId(value = "name")
|
||||
private String name;
|
||||
|
||||
private String anotherName;
|
||||
@@ -29,6 +31,7 @@ public class CsBmdPO {
|
||||
|
||||
private String unit;
|
||||
|
||||
@MppMultiId(value = "phase")
|
||||
private String phase;
|
||||
|
||||
private String classId;
|
||||
@@ -37,4 +40,6 @@ public class CsBmdPO {
|
||||
|
||||
private String tranRule;
|
||||
|
||||
private String opAttr;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -17,26 +21,40 @@ public class CsEpdPqdPO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String id;
|
||||
|
||||
@MppMultiId(value = "name")
|
||||
private String name;
|
||||
|
||||
private String anotherName;
|
||||
|
||||
private Integer idx;
|
||||
|
||||
private String type;
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.njcn.access.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 联网设备表
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("cs_net_dev")
|
||||
public class CsNetDevPO extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 装置型号
|
||||
*/
|
||||
private String devType;
|
||||
|
||||
private LocalDate time;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 系统软件表Id
|
||||
*/
|
||||
private String softInfoId;
|
||||
|
||||
/**
|
||||
* 工程配置表Id
|
||||
*/
|
||||
private String prjInfoId;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
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.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工程信息表
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("cs_prj_info")
|
||||
public class CsPrjInfoPO extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 读写操作属性:“r”
|
||||
*/
|
||||
private String opAttr;
|
||||
|
||||
/**
|
||||
* 安装区域省
|
||||
*/
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 安装区域省
|
||||
*/
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 安装区域县或区
|
||||
*/
|
||||
private String county;
|
||||
|
||||
/**
|
||||
* 安装地址(厂区或变电站)
|
||||
*/
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 安装位置
|
||||
*/
|
||||
private String position;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.njcn.access.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统软件表
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
@Data
|
||||
@TableName("cs_soft_info")
|
||||
public class CsSoftInfoPO extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 读写操作属性:“r”
|
||||
*/
|
||||
private String opAttr;
|
||||
|
||||
/**
|
||||
* 操作系统名称,裸机系统填Null
|
||||
*/
|
||||
private String osName;
|
||||
|
||||
/**
|
||||
* 操作系统版本,裸机系统填Null
|
||||
*/
|
||||
private String osVersion;
|
||||
|
||||
/**
|
||||
* 应用程序版本号
|
||||
*/
|
||||
private String appVersion;
|
||||
|
||||
/**
|
||||
* 应用程序发布日期
|
||||
*/
|
||||
private LocalDateTime appDate;
|
||||
|
||||
/**
|
||||
* 应用程序校验码
|
||||
*/
|
||||
private String appCheck;
|
||||
|
||||
/**
|
||||
* 是否支持远程升级程序
|
||||
*/
|
||||
private String softUpdate;
|
||||
|
||||
|
||||
}
|
||||
@@ -25,32 +25,6 @@
|
||||
<artifactId>access-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-web</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-oss</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-db</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-redis</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>algorithm-api</artifactId>
|
||||
@@ -61,12 +35,6 @@
|
||||
<artifactId>system-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!--kafka -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
<version>${kafka.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -16,6 +17,7 @@ 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) {
|
||||
|
||||
@@ -1,28 +1,18 @@
|
||||
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.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/3/31 9:12
|
||||
* @createTime 2023/5/16 13:58
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@@ -31,21 +21,13 @@ import org.springframework.web.bind.annotation.*;
|
||||
@Api(tags = "装置接入")
|
||||
public class AccessController extends BaseController {
|
||||
|
||||
private final IAccessService accessService;
|
||||
|
||||
@PostMapping("/add")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("平台发起注册")
|
||||
@ApiImplicitParam(name = "nDid", value = "网关识别码", required = true)
|
||||
public HttpResult<Object> add(@RequestParam String nDid){
|
||||
log.info("设备向装置侧发起注册请求,请求的nDid为:" + nDid);
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},设备向装置侧发起注册请求,请求的nDid为:{}", methodDescribe, nDid);
|
||||
boolean result = accessService.add(nDid);
|
||||
if (result){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.access.controller;
|
||||
|
||||
|
||||
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;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 联网设备表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/csNetDev")
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "网关管理")
|
||||
@Slf4j
|
||||
public class CsNetDevController extends BaseController {
|
||||
|
||||
}
|
||||
|
||||
@@ -42,7 +42,8 @@ public class DevModelController extends BaseController {
|
||||
log.info("装置录入模板文件");
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},装置录入模板文件", methodDescribe);
|
||||
return devModelService.add(devModelParam);
|
||||
devModelService.add(devModelParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
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<Object> 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);
|
||||
}
|
||||
}
|
||||
@@ -108,6 +108,8 @@ 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);
|
||||
//检验传递的参数是否准确
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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.CsEpdPqdPO;
|
||||
|
||||
/**
|
||||
@@ -11,6 +11,6 @@ import com.njcn.access.pojo.po.CsEpdPqdPO;
|
||||
* @author xuyang
|
||||
* @since 2023-05-11
|
||||
*/
|
||||
public interface CsEpdPqdMapper extends BaseMapper<CsEpdPqdPO> {
|
||||
public interface CsEpdPqdMapper extends MppBaseMapper<CsEpdPqdPO> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.access.pojo.po.CsNetDevPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 联网设备表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
public interface CsNetDevMapper extends BaseMapper<CsNetDevPO> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.access.pojo.po.CsPrjInfoPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工程信息表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
public interface CsPrjInfoMapper extends BaseMapper<CsPrjInfoPO> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.access.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.access.pojo.po.CsSoftInfoPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统软件表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
public interface CsSoftInfoMapper extends BaseMapper<CsSoftInfoPO> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.access.mapper.CsEpdPqdMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -12,5 +12,5 @@ public interface IAccessService {
|
||||
* 3.装置响应则修改装置状态;3分钟未响应则生成告警信息
|
||||
* @param nDid 网关识别码
|
||||
*/
|
||||
Boolean add(String nDid);
|
||||
void add(String nDid);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.github.jeffreyning.mybatisplus.service.IMppService;
|
||||
import com.njcn.access.pojo.po.CsEpdPqdPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
@@ -11,6 +14,7 @@ import com.njcn.access.pojo.po.CsEpdPqdPO;
|
||||
* @author xuyang
|
||||
* @since 2023-05-11
|
||||
*/
|
||||
public interface ICsEpdPqdService extends IService<CsEpdPqdPO> {
|
||||
public interface ICsEpdPqdService {
|
||||
|
||||
void saveData(List<CsEpdPqdPO> list);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsNetDevPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 联网设备表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
public interface ICsNetDevService {
|
||||
|
||||
boolean saveData(CsNetDevPO csNetDevPo);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsPrjInfoPO;
|
||||
import com.njcn.access.pojo.po.CsSoftInfoPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工程信息表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
public interface ICsPrjInfoService {
|
||||
|
||||
CsPrjInfoPO saveData(CsPrjInfoPO csPrjInfoPO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.njcn.access.service;
|
||||
|
||||
import com.njcn.access.pojo.po.CsSoftInfoPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统软件表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
public interface ICsSoftInfoService {
|
||||
|
||||
CsSoftInfoPO saveData(CsSoftInfoPO csSoftInfoPo);
|
||||
|
||||
}
|
||||
@@ -14,5 +14,5 @@ public interface IDevModelService {
|
||||
* 2.将文件上传至文件服务器保存起来,先以装置型号-版本号-时间作为名称名称
|
||||
* @param devModelParam 模板文件参数
|
||||
*/
|
||||
HttpResult<String> add(DevModelParam devModelParam);
|
||||
void add(DevModelParam devModelParam);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,26 @@
|
||||
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.po.CsEdDataPO;
|
||||
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;
|
||||
@@ -39,18 +47,49 @@ public class AccessServiceImpl implements IAccessService {
|
||||
|
||||
private final CsEdDataFeignClient csEdDataFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
public Boolean add(String nDid) {
|
||||
public void add(String nDid) {
|
||||
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
||||
System.out.println("vo==:" + vo);
|
||||
if (Objects.isNull(vo.getNdid())){
|
||||
logger.error("平台侧无此网关信息,请先录入!");
|
||||
return false;
|
||||
throw new BusinessException(AccessResponseEnum.NDID_NO_FIND);
|
||||
} else {
|
||||
HttpResult<CsEdDataVO> result = csEdDataFeignClient.findByDevTypeId(vo.getDevModel());
|
||||
System.out.println("result==:" + result);
|
||||
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");
|
||||
@@ -59,9 +98,8 @@ public class AccessServiceImpl implements IAccessService {
|
||||
reqAndResParam.setExpire(-1);
|
||||
AccessDto accessDto = new AccessDto();
|
||||
accessDto.setNDid(nDid);
|
||||
accessDto.setDevType(vo.getDevModel());
|
||||
accessDto.setDevType(devType);
|
||||
reqAndResParam.setMsg(accessDto);
|
||||
publisher.send("/platform/register/"+nDid, PubUtils.obj2json(reqAndResParam),1,false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
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.CsEpdPqdMapper;
|
||||
import com.njcn.access.pojo.po.CsEpdPqdPO;
|
||||
import com.njcn.access.service.ICsEpdPqdService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
@@ -15,6 +17,10 @@ import org.springframework.stereotype.Service;
|
||||
* @since 2023-05-11
|
||||
*/
|
||||
@Service
|
||||
public class CsEpdPqdServiceImpl extends ServiceImpl<CsEpdPqdMapper, CsEpdPqdPO> implements ICsEpdPqdService {
|
||||
public class CsEpdPqdServiceImpl extends MppServiceImpl<CsEpdPqdMapper, CsEpdPqdPO> implements ICsEpdPqdService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<CsEpdPqdPO> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,100);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 联网设备表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
@Service
|
||||
public class CsNetDevServiceImpl extends ServiceImpl<CsNetDevMapper, CsNetDevPO> implements ICsNetDevService {
|
||||
|
||||
@Override
|
||||
public boolean saveData(CsNetDevPO csNetDevPo) {
|
||||
LambdaQueryWrapper<CsNetDevPO> lambdaQueryWrapper = new LambdaQueryWrapper<CsNetDevPO>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工程信息表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
@Service
|
||||
public class CsPrjInfoServiceImpl extends ServiceImpl<CsPrjInfoMapper, CsPrjInfoPO> implements ICsPrjInfoService {
|
||||
|
||||
@Override
|
||||
public CsPrjInfoPO saveData(CsPrjInfoPO csPrjInfoPo) {
|
||||
this.save(csPrjInfoPo);
|
||||
return csPrjInfoPo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统软件表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-17
|
||||
*/
|
||||
@Service
|
||||
public class CsSoftInfoServiceImpl extends ServiceImpl<CsSoftInfoMapper, CsSoftInfoPO> implements ICsSoftInfoService {
|
||||
|
||||
@Override
|
||||
public CsSoftInfoPO saveData(CsSoftInfoPO entity) {
|
||||
this.save(entity);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,37 @@
|
||||
package com.njcn.access.service.serviceImpl;
|
||||
|
||||
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.pojo.dto.data.BmdDto;
|
||||
import com.njcn.access.pojo.dto.data.EpdPqdDto;
|
||||
import com.njcn.access.pojo.dto.devModel.*;
|
||||
import com.njcn.access.pojo.param.DevModelParam;
|
||||
import com.njcn.access.service.IDevModelService;
|
||||
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.param.CsDevModelQueryListParm;
|
||||
import com.njcn.algorithm.pojo.po.CsDevModelPO;
|
||||
import com.njcn.algorithm.pojo.vo.CsDevModelPageVO;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
@@ -47,71 +51,37 @@ public class DevModelServiceImpl implements IDevModelService {
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final CsDictFeignClient csDictFeignClient;
|
||||
|
||||
private final ICsNetDevService csNetDevService;
|
||||
|
||||
private final ICsSoftInfoService csSoftInfoService;
|
||||
|
||||
private final ICsPrjInfoService csPrjInfoService;
|
||||
|
||||
private final ICsEpdPqdService csEpdPqdService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public HttpResult<String> add(DevModelParam devModelParam) {
|
||||
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);
|
||||
|
||||
|
||||
// ParamDto pojo = templateDto.getParam();
|
||||
// //网关模板
|
||||
// NetDevModDto po1 = pojo.getDataArray().get(0).getTemplate().getNetDevModDto();
|
||||
// //装置信息模板
|
||||
// DevCfgDetailDto po2 = pojo.getDataArray().get(0).getTemplate().getDevCfgDetailDto();
|
||||
// //装置数据模板
|
||||
// List<DevModDetailDto> po3 = pojo.getDataArray().get(0).getTemplate().getDevModDetailDto();
|
||||
//
|
||||
// String name = po3.get(0).getName();
|
||||
// String version = po3.get(0).getVersion();
|
||||
// String time = po3.get(0).getTime();
|
||||
// String devType = po3.get(0).getDevType();
|
||||
// String devTypeId = "";
|
||||
//
|
||||
// DictData dicData = dicDataFeignClient.getDicDataByCode(devType).getData();
|
||||
// if (Objects.isNull(dicData)) {
|
||||
// log.info("新增模板失败,获取装置类型字典数据为空,请先录入装置类型!");
|
||||
// return HttpResultUtil.assembleResult(CommonResponseEnum.NO_DATA.getCode(), null, "获取装置类型字典数据为空!");
|
||||
// } else {
|
||||
// devTypeId = dicData.getId();
|
||||
// }
|
||||
// CsDevModelQueryListParm csDevModelQueryListParm = new CsDevModelQueryListParm();
|
||||
// csDevModelQueryListParm.setDevType(devTypeId);
|
||||
// csDevModelQueryListParm.setVersionNo(version);
|
||||
// csDevModelQueryListParm.setVersionDate(time);
|
||||
// csDevModelQueryListParm.setName(name);
|
||||
// CsDevModelPageVO vo = devModelFeignClient.queryDevModelOne(csDevModelQueryListParm).getData();
|
||||
// if (!Objects.isNull(vo)){
|
||||
// log.info("新增模板失败,新增的模板在库中存在!");
|
||||
// return HttpResultUtil.assembleResult(AccessResponseEnum.MODEL_REPEAT.getCode(), null, AccessResponseEnum.MODEL_REPEAT.getMessage());
|
||||
// } else {
|
||||
// CsDevModelAddParm csDevModelAddParm = new CsDevModelAddParm();
|
||||
// csDevModelAddParm.setName(name);
|
||||
// csDevModelAddParm.setDevType(devTypeId);
|
||||
// csDevModelAddParm.setVersionNo(version);
|
||||
// csDevModelAddParm.setVersionDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(time));
|
||||
// String filePath = fileStorageUtil.uploadMultipart(devModelParam.getFile(), OssPath.DEV_MODEL + devModelParam.getDevType() + "_");
|
||||
// log.info("文件路径为:" + filePath);
|
||||
// csDevModelAddParm.setFilePath(filePath);
|
||||
// //新增cs_dev_model表数据
|
||||
// CsDevModelPO csDevModelPO = devModelFeignClient.addDevModel(csDevModelAddParm).getData();
|
||||
// //新增cs_data_set
|
||||
//
|
||||
// //新增cs_data_array
|
||||
//
|
||||
// }
|
||||
} catch (IOException e) {
|
||||
log.error("文件转成json出现异常");
|
||||
e.getMessage();
|
||||
}
|
||||
// catch (ParseException e) {
|
||||
// log.error("时间转换出现异常");
|
||||
// e.getMessage();
|
||||
// }
|
||||
return HttpResultUtil.assembleResult(CommonResponseEnum.SUCCESS.getCode(), null, CommonResponseEnum.SUCCESS.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,4 +96,115 @@ public class DevModelServiceImpl implements IDevModelService {
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
* 新增直连设备、网关模板信息
|
||||
*/
|
||||
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<EpdPqdDto> epdDto = devModDto.getDataList().get(0).getEpdDto();
|
||||
if (!CollectionUtils.isEmpty(epdDto)){
|
||||
insertEpdPqd(epdDto);
|
||||
}
|
||||
//录入PQD
|
||||
List<EpdPqdDto> pqdDto = devModDto.getDataList().get(0).getPqdDto();
|
||||
if (!CollectionUtils.isEmpty(pqdDto)){
|
||||
insertEpdPqd(pqdDto);
|
||||
}
|
||||
//录入Bmd
|
||||
List<BmdDto> bmdDto = devModDto.getDataList().get(0).getBmdDto();
|
||||
if (!CollectionUtils.isEmpty(bmdDto)){
|
||||
insertEpdPqd(pqdDto);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* EPD、PQD字典录入
|
||||
*/
|
||||
public void insertEpdPqd(List<EpdPqdDto> epdPqdDto) {
|
||||
List<CsEpdPqdPO> list = epdPqdDto.stream().map(item->{
|
||||
CsEpdPqdPO csEpdPqdPo = new CsEpdPqdPO();
|
||||
BeanUtils.copyProperties(item,csEpdPqdPo);
|
||||
CsDictDTO csDictDTO = csDictFeignClient.getOwnAndFatherData(item.getName()).getData();
|
||||
if (Objects.isNull(item.getPhase())){
|
||||
csEpdPqdPo.setPhase("M");
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(item.getStatMethod())){
|
||||
csEpdPqdPo.setStatMethod(item.getStatMethod().stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||
}
|
||||
csEpdPqdPo.setAnotherName(csDictDTO.getName());
|
||||
csEpdPqdPo.setClassId(csDictDTO.getFatherName());
|
||||
return csEpdPqdPo;
|
||||
}).collect(Collectors.toList());
|
||||
csEpdPqdService.saveData(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bmd字典录入
|
||||
*/
|
||||
public void insertBmd(List<BmdDto> bmdDto) {
|
||||
List<CsBmdPO> list = bmdDto.stream().map(item->{
|
||||
CsBmdPO csBmdPo = new CsBmdPO();
|
||||
BeanUtils.copyProperties(item,csBmdPo);
|
||||
CsDictDTO csDictDTO = csDictFeignClient.getOwnAndFatherData(item.getName()).getData();
|
||||
|
||||
return csBmdPo;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -54,6 +54,60 @@
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>${velocity.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-db</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-web</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-oss</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-redis</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-swagger</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.nacos</groupId>
|
||||
<artifactId>nacos-client</artifactId>
|
||||
</dependency>
|
||||
<!--kafka -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
<version>${kafka.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
Reference in New Issue
Block a user