Initial commit

This commit is contained in:
2025-09-25 09:45:47 +08:00
commit 9e8662efc0
41 changed files with 4070 additions and 0 deletions

33
cn-auth/.gitignore vendored Normal file
View File

@@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

68
cn-auth/pom.xml Normal file
View File

@@ -0,0 +1,68 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.njcn.product</groupId>
<artifactId>CN_Product</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>cn-auth</artifactId>
<version>1.0.0</version>
<name>cn-auth</name>
<description>cn-auth</description>
<dependencies>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>njcn-common</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>mybatis-plus</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>spingboot2.3.12</artifactId>
<version>2.3.12</version>
</dependency>
<!-- Spring Security -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.3-jre</version> <!-- 使用最新稳定版 -->
</dependency>
<!-- JWT -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.5</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,91 @@
package com.njcn.product.security;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
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.RestController;
import javax.validation.constraints.NotBlank;
@RestController
@Slf4j
@RequiredArgsConstructor
public class AuthController extends BaseController {
private final AuthenticationManager authenticationManager;
private final JwtUtil jwtUtil;
@PostMapping("/cn_authenticate")
@ApiOperation("登录认证")
public HttpResult<AuthResponse> createAuthenticationToken(@RequestBody @Validated AuthRequest authRequest) {
String methodDescribe = getMethodDescribe("createAuthenticationToken");
//log.info("Authentication request - username: {}, password: {}",authRequest.getUsername(),authRequest.getPassword());
try {
// 执行认证,内部会调用 UserDetailsService 加载用户信息
Authentication authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(authRequest.getUsername(),authRequest.getPassword()));
// 将认证信息存入 SecurityContext
SecurityContextHolder.getContext().setAuthentication(authentication);
// 直接从 Authentication 对象中获取已加载的 UserDetails避免重复查询
MyUserDetails userDetails = (MyUserDetails) authentication.getPrincipal();
// 获取用户部门(假设 CustomUserDetails 包含部门信息)
String department = userDetails.getDeptId();
final String jwt = jwtUtil.generateToken(userDetails);
AuthResponse authResponse = new AuthResponse();
authResponse.setToken(jwt);
authResponse.setDeptId(department);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, authResponse, methodDescribe);
} catch (Exception e) {
e.printStackTrace();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
}
}
}
// 认证请求类
class AuthRequest {
@NotBlank(message = "用户名不可为空")
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}

View File

@@ -0,0 +1,20 @@
package com.njcn.product.security;
import lombok.Data;
/**
* @Author: cdf
* @CreateTime: 2025-06-26
* @Description:
*/
@Data
public class AuthResponse {
private String token;
private String deptId;
private String roleId;
private String userIndex;
}

View File

@@ -0,0 +1,81 @@
package com.njcn.product.security;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import io.jsonwebtoken.ExpiredJwtException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Component
@Slf4j
public class JwtRequestFilter extends OncePerRequestFilter {
private final UserDetailsService userDetailsService;
private final JwtUtil jwtUtil;
public JwtRequestFilter(UserDetailsService userDetailsService, JwtUtil jwtUtil) {
this.userDetailsService = userDetailsService;
this.jwtUtil = jwtUtil;
}
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws ServletException, IOException {
final String authorizationHeader = request.getHeader("Authorization");
String username = null;
String jwt = null;
if (authorizationHeader != null && authorizationHeader.startsWith("Bearer ")) {
jwt = authorizationHeader.substring(7);
try {
username = jwtUtil.extractUsername(jwt);
} catch (ExpiredJwtException e) {
log.error(e.getMessage());
sendErrorResponse(response,CommonResponseEnum.TOKEN_EXPIRE_JWT);
return;
} catch (Exception e) {
log.error(e.getMessage());
sendErrorResponse(response,CommonResponseEnum.PARSE_TOKEN_ERROR);
return;
}
}
if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
UserDetails userDetails = this.userDetailsService.loadUserByUsername(username);
if (jwtUtil.validateToken(jwt, userDetails)) {
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken =
new UsernamePasswordAuthenticationToken(
userDetails, null, userDetails.getAuthorities());
usernamePasswordAuthenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
}
}
chain.doFilter(request, response);
}
private void sendErrorResponse(HttpServletResponse response, CommonResponseEnum error) throws IOException {
response.setStatus(HttpServletResponse.SC_OK);
response.setContentType("application/json;charset=UTF-8");
HttpResult<String> httpResult = new HttpResult<>();
httpResult.setCode(error.getCode());
httpResult.setMessage(error.getMessage());
response.getWriter().write(new JSONObject(httpResult, false).toString());
}
}

View File

@@ -0,0 +1,85 @@
package com.njcn.product.security;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.security.Keys;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;
import java.security.Key;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
@Component
public class JwtUtil {
private final String userId = "userId";
private final String userName = "userName";
private final String deptId = "deptId";
private static final Key SECRET_KEY = Keys.secretKeyFor(SignatureAlgorithm.HS256);
private static final long EXPIRATION_TIME = 1000 * 60 * 60 * 1000000000L; // 100000小时
// 生成JWT令牌
public String generateToken(MyUserDetails userDetails) {
Map<String, Object> claims = new HashMap<>();
claims.put(userId,userDetails.getUserId());
claims.put(userName,userDetails.getUsername());
claims.put(deptId,userDetails.getDeptId());
return createToken(claims, userDetails.getUsername());
}
private String createToken(Map<String, Object> claims, String subject) {
return Jwts.builder()
.setClaims(claims)
.setSubject(subject)
.setIssuedAt(new Date(System.currentTimeMillis()))
.setExpiration(new Date(System.currentTimeMillis() + EXPIRATION_TIME))
.signWith(SECRET_KEY, SignatureAlgorithm.HS256)
.compact();
}
// 验证令牌
public Boolean validateToken(String token, UserDetails userDetails) {
final String username = extractUsername(token);
return (username.equals(userDetails.getUsername()) && !isTokenExpired(token));
}
// 提取用户名
public String extractUsername(String token) {
return extractClaim(token, it->it.get(userName).toString());
}
// 提取用户ID
public String extractUserId(String token) {
return extractClaim(token,it->it.get(userId).toString());
}
// 提取用户部门
public String extractDepartment(String token) {
return extractClaim(token, it->it.get(deptId).toString());
}
// 提取过期时间
public Date extractExpiration(String token) {
return extractClaim(token, Claims::getExpiration);
}
private <T> T extractClaim(String token, Function<Claims, T> claimsResolver) {
final Claims claims = extractAllClaims(token);
return claimsResolver.apply(claims);
}
private Claims extractAllClaims(String token) {
return Jwts.parser().setSigningKey(SECRET_KEY).parseClaimsJws(token).getBody();
}
private Boolean isTokenExpired(String token) {
return extractExpiration(token).before(new Date());
}
}

View File

@@ -0,0 +1,64 @@
package com.njcn.product.security;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.Collection;
/**
* @Author: cdf
* @CreateTime: 2025-06-26
* @Description:
*/
@Data
public class MyUserDetails implements UserDetails {
private String userId; // 用户唯一标识
private String username; // 用户名
private String password; // 密码
private String deptId; // 部门信息
private Collection<? extends GrantedAuthority> authorities; // 权限集合
private boolean accountNonExpired; // 账户是否未过期
private boolean accountNonLocked; // 账户是否未锁定
private boolean credentialsNonExpired; // 凭证是否未过期
private boolean enabled; // 账户是否启用
public MyUserDetails(String userId,String username, String password, String deptId,Collection<? extends GrantedAuthority> authorities) {
this.userId = userId;
this.username = username;
this.password = password;
this.deptId = deptId;
this.authorities = authorities;
}
@Override
public String getPassword() {
return this.password;
}
@Override
public String getUsername() {
return this.username;
}
@Override
public boolean isAccountNonExpired() {
return true;
}
@Override
public boolean isAccountNonLocked() {
return true;
}
@Override
public boolean isCredentialsNonExpired() {
return true;
}
@Override
public boolean isEnabled() {
return true;
}
}

View File

@@ -0,0 +1,51 @@
package com.njcn.product.security;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@Service
@RequiredArgsConstructor
public class MyUserDetailsService implements UserDetailsService {
@Override
public MyUserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
if("system_event".equals(username)){
return new MyUserDetails("12345678910","system_event", "@#001njcnpqs","10001",
new ArrayList<>());
}
// 这里应该从数据库中获取用户信息
PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
String encodedPassword = passwordEncoder.encode("@#001njcnpqs");
/*
LambdaQueryWrapper<PqsUser> userWrapper = new LambdaQueryWrapper<>();
userWrapper.eq(PqsUser::getLoginname,username);
PqsUser pqsUser = pqsUserMapper.selectOne(userWrapper);
if(Objects.isNull(pqsUser)){
throw new UsernameNotFoundException("User not found with username: " + username);
}
LambdaQueryWrapper<PqsUserSet> userSetWrapper = new LambdaQueryWrapper<>();
userSetWrapper.eq(PqsUserSet::getUserIndex,pqsUser.getUserIndex());
PqsUserSet pqsUserSet = pqsUserSetMapper.selectOne(userSetWrapper);
String deptId = pqsUserSet.getDeptsIndex();*/
return new MyUserDetails("12345678910","cdf", encodedPassword,"beac2cdb4acc4826d4519ea4177f3bfa",
new ArrayList<>());
}
}

View File

@@ -0,0 +1,58 @@
package com.njcn.product.security;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import javax.annotation.Resource;
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Resource
private UserDetailsService userDetailsService;
@Resource
private JwtRequestFilter jwtRequestFilter;
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests()
//.antMatchers("/cn_authenticate","/ws/**","/accept/testEvent","/accept/eventMsg").permitAll() // 允许访问认证接口
.antMatchers("/**").permitAll() // 允许访问认证接口
.anyRequest().authenticated()
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS); // 使用无状态会话
http.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class);
}
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}

33
cn-system/.gitignore vendored Normal file
View File

@@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

55
cn-system/pom.xml Normal file
View File

