dms_eco modify by zang
This commit is contained in:
commit
ede5053264
24
.gitignore
vendored
Normal file
24
.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
nbproject/private/
|
||||
build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
.nb-gradle/
|
38
file-1611022331496
Normal file
38
file-1611022331496
Normal file
@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>
|
||||
Ecology
|
||||
</title>
|
||||
<script>
|
||||
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
|
||||
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')
|
||||
</script>
|
||||
<link rel="stylesheet" href="/static/index.776c78d1.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<noscript>
|
||||
<strong>Please enable JavaScript to continue.</strong>
|
||||
</noscript>
|
||||
<div id="app"></div>
|
||||
<!-- built files will be auto injected -->
|
||||
<script type="text/javascript" src="/static/js/chunk-vendors.js"></script><script type="text/javascript" src="/static/js/index.js"></script></body>
|
||||
|
||||
</html>
|
||||
<script>
|
||||
(function () {
|
||||
var userAgent = navigator.userAgent
|
||||
window.addEventListener('resize', function () {
|
||||
if (navigator.userAgent !== userAgent) {
|
||||
/* eslint-disable no-undef */
|
||||
location.reload()
|
||||
}
|
||||
})
|
||||
})()
|
||||
|
||||
</script>
|
||||
|
560
pom.xml
Normal file
560
pom.xml
Normal file
@ -0,0 +1,560 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.xkrs.microservice</groupId>
|
||||
<artifactId>dms_eco</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>dms_eco</name>
|
||||
<description>后端通用服务平台</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.3.3.RELEASE</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<usercneter-sdk-version>5.0.0-SNAPSHOT</usercneter-sdk-version>
|
||||
<tus-client.version>0.4.0</tus-client.version>
|
||||
<tus-client.version>0.4.0</tus-client.version>
|
||||
<tus-server.version>1.0.0-2.0</tus-server.version>
|
||||
<log4j2.version>2.15.0</log4j2.version>
|
||||
<drools.version>7.14.0.Final</drools.version>
|
||||
<poi.version>5.0.0</poi.version>
|
||||
<commons-codec.version>1.15</commons-codec.version>
|
||||
<geotools.version>19.0</geotools.version>
|
||||
<dom4j.version>2.0.0</dom4j.version>
|
||||
<yauaa.version>5.19</yauaa.version>
|
||||
<jjwt.version>0.11.2</jjwt.version>
|
||||
<hutool-all.version>4.4.3</hutool-all.version>
|
||||
<httpmime.version>4.5.12</httpmime.version>
|
||||
<httpclient.version>4.5.12</httpclient.version>
|
||||
<hibernate-validator.version>6.1.5.Final</hibernate-validator.version>
|
||||
<hibernate-spatial.version>5.4.20.Final</hibernate-spatial.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>11</java.version>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>osgeo</id>
|
||||
<name>OSGeo Release Repository</name>
|
||||
<url>https://repo.osgeo.org/repository/release/</url>
|
||||
<snapshots><enabled>false</enabled></snapshots>
|
||||
<releases><enabled>true</enabled></releases>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>osgeo-snapshot</id>
|
||||
<name>OSGeo Snapshot Repository</name>
|
||||
<url>https://repo.osgeo.org/repository/snapshot/</url>
|
||||
<snapshots><enabled>true</enabled></snapshots>
|
||||
<releases><enabled>false</enabled></releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</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-web</artifactId>
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-logging</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<!--排除内置的tomcat-->
|
||||
<!--<exclusions>-->
|
||||
<!--<exclusion>-->
|
||||
<!--<groupId>org.springframework.boot</groupId>-->
|
||||
<!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
|
||||
<!--</exclusion>-->
|
||||
<!--</exclusions>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-devtools</artifactId>-->
|
||||
<!-- <optional>true</optional>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId> mysql</groupId>
|
||||
<artifactId> mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-api</artifactId>
|
||||
<version>${jjwt.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-impl</artifactId>
|
||||
<version>${jjwt.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-jackson</artifactId>
|
||||
<version>${jjwt.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>nl.basjes.parse.useragent</groupId>
|
||||
<artifactId>yauaa</artifactId>
|
||||
<version>${yauaa.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>cn.afterturn</groupId>
|
||||
<artifactId>easypoi-base</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.afterturn</groupId>
|
||||
<artifactId>easypoi-web</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.afterturn</groupId>
|
||||
<artifactId>easypoi-annotation</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>-->
|
||||
|
||||
|
||||
<!--go-fastdfs上传下载 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool-all.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
<version>${httpmime.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>${hibernate-validator.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-spatial</artifactId>
|
||||
<version>${hibernate-spatial.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- xml -->
|
||||
<dependency>
|
||||
<groupId>org.dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>${dom4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--kafka-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
<version>2.5.10.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-quartz</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 添加GeoTools依赖 -->
|
||||
<!-- https://mvnrepository.com/artifact/org.geotools/gt-shapefile -->
|
||||
<dependency>
|
||||
<groupId>org.geotools</groupId>
|
||||
<artifactId>gt-shapefile</artifactId>
|
||||
<version>${geotools.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.geotools</groupId>
|
||||
<artifactId>gt-swing</artifactId>
|
||||
<version>${geotools.version}</version>
|
||||
</dependency>
|
||||
<!-- JSR 303 规范验证包 -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>5.2.4.Final</version>
|
||||
</dependency>
|
||||
<!-- 添加geotools-jdbc -->
|
||||
<dependency>
|
||||
<groupId>org.geotools.jdbc</groupId>
|
||||
<artifactId>gt-jdbc-postgis</artifactId>
|
||||
<version>${geotools.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.geotools</groupId>
|
||||
<artifactId>gt-geojson</artifactId>
|
||||
<version>${geotools.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.67</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.coobird</groupId>
|
||||
<artifactId>thumbnailator</artifactId>
|
||||
<version>0.4.8</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.github.jai-imageio/jai-imageio-core -->
|
||||
<dependency>
|
||||
<groupId>com.github.jai-imageio</groupId>
|
||||
<artifactId>jai-imageio-core</artifactId>
|
||||
<version>1.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/javax.media/jai_core -->
|
||||
<dependency>
|
||||
<groupId>javax.media</groupId>
|
||||
<artifactId>jai_core</artifactId>
|
||||
<version>1.1.3</version>
|
||||
</dependency>
|
||||
|
||||
<!--region easypoi相关依赖 -->
|
||||
<dependency>
|
||||
<groupId>cn.afterturn</groupId>
|
||||
<artifactId>easypoi-spring-boot-starter</artifactId>
|
||||
<version>4.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>4.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
<version>4.1.1</version>
|
||||
</dependency>
|
||||
<!--endregion easypoi相关依赖 -->
|
||||
|
||||
|
||||
<!--Drools 规则引擎-->
|
||||
<dependency>
|
||||
<groupId>org.drools</groupId>
|
||||
<artifactId>drools-core</artifactId>
|
||||
<version>${drools.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kie</groupId>
|
||||
<artifactId>kie-spring</artifactId>
|
||||
<version>${drools.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.drools</groupId>
|
||||
<artifactId>drools-compiler</artifactId>
|
||||
<version>${drools.version}</version>
|
||||
</dependency>
|
||||
<!-- 决策表 -->
|
||||
<dependency>
|
||||
<groupId>org.drools</groupId>
|
||||
<artifactId>drools-decisiontables</artifactId>
|
||||
<version>${drools.version}</version>
|
||||
</dependency>
|
||||
<!-- 模板 -->
|
||||
<dependency>
|
||||
<groupId>org.drools</groupId>
|
||||
<artifactId>drools-templates</artifactId>
|
||||
<version>${drools.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.kie</groupId>
|
||||
<artifactId>kie-api</artifactId>
|
||||
<version>${drools.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- log4j2 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.logging.log4j</groupId>-->
|
||||
<!-- <artifactId>log4j-api</artifactId>-->
|
||||
<!-- <version>${log4j2.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.logging.log4j</groupId>-->
|
||||
<!-- <artifactId>log4j-core</artifactId>-->
|
||||
<!-- <version>${log4j2.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.logging.log4j</groupId>-->
|
||||
<!-- <artifactId>log4j-slf4j-impl</artifactId>-->
|
||||
<!-- <version>${log4j2.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency> <!-- 后向兼容:使用Log4j2实现log2j1.x的接口 -->
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-1.2-api</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.desair.tus</groupId>
|
||||
<artifactId>tus-java-server</artifactId>
|
||||
<version>${tus-server.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.tus.java.client</groupId>
|
||||
<artifactId>tus-java-client</artifactId>
|
||||
<version>${tus-client.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!--easyexcel-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<version>2.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<!--云粒-->
|
||||
<dependency>
|
||||
<groupId>com.yunlizhihui</groupId>
|
||||
<artifactId>yunli-common</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.yunlizhihui</groupId>
|
||||
<artifactId>user-center-sdk</artifactId>
|
||||
<version>${usercneter-sdk-version}</version>
|
||||
</dependency>
|
||||
<!--SM2-->
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.65</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcpkix-jdk15on</artifactId>
|
||||
<version>1.65</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.79</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.5</version>
|
||||
</dependency>
|
||||
<!-- io常用工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 文件上传工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- first portal jar import-->
|
||||
<dependency>
|
||||
<groupId>local-bsp-client-7.5.1-full.jar</groupId>
|
||||
<artifactId>local-bsp</artifactId>
|
||||
<version>7.5.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}\src\main\resources\WEB-INF\lib\bsp-client-7.5.1-full.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>local-ezmorph-1.0.6.jar</groupId>
|
||||
<artifactId>local-ezmorph</artifactId>
|
||||
<version>1.0.6</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}\src\main\resources\WEB-INF\lib\ezmorph-1.0.6.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>local-framework-7.5.0.jar</groupId>
|
||||
<artifactId>local-framework</artifactId>
|
||||
<version>7.5.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}\src\main\resources\WEB-INF\lib\framework-7.5.0.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>local-loushang-framework.jar</groupId>
|
||||
<artifactId>local-loushang-framework</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}\src\main\resources\WEB-INF\lib\loushang-framework.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>local-next-5.9.0.jar</groupId>
|
||||
<artifactId>local-next</artifactId>
|
||||
<version>5.9.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}\src\main\resources\WEB-INF\lib\next-5.9.0.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>local-rtf-1.0.0.jar</groupId>
|
||||
<artifactId>local-rtf</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}\src\main\resources\WEB-INF\lib\rtf-1.0.0.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>local-stax-1.1.2-bea-vista.jar</groupId>
|
||||
<artifactId>local-stax</artifactId>
|
||||
<version>1.1.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}\src\main\resources\WEB-INF\lib\stax-1.1.2-bea-vista.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>local-struts2-core-2.3.15.3.jar</groupId>
|
||||
<artifactId>local-struts2</artifactId>
|
||||
<version>2.3.15.3</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}\src\main\resources\WEB-INF\lib\struts2-core-2.3.15.3.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>local-velocity-engine-core-2.0.jar</groupId>
|
||||
<artifactId>local-velocity</artifactId>
|
||||
<version>2.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}\src\main\resources\WEB-INF\lib\velocity-engine-core-2.0.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>alimaven spring plugin</id>
|
||||
<name>alimaven spring plugin</name>
|
||||
<url>https://maven.aliyun.com/repository/spring-plugin</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.properties</include>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.properties</include>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.txt</include>
|
||||
<include>**/*.drl</include>
|
||||
<include>**/*.jar</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.3.3.RELEASE</version>
|
||||
<configuration>
|
||||
<!-- <mainClass>com.test.Starter4Platform</mainClass>-->
|
||||
<!-- 必须有下面这句话-->
|
||||
<includeSystemScope>true</includeSystemScope>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<release>11</release>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,19 @@
|
||||
package com.xkrs.microservice;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
|
||||
/**
|
||||
* 微服务入口
|
||||
* @author tajochen
|
||||
*/
|
||||
@EnableJpaAuditing
|
||||
@SpringBootApplication(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class})
|
||||
public class MicroserviceApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MicroserviceApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.xkrs.microservice.common.account;
|
||||
|
||||
/**
|
||||
* 账户实体
|
||||
* @author tajochen
|
||||
*/
|
||||
public class AccountCredentials {
|
||||
|
||||
private String userName;
|
||||
private String password;
|
||||
/**
|
||||
* 用户来源
|
||||
* 0 或不传, web端
|
||||
* 1:app端
|
||||
*/
|
||||
private String userSource;
|
||||
private boolean remember;
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public boolean isRemember() {
|
||||
return remember;
|
||||
}
|
||||
|
||||
public void setRemember(boolean remember) {
|
||||
this.remember = remember;
|
||||
}
|
||||
|
||||
public String getUserSource() {
|
||||
return userSource;
|
||||
}
|
||||
|
||||
public void setUserSource(String userSource) {
|
||||
this.userSource = userSource;
|
||||
}
|
||||
}
|
@ -0,0 +1,212 @@
|
||||
package com.xkrs.microservice.common.account;
|
||||
|
||||
import com.xkrs.microservice.model.entity.auth.RoleEntity;
|
||||
import com.xkrs.microservice.model.entity.auth.SysUserEntity;
|
||||
import com.xkrs.microservice.model.entity.log.PtStUserVisitsEntity;
|
||||
import com.xkrs.microservice.model.entity.yunli.YunLiUserExInfoEntity;
|
||||
import com.xkrs.microservice.service.RedisService;
|
||||
import com.xkrs.microservice.service.SysUserService;
|
||||
import com.xkrs.microservice.service.YunLiUserService;
|
||||
import com.xkrs.microservice.service.auth.MenuActionService;
|
||||
import com.xkrs.microservice.service.auth.MenuService;
|
||||
import com.xkrs.microservice.service.auth.SysDmsRoleService;
|
||||
import com.xkrs.microservice.service.log.LoginLogService;
|
||||
import com.xkrs.microservice.service.log.PtStUserVisitsService;
|
||||
import com.xkrs.microservice.util.AESUtil;
|
||||
import com.xkrs.microservice.util.HttpUtil;
|
||||
import org.springframework.security.authentication.AuthenticationProvider;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.xkrs.microservice.util.EncryptDecryptUtil.encry256;
|
||||
|
||||
/**
|
||||
* 自定义认证Provider
|
||||
* @author tajochen
|
||||
*/
|
||||
@Component
|
||||
public class CustomAuthenticationProvider implements AuthenticationProvider {
|
||||
|
||||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Resource
|
||||
private SysDmsRoleService sysSysDmsRoleService;
|
||||
|
||||
@Resource
|
||||
private MenuService menuService;
|
||||
|
||||
@Resource
|
||||
private MenuActionService menuActionService;
|
||||
|
||||
@Resource
|
||||
private LoginLogService loginLogService;
|
||||
|
||||
@Resource
|
||||
private YunLiUserService yunLiUserService;
|
||||
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
@Resource
|
||||
private PtStUserVisitsService ptStUserVisitsService;
|
||||
|
||||
/**
|
||||
* 初使化时将已静态化的Service实例化
|
||||
*/
|
||||
protected static CustomAuthenticationProvider customAuthenticationProvider;
|
||||
|
||||
private static final String URL = "http://172.20.234.46:8091/bsp/service/api/sdhbuser/userValidation";
|
||||
|
||||
/**
|
||||
* 通过@PostConstruct实现初始化bean之前进行的操作
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
customAuthenticationProvider = this;
|
||||
customAuthenticationProvider.sysUserService = this.sysUserService;
|
||||
customAuthenticationProvider.sysSysDmsRoleService = this.sysSysDmsRoleService;
|
||||
customAuthenticationProvider.menuService = this.menuService;
|
||||
customAuthenticationProvider.menuActionService = this.menuActionService;
|
||||
customAuthenticationProvider.loginLogService = this.loginLogService;
|
||||
customAuthenticationProvider.redisService = this.redisService;
|
||||
customAuthenticationProvider.yunLiUserService = this.yunLiUserService;
|
||||
customAuthenticationProvider.ptStUserVisitsService = this.ptStUserVisitsService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户认证授权
|
||||
* @param authentication
|
||||
* @return
|
||||
* @throws AuthenticationException
|
||||
*/
|
||||
@Override
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
// 获取认证的用户名 & 密码
|
||||
List<String> principal = (List<String>)authentication.getPrincipal();
|
||||
// String userName = authentication.getName();
|
||||
String userName = principal.get(0);
|
||||
String userSource = principal.get(1);
|
||||
String password = authentication.getCredentials().toString();
|
||||
PtStUserVisitsEntity en = new PtStUserVisitsEntity();
|
||||
// 子系统登陆
|
||||
final String pro = "0";
|
||||
final String appPro = "2";
|
||||
final String appCity = "3";
|
||||
final String app = "2";
|
||||
final String web = "1";
|
||||
// 检查用户是否存在
|
||||
if((pro.equals(userSource) || appPro.equals(userSource)) && chackUserIsLimit5(userName)){
|
||||
YunLiUserExInfoEntity userInfoMap = customAuthenticationProvider.yunLiUserService.getUserInfoByIdSso(userName);
|
||||
if (userInfoMap == null) {
|
||||
astrict(userName);
|
||||
throw new BadCredentialsException("user: " + userName + " password error");
|
||||
}
|
||||
String decodeString = AESUtil.encrypt1(password,"123456a?");
|
||||
Map<String, String> map = new HashMap<>(2);
|
||||
map.put("userName", userName);
|
||||
map.put("pass", decodeString);
|
||||
String s = HttpUtil.get(URL, map);
|
||||
// String s = "1";
|
||||
final String success = "1";
|
||||
if (success.equals(s)) {
|
||||
// 设置权限列表
|
||||
ArrayList<GrantedAuthority> permissions = new ArrayList<>();
|
||||
List<RoleEntity> permissionList = customAuthenticationProvider.sysSysDmsRoleService.getRoleListByYunLiUserId(userName);
|
||||
for(RoleEntity roleEntity : permissionList) {
|
||||
permissions.add(new GrantedAuthorityImpl(roleEntity.getRoleName()));
|
||||
}
|
||||
|
||||
if (appPro.equals(userSource)){
|
||||
en.setType(app);
|
||||
} else {
|
||||
en.setType(web);
|
||||
}
|
||||
customAuthenticationProvider.ptStUserVisitsService.add(en);
|
||||
// 生成令牌
|
||||
|
||||
return new UsernamePasswordAuthenticationToken(authentication, "decodeString", permissions);
|
||||
} else {
|
||||
astrict(userName);
|
||||
throw new BadCredentialsException("user: " + userName + " password error");
|
||||
}
|
||||
} else if (chackUserIsLimit5(userName)){
|
||||
SysUserEntity sysUserByUserName = customAuthenticationProvider.sysUserService.getSysUserByUserName(userName);
|
||||
if (sysUserByUserName == null) {
|
||||
astrict(userName);
|
||||
throw new BadCredentialsException("user: " + userName + " password error");
|
||||
}
|
||||
if (sysUserByUserName.getDeleteFlag() == 1) {
|
||||
throw new BadCredentialsException("user: " + userName + " password error");
|
||||
}
|
||||
String encryptPassword = encry256(password + sysUserByUserName.getSalt());
|
||||
if (encryptPassword.equals(sysUserByUserName.getPassword())) {
|
||||
// 设置权限列表
|
||||
ArrayList<GrantedAuthority> permissions = new ArrayList<>();
|
||||
List<RoleEntity> permissionList = customAuthenticationProvider.sysSysDmsRoleService.getRoleListByUserName(userName);
|
||||
for(RoleEntity roleEntity : permissionList) {
|
||||
permissions.add(new GrantedAuthorityImpl(roleEntity.getRoleName()));
|
||||
}
|
||||
if (appPro.equals(userSource)){
|
||||
en.setType(app);
|
||||
} else {
|
||||
en.setType(web);
|
||||
}
|
||||
if (appCity.equals(userSource)){
|
||||
en.setType(app);
|
||||
} else {
|
||||
en.setType(web);
|
||||
}
|
||||
customAuthenticationProvider.ptStUserVisitsService.add(en);
|
||||
// 生成令牌
|
||||
return new UsernamePasswordAuthenticationToken(authentication, "decodeString", permissions);
|
||||
} else {
|
||||
astrict(userName);
|
||||
throw new BadCredentialsException("user: " + userName + " password error");
|
||||
}
|
||||
} else {
|
||||
astrict(userName);
|
||||
throw new BadCredentialsException("user: " + userName + " password error");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可以提供输入类型的认证服务
|
||||
* @param authentication
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean supports(Class<?> authentication) {
|
||||
return authentication.equals(UsernamePasswordAuthenticationToken.class);
|
||||
}
|
||||
|
||||
private void astrict(String userName) {
|
||||
Boolean aBoolean = customAuthenticationProvider.redisService.hasKey(userName);
|
||||
if (aBoolean) {
|
||||
int o = (Integer)customAuthenticationProvider.redisService.get(userName);
|
||||
customAuthenticationProvider.redisService.set(userName, o + 1, 5, TimeUnit.MINUTES);
|
||||
} else {
|
||||
customAuthenticationProvider.redisService.set(userName, 1, 5, TimeUnit.MINUTES);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean chackUserIsLimit5(String userName) {
|
||||
Boolean aBoolean = customAuthenticationProvider.redisService.hasKey(userName);
|
||||
if (aBoolean) {
|
||||
int o = (Integer)customAuthenticationProvider.redisService.get(userName);
|
||||
return o < 5;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.xkrs.microservice.common.account;
|
||||
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
||||
/**
|
||||
* 权限认证服务
|
||||
* @author tajochen
|
||||
*/
|
||||
public class GrantedAuthorityImpl implements GrantedAuthority {
|
||||
|
||||
private String authority;
|
||||
|
||||
public GrantedAuthorityImpl(String authority) {
|
||||
this.authority = authority;
|
||||
}
|
||||
|
||||
public void setAuthority(String authority) {
|
||||
this.authority = authority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthority() {
|
||||
return this.authority;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.xkrs.microservice.common.account;
|
||||
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.filter.GenericFilterBean;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 拦截所有需要JWT的请求,然后调用TokenAuthenticationService类的静态方法去做JWT验证
|
||||
* @author tajochen
|
||||
*/
|
||||
public class JwtAuthenticationFilter extends GenericFilterBean {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request,
|
||||
ServletResponse response,
|
||||
FilterChain filterChain) throws IOException, ServletException {
|
||||
Authentication authentication = TokenAuthenticationService.getAuthentication((HttpServletRequest)request);
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
filterChain.doFilter(request,response);
|
||||
}
|
||||
}
|
@ -0,0 +1,247 @@
|
||||
package com.xkrs.microservice.common.account;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.xkrs.microservice.common.encapsulation.OutputEncapsulation;
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.model.entity.auth.SysUserEntity;
|
||||
import com.xkrs.microservice.model.entity.log.LoginLog;
|
||||
import com.xkrs.microservice.model.entity.yunli.YunLiUnitInfoEntity;
|
||||
import com.xkrs.microservice.model.entity.yunli.YunLiUserExInfoEntity;
|
||||
import com.xkrs.microservice.service.RedisService;
|
||||
import com.xkrs.microservice.service.SysUserService;
|
||||
import com.xkrs.microservice.service.YunLiUserService;
|
||||
import com.xkrs.microservice.service.log.LoginLogService;
|
||||
import com.xkrs.microservice.util.IpUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
|
||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.*;
|
||||
|
||||
import static com.xkrs.microservice.util.DateTimeUtil.getNowTimeStr;
|
||||
import static com.xkrs.microservice.util.StringUtil.stringIsNull;
|
||||
|
||||
/**
|
||||
* jwt登录过滤器
|
||||
* @author tajochen
|
||||
*/
|
||||
public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(JwtLoginFilter.class);
|
||||
|
||||
|
||||
@Resource
|
||||
private LoginLogService loginLogService;
|
||||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
@Resource
|
||||
private YunLiUserService yunLiUserService;
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
|
||||
public JwtLoginFilter(String url, AuthenticationManager authManager) {
|
||||
super(new AntPathRequestMatcher(url));
|
||||
setAuthenticationManager(authManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录时验证
|
||||
* @param req
|
||||
* @param res
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Authentication attemptAuthentication(HttpServletRequest req, HttpServletResponse res) throws UnsupportedEncodingException {
|
||||
req.setCharacterEncoding("UTF-8");
|
||||
res.setHeader("Access-Control-Allow-Origin","*");
|
||||
res.setHeader("Access-Control-Allow-Credentials", "false");
|
||||
AccountCredentials creds = new AccountCredentials();
|
||||
//获取表单数据
|
||||
String userName = req.getParameter("userName");
|
||||
String password = req.getParameter("password");
|
||||
String rememberMe = req.getParameter("remember");
|
||||
String userSource = req.getParameter("userSource");
|
||||
//如果用户名密码为空
|
||||
if(userName == null||password == null|| userName.trim().isEmpty()||password.trim().isEmpty()){
|
||||
throw new BadCredentialsException("user or password is null");
|
||||
}
|
||||
if(rememberMe == null||rememberMe.isEmpty()){
|
||||
rememberMe = "false";
|
||||
}
|
||||
if (!stringIsNull(userSource)) {
|
||||
userSource = "0";
|
||||
}
|
||||
creds.setUserSource(userSource);
|
||||
creds.setUserName(userName.trim());
|
||||
creds.setPassword(password.trim());
|
||||
creds.setRemember(Boolean.parseBoolean(rememberMe));
|
||||
List<String> prin = new ArrayList<>(2);
|
||||
prin.add(creds.getUserName());
|
||||
prin.add(creds.getUserSource());
|
||||
// 返回一个验证令牌
|
||||
return getAuthenticationManager().authenticate(
|
||||
new UsernamePasswordAuthenticationToken(
|
||||
prin,
|
||||
creds.getPassword()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证成功后调用
|
||||
* @param req
|
||||
* @param response
|
||||
* @param chain
|
||||
* @param auth
|
||||
* @throws IOException
|
||||
* @throws ServletException
|
||||
*/
|
||||
@Override
|
||||
protected void successfulAuthentication(
|
||||
HttpServletRequest req, HttpServletResponse response, FilterChain chain, Authentication auth) {
|
||||
if(yunLiUserService==null){
|
||||
ServletContext servletContext = req.getServletContext();
|
||||
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
|
||||
yunLiUserService = webApplicationContext.getBean(YunLiUserService.class);
|
||||
}
|
||||
if(sysUserService==null){
|
||||
ServletContext servletContext = req.getServletContext();
|
||||
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
|
||||
sysUserService = webApplicationContext.getBean(SysUserService.class);
|
||||
}
|
||||
if(loginLogService==null){
|
||||
ServletContext servletContext = req.getServletContext();
|
||||
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
|
||||
loginLogService = webApplicationContext.getBean(LoginLogService.class);
|
||||
}
|
||||
if(redisService==null){
|
||||
ServletContext servletContext = req.getServletContext();
|
||||
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
|
||||
redisService = webApplicationContext.getBean(RedisService.class);
|
||||
}
|
||||
//更新用户登录信息
|
||||
// sysUserService.updateSysUserLogin(auth.getName(), IpUtil.getIpAddr(req));
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
response.setHeader("Access-Control-Allow-Credentials", "false");
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
String hostName = "";
|
||||
String hostAddress = "";
|
||||
// 主机地址
|
||||
try {
|
||||
hostAddress = InetAddress.getLocalHost().getHostAddress();
|
||||
// 主机名称
|
||||
hostName = InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
UsernamePasswordAuthenticationToken principal = (UsernamePasswordAuthenticationToken)auth.getPrincipal();
|
||||
Object principal1 = principal.getPrincipal();
|
||||
List<String> list = JSON.parseObject(JSON.toJSONString(principal1), new TypeReference<>(){});
|
||||
Map<String, String> userMap = new HashMap<>(5);
|
||||
String userSource = list.get(1);
|
||||
final String pro = "0";
|
||||
final String appPro = "2";
|
||||
String userId;
|
||||
String orginId;
|
||||
String orginName = "";
|
||||
String realName;
|
||||
if (pro.equals(userSource) || appPro.equals(userSource)) {
|
||||
YunLiUserExInfoEntity userInfoById = yunLiUserService.getUserInfoByIdSso(list.get(0));
|
||||
userId = userInfoById.getoUserId();
|
||||
orginId = userInfoById.getoOrganId();
|
||||
realName = userInfoById.getoUserName();
|
||||
List<YunLiUnitInfoEntity> unitInfoByoriginId = yunLiUserService.getUnitInfoByoriginId(orginId);
|
||||
if (unitInfoByoriginId.size() > 0) {
|
||||
YunLiUnitInfoEntity unitInfoEntity = unitInfoByoriginId.get(0);
|
||||
orginName = unitInfoEntity.getUnitName();
|
||||
userMap.put("o_organ_name", orginName);
|
||||
}
|
||||
userMap.put("o_user_city", "山东省");
|
||||
userMap.put("o_user_code", "370000");
|
||||
userMap.put("o_user_from", "1");
|
||||
userMap.put("o_user_id", userId);
|
||||
|
||||
userMap.put("o_user_name", realName);
|
||||
userMap.put("o_organ_id", orginId);
|
||||
} else {
|
||||
SysUserEntity sysUserByUserName = sysUserService.getSysUserByUserName(list.get(0));
|
||||
userId = sysUserByUserName.getId();
|
||||
realName = sysUserByUserName.getRealName();
|
||||
userMap.put("o_user_id", sysUserByUserName.getId());
|
||||
userMap.put("o_user_name", realName);
|
||||
userMap.put("o_user_city", sysUserByUserName.getCityName());
|
||||
userMap.put("o_user_code", sysUserByUserName.getCityCode());
|
||||
userMap.put("o_user_from", "2");
|
||||
orginId = "O0000000000000001336";
|
||||
orginName = "生态与遥感室";
|
||||
}
|
||||
LoginLog loginLog = new LoginLog("ERSAC", getNowTimeStr(), hostName, hostAddress, userId, realName,
|
||||
orginId, orginName, IpUtil.getIpAddr(req), "Authentication", "log-in", "system", "成功", "");
|
||||
loginLogService.save(loginLog);
|
||||
TokenAuthenticationService.addAuthentication(response, auth.getName(), auth.getAuthorities(), userMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证失败后调用
|
||||
* @param request
|
||||
* @param response
|
||||
* @param failed
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
protected void unsuccessfulAuthentication(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
AuthenticationException failed) throws IOException {
|
||||
if(redisService==null){
|
||||
ServletContext servletContext = request.getServletContext();
|
||||
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
|
||||
redisService = webApplicationContext.getBean(RedisService.class);
|
||||
}
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
response.setHeader("Access-Control-Allow-Credentials", "false");
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
String localizedMessage = failed.getLocalizedMessage();
|
||||
String username = getUsername(localizedMessage);
|
||||
Object o = 0;
|
||||
if (redisService.hasKey(username)) {
|
||||
o = redisService.get(getUsername(localizedMessage));
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("errorNum", o);
|
||||
map.put("errorMsg", "username or password error");
|
||||
out.append(OutputEncapsulation.outputEncapsulationObject(PromptMessageEnum.USER_LOGIN_ERROR, map, locale));
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
}
|
||||
|
||||
private String getUsername(String info) {
|
||||
String[] s = info.split(" ");
|
||||
return s[1];
|
||||
}
|
||||
}
|
@ -0,0 +1,206 @@
|
||||
package com.xkrs.microservice.common.account;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.OutputEncapsulation;
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.model.entity.auth.SysUserEntity;
|
||||
import com.xkrs.microservice.model.entity.yunli.YunLiUserExInfoEntity;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.AuthorityUtils;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* token认证服务
|
||||
* @author tajochen
|
||||
*/
|
||||
public class TokenAuthenticationService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(TokenAuthenticationService.class);
|
||||
/**
|
||||
* 过期时间6小时
|
||||
*/
|
||||
static public final long EXPIRATIONTIME = 21_600_000;
|
||||
/**
|
||||
* 加密密钥
|
||||
*/
|
||||
static public final String SECRET_KEY = "0Y9H364Q9Y908262F25LMXGIKIN5N858XM3674GWL2DD8X1DS4W6I722IRY8PS4XPNB6U303" +
|
||||
"45HBVCUL94STG8C3Z53T7A09JJ100I56YE9894CI11PX9J71HIZ8L5Y2O504C4E2K8276425UA8734833F45K36878FXAG799QV9LXU" +
|
||||
"JOI3XA2046UPG8TB2OT84R5T6ZB127N9ZPJ7AJMC41JVHB2WK2B6H8NL45LZNAZ666KHZH3QUT65UX6F8";
|
||||
/**
|
||||
* Token前缀
|
||||
*/
|
||||
static public final String TOKEN_PREFIX = "Bearer";
|
||||
|
||||
/**
|
||||
* 存放Token的Header Key
|
||||
*/
|
||||
static final String HEADER_STRING = "Authorization";
|
||||
static SecretKey key = Keys.hmacShaKeyFor(SECRET_KEY.getBytes());
|
||||
|
||||
/**
|
||||
* JWT生成方法
|
||||
* @param response
|
||||
* @param userName
|
||||
* @param authorities
|
||||
*/
|
||||
static void addAuthentication(HttpServletResponse response, String userName,
|
||||
Collection<? extends GrantedAuthority > authorities, Map<String, String> userinfo) {
|
||||
|
||||
Locale locale = new Locale("zh", "CN");
|
||||
StringBuffer auths = new StringBuffer();
|
||||
String authsList = "";
|
||||
for(GrantedAuthority r : authorities) {
|
||||
auths.append("," + r.getAuthority());
|
||||
}
|
||||
authsList = auths.toString();
|
||||
if(authsList.length()>1){
|
||||
authsList=authsList.substring(1,authsList.length());
|
||||
}else{
|
||||
logger.warn(userName +" has no permission!");
|
||||
}
|
||||
// 生成JWT
|
||||
String jwt = Jwts.builder()
|
||||
.setSubject(userinfo.get("o_user_id"))
|
||||
.setIssuer("https://www.microservice.com")
|
||||
.setAudience(userinfo.get("o_user_name"))
|
||||
.claim("auths", authsList)
|
||||
.setExpiration(new Date(System.currentTimeMillis() + EXPIRATIONTIME))
|
||||
.signWith(key)
|
||||
.compact();
|
||||
PrintWriter out = null;
|
||||
try {
|
||||
out = response.getWriter();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
Map<String, Object> outMap = new HashMap<>(2);
|
||||
outMap.put("jwt", jwt);
|
||||
outMap.put("userInfo", userinfo);
|
||||
out.append(OutputEncapsulation.outputEncapsulationObject(PromptMessageEnum.SUCCESS, outMap, locale));
|
||||
}
|
||||
|
||||
/**
|
||||
* JWT验证方法
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
static Authentication getAuthentication(HttpServletRequest request) {
|
||||
// 从Header中拿到token
|
||||
String token = request.getHeader(HEADER_STRING);
|
||||
if (token != null) {
|
||||
try {
|
||||
// 解析 Token
|
||||
Claims claims = Jwts.parserBuilder()
|
||||
.setSigningKey(key).build()
|
||||
// 去掉 Bearer
|
||||
.parseClaimsJws(token.replace(TOKEN_PREFIX, ""))
|
||||
.getBody();
|
||||
// 获取用户名
|
||||
String userName = claims.getSubject();
|
||||
// 获取权限
|
||||
List<GrantedAuthority> authorities = AuthorityUtils.commaSeparatedStringToAuthorityList((String) claims.get("auths"));
|
||||
return new UsernamePasswordAuthenticationToken(userName, null, authorities);
|
||||
} catch(Exception e) {
|
||||
// the sub field was missing or did not have a value
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* user middleground info
|
||||
*/
|
||||
public static String getJwt(YunLiUserExInfoEntity userInfo, List<String> authsList) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (String au :
|
||||
authsList) {
|
||||
sb.append(au).append(",");
|
||||
}
|
||||
String substring = "";
|
||||
if (authsList.size() != 0) {
|
||||
substring = sb.substring(0, sb.length() - 1);
|
||||
}
|
||||
String jwt = Jwts.builder()
|
||||
.setSubject(userInfo.getoUserId())
|
||||
.setIssuer("https://www.microservice.com")
|
||||
.setAudience(userInfo.getoUserName())
|
||||
// 保存权限
|
||||
.claim("auths", substring)
|
||||
// 有效期设置
|
||||
.setExpiration(new Date(System.currentTimeMillis() + EXPIRATIONTIME))
|
||||
// 签名设置
|
||||
.signWith(key)
|
||||
.compact();
|
||||
return jwt;
|
||||
}
|
||||
|
||||
public static String getJwt(Map<String, String> userInfo, List<String> authsList) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (String au :
|
||||
authsList) {
|
||||
sb.append(au).append(",");
|
||||
}
|
||||
String substring = "";
|
||||
if (authsList.size() != 0) {
|
||||
substring = sb.substring(0, sb.length() - 1);
|
||||
}
|
||||
String jwt = Jwts.builder()
|
||||
.setSubject(userInfo.get("o_user_id"))
|
||||
.setIssuer("https://www.microservice.com")
|
||||
.setAudience(userInfo.get("o_user_name"))
|
||||
// 保存权限
|
||||
.claim("auths", substring)
|
||||
// 有效期设置
|
||||
.setExpiration(new Date(System.currentTimeMillis() + EXPIRATIONTIME))
|
||||
// 签名设置
|
||||
.signWith(key)
|
||||
.compact();
|
||||
return jwt;
|
||||
}
|
||||
|
||||
/**
|
||||
* own user info
|
||||
* @param userInfo
|
||||
* @param authsList
|
||||
* @return
|
||||
*/
|
||||
public static String getJwt(SysUserEntity userInfo, List<String> authsList) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (String au :
|
||||
authsList) {
|
||||
sb.append(au).append(",");
|
||||
}
|
||||
String substring = "";
|
||||
if (authsList.size() != 0) {
|
||||
substring = sb.substring(0, sb.length() - 1);
|
||||
}
|
||||
String jwt = Jwts.builder()
|
||||
.setSubject(userInfo.getId())
|
||||
.setIssuer("https://www.microservice.com")
|
||||
.setAudience(userInfo.getUserName())
|
||||
// 保存权限
|
||||
.claim("auths", substring)
|
||||
// 有效期设置
|
||||
.setExpiration(new Date(System.currentTimeMillis() + EXPIRATIONTIME))
|
||||
// 签名设置
|
||||
.signWith(key)
|
||||
.compact();
|
||||
return jwt;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.xkrs.microservice.common.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 系统跨域配置
|
||||
* @author tajochen
|
||||
*/
|
||||
@Configuration
|
||||
public class CorsConfig implements WebMvcConfigurer {
|
||||
|
||||
@Resource
|
||||
private CorsInterceptor corsInterceptor;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(corsInterceptor);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.xkrs.microservice.common.config;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 跨域处理
|
||||
* @author tajochen
|
||||
*/
|
||||
@Component
|
||||
public class CorsInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
|
||||
//添加跨域CORS
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
response.setHeader("Access-Control-Allow-Credentials", "false");
|
||||
response.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
|
||||
response.setHeader("Access-Control-Allow-Headers", "Content-Type , Authorization," +
|
||||
"Accept,Origin,X-Requested-With");
|
||||
response.setHeader("Access-Control-Max-Age", "216000");
|
||||
response.setHeader("Content-Type","application/json;charset=UTF-8");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package com.xkrs.microservice.common.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* WebMVC配置
|
||||
* @author Tajochen
|
||||
*/
|
||||
@Configuration
|
||||
public class MvcConfig implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
* 放行跨域请求
|
||||
*/
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOrigins("*")
|
||||
.allowedMethods("*")
|
||||
.allowedHeaders("*");
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时任务线程池更改,防止多个任务并行
|
||||
*/
|
||||
@Bean
|
||||
public TaskScheduler taskScheduler() {
|
||||
final ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
|
||||
scheduler.setPoolSize(5);
|
||||
return scheduler;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.xkrs.microservice.common.config;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Redis 缓存自动配置
|
||||
* @author tajochen
|
||||
*/
|
||||
@Configuration
|
||||
@AutoConfigureAfter(RedisAutoConfiguration.class)
|
||||
public class RedisCacheAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<String, Serializable> redisCacheTemplate(LettuceConnectionFactory redisConnectionFactory) {
|
||||
RedisTemplate<String, Serializable> template = new RedisTemplate<>();
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
|
||||
template.setConnectionFactory(redisConnectionFactory);
|
||||
return template;
|
||||
}
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
package com.xkrs.microservice.common.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cache.interceptor.CacheErrorHandler;
|
||||
import org.springframework.cache.interceptor.CacheResolver;
|
||||
import org.springframework.cache.interceptor.KeyGenerator;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
|
||||
/**
|
||||
* redis配置
|
||||
* @author tajochen
|
||||
*/
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public class RedisConfig extends CachingConfigurerSupport{
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(RedisConfig.class);
|
||||
|
||||
@Resource
|
||||
private LettuceConnectionFactory lettuceConnectionFactory;
|
||||
|
||||
private Duration timeToLive = Duration.ofSeconds(3600*6);
|
||||
|
||||
@Bean
|
||||
@Override
|
||||
public KeyGenerator keyGenerator() {
|
||||
|
||||
// 设置自动key的生成规则,配置spring boot的注解,进行方法级别的缓存
|
||||
return (target, method, params) -> {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(target.getClass().getName());
|
||||
sb.append(":");
|
||||
sb.append(method.getName());
|
||||
for (Object obj : params) {
|
||||
sb.append(":" + String.valueOf(obj));
|
||||
}
|
||||
String rsToUse = String.valueOf(sb);
|
||||
// logger.info("自动生成Redis Key -> [{}]", rsToUse);
|
||||
return rsToUse;
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Override
|
||||
public CacheManager cacheManager() {
|
||||
// 关键点,spring cache的注解使用的序列化都从这来,没有这个配置的话使用的jdk自己的序列化
|
||||
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig()
|
||||
//key序列化方式
|
||||
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(keySerializer()))
|
||||
//value序列化方式
|
||||
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(valueSerializer()))
|
||||
.disableCachingNullValues()
|
||||
.entryTtl(timeToLive);
|
||||
|
||||
RedisCacheManager.RedisCacheManagerBuilder builder = RedisCacheManager.RedisCacheManagerBuilder
|
||||
.fromConnectionFactory(lettuceConnectionFactory)
|
||||
.cacheDefaults(config)
|
||||
.transactionAware();
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* RedisTemplate配置 在单独使用redisTemplate的时候 重新定义序列化方式
|
||||
*/
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate(LettuceConnectionFactory lettuceConnectionFactory) {
|
||||
// 设置序列化
|
||||
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
// 配置null值序列化成空字符串
|
||||
om.getSerializerProvider().setNullValueSerializer(new JsonSerializer<Object>() {
|
||||
@Override
|
||||
public void serialize(Object o, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
|
||||
jsonGenerator.writeString("");
|
||||
}
|
||||
});
|
||||
// 解决jackson无法反序列化LocalDateTime的问题,引入jsr310标准
|
||||
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
||||
om.registerModule(javaTimeModule);
|
||||
om.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
// 其他设置
|
||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance ,
|
||||
ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
||||
jackson2JsonRedisSerializer.setObjectMapper(om);
|
||||
// 配置redisTemplate
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>();
|
||||
redisTemplate.setConnectionFactory(lettuceConnectionFactory);
|
||||
RedisSerializer<?> stringSerializer = new StringRedisSerializer();
|
||||
redisTemplate.setKeySerializer(stringSerializer);
|
||||
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
|
||||
redisTemplate.setHashKeySerializer(stringSerializer);
|
||||
redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);
|
||||
redisTemplate.afterPropertiesSet();
|
||||
return redisTemplate;
|
||||
}
|
||||
|
||||
private RedisSerializer<String> keySerializer() {
|
||||
return new StringRedisSerializer();
|
||||
}
|
||||
|
||||
private RedisSerializer<Object> valueSerializer() {
|
||||
// 设置序列化
|
||||
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(
|
||||
Object.class);
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
// 解决jackson无法反序列化LocalDateTime的问题,引入jsr310标准
|
||||
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
||||
om.registerModule(javaTimeModule);
|
||||
om.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
// 其他设置
|
||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance ,
|
||||
ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
||||
jackson2JsonRedisSerializer.setObjectMapper(om);
|
||||
return jackson2JsonRedisSerializer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CacheResolver cacheResolver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public CacheErrorHandler errorHandler() {
|
||||
// 异常处理,当Redis发生异常时,打印日志,但是程序正常走
|
||||
logger.info("初始化 -> [{}]", "Redis CacheErrorHandler");
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package com.xkrs.microservice.common.config;
|
||||
|
||||
import com.xkrs.microservice.common.account.CustomAuthenticationProvider;
|
||||
import com.xkrs.microservice.common.account.JwtAuthenticationFilter;
|
||||
import com.xkrs.microservice.common.account.JwtLoginFilter;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@EnableGlobalMethodSecurity(prePostEnabled=true)
|
||||
class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
/**
|
||||
* 设置 HTTP 验证规则
|
||||
* @param http
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
// 关闭csrf验证
|
||||
http.csrf().disable()
|
||||
// 对请求进行认证
|
||||
.authorizeRequests()
|
||||
// 所有 / 的所有请求 都放行
|
||||
.antMatchers("/").permitAll()
|
||||
// 所有OPTIONS请求都放行
|
||||
.antMatchers(HttpMethod.OPTIONS).permitAll()
|
||||
// 单点登陆
|
||||
.antMatchers(HttpMethod.GET, "/yunli/sso").permitAll()
|
||||
// app单点登录
|
||||
.antMatchers(HttpMethod.POST, "/yunli/app/sso").permitAll()
|
||||
// first portal sso
|
||||
.antMatchers(HttpMethod.GET, "/test1/r2").permitAll()
|
||||
// 验证码
|
||||
.antMatchers(HttpMethod.POST, "/user/verificationCode").permitAll()
|
||||
.antMatchers(HttpMethod.GET, "/user/verifyCode").permitAll()
|
||||
.antMatchers("/SAML2/*").permitAll()
|
||||
.antMatchers("/service/*").permitAll()
|
||||
.antMatchers("/yunli/portal/sso").permitAll()
|
||||
// 入库接口
|
||||
.antMatchers("/file/tif/base").permitAll()
|
||||
// 测试
|
||||
.antMatchers("/yun/*").permitAll()
|
||||
// 检查用户名是否存在
|
||||
.antMatchers(HttpMethod.GET, "/yunli/user/get/username").permitAll()
|
||||
// .antMatchers(HttpMethod.POST, "/user/add").permitAll()
|
||||
// 所有 /user/check/duplicate 检查用户名是否重复 的POST请求 都放行
|
||||
// .antMatchers(HttpMethod.POST, "/api/user/check/duplicate").permitAll()
|
||||
// 所有 /login 用户登录 的POST请求 都放行
|
||||
.antMatchers(HttpMethod.POST, "/login").permitAll()
|
||||
// 所有其它请求需要身份认证
|
||||
// .anyRequest().authenticated()
|
||||
.and()
|
||||
// 添加一个过滤器 所有访问 /login 的请求交给 JWTLoginFilter 来处理 这个类处理所有的JWT相关内容
|
||||
.addFilterBefore(new JwtLoginFilter("/login", authenticationManager()),
|
||||
UsernamePasswordAuthenticationFilter.class)
|
||||
// 添加一个过滤器验证其他请求的Token是否合法
|
||||
.addFilterBefore(new JwtAuthenticationFilter(),
|
||||
UsernamePasswordAuthenticationFilter.class);
|
||||
;}
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// 使用自定义身份验证组件
|
||||
auth.authenticationProvider(new CustomAuthenticationProvider());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,59 @@
|
||||
package com.xkrs.microservice.common.encapsulation;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 输出信息对象
|
||||
* @author tajochen
|
||||
* @param <T>
|
||||
*/
|
||||
public class EncapsulationObejct<T> implements Serializable {
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
int status;
|
||||
|
||||
/**
|
||||
* 提示信息
|
||||
*/
|
||||
String msg;
|
||||
|
||||
/**
|
||||
* 数据
|
||||
*/
|
||||
T data;
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EncapsulationObejct{" +
|
||||
"status=" + status +
|
||||
", msg='" + msg + '\'' +
|
||||
", data=" + data +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,136 @@
|
||||
package com.xkrs.microservice.common.encapsulation;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.support.ResourceBundleMessageSource;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.FieldError;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* 输出信息封装
|
||||
*
|
||||
* @author tajochen
|
||||
*/
|
||||
@Component
|
||||
public class OutputEncapsulation {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OutputEncapsulation.class);
|
||||
|
||||
/**
|
||||
* 读取多国语言文件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static MessageSource messageSource() {
|
||||
Properties properties = new Properties();
|
||||
// 使用ClassLoader加载properties配置文件生成对应的输入流
|
||||
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("application-dev.properties");
|
||||
// 使用properties对象加载输入流
|
||||
try {
|
||||
properties.load(in);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
|
||||
messageSource.setBasename("i18n/messages");
|
||||
messageSource.setDefaultEncoding("UTF-8");
|
||||
return messageSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装输出数据
|
||||
*
|
||||
* @param promptMessageEnum
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
public static String outputEncapsulationObject(PromptMessageEnum promptMessageEnum, Object obj, Locale locale) {
|
||||
|
||||
EncapsulationObejct encapsulationObejct = new EncapsulationObejct();
|
||||
encapsulationObejct.setStatus(promptMessageEnum.getCode());
|
||||
encapsulationObejct.setMsg(messageSource().getMessage(promptMessageEnum.getText(), null, locale));
|
||||
encapsulationObejct.setData(obj);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// 忽略无法转换的对象
|
||||
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
|
||||
// 忽略json字符串中不识别的属性
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
// 解决jackson无法反序列化LocalDateTime的问题,引入jsr310标准
|
||||
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
||||
objectMapper.registerModule(javaTimeModule);
|
||||
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
String strByEo = "";
|
||||
try {
|
||||
strByEo = objectMapper.writeValueAsString(encapsulationObejct);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
logger.warn(e.toString());
|
||||
}
|
||||
return strByEo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装输出数据, 数据填报
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public static String outputEncapsulationObject2(PromptMessageEnum promptMessageEnum, String filaName, Object obj) {
|
||||
|
||||
EncapsulationObejct encapsulationObejct = new EncapsulationObejct();
|
||||
encapsulationObejct.setStatus(promptMessageEnum.getCode());
|
||||
encapsulationObejct.setMsg(filaName + promptMessageEnum.getText());
|
||||
encapsulationObejct.setData(obj);
|
||||
|
||||
// Constants constants = new Constants();
|
||||
// constants.setCode(inventoryStatus.getCode());
|
||||
// constants.setMsg(filaName + inventoryStatus.getMsg());
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// 忽略无法转换的对象
|
||||
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
|
||||
// 忽略json字符串中不识别的属性
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
// 解决jackson无法反序列化LocalDateTime的问题,引入jsr310标准
|
||||
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
||||
objectMapper.registerModule(javaTimeModule);
|
||||
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
String strByEo = "";
|
||||
try {
|
||||
strByEo = objectMapper.writeValueAsString(encapsulationObejct);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
logger.warn(e.toString());
|
||||
}
|
||||
return strByEo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出请求值检验错误信息
|
||||
*
|
||||
* @param fieldErrors
|
||||
* @return
|
||||
*/
|
||||
public static String outputEncapsulationErrorList(List<FieldError> fieldErrors, Locale locale) {
|
||||
List<String> errorMsg = new ArrayList<>();
|
||||
for (FieldError fieldError : fieldErrors) {
|
||||
String errMessage = fieldError.getDefaultMessage().subSequence(1, fieldError.getDefaultMessage().length() - 1).toString();
|
||||
errorMsg.add(messageSource().getMessage(errMessage, null, locale));
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, errorMsg, locale);
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package com.xkrs.microservice.common.encapsulation;
|
||||
|
||||
/**
|
||||
* 提示信息枚举
|
||||
* @author tajochen
|
||||
*/
|
||||
public enum PromptMessageEnum{
|
||||
|
||||
// 执行成功
|
||||
SUCCESS(0, "sys.message.success"),
|
||||
|
||||
// 用户权限错误或非法操作: 1001-1999
|
||||
USER_NOT_LOGGED(1001, "sys.message.user.not_logged_in"),
|
||||
USER_LOGIN_ERROR(1002, "sys.message.user.login_error"),
|
||||
USER_ACCOUNT_FORBIDDEN(1003, "sys.message.user.account_forbidden"),
|
||||
USER_ACCOUNT_NOT_ACTIVATED(1004, "sys.message.user.account_not_activated"),
|
||||
USER_HAS_OVERTIME(1005, "sys.message.user.overtime"),
|
||||
USER_NO_PERMISSION(1006,"sys.message.user.no_permission"),
|
||||
USER_ALREADY_LOGGED(1007, "sys.message.user.already_logged"),
|
||||
USER_NAME_HAS_EXIST(1010, "sys.user.name.already.exists"),
|
||||
VERIFICATION_CODE_TIMEOUT(1008, "sys.message.verification.code.timeout"),
|
||||
VERIFICATION_CODE_ERROR(1009, "sys.message.verification.code.error"),
|
||||
|
||||
// 请求参数错误或非法:2001-2999
|
||||
PARAM_NULL(2001, "sys.message.param.null"),
|
||||
PARAM_ILLEGAL(2002, "sys.message.param.illegal"),
|
||||
TASK_NULL(2100, "sys.task.null"),
|
||||
TASK_NOT_ACTIVATE(2101, "sys.task.not.activate"),
|
||||
TASK_FINISH(2102, "sys.task.finish"),
|
||||
POINT_HAS_EXIST(2103, "sys.point.has.exist"),
|
||||
Tel_INVAILD(2014, "tel.invaild"),
|
||||
|
||||
// 数据返回错误:3001-3999
|
||||
DATA_NONE(3001, "sys.message.data.none"),
|
||||
DATA_WRONG(3002, "sys.message.data.wrong"),
|
||||
POINT_NULL_ERROR(3101, "sys.point.null.error"),
|
||||
IMG_REPETITION_ERROR(3102, "sys.img.repetition.error"),
|
||||
|
||||
// 操作失败:4001-4999
|
||||
PROCESS_FAIL(4001,"sys.message.process.fail"),
|
||||
PROCESS_OVERTIME(4002,"sys.message.process.overtime"),
|
||||
FILE_EXISTS(4003,"sys.message.file.exists"),
|
||||
FILE_WRITE_ERROR(4004,"sys.message.file.write.error"),
|
||||
FILE_READ_ERROR(4005,"sys.message.file.read.error"),
|
||||
READ_TIME_OUT_ERROR(4006, "yunli.read.timeout..error"),
|
||||
|
||||
// 系统内部错误或异常:5001-5999
|
||||
SYSTEM_INNER_ERROR(5001,"sys.message.system.inner_error"),
|
||||
SYSTEM_ABNORMAL(5002,"sys.message.system.abnormal"),
|
||||
SYSTEM_BUSY(5003,"sys.message.system.busy"),
|
||||
SYSTEM_MAINTAIN(5004,"sys.message.system.maintain"),
|
||||
|
||||
// 数据库错误:6001-6999
|
||||
DATABASE_ERROR(6001,"sys.message.database.error"),
|
||||
|
||||
// 文档错误
|
||||
PROCIRYCOUNTY_ERROR(7002, "procitycounty.error"),
|
||||
POINTNOTEXIT_ERROR(7003, "point.error"),
|
||||
DATAOUTOFRANGE_ERROR(7004, "data.error"),
|
||||
TIMEOUTOFRANGE_ERROR(7005, "time.error"),
|
||||
DATANULLERROR(7006, "data.null_error"),
|
||||
TEMPLATEILLAGE_ERROR(7007, "template.error"),
|
||||
DATAHASBLANK(7008, "data.blank_error"),
|
||||
EIDATAHASBEAN(7009, "ei.hava_error"),
|
||||
DOCUMENT_DIFFERENT(7010, "document.different_error"),
|
||||
// 地图服务已存在
|
||||
MAP_SERVICE_EXIST_ERROR(7011, "map_service_exist_error"),
|
||||
// 该年土地利用已存在
|
||||
Land_HAS_EXIST(7012, "land_has_exist"),
|
||||
|
||||
// python
|
||||
EI_API_ERROR(8001, "ei.api.error"),
|
||||
NECESSARY_DATA_BLANK(8002, "necessary_data_blank");
|
||||
|
||||
|
||||
private int code;
|
||||
|
||||
private String text;
|
||||
|
||||
private PromptMessageEnum(int code,String text) {
|
||||
this.code = code;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.xkrs.microservice.common.portal;
|
||||
|
||||
import org.loushang.bsp.security.AgentSessionIntegrationFilter;
|
||||
import org.loushang.bsp.security.sp.service.SpFilterWrapper;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
*/
|
||||
@Configuration
|
||||
public class SsoFilterRegistration {
|
||||
@Bean
|
||||
public FilterRegistrationBean SpFilterWrapper(){
|
||||
FilterRegistrationBean registrationBean = new
|
||||
FilterRegistrationBean();
|
||||
// 注入过滤器
|
||||
registrationBean.setFilter(new SpFilterWrapper());
|
||||
// 拦截规则
|
||||
registrationBean.addUrlPatterns("/service/*");
|
||||
registrationBean.addUrlPatterns("/SAML2/*");
|
||||
registrationBean.addUrlPatterns("/test1/r2");
|
||||
//过滤器名称
|
||||
registrationBean.setName("SpDispacher");
|
||||
//过滤器顺序
|
||||
registrationBean.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE);
|
||||
return registrationBean;
|
||||
}
|
||||
@Bean
|
||||
public FilterRegistrationBean SessionIntegrationFilter(){
|
||||
FilterRegistrationBean registrationBean = new
|
||||
FilterRegistrationBean();
|
||||
// 注入过滤器
|
||||
registrationBean.setFilter(new AgentSessionIntegrationFilter());
|
||||
// 拦截规则
|
||||
registrationBean.addUrlPatterns("/*");
|
||||
//过滤器名称
|
||||
registrationBean.setName("SessionIntegrationFilter");
|
||||
//过滤器顺序
|
||||
registrationBean.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE+1);
|
||||
return registrationBean;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.xkrs.microservice.common.tool;
|
||||
|
||||
/**
|
||||
* CompareVersion 比较版本号
|
||||
* @author tajochen
|
||||
*/
|
||||
public class CompareVersion {
|
||||
|
||||
/**
|
||||
* 比较三位版本号 ,若 版本1>版本2 返回 1,若版本1<版本2 返回 -1,否则返回0
|
||||
* @param version1 版本1
|
||||
* @param version2 版本2
|
||||
* @return
|
||||
*/
|
||||
public static int compareVersion(String version1, String version2) {
|
||||
String[] v1 = version1.split("\\.");
|
||||
String[] v2 = version2.split("\\.");
|
||||
int n = Math.max(v1.length, v2.length);
|
||||
for (int i = 0; i < n; i++) {
|
||||
int v1Int = i < v1.length ? Integer.parseInt(v1[i]) : 0;
|
||||
int v2Int = i < v2.length ? Integer.parseInt(v2[i]) : 0;
|
||||
if (v1Int == v2Int) {
|
||||
continue;
|
||||
}
|
||||
if (v1Int > v2Int){
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package com.xkrs.microservice.common.tool;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* dao接口类处理工具
|
||||
* @author tajochen
|
||||
*/
|
||||
public class EntityUtil {
|
||||
private static final Logger logger = LoggerFactory.getLogger(EntityUtil.class);
|
||||
|
||||
/**
|
||||
* 将数组数据转换为实体类
|
||||
* 此处数组元素的顺序必须与实体类构造函数中的属性顺序一致
|
||||
* @param list 数组对象集合
|
||||
* @param clazz 实体类
|
||||
* @param <T> 实体类
|
||||
* @param model 实例化的实体类
|
||||
* @return 实体类集合
|
||||
*/
|
||||
public static <T> List<T> castEntity(List<Object[]> list, Class<T> clazz, Object model) {
|
||||
List<T> returnList = new ArrayList<T>();
|
||||
if (list.isEmpty()) {
|
||||
return returnList;
|
||||
}
|
||||
//获取每个数组集合的元素个数
|
||||
Object[] co = list.get(0);
|
||||
|
||||
//获取当前实体类的属性名、属性值、属性类别
|
||||
List<Map> attributeInfoList = getFiledsInfo(model);
|
||||
//创建属性类别数组
|
||||
Class[] c2 = new Class[attributeInfoList.size()];
|
||||
//如果数组集合元素个数与实体类属性个数不一致则发生错误
|
||||
if (attributeInfoList.size() != co.length) {
|
||||
return returnList;
|
||||
}
|
||||
//确定构造方法
|
||||
for (int i = 0; i < attributeInfoList.size(); i++) {
|
||||
c2[i] = (Class) attributeInfoList.get(i).get("type");
|
||||
}
|
||||
try {
|
||||
for (Object[] o : list) {
|
||||
Constructor<T> constructor = clazz.getConstructor(c2);
|
||||
returnList.add(constructor.newInstance(o));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.error("实体数据转化为实体类发生异常:异常信息:{}", ex.getMessage());
|
||||
return returnList;
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据属性名获取属性值
|
||||
* @param fieldName 属性名
|
||||
* @param modle 实体类
|
||||
* @return 属性值
|
||||
*/
|
||||
private static Object getFieldValueByName(String fieldName, Object modle) {
|
||||
try {
|
||||
String firstLetter = fieldName.substring(0, 1).toUpperCase();
|
||||
String getter = "get" + firstLetter + fieldName.substring(1);
|
||||
Method method = modle.getClass().getMethod(getter, new Class[]{});
|
||||
Object value = method.invoke(modle, new Object[]{});
|
||||
return value;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取属性类型(type),属性名(name),属性值(value)的map组成的list
|
||||
* @param model 实体类
|
||||
* @return list集合
|
||||
*/
|
||||
private static List<Map> getFiledsInfo(Object model) {
|
||||
Field[] fields = model.getClass().getDeclaredFields();
|
||||
List<Map> list = new ArrayList(fields.length);
|
||||
Map infoMap = null;
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
infoMap = new HashMap(3);
|
||||
infoMap.put("type", fields[i].getType());
|
||||
infoMap.put("name", fields[i].getName());
|
||||
infoMap.put("value", getFieldValueByName(fields[i].getName(), model));
|
||||
list.add(infoMap);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
108
src/main/java/com/xkrs/microservice/common/tool/TokenUtil.java
Normal file
108
src/main/java/com/xkrs/microservice/common/tool/TokenUtil.java
Normal file
@ -0,0 +1,108 @@
|
||||
package com.xkrs.microservice.common.tool;
|
||||
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.AuthorityUtils;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* token工具
|
||||
* @author tajochen
|
||||
*/
|
||||
public class TokenUtil {
|
||||
/**
|
||||
* Token前缀
|
||||
*/
|
||||
static public final String TOKEN_PREFIX = "Bearer";
|
||||
|
||||
static public final String SECRETKEY = "0Y9H364Q9Y908262F25LMXGIKIN5N858XM3674GWL2DD8X1DS4W6I722IRY8PS4XPNB6U30345" +
|
||||
"HBVCUL94STG8C3Z53T7A09JJ100I56YE9894CI11PX9J71HIZ8L5Y2O504C4E2K8276425UA8734833F45K36878FXAG799QV9LXUJ" +
|
||||
"OI3XA2046UPG8TB2OT84R5T6ZB127N9ZPJ7AJMC41JVHB2WK2B6H8NL45LZNAZ666KHZH3QUT65UX6F8";
|
||||
|
||||
static SecretKey key = Keys.hmacShaKeyFor(SECRETKEY.getBytes());
|
||||
|
||||
public static String getTokenUserName(String token) {
|
||||
String userName = "";
|
||||
if (token != null) {
|
||||
try {
|
||||
// 解析 Token
|
||||
Claims claims = Jwts.parserBuilder()
|
||||
.setSigningKey(key).build()
|
||||
// 去掉 Bearer
|
||||
.parseClaimsJws(token.replace(TOKEN_PREFIX, ""))
|
||||
.getBody();
|
||||
// 获取用户名
|
||||
userName = claims.getAudience();
|
||||
// 获取权限
|
||||
List<GrantedAuthority> authorities = AuthorityUtils.commaSeparatedStringToAuthorityList((String) claims.get("auths"));
|
||||
} catch(Exception e) {
|
||||
// the sub field was missing or did not have a 'jsmith' value
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return userName;
|
||||
}
|
||||
|
||||
public static List<String> getTokenAuth(String token) {
|
||||
String userName = "";
|
||||
List<String> auths = new ArrayList<>();
|
||||
if (token != null) {
|
||||
try {
|
||||
// 解析 Token
|
||||
Claims claims = Jwts.parserBuilder()
|
||||
.setSigningKey(key).build()
|
||||
// 去掉 Bearer
|
||||
.parseClaimsJws(token.replace(TOKEN_PREFIX, ""))
|
||||
.getBody();
|
||||
// 获取用户名
|
||||
userName = claims.getSubject();
|
||||
// 获取权限
|
||||
List<GrantedAuthority> authorities = AuthorityUtils.commaSeparatedStringToAuthorityList((String) claims.get("auths"));
|
||||
if (authorities.size() != 0) {
|
||||
for (GrantedAuthority e :
|
||||
authorities) {
|
||||
String authority = e.getAuthority();
|
||||
auths.add(authority);
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
// the sub field was missing or did not have a 'jsmith' value
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return auths;
|
||||
}
|
||||
|
||||
public static String getUserId(String token) {
|
||||
String userId = "";
|
||||
List<String> auths = new ArrayList<>();
|
||||
if (token != null) {
|
||||
try {
|
||||
// 解析 Token
|
||||
Claims claims = Jwts.parserBuilder()
|
||||
.setSigningKey(key).build()
|
||||
// 去掉 Bearer
|
||||
.parseClaimsJws(token.replace(TOKEN_PREFIX, ""))
|
||||
.getBody();
|
||||
// 获取用户名
|
||||
userId = claims.getSubject();
|
||||
} catch(Exception e) {
|
||||
// the sub field was missing or did not have a 'jsmith' value
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return userId;
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package com.xkrs.microservice.config;
|
||||
|
||||
import org.kie.api.KieBase;
|
||||
import org.kie.api.KieServices;
|
||||
import org.kie.api.builder.*;
|
||||
import org.kie.api.runtime.KieContainer;
|
||||
import org.kie.api.runtime.KieSession;
|
||||
import org.kie.internal.io.ResourceFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Drools 配置类
|
||||
* @author dong
|
||||
* @date 2021/2/16
|
||||
*/
|
||||
|
||||
@Configuration
|
||||
public class KiaSessionConfig {
|
||||
|
||||
private static final String RULES_PATH = "rules/";
|
||||
|
||||
@Bean
|
||||
public KieFileSystem kieFileSystem() throws IOException {
|
||||
KieFileSystem kieFileSystem = getKieServices().newKieFileSystem();
|
||||
for (Resource file : getRuleFiles()) {
|
||||
kieFileSystem.write(ResourceFactory.newClassPathResource(RULES_PATH + file.getFilename(),
|
||||
"UTF-8"));
|
||||
}
|
||||
return kieFileSystem;
|
||||
}
|
||||
|
||||
private Resource[] getRuleFiles() throws IOException {
|
||||
ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
|
||||
return resourcePatternResolver.getResources("classpath*:" + RULES_PATH + "**/*.*");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public KieContainer kieContainer() throws IOException {
|
||||
final KieRepository kieRepository = getKieServices().getRepository();
|
||||
kieRepository.addKieModule(new KieModule() {
|
||||
@Override
|
||||
public ReleaseId getReleaseId() {
|
||||
return kieRepository.getDefaultReleaseId();
|
||||
}
|
||||
});
|
||||
|
||||
KieBuilder kieBuilder = getKieServices().newKieBuilder(kieFileSystem());
|
||||
kieBuilder.buildAll();
|
||||
return getKieServices().newKieContainer(kieRepository.getDefaultReleaseId());
|
||||
}
|
||||
|
||||
private KieServices getKieServices() {
|
||||
return KieServices.Factory.get();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public KieBase kieBase() throws IOException {
|
||||
return kieContainer().getKieBase();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public KieSession kieSession() throws IOException {
|
||||
return kieContainer().newKieSession();
|
||||
}
|
||||
}
|
70
src/main/java/com/xkrs/microservice/config/QuartzConfig.java
Normal file
70
src/main/java/com/xkrs/microservice/config/QuartzConfig.java
Normal file
@ -0,0 +1,70 @@
|
||||
package com.xkrs.microservice.config;
|
||||
|
||||
import com.xkrs.microservice.quartz.Demo;
|
||||
import com.xkrs.microservice.service.QuartzTriggerService;
|
||||
import org.quartz.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author dong
|
||||
*/
|
||||
@Configuration
|
||||
public class QuartzConfig {
|
||||
@Resource
|
||||
private QuartzTriggerService quartzTriggerService;
|
||||
|
||||
/**
|
||||
* 1.创建任务
|
||||
*/
|
||||
@Bean(name = {"scanDetail"})
|
||||
public JobDetail scanOrderjobDetail() {
|
||||
// 指定job的名称和持久化保存任务
|
||||
return JobBuilder
|
||||
// 引入自定义的任务
|
||||
.newJob(Demo.class)
|
||||
// 指定任务名称,随意
|
||||
.withIdentity("demo")
|
||||
.storeDurably()
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 2.定义触发器
|
||||
*/
|
||||
@Bean
|
||||
public Trigger orderTrigger(@Qualifier(value = "scanDetail") JobDetail jobDetail) {
|
||||
// SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule()
|
||||
// .withRepeatCount(5) //执行次数是从0开始计算的
|
||||
// .withIntervalInMilliseconds(1000); //设定间隔时间。1000ms
|
||||
|
||||
//0 0 * * * ? 时间表达式 规定任务多久执行一次
|
||||
CronScheduleBuilder scheduleBuilder
|
||||
= CronScheduleBuilder.cronSchedule("1 0 1 * * ? *");
|
||||
return TriggerBuilder
|
||||
.newTrigger()
|
||||
.forJob(scanOrderjobDetail())
|
||||
// 指定触发器随意
|
||||
.withIdentity("demo")
|
||||
.withSchedule(scheduleBuilder).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 3.任务调度 ,创建scheduler
|
||||
*/
|
||||
@Bean
|
||||
public SchedulerFactoryBean schedulerFactoryBean(@Autowired Trigger orderTrigger,
|
||||
@Autowired SpringJobFactory springJobFactory) {
|
||||
SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
|
||||
schedulerFactoryBean.setJobDetails(scanOrderjobDetail());
|
||||
schedulerFactoryBean.setTriggers(orderTrigger);
|
||||
schedulerFactoryBean.setJobFactory(springJobFactory);
|
||||
return schedulerFactoryBean;
|
||||
}
|
||||
}
|
198
src/main/java/com/xkrs/microservice/config/RequestLogAspect.java
Normal file
198
src/main/java/com/xkrs/microservice/config/RequestLogAspect.java
Normal file
@ -0,0 +1,198 @@
|
||||
package com.xkrs.microservice.config;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xkrs.microservice.model.entity.auth.SysUserEntity;
|
||||
import com.xkrs.microservice.model.entity.log.BusiLog;
|
||||
import com.xkrs.microservice.model.entity.yunli.YunLiUnitInfoEntity;
|
||||
import com.xkrs.microservice.model.entity.yunli.YunLiUserExInfoEntity;
|
||||
import com.xkrs.microservice.service.SysUserService;
|
||||
import com.xkrs.microservice.service.YunLiUserService;
|
||||
import com.xkrs.microservice.service.log.BusiLogService;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.*;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName;
|
||||
import static com.xkrs.microservice.util.DateTimeUtil.getNowTimeStr;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/4/27
|
||||
*/
|
||||
|
||||
@Component
|
||||
@Aspect
|
||||
public class RequestLogAspect {
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(RequestLogAspect.class);
|
||||
|
||||
|
||||
@Resource
|
||||
private BusiLogService busiLogService;
|
||||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
@Resource
|
||||
private YunLiUserService yunLiUserService;
|
||||
|
||||
|
||||
@Pointcut("execution(* com.xkrs.microservice.controller..*(..))")
|
||||
public void requestServer() {
|
||||
}
|
||||
|
||||
@Before("requestServer()")
|
||||
public void doBefore(JoinPoint joinPoint) {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
LOGGER.info("===============================Start========================");
|
||||
LOGGER.info("IP : {}", request.getRemoteAddr());
|
||||
LOGGER.info("URL : {}", request.getRequestURL().toString());
|
||||
LOGGER.info("HTTP Method : {}", request.getMethod());
|
||||
LOGGER.info("Class Method : {}.{}", joinPoint.getSignature().getDeclaringTypeName(),
|
||||
joinPoint.getSignature().getName());
|
||||
}
|
||||
|
||||
@Around("requestServer()")
|
||||
public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
|
||||
long start = System.currentTimeMillis();
|
||||
Object result = proceedingJoinPoint.proceed();
|
||||
LOGGER.info("Request Params : {}", getRequestParams(proceedingJoinPoint));
|
||||
LOGGER.info("Result : {}", result);
|
||||
LOGGER.info("Time Cost : {} ms", System.currentTimeMillis() - start);
|
||||
// saveLog(proceedingJoinPoint);
|
||||
return result;
|
||||
}
|
||||
@After("requestServer()")
|
||||
public void doAfter(JoinPoint joinPoint) {
|
||||
LOGGER.info("===============================End========================");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取入参
|
||||
* @param proceedingJoinPoint
|
||||
*
|
||||
* @return
|
||||
* */
|
||||
private Map<String, Object> getRequestParams(ProceedingJoinPoint proceedingJoinPoint) {
|
||||
Map<String, Object> requestParams = new HashMap<>();
|
||||
String[] paramNames = ((MethodSignature)proceedingJoinPoint.getSignature()).getParameterNames();
|
||||
//参数值
|
||||
Object[] paramValues = proceedingJoinPoint.getArgs();
|
||||
for (int i = 0; i < paramNames.length; i++) {
|
||||
Object value = paramValues[i];
|
||||
//如果是文件对象
|
||||
if (value instanceof MultipartFile) {
|
||||
//如果是文件对象
|
||||
MultipartFile file = (MultipartFile) value;
|
||||
//获取文件名
|
||||
value = file.getOriginalFilename();
|
||||
|
||||
}
|
||||
requestParams.put(paramNames[i], value);
|
||||
}
|
||||
return requestParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志
|
||||
* @param proceedingJoinPoint
|
||||
*/
|
||||
private void saveLog(ProceedingJoinPoint proceedingJoinPoint) {
|
||||
BusiLog busiLog = new BusiLog();
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
Object result = null;
|
||||
try {
|
||||
result = proceedingJoinPoint.proceed();
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
busiLog.setVisitIp(request.getRemoteAddr());
|
||||
busiLog.setUrl(request.getRequestURL().toString());
|
||||
busiLog.setMethod(request.getMethod());
|
||||
busiLog.setSystemSign("ERSAC");
|
||||
String hostAddress = null;
|
||||
String hostName = null;
|
||||
// 主机地址
|
||||
try {
|
||||
hostAddress = InetAddress.getLocalHost().getHostAddress();
|
||||
// 主机名称
|
||||
hostName = InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
busiLog.setDeviceIp(hostAddress);
|
||||
busiLog.setHostname(hostName);
|
||||
String authorization = request.getHeader("Authorization");
|
||||
if (authorization != null) {
|
||||
String userName = getTokenUserName(authorization);
|
||||
YunLiUserExInfoEntity userInfoById = yunLiUserService.getUserInfoById(userName);
|
||||
// Map<String, String> userInfoById = (Map<String, String>) userInfoById1;
|
||||
String userId;
|
||||
String orginId;
|
||||
String orginName = "";
|
||||
if (userInfoById == null) {
|
||||
SysUserEntity sysUserByRealName = sysUserService.getSysUserByRealName(userName);
|
||||
userId = sysUserByRealName.getId();
|
||||
orginId = "O0000000000000001336";
|
||||
orginName = "生态与遥感室";
|
||||
} else {
|
||||
|
||||
userId = userInfoById.getoUserId();
|
||||
orginId = userInfoById.getoOrganId();
|
||||
List<YunLiUnitInfoEntity> unitInfoByoriginId = yunLiUserService.getUnitInfoByoriginId(orginId);
|
||||
if (unitInfoByoriginId.size() > 0) {
|
||||
YunLiUnitInfoEntity unitInfoEntity = unitInfoByoriginId.get(0);
|
||||
orginName = unitInfoEntity.getUnitName();
|
||||
}
|
||||
}
|
||||
busiLog.setUserName(userName);
|
||||
busiLog.setUserId(userId);
|
||||
busiLog.setUserOrgId(orginId);
|
||||
busiLog.setUserOrgName(orginName);
|
||||
} else {
|
||||
busiLog.setUserName("");
|
||||
busiLog.setUserId("");
|
||||
busiLog.setUserOrgId("");
|
||||
busiLog.setUserOrgName("");
|
||||
}
|
||||
|
||||
busiLog.setOperateTime(getNowTimeStr());
|
||||
busiLog.setAccessResource("");
|
||||
|
||||
busiLog.setOperateMode("q");
|
||||
busiLog.setLogType("business");
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JsonNode arrayNode = null;
|
||||
try {
|
||||
arrayNode = mapper.readTree(String.valueOf(result));
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String msg = arrayNode.path("msg").asText();
|
||||
final String win = "成功";
|
||||
final String success = "success";
|
||||
if (win.equals(msg) || success.equals(msg)) {
|
||||
busiLog.setOperateResult("成功");
|
||||
} else {
|
||||
busiLog.setOperateResult("失败");
|
||||
}
|
||||
busiLogService.save(busiLog);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.xkrs.microservice.config;
|
||||
|
||||
import org.quartz.spi.TriggerFiredBundle;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.quartz.AdaptableJobFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* 解决spring bean注入Job的问题
|
||||
*/
|
||||
@Component
|
||||
@Configuration
|
||||
public class SpringJobFactory extends AdaptableJobFactory {
|
||||
@Autowired
|
||||
private AutowireCapableBeanFactory capableBeanFactory;
|
||||
|
||||
@Override
|
||||
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
|
||||
// 调用父类的方法
|
||||
Object jobInstance = super.createJobInstance(bundle);
|
||||
// 进行注入
|
||||
capableBeanFactory.autowireBean(jobInstance);
|
||||
return jobInstance;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,199 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.model.qo.LandBoundaryQo;
|
||||
import com.xkrs.microservice.model.qo.LandDisasterQo;
|
||||
import com.xkrs.microservice.model.qo.LandDynamicQo;
|
||||
import com.xkrs.microservice.model.qo.LandTypeQo;
|
||||
import com.xkrs.microservice.model.validation.*;
|
||||
import com.xkrs.microservice.service.ecology.*;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList;
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/2
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/app/file")
|
||||
public class AppDocumentController {
|
||||
@Resource
|
||||
private LandBoundaryService landBoundaryService;
|
||||
@Resource
|
||||
private LandDisasterService landDisasterService;
|
||||
@Resource
|
||||
private LandDynamicService landDynamicService;
|
||||
@Resource
|
||||
private LandTypeService landTypeService;
|
||||
@Resource
|
||||
private EcologyService ecologyService;
|
||||
@Resource
|
||||
private FieldVerificationService fieldVerificationService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 接收边界表
|
||||
* @param qo
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/landboundary", method = RequestMethod.POST)
|
||||
public String addLandBoundary(@Validated({LandBoundaryQoInsert.class}) @RequestBody LandBoundaryQo qo, BindingResult bindingResult,
|
||||
@RequestHeader(value="Authorization") String token) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
String userName = getTokenUserName(token);
|
||||
boolean b = ecologyService.checkPoint(qo, userName);
|
||||
if (b) {
|
||||
landBoundaryService.save(qo, userName);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
} else {
|
||||
return outputEncapsulationObject(PromptMessageEnum.POINT_NULL_ERROR,"核查点位不存在",locale);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收边界表
|
||||
* @param qo
|
||||
* @return
|
||||
*/
|
||||
// @RequestMapping(value = "/landboundary/update", method = RequestMethod.POST)
|
||||
public String updateLandBoundary(@Validated({LandBoundaryQoUpdate.class}) @RequestBody LandBoundaryQo qo, BindingResult bindingResult) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
landBoundaryService.update(qo);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/landdisaster", method = RequestMethod.POST)
|
||||
public String addLandDisaster(@Validated({LandDisasterQoInsert.class}) @RequestBody LandDisasterQo qo, BindingResult bindingResult,
|
||||
@RequestHeader(value="Authorization") String token) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
String userName = getTokenUserName(token);
|
||||
boolean b = ecologyService.checkPoint(qo, userName);
|
||||
if (b) {
|
||||
landDisasterService.save(qo, userName);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
} else {
|
||||
return outputEncapsulationObject(PromptMessageEnum.POINT_NULL_ERROR,"核查点位不存在",locale);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* update边界表
|
||||
* @param qo
|
||||
* @return
|
||||
*/
|
||||
// @RequestMapping(value = "/landdisaster/update", method = RequestMethod.POST)
|
||||
public String updateLanddisaster(@Validated({LandDisasterQoUpdate.class}) @RequestBody LandDisasterQo qo, BindingResult bindingResult) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
landDisasterService.update(qo);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/landdynamic", method = RequestMethod.POST)
|
||||
public String addLandDynamic(@Validated({LandDynamicQoInsert.class}) @RequestBody LandDynamicQo qo, BindingResult bindingResult,
|
||||
@RequestHeader(value="Authorization") String token) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
String userName = getTokenUserName(token);
|
||||
boolean b = ecologyService.checkPoint(qo, userName);
|
||||
if (b) {
|
||||
landDynamicService.save(qo, userName);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
} else {
|
||||
return outputEncapsulationObject(PromptMessageEnum.POINT_NULL_ERROR,"核查点位不存在",locale);
|
||||
}
|
||||
}
|
||||
|
||||
// @RequestMapping(value = "/landdynamic/update", method = RequestMethod.POST)
|
||||
public String updateLandDisaster(@Validated({LandDynamicQoUpdate.class}) @RequestBody LandDynamicQo qo, BindingResult bindingResult,
|
||||
@RequestHeader(value="Authorization") String token) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
|
||||
landDynamicService.update(qo);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/landtype", method = RequestMethod.POST)
|
||||
public String addLandType(@Validated({LandTypeQoInsert.class}) @RequestBody LandTypeQo qo, BindingResult bindingResult,
|
||||
@RequestHeader(value="Authorization") String token) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
String userName = getTokenUserName(token);
|
||||
boolean b = ecologyService.checkPoint(qo, userName);
|
||||
if (b) {
|
||||
landTypeService.save(qo, userName);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
} else {
|
||||
return outputEncapsulationObject(PromptMessageEnum.POINT_NULL_ERROR,"核查点位不存在",locale);
|
||||
}
|
||||
}
|
||||
|
||||
// @RequestMapping(value = "/landtype/update", method = RequestMethod.POST)
|
||||
public String updateLandType(@Validated({LandTypeQoUpdate.class}) @RequestBody LandTypeQo qo, BindingResult bindingResult) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
landTypeService.update(qo);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出核查文档
|
||||
* @param id 点位id
|
||||
* @param response
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/down/point", method = RequestMethod.GET)
|
||||
public String exportExcel(@RequestParam("id") Integer id, HttpServletResponse response, HttpServletRequest request) {
|
||||
return fieldVerificationService.exportExcel(id, request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量导出
|
||||
* @param id 核查任务id
|
||||
* @param response
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/down/point/batch", method = RequestMethod.GET)
|
||||
public String exportExcelBatch(@RequestParam("id") Integer id, HttpServletResponse response, HttpServletRequest request) {
|
||||
return fieldVerificationService.exportExcelBatch(id, request, response);
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.model.entity.AppFileEntity;
|
||||
import com.xkrs.microservice.model.qo.AppFileQo;
|
||||
import com.xkrs.microservice.model.validation.AppFileQoInsert;
|
||||
import com.xkrs.microservice.model.vo.FileServerResultVo;
|
||||
import com.xkrs.microservice.service.AppManageService;
|
||||
import com.xkrs.microservice.service.FileServerService;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList;
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName;
|
||||
import static com.xkrs.microservice.util.NumberUtil.isStrNumeric;
|
||||
|
||||
/**
|
||||
* App 管理服务
|
||||
* @author tajochen
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/app-file")
|
||||
public class AppManageController {
|
||||
|
||||
@Resource
|
||||
private AppManageService appManageService;
|
||||
|
||||
@Resource
|
||||
private FileServerService fileServerService;
|
||||
|
||||
@RequestMapping(value="/get/all",method = RequestMethod.GET)
|
||||
public String getAllAppFiles() {
|
||||
// 获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
Iterable<AppFileEntity> list = appManageService.getAllFile();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/get/new-version",method = RequestMethod.GET)
|
||||
@CrossOrigin
|
||||
public String appFileGetNew(@RequestParam("versionNumber") String versionNumber){
|
||||
// 获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
String pattern = "^([1-9]\\d|[1-9])(.([1-9]\\d|\\d)){2}$";
|
||||
boolean isMatch = Pattern.matches(pattern, versionNumber);
|
||||
if(!isMatch){
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"版本号错误",locale);
|
||||
}
|
||||
Iterable<AppFileEntity> list = appManageService.checkLastVersionNumber(versionNumber);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/add",method = RequestMethod.POST)
|
||||
@PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor')")
|
||||
@CrossOrigin
|
||||
public String appFileAdd(@Validated({AppFileQoInsert.class}) @RequestBody AppFileQo appFileQo,
|
||||
BindingResult bindingResult, @RequestHeader(value="Authorization") String token) {
|
||||
// 获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
// 验证数据合法性
|
||||
if(bindingResult.hasErrors()){
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
// 检查版本号是否存在
|
||||
Iterable<AppFileEntity> appFileEntityIterable = appManageService.getByVersionNumber(appFileQo.getVersionNumber());
|
||||
for (AppFileEntity o : appFileEntityIterable) {
|
||||
if(o!=null){
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"重复的版本号",locale);
|
||||
}
|
||||
}
|
||||
// 获取当前用户名
|
||||
String userName = getTokenUserName(token);
|
||||
appManageService.add(appFileQo,userName);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/delete",method = RequestMethod.DELETE)
|
||||
@PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')")
|
||||
@CrossOrigin
|
||||
public String appFileDelete(@RequestParam("id") String id) {
|
||||
//获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if(!isStrNumeric(id)){
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale);
|
||||
}
|
||||
Optional <AppFileEntity> sf = appManageService.getById(Integer.parseInt(id));
|
||||
if(sf.isEmpty()){
|
||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"指定id文件不存在",locale);
|
||||
}
|
||||
try {
|
||||
FileServerResultVo fileServerResultVo = fileServerService.deleteFile(sf.get().getMd5(),"");
|
||||
appManageService.delete(Integer.parseInt(id));
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,fileServerResultVo,locale);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"文件服务器出错",locale);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,755 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.model.entity.aquatic.*;
|
||||
import com.xkrs.microservice.model.qo.aquatic.*;
|
||||
import com.xkrs.microservice.model.qo.village.RiverNotInvolvedSurveyQoInsert;
|
||||
import com.xkrs.microservice.model.qo.village.RiverNotInvolvedSurveyQoUpdate;
|
||||
import com.xkrs.microservice.model.validation.*;
|
||||
import com.xkrs.microservice.model.vo.AquaticFindVo;
|
||||
import com.xkrs.microservice.model.vo.DatabaseVo;
|
||||
import com.xkrs.microservice.service.FileDocumentService;
|
||||
import com.xkrs.microservice.service.aquatic.*;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList;
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
import static com.xkrs.microservice.common.encapsulation.PromptMessageEnum.*;
|
||||
import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName;
|
||||
import static com.xkrs.microservice.util.DateTimeUtil.dateToString;
|
||||
import static com.xkrs.microservice.util.DateTimeUtil.stringToDate;
|
||||
import static com.xkrs.microservice.util.StringUtil.stringIsNull;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/3
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/aquatic")
|
||||
public class AquaticController {
|
||||
|
||||
@Resource
|
||||
private LakeSurveyService lakeSurveyService;
|
||||
@Resource
|
||||
private PhytoplanktonCountService phytoplanktonCountService;
|
||||
@Resource
|
||||
private PhytoplanktonDatabaseService phytoplanktonDatabaseService;
|
||||
@Resource
|
||||
private ZoobenthosDatabaseService zoobenthosDatabaseService;
|
||||
@Resource
|
||||
private ZooplanktonDatabaseService zooplanktonDatabaseService;
|
||||
@Resource
|
||||
private SpeciesTimeService speciesTimeService;
|
||||
@Resource
|
||||
private AquaticFindService aquaticFindService;
|
||||
@Resource
|
||||
private RiverInvolvedSurveyService riverInvolvedSurveyService;
|
||||
@Resource
|
||||
private RiverNotInvolvedSurveyService riverNotInvolvedSurveyService;
|
||||
@Resource
|
||||
private ZoobenthosCountService zoobenthosCountService;
|
||||
@Resource
|
||||
private ZooplanktonCountService zooplanktonCountService;
|
||||
@Resource
|
||||
private RiverLakeService riverLakeService;
|
||||
@Resource
|
||||
private FileDocumentService fileDocumentService;
|
||||
@Resource
|
||||
private AnalysisService analysisService;
|
||||
@Resource
|
||||
private SpeciesDicService speciesDicService;
|
||||
|
||||
|
||||
/**
|
||||
* 湖库生境调查表修改
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/update/lakesurvey", method = RequestMethod.POST)
|
||||
public String updateLakeSurvey(@Validated({LakeSurveyQoUpdate.class}) @RequestBody List<LakeSurveyQo> qo, BindingResult bindingResult){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
// String userName = getTokenUserName(token);
|
||||
for (LakeSurveyQo q :
|
||||
qo) {
|
||||
lakeSurveyService.add(q, "userName");
|
||||
}
|
||||
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 湖库生境调查表新增
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/add/lakesurvey", method = RequestMethod.POST)
|
||||
public String addLakeSurvey(@Validated({LakeSurveyQoInsert.class}) @RequestBody LakeSurveyQo qo, BindingResult bindingResult,
|
||||
@RequestHeader(value="Authorization") String token){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
String userName = getTokenUserName(token);
|
||||
lakeSurveyService.add(qo, userName);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 可涉河流生境调查表修改
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/update/riverinvolvedsurvey", method = RequestMethod.POST)
|
||||
public String updateRiverInvolvedSurvey(@Validated({RiverInvolvedSurveyUpdate.class}) @RequestBody List<RiverInvolvedSurveyQo> qo, BindingResult bindingResult){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
for (RiverInvolvedSurveyQo q :
|
||||
qo) {
|
||||
riverInvolvedSurveyService.add(q, "");
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 可涉河流生境调查表新增
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/add/riverinvolvedsurvey", method = RequestMethod.POST)
|
||||
public String addRiverInvolvedSurvey(@Validated({RiverInvolvedSurveyInsert.class}) @RequestBody RiverInvolvedSurveyQo qo, BindingResult bindingResult,
|
||||
@RequestHeader(value="Authorization") String token){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
String userName = getTokenUserName(token);
|
||||
riverInvolvedSurveyService.add(qo, userName);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 不可涉河流生境调查表修改
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/update/rivernotinvolvedsurvey", method = RequestMethod.POST)
|
||||
public String updateRiverNotInvolvedSurvey(@Validated({RiverNotInvolvedSurveyQoUpdate.class}) @RequestBody List<RiverNotInvolvedSurveyQo> qo, BindingResult bindingResult){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
for (RiverNotInvolvedSurveyQo q :
|
||||
qo) {
|
||||
riverNotInvolvedSurveyService.add(q, "");
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 不可涉河流生境调查表
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/add/rivernotinvolvedsurvey", method = RequestMethod.POST)
|
||||
public String addRiverNotInvolvedSurvey(@Validated({RiverNotInvolvedSurveyQoInsert.class}) @RequestBody RiverNotInvolvedSurveyQo qo, BindingResult bindingResult,
|
||||
@RequestHeader(value="Authorization") String token){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
String userName = getTokenUserName(token);
|
||||
riverNotInvolvedSurveyService.add(qo, userName);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 浮游植物计数记录表,修改
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/update/phytoplankton/count", method = RequestMethod.POST)
|
||||
public String updatePhytoplanktonCount(@Validated({PhytoplanktonCountQoUpdate.class}) @RequestBody List<PhytoplanktonCountQo> qo, BindingResult bindingResult){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
for (PhytoplanktonCountQo q :
|
||||
qo) {
|
||||
phytoplanktonCountService.update(q);
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 浮游植物计数记录表,add
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/add/phytoplankton/count", method = RequestMethod.POST)
|
||||
public String addPhytoplanktonCount(@Validated({PhytoplanktonCountQoInsert.class}) @RequestBody PhytoplanktonCountQo qo, BindingResult bindingResult,
|
||||
@RequestHeader(value="Authorization") String token){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
String userName = getTokenUserName(token);
|
||||
phytoplanktonCountService.add(qo, userName);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 浮游植物数据库修改
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/update/phytoplankton/database", method = RequestMethod.POST)
|
||||
public String updatePhytoplanktonDatabase(@Validated({PhytoplanktonDatabaseQoUpdate.class}) @RequestBody List<PhytoplanktonDatabaseQo> qo, BindingResult bindingResult){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
for (PhytoplanktonDatabaseQo q :
|
||||
qo) {
|
||||
phytoplanktonDatabaseService.add(q);
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 浮游植物数据库add
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/add/phytoplankton/database", method = RequestMethod.POST)
|
||||
public String addPhytoplanktonDatabase(@Validated({PhytoplanktonDatabaseQoInsert.class}) @RequestBody PhytoplanktonDatabaseQo qo, BindingResult bindingResult,
|
||||
@RequestHeader(value="Authorization") String token){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
phytoplanktonDatabaseService.add(qo);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 底栖动物技术标更新
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/update/zoobenthos/count", method = RequestMethod.POST)
|
||||
public String updateZoobenthosCount(@Validated({ZoobenthosCountQoUpdate.class}) @RequestBody List<ZoobenthosCountQo> qo, BindingResult bindingResult) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
for (ZoobenthosCountQo q :
|
||||
qo) {
|
||||
zoobenthosCountService.update(q);
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 底栖动物技术标更新
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/add/zoobenthos/count", method = RequestMethod.POST)
|
||||
public String addZoobenthos(@Validated({ZoobenthosCountQoInsert.class}) @RequestBody ZoobenthosCountQo qo, BindingResult bindingResult,
|
||||
@RequestHeader(value="Authorization") String token) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
String userName = getTokenUserName(token);
|
||||
zoobenthosCountService.add(qo, userName);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 底栖动物数据库更新
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/update/zoobenthos/database", method = RequestMethod.POST)
|
||||
public String updateZoobenthos(@Validated({ZoobenthosDatabaseQoUpdate.class}) @RequestBody List<ZoobenthosDatabaseQo> qo, BindingResult bindingResult) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
for (ZoobenthosDatabaseQo q :
|
||||
qo) {
|
||||
zoobenthosDatabaseService.add(q);
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 底栖动物数据库更新
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/add/zoobenthos/database", method = RequestMethod.POST)
|
||||
public String addZoobenthos(@Validated({ZoobenthosDatabaseQoInsert.class}) @RequestBody ZoobenthosDatabaseQo qo, BindingResult bindingResult,
|
||||
@RequestHeader(value="Authorization") String token) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
zoobenthosDatabaseService.add(qo);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 浮游动物计数表更新
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/update/zooplankton/count", method = RequestMethod.POST)
|
||||
public String updateZooplanktonCount(@Validated({ZooplanktonCountQoUpdate.class}) @RequestBody List<ZooplanktonCountQo> qo, BindingResult bindingResult) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
for (ZooplanktonCountQo q :
|
||||
qo) {
|
||||
zooplanktonCountService.update(q);
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 浮游动物计数表更新
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/add/zooplankton/count", method = RequestMethod.POST)
|
||||
public String addZooplanktonCount(@Validated({ZooplanktonCountQoInsert.class}) @RequestBody ZooplanktonCountQo qo, BindingResult bindingResult,
|
||||
@RequestHeader(value="Authorization") String token) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
String userName = getTokenUserName(token);
|
||||
zooplanktonCountService.add(qo, userName);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 浮游动物数据库更新
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/update/zooplankton/database", method = RequestMethod.POST)
|
||||
public String updateZooplankton(@Validated({ZooplanktonDatabaseQoUpdate.class}) @RequestBody List<ZooplanktonDatabaseQo> qo, BindingResult bindingResult) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
for (ZooplanktonDatabaseQo q :
|
||||
qo) {
|
||||
zooplanktonDatabaseService.add(q);
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 浮游动物数据库更新
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/add/zooplankton/database", method = RequestMethod.POST)
|
||||
public String addZooplankton(@Validated({ZooplanktonDatabaseQoInsert.class}) @RequestBody ZooplanktonDatabaseQo qo, BindingResult bindingResult,
|
||||
@RequestHeader(value="Authorization") String token) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
zooplanktonDatabaseService.add(qo);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取河流或湖库名称
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/get/river", method = RequestMethod.GET)
|
||||
public String getRiverOrLakeName(){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<String> river = riverInvolvedSurveyService.getRiver();
|
||||
river.addAll(riverNotInvolvedSurveyService.getRiver());
|
||||
Set<String> set = new HashSet<>(river);
|
||||
return outputEncapsulationObject(SUCCESS, set, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取点位名称
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/get/point", method = RequestMethod.GET)
|
||||
public String getPointName(){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<String> point = phytoplanktonCountService.getPoint();
|
||||
point.addAll(lakeSurveyService.getPoint());
|
||||
point.addAll(riverInvolvedSurveyService.getPoint());
|
||||
point.addAll(riverNotInvolvedSurveyService.getPoint());
|
||||
point.addAll(zoobenthosCountService.getPoint());
|
||||
point.addAll(zooplanktonCountService.getPoint());
|
||||
Set<String> set = new HashSet<>(point);
|
||||
return outputEncapsulationObject(SUCCESS, set, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取物种名称
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/get/species", method = RequestMethod.GET)
|
||||
public String getSpeciesName(){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<String> name = phytoplanktonDatabaseService.getName();
|
||||
name.addAll(zoobenthosDatabaseService.getName());
|
||||
name.addAll(zooplanktonDatabaseService.getName());
|
||||
Set<Map<String, String>> set = new HashSet<>();
|
||||
for (String var :
|
||||
name) {
|
||||
if (var.contains(",")) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
String[] split = var.split(",");
|
||||
if ("null".equals(split[0]) || "null".equals(split[1]) ) {
|
||||
continue;
|
||||
}
|
||||
map.put("name", split[0]);
|
||||
map.put("latinName", split[1]);
|
||||
set.add(map);
|
||||
}
|
||||
}
|
||||
return outputEncapsulationObject(SUCCESS, set, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件类型获取详细信息
|
||||
* @param fileType
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/getall/type", method = RequestMethod.GET)
|
||||
public String getDataByType(@RequestParam("fileType") Integer fileType) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
if (null == fileType ) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "fileType must be not null", locale);
|
||||
}
|
||||
if ( fileType < 6 || fileType > 24) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "fileType must between 6 and 24", locale);
|
||||
}
|
||||
AquaticFindVo byFileType = aquaticFindService.findByFileType(fileType);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byFileType, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据采集时间或者物种种群或点位信息、经纬度、河流湖库名称、获取信息
|
||||
* @param speciesName
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/inquire", method = RequestMethod.GET)
|
||||
public String getByPointOrLonLatOrRiverOrLakeOrTime(@RequestParam("point") String point, @RequestParam("speciesName") String speciesName,
|
||||
// @RequestParam("lonLeftTop") String lonLeftTop,@RequestParam("latLeftTop") String latLeftTop,
|
||||
// @RequestParam("lonRightButtom") String lonRightButtom,@RequestParam("latRightButtom") String latRightButtom,
|
||||
@RequestParam("river") String river, @RequestParam("documentType") Integer documentType,
|
||||
@RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
String endTimePlusDay1;
|
||||
if (stringIsNull(endTime)) {
|
||||
endTimePlusDay1 = dateToString(stringToDate(endTime).plusDays(1));
|
||||
} else {
|
||||
endTimePlusDay1 = endTime;
|
||||
}
|
||||
|
||||
List<LakeSurveyEntity> byPointAndRiverName = lakeSurveyService.findByPointAndRiverName(point, startTime, endTimePlusDay1);
|
||||
List<PhytoplanktonCountEntity> byPointAndAnimalName = phytoplanktonCountService.findByPointAndAnimalName(point, speciesName, startTime, endTimePlusDay1);
|
||||
List<RiverInvolvedSurveyEntity> byPointAndTimeAndLonLatAndRiver = riverInvolvedSurveyService.findByPointAndTimeAndLonLatAndRiver(point, startTime, endTimePlusDay1, river);
|
||||
List<ZoobenthosCountEntity> byAnimalNameAndPointAndTime = zoobenthosCountService.findByAnimalNameAndPointAndTime(point, speciesName, startTime, endTimePlusDay1);
|
||||
List<ZooplanktonCountEntity> byPointAndTimeAndAnimal = zooplanktonCountService.findByPointAndTimeAndAnimal(point, speciesName, startTime, endTimePlusDay1);
|
||||
List<RiverNotInvolvedSurveyEntity> byPointAndTimeAndRiverAndLonLat = riverNotInvolvedSurveyService.findByPointAndTimeAndRiverAndLonLat(point, startTime, endTimePlusDay1, river);
|
||||
|
||||
Map<String, List> map = new HashMap<>();
|
||||
map.put("LakeSurvey", byPointAndRiverName);
|
||||
map.put("PhytoplanktonCount", byPointAndAnimalName);
|
||||
map.put("RiverInvolvedSurvey", byPointAndTimeAndLonLatAndRiver);
|
||||
map.put("ZoobenthosCount", byAnimalNameAndPointAndTime);
|
||||
map.put("ZooplanktonCount", byPointAndTimeAndAnimal);
|
||||
map.put("RiverNotInvolvedSurvey", byPointAndTimeAndRiverAndLonLat);
|
||||
if (documentType == 7) {
|
||||
return outputEncapsulationObject(SUCCESS, byPointAndTimeAndRiverAndLonLat, locale);
|
||||
} else if (documentType == 8) {
|
||||
return outputEncapsulationObject(SUCCESS, byPointAndTimeAndLonLatAndRiver, locale);
|
||||
} else if (documentType == 10) {
|
||||
return outputEncapsulationObject(SUCCESS, byPointAndRiverName, locale);
|
||||
} else if (documentType == 16) {
|
||||
return outputEncapsulationObject(SUCCESS, byPointAndAnimalName, locale);
|
||||
} else if (documentType == 18) {
|
||||
return outputEncapsulationObject(SUCCESS, byAnimalNameAndPointAndTime, locale);
|
||||
} else if (documentType == 23) {
|
||||
return outputEncapsulationObject(SUCCESS, byPointAndTimeAndAnimal, locale);
|
||||
}
|
||||
return outputEncapsulationObject(SUCCESS, map, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分析,表格初始化
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/analysis/init", method = RequestMethod.GET)
|
||||
public String analysisInit() {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<AnalysisEntity> all = analysisService.findAll();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Map<String, Map<Integer, Long>> gradeNum = analysisService.getGradeNum();
|
||||
Map<String, Map<String, Long>> animalNum = analysisService.getAnimalNum();
|
||||
map.put("table", all);
|
||||
map.put("grade", gradeNum);
|
||||
map.put("animalNum", animalNum);
|
||||
return outputEncapsulationObject(SUCCESS, map, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分析,表格初始化
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/analysis/search", method = RequestMethod.GET)
|
||||
public String analysisSearch(@RequestParam("point") String point, @RequestParam("startYear") String startYear, @RequestParam("endYear") String endYear) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (stringIsNull(point, startYear, endYear)) {
|
||||
List<AnalysisEntity> byYearAndPoint = analysisService.findByYearAndPoint(startYear, endYear, point);
|
||||
Map<String, Map<String, Long>> animalByPoint = analysisService.getAnimalByYearAndPoint(startYear, endYear,point);
|
||||
Map<String, Map<Integer, Long>> gradeNumByPoint = analysisService.getGradeNumByYearAndPoint(startYear, endYear,point);
|
||||
Map<String, Object> map = new HashMap<>(3);
|
||||
map.put("table", byYearAndPoint);
|
||||
map.put("grade", gradeNumByPoint);
|
||||
map.put("animalNum", animalByPoint);
|
||||
return outputEncapsulationObject(SUCCESS, map, locale);
|
||||
} else if (stringIsNull(point)) {
|
||||
List<AnalysisEntity> byPoint = analysisService.findByPoint(point);
|
||||
Map<String, Map<String, Long>> animalByPoint = analysisService.getAnimalByPoint(point);
|
||||
Map<String, Map<Integer, Long>> gradeNumByPoint = analysisService.getGradeNumByPoint(point);
|
||||
Map<String, Object> map = new HashMap<>(3);
|
||||
map.put("table", byPoint);
|
||||
map.put("grade", gradeNumByPoint);
|
||||
map.put("animalNum", animalByPoint);
|
||||
return outputEncapsulationObject(SUCCESS, map, locale);
|
||||
} else if (stringIsNull(startYear, endYear)) {
|
||||
List<AnalysisEntity> byPoint = analysisService.findByYear(startYear, endYear);
|
||||
Map<String, Map<String, Long>> animalByPoint = analysisService.getAnimalByYear(startYear, endYear);
|
||||
Map<String, Map<Integer, Long>> gradeNumByPoint = analysisService.getGradeNumByYear(startYear, endYear);
|
||||
Map<String, Object> map = new HashMap<>(3);
|
||||
map.put("table", byPoint);
|
||||
map.put("grade", gradeNumByPoint);
|
||||
map.put("animalNum", animalByPoint);
|
||||
return outputEncapsulationObject(SUCCESS, map, locale);
|
||||
}
|
||||
return outputEncapsulationObject(PARAM_NULL, "", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算
|
||||
* @param point
|
||||
* @param startYear
|
||||
* @param endYear
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/analysis/calculate", method = RequestMethod.GET)
|
||||
public String analysisCalculate(@RequestParam("point") String point, @RequestParam("startYear") String startYear, @RequestParam("endYear") String endYear) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (stringIsNull(point, startYear, endYear)) {
|
||||
analysisService.calculateYearAndPoint(startYear,endYear,point);
|
||||
} else if (stringIsNull(point)) {
|
||||
analysisService.calculatePoint(point);
|
||||
} else if (stringIsNull(startYear, endYear)) {
|
||||
analysisService.calculateYear(startYear,endYear);
|
||||
} else {
|
||||
analysisService.calculateAll();
|
||||
}
|
||||
return outputEncapsulationObject(SUCCESS, "", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 种群管理, 初始化
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/database/all", method = RequestMethod.GET)
|
||||
public String database(){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
List<DatabaseVo> all = phytoplanktonDatabaseService.getAll();
|
||||
all.addAll(zooplanktonDatabaseService.getAll());
|
||||
all.addAll(zoobenthosDatabaseService.getAll());
|
||||
return outputEncapsulationObject(SUCCESS,all, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 种群管理, 删除
|
||||
* @param id
|
||||
* @param type 0:浮游植物 1:底栖动物 2:浮游植物
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/database/dele", method = RequestMethod.GET)
|
||||
public String databaseDele(@RequestParam("id") Integer id, @RequestParam("type") Integer type){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (type == null || id == null) {
|
||||
return outputEncapsulationObject(PARAM_ILLEGAL, "", locale);
|
||||
}
|
||||
if (type == 0) {
|
||||
phytoplanktonDatabaseService.deleById(id);
|
||||
} else if (type == 1) {
|
||||
zoobenthosDatabaseService.deleById(id);
|
||||
} else if (type == 2) {
|
||||
zooplanktonDatabaseService.deleById(id);
|
||||
}
|
||||
return outputEncapsulationObject(SUCCESS, "", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 种群管理, 删除 批量
|
||||
* @param ids
|
||||
* 0:浮游植物 1:底栖动物 2:浮游植物
|
||||
* {"0":[1,2,3],"1":[],"2":[]}
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/database/dele/batch", method = RequestMethod.POST)
|
||||
public String databaseDeleBatch(@RequestBody Map<String, List<Integer>> ids){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
final String ppKey = "0";
|
||||
List<Integer> ppIds = ids.get(ppKey);
|
||||
if (ppIds != null && ppIds.size() > 0) {
|
||||
phytoplanktonDatabaseService.deleByIdBatch(ppIds);
|
||||
}
|
||||
final String zbKey = "1";
|
||||
List<Integer> zbIds = ids.get(zbKey);
|
||||
if (zbIds != null && zbIds.size() > 0) {
|
||||
zoobenthosDatabaseService.deleByIdsBatch(zbIds);
|
||||
}
|
||||
final String zpKey = "2";
|
||||
List<Integer> zpIds = ids.get(zpKey);
|
||||
if (zpIds != null && zpIds.size() > 0) {
|
||||
zooplanktonDatabaseService.deleByIdsBatch(zpIds);
|
||||
}
|
||||
return outputEncapsulationObject(SUCCESS, "", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 种群查询
|
||||
* @param type
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/database/search", method = RequestMethod.GET)
|
||||
public String searchDatabase(@RequestParam("type") Integer type, @RequestParam("name") String name) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (type != null && stringIsNull(name)) {
|
||||
List<DatabaseVo> list = new ArrayList();
|
||||
if (type == 14) {
|
||||
List<DatabaseVo> bySpecies = phytoplanktonDatabaseService.findBySpecies(name);
|
||||
list.addAll(bySpecies);
|
||||
return outputEncapsulationObject(SUCCESS,list,locale);
|
||||
}
|
||||
if (type == 20) {
|
||||
List<DatabaseVo> bySpecies = zooplanktonDatabaseService.findBySpecies(name);
|
||||
list.addAll(bySpecies);
|
||||
return outputEncapsulationObject(SUCCESS,list,locale);
|
||||
}
|
||||
if (type == 21) {
|
||||
List<DatabaseVo> bySpecies = zoobenthosDatabaseService.findBySpecies(name);
|
||||
list.addAll(bySpecies);
|
||||
return outputEncapsulationObject(SUCCESS,list,locale);
|
||||
}
|
||||
} else if (type != null) {
|
||||
if (type == 14) {
|
||||
List<DatabaseVo> all = phytoplanktonDatabaseService.getAll();
|
||||
return outputEncapsulationObject(SUCCESS, all, locale);
|
||||
}
|
||||
if (type == 20) {
|
||||
List<DatabaseVo> all = zooplanktonDatabaseService.getAll();
|
||||
return outputEncapsulationObject(SUCCESS,all,locale);
|
||||
}
|
||||
if (type == 21) {
|
||||
List<DatabaseVo> all = zoobenthosDatabaseService.getAll();
|
||||
return outputEncapsulationObject(SUCCESS,all,locale);
|
||||
}
|
||||
} else if (stringIsNull(name)) {
|
||||
List<DatabaseVo> bySpecies = phytoplanktonDatabaseService.findBySpecies(name);
|
||||
List<DatabaseVo> bySpecies1 = zooplanktonDatabaseService.findBySpecies(name);
|
||||
List<DatabaseVo> bySpecies2 = zoobenthosDatabaseService.findBySpecies(name);
|
||||
List<DatabaseVo> list = new ArrayList();
|
||||
list.addAll(bySpecies);
|
||||
list.addAll(bySpecies1);
|
||||
list.addAll(bySpecies2);
|
||||
return outputEncapsulationObject(SUCCESS, list, locale);
|
||||
}
|
||||
List<DatabaseVo> all = phytoplanktonDatabaseService.getAll();
|
||||
all.addAll(zooplanktonDatabaseService.getAll());
|
||||
all.addAll(zoobenthosDatabaseService.getAll());
|
||||
return outputEncapsulationObject(SUCCESS,all, locale);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据物种名模糊查找
|
||||
* @param race
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/speciesDic/search", method = RequestMethod.GET)
|
||||
public String speciesDicByRace(@RequestParam("race") String race) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (!stringIsNull(race)) {
|
||||
return outputEncapsulationObject(DATA_WRONG, "", locale);
|
||||
}
|
||||
List<SpeciesDicEntity> byRace = speciesDicService.getByRace(race);
|
||||
return outputEncapsulationObject(SUCCESS, byRace, locale);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.service.CacheService;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
|
||||
/**
|
||||
* 缓存测试服务
|
||||
* @author tajochen
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/cache")
|
||||
public class CacheController {
|
||||
|
||||
@Resource
|
||||
private CacheService cacheService;
|
||||
|
||||
@GetMapping("/get/name")
|
||||
public String findByName(@RequestParam(value="name", required=false) String name)
|
||||
{
|
||||
//获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,cacheService.findByName(name),locale);
|
||||
}
|
||||
|
||||
@GetMapping("/get/nickname")
|
||||
public String findByNickName(@RequestParam(value="nickName", required=false) String nickName)
|
||||
{
|
||||
//获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
return cacheService.findByNickname(nickName);
|
||||
}
|
||||
|
||||
@GetMapping("/set/nickname")
|
||||
public String setNickName(@RequestParam(value="nickName", required=false) String nickName)
|
||||
{
|
||||
//获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
return cacheService.setNickname(nickName);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,202 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||
import com.xkrs.microservice.dao.aquatic.LakeEvaluateformDao;
|
||||
import com.xkrs.microservice.model.entity.aquatic.LakeEvaluateformEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverInvolvedEvaluateformEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverNotInvolvedEvaluateformEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.WaterQualityDataSheetForQualityMonitoring;
|
||||
import com.xkrs.microservice.service.aquatic.LakeEvaluateformService;
|
||||
import com.xkrs.microservice.service.aquatic.RiverInvolvedEvaluateformService;
|
||||
import com.xkrs.microservice.service.aquatic.RiverNotInvolvedEvaluateformService;
|
||||
import com.xkrs.microservice.service.aquatic.WaterQualityDataSheetForQualityMonitoringService;
|
||||
import com.xkrs.microservice.util.EasyPoiUtils;
|
||||
import com.xkrs.microservice.util.ExcelUtils;
|
||||
import com.xkrs.microservice.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
/**
|
||||
* 新增表的上传下载控制
|
||||
* author zang
|
||||
* date 2022/8/30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/excelController")
|
||||
public class ExcelController {
|
||||
|
||||
@Autowired
|
||||
private LakeEvaluateformService lakeEvaluateformService;
|
||||
@Autowired
|
||||
private RiverNotInvolvedEvaluateformService riverNotInvolvedEvaluateformService;
|
||||
@Autowired
|
||||
private RiverInvolvedEvaluateformService riverInvolvedEvaluateformService;
|
||||
@Autowired
|
||||
private WaterQualityDataSheetForQualityMonitoringService waterQualityDataSheetForQualityMonitoringService;
|
||||
|
||||
|
||||
/**导入
|
||||
* 将从Excel中获取的数据写入LakeEvaluateformEntity表中
|
||||
* */
|
||||
@RequestMapping("/uploadLakeEvaluateformExcels")
|
||||
@ResponseBody
|
||||
public Object uploadLakeEvaluateformExcel(@RequestParam("uploadFile") MultipartFile file) throws IOException {
|
||||
ExcelImportResult<LakeEvaluateformEntity> result = EasyPoiUtils.importExcel(file,1,1, LakeEvaluateformEntity.class);
|
||||
StringBuilder sb=new StringBuilder();
|
||||
for (LakeEvaluateformEntity lakeEvaluateformEntity : result.getFailList()) {
|
||||
sb.append(lakeEvaluateformEntity);
|
||||
}
|
||||
|
||||
if(sb.toString().equals("[]")||sb.toString().contains("{"))
|
||||
{
|
||||
System.out.println("错误行:"+result.getFailList());
|
||||
return "列为空或者日期数字格式错误,日期格式为[2000-01-01]";
|
||||
}
|
||||
//System.out.println("正确行:"+result.getList());
|
||||
lakeEvaluateformService.save(result.getList());
|
||||
return "success";
|
||||
}
|
||||
|
||||
|
||||
/**导出
|
||||
* 将LakeEvaluateformEntity表中获取的数据写入Excel中
|
||||
* */
|
||||
@GetMapping("/exportLakeEvaluateformExcel")
|
||||
public void exportLakeEvaluateform(HttpServletResponse response) {
|
||||
System.out.println("开始导出");
|
||||
// 模拟从数据库获取需要导出的数据
|
||||
List<LakeEvaluateformEntity> lakeEvaluateformEntities = lakeEvaluateformService.findAll();
|
||||
// 导出操作
|
||||
lakeEvaluateformEntities.clear();
|
||||
ExcelUtils.exportExcel(lakeEvaluateformEntities, "湖库生境评价表", "sheet1", LakeEvaluateformEntity.class, "湖库生境评价表.xlsx", response);
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------
|
||||
|
||||
// 将从Excel中获取的数据写入RiverInvolvedEvaluateformEntity表中
|
||||
|
||||
@RequestMapping("/uploadRiverInvolvedEvaluateformExcels")
|
||||
@ResponseBody
|
||||
public Object uploadRiverInvolvedEvaluateformExcel(@RequestParam("uploadFile") MultipartFile file) throws IOException {
|
||||
ExcelImportResult<RiverInvolvedEvaluateformEntity> result= EasyPoiUtils.importExcel(file,1,1, RiverInvolvedEvaluateformEntity.class);
|
||||
StringBuilder sb=new StringBuilder();
|
||||
for (RiverInvolvedEvaluateformEntity riverInvolvedEvaluateformEntity : result.getFailList()) {
|
||||
sb.append(riverInvolvedEvaluateformEntity);
|
||||
}
|
||||
|
||||
if(sb.toString().equals("[]")||sb.toString().contains("{"))
|
||||
{
|
||||
System.out.println("错误行:"+result.getFailList());
|
||||
return "列为空或者日期数字格式错误,日期格式为[2000-01-01]";
|
||||
}
|
||||
|
||||
//System.out.println("正确行:"+result.getList());
|
||||
riverInvolvedEvaluateformService.save(result.getList());
|
||||
return "success";
|
||||
}
|
||||
|
||||
|
||||
|
||||
//将RiverInvolvedEvaluateformEntity表中获取的数据写入Excel中
|
||||
|
||||
@GetMapping("/exportRiverInvolvedEvaluateformExcel")
|
||||
public void exportRiverInvolvedEvaluateform(HttpServletResponse response) {
|
||||
System.out.println("开始导出");
|
||||
// 模拟从数据库获取需要导出的数据
|
||||
List<RiverInvolvedEvaluateformEntity> riverInvolvedEvaluateformEntities = riverInvolvedEvaluateformService.findAll();
|
||||
// 导出操作
|
||||
riverInvolvedEvaluateformEntities.clear();
|
||||
ExcelUtils.exportExcel(riverInvolvedEvaluateformEntities, "可涉河流生境评价表", "sheet1", RiverInvolvedEvaluateformEntity.class, "可涉河流生境评价表.xls", response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------
|
||||
|
||||
//将从Excel中获取的数据写入RiverNotInvolvedEvaluateformEntity表中
|
||||
|
||||
@RequestMapping("/uploadRiverNotInvolvedEvaluateformExcels")
|
||||
@ResponseBody
|
||||
public Object uploadRiverNotInvolvedEvaluateformExcel(@RequestParam("uploadFile") MultipartFile file) throws IOException {
|
||||
ExcelImportResult<RiverNotInvolvedEvaluateformEntity> result= EasyPoiUtils.importExcel(file,1,1, RiverNotInvolvedEvaluateformEntity.class);
|
||||
StringBuilder sb=new StringBuilder();
|
||||
for (RiverNotInvolvedEvaluateformEntity riverNotInvolvedEvaluateformEntity : result.getFailList()) {
|
||||
sb.append(riverNotInvolvedEvaluateformEntity);
|
||||
}
|
||||
|
||||
if(sb.toString().equals("[]")||sb.toString().contains("{"))
|
||||
{
|
||||
System.out.println("错误行:"+result.getFailList());
|
||||
return "列为空或者日期数字格式错误,日期格式为[2000-01-01]";
|
||||
}
|
||||
//System.out.println("正确行:"+result.getList());
|
||||
riverNotInvolvedEvaluateformService.save(result.getList());
|
||||
return "success";
|
||||
}
|
||||
|
||||
|
||||
|
||||
//将RiverNotInvolvedEvaluateformEntity表中获取的数据写入Excel中
|
||||
|
||||
@GetMapping("/exportRiverNotInvolvedEvaluateformExcel")
|
||||
public void exportRiverNotInvolvedEvaluateform(HttpServletResponse response) {
|
||||
System.out.println("开始导出");
|
||||
// 模拟从数据库获取需要导出的数据
|
||||
List<RiverNotInvolvedEvaluateformEntity> riverNotInvolvedEvaluateformEntities = riverNotInvolvedEvaluateformService.findAll();
|
||||
// 导出操作
|
||||
riverNotInvolvedEvaluateformEntities.clear();
|
||||
ExcelUtils.exportExcel(riverNotInvolvedEvaluateformEntities, "不可涉河流生境评价表", "sheet1", RiverNotInvolvedEvaluateformEntity.class, "不可涉河流生境评价表.xls", response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//---------------------------------
|
||||
|
||||
//将从Excel中获取的数据写入WaterQualityDataSheetForQualityMonitoring表中
|
||||
@RequestMapping("/uploadWaterQualityDataSheetForQualityMonitoringExcels")
|
||||
@ResponseBody
|
||||
public Object uploadWaterQualityDataSheetForQualityMonitoringExcel(@RequestParam("uploadFile") MultipartFile file) throws IOException {
|
||||
ExcelImportResult<WaterQualityDataSheetForQualityMonitoring> result= EasyPoiUtils.importExcel(file,1,1, WaterQualityDataSheetForQualityMonitoring.class);
|
||||
StringBuilder sb=new StringBuilder();
|
||||
for (WaterQualityDataSheetForQualityMonitoring waterQualityDataSheetForQualityMonitoring : result.getFailList()) {
|
||||
sb.append(waterQualityDataSheetForQualityMonitoring);
|
||||
}
|
||||
|
||||
if(sb.toString().equals("[]")||sb.toString().contains("{"))
|
||||
{
|
||||
System.out.println("错误行:"+result.getFailList());
|
||||
return "列为空或者日期数字格式错误,日期格式为[2000-01-01]";
|
||||
}
|
||||
//System.out.println("正确行:"+result.getList());
|
||||
waterQualityDataSheetForQualityMonitoringService.save(result.getList());
|
||||
return "success";
|
||||
}
|
||||
|
||||
|
||||
//将WaterQualityDataSheetForQualityMonitoring表中获取的数据写入Excel中
|
||||
@GetMapping("/exportWaterQualityDataSheetForQualityMonitoringExcel")
|
||||
public void exportWaterQualityDataSheetForQualityMonitoring(HttpServletResponse response) {
|
||||
System.out.println("开始导出");
|
||||
// 模拟从数据库获取需要导出的数据
|
||||
List<WaterQualityDataSheetForQualityMonitoring> riverNotInvolvedEvaluateformEntities = waterQualityDataSheetForQualityMonitoringService.findAll();
|
||||
// 导出操作
|
||||
riverNotInvolvedEvaluateformEntities.clear();
|
||||
ExcelUtils.exportExcel(riverNotInvolvedEvaluateformEntities, "水生态环境质量监测水质数据表", "sheet1", WaterQualityDataSheetForQualityMonitoring.class, "水生态环境质量监测水质数据表.xls", response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,274 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.model.entity.ecology.DocumentEntity;
|
||||
import com.xkrs.microservice.model.vo.FileVo;
|
||||
import com.xkrs.microservice.model.vo.PageVo;
|
||||
import com.xkrs.microservice.service.FileService;
|
||||
import com.xkrs.microservice.service.ecology.DocumentService;
|
||||
import com.xkrs.microservice.service.ecology.RemoteSenseingService;
|
||||
import com.xkrs.microservice.service.ecology.RemoteService;
|
||||
import com.xkrs.microservice.util.filestorage.FileFastDfs;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName;
|
||||
import static com.xkrs.microservice.util.NumberUtil.isStrNumeric;
|
||||
import static com.xkrs.microservice.util.filestorage.FileUtil.getUploadInfo;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2020/12/30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/file")
|
||||
public class FileController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FileController.class);
|
||||
|
||||
@Resource
|
||||
private FileService fileService;
|
||||
|
||||
@Resource
|
||||
private DocumentService documentService;
|
||||
|
||||
@Resource
|
||||
private FileFastDfs fileFastDfs;
|
||||
|
||||
@Resource
|
||||
private RemoteSenseingService remoteSenseingService;
|
||||
|
||||
@Resource
|
||||
private RemoteService remoteService;
|
||||
|
||||
|
||||
/**
|
||||
* 接收上传文件信息
|
||||
* <p>
|
||||
* 1:技术规范、
|
||||
* 2:评价报告、
|
||||
* 3:野外核查报告、
|
||||
* 4:其他
|
||||
*
|
||||
* @param files
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR', 'ROLE_SYSTEM_MANAGER')")
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
public String addFile2FileService(MultipartFile[] files, @RequestParam("fileType") Integer fileType, @RequestHeader(value = "Authorization") String token) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (null == files || files.length == 0) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "result or fileType is null", locale);
|
||||
}
|
||||
String userName = getTokenUserName(token);
|
||||
List<Map<String, String>> list = new ArrayList<>(files.length);
|
||||
try {
|
||||
for (MultipartFile file :
|
||||
files) {
|
||||
File file1 = fileFastDfs.multipartFileToFile(file);
|
||||
String dir = "document";
|
||||
String info = fileFastDfs.uploadFile(file1, dir);
|
||||
Map<String, String> map = getUploadInfo(info);
|
||||
list.add(map);
|
||||
file1.delete();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (fileService.addDocument2(list, userName, fileType)) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "success", locale);
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "result or fileType is null", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
* @param fileIdList 文件id
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAnyRole('ROLE_ADMINISTOR', 'ROLE_SYSTEM_MANAGER','ROLE_PRO_USER')")
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/delete/id", method = RequestMethod.POST)
|
||||
public String deleteById(@RequestBody List<Integer> fileIdList) {
|
||||
//获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (null == fileIdList || fileIdList.isEmpty()) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "fileIdList is error", locale);
|
||||
}
|
||||
if (!documentService.deleDocument(fileIdList)) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "delet failed", locale);
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get/condition", method = RequestMethod.GET)
|
||||
public String getDocumentByCondition(@RequestParam(value = "startTime", required = false) String startTime,
|
||||
@RequestParam(value = "endTime", required = false) String endTime,
|
||||
@RequestParam(value = "username", required = false) String username,
|
||||
@RequestParam(value = "fileName", required = false) String fileName,
|
||||
@RequestParam(value = "fileType", required = false) String fileType,
|
||||
@RequestParam(value = "page") Integer page) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (page < 1) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "页数大于0", locale);
|
||||
}
|
||||
PageVo documentByCondition = documentService.getDocumentByCondition(startTime, endTime, username, fileName, fileType, page);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, documentByCondition, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有文件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/get/all", method = RequestMethod.POST)
|
||||
public String getAll() {
|
||||
//获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<DocumentEntity> all = documentService.getAll();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, all, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据时间获取所有文件
|
||||
*
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/get/date", method = RequestMethod.POST)
|
||||
public String getAllByDate(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate,
|
||||
@RequestParam("page") Integer page) {
|
||||
// 区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
if (null == page || page < 1) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "page should not be null or page less than 1", locale);
|
||||
}
|
||||
PageVo document = documentService.getDocument(startDate, endDate, page);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, document, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件 传MD5更省事
|
||||
*
|
||||
* @param md5List 文件md5
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
@RequestMapping(value = "/delete/md", method = RequestMethod.POST)
|
||||
public String deleteByMd(@RequestBody List<Map<String, String>> md5List) {
|
||||
//获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
if (null == md5List || md5List.isEmpty()) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "md5 is null", locale);
|
||||
}
|
||||
for (Map<String, String> md5Map : md5List) {
|
||||
String md5 = md5Map.get("md5");
|
||||
if (!fileService.deleteByMd(md5)) {
|
||||
FileVo fileVo = fileService.findByMd5(md5);
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, fileVo.getFileName() + " deletion failed", locale);
|
||||
}
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id获取文件
|
||||
*
|
||||
* @param fileId 文件id
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
@RequestMapping(value = "/get/id", method = RequestMethod.GET)
|
||||
public String getById(@RequestParam("fileId") String fileId) {
|
||||
//获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (!isStrNumeric(fileId)) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "fileId error", locale);
|
||||
}
|
||||
FileVo file = fileService.findById(Integer.valueOf(fileId));
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, file, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件名获取文件
|
||||
*
|
||||
* @param fileName 文件名
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
@RequestMapping(value = "/get/name", method = RequestMethod.POST)
|
||||
public String getByName(@RequestParam("fileName") String fileName) {
|
||||
//获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (fileName.isEmpty()) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "fileId error", locale);
|
||||
}
|
||||
FileVo file = fileService.findByFileName(fileName);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, file, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量下载
|
||||
*
|
||||
* @param fileIdList 文件ID
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
@RequestMapping(value = "/download/many", method = RequestMethod.POST)
|
||||
public String downloadFile(@RequestBody List<Integer> fileIdList, HttpServletResponse response, HttpServletRequest request) {
|
||||
|
||||
//获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
if (null == fileIdList) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "fileId should not be null", locale);
|
||||
}
|
||||
documentService.downloadDocument(fileIdList, request, response);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动入库
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAnyRole('ROLE_ADMINISTOR', 'ROLE_SYSTEM_MANAGER','ROLE_PRO_USER')")
|
||||
@RequestMapping(value = "/scan", method = RequestMethod.GET)
|
||||
public String sacnFile() {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
boolean b = remoteSenseingService.getFile();
|
||||
if (b) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "开始入库", locale);
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "无入库数据", locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/tif/base", method = RequestMethod.POST)
|
||||
public String tif2Base(@RequestBody List<String> tifPaths) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
remoteService.tif2Database(tifPaths);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale);
|
||||
}
|
||||
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,114 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.model.vo.FileServerResultVo;
|
||||
import com.xkrs.microservice.service.FileServerService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 文件服务器管理服务
|
||||
* @author tajochen
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/fileservice")
|
||||
public class FileServerController {
|
||||
|
||||
@Resource
|
||||
private FileServerService fileServerService;
|
||||
|
||||
/**
|
||||
* 文件统计
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value="/stat",method = RequestMethod.GET)
|
||||
@PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')")
|
||||
@CrossOrigin
|
||||
public FileServerResultVo getFileStat() {
|
||||
|
||||
return fileServerService.getFileStat();
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件删除
|
||||
* @param md5 信息摘要
|
||||
* @param path 路径
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value="/delete",method = RequestMethod.DELETE)
|
||||
@PreAuthorize("hasAnyAuthority('auth_system_manager','role_administor')")
|
||||
@CrossOrigin
|
||||
public FileServerResultVo deleteFile(@RequestParam(value = "md5",required = false) String md5,
|
||||
@RequestParam(value = "path",required = false) String path) {
|
||||
FileServerResultVo fileServerResultVo = new FileServerResultVo();
|
||||
Boolean existed = (md5==null||md5.isEmpty())&&(path==null||path.isEmpty());
|
||||
if(existed){
|
||||
fileServerResultVo.setStatus("fail");
|
||||
fileServerResultVo.setData("");
|
||||
fileServerResultVo.setMessage("参数为空");
|
||||
return fileServerResultVo;
|
||||
}
|
||||
return fileServerService.deleteFile(md5,path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件信息
|
||||
* @param md5 信息摘要
|
||||
* @param path 路径
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value="/get/info",method = RequestMethod.DELETE)
|
||||
@PreAuthorize("hasAnyAuthority('auth_system_manager','role_administor')")
|
||||
@CrossOrigin
|
||||
public FileServerResultVo getFileInfo(@RequestParam(value = "md5",required = false) String md5,
|
||||
@RequestParam(value = "path",required = false) String path) {
|
||||
|
||||
FileServerResultVo fileServerResultVo = new FileServerResultVo();
|
||||
Boolean existed = (md5==null||md5.isEmpty())&&(path==null||path.isEmpty());
|
||||
if(existed){
|
||||
fileServerResultVo.setStatus("fail");
|
||||
fileServerResultVo.setData("");
|
||||
fileServerResultVo.setMessage("参数为空");
|
||||
return fileServerResultVo;
|
||||
}
|
||||
return fileServerService.getFileInfo(md5,path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件列表
|
||||
* @param dir 文件夹
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value="/get/list",method = RequestMethod.DELETE)
|
||||
@PreAuthorize("hasAnyAuthority('auth_system_manager','role_administor')")
|
||||
@CrossOrigin
|
||||
public FileServerResultVo getFileList(@RequestParam(value = "dir") String dir) {
|
||||
return fileServerService.getFileList(dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修复统计信息
|
||||
* @param date 要修复的日期,格式如:20190725
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value="/get/repair_stat",method = RequestMethod.DELETE)
|
||||
@PreAuthorize("hasAnyAuthority('auth_system_manager','role_administor')")
|
||||
@CrossOrigin
|
||||
public FileServerResultVo getFileRepairStat(@RequestParam(value = "date") String date) {
|
||||
return fileServerService.getFileRepairStat(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步失败修复
|
||||
* @param force 是否强行修复(0|1)
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value="/get/repair",method = RequestMethod.DELETE)
|
||||
@PreAuthorize("hasAnyAuthority('auth_system_manager','role_administor')")
|
||||
@CrossOrigin
|
||||
public FileServerResultVo getFileRepair(@RequestParam(value = "force") String force) {
|
||||
return fileServerService.getFileRepair(force);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,187 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.model.entity.FileTemplateEntity;
|
||||
import com.xkrs.microservice.service.FileTemplateService;
|
||||
import com.xkrs.microservice.util.SnowFlakeUtil;
|
||||
import com.xkrs.microservice.util.filestorage.FileFastDfs;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
import static com.xkrs.microservice.util.StringUtil.stringIsNull;
|
||||
import static com.xkrs.microservice.util.filestorage.FileUtil.getUploadInfo;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/2/22
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/filetemplate")
|
||||
public class FileTemplateController {
|
||||
|
||||
@Resource
|
||||
private FileTemplateService fileTemplateService;
|
||||
@Resource
|
||||
private FileFastDfs fileFastDfs;
|
||||
@Value("${home.path}")
|
||||
private String uploadHomePath;
|
||||
|
||||
@CrossOrigin
|
||||
@PreAuthorize("hasAnyRole('ROLE_ADMINISTOR', 'ROLE_SYSTEM_MANAGER')")
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
public String addTemplate(@RequestBody MultipartFile[] files) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<Map<String, String>> list = new ArrayList<>(files.length);
|
||||
try {
|
||||
for (MultipartFile file :
|
||||
files) {
|
||||
File file1 = fileFastDfs.multipartFileToFile(file);
|
||||
String scene = "template";
|
||||
String info = fileFastDfs.uploadFile(file1, scene);
|
||||
Map<String, String> map = getUploadInfo(info);
|
||||
list.add(map);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
List<String> failFileList = new ArrayList<>(files.length);
|
||||
for (Map<String, String> map :
|
||||
list) {
|
||||
boolean aBoolean = addTemp(map.get("fileName"), map.get("path"), map.get("url"), map.get("md5"));
|
||||
if (!aBoolean) {
|
||||
failFileList.add(map.get("fileName"));
|
||||
}
|
||||
}
|
||||
|
||||
if (failFileList.size() == 0) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", locale);
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, failFileList, locale);
|
||||
}
|
||||
|
||||
private boolean addTemp(String fileName, String filePath, String url, String md5) {
|
||||
return fileTemplateService.addTemplate(fileName, filePath, url, "", md5);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模板下载
|
||||
* @param fileTypes
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "download/template", method = RequestMethod.POST)
|
||||
public String downloadTemplate(@RequestBody List<String> fileTypes) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (fileTypes == null || fileTypes.size() == 0) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, fileTypes, locale);
|
||||
}
|
||||
List<FileTemplateEntity> list = new ArrayList<>();
|
||||
for (String fileType :
|
||||
fileTypes) {
|
||||
if (!stringIsNull(fileType)) {
|
||||
continue;
|
||||
}
|
||||
FileTemplateEntity byFileName = fileTemplateService.findByFileType(fileType);
|
||||
if (null != byFileName) {
|
||||
list.add(byFileName);
|
||||
}
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, list, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模板下载,批量,自己下载
|
||||
* @param fileTypes
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "download/template/batch", method = RequestMethod.POST)
|
||||
public String downloadTemplateBatch(@RequestBody List<String> fileTypes, HttpServletResponse response, HttpServletRequest request) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (fileTypes == null || fileTypes.size() == 0) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, fileTypes, locale);
|
||||
}
|
||||
List<FileTemplateEntity> list = new ArrayList<>();
|
||||
// 不能用List 进行存储文件路径,因为文件名相同的时候os.putNextEntry(en)会报错
|
||||
final String userAgent = request.getHeader("USER-AGENT");
|
||||
SnowFlakeUtil snowFlake = new SnowFlakeUtil(5, 5);
|
||||
String fileName = String.valueOf(snowFlake.nextId() + ".zip");
|
||||
final String mzilla = "Mozilla";
|
||||
if (StringUtils.contains(userAgent, mzilla)) {
|
||||
fileName = URLEncoder.encode(fileName, StandardCharsets.ISO_8859_1);
|
||||
} else {
|
||||
fileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8);
|
||||
}
|
||||
response.setHeader("Content-disposition", "attachment; filename=" + fileName);
|
||||
response.setContentType("application/force-download;charset=UTF-8");
|
||||
|
||||
InputStream is = null;
|
||||
ZipOutputStream os = null;
|
||||
try {
|
||||
os = new ZipOutputStream(response.getOutputStream());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
byte[] buffer = new byte[1024];
|
||||
int len = 0;
|
||||
for (String fileType :
|
||||
fileTypes) {
|
||||
if (!stringIsNull(fileType)) {
|
||||
continue;
|
||||
}
|
||||
FileTemplateEntity byFileName = fileTemplateService.findByFileType(fileType);
|
||||
List<Object> paramList = new ArrayList<>();
|
||||
String filePath = uploadHomePath + byFileName.getFilePath().substring(7);
|
||||
File file = new File(filePath);
|
||||
if (file.exists()) {
|
||||
if (file.isFile()) {
|
||||
try {
|
||||
is = new FileInputStream(file);
|
||||
ZipEntry en = new ZipEntry(file.getName());
|
||||
// ZipEntry en = new ZipEntry("2019年SD野外核查土地利用土地覆盖边界核查表.xlsx");
|
||||
en.setSize(file.length());
|
||||
if (os != null) {
|
||||
// TODO 这里放重复文件名会报错
|
||||
os.putNextEntry(en);
|
||||
os.setComment("order download");
|
||||
while ((len = is.read(buffer)) > 0) {
|
||||
os.write(buffer, 0, len);
|
||||
}
|
||||
}
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (os != null) {
|
||||
os.flush();
|
||||
os.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, list, locale);
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.OutputEncapsulation;
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.model.entity.auth.SysUserEntity;
|
||||
import com.xkrs.microservice.service.SysUserService;
|
||||
import com.xkrs.microservice.service.auth.RoleUserService;
|
||||
import com.xkrs.microservice.service.auth.SysDmsRoleService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.xkrs.microservice.common.account.TokenAuthenticationService.getJwt;
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/test1")
|
||||
public class FirstPortalConterller {
|
||||
private static final Logger log = LoggerFactory.getLogger(FirstPortalConterller.class);
|
||||
private final Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
@Resource
|
||||
private SysDmsRoleService roleService;
|
||||
@Resource
|
||||
private RoleUserService roleUserService;
|
||||
@Value("${sso.fail.url}")
|
||||
private String failUrl;
|
||||
@Value("${sso.home.page.url}")
|
||||
private String homePage;
|
||||
|
||||
@ResponseBody
|
||||
@GetMapping(path = "/r2")
|
||||
public void r2(HttpServletRequest request, HttpServletResponse response){
|
||||
HttpSession session = request.getSession(false);
|
||||
String userId =
|
||||
(String) session.getAttribute("saml.userid");
|
||||
if (userId == null){
|
||||
userId = (String) request.getAttribute("saml.userid");
|
||||
}
|
||||
// todo 登录逻辑
|
||||
log.info("userId is :" + userId);
|
||||
// todo used during testing
|
||||
// userId = "ERS7f616503bf7c413fa2750b57a8165db3";
|
||||
try{
|
||||
response.sendRedirect(homePage + "?userID=" + userId);
|
||||
log.info("first portal sso success");
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to redirect to home page", e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
/**
|
||||
* @author wudong
|
||||
* @date 2022/4/14 10:59
|
||||
* @description
|
||||
*/
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
|
||||
@ControllerAdvice
|
||||
@Order(10000)
|
||||
public class GlobalControllerAdvice {
|
||||
|
||||
@InitBinder
|
||||
public void setAllowebFields(WebDataBinder dataBinder) {
|
||||
String[] abd = new String[] {"class.*","Class.*","*.class.*","*.Class.*"};
|
||||
dataBinder.setDisallowedFields(abd);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,124 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.model.vo.GridVo;
|
||||
import com.xkrs.microservice.model.vo.PageVo;
|
||||
import com.xkrs.microservice.service.GridService;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
import static com.xkrs.microservice.util.DateTimeUtil.dateToString;
|
||||
import static com.xkrs.microservice.util.DateTimeUtil.stringToDate;
|
||||
import static com.xkrs.microservice.util.StringUtil.stringIsNull;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/grid")
|
||||
public class GridController {
|
||||
|
||||
@Resource
|
||||
private GridService gridService;
|
||||
|
||||
/**
|
||||
* 根据行政区划查询
|
||||
* @param cityCode 行政区划
|
||||
* @param countyCode 行政区划
|
||||
* @param startDate 开始采集时间
|
||||
* @param endDate 采集结束时间
|
||||
* @param satelliteTypeList 卫星种类
|
||||
* @param lonLeftTop 经纬度
|
||||
* @param latLeftTop 经纬度
|
||||
* @param lonRightBottom 经纬度
|
||||
* @param latRightBottom 经纬度
|
||||
* @param cloudage 云量
|
||||
* @param page 页码(String)
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR', 'ROLE_SYSTEM_MANAGER')")
|
||||
@RequestMapping(value = "/get/admin", method = RequestMethod.POST)
|
||||
public String getGridByAdmin(@RequestParam(value = "cityCode", required = false) String cityCode,
|
||||
@RequestParam(value = "countyCode", required = false) String countyCode,
|
||||
@RequestParam(value = "startDate", required = false) String startDate,
|
||||
@RequestParam(value = "endDate", required = false) String endDate,
|
||||
@RequestBody List<String> satelliteTypeList,
|
||||
@RequestParam(value = "lonLeftTop", required = false) String lonLeftTop,
|
||||
@RequestParam(value = "latLeftTop", required = false) String latLeftTop,
|
||||
@RequestParam(value = "lonRightBottom", required = false) String lonRightBottom,
|
||||
@RequestParam(value = "latRightBottom", required = false) String latRightBottom,
|
||||
@RequestParam(value = "cloudage", required = false) String cloudage,
|
||||
@RequestParam(value = "page") String page) {
|
||||
// 获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (!stringIsNull(page)) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "page is null", locale);
|
||||
}
|
||||
if (null == satelliteTypeList) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL,"sensor is null",locale);
|
||||
}
|
||||
PageVo pageVo = gridService.getGridByAdmin(cityCode, countyCode, startDate, endDate, satelliteTypeList, lonLeftTop,
|
||||
latLeftTop, lonRightBottom, latRightBottom, cloudage, page);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,pageVo,locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据经纬度查询
|
||||
* @param startDate 开始时间
|
||||
* @param endDate 结束时间
|
||||
* @param satelliteTypeList 卫星列表
|
||||
* @param cloudage 云量
|
||||
* @param lonLeftTop 坐上经度
|
||||
* @param latLeftTop 坐上纬度
|
||||
* @param lonRightBottom 右下经度
|
||||
* @param latRightBottom 右下纬度
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR', 'ROLE_SYSTEM_MANAGER')")
|
||||
@RequestMapping(value = "/get/lon", method = RequestMethod.POST)
|
||||
private String getGridByLon(@RequestParam String lonLeftTop, @RequestParam String latLeftTop,
|
||||
@RequestParam String lonRightBottom, @RequestParam String latRightBottom,
|
||||
@RequestParam String startDate, @RequestParam String endDate,
|
||||
@RequestBody List<String> satelliteTypeList, @RequestParam String cloudage,
|
||||
@RequestParam String page) {
|
||||
// 获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (!stringIsNull(page)) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "page is null", locale);
|
||||
}
|
||||
List<GridVo> gridVo = null;
|
||||
String endTimePlusDay1 = null;
|
||||
if (stringIsNull(endDate)) {
|
||||
endTimePlusDay1 = dateToString(stringToDate(endDate).plusDays(1));
|
||||
} else {
|
||||
endTimePlusDay1 = endDate;
|
||||
}
|
||||
|
||||
gridVo = gridService.getGridByLonAndLat(startDate, endTimePlusDay1, satelliteTypeList, cloudage, lonLeftTop, latLeftTop,
|
||||
lonRightBottom, latRightBottom, page);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, gridVo, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有栅格数据
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR', 'ROLE_SYSTEM_MANAGER')")
|
||||
@RequestMapping(value = "/get", method = RequestMethod.POST)
|
||||
public String getGrid() {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<GridVo> all = gridService.getAll();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, all, locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get/sensor", method = RequestMethod.GET)
|
||||
public String getSensor(){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
Map<String, List<String>> sensor = gridService.getSensor();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, sensor, locale);
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
|
||||
/**
|
||||
* HelloController
|
||||
* @author tajochen
|
||||
*/
|
||||
@RestController
|
||||
public class HelloController {
|
||||
|
||||
/**
|
||||
* 返回类型为Mono<String>
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/hello")
|
||||
public Mono<String> hello() {
|
||||
//获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
// 【改】使用Mono.just生成响应式数据
|
||||
return Mono.just(outputEncapsulationObject(PromptMessageEnum.SUCCESS,"Welcome to reactive world ~",locale));
|
||||
}
|
||||
}
|
@ -0,0 +1,207 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.model.entity.ecology.LandShpEntity;
|
||||
import com.xkrs.microservice.model.entity.ecology.ModHefEntity;
|
||||
import com.xkrs.microservice.model.entity.ecology.ProvidedDataEntity;
|
||||
import com.xkrs.microservice.model.qo.LandShpQo;
|
||||
import com.xkrs.microservice.model.qo.ModHefQo;
|
||||
import com.xkrs.microservice.service.FileDocumentService;
|
||||
import com.xkrs.microservice.service.ecology.*;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
|
||||
/**
|
||||
* @author wudong
|
||||
* @date 2021/12/17 8:48
|
||||
* @description
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/index")
|
||||
public class IndexController {
|
||||
|
||||
@Resource
|
||||
private ReIndexService reIndexService;
|
||||
@Resource
|
||||
private LandShpService landShpService;
|
||||
@Resource
|
||||
private ModHefService modHefService;
|
||||
@Resource
|
||||
private ProvidedDataService providedDataService;
|
||||
@Resource
|
||||
private LandService landService;
|
||||
@Resource
|
||||
private IndexService indexService;
|
||||
@Resource
|
||||
private FileDocumentService fileDocumentService;
|
||||
|
||||
/**
|
||||
* 计算生物丰度指数
|
||||
*
|
||||
* @param year
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/bio", method = RequestMethod.GET)
|
||||
public String calcuBio(@RequestParam("year") String year, @RequestParam("code") String code) {
|
||||
String b = reIndexService.calcuBio(year, code);
|
||||
if (b.length() > 0) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, b, LocaleContextHolder.getLocale());
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.EI_API_ERROR, "", LocaleContextHolder.getLocale());
|
||||
}
|
||||
|
||||
/**
|
||||
* 土地胁迫指数
|
||||
* @param year
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/land", method = RequestMethod.GET)
|
||||
public String calcuLand(@RequestParam("year") String year, @RequestParam("code") String code) {
|
||||
String b = reIndexService.calcuLand(year, code);
|
||||
if (b.length() > 0) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, b, LocaleContextHolder.getLocale());
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.EI_API_ERROR, "", LocaleContextHolder.getLocale());
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算环境污染指数
|
||||
*
|
||||
* @param year
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/pollution", method = RequestMethod.GET)
|
||||
public String calcuPollution(@RequestParam("year") String year, @RequestParam("code") String code) {
|
||||
String b = reIndexService.calcuPollut(year, code);
|
||||
if (b.length() > 0) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, b, LocaleContextHolder.getLocale());
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.EI_API_ERROR, "", LocaleContextHolder.getLocale());
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算植被覆盖指数
|
||||
*
|
||||
* @param year
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/vg", method = RequestMethod.GET)
|
||||
public String calcuVg(@RequestParam("year") String year, @RequestParam("code") String code) {
|
||||
String b = reIndexService.calcuVege(year, code);
|
||||
if (b.length() > 0) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, b, LocaleContextHolder.getLocale());
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.EI_API_ERROR, "", LocaleContextHolder.getLocale());
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算水网密集指数
|
||||
*
|
||||
* @param year
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/water", method = RequestMethod.GET)
|
||||
public String calcuWater(@RequestParam("year") String year, @RequestParam("code") String code) {
|
||||
String b = reIndexService.calcuWater(year, code);
|
||||
if (b.length() > 0) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, b, LocaleContextHolder.getLocale());
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.EI_API_ERROR, "", LocaleContextHolder.getLocale());
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算环境限制指数
|
||||
*
|
||||
* @param year
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/envir", method = RequestMethod.GET)
|
||||
public String calcuEnvir(@RequestParam("year") String year, @RequestParam("code") String code) {
|
||||
String b = reIndexService.calcuEnvir(year, code);
|
||||
if (b.length() > 0) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, b, LocaleContextHolder.getLocale());
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.EI_API_ERROR, "", LocaleContextHolder.getLocale());
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/index", method = RequestMethod.GET)
|
||||
public String calcuIndex(@RequestParam("year") String year) throws Exception {
|
||||
|
||||
List<ProvidedDataEntity> byTime = providedDataService.findByTime(year);
|
||||
if (byTime.size() == 0) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "填报数据不存在", LocaleContextHolder.getLocale());
|
||||
} else {
|
||||
Integer audit = fileDocumentService.getFileDocumentByFileName(byTime.get(0).getFileName()).getAudit();
|
||||
if (audit != 1) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "填报数据未通过审核", LocaleContextHolder.getLocale());
|
||||
}
|
||||
}
|
||||
boolean b1 = landService.checkYear(year, 2);
|
||||
if (b1) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "土地利用现状数据不存在", LocaleContextHolder.getLocale());
|
||||
}
|
||||
boolean b2 = landService.checkYear(year, 1);
|
||||
if (b2) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "土地利用动态数据不存在", LocaleContextHolder.getLocale());
|
||||
}
|
||||
// Boolean b = reIndexService.calculateAll(year);
|
||||
String code = "37";
|
||||
indexService.getVg(year, code);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", LocaleContextHolder.getLocale());
|
||||
}
|
||||
|
||||
/**
|
||||
* shp上传路径
|
||||
*
|
||||
* @param year
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/shp", method = RequestMethod.GET)
|
||||
public String saveEiShp(@RequestParam("year") String year, @RequestParam("path") String path, @RequestParam("fileName") String fileName, @RequestParam("type") String type) {
|
||||
// 不要zip,直接为文件夹格式
|
||||
LandShpQo qo = new LandShpQo();
|
||||
qo.setYear(year);
|
||||
qo.setFilePath(path);
|
||||
qo.setFileName(fileName);
|
||||
qo.setType(type);
|
||||
LandShpEntity add = landShpService.add(qo);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, add, LocaleContextHolder.getLocale());
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加mod数据信息
|
||||
*
|
||||
* @param year
|
||||
* @param path
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/mod", method = RequestMethod.GET)
|
||||
public String saveEiMod(@RequestParam("year") String year, @RequestParam("path") String path, @RequestParam("fileName") String fileName) {
|
||||
ModHefQo qo = new ModHefQo();
|
||||
qo.setFileName(fileName);
|
||||
qo.setFilePath(path);
|
||||
qo.setYear(year);
|
||||
ModHefEntity add = modHefService.add(qo);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, add, LocaleContextHolder.getLocale());
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/call_index", method = RequestMethod.POST)
|
||||
public String getIndex(@RequestBody List<Map<String, String>> map, @RequestParam("year") String year, @RequestParam("code") String code) {
|
||||
indexService.getEi(year, "37", map);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", LocaleContextHolder.getLocale());
|
||||
}
|
||||
}
|
@ -0,0 +1,182 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.model.entity.log.BusiLog;
|
||||
import com.xkrs.microservice.model.entity.log.LoginLog;
|
||||
import com.xkrs.microservice.model.entity.log.PermissionLog;
|
||||
import com.xkrs.microservice.model.entity.log.VillageLogEntity;
|
||||
import com.xkrs.microservice.service.log.BusiLogService;
|
||||
import com.xkrs.microservice.service.log.LoginLogService;
|
||||
import com.xkrs.microservice.service.log.PermissionLogService;
|
||||
import com.xkrs.microservice.service.log.VillageLogService;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
import static com.xkrs.microservice.util.DateTimeUtil.dateToString;
|
||||
import static com.xkrs.microservice.util.DateTimeUtil.stringToDate;
|
||||
import static com.xkrs.microservice.util.StringUtil.stringIsNull;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/4/28
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/log")
|
||||
public class LogController {
|
||||
@Resource
|
||||
private LoginLogService loginLogService;
|
||||
@Resource
|
||||
private PermissionLogService permissionLogService;
|
||||
@Resource
|
||||
private BusiLogService busiLogService;
|
||||
@Resource
|
||||
private VillageLogService villageLogService;
|
||||
|
||||
@PreAuthorize("hasAnyRole('ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/login/get", method = RequestMethod.GET)
|
||||
public String loginGetAll() {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<LoginLog> all = loginLogService.getAll();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,all,locale);
|
||||
}
|
||||
|
||||
|
||||
@PreAuthorize("hasAnyRole('ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/login/search", method = RequestMethod.GET)
|
||||
public String loginSearch(@RequestParam("username") String username, @RequestParam("startTime")String startTime,
|
||||
@RequestParam("endTime")String endTime) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
String endTimePlusDay1;
|
||||
if (stringIsNull(endTime)) {
|
||||
endTimePlusDay1 = dateToString(stringToDate(endTime).plusDays(1));
|
||||
} else {
|
||||
endTimePlusDay1 = endTime;
|
||||
}
|
||||
List<LoginLog> all = loginLogService.sreachByCondition(username, startTime, endTimePlusDay1);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,all,locale);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAnyRole('ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/login/user", method = RequestMethod.GET)
|
||||
public String loginUser() {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<String> all = loginLogService.getAllName();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,all,locale);
|
||||
}
|
||||
|
||||
|
||||
@PreAuthorize("hasAnyRole('ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/permission/get", method = RequestMethod.GET)
|
||||
public String permissionAll() {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<PermissionLog> all = permissionLogService.getAll();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,all,locale);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAnyRole('ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/permission/search", method = RequestMethod.GET)
|
||||
public String permissionSearch(@RequestParam("username") String username, @RequestParam("startTime")String startTime,
|
||||
@RequestParam("endTime")String endTime) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
String endTimePlusDay1;
|
||||
if (stringIsNull(endTime)) {
|
||||
endTimePlusDay1 = dateToString(stringToDate(endTime).plusDays(1));
|
||||
} else {
|
||||
endTimePlusDay1 = endTime;
|
||||
}
|
||||
List<PermissionLog> all = permissionLogService.sreachByCondition(username, startTime, endTimePlusDay1);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,all,locale);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/get/user", method = RequestMethod.GET)
|
||||
public String permissionUser(@RequestParam("type") Integer type) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
final int wrongData = 3;
|
||||
if (type < 0 || type > wrongData) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"",locale);
|
||||
}
|
||||
List<String> all;
|
||||
final int log = 0;
|
||||
final int per = 1;
|
||||
final int bus = 2;
|
||||
if (type == log) {
|
||||
all = loginLogService.getAllName();
|
||||
} else if (type == per) {
|
||||
all = permissionLogService.getAllName();
|
||||
} else if (type == bus){
|
||||
all = busiLogService.getAllName();
|
||||
} else {
|
||||
all = villageLogService.getAllName();
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,all,locale);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAnyRole('ROLE_PRO_USER','ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/bus/get", method = RequestMethod.GET)
|
||||
public String busAll() {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<BusiLog> all = busiLogService.getAll();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,all,locale);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/bus/search", method = RequestMethod.GET)
|
||||
public String busSearch(@RequestParam("username") String username, @RequestParam("startTime")String startTime,
|
||||
@RequestParam("endTime")String endTime) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
String endTimePlusDay1;
|
||||
if (stringIsNull(endTime)) {
|
||||
endTimePlusDay1 = dateToString(stringToDate(endTime).plusDays(1));
|
||||
} else {
|
||||
endTimePlusDay1 = endTime;
|
||||
}
|
||||
List<BusiLog> all = busiLogService.sreachByCondition(username, startTime, endTimePlusDay1);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, all, locale);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/bus/user", method = RequestMethod.GET)
|
||||
public String busUser() {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<String> all = busiLogService.getAllName();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,all,locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/village/get", method = RequestMethod.GET)
|
||||
public String villageAll() {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<VillageLogEntity> all = villageLogService.getAll();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,all,locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/village/search", method = RequestMethod.GET)
|
||||
public String villageSearch(@RequestParam("username") String username, @RequestParam("startTime")String startTime,
|
||||
@RequestParam("endTime")String endTime) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
String endTimePlusDay1;
|
||||
if (stringIsNull(endTime)) {
|
||||
endTimePlusDay1 = dateToString(stringToDate(endTime).plusDays(1));
|
||||
} else {
|
||||
endTimePlusDay1 = endTime;
|
||||
}
|
||||
List<VillageLogEntity> all = villageLogService.sreachByCondition(username, startTime, endTimePlusDay1);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, all, locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/village/user", method = RequestMethod.GET)
|
||||
public String villageUser() {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<String> all = villageLogService.getAllName();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,all,locale);
|
||||
}
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.model.entity.ecology.RemoteEntity;
|
||||
import com.xkrs.microservice.model.vo.OrderVo;
|
||||
import com.xkrs.microservice.service.OrderService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/2/2
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/order")
|
||||
public class OrderController {
|
||||
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
|
||||
@Value("${home.path}")
|
||||
private String homePath;
|
||||
|
||||
/**
|
||||
* 增加订单
|
||||
* @param idList
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
public String addOrder(@RequestBody List<Integer> idList, @RequestHeader(value="Authorization") String token){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
if (null == idList || idList.size() == 0){
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "id不能为空", locale);
|
||||
|
||||
}
|
||||
String username = getTokenUserName(token);
|
||||
return orderService.addOrder(username, idList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看订单
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "get", method = RequestMethod.GET)
|
||||
public String getOrder( @RequestHeader(value="Authorization") String token){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
String userName = getTokenUserName(token);
|
||||
List<OrderVo> orderVoList = orderService.selectAll(userName);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, orderVoList, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除订单
|
||||
* @param idList
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/del", method = RequestMethod.POST)
|
||||
public String delOrder(@RequestBody List<Integer> idList) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (null != idList) {
|
||||
if (orderService.delOrder(idList)) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "success", locale);
|
||||
}
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "order can not save", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载链接
|
||||
* @param idList
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/download/one", method = RequestMethod.POST)
|
||||
public String downloadOne(@RequestBody List<Integer> idList) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (null != idList) {
|
||||
List<RemoteEntity> list = orderService.download(idList);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, list, locale);
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "fail", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量下载
|
||||
* @param idList
|
||||
* @param response
|
||||
* @param request
|
||||
*/
|
||||
@RequestMapping(value = "/download/many", method = RequestMethod.POST)
|
||||
public void downloadMany(@RequestBody List<Integer> idList, HttpServletResponse response, HttpServletRequest request){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
orderService.downloadMany(idList, response, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量下载 ,将下载路径写入到txt中
|
||||
* @param idList
|
||||
* @param response
|
||||
* @param request
|
||||
*/
|
||||
@RequestMapping(value = "/download/txt", method = RequestMethod.POST)
|
||||
public void downloadTxt(@RequestBody List<Integer> idList, HttpServletResponse response, HttpServletRequest request) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
orderService.downloadTxt(idList, response, request);
|
||||
}
|
||||
}
|
@ -0,0 +1,142 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.model.entity.ecology.RemoteEntity;
|
||||
import com.xkrs.microservice.model.entity.ecology.TiffRuleEntity;
|
||||
import com.xkrs.microservice.model.qo.RemoteQo;
|
||||
import com.xkrs.microservice.service.ecology.RemoteService;
|
||||
import com.xkrs.microservice.service.ecology.TiffRuleService;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
import static com.xkrs.microservice.util.DateTimeUtil.stringToDate;
|
||||
import static com.xkrs.microservice.util.DateTimeUtil.timeMillisToTime;
|
||||
|
||||
/**
|
||||
* @author wudong
|
||||
* @date 2022/4/20 15:51
|
||||
* @description
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/remote")
|
||||
public class RemoteController {
|
||||
|
||||
@Resource
|
||||
private RemoteService remoteService;
|
||||
@Resource
|
||||
private TiffRuleService tiffRuleService;
|
||||
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
/**
|
||||
* 获取菜单
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/menu", method = RequestMethod.GET)
|
||||
public String getMenu() {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, remoteService.getMenu(), locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建目录
|
||||
*
|
||||
* @param dirName
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/create_dir", method = RequestMethod.GET)
|
||||
public String createDir(@RequestParam("dirName") String dirName) {
|
||||
if (dirName.length() == 0) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "参数长度为0", locale);
|
||||
}
|
||||
Boolean dir = remoteService.createDir(dirName);
|
||||
if (dir == null) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.FILE_EXISTS, "目录已存在", locale);
|
||||
} else if (dir) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "创建成功", locale);
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "内部错误", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始扫描任务
|
||||
*
|
||||
* @param dirName
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/scan", method = RequestMethod.GET)
|
||||
public String beginScan(@RequestParam("dirName") List<String> dirName) {
|
||||
remoteService.beginScan(dirName);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "开始任务", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 进度
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/progress", method = RequestMethod.GET)
|
||||
public String progress() {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, remoteService.progress(), locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取卫星传感器
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/satellite-sensor", method = RequestMethod.GET)
|
||||
public String getSatelliteSensor(){
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, remoteService.getSatelliteSensor(), locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
* @param qo
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/query", method = RequestMethod.POST)
|
||||
public String getRemoteQuery(@RequestBody RemoteQo qo) {
|
||||
if (qo.getSatelliteSensors() == null) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "传感器和卫星不能为空", locale);
|
||||
}
|
||||
if (qo.getCode() == null) {
|
||||
qo.setCode("");
|
||||
}
|
||||
if (qo.getLeftTopLat() == null || qo.getLeftTopLon() == null || qo.getRightBottomLat() == null || qo.getRightBottomLon() == null) {
|
||||
qo.setRightBottomLat("");
|
||||
qo.setRightBottomLon("");
|
||||
qo.setLeftTopLat("");
|
||||
qo.setLeftTopLon("");
|
||||
}
|
||||
if (qo.getScanBeginStamp() == null) {
|
||||
qo.setScanEndDate(LocalDate.now());
|
||||
qo.setScanBeginDate(stringToDate("1970-01-01"));
|
||||
} else {
|
||||
qo.setScanEndDate(timeMillisToTime(qo.getScanEndStamp()).toLocalDate());
|
||||
qo.setScanBeginDate(timeMillisToTime(qo.getScanBeginStamp()).toLocalDate());
|
||||
}
|
||||
if (qo.getFinishFlag() == null) {
|
||||
qo.setFinishFlag(-1);
|
||||
}
|
||||
List<RemoteEntity> query = remoteService.findQuery(qo);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, query, locale);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/tifrule/add", method = RequestMethod.POST)
|
||||
public String addTifRule(@RequestBody TiffRuleEntity ruleEntity) {
|
||||
return tiffRuleService.add(ruleEntity);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/tifrule/dele", method = RequestMethod.GET)
|
||||
public String addTifRule(@RequestParam Integer id) {
|
||||
tiffRuleService.delete(id);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.model.vo.ShpCityVo;
|
||||
import com.xkrs.microservice.model.vo.ShpCountyVo;
|
||||
import com.xkrs.microservice.service.AdministrativeDivisionService;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
|
||||
/**
|
||||
* 行政区划服务
|
||||
* @author tajochen
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/adm")
|
||||
public class ShpAdmController {
|
||||
|
||||
@Resource
|
||||
private AdministrativeDivisionService administrativeDivisionService;
|
||||
|
||||
@RequestMapping(value="/county/get/all",method = RequestMethod.GET)
|
||||
public String getAllCounty() {
|
||||
//获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
Iterable<ShpCountyVo> list = administrativeDivisionService.getAllCounty();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/city/get/all",method = RequestMethod.GET)
|
||||
public String getAllCity() {
|
||||
//获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
Iterable<ShpCityVo> list = administrativeDivisionService.getAllCity();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale);
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import nl.basjes.parse.useragent.UserAgent;
|
||||
import nl.basjes.parse.useragent.UserAgentAnalyzer;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
|
||||
/**
|
||||
* 系统管理测试服务
|
||||
* @author tajochen
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/sys")
|
||||
public class SysManageController {
|
||||
|
||||
@RequestMapping(value="/hello/role",method = RequestMethod.GET)
|
||||
@PreAuthorize("hasAnyRole('role_administor','role_system_manager')")
|
||||
public String hello() {
|
||||
//获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"hello vip",locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/hello/auth",method = RequestMethod.GET)
|
||||
@PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user')")
|
||||
public String world() {
|
||||
//获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"world",locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value="/greeting",method = RequestMethod.GET)
|
||||
public String greeting(@RequestParam(required=false, defaultValue="World") String name,
|
||||
@RequestHeader(value="User-Agent") String userAgent) {
|
||||
//获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
System.out.println("==== in greeting ====");
|
||||
System.out.println(userAgent);
|
||||
UserAgentAnalyzer uaa = UserAgentAnalyzer
|
||||
.newBuilder()
|
||||
.hideMatcherLoadStats()
|
||||
.withCache(10000)
|
||||
.build();
|
||||
|
||||
UserAgent agent = uaa.parse(userAgent);
|
||||
for (String fieldName: agent.getAvailableFieldNamesSorted()) {
|
||||
System.out.println(fieldName + " = " + agent.getValue(fieldName));
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,name,locale);
|
||||
}
|
||||
}
|
@ -0,0 +1,250 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.model.entity.auth.RoleEntity;
|
||||
import com.xkrs.microservice.model.qo.SysUserQo;
|
||||
import com.xkrs.microservice.model.qo.auth.RoleQo;
|
||||
import com.xkrs.microservice.model.validation.SysUserQoInsert;
|
||||
import com.xkrs.microservice.model.validation.SysUserQoUpdate;
|
||||
import com.xkrs.microservice.service.RedisService;
|
||||
import com.xkrs.microservice.service.SysUserService;
|
||||
import com.xkrs.microservice.service.auth.RoleUserService;
|
||||
import com.xkrs.microservice.service.auth.SysDmsRoleService;
|
||||
import com.xkrs.microservice.service.impl.SysUserServiceImpl;
|
||||
import com.xkrs.microservice.service.log.PermissionLogService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList;
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName;
|
||||
import static com.xkrs.microservice.common.tool.TokenUtil.getUserId;
|
||||
import static com.xkrs.microservice.util.StringUtil.stringIsNull;
|
||||
|
||||
/**
|
||||
* 系统用户Controller
|
||||
* @author tajocehn
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/user")
|
||||
public class SysUserController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SysUserController.class);
|
||||
|
||||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
@Resource
|
||||
private SysUserServiceImpl sysUserServiceImpl;
|
||||
@Resource
|
||||
private SysDmsRoleService sysDmsRoleService;
|
||||
@Resource
|
||||
private RoleUserService roleUserService;
|
||||
@Resource
|
||||
private PermissionLogService permissionLogService;
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 登录用户Token验证
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/logged/check",method = RequestMethod.POST)
|
||||
public String loginUserTokenCheck(){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/check/duplicate", method = RequestMethod.POST)
|
||||
public String checkDuplicate(@RequestParam(value="userName", required=false) String userName){
|
||||
// 获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
// 验证用户名是否重复
|
||||
boolean b = sysUserService.checkUserName(userName);
|
||||
if(!sysUserService.checkUserName(userName)){
|
||||
return outputEncapsulationObject(PromptMessageEnum.USER_NAME_HAS_EXIST,"",locale);
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"OK",locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
public String addUser(@Validated({SysUserQoInsert.class}) @RequestBody SysUserQo userQo,
|
||||
BindingResult bindingResult, @RequestHeader(value="Authorization") String token){
|
||||
// 获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
// 验证数据合法性
|
||||
if(bindingResult.hasErrors()){
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
// 验证用户名是否重复
|
||||
if(!sysUserService.checkUserName(userQo.getUserName())){
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"用户名重复",locale);
|
||||
}
|
||||
// 验证手机号是否重复
|
||||
if (!sysUserService.findByTel(userQo.getTelephone())) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.Tel_INVAILD,"手机号重复",locale);
|
||||
}
|
||||
// 添加新用户
|
||||
String userId = getUserId(token);
|
||||
sysUserService.addUser(userId, userQo);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"OK",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色
|
||||
* @param qo
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@CrossOrigin
|
||||
@PreAuthorize("hasAnyRole('ROLE_ADMINISTOR', 'ROLE_SYSTEM_MANAGER')")
|
||||
// @RequestMapping(value = "/add/role", method = RequestMethod.POST)
|
||||
public String addUser(@Validated({SysUserQoInsert.class}) @RequestBody RoleQo qo,
|
||||
BindingResult bindingResult){
|
||||
// 获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
// 验证数据合法性
|
||||
if(bindingResult.hasErrors()){
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
// 验证角色名是否重复
|
||||
if(sysDmsRoleService.getRole(qo.getRoleName()) != null){
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale);
|
||||
}
|
||||
// 添加新角色
|
||||
sysDmsRoleService.add(qo);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"OK",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有用户
|
||||
* @return
|
||||
*/
|
||||
@CrossOrigin
|
||||
@PreAuthorize("hasAnyRole('ROLE_ADMINISTOR', 'ROLE_SYSTEM_MANAGER')")
|
||||
@RequestMapping(value="/get/all", method = RequestMethod.GET)
|
||||
public String getAllSysUser(){
|
||||
// 获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
Map<String, Object> sysUserDtoList = sysUserService.getAllSysUser();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,sysUserDtoList,locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有角色
|
||||
* @return
|
||||
*/
|
||||
@CrossOrigin
|
||||
@PreAuthorize("hasAnyRole('ROLE_ADMINISTOR', 'ROLE_SYSTEM_MANAGER')")
|
||||
@RequestMapping(value="/get/role/all", method = RequestMethod.GET)
|
||||
public String getAllRole(){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<RoleEntity> all = sysDmsRoleService.getAll();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,all,locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户角色分配
|
||||
* @return
|
||||
*/
|
||||
// @CrossOrigin
|
||||
@PreAuthorize("hasAnyRole('ROLE_ADMINISTOR', 'ROLE_SYSTEM_MANAGER')")
|
||||
@RequestMapping(value="/role/user", method = RequestMethod.POST)
|
||||
public String user2Role(@RequestParam("userId") String userId, @RequestBody List<String> roleIds,
|
||||
@RequestHeader(value="Authorization") String token,
|
||||
HttpServletResponse response, HttpServletRequest request){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
String userName = getTokenUserName(token);
|
||||
String accountId = getUserId(token);
|
||||
roleUserService.add(userId,roleIds, userName);
|
||||
permissionLogService.add(accountId, request, response, userId);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
@PreAuthorize("hasAnyRole('ROLE_ADMINISTOR', 'ROLE_SYSTEM_MANAGER')")
|
||||
public String updateUser(@Validated({SysUserQoUpdate.class}) @RequestBody SysUserQo userQo,
|
||||
BindingResult bindingResult){
|
||||
// 获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
// 验证数据合法性
|
||||
if(bindingResult.hasErrors()){
|
||||
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
|
||||
}
|
||||
// 修改用户
|
||||
sysUserService.updateSysUser(userQo);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"OK",locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
* @param username
|
||||
* @param type
|
||||
* @param cityCode
|
||||
* @param countyCode
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasAnyRole('ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/search", method = RequestMethod.GET)
|
||||
public String userSearch(@RequestParam("username") String username, @RequestParam("type") String type, @RequestParam("cityCode") String cityCode, @RequestParam("countyCode") String countyCode){
|
||||
Map<String, Object> map = sysUserService.userSearch(username, type, cityCode, countyCode);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, map, LocaleContextHolder.getLocale());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码,只允许修改系统用户
|
||||
* @param password
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/update/pw", method = RequestMethod.POST)
|
||||
@PreAuthorize("hasAnyRole('ROLE_ADMINISTOR')")
|
||||
public String updatePw(@RequestParam("password") String password, @RequestParam("id") String id){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (!stringIsNull(password, id)) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "", locale);
|
||||
}
|
||||
int i = sysUserService.updatePw(password, id);
|
||||
if (i == 1) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale);
|
||||
} else {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "", locale);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 软删除指定id的用户
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/soft/delete", method = RequestMethod.GET)
|
||||
@PreAuthorize("hasAnyRole('ROLE_ADMINISTOR', 'ROLE_SYSTEM_MANAGER')")
|
||||
public String deleteCustomUser(@RequestParam(value="id") String id){
|
||||
// 获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
int res = sysUserService.softDeleteUser(id);
|
||||
if(res==0){
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"",locale);
|
||||
} else {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,200 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.model.entity.village.*;
|
||||
import com.xkrs.microservice.model.vo.village.VillageVo;
|
||||
import com.xkrs.microservice.service.village.*;
|
||||
import com.xkrs.microservice.service.village.impl.VillageRiverLakeMonitorPointServiceImpl;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
import static com.xkrs.microservice.util.DateTimeUtil.dateToString;
|
||||
import static com.xkrs.microservice.util.DateTimeUtil.stringToDate;
|
||||
import static com.xkrs.microservice.util.StringUtil.stringIsNull;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/22
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/village")
|
||||
@PreAuthorize("hasAnyAuthority('ROLE_ADMINISTOR', 'ROLE_PRO_USER')")
|
||||
public class VillageController {
|
||||
@Resource
|
||||
private VillageService service;
|
||||
|
||||
/**
|
||||
* 农村省(市)农村环境质量试点监测基本信息表
|
||||
*/
|
||||
@Resource
|
||||
private VillageEnvironmentQualityMonitorPointService villageEnvironmentQualityMonitorPointService;
|
||||
|
||||
/**
|
||||
* 农村县域河流湖库水质监测点位信息表
|
||||
*/
|
||||
@Resource
|
||||
private VillageRiverLakeMonitorPointServiceImpl villageRiverLakeMonitorPointService;
|
||||
|
||||
/**
|
||||
* 农村万人千吨地下水饮用水水源地监测点位信息表
|
||||
*/
|
||||
@Resource
|
||||
private VillageMillionPeopleKilotonUnderDrinkWaterSourceMonitorPointService villageMillionPeopleKilotonUnderDrinkWaterSourceMonitorPointService;
|
||||
|
||||
/**
|
||||
* 农村万人千吨地表水饮用水水源地监测点位信息表
|
||||
*/
|
||||
@Resource
|
||||
private VillageMillionPeopleKilotonSurfaceDrinkWaterSourceMonitorPointService villageMillionPeopleKilotonSurfaceDrinkWaterSourceMonitorPointService;
|
||||
|
||||
/**
|
||||
* 农村日处理能力20吨及以上的生活污水处理设施点位信息表
|
||||
*/
|
||||
@Resource
|
||||
private VillageDailyProcessCapacity20PointDataService villageDailyProcessCapacity20PointDataService;
|
||||
|
||||
/**
|
||||
* 农田灌溉水点位信息表
|
||||
*/
|
||||
@Resource
|
||||
private VillageIrrigationWaterPointDataService villageIrrigationWaterPointDataService;
|
||||
|
||||
/**
|
||||
* 点位信息
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/environmentqualitymonitorpoint", method = RequestMethod.GET)
|
||||
public String getEnvironmentQualityMonitorPoint() {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<VillageEnvironmentQualityMonitorPointEntity> allDistinct = villageEnvironmentQualityMonitorPointService.findAllDistinct();
|
||||
List<VillageRiverLakeMonitorPointEntity> allDistinct1 = villageRiverLakeMonitorPointService.findAllDistinct();
|
||||
Map<String, List> map = new HashMap<>();
|
||||
map.put("environment", allDistinct);
|
||||
map.put("riverLake", allDistinct1);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, map, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
* @param fileType 文件类型
|
||||
* @param city 市
|
||||
* @param county 县
|
||||
* @param beginTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/initinquire", method = RequestMethod.GET)
|
||||
public String initAndInquire(@RequestParam("fileType") Integer fileType, @RequestParam("city") String city,
|
||||
@RequestParam("county") String county, @RequestParam("beginTime") String beginTime,
|
||||
@RequestParam("endTime") String endTime) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (fileType == null) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "fileType is null", locale);
|
||||
}
|
||||
String endTimePlusDay1;
|
||||
if (stringIsNull(endTime)) {
|
||||
endTimePlusDay1 = dateToString(stringToDate(endTime).plusDays(1));
|
||||
} else {
|
||||
endTimePlusDay1 = endTime;
|
||||
}
|
||||
VillageVo byCondition = service.findByCondition(fileType, city, county, beginTime, endTimePlusDay1);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byCondition, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模块一分析模块
|
||||
* @param lon 经度
|
||||
* @param lat 纬度
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/analysisOne", method = RequestMethod.GET)
|
||||
public String analysisOne(@RequestParam(name = "lon", required = false) String lon,@RequestParam(name = "lat", required = false) String lat) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
Map<String, Map> stringListMap = service.analysisOne(lon, lat);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, stringListMap, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 万人千吨,点位信息
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/point/kiloton", method = RequestMethod.GET)
|
||||
public String kilotonPoint(){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<VillageMillionPeopleKilotonUnderDrinkWaterSourceMonitorPointEntity> distinct = villageMillionPeopleKilotonUnderDrinkWaterSourceMonitorPointService.findDistinct();
|
||||
List<VillageMillionPeopleKilotonSurfaceDrinkWaterSourceMonitorPointEntity> distinct1 = villageMillionPeopleKilotonSurfaceDrinkWaterSourceMonitorPointService.findDistinct();
|
||||
Map<String, List> map = new HashMap<>();
|
||||
map.put("under", distinct);
|
||||
map.put("surface", distinct1);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,map, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 万人千吨 分析
|
||||
* @param lon
|
||||
* @param lat
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/analysis/kiloton", method = RequestMethod.GET)
|
||||
public String analysisTwo(@RequestParam(name = "lon", required = false) String lon, @RequestParam(name = "lat", required = false) String lat) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
Map<String, Map> stringListMap = service.analysisTwo(lon, lat);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, stringListMap, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生活污水,点位信息
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/point/sewage", method = RequestMethod.GET)
|
||||
public String capacityPoint(){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<VillageDailyProcessCapacity20PointDataEntity> distinct = villageDailyProcessCapacity20PointDataService.findDistinct();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,distinct, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生活污水 分析
|
||||
* @param lon
|
||||
* @param lat
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/analysis/sewage", method = RequestMethod.GET)
|
||||
public String analysisThree(@RequestParam(name = "lon", required = false) String lon, @RequestParam(name = "lat", required = false) String lat) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
Map<String, Map> stringListMap = service.analysisThree(lon, lat);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, stringListMap, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 农灌水,点位信息
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/point/irrigat", method = RequestMethod.GET)
|
||||
public String irrigatPoint(){
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<VillageIrrigationWaterPointDataEntity> distinct = villageIrrigationWaterPointDataService.findDistinct();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,distinct, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 灌溉水 分析
|
||||
* @param lon
|
||||
* @param lat
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/analysis/irrigate", method = RequestMethod.GET)
|
||||
public String analysisFour(@RequestParam(name = "lon", required = false) String lon, @RequestParam(name = "lat", required = false) String lat) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
Map<String, Map> stringListMap = service.analysisFour(lon, lat);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, stringListMap, locale);
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.xkrs.microservice.service.YunLiUserService;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/yun")
|
||||
public class YunLiUser {
|
||||
|
||||
@Resource
|
||||
private YunLiUserService yunLiUserService;
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/user/info", method = RequestMethod.GET)
|
||||
public void getUserInfo(){
|
||||
yunLiUserService.quartzUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组织信息
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/unit/info", method = RequestMethod.GET)
|
||||
public void getUnitInfo(){
|
||||
yunLiUserService.quartzUnit();
|
||||
}
|
||||
}
|
@ -0,0 +1,527 @@
|
||||
package com.xkrs.microservice.controller;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xkrs.microservice.common.account.AccountCredentials;
|
||||
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.microservice.dao.auth.YunLiInSysDao;
|
||||
import com.xkrs.microservice.model.entity.auth.RoleEntity;
|
||||
import com.xkrs.microservice.model.entity.auth.SysUserEntity;
|
||||
import com.xkrs.microservice.model.entity.yunli.YunLIInSys;
|
||||
import com.xkrs.microservice.model.entity.yunli.YunLiUserExInfoEntity;
|
||||
import com.xkrs.microservice.service.SysUserService;
|
||||
import com.xkrs.microservice.service.YunLiUserService;
|
||||
import com.xkrs.microservice.service.auth.PtStPersonNumberService;
|
||||
import com.xkrs.microservice.service.auth.RoleUserService;
|
||||
import com.xkrs.microservice.service.auth.SysDmsRoleService;
|
||||
import com.xkrs.microservice.util.sm.Sm2Encryptor;
|
||||
import com.yunlizhihui.auth.base.model.qo.sdk.UnitQo;
|
||||
import com.yunlizhihui.auth.base.model.qo.sdk2.UserInfoQo;
|
||||
import com.yunlizhihui.auth.base.model.vo.sdk.*;
|
||||
import com.yunlizhihui.auth.sdk2.service.PlatformUnitService;
|
||||
import com.yunlizhihui.auth.sdk2.service.PlatformUserService;
|
||||
import com.yunlizhihui.common.model.vo.PageData;
|
||||
import org.bouncycastle.crypto.InvalidCipherTextException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.crypto.keygen.KeyGenerators;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.xkrs.microservice.common.account.TokenAuthenticationService.getJwt;
|
||||
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
import static com.xkrs.microservice.common.tool.TokenUtil.getUserId;
|
||||
import static com.xkrs.microservice.util.EncryptDecryptUtil.encry256;
|
||||
import static com.xkrs.microservice.util.HttpClientUtils.sendHttpsGet;
|
||||
import static com.xkrs.microservice.util.StringUtil.stringIsNull;
|
||||
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/yunli")
|
||||
public class YunLiUserController {
|
||||
private static final Logger log = LoggerFactory.getLogger(YunLiUserController.class);
|
||||
private final Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
@Resource
|
||||
private PlatformUserService userService;
|
||||
@Resource
|
||||
private PlatformUnitService unitService;
|
||||
@Resource
|
||||
private RoleUserService roleUserService;
|
||||
@Resource
|
||||
private SysDmsRoleService roleService;
|
||||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
@Resource
|
||||
private YunLiUserService yunLiUserService;
|
||||
@Resource
|
||||
private YunLiInSysDao yunLIInSysDao;
|
||||
@Resource
|
||||
private PtStPersonNumberService ptStPersonNumberService;
|
||||
|
||||
@Value("${private.key}")
|
||||
private String key;
|
||||
@Value("${sso.url}")
|
||||
private String url;
|
||||
@Value("${sso.fail.url}")
|
||||
private String failUrl;
|
||||
@Value("${sso.home.page.url}")
|
||||
private String homePage;
|
||||
|
||||
private final String clientId = "sdceshi";
|
||||
private final String operatorId = "ceshi";
|
||||
private final String token = "token";
|
||||
private final String tenantId = "6b4f7ba1b57fb43de3fe9cd91d8f690e";
|
||||
private final Client client = new Client(clientId, operatorId, token, tenantId);
|
||||
private final String unitId = "38b3e6afcfeb33b5828f927808833f8c";
|
||||
|
||||
/**
|
||||
* 创建用户
|
||||
*
|
||||
* @param userImportInfo 用户信息
|
||||
* @return
|
||||
*/
|
||||
// @PreAuthorize("hasRole('ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/user/insert", method = RequestMethod.POST)
|
||||
public String insert(@RequestBody UserImportInfo userImportInfo, @RequestHeader(value = "Authorization") String token) {
|
||||
String userId = getUserId(token);
|
||||
String salt = KeyGenerators.string().generateKey();
|
||||
String s = encry256(userImportInfo.getPassword());
|
||||
String password = encry256(userImportInfo.getPassword() + salt);
|
||||
List<ExtraInfo> list = new ArrayList<>();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("salt", salt);
|
||||
map.put("password", password);
|
||||
map.forEach((k, v) -> {
|
||||
ExtraInfo extraInfo = new ExtraInfo();
|
||||
extraInfo.setInfoKey(k);
|
||||
extraInfo.setInfoValue(v);
|
||||
list.add(extraInfo);
|
||||
});
|
||||
userImportInfo.setPassword(s);
|
||||
userImportInfo.setExtraList(list);
|
||||
|
||||
UserInfo userInfo = null;
|
||||
try {
|
||||
userInfo = userService.saveOrUpdateUser(client, userImportInfo);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 新建用户,默认权限
|
||||
UserInfoQo qo = new UserInfoQo();
|
||||
qo.setUserName(userImportInfo.getUserName());
|
||||
List<UserInfo> userInfos = userService.queryUserList(client, qo);
|
||||
UserInfo userInfo1 = null;
|
||||
if (userInfos.size() != 0) {
|
||||
userInfo1 = userInfos.get(0);
|
||||
roleUserService.addUserRole(userId, userInfo1.getUserId(), userInfo1.getUsername(), "ROLE_CITY_USER");
|
||||
}
|
||||
UnitUserList var = new UnitUserList();
|
||||
List<String> varList = new ArrayList<>();
|
||||
var.setUnitId(unitId);
|
||||
varList.add(Objects.requireNonNull(userInfo1).getUserId());
|
||||
var.setUserIdList(varList);
|
||||
unitService.setUnitUser(client, var);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, userInfo, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户是否存在
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/user/checkUserName", method = RequestMethod.GET)
|
||||
public String checkUserNameAvailable(@RequestParam("username") String username) {
|
||||
Boolean aBoolean = userService.checkUserNameAvailable(client, username);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, aBoolean, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理用户,禁用、激活
|
||||
*
|
||||
* @param userId
|
||||
* @param type 0:启用 1:禁用
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/user/disable/userId", method = RequestMethod.GET)
|
||||
public String disableUser(@RequestParam("userId") String userId, @RequestParam("type") Integer type) {
|
||||
if (!stringIsNull(userId)) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "", locale);
|
||||
}
|
||||
if (type.equals(1)) {
|
||||
UserInfo userInfo = userService.disableUser(userId);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, userInfo, locale);
|
||||
} else if (type.equals(0)) {
|
||||
UserInfo userInfo = userService.enableUser(userId);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, userInfo, locale);
|
||||
} else {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "", locale);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/user/delete/userId", method = RequestMethod.GET)
|
||||
public String deleteUser(@RequestParam("userId") String userId) {
|
||||
if (!stringIsNull(userId)) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "", locale);
|
||||
}
|
||||
UserInfo userInfo = null;
|
||||
try {
|
||||
userInfo = userService.deleteUser(client, userId);
|
||||
} catch (Exception e) {
|
||||
log.error("删除用户 连接超时");
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, userInfo, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件查询用户
|
||||
*
|
||||
* @param qo
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/user/all", method = RequestMethod.POST)
|
||||
public String findUser(@RequestBody UserInfoQo qo) {
|
||||
try {
|
||||
List<UserInfo> userInfos = userService.queryUserList(client, qo);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, userInfos, locale);
|
||||
} catch (Exception e) {
|
||||
log.error("搜索用户 :搜索用户超时");
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.READ_TIME_OUT_ERROR, "", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*
|
||||
* @param password
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMINISTOR')")
|
||||
@RequestMapping(value = "/user/reset/pw")
|
||||
public String modifyPw(@RequestParam("password") String password, @RequestParam("userId") String userId) {
|
||||
UserInfo userInfo = null;
|
||||
try {
|
||||
userInfo = userService.getUserInfo(userId);
|
||||
} catch (Exception e) {
|
||||
log.error("重置密码:搜索用户超时");
|
||||
return outputEncapsulationObject(PromptMessageEnum.READ_TIME_OUT_ERROR, "", locale);
|
||||
}
|
||||
Map<String, String> exInfoMap = userInfo.getExInfoMap();
|
||||
String salt = exInfoMap.get("salt");
|
||||
String pw = encry256(password + salt);
|
||||
exInfoMap.put("password", pw);
|
||||
List<ExtraInfo> list = new ArrayList<>();
|
||||
exInfoMap.forEach((k, v) -> {
|
||||
ExtraInfo extraInfo = new ExtraInfo();
|
||||
extraInfo.setInfoKey(k);
|
||||
extraInfo.setInfoValue(v);
|
||||
list.add(extraInfo);
|
||||
});
|
||||
userInfo.setPassword(pw);
|
||||
try {
|
||||
UserInfo userInfo1 = userService.insertOrUpdate(client, userInfo);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, userInfo1, locale);
|
||||
} catch (Exception e) {
|
||||
log.error("重置密码:重置超时");
|
||||
return outputEncapsulationObject(PromptMessageEnum.READ_TIME_OUT_ERROR, "", locale);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建或修改部门
|
||||
*
|
||||
* @param unit
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/unit/insert", method = RequestMethod.POST)
|
||||
public String insertOrUpdateUnit(@RequestBody Unit unit) {
|
||||
Unit unit1 = null;
|
||||
try {
|
||||
unit1 = unitService.insertOrUpdate(client, unit);
|
||||
} catch (Exception e) {
|
||||
log.error("新增部门:读取超时");
|
||||
return outputEncapsulationObject(PromptMessageEnum.SYSTEM_INNER_ERROR, "", locale);
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, unit1, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
*
|
||||
* @param unitId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/unit/dete", method = RequestMethod.GET)
|
||||
public String deleUnit(@RequestParam("unitId") String unitId) {
|
||||
if (!stringIsNull(unitId)) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "", locale);
|
||||
}
|
||||
try {
|
||||
unitService.deleteUnit(client, unitId);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale);
|
||||
} catch (Exception e) {
|
||||
log.error("删除部门:连接超时");
|
||||
return outputEncapsulationObject(PromptMessageEnum.READ_TIME_OUT_ERROR, "", locale);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门下的用户
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/unit/user", method = RequestMethod.GET)
|
||||
public String getUnitUser() {
|
||||
try {
|
||||
List<UserWithUnit> unitUserList = unitService.getUnitUserList(client, unitId);
|
||||
List<RoleEntity> all = roleService.getAll();
|
||||
List list = new ArrayList(unitUserList.size());
|
||||
Map<Object, Object> map = new HashMap<>(2);
|
||||
for (UserWithUnit user :
|
||||
unitUserList) {
|
||||
String userId = user.getUserId();
|
||||
List<String> byId = roleUserService.getById(userId);
|
||||
List<RoleEntity> roles = new ArrayList<>();
|
||||
for (String id :
|
||||
byId) {
|
||||
List<RoleEntity> collect = all.stream().filter(roleEntity -> id.equals(roleEntity.getId())).collect(Collectors.toList());
|
||||
roles.addAll(collect);
|
||||
}
|
||||
map.put("user", user);
|
||||
map.put("role", roles);
|
||||
list.add(map);
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, list, locale);
|
||||
} catch (Exception e) {
|
||||
log.error("获取部门:连接超时");
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.READ_TIME_OUT_ERROR, "", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索部门
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/unit/search", method = RequestMethod.POST)
|
||||
public String getUnitUser(@RequestBody UnitQo unitQo) {
|
||||
try {
|
||||
PageData<Unit> pageList = unitService.getPageList(client, unitQo);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, pageList, locale);
|
||||
} catch (Exception e) {
|
||||
log.error("获取部门:连接超时");
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.READ_TIME_OUT_ERROR, "", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将用户分配到部门
|
||||
*
|
||||
* @param unitUserList
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/unit/user_unit", method = RequestMethod.POST)
|
||||
public String setUser2Unit(@RequestBody UnitUserList unitUserList) {
|
||||
try {
|
||||
unitService.setUnitUser(client, unitUserList);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale);
|
||||
} catch (Exception e) {
|
||||
log.error("将用户分配到部门失败");
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.READ_TIME_OUT_ERROR, "", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单点登录
|
||||
*
|
||||
* @param userid
|
||||
*/
|
||||
@RequestMapping(value = "/sso", method = RequestMethod.GET)
|
||||
public String getSm2UserId(@RequestParam("userid") String userid) {
|
||||
try {
|
||||
if (!stringIsNull(userid)) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "", locale);
|
||||
}
|
||||
String userId = Sm2Encryptor.privateDecrypt(userid, key);
|
||||
|
||||
// UserInfo userInfo = userService.getUserInfo(client, userId);
|
||||
// UserInfo userInfo = userService.getUserInfo(client, "28d513be6b0dafef6803063e1c559e76");
|
||||
YunLiUserExInfoEntity userInfoById = yunLiUserService.getUserInfoByIdSso(userId);
|
||||
// Map<String, String> userInfoById = (Map<String, String>) userInfoByIdSso;
|
||||
if (userInfoById == null) {
|
||||
log.info("用户信息不存在,用户id:{}", userId);
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "", locale);
|
||||
}
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String urlWithParam = url + "?sm2UserId=" + userid;
|
||||
log.error(urlWithParam);
|
||||
String s2 = sendHttpsGet(urlWithParam);
|
||||
JsonNode jsonNode = mapper.readTree(s2);
|
||||
String code = jsonNode.path("code").asText();
|
||||
String msg = jsonNode.path("msg").asText();
|
||||
final String success = "0";
|
||||
if (success.equals(code)) {
|
||||
// 进去子系统
|
||||
List<String> roleById = roleUserService.getRoleById(userId);
|
||||
// UserInfo userInfo = new UserInfo();
|
||||
// userInfo.setUserId(userId);
|
||||
// final String usernameKey = "userInfoById";
|
||||
// String name = userInfoById.get(usernameKey);
|
||||
// userInfo.setUsername(name);
|
||||
String jwt = getJwt(userInfoById, roleById);
|
||||
Map<String, Object> map = new HashMap<>(5);
|
||||
map.put("o_user_city", "山东省");
|
||||
map.put("o_user_code", "370000");
|
||||
map.put("o_user_from", "1");
|
||||
map.put("o_user_id", userInfoById.getoUserId());
|
||||
map.put("o_user_name", userInfoById.getoUserName());
|
||||
Map<String, Object> userMap = new HashMap<>(2);
|
||||
userMap.put("jwt", jwt);
|
||||
userMap.put("userInfo", map);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, userMap, locale);
|
||||
} else {
|
||||
log.error("回调验证不通过:" + s2);
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "", locale);
|
||||
}
|
||||
} catch (InvalidCipherTextException e) {
|
||||
e.printStackTrace();
|
||||
} catch (JsonMappingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "", locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/user/info", method = RequestMethod.GET)
|
||||
public String getUserInfo(@RequestParam("userId") String userId) {
|
||||
UserInfo userInfo = userService.getUserInfo(client, userId);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, userInfo, locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/app/sso", method = RequestMethod.POST)
|
||||
public String appSso(@RequestBody AccountCredentials map) {
|
||||
String user = map.getUserName();
|
||||
try {
|
||||
if (!stringIsNull(user)) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "", locale);
|
||||
}
|
||||
// String username = Sm2Encryptor.privateDecrypt("04" + user, "00C5484DFC2627EE7BCA04EAB2B463971398D56C13A42335B3D2C84814E9BC240C");
|
||||
SysUserEntity sysUserByUserName = sysUserService.getSysUserByUserName(user);
|
||||
YunLiUserExInfoEntity userInfoById = yunLiUserService.getUserInfoById(user);
|
||||
// Map<String, String> userInfoById = (Map<String, String>) userInfoById1;
|
||||
log.info("登录用户为{}", user);
|
||||
if (sysUserByUserName == null && userInfoById == null) {
|
||||
log.info("用户信息不存在");
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "", locale);
|
||||
}
|
||||
Map<String, String> userMap = new HashMap<>(5);
|
||||
String userId;
|
||||
if (userInfoById != null) {
|
||||
userId = userInfoById.getoUserId();
|
||||
userMap.put("o_user_city", "山东省");
|
||||
userMap.put("o_user_code", "370000");
|
||||
userMap.put("o_user_from", "1");
|
||||
userMap.put("o_user_id", userId);
|
||||
userMap.put("o_user_name", userInfoById.getoUserName());
|
||||
} else {
|
||||
userId = sysUserByUserName.getId();
|
||||
userMap.put("o_user_from", "2");
|
||||
userMap.put("oUserId", userId);
|
||||
userMap.put("o_user_city", sysUserByUserName.getCityName());
|
||||
userMap.put("o_user_code", sysUserByUserName.getCityCode());
|
||||
userMap.put("o_user_name", sysUserByUserName.getRealName());
|
||||
}
|
||||
List<String> roleById = roleUserService.getRoleById(userId);
|
||||
String jwt = getJwt(userMap, roleById);
|
||||
Map<String, Object> outMap = new HashMap<>(2);
|
||||
outMap.put("jwt", jwt);
|
||||
outMap.put("userInfo", userMap);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, outMap, locale);
|
||||
} catch (Exception e) {
|
||||
log.error("app单点登录失败:", e);
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* first portal sso
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/portal/sso", method = RequestMethod.GET)
|
||||
public String portalSso(@RequestParam("userId") String userId) {
|
||||
YunLiUserExInfoEntity userInfoById = yunLiUserService.getUserInfoById(userId);
|
||||
// Map<String, String> userInfoById = (Map<String, String>) userInfoById1;
|
||||
final String oUserId = "o_user_id";
|
||||
if (userInfoById == null || userInfoById == null) {
|
||||
log.info("first portal sso fail, user info does not exit");
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "", locale);
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>(5);
|
||||
map.put("o_user_city", "山东省");
|
||||
map.put("o_user_code", "370000");
|
||||
map.put("o_user_from", "1");
|
||||
map.put("o_user_id", userInfoById.getoUserId());
|
||||
map.put("o_user_name", userInfoById.getoUserName());
|
||||
List<String> roleById = roleUserService.getRoleById(userId);
|
||||
String jwt = getJwt(userInfoById, roleById);
|
||||
Map<String, Object> userMap = new HashMap<>(2);
|
||||
userMap.put("jwt", jwt);
|
||||
userMap.put("userInfo", map);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, userMap, locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/in_sys", method = RequestMethod.POST)
|
||||
public String yunliInSys(@RequestBody YunLIInSys sys) {
|
||||
yunLIInSysDao.save(sys);
|
||||
ptStPersonNumberService.updateGatewayById();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/dele_sys", method = RequestMethod.POST)
|
||||
public String yunliInSysDele(@RequestBody YunLIInSys sys) {
|
||||
yunLIInSysDao.deleteById(sys.getId());
|
||||
ptStPersonNumberService.updateGatewayById();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取所有
|
||||
*
|
||||
* @param page
|
||||
* @param num
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/all/page", method = RequestMethod.GET)
|
||||
public String yunliUserAllPage(@RequestParam("page") int page, @RequestParam("num") int num,
|
||||
@RequestParam(value = "name", required = false) String name) {
|
||||
Page<YunLiUserExInfoEntity> pages = yunLiUserService.getPage(page, num, name);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, pages, locale);
|
||||
}
|
||||
}
|
18
src/main/java/com/xkrs/microservice/dao/AppFileDao.java
Normal file
18
src/main/java/com/xkrs/microservice/dao/AppFileDao.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.xkrs.microservice.dao;
|
||||
|
||||
import com.xkrs.microservice.model.entity.AppFileEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
* AppFileDao
|
||||
* @author tajochen
|
||||
*/
|
||||
public interface AppFileDao extends JpaRepository<AppFileEntity,Integer> {
|
||||
|
||||
/**
|
||||
* 获取指定版本号的记录
|
||||
* @param versionNumber 版本号
|
||||
* @return
|
||||
*/
|
||||
Iterable<AppFileEntity> findByVersionNumber(String versionNumber);
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.xkrs.microservice.dao;
|
||||
|
||||
import com.xkrs.microservice.model.entity.CountyStandardName;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/22
|
||||
*/
|
||||
public interface CountyStandardNameDao extends JpaRepository<CountyStandardName, String> {
|
||||
|
||||
CountyStandardName findByName(String name);
|
||||
}
|
29
src/main/java/com/xkrs/microservice/dao/DicDao.java
Normal file
29
src/main/java/com/xkrs/microservice/dao/DicDao.java
Normal file
@ -0,0 +1,29 @@
|
||||
package com.xkrs.microservice.dao;
|
||||
|
||||
import com.xkrs.microservice.model.entity.Dic;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/19
|
||||
*/
|
||||
public interface DicDao extends JpaRepository<Dic, Integer> {
|
||||
|
||||
Dic findByCn(String cn);
|
||||
|
||||
/**
|
||||
* 根据文件类型获取字典
|
||||
* @param fileType
|
||||
* @return
|
||||
*/
|
||||
List<Dic> findAllByFileType(String fileType);
|
||||
|
||||
/**
|
||||
* 根据文件名获取字典
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
List<Dic> findAllByFileName(String fileName);
|
||||
}
|
95
src/main/java/com/xkrs/microservice/dao/FileDocumentDao.java
Normal file
95
src/main/java/com/xkrs/microservice/dao/FileDocumentDao.java
Normal file
@ -0,0 +1,95 @@
|
||||
package com.xkrs.microservice.dao;
|
||||
|
||||
import com.xkrs.microservice.model.entity.FileDocumentEntity;
|
||||
import com.xkrs.microservice.model.entity.ecology.DocumentEntity;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* FileDocumentDao
|
||||
* @author tajochen
|
||||
*/
|
||||
public interface FileDocumentDao extends PagingAndSortingRepository<FileDocumentEntity, Integer>, JpaSpecificationExecutor<FileDocumentEntity> {
|
||||
|
||||
/**
|
||||
* 根据文件类型查找
|
||||
* @param fileType
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from file_document where file_type = :fileType", nativeQuery = true)
|
||||
Iterable<FileDocumentEntity> findByFileType(Integer fileType);
|
||||
|
||||
/**
|
||||
* 根据模块查找
|
||||
* @param fileType1
|
||||
* @param fileType2
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from file_document where file_type between :fileType1 and :fileType2 order by id desc", nativeQuery = true)
|
||||
Iterable<FileDocumentEntity> findByFileType(Integer fileType1, Integer fileType2);
|
||||
|
||||
/**
|
||||
* 根据模块查找
|
||||
* @param fileType1
|
||||
* @param fileType2
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from file_document where file_type between :fileType1 and :fileType2 and username in " +
|
||||
"(select user_name from sys_user where city_name = (select city_name from sys_user where user_name = :username)) order by id desc", nativeQuery = true)
|
||||
Iterable<FileDocumentEntity> findByFileType(Integer fileType1, Integer fileType2, String username);
|
||||
|
||||
/**
|
||||
* 根据模块查找
|
||||
* @param fileType1
|
||||
* @param fileType2
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from file_document where file_type between :fileType1 and :fileType2 and username in " +
|
||||
":usernames order by id desc", nativeQuery = true)
|
||||
Iterable<FileDocumentEntity> findByFileType(Integer fileType1, Integer fileType2, List<String> usernames);
|
||||
|
||||
/**
|
||||
* 更新审核状态
|
||||
* @param id
|
||||
* @param audit
|
||||
* @param progress
|
||||
* @param approverCity
|
||||
*/
|
||||
@Modifying
|
||||
@Query(value = "update file_document set audit = :audit, progress = :progress, approver_city = :approverCity where id = :id", nativeQuery = true)
|
||||
void updateApproverCityById(Integer id, Integer audit, Integer progress, String approverCity);
|
||||
|
||||
/**
|
||||
* 更新审核状态
|
||||
* @param id
|
||||
* @param audit
|
||||
* @param progress
|
||||
* @param approverProvince
|
||||
*/
|
||||
@Modifying
|
||||
@Query(value = "update file_document set audit = :audit, progress = :progress, approver_province = :approverProvince, " +
|
||||
"reject_reason = :rejectReason where id = :id", nativeQuery = true)
|
||||
void updateApproverProvinceById(Integer id, Integer audit, Integer progress, String approverProvince, String rejectReason);
|
||||
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
FileDocumentEntity findByFileName(String fileName);
|
||||
|
||||
/**
|
||||
* 根据文件类型查找,获取审核通过的文件名
|
||||
* @param fileType
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select file_name from file_document where file_type = :fileType and audit = 1", nativeQuery = true)
|
||||
List<String> findByFileTypeAndAudit(Integer fileType);
|
||||
}
|
61
src/main/java/com/xkrs/microservice/dao/FileEntityDao.java
Normal file
61
src/main/java/com/xkrs/microservice/dao/FileEntityDao.java
Normal file
@ -0,0 +1,61 @@
|
||||
package com.xkrs.microservice.dao;
|
||||
|
||||
import com.xkrs.microservice.model.entity.FileEntity;
|
||||
import com.xkrs.microservice.model.vo.FileVo;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2020/12/30
|
||||
*/
|
||||
public interface FileEntityDao extends JpaRepository<FileEntity, Integer>, JpaSpecificationExecutor<FileEntity> {
|
||||
|
||||
/**
|
||||
* 根据id查找
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id, file_name, file_path, file_size, md5, mtime, scene, url, data_to_source from file where id = :id", nativeQuery = true)
|
||||
FileEntity selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 根据用户名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id, file_name, file_path, file_size, md5, mtime, scene, url, data_to_source from file where file_name = :fileName", nativeQuery = true)
|
||||
FileEntity selectByFileName(String fileName);
|
||||
|
||||
/**
|
||||
* 根据md5查找
|
||||
* @param md5
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id, file_name, file_path, file_size, md5, mtime, scene, url, data_to_source from file where md5 = :md5", nativeQuery = true)
|
||||
FileEntity selectByMd5(String md5);
|
||||
|
||||
/**
|
||||
* 查找所有
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id, file_name, file_path, file_size, md5, mtime, scene, url, data_to_source from file", nativeQuery = true)
|
||||
List<FileEntity> selectAll();
|
||||
|
||||
/**
|
||||
* 根据md5删除
|
||||
* @param md5
|
||||
* @return
|
||||
*/
|
||||
@Modifying
|
||||
@Query(value = "delete from file where md5 = :md5", nativeQuery = true)
|
||||
int deleteByMd5(String md5);
|
||||
|
||||
|
||||
|
||||
}
|
38
src/main/java/com/xkrs/microservice/dao/FileTemplateDao.java
Normal file
38
src/main/java/com/xkrs/microservice/dao/FileTemplateDao.java
Normal file
@ -0,0 +1,38 @@
|
||||
package com.xkrs.microservice.dao;
|
||||
|
||||
import com.xkrs.microservice.model.entity.FileTemplateEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author dong
|
||||
* @date 2021/2/22
|
||||
*/
|
||||
public interface FileTemplateDao extends JpaRepository<FileTemplateEntity, Integer> {
|
||||
|
||||
/**
|
||||
* 根据文件名
|
||||
*
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
FileTemplateEntity findByFileName(String fileName);
|
||||
|
||||
/**
|
||||
* 根据md5
|
||||
*
|
||||
* @param md5
|
||||
* @return
|
||||
*/
|
||||
FileTemplateEntity findByMd5(String md5);
|
||||
|
||||
/**
|
||||
* 根据文件类型
|
||||
*
|
||||
* @param fileType
|
||||
* @return
|
||||
*/
|
||||
FileTemplateEntity findByFileType(String fileType);
|
||||
|
||||
|
||||
}
|
52
src/main/java/com/xkrs/microservice/dao/GridEntityDao.java
Normal file
52
src/main/java/com/xkrs/microservice/dao/GridEntityDao.java
Normal file
@ -0,0 +1,52 @@
|
||||
package com.xkrs.microservice.dao;
|
||||
|
||||
import com.xkrs.microservice.model.entity.ecology.remote.GridEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GridEntityDao extends JpaRepository<GridEntity, Integer>, JpaSpecificationExecutor<GridEntity> {
|
||||
|
||||
|
||||
@Query(value = "select distinct upper(satellite_sensor) from grid", nativeQuery = true)
|
||||
List<String> getSensor();
|
||||
|
||||
/**
|
||||
* 获取上传遥感数据的年份
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "SELECT DISTINCT year from grid", nativeQuery = true)
|
||||
List<String> getYear();
|
||||
|
||||
/**
|
||||
* 根据市行政区县代码获取id
|
||||
* @param cityCode
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id from (select * from grid where center_point_latitude is not null and center_point_latitude <> '' " +
|
||||
"and center_point_longtitude is not null and center_point_longtitude <> '') as xz where st_intersects((" +
|
||||
"select geom from shp_city where code = ?1) " +
|
||||
",st_setsrid(st_geometryfromtext(concat('point(', xz.center_point_longtitude, ' ', xz.center_point_latitude,')')),4326))", nativeQuery = true)
|
||||
List<Integer> getByCityCode(int cityCode);
|
||||
|
||||
/**
|
||||
* 根据区县行政区划获取id
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id from (select * from grid where center_point_latitude is not null and center_point_latitude <> '' and" +
|
||||
" center_point_longtitude is not null and center_point_longtitude <> '') as xz where st_intersects((" +
|
||||
"select geom from shp_county where code = ?1) " +
|
||||
",st_setsrid(st_geometryfromtext(concat('point(', xz.center_point_longtitude, ' ', xz.center_point_latitude,')')),4326))", nativeQuery = true)
|
||||
List<Integer> getByCountyCode(int code);
|
||||
|
||||
/**
|
||||
* 根据传感器获取id
|
||||
* @param satelliteList
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id from grid where upper(satellite_sensor) in ?1 and img_path is not null", nativeQuery = true)
|
||||
List<Integer> getBySatelliteSensor(List<String> satelliteList);
|
||||
}
|
33
src/main/java/com/xkrs/microservice/dao/OrderEntityDao.java
Normal file
33
src/main/java/com/xkrs/microservice/dao/OrderEntityDao.java
Normal file
@ -0,0 +1,33 @@
|
||||
package com.xkrs.microservice.dao;
|
||||
|
||||
import com.xkrs.microservice.model.entity.OrderEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2020/12/31
|
||||
*/
|
||||
public interface OrderEntityDao extends JpaRepository<OrderEntity, Integer> {
|
||||
|
||||
/**
|
||||
* 获取某人的订单
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id, audit, audit_id, date, del_flag, description, finished, order_code," +
|
||||
"url, username, file_id from orders where username = :username and del_flag = 0", nativeQuery = true)
|
||||
List<OrderEntity> selectByUsername(String username);
|
||||
|
||||
/**
|
||||
* 删除根据id
|
||||
* @param ids
|
||||
*/
|
||||
@Modifying
|
||||
@Query(value = "delete from orders where id in :ids ", nativeQuery = true)
|
||||
void delById(List<Integer> ids);
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.xkrs.microservice.dao;
|
||||
|
||||
import com.xkrs.microservice.model.entity.QuartzTriggerEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/4/18
|
||||
*/
|
||||
public interface QuartzTriggerDao extends JpaRepository<QuartzTriggerEntity, Integer> {
|
||||
|
||||
/**
|
||||
* 根据任务编号查找
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
QuartzTriggerEntity findByQuartzId(Integer id);
|
||||
}
|
33
src/main/java/com/xkrs/microservice/dao/ShpCityDao.java
Normal file
33
src/main/java/com/xkrs/microservice/dao/ShpCityDao.java
Normal file
@ -0,0 +1,33 @@
|
||||
package com.xkrs.microservice.dao;
|
||||
|
||||
import com.xkrs.microservice.model.entity.ShpCityEntity;
|
||||
import com.xkrs.microservice.model.vo.ShpCityVo;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ShpCityDao 表实体类
|
||||
* @author tajochen
|
||||
*/
|
||||
public interface ShpCityDao extends JpaRepository<ShpCityEntity,Integer> {
|
||||
|
||||
/**
|
||||
* 查找所有地级市
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * " +
|
||||
"from shp_city ", nativeQuery = true)
|
||||
List<ShpCityEntity> selectAllCity();
|
||||
|
||||
/**
|
||||
* 根据Name查找
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select code from shp_city where name = :name", nativeQuery = true)
|
||||
String findByName(String name);
|
||||
|
||||
}
|
43
src/main/java/com/xkrs/microservice/dao/ShpCountyDao.java
Normal file
43
src/main/java/com/xkrs/microservice/dao/ShpCountyDao.java
Normal file
@ -0,0 +1,43 @@
|
||||
package com.xkrs.microservice.dao;
|
||||
|
||||
import com.xkrs.microservice.model.entity.ShpCountyEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ShpCountyDao 表实体类
|
||||
* @author tajochen
|
||||
*/
|
||||
public interface ShpCountyDao extends JpaRepository<ShpCountyEntity,Integer> {
|
||||
|
||||
/**
|
||||
* 查找广东省所有区县
|
||||
* @return
|
||||
*/
|
||||
// @Query(value = "select new com.xkrs.microservice.model.vo.ShpCountyVo (county.id,county.code,county.name," +
|
||||
// "county.shpArea,county.center,city.code,city.name) " +
|
||||
// "from ShpCountyEntity county,ShpCityEntity city where county.code/100 = city.code")
|
||||
// List<ShpCountyVo> selectAllCounty();
|
||||
|
||||
@Query(value = "select id, name, pro_name, city_name, code, city_code, pro_code, shape_area, shp_area," +
|
||||
"center, geom, memo from shp_county where name = :name", nativeQuery = true)
|
||||
ShpCountyEntity findByName(String name);
|
||||
|
||||
/**
|
||||
* 查找所有县
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id, name, pro_name, city_name, code, city_code, pro_code, shape_area, shp_area," +
|
||||
"center, geom, memo from shp_county", nativeQuery = true)
|
||||
List<ShpCountyEntity> selectAllCounty();
|
||||
|
||||
/**
|
||||
* 根据编号查找
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from shp_county where code = ?1", nativeQuery = true)
|
||||
ShpCountyEntity selectByCode(Integer code);
|
||||
}
|
27
src/main/java/com/xkrs/microservice/dao/SysAuthorityDao.java
Normal file
27
src/main/java/com/xkrs/microservice/dao/SysAuthorityDao.java
Normal file
@ -0,0 +1,27 @@
|
||||
package com.xkrs.microservice.dao;
|
||||
|
||||
import com.xkrs.microservice.model.entity.SysAuthorityEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* SysAuthorityDao
|
||||
* @author tajochen
|
||||
*/
|
||||
public interface SysAuthorityDao extends JpaRepository<SysAuthorityEntity,Integer> {
|
||||
/**
|
||||
* 查询权限实体列表根据用户名 Object[]
|
||||
* @param userName 用户名
|
||||
* @return 用户实体
|
||||
*/
|
||||
@Query(value = "SELECT a.id, a.authority_name, a.authority_name_zh, a.authority_desc " +
|
||||
"FROM sys_authority a,rel_role_authority ra,sys_role r " +
|
||||
"WHERE r.id = ra.role_id AND ra.authority_id = a.id AND r.id " +
|
||||
"IN (SELECT r.id FROM sys_user u,sys_role r,rel_user_role ur " +
|
||||
" WHERE u.user_name = :userName AND u.id = ur.user_id AND ur.role_id = r.id)", nativeQuery = true)
|
||||
List<SysAuthorityEntity> selectByUserName(@Param("userName") String userName);
|
||||
}
|
61
src/main/java/com/xkrs/microservice/dao/SysRoleDao.java
Normal file
61
src/main/java/com/xkrs/microservice/dao/SysRoleDao.java
Normal file
@ -0,0 +1,61 @@
|
||||
package com.xkrs.microservice.dao;
|
||||
|
||||
import com.xkrs.microservice.model.entity.SysRoleEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* SysRoleDao
|
||||
* @author tajochen
|
||||
*/
|
||||
public interface SysRoleDao extends JpaRepository<SysRoleEntity,Integer> {
|
||||
|
||||
/**
|
||||
* 查询用户角色列表根据用户id
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "SELECT sys_role.id,sys_role.role_name,sys_role.role_name_zh,sys_role.role_desc " +
|
||||
"FROM sys_role,rel_user_role " +
|
||||
"WHERE sys_role.id = rel_user_role.role_id " +
|
||||
"AND rel_user_role.user_id = :id ", nativeQuery = true)
|
||||
List<SysRoleEntity> selectByUserId(@Param("id") Integer id);
|
||||
|
||||
/**
|
||||
* 查询用户角色列表根据用户名
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "SELECT sys_role.id,sys_role.role_name,sys_role.role_name_zh,sys_role.role_desc " +
|
||||
"FROM sys_role.ID = rel_user_role.role_id " +
|
||||
"WHERE rel_user_role.user_id = sys_user.id " +
|
||||
"AND rel_user_role.user_id = sys_user.id " +
|
||||
"AND sys_user.user_name = :userName ", nativeQuery = true)
|
||||
List<SysRoleEntity> selectByUserName(@Param("userName") String userName);
|
||||
|
||||
|
||||
// /**
|
||||
// * 根据用户名修改用户角色
|
||||
// */
|
||||
// @Modifying
|
||||
// @Query(value = "UPDATE sys_user SET last_entry_time = now(), last_entry_ip = :ipAddress " +
|
||||
// "WHERE user_name = :userName ;", nativeQuery = true)
|
||||
// int updateUserRoleByUserName(@Param("userName") String userName);
|
||||
|
||||
/**
|
||||
* 添加用户角色根据用户名和角色名
|
||||
* @param userName
|
||||
* @param roleName
|
||||
* @return
|
||||
*/
|
||||
@Modifying
|
||||
@Query(value = "INSERT INTO rel_user_role (id,role_id, user_id) " +
|
||||
"SELECT nextval('rel_user_role_seq'),sys_role.ID,sys_user.ID FROM sys_role,sys_user " +
|
||||
"WHERE sys_role.role_name = :roleName AND sys_user.user_name = :userName ", nativeQuery = true)
|
||||
int insertRelUserRole(@Param("userName") String userName,@Param("roleName") String roleName);
|
||||
}
|
117
src/main/java/com/xkrs/microservice/dao/SysUserDao.java
Normal file
117
src/main/java/com/xkrs/microservice/dao/SysUserDao.java
Normal file
@ -0,0 +1,117 @@
|
||||
package com.xkrs.microservice.dao;
|
||||
|
||||
import com.xkrs.microservice.model.entity.auth.SysUserEntity;
|
||||
import com.xkrs.microservice.model.vo.SysUserVo;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* SysUserDao
|
||||
* @author tajochen
|
||||
*/
|
||||
public interface SysUserDao extends JpaRepository<SysUserEntity, String>, JpaSpecificationExecutor<SysUserEntity> {
|
||||
|
||||
/**
|
||||
* 检查系统用户名是否存在
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "SELECT COUNT(*) FROM sys_user WHERE user_name = :userName", nativeQuery = true)
|
||||
int checkUserName(@Param("userName") String userName);
|
||||
|
||||
/**
|
||||
* 查找用户实体根据用户名
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "SELECT * FROM sys_user WHERE upper(user_name) = upper(:userName)", nativeQuery = true)
|
||||
SysUserEntity selectByUserName(@Param("userName") String userName);
|
||||
|
||||
/**
|
||||
* 查找用户实体根据真实姓名
|
||||
* @param realName
|
||||
* @return
|
||||
*/
|
||||
SysUserEntity findByRealName(String realName);
|
||||
/**
|
||||
* 更新用户登录信息
|
||||
* @param userName
|
||||
* @param ipAddress
|
||||
* @return
|
||||
*/
|
||||
@Modifying
|
||||
@Query(value = "UPDATE sys_user SET last_entry_time = now(), last_entry_ip = :ipAddress " +
|
||||
"WHERE user_name = :userName ;", nativeQuery = true)
|
||||
int updateSysUserLogin(@Param("userName") String userName,@Param("ipAddress") String ipAddress);
|
||||
|
||||
/**
|
||||
* 软删除系统用户根据用户名
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
@Modifying
|
||||
@Query(value = "UPDATE sys_user SET delete_flag = 1 " +
|
||||
"WHERE user_name = :userName ;", nativeQuery = true)
|
||||
int softDeleteSysUserByUserName(@Param("userName") String userName);
|
||||
|
||||
/**
|
||||
* 软删除系统用户根据id
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Modifying
|
||||
@Query(value = "UPDATE sys_user SET delete_flag = 1 WHERE id = :id ;", nativeQuery = true)
|
||||
int softDeleteGeneralUserById(@Param("id") String id);
|
||||
|
||||
/**
|
||||
* 删除系统用户(危险操作!)
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
@Modifying
|
||||
@Query(value = "DELETE FROM sys_user WHERE user_name = :userName ;", nativeQuery = true)
|
||||
int deleteSysUser(@Param("userName") String userName);
|
||||
|
||||
/**
|
||||
* 获取所有存在的系统用户Vo
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select new com.xkrs.microservice.model.vo.SysUserVo (u.id, u.userName, u.nickName, u.userCode, " +
|
||||
"u.sex, u.telephone, u.email, u.admCode, u.address,u.birthday,u.signature, u.portraitId," +
|
||||
"u.statusCode,u.addTime,u.lastEntryTime,u.lastEntryIp) from SysUserEntity u ,RoleEntity r," +
|
||||
"UserRoleEntity u_r " +
|
||||
"WHERE u.deleteFlag = 0 AND u.activeFlag = 0 AND r.id = u_r.roleId AND u.id = u_r.userId")
|
||||
List<SysUserVo> selectAllSysUser();
|
||||
|
||||
/**
|
||||
* 获取所有存在的系统用户Vo
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select new com.xkrs.microservice.model.vo.SysUserVo (u.id, u.userName, " +
|
||||
"u.sex, u.telephone, u.email, u.address,u.cityName, u.cityCode, u.countyName, u.countyCode, u.birthday," +
|
||||
" u.addTime,u.realName) from SysUserEntity u " +
|
||||
"WHERE u.deleteFlag = 0 AND u.activeFlag = 0")
|
||||
List<SysUserVo> selectAllUser();
|
||||
|
||||
@Query(value = "select user_name from sys_user where city_code = (select city_code from sys_user where user_name = ?1)", nativeQuery = true)
|
||||
List<String> getUserBySameCity(String username);
|
||||
|
||||
/**
|
||||
* 获取有效用户数
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select count(id) from sys_user where delete_flag = 0 AND active_flag = 0", nativeQuery = true)
|
||||
Integer findVaildUserNum();
|
||||
|
||||
/**
|
||||
* 根据手机号查找
|
||||
* @param tel
|
||||
* @return
|
||||
*/
|
||||
SysUserEntity findByTelephone(String tel);
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.AnalysisEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/4/7
|
||||
*/
|
||||
public interface AnalysisDao extends JpaRepository<AnalysisEntity, Integer> {
|
||||
|
||||
/**
|
||||
* 获取某点的数据
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from analysis where year in (select max(year) as year " +
|
||||
" from analysis GROUP BY year order by year desc limit 5)",nativeQuery = true)
|
||||
List<AnalysisEntity> findBy5Year();
|
||||
|
||||
/**
|
||||
* 获取某年的数据
|
||||
* @param startYear
|
||||
* @param endYear
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from analysis where year >= ?1 and year <= ?2",nativeQuery = true)
|
||||
List<AnalysisEntity> findByYear(String startYear, String endYear );
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取某年的数据
|
||||
* @param year
|
||||
* @return
|
||||
*/
|
||||
List<AnalysisEntity> findByYear(String year);
|
||||
|
||||
/**
|
||||
* 获取某点的数据
|
||||
* @param point
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from analysis where point like concat('%', ?1, '%') ", nativeQuery = true)
|
||||
List<AnalysisEntity> findByPoint(String point);
|
||||
|
||||
/**
|
||||
* 获取某点的数据
|
||||
* @param point
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from analysis where year in (select max(year) as year " +
|
||||
" from analysis GROUP BY year order by year desc limit 5) and point like concat('%', ?1, '%') ",nativeQuery = true)
|
||||
List<AnalysisEntity> findByPointNear5Year(String point);
|
||||
|
||||
/**
|
||||
* 根据点位和年份获得
|
||||
* @param startYear
|
||||
* @param endYear
|
||||
* @param point
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from analysis where year >= ?1 and year <= ?2 and point like concat('%', ?3, '%') ",nativeQuery = true)
|
||||
List<AnalysisEntity> findByYearAndPoint(String startYear, String endYear, String point);
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.HydrobiontSummaryEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.LakeEvaluateEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/2
|
||||
*/
|
||||
public interface HydrobiontSummaryDao extends JpaRepository<HydrobiontSummaryEntity, Integer> {
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
List<HydrobiontSummaryEntity> findByFileName(String fileName);
|
||||
}
|
28
src/main/java/com/xkrs/microservice/dao/aquatic/ImgDao.java
Normal file
28
src/main/java/com/xkrs/microservice/dao/aquatic/ImgDao.java
Normal file
@ -0,0 +1,28 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.ImgEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/4/6
|
||||
*/
|
||||
public interface ImgDao extends JpaRepository<ImgEntity, Integer> {
|
||||
|
||||
/**
|
||||
* 根据MD5查找
|
||||
* @param md5
|
||||
* @return
|
||||
*/
|
||||
List<ImgEntity> findByMd5(String md5);
|
||||
|
||||
/**
|
||||
* 根据外键查找
|
||||
* @param fileType
|
||||
* @param fileId
|
||||
* @return
|
||||
*/
|
||||
List<ImgEntity> findByFileTypeAndFileId(Integer fileType, Integer fileId);
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.xkrs.microservice.model.entity.aquatic.LakeEvaluateEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.LakeSurveyEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/2
|
||||
*/
|
||||
public interface LakeEvaluateDao extends JpaRepository<LakeEvaluateEntity, Integer> {
|
||||
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
List<LakeEvaluateEntity> findByFileName(String fileName);
|
||||
|
||||
/**
|
||||
* 根据
|
||||
* @param lakeName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from lake_evaluate as l where l.lake_name like concat('%', ?1, '%')", nativeQuery = true)
|
||||
List<LakeEvaluateEntity> findByLakeNameLike(String lakeName);
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.LakeEvaluateformEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.LakeSurveyEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* author zang
|
||||
* date 2022/8/27
|
||||
*/
|
||||
|
||||
public interface LakeEvaluateformDao extends JpaRepository<LakeEvaluateformEntity, Integer>, JpaSpecificationExecutor<LakeEvaluateformEntity> {
|
||||
|
||||
|
||||
List<LakeEvaluateformEntity> findByFileName(String fileName);
|
||||
|
||||
|
||||
@Query(value = "select distinct point_number from lake_evaluateform", nativeQuery = true)
|
||||
List<String> getPoint();
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.LakeEvaluateEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.LakeSurveyEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/2
|
||||
*/
|
||||
public interface LakeSurveyDao extends JpaRepository<LakeSurveyEntity, Integer>, JpaSpecificationExecutor<LakeSurveyEntity> {
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
List<LakeSurveyEntity> findByFileName(String fileName);
|
||||
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id from lake_survey where file_name = ?1 order by id desc limit 1", nativeQuery = true)
|
||||
Integer findByFileNameNewest(String fileName);
|
||||
|
||||
/**
|
||||
* 根据
|
||||
* @param lakeName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from lake_survey as l where l.lake_name like concat('%', ?1, '%')", nativeQuery = true)
|
||||
List<LakeSurveyEntity> findByLakeNameLike(String lakeName);
|
||||
|
||||
/**
|
||||
* 获得点位信息
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select distinct point_number from lake_survey", nativeQuery = true)
|
||||
List<String> getPoint();
|
||||
|
||||
/**
|
||||
* 获取地市信息
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select prefecture_level_city from lake_survey",nativeQuery = true)
|
||||
List<String> getPrefectureLevelCity();
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.PhytoplanktonCountEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/3
|
||||
*/
|
||||
public interface PhytoplanktonCountDao extends JpaRepository<PhytoplanktonCountEntity, Integer>, JpaSpecificationExecutor<PhytoplanktonCountEntity> {
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
List<PhytoplanktonCountEntity> findByFileName(String fileName);
|
||||
|
||||
/**
|
||||
* 获取点位信息
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select distinct points from phytoplankton_count", nativeQuery = true)
|
||||
List<String> getPointName();
|
||||
|
||||
/**
|
||||
* 获取最新文档
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from phytoplankton_count where sampling_time = (select sampling_time from phytoplankton_count" +
|
||||
" order by sampling_time desc limit 1)",nativeQuery = true)
|
||||
List<PhytoplanktonCountEntity> findNewest();
|
||||
|
||||
/**
|
||||
* 获取最新文档
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from phytoplankton_count where file_name in (select f.file_name from file_document as f where f.audit = 1 and f.file_type = 16) " +
|
||||
" and left(sampling_time, 4) >= ?1 ",nativeQuery = true)
|
||||
List<PhytoplanktonCountEntity> findNewest5Year(String year);
|
||||
|
||||
/**
|
||||
* 获取最新文档
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from phytoplankton_count where file_name in (select f.file_name from file_document as f where f.audit = 1 and f.file_type = 16)" +
|
||||
" and sampling_time in (select max(sampling_time) as sampling_time " +
|
||||
" from phytoplankton_count GROUP BY left(sampling_time, 4) order by left(sampling_time, 4)) and points like concat('%', ?1, '%')", nativeQuery = true)
|
||||
List<PhytoplanktonCountEntity> findByPoint(String point);
|
||||
|
||||
/**
|
||||
* 获取最新文档
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from phytoplankton_count where file_name in (select f.file_name from file_document as f where f.audit = 1 and f.file_type = 16)" +
|
||||
"and sampling_time in (select max(sampling_time) as sampling_time " +
|
||||
" from phytoplankton_count GROUP BY left(sampling_time, 4)) and left(sampling_time, 4) >= ?1 and left(sampling_time, 4) <= ?2 ", nativeQuery = true)
|
||||
List<PhytoplanktonCountEntity> findByYear(String startYear, String endYear);
|
||||
|
||||
/**
|
||||
* 获取最新文档
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from phytoplankton_count where file_name in (select f.file_name from file_document as f where f.audit = 1 and f.file_type = 16)" +
|
||||
" and sampling_time in (select max(sampling_time) as sampling_time " +
|
||||
" from phytoplankton_count GROUP BY left(sampling_time, 4)) and left(sampling_time, 4) >= ?1 and left(sampling_time, 4) <= ?2 and points like concat('%', ?3, '%')", nativeQuery = true)
|
||||
List<PhytoplanktonCountEntity> findByYearAndPoints(String startYear, String endYear, String point);
|
||||
|
||||
/**
|
||||
* 获取最新文档
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from phytoplankton_count where file_name in (select f.file_name from file_document as f where f.audit = 1 and f.file_type = 16)" +
|
||||
"and sampling_time in (select max(sampling_time) as sampling_time " +
|
||||
" from phytoplankton_count GROUP BY left(sampling_time, 4)) ", nativeQuery = true)
|
||||
List<PhytoplanktonCountEntity> findAllPas();
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.PhytoplanktonDatabaseEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.PhytoplanktonGatherEntity;
|
||||
import com.xkrs.microservice.model.vo.DatabaseVo;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/3
|
||||
*/
|
||||
public interface PhytoplanktonDatabaseDao extends JpaRepository<PhytoplanktonDatabaseEntity, Integer> {
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
List<PhytoplanktonDatabaseEntity> findByFileName(String fileName);
|
||||
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id from phytoplankton_database where file_name = ?1 order by id desc limit 1", nativeQuery = true)
|
||||
Integer findByFileNameNewest(String fileName);
|
||||
|
||||
/**
|
||||
* 根据物种名称查询
|
||||
* @param nameOfPhytoplankton
|
||||
* @return
|
||||
*/
|
||||
PhytoplanktonDatabaseEntity findByNameOfPhytoplankton(String nameOfPhytoplankton);
|
||||
|
||||
/**
|
||||
* 根据物种名称查询
|
||||
* @param nameOfPhytoplankton
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select new com.xkrs.microservice.model.vo.DatabaseVo" +
|
||||
"(pp.id, pp.fileName, pp.nameOfPhytoplankton, pp.latinName, pp.species, pp.picture, pp.remarks, pp.imgId, pp.phylum, pp.family, pp.genus, " +
|
||||
"pp.phylumLatin, pp.familyLatin, pp.genusLatin)" +
|
||||
" from PhytoplanktonDatabaseEntity as pp where pp.nameOfPhytoplankton like concat('%', ?1, '%')")
|
||||
List<DatabaseVo> findByName(String nameOfPhytoplankton);
|
||||
|
||||
/**
|
||||
* 获取种群名
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select distinct name_of_phytoplankton, latin_name from phytoplankton_database", nativeQuery = true)
|
||||
List<String> getName();
|
||||
|
||||
@Query(value = "select new com.xkrs.microservice.model.vo.DatabaseVo" +
|
||||
"(pp.id, pp.fileName, pp.nameOfPhytoplankton, pp.latinName, pp.species, pp.picture, pp.remarks, pp.imgId, pp.phylum, pp.family, pp.genus, " +
|
||||
"pp.phylumLatin, pp.familyLatin, pp.genusLatin)" +
|
||||
" from PhytoplanktonDatabaseEntity as pp")
|
||||
List<DatabaseVo> getAll();
|
||||
|
||||
|
||||
@Modifying
|
||||
void deleteByIdIn(List<Integer> ids);
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.LakeSurveyEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.PhytoplanktonGatherEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/3
|
||||
*/
|
||||
public interface PhytoplanktonGatherDao extends JpaRepository<PhytoplanktonGatherEntity, Integer> {
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
List<PhytoplanktonGatherEntity> findByFileName(String fileName);
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.PhytoplanktonGatherEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.PhytoplanktonMonitorEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/3
|
||||
*/
|
||||
public interface PhytoplanktonMonitorDao extends JpaRepository<PhytoplanktonMonitorEntity, Integer> {
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
List<PhytoplanktonMonitorEntity> findByFileName(String fileName);
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverInvolvedEvaluateEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverInvolvedSurveyEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/1
|
||||
*/
|
||||
public interface RiverInvolvedEvaluateDao extends JpaRepository<RiverInvolvedEvaluateEntity, Integer> {
|
||||
List<RiverInvolvedEvaluateEntity> findByFileName(String fileName);
|
||||
|
||||
/**
|
||||
* 根据河流名称查询
|
||||
* @param riverName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from river_involved_evaluate as r where river_name like concat('%', ?1, '%')", nativeQuery = true)
|
||||
List<RiverInvolvedEvaluateEntity> findByRiverNameLike(String riverName);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverInvolvedEvaluateformEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* author zang
|
||||
* date 2022/8/25
|
||||
*/
|
||||
public interface RiverInvolvedEvaluateformDao extends JpaRepository<RiverInvolvedEvaluateformEntity, Integer>, JpaSpecificationExecutor<RiverInvolvedEvaluateformEntity> {
|
||||
List<RiverInvolvedEvaluateformEntity> findByFileName(String id);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverInvolvedEvaluateEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverInvolvedSurveyEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverNotInvolvedEvaluateEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverNotInvolvedSurveyEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/2/27
|
||||
*/
|
||||
public interface RiverInvolvedSurveyDao extends JpaRepository<RiverInvolvedSurveyEntity, Integer>, JpaSpecificationExecutor<RiverInvolvedSurveyEntity> {
|
||||
List<RiverInvolvedSurveyEntity> findByFileName(String fileName);
|
||||
|
||||
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id from river_involved_survey where file_name = ?1 order by id desc limit 1", nativeQuery = true)
|
||||
Integer findByFileNameNewest(String fileName);
|
||||
|
||||
/**
|
||||
* 根据河流名称查询
|
||||
* @param riverName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from river_involved_survey as r where river_name like concat('%', ?1, '%')", nativeQuery = true)
|
||||
List<RiverInvolvedSurveyEntity> findByRiverNameLike(String riverName);
|
||||
|
||||
/**
|
||||
* 点位信息
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select distinct point from river_involved_survey", nativeQuery = true)
|
||||
List<String> getPoint();
|
||||
|
||||
/**
|
||||
* 河流信息
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select distinct river_name from river_involved_survey", nativeQuery = true)
|
||||
List<String> getRiver();
|
||||
|
||||
/**
|
||||
* 地市信息
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select prefecture_level_city from river_involved_survey", nativeQuery = true)
|
||||
List<String> getPrefectureLevelCity();
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverLakeEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/6
|
||||
*/
|
||||
public interface RiverLakeDao extends JpaRepository<RiverLakeEntity, String> {
|
||||
|
||||
/**
|
||||
* 根据河流或湖库名查找
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from river_lake as rl where rl.name like concat('%', ?1, '%')", nativeQuery = true)
|
||||
List<RiverLakeEntity> findByName(String name);
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverInvolvedSurveyEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverNotInvolvedEvaluateEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/2/25
|
||||
*/
|
||||
public interface RiverNotInvolvedDao extends JpaRepository<RiverNotInvolvedEvaluateEntity, Integer> {
|
||||
List<RiverNotInvolvedEvaluateEntity> findByFileName(String fileName);
|
||||
|
||||
/**
|
||||
* 根据河流名称查询
|
||||
* @param riverName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from river_not_involved_evaluate as r where river_name like concat('%', ?1, '%')", nativeQuery = true)
|
||||
List<RiverNotInvolvedEvaluateEntity> findByRiverNameLike(String riverName);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverNotInvolvedEvaluateformEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
/**
|
||||
* author zang
|
||||
* date 2022/8/27
|
||||
*/
|
||||
public interface RiverNotInvolvedEvaluateformDao extends JpaRepository<RiverNotInvolvedEvaluateformEntity, Integer>, JpaSpecificationExecutor<RiverNotInvolvedEvaluateformEntity> {
|
||||
List<RiverNotInvolvedEvaluateformEntity> findByFileName(String fileName);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverNotInvolvedEvaluateEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverNotInvolvedSurveyEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/2/27
|
||||
*/
|
||||
public interface RiverNotInvolvedSurveyDao extends JpaRepository<RiverNotInvolvedSurveyEntity, Integer>, JpaSpecificationExecutor<RiverNotInvolvedSurveyEntity> {
|
||||
List<RiverNotInvolvedSurveyEntity> findByFileName(String fileName);
|
||||
|
||||
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id from river_not_involved_survey where file_name = ?1 order by id desc limit 1", nativeQuery = true)
|
||||
Integer findByFileNameNewest(String fileName);
|
||||
/**
|
||||
* 根据河流名称查询
|
||||
* @param riverName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from river_not_involved_survey as r where river_name like concat('%', ?1, '%')", nativeQuery = true)
|
||||
List<RiverNotInvolvedSurveyEntity> findByRiverNameLike(String riverName);
|
||||
|
||||
@Query(value = "select distinct point from river_not_involved_survey", nativeQuery = true)
|
||||
List<String> getPoint();
|
||||
|
||||
@Query(value = "select distinct river_name from river_not_involved_survey", nativeQuery = true)
|
||||
List<String> getRiver();
|
||||
|
||||
/**
|
||||
* 获取地市信息
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select prefecture_level_city from river_not_involved_survey", nativeQuery = true)
|
||||
List<String> getPrefectureLevelCity();
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.SpeciesDicEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wudong
|
||||
* @date 2021/7/3 15:41
|
||||
*/
|
||||
public interface SpeciesDicDao extends JpaRepository<SpeciesDicEntity, Integer> {
|
||||
|
||||
|
||||
/**
|
||||
* 根据物种名模糊查找
|
||||
* @param race
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from species_dic where id in (select min(id) from species_dic where race_cn like concat('%', ?1, '%') group by race_cn);", nativeQuery = true)
|
||||
List<SpeciesDicEntity> getByRace(String race);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.SpeciesTimeEntity;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/11
|
||||
*/
|
||||
public interface SpeciesTimeDao extends JpaRepository<SpeciesTimeEntity, Integer>, JpaSpecificationExecutor<SpeciesTimeEntity> {
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverNotInvolvedEvaluateEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverNotInvolvedEvaluateformEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.WaterQualityDataSheetForQualityMonitoring;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
/**
|
||||
* author zang
|
||||
* date 2022/8/27
|
||||
*/
|
||||
public interface WaterQualityDataSheetForQualityMonitoringDao extends JpaRepository<WaterQualityDataSheetForQualityMonitoring, Integer>, JpaSpecificationExecutor<WaterQualityDataSheetForQualityMonitoring> {
|
||||
List<WaterQualityDataSheetForQualityMonitoring> findByFileName(String fileName);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.ZoobenthosCountEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/8
|
||||
*/
|
||||
public interface ZoobenthosCountDao extends JpaRepository<ZoobenthosCountEntity, Integer>, JpaSpecificationExecutor<ZoobenthosCountEntity> {
|
||||
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
List<ZoobenthosCountEntity> findByFileName(String fileName);
|
||||
|
||||
/**
|
||||
* 获取呆腻味信息
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select distinct points from zoobenthos_count", nativeQuery = true)
|
||||
List<String> getPoint();
|
||||
|
||||
|
||||
/**
|
||||
* 获取最新文档
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from zoobenthos_count where sampling_date = (select sampling_date from zoobenthos_count" +
|
||||
" order by sampling_date desc limit 1)",nativeQuery = true)
|
||||
List<ZoobenthosCountEntity> findNewest();
|
||||
|
||||
/**
|
||||
* 获取最新文档
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from zoobenthos_count where file_name in (select f.file_name from file_document as f where f.audit = 1 and f.file_type = 18)" +
|
||||
" and left(sampling_date, 4) >= ?1",nativeQuery = true)
|
||||
List<ZoobenthosCountEntity> findNewest5Year(String year);
|
||||
|
||||
/**
|
||||
* 获取最新文档
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from zoobenthos_count where file_name in (select f.file_name from file_document as f where f.audit = 1 and f.file_type = 18)" +
|
||||
" and sampling_date in (select max(sampling_date) as sampling_date " +
|
||||
" from zoobenthos_count GROUP BY left(sampling_date, 4)) and points like concat('%', ?1, '%')", nativeQuery = true)
|
||||
List<ZoobenthosCountEntity> findByPoint(String point);
|
||||
|
||||
/**
|
||||
* 获取最新文档
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from zoobenthos_count where file_name in (select f.file_name from file_document as f where f.audit = 1 and f.file_type = 18) " +
|
||||
" and sampling_date in (select max(sampling_date) as sampling_date " +
|
||||
" from zoobenthos_count GROUP BY left(sampling_date, 4)) and left(sampling_date, 4) >= ?1 and left(sampling_date, 4) <= ?2 ", nativeQuery = true)
|
||||
List<ZoobenthosCountEntity> findByYear(String startYear, String endYear);
|
||||
|
||||
/**
|
||||
* 获取最新文档
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from zoobenthos_count where file_name in (select f.file_name from file_document as f where f.audit = 1 and f.file_type = 18) " +
|
||||
" and sampling_date in (select max(sampling_date) as sampling_date " +
|
||||
" from zoobenthos_count GROUP BY left(sampling_date, 4)) and left(sampling_date, 4) >= ?1 and left(sampling_date, 4) <= ?2 and points like concat('%', ?3, '%')", nativeQuery = true)
|
||||
List<ZoobenthosCountEntity> findByYearAndPoints(String startYear, String endYear, String point);
|
||||
|
||||
@Query(value = "select * from zoobenthos_count where file_name in (select f.file_name from file_document as f where f.audit = 1 and f.file_type = 18) " +
|
||||
"and sampling_date in (select max(sampling_date) as sampling_date " +
|
||||
" from zoobenthos_count GROUP BY left(sampling_date, 4)) ", nativeQuery = true)
|
||||
List<ZoobenthosCountEntity> findAllPass();
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.ZoobenthosDatabaseEntity;
|
||||
import com.xkrs.microservice.model.vo.DatabaseVo;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/8
|
||||
*/
|
||||
public interface ZoobenthosDataBaseDao extends JpaRepository<ZoobenthosDatabaseEntity, Integer> {
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
List<ZoobenthosDatabaseEntity> findByFileName(String fileName);
|
||||
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id from zoobenthos_database where file_name = ?1 order by id desc limit 1", nativeQuery = true)
|
||||
Integer findByFileNameNewest(String fileName);
|
||||
|
||||
/**
|
||||
* 获取拉丁名及中文名
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select distinct name_of_zoobenthos, latin_name from zoobenthos_database", nativeQuery = true)
|
||||
List<String> getName();
|
||||
|
||||
/**
|
||||
* 根据物种名查询
|
||||
* @param nameOfZoobenthos
|
||||
* @return
|
||||
*/
|
||||
ZoobenthosDatabaseEntity findByNameOfZoobenthos(String nameOfZoobenthos);
|
||||
|
||||
/**
|
||||
* 根据物种名查询
|
||||
* @param nameOfZoobenthos
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select new com.xkrs.microservice.model.vo.DatabaseVo" +
|
||||
"(pp.id, pp.fileName, pp.nameOfZoobenthos, pp.latinName, pp.species, pp.picture, pp.remarks, pp.imgId, pp.phylum, pp.family, pp.genus," +
|
||||
" pp.phylumLatin, pp.familyLatin, pp.genusLatin)" +
|
||||
" from ZoobenthosDatabaseEntity as pp where pp.nameOfZoobenthos like concat('%', ?1, '%') ")
|
||||
List<DatabaseVo> findByName(String nameOfZoobenthos);
|
||||
|
||||
@Query(value = "select new com.xkrs.microservice.model.vo.DatabaseVo" +
|
||||
"(pp.id, pp.fileName, pp.nameOfZoobenthos, pp.latinName, pp.species, pp.picture, pp.remarks, pp.imgId, pp.phylum, pp.family, pp.genus" +
|
||||
", pp.phylumLatin, pp.familyLatin, pp.genusLatin)" +
|
||||
" from ZoobenthosDatabaseEntity as pp")
|
||||
List<DatabaseVo> getAll();
|
||||
|
||||
@Modifying
|
||||
void deleteByIdIn(List<Integer> ids);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.ZoobenthosCountEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.ZoobenthosGatherEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/8
|
||||
*/
|
||||
public interface ZoobenthosGatherDao extends JpaRepository<ZoobenthosGatherEntity, Integer> {
|
||||
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
List<ZoobenthosGatherEntity> findByFileName(String fileName);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.ZoobenthosMonitorEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.ZooplanktonCountEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/8
|
||||
*/
|
||||
public interface ZoobenthosMonitorDao extends JpaRepository<ZoobenthosMonitorEntity, Integer> {
|
||||
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
List<ZoobenthosMonitorEntity> findByFileName(String fileName);
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.ZoobenthosCountEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.ZooplanktonCountEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/8
|
||||
*/
|
||||
public interface ZooplanktonCountDao extends JpaRepository<ZooplanktonCountEntity, Integer>, JpaSpecificationExecutor<ZooplanktonCountEntity> {
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
List<ZooplanktonCountEntity> findByFileName(String fileName);
|
||||
|
||||
@Query(value = "select distinct points from zooplankton_count", nativeQuery = true)
|
||||
List<String> getPoint();
|
||||
|
||||
/**
|
||||
* 获取最新文档
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from zooplankton_count where file_name in (select f.file_name from file_document as f where f.audit = 1 and f.file_type = 23) and " +
|
||||
"sampling_date = (select sampling_date from zooplankton_count" +
|
||||
" order by sampling_date desc limit 1)",nativeQuery = true)
|
||||
List<ZooplanktonCountEntity> findNewest();
|
||||
|
||||
|
||||
/**
|
||||
* 获取最新文档
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from zooplankton_count where file_name in (select f.file_name from file_document as f where f.audit = 1 and f.file_type = 23) and" +
|
||||
" sampling_date >= ?1",nativeQuery = true)
|
||||
List<ZooplanktonCountEntity> findNewest5Year(String year);
|
||||
|
||||
/**
|
||||
* 获取最新文档
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from zooplankton_count where file_name in (select f.file_name from file_document as f where f.audit = 1 and f.file_type = 23) and" +
|
||||
"sampling_date in (select max(sampling_date) as sampling_date " +
|
||||
" from zooplankton_count GROUP BY left(sampling_date, 4)) and points = like concat('%', ?1, '%')", nativeQuery = true)
|
||||
List<ZooplanktonCountEntity> findByPoint(String point);
|
||||
|
||||
/**
|
||||
* 获取最新文档
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from zooplankton_count where file_name in (select f.file_name from file_document as f where f.audit = 1 and f.file_type = 23) and" +
|
||||
" left(sampling_date, 4) >= ?1 and left(sampling_date, 4) <= ?2 and sampling_date in (select max(sampling_date) as sampling_date " +
|
||||
" from zooplankton_count GROUP BY left(sampling_date, 4))", nativeQuery = true)
|
||||
List<ZooplanktonCountEntity> findByYear(String startYear, String endYear);
|
||||
|
||||
/**
|
||||
* 获取最新文档
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from zooplankton_count where file_name in (select f.file_name from file_document as f where f.audit = 1 and f.file_type = 23) and" +
|
||||
" sampling_date in (select max(sampling_date) as sampling_date " +
|
||||
" from zooplankton_count GROUP BY left(sampling_date, 4)) and left(sampling_date, 4) >= ?1 and left(sampling_date, 4) <= ?2 and points like concat('%', ?3, '%')", nativeQuery = true)
|
||||
List<ZooplanktonCountEntity> findByYearAndPoints(String startYear, String endYear, String point);
|
||||
|
||||
|
||||
|
||||
@Query(value = "select * from zooplankton_count where file_name in (select f.file_name from file_document as f where f.audit = 1 and f.file_type = 23) " +
|
||||
"and sampling_date in (select max(sampling_date) as sampling_date " +
|
||||
" from zooplankton_count GROUP BY left(sampling_date, 4)) ", nativeQuery = true)
|
||||
List<ZooplanktonCountEntity> findAllPass();
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.ZooplanktonDatabaseEntity;
|
||||
import com.xkrs.microservice.model.vo.DatabaseVo;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/8
|
||||
*/
|
||||
public interface ZooplanktonDatabaseDao extends JpaRepository<ZooplanktonDatabaseEntity, Integer> {
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
List<ZooplanktonDatabaseEntity> findByFileName(String fileName);
|
||||
/**
|
||||
* 根据文件名查找
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id from zooplankton_database where file_name = ?1 order by id desc limit 1", nativeQuery = true)
|
||||
Integer findByFileNameNewest(String fileName);
|
||||
|
||||
/**
|
||||
* 中——拉丁
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select distinct name_of_zooplankton, latin_name from zooplankton_database", nativeQuery = true)
|
||||
List<String> getName();
|
||||
|
||||
/**
|
||||
* 根据物种名查询
|
||||
* @param nameOfZooplankton
|
||||
* @return
|
||||
*/
|
||||
ZooplanktonDatabaseEntity findByNameOfZooplankton(String nameOfZooplankton);
|
||||
|
||||
/**
|
||||
* 根据物种名查询
|
||||
* @param nameOfZooplankton
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select new com.xkrs.microservice.model.vo.DatabaseVo" +
|
||||
"(pp.id, pp.fileName, pp.nameOfZooplankton, pp.latinName, pp.species, pp.picture, pp.remarks, pp.imgId, pp.phylum, pp.family, pp.genus, " +
|
||||
"pp.phylumLatin, pp.familyLatin, pp.genusLatin)" +
|
||||
" from ZooplanktonDatabaseEntity as pp where pp.nameOfZooplankton like concat('%', ?1, '%')")
|
||||
List<DatabaseVo> findByName(String nameOfZooplankton);
|
||||
|
||||
@Query(value = "select new com.xkrs.microservice.model.vo.DatabaseVo" +
|
||||
"(pp.id, pp.fileName, pp.nameOfZooplankton, pp.latinName, pp.species, pp.picture, pp.remarks, pp.imgId, pp.phylum, pp.family, pp.genus" +
|
||||
", pp.phylumLatin, pp.familyLatin, pp.genusLatin)" +
|
||||
" from ZooplanktonDatabaseEntity as pp")
|
||||
List<DatabaseVo> getAll();
|
||||
|
||||
|
||||
@Modifying
|
||||
void deleteByIdIn(List<Integer> ids);
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.RiverNotInvolvedSurveyEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.ZooplanktonGatherEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/3
|
||||
*/
|
||||
public interface ZooplanktonGatherDao extends JpaRepository<ZooplanktonGatherEntity, Integer> {
|
||||
List<ZooplanktonGatherEntity> findByFileName(String fileName);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.xkrs.microservice.dao.aquatic;
|
||||
|
||||
import com.xkrs.microservice.model.entity.aquatic.ZoobenthosMonitorEntity;
|
||||
import com.xkrs.microservice.model.entity.aquatic.ZooplanktonMonitorEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/3/8
|
||||
*/
|
||||
public interface ZooplanktonMonitorDao extends JpaRepository<ZooplanktonMonitorEntity, Integer> {
|
||||
|
||||
List<ZooplanktonMonitorEntity> findByFileName(String fileName);
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.xkrs.microservice.dao.auth;
|
||||
|
||||
import com.xkrs.microservice.model.entity.auth.MenuActionEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/4/22
|
||||
*/
|
||||
public interface MenuActionDao extends JpaRepository<MenuActionEntity, String> {
|
||||
|
||||
/**
|
||||
* 根据角色id查询
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id, system_sign, menu_id, auth_code, action_url, action_name from pt_st_menu_action where id in " +
|
||||
"(select menu_action_id from pt_gx_role_menu_action where role_id = ?1 and status_id = '1') and status_id = '1'", nativeQuery = true)
|
||||
List<MenuActionEntity> findByRoleId(String roleId);
|
||||
|
||||
/**
|
||||
* 根据角色id查询
|
||||
* @param roleName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id, system_sign, menu_id, auth_code, action_url, action_name from pt_st_menu_action where id in " +
|
||||
"(select menu_action_id from pt_gx_role_menu_action where role_name = ?1 and status_id = '1') and status_id = '1'", nativeQuery = true)
|
||||
List<MenuActionEntity> findByRoleName(String roleName);
|
||||
|
||||
/**
|
||||
* 根据菜单id查询
|
||||
* @param menuId
|
||||
* @return
|
||||
*/
|
||||
List<MenuActionEntity> findByMenuId(String menuId);
|
||||
|
||||
/**
|
||||
* 根据菜单id查询
|
||||
* @param menuName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id, system_sign, menu_id, auth_code, action_url, action_name from pt_st_menu_action where menu_id = " +
|
||||
"(select id from pt_st_menu where menuName = ?1 and status_id = '1')" +
|
||||
" and status_id = '1'", nativeQuery = true)
|
||||
List<MenuActionEntity> findByMenuName(String menuName);
|
||||
|
||||
}
|
48
src/main/java/com/xkrs/microservice/dao/auth/MenuDao.java
Normal file
48
src/main/java/com/xkrs/microservice/dao/auth/MenuDao.java
Normal file
@ -0,0 +1,48 @@
|
||||
package com.xkrs.microservice.dao.auth;
|
||||
|
||||
import com.xkrs.microservice.model.entity.auth.MenuEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/4/23
|
||||
*/
|
||||
public interface MenuDao extends JpaRepository<MenuEntity, String> {
|
||||
|
||||
|
||||
/**
|
||||
* 根据角色id获取
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id, system_sign, menu_name, parent_id, menu_url, order_no from pt_st_menu where id in " +
|
||||
"(select menu_id from pt_gx_role_menu where role_id = ?1 and status_id = '1') and status_id = '1'", nativeQuery = true)
|
||||
List<MenuEntity> findByRoleId(String roleId);
|
||||
|
||||
/**
|
||||
* 根据角色ming获取
|
||||
* @param roleName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select id, system_sign, menu_name, parent_id, menu_url, order_no from pt_st_menu where id in " +
|
||||
"(select menu_id from pt_gx_role_menu where role_name = ?1 and status_id = '1') and status_id = '1'", nativeQuery = true)
|
||||
List<MenuEntity> findByRoleName(String roleName);
|
||||
|
||||
/**
|
||||
* 根据菜单id软删除
|
||||
* @param id
|
||||
*/
|
||||
@Query(value = "update pt_st_menu set status_id = '2' where id = ?1", nativeQuery = true)
|
||||
void softDeleById(String id);
|
||||
|
||||
/**
|
||||
* 根据菜单id恢复
|
||||
* @param id
|
||||
*/
|
||||
@Query(value = "update pt_st_menu set status_id = '1' where id = ?1", nativeQuery = true)
|
||||
void regainById(String id);
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.xkrs.microservice.dao.auth;
|
||||
|
||||
import com.xkrs.microservice.model.entity.auth.PtStPersonNumber;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
/**
|
||||
* @author wudong
|
||||
* @date 2021/12/7 10:05
|
||||
* @description
|
||||
*/
|
||||
public interface PtStPersonNumberDao extends JpaRepository<PtStPersonNumber, String> {
|
||||
|
||||
/**
|
||||
* 新建账户,自建账户增一
|
||||
* @param id
|
||||
* @param number
|
||||
*/
|
||||
@Modifying
|
||||
@Query(value = "update pt_st_person_number set build_number = ?2 where id = ?1", nativeQuery = true)
|
||||
int updateById(String id, Integer number);
|
||||
|
||||
|
||||
@Modifying
|
||||
@Query(value = "update pt_st_person_number set gateway_number = ?2 where id = ?1", nativeQuery = true)
|
||||
int updateGatewayById(String id, Integer num);
|
||||
|
||||
}
|
56
src/main/java/com/xkrs/microservice/dao/auth/RoleDao.java
Normal file
56
src/main/java/com/xkrs/microservice/dao/auth/RoleDao.java
Normal file
@ -0,0 +1,56 @@
|
||||
package com.xkrs.microservice.dao.auth;
|
||||
|
||||
import com.xkrs.microservice.model.entity.auth.RoleEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/4/22
|
||||
*/
|
||||
public interface RoleDao extends JpaRepository<RoleEntity, String> {
|
||||
|
||||
/**
|
||||
* 获取用户的角色列表
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from pt_st_role where id in " +
|
||||
"(select role_id from pt_gx_user_role where user_id = ?1) and status_id = '1'", nativeQuery = true)
|
||||
List<RoleEntity> findByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 获取用户的角色列表
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from pt_st_role where id in " +
|
||||
"(select role_id from pt_gx_user_role where user_id = " +
|
||||
"(select id from sys_user where upper(user_name) = upper(?1))) and status_id = '1'", nativeQuery = true)
|
||||
List<RoleEntity> findByUserName(String username);
|
||||
|
||||
/**
|
||||
* 获取用户的角色列表
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from pt_st_role where id in " +
|
||||
"(select role_id from pt_gx_user_role where upper(user_id) = upper(?1))", nativeQuery = true)
|
||||
List<RoleEntity> findByYunLiUserId(String userId);
|
||||
|
||||
/**
|
||||
* 根据角色名获取
|
||||
* @param roleName
|
||||
* @return
|
||||
*/
|
||||
RoleEntity findByRoleName(String roleName);
|
||||
|
||||
/**
|
||||
* 根据角色id获取
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<RoleEntity> findAllByIdIn(List<String> ids);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.xkrs.microservice.dao.auth;
|
||||
|
||||
import com.xkrs.microservice.model.entity.auth.RoleMenuActionEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/4/22
|
||||
*/
|
||||
public interface RoleMenuActionDao extends JpaRepository<RoleMenuActionEntity, String> {
|
||||
|
||||
/**
|
||||
* 根据角色id查询
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
List<RoleMenuActionEntity> findByRoleId(String roleId);
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.xkrs.microservice.dao.auth;
|
||||
|
||||
import com.xkrs.microservice.model.entity.auth.RoleMenuEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
/**
|
||||
* @author dong
|
||||
* @date 2021/4/22
|
||||
*/
|
||||
public interface RoleMenuDao extends JpaRepository<RoleMenuEntity, String> {
|
||||
|
||||
/**
|
||||
* 根据id软删除、禁用
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@Query(value = "update pt_gx_role_menu set status_id = '2' where id = ?1", nativeQuery = true)
|
||||
void softDeleteById(String id);
|
||||
|
||||
/**
|
||||
* 恢复
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@Query(value = "update pt_gx_role_menu set status_id = '1' where id = ?1", nativeQuery = true)
|
||||
void regainByid(String id);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user