调整
This commit is contained in:
50
cs-system/cs-system-api/pom.xml
Normal file
50
cs-system/cs-system-api/pom.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>cs-system</artifactId>
|
||||
<groupId>com.njcn</groupId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cs-system-api</artifactId>
|
||||
|
||||
<name>cs-system-api</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<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-microservice</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-poi</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.jeffreyning</groupId>
|
||||
<artifactId>mybatisplus-plus</artifactId>
|
||||
<version>${mybatis-plus.jeffreyning.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.njcn.system.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.system.api.fallback.EpdFeignClientFallbackFactory;
|
||||
import com.njcn.system.pojo.param.EleEpdPqdParam;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年05月08日 15:11
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_SYSTEM_BOOT,path = "/csDictData",fallbackFactory = EpdFeignClientFallbackFactory.class,contextId = "csDictData")
|
||||
public interface EpdFeignClient {
|
||||
|
||||
@PostMapping("/addByModel")
|
||||
HttpResult<String> addByModel(@RequestBody List<EleEpdPqdParam> eleEpdPqdParam);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.njcn.system.api.fallback;
|
||||
|
||||
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.system.api.EpdFeignClient;
|
||||
import com.njcn.system.pojo.param.EleEpdPqdParam;
|
||||
import com.njcn.system.utils.CsSystemEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/24 18:46
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class EpdFeignClientFallbackFactory implements FallbackFactory<EpdFeignClient> {
|
||||
@Override
|
||||
public EpdFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if(cause.getCause() instanceof BusinessException){
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
exceptionEnum = CsSystemEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new EpdFeignClient() {
|
||||
@Override
|
||||
public HttpResult<String> addByModel(List<EleEpdPqdParam> eleEpdPqdParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}","通过模板录入字典数据",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.njcn.system.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @date 2023年04月17日 10:50
|
||||
*/
|
||||
@Getter
|
||||
public enum CsSystemResponseEnum {
|
||||
|
||||
/**
|
||||
* A0301 ~ A0399 用于治理系统模块的枚举
|
||||
* <p>
|
||||
*/
|
||||
DICT_REPEAT("A0301","字典数据重复!"),
|
||||
|
||||
CS_SYSTEM_COMMON_ERROR("A00302","治理系统模块异常"),
|
||||
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String message;
|
||||
|
||||
CsSystemResponseEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.njcn.system.pojo.param;
|
||||
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/24 14:37
|
||||
*/
|
||||
@Data
|
||||
public class EleEpdPqdParam {
|
||||
|
||||
@ApiModelProperty(value = "数据名称")
|
||||
@NotBlank(message="数据名称不能为空!")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "别名")
|
||||
private String otherName;
|
||||
|
||||
@ApiModelProperty(value = "展示名称")
|
||||
private String showName;
|
||||
|
||||
@ApiModelProperty(value = "序号")
|
||||
@NotNull(message="序号不能为空!")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "基础数据类型")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "相别")
|
||||
@NotBlank(message="相别不能为空!")
|
||||
private String phase;
|
||||
|
||||
@ApiModelProperty(value = "单位")
|
||||
private String unit;
|
||||
|
||||
@ApiModelProperty(value = "数据开始谐波次数")
|
||||
private Integer harmStart;
|
||||
|
||||
@ApiModelProperty(value = "数据结束谐波次数")
|
||||
private Integer harmEnd;
|
||||
|
||||
@ApiModelProperty(value = "数据分类")
|
||||
@NotBlank(message="数据分类不能为空!")
|
||||
private String classId;
|
||||
|
||||
@ApiModelProperty(value = "数据统计方法")
|
||||
private String statMethod;
|
||||
|
||||
@ApiModelProperty(value = "系统类别")
|
||||
private String systemType;
|
||||
|
||||
@ApiModelProperty(value = "数据模型")
|
||||
@NotBlank(message="数据模型不能为空!")
|
||||
private String dataType;
|
||||
|
||||
@ApiModelProperty(value = "数据是否上送")
|
||||
private Integer tranFlag;
|
||||
|
||||
@ApiModelProperty(value = "上送规则")
|
||||
private String tranRule;
|
||||
|
||||
@ApiModelProperty(value = "事件类别||参数类别||定值数据类型")
|
||||
private String eventType;
|
||||
|
||||
@ApiModelProperty(value = "是否存储||是否加密")
|
||||
private Integer storeFlag;
|
||||
|
||||
@ApiModelProperty(value = "是否需遥控校验")
|
||||
private Integer curSts;
|
||||
|
||||
@ApiModelProperty(value = "是否可远程控制||是否可修改||是否支持自动控制")
|
||||
private String ctlSts;
|
||||
|
||||
@ApiModelProperty(value = "设置最大值")
|
||||
private Integer maxNum;
|
||||
|
||||
@ApiModelProperty(value = "设置最小值")
|
||||
private Integer minNum;
|
||||
|
||||
@ApiModelProperty(value = "参数为enum可设置的所有值序列")
|
||||
private String setValue;
|
||||
|
||||
@ApiModelProperty(value = "参数string可设置字符串的长度上限")
|
||||
private Integer strlen;
|
||||
|
||||
@ApiModelProperty(value = "参数缺省值")
|
||||
private String defaultValue;
|
||||
|
||||
@ApiModelProperty(value = "报表数据来源(mysql表名)")
|
||||
private String resourcesId;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class EleEpdPqdUpdateParam extends EleEpdPqdParam {
|
||||
@ApiModelProperty("Id")
|
||||
@NotBlank(message = "id不为空")
|
||||
private String id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class EleEpdPqdQueryParam extends BaseParam {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.njcn.system.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-24
|
||||
*/
|
||||
@Data
|
||||
@TableName("ele_epd_pqd")
|
||||
public class EleEpdPqd {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 数据名称
|
||||
*/
|
||||
@MppMultiId(value = "name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 别名
|
||||
*/
|
||||
private String otherName;
|
||||
|
||||
/**
|
||||
* 展示
|
||||
*/
|
||||
private String showName;
|
||||
|
||||
/**
|
||||
* 数据编号
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 数据类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 相别
|
||||
*/
|
||||
@MppMultiId(value = "phase")
|
||||
private String phase;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
private String unit;
|
||||
|
||||
/**
|
||||
* 数据开始谐波次数
|
||||
*/
|
||||
private Integer harmStart;
|
||||
|
||||
/**
|
||||
* 数据结束谐波次数
|
||||
*/
|
||||
private Integer harmEnd;
|
||||
|
||||
/**
|
||||
* 数据分类,唯一类别
|
||||
*/
|
||||
@MppMultiId(value = "class_id")
|
||||
private String classId;
|
||||
|
||||
/**
|
||||
* 数据统计方法,“max”“min”“avg”“cp95”
|
||||
*/
|
||||
private String statMethod;
|
||||
|
||||
/**
|
||||
* 系统类别(区分用能/电能)
|
||||
*/
|
||||
private String systemType;
|
||||
|
||||
/**
|
||||
* 数据类型(epd、pqd...)
|
||||
*/
|
||||
@MppMultiId(value = "data_type")
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 数据是否上送 0:不上送 1:上送
|
||||
*/
|
||||
private Integer tranFlag;
|
||||
|
||||
/**
|
||||
* 上送规则 变化:“change”周期:“period”
|
||||
*/
|
||||
private String tranRule;
|
||||
|
||||
/**
|
||||
* evt的事件类别 "1"、"2"; parm的参数类别 系统参数:“sys”,运行参数:“run”,功能参数:“fun”; set的定值数据类型 “hex”“number”
|
||||
*/
|
||||
private String eventType;
|
||||
|
||||
/**
|
||||
* sts、di的是否存储 1:存储 0:不存储; ctrl的是否加密 1:加密 0:不加密
|
||||
*/
|
||||
private Integer storeFlag;
|
||||
|
||||
/**
|
||||
* sts、do的当前值; ctrl的是否需遥控校验 1:需要 0:不需要
|
||||
*/
|
||||
private Integer curSts;
|
||||
|
||||
/**
|
||||
* do的是否可远程控制 1:是 0:否; parm的是否可修改 1:是 0:否; ctrl的是否支持自动控制 1:是 0:否
|
||||
*/
|
||||
private String ctlSts;
|
||||
|
||||
/**
|
||||
* 设置最大值
|
||||
*/
|
||||
private Integer maxNum;
|
||||
|
||||
/**
|
||||
* 设置最小值
|
||||
*/
|
||||
private Integer minNum;
|
||||
|
||||
/**
|
||||
* 参数为enum可设置的所有值序列
|
||||
*/
|
||||
private String setValue;
|
||||
|
||||
/**
|
||||
* 参数string可设置字符串的长度上限
|
||||
*/
|
||||
private Integer strlen;
|
||||
|
||||
/**
|
||||
* 参数缺省值
|
||||
*/
|
||||
private String defaultValue;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.njcn.system.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/24 15:30
|
||||
*/
|
||||
@Data
|
||||
public class EleEpdPqdVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "数据名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "别名")
|
||||
private String otherName;
|
||||
|
||||
@ApiModelProperty(value = "展示名称")
|
||||
private String showName;
|
||||
|
||||
@ApiModelProperty(value = "序号")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "基础数据类型")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "相别")
|
||||
private String phase;
|
||||
|
||||
@ApiModelProperty(value = "单位")
|
||||
private String unit;
|
||||
|
||||
@ApiModelProperty(value = "数据开始谐波次数")
|
||||
private Integer harmStart;
|
||||
|
||||
@ApiModelProperty(value = "数据结束谐波次数")
|
||||
private Integer harmEnd;
|
||||
|
||||
@ApiModelProperty(value = "数据分类(influxDB表名)")
|
||||
private String classId;
|
||||
|
||||
@ApiModelProperty(value = "数据模型")
|
||||
private String dataType;
|
||||
|
||||
@ApiModelProperty(value = "报表数据来源(mysql表名)")
|
||||
private String resourcesId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.njcn.system.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.EnumUtils;
|
||||
import com.njcn.system.enums.CsSystemResponseEnum;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年12月20日 10:03
|
||||
*/
|
||||
public class CsSystemEnumUtil {
|
||||
|
||||
public static CsSystemResponseEnum getDeviceEnumResponseEnumByMessage(@NotNull Object value) {
|
||||
CsSystemResponseEnum deviceResponseEnum;
|
||||
try {
|
||||
String message = value.toString();
|
||||
if(message.indexOf(StrUtil.C_COMMA)>0){
|
||||
value = message.substring(message.indexOf(StrUtil.C_COMMA)+1);
|
||||
}
|
||||
deviceResponseEnum = EnumUtils.valueOf(CsSystemResponseEnum.class, value, CsSystemResponseEnum.class.getMethod(BusinessException.GET_MESSAGE_METHOD));
|
||||
return Objects.isNull(deviceResponseEnum) ? CsSystemResponseEnum.CS_SYSTEM_COMMON_ERROR : deviceResponseEnum;
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new BusinessException(CommonResponseEnum.INTERNAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static Enum<?> getExceptionEnum(HttpResult<Object> result){
|
||||
//如果返回错误,且为内部错误,则直接抛出异常
|
||||
CommonResponseEnum commonResponseEnum = EnumUtils.getCommonResponseEnumByCode(result.getCode());
|
||||
if (commonResponseEnum == CommonResponseEnum.SYSTEM_RESPONSE_ENUM) {
|
||||
return getDeviceEnumResponseEnumByMessage(result.getMessage());
|
||||
}
|
||||
return commonResponseEnum;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
121
cs-system/cs-system-boot/pom.xml
Normal file
121
cs-system/cs-system-boot/pom.xml
Normal file
@@ -0,0 +1,121 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>cs-system</artifactId>
|
||||
<groupId>com.njcn</groupId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cs-system-boot</artifactId>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<name>cs-system-boot</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>cs-system-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-swagger</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis-spring</artifactId>
|
||||
<version>2.0.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-db</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.jeffreyning</groupId>
|
||||
<artifactId>mybatisplus-plus</artifactId>
|
||||
<version>${mybatis-plus.jeffreyning.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>csSystemBoot</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<configuration>
|
||||
<compilerArgument>-Xlint:unchecked</compilerArgument>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<executions>
|
||||
<!--执行mvn package,即执行 mvn clean package docker:build-->
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<phase>${docker.operate}</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<!--<serverId>36dockerHarbor</serverId>-->
|
||||
<registryUrl>http://${docker.repostory}</registryUrl>
|
||||
<!-- 镜像名称 -->
|
||||
<imageName>${docker.repostory}/${docker.registry.name}/${project.artifactId}</imageName>
|
||||
<!-- 指定标签 -->
|
||||
<imageTags>
|
||||
<imageTag>latest</imageTag>
|
||||
</imageTags>
|
||||
<!-- 指定远程 Docker API地址 -->
|
||||
<dockerHost>${docker.url}</dockerHost>
|
||||
<dockerDirectory>${basedir}/</dockerDirectory>
|
||||
<!-- 复制 jar包到docker容器指定目录-->
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/ROOT</targetPath>
|
||||
<!-- 用于指定需要复制的根目录,${project.build.directory}表示target目录 -->
|
||||
<directory>${project.build.directory}</directory>
|
||||
<!-- 用于指定需要复制的文件,${project.build.finalName}.jar就是打包后的target目录下的jar包名称 -->
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.system;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.conf.EnableMPP;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年12月09日 20:59
|
||||
*/
|
||||
@Slf4j
|
||||
@MapperScan("com.njcn.**.mapper")
|
||||
@EnableFeignClients(basePackages = "com.njcn")
|
||||
@SpringBootApplication(scanBasePackages = "com.njcn")
|
||||
@EnableMPP
|
||||
public class CsSystemBootApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CsSystemBootApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.njcn.system.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
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.system.pojo.param.EleEpdPqdParam;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.system.pojo.vo.EleEpdPqdVO;
|
||||
import com.njcn.system.service.IEleEpdPqdService;
|
||||
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.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-24
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/csDictData")
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "数据字典")
|
||||
@Validated
|
||||
public class EleEpdPqdController extends BaseController {
|
||||
|
||||
private final IEleEpdPqdService eleEpdPqdService;
|
||||
|
||||
@PostMapping("/addByModel")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("根据模板录入字典数据")
|
||||
@ApiImplicitParam(name = "eleEpdPqdParam", value = "模板的字典数据", required = true)
|
||||
public HttpResult<String> addByModel(@RequestBody @Validated List<EleEpdPqdParam> eleEpdPqdParam){
|
||||
log.info("根据模板录入字典数据");
|
||||
String methodDescribe = getMethodDescribe("addByModel");
|
||||
LogUtil.njcnDebug(log, "{},模板当前解析字典数据为:", methodDescribe);
|
||||
eleEpdPqdService.saveData(eleEpdPqdParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("录入字典数据")
|
||||
@ApiImplicitParam(name = "eleEpdPqdParam", value = "字典数据", required = true)
|
||||
public HttpResult<String> add(@RequestBody @Validated EleEpdPqdParam eleEpdPqdParam){
|
||||
log.info("录入字典数据");
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},模板当前解析字典数据为:", methodDescribe);
|
||||
eleEpdPqdService.add(eleEpdPqdParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("删除字典数据")
|
||||
@ApiImplicitParam(name = "id", value = "字典数据id", required = true)
|
||||
public HttpResult<String> delete(@RequestParam String id){
|
||||
log.info("删除字典数据");
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
LogUtil.njcnDebug(log, "{},字典id为:", methodDescribe);
|
||||
eleEpdPqdService.delete(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("更新字典数据")
|
||||
@ApiImplicitParam(name = "updateParam", value = "字典数据", required = true)
|
||||
public HttpResult<String> update(@RequestBody @Validated EleEpdPqdParam.EleEpdPqdUpdateParam updateParam){
|
||||
log.info("更新字典数据");
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},字典数据为:", updateParam);
|
||||
eleEpdPqdService.update(updateParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("列表分页")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<EleEpdPqdVO>> getList(@RequestBody @Validated EleEpdPqdParam.EleEpdPqdQueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("getList");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
Page<EleEpdPqdVO> list = eleEpdPqdService.eleEpdPqdList(queryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.system.pojo.vo.EleEpdPqdVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-24
|
||||
*/
|
||||
public interface EleEpdPqdMapper extends MppBaseMapper<EleEpdPqd> {
|
||||
|
||||
Page<EleEpdPqdVO> page(@Param("page")Page<EleEpdPqdVO> page, @Param("ew") QueryWrapper<EleEpdPqdVO> queryWrapper);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?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.system.mapper.EleEpdPqdMapper">
|
||||
|
||||
<select id="page" resultType="EleEpdPqdVO">
|
||||
SELECT t0.*
|
||||
FROM ele_epd_pqd t0
|
||||
${ew.sqlSegment}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.njcn.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.system.pojo.param.EleEpdPqdParam;
|
||||
import com.njcn.system.pojo.vo.EleEpdPqdVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-24
|
||||
*/
|
||||
public interface IEleEpdPqdService {
|
||||
|
||||
/**
|
||||
* 存储模板的字典数据
|
||||
* @param eleEpdPqdParam
|
||||
*/
|
||||
void saveData(List<EleEpdPqdParam> eleEpdPqdParam);
|
||||
|
||||
/**
|
||||
* 存储字典数据
|
||||
* @param eleEpdPqdParam
|
||||
*/
|
||||
void add(EleEpdPqdParam eleEpdPqdParam);
|
||||
|
||||
/**
|
||||
* 删除字典数据
|
||||
* @param id
|
||||
*/
|
||||
void delete(String id);
|
||||
|
||||
/**
|
||||
* 更新字典数据
|
||||
* @param updateParam
|
||||
*/
|
||||
void update(EleEpdPqdParam.EleEpdPqdUpdateParam updateParam);
|
||||
|
||||
/**
|
||||
* 查询字典分页
|
||||
* @param queryParam
|
||||
* @return
|
||||
*/
|
||||
Page<EleEpdPqdVO> eleEpdPqdList(EleEpdPqdParam.EleEpdPqdQueryParam queryParam);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.njcn.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.db.constant.DbConstant;
|
||||
import com.njcn.system.enums.CsSystemResponseEnum;
|
||||
import com.njcn.system.mapper.EleEpdPqdMapper;
|
||||
import com.njcn.system.pojo.param.EleEpdPqdParam;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.system.pojo.vo.EleEpdPqdVO;
|
||||
import com.njcn.system.service.IEleEpdPqdService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-24
|
||||
*/
|
||||
@Service
|
||||
public class EleEpdPqdServiceImpl extends MppServiceImpl<EleEpdPqdMapper, EleEpdPqd> implements IEleEpdPqdService {
|
||||
|
||||
@Override
|
||||
public void saveData(List<EleEpdPqdParam> eleEpdPqdParam) {
|
||||
List<EleEpdPqd> list = eleEpdPqdParam.stream().map(item->{
|
||||
EleEpdPqd eleEpdPqd = new EleEpdPqd();
|
||||
BeanUtils.copyProperties(item,eleEpdPqd);
|
||||
return eleEpdPqd;
|
||||
}).collect(Collectors.toList());
|
||||
this.saveOrUpdateBatchByMultiId(list,1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(EleEpdPqdParam eleEpdPqdParam) {
|
||||
checkEleEpdPqdParam(eleEpdPqdParam,false);
|
||||
EleEpdPqd eleEpdPqd = new EleEpdPqd();
|
||||
BeanUtils.copyProperties(eleEpdPqdParam,eleEpdPqd);
|
||||
this.save(eleEpdPqd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String id) {
|
||||
this.baseMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(EleEpdPqdParam.EleEpdPqdUpdateParam updateParam) {
|
||||
checkEleEpdPqdParam(updateParam,true);
|
||||
EleEpdPqd eleEpdPqd = new EleEpdPqd();
|
||||
BeanUtils.copyProperties(updateParam,eleEpdPqd);
|
||||
this.updateById(eleEpdPqd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<EleEpdPqdVO> eleEpdPqdList(EleEpdPqdParam.EleEpdPqdQueryParam queryParam) {
|
||||
QueryWrapper<EleEpdPqdVO> queryWrapper = new QueryWrapper<EleEpdPqdVO>();
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
//查询参数不为空,进行条件填充
|
||||
if (StrUtil.isNotBlank(queryParam.getSearchValue())) {
|
||||
//部门根据名称模糊查询
|
||||
queryWrapper
|
||||
.and(param -> param.like("ele_epd_pqd.Name", queryParam.getSearchValue())
|
||||
.or().like("ele_epd_pqd.Other_Name", queryParam.getSearchValue())
|
||||
.or().like("ele_epd_pqd.Show_Name", queryParam.getSearchValue()));
|
||||
}
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equalsIgnoreCase(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
} else {
|
||||
//默认根据sort排序
|
||||
queryWrapper.orderBy(true, true, "Sort");
|
||||
}
|
||||
}
|
||||
return this.baseMapper.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验参数,
|
||||
* 1.检查是否存在相同名称的菜单
|
||||
* 名称 && 路径做唯一判断
|
||||
*/
|
||||
private void checkEleEpdPqdParam(EleEpdPqdParam eleEpdPqdParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<EleEpdPqd> eleEpdPqdLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
eleEpdPqdLambdaQueryWrapper
|
||||
.eq(EleEpdPqd::getName, eleEpdPqdParam.getName())
|
||||
.eq(EleEpdPqd::getPhase, eleEpdPqdParam.getPhase())
|
||||
.eq(EleEpdPqd::getClassId,eleEpdPqdParam.getClassId())
|
||||
.eq(EleEpdPqd::getDataType, eleEpdPqdParam.getDataType());
|
||||
//更新的时候,需排除当前记录
|
||||
if (isExcludeSelf) {
|
||||
if (eleEpdPqdParam instanceof EleEpdPqdParam.EleEpdPqdUpdateParam) {
|
||||
eleEpdPqdLambdaQueryWrapper.ne(EleEpdPqd::getId, ((EleEpdPqdParam.EleEpdPqdUpdateParam) eleEpdPqdParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(eleEpdPqdLambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(CsSystemResponseEnum.DICT_REPEAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
51
cs-system/cs-system-boot/src/main/resources/bootstrap.yml
Normal file
51
cs-system/cs-system-boot/src/main/resources/bootstrap.yml
Normal file
@@ -0,0 +1,51 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: '@name@'
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10224
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
spring:
|
||||
application:
|
||||
name: @artifactId@
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
- data-id: share-config.yaml
|
||||
refresh: true
|
||||
- data-Id: share-config-datasource-db.yaml
|
||||
refresh: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
#别名扫描
|
||||
type-aliases-package: com.njcn.system.pojo
|
||||
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
20
cs-system/cs-system-boot/src/test/java/com/njcn/AppTest.java
Normal file
20
cs-system/cs-system-boot/src/test/java/com/njcn/AppTest.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.njcn;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
{
|
||||
/**
|
||||
* Rigorous Test :-)
|
||||
*/
|
||||
@Test
|
||||
public void shouldAnswerWithTrue()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
||||
28
cs-system/pom.xml
Normal file
28
cs-system/pom.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>govern</artifactId>
|
||||
<groupId>com.njcn</groupId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cs-system</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0.0</version>
|
||||
<modules>
|
||||
<module>cs-system-api</module>
|
||||
<module>cs-system-boot</module>
|
||||
</modules>
|
||||
|
||||
<name>cs-system</name>
|
||||
<description>治理系统配置模块</description>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
</project>
|
||||
Reference in New Issue
Block a user