@@ -0,0 +1,55 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.njcn.product</groupId>
<artifactId>CN_Product</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>cn-system</artifactId>
<version>1.0.0</version>
<name>cn-system</name>
<description>cn-system</description>
<dependencies>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>njcn-common</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>mybatis-plus</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>spingboot2.3.12</artifactId>
<version>2.3.12</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>common-oss</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>com.njcn</groupId>
<artifactId>common-web</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,64 @@
package com.njcn.product.system.dict.controller;
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.product.system.dict.pojo.po.DictData;
import com.njcn.product.system.dict.service.IDictDataService;
import com.njcn.product.system.elequality.pojo.param.EleEpdPqdParam;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
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 springfox.documentation.annotations.ApiIgnore;
import java.util.List;
/**
* @Author: cdf
* @CreateTime: 2025-09-18
* @Description:
*/
@Slf4j
@RestController
@RequestMapping("/dicData")
@RequiredArgsConstructor
@Api(tags = "数据字典")
public class DicDataController extends BaseController {
private final IDictDataService iDictDataService;
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@GetMapping("/getDicDataByCodeAndType")
@ApiOperation("根据字典Code和字典类型查询字典数据")
@ApiImplicitParams({
@ApiImplicitParam(name = "dicDataCode", value = "查询参数", required = true),
@ApiImplicitParam(name = "dicTypeCode", value = "查询参数", required = true)
})
public HttpResult<DictData> getDicDataByCodeAndType(@RequestParam("dicDataCode") String dicCode, @RequestParam("dicTypeCode") String typeCode) {
String methodDescribe = getMethodDescribe("getDicDataByCodeAndType");
DictData result = iDictDataService.getDicDataByCodeAndType(dicCode,typeCode);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@GetMapping("/getDicDataByTypeCode")
@ApiOperation("根据字典类型code查询字典数据")
@ApiImplicitParam(name = "dictTypeCode", value = "查询参数", required = true)
public HttpResult<List<DictData>> getDicDataByTypeCode(@RequestParam("dictTypeCode") String dictTypeCode) {
String methodDescribe = getMethodDescribe("getDicDataByTypeCode");
List<DictData> result = iDictDataService.getDicDataByTypeCode(dictTypeCode);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -0,0 +1,40 @@
package com.njcn.product.system.dict.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.product.system.dict.pojo.po.DictData;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author hongawen
* @since 2021-12-13
*/
public interface DictDataMapper extends BaseMapper<DictData> {
/**
* 根据字典类型名称&数据名称获取字典数据
*
* @param dicTypeName 字典类型名称
* @param dicDataName 字典数据名称
* @return 字典数据
*/
DictData getDicDataByNameAndTypeName(@Param("dicTypeName") String dicTypeName, @Param("dicDataName") String dicDataName);
/**
* @param dictTypeCode 字典类型名称
* @return 根据字典类型名称查询字典数据
*/
List<DictData> getDicDataByTypeCode(@Param("dictTypeCode") String dictTypeCode);
DictData getDicDataByCodeAndType(@Param("dicCode") String dicCode, @Param("typeCode") String typeCode);
}

View File

@@ -0,0 +1,62 @@
<?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.product.system.dict.mapper.DictDataMapper">
<select id="getDicDataByNameAndType" resultType="DictData">
SELECT sys_dict_data.*
FROM sys_dict_data sys_dict_data
LEFT JOIN sys_dict_type sdt ON sdt.Id = sys_dict_data.Type_Id
WHERE sys_dict_data.name = #{dicName}
and sys_dict_data.state = 1
and sdt.Name= #{typeName}
order by sys_dict_data.sort
</select>
<!-- 根据字典名称查询字典数据-->
<select id="getDicDataByCode" resultType="DictData">
SELECT sys_dict_data.*
FROM sys_dict_data sys_dict_data
WHERE sys_dict_data.code = #{code}
and sys_dict_data.state = 1
order by sys_dict_data.sort
</select>
<select id="getDicDataByNameAndTypeName" resultType="DictData">
SELECT
T2.*
FROM
sys_dict_type t1,
sys_dict_data t2
WHERE
t1.id = t2.Type_Id
AND T1.State = 1
AND T2.State = 1
AND t1.NAME = #{dicTypeName}
AND t2.NAME = #{dicDataName}
</select>
<!-- 根据字典类型名称查询字典数据-->
<select id="getDicDataByTypeCode" resultType="DictData">
SELECT sys_dict_data.*
FROM sys_dict_data sys_dict_data,
sys_dict_type sys_dict_type
WHERE sys_dict_data.type_id = sys_dict_type.id
AND sys_dict_type.code = #{dictTypeCode}
and sys_dict_data.state = 1
order by sort
</select>
<select id="getDicDataByCodeAndType" resultType="com.njcn.product.system.dict.pojo.po.DictData">
SELECT sys_dict_data.*
FROM sys_dict_data sys_dict_data
LEFT JOIN sys_dict_type sdt ON sdt.Id = sys_dict_data.Type_Id
WHERE sys_dict_data.code = #{dicCode}
and sys_dict_data.state = 1
and sdt.code= #{typeCode}
order by sys_dict_data.sort
</select>
</mapper>

View File

@@ -0,0 +1,684 @@
package com.njcn.product.system.dict.pojo.enums;
import lombok.Getter;
/**
* 类的介绍:字典数据名称
*
* @author xuyang
* @version 1.0.0
* @createTime 2021/8/5 21:56
*/
@Getter
public enum DicDataEnum {
/**
* 数据中心稳态统计指标
*/
PLPC_ENUM("频率偏差", "PLPC"),
DYPC_ENUM("电压偏差", "DYPC"),
SXDYBPHD_ENUM("负序电压不平衡度", "SXDYBPHD"),
XBDY_ENUM("谐波电压", "XBDY"),
CSSB_ENUM("长时闪变", "CSSB"),
XBDL_ENUM("谐波电流", "XBDL"),
FXDL_ENUM("负序电流", "FXDL"),
JXBDY_ENUM("间谐波电压", "JXBDY"),
/**
* 稳态统计指标
*/
VOLTAGE_DEV("电压偏差", "Voltage_Dev"),
FLICKER("长时闪变", "Flicker"),
HARMONIC_VOLTAGE("谐波电压", "Harmonic_Voltage"),
HARMONIC_CURRENT("谐波电流", "Harmonic_Current"),
INTERHARMONIC_VOLTAGE("间谐波电压", "Interharmonic_Voltage"),
PHASE_VOLTAGE("负序电压不平衡度", "phase_Voltage"),
FREQUENCY_DEV("频率偏差", "Frequency_Dev"),
NEG_CURRENT("负序电流", "Neg_Current"),
THD_V("电压总谐波畸变率", "Thd_V"),
phase_Voltage("三相电压不平衡度","phase_Voltage"),
TOTAL_INDICATOR("总稳态指标", "Total_Indicator"),
/**
* 污区图统计类型
*/
I_ALL("谐波电流", "I_All"),
V_HARMONIC("谐波电压", "V_Harmonic"),
/**
* 谐波污染值
*/
I_ALL_LIMIT("谐波电流", "I_All_Limit"),
V_HARMONIC_LIMIT("谐波电压", "V_Harmonic_Limit"),
/**
* 监测点类别
*/
ONE_LINE("Ⅰ类监测点", "One_Line"),
TWO_LINE("Ⅱ类监测点", "Two_Line"),
THREE_LINE("Ⅲ类监测点", "Three_Line"),
/**
* 监测点类型
*/
Power_Supply_Point("供电点","Power_Supply_Point"),
Pub_Connect_Point("公共连接点PCC","Pub_Connect_Point"),
Parallel_Point("并网点","Parallel_Point"),
Other("其他","Other"),
/**
* 电压互感器类型
*/
Cap_V("电容式","Cap_V"),
Pele_V("光电式","Pele_V"),
Elec_V("电子式","Elec_V"),
Other_S("其他","Other"),
Ele_V("电磁式","Ele_V"),
/**
* 中性点接地方式
*/
Ground_Res("经非线性电阻接地-消谐器","Ground_Res"),
Ground_Trans("经互感器接地-4PT","Ground_Trans"),
Ground_Dir("直接接地-3PT","Ground_Dir"),
A_Center("A类测试中性点接地方式","A_Center"),
Ground_Other("其他","Other"),
/**
* 终端类型
*/
DEV_QUALITY("电能质量监测终端", "Dev_Quality"),
DEV_SMART("智能电表", "Dev_Smart"),
DEV_MIX("智能融合终端", "Dev_Mix"),
/**
* 装置类别
*/
Test_Equipment("测试设备","Test_Equipment"),
Monitor_Terminals("监测终端","Monitor_Terminals"),
Detect_Equipment("检测设备","Detect_Equipment"),
Govern_Devices("治理设备","Govern_Devices"),
/***
* 告警类型
*/
COMM_ERR("通讯异常", "Comm_Err"),
/**
* 暂态统计指标
*/
TOTAL_INDICATORS("总暂态指标", "Total_Indicators"),
VOLTAGE_DIP("电压暂降", "Voltage_Dip"),
VOLTAGE_RISE("电压暂升", "Voltage_Rise"),
SHORT_INTERRUPTIONS("短时中断", "Short_Interruptions"),
DISTURBANCE("扰动", "Disturbance"),
OTHER("其他", "Other"),
RECORDING_WAVE("录波", "Recording_Wave"),
/**
* 数据类型
*/
MAINNET_POINT("主网测点", "Mainnet_Point"),
DISTRIBUTION_POINT("配网测点", "Distribution_Point"),
/**
* 分布式光伏台区渗透率水平
*/
RATE_0_25("0-25", "Rate_0_25"),
RATE_25_50("25-50", "Rate_25_50"),
RATE_50_75("50-75", "Rate_50_75"),
RATE_75_100("75-100", "Rate_75_100"),
RATE_100("100", "Rate_100"),
/**
* 入网报告状态
*/
NEWLY("新建", "Newly"),
AUDIT("待审核", "Audit"),
FAILED("未通过", "Failed"),
FINISH("已生效", "Finish"),
/**
* 审核状态
*/
INIT("新建", "Init"),
FAIL("未通过", "Fail"),
AUDITT("待审核", "Auditt"),
SUCCESS("已通过", "Success"),
/**
* 填报进度
*/
NOT_REPORTED("未填报", "Not_Reported"),
INSIGHTS("成效分析", "Insights"),
PLAN_MEASURES("计划整改措施", "Plan_Measures"),
ACTUAL_MEASURES("实际采取措施", "Actual_Measures"),
CAUSE_ANALYSIS("原因分析", "Cause_Analysis"),
ARCHIVED("已归档", "Archived"),
/**
* 问题来源
*/
ONLINE("在线监测告警", "Online"),
DEV_EXCEPTION("设备异常", "Dev_Exception"),
GENERAL("普测超标", "General"),
USER_COMPLAINTS("用户投诉", "User_Complaints"),
/**
* 台区电能质量事件类型
*/
EVENT_TYPE_P("低功率因数0.7-0.8", "Event_Type_p"),
EVENT_TYPE_U("潮流倒送", "Event_Type_u"),
EVENT_TYPE_T("电压越上限15%以上", "Event_Type_t"),
EVENT_TYPE_W("电压越限", "Event_Type_w"),
EVENT_TYPE_O("低功率因数0.7以下", "Event_Type_o"),
EVENT_TYPE_E("电压越上限", "Event_Type_e"),
EVENT_TYPE_Y("电压越下限", "Event_Type_y"),
EVENT_TYPE_L("低功率因数0.8-0.9", "Event_Type_l"),
EVENT_TYPE_Q("电压总谐波畸变率超标", "Event_Type_q"),
EVENT_TYPE_R("电压越上限7%-15%", "Event_Type_r"),
EVENT_TYPE_I("低功率因数", "Event_Type_i"),
PENET_LIMIT("渗透率超上限", "Penet_Limit"),
EVENT_TYPE_A("潮流倒送导致设备重载", "Event_Type_a"),
EVENT_TYPE_S("潮流倒送导致设备过载", "Event_Type_s"),
EVENT_TYPE_D("电压越上限严重度", "Event_Type_d"),
EVENT_TYPE_F("电压越下限严重度", "Event_Type_f"),
EVENT_TYPE_G("渗透率", "Event_Type_g"),
EVENT_TYPE_Z("超标3%-10%", "Event_Type_z"),
EVENT_TYPE_X("超标10%以下", "Event_Type_x"),
EVENT_TYPE_C("重过载", "Event_Type_c"),
/**
* 监测点状态
*/
RUN("运行", "Run"),
OVERHAUL("检修", "Overhaul"),
DEBUGGING("调试", "Debugging"),
DECOMMISSIONING("停运", "Decommissioning"),
RETIREMENT("退役", "Retirement"),
/**
* 终端状态
*/
FREE_MOORY("剩余内存", "Free_Mmory"),
FREE_STORE("剩余存储空间", "Free_Store"),
NOT_OPERATION("未投运", "Not_Operation"),
RUNNING("在运", "Running"),
RETIRE("退役", "Retire"),
ON_SITE("现场留用", "On_Site"),
STOCK_STANDBY("库存备用", "Stock_Standby"),
TO_BE_SCRAPPED("待报废", "To_Be_Scrapped"),
SCRAP("报废", "Scrap"),
/**
* 监测点标签(废弃,统一使用监测点对象类型)
*/
ONSHORE_WIND("陆上风电", "Onshore_Wind"),
POWER_STATION("光伏电站", "Power_Station"),
ELECTRIFIED_RAILWAYS("电气化铁路", "Electrified_Railways"),
SMELT_LOAD("冶炼负荷", "Smelt_Load"),
DISTRIBUTED_PHOTOVOLTAICS("分布式光伏", "Distributed_Photovoltaics"),
WIND_FARM("风电场", "Wind_Farm"),
SENSITIVE_USERS("重要敏感用户", "Sensitive_Users"),
IMPORTANT_USERS("重要用户", "Important_Users"),
//废弃字段
TRACTION_STATION("牵引站", "Traction_Station"),
LINEAR_LOADS("其他非线性负荷", "Linear_Loads"),
/**
* 电压等级
*/
AC_380V("交流380V含400V", "AC_380V400V"),
DY_380V("交流0.38kV", "0.38kV"),
DY_10KV("交流10kV", "10kV"),
DY_35KV("交流35kV", "35kV"),
DY_110KV("交流110kV", "110kV"),
DY_220KV("交流220kV", "220kV"),
DY_500KV("交流500kV", "500kV"),
DY_DC_500kV("直流500kV", "DC_500kV"),
/**
* 电压等级
* 此电压用于计算,真实code请使用上面枚举
*/
V100("100V", "0.1",0.1f),
V220("220V", "0.22",0.22f),
KV038("0.38kV", "0.38",0.38f),
V380("380V", "0.38",0.38f),
KV04("0.4kV", "0.4",0.4f),
KV06("0.6kV", "0.6",0.6f),
V400("400V", "0.4",0.4f),
KV1("1kV", "1",1.0f),
KV6("6kV", "6",6.0f),
KV10("10kV", "10",10.0f),
KV20("20kV", "20",20.0f),
KV30("30kV", "30",30.0f),
KV35("35kV", "35",35.0f),
KV50("50kV", "50",50.0f),
KV66("66kV", "66",66.0f),
KV72_5("72.5kV", "725",725.0f),
KV110("110kV", "110",110.0f),
KV120("120kV", "120",120.0f),
KV125("125kV", "125",125.0f),
KV200("200kV", "200",200.0f),
KV220("220kV", "220",220.0f),
KV320("320kV", "320",320.0f),
KV330("330kV", "330",330.0f),
KV400("400kV", "400",400.0f),
KV500("500kV", "500",500.0f),
KV600("600kV", "600",600.0f),
KV660("660kV", "660",660.0f),
KV750("750kV", "750",750.0f),
KV1000("1000kV", "1000",1000.0f),
KV1100("1100kV", "1100",1100.0f),
/**
* 计划采取实施
*/
GOVERNANCE_FACTS("事实治理工程", "Governance_Facts"),
GRID_OPERATES("电网运行方式调整", "Grid_Operates"),
PARAMETER_OPT("治理装置运行参数优化", "Parameter_Opt"),
RECTIFY_ORDERS("提出整改工单", "Rectify_Orders"),
/**
* 牵引站变压器接线方式
*/
SINGLE_TRANS("单相牵引变压器", "Single_Trans"),
THREE_TRANS("三相YN d11联结牵引变压器", "Three_Trans"),
THREE_PHASE_TRANS("三相YN d11 d1组成的牵引变压器", "Three_Phase_Trans"),
SCOTT_TRANS("SCOTT牵引变压器", "SCOTT_Trans"),
YN_V_TRANS("YN v联结平衡牵引变压器", "YN_V_Trans"),
YN_A_TRANS("YN A联结平衡牵引变压器", "YN_A_Trans"),
/**
* APP暂态事件类型
*/
EVT_DIPSTR("电压暂降事件启动","Evt_DipStr"),
EVT_INTRSTR("电压中断事件启动","Evt_IntrStr"),
EVT_SWLSTR("电压暂升事件启动","Evt_SwlStr"),
/**
* 监测对象
*/
PHOTOVOLT("光伏台区", "Photovolt"),
FEEDER_TENKV("10kV馈线", "Feeder_TenkV"),
MAIN_CHANGE("主变", "Main_Change"),
/**
* 工单状态
*/
PEND_DISPATCH("待派单", "Pend_Dispatch"),
DISPATCHED("已派单", "Dispatched"),
CLOSED("已关闭", "Closed"),
/**
* 问题类型
*/
VOLTAGE_LIMIT("谐波电压越限", "Voltage_Limit"),
CURRENT_LIMIT("谐波电流越限", "Current_Limit"),
/**
* 审核状态
*/
REVIEW("待审核", "Review"),
AUDITED("已审核", "Audited"),
APPROVED("审核通过", "Approved"),
NOT_APPROVED("审核通过", "Not_Approved"),
/**
* 审核处理
*/
GENERATE("生成工单", "Generate"),
NO_REQUIRED("无需处理", "No_Required"),
/**
* 工单流程
*/
GENERATED("生成工单", "Generated"),
DISPATCH("派单", "Dispatch"),
FEEDBACK("反馈", "Feedback"),
AUDITING("审核", "Auditing"),
RECTIFICATION("整改", "Rectification"),
ASSESS("评估", "Assess"),
PIGEONHOLE("归档", "Pigeonhole"),
/**
* 评估结果
*/
PASS("评估合格", "Pass"),
NOT_PASS("评估不合格", "Not_Pass"),
/**
* 工单类型
*/
RECT_ORDER("整改单", "Rect_Order"),
/**
* 一级业务类型
*/
TRANS_BUSINESS("运检业务", "Trans_Business"),
/**
* 日志字典类型
*/
LINE_PARAMETER("监测点日志", "Line_Parameter"),
DEV_PARAMETER("设备日志", "Dev_Parameter"),
WEB_ADD("web新增用户", "Web_Add"),
DATA_PLAN("流量套餐修改", "Data_Plan"),
PROCESS_PARMETER("终端进程操作", "Process_Parmeter"),
/**
* 接线方式
*/
STAR("星型接线", "Trans_Business"),
STAR_TRIANGLE("星三角", "Star_Triangle"),
OPEN_DELTA("开口三角", "Open_Delta"),
/**
* 装置类型
*/
GATEWAY_DEV("网关", "Gateway"),
CONNECT_DEV("直连设备", "Direct_Connected_Device"),
DEV("装置", "Device"),
PORTABLE("便携式设备", "Portable"),
/**
* 数据模型
*/
APF("APF","Apf"),
DVR("DVR","Dvr"),
EPD("电能数据","Epd"),
PQD("电能质量数据","Pqd"),
BMD("基础测量数据","Bmd"),
EVT("事件","Evt"),
ALM("告警","Alm"),
STS("状态","Sts"),
DI("开入","Di"),
DO("电能数据","Do"),
PARM("参数","Parm"),
SET("定值","Set"),
INSET("内部定值","InSet"),
CTRL("控制","Ctrl"),
TERMINAL_SORT("台账类型","terminal_sort"),
/**
* 暂降原因
*/
SHORT_TROUBLE("短路故障", "Short_Trouble"),
TRANSFORMER_EXCITATION("变压器激磁", "Transformer_Excitation"),
RESON_REST("其他", "Reson_Rest"),
LARGE_INDUCTION("大型感应电动机启动", "Large_Induction"),
VOLTAGE_DISTURBANCE("电压扰动", "Voltage_Disturbance"),
/**
* 暂降类型
*/
PHASE_A("A相接地", "Phase_A"),
PHASE_B("B相接地", "Phase_B"),
PHASE_C("C相接地", "Phase_C"),
INTERPHASE_AB("AB相间", "Interphase_AB"),
INTERPHASE_BC("BC相间", "Interphase_BC"),
INTERPHASE_AC("AC相间", "Interphase_AC"),
GROUND_AB("AB两相接地", "Ground_AB"),
GROUND_BC("BC两相接地", "Ground_BC"),
GROUND_AC("AC两相接地", "Ground_AC"),
GROUND_ABC("三相接地", "Ground_ABC"),
TYPE_REST("其他", "Type_Rest"),
/**
* 监测点位置
*/
LOAD_SIDE("负载侧", "Load_Side"),
GRID_SIDE("电网侧", "Grid_Side"),
OUTPUT_SIDE("输出侧", "Output_Side"),
/**
* 警告级别
*/
ALARM("告警", "Alarm"),
FAULT("故障", "Fault"),
/**
* 装置级别
*/
MOST_IMPORMENT("极重要","Vital"),
/**
* 测量信号输入形式
*/
NUMBER_SIGNAL("数字信号","Digital_Signal"),
SIMULATION_SIGNAL("模拟信号","Analog_Signal"),
/**
* 设备地区特征
*/
DOWNTOWN("市中心区","downtown"),
CITY("市区","city"),
TOWN("城镇","town"),
COUNTY_SEAT("县城区","County_Seat"),
COUNTRYSIDE("农村","countryside"),
TOWNSHIP("乡镇","township"),
AGRO_AREA("农牧区","Agro_Area"),
/**
* 设备使用性质代码
*/
DEDICATED("专用","dedicated"),
PUBLIC("公用","public"),
/**
* 监督类型
*/
POWER_QUALITY("电能质量敏感用户监督","Power_Quality"),
UHV_Converter("特高压换流站监督","UHV_Converter"),
New_Energy("新能源场站监督","New_Energy"),
Technical_Super("供电电压质量技术监督","Technical_Super"),
capacitor_bank("电容器组监督","capacitor_bank"),
report_supervision("评估报告监督","report_supervision"),
/**
* app基础信息类型
*/
DATA_BASE("资料库","Data_base"),
INTRODUCTION("系统介绍","introduction"),
USER_MANUAL("使用手册","User_Manual"),
USER_AGREEMENT("用户协议","User_Agreement"),
COMPANY_PROFILE("公司简介","Company_Profile"),
PERSONAL_INFOR_PROTECT("个人信息保护政策","Personal_Infor_Protect"),
/**
* app设备事件类型权限转移数据恢复
*/
AUTHORITY_TRANSFER("权限转移","Authority_transfer"),
DATA_RECOVERY("数据恢复","Data_recovery"),
/**
* 谐波数据报表,数据单位类别
*/
EFFECTIVE("有效值","effective"),
POWER("功率","power"),
DISTORTION("畸变率","distortion"),
VOLTAGE("电压偏差","voltage"),
UNIT_FREQUENCY("频率","unitFrequency"),
UNBALANCE("三项不平横","unbalance"),
FUND("基波","fund"),
/**pms******************************start*/
/**
* 实施状态
*/
Nocarried("未开展","Nocarried"),
Progressing("开展中","Progressing"),
Reviewing("待审核","Reviewing"),
Completed("已完成","Completed"),
/*3.45 典型源荷用户类型*/
TRACTIONSTATION("牵引站","01"),
WINDFARM_USER("风电场用户","02"),
PHOTOVOLTAICSIT_EUSERS("光伏场站用户","03"),
OTHER_INTERFERENCESOURCE_USERS("其他干扰源用户","04"),
/*3.39 监测对象类型-大类*/
SEMICONDUCTOR_MANUFACTURING("半导体制造","2401"),
PRECISION_MACHINING("精密加工","2402"),
PARTY_GOVERNMENT("党政机关","2403"),
NOSOCOMIUM("医院","2404"),
TRANSPORTATION_HUB("交通枢纽(公交场站、客运站、火车站等)","2405"),
AERODROME("机场","2406"),
FINANCE("金融","2407"),
DATA_CENTER("数据中心","2408"),
HAZARDOUS_CHEMICALS("危险化学品","2409"),
EXPLOSIVE_PRODUCTS("易燃易爆品制造","2410"),
LARGEVENUE("大型场馆(体育场、剧院等)","2411"),
WINDPOWER_STATION("风电场","1401"),
PHOTOVOLTAIC_POWER_STATION("光伏电站","1402"),
ELECTRIFIED_RAILWAY("电气化铁路","1300"),
/**
* 所属站别类型
*/
Trans_Sub("变电站","Trans_Sub"),
Converter("换流站","Converter"),
Ele_Railways("电气化铁路","Ele_Railways"),
Wind_Farms("风电场","Wind_Farms"),
Power_Station("光伏电站","Power_Station"),
Smelting_Load("冶炼负荷","Smelting_Load"),
Imp_Users("重要敏感用户","Imp_Users"),
Station_Other("其他","Other"),
/*承载能力评估用户类型*/
Power_Station_Users("光伏电站用户","Power_Station_Users"),
Charging_Station_Users("充电站用户","Charging_Station_Users"),
Electric_Heating_Load_Users("电加热负荷用户","Electric_Heating_Load_Users"),
Electrified_Rail_Users("电气化铁路用户","Electrified_Rail_Users"),
//变压器连接方式
YNd11("YNd11","YNd11"),
YNy0("YNy0","YNy0"),
Yy0("Yy0","Yy0"),
Yyn0("Yyn0","Yyn0"),
Yd11("Yd11","Yd11"),
Y_yn("Y/yn","Y_yn"),
Y_d("Y/d","Y_d"),
D_y("D/y","D_y"),
YNyn("YNyn","YNyn"),
//用户模式
SPECIAL_USER("专变用户","special_user"),//专变用户
PUBLIC_USER("公变用户","public_user"),// ,公变用户
//统计类型
STATISTICAL_TYPE_Y("年数据","01"),
STATISTICAL_TYPE_M("月数据","02"),
STATISTICAL_TYPE_D("日数据","03"),
/**pms******************************end*/
//pq干扰源类型
PQ_ELE_RAILWAYS("电气化铁路","Ele_Railways"),
PQ_POWER_STATION("光伏电站","Power_Station"),
PQ_WIND_FARMS("风电场","Electrolytic_Load"),
//所属地市local_municipality
//张家口市、廊坊市、唐山市、承德市、秦皇岛市、风光储、超高压
ZHANGJIAKOU("张家口市","zhangjiakou"),
LANGFANG("廊坊市","langfang"),
TANGSHAN("唐山市","tangshan"),
CHENGDE("承德市","chengde"),
QINGHUANGDAO("秦皇岛市","qinghuangdao"),
FENGFENGRESERVE("风光储","fengfengreserve"),
EXTRA_HIGH_PRESSURE("超高压","extra_high_pressure"),
//行业类型-冀北
TRAFFIC("交通","Traffic"),
METALLURGY("冶金","Metallurgy"),
MACHINERY("机械","Machinery"),
CHEMICAL_INDUSTRY("化工","Chemical_Industry"),
MANUFACTURING("制造","Manufacturing"),
SHIPBUILDING("造船","Shipbuilding"),
UTILITIES("公用事业","Utilities"),
POWER_PLANT("电厂","Power_Plant"),
COMMERCE("商业","Commerce"),
MUNICIPAL("市政","Municipal"),
CIVILIAN("民用","Civilian"),
ELECTRONICS("电子","Electronics"),
COMMUNICATION("通讯","Communication"),
ELECTRIC_POWER("电力","Electric_Power"),
OTHER_INDUSTRY("其他","Other_Industry"),
//河北工单相关
//3.67工单状态
WORK_ORDER_STATUS_NO("未处理","01"),
WORK_ORDER_STATUS_ING("处理中","02"),
WORK_ORDER_STATUS_HAS("已上报","03"),
WORK_ORDER_STATUS_CLOSE("已闭环","04"),
YES("","1"),
NO("","0"),
No_Upload("未上送","0"),
Has_Upload("已上送","1"),
Reduce_Upload("取消上送","2"),
Return_Upload("待重新上送","3"),
//字典树类型
Obj_Type("监测对象类型","0"),
Custom_Report_Type("自定义报表类型","1")
;
private final String name;
private final String code;
private final Float value;
DicDataEnum(String name, String code,Float value) {
this.name = name;
this.code = code;
this.value = value;
}
DicDataEnum(String name, String code) {
this.name = name;
this.code = code;
this.value =
null;
}
public static DicDataEnum getDicDataEnumValue(String code) {
for (DicDataEnum item : values()) {
if (item.getCode().equals(code)) {
return item;
}
}
return null;
}
}

View File

@@ -0,0 +1,164 @@
package com.njcn.product.system.dict.pojo.enums;
import lombok.Getter;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2021/8/5 21:56
*/
@Getter
public enum DicDataTypeEnum {
/**
* 字典类型名称
*/
FRONT_TYPE("前置类型","Front_Type"),
POWER_CATEGORY("电源类别","Power_Category"),
POWER_STATION_TYPE("电站类型","Power_Station_Type"),
POWER_GENERATION("发电方式","Power_Generation"),
CONNECTION_MODE("能源消纳方式","Connection_Mode"),
ECC_STAT("用电客户状态","Ecc_Stat"),
DEV_TYPE("终端型号","Dev_Type"),
DEV_VARIETY("终端类型","Dev_Variety"),
DEV_FUN("终端功能","Dev_Fun"),
DEV_STATUS("终端状态","Dev_Status"),
DEV_LEVEL("终端等级","Dev_Level"),
DEV_CONNECT("接线方式","Dev_Connect"),
DEV_MANUFACTURER("制造厂商","Dev_Manufacturers"),
//电压等级用于pms区分交直流
DEV_VOLTAGE("电压等级","Dev_Voltage"),
//标准电压等级用于pq不区分交直流
DEV_VOLTAGE_STAND("标准电压等级","Dev_Voltage_Stand"),
PANORAMIC_VOLTAGE("全景电压等级","Panoramic_voltage"),
EVENT_REASON("暂降原因","Event_Reason"),
EVENT_TYPE("暂降类型","Event_Type"),
BUSINESS_TYPE("行业类型","Business_Type"),
INTERFERENCE_SOURCE_TYPE("干扰源类型","Interference_Source"),
ALARM_TYPE("告警类型","alarm_Type"),
DEV_OPS("运维日志","Dev_Ops"),
INDICATOR_TYPE("指标类型","Indicator_Type"),
COMMUNICATE_TYPE("通讯类型","Communicate_Type"),
RATE_TYPE("费率类型","Rate_Type"),
ELE_LOAD_TYPE("用能负荷类型","Ele_Load_Type"),
ELE_STATISTICAL_TYPE("用能统计类型","Ele_Statistical_Type"),
REPORT_TYPE("自定义报表类型","Report_Type"),
LINE_MARK("监测点评分等级","Line_Grade"),
LINE_TYPE("监测点类型","Line_Type"),
STEADY_STATIS("稳态统计指标","Steady_Statis"),
EVENT_STATIS("暂态指标","Event_Statis"),
MONITORING_LABELS("监测点标签","Monitoring_Labels"),
POLLUTION_STATIS("污区图统计类型","Pollution_Statis"),
POLLUTION_CALC("谐波污染值","Pollution_Calc"),
BENCHMARK_INDICATORS("基准水平评价指标","Benchmark_Indicator"),
LINE_SORT("监测点类别","Line_Sort"),
DATA_TYPE("数据类型","Data_Type"),
PERMEABILITY_TYPE("分布式光伏台区渗透率水平","Permeability_Type"),
ON_NETWORK_STATUS("报告状态","On-network_Status"),
AUDIT_STATUS("审核状态","Audit_Status"),
FILL_PROGRESS("填报进度","Fill_Progress"),
PROBLEM_SOURCES("问题来源","Problem_Sources"),
AREA_PQ_EVENT_TYPE("台区电能质量事件类型","area_pq_event_type"),
LINE_STATE("监测点状态","Line_State"),
DEVICE_STATUS("设备状态","Device_Status"),
//INTERFERENCE_SOURCE("监测对象类别","Interference_Source"),
PLAN_TAKE("计划采取实施","Plan_Take"),
MONITOR_OBJ("监测对象","Monitor_Obj"),
CONNET_GROUP_WAY("牵引站变压器接线方式","Connet_Group_Way"),
WORK_ORDER_STATUS("工单状态","Work_Order_Status"),
PROBLEM_TYPE("问题类型","Problem_Type"),
CHECK_STATUS("审核状态","Check_Status"),
CHECK_RESULT("审核处理","Check_Result"),
WORK_ORDER_PROCESS("工单流程","Work_Order_Process"),
ASSESS_RESULT("评估结果","Assess_Result"),
WORK_ORDER_TYPE("工单类型","Work_Order_Type"),
PRIMARY_TYPE("一级业务类型","Primary_Type"),
DEV_CLASS("终端类型(治理)","Dev_Class"),
CS_STATISTICAL_TYPE("治理统计类型","Cs_Statistical_Type"),
LINE_POSITION("监测点位置","Line_Position"),
ALARM_LEVEL("警告级别","Alarm_Level"),
CS_DATA_TYPE("数据模型类别", "Cs_Data_Type"),
PROBLEM_INDICATORS("问题指标","Problem_Indicators"),
//pms
DEV_CATEGORY("装置类别","Device_Category"),
DEV_GRADE("终端等级","Dev_Level"),
INPUT_SIGNAL("测量信号输入形式","Signal_form"),
VOLTAGE_TRANSFORMER("电压互感器类型","Voltage_Transformer"),
Neutral_Point("中性点接地方式","Neutral_Point"),
DEVICE_REGIONLYPE("设备地区特征","Device_RegionLype"),
DEVICE_USERNATURE("设备使用性质代码","Device_UseNature"),
SUPV_TYPE("监督类型","supv_type"),
SUPV_OBJ_TYPE("监督对象类型","supv_obj_type"),
evaluation_report("评估用户或报告分类编码","evaluation_report"),
user_class("用户分类","user_class"),
SUPV_STAGE("监督阶段","supv_stage"),
EFFECT_STATUS("实施状态","effect_status"),
MONITOR_TYPE("监督监测点类型","monitor_type"),
SUPV_PROBLEM_TYPE("监督问题类型","problem_type"),
RECTIFICATION_MEASURE("整改方案","RectificationMeasure"),
SUPV_PLAN_STATUS("监督计划状态","plan_status"),
BILL_TYPE("单据类型","bill_type"),
SPECIALITY_TYPE("所属专业","speciality_type"),
RECTIFICATION_STATUS_TYPE("整改情况","rectification_status_type"),
file_type("附件分类"," file_type"),
problem_level_type("问题等级"," problem_level_type"),
Station_Type("所属站别类型","Station_Type"),
APP_BASE_INFORMATION_TYPE("app基础信息类型","appInformationType"),
APP_DEVICE_EVENT_TYPE("app设备事件类型","appDeviceEventType"),
DEVICE_UNIT("数据单位类型","Device_Unit"),
//国网上送
pms_disturb_type("pms国网上送干扰源类型","pms_disturb_type"),
pms_disturb_sort("pms国网上送干扰源类别","pms_disturb_sort"),
type_of_station("站房类型","type_of_station"),
File_status("档案状态","File_status"),
USER_CLASS("用户分类","User_Class"),
IMPORTANCE_LEVEL("重要性等级","Importance_Level"),
ELE_CLASS("用电类别","Ele_Class"),
INDUSTRY_TYPE("行业分类","industry_type"),
PLAN_STATUS("计划状态","plan_status"),
APP_EVENT("APP暂态事件类型","app_event"),
DEVICE_TYPE("治理装置类型编码","Device_Type"),
CARRY_CAPCITY_USER_TYPE("承载能力评估用户类型","carry_capcity_user_type"),
CARRY_CAPCITY_CONNECTION_MODE("变压器连接方式","carry_capcity_connection_mode"),
CARRY_CAPCITYUSER_MODE("用户模式","carry_capcity_user_mode"),
LOCAL_MUNICIPALITY("所属地市","local_municipality"),
INDUSTRY_TYPE_JB("行业类型-冀北","industry_type_jb"),
LOAD_LEVEL("负荷级别","load_level"),
SUPPLY_CONDITION("供电电源情况","supply_condition"),
JIBEI_AREA("所属地市","jibei_area"),
Major_Nonlinear_Device("主要非线性设备类型","Major_Nonlinear_Device"),
EVALUATION_DEPT("主要非线性设备类型","evaluation_dept"),
EVALUATION_TYPE("评估类型","Evaluation_Type"),
;
private final String name;
private final String code;
DicDataTypeEnum(String name,String code){
this.name=name;
this.code=code;
}
}

View File

@@ -0,0 +1,77 @@
package com.njcn.product.system.dict.pojo.enums;
import lombok.Getter;
/**
* @author hongawen
* @version 1.0.0
* @date 2021年12月20日 09:56
*/
@Getter
public enum SystemResponseEnum {
/**
* 系统模块异常响应码的范围:
* A00350 ~ A00449
*/
SYSTEM_COMMON_ERROR("A00350","系统模块异常"),
DICT_TYPE_NAME_REPEAT("A00351", "字典类型名称重复"),
DICT_DATA_NAME_REPEAT("A00352", "字典数据名称重复"),
AREA_CODE_REPEAT("A00353","行政区域编码重复"),
LOAD_TYPE_EMPTY("A00354","用能负荷数据为空"),
LINE_MARK_EMPTY("A00355","字典监测点评分等级数据为空"),
VOLTAGE_EMPTY("A00356","查询字典电压等级数据为空"),
INTERFERENCE_EMPTY("A00356","查询字典干扰源类型数据为空"),
BUSINESS_EMPTY("A00356","查询字典行业类型数据为空"),
SYSTEM_TYPE_EMPTY("A00356","查询字典系统类型数据为空"),
DEV_TYPE_EMPTY("A00357","查询字典设备类型数据为空"),
MANUFACTURER("A00358","查询字典终端厂家数据为空"),
DEV_VARIETY("A00359","查询字典终端类型数据为空"),
/*pms*/
LINE_TYPE_VARIETY_EMPTY("A00360","查询字典监测点类型数据为空"),
LINE_STATE_EMPTY("A00361","查询字典监测点状态为空"),
LINE_TYPE_EMPTY("A00362","查询字典监测点类型状态为空"),
POTENTIAL_TYPE_EMPTY("A00363","查询字典电压互感器类型为空"),
Neutral_Mode_EMPTY("A00364","查询字典中性点接地方式为空"),
MONITOR_TAG_EMPTY("A00365","查询字典监测点标签类型为空"),
MONITORY_TYPE_EMPTY("A00366","查询字典监测对象类型为空"),
TERMINAL_WIRING_EMPTY("A00367","查询字典监测终端接线方式为空"),
MONITOR_TYPE_EMPTY("A00368","查询字典监测点类别为空"),
ACTIVATED_STATE("A00369","必须存在一个已激活的系统类型"),
ADVANCE_REASON("A00370","查询字典暂降原因为空"),
EFFECT_STATUS_EMPTY("A00370","查询字典实施状态为空"),
EVENT_REPORT_REPEAT("A00361","暂态报告模板重复"),
NOT_EXISTED("A00361", "您查询的该条记录不存在"),
TIMER_NO_CLASS("A00361", "请检查定时任务是否添加"),
/**
* 定时任务执行类不存在
*/
TIMER_NOT_EXISTED("A00361", "定时任务执行类不存在"),
EXE_EMPTY_PARAM("A00361", "请检查定时器的id定时器cron表达式定时任务是否为空"),
/**
* 审计日志模块异常响应
*/
NOT_FIND_FILE("A0300", "文件未备份或者备份文件为空,请先备份文件"),
LOG_EXCEPTION("A0301", "导入旧日志文件异常"),
LOG_EXCEPTION_TIME("A0302", "导入旧日志文件异常:缺少时间范围"),
DELETE_DATA("A0303", "导入旧日志文件异常:删除数据失败"),
MULTIPLE_CLICKS_LOG_FILE_WRITER("A0304", "当前文件备份数据未结束,请勿多次点击"),
MULTIPLE_CLICKS_RECOVER_LOG_FILE("A0303", "当前文件恢复数据未结束,请勿多次点击"),
PAGE_SAME_NAME("A00357","页面名称重复"),
;
private final String code;
private final String message;
SystemResponseEnum(String code, String message) {
this.code = code;
this.message = message;
}
}

View File

@@ -0,0 +1,87 @@
package com.njcn.product.system.dict.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.*;
/**
* @author hongawen
* @version 1.0.0
* @date 2021年12月17日 15:49
*/
@Data
public class DictDataParam {
@ApiModelProperty("字典类型id")
private String typeId;
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("编码")
private String code;
@ApiModelProperty("排序")
private Integer sort;
@ApiModelProperty("事件等级0-普通1-中等2-严重(默认为0)")
private Integer level;
@ApiModelProperty("与高级算法内部Id描述对应")
private Integer algoDescribe;
@ApiModelProperty("字典值,用于记录字典的计算值如10kV记录为 10")
private String value;
/**
* 更新操作实体
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class DictDataUpdateParam extends DictDataParam {
/**
* 表Id
*/
@ApiModelProperty("id")
private String id;
}
/**
* 分页查询实体
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class DictDataQueryParam extends BaseParam {
}
/**
* 根据字典类型id分页查询字典数据
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class DicTypeIdQueryParam extends BaseParam {
@ApiModelProperty("字典类型id")
private String typeId;
}
}

View File

@@ -0,0 +1,65 @@
package com.njcn.product.system.dict.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.mybatisplus.bo.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
*
* @author hongawen
* @since 2021-12-13
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_dict_data")
public class DictData extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 字典数据表Id
*/
private String id;
/**
* 字典类型表Id
*/
private String typeId;
/**
* 名称
*/
private String name;
/**
* 编码
*/
private String code;
/**
* 排序
*/
private Integer sort;
/**
* 事件等级0-普通1-中等2-严重(默认为0)
*/
private Integer level;
/**
* 与高级算法内部Id描述对应
*/
private Integer algoDescribe;
/**
* 目前只用于表示电压等级数值
*/
private String value;
/**
* 状态0-删除 1-正常
*/
private Integer state;
}

View File

@@ -0,0 +1,62 @@
package com.njcn.product.system.dict.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.mybatisplus.bo.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
*
* @author hongawen
* @since 2021-12-13
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_dict_type")
public class DictType extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 字典类型表Id
*/
private String id;
/**
* 名称
*/
private String name;
/**
* 编码
*/
private String code;
/**
* 排序
*/
private Integer sort;
/**
* 开启等级0-不开启1-开启,默认不开启
*/
private Integer openLevel;
/**
* 开启描述0-不开启1-开启,默认不开启
*/
private Integer openDescribe;
/**
* 描述
*/
private String remark;
/**
* 状态0-删除 1-正常
*/
private Integer state;
}

View File

@@ -0,0 +1,63 @@
package com.njcn.product.system.dict.pojo.vo;
import lombok.Data;
import java.io.Serializable;
/**
* @author hongawen
* @version 1.0.0
* @date 2021年12月20日 15:52
*/
@Data
public class DictDataVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 字典数据表Id
*/
private String id;
/**
* 字典类型表名称
*/
private String typeName;
/**
* 名称
*/
private String name;
/**
* 编码
*/
private String code;
/**
* 排序
*/
private Integer sort;
/**
* 事件等级0-普通1-中等2-严重(默认为0)
*/
private Integer level;
/**
* 与高级算法内部Id描述对应
*/
private Integer algoDescribe;
/**
* 字典值
*/
private String value;
/**
* 状态0-删除 1-正常
*/
private Integer state;
}

