diff --git a/README.MD b/README.MD index 572491f..d3482bd 100644 --- a/README.MD +++ b/README.MD @@ -1,4 +1,4 @@ -# 漳河大坝安全api +# 清洗规则api ## 目录 ``` diff --git a/pom.xml b/pom.xml index 3948f1e..fca02ec 100644 --- a/pom.xml +++ b/pom.xml @@ -11,9 +11,9 @@ com.whdc - zhdbaqapi + rule-service 1.0 - 漳河大坝安全api + 清洗规则api 8 @@ -53,6 +53,20 @@ mybatis-plus-boot-starter 3.5.2 + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + + com.github.jeffreyning + mybatisplus-plus + 1.7.2-RELEASE + + org.springframework.boot spring-boot-starter-validation @@ -72,17 +86,6 @@ - - - cn.dev33 - sa-token-spring-boot-starter - 1.30.0 - - - cn.dev33 - sa-token-dao-redis-jackson - 1.30.0 - org.apache.commons @@ -119,7 +122,7 @@ com.alibaba fastjson - 1.2.80 + 1.2.83 @@ -134,7 +137,7 @@ com.dameng @@ -174,68 +177,19 @@ + - - org.apache.maven.plugins - maven-jar-plugin - - - false - - - true - - lib/ - - com.whdc.zhdbaqapi.ZhDbaqApiApplication - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin + org.springframework.boot + spring-boot-maven-plugin + 2.7.5 - copy-lib - package - copy-dependencies - - - ${copy.jar.directory}/lib - false - false - runtime - - - - - - - - maven-antrun-plugin - - - copy - package - - - - - - - - - - - run + repackage diff --git a/sql/dm_start.sql b/sql/dm_start.sql new file mode 100644 index 0000000..7a7dfa9 --- /dev/null +++ b/sql/dm_start.sql @@ -0,0 +1,46 @@ +CREATE TABLE "SHZH_IOT"."E_RULE" +( + "ID" INT IDENTITY(1, 1) NOT NULL, + "NAME" VARCHAR(50), + "ITEM" VARCHAR(50), + "MIN" VARCHAR(50), + "MAX" VARCHAR(50), + "DIFF_MAX" VARCHAR(50), + "DURATION" INTEGER, + "CREATETIME" DATETIME(0), + "DEL" VARCHAR(2) DEFAULT 1, + "LEADING_TIME" INTEGER, + "LAG_TIME" INTEGER); + +COMMENT ON TABLE "SHZH_IOT"."E_RULE" IS '规则表'; +COMMENT ON COLUMN "SHZH_IOT"."E_RULE"."ID" IS '主键id'; +COMMENT ON COLUMN "SHZH_IOT"."E_RULE"."NAME" IS '规则名称'; +COMMENT ON COLUMN "SHZH_IOT"."E_RULE"."ITEM" IS '测站类型'; +COMMENT ON COLUMN "SHZH_IOT"."E_RULE"."MIN" IS '最小值'; +COMMENT ON COLUMN "SHZH_IOT"."E_RULE"."MAX" IS '最小值'; +COMMENT ON COLUMN "SHZH_IOT"."E_RULE"."DIFF_MAX" IS '两条数据之间的最大差值'; +COMMENT ON COLUMN "SHZH_IOT"."E_RULE"."DURATION" IS '时间段, 单位 s'; +COMMENT ON COLUMN "SHZH_IOT"."E_RULE"."CREATETIME" IS '创建时间'; +COMMENT ON COLUMN "SHZH_IOT"."E_RULE"."DEL" IS '1: 未删除 0: 删除'; +COMMENT ON COLUMN "SHZH_IOT"."E_RULE"."LEADING_TIME" IS '接收超出时间,单位: s ,指接收时间超前范围'; +COMMENT ON COLUMN "SHZH_IOT"."E_RULE"."LAG_TIME" IS '接收滞后时间,单位: s ,指接收时间滞后范围'; + + +CREATE TABLE "SHZH_IOT"."E_STATION_RULES" +( + "ID" INT IDENTITY(1, 1) NOT NULL, + "STCD" VARCHAR(50), + "RULE_ID" INTEGER, + "SORT" INTEGER, + "CREATETIME" DATETIME(0), + "DEL" INT DEFAULT 0) ; + +COMMENT ON TABLE "SHZH_IOT"."E_STATION_RULES" IS '测站关联规则表'; +COMMENT ON COLUMN "SHZH_IOT"."E_STATION_RULES"."ID" IS '主键id'; +COMMENT ON COLUMN "SHZH_IOT"."E_STATION_RULES"."STCD" IS '测站编码'; +COMMENT ON COLUMN "SHZH_IOT"."E_STATION_RULES"."RULE_ID" IS '规则id'; +COMMENT ON COLUMN "SHZH_IOT"."E_STATION_RULES"."SORT" IS '顺序'; +COMMENT ON COLUMN "SHZH_IOT"."E_STATION_RULES"."CREATETIME" IS '创建时间'; +COMMENT ON COLUMN "SHZH_IOT"."E_STATION_RULES"."DEL" IS '1: 未删除 0: 删除'; + + diff --git a/src/main/java/com/whdc/zhdbaqapi/ZhDbaqApiApplication.java b/src/main/java/com/whdc/RuleApiApplication.java similarity index 73% rename from src/main/java/com/whdc/zhdbaqapi/ZhDbaqApiApplication.java rename to src/main/java/com/whdc/RuleApiApplication.java index 6826032..c8d3173 100644 --- a/src/main/java/com/whdc/zhdbaqapi/ZhDbaqApiApplication.java +++ b/src/main/java/com/whdc/RuleApiApplication.java @@ -1,39 +1,36 @@ -package com.whdc.zhdbaqapi; - -import cn.dev33.satoken.SaManager; -import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; -import lombok.extern.slf4j.Slf4j; -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.beans.BeansException; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cache.annotation.EnableCaching; -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; - -/** - * @author 李赛 - * @date 2022-06-26 0:17 - */ -@Slf4j -@EnableWebMvc -@EnableKnife4j -@EnableCaching -@EnableScheduling -@SpringBootApplication -@MapperScan("com.whdc.zhdbaqapi.mapper") -public class ZhDbaqApiApplication { - - public static void main(String[] args) { - try { - SpringApplication.run(ZhDbaqApiApplication.class, args); - - System.out.println("启动成功:Sa-Token 配置如下:" + SaManager.getConfig()); - - System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>> 启动完成 <<<<<<<<<<<<<<<<<<<<<<<<<<<"); - } catch (BeansException e) { - e.printStackTrace(); - log.error(e.getMessage(), e); - } - } -} +package com.whdc; + +import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; +import lombok.extern.slf4j.Slf4j; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.beans.BeansException; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; + +/** + * @author 李赛 + * @date 2022-06-26 0:17 + */ +@Slf4j +@EnableWebMvc +@EnableKnife4j +@EnableCaching +@EnableScheduling +@SpringBootApplication +@MapperScan("com.whdc.mapper") +public class RuleApiApplication { + + public static void main(String[] args) { + try { + SpringApplication.run(RuleApiApplication.class, args); + + System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>> 启动完成 <<<<<<<<<<<<<<<<<<<<<<<<<<<"); + } catch (BeansException e) { + e.printStackTrace(); + log.error(e.getMessage(), e); + } + } +} diff --git a/src/main/java/com/whdc/zhdbaqapi/annotation/DateTimeRange.java b/src/main/java/com/whdc/annotation/DateTimeRange.java similarity index 91% rename from src/main/java/com/whdc/zhdbaqapi/annotation/DateTimeRange.java rename to src/main/java/com/whdc/annotation/DateTimeRange.java index 4f936d6..6d9e108 100644 --- a/src/main/java/com/whdc/zhdbaqapi/annotation/DateTimeRange.java +++ b/src/main/java/com/whdc/annotation/DateTimeRange.java @@ -1,53 +1,53 @@ -package com.whdc.zhdbaqapi.annotation; - -import javax.validation.Constraint; -import javax.validation.Payload; -import java.lang.annotation.*; -import java.util.concurrent.TimeUnit; - -/** - * @author 李赛 - * @date 2022-04-27 12:08 - */ -@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Constraint(validatedBy = DateTimeRangeValidator.class) -@Documented -public @interface DateTimeRange { - - String message() default "{message}"; - - Class[] groups() default {}; - - Class[] payload() default {}; - - String datafmt() default "yyyy-MM-dd HH:mm:ss"; - - /** - * 起始属性字段名称 - * - * @return - */ - String startField(); - - /** - * 截止属性字段名称 - * - * @return - */ - String endField(); - - /** - * 时间间隔 - * - * @return - */ - long interval(); - - /** - * 时间间隔单位 - * - * @return - */ - TimeUnit timeUnit() default TimeUnit.HOURS; -} +package com.whdc.annotation; + +import javax.validation.Constraint; +import javax.validation.Payload; +import java.lang.annotation.*; +import java.util.concurrent.TimeUnit; + +/** + * @author 李赛 + * @date 2022-04-27 12:08 + */ +@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Constraint(validatedBy = DateTimeRangeValidator.class) +@Documented +public @interface DateTimeRange { + + String message() default "{message}"; + + Class[] groups() default {}; + + Class[] payload() default {}; + + String datafmt() default "yyyy-MM-dd HH:mm:ss"; + + /** + * 起始属性字段名称 + * + * @return + */ + String startField(); + + /** + * 截止属性字段名称 + * + * @return + */ + String endField(); + + /** + * 时间间隔 + * + * @return + */ + long interval(); + + /** + * 时间间隔单位 + * + * @return + */ + TimeUnit timeUnit() default TimeUnit.HOURS; +} diff --git a/src/main/java/com/whdc/zhdbaqapi/annotation/DateTimeRangeValidator.java b/src/main/java/com/whdc/annotation/DateTimeRangeValidator.java similarity index 94% rename from src/main/java/com/whdc/zhdbaqapi/annotation/DateTimeRangeValidator.java rename to src/main/java/com/whdc/annotation/DateTimeRangeValidator.java index f36323f..88db307 100644 --- a/src/main/java/com/whdc/zhdbaqapi/annotation/DateTimeRangeValidator.java +++ b/src/main/java/com/whdc/annotation/DateTimeRangeValidator.java @@ -1,63 +1,63 @@ -package com.whdc.zhdbaqapi.annotation; - -import org.apache.commons.beanutils.BeanUtils; -import org.apache.commons.lang3.StringUtils; - -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.concurrent.TimeUnit; - -/** - * @author 李赛 - * @date 2022-04-27 11:55 - */ -public class DateTimeRangeValidator implements ConstraintValidator { - - private String datefmt; - private String startField; - private String endField; - private long interval; - private TimeUnit timeUnit; - - @Override - public void initialize(DateTimeRange dateTimeRange) { - this.datefmt = dateTimeRange.datafmt(); - this.startField = dateTimeRange.startField(); - this.endField = dateTimeRange.endField(); - this.interval = dateTimeRange.interval(); - this.timeUnit = dateTimeRange.timeUnit(); - } - - @Override - public boolean isValid(Object obj, ConstraintValidatorContext context) { - try { - if (obj == null) { - return false; - } - - if (StringUtils.isBlank(this.startField) || StringUtils.isBlank(this.endField)) { - return false; - } - - String stmval = BeanUtils.getProperty(obj, this.startField); - String etmval = BeanUtils.getProperty(obj, this.endField); - - if (StringUtils.isBlank(stmval) || StringUtils.isBlank(etmval)) { - return false; - } - - DateFormat df = new SimpleDateFormat(this.datefmt); - Date stm = df.parse(stmval); - Date etm = df.parse(etmval); - - long dateDiff = stm.getTime() - etm.getTime(); - - return Math.abs(dateDiff) < this.timeUnit.toMillis(this.interval); - } catch (Exception e) { - return false; - } - } +package com.whdc.annotation; + +import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.lang3.StringUtils; + +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.concurrent.TimeUnit; + +/** + * @author 李赛 + * @date 2022-04-27 11:55 + */ +public class DateTimeRangeValidator implements ConstraintValidator { + + private String datefmt; + private String startField; + private String endField; + private long interval; + private TimeUnit timeUnit; + + @Override + public void initialize(DateTimeRange dateTimeRange) { + this.datefmt = dateTimeRange.datafmt(); + this.startField = dateTimeRange.startField(); + this.endField = dateTimeRange.endField(); + this.interval = dateTimeRange.interval(); + this.timeUnit = dateTimeRange.timeUnit(); + } + + @Override + public boolean isValid(Object obj, ConstraintValidatorContext context) { + try { + if (obj == null) { + return false; + } + + if (StringUtils.isBlank(this.startField) || StringUtils.isBlank(this.endField)) { + return false; + } + + String stmval = BeanUtils.getProperty(obj, this.startField); + String etmval = BeanUtils.getProperty(obj, this.endField); + + if (StringUtils.isBlank(stmval) || StringUtils.isBlank(etmval)) { + return false; + } + + DateFormat df = new SimpleDateFormat(this.datefmt); + Date stm = df.parse(stmval); + Date etm = df.parse(etmval); + + long dateDiff = stm.getTime() - etm.getTime(); + + return Math.abs(dateDiff) < this.timeUnit.toMillis(this.interval); + } catch (Exception e) { + return false; + } + } } \ No newline at end of file diff --git a/src/main/java/com/whdc/zhdbaqapi/aspect/WebLogAspect.java b/src/main/java/com/whdc/aspect/WebLogAspect.java similarity index 93% rename from src/main/java/com/whdc/zhdbaqapi/aspect/WebLogAspect.java rename to src/main/java/com/whdc/aspect/WebLogAspect.java index a868034..d8fdd80 100644 --- a/src/main/java/com/whdc/zhdbaqapi/aspect/WebLogAspect.java +++ b/src/main/java/com/whdc/aspect/WebLogAspect.java @@ -1,86 +1,86 @@ -package com.whdc.zhdbaqapi.aspect; - -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.support.spring.PropertyPreFilters; -import com.whdc.zhdbaqapi.utils.ReqUtils; -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.Signature; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.aspectj.lang.annotation.Pointcut; -import org.springframework.stereotype.Component; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; -import org.springframework.web.multipart.MultipartFile; - -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; - -/** - * @author 李赛 - * @date 2022-06-26 0:34 - */ - -@Aspect -@Component -@Slf4j -public class WebLogAspect { - - private void print(String fmt, Object... str) { - log.info(fmt, str); - } - - @Pointcut("execution(public * com.whdc.zhdbaqapi.controller.*Controller.*(..))") - public void controllerPointcut() { - } - - @Before("controllerPointcut()") - public void doBefore(JoinPoint joinPoint) throws Throwable { - ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - HttpServletRequest request = attributes.getRequest(); - Signature signature = joinPoint.getSignature(); - String name = signature.getName(); - - print("------------- 开始 -------------"); - print("请求: {} {}", name, request.getRequestURI(), request.getMethod()); - print("方法: {} {}.{}", name, signature.getDeclaringTypeName(), name); - print("地址: {} {}", name, ReqUtils.getIpAddress(request)); - - Object[] args = joinPoint.getArgs(); - Object[] arguments = new Object[args.length]; - for (int i = 0; i < args.length; i++) { - if (args[i] instanceof ServletRequest - || args[i] instanceof ServletResponse - || args[i] instanceof MultipartFile) { - continue; - } - arguments[i] = args[i]; - } - - String[] excludeProperties = {"password", "file"}; - PropertyPreFilters filters = new PropertyPreFilters(); - PropertyPreFilters.MySimplePropertyPreFilter excludeFilter = filters.addFilter(); - excludeFilter.addExcludes(excludeProperties); - print("参数: {} {}", name, JSONObject.toJSONString(arguments, excludeFilter)); - } - - @Around("controllerPointcut()") - public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { - long startTime = System.currentTimeMillis(); - Signature signature = proceedingJoinPoint.getSignature(); - String name = signature.getName(); - Object result = proceedingJoinPoint.proceed(); - - String[] excludeProperties = {"password", "file"}; - PropertyPreFilters filters = new PropertyPreFilters(); - PropertyPreFilters.MySimplePropertyPreFilter excludeFilter = filters.addFilter(); - excludeFilter.addExcludes(excludeProperties); -// print("返回结果: {}", JSONObject.toJSONString(result, excludeFilter)); - print("------------- 耗时:{} {} ms -------------", name, System.currentTimeMillis() - startTime); - return result; - } +package com.whdc.aspect; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.support.spring.PropertyPreFilters; +import com.whdc.utils.ReqUtils; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.Signature; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; + +/** + * @author 李赛 + * @date 2022-06-26 0:34 + */ + +@Aspect +@Component +@Slf4j +public class WebLogAspect { + + private void print(String fmt, Object... str) { + log.info(fmt, str); + } + + @Pointcut("execution(public * com.whdc.controller.*Controller.*(..))") + public void controllerPointcut() { + } + + @Before("controllerPointcut()") + public void doBefore(JoinPoint joinPoint) throws Throwable { + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + HttpServletRequest request = attributes.getRequest(); + Signature signature = joinPoint.getSignature(); + String name = signature.getName(); + + print("------------- 开始 -------------"); + print("请求: {} {}", name, request.getRequestURI(), request.getMethod()); + print("方法: {} {}.{}", name, signature.getDeclaringTypeName(), name); + print("地址: {} {}", name, ReqUtils.getIpAddress(request)); + + Object[] args = joinPoint.getArgs(); + Object[] arguments = new Object[args.length]; + for (int i = 0; i < args.length; i++) { + if (args[i] instanceof ServletRequest + || args[i] instanceof ServletResponse + || args[i] instanceof MultipartFile) { + continue; + } + arguments[i] = args[i]; + } + + String[] excludeProperties = {"password", "file"}; + PropertyPreFilters filters = new PropertyPreFilters(); + PropertyPreFilters.MySimplePropertyPreFilter excludeFilter = filters.addFilter(); + excludeFilter.addExcludes(excludeProperties); + print("参数: {} {}", name, JSONObject.toJSONString(arguments, excludeFilter)); + } + + @Around("controllerPointcut()") + public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { + long startTime = System.currentTimeMillis(); + Signature signature = proceedingJoinPoint.getSignature(); + String name = signature.getName(); + Object result = proceedingJoinPoint.proceed(); + + String[] excludeProperties = {"password", "file"}; + PropertyPreFilters filters = new PropertyPreFilters(); + PropertyPreFilters.MySimplePropertyPreFilter excludeFilter = filters.addFilter(); + excludeFilter.addExcludes(excludeProperties); +// print("返回结果: {}", JSONObject.toJSONString(result, excludeFilter)); + print("------------- 耗时:{} {} ms -------------", name, System.currentTimeMillis() - startTime); + return result; + } } \ No newline at end of file diff --git a/src/main/java/com/whdc/zhdbaqapi/component/MyPostConstruct.java b/src/main/java/com/whdc/component/MyPostConstruct.java similarity index 71% rename from src/main/java/com/whdc/zhdbaqapi/component/MyPostConstruct.java rename to src/main/java/com/whdc/component/MyPostConstruct.java index c7ceaa7..76406c5 100644 --- a/src/main/java/com/whdc/zhdbaqapi/component/MyPostConstruct.java +++ b/src/main/java/com/whdc/component/MyPostConstruct.java @@ -1,21 +1,20 @@ -package com.whdc.zhdbaqapi.component; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.annotation.PostConstruct; - -/** - * @author 李赛 - * @date 2022-07-17 15:33 - */ -@Component -@Slf4j -public class MyPostConstruct { - - @PostConstruct - public void initCache() { - log.debug("加载缓存"); - } -} +package com.whdc.component; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; + +/** + * @author 李赛 + * @date 2022-07-17 15:33 + */ +@Component +@Slf4j +public class MyPostConstruct { + + @PostConstruct + public void initCache() { + log.debug("加载缓存"); + } +} diff --git a/src/main/java/com/whdc/zhdbaqapi/config/InterceptorConfig.java b/src/main/java/com/whdc/config/InterceptorConfig.java similarity index 95% rename from src/main/java/com/whdc/zhdbaqapi/config/InterceptorConfig.java rename to src/main/java/com/whdc/config/InterceptorConfig.java index 4c4f50a..d3a9ff7 100644 --- a/src/main/java/com/whdc/zhdbaqapi/config/InterceptorConfig.java +++ b/src/main/java/com/whdc/config/InterceptorConfig.java @@ -1,40 +1,40 @@ -package com.whdc.zhdbaqapi.config; - -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -/** - * @author 李赛 - * @date 2022-06-26 1:09 - */ -@EnableWebMvc -@Configuration -public class InterceptorConfig implements WebMvcConfigurer { - - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("/**").addResourceLocations("classpath:/static/"); - registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/"); - registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); - } - - /** - * 开启跨域 - */ - @Override - public void addCorsMappings(CorsRegistry registry) { - // 设置允许跨域的路由 - registry.addMapping("/**") - // 设置允许跨域请求的域名------------修改此行 - .allowedOriginPatterns("*") - // 是否允许证书(cookies) - .allowCredentials(true) - // 设置允许的方法 - .allowedMethods("*") - // 跨域允许时间 - .maxAge(3600); - } -} +package com.whdc.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * @author 李赛 + * @date 2022-06-26 1:09 + */ +@EnableWebMvc +@Configuration +public class InterceptorConfig implements WebMvcConfigurer { + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/**").addResourceLocations("classpath:/static/"); + registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/"); + registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); + } + + /** + * 开启跨域 + */ + @Override + public void addCorsMappings(CorsRegistry registry) { + // 设置允许跨域的路由 + registry.addMapping("/**") + // 设置允许跨域请求的域名------------修改此行 + .allowedOriginPatterns("*") + // 是否允许证书(cookies) + .allowCredentials(true) + // 设置允许的方法 + .allowedMethods("*") + // 跨域允许时间 + .maxAge(3600); + } +} diff --git a/src/main/java/com/whdc/zhdbaqapi/config/Knife4jConfiguration.java b/src/main/java/com/whdc/config/Knife4jConfiguration.java similarity index 90% rename from src/main/java/com/whdc/zhdbaqapi/config/Knife4jConfiguration.java rename to src/main/java/com/whdc/config/Knife4jConfiguration.java index 507f2e5..4c49ed6 100644 --- a/src/main/java/com/whdc/zhdbaqapi/config/Knife4jConfiguration.java +++ b/src/main/java/com/whdc/config/Knife4jConfiguration.java @@ -1,66 +1,66 @@ -package com.whdc.zhdbaqapi.config; - -import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -/** - * @author 李赛 - * @date 2022-04-06 9:49 - */ -@EnableSwagger2 -@Configuration -public class Knife4jConfiguration { - private final OpenApiExtensionResolver openApiExtensionResolver; - - @Autowired - public Knife4jConfiguration(OpenApiExtensionResolver openApiExtensionResolver) { - this.openApiExtensionResolver = openApiExtensionResolver; - } - - - private ApiInfo getApiInfoBuilder() { - return new ApiInfoBuilder() - .title("漳河大坝安全api") - .description("# 漳河大坝安全api RESTful APIs") - .termsOfServiceUrl("http://219.138.108.99:19000/dbaq") - .contact(new Contact("湖北纬皓端成", null, null)) - .version("1.0") - .build(); - } - - @Bean(value = "base") - public Docket base() { - return new Docket(DocumentationType.OAS_30) - .apiInfo(getApiInfoBuilder()) - //分组名称 - .groupName("v1.0") - .select() - //这里指定Controller扫描包路径 - .apis(RequestHandlerSelectors.basePackage("com.whdc.zhdbaqapi.controller")) - .paths(PathSelectors.any()) - .build() - .extensions(openApiExtensionResolver.buildExtensions("v1.0")); - } - - @Bean(value = "md") - public Docket md() { - return new Docket(DocumentationType.OAS_30) - .apiInfo(getApiInfoBuilder()) - .select() - // ... - .build() - // 构建扩展插件-自定义文档 group - .extensions(openApiExtensionResolver.buildExtensions("doc-knife4j-1.0.0")) - .groupName("接口说明文档"); - } +package com.whdc.config; + +import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +/** + * @author 李赛 + * @date 2022-04-06 9:49 + */ +@EnableSwagger2 +@Configuration +public class Knife4jConfiguration { + private final OpenApiExtensionResolver openApiExtensionResolver; + + @Autowired + public Knife4jConfiguration(OpenApiExtensionResolver openApiExtensionResolver) { + this.openApiExtensionResolver = openApiExtensionResolver; + } + + + private ApiInfo getApiInfoBuilder() { + return new ApiInfoBuilder() + .title("山洪接收中心数据清洗api") + .description("# 山洪接收中心数据清洗api RESTful APIs") + .termsOfServiceUrl("http://219.138.108.99:19000/jszx") + .contact(new Contact("湖北纬皓端成", null, null)) + .version("1.0") + .build(); + } + + @Bean(value = "base") + public Docket base() { + return new Docket(DocumentationType.OAS_30) + .apiInfo(getApiInfoBuilder()) + //分组名称 + .groupName("v1.0") + .select() + //这里指定Controller扫描包路径 + .apis(RequestHandlerSelectors.basePackage("com.whdc.controller")) + .paths(PathSelectors.any()) + .build() + .extensions(openApiExtensionResolver.buildExtensions("v1.0")); + } + + @Bean(value = "md") + public Docket md() { + return new Docket(DocumentationType.OAS_30) + .apiInfo(getApiInfoBuilder()) + .select() + // ... + .build() + // 构建扩展插件-自定义文档 group + .extensions(openApiExtensionResolver.buildExtensions("doc-knife4j-1.0.0")) + .groupName("接口说明文档"); + } } \ No newline at end of file diff --git a/src/main/java/com/whdc/zhdbaqapi/config/MyBatisPlusConfig.java b/src/main/java/com/whdc/config/MyBatisPlusConfig.java similarity index 90% rename from src/main/java/com/whdc/zhdbaqapi/config/MyBatisPlusConfig.java rename to src/main/java/com/whdc/config/MyBatisPlusConfig.java index 05c837c..fb3fa96 100644 --- a/src/main/java/com/whdc/zhdbaqapi/config/MyBatisPlusConfig.java +++ b/src/main/java/com/whdc/config/MyBatisPlusConfig.java @@ -1,34 +1,34 @@ -package com.whdc.zhdbaqapi.config; - -import com.baomidou.mybatisplus.annotation.DbType; -import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; -import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author 李赛 - * @date 2022-04-08 0:33 - */ -@Configuration -@MapperScan("com.whdc.zhdbaqapi.mapper") -public class MyBatisPlusConfig { - - /* 旧版本配置 - @Bean - public PaginationInterceptor paginationInterceptor(){ - return new PaginationInterceptor(); - }*/ - - /** - * 新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题 - */ - @Bean - public MybatisPlusInterceptor mybatisPlusInterceptor() { - MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); - interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); // 分页插件 - return interceptor; - } -} - +package com.whdc.config; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author 李赛 + * @date 2022-04-08 0:33 + */ +@Configuration +@MapperScan("com.whdc.mapper") +public class MyBatisPlusConfig { + + /* 旧版本配置 + @Bean + public PaginationInterceptor paginationInterceptor(){ + return new PaginationInterceptor(); + }*/ + + /** + * 新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题 + */ + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); // 分页插件 + return interceptor; + } +} + diff --git a/src/main/java/com/whdc/config/MybatisInterceptor.java b/src/main/java/com/whdc/config/MybatisInterceptor.java new file mode 100644 index 0000000..8d36200 --- /dev/null +++ b/src/main/java/com/whdc/config/MybatisInterceptor.java @@ -0,0 +1,79 @@ +package com.whdc.config; + +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.executor.Executor; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.mapping.SqlCommandType; +import org.apache.ibatis.plugin.Interceptor; +import org.apache.ibatis.plugin.Intercepts; +import org.apache.ibatis.plugin.Invocation; +import org.apache.ibatis.plugin.Signature; +import org.springframework.stereotype.Component; + +import java.lang.reflect.Field; +import java.util.Date; + +import static com.whdc.model.MyConstant.REC; + +@Slf4j +@Component +@Intercepts({@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class})}) +public class MybatisInterceptor implements Interceptor { + + @Override + public Object intercept(Invocation invocation) throws Throwable { + MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0]; + String sqlId = mappedStatement.getId(); + log.debug("------sqlId------" + sqlId); + SqlCommandType sqlCommandType = mappedStatement.getSqlCommandType(); + Object parameter = invocation.getArgs()[1]; + log.debug("------sqlCommandType------" + sqlCommandType); + + if (parameter == null) { + return invocation.proceed(); + } + if (SqlCommandType.INSERT == sqlCommandType || SqlCommandType.UPDATE == sqlCommandType) { + Field[] fields = parameter.getClass().getDeclaredFields(); +// Field[] fields = oConvertUtils.getAllFields(parameter); + for (Field field : fields) { + if (field.getType().equals(String.class)) { + field.setAccessible(true); + Object o = field.get(parameter); + field.setAccessible(false); + String newVal = o == null ? "" : String.valueOf(o).trim(); + field.setAccessible(true); + field.set(parameter, newVal); + field.setAccessible(false); + } + + // 注入创建时间 + if ("createtime".equals(field.getName())) { + field.setAccessible(true); + Object local_createDate = field.get(parameter); + field.setAccessible(false); + if (local_createDate == null || "".equals(local_createDate)) { + field.setAccessible(true); + field.set(parameter, new Date()); + field.setAccessible(false); + } + } + + // 删除标识 + if ("del".equals(field.getName())) { + field.setAccessible(true); + Object local_createDate = field.get(parameter); + field.setAccessible(false); + if (local_createDate == null || "".equals(local_createDate)) { + field.setAccessible(true); + field.set(parameter, REC); + field.setAccessible(false); + } + } + + } + } + + return invocation.proceed(); + } + +} \ No newline at end of file diff --git a/src/main/java/com/whdc/zhdbaqapi/config/RestTemplateConfig.java b/src/main/java/com/whdc/config/RestTemplateConfig.java similarity index 66% rename from src/main/java/com/whdc/zhdbaqapi/config/RestTemplateConfig.java rename to src/main/java/com/whdc/config/RestTemplateConfig.java index 837ebc5..cc65366 100644 --- a/src/main/java/com/whdc/zhdbaqapi/config/RestTemplateConfig.java +++ b/src/main/java/com/whdc/config/RestTemplateConfig.java @@ -1,41 +1,60 @@ -package com.whdc.zhdbaqapi.config; - -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.http.client.ClientHttpRequestFactory; -import org.springframework.http.client.SimpleClientHttpRequestFactory; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.web.client.RestTemplate; - -import java.util.Arrays; - -/** - * @author 李赛 - * @date 2022-04-22 14:13 - */ -@Configuration -public class RestTemplateConfig { - - @Bean - public RestTemplate restTemplate(@Qualifier("simpleClientHttpRequestFactory") ClientHttpRequestFactory factory){ - RestTemplate restTemplate = new RestTemplate(factory); - MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); - mappingJackson2HttpMessageConverter.setSupportedMediaTypes(Arrays.asList( - MediaType.APPLICATION_JSON, - MediaType.APPLICATION_OCTET_STREAM, - MediaType.TEXT_HTML)); - restTemplate.getMessageConverters().add(mappingJackson2HttpMessageConverter); - return restTemplate; - } - - @Bean - public RestTemplate restTemplate() { - SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); - requestFactory.setConnectTimeout(10000); // 单位毫秒 - requestFactory.setReadTimeout(30000); // 单位毫秒 - - return new RestTemplate(requestFactory); - } -} +package com.whdc.config; + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.StringRedisSerializer; +import org.springframework.http.MediaType; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.client.RestTemplate; + +import java.util.Arrays; + +/** + * @author 李赛 + * @date 2022-04-22 14:13 + */ +@Configuration +public class RestTemplateConfig { + + @Order(1) + @Bean + public RestTemplate restTemplate(@Qualifier("simpleClientHttpRequestFactory") ClientHttpRequestFactory factory){ + RestTemplate restTemplate = new RestTemplate(factory); + MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); + mappingJackson2HttpMessageConverter.setSupportedMediaTypes(Arrays.asList( + MediaType.APPLICATION_JSON, + MediaType.APPLICATION_OCTET_STREAM, + MediaType.TEXT_HTML)); + restTemplate.getMessageConverters().add(mappingJackson2HttpMessageConverter); + return restTemplate; + } + + @Order(2) + @Bean + public RestTemplate restTemplate() { + SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); + requestFactory.setConnectTimeout(10000); // 单位毫秒 + requestFactory.setReadTimeout(30000); // 单位毫秒 + + return new RestTemplate(requestFactory); + } + + + @Order(4) + @Bean("redisTemplate") + public RedisTemplate redisTemplate(LettuceConnectionFactory lettuceConnectionFactory) { + RedisTemplate template = new RedisTemplate<>(); + template.setConnectionFactory(lettuceConnectionFactory); + // 设置键和值的序列化方式,默认使用JDK的序列化方式 + template.setKeySerializer(new StringRedisSerializer()); + template.setValueSerializer(new StringRedisSerializer()); + return template; + } + +} diff --git a/src/main/java/com/whdc/config/ThreadPools.java b/src/main/java/com/whdc/config/ThreadPools.java new file mode 100644 index 0000000..e020ae0 --- /dev/null +++ b/src/main/java/com/whdc/config/ThreadPools.java @@ -0,0 +1,32 @@ +package com.whdc.config; + +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.AsyncConfigurer; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * @author XuSan + * @date 2021/1/11 16:39 + * @explain 线程池类 + */ +@Configuration +//@Slf4j +public class ThreadPools implements AsyncConfigurer { + + + // 全核心线程池 + @Bean(value = "intensivePool", destroyMethod = "shutdown") + public ExecutorService intensive() { + return Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), new ThreadFactoryBuilder() + .setNameFormat("fixed -- %d").build()); + } + +// public static Void handleException(Throwable ex) { +// log.error("请求出现异常:" + ex.getMessage(), ex); +// return null; +// } +} diff --git a/src/main/java/com/whdc/controller/ERuleController.java b/src/main/java/com/whdc/controller/ERuleController.java new file mode 100644 index 0000000..b66889b --- /dev/null +++ b/src/main/java/com/whdc/controller/ERuleController.java @@ -0,0 +1,120 @@ +package com.whdc.controller; + + +import com.whdc.model.bean.ItemType; +import com.whdc.model.dto.FindRuleDto; +import com.whdc.model.entity.ERule; +import com.whdc.model.group.Insert; +import com.whdc.model.group.Update; +import com.whdc.service.IERuleService; +import com.whdc.utils.ResultJson; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.Objects; + +/** + * @author xusan + * @since 2023-03-19 + */ +@Api(tags = "规则管理 - Controller") +@RestController +@RequestMapping("/v2/eRule") +public class ERuleController { + + @Autowired + private IERuleService ieRuleService; + + + @ApiOperation(value = "查询所有") + @PostMapping(value = "list") + public ResultJson list() { + + return ResultJson.ok(ieRuleService.list()); + + } + + @ApiOperation(value = "分页查询") + @PostMapping(value = "page") + public ResultJson page(@RequestBody FindRuleDto ruleDto) { + + return ResultJson.ok(ieRuleService.page(ruleDto)); + + } + + + @ApiOperation(value = "添加") + @PostMapping(value = "save") + public ResultJson insert(@RequestBody @Validated(Insert.class) ERule model) { + + if (CollectionUtils.isNotEmpty( + ieRuleService.lambdaQuery() + .eq(ERule::getName,String.valueOf(model.getName()).trim()) + .list()) + ){ + return ResultJson.error("该名称重复"); + } + + if ( + StringUtils.isBlank(model.getDiffMax()) + && StringUtils.isBlank(model.getMin()) + && StringUtils.isBlank(model.getMax()) + ){ + return ResultJson.error("请设置规则"); + } + + if (!ItemType.map().containsKey(model.getItem())) { + return ResultJson.error("规则类型不存在"); + } + + return ResultJson.ok(ieRuleService.save(model)); + + } + + @ApiOperation(value = "修改") + @PostMapping(value = "edit") + public ResultJson update(@RequestBody @Validated(Update.class) ERule model) { + + if (CollectionUtils.isNotEmpty( + ieRuleService.lambdaQuery() + .eq(ERule::getName,String.valueOf(model.getName()).trim()) + .ne(ERule::getId, model.getId()) + .list()) + ){ + return ResultJson.error("该名称重复"); + } + + return ResultJson.ok(ieRuleService.updateById(model)); + } + + + @ApiOperation(value = "删除") + @GetMapping(value = "del/{id}") + public ResultJson delete(@PathVariable("id") Integer id) { + + + if (Objects.isNull(ieRuleService.getById(id))) { + + return ResultJson.error("当前数据不存在"); + + } + + return ResultJson.ok(ieRuleService.removeById(id)); + + } + + + @ApiOperation(value = "获取规则类型") + @GetMapping(value = "getItem") + public ResultJson getItem() { + return ResultJson.ok(ItemType.list()); + } + + + +} diff --git a/src/main/java/com/whdc/controller/EStationRulesController.java b/src/main/java/com/whdc/controller/EStationRulesController.java new file mode 100644 index 0000000..2036800 --- /dev/null +++ b/src/main/java/com/whdc/controller/EStationRulesController.java @@ -0,0 +1,112 @@ +package com.whdc.controller; + + +import com.whdc.model.dto.FindStationDto; +import com.whdc.model.entity.EStationRules; +import com.whdc.model.group.Insert; +import com.whdc.model.group.Update; +import com.whdc.service.IERuleService; +import com.whdc.service.IEStationRulesService; +import com.whdc.utils.ResultJson; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.Objects; + +/** + * @author xusan + * @since 2023-03-19 + */ +@Api(tags = "站点规则管理 - Controller") +@RestController +@RequestMapping("/v2/eStationRule") +public class EStationRulesController { + + @Autowired + private IEStationRulesService ieStationRulesService; + + @Autowired + private IERuleService ieruleService; + + + @ApiOperation(value = "查询全部") + @PostMapping(value = "find") + public ResultJson find(@RequestBody FindStationDto eStationRules) { + return ResultJson.ok(ieStationRulesService.find(eStationRules)); + } + + @ApiOperation(value = "分页查询") + @PostMapping(value = "page") + public ResultJson page(@RequestBody FindStationDto eStationRules) { + return ResultJson.ok(ieStationRulesService.page(eStationRules)); + } + + @ApiOperation(value = "新增测站规则") + @PostMapping(value = "save") + public ResultJson bind(@RequestBody @Validated({Insert.class}) EStationRules eStationRules) { + + if (Objects.isNull(ieruleService.getById(eStationRules.getRuleId()))) { + return ResultJson.error("当前规则不存在"); + } + + if (CollectionUtils.isNotEmpty( + ieStationRulesService.lambdaQuery() + .eq(EStationRules::getStcd,eStationRules.getStcd()) + .eq(EStationRules::getRuleId,eStationRules.getRuleId()) + .list() + )){ + return ResultJson.error("当前规则和测站已绑定"); + } + + return ResultJson.ok(ieStationRulesService.save(eStationRules)); + + } + + @ApiOperation(value = "修改测站规则") + @PostMapping(value = "update") + public ResultJson bindUpdate(@RequestBody @Validated({Update.class}) EStationRules eStationRules) { + + if (Objects.isNull(ieStationRulesService.getById(eStationRules.getId()))) { + + return ResultJson.error("当前数据不存在"); + + } + + if (Objects.isNull(ieruleService.getById(eStationRules.getRuleId()))) { + return ResultJson.error("当前规则不存在"); + } + + if (CollectionUtils.isNotEmpty( + ieStationRulesService.lambdaQuery() + .eq(EStationRules::getStcd,eStationRules.getStcd()) + .eq(EStationRules::getRuleId,eStationRules.getRuleId()) + .ne(EStationRules::getId,eStationRules.getId()) + .list() + )){ + return ResultJson.error("当前规则和测站已绑定"); + } + + return ResultJson.ok(ieStationRulesService.updateById(eStationRules)); + + } + + + @ApiOperation(value = "删除") + @GetMapping(value = "del/{id}") + public ResultJson del(@PathVariable Integer id) { + + EStationRules model = ieStationRulesService.getById(id); + if (Objects.isNull(model)) { + + return ResultJson.error("当前数据不存在"); + + } + + return ResultJson.ok(ieStationRulesService.removeById(id,model)); + } + +} diff --git a/src/main/java/com/whdc/zhdbaqapi/exception/CustomErrorController.java b/src/main/java/com/whdc/exception/CustomErrorController.java similarity index 92% rename from src/main/java/com/whdc/zhdbaqapi/exception/CustomErrorController.java rename to src/main/java/com/whdc/exception/CustomErrorController.java index 5a76f51..843f1cd 100644 --- a/src/main/java/com/whdc/zhdbaqapi/exception/CustomErrorController.java +++ b/src/main/java/com/whdc/exception/CustomErrorController.java @@ -1,70 +1,68 @@ -package com.whdc.zhdbaqapi.exception; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.web.ServerProperties; -import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController; -import org.springframework.boot.web.error.ErrorAttributeOptions; -import org.springframework.boot.web.servlet.error.DefaultErrorAttributes; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.servlet.ModelAndView; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.HashMap; -import java.util.Map; -import java.util.StringJoiner; - -/** - * 拦截全局异常,统一异常的返沪格式 - * - * @author 李赛 - * @date 2022-04-09 15:38 - */ -@Controller -@RequestMapping("${server.error.path:${error.path:/error}}") -public class CustomErrorController extends BasicErrorController { - - @Value("${server.error.path:${error.path:/error}}") - private String path; - - public CustomErrorController(ServerProperties serverProperties) { - super(new DefaultErrorAttributes(), serverProperties.getError()); - } - - /** - * 覆盖默认的JSON响应 - * 发送的请求类型是 json 时,出现异常时的返回 - */ - @Override - public ResponseEntity> error(HttpServletRequest request) { - HttpStatus status = getStatus(request); - Map map = new HashMap(16); - Map originalMsgMap = getErrorAttributes(request, ErrorAttributeOptions.defaults()); - String path = (String) originalMsgMap.get("path"); - String error = (String) originalMsgMap.get("error"); - String message = (String) originalMsgMap.get("message"); - StringJoiner joiner = new StringJoiner(",", "[", "]"); - joiner.add(path).add(error).add(message); - map.put("code", status.value()); - map.put("msg", joiner.toString()); - return new ResponseEntity>(map, status); - } - - /** - * 覆盖默认的HTML响应 - * 发送的请求类型是 html 时,出现异常时的返回 - */ - @Override - public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) { - //请求的状态 - HttpStatus status = getStatus(request); - response.setStatus(getStatus(request).value()); - Map model = getErrorAttributes(request, ErrorAttributeOptions.defaults()); - ModelAndView modelAndView = resolveErrorView(request, response, status, model); - //指定自定义的视图 - return (modelAndView == null ? new ModelAndView("error", model) : modelAndView); - } -} +package com.whdc.exception; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.web.ServerProperties; +import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController; +import org.springframework.boot.web.error.ErrorAttributeOptions; +import org.springframework.boot.web.servlet.error.DefaultErrorAttributes; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.Map; +import java.util.StringJoiner; + +/** + * 拦截全局异常,统一异常的返沪格式 + * + * @author 李赛 + * @date 2022-04-09 15:38 + */ +@Controller +@RequestMapping("${server.error.path:${error.path:/error}}") +public class CustomErrorController extends BasicErrorController { + + @Value("${server.error.path:${error.path:/error}}") + private String path; + + public CustomErrorController(ServerProperties serverProperties) { + super(new DefaultErrorAttributes(), serverProperties.getError()); + } + + /** + * 覆盖默认的JSON响应 + */ + @Override + public ResponseEntity> error(HttpServletRequest request) { + HttpStatus status = getStatus(request); + Map map = new HashMap(16); + Map originalMsgMap = getErrorAttributes(request, ErrorAttributeOptions.defaults()); + String path = (String) originalMsgMap.get("path"); + String error = (String) originalMsgMap.get("error"); + String message = (String) originalMsgMap.get("message"); + StringJoiner joiner = new StringJoiner(",", "[", "]"); + joiner.add(path).add(error).add(message); + map.put("code", status.value()); + map.put("msg", joiner.toString()); + return new ResponseEntity>(map, status); + } + + /** + * 覆盖默认的HTML响应 + */ + @Override + public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) { + //请求的状态 + HttpStatus status = getStatus(request); + response.setStatus(getStatus(request).value()); + Map model = getErrorAttributes(request, ErrorAttributeOptions.defaults()); + ModelAndView modelAndView = resolveErrorView(request, response, status, model); + //指定自定义的视图 + return (modelAndView == null ? new ModelAndView("error", model) : modelAndView); + } +} diff --git a/src/main/java/com/whdc/zhdbaqapi/exception/MyException.java b/src/main/java/com/whdc/exception/MyException.java similarity index 80% rename from src/main/java/com/whdc/zhdbaqapi/exception/MyException.java rename to src/main/java/com/whdc/exception/MyException.java index 8ed1a50..8a7ec61 100644 --- a/src/main/java/com/whdc/zhdbaqapi/exception/MyException.java +++ b/src/main/java/com/whdc/exception/MyException.java @@ -1,25 +1,25 @@ -package com.whdc.zhdbaqapi.exception; - -/** - * @author 李赛 - * @date 2022-06-26 10:58 - */ - -public class MyException extends RuntimeException { - - private String msg; - - public String getMsg() { - return msg; - } - - public MyException(String msg) { - super(msg); - this.msg = msg; - } - - public MyException(String msg, Throwable e) { - super(msg, e); - this.msg = msg; - } -} +package com.whdc.exception; + +/** + * @author 李赛 + * @date 2022-06-26 10:58 + */ + +public class MyException extends RuntimeException { + + private final String msg; + + public String getMsg() { + return msg; + } + + public MyException(String msg) { + super(msg); + this.msg = msg; + } + + public MyException(String msg, Throwable e) { + super(msg, e); + this.msg = msg; + } +} diff --git a/src/main/java/com/whdc/zhdbaqapi/exception/MyExceptionHandler.java b/src/main/java/com/whdc/exception/MyExceptionHandler.java similarity index 89% rename from src/main/java/com/whdc/zhdbaqapi/exception/MyExceptionHandler.java rename to src/main/java/com/whdc/exception/MyExceptionHandler.java index d9fcca1..bded5a2 100644 --- a/src/main/java/com/whdc/zhdbaqapi/exception/MyExceptionHandler.java +++ b/src/main/java/com/whdc/exception/MyExceptionHandler.java @@ -1,206 +1,199 @@ -package com.whdc.zhdbaqapi.exception; - -import cn.dev33.satoken.exception.NotLoginException; -import com.whdc.zhdbaqapi.utils.ResultJson; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springframework.dao.DataIntegrityViolationException; -import org.springframework.http.HttpStatus; -import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.validation.BindException; -import org.springframework.validation.BindingResult; -import org.springframework.validation.FieldError; -import org.springframework.validation.ObjectError; -import org.springframework.web.HttpMediaTypeNotSupportedException; -import org.springframework.web.HttpRequestMethodNotSupportedException; -import org.springframework.web.bind.MethodArgumentNotValidException; -import org.springframework.web.bind.MissingServletRequestParameterException; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -import javax.annotation.PostConstruct; -import javax.validation.ConstraintViolation; -import javax.validation.ConstraintViolationException; -import javax.validation.ValidationException; -import java.sql.SQLIntegrityConstraintViolationException; -import java.util.Set; - -/** - * @author 李赛 - * @date 2022-06-26 10:58 - */ -@RestControllerAdvice -@Slf4j -public class MyExceptionHandler { - - @PostConstruct - public void init() { - - } - - /** - * 保存错误日志 - * - * @param e 错误内容 - */ - private void saveLogs(Exception e) { - } - - /** - * 400 - Bad Request - */ - @ResponseStatus(HttpStatus.OK) - @ExceptionHandler(MissingServletRequestParameterException.class) - public ResultJson handleMissingServletRequestParameterException(MissingServletRequestParameterException e) { - log.error("缺少请求参数", e); - return ResultJson.error(ResultJson.PARAM_ERROR, "缺少请求参数"); - } - - /** - * 400 - Bad Request - */ - @ResponseStatus(HttpStatus.OK) - @ExceptionHandler(HttpMessageNotReadableException.class) - public ResultJson handleHttpMessageNotReadableException(HttpMessageNotReadableException e) { - log.error("缺少请求参数", e); - return ResultJson.error(ResultJson.PARAM_ERROR, "参数格式错误。使用 json 格式字符串传递参数"); - } - - /** - * 400 - Bad Request--------------------- - */ - @ResponseStatus(HttpStatus.OK) - @ExceptionHandler(MethodArgumentNotValidException.class) - public ResultJson handleMethodArgumentNotValidException(MethodArgumentNotValidException e) { - try { -// log.error("参数验证失败 " + e.getMessage(), e); - - BindingResult result = e.getBindingResult(); - - if (result.getErrorCount() > 0) { - StringBuffer strbuf = new StringBuffer(); - for (ObjectError err : result.getAllErrors()) { - if (strbuf.length() > 0) { - strbuf.append(";"); - } - strbuf.append(err.getDefaultMessage()); - } - - return ResultJson.error(ResultJson.PARAM_ERROR, "参数验证失败:" + strbuf.toString()); - } - - return ResultJson.error(ResultJson.PARAM_ERROR, "参数验证失败"); - } catch (Exception err) { - return ResultJson.error(ResultJson.PARAM_ERROR, "参数验证失败," + err.getMessage()); - } - } - - /** - * 400 - Bad Request - */ - @ResponseStatus(HttpStatus.OK) - @ExceptionHandler(BindException.class) - public ResultJson handleBindException(BindException e) { - BindingResult result = e.getBindingResult(); - FieldError error = result.getFieldError(); - String field = error.getField(); - String code = error.getDefaultMessage(); - String message = String.format("%s:%s", field, code); - log.error("参数绑定失败", message); - return ResultJson.error(ResultJson.PARAM_ERROR, "参数绑定失败," + message); - } - - /** - * 400 - Bad Request - */ - @ResponseStatus(HttpStatus.OK) - @ExceptionHandler(ConstraintViolationException.class) - public ResultJson handleServiceException(ConstraintViolationException e) { - Set> violations = e.getConstraintViolations(); - ConstraintViolation violation = violations.iterator().next(); - String message = violation.getMessage(); - log.error("参数验证失败 " + message, e); - return ResultJson.error(ResultJson.PARAM_ERROR, "参数验证失败," + message); - } - - /** - * 400 - Bad Request - */ - @ResponseStatus(HttpStatus.OK) - @ExceptionHandler(ValidationException.class) - public ResultJson handleValidationException(ValidationException e) { - log.error("参数验证失败 " + e.getMessage(), e); - return ResultJson.error(ResultJson.PARAM_ERROR, "参数验证失败"); - } - - /** - * 405 - Method Not Allowed - */ - @ResponseStatus(HttpStatus.OK) - @ExceptionHandler(HttpRequestMethodNotSupportedException.class) - public ResultJson handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) { - log.error("不支持当前请求方法", e.getMessage()); - return ResultJson.error(ResultJson.METHOD_NOT_ALLOWED, "不支持当前请求方法"); - } - - /** - * 415 - Unsupported Media Type - */ - @ResponseStatus(HttpStatus.OK) - @ExceptionHandler(HttpMediaTypeNotSupportedException.class) - public ResultJson handleHttpMediaTypeNotSupportedException(Exception e) { - log.error("不支持当前媒体类型", e.getMessage()); - return ResultJson.error(ResultJson.NSUPPORTED_MEDIA_TYPE, "不支持当前媒体类型"); - } - - /** - * 操作数据库出现异常:名称重复,外键关联 - */ - @ResponseStatus(HttpStatus.OK) - @ExceptionHandler(DataIntegrityViolationException.class) - public ResultJson handleException(DataIntegrityViolationException e) { - log.error("操作数据库出现异常: ", e); - return ResultJson.error(ResultJson.FAIL, "操作数据库出现异常"); - } - - /** - * 通用异常 - */ - @ResponseStatus(HttpStatus.OK) - @ExceptionHandler(Exception.class) - public ResultJson handleException(Exception e) { - log.error("通用异常:" + e.getMessage(), e); - - if (e instanceof SQLIntegrityConstraintViolationException) { - return ResultJson.error(ResultJson.FAIL, "数据库主键冲突,请联系管理员"); - } else if (e instanceof org.springframework.web.servlet.NoHandlerFoundException) { - return ResultJson.error(ResultJson.FAIL, "找不到资源"); - } - - return ResultJson.error(ResultJson.SERVER_ERROR, "内部服务器错误"); - } - - /** - * 500 - Internal Server Error - */ - @ResponseStatus(HttpStatus.OK) - @ExceptionHandler(MyException.class) - public ResultJson handleServiceException(MyException e) { - log.error("业务逻辑异常", e); - //RetryableException 无法单独捕获处理,只能简单处理一下返回值 - String msg = e.getMsg(); - if (StringUtils.isNotBlank(e.getMsg()) && e.getMsg().startsWith("Connection refused: connect executing POST")) { - msg = "连接被拒绝"; - } - return ResultJson.error(ResultJson.FAIL, msg); - } - - @ResponseStatus(HttpStatus.OK) - @ExceptionHandler(NotLoginException.class) - public ResultJson handleNotLoginException(NotLoginException e) { - log.error("业务逻辑异常", e); - - return ResultJson.error(ResultJson.UNAUTHORIZED, e.getMessage()); - } -} +package com.whdc.exception; + +import com.whdc.utils.ResultJson; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.http.HttpStatus; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.validation.BindException; +import org.springframework.validation.BindingResult; +import org.springframework.validation.FieldError; +import org.springframework.validation.ObjectError; +import org.springframework.web.HttpMediaTypeNotSupportedException; +import org.springframework.web.HttpRequestMethodNotSupportedException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.MissingServletRequestParameterException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +import javax.annotation.PostConstruct; +import javax.validation.ConstraintViolation; +import javax.validation.ConstraintViolationException; +import javax.validation.ValidationException; +import java.sql.SQLIntegrityConstraintViolationException; +import java.util.Set; + +/** + * @author 李赛 + * @date 2022-06-26 10:58 + */ +@RestControllerAdvice +@Slf4j +public class MyExceptionHandler { + + @PostConstruct + public void init() { + + } + + /** + * 保存错误日志 + * + * @param e 错误内容 + */ + private void saveLogs(Exception e) { + } + + /** + * 400 - Bad Request + */ + @ResponseStatus(HttpStatus.OK) + @ExceptionHandler(MissingServletRequestParameterException.class) + public ResultJson handleMissingServletRequestParameterException(MissingServletRequestParameterException e) { + log.error("缺少请求参数", e); + return ResultJson.error(ResultJson.PARAM_ERROR, "缺少请求参数"); + } + + /** + * 400 - Bad Request + */ + @ResponseStatus(HttpStatus.OK) + @ExceptionHandler(HttpMessageNotReadableException.class) + public ResultJson handleHttpMessageNotReadableException(HttpMessageNotReadableException e) { + log.error("缺少请求参数", e); + return ResultJson.error(ResultJson.PARAM_ERROR, "参数格式错误。使用 json 格式字符串传递参数"); + } + + /** + * 400 - Bad Request--------------------- + */ + @ResponseStatus(HttpStatus.OK) + @ExceptionHandler(MethodArgumentNotValidException.class) + public ResultJson handleMethodArgumentNotValidException(MethodArgumentNotValidException e) { + try { +// log.error("参数验证失败 " + e.getMessage(), e); + + BindingResult result = e.getBindingResult(); + + if (result.getErrorCount() > 0) { + StringBuffer strbuf = new StringBuffer(); + for (ObjectError err : result.getAllErrors()) { + if (strbuf.length() > 0) { + strbuf.append(";"); + } + strbuf.append(err.getDefaultMessage()); + } + + return ResultJson.error(ResultJson.PARAM_ERROR, "参数验证失败1:" + strbuf); + } + + return ResultJson.error(ResultJson.PARAM_ERROR, "参数验证失败2"); + } catch (Exception err) { + return ResultJson.error(ResultJson.PARAM_ERROR, "参数验证失败3," + err.getMessage()); + } + } + + /** + * 400 - Bad Request + */ + @ResponseStatus(HttpStatus.OK) + @ExceptionHandler(BindException.class) + public ResultJson handleBindException(BindException e) { + BindingResult result = e.getBindingResult(); + FieldError error = result.getFieldError(); + String field = error.getField(); + String code = error.getDefaultMessage(); + String message = String.format("%s:%s", field, code); + log.error("参数绑定失败", message); + return ResultJson.error(ResultJson.PARAM_ERROR, "参数绑定失败," + message); + } + + /** + * 400 - Bad Request + */ + @ResponseStatus(HttpStatus.OK) + @ExceptionHandler(ConstraintViolationException.class) + public ResultJson handleServiceException(ConstraintViolationException e) { + Set> violations = e.getConstraintViolations(); + ConstraintViolation violation = violations.iterator().next(); + String message = violation.getMessage(); + log.error("参数验证失败4 " + message, e); + return ResultJson.error(ResultJson.PARAM_ERROR, "参数验证失败5," + message); + } + + /** + * 400 - Bad Request + */ + @ResponseStatus(HttpStatus.OK) + @ExceptionHandler(ValidationException.class) + public ResultJson handleValidationException(ValidationException e) { + log.error("参数验证失败6 " + e.getMessage()); + e.printStackTrace(); + return ResultJson.error(ResultJson.PARAM_ERROR, "参数验证失败7"); + } + + /** + * 405 - Method Not Allowed + */ + @ResponseStatus(HttpStatus.OK) + @ExceptionHandler(HttpRequestMethodNotSupportedException.class) + public ResultJson handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) { + log.error("不支持当前请求方法", e.getMessage()); + return ResultJson.error(ResultJson.METHOD_NOT_ALLOWED, "不支持当前请求方法"); + } + + /** + * 415 - Unsupported Media Type + */ + @ResponseStatus(HttpStatus.OK) + @ExceptionHandler(HttpMediaTypeNotSupportedException.class) + public ResultJson handleHttpMediaTypeNotSupportedException(Exception e) { + log.error("不支持当前媒体类型", e.getMessage()); + return ResultJson.error(ResultJson.NSUPPORTED_MEDIA_TYPE, "不支持当前媒体类型"); + } + + /** + * 操作数据库出现异常:名称重复,外键关联 + */ + @ResponseStatus(HttpStatus.OK) + @ExceptionHandler(DataIntegrityViolationException.class) + public ResultJson handleException(DataIntegrityViolationException e) { + log.error("操作数据库出现异常: ", e); + return ResultJson.error(ResultJson.FAIL, "操作数据库出现异常"); + } + + /** + * 通用异常 + */ + @ResponseStatus(HttpStatus.OK) + @ExceptionHandler(Exception.class) + public ResultJson handleException(Exception e) { + log.error("通用异常:" + e.getMessage(), e); + + if (e instanceof SQLIntegrityConstraintViolationException) { + return ResultJson.error(ResultJson.FAIL, "数据库主键冲突,请联系管理员"); + } else if (e instanceof org.springframework.web.servlet.NoHandlerFoundException) { + return ResultJson.error(ResultJson.FAIL, "找不到资源"); + } + + return ResultJson.error(ResultJson.SERVER_ERROR, "内部服务器错误"); + } + + /** + * 500 - Internal Server Error + */ + @ResponseStatus(HttpStatus.OK) + @ExceptionHandler(MyException.class) + public ResultJson handleServiceException(MyException e) { + log.error("业务逻辑异常", e); + //RetryableException 无法单独捕获处理,只能简单处理一下返回值 + String msg = e.getMsg(); + if (StringUtils.isNotBlank(e.getMsg()) && e.getMsg().startsWith("Connection refused: connect executing POST")) { + msg = "连接被拒绝"; + } + return ResultJson.error(ResultJson.FAIL, msg); + } + +} diff --git a/src/main/java/com/whdc/mapper/ERuleMapper.java b/src/main/java/com/whdc/mapper/ERuleMapper.java new file mode 100644 index 0000000..4b8d969 --- /dev/null +++ b/src/main/java/com/whdc/mapper/ERuleMapper.java @@ -0,0 +1,28 @@ +package com.whdc.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.whdc.model.dto.FindRuleDto; +import com.whdc.model.entity.ERule; +import org.apache.ibatis.annotations.Param; + +/** + *

