初始化
commit
7c67b5ac20
|
|
@ -0,0 +1,44 @@
|
|||
# Log files
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
|
||||
/target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.DS_Store
|
||||
.mvn
|
||||
mvnw
|
||||
mvnw.cmd
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
node_modules
|
||||
/dist
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/build/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
logs/
|
||||
/logs/
|
||||
/logs/**
|
||||
/.nb-gradle/
|
||||
yus-water/logs/
|
||||
*.vm
|
||||
**/target/**
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
# 漳河大坝安全api
|
||||
|
||||
## 目录
|
||||
```
|
||||
java
|
||||
|_annotation:放置项目自定义注解
|
||||
|_aspect:放置切面代码
|
||||
|_config:放置配置类
|
||||
|_constant:放置常量、枚举等定义
|
||||
|__consist:存放常量定义
|
||||
|__enums:存放枚举定义
|
||||
|_controller:放置控制器代码
|
||||
|_filter:放置一些过滤、拦截相关的代码
|
||||
|_mapper:放置数据访问层代码接口
|
||||
|_model:放置数据模型代码
|
||||
|__entity:放置数据库实体对象定义
|
||||
|__dto:存放数据传输对象定义
|
||||
|__vo:存放显示层对象定义
|
||||
|_service:放置具体的业务逻辑代码(接口和实现分离)
|
||||
|__intf:存放业务逻辑接口定义
|
||||
|__impl:存放业务逻辑实际实现
|
||||
|_utils:放置工具类和辅助代码
|
||||
```
|
||||
|
||||
```
|
||||
resources
|
||||
|_mapper:存放mybatis的XML映射文件(如果是mybatis项目)
|
||||
|_static:存放网页静态资源,比如下面的js/css/img
|
||||
|__js:
|
||||
|__css:
|
||||
|__img:
|
||||
|__font:
|
||||
|__等等
|
||||
|_template:存放网页模板,比如thymeleaf/freemarker模板等
|
||||
|__header
|
||||
|__sidebar
|
||||
|__bottom
|
||||
|__XXX.html等等
|
||||
|_application.yml 基本配置文件
|
||||
|_application-dev.yml 开发环境配置文件
|
||||
|_application-test.yml 测试环境配置文件
|
||||
|_application-prod.yml 生产环境配置文件
|
||||
```
|
||||
|
|
@ -0,0 +1,229 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.7.1</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<groupId>com.whdc</groupId>
|
||||
<artifactId>zhdbaqapi</artifactId>
|
||||
<version>1.0</version>
|
||||
<description>漳河大坝安全api</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<java.version>1.8</java.version>
|
||||
<copy.jar.directory>target/release</copy.jar.directory>
|
||||
</properties>
|
||||
|
||||
<!-- 使用阿里 maven 库 -->
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>ali-maven</id>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-cache</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Sa-Token 权限认证, 在线文档:http://sa-token.dev33.cn/ -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
<version>1.30.0</version>
|
||||
</dependency><!-- Sa-Token 整合 Redis (使用 jackson 序列化方式) -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-dao-redis-jackson</artifactId>
|
||||
<version>1.30.0</version>
|
||||
</dependency>
|
||||
<!-- 提供Redis连接池 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
<!-- Sa-Token 权限认证 end -->
|
||||
|
||||
|
||||
|
||||
<!-- knife4j swagger start-->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
<version>3.0.3</version>
|
||||
</dependency>
|
||||
<!-- knife4j swagger end-->
|
||||
|
||||
<!-- devtools start -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional> <!-- 这个需要为 true 热部署才有效 -->
|
||||
</dependency>
|
||||
<!-- devtools end -->
|
||||
|
||||
<!-- lombok start -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<!-- lombok end -->
|
||||
|
||||
<!-- fastjson start -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.80</version>
|
||||
</dependency>
|
||||
<!-- fastjson end-->
|
||||
|
||||
<!-- dameng start -->
|
||||
<dependency>
|
||||
<groupId>com.dameng</groupId>
|
||||
<artifactId>DmJdbcDriver18</artifactId>
|
||||
<version>8.1.2.79</version>
|
||||
</dependency>
|
||||
<!--达梦数据库方言-->
|
||||
<dependency>
|
||||
<groupId>com.dameng</groupId>
|
||||
<artifactId>DmDialect-for-hibernate4.0</artifactId>
|
||||
<version>8.1.2.79</version>
|
||||
</dependency>
|
||||
<!-- dameng end -->
|
||||
|
||||
<!-- druid start -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
<version>1.2.8</version>
|
||||
</dependency>
|
||||
<!-- druid end -->
|
||||
|
||||
<!-- beanutils start -->
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
<version>1.9.4</version>
|
||||
</dependency>
|
||||
<!-- beanutils end -->
|
||||
|
||||
<!-- joda-time 时间工具 start -->
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.10.14</version>
|
||||
</dependency>
|
||||
<!-- joda-time end -->
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- 1.生成的jar中,不要包含pom.xml和pom.properties这两个文件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<addMavenDescriptor>false</addMavenDescriptor>
|
||||
<manifest>
|
||||
<!-- 是否要把第三方jar加入到类构建路径 -->
|
||||
<addClasspath>true</addClasspath>
|
||||
<!-- 外部依赖jar包的最终位置 -->
|
||||
<classpathPrefix>lib/</classpathPrefix>
|
||||
<!-- 项目启动类 -->
|
||||
<mainClass>com.whdc.zhdbaqapi.ZhSjgxApiApplication</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!--2.拷贝依赖到jar外面的lib目录-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-lib</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${copy.jar.directory}/lib</outputDirectory>
|
||||
<excludeTransitive>false</excludeTransitive>
|
||||
<stripVersion>false</stripVersion>
|
||||
<includeScope>runtime</includeScope>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- 3.把jar包拷贝到指定目录位置 -->
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy</id>
|
||||
<phase>package</phase>
|
||||
<configuration>
|
||||
<target>
|
||||
<copy todir="${copy.jar.directory}">
|
||||
<fileset dir="${project.build.directory}">
|
||||
<include name="${project.artifactId}.${project.version}.jar"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +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<? extends Payload>[] 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;
|
||||
}
|
||||
|
|
@ -0,0 +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<DateTimeRange, Object> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
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("加载缓存");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.whdc.zhdbaqapi.component;
|
||||
|
||||
import com.whdc.zhdbaqapi.service.IDeviceDataService;
|
||||
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;
|
||||
|
||||
@Scheduled(fixedDelay = 60000)
|
||||
public void scheduledTask() {
|
||||
iDeviceDataService.syncData();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
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<String> getPermissionList(Object o, String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回一个账号所拥有的角色标识集合 (权限与角色可分开校验)
|
||||
*/
|
||||
@Override
|
||||
public List<String> getRoleList(Object loginId, String loginType) {
|
||||
SysUser sysUser = iSysUserService.getById(Integer.valueOf(loginId.toString()));
|
||||
|
||||
// 实际项目中要根据具体业务逻辑来查询角色
|
||||
List<String> list = new ArrayList<String>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +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);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +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/sjgx")
|
||||
.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("接口说明文档");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
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")
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
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";
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
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<IPage<DeviceDataVo>> page(@RequestBody FindDeviceDto findDto) {
|
||||
return ResultJson.ok(iDeviceDataService.page(findDto));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
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.service.IDeviceInfoService;
|
||||
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.util.List;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-21 23:58
|
||||
*/
|
||||
@Api(tags = "设备信息 - Controller")
|
||||
@RestController
|
||||
@RequestMapping("/v1/deviceInfo")
|
||||
public class DeviceInfoController {
|
||||
|
||||
@Autowired
|
||||
private IDeviceInfoService iDeviceInfoService;
|
||||
|
||||
@ApiOperation(value = "获取单个对象")
|
||||
@PostMapping("/get")
|
||||
public ResultJson<DeviceInfo> get(@RequestBody @Validated IntegerIdDto idDto) {
|
||||
return ResultJson.ok(iDeviceInfoService.get(idDto.getId()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增")
|
||||
@PostMapping("/save")
|
||||
public ResultJson<Boolean> save(@RequestBody @Validated DeviceInfo bean) {
|
||||
return ResultJson.ok(iDeviceInfoService.save(bean));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除")
|
||||
@PostMapping("/del")
|
||||
public ResultJson<Boolean> del(@RequestBody @Validated IntegerIdDto bean) {
|
||||
return ResultJson.ok(iDeviceInfoService.removeById(bean.getId()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改")
|
||||
@PostMapping("/edit")
|
||||
public ResultJson<Boolean> edit(@RequestBody @Validated DeviceInfo bean) {
|
||||
return ResultJson.ok(iDeviceInfoService.updateById(bean));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "恢复")
|
||||
@PostMapping("/restore")
|
||||
public ResultJson<Boolean> edit(@RequestBody @Validated IntegerIdDto bean) {
|
||||
return ResultJson.ok(iDeviceInfoService.restore(bean.getId()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "列表查询")
|
||||
@PostMapping(value = "/list")
|
||||
public ResultJson<List<DeviceInfo>> list(@RequestBody StationCodeDto dto) {
|
||||
return ResultJson.ok(iDeviceInfoService.list(dto.getStationCode()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页查询")
|
||||
@PostMapping(value = "/page")
|
||||
public ResultJson<IPage<DeviceInfo>> page(@RequestBody FindDeviceDto findDto) {
|
||||
return ResultJson.ok(iDeviceInfoService.page(findDto));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
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("接口连通测试通过");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
package com.whdc.zhdbaqapi.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.whdc.zhdbaqapi.model.dto.FindSysUserDto;
|
||||
import com.whdc.zhdbaqapi.model.dto.IdDto;
|
||||
import com.whdc.zhdbaqapi.model.dto.LoginDto;
|
||||
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.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<Boolean> save(@RequestBody @Validated SysUser bean) {
|
||||
return ResultJson.ok(iSysUserService.save(bean));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除")
|
||||
@PostMapping("/del")
|
||||
public ResultJson<Boolean> del(@RequestBody @Validated IdDto bean) {
|
||||
return ResultJson.ok(iSysUserService.removeById(bean.getId()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改")
|
||||
@PostMapping("/edit")
|
||||
public ResultJson<Boolean> edit(@RequestBody @Validated SysUser bean) {
|
||||
return ResultJson.ok(iSysUserService.updateById(bean));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页查询")
|
||||
@PostMapping(value = "/page")
|
||||
public ResultJson<IPage<SysUser>> page(@RequestBody FindSysUserDto findDto) {
|
||||
return ResultJson.ok(iSysUserService.page(findDto));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "登录")
|
||||
@PostMapping("doLogin")
|
||||
public ResultJson<LoginVo> 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<AuthToken> 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() + "]踢下线");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
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<Map<String, Object>> error(HttpServletRequest request) {
|
||||
HttpStatus status = getStatus(request);
|
||||
Map<String, Object> map = new HashMap<String, Object>(16);
|
||||
Map<String, Object> 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<String, Object>>(map, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 覆盖默认的HTML响应
|
||||
* 发送的请求类型是 html 时,出现异常时的返回
|
||||
*/
|
||||
@Override
|
||||
public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) {
|
||||
//请求的状态
|
||||
HttpStatus status = getStatus(request);
|
||||
response.setStatus(getStatus(request).value());
|
||||
Map<String, Object> model = getErrorAttributes(request, ErrorAttributeOptions.defaults());
|
||||
ModelAndView modelAndView = resolveErrorView(request, response, status, model);
|
||||
//指定自定义的视图
|
||||
return (modelAndView == null ? new ModelAndView("error", model) : modelAndView);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
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<ConstraintViolation<?>> 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());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
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<DeviceData> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page
|
||||
* @param findDto
|
||||
* @return
|
||||
*/
|
||||
IPage<DeviceData> page(@Param("page") IPage<SysUser> page, @Param("obj") FindDeviceDto findDto);
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
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;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-21 23:40
|
||||
*/
|
||||
public interface DeviceInfoMapper extends BaseMapper<DeviceInfo> {
|
||||
/**
|
||||
* 返回查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DeviceInfo> list(String stationCode);
|
||||
|
||||
List<DeviceInfo> listAll();
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page
|
||||
* @param findDto
|
||||
* @return
|
||||
*/
|
||||
IPage<DeviceInfo> page(@Param("page") IPage<SysUser> page, @Param("obj") FindDeviceDto findDto);
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
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<SysUser> {
|
||||
/**
|
||||
* 返回所有
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> list();
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page
|
||||
* @param findDto
|
||||
* @return
|
||||
*/
|
||||
IPage<SysUser> page(@Param("page") IPage<SysUser> page, @Param("obj") FindSysUserDto findDto);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.whdc.zhdbaqapi.model.cklat;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
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")
|
||||
private String deviceId;
|
||||
|
||||
@JsonProperty("channel_num")
|
||||
private Integer channelNum;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssZ", timezone = "GMT+8")
|
||||
@JsonProperty("start_timestamp")
|
||||
private Date startTimestamp;
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
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<CklatRecord> rows;
|
||||
private String status;
|
||||
private String message;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.whdc.zhdbaqapi.model.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-01 1:17
|
||||
*/
|
||||
@Data
|
||||
public class FindDeviceDto extends FindPageDto {
|
||||
@ApiModelProperty(value = "站点编码", dataType = "java.lang.String")
|
||||
private String deviceId;
|
||||
|
||||
@ApiModelProperty(value = "测头编码", dataType = "java.lang.String")
|
||||
private String stationCode;
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
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 IntegerIdDto implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiParam(value = "主键ID", example = "")
|
||||
@ApiModelProperty(value = "主键ID", dataType = "java.lang.String")
|
||||
@NotBlank(message = "主键ID")
|
||||
private Integer id;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,481 @@
|
|||
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 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")
|
||||
@TableId(value = "ID", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 测头编码
|
||||
*/
|
||||
@ApiParam(value = "测头编码")
|
||||
@ApiModelProperty(value = "测头编码", dataType = "java.lang.String", required = true)
|
||||
@NotEmpty(message = "测头编码必填")
|
||||
@TableField("STATION_CODE")
|
||||
private String stationCode;
|
||||
|
||||
/**
|
||||
* 测站编码(MCU)
|
||||
*/
|
||||
@ApiParam(value = "测站编码(MCU)")
|
||||
@ApiModelProperty(value = "测站编码(MCU)", dataType = "java.lang.String")
|
||||
@NotEmpty(message = "测站编码(MCU)必填")
|
||||
@TableField("DEVICE_ID")
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 通道号
|
||||
*/
|
||||
@ApiParam(value = "通道号")
|
||||
@ApiModelProperty(value = "通道号", dataType = "java.lang.Integer", required = true)
|
||||
@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)
|
||||
@NotNull(message = "温度率定系娄(K)必填")
|
||||
@TableField("TEMPERATURE_K")
|
||||
private BigDecimal temperatureK;
|
||||
|
||||
/**
|
||||
* 初始温度读数
|
||||
*/
|
||||
@ApiParam(value = "初始温度读数")
|
||||
@ApiModelProperty(value = "初始温度读数", dataType = "java.lang.Double", required = true)
|
||||
@NotNull(message = "初始温度读数必填")
|
||||
@TableField("START_TEMPERATURE")
|
||||
private BigDecimal startTemperature;
|
||||
|
||||
/**
|
||||
* 率定系数(G)
|
||||
*/
|
||||
@ApiParam(value = "率定系数(G)")
|
||||
@ApiModelProperty(value = "率定系数(G)", dataType = "java.math.BigDecimal", required = true)
|
||||
@NotNull(message = "率定系数(G)必填")
|
||||
@TableField("CALIBRATION_COEFFICIENT")
|
||||
private BigDecimal calibrationCoefficient;
|
||||
|
||||
/**
|
||||
* 初始读数。单位是“模数”, 乘 1000 后开方得到频率值
|
||||
*/
|
||||
@ApiParam(value = "初始读数")
|
||||
@ApiModelProperty(value = "初始读数", notes = "单位是“模数”, 乘 1000 后开方得到频率值", dataType = "java.math.BigDecimal", required = true)
|
||||
@NotNull(message = "初始读数必填")
|
||||
@TableField("INITIAL_READING")
|
||||
private BigDecimal initialReading;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
@ApiParam(value = "项目名称")
|
||||
@ApiModelProperty(value = "项目名称", dataType = "java.lang.String")
|
||||
@TableField("PROJECT_NAME")
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ApiParam(value = "备注")
|
||||
@ApiModelProperty(value = "备注", dataType = "java.lang.String")
|
||||
@TableField("REMARK")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 监理工程师
|
||||
*/
|
||||
@ApiParam(value = "监理工程师")
|
||||
@ApiModelProperty(value = "监理工程师", dataType = "java.lang.String")
|
||||
@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("SKETCH_MAP")
|
||||
private String sketchMap;
|
||||
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
@ApiParam(value = "日期")
|
||||
@ApiModelProperty(value = "日期", dataType = "java.util.Date")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@TableField("CREATE_DATE")
|
||||
private Date createDate;
|
||||
|
||||
/**
|
||||
* 埋设及填表人
|
||||
*/
|
||||
@ApiParam(value = "埋设及填表人")
|
||||
@ApiModelProperty(value = "埋设及填表人", dataType = "java.lang.String")
|
||||
@TableField("BURIED_PERSONNEL")
|
||||
private String buriedPersonnel;
|
||||
|
||||
/**
|
||||
* 校验人
|
||||
*/
|
||||
@ApiParam(value = "校验人")
|
||||
@ApiModelProperty(value = "校验人", dataType = "java.lang.String")
|
||||
@TableField("CHECK_PERSONNEL")
|
||||
private String checkPersonnel;
|
||||
|
||||
/**
|
||||
* 技术负责人
|
||||
*/
|
||||
@ApiParam(value = "技术负责人")
|
||||
@ApiModelProperty(value = "技术负责人", dataType = "java.lang.String")
|
||||
@TableField("TECHNICAL_DIRECTOR")
|
||||
private String technicalDirector;
|
||||
|
||||
/**
|
||||
* 下游水位(m)
|
||||
*/
|
||||
@ApiParam(value = "下游水位(m)")
|
||||
@ApiModelProperty(value = "下游水位(m)", dataType = "java.lang.Double")
|
||||
@TableField("TAILWATER_LEVEL")
|
||||
private Double tailwaterLevel;
|
||||
|
||||
/**
|
||||
* 上游水位(m)
|
||||
*/
|
||||
@ApiParam(value = "上游水位(m)")
|
||||
@ApiModelProperty(value = "上游水位(m)", dataType = "java.lang.Double")
|
||||
@TableField("HEADWATER_LEVEL")
|
||||
private Double headwaterLevel;
|
||||
|
||||
/**
|
||||
* 天气(℃)
|
||||
*/
|
||||
@ApiParam(value = "天气(℃)")
|
||||
@ApiModelProperty(value = "天气(℃)", dataType = "java.lang.Double")
|
||||
@TableField("WEATHER")
|
||||
private Double weather;
|
||||
|
||||
/**
|
||||
* 气压
|
||||
*/
|
||||
@ApiParam(value = "气压")
|
||||
@ApiModelProperty(value = "气压", dataType = "java.math.BigDecimal")
|
||||
@TableField("AIR_PRESSURE")
|
||||
private BigDecimal airPressure;
|
||||
|
||||
/**
|
||||
* 气温
|
||||
*/
|
||||
@ApiParam(value = "气温")
|
||||
@ApiModelProperty(value = "气温", dataType = "java.math.BigDecimal")
|
||||
@TableField("AIR_TEMPERATURE")
|
||||
private BigDecimal airTemperature;
|
||||
|
||||
/**
|
||||
* 埋设日期
|
||||
*/
|
||||
@ApiParam(value = "埋设日期")
|
||||
@ApiModelProperty(value = "埋设日期", dataType = "java.util.Date")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@TableField("EMBEDDING_DATE")
|
||||
private Date embeddingDate;
|
||||
|
||||
/**
|
||||
* 埋设完毕读数
|
||||
*/
|
||||
@ApiParam(value = "埋设完毕读数")
|
||||
@ApiModelProperty(value = "埋设完毕读数", dataType = "java.math.BigDecimal")
|
||||
@TableField("EMBEDDING_FINISH_READING")
|
||||
private BigDecimal embeddingFinishReading;
|
||||
|
||||
/**
|
||||
* 零压读数
|
||||
*/
|
||||
@ApiParam(value = "零压读数")
|
||||
@ApiModelProperty(value = "零压读数", dataType = "java.math.BigDecimal")
|
||||
@TableField("ZERO_PRESSURE_READINGS")
|
||||
private BigDecimal zeroPressureReadings;
|
||||
|
||||
/**
|
||||
* 就位后读数
|
||||
*/
|
||||
@ApiParam(value = "就位后读数")
|
||||
@ApiModelProperty(value = "就位后读数", dataType = "java.math.BigDecimal")
|
||||
@TableField("END_READINGS")
|
||||
private BigDecimal endReadings;
|
||||
|
||||
/**
|
||||
* 入孔前读数
|
||||
*/
|
||||
@ApiParam(value = "入孔前读数")
|
||||
@ApiModelProperty(value = "入孔前读数", dataType = "java.math.BigDecimal")
|
||||
@TableField("START_READINGS")
|
||||
private BigDecimal startReadings;
|
||||
|
||||
/**
|
||||
* 孔内水深
|
||||
*/
|
||||
@ApiParam(value = "孔内水深")
|
||||
@ApiModelProperty(value = "孔内水深", dataType = "java.math.BigDecimal")
|
||||
@TableField("DRAFT")
|
||||
private BigDecimal draft;
|
||||
|
||||
/**
|
||||
* 现场室内读数
|
||||
*/
|
||||
@ApiParam(value = "现场室内读数")
|
||||
@ApiModelProperty(value = "现场室内读数", dataType = "java.math.BigDecimal")
|
||||
@TableField("READINGS")
|
||||
private BigDecimal readings;
|
||||
|
||||
/**
|
||||
* 大坝轴距
|
||||
*/
|
||||
@ApiParam(value = "大坝轴距")
|
||||
@ApiModelProperty(value = "大坝轴距", dataType = "java.math.BigDecimal")
|
||||
@TableField("DAM_WHEELBASE")
|
||||
private BigDecimal damWheelbase;
|
||||
|
||||
/**
|
||||
* 柱号
|
||||
*/
|
||||
@ApiParam(value = "柱号")
|
||||
@ApiModelProperty(value = "柱号", dataType = "java.lang.String")
|
||||
@TableField("COLUMN_NO")
|
||||
private String columnNo;
|
||||
|
||||
/**
|
||||
* 埋设高程
|
||||
*/
|
||||
@ApiParam(value = "埋设高程")
|
||||
@ApiModelProperty(value = "埋设高程", dataType = "java.math.BigDecimal")
|
||||
@TableField("EMBEDDING_ELEVATION")
|
||||
private BigDecimal embeddingElevation;
|
||||
|
||||
/**
|
||||
* 电缆长度标记
|
||||
*/
|
||||
@ApiParam(value = "电缆长度标记")
|
||||
@ApiModelProperty(value = "电缆长度标记", dataType = "java.lang.String")
|
||||
@TableField("CABLE_LENGTH_MARK")
|
||||
private String cableLengthMark;
|
||||
|
||||
/**
|
||||
* 电缆长度
|
||||
*/
|
||||
@ApiParam(value = "电缆长度")
|
||||
@ApiModelProperty(value = "电缆长度", dataType = "java.math.BigDecimal")
|
||||
@TableField("CABLE_LENGTH")
|
||||
private BigDecimal cableLength;
|
||||
|
||||
/**
|
||||
* 测头内阻
|
||||
*/
|
||||
@ApiParam(value = "测头内阻")
|
||||
@ApiModelProperty(value = "测头内阻", dataType = "java.math.BigDecimal")
|
||||
@TableField("RESISTANCE")
|
||||
private BigDecimal resistance;
|
||||
|
||||
/**
|
||||
* 量程
|
||||
*/
|
||||
@ApiParam(value = "量程")
|
||||
@ApiModelProperty(value = "量程", dataType = "java.math.BigDecimal")
|
||||
@TableField("RANGE")
|
||||
private BigDecimal range;
|
||||
|
||||
/**
|
||||
* 传感器系数
|
||||
*/
|
||||
@ApiParam(value = "传感器系数")
|
||||
@ApiModelProperty(value = "传感器系数", dataType = "java.math.BigDecimal")
|
||||
@TableField("SENSOR_COEFFICIENT")
|
||||
private BigDecimal sensorCoefficient;
|
||||
|
||||
/**
|
||||
* 生产厂家
|
||||
*/
|
||||
@ApiParam(value = "生产厂家")
|
||||
@ApiModelProperty(value = "生产厂家", dataType = "java.lang.String")
|
||||
@TableField("MANUFACTURER")
|
||||
private String manufacturer;
|
||||
|
||||
/**
|
||||
* 测头编号
|
||||
*/
|
||||
@ApiParam(value = "测头编号")
|
||||
@ApiModelProperty(value = "测头编号", dataType = "java.lang.String")
|
||||
@TableField("MEASURING_PROBE_NO")
|
||||
private String measuringProbeNo;
|
||||
|
||||
/**
|
||||
* 稳定水位
|
||||
*/
|
||||
@ApiParam(value = "稳定水位")
|
||||
@ApiModelProperty(value = "稳定水位", dataType = "java.lang.Double")
|
||||
@TableField("STEADY_WATER_LEVEL")
|
||||
private Double steadyWaterLevel;
|
||||
|
||||
/**
|
||||
* 初见水位
|
||||
*/
|
||||
@ApiParam(value = "初见水位")
|
||||
@ApiModelProperty(value = "初见水位", dataType = "java.lang.Double")
|
||||
@TableField("INITIAL_WATER_LEVEL")
|
||||
private Double initialWaterLevel;
|
||||
|
||||
/**
|
||||
* 钻孔直径
|
||||
*/
|
||||
@ApiParam(value = "钻孔直径")
|
||||
@ApiModelProperty(value = "钻孔直径", dataType = "java.lang.String")
|
||||
@TableField("DRILLING_SIZE")
|
||||
private String drillingSize;
|
||||
|
||||
/**
|
||||
* 转孔编号
|
||||
*/
|
||||
@ApiParam(value = "转孔编号")
|
||||
@ApiModelProperty(value = "转孔编号", dataType = "java.lang.String")
|
||||
@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("INSTALLATION_POSITION_Y")
|
||||
private Double installationPositionY;
|
||||
|
||||
/**
|
||||
* 安装经度
|
||||
*/
|
||||
@ApiParam(value = "安装经度")
|
||||
@ApiModelProperty(value = "安装经度", dataType = "java.lang.Double")
|
||||
@TableField("INSTALLATION_POSITION_X")
|
||||
private Double installationPositionX;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.whdc.zhdbaqapi.model.group;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-06-26 15:13
|
||||
*/
|
||||
public interface Delete {
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.whdc.zhdbaqapi.model.group;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-06-27 22:27
|
||||
*/
|
||||
public interface Find {
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.whdc.zhdbaqapi.model.group;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-06-26 15:12
|
||||
*/
|
||||
public interface Insert {
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
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<String> roleList;
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
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<DeviceData> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param findDto
|
||||
* @return
|
||||
*/
|
||||
IPage<DeviceDataVo> page(FindDeviceDto findDto);
|
||||
|
||||
/**
|
||||
* 同步数据
|
||||
*/
|
||||
void syncData();
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
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 java.util.List;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-21 23:47
|
||||
*/
|
||||
public interface IDeviceInfoService extends IService<DeviceInfo> {
|
||||
|
||||
DeviceInfo get(Integer id);
|
||||
|
||||
/**
|
||||
* 恢复
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
boolean restore(Integer id);
|
||||
|
||||
/**
|
||||
* 返回查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DeviceInfo> list(String stationCode);
|
||||
|
||||
List<DeviceInfo> listAll();
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param findDto
|
||||
* @return
|
||||
*/
|
||||
IPage<DeviceInfo> page(FindDeviceDto findDto);
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
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<SysUser> {
|
||||
/**
|
||||
* 返回所有
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
LoginVo login(LoginDto obj);
|
||||
|
||||
SysUser getById(Integer id);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param findDto
|
||||
* @return
|
||||
*/
|
||||
IPage<SysUser> page(FindSysUserDto findDto);
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
Boolean changePwd(ChangePwdDto obj);
|
||||
}
|
||||
|
|
@ -0,0 +1,182 @@
|
|||
package com.whdc.zhdbaqapi.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.whdc.zhdbaqapi.constant.Constants;
|
||||
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 com.whdc.zhdbaqapi.utils.DataUtils;
|
||||
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;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-22 0:46
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Configuration
|
||||
public class DeviceDataServiceImpl extends ServiceImpl<DeviceDataMapper, DeviceData> 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<String, String> redisTemplate;
|
||||
|
||||
private static ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@Override
|
||||
public IPage<DeviceDataVo> page(FindDeviceDto findDto) {
|
||||
return baseMapper.page(findDto.getPage(), findDto);
|
||||
}
|
||||
|
||||
|
||||
public List<CklatRecord> 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<String> request = new HttpEntity<String>(objectMapper.writeValueAsString(query), headers);
|
||||
|
||||
ResponseEntity<CklatResult> 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<DeviceInfo> 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);
|
||||
} else {
|
||||
c.setTime(lasttm);
|
||||
c.add(Calendar.SECOND, 1); // 传最后数据时间,会一直拉到最后一条记录,所以这里加了一秒
|
||||
}
|
||||
|
||||
lasttm = c.getTime();
|
||||
|
||||
List<CklatRecord> rows = getRemoteData(deviceId, di.getChannelNum(), lasttm);
|
||||
|
||||
if (rows == null || rows.isEmpty()) {
|
||||
log.debug("没有取到数据 " + deviceId);
|
||||
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)
|
||||
|
||||
R0 = DataUtils.sqrt(R0.multiply(BigDecimal.valueOf(1000)), 6);
|
||||
|
||||
BigDecimal T1 = record.getDataB();
|
||||
BigDecimal R1 = record.getDataA();
|
||||
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)));
|
||||
}
|
||||
|
||||
if (super.save(dd)) {
|
||||
cnt += 1;
|
||||
|
||||
di.setLatestReportingTime(dd.getTimestamp());
|
||||
iDeviceInfoService.updateById(di);
|
||||
changeDi = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
log.debug("拉取 " + rows.size() + " 保存 " + cnt);
|
||||
}
|
||||
|
||||
if (changeDi) {
|
||||
Set<String> keys = redisTemplate.keys(Constants.CACHE_NAME + "*");
|
||||
for (String k : keys) {
|
||||
redisTemplate.delete(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
package com.whdc.zhdbaqapi.service.impl;
|
||||
|
||||
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.mapper.DeviceInfoMapper;
|
||||
import com.whdc.zhdbaqapi.model.dto.FindDeviceDto;
|
||||
import com.whdc.zhdbaqapi.model.entity.DeviceInfo;
|
||||
import com.whdc.zhdbaqapi.service.IDeviceInfoService;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-21 23:47
|
||||
*/
|
||||
@Service
|
||||
public class DeviceInfoServiceimpl extends ServiceImpl<DeviceInfoMapper, DeviceInfo> implements IDeviceInfoService {
|
||||
@Override
|
||||
public DeviceInfo get(Integer id) {
|
||||
return baseMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(Constants.CACHE_NAME)
|
||||
public boolean restore(Integer id) {
|
||||
DeviceInfo entity = baseMapper.selectById(id);
|
||||
entity.setDel(0);
|
||||
return super.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceInfo> list(String stationCode) {
|
||||
return baseMapper.list(stationCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(Constants.CACHE_NAME)
|
||||
public List<DeviceInfo> listAll() {
|
||||
return baseMapper.listAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<DeviceInfo> page(FindDeviceDto findDto) {
|
||||
return baseMapper.page(findDto.getPage(), findDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(Constants.CACHE_NAME)
|
||||
public boolean save(DeviceInfo entity) {
|
||||
entity.setCreateDate(new Date());
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(Constants.CACHE_NAME)
|
||||
public boolean updateById(DeviceInfo entity) {
|
||||
entity.setModificationTime(new Date());
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
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<SysUserMapper, SysUser> implements ISysUserService {
|
||||
private static final String TOKENPRE = "token:";
|
||||
private static final int EXPTIME = 24 * 60 * 60; // 24 小时
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
private String getPassword(String password) {
|
||||
return DigestUtils.md5DigestAsHex((Constants.PASSWORD_SALT + password).getBytes());
|
||||
}
|
||||
|
||||
private SysUser findByLoginName(String loginName) {
|
||||
QueryWrapper<SysUser> 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<SysUser> page(FindSysUserDto findDto) {
|
||||
return baseMapper.page(findDto.getPage(), findDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean changePwd(ChangePwdDto obj) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.whdc.zhdbaqapi.utils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-22 8:46
|
||||
*/
|
||||
public class DataUtils {
|
||||
/**
|
||||
* 标准差σ=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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
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<SimpleDateFormat> sdfhmsS = new ThreadLocal<SimpleDateFormat>() {
|
||||
protected SimpleDateFormat initialValue() {
|
||||
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
}
|
||||
};
|
||||
public static final ThreadLocal<SimpleDateFormat> sdfhms = new ThreadLocal<SimpleDateFormat>() {
|
||||
protected SimpleDateFormat initialValue() {
|
||||
return new SimpleDateFormat(DATE_TIME_PATTERN);
|
||||
}
|
||||
};
|
||||
public static final ThreadLocal<SimpleDateFormat> sdf_utc = new ThreadLocal<SimpleDateFormat>() {
|
||||
protected SimpleDateFormat initialValue() {
|
||||
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
|
||||
}
|
||||
};
|
||||
public static final ThreadLocal<SimpleDateFormat> sdf_utc_sss = new ThreadLocal<SimpleDateFormat>() {
|
||||
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"));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
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<Object> {
|
||||
@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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
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<Object> {
|
||||
@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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
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<Object> {
|
||||
@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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +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");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +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<T> 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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
server:
|
||||
port: 18005
|
||||
|
||||
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
|
||||
username: DAM_SAFE
|
||||
password: Dam_safe_890
|
||||
druid:
|
||||
initialSize: 5
|
||||
minIdle: 5
|
||||
maxActive: 20
|
||||
maxWait: 60000
|
||||
timeBetweenEvictionRunsMillis: 60000
|
||||
minEvictableIdleTimeMillis: 300000
|
||||
validationQuery: SELECT1FROMDUAL
|
||||
testWhileIdle: true
|
||||
testOnBorrow: false
|
||||
testOnReturn: false
|
||||
filters: stat,wall,log4j #wall表示排除防火请
|
||||
logSlowSql: true
|
||||
|
||||
#jpa配置
|
||||
jpa:
|
||||
properties:
|
||||
hibernate:
|
||||
dialect: org.hibernate.dialect.DmDialect
|
||||
|
||||
# Redis
|
||||
redis:
|
||||
database: 4
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
password: Whdc_890
|
||||
|
||||
knife4j:
|
||||
enable: true
|
||||
setting:
|
||||
enableFooter: false
|
||||
enableFooterCustom: true
|
||||
footerCustomContent: Copyright 2018-[湖北纬皓端成科技有限公司](http://www.wavehorizon.cn)
|
||||
|
||||
documents: # 文档配置,可配置多个分组
|
||||
- group: doc-knife4j-1.0.0
|
||||
name: MarkDown文档
|
||||
locations: classpath:markdown/*
|
||||
- group: v1.0
|
||||
name: v1.0
|
||||
|
||||
|
||||
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://localhost:8008/api/v1/devices/records
|
||||
|
||||
# 渗压换算管内水位系数
|
||||
o_z_modulus: 0.10197
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,209 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
|
||||
<!-- scan:当此属性设置为true时,配置文档如果发生改变,将会被重新加载,默认值为true -->
|
||||
<!-- scanPeriod:设置监测配置文档是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。 当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
|
||||
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
|
||||
<configuration scan="true" scanPeriod="10 seconds">
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
||||
<contextName>logback</contextName>
|
||||
|
||||
<!-- 文件切割大小 -->
|
||||
<property name="maxFileSize" value="500MB"/>
|
||||
<!-- 文档保留天数 -->
|
||||
<property name="maxHistory" value="20"/>
|
||||
<!-- 文档保留总大小 -->
|
||||
<property name="totalSizeCap" value="50GB"/>
|
||||
|
||||
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义后,可以使“${}”来使用变量。 -->
|
||||
<property name="log.path" value="./logs"/>
|
||||
|
||||
<!--0. 日志格式和颜色渲染 -->
|
||||
<!-- 彩色日志依赖的渲染类 -->
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
|
||||
<conversionRule conversionWord="wex"
|
||||
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
|
||||
<conversionRule conversionWord="wEx"
|
||||
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
|
||||
<!-- 彩色日志格式 -->
|
||||
<property name="CONSOLE_LOG_PATTERN"
|
||||
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||
|
||||
<!-- <property name="CONSOLE_LOG_PATTERN" value="%-12(%d{yyyy-MM-dd HH:mm:ss.SSS}) |-%-5level [%thread] %c [%L] -| %msg%n"/>-->
|
||||
|
||||
<!--1. 输出到控制台-->
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>debug</level>
|
||||
</filter>
|
||||
<encoder>
|
||||
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
|
||||
<!-- 设置字符集 -->
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!--2. 输出到文档-->
|
||||
<!-- 2.1 level为 DEBUG 日志,时间滚动输出 -->
|
||||
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 正在记录的日志文档的路径及文档名 -->
|
||||
<file>${log.path}/web_debug.log</file>
|
||||
<!--日志文档输出格式-->
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||
<charset>UTF-8</charset> <!-- 设置字符集 -->
|
||||
</encoder>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志归档 -->
|
||||
<fileNamePattern>${log.path}/web-debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>100MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<!--日志文档保留天数-->
|
||||
<maxHistory>15</maxHistory>
|
||||
</rollingPolicy>
|
||||
<!-- 此日志文档只记录debug级别的 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>debug</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 2.2 level为 INFO 日志,时间滚动输出 -->
|
||||
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 正在记录的日志文档的路径及文档名 -->
|
||||
<file>${log.path}/web_info.log</file>
|
||||
<!--日志文档输出格式-->
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 每天日志归档路径以及格式 -->
|
||||
<fileNamePattern>${log.path}/web-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>100MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<!--日志文档保留天数-->
|
||||
<maxHistory>15</maxHistory>
|
||||
</rollingPolicy>
|
||||
<!-- 此日志文档只记录info级别的 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>info</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 2.3 level为 WARN 日志,时间滚动输出 -->
|
||||
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 正在记录的日志文档的路径及文档名 -->
|
||||
<file>${log.path}/web_warn.log</file>
|
||||
<!--日志文档输出格式-->
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
|
||||
</encoder>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/web-warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>100MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<!--日志文档保留天数-->
|
||||
<maxHistory>15</maxHistory>
|
||||
</rollingPolicy>
|
||||
<!-- 此日志文档只记录warn级别的 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>warn</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 2.4 level为 ERROR 日志,时间滚动输出 -->
|
||||
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 正在记录的日志文档的路径及文档名 -->
|
||||
<file>${log.path}/web_error.log</file>
|
||||
<!--日志文档输出格式-->
|
||||
<encoder>
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
|
||||
</encoder>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.path}/web-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>100MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<!--日志文档保留天数-->
|
||||
<maxHistory>15</maxHistory>
|
||||
</rollingPolicy>
|
||||
<!-- 此日志文档只记录ERROR级别的 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>ERROR</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!--
|
||||
<logger>用来设置某一个包或者具体的某一个类的日志打印级别、以及指定<appender>。<logger>仅有一个name属性, 一个可选的level和一个可选的addtivity属性。
|
||||
name:用来指定受此logger约束的某一个包或者具体的某一个类。
|
||||
level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
|
||||
还有一个特俗值INHERITED或者同义词NULL,代表强制执行上级的级别。
|
||||
如果未设置此属性,那么当前logger将会继承上级的级别。
|
||||
addtivity:是否向上级logger传递打印信息。默认是true。
|
||||
|
||||
<logger name="org.springframework.web" level="info"/>
|
||||
<logger name="org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor" level="INFO"/>
|
||||
-->
|
||||
|
||||
<!--
|
||||
使用mybatis的时候,sql语句是debug下才会打印,而这里我们只配置了info,所以想要查看sql语句的话,有以下两种操作:
|
||||
第一种把<root level="info">改成<root level="DEBUG">这样就会打印sql,不过这样日志那边会出现很多其他消息
|
||||
第二种就是单独给dao下目录配置debug模式,代码如下,这样配置sql语句会打印,其他还是正常info级别:
|
||||
|
||||
【logging.level.org.mybatis=debug logging.level.dao=debug】
|
||||
-->
|
||||
|
||||
<!--
|
||||
root节点是必选节点,用来指定最基础的日志输出级别,只有一个level属性
|
||||
level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,不能设置为INHERITED或者同义词NULL。默认是DEBUG
|
||||
,标识这个appender将会添加到这个logger。
|
||||
-->
|
||||
|
||||
<logger name="_org.springframework" level="error" additivity="false"/>
|
||||
<logger name="org.springframework" level="error" additivity="false"/>
|
||||
<logger name="springfox.bean" level="error" additivity="false"/>
|
||||
<logger name="springfox.documentation" level="error" additivity="false"/>
|
||||
<logger name="org.mybatis.spring" level="error" additivity="false"/>
|
||||
<logger name="com.alibaba.druid" level="error" additivity="false"/>
|
||||
<logger name="org.hibernate.validator" level="error" additivity="false"/>
|
||||
<logger name="io.lettuce.core" level="error" additivity="false"/>
|
||||
<logger name="io.netty" level="error" additivity="false"/>
|
||||
<logger name="com.corundumstudio.socketio" level="error" additivity="false"/>
|
||||
<logger name="org.apache.kafka.clients.consumer.internals" level="error" additivity="false"/>
|
||||
<logger name="org.apache.kafka.clients" level="error" additivity="false"/>
|
||||
<logger name="org.mongodb.driver" level="error" additivity="false"/>
|
||||
<logger name="org.apache.commons.beanutils" level="error" additivity="false"/>
|
||||
|
||||
<!--
|
||||
ERROR [ModelSpecification.spec] At least one type of specification is required
|
||||
https://github.com/jhipster/generator-jhipster/pull/15004/files
|
||||
-->
|
||||
<logger name="Validator" level="INFO"/>
|
||||
|
||||
<root level="debug">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="DEBUG_FILE"/>
|
||||
<appender-ref ref="INFO_FILE"/>
|
||||
<appender-ref ref="WARN_FILE"/>
|
||||
<appender-ref ref="ERROR_FILE"/>
|
||||
</root>
|
||||
|
||||
|
||||
</configuration>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.whdc.zhdbaqapi.mapper.DeviceDataMapper">
|
||||
|
||||
<select id="page" resultType="com.whdc.zhdbaqapi.model.vo.DeviceDataVo">
|
||||
SELECT D.*, I.STATION_CODE FROM DEVICE_DATA D
|
||||
LEFT JOIN DEVICE_INFO I ON D.DEVICE_ID = I.DEVICE_ID AND D.CHANNEL_NUM = I.CHANNEL_NUM
|
||||
WHERE DEL = 0
|
||||
<if test="obj.deviceId != null and obj.deviceId != '' ">
|
||||
AND D.DEVICE_ID LIKE CONCAT('%', #{obj.deviceId}, '%')
|
||||
</if>
|
||||
<if test="obj.stationCode != null and obj.stationCode != '' ">
|
||||
AND I.STATION_CODE LIKE CONCAT('%', #{obj.stationCode}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.whdc.zhdbaqapi.mapper.DeviceInfoMapper">
|
||||
|
||||
<select id="list" resultType="com.whdc.zhdbaqapi.model.entity.DeviceInfo">
|
||||
SELECT ID, DEVICE_ID, STATION_CODE, CHANNEL_NUM FROM DEVICE_INFO
|
||||
WHERE DEL = 0
|
||||
<if test="obj.deviceId != null and obj.deviceId != '' ">
|
||||
AND DEVICE_ID LIKE CONCAT('%', #{obj.deviceId}, '%')
|
||||
</if>
|
||||
<if test="obj.stationCode != null and obj.stationCode != '' ">
|
||||
AND STATION_CODE LIKE CONCAT('%', #{obj.stationCode}, '%')
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultType="com.whdc.zhdbaqapi.model.entity.DeviceInfo">
|
||||
SELECT ID, DEVICE_ID, STATION_CODE, CHANNEL_NUM, LATEST_REPORTING_TIME, TEMPERATURE_K, START_TEMPERATURE,
|
||||
CALIBRATION_COEFFICIENT, INITIAL_READING
|
||||
FROM DEVICE_INFO
|
||||
WHERE DEL = 0
|
||||
</select>
|
||||
|
||||
<select id="page" resultType="com.whdc.zhdbaqapi.model.entity.DeviceInfo">
|
||||
SELECT * FROM DEVICE_INFO
|
||||
WHERE DEL = 0
|
||||
<if test="obj.deviceId != null and obj.deviceId != '' ">
|
||||
AND DEVICE_ID LIKE CONCAT('%', #{obj.deviceId}, '%')
|
||||
</if>
|
||||
<if test="obj.stationCode != null and obj.stationCode != '' ">
|
||||
AND STATION_CODE LIKE CONCAT('%', #{obj.stationCode}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.whdc.zhdbaqapi.mapper.SysUserMapper">
|
||||
|
||||
<select id="page" resultType="com.whdc.zhdbaqapi.model.entity.SysUser">
|
||||
SELECT ID, NAME, LOGIN_NAME, TYPE FROM SYS_USER
|
||||
WHERE 1=1
|
||||
<if test="obj.name != null and obj.name != '' ">
|
||||
AND NAME LIKE CONCAT('%', #{obj.name}, '%')
|
||||
</if>
|
||||
<if test="obj.loginName != null and obj.loginName != '' ">
|
||||
AND LOGIN_NAME LIKE CONCAT('%', #{obj.loginName}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1 @@
|
|||
# 数据接口
|
||||
Loading…
Reference in New Issue