View File

@@ -0,0 +1,57 @@
package com.njcn.product.system.dict.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.product.system.dict.pojo.param.DictDataParam;
import com.njcn.product.system.dict.pojo.po.DictData;
import com.njcn.product.system.dict.pojo.vo.DictDataVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author hongawen
* @since 2021-12-13
*/
public interface IDictDataService extends IService<DictData> {
/**
*
* @param dicIndex 字典id
* @return 根据字典id查询字典数据
*/
DictData getDicDataById(String dicIndex);
/**
* 根据字典类型名称&数据名称获取字典数据
*
* @param dicTypeName 字典类型名称
* @param dicDataName 字典数据名称
* @return 字典数据
*/
DictData getDicDataByNameAndTypeName(@Param("dicTypeName") String dicTypeName, @Param("dicDataName") String dicDataName);
/**
*
* @param dicCode 字典Code,类型名称
* @return 根据字典Code查询字典数据
*/
DictData getDicDataByCodeAndType(String dicCode,String typeCode);
/**
*
* @param dictTypeCode 字典类型code
* @return 根据字典类型名称查询字典数据
*/
List<DictData> getDicDataByTypeCode(String dictTypeCode);
}

View File

@@ -0,0 +1,69 @@
package com.njcn.product.system.dict.service.impl;
import cn.hutool.core.bean.BeanUtil;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.db.mybatisplus.constant.DbConstant;
import com.njcn.product.system.dict.mapper.DictDataMapper;
import com.njcn.product.system.dict.pojo.enums.DicDataEnum;
import com.njcn.product.system.dict.pojo.enums.DicDataTypeEnum;
import com.njcn.product.system.dict.pojo.enums.SystemResponseEnum;
import com.njcn.product.system.dict.pojo.param.DictDataParam;
import com.njcn.product.system.dict.pojo.po.DictData;
import com.njcn.product.system.dict.pojo.po.DictType;
import com.njcn.product.system.dict.pojo.vo.DictDataVO;
import com.njcn.product.system.dict.service.IDictDataService;
import com.njcn.web.factory.PageFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author hongawen
* @since 2021-12-13
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> implements IDictDataService {
@Override
public DictData getDicDataById(String dicIndex) {
return this.baseMapper.selectById(dicIndex);
}
@Override
public DictData getDicDataByNameAndTypeName(String dicTypeName, String dicDataName) {
return this.baseMapper.getDicDataByNameAndTypeName(dicTypeName, dicDataName);
}
@Override
public DictData getDicDataByCodeAndType(String dicCode, String typeCode) {
return this.baseMapper.getDicDataByCodeAndType(dicCode, typeCode);
}
@Override
public List<DictData> getDicDataByTypeCode(String dictTypeCode) {
return this.baseMapper.getDicDataByTypeCode(dictTypeCode);
}
}