+ * Mapper 接口 + *

+ * + * @author xusan + * @since 2023-03-19 + */ +public interface ERuleMapper extends BaseMapper { + + /** + * 分页查询 + * + * @param page + * @param findDto + * @return + */ + IPage page(@Param("page") IPage page, @Param("findDto") FindRuleDto findDto); + +} diff --git a/src/main/java/com/whdc/mapper/EStationRulesMapper.java b/src/main/java/com/whdc/mapper/EStationRulesMapper.java new file mode 100644 index 0000000..6e93e18 --- /dev/null +++ b/src/main/java/com/whdc/mapper/EStationRulesMapper.java @@ -0,0 +1,28 @@ +package com.whdc.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.whdc.model.dto.FindStationDto; +import com.whdc.model.entity.EStationRules; +import com.whdc.model.vo.EStationRulesVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author xusan + * @since 2023-03-19 + */ +public interface EStationRulesMapper extends BaseMapper { + + + IPage page(@Param("page") IPage page, @Param("findDto") FindStationDto findDto); + + List find(@Param("findDto") FindStationDto findDto); + + +} diff --git a/src/main/java/com/whdc/model/MyConstant.java b/src/main/java/com/whdc/model/MyConstant.java new file mode 100644 index 0000000..f359345 --- /dev/null +++ b/src/main/java/com/whdc/model/MyConstant.java @@ -0,0 +1,25 @@ +package com.whdc.model; + +/** + * @author xusan + * @date 2023/4/27 9:41 + */ +public class MyConstant { + + public static final String + + // 删除 + DEL = "0", + + // 未删除 + REC = "1", + + + // redis KEY + TOKEN_KEY = "SW_TOKEN_SJQX"; + + /** + * 数据-数据服务运维员 角色编码 + */ + public static final String ROLE_PUSH = "data_zh_om"; +} diff --git a/src/main/java/com/whdc/model/bean/ItemType.java b/src/main/java/com/whdc/model/bean/ItemType.java new file mode 100644 index 0000000..4bf70a2 --- /dev/null +++ b/src/main/java/com/whdc/model/bean/ItemType.java @@ -0,0 +1,72 @@ +package com.whdc.model.bean; + +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * + * @author xusan + * @date 2023年3月22日10:32:54 + * @description: 测站类型代码 + */ +public enum ItemType { + + YU_LIANG("雨量", "P"), + SHUI_WEI("水位", "Z"), + LIU_LIANG("流量", "Q"); + + private String name; + private String value; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + ItemType(String name, String value) { + this.name = name; + this.value = value; + } + + public static List list() { + List list = new ArrayList<>(); + ItemType[] values = ItemType.values(); + for (ItemType type : values) { + JSONObject obj = new JSONObject(); + obj.put("name", type.getName()); + obj.put("value", type.getValue()); + list.add(obj); + } + return list; + } + + public static Map map() { + Map map = new HashMap<>(); + ItemType[] values = ItemType.values(); + for (ItemType e : values) { + map.put(e.getValue(), e); + } + return map; + } + + public static ItemType getByValue(String value) { + if (StringUtils.isEmpty(value)) return null; + return map().get(value); + } +} diff --git a/src/main/java/com/whdc/model/dto/ERuleDto.java b/src/main/java/com/whdc/model/dto/ERuleDto.java new file mode 100644 index 0000000..f78e766 --- /dev/null +++ b/src/main/java/com/whdc/model/dto/ERuleDto.java @@ -0,0 +1,72 @@ +package com.whdc.model.dto; + +import io.swagger.annotations.ApiModelProperty; +import io.swagger.annotations.ApiParam; +import lombok.Data; + +import javax.validation.constraints.Max; +import javax.validation.constraints.NotEmpty; + +/** + * @author xusan + * @date 2023年3月20日08:57:22 + */ +@Data +public class ERuleDto { + + /** + * 主键自增 + */ + @ApiParam(value = "主键自增", required = true, example = "0") + @ApiModelProperty(value = "主键自增", required = true, dataType = "Integer", example = "0") + private Integer id; + + /** + * 规则名称 + */ + @ApiParam(value = "规则名称", required = true, example = "规则名称") + @ApiModelProperty(value = "规则名称", required = true, dataType = "String", example = "规则名称") + @NotEmpty(message = "规则名称不能为空") + @Max(50) + private String name; + /** + * 1:正常值范围规则 + * 2:最大差值规则 + */ + @ApiParam(value = "1:正常值范围规则 2:最大差值规则", required = false, example = "1:正常值范围规则 2:最大差值规则 ") + @ApiModelProperty(value = "1:正常值范围规则 2:最大差值规则, required = false ", dataType = "String", example = " 1:正常值范围规则 2:最大差值规则 ") + @NotEmpty(message = "规则类型不能为空") + private String ruleType; + + /** + * 测站类型 + */ + @ApiParam(value = "测站类型", required = true, example = "测站类型") + @ApiModelProperty(value = "测站类型", required = true, dataType = "String", example = "测站类型") + @NotEmpty(message = "测站类型不能为空") + @Max(2) + private String type; + + /** + * 最小值 + */ + @ApiParam(value = "最小值", required = false, example = "最小值") + @ApiModelProperty(value = "最小值", required = false, dataType = "String", example = "最小值") + @Max(100) + private String min; + /** + * 最大值 + */ + @ApiParam(value = "最大值", required = false, example = "最大值") + @ApiModelProperty(value = "最大值", required = false, dataType = "String", example = "最大值") + @Max(100) + private String max; + + /** + * 两条数据之间的差值 + */ + @ApiParam(value = "两条数据之间的差值", required = false, example = "两条数据之间的差值") + @ApiModelProperty(value = "两条数据之间的差值", required = false, dataType = "String", example = "两条数据之间的差值") + @Max(100) + private String lastDataMax; +} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/dto/FindPageDto.java b/src/main/java/com/whdc/model/dto/FindPageDto.java similarity index 82% rename from src/main/java/com/whdc/zhdbaqapi/model/dto/FindPageDto.java rename to src/main/java/com/whdc/model/dto/FindPageDto.java index 8b41de7..bf824d6 100644 --- a/src/main/java/com/whdc/zhdbaqapi/model/dto/FindPageDto.java +++ b/src/main/java/com/whdc/model/dto/FindPageDto.java @@ -1,35 +1,31 @@ -package com.whdc.zhdbaqapi.model.dto; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.Pattern; - -@Data -public class FindPageDto { - - // 页数,从1开始,默认1 - @ApiModelProperty(value = "当前页", example = "1") - private Integer pageNumber = 1; - - // 每页记录数,默认10 - @ApiModelProperty(value = "每页条数", example = "10") - private Integer pageSize = 10; - - // 是否统计总数,默认 true - @ApiModelProperty(value = "是否统计总数。数据量大时,为了提高查询效率,可以将该字段置为 false", example = "10") - private Boolean searchCount = true; - - // 排序字段 - @ApiModelProperty(value = "排序字段") - private String sortField; - - @ApiModelProperty(value = "排序顺序", example = "asc") - @Pattern(message = "排序顺序,仅支持 asc 或者 desc", regexp = "asc|desc") - private String sortOrder = "asc"; - - public Page getPage() { - return new Page(pageNumber, pageSize, searchCount); - } -} +package com.whdc.model.dto; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.Pattern; + +@Data +public class FindPageDto { + + @ApiModelProperty(value = "当前页", example = "1") + private Integer pageNumber = 1; + + @ApiModelProperty(value = "每页条数", example = "10") + private Integer pageSize = 10; + + @ApiModelProperty(value = "是否统计总数。数据量大时,为了提高查询效率,可以将该字段置为 false", example = "10") + private Boolean searchCount = true; + + @ApiModelProperty(value = "排序字段") + private String sortField; + + @ApiModelProperty(value = "排序顺序", example = "asc") + @Pattern(message = "排序顺序,仅支持 asc 或者 desc", regexp = "asc|desc") + private String sortOrder = "asc"; + + public Page getPage() { + return new Page(pageNumber, pageSize, searchCount); + } +} diff --git a/src/main/java/com/whdc/model/dto/FindRuleDto.java b/src/main/java/com/whdc/model/dto/FindRuleDto.java new file mode 100644 index 0000000..29893e6 --- /dev/null +++ b/src/main/java/com/whdc/model/dto/FindRuleDto.java @@ -0,0 +1,38 @@ +package com.whdc.model.dto; + +import com.whdc.annotation.DateTimeRange; +import com.whdc.model.group.Find; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; +import java.util.concurrent.TimeUnit; + +/** + * @author xusan + * @date 2023年3月20日08:57:22 + */ +@Data +@DateTimeRange(message = "时间间隔不能超过 31 天", startField = "stm", endField = "etm", interval = 31, timeUnit = TimeUnit.DAYS) +public class FindRuleDto extends FindPageDto { + + @ApiModelProperty(value = "规则名称", dataType = "java.lang.String") + private String name; + + @ApiModelProperty(value = "规则类型", dataType = "java.lang.String") + private String item; + + @ApiModelProperty(value = "起始时间", example = "2023-03-20 10:00:00") + @NotEmpty(message = "起始时间不能为空", groups = Find.class) + @Pattern(regexp = "^[1-9]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\\s+(20|21|22|23|[0-1]\\d):[0-5]\\d:[0-5]\\d$", + message = "时间格式应为:yyyy-MM-dd HH:mm:ss", groups = Find.class) + private String stm; + + @ApiModelProperty(value = "截止时间", example = "2023-03-20 10:00:00") + @NotEmpty(message = "截止时间不能为空", groups = Find.class) + @Pattern(regexp = "^[1-9]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\\s+(20|21|22|23|[0-1]\\d):[0-5]\\d:[0-5]\\d$", + message = "时间格式应为:yyyy-MM-dd HH:mm:ss", groups = Find.class) + private String etm; + +} diff --git a/src/main/java/com/whdc/model/dto/FindStationDto.java b/src/main/java/com/whdc/model/dto/FindStationDto.java new file mode 100644 index 0000000..3aa1368 --- /dev/null +++ b/src/main/java/com/whdc/model/dto/FindStationDto.java @@ -0,0 +1,22 @@ +package com.whdc.model.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author xusan + * @date 2023年3月20日08:57:22 + */ +@Data +public class FindStationDto extends FindPageDto { + + @ApiModelProperty(value = "规则名称", dataType = "java.lang.String") + private String name; + + @ApiModelProperty(value = "测站编码", dataType = "java.lang.String") + private String stcd; + + @ApiModelProperty(value = "适用测站类型", dataType = "java.lang.String") + private String item; + +} diff --git a/src/main/java/com/whdc/model/entity/ERule.java b/src/main/java/com/whdc/model/entity/ERule.java new file mode 100644 index 0000000..7820aac --- /dev/null +++ b/src/main/java/com/whdc/model/entity/ERule.java @@ -0,0 +1,148 @@ +package com.whdc.model.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.whdc.model.group.Insert; +import com.whdc.model.group.Update; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.annotations.ApiParam; +import lombok.Data; +import lombok.experimental.Accessors; +import org.apache.commons.lang3.StringUtils; + +import javax.validation.constraints.Max; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.Date; +import java.util.Locale; + +import static com.whdc.model.MyConstant.DEL; +import static com.whdc.model.MyConstant.REC; + +/** + *

+ * + *

+ * + * @author xusan + * @date 2023-03-19 + */ +@Data +@ApiModel(description = "正常范围规则表") +@Accessors(chain = true) +@TableName("E_RULE") +public class ERule extends Model { + private static final long serialVersionUID = 1L; + /** + * 主键自增 + */ + @ApiParam(value = "主键自增", required = true) + @ApiModelProperty(value = "主键自增", required = true, dataType = "Integer") + @TableId(value = "ID", type = IdType.AUTO) + @NotNull(message = "主键不能为空", groups = {Update.class}) + private Integer id; + + /** + * 规则名称 + */ + @ApiParam(value = "规则名称", required = true, example = "") + @ApiModelProperty(value = "规则名称", required = true, dataType = "String") + @TableField(value = "NAME", updateStrategy = FieldStrategy.NOT_EMPTY) + @NotEmpty(message = "规则名称不能为空", groups = {Insert.class,Update.class}) + @Max(50) + private String name; + + /** + * 测站类型 + */ + @ApiParam(value = "规则类型", required = true, example = "") + @ApiModelProperty(value = "规则类型", required = true, dataType = "String") + @TableField(value = "ITEM", updateStrategy = FieldStrategy.NOT_EMPTY) + @NotEmpty(message = "规则类型不能为空", groups = {Insert.class,Update.class}) + @Max(50) + private String item; + + public void setItem(String item) { + + if (StringUtils.isNotBlank(item)){ + item = item.toUpperCase(Locale.ROOT); + } + + this.item = item; + } + + /** + * 最小值 + */ + @ApiParam(value = "最小值", required = false, example = "") + @ApiModelProperty(value = "最小值", required = false, dataType = "String") + @TableField(value = "MIN", updateStrategy = FieldStrategy.NOT_EMPTY) + @Max(50) + private String min; + + /** + * 最大值 + */ + @ApiParam(value = "最大值", required = false, example = "") + @ApiModelProperty(value = "最大值", required = false, dataType = "String") + @TableField(value = "MAX", updateStrategy = FieldStrategy.NOT_EMPTY) + @Max(50) + private String max; + + /** + * 最大值 + */ + @ApiParam(value = "两条数据之间的最大差值", required = false, example = "") + @ApiModelProperty(value = "两条数据之间的最大差值", required = false, dataType = "String") + @TableField(value = "DIFF_MAX", updateStrategy = FieldStrategy.NOT_EMPTY) + private String diffMax; + + /** + * 最大值 + */ + @ApiParam(value = "时间段, 单位 s", required = false, example = "") + @ApiModelProperty(value = "时间段, 单位 s", required = false, dataType = "Integer") + @TableField(value = "DURATION", updateStrategy = FieldStrategy.NOT_EMPTY) + @Max(10) + private Integer duration; + + /** + * 接收超出时间,单位: s ,指接收时间超前范围 + */ + @ApiParam(value = "接收超前时间,单位: s ,指接收时间超前范围", required = false, example = "") + @ApiModelProperty(value = "接收超前时间,单位: s ,指接收时间超前范围", required = false, dataType = "Integer") + @TableField(value = "LEADING_TIME", updateStrategy = FieldStrategy.NOT_EMPTY) + @Max(10) + private Integer leadingTime; + + /** + * 接收滞后时间,单位: s ,指接收时间滞后范围 + */ + @ApiParam(value = "接收滞后时间,单位: s ,指接收时间滞后范围", required = false, example = "") + @ApiModelProperty(value = "接收滞后时间,单位: s ,指接收时间滞后范围", required = false, dataType = "Integer") + @TableField(value = "LAG_TIME", updateStrategy = FieldStrategy.NOT_EMPTY) + @Max(10) + private Integer lagTime; + + /** + * 创建时间 + */ + @ApiParam(value = "创建时间", required = false) + @ApiModelProperty(value = "创建时间", required = false, dataType = "Date") + @TableField(value = "CREATETIME", updateStrategy = FieldStrategy.NOT_EMPTY) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createtime; + + /** + * 1: 未删除 0: 删除 + */ + @ApiParam(value = "1: 未删除 0: 删除", required = false, example = "1") + @ApiModelProperty(value = "1: 未删除 0: 删除", required = false, dataType = "String", example = "1") + @TableField(value = "DEL", fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NOT_EMPTY) + @TableLogic(value = REC,delval = DEL) + @Max(2) + private String del; + +} diff --git a/src/main/java/com/whdc/model/entity/EStationRules.java b/src/main/java/com/whdc/model/entity/EStationRules.java new file mode 100644 index 0000000..2f5bd73 --- /dev/null +++ b/src/main/java/com/whdc/model/entity/EStationRules.java @@ -0,0 +1,90 @@ +package com.whdc.model.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.whdc.model.group.Insert; +import com.whdc.model.group.Update; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.annotations.ApiParam; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.Max; +import javax.validation.constraints.NotNull; +import java.util.Date; + +import static com.whdc.model.MyConstant.DEL; +import static com.whdc.model.MyConstant.REC; + +/** + *

+ * + *

+ * + * @author xusan + * @date 2023-03-19 + */ +@Data +@ApiModel(description = "测站关联规则表") +@Accessors(chain = true) +@TableName("E_STATION_RULES") +public class EStationRules extends Model { + private static final long serialVersionUID = 1L; + /** + * 主键id + */ + @ApiParam(value = "主键id", required = true) + @ApiModelProperty(value = "主键id", required = true, dataType = "Integer") + @TableId(value = "ID", type = IdType.AUTO) + @NotNull(message = "主键id不能为空",groups = {Update.class}) + private Integer id; + + /** + * 测站编码 + */ + @ApiParam(value = "测站编码", required = true) + @ApiModelProperty(value = "测站编码", required = false, dataType = "String", example = "") + @TableField(value = "STCD") + @NotNull(message = "测站编码不能为空",groups = {Insert.class}) + @Max(50) + private String stcd; + + /** + * 规则id + */ + @ApiParam(value = "规则id", required = true) + @ApiModelProperty(value = "规则id", required = false, dataType = "Integer", example = "") + @TableField(value = "RULE_ID", updateStrategy = FieldStrategy.IGNORED) + @NotNull(message = "规则不能为空",groups = {Insert.class}) + private Integer ruleId; + + /** + * 顺序 + */ + @ApiParam(value = "顺序", required = true ) + @ApiModelProperty(value = "顺序, required = false ", dataType = "Integer") + @TableField(value = "SORT", updateStrategy = FieldStrategy.NOT_EMPTY) + private Integer sort; + + /** + * 创建时间 + */ + @ApiParam(value = "创建时间", required = false) + @ApiModelProperty(value = "创建时间", required = false, dataType = "Date", example = "") + @TableField(value = "CREATETIME", updateStrategy = FieldStrategy.NOT_EMPTY) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createtime; + + /** + * 0:未删除 1 删除 + */ + @ApiParam(value = "1: 未删除 0: 删除", required = false) + @ApiModelProperty(value = "1: 未删除 0: 删除", required = false, dataType = "String", example = "") + @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.IGNORED) + @TableLogic(value = REC,delval = DEL) + @Max(2) + private String del; + +} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/group/Delete.java b/src/main/java/com/whdc/model/group/Delete.java similarity index 62% rename from src/main/java/com/whdc/zhdbaqapi/model/group/Delete.java rename to src/main/java/com/whdc/model/group/Delete.java index 0c17311..9f49154 100644 --- a/src/main/java/com/whdc/zhdbaqapi/model/group/Delete.java +++ b/src/main/java/com/whdc/model/group/Delete.java @@ -1,8 +1,8 @@ -package com.whdc.zhdbaqapi.model.group; - -/** - * @author 李赛 - * @date 2022-06-26 15:13 - */ -public interface Delete { -} +package com.whdc.model.group; + +/** + * @author 李赛 + * @date 2022-06-26 15:13 + */ +public interface Delete { +} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/group/Find.java b/src/main/java/com/whdc/model/group/Find.java similarity index 62% rename from src/main/java/com/whdc/zhdbaqapi/model/group/Find.java rename to src/main/java/com/whdc/model/group/Find.java index 35753f6..66ccc8d 100644 --- a/src/main/java/com/whdc/zhdbaqapi/model/group/Find.java +++ b/src/main/java/com/whdc/model/group/Find.java @@ -1,8 +1,8 @@ -package com.whdc.zhdbaqapi.model.group; - -/** - * @author 李赛 - * @date 2022-06-27 22:27 - */ -public interface Find { -} +package com.whdc.model.group; + +/** + * @author 李赛 + * @date 2022-06-27 22:27 + */ +public interface Find { +} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/group/Insert.java b/src/main/java/com/whdc/model/group/Insert.java similarity index 62% rename from src/main/java/com/whdc/zhdbaqapi/model/group/Insert.java rename to src/main/java/com/whdc/model/group/Insert.java index eb4937e..1e8fac9 100644 --- a/src/main/java/com/whdc/zhdbaqapi/model/group/Insert.java +++ b/src/main/java/com/whdc/model/group/Insert.java @@ -1,8 +1,8 @@ -package com.whdc.zhdbaqapi.model.group; - -/** - * @author 李赛 - * @date 2022-06-26 15:12 - */ -public interface Insert { -} +package com.whdc.model.group; + +/** + * @author 李赛 + * @date 2022-06-26 15:12 + */ +public interface Insert { +} diff --git a/src/main/java/com/whdc/model/group/Update.java b/src/main/java/com/whdc/model/group/Update.java new file mode 100644 index 0000000..52666d9 --- /dev/null +++ b/src/main/java/com/whdc/model/group/Update.java @@ -0,0 +1,8 @@ +package com.whdc.model.group; + +/** + * @author 李赛 + * @date 2022-06-26 15:12 + */ +public interface Update { +} diff --git a/src/main/java/com/whdc/model/vo/ERuleVo.java b/src/main/java/com/whdc/model/vo/ERuleVo.java new file mode 100644 index 0000000..d607537 --- /dev/null +++ b/src/main/java/com/whdc/model/vo/ERuleVo.java @@ -0,0 +1,31 @@ +package com.whdc.model.vo; + +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * @author 李赛 + * @date 2022-06-26 10:43 + */ +@Data +@Accessors(chain = true) // chain = true 实现链式调用 +@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性 +public class ERuleVo implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键id") + private Integer id; + + @ApiModelProperty(value = "规则id") + private Integer ruleId; + + @ApiModelProperty(value = "规则类型") + private String ruleType; + + +} diff --git a/src/main/java/com/whdc/model/vo/EStationRulesVo.java b/src/main/java/com/whdc/model/vo/EStationRulesVo.java new file mode 100644 index 0000000..067b821 --- /dev/null +++ b/src/main/java/com/whdc/model/vo/EStationRulesVo.java @@ -0,0 +1,45 @@ +package com.whdc.model.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author xusan + * @date 2023年3月28日14:07:28 + */ +@Data +@Accessors(chain = true) // chain = true 实现链式调用 +@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性 +public class EStationRulesVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键id") + private Integer id; + + @ApiModelProperty(value = "规则id") + private Integer ruleId; + + @ApiModelProperty(value = "测站编码") + private String stcd; + + @ApiModelProperty(value = "规则类型") + private String item; + + @ApiModelProperty(value = "规则名称") + private String name; + + @ApiModelProperty(value = "顺序") + private String sort; + + @ApiModelProperty(value = "创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createtime; + + +} diff --git a/src/main/java/com/whdc/model/vo/ValidateVo.java b/src/main/java/com/whdc/model/vo/ValidateVo.java new file mode 100644 index 0000000..e98bf58 --- /dev/null +++ b/src/main/java/com/whdc/model/vo/ValidateVo.java @@ -0,0 +1,36 @@ +package com.whdc.model.vo; + +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * @author 李赛 + * @date 2022-06-26 10:43 + */ +@Data +@Accessors(chain = true) // chain = true 实现链式调用 +@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性 +public class ValidateVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "是否通过 1是可,0是否") + private Integer isPass = 1; + + @ApiModelProperty(value = "提示信息") + private String msg; + + + @ApiModelProperty(value = "验证不通过规则id") + private String npRuleCode; + + + @ApiModelProperty(value = "规则id") + private List ruleCodes = new ArrayList<>(); + +} diff --git a/src/main/java/com/whdc/service/IERuleService.java b/src/main/java/com/whdc/service/IERuleService.java new file mode 100644 index 0000000..b892ddc --- /dev/null +++ b/src/main/java/com/whdc/service/IERuleService.java @@ -0,0 +1,25 @@ +package com.whdc.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.whdc.model.dto.FindRuleDto; +import com.whdc.model.entity.ERule; + +/** + *