View File

@@ -0,0 +1,255 @@
package com.njcn.product.system.elequality.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.product.system.elequality.pojo.dto.EpdDTO;
import com.njcn.product.system.elequality.pojo.param.EleEpdPqdParam;
import com.njcn.product.system.elequality.pojo.po.EleEpdPqd;
import com.njcn.product.system.elequality.pojo.vo.EleEpdPqdListVO;
import com.njcn.product.system.elequality.pojo.vo.EleEpdPqdVO;
import com.njcn.product.system.elequality.pojo.vo.EleEpdTreeVO;
import com.njcn.product.system.elequality.service.IEleEpdPqdService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.asn1.x509.Targets;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import java.util.Map;
/**
* <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)
@ApiIgnore
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<EleEpdPqd> add(@RequestBody @Validated EleEpdPqdParam eleEpdPqdParam){
log.info("录入字典数据");
String methodDescribe = getMethodDescribe("add");
LogUtil.njcnDebug(log, "{},模板当前解析字典数据为:", methodDescribe);
EleEpdPqd eleEpdPqd = eleEpdPqdService.add(eleEpdPqdParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eleEpdPqd, 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);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@PostMapping("/dictMarkByDataType")
@ApiOperation("字典数据组装唯一标识")
@ApiImplicitParam(name = "dataType", value = "数据模型", required = true)
@ApiIgnore
public HttpResult<List<EleEpdPqd>> dictMarkByDataType(@RequestParam("dataType") @Validated String dataType) {
String methodDescribe = getMethodDescribe("dictMarkByDataType");
List<EleEpdPqd> list = eleEpdPqdService.dictMarkByDataType(dataType);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@PostMapping("/addEvt")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("事件录入字典数据")
@ApiImplicitParam(name = "eleEpdPqdParam", value = "模板的字典数据", required = true)
@ApiIgnore
public HttpResult<Map<String,String>> addEvt(@RequestBody @Validated List<EleEpdPqdParam> eleEpdPqdParam){
log.info("根据模板录入字典数据");
String methodDescribe = getMethodDescribe("addEvt");
LogUtil.njcnDebug(log, "{},模板当前解析字典数据为:", methodDescribe);
Map<String,String> map = eleEpdPqdService.saveEvt(eleEpdPqdParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, map, methodDescribe);
}
@PostMapping("/selectById")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("根据id查询字典数据")
@ApiImplicitParam(name = "id", value = "字典id", required = true)
public HttpResult<EleEpdPqd> selectById(@RequestParam("id") @Validated String id){
log.info("根据id查询字典数据");
String methodDescribe = getMethodDescribe("selectById");
LogUtil.njcnDebug(log, "{}根据id查询字典数据:", methodDescribe);
EleEpdPqd eleEpdPqd = eleEpdPqdService.selectById(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eleEpdPqd, methodDescribe);
}
@PostMapping("/selectAll")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("查询指标库按datatype分类")
public HttpResult<List<EleEpdPqdListVO>> selectAll(){
log.info("查询指标库按datatype分类");
String methodDescribe = getMethodDescribe("selectAll");
LogUtil.njcnDebug(log, "{}查询指标库按datatype分类:", methodDescribe);
List<EleEpdPqdListVO> eleEpdPqds = eleEpdPqdService.selectAll();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eleEpdPqds, methodDescribe);
}
@PostMapping("/selectByIds")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("根据集合查询字典数据")
@ApiImplicitParam(name = "ids", value = "id集合", required = true)
public HttpResult<List<EleEpdPqd>> selectByIds(@RequestBody @Validated List<String> ids){
String methodDescribe = getMethodDescribe("selectByIds");
LogUtil.njcnDebug(log, "{},根据集合查询字典数据:", methodDescribe);
List<EleEpdPqd> eleEpdPqds = eleEpdPqdService.selectByIds(ids);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eleEpdPqds, methodDescribe);
}
@PostMapping("/selectByClassId")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("根据数据分类查询字典数据")
public HttpResult<List<EleEpdPqd>> selectByClassId(@RequestParam("classId") @Validated String classId){
String methodDescribe = getMethodDescribe("selectByClassId");
LogUtil.njcnDebug(log, "{},根据数据分类查询字典数据:", methodDescribe);
List<EleEpdPqd> eleEpdPqds = eleEpdPqdService.selectByClassId(classId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eleEpdPqds, methodDescribe);
}
@PostMapping("/judgeExist")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("校验字典是否存在")
@ApiImplicitParams({
@ApiImplicitParam(name = "name", value = "指标名称", required = true),
@ApiImplicitParam(name = "dataType", value = "数据模型", required = true)
})
public HttpResult<List<EleEpdPqd>> judgeExist(@RequestParam("name") @Validated String name, @RequestParam("dataType") @Validated String dataType){
String methodDescribe = getMethodDescribe("judgeExist");
LogUtil.njcnDebug(log, "{},校验字典是否存在:", methodDescribe);
List<EleEpdPqd> list = eleEpdPqdService.judgeExist(name,dataType);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@PostMapping("/findByParam")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("根据条件查询字典数据")
@ApiImplicitParams({
@ApiImplicitParam(name = "name", value = "指标名称", required = true),
@ApiImplicitParam(name = "dataType", value = "数据模型", required = true),
@ApiImplicitParam(name = "phase", value = "相别", required = true)
})
public HttpResult<EleEpdPqd> findByParam(@RequestParam("name") @Validated String name, @RequestParam("dataType") @Validated String dataType, @RequestParam("phase") @Validated String phase){
String methodDescribe = getMethodDescribe("findByParam");
LogUtil.njcnDebug(log, "{},根据条件查询字典数据:", methodDescribe);
EleEpdPqd eleEpdPqd = eleEpdPqdService.findByParam(name,dataType,phase);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eleEpdPqd, methodDescribe);
}
@PostMapping("/findAll")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("查询所有字典数据")
@ApiIgnore
public HttpResult<List<EpdDTO>> findAll(){
String methodDescribe = getMethodDescribe("findAll");
List<EpdDTO> list = eleEpdPqdService.findAll();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@PostMapping("/findByName")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("根据名称查询字典信息")
@ApiImplicitParam(name = "name", value = "指标名称", required = true)
@ApiIgnore
public HttpResult<EleEpdPqd> findByName(@RequestParam("name") @Validated String name){
String methodDescribe = getMethodDescribe("findByName");
EleEpdPqd po = eleEpdPqdService.lambdaQuery().eq(EleEpdPqd::getName,name).one();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
@PostMapping("/findListByShowName")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("根据名称查询字典信息集合")
@ApiImplicitParam(name = "name", value = "指标名称", required = true)
@ApiIgnore
public HttpResult<List<EleEpdPqd>> findListByShowName(@RequestParam("name") @Validated String name){
String methodDescribe = getMethodDescribe("findListByShowName");
List<EleEpdPqd> po = eleEpdPqdService.lambdaQuery().eq(EleEpdPqd::getShowName,name).list();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
/**
* 获取电能质量指标模板树
* @author cdf
* @date 2022/8/16
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@GetMapping("/eleEpdChooseTree")
@ApiOperation("获取电能质量指标模板树")
public HttpResult<List<EleEpdTreeVO>> eleEpdChooseTree(){
String methodDescribe = getMethodDescribe("eleEpdChooseTree");
List<EleEpdTreeVO> res = eleEpdPqdService.eleEpdChooseTree();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
}
}

View File

@@ -0,0 +1,28 @@
package com.njcn.product.system.elequality.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.product.system.elequality.pojo.dto.EpdDTO;
import com.njcn.product.system.elequality.pojo.po.EleEpdPqd;
import com.njcn.product.system.elequality.pojo.vo.EleEpdPqdVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xuyang
* @since 2023-05-24
*/
public interface EleEpdPqdMapper extends BaseMapper<EleEpdPqd> {
Page<EleEpdPqdVO> page(@Param("page")Page<EleEpdPqdVO> page, @Param("ew") QueryWrapper<EleEpdPqdVO> queryWrapper);
List<EpdDTO> findAll();
}