+ * 服务类 + *

+ * + * @author xusan + * @since 2023-03-19 + */ +public interface IERuleService extends IService { + /** + * + * @param eData + * @return + */ + IPage page(FindRuleDto eData); + + +} diff --git a/src/main/java/com/whdc/service/IEStationRulesService.java b/src/main/java/com/whdc/service/IEStationRulesService.java new file mode 100644 index 0000000..2fcd20a --- /dev/null +++ b/src/main/java/com/whdc/service/IEStationRulesService.java @@ -0,0 +1,30 @@ +package com.whdc.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.whdc.model.dto.FindStationDto; +import com.whdc.model.entity.EStationRules; +import com.whdc.model.vo.EStationRulesVo; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author xusan + * @since 2023-03-19 + */ +public interface IEStationRulesService extends IService { + + // 获取所有规则分页 + IPage page(FindStationDto ruleDto); + + // 获取所有规则 + List find(FindStationDto ruleDto); + + boolean removeById(Integer id, EStationRules model); + + void delRule(Integer eRuleId); +} diff --git a/src/main/java/com/whdc/service/impl/ERuleServiceImpl.java b/src/main/java/com/whdc/service/impl/ERuleServiceImpl.java new file mode 100644 index 0000000..45ca55b --- /dev/null +++ b/src/main/java/com/whdc/service/impl/ERuleServiceImpl.java @@ -0,0 +1,44 @@ +package com.whdc.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.whdc.mapper.ERuleMapper; +import com.whdc.model.dto.FindRuleDto; +import com.whdc.model.entity.ERule; +import com.whdc.service.IERuleService; +import com.whdc.service.IEStationRulesService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author xusan + * @since 2023-03-19 + */ +@Service +public class ERuleServiceImpl extends ServiceImpl implements IERuleService { + + @Autowired + private IEStationRulesService ieStationRulesService; + + @Override + public IPage page(FindRuleDto findDto) { + return baseMapper.page(findDto.getPage(), findDto); + } + + + @Override + public boolean updateById(ERule model){ + + boolean update = super.updateById(model); + if (update){ + ieStationRulesService.delRule(model.getId()); + } + + return update; + } + +} diff --git a/src/main/java/com/whdc/service/impl/EStationRulesServiceImpl.java b/src/main/java/com/whdc/service/impl/EStationRulesServiceImpl.java new file mode 100644 index 0000000..293e233 --- /dev/null +++ b/src/main/java/com/whdc/service/impl/EStationRulesServiceImpl.java @@ -0,0 +1,83 @@ +package com.whdc.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.whdc.mapper.EStationRulesMapper; +import com.whdc.model.dto.FindStationDto; +import com.whdc.model.entity.EStationRules; +import com.whdc.model.vo.EStationRulesVo; +import com.whdc.service.IEStationRulesService; +import com.whdc.valid.component.RuleRedisService; +import org.apache.commons.collections.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + *

+ * 服务实现类 + *

+ * + * @author xusan + * @since 2023-03-19 + */ +@Service +public class EStationRulesServiceImpl extends ServiceImpl implements IEStationRulesService { + + + @Autowired + private RuleRedisService ruleRedis; + + + @Override + public IPage page(FindStationDto ruleDto) { + return baseMapper.page(ruleDto.getPage(), ruleDto); + } + + + @Override + public List find(FindStationDto ruleDto) { + + return baseMapper.find(ruleDto); + } + + + @Override + public boolean updateById(EStationRules model){ + + boolean update = super.updateById(model); + if (update){ + ruleRedis.delRule(model.getStcd()); + } + + return update; + } + + + @Override + public boolean removeById( Integer id,EStationRules model){ + + boolean update = super.removeById(id); + if (update){ + ruleRedis.delRule(model.getStcd()); + } + + return update; + } + + @Override + public void delRule(Integer eRuleId) { + + List list = this.lambdaQuery().eq(EStationRules::getRuleId, eRuleId) + .list(); + if (CollectionUtils.isNotEmpty(list)) { + for (EStationRules rules : list) { + ruleRedis.delRule(rules.getStcd()); + } + } + + } + + +} diff --git a/src/main/java/com/whdc/strategy/SaveContext.java b/src/main/java/com/whdc/strategy/SaveContext.java new file mode 100644 index 0000000..cfaceff --- /dev/null +++ b/src/main/java/com/whdc/strategy/SaveContext.java @@ -0,0 +1,29 @@ +package com.whdc.strategy; + +import com.alibaba.fastjson.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * 定义环境角色(Context):用于连接上下文 + */ +@Component +public class SaveContext { + + private final Map strategyMap = new ConcurrentHashMap<>(); + + @Autowired + public SaveContext(Map strategyMap) { + this.strategyMap.putAll(strategyMap); + } + + // 新增 + public boolean syncSave(String channel, JSONObject jsonObject) { + return strategyMap.get(channel).syncSave(jsonObject); + } + + +} diff --git a/src/main/java/com/whdc/strategy/SyncSaveInterface.java b/src/main/java/com/whdc/strategy/SyncSaveInterface.java new file mode 100644 index 0000000..8acf748 --- /dev/null +++ b/src/main/java/com/whdc/strategy/SyncSaveInterface.java @@ -0,0 +1,14 @@ +package com.whdc.strategy; + +import com.alibaba.fastjson.JSONObject; + +/** + * @author xusan + * @date 2023/4/20 16:28 + */ + +public interface SyncSaveInterface { + + boolean syncSave(JSONObject jsonObject); + +} diff --git a/src/main/java/com/whdc/zhdbaqapi/utils/DataUtils.java b/src/main/java/com/whdc/utils/DataUtils.java similarity index 74% rename from src/main/java/com/whdc/zhdbaqapi/utils/DataUtils.java rename to src/main/java/com/whdc/utils/DataUtils.java index bb3d424..480e555 100644 --- a/src/main/java/com/whdc/zhdbaqapi/utils/DataUtils.java +++ b/src/main/java/com/whdc/utils/DataUtils.java @@ -1,88 +1,129 @@ -package com.whdc.zhdbaqapi.utils; - -import org.apache.commons.lang3.StringUtils; - -import java.io.File; -import java.io.FileInputStream; -import java.math.BigDecimal; -import java.math.MathContext; -import java.math.RoundingMode; -import java.util.Base64; -import java.util.HashMap; -import java.util.Map; - -/** - * @author 李赛 - * @date 2022-07-22 8:46 - */ -public class DataUtils { - private static Map extension2Scheme = new HashMap(); - - static { - extension2Scheme.put("jpg", "data:image/jpg;base64,"); - extension2Scheme.put("jpeg", "data:image/jpeg;base64,"); - extension2Scheme.put("png", "data:image/png;base64,"); - extension2Scheme.put("gif", "data:image/gif;base64,"); - extension2Scheme.put("icon", "data:image/x-icon;base64,"); - } - - /** - * 标准差σ=sqrt(s^2) - * 结果精度:scale - * 牛顿迭代法求大数开方 - * - * @param value - * @param scale - * @return - */ - public static BigDecimal sqrt(BigDecimal value, int scale) { - BigDecimal num2 = BigDecimal.valueOf(2); - int precision = 100; - MathContext mc = new MathContext(precision, RoundingMode.HALF_UP); - BigDecimal deviation = value; - int cnt = 0; - while (cnt < precision) { - deviation = (deviation.add(value.divide(deviation, mc))).divide(num2, mc); - cnt++; - } - deviation = deviation.setScale(scale, BigDecimal.ROUND_HALF_UP); - return deviation; - } - - public static String File2Base64(String filepath) { - if (StringUtils.isBlank(filepath)) { - return null; - } - File file1 = new File(filepath); - - if (!file1.exists()) { - return null; - } - - int lastPointIndex = filepath.lastIndexOf("."); - String type = filepath.substring(lastPointIndex + 1); - - if (!extension2Scheme.containsKey(type.toLowerCase())) { - System.out.println("文件类型错误 " + type); - return null; - } - - try (FileInputStream inputStream = new FileInputStream(file1)) { - byte[] buffer = new byte[inputStream.available()]; - if (inputStream.read(buffer) == -1) { - inputStream.close(); - } - - return extension2Scheme.get(type.toLowerCase()) + Base64.getEncoder().encodeToString(buffer); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - public static void DelFile(String filepath) { - File file1 = new File(filepath); - - System.out.println("清理图片缓存:" + filepath + (file1.delete() ? "成功" : "失败")); - } -} +package com.whdc.utils; + +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.io.File; +import java.io.FileInputStream; +import java.math.BigDecimal; +import java.math.MathContext; +import java.math.RoundingMode; +import java.util.Base64; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * @author 李赛 + * @date 2022-07-22 8:46 + */ +@Slf4j +public class DataUtils { + + public static final BigDecimal MIN_VALUE = BigDecimal.valueOf(0.001); + + + private static Map extension2Scheme = new HashMap(); + + static { + extension2Scheme.put("jpg", "data:image/jpg;base64,"); + extension2Scheme.put("jpeg", "data:image/jpeg;base64,"); + extension2Scheme.put("png", "data:image/png;base64,"); + extension2Scheme.put("gif", "data:image/gif;base64,"); + extension2Scheme.put("icon", "data:image/x-icon;base64,"); + } + + /** + * 标准差σ=sqrt(s^2) + * 结果精度:scale + * 牛顿迭代法求大数开方 + * + * @param value + * @param scale + * @return + */ + public static BigDecimal sqrt(BigDecimal value, int scale) { + BigDecimal num2 = BigDecimal.valueOf(2); + int precision = 100; + MathContext mc = new MathContext(precision, RoundingMode.HALF_UP); + BigDecimal deviation = value; + int cnt = 0; + while (cnt < precision) { + deviation = (deviation.add(value.divide(deviation, mc))).divide(num2, mc); + cnt++; + } + deviation = deviation.setScale(scale, BigDecimal.ROUND_HALF_UP); + return deviation; + } + + public static String File2Base64(String filepath) { + if (StringUtils.isBlank(filepath)) { + return null; + } + File file1 = new File(filepath); + + if (!file1.exists()) { + return null; + } + + int lastPointIndex = filepath.lastIndexOf("."); + String type = filepath.substring(lastPointIndex + 1); + + if (!extension2Scheme.containsKey(type.toLowerCase())) { + System.out.println("文件类型错误 " + type); + return null; + } + + try (FileInputStream inputStream = new FileInputStream(file1)) { + byte[] buffer = new byte[inputStream.available()]; + if (inputStream.read(buffer) == -1) { + inputStream.close(); + } + + return extension2Scheme.get(type.toLowerCase()) + Base64.getEncoder().encodeToString(buffer); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public static void DelFile(String filepath) { + File file1 = new File(filepath); + + System.out.println("清理图片缓存:" + filepath + (file1.delete() ? "成功" : "失败")); + } + + + public static Void handleException(Throwable ex) { + log.error("请求出现异常:" + ex.getMessage(), ex); + return null; + } + + public static String handleExceptionStr(Throwable ex) { + log.error("请求出现异常:" + ex.getMessage(), ex); + return null; + } + + public static Integer handleExceptionInt(Throwable ex) { + log.error("请求出现异常:" + ex.getMessage(), ex); + return null; + } + + + /** + * 高程 + * @param elValue + * @return + */ + public static BigDecimal gcFormat(BigDecimal elValue){ + if (Objects.isNull(elValue)){ + return null; + } + + if (BigDecimal.ZERO.equals(elValue)){ + return MIN_VALUE; + } + return elValue; + } + +} diff --git a/src/main/java/com/whdc/zhdbaqapi/utils/DateUtils.java b/src/main/java/com/whdc/utils/DateUtils.java similarity index 70% rename from src/main/java/com/whdc/zhdbaqapi/utils/DateUtils.java rename to src/main/java/com/whdc/utils/DateUtils.java index b93e841..e90db27 100644 --- a/src/main/java/com/whdc/zhdbaqapi/utils/DateUtils.java +++ b/src/main/java/com/whdc/utils/DateUtils.java @@ -1,74 +1,101 @@ -package com.whdc.zhdbaqapi.utils; - -import net.sf.jsqlparser.expression.DateTimeLiteralExpression; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.SimpleTimeZone; - -/** - * @author 李赛 - * @date 2022-06-26 1:01 - */ -public class DateUtils { - /** - * 时间格式(yyyy-MM-dd HH:mm:ss) - */ - public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; - - public static final ThreadLocal sdfhmsS = new ThreadLocal() { - protected SimpleDateFormat initialValue() { - return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); - } - }; - public static final ThreadLocal sdfhms = new ThreadLocal() { - protected SimpleDateFormat initialValue() { - return new SimpleDateFormat(DATE_TIME_PATTERN); - } - }; - public static final ThreadLocal sdf_utc = new ThreadLocal() { - protected SimpleDateFormat initialValue() { - return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); - } - }; - public static final ThreadLocal sdf_utc_sss = new ThreadLocal() { - protected SimpleDateFormat initialValue() { - return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); - } - }; - - - /** - * mongo 日期查询isodate - * - * @param dateStr - * @return - */ - public static Date dateToISODate(String dateStr) throws ParseException { - //T代表后面跟着时间,Z代表UTC统一时间 - Date date = formatD(dateStr); - SimpleDateFormat format = sdfhms.get(); - format.setCalendar(new GregorianCalendar(new SimpleTimeZone(0, "GMT"))); - String isoDate = format.format(date); - return format.parse(isoDate); - } - - public static Date formatD(String dateStr) throws ParseException { - return formatD(dateStr, DATE_TIME_PATTERN); - } - - public static Date formatD(String dateStr, String format) throws ParseException { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format); - - return simpleDateFormat.parse(dateStr); - } - - - public static void main(String[] args) throws ParseException { - - System.out.println(dateToISODate("2021-11-05T13:00:00Z")); - - } -} +package com.whdc.utils; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.SimpleTimeZone; + +/** + * @author 李赛 + * @date 2022-06-26 1:01 + */ +public class DateUtils { + /** + * 时间格式(yyyy-MM-dd HH:mm:ss) + */ + public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; + + + public static final ThreadLocal sdfhmsS = new ThreadLocal() { + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + } + }; + + public static final ThreadLocal sdfYMDh = ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd HH:mm")); + + public static final ThreadLocal sdfhms = new ThreadLocal() { + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat(DATE_TIME_PATTERN); + } + }; + public static final ThreadLocal sdf_utc = new ThreadLocal() { + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); + } + }; + public static final ThreadLocal sdf_utc_sss = new ThreadLocal() { + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); + } + }; + + public static final ThreadLocal sdf_Str = ThreadLocal.withInitial(() -> new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy")); + + + + public static LocalDateTime strToLDT(String str,String format){ + return LocalDateTime.parse(str, DateTimeFormatter.ofPattern(format)); + } + + public static String dateToStr(Date date){ + return sdfhms.get().format(date); + } + + public static Date dateToStr(String dateString){ + try { + return sdf_Str.get().parse(dateString); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + + public static String dateToStr(Date date, ThreadLocal format){ + return format.get().format(date); + } + + /** + * mongo 日期查询isodate + * + * @param dateStr + * @return + */ + public static Date dateToISODate(String dateStr) throws ParseException { + //T代表后面跟着时间,Z代表UTC统一时间 + Date date = formatD(dateStr); + SimpleDateFormat format = sdfhms.get(); + format.setCalendar(new GregorianCalendar(new SimpleTimeZone(0, "GMT"))); + String isoDate = format.format(date); + return format.parse(isoDate); + } + + public static Date formatD(String dateStr) throws ParseException { + return formatD(dateStr, DATE_TIME_PATTERN); + } + + public static Date formatD(String dateStr, String format) throws ParseException { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format); + + return simpleDateFormat.parse(dateStr); + } + + + public static void main(String[] args) throws ParseException { + + System.out.println(dateToISODate("2021-11-05T13:00:00Z")); + + } +} diff --git a/src/main/java/com/whdc/utils/JsonUtils.java b/src/main/java/com/whdc/utils/JsonUtils.java new file mode 100644 index 0000000..2399e21 --- /dev/null +++ b/src/main/java/com/whdc/utils/JsonUtils.java @@ -0,0 +1,31 @@ +package com.whdc.utils; + +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; + +/** + * @author xusan + * @date 2023/4/17 16:44 + */ +public class JsonUtils { + + public static boolean isJson(String str) { + + if (StringUtils.isBlank(str)){ + return false; + } + try { + JSONObject.parseObject(str); + return true; + } catch (Exception e) { + return false; + } + } + + public static void updateJson(JSONObject jsonObject,String key){ + String data = jsonObject.getString("DATA"); + if (StringUtils.isNotBlank(data) && StringUtils.isBlank(jsonObject.getString(key))){ + jsonObject.put(key,data); + } + } +} diff --git a/src/main/java/com/whdc/utils/NumUtils.java b/src/main/java/com/whdc/utils/NumUtils.java new file mode 100644 index 0000000..8b8502e --- /dev/null +++ b/src/main/java/com/whdc/utils/NumUtils.java @@ -0,0 +1,25 @@ +package com.whdc.utils; + +import org.apache.commons.lang3.StringUtils; + +import java.util.regex.Pattern; + +/** + * @author xusan + * @date 2023/4/11 15:03 + */ +public class NumUtils { + + public static Pattern isNumber = Pattern.compile("^-?\\d+(\\.\\d+)?$"); + + public static boolean isNumber(String number) { + // 非空校验 + if (StringUtils.isEmpty(number)) { + return false; + } + // 数字校验(可以包含小数,可以是1,9,-1,1.1,-1.1,不能是+1.1,+1) + // 这个支持+1.1,+1 + // Pattern pattern = Pattern.compile("[+-]?[@-9]+(\\\\.[0-9]+)?"); + return isNumber.matcher(number).matches(); + } +} diff --git a/src/main/java/com/whdc/utils/RedisConfUtils.java b/src/main/java/com/whdc/utils/RedisConfUtils.java new file mode 100644 index 0000000..94ebcfb --- /dev/null +++ b/src/main/java/com/whdc/utils/RedisConfUtils.java @@ -0,0 +1,113 @@ +package com.whdc.utils; + +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +import java.util.Collection; +import java.util.Objects; +import java.util.Set; + +/** + * @author xusan + * @date 2023/4/13 14:19 + */ +public class RedisConfUtils { + + public static StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); + + + public static void setStringRedisSerializer(RedisTemplate redisTemplate) { + if (!Objects.isNull(redisTemplate)) { + + if (!(redisTemplate.getKeySerializer() instanceof StringRedisSerializer)) { + redisTemplate.setKeySerializer(stringRedisSerializer); + } + } + } + + + public static void setDefaultRedisSerializer(RedisTemplate redisTemplate) { + if (!Objects.isNull(redisTemplate)) { + + if (redisTemplate.getKeySerializer() instanceof StringRedisSerializer) { + redisTemplate.setKeySerializer(redisTemplate.getHashKeySerializer()); + } + } + + } + + public static void setStringRedisSeria(RedisTemplate redisTemplate) { + if (!Objects.isNull(redisTemplate)) { + + if (!(redisTemplate.getKeySerializer() instanceof StringRedisSerializer)) { + redisTemplate.setKeySerializer(stringRedisSerializer); + } + } + } + + + public static void setDefaultRedisSeria(RedisTemplate redisTemplate) { + if (!Objects.isNull(redisTemplate)) { + + if (redisTemplate.getKeySerializer() instanceof StringRedisSerializer) { + redisTemplate.setKeySerializer(redisTemplate.getHashKeySerializer()); + } + } + + } + + + public static Object get(String key, RedisTemplate redisTemplate) { + try { + setStringRedisSerializer(redisTemplate); + return redisTemplate.opsForValue().get(key); + } finally { + setDefaultRedisSerializer(redisTemplate); + } + } + + public static void set(String key, Object o, RedisTemplate redisTemplate) { + try { + setStringRedisSerializer(redisTemplate); + redisTemplate.opsForValue().set(key, o); + } finally { + setDefaultRedisSerializer(redisTemplate); + } + } + + public static Set getKeys(String key, RedisTemplate redisTemplate) { + try { + setStringRedisSerializer(redisTemplate); + return redisTemplate.keys(key + "*"); + } finally { + setDefaultRedisSerializer(redisTemplate); + } + } + + public static Boolean hasKey(String key, RedisTemplate redisTemplate) { + try { + setStringRedisSerializer(redisTemplate); + return redisTemplate.hasKey(key); + } finally { + setDefaultRedisSerializer(redisTemplate); + } + } + + public static void delete(String key, RedisTemplate redisTemplate) { + try { + setStringRedisSeria(redisTemplate); + redisTemplate.delete(key); + } finally { + setDefaultRedisSeria(redisTemplate); + } + } + + public static void delete(Collection keys, RedisTemplate redisTemplate) { + try { + setStringRedisSeria(redisTemplate); + redisTemplate.delete(keys); + } finally { + setDefaultRedisSeria(redisTemplate); + } + } +} diff --git a/src/main/java/com/whdc/zhdbaqapi/utils/ReqUtils.java b/src/main/java/com/whdc/utils/ReqUtils.java similarity index 95% rename from src/main/java/com/whdc/zhdbaqapi/utils/ReqUtils.java rename to src/main/java/com/whdc/utils/ReqUtils.java index 907c735..5c25f92 100644 --- a/src/main/java/com/whdc/zhdbaqapi/utils/ReqUtils.java +++ b/src/main/java/com/whdc/utils/ReqUtils.java @@ -1,128 +1,128 @@ -package com.whdc.zhdbaqapi.utils; - -import javax.servlet.http.HttpServletRequest; - -public class ReqUtils { - private static String dbPath = null; - - /** - * 获取用户真实IP地址,不使用request.getRemoteAddr();的原因是有可能用户使用了代理软件方式避免真实IP地址, - * 可是,如果通过了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP值,究竟哪个才是真正的用户端的真实IP呢? - * 答案是取X-Forwarded-For中第一个非unknown的有效IP字符串。 - * 如:X-Forwarded-For:192.168.1.110, 192.168.1.120, 192.168.1.130, 192.168.1.100 - * 用户真实IP为: 192.168.1.110 - * - * @param request - * @return - */ - public static String getIpAddress(HttpServletRequest request) {// 获取客户端ip地址 - String clientIp = request.getHeader("x-forwarded-for"); - - if (clientIp == null || clientIp.length() == 0 || "unknown".equalsIgnoreCase(clientIp)) { - clientIp = request.getHeader("Proxy-Client-IP"); - } - if (clientIp == null || clientIp.length() == 0 || "unknown".equalsIgnoreCase(clientIp)) { - clientIp = request.getHeader("WL-Proxy-Client-IP"); - } - if (clientIp == null || clientIp.length() == 0 || "unknown".equalsIgnoreCase(clientIp)) { - clientIp = request.getRemoteAddr(); - } - /* - * 对于获取到多ip的情况下,找到公网ip. - */ - String sIP = null; - if (clientIp != null && !clientIp.contains("unknown") && clientIp.indexOf(",") > 0) { - String[] ipsz = clientIp.split(","); - for (String anIpsz : ipsz) { - if (!isInnerIP(anIpsz.trim())) { - sIP = anIpsz.trim(); - break; - } - } - /* - * 如果多ip都是内网ip,则取第一个ip. - */ - if (null == sIP) { - sIP = ipsz[0].trim(); - } - clientIp = sIP; - } - if (clientIp != null && clientIp.contains("unknown")) { - clientIp = clientIp.replaceAll("unknown,", ""); - clientIp = clientIp.trim(); - } - if ("".equals(clientIp) || null == clientIp) { - clientIp = "127.0.0.1"; - } - return clientIp; - } - - /** - * 判断IP是否是内网地址 - * - * @param ipAddress ip地址 - * @return 是否是内网地址 - */ - public static boolean isInnerIP(String ipAddress) { - boolean isInnerIp; - long ipNum = getIpNum(ipAddress); - /** - 私有IP:A类 10.0.0.0-10.255.255.255 - B类 172.16.0.0-172.31.255.255 - C类 192.168.0.0-192.168.255.255 - 当然,还有127这个网段是环回地址 - **/ - long aBegin = getIpNum("10.0.0.0"); - long aEnd = getIpNum("10.255.255.255"); - - long bBegin = getIpNum("172.16.0.0"); - long bEnd = getIpNum("172.31.255.255"); - - long cBegin = getIpNum("192.168.0.0"); - long cEnd = getIpNum("192.168.255.255"); - isInnerIp = isInner(ipNum, aBegin, aEnd) || isInner(ipNum, bBegin, bEnd) || isInner(ipNum, cBegin, cEnd) - || ipAddress.equals("127.0.0.1"); - return isInnerIp; - } - - private static long getIpNum(String ipAddress) { - String[] ip = ipAddress.split("\\."); - long a = Integer.parseInt(ip[0]); - long b = Integer.parseInt(ip[1]); - long c = Integer.parseInt(ip[2]); - long d = Integer.parseInt(ip[3]); - - return a * 256 * 256 * 256 + b * 256 * 256 + c * 256 + d; - } - - private static boolean isInner(long userIp, long begin, long end) { - return (userIp >= begin) && (userIp <= end); - } - - public static String getRealIP(HttpServletRequest request) { - // 获取客户端ip地址 - String clientIp = request.getHeader("x-forwarded-for"); - - if (clientIp == null || clientIp.length() == 0 || "unknown".equalsIgnoreCase(clientIp)) { - clientIp = request.getRemoteAddr(); - } - - String[] clientIps = clientIp.split(","); - if (clientIps.length <= 1) return clientIp.trim(); - - // 判断是否来自CDN - if (isComefromCDN(request)) { - if (clientIps.length >= 2) return clientIps[clientIps.length - 2].trim(); - } - - return clientIps[clientIps.length - 1].trim(); - } - - private static boolean isComefromCDN(HttpServletRequest request) { - String host = request.getHeader("host"); - return host.contains("www.189.cn") || - host.contains("shouji.189.cn") || - host.contains("image2.chinatelecom-ec.com") || - host.contains("image1.chinatelecom-ec.com"); - } -} +package com.whdc.utils; + +import javax.servlet.http.HttpServletRequest; + +public class ReqUtils { + private static final String dbPath = null; + + /** + * 获取用户真实IP地址,不使用request.getRemoteAddr();的原因是有可能用户使用了代理软件方式避免真实IP地址, + * 可是,如果通过了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP值,究竟哪个才是真正的用户端的真实IP呢? + * 答案是取X-Forwarded-For中第一个非unknown的有效IP字符串。 + * 如:X-Forwarded-For:192.168.1.110, 192.168.1.120, 192.168.1.130, 192.168.1.100 + * 用户真实IP为: 192.168.1.110 + * + * @param request + * @return + */ + public static String getIpAddress(HttpServletRequest request) {// 获取客户端ip地址 + String clientIp = request.getHeader("x-forwarded-for"); + + if (clientIp == null || clientIp.length() == 0 || "unknown".equalsIgnoreCase(clientIp)) { + clientIp = request.getHeader("Proxy-Client-IP"); + } + if (clientIp == null || clientIp.length() == 0 || "unknown".equalsIgnoreCase(clientIp)) { + clientIp = request.getHeader("WL-Proxy-Client-IP"); + } + if (clientIp == null || clientIp.length() == 0 || "unknown".equalsIgnoreCase(clientIp)) { + clientIp = request.getRemoteAddr(); + } + /* + * 对于获取到多ip的情况下,找到公网ip. + */ + String sIP = null; + if (clientIp != null && !clientIp.contains("unknown") && clientIp.indexOf(",") > 0) { + String[] ipsz = clientIp.split(","); + for (String anIpsz : ipsz) { + if (!isInnerIP(anIpsz.trim())) { + sIP = anIpsz.trim(); + break; + } + } + /* + * 如果多ip都是内网ip,则取第一个ip. + */ + if (null == sIP) { + sIP = ipsz[0].trim(); + } + clientIp = sIP; + } + if (clientIp != null && clientIp.contains("unknown")) { + clientIp = clientIp.replaceAll("unknown,", ""); + clientIp = clientIp.trim(); + } + if ("".equals(clientIp) || null == clientIp) { + clientIp = "127.0.0.1"; + } + return clientIp; + } + + /** + * 判断IP是否是内网地址 + * + * @param ipAddress ip地址 + * @return 是否是内网地址 + */ + public static boolean isInnerIP(String ipAddress) { + boolean isInnerIp; + long ipNum = getIpNum(ipAddress); + /** + 私有IP:A类 10.0.0.0-10.255.255.255 + B类 172.16.0.0-172.31.255.255 + C类 192.168.0.0-192.168.255.255 + 当然,还有127这个网段是环回地址 + **/ + long aBegin = getIpNum("10.0.0.0"); + long aEnd = getIpNum("10.255.255.255"); + + long bBegin = getIpNum("172.16.0.0"); + long bEnd = getIpNum("172.31.255.255"); + + long cBegin = getIpNum("192.168.0.0"); + long cEnd = getIpNum("192.168.255.255"); + isInnerIp = isInner(ipNum, aBegin, aEnd) || isInner(ipNum, bBegin, bEnd) || isInner(ipNum, cBegin, cEnd) + || ipAddress.equals("127.0.0.1"); + return isInnerIp; + } + + private static long getIpNum(String ipAddress) { + String[] ip = ipAddress.split("\\."); + long a = Integer.parseInt(ip[0]); + long b = Integer.parseInt(ip[1]); + long c = Integer.parseInt(ip[2]); + long d = Integer.parseInt(ip[3]); + + return a * 256 * 256 * 256 + b * 256 * 256 + c * 256 + d; + } + + private static boolean isInner(long userIp, long begin, long end) { + return (userIp >= begin) && (userIp <= end); + } + + public static String getRealIP(HttpServletRequest request) { + // 获取客户端ip地址 + String clientIp = request.getHeader("x-forwarded-for"); + + if (clientIp == null || clientIp.length() == 0 || "unknown".equalsIgnoreCase(clientIp)) { + clientIp = request.getRemoteAddr(); + } + + String[] clientIps = clientIp.split(","); + if (clientIps.length <= 1) return clientIp.trim(); + + // 判断是否来自CDN + if (isComefromCDN(request)) { + if (clientIps.length >= 2) return clientIps[clientIps.length - 2].trim(); + } + + return clientIps[clientIps.length - 1].trim(); + } + + private static boolean isComefromCDN(HttpServletRequest request) { + String host = request.getHeader("host"); + return host.contains("www.189.cn") || + host.contains("shouji.189.cn") || + host.contains("image2.chinatelecom-ec.com") || + host.contains("image1.chinatelecom-ec.com"); + } +} diff --git a/src/main/java/com/whdc/zhdbaqapi/utils/ResultJson.java b/src/main/java/com/whdc/utils/ResultJson.java similarity index 95% rename from src/main/java/com/whdc/zhdbaqapi/utils/ResultJson.java rename to src/main/java/com/whdc/utils/ResultJson.java index 2c40d72..9e2ddc2 100644 --- a/src/main/java/com/whdc/zhdbaqapi/utils/ResultJson.java +++ b/src/main/java/com/whdc/utils/ResultJson.java @@ -1,171 +1,171 @@ -package com.whdc.zhdbaqapi.utils; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.springframework.stereotype.Component; - -import java.io.Serializable; -import java.util.Date; - -@ApiModel(description = "数据传输对象") -@Component -@SuppressWarnings("all") -public class ResultJson implements Serializable { - - private static final long serialVersionUID = 1L; - /** - * 成功 - */ - public static final Integer SUCCESS = 200; - private static final String SUCCESS_MSG = "success"; - - /** - * 失败 - */ - public static final Integer FAIL = 900; - private static final String FAIL_MSG = "fail"; - - public static final Integer PARAM_ERROR = 400; // 失败、参数错误等 - public static final Integer UNAUTHORIZED = 401; // 用户验证失败,或者用户验证信息过期 - public static final Integer PERMISSION_DENIED = 403; // 没有权限 - public static final Integer NOT_FOUND = 404; // 未找到资源 - public static final Integer METHOD_NOT_ALLOWED = 405; // 不支持的类型 - public static final Integer NSUPPORTED_MEDIA_TYPE = 415; // 不支持的媒体 - public static final Integer NOT_ALLOWED = 405; // 请求太频繁,同一个用户(token)、同一个url、同样的请求参数,请求间隔小于0.5秒 - public static final Integer SERVER_ERROR = 500; // 后台错误 - public static final Integer SRC_TIMEOUT = 504; // 请求资源超时 - - - @ApiModelProperty("数据消息") - private String msg; - - @ApiModelProperty("传输状态码(200=成功;400=参数错误; 500=后端错误;900=失败)") - private Integer code; - - @ApiModelProperty("传输数据") - private T data; - - @ApiModelProperty("接口响应时间戳") - private String restm; // 接口响应时间戳。如果有缓存,则该时间表示最后接口响应时间 - - public static ResultJson error() { - return error(FAIL, "未知异常,请联系管理员"); - } - - public static ResultJson error(String msg) { - return error(FAIL, msg); - } - - public static ResultJson error(int code, String msg) { - ResultJson r = new ResultJson(); - r.setCode(code); - r.setMsg(msg); - r.setRestm(DateUtils.sdfhmsS.get().format(new Date())); - return r; - } - - public static ResultJson error(int code, String msg, Object data) { - ResultJson r = new ResultJson(); - r.setCode(code); - r.setMsg(msg); - r.setData(data); - r.setRestm(DateUtils.sdfhmsS.get().format(new Date())); - return r; - } - - public static ResultJson ok(Integer code, String msg) { - ResultJson r = new ResultJson(); - r.setMsg(msg); - r.setCode(code); - r.setRestm(DateUtils.sdfhmsS.get().format(new Date())); - return r; - } - - public static ResultJson ok() { - ResultJson r = new ResultJson(); - r.setCode(SUCCESS); - r.setMsg(SUCCESS_MSG); - r.setRestm(DateUtils.sdfhmsS.get().format(new Date())); - return r; - } - - public static ResultJson ok(Object data) { - ResultJson r = new ResultJson(); - r.setCode(SUCCESS); - r.setMsg(SUCCESS_MSG); - r.setData(data); - r.setRestm(DateUtils.sdfhmsS.get().format(new Date())); - return r; - } - - public static ResultJson ok(Object data, String msg) { - ResultJson r = new ResultJson(); - r.setData(data); - r.setCode(SUCCESS); - r.setMsg(msg); - r.setRestm(DateUtils.sdfhmsS.get().format(new Date())); - return r; - } - - public String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } - - public Integer getCode() { - return code; - } - - public void setCode(Integer code) { - this.code = code; - } - - public T getData() { - return data; - } - - public void setData(T data) { - this.data = data; - } - - public static long getSerialVersionUID() { - return serialVersionUID; - } - - public static Integer getSUCCESS() { - return SUCCESS; - } - - public static String getSuccessMsg() { - return SUCCESS_MSG; - } - - public static Integer getFAIL() { - return FAIL; - } - - public static String getFailMsg() { - return FAIL_MSG; - } - - public String getRestm() { - return restm; - } - - public void setRestm(String restm) { - this.restm = restm; - } - - @Override - public String toString() { - return "ResultJson{" + - "msg='" + msg + "'" + - ", code=" + code + - ", data=" + data + - ", restm=" + restm + - '}'; - } -} +package com.whdc.utils; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.springframework.stereotype.Component; + +import java.io.Serializable; +import java.util.Date; + +@ApiModel(description = "数据传输对象") +@Component +@SuppressWarnings("all") +public class ResultJson implements Serializable { + + private static final long serialVersionUID = 1L; + /** + * 成功 + */ + public static final Integer SUCCESS = 200; + private static final String SUCCESS_MSG = "success"; + + /** + * 失败 + */ + public static final Integer FAIL = 900; + private static final String FAIL_MSG = "fail"; + + public static final Integer PARAM_ERROR = 400; // 失败、参数错误等 + public static final Integer UNAUTHORIZED = 401; // 用户验证失败,或者用户验证信息过期 + public static final Integer PERMISSION_DENIED = 403; // 没有权限 + public static final Integer NOT_FOUND = 404; // 未找到资源 + public static final Integer METHOD_NOT_ALLOWED = 405; // 不支持的类型 + public static final Integer NSUPPORTED_MEDIA_TYPE = 415; // 不支持的媒体 + public static final Integer NOT_ALLOWED = 405; // 请求太频繁,同一个用户(token)、同一个url、同样的请求参数,请求间隔小于0.5秒 + public static final Integer SERVER_ERROR = 500; // 后台错误 + public static final Integer SRC_TIMEOUT = 504; // 请求资源超时 + + + @ApiModelProperty("数据消息") + private String msg; + + @ApiModelProperty("传输状态码(200=成功;400=参数错误; 500=后端错误;900=失败)") + private Integer code; + + @ApiModelProperty("传输数据") + private T data; + + @ApiModelProperty("接口响应时间戳") + private String restm; // 接口响应时间戳。如果有缓存,则该时间表示最后接口响应时间 + + public static ResultJson error() { + return error(FAIL, "未知异常,请联系管理员"); + } + + public static ResultJson error(String msg) { + return error(FAIL, msg); + } + + public static ResultJson error(int code, String msg) { + ResultJson r = new ResultJson(); + r.setCode(code); + r.setMsg(msg); + r.setRestm(DateUtils.sdfhmsS.get().format(new Date())); + return r; + } + + public static ResultJson error(int code, String msg, Object data) { + ResultJson r = new ResultJson(); + r.setCode(code); + r.setMsg(msg); + r.setData(data); + r.setRestm(DateUtils.sdfhmsS.get().format(new Date())); + return r; + } + + public static ResultJson ok(Integer code, String msg) { + ResultJson r = new ResultJson(); + r.setMsg(msg); + r.setCode(code); + r.setRestm(DateUtils.sdfhmsS.get().format(new Date())); + return r; + } + + public static ResultJson ok() { + ResultJson r = new ResultJson(); + r.setCode(SUCCESS); + r.setMsg(SUCCESS_MSG); + r.setRestm(DateUtils.sdfhmsS.get().format(new Date())); + return r; + } + + public static ResultJson ok(Object data) { + ResultJson r = new ResultJson(); + r.setCode(SUCCESS); + r.setMsg(SUCCESS_MSG); + r.setData(data); + r.setRestm(DateUtils.sdfhmsS.get().format(new Date())); + return r; + } + + public static ResultJson ok(Object data, String msg) { + ResultJson r = new ResultJson(); + r.setData(data); + r.setCode(SUCCESS); + r.setMsg(msg); + r.setRestm(DateUtils.sdfhmsS.get().format(new Date())); + return r; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } + + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public static Integer getSUCCESS() { + return SUCCESS; + } + + public static String getSuccessMsg() { + return SUCCESS_MSG; + } + + public static Integer getFAIL() { + return FAIL; + } + + public static String getFailMsg() { + return FAIL_MSG; + } + + public String getRestm() { + return restm; + } + + public void setRestm(String restm) { + this.restm = restm; + } + + @Override + public String toString() { + return "ResultJson{" + + "msg='" + msg + "'" + + ", code=" + code + + ", data=" + data + + ", restm=" + restm + + '}'; + } +} diff --git a/src/main/java/com/whdc/valid/component/RuleRedisService.java b/src/main/java/com/whdc/valid/component/RuleRedisService.java new file mode 100644 index 0000000..1a37f7e --- /dev/null +++ b/src/main/java/com/whdc/valid/component/RuleRedisService.java @@ -0,0 +1,82 @@ +package com.whdc.valid.component; + +import com.alibaba.fastjson.JSON; +import com.whdc.valid.mapper.ValidateMapper; +import com.whdc.valid.model.ValidateVo; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.stream.Collectors; + +@Slf4j +@Component("ruleRedis") +public class RuleRedisService { + + + private static final String VALIDATE_REDIS_KEY = "validate:"; + + + @Autowired + private RedisTemplate ruleRedisTemplate; + + public List getRule(String stcd,ValidateMapper validateMapper) { + + log.info("获取规则: " + stcd); + + String key = VALIDATE_REDIS_KEY + stcd; + + if (Boolean.TRUE.equals(ruleRedisTemplate.hasKey(key))) { + + List json = ruleRedisTemplate.opsForList().range(key, 0, -1); + + if (CollectionUtils.isNotEmpty(json)) { + return + json.stream() + .filter(StringUtils::isNotBlank) + .map(s -> JSON.toJavaObject(JSON.parseObject(s), ValidateVo.class)) + .collect(Collectors.toList()); + } + } + + List rules = validateMapper.getRuleByStcd(stcd); + + + log.info("保存规则: " + rules.size()); + + if (CollectionUtils.isNotEmpty(rules)) { + Long aLong = ruleRedisTemplate.opsForList().rightPushAll(key, rules.stream().map(JSON::toJSONString).collect(Collectors.toList())); + + if (aLong != rules.size()) { + log.info("保存规则失败: " + key + "_" + rules.size()); + } + } else { + ruleRedisTemplate.opsForList().rightPushAll(key, ""); + } + + return rules; + } + + public void delRule(String stcd){ + + if (StringUtils.isBlank(stcd)){ + return; + } + + String key = VALIDATE_REDIS_KEY + stcd; + + if (Boolean.TRUE.equals(ruleRedisTemplate.hasKey(key))) { + + Boolean delete = ruleRedisTemplate.delete(key); + if (!Boolean.TRUE.equals(delete)) { + + log.info("删除失败, 主键: {}" ,key); + + } + } + } +} \ No newline at end of file diff --git a/src/main/java/com/whdc/valid/conf/MapperScanConfig.java b/src/main/java/com/whdc/valid/conf/MapperScanConfig.java new file mode 100644 index 0000000..0bc3cff --- /dev/null +++ b/src/main/java/com/whdc/valid/conf/MapperScanConfig.java @@ -0,0 +1,10 @@ +package com.whdc.valid.conf; + + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@MapperScan("com.whdc.valid.mapper") +public class MapperScanConfig { +} diff --git a/src/main/java/com/whdc/valid/conf/RuleRestTemplateConfig.java b/src/main/java/com/whdc/valid/conf/RuleRestTemplateConfig.java new file mode 100644 index 0000000..c3f5811 --- /dev/null +++ b/src/main/java/com/whdc/valid/conf/RuleRestTemplateConfig.java @@ -0,0 +1,118 @@ +package com.whdc.valid.conf; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.PropertyAccessor; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.pool2.impl.GenericObjectPoolConfig; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisStandaloneConfiguration; +import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration; +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; +import org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.RedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +import java.time.Duration; + +/** + * @author xusan + * @date 2023年9月8日11:09:47 + */ +@Configuration +public class RuleRestTemplateConfig { + + /** + + # 数据清洗专用redis + redisRules: + database: 0 + host: 127.0.0.1 + port: 6379 + password: + timeout: 60000 + lettuce: + pool: + max-active: 50 + max-idle: 50 + min-idle: 1 + max-wait: 50000 + + */ + + + @Value("${spring.redisRules.host}") + private String host; + + @Value("${spring.redisRules.port}") + private Integer port; + + @Value("${spring.redisRules.password}") + private String password; + + @Value("${spring.redisRules.database}") + private int database; + + @Value("${spring.redisRules.lettuce.pool.max-active}") + private String maxActive; + + @Value("${spring.redisRules.lettuce.pool.max-idle}") + private String maxIdle; + + @Value("${spring.redisRules.lettuce.pool.min-idle}") + private String minIdle; + + @Value("${spring.redisRules.lettuce.pool.max-wait}") + private String maxWait; + + @Value("${spring.redisRules.timeout}") + private String timeOut; + + + private LettuceConnectionFactory getConnectionOneFactory() { + RedisStandaloneConfiguration redisStandaloneConfiguration = + new RedisStandaloneConfiguration(); + redisStandaloneConfiguration.setHostName(host); + redisStandaloneConfiguration.setDatabase(database); + redisStandaloneConfiguration.setPassword(password); + redisStandaloneConfiguration.setPort(port); + + GenericObjectPoolConfig genericObjectPoolConfig = + new GenericObjectPoolConfig(); + genericObjectPoolConfig.setMaxIdle(Integer.parseInt(maxIdle)); + genericObjectPoolConfig.setMinIdle(Integer.parseInt(minIdle)); + genericObjectPoolConfig.setMaxTotal(Integer.parseInt(maxActive)); + genericObjectPoolConfig.setMaxWait(Duration.ofMillis(Integer.parseInt(maxWait))); + LettucePoolingClientConfiguration.LettucePoolingClientConfigurationBuilder + builder = LettucePoolingClientConfiguration.builder(). + commandTimeout(Duration.ofMillis(Integer.parseInt(timeOut))); + builder.poolConfig(genericObjectPoolConfig); + LettuceClientConfiguration lettuceClientConfiguration = builder.build(); + //根据配置和客户端配置创建连接 + LettuceConnectionFactory lettuceConnectionFactory = new + LettuceConnectionFactory(redisStandaloneConfiguration,lettuceClientConfiguration); + lettuceConnectionFactory .afterPropertiesSet(); + return lettuceConnectionFactory; + } + + @Bean("ruleRedisTemplate") + public RedisTemplate ruleRedisTemplate() { + LettuceConnectionFactory connectionFactory = getConnectionOneFactory(); + RedisTemplate redisTemplate = new RedisTemplate<>(); + redisTemplate.setConnectionFactory(connectionFactory); + Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); + ObjectMapper om = new ObjectMapper(); + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + jackson2JsonRedisSerializer.setObjectMapper(om); + RedisSerializer stringSerializer = new StringRedisSerializer(); + redisTemplate.setKeySerializer(stringSerializer); + redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer); + redisTemplate.afterPropertiesSet(); + redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); + redisTemplate.setHashKeySerializer(stringSerializer); + return redisTemplate; + } +} diff --git a/src/main/java/com/whdc/valid/error/MyException.java b/src/main/java/com/whdc/valid/error/MyException.java new file mode 100644 index 0000000..b295749 --- /dev/null +++ b/src/main/java/com/whdc/valid/error/MyException.java @@ -0,0 +1,29 @@ +package com.whdc.valid.error; + +/** + * @author 李赛 + * @date 2022-06-26 10:58 + */ + +public class MyException extends RuntimeException { + + private final String msg; + + public String getMsg() { + return msg; + } + + public MyException(String msg) { + super(msg); + this.msg = msg; + } + + public MyException(String msg, Throwable e) { + super(msg, e); + this.msg = msg; + } + + public static MyException getException(String msg) { + return new MyException(msg); + } +} diff --git a/src/main/java/com/whdc/valid/mapper/ValidateMapper.java b/src/main/java/com/whdc/valid/mapper/ValidateMapper.java new file mode 100644 index 0000000..40c5827 --- /dev/null +++ b/src/main/java/com/whdc/valid/mapper/ValidateMapper.java @@ -0,0 +1,24 @@ +package com.whdc.valid.mapper; + +import com.whdc.valid.model.ValidateVo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +/** + * @author XuSan + */ +@Mapper +public interface ValidateMapper { + + /** + * stcd 查询 规则 + * @param stcd + * @return + */ + @Select("SELECT E.ITEM,E.MIN,E.MAX,E.DIFF_MAX,E.DURATION,E.LEADING_TIME,E.LAG_TIME,T.SORT FROM E_STATION_RULES T LEFT JOIN E_RULE E ON T.RULE_ID = E.ID WHERE T.DEL = 1 AND E.DEL = 1 AND T.STCD = #{stcd} ORDER BY T.SORT ASC;") + List getRuleByStcd(String stcd); + + +} diff --git a/src/main/java/com/whdc/valid/model/ValidateDto.java b/src/main/java/com/whdc/valid/model/ValidateDto.java new file mode 100644 index 0000000..eaefe1d --- /dev/null +++ b/src/main/java/com/whdc/valid/model/ValidateDto.java @@ -0,0 +1,49 @@ +package com.whdc.valid.model; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author xusan + * @date 2023年3月20日08:57:22 + */ +@Data +public class ValidateDto implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "测站编码", dataType = "java.lang.String") + private String stcd; + + @ApiModelProperty(value = "所在区域", dataType = "java.lang.String") + private String countyCode; + + @ApiModelProperty(value = "监测时间", dataType = "java.lang.Date") + private Date tm; + + private Data data; + + @lombok.Data + public static class Data { + + /** + * 雨量 + */ + private BigDecimal p; + + /** + * 水位 + */ + private BigDecimal q; + + /** + * 流量 + */ + private BigDecimal z; + + } +} diff --git a/src/main/java/com/whdc/valid/model/ValidateVo.java b/src/main/java/com/whdc/valid/model/ValidateVo.java new file mode 100644 index 0000000..c218635 --- /dev/null +++ b/src/main/java/com/whdc/valid/model/ValidateVo.java @@ -0,0 +1,80 @@ +package com.whdc.valid.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.annotations.ApiParam; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @author 李赛 + * @date 2022-06-26 10:43 + */ +@Data +@Accessors(chain = true) // chain = true 实现链式调用 +@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性 +public class ValidateVo implements Serializable { + + private static final long serialVersionUID = 1L; + + + /** + * 测站类型 + */ + @ApiParam(value = "规则类型", required = true, example = "") + @ApiModelProperty(value = "规则类型", required = true, dataType = "String") + private String item; + + + /** + * 最小值 + */ + @ApiParam(value = "最小值", required = false, example = "") + @ApiModelProperty(value = "最小值", required = false, dataType = "String") + private BigDecimal min; + + /** + * 最大值 + */ + @ApiParam(value = "最大值", required = false, example = "") + @ApiModelProperty(value = "最大值", required = false, dataType = "String") + private BigDecimal max; + + /** + * 最大值 + */ + @ApiParam(value = "两条数据之间的最大差值", required = false, example = "") + @ApiModelProperty(value = "两条数据之间的最大差值", required = false, dataType = "String") + private BigDecimal diffMax; + + /** + * 接收超出时间,单位: s ,指接收时间超前范围 + */ + @ApiParam(value = "接收超前时间,单位: s ,指接收时间超前范围", required = false, example = "") + @ApiModelProperty(value = "接收超前时间,单位: s ,指接收时间超前范围", required = false, dataType = "Integer") + private Integer leadingTime; + + /** + * 接收滞后时间,单位: s ,指接收时间滞后范围 + */ + @ApiParam(value = "接收滞后时间,单位: s ,指接收时间滞后范围", required = false, example = "") + @ApiModelProperty(value = "接收滞后时间,单位: s ,指接收时间滞后范围", required = false, dataType = "Integer") + private Integer lagTime; + + /** + * 最大值 + */ + @ApiParam(value = "时间段, 单位 s", required = false, example = "") + @ApiModelProperty(value = "时间段, 单位 s", required = false, dataType = "Integer") + private Integer duration; + + + @ApiParam(value = "排序", required = false, example = "") + @ApiModelProperty(value = "排序", required = false, dataType = "Integer") + private Integer sort; + + +} diff --git a/src/main/java/com/whdc/valid/service/ValidateService.java b/src/main/java/com/whdc/valid/service/ValidateService.java new file mode 100644 index 0000000..5a24a69 --- /dev/null +++ b/src/main/java/com/whdc/valid/service/ValidateService.java @@ -0,0 +1,10 @@ +package com.whdc.valid.service; + +public interface ValidateService { + + Boolean validate(String json); + + Boolean validate(String json,String prevJson); + + Boolean needPrev(String json); +} diff --git a/src/main/java/com/whdc/valid/service/ValidateServiceImpl.java b/src/main/java/com/whdc/valid/service/ValidateServiceImpl.java new file mode 100644 index 0000000..efbfada --- /dev/null +++ b/src/main/java/com/whdc/valid/service/ValidateServiceImpl.java @@ -0,0 +1,526 @@ +package com.whdc.valid.service; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONException; +import com.alibaba.fastjson.JSONObject; +import com.whdc.model.bean.ItemType; +import com.whdc.valid.component.RuleRedisService; +import com.whdc.valid.mapper.ValidateMapper; +import com.whdc.valid.model.ValidateDto; +import com.whdc.valid.model.ValidateVo; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +import static com.whdc.model.bean.ItemType.getByValue; +import static com.whdc.valid.error.MyException.getException; + + +@Slf4j +@Service +public class ValidateServiceImpl implements ValidateService { + + @Autowired + private ValidateMapper validateMapper; + + @Autowired + private RuleRedisService ruleRedis; + + /** + * 正常值判断 + * + * @param json + * @return true: 通过 false: 不通过 + */ + public Boolean validate(String json) { + return validate(json, null); + } + + /** + * 弃用 + * + * @param json + * @return + */ + public Boolean validateV1(String json) { + + ValidateDto dto = getValidateDto(json); //正常值 + + ValidateDto.Data data = dto.getData(); + BigDecimal p = data.getP(); + BigDecimal z = data.getZ(); + BigDecimal q = data.getQ(); + + if (BigDecimal.ZERO.compareTo(p) < 0 + && BigDecimal.ZERO.compareTo(z) < 0 + && BigDecimal.ZERO.compareTo(q) < 0 + ) { + return false; + } + + List rule = ruleRedis.getRule(dto.getStcd(), validateMapper); + if (CollectionUtils.isEmpty(rule)) { + return true; + } + +// Map> items = rule.stream() +// .collect(Collectors.groupingBy(ValidateVo::getItem)); +// +// List rules = new ArrayList<>(); +// +// if (Objects.nonNull(p)) { +// List list = items.get("P"); +// if (CollectionUtils.isNotEmpty(list)) { +// rules.addAll(list); +// } +// } +// if (Objects.nonNull(z)) { +// List list = items.get("Z"); +// if (CollectionUtils.isNotEmpty(list)) { +// rules.addAll(list); +// } +// } +// if (Objects.nonNull(q)) { +// List list = items.get("Q"); +// if (CollectionUtils.isNotEmpty(list)) { +// rules.addAll(list); +// } +// } +// if (CollectionUtils.isEmpty(rules)) { +// return true; +// } + + + Date tm = dto.getTm(); + long currentTime = System.currentTimeMillis(); + + + for (ValidateVo vo : rule) { + + BigDecimal min = vo.getMin(); + BigDecimal max = vo.getMax(); + Integer leadingTime = vo.getLeadingTime(); + Integer lagTime = vo.getLagTime(); + + if (Objects.nonNull(leadingTime)) { + if (tm.getTime() > currentTime + (leadingTime * 1000)) { + return false; + } + } + + if (Objects.nonNull(lagTime)) { + if (tm.getTime() < currentTime - (lagTime * 1000)) { + return false; + } + } + + String item = vo.getItem(); + + if (StringUtils.isBlank(item)) { + continue; + } + + if (Objects.isNull(min) && Objects.isNull(max) && Objects.isNull(leadingTime) && Objects.isNull(lagTime)) { + continue; + } + + ItemType itemType = getByValue(item); + + if (Objects.isNull(itemType)) { + continue; + } + + switch (itemType) { + case YU_LIANG: { // 雨量判断 P + if (!rangeRuleValidate(p, min, max)) { + return false; + } + + break; + } + case SHUI_WEI: { // 水位判断 Z + + if (!rangeRuleValidate(z, min, max)) { + return false; + } + + break; + } + case LIU_LIANG: { // 流量判断 Q + + if (!rangeRuleValidate(q, min, max)) { + return false; + } + + break; + } + default: { + } + } + + } + + + return true; + } + + private Boolean rangeRuleValidate(BigDecimal value, BigDecimal min, BigDecimal max) { + + if (Objects.nonNull(value)) { + + if (Objects.nonNull(min) && value.compareTo(min) < 0) { + log.info("对比值小于最小值: {} < {}", value, min); + return false; + } + + if (Objects.nonNull(max) && value.compareTo(max) > 0) { + log.info("对比值大于最大值: {} < {}", max, value); + return false; + } + + } + + return true; + } + + /** + * 判断差值 + * + * @param json + * @param prevJson + * @return true: 通过 false: 不通过 + */ + public Boolean validate(String json, String prevJson) { + + ValidateDto dto = getValidateDto(json); //正常值 + ValidateDto prevDto = null; + + if (StringUtils.isNotBlank(prevJson)) { + + prevDto = getValidateDto(prevJson); // 老差值 + } + + ValidateDto.Data data = dto.getData(); + BigDecimal p = data.getP(); + BigDecimal z = data.getZ(); + BigDecimal q = data.getQ(); + + if (BigDecimal.ZERO.compareTo(p) < 0 + && BigDecimal.ZERO.compareTo(z) < 0 + && BigDecimal.ZERO.compareTo(q) < 0 + ) { + log.info("对比值小于0: {} {} {}", p, z, q); + + return false; + } + + List rule = ruleRedis.getRule(dto.getStcd(), validateMapper); + if (CollectionUtils.isEmpty(rule)) { + log.info("规则为空: {}", rule); + return true; + } + + + Date tm = dto.getTm(); + long currentTime = System.currentTimeMillis(); + + + for (ValidateVo vo : rule) { + + BigDecimal min = vo.getMin(); + BigDecimal max = vo.getMax(); + Integer leadingTime = vo.getLeadingTime(); + Integer lagTime = vo.getLagTime(); + String item = vo.getItem(); + ItemType itemType = getByValue(item); + + if (Objects.nonNull(min) && Objects.nonNull(max) && Objects.nonNull(leadingTime) && Objects.nonNull(lagTime)) { + if (Objects.nonNull(leadingTime)) { + long time = currentTime + (leadingTime * 1000); + if (tm.getTime() > time) { + log.info("时间大于最大差值时间: {} > {}", tm.getTime(), time); + return false; + } + } + + if (Objects.nonNull(lagTime)) { + long time = currentTime - (lagTime * 1000); + if (tm.getTime() < time) { + log.info("时间小于最小差值时间: {} < {}", tm.getTime(), time); + return false; + } + } + + + if (StringUtils.isBlank(item)) { + log.info("规则类型为空"); + continue; + } + + + if (Objects.isNull(itemType)) { + continue; + } + + switch (itemType) { + case YU_LIANG: { // 雨量判断 P + if (!rangeRuleValidate(p, min, max)) { + return false; + } + + break; + } + case SHUI_WEI: { // 水位判断 Z + + if (!rangeRuleValidate(z, min, max)) { + return false; + } + + break; + } + case LIU_LIANG: { // 流量判断 Q + + if (!rangeRuleValidate(q, min, max)) { + return false; + } + + break; + } + default: { + } + } + } + + + if (Objects.isNull(prevDto)) { + continue; + } + + ValidateDto.Data oldData = prevDto.getData(); + + BigDecimal oldP = oldData.getP(); + BigDecimal oldZ = oldData.getZ(); + BigDecimal oldQ = oldData.getQ(); + + if (BigDecimal.ZERO.compareTo(oldP) < 0 + && BigDecimal.ZERO.compareTo(oldZ) < 0 + && BigDecimal.ZERO.compareTo(oldQ) < 0 + ) { + return false; + } + + // 获取时间 + Date oldTm = prevDto.getTm(); + + BigDecimal diffMax = vo.getDiffMax(); + Integer duration = vo.getDuration(); + + if (Objects.nonNull(duration)) { + + if (Math.abs(tm.getTime() - oldTm.getTime()) > duration * 1000) { + continue; + } + + + if (Objects.isNull(itemType)) { + continue; + } + + switch (itemType) { + case YU_LIANG: { // 雨量判断 P + if (Objects.nonNull(p) && Objects.nonNull(oldP) && Math.abs(p.subtract(oldP).doubleValue()) > diffMax.doubleValue()) { + return false; + } + + break; + } + case SHUI_WEI: { // 水位判断 Z + + if (Objects.nonNull(z) && Objects.nonNull(oldZ) && Math.abs(z.subtract(oldZ).doubleValue()) > diffMax.doubleValue()) { + return false; + } + + break; + } + case LIU_LIANG: { // 流量判断 Q + + if (Objects.nonNull(q) && Objects.nonNull(oldQ) && Math.abs(q.subtract(oldQ).doubleValue()) > diffMax.doubleValue()) { + return false; + } + + + break; + } + default: { + } + } + + } + } + + return true; + + } + + public Boolean validateV1(String json, String prevJson) { + + if (!validate(json)) { // 正常值判断 + return false; + } + + ValidateDto dto = getValidateDto(json); // 差值 + + List rule = ruleRedis.getRule(dto.getStcd(), validateMapper); + if (CollectionUtils.isEmpty(rule)) { + return true; + } + + + ValidateDto prevDto = getValidateDto(prevJson); // 老差值 + + + ValidateDto.Data data = dto.getData(); + + BigDecimal p = data.getP(); + BigDecimal z = data.getZ(); + BigDecimal q = data.getQ(); + + if (BigDecimal.ZERO.compareTo(p) < 0 + && BigDecimal.ZERO.compareTo(z) < 0 + && BigDecimal.ZERO.compareTo(q) < 0 + ) { + return false; + } + + ValidateDto.Data oldData = prevDto.getData(); + BigDecimal oldP = oldData.getP(); + BigDecimal oldZ = oldData.getZ(); + BigDecimal oldQ = oldData.getQ(); + + if (BigDecimal.ZERO.compareTo(oldP) < 0 + && BigDecimal.ZERO.compareTo(oldZ) < 0 + && BigDecimal.ZERO.compareTo(oldQ) < 0 + ) { + return false; + } + + + // 获取时间 + Date tm = dto.getTm(); + Date oldTm = prevDto.getTm(); + + for (ValidateVo vo : rule) { + + BigDecimal diffMax = vo.getDiffMax(); + Integer duration = vo.getDuration(); + + if (Objects.nonNull(duration)) { + + if (Math.abs(tm.getTime() - oldTm.getTime()) > duration * 1000) { + continue; + } + + if (Objects.nonNull(p) && Objects.nonNull(oldP) && Math.abs(p.subtract(oldP).doubleValue()) > diffMax.doubleValue()) { + return false; + } + if (Objects.nonNull(z) && Objects.nonNull(oldZ) && Math.abs(z.subtract(oldZ).doubleValue()) > diffMax.doubleValue()) { + return false; + } + if (Objects.nonNull(q) && Objects.nonNull(oldQ) && Math.abs(q.subtract(oldQ).doubleValue()) > diffMax.doubleValue()) { + return false; + } + + } + } + + return true; + } + + /** + * 判断是否需要传入多个值 + * + * @param json + * @return true: 需要, false: 不需要 + */ + public Boolean needPrev(String json) { + + ValidateDto dto = getValidateDto(json); // 多个值 + + List rule = ruleRedis.getRule(dto.getStcd(), validateMapper); + + if (CollectionUtils.isEmpty(rule)) { + + return false; + + } + + if (CollectionUtils.isEmpty( + + rule.stream().map(ValidateVo::getDiffMax) + + .filter(Objects::nonNull) + + .collect(Collectors.toList()) + + )) { + + return false; + + } + + + return true; + } + + + private ValidateDto getValidateDto(String json) { + JSONObject jsonObject; + try { + jsonObject = JSON.parseObject(json); + } catch (JSONException e) { + throw getException("格式错误: " + json); + } + + + if (Objects.isNull(jsonObject)) { + throw getException("空数据"); + } + + ValidateDto validateDto = JSON.toJavaObject(jsonObject, ValidateDto.class); + + if (Objects.isNull(validateDto.getStcd())) { + throw getException("编码不能为空"); + } + + Date tm = validateDto.getTm(); + if (Objects.isNull(tm)) { + throw getException("时间不能为空"); + } + + + ValidateDto.Data data = validateDto.getData(); + + if (Objects.isNull(data)) { + throw getException("数据不能为空"); + } else { + if (Objects.isNull(data.getP()) + && Objects.isNull(data.getQ()) + && Objects.isNull(data.getZ()) + ) { + throw getException("数据内容不能为空"); + } + } + + return validateDto; + } + + +} diff --git a/src/main/java/com/whdc/zhdbaqapi/component/ScheduledTask.java b/src/main/java/com/whdc/zhdbaqapi/component/ScheduledTask.java deleted file mode 100644 index b956dbd..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/component/ScheduledTask.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.whdc.zhdbaqapi.component; - -import com.whdc.zhdbaqapi.service.IDeviceDataService; -import com.whdc.zhdbaqapi.service.IDeviceSLDataService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -/** - * @author 李赛 - * @date 2022-07-22 1:04 - */ -@Component -public class ScheduledTask { - - @Autowired - private IDeviceDataService iDeviceDataService; - @Autowired - private IDeviceSLDataService iDeviceSLDataService; - @Scheduled(fixedDelay = 60000) - public void scheduledTask() { - String OS = System.getProperty("os.name").toLowerCase(); - - // 简单粗暴的判断,在 linux 环境下运行时,为生成环境 - if (OS.contains("linux")) { - iDeviceDataService.syncData(); - iDeviceSLDataService.syncData(); - } - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/component/StpInterfaceImpl.java b/src/main/java/com/whdc/zhdbaqapi/component/StpInterfaceImpl.java deleted file mode 100644 index 11e9be9..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/component/StpInterfaceImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.whdc.zhdbaqapi.component; - -/** - * @author 李赛 - * @date 2022-07-06 10:39 - */ - -import cn.dev33.satoken.stp.StpInterface; -import com.whdc.zhdbaqapi.model.entity.SysUser; -import com.whdc.zhdbaqapi.service.ISysUserService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; - -/** - * 自定义权限验证接口扩展 - */ -@Component // 保证此类被SpringBoot扫描,完成Sa-Token的自定义权限验证扩展 -public class StpInterfaceImpl implements StpInterface { - - @Autowired - private ISysUserService iSysUserService; - - @Override - public List getPermissionList(Object o, String s) { - return null; - } - - /** - * 返回一个账号所拥有的角色标识集合 (权限与角色可分开校验) - */ - @Override - public List getRoleList(Object loginId, String loginType) { - SysUser sysUser = iSysUserService.getById(Integer.valueOf(loginId.toString())); - - // 实际项目中要根据具体业务逻辑来查询角色 - List list = new ArrayList(); - - if(sysUser.getType() == 0){ - list.add("super-admin"); - }else if(sysUser.getType() == 1){ - list.add("admin"); - }else if(sysUser.getType() == 2){ - list.add("user"); - } - - return list; - } - -} \ No newline at end of file diff --git a/src/main/java/com/whdc/zhdbaqapi/config/SaTokenConfigure.java b/src/main/java/com/whdc/zhdbaqapi/config/SaTokenConfigure.java deleted file mode 100644 index 6a8d066..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/config/SaTokenConfigure.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.whdc.zhdbaqapi.config; - -import cn.dev33.satoken.interceptor.SaRouteInterceptor; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -/** - * @author 李赛 - * @date 2022-07-06 7:52 - */ -@Configuration -public class SaTokenConfigure implements WebMvcConfigurer { - // 注册拦截器 - @Override - public void addInterceptors(InterceptorRegistry registry) { - // 注册 Sa-Token 的路由拦截器 - registry.addInterceptor(new SaRouteInterceptor()) - .addPathPatterns("/**") - .excludePathPatterns("/socket.io**") - .excludePathPatterns("/doc.html**") - .excludePathPatterns("/swagger-resources") - .excludePathPatterns("/webjars/**") - .excludePathPatterns("/v3/api-docs**") - .excludePathPatterns("/v1/sysuser/doLogin") - .excludePathPatterns("/v1/auth/getToken") - .excludePathPatterns("/v1/sysuser/registerByToken"); - } -} \ No newline at end of file diff --git a/src/main/java/com/whdc/zhdbaqapi/constant/Constants.java b/src/main/java/com/whdc/zhdbaqapi/constant/Constants.java deleted file mode 100644 index b4a7968..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/constant/Constants.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.whdc.zhdbaqapi.constant; - -/** - * @author 李赛 - * @date 2022-07-17 10:18 - */ -public class Constants { - public static final String PASSWORD_SALT = "whdc"; - - - public static final String CACHE_NAME = "DeviceInfoListAll"; - public static final String CACHE_NAME_SL = "DeviceSLInfoListAll"; - -} diff --git a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceDataController.java b/src/main/java/com/whdc/zhdbaqapi/controller/DeviceDataController.java deleted file mode 100644 index 7c4d282..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceDataController.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.whdc.zhdbaqapi.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; -import com.whdc.zhdbaqapi.model.vo.DeviceDataVo; -import com.whdc.zhdbaqapi.service.IDeviceDataService; -import com.whdc.zhdbaqapi.utils.ResultJson; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author 李赛 - * @date 2022-07-22 0:47 - */ -@Api(tags = "设备数据 - Controller") -@RestController -@RequestMapping("/v1/deviceData") -public class DeviceDataController { - @Autowired - private IDeviceDataService iDeviceDataService; - - @ApiOperation(value = "分页查询") - @PostMapping(value = "/page") - public ResultJson> page(@RequestBody FindDeviceDto findDto) { - return ResultJson.ok(iDeviceDataService.page(findDto)); - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceGNSSController.java b/src/main/java/com/whdc/zhdbaqapi/controller/DeviceGNSSController.java deleted file mode 100644 index a8870ea..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceGNSSController.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.whdc.zhdbaqapi.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.mapper.DeviceGNSSMapper; -import com.whdc.zhdbaqapi.model.dto.FindPageDto; -import com.whdc.zhdbaqapi.model.dto.IntegerIdDto; -import com.whdc.zhdbaqapi.model.entity.DeviceGNSS; -import com.whdc.zhdbaqapi.model.entity.DeviceInfo; -import com.whdc.zhdbaqapi.utils.ResultJson; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@Api(tags = "GNSS设备信息 - Controller") -@RestController -@RequestMapping("/v1/deviceGNSSInfo") -@Slf4j -public class DeviceGNSSController { - @Autowired - private DeviceGNSSMapper deviceGNSSMapper; - - @ApiOperation(value = "新增") - @PostMapping("/save") - public ResultJson save(@RequestBody @Validated DeviceGNSS bean) { - return ResultJson.ok(deviceGNSSMapper.insert(bean) == 1); - } - - @ApiOperation(value = "删除") - @PostMapping("/del") - public ResultJson del(@RequestBody @Validated IntegerIdDto bean) { - return ResultJson.ok(deviceGNSSMapper.deleteById(bean.getId()) == 1); - } - - @ApiOperation(value = "修改") - @PostMapping("/edit") - public ResultJson edit(@RequestBody @Validated DeviceGNSS bean) { - return ResultJson.ok(deviceGNSSMapper.updateById(bean) == 1); - } - - @ApiOperation(value = "分页查询") - @PostMapping(value = "/page") - public ResultJson> page(@RequestBody FindPageDto findDto) { - return ResultJson.ok(deviceGNSSMapper.page(findDto.getPage())); - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceGNSSDataController.java b/src/main/java/com/whdc/zhdbaqapi/controller/DeviceGNSSDataController.java deleted file mode 100644 index 1b940ac..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceGNSSDataController.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.whdc.zhdbaqapi.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.mapper.DeviceGNSSDataMapper; -import com.whdc.zhdbaqapi.model.dto.FindPageDto; -import com.whdc.zhdbaqapi.model.entity.DeviceGNSSData; -import com.whdc.zhdbaqapi.model.entity.DeviceInfo; -import com.whdc.zhdbaqapi.utils.ResultJson; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@Api(tags = "GNSS设备信息 - Controller") -@RestController -@RequestMapping("/v1/deviceGNSSData") -@Slf4j -public class DeviceGNSSDataController { - @Autowired - private DeviceGNSSDataMapper deviceGNSSDataMapper; - - @ApiOperation(value = "分页查询") - @PostMapping(value = "/page") - public ResultJson> page(@RequestBody FindPageDto findDto) { - return ResultJson.ok(deviceGNSSDataMapper.page(findDto.getPage())); - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceInfoController.java b/src/main/java/com/whdc/zhdbaqapi/controller/DeviceInfoController.java deleted file mode 100644 index c1a624f..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceInfoController.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.whdc.zhdbaqapi.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; -import com.whdc.zhdbaqapi.model.dto.IntegerIdDto; -import com.whdc.zhdbaqapi.model.dto.StationCodeDto; -import com.whdc.zhdbaqapi.model.entity.DeviceInfo; -import com.whdc.zhdbaqapi.model.vo.DeviceInfoImpVo; -import com.whdc.zhdbaqapi.service.IDeviceInfoService; -import com.whdc.zhdbaqapi.utils.ResultJson; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; - -/** - * @author 李赛 - * @date 2022-07-21 23:58 - */ -@Api(tags = "设备信息 - Controller") -@RestController -@RequestMapping("/v1/deviceInfo") -@Slf4j -public class DeviceInfoController { - - @Autowired - private IDeviceInfoService iDeviceInfoService; - - @ApiOperation(value = "获取单个对象") - @PostMapping("/get") - public ResultJson get(@RequestBody @Validated IntegerIdDto idDto) { - return ResultJson.ok(iDeviceInfoService.get(idDto.getId())); - } - - @ApiOperation(value = "新增") - @PostMapping("/save") - public ResultJson save(@RequestBody @Validated DeviceInfo bean) { - return ResultJson.ok(iDeviceInfoService.save(bean)); - } - - @ApiOperation(value = "删除") - @PostMapping("/del") - public ResultJson del(@RequestBody @Validated IntegerIdDto bean) { - return ResultJson.ok(iDeviceInfoService.removeById(bean.getId())); - } - - @ApiOperation(value = "修改") - @PostMapping("/edit") - public ResultJson edit(@RequestBody @Validated DeviceInfo bean) { - return ResultJson.ok(iDeviceInfoService.updateById(bean)); - } - - @ApiOperation(value = "恢复") - @PostMapping("/restore") - public ResultJson edit(@RequestBody @Validated IntegerIdDto bean) { - return ResultJson.ok(iDeviceInfoService.restore(bean.getId())); - } - - @ApiOperation(value = "列表查询") - @PostMapping(value = "/list") - public ResultJson> list(@RequestBody StationCodeDto dto) { - return ResultJson.ok(iDeviceInfoService.list(dto.getStationCode())); - } - - @ApiOperation(value = "分页查询") - @PostMapping(value = "/page") - public ResultJson> page(@RequestBody FindDeviceDto findDto) { - return ResultJson.ok(iDeviceInfoService.page(findDto)); - } - - @ApiOperation(value = "Excel数据导入") - @PostMapping("/imp") - public ResultJson imp(@RequestParam(value = "file") @RequestPart MultipartFile file) throws Exception { - if (file == null) { - return ResultJson.error("无效文件"); - } - - return ResultJson.ok(iDeviceInfoService.imp(file.getInputStream())); - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceRobotController.java b/src/main/java/com/whdc/zhdbaqapi/controller/DeviceRobotController.java deleted file mode 100644 index 86fd9c8..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceRobotController.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.whdc.zhdbaqapi.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.mapper.DeviceRobotPointMapper; -import com.whdc.zhdbaqapi.model.dto.FindPageDto; -import com.whdc.zhdbaqapi.model.dto.IntegerIdDto; -import com.whdc.zhdbaqapi.model.entity.DeviceInfo; -import com.whdc.zhdbaqapi.model.entity.DeviceRobot; -import com.whdc.zhdbaqapi.utils.ResultJson; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.Date; - -@Api(tags = "变形机器人信息 - Controller") -@RestController -@RequestMapping("/v1/deviceRobotInfo") -@Slf4j -public class DeviceRobotController { - @Autowired - private DeviceRobotPointMapper deviceRobotPointMapper; - - @ApiOperation(value = "新增") - @PostMapping("/save/point") - public ResultJson save(@RequestBody @Validated DeviceRobot bean) { - bean.getPoint().setEpoch(new Date()); - return ResultJson.ok(deviceRobotPointMapper.insert(bean.getPoint()) == 1); - } - - @ApiOperation(value = "删除") - @PostMapping("/del/point") - public ResultJson del(@RequestBody @Validated IntegerIdDto bean) { - return ResultJson.ok(deviceRobotPointMapper.deleteById(bean.getId()) == 1); - } - - @ApiOperation(value = "修改") - @PostMapping("/edit/point") - public ResultJson edit(@RequestBody @Validated DeviceRobot bean) { - return ResultJson.ok(deviceRobotPointMapper.updateById(bean.getPoint()) == 1); - } - - @ApiOperation(value = "分页查询") - @PostMapping(value = "/page/point") - public ResultJson> page(@RequestBody FindPageDto findDto) { - return ResultJson.ok(deviceRobotPointMapper.page(findDto.getPage())); - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceRobotDataController.java b/src/main/java/com/whdc/zhdbaqapi/controller/DeviceRobotDataController.java deleted file mode 100644 index 7bd5d2a..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceRobotDataController.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.whdc.zhdbaqapi.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.mapper.DeviceRobotDataMapper; -import com.whdc.zhdbaqapi.model.dto.FindPageDto; -import com.whdc.zhdbaqapi.model.entity.DeviceGNSSData; -import com.whdc.zhdbaqapi.utils.ResultJson; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@Api(tags = "GNSS设备信息 - Controller") -@RestController -@RequestMapping("/v1/deviceRobotData") -@Slf4j -public class DeviceRobotDataController { - @Autowired - private DeviceRobotDataMapper deviceRobotDataMapper; - - @ApiOperation(value = "分页查询") - @PostMapping(value = "/page") - public ResultJson> page(@RequestBody FindPageDto findDto) { - return ResultJson.ok(deviceRobotDataMapper.page(findDto.getPage())); - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceSLDataController.java b/src/main/java/com/whdc/zhdbaqapi/controller/DeviceSLDataController.java deleted file mode 100644 index e664633..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceSLDataController.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.whdc.zhdbaqapi.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; -import com.whdc.zhdbaqapi.model.vo.DeviceDataVo; -import com.whdc.zhdbaqapi.service.IDeviceDataService; -import com.whdc.zhdbaqapi.service.IDeviceSLDataService; -import com.whdc.zhdbaqapi.utils.ResultJson; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author 李赛 - * @date 2022-07-22 0:47 - */ -@Api(tags = "设备数据 - Controller") -@RestController -@RequestMapping("/v1/deviceSLData") -public class DeviceSLDataController { - @Autowired - private IDeviceSLDataService iDeviceSLDataService; - - @ApiOperation(value = "分页查询") - @PostMapping(value = "/page") - public ResultJson> page(@RequestBody FindDeviceDto findDto) { - return ResultJson.ok(iDeviceSLDataService.page(findDto)); - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceSLInfoController.java b/src/main/java/com/whdc/zhdbaqapi/controller/DeviceSLInfoController.java deleted file mode 100644 index 820a638..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceSLInfoController.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.whdc.zhdbaqapi.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; -import com.whdc.zhdbaqapi.model.dto.IntegerIdDto; -import com.whdc.zhdbaqapi.model.dto.StationCodeDto; -import com.whdc.zhdbaqapi.model.entity.DeviceInfo; -import com.whdc.zhdbaqapi.model.entity.DeviceSLInfo; -import com.whdc.zhdbaqapi.model.vo.DeviceInfoImpVo; -import com.whdc.zhdbaqapi.service.IDeviceSLInfoService; -import com.whdc.zhdbaqapi.utils.ResultJson; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; - -/** - * @author 李赛 - * @date 2022-07-21 23:58 - */ -@Api(tags = "设备信息 - Controller") -@RestController -@RequestMapping("/v1/deviceSLInfo") -@Slf4j -public class DeviceSLInfoController { - - @Autowired - private IDeviceSLInfoService iDeviceSLInfoService; - - @ApiOperation(value = "获取单个对象") - @PostMapping("/get") - public ResultJson get(@RequestBody @Validated IntegerIdDto idDto) { - return ResultJson.ok(iDeviceSLInfoService.get(idDto.getId())); - } - - @ApiOperation(value = "新增") - @PostMapping("/save") - public ResultJson save(@RequestBody @Validated DeviceSLInfo bean) { - return ResultJson.ok(iDeviceSLInfoService.save(bean)); - } - - @ApiOperation(value = "删除") - @PostMapping("/del") - public ResultJson del(@RequestBody @Validated IntegerIdDto bean) { - return ResultJson.ok(iDeviceSLInfoService.removeById(bean.getId())); - } - - @ApiOperation(value = "修改") - @PostMapping("/edit") - public ResultJson edit(@RequestBody @Validated DeviceSLInfo bean) { - return ResultJson.ok(iDeviceSLInfoService.updateById(bean)); - } - - @ApiOperation(value = "恢复") - @PostMapping("/restore") - public ResultJson edit(@RequestBody @Validated IntegerIdDto bean) { - return ResultJson.ok(iDeviceSLInfoService.restore(bean.getId())); - } - - @ApiOperation(value = "列表查询") - @PostMapping(value = "/list") - public ResultJson> list(@RequestBody StationCodeDto dto) { - return ResultJson.ok(iDeviceSLInfoService.list(dto.getStationCode())); - } - - @ApiOperation(value = "分页查询") - @PostMapping(value = "/page") - public ResultJson> page(@RequestBody FindDeviceDto findDto) { - return ResultJson.ok(iDeviceSLInfoService.page(findDto)); - } - - @ApiOperation(value = "Excel数据导入") - @PostMapping("/imp") - public ResultJson imp(@RequestParam(value = "file") @RequestPart MultipartFile file) throws Exception { - if (file == null) { - return ResultJson.error("无效文件"); - } - - return ResultJson.ok(iDeviceSLInfoService.imp(file.getInputStream())); - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/controller/HomeController.java b/src/main/java/com/whdc/zhdbaqapi/controller/HomeController.java deleted file mode 100644 index 14442b4..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/controller/HomeController.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.whdc.zhdbaqapi.controller; - -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.github.xiaoymin.knife4j.annotations.ApiSupport; -import com.whdc.zhdbaqapi.utils.ResultJson; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author 李赛 - * @date 2022-06-26 0:24 - */ -@RestController -@ApiSupport(author = "李赛") -@Slf4j -public class HomeController { - - @ApiOperationSupport(author = "接口连通测试") - @GetMapping("/") - public ResultJson index() { - return ResultJson.ok("接口连通测试通过"); - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/controller/SysUserController.java b/src/main/java/com/whdc/zhdbaqapi/controller/SysUserController.java deleted file mode 100644 index a309e33..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/controller/SysUserController.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.whdc.zhdbaqapi.controller; - -import cn.dev33.satoken.stp.SaTokenInfo; -import cn.dev33.satoken.stp.StpUtil; -import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.model.dto.*; -import com.whdc.zhdbaqapi.model.entity.ForeignUserInfo; -import com.whdc.zhdbaqapi.model.entity.SysUser; -import com.whdc.zhdbaqapi.model.vo.AuthToken; -import com.whdc.zhdbaqapi.model.vo.LoginVo; -import com.whdc.zhdbaqapi.service.ISysUserService; -import com.whdc.zhdbaqapi.utils.HttpUtil; -import com.whdc.zhdbaqapi.utils.ResultJson; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.lang.reflect.InvocationTargetException; - -/** - * @author 李赛 - * @date 2022-06-26 10:58 - */ -@Api(tags = "用户信息 - Controller") -@RestController -@RequestMapping("/v1/sysuser") -public class SysUserController { - - @Autowired - private ISysUserService iSysUserService; - - @ApiOperation(value = "新增") - @PostMapping("/save") - public ResultJson save(@RequestBody @Validated SysUser bean) { - return ResultJson.ok(iSysUserService.save(bean)); - } - - @ApiOperation(value = "删除") - @PostMapping("/del") - public ResultJson del(@RequestBody @Validated IdDto bean) { - return ResultJson.ok(iSysUserService.removeById(bean.getId())); - } - - @ApiOperation(value = "修改") - @PostMapping("/edit") - public ResultJson edit(@RequestBody @Validated SysUser bean) { - return ResultJson.ok(iSysUserService.updateById(bean)); - } - - @ApiOperation(value = "分页查询") - @PostMapping(value = "/page") - public ResultJson> page(@RequestBody FindSysUserDto findDto) { - return ResultJson.ok(iSysUserService.page(findDto)); - } - - @ApiOperation(value = "登录", notes = "登录后,从 tokenInfo 中获取 token 相关信息。headers[tokenName] = tokenValue ") - @PostMapping("doLogin") - public ResultJson doLogin(@RequestBody @Validated LoginDto obj) throws InvocationTargetException, IllegalAccessException { - LoginVo loginVo = iSysUserService.login(obj); - - if (loginVo == null || loginVo.getId() == null) { - return ResultJson.error("登录失败"); - } else { - StpUtil.login(loginVo.getId()); // 使用 user id 登录 - - // 获取 Token 相关参数 - loginVo.setTokenInfo(new AuthToken(StpUtil.getTokenInfo())); - loginVo.setRoleList(StpUtil.getRoleList()); - - return ResultJson.ok(loginVo); - } - } - - @ApiOperation(value = "查询登录状态") - @PostMapping("isLogin") - public ResultJson isLogin() { - return ResultJson.ok(StpUtil.getTokenInfo()); - } - - @ApiOperation(value = "按id踢人下线") - @PostMapping("kickout") - public ResultJson kickout(@RequestBody IdDto idDto) { - StpUtil.kickout(idDto.getId()); - return ResultJson.ok("将用户[" + idDto.getId() + "]踢下线"); - } - - @ApiOperation(value = "token注册") - @PostMapping("registerByToken") - public ResultJson registerByToken(@RequestBody @Validated ForeignTokenDto dto) throws InvocationTargetException, IllegalAccessException { - String jstr = HttpUtil.get("http://172.20.1.210:30042/sys/loginByToken?token=" + dto.getToken()); - System.out.println("======================="); - System.out.println(dto.getToken()); - System.out.println(jstr); - ForeignResp resp = JSON.parseObject(jstr, ForeignResp.class); - if (resp.getCode() != 200) { - return ResultJson.error("登录失败"); - } - ForeignUserInfo userInfo = resp.getResult().getUserInfo(); - SysUser bean = new SysUser(); - bean.setName(userInfo.getRealname()); - bean.setType(9527); - bean.setLoginName(userInfo.getUsername()); - bean.setPassword(null); - bean.setForeignId(userInfo.getId()); - SysUser byForeignId = iSysUserService.getByForeignId(userInfo.getId()); - if (byForeignId == null) { - iSysUserService.save(bean); - } - - LoginDto obj = new LoginDto(); - obj.setLoginName(bean.getLoginName()); - obj.setPassword(null); - LoginVo loginVo = iSysUserService.login(obj); - - if (loginVo == null || loginVo.getId() == null) { - return ResultJson.error("登录失败"); - } else { - StpUtil.login(loginVo.getId()); // 使用 user id 登录 - // 获取 Token 相关参数 - loginVo.setTokenInfo(new AuthToken(StpUtil.getTokenInfo())); - loginVo.setRoleList(StpUtil.getRoleList()); - return ResultJson.ok(loginVo); - } - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceDataMapper.java b/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceDataMapper.java deleted file mode 100644 index 3cb5185..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceDataMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.whdc.zhdbaqapi.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; -import com.whdc.zhdbaqapi.model.entity.DeviceData; -import com.whdc.zhdbaqapi.model.entity.SysUser; -import org.apache.ibatis.annotations.Param; - -/** - * @author 李赛 - * @date 2022-07-21 23:40 - */ -public interface DeviceDataMapper extends BaseMapper { - - /** - * 分页查询 - * - * @param page - * @param findDto - * @return - */ - IPage page(@Param("page") IPage page, @Param("obj") FindDeviceDto findDto); - - void clearByDeviceId(@Param("deviceId") String deviceId, @Param("channelNum") Integer channelNum); -} diff --git a/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceGNSSDataMapper.java b/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceGNSSDataMapper.java deleted file mode 100644 index 07a70dc..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceGNSSDataMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.whdc.zhdbaqapi.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.model.entity.DeviceGNSS; -import com.whdc.zhdbaqapi.model.entity.DeviceGNSSData; -import com.whdc.zhdbaqapi.model.entity.SysUser; -import org.apache.ibatis.annotations.Param; - -public interface DeviceGNSSDataMapper extends BaseMapper { - - IPage page(@Param("page") IPage page); - -} diff --git a/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceGNSSMapper.java b/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceGNSSMapper.java deleted file mode 100644 index 2d9f816..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceGNSSMapper.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.whdc.zhdbaqapi.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.model.entity.DeviceGNSS; -import com.whdc.zhdbaqapi.model.entity.SysUser; -import org.apache.ibatis.annotations.Param; - -public interface DeviceGNSSMapper extends BaseMapper { - - IPage page(@Param("page") IPage page); - -} diff --git a/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceInfoMapper.java b/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceInfoMapper.java deleted file mode 100644 index d162d81..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceInfoMapper.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.whdc.zhdbaqapi.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; -import com.whdc.zhdbaqapi.model.entity.DeviceInfo; -import com.whdc.zhdbaqapi.model.entity.SysUser; -import org.apache.ibatis.annotations.Param; - -import java.util.List; -import java.util.Set; - -/** - * @author 李赛 - * @date 2022-07-21 23:40 - */ -public interface DeviceInfoMapper extends BaseMapper { - - /** - * TODO: SKETCH_MAP 的数据类型是 text,不知道为啥非要 IFNULL(SKETCH_MAP, '') SKETCH_MAP 这样处理一下才能正常查询到结果 - * @param id - * @return - */ - DeviceInfo get(Integer id); - - /** - * 返回查询 - * - * @return - */ - List list(String stationCode); - - List listAll(); - - - /** - * 分页查询 - * - * @param page - * @param findDto - * @return - */ - IPage page(@Param("page") IPage page, @Param("obj") FindDeviceDto findDto); - - /** - * 按 stationCode 查询 - * - * @param scs - * @return - */ - List listBySC(Set scs); - - /** - * 检查 station_code 是否有效 - * @param stationCode - * @return - */ - DeviceInfo checkValidStationCode(String stationCode); -} diff --git a/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceRobotDataMapper.java b/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceRobotDataMapper.java deleted file mode 100644 index 31f6ebf..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceRobotDataMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.whdc.zhdbaqapi.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.model.entity.DeviceGNSSData; -import com.whdc.zhdbaqapi.model.entity.DeviceRobotData; -import com.whdc.zhdbaqapi.model.entity.SysUser; -import org.apache.ibatis.annotations.Param; - -public interface DeviceRobotDataMapper extends BaseMapper { - - IPage page(@Param("page") IPage page); - -} diff --git a/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceRobotPointMapper.java b/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceRobotPointMapper.java deleted file mode 100644 index 223ddc0..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceRobotPointMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.whdc.zhdbaqapi.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.model.entity.DeviceGNSS; -import com.whdc.zhdbaqapi.model.entity.RobotPoint; -import com.whdc.zhdbaqapi.model.entity.SysUser; -import org.apache.ibatis.annotations.Param; - -public interface DeviceRobotPointMapper extends BaseMapper { - - IPage page(@Param("page") IPage page); - -} diff --git a/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceSLDataMapper.java b/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceSLDataMapper.java deleted file mode 100644 index f90b230..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceSLDataMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.whdc.zhdbaqapi.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; -import com.whdc.zhdbaqapi.model.entity.DeviceData; -import com.whdc.zhdbaqapi.model.entity.DeviceSLData; -import com.whdc.zhdbaqapi.model.entity.SysUser; -import org.apache.ibatis.annotations.Param; - -/** - * @author 李赛 - * @date 2022-07-21 23:40 - */ -public interface DeviceSLDataMapper extends BaseMapper { - - /** - * 分页查询 - * - * @param page - * @param findDto - * @return - */ - IPage page(@Param("page") IPage page, @Param("obj") FindDeviceDto findDto); - - void clearByDeviceId(@Param("deviceId") String deviceId, @Param("channelNum") Integer channelNum); -} diff --git a/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceSLInfoMapper.java b/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceSLInfoMapper.java deleted file mode 100644 index 81a9c8a..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/mapper/DeviceSLInfoMapper.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.whdc.zhdbaqapi.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; -import com.whdc.zhdbaqapi.model.entity.DeviceInfo; -import com.whdc.zhdbaqapi.model.entity.DeviceSLInfo; -import com.whdc.zhdbaqapi.model.entity.SysUser; -import org.apache.ibatis.annotations.Param; - -import java.util.List; -import java.util.Set; - -/** - * @author 李赛 - * @date 2022-07-21 23:40 - */ -public interface DeviceSLInfoMapper extends BaseMapper { - - /** - * TODO: SKETCH_MAP 的数据类型是 text,不知道为啥非要 IFNULL(SKETCH_MAP, '') SKETCH_MAP 这样处理一下才能正常查询到结果 - * - * @param id - * @return - */ - DeviceSLInfo get(Integer id); - - /** - * 返回查询 - * - * @return - */ - List list(String stationCode); - - List listAll(); - - - /** - * 分页查询 - * - * @param page - * @param findDto - * @return - */ - IPage page(@Param("page") IPage page, @Param("obj") FindDeviceDto findDto); - - /** - * 按 stationCode 查询 - * - * @param scs - * @return - */ - List listBySC(Set scs); - - /** - * 检查 station_code 是否有效 - * - * @param stationCode - * @return - */ - DeviceSLInfo checkValidStationCode(String stationCode); -} diff --git a/src/main/java/com/whdc/zhdbaqapi/mapper/SysUserMapper.java b/src/main/java/com/whdc/zhdbaqapi/mapper/SysUserMapper.java deleted file mode 100644 index 3335f92..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/mapper/SysUserMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.whdc.zhdbaqapi.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.whdc.zhdbaqapi.model.dto.FindSysUserDto; -import com.whdc.zhdbaqapi.model.entity.SysUser; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * @author 李赛 - * @date 2022-07-01 1:17 - */ -public interface SysUserMapper extends BaseMapper { - /** - * 返回所有 - * - * @return - */ - List list(); - - /** - * 分页查询 - * - * @param page - * @param findDto - * @return - */ - IPage page(@Param("page") IPage page, @Param("obj") FindSysUserDto findDto); - - SysUser findByForeignId(String foreignId); -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/cklat/CklatQueryDto.java b/src/main/java/com/whdc/zhdbaqapi/model/cklat/CklatQueryDto.java deleted file mode 100644 index cab498f..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/cklat/CklatQueryDto.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.whdc.zhdbaqapi.model.cklat; - -import com.alibaba.fastjson.annotation.JSONField; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.Date; - -/** - * @author 李赛 - * @date 2022-07-22 8:14 - */ -@Data -@Accessors(chain = true) // chain = true 实现链式调用 -public class CklatQueryDto { - - @JsonProperty("device_id") - @JSONField(name = "device_id") - private String deviceId; - - @JsonProperty("channel_num") - @JSONField(name = "channel_num") - private Integer channelNum; - - @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssZ", timezone = "GMT+8") - @JSONField(name = "start_timestamp", format = "yyyy-MM-dd'T'HH:mm:ssZ") - @JsonProperty("start_timestamp") - private Date startTimestamp; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/cklat/CklatRecord.java b/src/main/java/com/whdc/zhdbaqapi/model/cklat/CklatRecord.java deleted file mode 100644 index 6c6dc6c..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/cklat/CklatRecord.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.whdc.zhdbaqapi.model.cklat; - -import com.alibaba.fastjson.annotation.JSONField; -import com.fasterxml.jackson.annotation.JsonAlias; -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; - -import java.math.BigDecimal; -import java.util.Date; - -/** - * @author 李赛 - * @date 2022-07-22 7:48 - */ -@Data -public class CklatRecord { - - /* - "device_id": "00004216", -"timestamp": "2021-09-05T22:00:07+08:00", -"channel_num": 0, -"data_a": 2906.9, -"data_b": 26.77, -"data_c": 83857808 - */ - - @JsonProperty("device_id") - private String deviceId; - - @JsonProperty("timestamp") - private Date timestamp; - - @JsonProperty("channel_num") - private Integer channelNum; - - @JsonProperty("data_a") - private BigDecimal dataA; - - @JsonProperty("data_b") - private BigDecimal dataB; - - @JsonProperty("data_c") - private BigDecimal dataC; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/cklat/CklatResult.java b/src/main/java/com/whdc/zhdbaqapi/model/cklat/CklatResult.java deleted file mode 100644 index 0630626..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/cklat/CklatResult.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.whdc.zhdbaqapi.model.cklat; - -import lombok.Data; - -import java.util.List; - -/** - * @author 李赛 - * @date 2022-07-22 7:48 - */ -@Data -public class CklatResult { - private Integer total; - private List rows; - private String status; - private String message; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/dto/ChangePwdDto.java b/src/main/java/com/whdc/zhdbaqapi/model/dto/ChangePwdDto.java deleted file mode 100644 index cf2df08..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/dto/ChangePwdDto.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.whdc.zhdbaqapi.model.dto; - -import io.swagger.annotations.ApiParam; -import lombok.Data; - -/** - * @author 李赛 - * @date 2022-07-01 1:21 - */ -@Data -public class ChangePwdDto { - @ApiParam(value = "旧密码") - private String oldpwd; - - @ApiParam(value = "新密码") - private String newpwd; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/dto/FindDeviceDto.java b/src/main/java/com/whdc/zhdbaqapi/model/dto/FindDeviceDto.java deleted file mode 100644 index c8a0488..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/dto/FindDeviceDto.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.whdc.zhdbaqapi.model.dto; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.Pattern; - -/** - * @author 李赛 - * @date 2022-07-01 1:17 - */ -@Data -public class FindDeviceDto extends FindPageDto { - @ApiModelProperty(value = "起始时间,格式应为:yyyy-MM-dd HH:mm:ss", dataType = "java.lang.String") - @Pattern(regexp = "^[1-9]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\\s+(20|21|22|23|[0-1]\\d):[0-5]\\d:[0-5]\\d$", - message = "时间格式应为:yyyy-MM-dd HH:mm:ss") - private String stm; - - @ApiModelProperty(value = "截止时间,格式应为:yyyy-MM-dd HH:mm:ss", dataType = "java.lang.String") - @Pattern(regexp = "^[1-9]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\\s+(20|21|22|23|[0-1]\\d):[0-5]\\d:[0-5]\\d$", - message = "时间格式应为:yyyy-MM-dd HH:mm:ss") - private String etm; - - @ApiModelProperty(value = "站点编码", dataType = "java.lang.String") - private String deviceId; - - @ApiModelProperty(value = "测点编号", dataType = "java.lang.String") - private String stationCode; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/dto/FindSysUserDto.java b/src/main/java/com/whdc/zhdbaqapi/model/dto/FindSysUserDto.java deleted file mode 100644 index e5c97ce..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/dto/FindSysUserDto.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.whdc.zhdbaqapi.model.dto; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * @author 李赛 - * @date 2022-07-01 1:17 - */ -@Data -public class FindSysUserDto extends FindPageDto { - @ApiModelProperty(value = "姓名", dataType = "java.lang.String") - private String name; - - @ApiModelProperty(value = "登录名", dataType = "java.lang.String") - private String loginName; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/dto/ForeignResp.java b/src/main/java/com/whdc/zhdbaqapi/model/dto/ForeignResp.java deleted file mode 100644 index b78409d..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/dto/ForeignResp.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.whdc.zhdbaqapi.model.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -@Data -@Accessors(chain = true) // chain = true 实现链式调用 -public class ForeignResp { - boolean success; - String message; - String extMessage; - int code; - @JsonProperty(value = "result") - ForeignResult result; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/dto/ForeignResult.java b/src/main/java/com/whdc/zhdbaqapi/model/dto/ForeignResult.java deleted file mode 100644 index 7087cba..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/dto/ForeignResult.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.whdc.zhdbaqapi.model.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.whdc.zhdbaqapi.model.entity.ForeignUserInfo; -import lombok.Data; -import lombok.experimental.Accessors; - -@Data -@Accessors(chain = true) // chain = true 实现链式调用 -public class ForeignResult { - int multi_depart; - @JsonProperty(value = "userInfo") - ForeignUserInfo userInfo; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/dto/ForeignTokenDto.java b/src/main/java/com/whdc/zhdbaqapi/model/dto/ForeignTokenDto.java deleted file mode 100644 index d694506..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/dto/ForeignTokenDto.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.whdc.zhdbaqapi.model.dto; - -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; -import lombok.Data; - -import javax.validation.constraints.NotBlank; - -@Data -public class ForeignTokenDto { - @ApiParam(value = "token", example = "") - @ApiModelProperty(value = "token", dataType = "java.lang.String") - @NotBlank(message = "token") - private String token; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/dto/IdDto.java b/src/main/java/com/whdc/zhdbaqapi/model/dto/IdDto.java deleted file mode 100644 index 4f0e9f0..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/dto/IdDto.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.whdc.zhdbaqapi.model.dto; - -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import java.io.Serializable; - -/** - * @author 李赛 - * @date 2022-06-26 10:43 - */ -@Data -public class IdDto implements Serializable { - private static final long serialVersionUID = 1L; - - @ApiParam(value = "主键ID", example = "") - @ApiModelProperty(value = "主键ID", dataType = "java.lang.String") - @NotBlank(message = "主键ID") - private String id; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/dto/IntegerIdDto.java b/src/main/java/com/whdc/zhdbaqapi/model/dto/IntegerIdDto.java deleted file mode 100644 index 79f0f91..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/dto/IntegerIdDto.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.whdc.zhdbaqapi.model.dto; - -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.io.Serializable; - -/** - * @author 李赛 - * @date 2022-06-26 10:43 - */ -@Data -public class IntegerIdDto implements Serializable { - private static final long serialVersionUID = 1L; - - @ApiParam(value = "主键ID", example = "") - @ApiModelProperty(value = "主键ID", dataType = "java.lang.Integer") - @NotNull(message = "主键ID") - private Integer id; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/dto/LoginDto.java b/src/main/java/com/whdc/zhdbaqapi/model/dto/LoginDto.java deleted file mode 100644 index 694107d..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/dto/LoginDto.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.whdc.zhdbaqapi.model.dto; - -import com.fasterxml.jackson.annotation.JsonInclude; -import io.swagger.annotations.ApiParam; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotEmpty; - -/** - * @author 李赛 - * @date 2022-07-01 1:21 - */ -@Data -public class LoginDto { - @ApiParam(value = "登录名") - @NotEmpty(message = "登录名不能为空") - private String loginName; - - @ApiParam(value = "密码") - @NotEmpty(message = "密码不能为空") - private String password; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/dto/StationCodeDto.java b/src/main/java/com/whdc/zhdbaqapi/model/dto/StationCodeDto.java deleted file mode 100644 index 7b64d55..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/dto/StationCodeDto.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.whdc.zhdbaqapi.model.dto; - -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import java.io.Serializable; - -/** - * @author 李赛 - * @date 2022-06-26 10:43 - */ -@Data -public class StationCodeDto implements Serializable { - private static final long serialVersionUID = 1L; - - @ApiParam(value = "测点编号", example = "") - @ApiModelProperty(value = "测点编号", dataType = "java.lang.String") - @NotBlank(message = "测点编号") - private String stationCode; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/dto/StcdStmEtmDto.java b/src/main/java/com/whdc/zhdbaqapi/model/dto/StcdStmEtmDto.java deleted file mode 100644 index db63050..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/dto/StcdStmEtmDto.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.whdc.zhdbaqapi.model.dto; - -import com.whdc.zhdbaqapi.annotation.DateTimeRange; -import com.whdc.zhdbaqapi.model.group.Find; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Pattern; -import java.util.concurrent.TimeUnit; - -/** - * @author 李赛 - * @date 2022-07-18 1:37 - */ -@Data -@DateTimeRange(message = "时间间隔不能超过 7 天", startField = "stm", endField = "etm", interval = 7, timeUnit = TimeUnit.DAYS) -public class StcdStmEtmDto { - - @ApiModelProperty(value = "站码") - @NotEmpty(message = "站码不能为空") - private String stcd; - - @ApiModelProperty(value = "起始时间", example = "2022-07-18 00:00:00") - @NotEmpty(message = "起始时间不能为空") - @Pattern(regexp = "^[1-9]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\\s+(20|21|22|23|[0-1]\\d):[0-5]\\d:[0-5]\\d$", - message = "时间格式应为:yyyy-MM-dd HH:mm:ss", groups = Find.class) - private String stm; - - @ApiModelProperty(value = "截止时间", example = "2022-07-18 10:00:00") - @NotEmpty(message = "截止时间不能为空") - @Pattern(regexp = "^[1-9]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\\s+(20|21|22|23|[0-1]\\d):[0-5]\\d:[0-5]\\d$", - message = "时间格式应为:yyyy-MM-dd HH:mm:ss", groups = Find.class) - private String etm; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceData.java b/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceData.java deleted file mode 100644 index 68f5020..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceData.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.whdc.zhdbaqapi.model.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonInclude; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.math.BigDecimal; -import java.util.Date; - -/** - * @author 李赛 - * @date 2022-07-21 23:28 - */ -@Data -@TableName("DEVICE_DATA") -@Accessors(chain = true) // chain = true 实现链式调用 -@ApiModel(value = "DEVICE_DATA 对象", description = "设备数据") -@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性 -public class DeviceData { - - /** - * 主键id - */ - @ApiParam(value = "主键id") - @ApiModelProperty(value = "主键id", dataType = "java.lang.Integer") - @TableId(value = "ID", type = IdType.AUTO) - private Integer id; - - /** - * 渗压值 - */ - @ApiParam(value = "渗压值") - @ApiModelProperty(value = "渗压值", dataType = "java.math.BigDecimal") - @TableField("OSMOMETER") - private BigDecimal osmometer; - - /** - * 通道类型。=5时, data_a 频率,data_b 温度 - */ - @ApiParam(value = "通道类型。=5时, data_a 频率,data_b 温度") - @ApiModelProperty(value = "通道类型。=5时, data_a 频率,data_b 温度", dataType = "java.lang.String") - @TableField("CHANNEL_TYPE") - private String channelType; - - /** - * 入库时间 - */ - @ApiParam(value = "入库时间") - @ApiModelProperty(value = "入库时间", dataType = "java.lang.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - @TableField("CREATETIME") - private Date createtime; - - /** - * - */ - @ApiParam(value = "") - @ApiModelProperty(value = "", dataType = "java.math.BigDecimal") - @TableField("DATA_C") - private BigDecimal dataC; - - /** - * - */ - @ApiParam(value = "") - @ApiModelProperty(value = "", dataType = "java.math.BigDecimal") - @TableField("DATA_B") - private BigDecimal dataB; - - /** - * - */ - @ApiParam(value = "") - @ApiModelProperty(value = "", dataType = "java.math.BigDecimal") - @TableField("DATA_A") - private BigDecimal dataA; - - /** - * 通道号 - */ - @ApiParam(value = "通道号") - @ApiModelProperty(value = "通道号", dataType = "java.lang.Integer") - @TableField("CHANNEL_NUM") - private Integer channelNum; - - /** - * 数据时间 - */ - @ApiParam(value = "数据时间") - @ApiModelProperty(value = "数据时间", dataType = "java.lang.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - @TableField("TIMESTAMP") - private Date timestamp; - - /** - * 测站编码(MCU) - */ - @ApiParam(value = "测站编码(MCU)") - @ApiModelProperty(value = "测站编码(MCU)", dataType = "java.lang.String") - @TableField("DEVICE_ID") - private String deviceId; - - /** - * 管内水位 - */ - @ApiParam(value = "管内水位") - @ApiModelProperty(value = "管内水位", dataType = "java.math.BigDecimal") - @TableField("PIPE_Z") - private BigDecimal pipeZ; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceGNSS.java b/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceGNSS.java deleted file mode 100644 index e002afc..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceGNSS.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.whdc.zhdbaqapi.model.entity; - -import cn.afterturn.easypoi.excel.annotation.Excel; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonInclude; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotEmpty; -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; - -@Data -@TableName("DSM_GNSS_DEVICE") -@Accessors(chain = true) // chain = true 实现链式调用 -@ApiModel(value = "DEVICE_GNSS 对象", description = "GNSS设备信息") -@JsonInclude(JsonInclude.Include.ALWAYS) // 表示序列化非null属性 -public class DeviceGNSS implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键id - */ - @ApiParam(value = "主键id") - @ApiModelProperty(value = "主键id", dataType = "java.lang.Integer") - @TableId(value = "ID", type = IdType.AUTO) - protected Integer id; - - /** - * 设备名称 - */ - @ApiParam(value = "设备名称") - @ApiModelProperty(value = "设备名称", dataType = "java.lang.String", required = true) - @Excel(name = "设备名称") - @NotEmpty(message = "设备名称") - @TableField("STATION_NAME") - private String stationName; - - /** - * 设备类型 - * 值范围:监测站/基准站 - */ - @ApiParam(value = "设备类型") - @ApiModelProperty(value = "设备类型", dataType = "java.lang.String", required = true) - @Excel(name = "设备类型") - @NotEmpty(message = "设备类型") - @TableField("STATION_TYPE") - private String stationType; - - /** - * 开始解算时间 - */ - @ApiParam(value = "开始解算时间") - @ApiModelProperty(value = "开始解算时间", dataType = "java.util.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - @Excel(name = "开始解算时间") - @TableField("START_TIME") - private Date startTime; - - /** - * 终止解算时间 - */ - @ApiParam(value = "终止解算时间") - @ApiModelProperty(value = "终止解算时间", dataType = "java.util.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - @Excel(name = "终止解算时间") - @TableField("END_TIME") - private Date endTime; - - /** - * 纬度 - */ - @ApiParam(value = "纬度") - @ApiModelProperty(value = "纬度", dataType = "java.math.BigDecimal") - @Excel(name = "纬度") - @TableField("B") - private BigDecimal b; - - /** - * 经度 - */ - @ApiParam(value = "经度") - @ApiModelProperty(value = "经度", dataType = "java.math.BigDecimal") - @Excel(name = "经度") - @TableField("L") - private BigDecimal l; - - /** - * 表面位移测点X方向值 - */ - @ApiParam(value = "表面位移测点X方向值") - @ApiModelProperty(value = "表面位移测点X方向值", dataType = "java.math.BigDecimal") - @Excel(name = "表面位移测点X方向值") - @TableField("X") - private BigDecimal x; - - /** - * 表面位移测点Y方向值 - */ - @ApiParam(value = "表面位移测点Y方向值") - @ApiModelProperty(value = "表面位移测点Y方向值", dataType = "java.math.BigDecimal") - @Excel(name = "表面位移测点Y方向值") - @TableField("Y") - private BigDecimal y; - - /** - * 表面位移测点H方向值 - */ - @ApiParam(value = "表面位移测点H方向值") - @ApiModelProperty(value = "表面位移测点H方向值", dataType = "java.math.BigDecimal") - @Excel(name = "表面位移测点H方向值") - @TableField("H") - private BigDecimal h; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceGNSSData.java b/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceGNSSData.java deleted file mode 100644 index ee96625..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceGNSSData.java +++ /dev/null @@ -1,175 +0,0 @@ -package com.whdc.zhdbaqapi.model.entity; - -import cn.afterturn.easypoi.excel.annotation.Excel; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonInclude; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotEmpty; -import java.math.BigDecimal; -import java.util.Date; - -@Data -@TableName("DSM_GNSS_SURF_DEVICE_DATA_HIST") -@Accessors(chain = true) // chain = true 实现链式调用 -@ApiModel(value = "DSM_GNSS_SURF_DEVICE_DATA_HIST 对象", description = "GNSS设备监测数据") -@JsonInclude(JsonInclude.Include.ALWAYS) // 表示序列化非null属性 -public class DeviceGNSSData { - /** - * 主键id - */ - @ApiParam(value = "主键id") - @ApiModelProperty(value = "主键id", dataType = "java.lang.Integer") - @TableId(value = "ID", type = IdType.AUTO) - private Integer id; - - /** - * 表面位移测点ID - */ - @ApiParam(value = "表面位移测点ID") - @ApiModelProperty(value = "表面位移测点ID", dataType = "java.lang.Integer") - @Excel(name = "表面位移测点ID") - @NotEmpty(message = "表面位移测点ID") - @TableField("DEVICE_ID") - private Integer deviceId; - - /** - * 表面位移监测类型ID - */ - @ApiParam(value = "表面位移监测类型ID") - @ApiModelProperty(value = "表面位移监测类型ID", dataType = "java.lang.Integer") - @Excel(name = "表面位移监测类型ID") - @NotEmpty(message = "表面位移监测类型ID") - @TableField("DEVICE_DATA_TYPE_ID") - private Integer DeviceDataTypeId; - - /** - * 表面位移测点X方向值 - */ - @ApiParam(value = "表面位移测点X方向值") - @ApiModelProperty(value = "表面位移测点X方向值", dataType = "java.math.BigDecimal") - @Excel(name = "表面位移测点X方向值") - @TableField("V1") - private BigDecimal v1; - - /** - * 表面位移测点Y方向值 - */ - @ApiParam(value = "表面位移测点Y方向值") - @ApiModelProperty(value = "表面位移测点Y方向值", dataType = "java.math.BigDecimal") - @Excel(name = "表面位移测点Y方向值") - @TableField("V2") - private BigDecimal v2; - - /** - * 表面位移测点H方向值 - */ - @ApiParam(value = "表面位移测点H方向值") - @ApiModelProperty(value = "表面位移测点H方向值", dataType = "java.math.BigDecimal") - @Excel(name = "表面位移测点H方向值") - @TableField("V3") - private BigDecimal v3; - - /** - * 预留1 - */ - @ApiParam(value = "预留1") - @ApiModelProperty(value = "预留1", dataType = "java.math.BigDecimal") - @Excel(name = "预留1") - @TableField("V4") - private BigDecimal v4; - - /** - * 预留2 - */ - @ApiParam(value = "预留2") - @ApiModelProperty(value = "预留2", dataType = "java.math.BigDecimal") - @Excel(name = "预留2") - @TableField("V5") - private BigDecimal v5; - - /** - * 创建人ID - */ - @ApiParam(value = "创建人ID") - @ApiModelProperty(value = "创建人ID", dataType = "java.lang.Integer") - @Excel(name = "创建人ID") - @NotEmpty(message = "创建人ID") - @TableField("CREATE_USER_ID") - private Integer createUserId; - - /** - * 创建时间 - */ - @ApiParam(value = "创建时间") - @ApiModelProperty(value = "创建时间", dataType = "java.util.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - @Excel(name = "创建时间") - @TableField("CREATE_TIME") - private Date createTime; - - /** - * 修改人ID - */ - @ApiParam(value = "修改人ID") - @ApiModelProperty(value = "修改人ID", dataType = "java.lang.Integer") - @Excel(name = "修改人ID") - @NotEmpty(message = "修改人ID") - @TableField("MODIFY_USER_ID") - private Integer modifyUserId; - - /** - * 修改时间 - */ - @ApiParam(value = "修改时间") - @ApiModelProperty(value = "修改时间", dataType = "java.util.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - @Excel(name = "修改时间") - @TableField("MODIFY_TIME") - private Date modifyTime; - - /** - * 测点采集时间 - */ - @ApiParam(value = "测点采集时间") - @ApiModelProperty(value = "测点采集时间", dataType = "java.util.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - @Excel(name = "测点采集时间") - @TableField("DAC_TIME") - private Date dacTime; - - /** - * DV1 - */ - @ApiParam(value = "DV1") - @ApiModelProperty(value = "DV1", dataType = "java.math.BigDecimal") - @Excel(name = "DV1") - @TableField("DV1") - private BigDecimal dv1; - - /** - * DV2 - */ - @ApiParam(value = "DV2") - @ApiModelProperty(value = "DV2", dataType = "java.math.BigDecimal") - @Excel(name = "DV2") - @TableField("DV2") - private BigDecimal dv2; - - /** - * DV3 - */ - @ApiParam(value = "DV3") - @ApiModelProperty(value = "DV3", dataType = "java.math.BigDecimal") - @Excel(name = "DV3") - @TableField("DV3") - private BigDecimal dv3; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceInfo.java b/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceInfo.java deleted file mode 100644 index 626c98c..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceInfo.java +++ /dev/null @@ -1,544 +0,0 @@ -package com.whdc.zhdbaqapi.model.entity; - -import cn.afterturn.easypoi.excel.annotation.Excel; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonInclude; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; - -/** - * @author 李赛 - * @date 2022-07-21 23:26 - */ -@Data -@TableName("DEVICE_INFO") -@Accessors(chain = true) // chain = true 实现链式调用 -@ApiModel(value = "DEVICE_INFO 对象", description = "设备信息") -@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性 -public class DeviceInfo implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键id - */ - @ApiParam(value = "主键id") - @ApiModelProperty(value = "主键id", dataType = "java.lang.Integer", position = 1) - @TableId(value = "ID", type = IdType.AUTO) - private Integer id; - - /** - * 测点编号 - */ - @ApiParam(value = "测点编号") - @ApiModelProperty(value = "测点编号", dataType = "java.lang.String", required = true, position = 2) - @Excel(name = "测点编号") - @NotEmpty(message = "测点编号必填") - @TableField("STATION_CODE") - private String stationCode; - - /** - * 测站编码(MCU) - */ - @ApiParam(value = "测站编码(MCU)") - @ApiModelProperty(value = "测站编码(MCU)", dataType = "java.lang.String", required = true, position = 3) - @Excel(name = "测站编码(MCU)") - @NotEmpty(message = "测站编码(MCU)必填") - @TableField("DEVICE_ID") - private String deviceId; - - /** - * 通道号 - */ - @ApiParam(value = "通道号") - @ApiModelProperty(value = "通道号", dataType = "java.lang.Integer", required = true, position = 4) - @Excel(name = "通道号") - @NotNull(message = "通道号必填") - @Max(message = "通道号最大值 7", value = 7) - @Min(message = "通道号最小值 0", value = 0) - @TableField("CHANNEL_NUM") - private Integer channelNum; - - /** - * 温度率定系娄(K) - */ - @ApiParam(value = "温度率定系娄(K)") - @ApiModelProperty(value = "温度率定系娄(K)", dataType = "java.math.BigDecimal", required = true, position = 5) - @Excel(name = "温度率定系娄(K)") - @NotNull(message = "温度率定系娄(K)必填") - @TableField("TEMPERATURE_K") - private BigDecimal temperatureK; - - /** - * 初始温度读数 - */ - @ApiParam(value = "初始温度读数") - @ApiModelProperty(value = "初始温度读数", dataType = "java.lang.Double", required = true, position = 6) - @Excel(name = "初始温度读数") - @NotNull(message = "初始温度读数必填") - @TableField("START_TEMPERATURE") - private BigDecimal startTemperature; - - /** - * 率定系数(G) - */ - @ApiParam(value = "率定系数(G)") - @ApiModelProperty(value = "率定系数(G)", dataType = "java.math.BigDecimal", required = true, position = 7) - @Excel(name = "率定系数(G)") - @NotNull(message = "率定系数(G)必填") - @TableField("CALIBRATION_COEFFICIENT") - private BigDecimal calibrationCoefficient; - - /** - * 初始读数。单位是“模数”, 乘 1000 后开方得到频率值 - */ - @ApiParam(value = "初始读数") - @ApiModelProperty(value = "初始读数", notes = "单位是“模数”, 乘 1000 后开方得到频率值", dataType = "java.math.BigDecimal", required = true, position = 8) - @Excel(name = "初始读数") - @NotNull(message = "初始读数必填") - @TableField("INITIAL_READING") - private BigDecimal initialReading; - - /** - * 项目名称 - */ - @ApiParam(value = "项目名称") - @ApiModelProperty(value = "项目名称", dataType = "java.lang.String", position = 9) - @Excel(name = "工程或项目名称") - @TableField("PROJECT_NAME") - private String projectName; - - /** - * 备注 - */ - @ApiParam(value = "备注") - @ApiModelProperty(value = "备注", dataType = "java.lang.String") - @Excel(name = "备注") - @TableField("REMARK") - private String remark; - - /** - * 监理工程师 - */ - @ApiParam(value = "监理工程师") - @ApiModelProperty(value = "监理工程师", dataType = "java.lang.String") - @Excel(name = "监理工程师") - @TableField("SUPERVISOR") - private String supervisor; - - /** - * 创建时间 - */ - @ApiParam(value = "创建时间") - @ApiModelProperty(value = "创建时间", dataType = "java.util.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - @TableField("CREATION_TIME") - private Date creationTime; - - /** - * 修改时间 - */ - @ApiParam(value = "修改时间") - @ApiModelProperty(value = "修改时间", dataType = "java.util.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - @TableField("MODIFICATION_TIME") - private Date modificationTime; - - /** - * 0:删除 1 已逻辑删除 - */ - @ApiParam(value = "0:删除 1 已逻辑删除") - @ApiModelProperty(value = "0:删除 1 已逻辑删除", dataType = "java.lang.Integer") - @TableField("DEL") - private Integer del; - - /** - * 埋设示意图 - */ - @ApiParam(value = "埋设示意图") - @ApiModelProperty(value = "埋设示意图", dataType = "java.lang.String") - @TableField(value = "SKETCH_MAP") - private String sketchMap; - - /** - * 日期 - */ - @ApiParam(value = "日期") - @ApiModelProperty(value = "日期", dataType = "java.util.Date") - @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") - @Excel(name = "日期") - @TableField("CREATE_DATE") - private Date createDate; - - /** - * 埋设及填表人 - */ - @ApiParam(value = "埋设及填表人") - @ApiModelProperty(value = "埋设及填表人", dataType = "java.lang.String") - @Excel(name = "埋设及填表人") - @TableField("BURIED_PERSONNEL") - private String buriedPersonnel; - - /** - * 校验人 - */ - @ApiParam(value = "校验人") - @ApiModelProperty(value = "校验人", dataType = "java.lang.String") - @Excel(name = "校验人") - @TableField("CHECK_PERSONNEL") - private String checkPersonnel; - - /** - * 技术负责人 - */ - @ApiParam(value = "技术负责人") - @ApiModelProperty(value = "技术负责人", dataType = "java.lang.String") - @Excel(name = "技术负责人") - @TableField("TECHNICAL_DIRECTOR") - private String technicalDirector; - - /** - * 下游水位(m) - */ - @ApiParam(value = "下游水位(m)") - @ApiModelProperty(value = "下游水位(m)", dataType = "java.lang.Double") - @Excel(name = "下游水位") - @TableField("TAILWATER_LEVEL") - private Double tailwaterLevel; - - /** - * 上游水位(m) - */ - @ApiParam(value = "上游水位(m)") - @ApiModelProperty(value = "上游水位(m)", dataType = "java.lang.Double") - @Excel(name = "上游水位") - @TableField("HEADWATER_LEVEL") - private Double headwaterLevel; - - /** - * 天气 - */ - @ApiParam(value = "天气") - @ApiModelProperty(value = "天气", dataType = "java.lang.String") - @Excel(name = "天气") - @TableField("WEATHER") - private String weather; - - /** - * 气压 - */ - @ApiParam(value = "气压") - @ApiModelProperty(value = "气压", dataType = "java.math.BigDecimal") - @Excel(name = "气压") - @TableField("AIR_PRESSURE") - private BigDecimal airPressure; - - /** - * 气温 - */ - @ApiParam(value = "气温") - @ApiModelProperty(value = "气温", dataType = "java.math.BigDecimal") - @Excel(name = "气温") - @TableField("AIR_TEMPERATURE") - private BigDecimal airTemperature; - - /** - * 埋设日期 - */ - @ApiParam(value = "埋设日期") - @ApiModelProperty(value = "埋设日期", dataType = "java.util.Date") - @Excel(name = "埋设日期") - @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") - @TableField("EMBEDDING_DATE") - private Date embeddingDate; - - /** - * 埋设完毕读数(Hz,kHz) - */ - @ApiParam(value = "埋设完毕读数(Hz,kHz)") - @ApiModelProperty(value = "埋设完毕读数(Hz,kHz)", dataType = "java.lang.String") - @Excel(name = "埋设完毕读数(Hz,kHz)") - @TableField("EMBEDDING_FINISH_READING") - private String embeddingFinishReading; - - /** - * 零压读数(Hz,kHz) - */ - @ApiParam(value = "零压读数(Hz,kHz)") - @ApiModelProperty(value = "零压读数(Hz,kHz)", dataType = "java.math.BigDecimal") - @Excel(name = "零压读数(Hz,kHz)") - @TableField("ZERO_PRESSURE_READINGS") - private BigDecimal zeroPressureReadings; - - /** - * 就位后读数(Hz,kHz) - */ - @ApiParam(value = "就位后读数(Hz,kHz)") - @ApiModelProperty(value = "就位后读数(Hz,kHz)", dataType = "java.math.BigDecimal") - @Excel(name = "就位后读数(Hz,kHz)") - @TableField("END_READINGS") - private BigDecimal endReadings; - - /** - * 入孔前读数(Hz,kHz) - */ - @ApiParam(value = "入孔前读数(Hz,kHz)") - @ApiModelProperty(value = "入孔前读数(Hz,kHz)", dataType = "java.lang.String") - @Excel(name = "入孔前读数(Hz,kHz)") - @TableField("START_READINGS") - private String startReadings; - - /** - * 孔内水深 - */ - @ApiParam(value = "孔内水深") - @ApiModelProperty(value = "孔内水深", dataType = "java.math.BigDecimal") - @Excel(name = "孔内水深") - @TableField("DRAFT") - private BigDecimal draft; - - /** - * 现场室内读数(Hz,kHz) - */ - @ApiParam(value = "现场室内读数(Hz,kHz)") - @ApiModelProperty(value = "现场室内读数(Hz,kHz)", dataType = "java.math.BigDecimal") - @Excel(name = "现场室内读数(Hz,kHz)") - @TableField("READINGS") - private BigDecimal readings; - - /** - * 坝轴距(m) - */ - @ApiParam(value = "坝轴距(m)") - @ApiModelProperty(value = "坝轴距(m)", dataType = "java.math.BigDecimal") - @Excel(name = "坝轴距(m)") - @TableField("DAM_WHEELBASE") - private BigDecimal damWheelbase; - - /** - * 桩号(m) - */ - @ApiParam(value = "桩号(m)") - @ApiModelProperty(value = "桩号(m)", dataType = "java.lang.String") - @Excel(name = "桩号(m)") - @TableField("COLUMN_NO") - private String columnNo; - - /** - * 埋设高程(m) - */ - @ApiParam(value = "埋设高程(m)") - @ApiModelProperty(value = "埋设高程(m)", dataType = "java.math.BigDecimal") - @Excel(name = "埋设高程(m)") - @NotNull(message = "埋设高程必填") - @TableField("EMBEDDING_ELEVATION") - private BigDecimal embeddingElevation; - - /** - * 电缆长度标记 - */ - @ApiParam(value = "电缆长度标记") - @ApiModelProperty(value = "电缆长度标记", dataType = "java.lang.String") - @Excel(name = "电缆长度标记(m)") - @TableField("CABLE_LENGTH_MARK") - private String cableLengthMark; - - /** - * 电缆长度(m) - */ - @ApiParam(value = "电缆长度(m)") - @ApiModelProperty(value = "电缆长度(m)", dataType = "java.math.BigDecimal") - @Excel(name = "电缆长度(m)") - @TableField("CABLE_LENGTH") - private BigDecimal cableLength; - - /** - * 测头内阻 - */ - @ApiParam(value = "测头内阻") - @ApiModelProperty(value = "测头内阻", dataType = "java.lang.String") - @Excel(name = "测头内阻") - @TableField("RESISTANCE") - private String resistance; - - /** - * 量程 - */ - @ApiParam(value = "量程") - @ApiModelProperty(value = "量程", dataType = "java.math.BigDecimal") - @Excel(name = "量程") - @TableField("RANGE") - private BigDecimal range; - - /** - * 传感器系数K(kpa/Hz,kHz) - */ - @ApiParam(value = "传感器系数K(kpa/Hz,kHz)") - @ApiModelProperty(value = "传感器系数K(kpa/Hz,kHz)", dataType = "java.math.BigDecimal") - @Excel(name = "传感器系数K(kpa/Hz,kHz)") - @TableField("SENSOR_COEFFICIENT") - private BigDecimal sensorCoefficient; - - /** - * 生产厂家 - */ - @ApiParam(value = "生产厂家") - @ApiModelProperty(value = "生产厂家", dataType = "java.lang.String") - @Excel(name = "生产厂家") - @TableField("MANUFACTURER") - private String manufacturer; - - /** - * 测头编号 - */ - @ApiParam(value = "测头编号") - @ApiModelProperty(value = "测头编号", dataType = "java.lang.String") - @Excel(name = "测头编号") - @TableField("MEASURING_PROBE_NO") - private String measuringProbeNo; - - /** - * 稳定水位 - */ - @ApiParam(value = "稳定水位") - @ApiModelProperty(value = "稳定水位", dataType = "java.lang.Double") - @Excel(name = "稳定水位") - @TableField("STEADY_WATER_LEVEL") - private Double steadyWaterLevel; - - /** - * 初见水位 - */ - @ApiParam(value = "初见水位") - @ApiModelProperty(value = "初见水位", dataType = "java.lang.Double") - @Excel(name = "初见水位") - @TableField("INITIAL_WATER_LEVEL") - private Double initialWaterLevel; - - /** - * 钻孔直径 - */ - @ApiParam(value = "钻孔直径(mm)") - @ApiModelProperty(value = "钻孔直径(mm)", dataType = "java.lang.String") - @Excel(name = "钻孔直径(mm)") - @TableField("DRILLING_SIZE") - private String drillingSize; - - /** - * 钻孔编号 - */ - @ApiParam(value = "钻孔编号") - @ApiModelProperty(value = "钻孔编号", dataType = "java.lang.String") - @Excel(name = "钻孔编号") - @TableField("DRILLING_NO") - private String drillingNo; - - /** - * 作废字段,为了兼容前面的,暂时未删除 - */ - @ApiParam(value = "作废字段,为了兼容前面的,暂时未删除") - @ApiModelProperty(value = "作废字段,为了兼容前面的,暂时未删除", dataType = "java.math.BigDecimal") - @TableField("PRESSURE") - private BigDecimal pressure; - - /** - * 作废字段,为了兼容前面的,暂时未删除 - */ - @ApiParam(value = "作废字段,为了兼容前面的,暂时未删除") - @ApiModelProperty(value = "作废字段,为了兼容前面的,暂时未删除", dataType = "java.math.BigDecimal") - @TableField("RECENT_DATA") - private BigDecimal recentData; - - /** - * 最后数据同步时间 - */ - @ApiParam(value = "最后数据同步时间") - @ApiModelProperty(value = "最后数据同步时间", dataType = "java.util.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - @TableField("LATEST_REPORTING_TIME") - private Date latestReportingTime; - - /** - * 所在断面 - */ - @ApiParam(value = "所在断面") - @ApiModelProperty(value = "所在断面", dataType = "java.lang.String") - @TableField("CROSS_SECTION") - private String crossSection; - - /** - * 所在大坝 - */ - @ApiParam(value = "所在大坝") - @ApiModelProperty(value = "所在大坝", dataType = "java.lang.String") - @TableField("DAM") - private String dam; - - /** - * 作废字段,为了兼容前面的,暂时未删除 - */ - @ApiParam(value = "作废字段,为了兼容前面的,暂时未删除") - @ApiModelProperty(value = "作废字段,为了兼容前面的,暂时未删除", dataType = "java.lang.String") - @TableField("MOUNTING_HEIGHT") - private String mountingHeight; - - /** - * 安装高程 - */ - @ApiParam(value = "安装高程") - @ApiModelProperty(value = "安装高程", dataType = "java.lang.Double") - @TableField("INSTALLATION_POSITION_Z") - private Double installationPositionZ; - - /** - * 渗压计到孔底距离 - */ - @ApiParam(value = "渗压计到孔底距离") - @ApiModelProperty(value = "渗压计到孔底距离", dataType = "java.lang.Double") - @TableField("DIST_FROM_OSMOSIS_METER_TO_BOTTOM") - private Double distFromOsmosisMeterToBottom; - - /** - * 安装纬度 - */ - @ApiParam(value = "安装纬度") - @ApiModelProperty(value = "安装纬度", dataType = "java.lang.Double") - @TableField("INSTALLATION_POSITION_Y") - private Double installationPositionY; - - /** - * 安装经度 - */ - @ApiParam(value = "安装经度") - @ApiModelProperty(value = "安装经度", dataType = "java.lang.Double") - @TableField("INSTALLATION_POSITION_X") - private Double installationPositionX; - - @Excel(name = "埋设示意图说明", type = 2, savePath = "img") - @TableField(exist = false) - private String picPath; - - @ApiParam(value = "管口高程") - @ApiModelProperty(value = "管口高程", dataType = "java.lang.Double") - @TableField("PIPE_TOP_HEIGHT") - private Double pipeTopHeight; - - @ApiParam(value = "管底高程") - @ApiModelProperty(value = "管底高程", dataType = "java.lang.Double") - @TableField("PIPE_BOTTOM_HEIGHT") - private Double pipeBottomHeight; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceRobot.java b/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceRobot.java deleted file mode 100644 index f7f9e2c..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceRobot.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.whdc.zhdbaqapi.model.entity; - -import lombok.Data; - -@Data -public class DeviceRobot { - private RobotPoint point; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceRobotData.java b/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceRobotData.java deleted file mode 100644 index f0cf9cd..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceRobotData.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.whdc.zhdbaqapi.model.entity; - -import cn.afterturn.easypoi.excel.annotation.Excel; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonInclude; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotEmpty; -import java.math.BigDecimal; -import java.util.Date; - -@Data -@TableName("DSM_COORDINATES") -@Accessors(chain = true) // chain = true 实现链式调用 -@ApiModel(value = "DSM_COORDINATES 对象", description = "GNSS设备监测数据") -@JsonInclude(JsonInclude.Include.ALWAYS) // 表示序列化非null属性 -public class DeviceRobotData { - /** - * 主键id - */ - @ApiParam(value = "主键id") - @ApiModelProperty(value = "主键id", dataType = "java.lang.Integer") - @TableId(value = "ID", type = IdType.AUTO) - private Integer id; - - /** - * 关联POINTS表的ID - */ - @ApiParam(value = "关联POINTS表的ID") - @ApiModelProperty(value = "关联POINTS表的ID", dataType = "java.lang.Integer") - @Excel(name = "关联POINTS表的ID") - @NotEmpty(message = "关联POINTS表的ID") - @TableField("POINT_ID") - private Integer pointId; - - /** - * 测点ID - */ - @ApiParam(value = "测点ID") - @ApiModelProperty(value = "测点ID", dataType = "java.lang.String", required = true) - @Excel(name = "测点ID") - @NotEmpty(message = "测点ID") - @TableField("TPS_SETUP_ID") - private String tpsSetupId; - - /** - * 初始值更新时间 - */ - @ApiParam(value = "初始值更新时间") - @ApiModelProperty(value = "初始值更新时间", dataType = "java.util.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - @Excel(name = "初始值更新时间") - @TableField("EPOCH") - private Date epoch; - - /** - * 东坐标 - */ - @ApiParam(value = "东坐标") - @ApiModelProperty(value = "东坐标", dataType = "java.math.BigDecimal") - @Excel(name = "东坐标") - @TableField("EASTING") - private BigDecimal easting; - - /** - * 北坐标 - */ - @ApiParam(value = "北坐标") - @ApiModelProperty(value = "北坐标", dataType = "java.math.BigDecimal") - @Excel(name = "北坐标") - @TableField("NORTHING") - private BigDecimal northing; - - /** - * 高程 - */ - @ApiParam(value = "高程") - @ApiModelProperty(value = "高程", dataType = "java.math.BigDecimal") - @Excel(name = "高程") - @TableField("HEIGHT") - private BigDecimal height; - - /** - * 坐标类型(1初始值,2参考值,3当前值,4扫描值) - */ - @ApiParam(value = "坐标类型") - @ApiModelProperty(value = "坐标类型", dataType = "java.lang.Integer") - @Excel(name = "坐标类型") - @NotEmpty(message = "坐标类型") - @TableField("TYPE") - private Integer type; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceSLData.java b/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceSLData.java deleted file mode 100644 index d6f9fe4..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceSLData.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.whdc.zhdbaqapi.model.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonInclude; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.math.BigDecimal; -import java.util.Date; - -/** - * @author 李赛 - * @date 2022-07-21 23:28 - */ -@Data -@TableName("DEVICE_SL_DATA") -@Accessors(chain = true) // chain = true 实现链式调用 -@ApiModel(value = "DEVICE_SL_DATA 对象", description = "设备数据") -@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性 -public class DeviceSLData { - - /** - * 主键id - */ - @ApiParam(value = "主键id") - @ApiModelProperty(value = "主键id", dataType = "java.lang.Integer") - @TableId(value = "ID", type = IdType.AUTO) - private Integer id; - - /** - * 堰上水头 - */ - @ApiParam(value = "堰上水头") - @ApiModelProperty(value = "堰上水头", dataType = "java.math.BigDecimal") - @TableField("L") - private BigDecimal l; - - /** - * 流量 - */ - @ApiParam(value = "流量") - @ApiModelProperty(value = "流量", dataType = "java.math.BigDecimal") - @TableField("Q") - private BigDecimal q; - /** - * 入库时间 - */ - @ApiParam(value = "入库时间") - @ApiModelProperty(value = "入库时间", dataType = "java.lang.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - @TableField("CREATETIME") - private Date createtime; - - /** - * - */ - @ApiParam(value = "") - @ApiModelProperty(value = "", dataType = "java.math.BigDecimal") - @TableField("DATA_C") - private BigDecimal dataC; - - /** - * - */ - @ApiParam(value = "") - @ApiModelProperty(value = "", dataType = "java.math.BigDecimal") - @TableField("DATA_B") - private BigDecimal dataB; - - /** - * - */ - @ApiParam(value = "") - @ApiModelProperty(value = "", dataType = "java.math.BigDecimal") - @TableField("DATA_A") - private BigDecimal dataA; - - /** - * 通道号 - */ - @ApiParam(value = "通道号") - @ApiModelProperty(value = "通道号", dataType = "java.lang.Integer") - @TableField("CHANNEL_NUM") - private Integer channelNum; - - /** - * 数据时间 - */ - @ApiParam(value = "数据时间") - @ApiModelProperty(value = "数据时间", dataType = "java.lang.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - @TableField("TIMESTAMP") - private Date timestamp; - - /** - * 测站编码(MCU) - */ - @ApiParam(value = "测站编码(MCU)") - @ApiModelProperty(value = "测站编码(MCU)", dataType = "java.lang.String") - @TableField("DEVICE_ID") - private String deviceId; - -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceSLInfo.java b/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceSLInfo.java deleted file mode 100644 index 11f9ebb..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceSLInfo.java +++ /dev/null @@ -1,468 +0,0 @@ -package com.whdc.zhdbaqapi.model.entity; - -import cn.afterturn.easypoi.excel.annotation.Excel; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonInclude; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; - -/** - * @author 李赛 - * @date 2022-07-21 23:26 - */ -@Data -@TableName("DEVICE_SL_INFO") -@Accessors(chain = true) // chain = true 实现链式调用 -@ApiModel(value = "DEVICE_SL 对象", description = "渗流设备信息") -@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性 -public class DeviceSLInfo implements Serializable { - private static final long serialVersionUID = 1L; - - public static final String FORMULA_ZHIXIAN = "直线"; //Delta(L) = G*(R1-R0) - public static final String FORMULA_DUOXIANGSHI = "多项式"; //Delta(L) = A*R0*R0+B*R0+C-(A*R1*R1+B*R1+C) - - /** - * 主键id - */ - @ApiParam(value = "主键id") - @ApiModelProperty(value = "主键id", dataType = "java.lang.Integer") - @TableId(value = "ID", type = IdType.AUTO) - protected Integer id; - - //region ====================必填信息==================== - /** - * 测点编号 - */ - @ApiParam(value = "测点编号") - @ApiModelProperty(value = "测点编号", dataType = "java.lang.String", required = true) - @Excel(name = "测点编号") - @NotEmpty(message = "测点编号必填") - @TableField("STATION_CODE") - protected String stationCode; - - /** - * 测站编码(MCU) - */ - @ApiParam(value = "测站编码(MCU)") - @ApiModelProperty(value = "测站编码(MCU)", dataType = "java.lang.String", required = true) - @Excel(name = "测站编码(MCU)") - @NotEmpty(message = "测站编码(MCU)必填") - @TableField("DEVICE_ID") - protected String deviceId; - - /** - * 通道号 - */ - @ApiParam(value = "通道号") - @ApiModelProperty(value = "通道号", dataType = "java.lang.Integer", required = true) - @Excel(name = "通道号") - @NotNull(message = "通道号必填") - @Max(message = "通道号最大值 7", value = 7) - @Min(message = "通道号最小值 0", value = 0) - @TableField("CHANNEL_NUM") - protected Integer channelNum; - - /** - * 仪器编号 - */ - @ApiParam(value = "仪器编号") - @ApiModelProperty(value = "仪器编号", dataType = "java.lang.String", required = true) - @Excel(name = "仪器编号") - @TableField("PROBE_SERIAL") - private String probeSerial; - - /** - * 零位读数 - * data_c - */ - @ApiParam(value = "零位读数") - @ApiModelProperty(value = "零位读数", dataType = "java.math.BigDecimal", required = true) - @Excel(name = "零位读数") - @TableField("READING0") - private BigDecimal reading0; - - @ApiParam(value = "公式") - @ApiModelProperty(value = "公式", dataType = "java.lang.String", required = true) - @TableField("FORMULA") - private String formula; - - /** - * 零点高度(mm) - */ - @ApiParam(value = "零点高度(mm)") - @ApiModelProperty(value = "零点高度(mm)", dataType = "java.math.BigDecimal", required = true) - @Excel(name = "零点高度(mm)") - @TableField("ZERO_POINT_HEIGHT") - private BigDecimal zeroPointHeight; - - /** - * 最大堰上水头(m) - */ - @ApiParam(value = "最大堰上水头(m)") - @ApiModelProperty(value = "最大堰上水头(m)", dataType = "java.math.BigDecimal", required = true) - @Excel(name = "最大堰上水头(m)") - @TableField("MAX_H") - private BigDecimal maxH; - - @ApiParam(value = "直线系数G") - @ApiModelProperty(value = "直线系数G", dataType = "java.math.BigDecimal", required = true) - @Excel(name = "直线系数G") - @TableField("G") - private BigDecimal g; - - @ApiParam(value = "多项式系数A") - @ApiModelProperty(value = "多项式系数A", dataType = "java.math.BigDecimal", required = true) - @Excel(name = "多项式系数A") - @TableField("A") - - private BigDecimal a; - - @ApiParam(value = "多项式系数B") - @ApiModelProperty(value = "多项式系数B", dataType = "java.math.BigDecimal", required = true) - @Excel(name = "多项式系数B") - @TableField("B") - private BigDecimal b; - - - @ApiParam(value = "多项式系数C") - @ApiModelProperty(value = "多项式系数C", dataType = "java.math.BigDecimal", required = true) - @Excel(name = "多项式系数C") - @TableField("C") - private BigDecimal c; - - //endregion - - //region ====================设备读数信息==================== - /** - * 安装时温度(℃) - * data_b - */ - @ApiParam(value = "安装时温度(℃)") - @ApiModelProperty(value = "安装时温度(℃)", dataType = "java.math.BigDecimal") - @Excel(name = "安装时温度(℃)") - @TableField("TEMPERATURE0") - private BigDecimal temperature0; - - /** - * 温度(℃) - * data_b - */ - @ApiParam(value = "温度(℃)") - @ApiModelProperty(value = "温度(℃)", dataType = "java.math.BigDecimal") - @Excel(name = "温度(℃)") - @TableField("TEMPERATURE1") - private BigDecimal temperature1; - - /** - * 仪器测值 - */ - @ApiParam(value = "仪器测值") - @ApiModelProperty(value = "仪器测值", dataType = "java.math.BigDecimal") - @Excel(name = "仪器测值") - @TableField("DEVICE_MEASURE") - private BigDecimal deviceMeasure; - - /** - * 埋设后测值 - */ - @ApiParam(value = "埋设后测值") - @ApiModelProperty(value = "埋设后测值", dataType = "java.math.BigDecimal") - @Excel(name = "埋设后测值") - @TableField("DEVICE_MEASURE_AFTER") - private BigDecimal deviceMeasureAfter; - //endregion - - //region ====================安装信息==================== - /** - * 安装高程 - */ - @ApiParam(value = "安装高程") - @ApiModelProperty(value = "安装高程", dataType = "java.lang.Double") - @TableField("INSTALLATION_POSITION_Z") - protected Double installationPositionZ; - - /** - * 安装纬度 - */ - @ApiParam(value = "安装纬度") - @ApiModelProperty(value = "安装纬度", dataType = "java.lang.Double") - @TableField("INSTALLATION_POSITION_Y") - protected Double installationPositionY; - - /** - * 安装经度 - */ - @ApiParam(value = "安装经度") - @ApiModelProperty(value = "安装经度", dataType = "java.lang.Double") - @TableField("INSTALLATION_POSITION_X") - protected Double installationPositionX; - - /** - * 下游水位(m) - */ - @ApiParam(value = "下游水位(m)") - @ApiModelProperty(value = "下游水位(m)", dataType = "java.lang.Double") - @Excel(name = "下游水位") - @TableField("TAILWATER_LEVEL") - private Double tailWaterLevel; - - /** - * 上游水位(m) - */ - @ApiParam(value = "上游水位(m)") - @ApiModelProperty(value = "上游水位(m)", dataType = "java.lang.Double") - @Excel(name = "上游水位") - @TableField("HEADWATER_LEVEL") - private Double headwaterLevel; - - /** - * 天气 - */ - @ApiParam(value = "天气") - @ApiModelProperty(value = "天气", dataType = "java.lang.String") - @Excel(name = "天气") - @TableField("WEATHER") - private String weather; - - /** - * 气温 - */ - @ApiParam(value = "气温") - @ApiModelProperty(value = "气温", dataType = "java.math.BigDecimal") - @Excel(name = "气温") - @TableField("AIR_TEMPERATURE") - private BigDecimal airTemperature; - //endregion - - //region ====================工程信息==================== - /** - * 工程部位 - */ - @ApiParam(value = "工程部位") - @ApiModelProperty(value = "工程部位", dataType = "java.lang.String") - @Excel(name = "工程部位") - @TableField("PROJECT_LOCATION") - private String projectLocation; - - /** - * 项目名称 - */ - @ApiParam(value = "项目名称") - @ApiModelProperty(value = "项目名称", dataType = "java.lang.String") - @Excel(name = "工程或项目名称") - @TableField("PROJECT_NAME") - private String projectName; - - - /** - * 生产厂家 - */ - @ApiParam(value = "生产厂家") - @ApiModelProperty(value = "生产厂家", dataType = "java.lang.String") - @Excel(name = "生产厂家") - @TableField("MANUFACTURER") - private String manufacturer; - - /** - * 站型 - */ - @ApiParam(value = "站型") - @ApiModelProperty(value = "站型", dataType = "java.lang.String") - @Excel(name = "站型") - @TableField("STATION_TYPE") - private String stationType; - - /** - * 堰型 - */ - @ApiParam(value = "堰型") - @ApiModelProperty(value = "堰型", dataType = "java.lang.String") - @Excel(name = "堰型") - @TableField("STANK_TYPE") - private String stankType; - - /** - * 堰板材料 - */ - @ApiParam(value = "堰板材料") - @ApiModelProperty(value = "堰板材料", dataType = "java.lang.String") - @Excel(name = "堰板材料") - @TableField("STANK_MATERIAL") - private String stankMaterial; - - /** - * 堰口至堰槽底距离(mm) - */ - @ApiParam(value = "堰口至堰槽底距离(mm)") - @ApiModelProperty(value = "堰口至堰槽底距离(mm)", dataType = "java.lang.String") - @Excel(name = "堰口至堰槽底距离(mm)") - @TableField("STANK_TOP_TO_BOTTOM_DISTANCE") - private String stankTopToBottomDistance; - - /** - * 堰槽尺寸(mm*mm*mm) - */ - @ApiParam(value = "堰槽尺寸(mm*mm*mm)") - @ApiModelProperty(value = "堰槽尺寸(mm*mm*mm)", dataType = "java.lang.String") - @Excel(name = "堰槽尺寸(mm*mm*mm)") - @TableField("STANK_SIZE") - private String stankSize; - - /** - * 水尺(传感器)形式 - */ - @ApiParam(value = "水尺(传感器)形式") - @ApiModelProperty(value = "水尺(传感器)形式", dataType = "java.lang.String") - @Excel(name = "水尺(传感器)形式") - @TableField("RULER_TYPE") - private String rulerType; - - /** - * 水尺(测针)位置 - */ - @ApiParam(value = "水尺(测针)位置") - @ApiModelProperty(value = "水尺(测针)位置", dataType = "java.lang.String") - @Excel(name = "水尺(测针)位置") - @TableField("RULER_POSITION") - private String rulerPosition; - - /** - * 温度系数(mm/℃) - */ - @ApiParam(value = "温度系数(mm/℃)") - @ApiModelProperty(value = "温度系数(mm/℃)", dataType = "java.math.BigDecimal") - @Excel(name = "温度系数(mm/℃)") - @TableField("TEMPERATURE_MOD") - private BigDecimal temperatureMod; - - /** - * 量测(mm) - */ - @ApiParam(value = "量测(mm)") - @ApiModelProperty(value = "量测(mm)", dataType = "java.math.BigDecimal") - @Excel(name = "量测(mm)") - @TableField("MEASURE") - private BigDecimal measure; - - /** - * 埋设示意图 - */ - @ApiParam(value = "埋设示意图") - @ApiModelProperty(value = "埋设示意图", dataType = "java.lang.String") - @TableField(value = "SKETCH_MAP") - protected String sketchMap; - //endregion - - //region ====================人员信息==================== - /** - * 技术负责人 - */ - @ApiParam(value = "技术负责人") - @ApiModelProperty(value = "技术负责人", dataType = "java.lang.String") - @Excel(name = "技术负责人") - @TableField("DIRECTOR") - protected String director; - - /** - * 校验人 - */ - @ApiParam(value = "校验人") - @ApiModelProperty(value = "校验人", dataType = "java.lang.String") - @Excel(name = "校验人") - @TableField("VERIFIER") - protected String verifier; - - /** - * 埋设及填表人 - */ - @ApiParam(value = "埋设及填表人") - @ApiModelProperty(value = "埋设及填表人", dataType = "java.lang.String") - @Excel(name = "埋设及填表人") - @TableField("OPERATOR") - protected String operator; - - /** - * 监理工程师 - */ - @ApiParam(value = "监理工程师") - @ApiModelProperty(value = "监理工程师", dataType = "java.lang.String") - @Excel(name = "监理工程师") - @TableField("SUPERVISOR") - private String supervisor; - - /** - * 日期 - */ - @ApiParam(value = "日期") - @ApiModelProperty(value = "日期", dataType = "java.util.Date") - @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") - @Excel(name = "日期") - @TableField("INSTALL_DATE") - protected Date installDate; - - /** - * 备注 - */ - @ApiParam(value = "备注") - @ApiModelProperty(value = "备注", dataType = "java.lang.String") - @Excel(name = "备注") - @TableField("REMARK") - private String remark; - //endregion - - //region ====================计算用字段,可能不展示==================== - /** - * 修改时间 - */ - @ApiParam(value = "修改时间") - @ApiModelProperty(value = "修改时间", dataType = "java.util.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - @TableField("MODIFICATION_TIME") - private Date modificationTime; - - /** - * 最后数据同步时间 - */ - @ApiParam(value = "最后数据同步时间") - @ApiModelProperty(value = "最后数据同步时间", dataType = "java.util.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - @TableField("LATEST_REPORTING_TIME") - private Date latestReportingTime; - - /** - * 修改时间 - */ - @ApiParam(value = "修改时间") - @ApiModelProperty(value = "修改时间", dataType = "java.util.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - @TableField("CREATE_TIME") - private Date createTime; - - /** - * 0:删除 1 已逻辑删除 - */ - @ApiParam(value = "0:删除 1 已逻辑删除") - @ApiModelProperty(value = "0:删除 1 已逻辑删除", dataType = "java.lang.Integer") - @TableField("DEL") - private Integer del; - - @Excel(name = "埋设示意图说明", type = 2, savePath = "img") - @TableField(exist = false) - private String picPath; - //endregion -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/entity/ForeignOrg.java b/src/main/java/com/whdc/zhdbaqapi/model/entity/ForeignOrg.java deleted file mode 100644 index af4cf48..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/entity/ForeignOrg.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.whdc.zhdbaqapi.model.entity; - -import lombok.Data; -import lombok.experimental.Accessors; - -@Data -@Accessors(chain = true) // chain = true 实现链式调用 -public class ForeignOrg { - String id; - String parentId; - String departName; - String departNameEn; - String departNameAbbr; - String departOrder; - String description; - String orgCategory; - String orgType; - String orgCode; - String departmentContactUsername; - String ownerOrgCode; - String mobile; - String fax; - String address; - String departNameFn; - String addvcd; - String municipalUnit; - String memo; - String status; - String delFlag; - String qywxIdentifier; - String createBy; - String createTime; - String updateBy; - String updateTime; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/entity/ForeignUserInfo.java b/src/main/java/com/whdc/zhdbaqapi/model/entity/ForeignUserInfo.java deleted file mode 100644 index 5c908d6..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/entity/ForeignUserInfo.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.whdc.zhdbaqapi.model.entity; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -@Data -@Accessors(chain = true) // chain = true 实现链式调用 -public class ForeignUserInfo { - String id; - String username; - String realname; - String avatar; - String birthday; - int sex; - String email; - String phone; - String orgCode; - String orgCodeTxt; - int orgIsExternal; - int status; - int delFlag; - String workNo; - String post; - String telephone; - String createBy; - String createTime; - String updateBy; - String updateTime; - int activitiSync; - int userIdentity; - String departIds; - String relTenantIds; - String clientId; - @JsonProperty(value = "currentOrg") - ForeignOrg currentOrg; - @JsonProperty(value = "currentOwnOrg") - ForeignOrg currentOwnOrg; - String roleCodes; - boolean originalPassword; - boolean simplePassword; - int numberOfErrors; - String addvcd; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/entity/RobotPoint.java b/src/main/java/com/whdc/zhdbaqapi/model/entity/RobotPoint.java deleted file mode 100644 index 65495c0..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/entity/RobotPoint.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.whdc.zhdbaqapi.model.entity; - -import cn.afterturn.easypoi.excel.annotation.Excel; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonInclude; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotEmpty; -import java.math.BigDecimal; -import java.util.Date; - -@Data -@TableName("DSM_POINTS") -@Accessors(chain = true) // chain = true 实现链式调用 -@ApiModel(value = "DSM_POINTS 对象", description = "变形机器人信息") -@JsonInclude(JsonInclude.Include.ALWAYS) // 表示序列化非null属性 -public class RobotPoint { - /** - * 主键id - */ - @ApiParam(value = "主键id") - @ApiModelProperty(value = "主键id", dataType = "java.lang.Integer") - @TableId(value = "ID", type = IdType.AUTO) - protected Integer id; - - /** - * 限差ID - */ - @ApiParam(value = "限差ID") - @ApiModelProperty(value = "限差ID", dataType = "java.lang.Integer") - @Excel(name = "限差ID") - @NotEmpty(message = "限差ID") - @TableField("LIMIT_ID") - private Integer limitId; - - /** - * 参考断面ID - */ - @ApiParam(value = "参考断面ID") - @ApiModelProperty(value = "参考断面ID", dataType = "java.lang.Integer") - @Excel(name = "参考断面ID") - @NotEmpty(message = "参考断面ID") - @TableField("PROFILE_ID") - private Integer profileId; - - /** - * 点名 - */ - @ApiParam(value = "点名") - @ApiModelProperty(value = "点名", dataType = "java.lang.String", required = true) - @Excel(name = "点名") - @NotEmpty(message = "点名") - @TableField("NAME") - private String name; - - /** - * 点名创建时间 - */ - @ApiParam(value = "点名创建时间") - @ApiModelProperty(value = "点名创建时间", dataType = "java.util.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - @Excel(name = "点名创建时间") - @TableField("EPOCH") - private Date epoch; - - /** - * 棱镜高 - */ - @ApiParam(value = "棱镜高") - @ApiModelProperty(value = "棱镜高", dataType = "java.math.BigDecimal") - @Excel(name = "棱镜高") - @TableField("REFLECTOR_HEIGHT") - private BigDecimal reflectorHeight; - - /** - * 棱镜加常数 - */ - @ApiParam(value = "棱镜加常数") - @ApiModelProperty(value = "棱镜加常数", dataType = "java.math.BigDecimal") - @Excel(name = "棱镜加常数") - @TableField("REFLECTOR_CONSTANT") - private BigDecimal reflectorConstant; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/entity/RobotProfile.java b/src/main/java/com/whdc/zhdbaqapi/model/entity/RobotProfile.java deleted file mode 100644 index 8c6089e..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/entity/RobotProfile.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.whdc.zhdbaqapi.model.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; -import lombok.Data; - -@Data -public class RobotProfile { - /** - * 主键id - */ - @ApiParam(value = "主键id") - @ApiModelProperty(value = "主键id", dataType = "java.lang.Integer") - @TableId(value = "ID", type = IdType.AUTO) - protected Integer id; - - -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/entity/SysUser.java b/src/main/java/com/whdc/zhdbaqapi/model/entity/SysUser.java deleted file mode 100644 index 64a4672..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/entity/SysUser.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.whdc.zhdbaqapi.model.entity; - - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.fasterxml.jackson.annotation.JsonInclude; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * @author 李赛 - * @date 2022-07-01 1:15 - */ -@Data -@TableName("SYS_USER") -@Accessors(chain = true) // chain = true 实现链式调用 -@ApiModel(value = "SYS_USER 对象", description = "用户信息") -@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性 -public class SysUser { - @ApiParam(value = "主键ID", example = "") - @ApiModelProperty(value = "主键ID", dataType = "java.lang.Integer") - @TableId(value = "ID", type = IdType.AUTO) - private Integer id; - - @ApiParam(value = "类型", example = "") - @ApiModelProperty(value = "类型", dataType = "java.lang.Integer") - @TableField("TYPE") - private Integer type; - - @ApiParam(value = "密码", example = "") - @ApiModelProperty(value = "密码", dataType = "java.lang.String") - @TableField("PASSWORD") - private String password; - - @ApiParam(value = "登录名", example = "") - @ApiModelProperty(value = "登录名", dataType = "java.lang.String") - @TableField("LOGIN_NAME") - private String loginName; - - @ApiParam(value = "姓名", example = "") - @ApiModelProperty(value = "姓名", dataType = "java.lang.String") - @TableField("NAME") - private String name; - - @ApiParam(value = "外部id", example = "") - @ApiModelProperty(value = "外部id", dataType = "java.lang.String") - @TableField("FOREIGN_ID") - private String foreignId; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/vo/AuthToken.java b/src/main/java/com/whdc/zhdbaqapi/model/vo/AuthToken.java deleted file mode 100644 index f464228..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/vo/AuthToken.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.whdc.zhdbaqapi.model.vo; - -import cn.dev33.satoken.stp.SaTokenInfo; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import org.apache.commons.beanutils.BeanUtils; - -import java.lang.reflect.InvocationTargetException; - -/** - * 原 SaTokenInfo 再 swagger 中没有对应的说明,这里复制一份,加上说明 - * - * @author 李赛 - * @date 2022-07-18 8:10 - * { - * "tokenName": "satoken", // token名称 - * "tokenValue": "e67b99f1-3d7a-4a8d-bb2f-e888a0805633", // token值 - * "isLogin": true, // 此token是否已经登录 - * "loginId": "10001", // 此token对应的LoginId,未登录时为null - * "loginType": "login", // 账号类型标识 - * "tokenTimeout": 2591977, // token剩余有效期 (单位: 秒) - * "sessionTimeout": 2591977, // User-Session剩余有效时间 (单位: 秒) - * "tokenSessionTimeout": -2, // Token-Session剩余有效时间 (单位: 秒) - * "tokenActivityTimeout": -1, // token剩余无操作有效时间 (单位: 秒) - * "loginDevice": "default-device" // 登录设备类型 - * } - */ -@Data -@ApiModel("授权 token 信息") -public class AuthToken extends SaTokenInfo { - @ApiModelProperty("token 名称") - public String tokenName; - - @ApiModelProperty("token 值") - public String tokenValue; - - @ApiModelProperty("token 剩余有效期 (单位: 秒)") - public long tokenTimeout; - - public AuthToken(SaTokenInfo info) throws InvocationTargetException, IllegalAccessException { - BeanUtils.copyProperties(this, info); - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/vo/DeviceDataVo.java b/src/main/java/com/whdc/zhdbaqapi/model/vo/DeviceDataVo.java deleted file mode 100644 index 13d5ef6..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/vo/DeviceDataVo.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.whdc.zhdbaqapi.model.vo; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonInclude; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotEmpty; -import java.math.BigDecimal; -import java.util.Date; - -/** - * @author 李赛 - * @date 2022-07-22 0:42 - */ -@Data -@Accessors(chain = true) // chain = true 实现链式调用 -@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性 -public class DeviceDataVo { - - /** - * 主键id - */ - @ApiParam(value = "主键id") - @ApiModelProperty(value = "主键id", dataType = "java.lang.Integer") - private Integer id; - - /** - * 渗压值 - */ - @ApiParam(value = "渗压值") - @ApiModelProperty(value = "渗压值", dataType = "java.math.BigDecimal") - private BigDecimal osmometer; - - /** - * 通道类型。=5时, data_a 频率,data_b 温度 - */ - @ApiParam(value = "通道类型。=5时, data_a 频率,data_b 温度") - @ApiModelProperty(value = "通道类型。=5时, data_a 频率,data_b 温度", dataType = "java.lang.String") - private String channelType; - - /** - * 入库时间 - */ - @ApiParam(value = "入库时间") - @ApiModelProperty(value = "入库时间", dataType = "java.lang.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - private Date createtime; - - /** - * - */ - @ApiParam(value = "") - @ApiModelProperty(value = "", dataType = "java.math.BigDecimal") - private BigDecimal dataC; - - /** - * - */ - @ApiParam(value = "") - @ApiModelProperty(value = "", dataType = "java.math.BigDecimal") - private BigDecimal dataB; - - /** - * - */ - @ApiParam(value = "") - @ApiModelProperty(value = "", dataType = "java.math.BigDecimal") - private BigDecimal dataA; - - /** - * 通道号 - */ - @ApiParam(value = "通道号") - @ApiModelProperty(value = "通道号", dataType = "java.lang.Integer") - private Integer channelNum; - - /** - * 数据时间 - */ - @ApiParam(value = "数据时间") - @ApiModelProperty(value = "数据时间", dataType = "java.lang.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - private Date timestamp; - - /** - * 测站编码(MCU) - */ - @ApiParam(value = "测站编码(MCU)") - @ApiModelProperty(value = "测站编码(MCU)", dataType = "java.lang.String") - private String deviceId; - - - /** - * 测点编号 - */ - @ApiParam(value = "测点编号") - @ApiModelProperty(value = "测点编号", dataType = "java.lang.String", required = true) - @NotEmpty(message = "测点编号必填") - private String stationCode; - - /** - * 管内水位 - */ - @ApiParam(value = "管内水位") - @ApiModelProperty(value = "管内水位", dataType = "java.math.BigDecimal") - private BigDecimal pipeZ; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/vo/DeviceInfoImpVo.java b/src/main/java/com/whdc/zhdbaqapi/model/vo/DeviceInfoImpVo.java deleted file mode 100644 index ae0bb95..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/vo/DeviceInfoImpVo.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.whdc.zhdbaqapi.model.vo; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.whdc.zhdbaqapi.model.entity.DeviceInfo; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.List; - -/** - * @author 李赛 - * @date 2022-07-22 11:42 - */ -@Data -@Accessors(chain = true) // chain = true 实现链式调用 -@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性 -public class DeviceInfoImpVo { - @ApiModelProperty("成功读取记录条数") - private int load; - - @ApiModelProperty("成功入库记录条数") - private int success; - - @ApiModelProperty("入库失败记录条数") - private int fail; - - @ApiModelProperty("入库失败记录") - private List err; - - @ApiModelProperty("消息") - private String msg; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/vo/DeviceSLDataVo.java b/src/main/java/com/whdc/zhdbaqapi/model/vo/DeviceSLDataVo.java deleted file mode 100644 index 91f714c..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/vo/DeviceSLDataVo.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.whdc.zhdbaqapi.model.vo; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonInclude; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiParam; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotEmpty; -import java.math.BigDecimal; -import java.util.Date; - -/** - * @author 李赛 - * @date 2022-07-22 0:42 - */ -@Data -@Accessors(chain = true) // chain = true 实现链式调用 -@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性 -public class DeviceSLDataVo { - - /** - * 主键id - */ - @ApiParam(value = "主键id") - @ApiModelProperty(value = "主键id", dataType = "java.lang.Integer") - private Integer id; - - /** - * 入库时间 - */ - @ApiParam(value = "入库时间") - @ApiModelProperty(value = "入库时间", dataType = "java.lang.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - private Date createtime; - - /** - * - */ - @ApiParam(value = "") - @ApiModelProperty(value = "", dataType = "java.math.BigDecimal") - private BigDecimal dataC; - - /** - * - */ - @ApiParam(value = "") - @ApiModelProperty(value = "", dataType = "java.math.BigDecimal") - private BigDecimal dataB; - - /** - * - */ - @ApiParam(value = "") - @ApiModelProperty(value = "", dataType = "java.math.BigDecimal") - private BigDecimal dataA; - - @ApiParam(value = "") - @ApiModelProperty(value = "", dataType = "java.math.BigDecimal") - private BigDecimal q; - /** - * 通道号 - */ - @ApiParam(value = "通道号") - @ApiModelProperty(value = "通道号", dataType = "java.lang.Integer") - private Integer channelNum; - - /** - * 数据时间 - */ - @ApiParam(value = "数据时间") - @ApiModelProperty(value = "数据时间", dataType = "java.lang.Date") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - private Date timestamp; - - /** - * 测站编码(MCU) - */ - @ApiParam(value = "测站编码(MCU)") - @ApiModelProperty(value = "测站编码(MCU)", dataType = "java.lang.String") - private String deviceId; - - - /** - * 测点编号 - */ - @ApiParam(value = "测点编号") - @ApiModelProperty(value = "测点编号", dataType = "java.lang.String", required = true) - @NotEmpty(message = "测点编号必填") - private String stationCode; - - /** - * 计算值 - */ - @ApiParam(value = "计算值") - @ApiModelProperty(value = "计算值", dataType = "java.math.BigDecimal") - private BigDecimal data; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/vo/DeviceSLInfoImpVo.java b/src/main/java/com/whdc/zhdbaqapi/model/vo/DeviceSLInfoImpVo.java deleted file mode 100644 index 36667a6..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/vo/DeviceSLInfoImpVo.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.whdc.zhdbaqapi.model.vo; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.whdc.zhdbaqapi.model.entity.DeviceSLInfo; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.List; - -/** - * @author 李赛 - * @date 2022-07-22 11:42 - */ -@Data -@Accessors(chain = true) // chain = true 实现链式调用 -@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性 -public class DeviceSLInfoImpVo { - @ApiModelProperty("成功读取记录条数") - private int load; - - @ApiModelProperty("成功入库记录条数") - private int success; - - @ApiModelProperty("入库失败记录条数") - private int fail; - - @ApiModelProperty("入库失败记录") - private List err; - - @ApiModelProperty("消息") - private String msg; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/model/vo/LoginVo.java b/src/main/java/com/whdc/zhdbaqapi/model/vo/LoginVo.java deleted file mode 100644 index 7c18373..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/model/vo/LoginVo.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.whdc.zhdbaqapi.model.vo; - -import cn.dev33.satoken.stp.SaTokenInfo; -import com.fasterxml.jackson.annotation.JsonInclude; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.List; - -/** - * @author 李赛 - * @date 2022-07-01 1:22 - */ -@Data -@Accessors(chain = true) // chain = true 实现链式调用 -@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性 -public class LoginVo { - @ApiModelProperty(value = "主键ID") - private Integer id; - - @ApiModelProperty(value = "类型") - private Integer type; - - @ApiModelProperty(value = "登录名") - private String loginName; - - @ApiModelProperty(value = "姓名") - private String name; - - @ApiModelProperty(value = "token 信息") - private AuthToken tokenInfo; - - @ApiModelProperty(value = "角色列表") - private List roleList; -} diff --git a/src/main/java/com/whdc/zhdbaqapi/service/IDeviceDataService.java b/src/main/java/com/whdc/zhdbaqapi/service/IDeviceDataService.java deleted file mode 100644 index 7a9fd08..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/service/IDeviceDataService.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.whdc.zhdbaqapi.service; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.IService; -import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; -import com.whdc.zhdbaqapi.model.entity.DeviceData; -import com.whdc.zhdbaqapi.model.vo.DeviceDataVo; - -/** - * @author 李赛 - * @date 2022-07-22 0:45 - */ -public interface IDeviceDataService extends IService { - - /** - * 分页查询 - * - * @param findDto - * @return - */ - IPage page(FindDeviceDto findDto); - - /** - * 同步数据 - */ - void syncData(); -} diff --git a/src/main/java/com/whdc/zhdbaqapi/service/IDeviceInfoService.java b/src/main/java/com/whdc/zhdbaqapi/service/IDeviceInfoService.java deleted file mode 100644 index 29d6296..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/service/IDeviceInfoService.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.whdc.zhdbaqapi.service; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.IService; -import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; -import com.whdc.zhdbaqapi.model.entity.DeviceInfo; -import com.whdc.zhdbaqapi.model.vo.DeviceInfoImpVo; - -import java.io.InputStream; -import java.util.List; - -/** - * @author 李赛 - * @date 2022-07-21 23:47 - */ -public interface IDeviceInfoService extends IService { - - DeviceInfo get(Integer id); - - /** - * 恢复 - * - * @param id - * @return - */ - boolean restore(Integer id); - - /** - * 返回查询 - * - * @return - */ - List list(String stationCode); - - List listAll(); - boolean updateByIdInternal(DeviceInfo entity); - /** - * 分页查询 - * - * @param findDto - * @return - */ - IPage page(FindDeviceDto findDto); - - /** - * 导入 - * - * @param file - * @return - */ - DeviceInfoImpVo imp(InputStream file); - - void clearCache(); -} diff --git a/src/main/java/com/whdc/zhdbaqapi/service/IDeviceSLDataService.java b/src/main/java/com/whdc/zhdbaqapi/service/IDeviceSLDataService.java deleted file mode 100644 index 47b4a85..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/service/IDeviceSLDataService.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.whdc.zhdbaqapi.service; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.IService; -import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; -import com.whdc.zhdbaqapi.model.entity.DeviceSLData; -import com.whdc.zhdbaqapi.model.vo.DeviceSLDataVo; - -/** - * @author 李赛 - * @date 2022-07-22 0:45 - */ -public interface IDeviceSLDataService extends IService { - - /** - * 分页查询 - * - * @param findDto - * @return - */ - IPage page(FindDeviceDto findDto); - - /** - * 同步数据 - */ - void syncData(); -} diff --git a/src/main/java/com/whdc/zhdbaqapi/service/IDeviceSLInfoService.java b/src/main/java/com/whdc/zhdbaqapi/service/IDeviceSLInfoService.java deleted file mode 100644 index 123ae90..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/service/IDeviceSLInfoService.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.whdc.zhdbaqapi.service; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.IService; -import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; -import com.whdc.zhdbaqapi.model.entity.DeviceInfo; -import com.whdc.zhdbaqapi.model.entity.DeviceSLInfo; -import com.whdc.zhdbaqapi.model.vo.DeviceInfoImpVo; -import com.whdc.zhdbaqapi.model.vo.DeviceSLInfoImpVo; - -import java.io.InputStream; -import java.util.List; - -/** - * @author 李赛 - * @date 2022-07-21 23:47 - */ -public interface IDeviceSLInfoService extends IService { - - DeviceSLInfo get(Integer id); - - /** - * 恢复 - * - * @param id - * @return - */ - boolean restore(Integer id); - - /** - * 返回查询 - * - * @return - */ - List list(String stationCode); - - List listAll(); - - boolean updateByIdInternal(DeviceSLInfo entity); - - /** - * 分页查询 - * - * @param findDto - * @return - */ - IPage page(FindDeviceDto findDto); - - /** - * 导入 - * - * @param file - * @return - */ - DeviceSLInfoImpVo imp(InputStream file); - - void clearCache(); -} diff --git a/src/main/java/com/whdc/zhdbaqapi/service/ISysUserService.java b/src/main/java/com/whdc/zhdbaqapi/service/ISysUserService.java deleted file mode 100644 index 696a81b..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/service/ISysUserService.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.whdc.zhdbaqapi.service; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.IService; -import com.whdc.zhdbaqapi.model.dto.ChangePwdDto; -import com.whdc.zhdbaqapi.model.dto.FindSysUserDto; -import com.whdc.zhdbaqapi.model.dto.LoginDto; -import com.whdc.zhdbaqapi.model.entity.SysUser; -import com.whdc.zhdbaqapi.model.vo.LoginVo; - -/** - * @author 李赛 - * @date 2022-07-01 1:20 - */ -public interface ISysUserService extends IService { - /** - * 返回所有 - * - * @return - */ - LoginVo login(LoginDto obj); - - SysUser getById(Integer id); - - /** - * 分页查询 - * - * @param findDto - * @return - */ - IPage page(FindSysUserDto findDto); - - /** - * 修改密码 - * @param obj - * @return - */ - Boolean changePwd(ChangePwdDto obj); - - SysUser getByForeignId(String foreignId); -} diff --git a/src/main/java/com/whdc/zhdbaqapi/service/impl/DeviceDataServiceImpl.java b/src/main/java/com/whdc/zhdbaqapi/service/impl/DeviceDataServiceImpl.java deleted file mode 100644 index 50cef1d..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/service/impl/DeviceDataServiceImpl.java +++ /dev/null @@ -1,185 +0,0 @@ -package com.whdc.zhdbaqapi.service.impl; - -import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.whdc.zhdbaqapi.mapper.DeviceDataMapper; -import com.whdc.zhdbaqapi.model.cklat.CklatQueryDto; -import com.whdc.zhdbaqapi.model.cklat.CklatRecord; -import com.whdc.zhdbaqapi.model.cklat.CklatResult; -import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; -import com.whdc.zhdbaqapi.model.entity.DeviceData; -import com.whdc.zhdbaqapi.model.entity.DeviceInfo; -import com.whdc.zhdbaqapi.model.vo.DeviceDataVo; -import com.whdc.zhdbaqapi.service.IDeviceDataService; -import com.whdc.zhdbaqapi.service.IDeviceInfoService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; -import org.springframework.web.client.RestTemplate; - -import java.math.BigDecimal; -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -/** - * @author 李赛 - * @date 2022-07-22 0:46 - */ -@Slf4j -@Service -@Configuration -public class DeviceDataServiceImpl extends ServiceImpl implements IDeviceDataService { - - - @Value("${cklat_data_api}") - private String cklat_data_api; - - @Value("${o_z_modulus}") - private Double o_z_modulus; - - @Autowired - private IDeviceInfoService iDeviceInfoService; - - @Autowired - private RestTemplate restTemplate; - - @Autowired - private RedisTemplate redisTemplate; - -// private static ObjectMapper objectMapper = new ObjectMapper(); - - @Override - public IPage page(FindDeviceDto findDto) { - return baseMapper.page(findDto.getPage(), findDto); - } - - - public List getRemoteData(String deviceId, Integer channelNum, Date tm) { - try { - CklatQueryDto query = new CklatQueryDto() - .setDeviceId(deviceId) - .setStartTimestamp(tm) - .setChannelNum(channelNum); - - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_JSON); - HttpEntity request = new HttpEntity(JSON.toJSONString(query), headers); - - ResponseEntity result = restTemplate.postForEntity(cklat_data_api, request, CklatResult.class); - - CklatResult ret = result.getBody(); - - if (ret != null && "success".equals(ret.getStatus())) { - return ret.getRows(); - } - - return null; - } catch (Exception e) { - log.error(e.getMessage(), e); - return null; - } - } - - @Override - public void syncData() { - List list = iDeviceInfoService.listAll(); - boolean changeDi = false; - - for (DeviceInfo di : list) { - String deviceId = di.getDeviceId(); - Date lasttm = di.getLatestReportingTime(); - Calendar c = Calendar.getInstance(); - - if (lasttm == null) { - c.add(Calendar.DATE, -31); // 取近 31 天的数据 - } else { - c.setTime(lasttm); - c.add(Calendar.SECOND, 1); // 传最后数据时间,会一直拉到最后一条记录,所以这里加了一秒 - } - - lasttm = c.getTime(); - - List rows = getRemoteData(deviceId, di.getChannelNum(), lasttm); - - if (rows == null || rows.isEmpty()) { - log.debug("没有取到数据 " + deviceId + ", " + di.getChannelNum()); - continue; - } - - int cnt = 0; - - for (CklatRecord record : rows) { - // 数据量不大,逐条插入,避免部分数据错误导致批量插入失败 - try { - DeviceData dd = new DeviceData() - .setDeviceId(record.getDeviceId()) - .setChannelType("5") - .setChannelNum(record.getChannelNum()) - .setTimestamp(record.getTimestamp()) - .setDataA(record.getDataA()) - .setDataB(record.getDataB()) - .setDataC(record.getDataC()); - - BigDecimal R0 = di.getInitialReading();// initialReading 初始读数 - BigDecimal G = di.getCalibrationCoefficient(); // calibrationCoefficient 率定系数(G) - BigDecimal T0 = di.getStartTemperature(); // startTemperature 初始温度读数 - BigDecimal K = di.getTemperatureK(); // temperatureK 初始温度读数 - - if (R0 == null || G == null || T0 == null || K == null) { - log.debug("参数数据不完整"); - } else { - // 计算公式 压力(P,单位 kPa) = G (R1 - R0) + K(T1 - T0) - // 2022-08-03 R 是模数,模数 = 频率的平方 / 1000 - - BigDecimal T1 = record.getDataB(); - BigDecimal R1 = record.getDataA(); - - R1 = R1.multiply(R1).divide(BigDecimal.valueOf(1000), 6, BigDecimal.ROUND_HALF_UP); - - BigDecimal R3 = R1.subtract(R0); - BigDecimal T3 = T1.subtract(T0); - BigDecimal GR = G.multiply(R3); - BigDecimal KT = K.multiply(T3); - BigDecimal decimal = GR.add(KT); - - dd.setOsmometer(decimal); -// dd.setPipeZ(decimal.multiply(BigDecimal.valueOf(o_z_modulus))); - //加“渗压计到孔底距离”,浮点(三位小数)同步数据时计算出的管水位加上这个数值 - // 2022-10-08 lyf -// dd.setPipeZ(decimal.multiply(BigDecimal.valueOf(o_z_modulus)).add(BigDecimal.valueOf(di.getDistFromOsmosisMeterToBottom()))); - // 2022-10-27 lyf - //修改渗压入库公式:在计算时,用“埋设高程”代替“渗压计到孔底距离”字段 - System.out.println("修改渗压入库公式:在计算时,用“埋设高程”代替“渗压计到孔底距离”字段"); - System.out.println(di.getStationCode() + "---" + di.getEmbeddingElevation()); - dd.setPipeZ(decimal.multiply(BigDecimal.valueOf(o_z_modulus)).add(di.getEmbeddingElevation())); - } - - if (super.save(dd)) { - cnt += 1; - - di.setLatestReportingTime(dd.getTimestamp()); - iDeviceInfoService.updateByIdInternal(di); - changeDi = true; - } - } catch (Exception e) { - log.error(e.getMessage(), e); - } - } - - log.debug("拉取 " + rows.size() + " 保存 " + cnt); - } - - if (changeDi) { - iDeviceInfoService.clearCache(); - } - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/service/impl/DeviceInfoServiceimpl.java b/src/main/java/com/whdc/zhdbaqapi/service/impl/DeviceInfoServiceimpl.java deleted file mode 100644 index 9687de1..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/service/impl/DeviceInfoServiceimpl.java +++ /dev/null @@ -1,236 +0,0 @@ -package com.whdc.zhdbaqapi.service.impl; - -import cn.afterturn.easypoi.excel.ExcelImportUtil; -import cn.afterturn.easypoi.excel.entity.ImportParams; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.whdc.zhdbaqapi.constant.Constants; -import com.whdc.zhdbaqapi.exception.MyException; -import com.whdc.zhdbaqapi.mapper.DeviceDataMapper; -import com.whdc.zhdbaqapi.mapper.DeviceInfoMapper; -import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; -import com.whdc.zhdbaqapi.model.entity.DeviceInfo; -import com.whdc.zhdbaqapi.model.vo.DeviceInfoImpVo; -import com.whdc.zhdbaqapi.service.IDeviceInfoService; -import com.whdc.zhdbaqapi.utils.DataUtils; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.io.InputStream; -import java.io.Serializable; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; - -/** - * @author 李赛 - * @date 2022-07-21 23:47 - */ -@Service -public class DeviceInfoServiceimpl extends ServiceImpl implements IDeviceInfoService { - @Autowired - private RedisTemplate redisTemplate; - @Autowired - private DeviceDataMapper deviceDataMapper; - - private static long defaultTimeStamp; - - static { - try { - defaultTimeStamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2022-07-01 00:00:00").getTime(); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - - @Override - public DeviceInfo get(Integer id) { - DeviceInfo ret = baseMapper.get(id); - - return ret; - } - - @Override - @CacheEvict(Constants.CACHE_NAME) - public boolean save(DeviceInfo entity) { - if (baseMapper.checkValidStationCode(entity.getStationCode()) != null) { - throw new MyException("stationCode=" + entity.getStationCode() + " 已被其他有效数据使用,不能恢复"); - } - - entity.setCreateDate(new Date()); - return super.save(entity); - } - - @Override - @CacheEvict(Constants.CACHE_NAME) - public boolean updateById(DeviceInfo entity) { - DeviceInfo old = baseMapper.checkValidStationCode(entity.getStationCode()); - if (old == null) { - throw new MyException("stationCode=" + entity.getStationCode() + " 没有找到"); - } - if (old != null && !old.getId().equals(entity.getId())) { - throw new MyException("stationCode=" + entity.getStationCode() + " 已被其他有效数据使用,不能恢复"); - } - entity.setModificationTime(new Date()); - System.out.println("=============================="); - System.out.println(old.getChannelNum()); - System.out.println(entity.getChannelNum()); - System.out.println("=============================="); - if ( - !old.getChannelNum().equals(entity.getChannelNum()) - || !old.getStationCode().equals(entity.getStationCode()) - || !old.getInitialReading().equals(entity.getInitialReading()) - || !old.getStartTemperature().equals(entity.getStartTemperature()) - || !old.getCalibrationCoefficient().equals(entity.getCalibrationCoefficient()) - || !old.getTemperatureK().equals(entity.getTemperatureK()) - || !old.getDeviceId().equals(entity.getDeviceId()) - || !old.getDistFromOsmosisMeterToBottom().equals(entity.getDistFromOsmosisMeterToBottom()) - || !old.getEmbeddingElevation().equals(entity.getEmbeddingElevation()) - ) { - entity.setLatestReportingTime(new Date(defaultTimeStamp)); - deviceDataMapper.clearByDeviceId(entity.getDeviceId(), entity.getChannelNum()); - } - redisTemplate.delete(Constants.CACHE_NAME); - return super.updateById(entity); - } - - @Override - @CacheEvict(Constants.CACHE_NAME) - public boolean updateByIdInternal(DeviceInfo entity) { - DeviceInfo old = baseMapper.checkValidStationCode(entity.getStationCode()); - if (old != null && !old.getId().equals(entity.getId())) { - throw new MyException("stationCode=" + entity.getStationCode() + " 已被其他有效数据使用,不能恢复"); - } - entity.setModificationTime(new Date()); - redisTemplate.delete(Constants.CACHE_NAME); - return super.updateById(entity); - } - - @Override - @CacheEvict(Constants.CACHE_NAME) - public boolean removeById(Serializable id) { - DeviceInfo entity = baseMapper.selectById(id); - entity.setDel(1); - return super.updateById(entity); - } - - @Override - @CacheEvict(Constants.CACHE_NAME) - public boolean restore(Integer id) { - DeviceInfo entity = baseMapper.selectById(id); - - if (entity == null) { - return false; - } - - if (baseMapper.checkValidStationCode(entity.getStationCode()) != null) { - throw new MyException(entity.getStationCode() + " 已被其他有效数据使用,不能恢复"); - } - - entity.setDel(0); - return super.updateById(entity); - } - - @Override - public List list(String stationCode) { - return baseMapper.list(stationCode); - } - - @Override - @Cacheable(Constants.CACHE_NAME) - public List listAll() { - return baseMapper.listAll(); - } - - @Override - public IPage page(FindDeviceDto findDto) { - return baseMapper.page(findDto.getPage(), findDto); - } - - @Override - @Transactional - public DeviceInfoImpVo imp(InputStream file) { - ImportParams params = new ImportParams(); - params.setHeadRows(1); - params.setNeedSave(false); - try { - List list = ExcelImportUtil.importExcel(file, DeviceInfo.class, params); - - if (list == null || list.isEmpty()) { - return new DeviceInfoImpVo().setLoad(0).setSuccess(0).setFail(0).setMsg("没有读取有有效数据"); - } - - List err = new ArrayList<>(); - List impList = new ArrayList<>(); - Set scs = new HashSet<>(); - Map chkMap = new HashMap<>(); - - for (DeviceInfo di : list) { - if (StringUtils.isBlank(di.getStationCode())) { - err.add(di); - } else { - scs.add(di.getStationCode()); - } - } - - if (scs.isEmpty() || err.size() == list.size()) { - return new DeviceInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("没有读取到有效的测点编号"); - } - - if (scs.size() != list.size()) { - return new DeviceInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("有重复的测点编号,请检查后再导入"); - } - - List chkscs = baseMapper.listBySC(scs); - if (chkscs.size() == scs.size()) { - return new DeviceInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("测点编号全部已存在"); - } - - for (DeviceInfo dbdi : chkscs) { - chkMap.put(dbdi.getStationCode(), dbdi); - } - - for (DeviceInfo di : list) { - if (chkMap.containsKey(di.getStationCode())) { - err.add(di); - } else { - if (StringUtils.isNotBlank(di.getPicPath())) { - String filepath = System.getProperty("user.dir") + "/" + di.getPicPath(); - di.setSketchMap(DataUtils.File2Base64(filepath)); - DataUtils.DelFile(filepath); - } - - impList.add(di); - } - } - - if (impList.isEmpty()) { - return new DeviceInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("测点编号全部已存在"); - } - - if (super.saveBatch(impList)) { - clearCache(); - - return new DeviceInfoImpVo().setLoad(list.size()).setSuccess(impList.size()).setFail(err.size()).setErr(err).setMsg("成功"); - } else { - return new DeviceInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("失败"); - } - } catch (Exception e) { - log.error(e.getMessage(), e); - throw new MyException("导入异常!" + e.getMessage()); - } - } - - @Override - public void clearCache() { - Set keys = redisTemplate.keys(Constants.CACHE_NAME + "*"); - for (String k : keys) { - redisTemplate.delete(k); - } - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/service/impl/DeviceSLDataServiceImpl.java b/src/main/java/com/whdc/zhdbaqapi/service/impl/DeviceSLDataServiceImpl.java deleted file mode 100644 index d05dfa7..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/service/impl/DeviceSLDataServiceImpl.java +++ /dev/null @@ -1,192 +0,0 @@ -package com.whdc.zhdbaqapi.service.impl; - -import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.whdc.zhdbaqapi.mapper.DeviceSLDataMapper; -import com.whdc.zhdbaqapi.model.cklat.CklatQueryDto; -import com.whdc.zhdbaqapi.model.cklat.CklatRecord; -import com.whdc.zhdbaqapi.model.cklat.CklatResult; -import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; -import com.whdc.zhdbaqapi.model.entity.DeviceSLData; -import com.whdc.zhdbaqapi.model.entity.DeviceSLInfo; -import com.whdc.zhdbaqapi.model.vo.DeviceSLDataVo; -import com.whdc.zhdbaqapi.service.IDeviceSLDataService; -import com.whdc.zhdbaqapi.service.IDeviceSLInfoService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; -import org.springframework.web.client.RestTemplate; - -import java.math.BigDecimal; -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -/** - * @author 李赛 - * @date 2022-07-22 0:46 - */ -@Slf4j -@Service -@Configuration -public class DeviceSLDataServiceImpl extends ServiceImpl implements IDeviceSLDataService { - - - @Value("${cklat_data_api}") - private String cklat_data_api; - - @Value("${o_z_modulus}") - private Double o_z_modulus; - - @Autowired - private IDeviceSLInfoService iDeviceSLInfoService; - - @Autowired - private RestTemplate restTemplate; - - @Autowired - private RedisTemplate redisTemplate; - -// private static ObjectMapper objectMapper = new ObjectMapper(); - - @Override - public IPage page(FindDeviceDto findDto) { - return baseMapper.page(findDto.getPage(), findDto); - } - - - public List getRemoteData(String deviceId, Integer channelNum, Date tm) { - try { - CklatQueryDto query = new CklatQueryDto() - .setDeviceId(deviceId) - .setStartTimestamp(tm) - .setChannelNum(channelNum); - - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_JSON); - HttpEntity request = new HttpEntity(JSON.toJSONString(query), headers); - - ResponseEntity result = restTemplate.postForEntity(cklat_data_api, request, CklatResult.class); - - CklatResult ret = result.getBody(); - - if (ret != null && "success".equals(ret.getStatus())) { - return ret.getRows(); - } - - return null; - } catch (Exception e) { - log.error(e.getMessage(), e); - return null; - } - } - - @Override - public void syncData() { - List list = iDeviceSLInfoService.listAll(); - boolean changeDi = false; - - for (DeviceSLInfo di : list) { - String deviceId = di.getDeviceId(); - Date lasttm = di.getLatestReportingTime(); - Calendar c = Calendar.getInstance(); - - if (lasttm == null) { - c.add(Calendar.DATE, -31); // 取近 31 天的数据 - } else { - c.setTime(lasttm); - c.add(Calendar.SECOND, 1); // 传最后数据时间,会一直拉到最后一条记录,所以这里加了一秒 - } - - lasttm = c.getTime(); - - List rows = getRemoteData(deviceId, di.getChannelNum(), lasttm); - - if (rows == null || rows.isEmpty()) { - log.debug("没有取到数据 " + deviceId + ", " + di.getChannelNum()); - continue; - } - - int cnt = 0; - - for (CklatRecord record : rows) { - // 数据量不大,逐条插入,避免部分数据错误导致批量插入失败 - try { - DeviceSLData dd = new DeviceSLData() - .setDeviceId(record.getDeviceId()) - .setChannelNum(record.getChannelNum()) - .setTimestamp(record.getTimestamp()) - .setDataA(record.getDataA()) - .setDataB(record.getDataB()) - .setDataC(record.getDataC()); - String formula = di.getFormula(); - BigDecimal R0 = di.getReading0();// initialReading 初始读数 - BigDecimal R1 = record.getDataC();// initialReading 初始读数 - - - if (R0 == null || formula == null) { - log.debug("参数数据不完整"); - } else { - BigDecimal L; - if (formula.equals(DeviceSLInfo.FORMULA_ZHIXIAN)) { - BigDecimal G = di.getG(); - //Delta(L) = G*(R1-R0) - L = G.multiply(R1.subtract(R0)); - } else if (formula.equals(DeviceSLInfo.FORMULA_DUOXIANGSHI)) { - BigDecimal A = di.getA(); - BigDecimal B = di.getB(); - BigDecimal C = di.getC(); - //Delta(L) = A*R0*R0+B*R0+C-(A*R1*R1+B*R1+C) - BigDecimal a = A.multiply(R0.multiply(R0)); - BigDecimal b = B.multiply(R0); - BigDecimal d = A.multiply(R1.multiply(R1)); - BigDecimal e = B.multiply(R1); - L = a.add(b).add(C).subtract(d).subtract(e); - } else { - L = null; - } - dd.setL(L); - - BigDecimal Q; //单位L/s - //Q=1343∗H^2.47 - //H=h+P - BigDecimal P = di.getZeroPointHeight();//单位mm - BigDecimal h = L; //单位mm - BigDecimal H = h.add(P); //单位mm - H = H.divide(BigDecimal.valueOf(1000)); //单位m - BigDecimal maxH = di.getMaxH(); //单位m - if (H.doubleValue() > maxH.doubleValue()) { - Q = new BigDecimal(1343).multiply(BigDecimal.valueOf(Math.pow(maxH.doubleValue(), 2.47))); - } else { - Q = new BigDecimal(1343).multiply(BigDecimal.valueOf(Math.pow(H.doubleValue(), 2.47))); - } - dd.setQ(Q); - } - if (super.save(dd)) { - cnt += 1; - - di.setLatestReportingTime(dd.getTimestamp()); - iDeviceSLInfoService.updateByIdInternal(di); - changeDi = true; - } - } catch (Exception e) { - log.error(e.getMessage(), e); - } - } - - log.debug("拉取 " + rows.size() + " 保存 " + cnt); - } - - if (changeDi) { - iDeviceSLInfoService.clearCache(); - } - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/service/impl/DeviceSLInfoServiceimpl.java b/src/main/java/com/whdc/zhdbaqapi/service/impl/DeviceSLInfoServiceimpl.java deleted file mode 100644 index 0475fae..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/service/impl/DeviceSLInfoServiceimpl.java +++ /dev/null @@ -1,230 +0,0 @@ -package com.whdc.zhdbaqapi.service.impl; - -import cn.afterturn.easypoi.excel.ExcelImportUtil; -import cn.afterturn.easypoi.excel.entity.ImportParams; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.whdc.zhdbaqapi.constant.Constants; -import com.whdc.zhdbaqapi.exception.MyException; -import com.whdc.zhdbaqapi.mapper.DeviceDataMapper; -import com.whdc.zhdbaqapi.mapper.DeviceSLInfoMapper; -import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; -import com.whdc.zhdbaqapi.model.entity.DeviceSLInfo; -import com.whdc.zhdbaqapi.model.vo.DeviceSLInfoImpVo; -import com.whdc.zhdbaqapi.service.IDeviceSLInfoService; -import com.whdc.zhdbaqapi.utils.DataUtils; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.io.InputStream; -import java.io.Serializable; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; - -/** - * @author 李赛 - * @date 2022-07-21 23:47 - */ -@Service -public class DeviceSLInfoServiceimpl extends ServiceImpl implements IDeviceSLInfoService { - @Autowired - private RedisTemplate redisTemplate; - @Autowired - private DeviceDataMapper deviceDataMapper; - - private static long defaultTimeStamp; - - static { - try { - defaultTimeStamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2022-07-01 00:00:00").getTime(); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - - @Override - public DeviceSLInfo get(Integer id) { - DeviceSLInfo ret = baseMapper.get(id); - - return ret; - } - - @Override - @CacheEvict(Constants.CACHE_NAME_SL) - public boolean save(DeviceSLInfo entity) { - if (baseMapper.checkValidStationCode(entity.getStationCode()) != null) { - throw new MyException("stationCode=" + entity.getStationCode() + " 已被其他有效数据使用,不能恢复"); - } - - entity.setCreateTime(new Date()); - return super.save(entity); - } - - @Override - @CacheEvict(Constants.CACHE_NAME_SL) - public boolean updateById(DeviceSLInfo entity) { - DeviceSLInfo old = baseMapper.checkValidStationCode(entity.getStationCode()); - if (old == null) { - throw new MyException("stationCode=" + entity.getStationCode() + " 没有找到"); - } - if (old != null && !old.getId().equals(entity.getId())) { - throw new MyException("stationCode=" + entity.getStationCode() + " 已被其他有效数据使用,不能恢复"); - } - entity.setModificationTime(new Date()); - System.out.println("=============================="); - System.out.println(old.getChannelNum()); - System.out.println(entity.getChannelNum()); - System.out.println("=============================="); - if ( - !old.getChannelNum().equals(entity.getChannelNum()) - || !old.getStationCode().equals(entity.getStationCode()) - || !old.getReading0().equals(entity.getReading0()) - ) { - entity.setLatestReportingTime(new Date(defaultTimeStamp)); - deviceDataMapper.clearByDeviceId(entity.getDeviceId(), entity.getChannelNum()); - } - redisTemplate.delete(Constants.CACHE_NAME_SL); - return super.updateById(entity); - } - - @Override - @CacheEvict(Constants.CACHE_NAME_SL) - public boolean updateByIdInternal(DeviceSLInfo entity) { - DeviceSLInfo old = baseMapper.checkValidStationCode(entity.getStationCode()); - if (old != null && !old.getId().equals(entity.getId())) { - throw new MyException("stationCode=" + entity.getStationCode() + " 已被其他有效数据使用,不能恢复"); - } - entity.setModificationTime(new Date()); - redisTemplate.delete(Constants.CACHE_NAME_SL); - return super.updateById(entity); - } - - @Override - @CacheEvict(Constants.CACHE_NAME_SL) - public boolean removeById(Serializable id) { - DeviceSLInfo entity = baseMapper.selectById(id); - entity.setDel(1); - return super.updateById(entity); - } - - @Override - @CacheEvict(Constants.CACHE_NAME_SL) - public boolean restore(Integer id) { - DeviceSLInfo entity = baseMapper.selectById(id); - - if (entity == null) { - return false; - } - - if (baseMapper.checkValidStationCode(entity.getStationCode()) != null) { - throw new MyException(entity.getStationCode() + " 已被其他有效数据使用,不能恢复"); - } - - entity.setDel(0); - return super.updateById(entity); - } - - @Override - public List list(String stationCode) { - return baseMapper.list(stationCode); - } - - @Override - @Cacheable(Constants.CACHE_NAME_SL) - public List listAll() { - return baseMapper.listAll(); - } - - @Override - public IPage page(FindDeviceDto findDto) { - return baseMapper.page(findDto.getPage(), findDto); - } - - @Override - @Transactional - public DeviceSLInfoImpVo imp(InputStream file) { - ImportParams params = new ImportParams(); - params.setHeadRows(1); - params.setNeedSave(false); - try { - List list = ExcelImportUtil.importExcel(file, DeviceSLInfo.class, params); - - if (list == null || list.isEmpty()) { - return new DeviceSLInfoImpVo().setLoad(0).setSuccess(0).setFail(0).setMsg("没有读取有有效数据"); - } - - List err = new ArrayList<>(); - List impList = new ArrayList<>(); - Set scs = new HashSet<>(); - Map chkMap = new HashMap<>(); - - for (DeviceSLInfo di : list) { - if (StringUtils.isBlank(di.getStationCode())) { - err.add(di); - } else { - scs.add(di.getStationCode()); - } - } - - if (scs.isEmpty() || err.size() == list.size()) { - return new DeviceSLInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("没有读取到有效的测点编号"); - } - - if (scs.size() != list.size()) { - return new DeviceSLInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("有重复的测点编号,请检查后再导入"); - } - - List chkscs = baseMapper.listBySC(scs); - if (chkscs.size() == scs.size()) { - return new DeviceSLInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("测点编号全部已存在"); - } - - for (DeviceSLInfo dbdi : chkscs) { - chkMap.put(dbdi.getStationCode(), dbdi); - } - - for (DeviceSLInfo di : list) { - if (chkMap.containsKey(di.getStationCode())) { - err.add(di); - } else { - if (StringUtils.isNotBlank(di.getPicPath())) { - String filepath = System.getProperty("user.dir") + "/" + di.getPicPath(); - di.setSketchMap(DataUtils.File2Base64(filepath)); - DataUtils.DelFile(filepath); - } - - impList.add(di); - } - } - - if (impList.isEmpty()) { - return new DeviceSLInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("测点编号全部已存在"); - } - - if (super.saveBatch(impList)) { - clearCache(); - - return new DeviceSLInfoImpVo().setLoad(list.size()).setSuccess(impList.size()).setFail(err.size()).setErr(err).setMsg("成功"); - } else { - return new DeviceSLInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("失败"); - } - } catch (Exception e) { - log.error(e.getMessage(), e); - throw new MyException("导入异常!" + e.getMessage()); - } - } - - @Override - public void clearCache() { - Set keys = redisTemplate.keys(Constants.CACHE_NAME_SL + "*"); - for (String k : keys) { - redisTemplate.delete(k); - } - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/service/impl/SysUserServiceImpl.java b/src/main/java/com/whdc/zhdbaqapi/service/impl/SysUserServiceImpl.java deleted file mode 100644 index 31a41ed..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/service/impl/SysUserServiceImpl.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.whdc.zhdbaqapi.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.whdc.zhdbaqapi.constant.Constants; -import com.whdc.zhdbaqapi.exception.MyException; -import com.whdc.zhdbaqapi.mapper.SysUserMapper; -import com.whdc.zhdbaqapi.model.dto.ChangePwdDto; -import com.whdc.zhdbaqapi.model.dto.FindSysUserDto; -import com.whdc.zhdbaqapi.model.dto.LoginDto; -import com.whdc.zhdbaqapi.model.entity.SysUser; -import com.whdc.zhdbaqapi.model.vo.LoginVo; -import com.whdc.zhdbaqapi.service.ISysUserService; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Service; -import org.springframework.util.DigestUtils; - -/** - * @author 李赛 - * @date 2022-07-01 1:26 - */ -@Service -public class SysUserServiceImpl extends ServiceImpl implements ISysUserService { - private static final String TOKENPRE = "token:"; - private static final int EXPTIME = 24 * 60 * 60; // 24 小时 - - @Autowired - private RedisTemplate redisTemplate; - - private String getPassword(String password) { - return DigestUtils.md5DigestAsHex((Constants.PASSWORD_SALT + password).getBytes()); - } - - private SysUser findByLoginName(String loginName) { - QueryWrapper query = new QueryWrapper<>(); - query.eq("login_name", loginName); - - return baseMapper.selectOne(query); - } - - @Override - public boolean updateById(SysUser bean) { - if (StringUtils.isNotBlank(bean.getPassword())) { - bean.setPassword(getPassword(bean.getPassword())); - } - return super.updateById(bean); - } - - @Override - public boolean save(SysUser bean) { - SysUser sysUser = findByLoginName(bean.getLoginName()); - if (sysUser != null) { - throw new MyException("登录名" + bean.getLoginName() + "已存在"); - } - - bean.setPassword(getPassword(bean.getPassword())); - return super.save(bean); - } - - @Override - public LoginVo login(LoginDto obj) { - SysUser sysUser = findByLoginName(obj.getLoginName()); - - if (sysUser == null) { - throw new MyException("用户名或密码错误"); - } - - if (getPassword(obj.getPassword()).equals(sysUser.getPassword())) { - LoginVo out = new LoginVo(); - - BeanUtils.copyProperties(sysUser, out); - - return out; - - } - - throw new MyException("用户名或密码错误"); - } - - @Override - public SysUser getById(Integer id) { - return baseMapper.selectById(id); - } - - @Override - public IPage page(FindSysUserDto findDto) { - return baseMapper.page(findDto.getPage(), findDto); - } - - @Override - public Boolean changePwd(ChangePwdDto obj) { - return null; - } - - public SysUser getByForeignId(String foreignId) { - return baseMapper.findByForeignId(foreignId); - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/utils/HttpUtil.java b/src/main/java/com/whdc/zhdbaqapi/utils/HttpUtil.java deleted file mode 100644 index 3420526..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/utils/HttpUtil.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.whdc.zhdbaqapi.utils; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.nio.charset.StandardCharsets; - -public class HttpUtil { - public static String get(String _url) { - InputStream is = null; - BufferedReader br = null; - HttpURLConnection conn = null; - String jstr = null; - try { - URL url = new URL(_url); - conn = (HttpURLConnection) url.openConnection(); - conn.setRequestMethod("GET"); - conn.setConnectTimeout(5000); - conn.setReadTimeout(5000); - conn.connect(); - if (conn.getResponseCode() == 200) { - is = conn.getInputStream(); - if (is != null) { - br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); - StringBuffer sb = new StringBuffer(); - String tmp = ""; - while ((tmp = br.readLine()) != null) { - sb.append(tmp); - } - jstr = sb.toString(); - return jstr; - } - } - } catch (Exception ignore) { - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException ignore) { - } - } - if (is != null) { - try { - is.close(); - } catch (IOException ignore) { - } - } - if (conn != null) { - try { - conn.disconnect(); - } catch (Exception ignore) { - } - } - } - return null; - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/utils/MongoReceiveTmSerializer.java b/src/main/java/com/whdc/zhdbaqapi/utils/MongoReceiveTmSerializer.java deleted file mode 100644 index f5e329c..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/utils/MongoReceiveTmSerializer.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.whdc.zhdbaqapi.utils; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import org.joda.time.DateTime; - -import java.io.IOException; - -/** - * 强行处理 mongo 存储的几个 Tm 字段时区问题 - * - * @author 李赛 - * @date 2022-07-02 11:22 - */ -public class MongoReceiveTmSerializer extends JsonSerializer { - @Override - public void serialize(Object o, JsonGenerator gen, SerializerProvider serializers) throws IOException { - try { - if (o == null) { - gen.writeNull(); - } else { - gen.writeString(DateUtils.sdfhmsS.get().format(new DateTime(o).toDate())); - } - } catch (Exception e) { - e.printStackTrace(); - gen.writeNull(); - } - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/utils/MongoTmDeserializer.java b/src/main/java/com/whdc/zhdbaqapi/utils/MongoTmDeserializer.java deleted file mode 100644 index 08577ab..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/utils/MongoTmDeserializer.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.whdc.zhdbaqapi.utils; - -import com.fasterxml.jackson.core.JacksonException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import org.joda.time.DateTime; - -import java.io.IOException; -import java.util.Date; - -/** - * @author 李赛 - * @date 2022-07-03 0:10 - */ -public class MongoTmDeserializer extends JsonDeserializer { - @Override - public Date deserialize(JsonParser parser, DeserializationContext context) throws IOException, JacksonException { - try { - return new DateTime(parser.getText()).toDate(); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } -} diff --git a/src/main/java/com/whdc/zhdbaqapi/utils/MongoTmSerializer.java b/src/main/java/com/whdc/zhdbaqapi/utils/MongoTmSerializer.java deleted file mode 100644 index d654976..0000000 --- a/src/main/java/com/whdc/zhdbaqapi/utils/MongoTmSerializer.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.whdc.zhdbaqapi.utils; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; -import org.joda.time.DateTime; - -import java.io.IOException; -import java.util.Calendar; - -/** - * 强行处理 mongo 存储的几个 Tm 字段时区问题 - * - * @author 李赛 - * @date 2022-07-02 11:22 - */ -public class MongoTmSerializer extends JsonSerializer { - @Override - public void serialize(Object o, JsonGenerator gen, SerializerProvider serializers) throws IOException { - try { - if (o == null) { - gen.writeNull(); - } else { - Calendar c = Calendar.getInstance(); - c.setTime(new DateTime(o).toDate()); - c.add(Calendar.HOUR, -8); - - gen.writeString(DateUtils.sdfhmsS.get().format(c.getTime())); - } - } catch (Exception e) { - e.printStackTrace(); - gen.writeNull(); - } - } -} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 97e0709..66f1aa3 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -6,10 +6,12 @@ spring: datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: dm.jdbc.driver.DmDriver - # url: jdbc:dm://120.76.31.37:5236/DAM_SAFE?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8 - url: jdbc:dm://172.20.1.100:5236/DAM_SAFE?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8 - username: DAM_SAFE - password: Dam_safe_890 +# url: jdbc:dm://127.0.0.1:5236?schema=SYSDBA +# username: SYSDBA +# password: 199999999 + url: jdbc:dm://10.42.6.142:5236?schema=SHZH + username: SHZH + password: Shzh_890 druid: initialSize: 5 minIdle: 5 @@ -32,11 +34,24 @@ spring: # Redis redis: - database: 4 - host: 127.0.0.1 + database: 5 + host: 10.42.6.75 port: 6379 password: Whdc_890 + # 数据清洗专用redis + redisRules: + database: 6 + host: 10.42.6.75 + port: 6379 + password: Whdc_890 + timeout: 60000 + lettuce: + pool: + max-active: 50 + max-idle: 50 + min-idle: 1 + max-wait: 50000 servlet: multipart: @@ -62,27 +77,8 @@ logging: level.org.springframework.boot.autoconfigure: error #spring的自动装配日志只打error,否则debug输出的会打印很多自动装配的log信息到控制台 config: classpath:logback-spring.xml -# Sa-Token配置 -sa-token: - # token 名称 (同时也是cookie名称) - token-name: token - # token 有效期, 24小时,单位s, -1代表永不过期 - timeout: 86400 - # token 临时有效期 (指定时间内无操作就视为token过期) 单位: 秒 - activity-timeout: -1 - # 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录) - is-concurrent: true - # 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token) - is-share: false - # token风格 - token-style: simple-uuid - # 是否输出操作日志 - is-log: false - -# 大坝安全监测数据获取接口 -cklat_data_api: http://172.20.1.202:8008/api/v1/devices/records - -# 渗压换算管内水位系数 -o_z_modulus: 0.10197 - - +mybatis-plus: + global-config: + db-config: + update-strategy: not_empty + insert-strategy: not_empty diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index 6104deb..a7f2a35 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -191,6 +191,14 @@ + + + + + + + +