View File

@@ -0,0 +1,63 @@
<?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.product.system.elequality.mapper.EleEpdPqdMapper">
<select id="page" resultType="EleEpdPqdVO">
select
sdd.Name dataTypeName,
ele_epd_pqd.Id,
ele_epd_pqd.Name,
ele_epd_pqd.Other_Name otherName,
ele_epd_pqd.Show_Name showName,
ele_epd_pqd.Sort,
ele_epd_pqd.Type ,
ele_epd_pqd.Phase ,
ele_epd_pqd.Unit ,
case when ele_epd_pqd.Harm_Start = 1 then 0.5 else ele_epd_pqd.Harm_Start end harmStart,
case when ele_epd_pqd.Harm_Start = 1 then 49.5 else ele_epd_pqd.Harm_End end harmEnd ,
ele_epd_pqd.Stat_Method statMethod,
ele_epd_pqd.Class_Id classId,
ele_epd_pqd.System_Type systemType,
ele_epd_pqd.data_type dataType,
ele_epd_pqd.tran_flag tranFlag,
ele_epd_pqd.tran_rule tranRule,
ele_epd_pqd.event_type eventType,
ele_epd_pqd.store_flag storeFlag,
ele_epd_pqd.cur_sts curSts,
ele_epd_pqd.ctl_sts ctlSts,
ele_epd_pqd.max_num maxNum,
ele_epd_pqd.min_num minNum,
ele_epd_pqd.set_value setValue,
ele_epd_pqd.strlen ,
ele_epd_pqd.default_value defaultValue,
ele_epd_pqd.resources_id resourcesId,
ele_epd_pqd.status,
ele_epd_pqd.limit_name limitName,
ele_epd_pqd.limit_table limitTable,
ele_epd_pqd.formula formula
from
ele_epd_pqd ele_epd_pqd
left join
sys_dict_data sdd
on
ele_epd_pqd.data_type = sdd.Id
<where>
1=1
and ${ew.sqlSegment}
</where>
</select>
<select id="findAll" resultType="EpdDTO">
select
t0.Name dictName,
t1.Name tableName,
t0.Harm_Start harmStart,
t0.Harm_End harmEnd
from
ele_epd_pqd t0
left join sys_dict_data t1 on
t0.Class_Id = t1.Id
where t0.status = 1
group by t0.Name,t1.Name,t0.Harm_Start,t0.Harm_End
</select>
</mapper>

View File

@@ -0,0 +1,28 @@
package com.njcn.product.system.elequality.pojo.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/8/14 20:28
*/
@Data
public class EpdDTO {
@ApiModelProperty("指标名称")
private String dictName;
@ApiModelProperty("inflxuDB表名")
private String tableName;
@ApiModelProperty("起始次数")
private Integer harmStart;
@ApiModelProperty("结束次数")
private Integer harmEnd;
}

View File

@@ -0,0 +1,131 @@
package com.njcn.product.system.elequality.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;
import java.util.List;
/**
* 类的介绍:
*
* @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 = "相别")
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 List<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 Integer ctlSts;
@ApiModelProperty(value = "设置最大值")
private Double maxNum;
@ApiModelProperty(value = "设置最小值")
private Double minNum;
@ApiModelProperty(value = "参数为enum可设置的所有值序列")
private String setValue;
@ApiModelProperty(value = "参数string可设置字符串的长度上限")
private Integer strlen;
@ApiModelProperty(value = "参数缺省值")
private String defaultValue;
@ApiModelProperty(value = "报表数据来源(mysql表名)")
private String resourcesId;
@ApiModelProperty(value = "限值名称")
private String limitName;
@ApiModelProperty(value = "限值表名")
private String limitTable;
@ApiModelProperty(value = "超标判断方式")
private String formula;
@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 {
@ApiModelProperty("dataType")
private List<String> dataType;
@ApiModelProperty("classId")
private List<String> classId;
}
}

View File

@@ -0,0 +1,175 @@
package com.njcn.product.system.elequality.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
* <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;
/**
* 数据名称
*/
private String name;
/**
* 别名
*/
private String otherName;
/**
* 展示
*/
private String showName;
/**
* 数据编号
*/
private Integer sort;
/**
* 数据类型
*/
private String type;
/**
* 相别
*/
private String phase;
/**
* 单位
*/
private String unit;
/**
* 数据开始谐波次数
*/
private Integer harmStart;
/**
* 数据结束谐波次数
*/
private Integer harmEnd;
/**
* 数据分类,唯一类别
*/
private String classId;
/**
* 数据统计方法“max”“min”“avg”“cp95”
*/
private String statMethod;
/**
* 系统类别(区分用能/电能)
*/
private String systemType;
/**
* 数据类型(epd、pqd...)
*/
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 Integer ctlSts;
/**
* 设置最大值
*/
private Double maxNum;
/**
* 设置最小值
*/
private Double minNum;
/**
* 参数为enum可设置的所有值序列
*/
private String setValue;
/**
* 参数string可设置字符串的长度上限
*/
private Integer strlen;
/**
* 参数缺省值
*/
private String defaultValue;
/**
* 状态(0:删除 1:正常)
*/
private Integer status;
/**
* 报表数据来源(mysql表名)
*/
private String resourcesId;
/**
* 限值名称
*/
private String limitName;
/**
* 限值表名
*/
private String limitTable;
/**
* 超标判断方式
*/
private String formula;
/**
* 二次值转一次值公式
*/
private String primaryFormula;
}

View File

@@ -0,0 +1,28 @@
package com.njcn.product.system.elequality.pojo.vo;
import com.njcn.product.system.elequality.pojo.po.EleEpdPqd;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/5/24 15:30
*/
@Data
public class EleEpdPqdListVO implements Serializable {
private String dataType;
private String dataTypeName;
private Integer sort;
private List<EleEpdPqd> eleEpdPqdVOS;
}

View File

@@ -0,0 +1,110 @@
package com.njcn.product.system.elequality.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
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 = "id")
private String id;
@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 Double harmStart;
@ApiModelProperty(value = "数据结束谐波次数")
private Double harmEnd;
@ApiModelProperty(value = "统计方式")
private String statMethod;
@ApiModelProperty(value = "系统类型")
private String systemType;
@ApiModelProperty(value = "数据分类(influxDB表名)")
private String classId;
@ApiModelProperty(value = "数据模型")
private String dataType;
@ApiModelProperty(value = "数据模型名称")
private String dataTypeName;
@ApiModelProperty(value = "报表数据来源(mysql表名)")
private String resourcesId;
@ApiModelProperty(value = "数据是否上送 0:不上送 1:上送")
private Integer tranFlag;
@ApiModelProperty(value = "上送规则 变化:change 周期:period")
private String tranRule;
@ApiModelProperty(value = "事件类别||参数类别||系统参数||定值数据类型")
private String eventType;
@ApiModelProperty(value = "是否存储 1:存储 0:不存储||是否加密 1:加密 0:不加密")
private Integer storeFlag;
@ApiModelProperty(value = "当前值||是否需遥控校验 1需要 0不需要")
private Integer curSts;
@ApiModelProperty(value = "是否可远程控制 1:是 0:否||是否可修改 1:是 0:否||是否支持自动控制 1:是 0:否")
private Integer 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 = "限值名称")
private String limitName;
@ApiModelProperty(value = "限值表名")
private String limitTable;
@ApiModelProperty(value = "超标判断方式")
private String formula;
}

View File

@@ -0,0 +1,27 @@
package com.njcn.product.system.elequality.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class EleEpdTreeVO {
@ApiModelProperty(name = "id",value = "模板索引")
private String id;
@ApiModelProperty(name = "name",value = "模板字段名")
private String name;
@ApiModelProperty(name = "showName",value = "模板中文展示名")
private String showName;
@ApiModelProperty(name = "flag",value = "用于标识最底层对象 1.表示已经没有子级")
private Integer flag;
@ApiModelProperty(name = "unit",value = "单位")
private String unit;
private List<EleEpdTreeVO> children;
}

View File

@@ -0,0 +1,114 @@
package com.njcn.product.system.elequality.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.product.system.elequality.pojo.dto.EpdDTO;
import com.njcn.product.system.elequality.pojo.param.EleEpdPqdParam;
import com.njcn.product.system.elequality.pojo.po.EleEpdPqd;
import com.njcn.product.system.elequality.pojo.vo.EleEpdPqdListVO;
import com.njcn.product.system.elequality.pojo.vo.EleEpdPqdVO;
import com.njcn.product.system.elequality.pojo.vo.EleEpdTreeVO;
import java.util.List;
import java.util.Map;
/**
* <p>
* 服务类
* </p>
*
* @author xuyang
* @since 2023-05-24
*/
public interface IEleEpdPqdService extends IService<EleEpdPqd> {
/**
* 刷新epd内容
*/
void refreshEpdPqdDataCache();
/**
* 存储模板的字典数据
* @param eleEpdPqdParam 参数
*/
void saveData(List<EleEpdPqdParam> eleEpdPqdParam);
/**
* 存储字典数据
* @param eleEpdPqdParam 参数
*/
EleEpdPqd add(EleEpdPqdParam eleEpdPqdParam);
/**
* 删除字典数据
* @param id id
*/
void delete(String id);
/**
* 更新字典数据
* @param updateParam 参数
*/
void update(EleEpdPqdParam.EleEpdPqdUpdateParam updateParam);
/**
* 查询字典分页
* @param queryParam 参数
*/
Page<EleEpdPqdVO> eleEpdPqdList(EleEpdPqdParam.EleEpdPqdQueryParam queryParam);
/**
* 查询所有字典数据组成唯一标识,用于验证字典是否重复
*/
List<EleEpdPqd> dictMarkByDataType(String dataType);
/**
* 存储事件的字典数据
* @param eleEpdPqdParam 参数
*/
Map<String,String> saveEvt(List<EleEpdPqdParam> eleEpdPqdParam);
/**
* 存储事件的字典数据
* @param id id
*/
EleEpdPqd selectById(String id);
/**
* @Description: 查询指标库按datatype分类
* @Author: clam
* @Date: 2023/6/12
*/
List<EleEpdPqdListVO> selectAll();
/**
* 根据集合查询字典数据
* @param ids id集合
*/
List<EleEpdPqd> selectByIds(List<String> ids);
/**
* 校验字典是否存在
* @param name 名称
* @param dataType 数据类型
*/
List<EleEpdPqd> judgeExist(String name, String dataType);
/**
* 根据条件查询字典数据
* @param name 名称
* @param dataType 数据类型
* @param phase 相别
*/
EleEpdPqd findByParam(String name, String dataType, String phase);
/**
* 查询指标和influxDB表关系
*/
List<EpdDTO> findAll();
List<EleEpdPqd> selectByClassId(String classId);
List<EleEpdTreeVO> eleEpdChooseTree();
}

View File

@@ -0,0 +1,379 @@
package com.njcn.product.system.elequality.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.db.mybatisplus.constant.DbConstant;
import com.njcn.product.system.dict.pojo.enums.DicDataEnum;
import com.njcn.product.system.dict.pojo.enums.DicDataTypeEnum;
import com.njcn.product.system.dict.pojo.enums.SystemResponseEnum;
import com.njcn.product.system.dict.pojo.po.DictData;
import com.njcn.product.system.dict.service.IDictDataService;
import com.njcn.product.system.elequality.mapper.EleEpdPqdMapper;
import com.njcn.product.system.elequality.pojo.dto.EpdDTO;
import com.njcn.product.system.elequality.pojo.param.EleEpdPqdParam;
import com.njcn.product.system.elequality.pojo.po.EleEpdPqd;
import com.njcn.product.system.elequality.pojo.vo.EleEpdPqdListVO;
import com.njcn.product.system.elequality.pojo.vo.EleEpdPqdVO;
import com.njcn.product.system.elequality.pojo.vo.EleEpdTreeVO;
import com.njcn.product.system.elequality.service.IEleEpdPqdService;
import com.njcn.web.factory.PageFactory;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* <p>
* 服务实现类
* </p>
*
* @author xuyang
* @since 2023-05-24
*/
@Service
@RequiredArgsConstructor
public class EleEpdPqdServiceImpl extends ServiceImpl<EleEpdPqdMapper, EleEpdPqd> implements IEleEpdPqdService {
private final IDictDataService idictDataService;
private final String CELL_DATA = "celldata";
private final String V = "v";
private final String STR_ONE = "#";
private final String STR_TWO = "$";
private final String STR_THREE = "&";
private final String STR_FOUR = "%";
@Override
public void refreshEpdPqdDataCache() {
Map<String,String> map = new HashMap<>(16);
List<EpdDTO> list = findAll();
list.forEach(item->{
map.put(item.getDictName(),item.getTableName());
});
}
@Override
public void saveData(List<EleEpdPqdParam> eleEpdPqdParam) {
List<EleEpdPqd> list = eleEpdPqdParam.stream().map(item->{
EleEpdPqd eleEpdPqd = new EleEpdPqd();
BeanUtils.copyProperties(item,eleEpdPqd);
if (StringUtils.isBlank(item.getType())){
eleEpdPqd.setType("");
}
eleEpdPqd.setStatus(1);
if (CollectionUtil.isNotEmpty(item.getStatMethod())){
eleEpdPqd.setStatMethod(String.join(",", item.getStatMethod()));
}
return eleEpdPqd;
}).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(list)){
boolean result = this.saveBatch(list,1000);
if (result) {
refreshEpdPqdDataCache();
}
}
}
@Override
public EleEpdPqd add(EleEpdPqdParam eleEpdPqdParam) {
checkEleEpdPqdParam(eleEpdPqdParam,false);
EleEpdPqd eleEpdPqd = new EleEpdPqd();
BeanUtils.copyProperties(eleEpdPqdParam,eleEpdPqd);
if (CollectionUtil.isNotEmpty(eleEpdPqdParam.getStatMethod())){
eleEpdPqd.setStatMethod(String.join(",", eleEpdPqdParam.getStatMethod()));
}
if (Objects.isNull(eleEpdPqdParam.getPhase())){
eleEpdPqd.setPhase("M");
}
eleEpdPqd.setStatus(1);
boolean result = this.save(eleEpdPqd);
if (result) {
refreshEpdPqdDataCache();
}
return eleEpdPqd;
}
@Override
public void delete(String id) {
EleEpdPqd eleEpdPqd = this.lambdaQuery().eq(EleEpdPqd::getId,id).one();
eleEpdPqd.setStatus(0);
boolean result = this.updateById(eleEpdPqd);
if (result) {
refreshEpdPqdDataCache();
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(EleEpdPqdParam.EleEpdPqdUpdateParam updateParam) {
checkEleEpdPqdParam(updateParam,true);
EleEpdPqd eleEpdPqd = new EleEpdPqd();
BeanUtils.copyProperties(updateParam,eleEpdPqd);
if (CollectionUtil.isNotEmpty(updateParam.getStatMethod())){
eleEpdPqd.setStatMethod(String.join(",", updateParam.getStatMethod()));
}
if (Objects.isNull(updateParam.getPhase())){
eleEpdPqd.setPhase("M");
}
boolean result = this.updateById(eleEpdPqd);
if (result) {
refreshEpdPqdDataCache();
}
}
@Override
public Page<EleEpdPqdVO> eleEpdPqdList(EleEpdPqdParam.EleEpdPqdQueryParam queryParam) {
QueryWrapper<EleEpdPqdVO> queryWrapper = new QueryWrapper<>();
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, "data_type","Sort");
}
}
if (CollectionUtil.isNotEmpty(queryParam.getDataType())){
queryWrapper.in("ele_epd_pqd.data_type", queryParam.getDataType());
}
if (CollectionUtil.isNotEmpty(queryParam.getClassId())){
queryWrapper.in("ele_epd_pqd.Class_Id", queryParam.getClassId());
}
queryWrapper.eq("ele_epd_pqd.status", 1);
return this.baseMapper.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
}
@Override
public List<EleEpdPqd> dictMarkByDataType(String dataType) {
LambdaQueryWrapper<EleEpdPqd> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(EleEpdPqd::getDataType,dataType);
return this.baseMapper.selectList(lambdaQueryWrapper);
}
@Override
public Map<String, String> saveEvt(List<EleEpdPqdParam> eleEpdPqdParam) {
List<EleEpdPqd> list = eleEpdPqdParam.stream().map(item->{
EleEpdPqd eleEpdPqd = new EleEpdPqd();
BeanUtils.copyProperties(item,eleEpdPqd);
if (StringUtils.isBlank(item.getType())){
eleEpdPqd.setType("");
}
return eleEpdPqd;
}).collect(Collectors.toList());
this.saveBatch(list,1000);
List<String> nameList = eleEpdPqdParam.stream().map(EleEpdPqdParam::getName).collect(Collectors.toList());
List<EleEpdPqd> list1 = this.lambdaQuery().in(EleEpdPqd::getName,nameList).list();
Map<String,String> map = new HashMap<>(16);
list1.forEach(item->{
map.put(item.getName(),item.getId());
});
return map;
}
@Override
public EleEpdPqd selectById(String id) {
return this.lambdaQuery().eq(EleEpdPqd::getId,id).one();
}
@Override
public List<EleEpdPqdListVO> selectAll() {
List<EleEpdPqdListVO> vos = new ArrayList<>();
this.getBaseMapper().selectList(null);
List<EleEpdPqd> eleEpdPqds = this.baseMapper.selectList(null);
Map<String, List<EleEpdPqd>> collect = eleEpdPqds.stream().collect(Collectors.groupingBy(EleEpdPqd::getDataType));
collect.forEach((k,v)->{
EleEpdPqdListVO vo = new EleEpdPqdListVO();
vo.setDataType(k);
vo.setEleEpdPqdVOS(v);
DictData dicDataById = idictDataService.getDicDataById(vo.getDataType());
vo.setDataTypeName(dicDataById.getName());
vos.add(vo);
});
return vos;
}
@Override
public List<EleEpdPqd> selectByIds(List<String> ids) {
return this.lambdaQuery().in(EleEpdPqd::getId,ids).orderByAsc(EleEpdPqd::getSort).list();
}
@Override
public List<EleEpdPqd> judgeExist(String name, String dataType) {
LambdaQueryWrapper<EleEpdPqd> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(EleEpdPqd::getDataType,dataType).eq(EleEpdPqd::getName,name).eq(EleEpdPqd::getStatus,1);
return this.baseMapper.selectList(lambdaQueryWrapper);
}
@Override
public EleEpdPqd findByParam(String name, String dataType, String phase) {
LambdaQueryWrapper<EleEpdPqd> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(EleEpdPqd::getDataType,dataType).eq(EleEpdPqd::getName,name).eq(EleEpdPqd::getPhase,phase).eq(EleEpdPqd::getStatus,1);
return this.baseMapper.selectOne(lambdaQueryWrapper);
}
@Override
public List<EpdDTO> findAll() {
List<EpdDTO> removeList = new ArrayList<>(),addList = new ArrayList<>();
List<EpdDTO> list = this.baseMapper.findAll();
if (CollectionUtil.isNotEmpty(list)){
list.forEach(item->{
if (!Objects.isNull(item.getHarmStart()) && !Objects.isNull(item.getHarmEnd())){
removeList.add(item);
for (int i = item.getHarmStart(); i <= item.getHarmEnd(); i++) {
EpdDTO epdDTO = new EpdDTO();
epdDTO.setDictName(item.getDictName() + "_" + i);
epdDTO.setTableName(item.getTableName());
addList.add(epdDTO);
}
}
});
if (CollectionUtil.isNotEmpty(removeList)){
list.removeAll(removeList);
}
if (CollectionUtil.isNotEmpty(addList)){
list.addAll(addList);
}
}
return list;
}
@Override
public List<EleEpdPqd> selectByClassId(String classId) {
return this.lambdaQuery().eq(EleEpdPqd::getClassId,classId).list();
}
@Override
public List<EleEpdTreeVO> eleEpdChooseTree() {
DictData dic = idictDataService.getDicDataByNameAndTypeName(DicDataTypeEnum.CS_DATA_TYPE.getName(), DicDataEnum.EPD.getName());
LambdaQueryWrapper<EleEpdPqd> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(EleEpdPqd::getDataType, dic.getId()).orderByAsc(EleEpdPqd::getSort);
List<EleEpdPqd> list = this.getBaseMapper().selectList(lambdaQueryWrapper);
Map<String, List<EleEpdPqd>> map = list.stream().collect(Collectors.groupingBy(EleEpdPqd::getName, LinkedHashMap::new, Collectors.toList()));
List<EleEpdTreeVO> tree = new ArrayList<>();
map.forEach((key, value) -> {
EleEpdTreeVO reportTreeVO = new EleEpdTreeVO();
reportTreeVO.setName(value.get(0).getOtherName());
reportTreeVO.setShowName(value.get(0).getShowName());
//存在1-50次 2-50次情况
if (Objects.nonNull(value.get(0).getHarmStart()) && Objects.nonNull(value.get(0).getHarmEnd())) {
List<EleEpdTreeVO> reHarm = new ArrayList<>();
for (int i = value.get(0).getHarmStart(); i <= value.get(0).getHarmEnd(); i++) {
EleEpdTreeVO reportTreeCount = new EleEpdTreeVO();
reportTreeCount.setName(value.get(0).getOtherName() + "_" + i);
reportTreeCount.setShowName(i + "" + value.get(0).getShowName());
reportTreeVO.setFlag(1);
assPhase(value, reportTreeCount, reportTreeCount.getName());
reHarm.add(reportTreeCount);
}
reportTreeVO.setChildren(reHarm);
} else {
assPhase(value, reportTreeVO, value.get(0).getOtherName());
}
tree.add(reportTreeVO);
});
return tree;
}
/*组装相别*/
private void assPhase(List<EleEpdPqd> value, EleEpdTreeVO reportTreeItem, String key) {
List<EleEpdTreeVO> phaseTree = new ArrayList<>();
value.forEach(item -> {
if (Objects.nonNull(item.getPhase()) && !"M".equals(item.getPhase())) {
List<EleEpdTreeVO> statTree = new ArrayList<>();
EleEpdTreeVO reportTreePhase = new EleEpdTreeVO();
reportTreePhase.setName(item.getPhase());
reportTreePhase.setShowName(item.getPhase());
// reportTreePhase.setUnit(item.getUnit());
assStatMethod(item, statTree, key, item.getPhase());
reportTreePhase.setChildren(statTree);
phaseTree.add(reportTreePhase);
reportTreeItem.setChildren(phaseTree);
} else {
List<EleEpdTreeVO> statTree = new ArrayList<>();
assStatMethod(item, statTree, key, "T");
reportTreeItem.setChildren(statTree);
}
});
}
private void assStatMethod(EleEpdPqd item, List<EleEpdTreeVO> statTree, String oneKey, String twoKey) {
//存在向别为M但是Stat_Method不为空
if (StrUtil.isNotBlank(item.getStatMethod())) {
String[] arr = item.getStatMethod().split(",");
List<String> stat = Stream.of(arr).collect(Collectors.toList());
if (CollUtil.isNotEmpty(stat)) {
stat.forEach(statItem -> {
EleEpdTreeVO reportTreeStat = new EleEpdTreeVO();
reportTreeStat.setUnit(item.getUnit());
String tem = "";
if (Objects.nonNull(item.getLimitName())) {
tem = STR_ONE + item.getLimitName();
} else {
tem = "#NO";
}
if (StrUtil.isNotBlank(twoKey)) {
reportTreeStat.setName(STR_TWO + oneKey + STR_ONE + twoKey + STR_ONE + statItem + STR_ONE + item.getClassId().trim() + tem.trim() + STR_TWO);
} else {
reportTreeStat.setName(STR_TWO + oneKey + STR_ONE + statItem + STR_ONE + item.getClassId().trim() + tem.trim() + STR_TWO);
}
reportTreeStat.setShowName(statItem);
statTree.add(reportTreeStat);
});
}
}
}
/**
* 校验参数,
* 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())
.eq(EleEpdPqd::getStatus,1);
//更新的时候,需排除当前记录
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(SystemResponseEnum.DICT_DATA_NAME_REPEAT);
}
}
}

View File

@@ -0,0 +1,83 @@
package com.njcn.product.system.fileOperate;
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.oss.utils.FileStorageUtil;
import com.njcn.product.system.fileOperate.pojo.vo.FileVO;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
/**
* @author hongawen
* @version 1.0.0
* @date 2022年10月16日 19:34
*/
@Slf4j
@Api(tags = "文件控制管理器")
@RestController
@RequestMapping("/system-boot/file")
@RequiredArgsConstructor
public class FileController extends BaseController {
private final FileStorageUtil fileStorageUtil;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("文件上传")
@RequestMapping(value = "/upload", method = RequestMethod.POST)
public HttpResult<FileVO> upload(@RequestParam(value = "file") MultipartFile file, @RequestParam("path") String path, @RequestParam(defaultValue = "true") Boolean isReserveName) {
String methodDescribe = getMethodDescribe("upload");
String ossPath = fileStorageUtil.uploadMultipart(file, path,isReserveName);
String url = fileStorageUtil.getFileUrl(ossPath);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, new FileVO(ossPath,url), methodDescribe);
}
@ApiOperation("删除文件服务器文件")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public HttpResult<String> delete(String filePath) {
String methodDescribe = getMethodDescribe("delete");
fileStorageUtil.deleteFile(filePath);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, CommonResponseEnum.SUCCESS.getMessage(), methodDescribe);
}
@ApiOperation("下载文件")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@RequestMapping(value = "/download", method = RequestMethod.GET)
public void download(String filePath, HttpServletResponse response) {
fileStorageUtil.downloadStream(response, filePath);
}
@ApiOperation("获取文件的一个短期url")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@RequestMapping(value = "/getFileUrl", method = RequestMethod.GET)
public HttpResult<String> getFileUrl(String filePath) {
String methodDescribe = getMethodDescribe("getFileUrl");
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, fileStorageUtil.getFileUrl(filePath), methodDescribe);
}
@ApiOperation("获取文件的一个短期url及文件名")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@RequestMapping(value = "/getFileVO", method = RequestMethod.GET)
public HttpResult<FileVO> getFileVO(String filePath) {
String methodDescribe = getMethodDescribe("getFileVO");
String url = fileStorageUtil.getFileUrl(filePath);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, new FileVO(filePath,url), methodDescribe);
}
}

View File

@@ -0,0 +1,35 @@
package com.njcn.product.system.fileOperate.pojo.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FileVO implements Serializable {
//全名 路径+文件名
private String name;
//文件名
private String fileName;
private String url;
public FileVO(String name, String url){
this.name = name;
this.fileName = getFileName(name);
this.url = url;
}
public static String getFileName(String filePath) {
int index = filePath.lastIndexOf("/");
if (index == -1) {
return filePath; // 如果没有/,则返回整个路径
} else {
return filePath.substring(index + 1); // 截取最后一个/后面的部分作为文件名
}
}
}

View File

@@ -0,0 +1,37 @@
package com.njcn.product.system.handler;
import com.njcn.common.pojo.constant.LogInfo;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.MethodArgumentNotValidException;
import java.lang.reflect.Method;
import java.util.Objects;
/**
* @author hongawen
* @version 1.0.0
* @date 2021年06月22日 10:25
*/
@Slf4j
public class ControllerUtil {
/**
* 针对methodArgumentNotValidException 异常的处理
* @author cdf
*/
public static String getMethodArgumentNotValidException(MethodArgumentNotValidException methodArgumentNotValidException) {
String operate = LogInfo.UNKNOWN_OPERATE;
Method method = null;
try {
method = methodArgumentNotValidException.getParameter().getMethod();
if (!Objects.isNull(method) && method.isAnnotationPresent(ApiOperation.class)) {
ApiOperation apiOperation = method.getAnnotation(ApiOperation.class);
operate = apiOperation.value();
}
}catch (Exception e){
log.error("根据方法参数非法异常获取@ApiOperation注解值失败参数非法异常信息{},方法名:{},异常信息:{}",methodArgumentNotValidException.getMessage(),method,e.getMessage());
}
return operate;
}
}

View File

@@ -0,0 +1,257 @@
package com.njcn.product.system.handler;
import cn.hutool.core.text.StrFormatter;
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.LogUtil;
import com.njcn.web.utils.HttpResultUtil;
import com.njcn.web.utils.HttpServletUtil;
import com.njcn.web.utils.ReflectCommonUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONException;
import org.springframework.validation.ObjectError;
import org.springframework.web.HttpMediaTypeNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.util.NestedServletException;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 全局通用业务异常处理器
*
* @author hongawen
* @version 1.0.0
* @date 2021年04月20日 18:04
*/
@Slf4j
@AllArgsConstructor
@RestControllerAdvice
public class GlobalBusinessExceptionHandler {
//@Resource
// private final ISysLogAuditService sysLogAuditService;
/* private final ThreadPoolExecutor executor = new ThreadPoolExecutor(
4, 8, 30, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(100),
// 队列满时由主线程执行
new ThreadPoolExecutor.CallerRunsPolicy()
);*/
/**
* 捕获业务功能异常,通常为业务数据抛出的异常
*
* @param businessException 业务异常
*/
@ExceptionHandler(BusinessException.class)
public HttpResult<String> handleBusinessException(BusinessException businessException) {
String operate = ReflectCommonUtil.getMethodDescribeByException(businessException);
recodeBusinessExceptionLog(businessException, businessException.getMessage());
return HttpResultUtil.assembleBusinessExceptionResult(businessException, null, operate);
}
/**
* 空指针异常捕捉
*
* @param nullPointerException 空指针异常
*/
@ExceptionHandler(NullPointerException.class)
public HttpResult<String> handleNullPointerException(NullPointerException nullPointerException) {
LogUtil.logExceptionStackInfo(CommonResponseEnum.NULL_POINTER_EXCEPTION.getMessage(), nullPointerException);
recodeBusinessExceptionLog(nullPointerException, CommonResponseEnum.NULL_POINTER_EXCEPTION.getMessage());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NULL_POINTER_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(nullPointerException));
}
/**
* 算数运算异常
*
* @param arithmeticException 算数运算异常由于除数为0引起的异常
*/
@ExceptionHandler(ArithmeticException.class)
public HttpResult<String> handleArithmeticException(ArithmeticException arithmeticException) {
LogUtil.logExceptionStackInfo(CommonResponseEnum.ARITHMETIC_EXCEPTION.getMessage(), arithmeticException);
recodeBusinessExceptionLog(arithmeticException, CommonResponseEnum.ARITHMETIC_EXCEPTION.getMessage());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.ARITHMETIC_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(arithmeticException));
}
/**
* 类型转换异常捕捉
*
* @param classCastException 类型转换异常
*/
@ExceptionHandler(ClassCastException.class)
public HttpResult<String> handleClassCastException(ClassCastException classCastException) {
LogUtil.logExceptionStackInfo(CommonResponseEnum.CLASS_CAST_EXCEPTION.getMessage(), classCastException);
recodeBusinessExceptionLog(classCastException, CommonResponseEnum.CLASS_CAST_EXCEPTION.getMessage());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.CLASS_CAST_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(classCastException));
}
/**
* 索引下标越界异常捕捉
*
* @param indexOutOfBoundsException 索引下标越界异常
*/
@ExceptionHandler(IndexOutOfBoundsException.class)
public HttpResult<String> handleIndexOutOfBoundsException(IndexOutOfBoundsException indexOutOfBoundsException) {
LogUtil.logExceptionStackInfo(CommonResponseEnum.INDEX_OUT_OF_BOUNDS_EXCEPTION.getMessage(), indexOutOfBoundsException);
recodeBusinessExceptionLog(indexOutOfBoundsException, CommonResponseEnum.INDEX_OUT_OF_BOUNDS_EXCEPTION.getMessage());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.INDEX_OUT_OF_BOUNDS_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(indexOutOfBoundsException));
}
/**
* 前端请求后端,请求中参数的媒体方式不支持异常
*
* @param httpMediaTypeNotSupportedException 请求中参数的媒体方式不支持异常
*/
@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
public HttpResult<String> httpMediaTypeNotSupportedExceptionHandler(HttpMediaTypeNotSupportedException httpMediaTypeNotSupportedException) {
LogUtil.logExceptionStackInfo(CommonResponseEnum.HTTP_MEDIA_TYPE_NOT_SUPPORTED_EXCEPTION.getMessage(), httpMediaTypeNotSupportedException);
// 然后提取错误提示信息进行返回
recodeBusinessExceptionLog(httpMediaTypeNotSupportedException, CommonResponseEnum.HTTP_MEDIA_TYPE_NOT_SUPPORTED_EXCEPTION.getMessage());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.HTTP_MEDIA_TYPE_NOT_SUPPORTED_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(httpMediaTypeNotSupportedException));
}
/**
* 前端请求后端,参数校验异常捕捉
* RequestBody注解参数异常
*
* @param methodArgumentNotValidException 参数校验异常
*/
@ExceptionHandler(MethodArgumentNotValidException.class)
public HttpResult<String> methodArgumentNotValidExceptionHandler(MethodArgumentNotValidException methodArgumentNotValidException) {
// 从异常对象中拿到allErrors数据
String messages = methodArgumentNotValidException.getBindingResult().getAllErrors()
.stream().map(ObjectError::getDefaultMessage).collect(Collectors.joining(""));
// 然后提取错误提示信息进行返回
LogUtil.njcnDebug(log, "参数校验异常,异常为:{}", messages);
recodeBusinessExceptionLog(methodArgumentNotValidException, CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION.getMessage());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION, messages, ControllerUtil.getMethodArgumentNotValidException(methodArgumentNotValidException));
}
/**
* 前端请求后端,参数校验异常捕捉
* PathVariable注解、RequestParam注解参数异常
*
* @param constraintViolationException 参数校验异常
*/
@ExceptionHandler(ConstraintViolationException.class)
public HttpResult<String> constraintViolationExceptionExceptionHandler(ConstraintViolationException constraintViolationException) {
String exceptionMessage = constraintViolationException.getMessage();
StringBuilder messages = new StringBuilder();
if (exceptionMessage.indexOf(StrUtil.COMMA) > 0) {
String[] tempMessage = exceptionMessage.split(StrUtil.COMMA);
Stream.of(tempMessage).forEach(message -> {
messages.append(message.substring(message.indexOf(StrUtil.COLON) + 2)).append(';');
});
} else {
messages.append(exceptionMessage.substring(exceptionMessage.indexOf(StrUtil.COLON) + 2));
}
// 然后提取错误提示信息进行返回
LogUtil.njcnDebug(log, "参数校验异常,异常为:{}", messages);
recodeBusinessExceptionLog(constraintViolationException, CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION.getMessage());
List<ConstraintViolation<?>> constraintViolationList = new ArrayList<>(constraintViolationException.getConstraintViolations());
ConstraintViolation<?> constraintViolation = constraintViolationList.get(0);
Class<?> rootBeanClass = constraintViolation.getRootBeanClass();
//判断校验参数异常捕获的根源是controller还是service处
if (rootBeanClass.getName().endsWith("Controller")) {
String methodName = constraintViolation.getPropertyPath().toString().substring(0, constraintViolation.getPropertyPath().toString().indexOf(StrUtil.DOT));
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION, messages.toString(), ReflectCommonUtil.getMethodDescribeByClassAndMethodName(rootBeanClass, methodName));
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION, messages.toString(), ReflectCommonUtil.getMethodDescribeByException(constraintViolationException));
}
}
/**
* 索引下标越界异常捕捉
*
* @param illegalArgumentException 参数校验异常
*/
@ExceptionHandler(IllegalArgumentException.class)
public HttpResult<String> handleIndexOutOfBoundsException(IllegalArgumentException illegalArgumentException) {
LogUtil.logExceptionStackInfo(CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION.getMessage(), illegalArgumentException);
recodeBusinessExceptionLog(illegalArgumentException, CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION.getMessage());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION, illegalArgumentException.getMessage(), ReflectCommonUtil.getMethodDescribeByException(illegalArgumentException));
}
/**
* 未声明异常捕捉
*
* @param exception 未声明异常
*/
@ExceptionHandler(Exception.class)
public HttpResult<String> handleException(Exception exception) {
exception.printStackTrace();
//针对fallbackFactory降级异常特殊处理
Exception tempException = exception;
String exceptionCause = CommonResponseEnum.UN_DECLARE.getMessage();
String code = CommonResponseEnum.UN_DECLARE.getCode();
if (exception instanceof NestedServletException) {
Throwable cause = exception.getCause();
if (cause instanceof AssertionError) {
if (cause.getCause() instanceof BusinessException) {
tempException = (BusinessException) cause.getCause();
BusinessException tempBusinessException = (BusinessException) cause.getCause();
exceptionCause = tempBusinessException.getMessage();
code = tempBusinessException.getCode();
}
}
}
LogUtil.logExceptionStackInfo(exceptionCause, tempException);
recodeBusinessExceptionLog(exception, exceptionCause);
//判断方法上是否有自定义注解,做特殊处理
// Method method = ReflectCommonUtil.getMethod(exception);
// if (!Objects.isNull(method)){
// if(method.isAnnotationPresent(ReturnMsg.class)){
// return HttpResultUtil.assembleResult(code, null, StrFormatter.format("{}",exceptionCause));
// }
// }
return HttpResultUtil.assembleResult(code, null, StrFormatter.format("{}{}{}", ReflectCommonUtil.getMethodDescribeByException(tempException), StrUtil.C_COMMA, exceptionCause));
}
/**
* json解析异常
*
* @param jsonException json参数
*/
@ExceptionHandler(JSONException.class)
public HttpResult<String> handleIndexOutOfBoundsException(JSONException jsonException) {
LogUtil.logExceptionStackInfo(CommonResponseEnum.JSON_CONVERT_EXCEPTION.getMessage(), jsonException);
recodeBusinessExceptionLog(jsonException, CommonResponseEnum.JSON_CONVERT_EXCEPTION.getMessage());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.JSON_CONVERT_EXCEPTION, jsonException.getMessage(), ReflectCommonUtil.getMethodDescribeByException(jsonException));
}
private void recodeBusinessExceptionLog(Exception businessException, String methodDescribe) {
/*HttpServletRequest httpServletRequest = HttpServletUtil.getRequest();
Future<?> future = executor.submit(() -> {
HttpServletUtil.setRequest(httpServletRequest);
sysLogAuditService.recodeBusinessExceptionLog(businessException, methodDescribe);
});
try {
// 抛出 ExecutionException
future.get();
} catch (ExecutionException | InterruptedException e) {
log.error("保存审计日志异常,异常为:" + e.getMessage());
}*/
}
}

View File

@@ -0,0 +1,22 @@
package com.njcn.product.system.other.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.product.system.other.pojo.po.Area;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author hongawen
* @since 2021-12-13
*/
public interface AreaMapper extends BaseMapper<Area> {
}

View File

@@ -0,0 +1,73 @@
package com.njcn.product.system.other.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.mybatisplus.bo.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.math.BigDecimal;
/**
*
* @author hongawen
* @since 2021-12-13
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_area")
public class Area extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 区域Id
*/
private String id;
/**
* 父节点0为根节点
*/
private String pid;
/**
* 上层所有节点
*/
private String pids;
/**
* 区域名称
*/
private String name;
/**
* 简称
*/
private String shortName;
/**
* 排序(编号)
*/
private String areaCode;
/**
* 区域类型 0-省级区域1-企业区域;
*/
private Integer type;
/**
* 中心点经度
*/
private BigDecimal lng;
/**
* 中心点纬度
*/
private BigDecimal lat;
/**
* 区域状态 0-删除1-正常;默认正常
*/
private Integer state;
}

92
pom.xml Normal file
View File

@@ -0,0 +1,92 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.njcn.product</groupId>
<artifactId>CN_Product</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>灿能产品项目集</name>
<modules>
<!-- <module>carry_capacity</module>-->
<module>cn-system</module>
<module>cn-user</module>
<module>cn-zutai</module>
<module>cn-terminal</module>
<module>cn-auth</module>
<module>cn-advance</module>
<module>cn-diagram</module>
<module>cn-begin</module>
<module>event_smart</module>
</modules>
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>Nexus Release Repository</name>
<url>http://192.168.1.22:8001/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://192.168.1.22:8001/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.3.12.RELEASE</spring-boot.version>
<websocket.version>2.7.12</websocket.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.2.2.RELEASE</version>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
</project>