From db44f336e46825afc855466512065cc08e5790bd Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期五, 14 七月 2023 12:11:53 +0800 Subject: [PATCH] 添加新代码 --- src/main/java/com/yssh/entity/FeedbackDetail.java | 136 src/main/java/com/yssh/mapper/StratumMapper.java | 20 src/main/java/com/yssh/utils/CacheUtils.java | 35 src/main/java/com/yssh/entity/Temporary.java | 105 src/main/java/com/yssh/service/LocationService.java | 61 src/main/java/com/yssh/mapper/EmissionMapper.java | 22 src/main/resources/application-prod.yml | 47 src/main/java/com/yssh/mapper/CommonMapper.java | 31 src/main/java/com/yssh/controller/FeedbackController.java | 31 src/main/java/com/yssh/service/WarningAnalyseService.java | 396 ++ src/main/java/com/yssh/entity/Report.java | 199 + src/main/java/com/yssh/config/ScheduleConfig.java | 191 + src/main/java/com/yssh/utils/AjaxResult.java | 186 + src/main/java/com/yssh/utils/StringUtils.java | 528 +++ src/main/java/com/yssh/entity/SuYuan3d.java | 131 src/main/resources/application-dev.yml | 47 src/main/java/com/yssh/config/InitConfig.java | 65 src/main/java/com/yssh/mapper/AlertConfigMapper.java | 23 src/main/resources/mapper/QxshMapper.xml | 31 src/main/java/com/yssh/entity/Qxsh.java | 83 src/main/resources/mapper/ThuAccuracyMapper.xml | 43 src/main/resources/mybatis.xml | 37 src/main/java/com/yssh/mapper/VocValsMapper.java | 72 src/main/java/com/yssh/Application.java | 27 src/main/resources/application-test.yml | 47 src/main/java/com/yssh/utils/HttpStatus.java | 96 src/main/java/com/yssh/utils/GisUtil.java | 36 src/main/resources/mapper/CommonMapper.xml | 14 src/main/java/com/yssh/config/CsvFilePathConfig.java | 31 src/main/java/com/yssh/entity/DistanceSuYuan.java | 149 src/main/java/com/yssh/entity/VocVals.java | 94 src/main/java/com/yssh/controller/CountController.java | 31 pom.xml | 361 ++ src/main/java/com/yssh/service/DictRecordService.java | 77 src/main/java/com/yssh/entity/ForecastAnalyseVo.java | 53 src/main/java/com/yssh/entity/Weather.java | 69 src/main/java/com/yssh/mapper/DictRecordMapper.java | 57 src/main/resources/mapper/WarningDetailMapper.xml | 128 src/main/java/com/yssh/utils/ServletInitializer.java | 27 src/main/java/com/yssh/controller/WarningAnalyseController.java | 134 src/main/java/com/yssh/service/AsyncService.java | 24 src/main/java/com/yssh/controller/LocationController.java | 75 src/main/java/com/yssh/utils/CsvParser.java | 71 src/main/java/com/yssh/service/FeedbackService.java | 31 src/main/java/com/yssh/entity/VocCoords.java | 62 src/main/java/com/yssh/mapper/FeedbackMapper.java | 16 src/main/java/com/yssh/config/Knife4jConfig.java | 71 src/main/resources/mapper/SuYuanMapper.xml | 232 + src/main/java/com/yssh/utils/CalculateUtils.java | 371 ++ src/main/java/com/yssh/utils/VocParser.java | 82 src/main/java/com/yssh/controller/EmissionController.java | 72 src/main/java/com/yssh/utils/TableStrategy.java | 10 src/main/java/com/yssh/config/DatFilePathConfig.java | 31 src/main/java/com/yssh/entity/ExpPoint.java | 144 src/main/java/com/yssh/entity/Stratum.java | 99 src/main/resources/mapper/FeedbackMapper.xml | 53 src/main/resources/mapper/DictRecordMapper.xml | 84 src/main/java/com/yssh/entity/WarningDetail.java | 101 src/main/java/com/yssh/mapper/LocationMapper.java | 27 src/main/java/com/yssh/entity/MonitorPointPosition.java | 86 src/main/java/com/yssh/utils/CommonConstant.java | 22 src/main/java/com/yssh/service/SuYuanService.java | 313 ++ src/main/resources/application.yml | 60 src/main/java/com/yssh/utils/SpringUtils.java | 135 src/main/resources/application-scheduled.yml | 8 src/main/java/com/yssh/service/CountService.java | 38 src/main/resources/logback.xml | 99 src/main/java/com/yssh/service/CommonService.java | 166 + src/main/java/com/yssh/mapper/SuYuanMapper.java | 46 src/main/java/com/yssh/entity/Coordinate.java | 36 src/main/java/com/yssh/entity/SuYuan700.java | 187 + src/main/java/com/yssh/utils/FileUtils.java | 76 src/main/java/com/yssh/mapper/QxshMapper.java | 21 src/main/resources/application-file.yml | 8 src/main/resources/mapper/AlertConfigMapper.xml | 57 src/main/java/com/yssh/controller/SuYuanController.java | 190 + src/main/java/com/yssh/service/AlertConfigService.java | 36 src/main/resources/mapper/EmissionMapper.xml | 40 src/main/resources/mapper/WeatherMapper.xml | 43 src/main/java/com/yssh/entity/ThuAccuracy.java | 126 src/main/resources/mapper/StratumMapper.xml | 41 src/main/java/com/yssh/config/ThreadPoolConfig.java | 46 src/main/java/com/yssh/entity/SuYuan.java | 99 src/main/java/com/yssh/utils/DateUtils.java | 267 + src/main/java/com/yssh/mapper/ExpPointMapper.java | 15 src/main/java/com/yssh/config/WebSocketConfig.java | 20 src/main/resources/mapper/LocationMapper.xml | 59 src/main/java/com/yssh/entity/Emission.java | 85 src/main/java/com/yssh/mapper/BaseMapper.java | 11 src/main/java/com/yssh/service/WeatherService.java | 38 src/main/java/com/yssh/controller/AlertConfigController.java | 82 src/main/java/com/yssh/entity/SuYuan2d.java | 69 src/main/java/com/yssh/entity/SuYuanMonitorData.java | 48 src/main/java/com/yssh/entity/DictRecord.java | 88 src/main/java/com/yssh/utils/Result.java | 154 src/main/java/com/yssh/controller/ForecastAnalyseController.java | 39 src/main/java/com/yssh/entity/WarningVo.java | 95 src/main/java/com/yssh/mapper/ThuAccuracyMapper.java | 17 src/main/java/com/yssh/entity/AlertConfig.java | 74 src/main/java/com/yssh/controller/WeatherController.java | 90 src/main/java/com/yssh/service/ForecastAnalyseService.java | 69 src/main/java/com/yssh/mapper/WarningDetailMapper.java | 34 src/main/java/com/yssh/entity/Location.java | 70 src/main/java/com/yssh/service/EmissionService.java | 39 src/main/java/com/yssh/service/VocValsService.java | 82 src/main/java/com/yssh/config/CorsConfig.java | 62 src/main/java/com/yssh/mapper/WeatherMapper.java | 22 src/main/resources/mapper/VocValsMapper.xml | 62 108 files changed, 9,277 insertions(+), 0 deletions(-) diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..617542d --- /dev/null +++ b/pom.xml @@ -0,0 +1,361 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <!-- https://start.springboot.io/ --> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>2.3.6.RELEASE</version> + <relativePath/> + </parent> + <!--鎵撳寘鎴恮ar--> + <packaging>war</packaging> + + <groupId>com</groupId> + <artifactId>yssh</artifactId> + <version>1.0.0</version> + <name>yssh</name> + <description>鐕曞北鐭冲寲婧簮涓夌淮鐢靛瓙娌欑洏</description> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <java.version>1.8</java.version> + </properties> + + <dependencies> + <!--log4j--> + <!--<dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.17</version> + </dependency>--> + <!--logback--> + <!--<dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + <version>1.1.3</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-access</artifactId> + <version>1.1.3</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>1.1.3</version> + </dependency>--> + <!--spring-boot--> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + <!--鎺掗櫎鍐呯疆tomcat瀹瑰櫒锛岃澶栭儴瀹瑰櫒杩愯spring-boot椤圭洰--> + <exclusions> + <!--<exclusion> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-tomcat</artifactId> + </exclusion>--> + <exclusion> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + </exclusion> + </exclusions> + </dependency> + <!--spring浜嬪姟绠$悊--> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-tx</artifactId> + </dependency> + <!--tomcat--> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-tomcat</artifactId> + <scope>provided</scope> + </dependency> + <!--jdbc--> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-jdbc</artifactId> + </dependency> + <!--thymeleaf--> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-thymeleaf</artifactId> + <version>2.2.2.RELEASE</version> + </dependency> + <!--lombok--> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <optional>true</optional> + </dependency> + <!--mybatis-plus--> + <dependency> + <groupId>com.baomidou</groupId> + <artifactId>mybatis-plus-boot-starter</artifactId> + <version>3.5.1</version> + </dependency> + <!--postgresql--> + <!--dependency> + <groupId>org.postgresql</groupId> + <artifactId>postgresql</artifactId> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-pool2</artifactId> + </dependency--> + <!--aop--> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-aop</artifactId> + </dependency> + <!--椤甸潰鐑儴缃�--> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-devtools</artifactId> + <optional>true</optional> + <scope>true</scope> + </dependency> + <!--fastjson--> + <dependency> + <groupId>com.alibaba</groupId> + <artifactId>fastjson</artifactId> + <version>1.2.47</version> + </dependency> + <!--鏁村悎druid鏁版嵁婧�--> + <dependency> + <groupId>com.alibaba</groupId> + <artifactId>druid</artifactId> + <version>1.1.22</version> + </dependency> + <dependency> + <groupId>com.alibaba</groupId> + <artifactId>druid-spring-boot-starter</artifactId> + <version>1.1.22</version> + </dependency> + <!--test--> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <!--text--> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-text</artifactId> + <version>1.1</version> + </dependency> + <!--swagger--> + <!--<dependency> + <groupId>io.springfox</groupId> + <artifactId>springfox-swagger2</artifactId> + <version>2.9.2</version> + </dependency> + <dependency> + <groupId>io.springfox</groupId> + <artifactId>springfox-swagger-ui</artifactId> + <version>2.9.2</version> + </dependency>--> + <!--httpclient--> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + </dependency> + <!--websocket--> + <dependency> + <groupId>javax.websocket</groupId> + <artifactId>javax.websocket-api</artifactId> + <version>1.0</version> + </dependency> + <!--websocket--> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-websocket</artifactId> + </dependency> + <!--hutool--> + <dependency> + <groupId>cn.hutool</groupId> + <artifactId>hutool-all</artifactId> + <version>5.7.20</version> + </dependency> + <dependency> + <groupId>net.java.dev.jna</groupId> + <artifactId>jna</artifactId> + <version>5.5.0</version> + </dependency> + <dependency> + <groupId>net.java.dev.jna</groupId> + <artifactId>jna-platform</artifactId> + <version>5.5.0</version> + </dependency> + <!--commons-fileupload--> + <dependency> + <groupId>commons-fileupload</groupId> + <artifactId>commons-fileupload</artifactId> + <version>1.4</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.11.0</version> + </dependency> + <!--war:servlet--> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.1.0</version> + <scope>provided</scope> + </dependency> + <!--fast-md5--> + <dependency> + <groupId>com.joyent.util</groupId> + <artifactId>fast-md5</artifactId> + <version>2.7.1</version> + </dependency> + <!--apache.poi--> + <dependency> + <groupId>org.apache.poi</groupId> + <artifactId>poi-ooxml</artifactId> + <version>3.16</version> + </dependency> + + <!--mysql--> + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + </dependency> + <!--biyanwen--> + <dependency> + <groupId>com.github.biyanwen</groupId> + <artifactId>easycsv</artifactId> + <version>1.0.0</version> + </dependency> + <dependency> + <groupId>com.github.xiaoymin</groupId> + <artifactId>knife4j-spring-boot-starter</artifactId> + <version>3.0.3</version> + </dependency> + <!--geotools渚濊禆--> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt-shapefile</artifactId> + <version>22.0</version> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt-main</artifactId> + <version>22.0</version> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt-epsg-hsql</artifactId> + <version>22.0</version> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt-geotiff</artifactId> + <version>22.0</version> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt-geojson</artifactId> + <version>22.0</version> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt-api</artifactId> + <version>20.0</version> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt-metadata</artifactId> + <version>22.0</version> + </dependency> + <dependency> + <groupId>org.geotools</groupId> + <artifactId>gt-opengis</artifactId> + <version>22.0</version> + <scope>compile</scope> + </dependency> + <!--Caffeine缂撳瓨--> + <dependency> + <groupId>com.github.ben-manes.caffeine</groupId> + <artifactId>caffeine</artifactId> + <version>2.9.3</version> + </dependency> + </dependencies> + + <profiles> + <profile> + <id>test</id> + <properties> + <activatedProperties>test</activatedProperties> + </properties> + </profile> + <profile> + <id>dev</id> + <properties> + <activatedProperties>dev</activatedProperties> + </properties> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + </profile> + <profile> + <id>prod</id> + <properties> + <activatedProperties>prod</activatedProperties> + </properties> + </profile> + </profiles> + + <build> + <finalName>yssh</finalName> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <!--<version>2.3.0.RELEASE</version>--> + <configuration> + <mainClass>com.yssh.Application</mainClass> + </configuration> + </plugin> + </plugins> + </build> + + <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> + <repository> + <id>public</id> + <name>aliyun nexus</name> + <url>http://maven.aliyun.com/nexus/content/groups/public/</url> + <releases> + <enabled>true</enabled> + </releases> + </repository> + </repositories> +</project> diff --git a/src/main/java/com/yssh/Application.java b/src/main/java/com/yssh/Application.java new file mode 100644 index 0000000..ac78571 --- /dev/null +++ b/src/main/java/com/yssh/Application.java @@ -0,0 +1,27 @@ +package com.yssh; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +/** + * 搴旂敤绋嬪簭 + * @author WWW + * 鎺掗櫎Security锛�, exclude = {SecurityAutoConfiguration.class, SecurityFilterAutoConfiguration.class} + * + * jar -> war锛氱户鎵� SpringBootServletInitializer锛屽疄鐜� configure 鍑芥暟 + */ +@EnableSwagger2 +@SpringBootApplication(scanBasePackages = {"com.yssh.*"}) +public class Application extends SpringBootServletInitializer { + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder springApplicationBuilder) { + return springApplicationBuilder.sources(Application.class); + } +} diff --git a/src/main/java/com/yssh/config/CorsConfig.java b/src/main/java/com/yssh/config/CorsConfig.java new file mode 100644 index 0000000..1145810 --- /dev/null +++ b/src/main/java/com/yssh/config/CorsConfig.java @@ -0,0 +1,62 @@ +package com.yssh.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.Ordered; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; + +/** + * @author wMeng + * @ClassName CorsConfig + * @Description 璺ㄥ煙閰嶇疆 + * @date 2022/10/31 16:42 + * @Version 1.0 + */ +@Configuration +public class CorsConfig extends WebMvcConfigurationSupport { + @Override + public void addViewControllers(ViewControllerRegistry registry) { + // 璁剧疆璁块棶璺緞涓� 鈥�/鈥� 璺宠浆鍒版寚瀹氶〉闈� + registry.addViewController("/").setViewName("redirect:/doc.html"); + // 璁剧疆涓烘渶楂樹紭鍏堢骇 + registry.setOrder(Ordered.HIGHEST_PRECEDENCE); + } + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowCredentials(true) + .allowedOrigins("*") + .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") + .allowedHeaders("*") + .maxAge(3600); + } + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + //璁剧疆闈欐�佽祫婧愭槧灏� + registry.addResourceHandler("/backend/**").addResourceLocations("classpath:/backend/"); + registry.addResourceHandler("/front/**").addResourceLocations("classpath:/front/"); + + registry.addResourceHandler("/**").addResourceLocations("classpath:/static/"); + registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/"); + registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); + } + + @Bean + public CorsFilter corsFilter() { + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + CorsConfiguration corsConfiguration = new CorsConfiguration(); + corsConfiguration.addAllowedOrigin("*"); + corsConfiguration.addAllowedHeader("*"); + corsConfiguration.addAllowedMethod("*"); + source.registerCorsConfiguration("/**", corsConfiguration); + return new CorsFilter(source); + } +} diff --git a/src/main/java/com/yssh/config/CsvFilePathConfig.java b/src/main/java/com/yssh/config/CsvFilePathConfig.java new file mode 100644 index 0000000..f309337 --- /dev/null +++ b/src/main/java/com/yssh/config/CsvFilePathConfig.java @@ -0,0 +1,31 @@ +package com.yssh.config; + +import lombok.Data; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Data +@Component +@ConfigurationProperties(prefix = "csv") +public class CsvFilePathConfig { + private String filePath; + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + private String vocPath; + + public String getVocPath() { + return vocPath; + } + + public void setVocPath(String vocPath) { + this.vocPath = vocPath; + } +} diff --git a/src/main/java/com/yssh/config/DatFilePathConfig.java b/src/main/java/com/yssh/config/DatFilePathConfig.java new file mode 100644 index 0000000..a422f6d --- /dev/null +++ b/src/main/java/com/yssh/config/DatFilePathConfig.java @@ -0,0 +1,31 @@ +package com.yssh.config; + +import lombok.Data; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Data +@Component +@ConfigurationProperties(prefix = "dat") +public class DatFilePathConfig { + + private String filePath2d; + private String filePath3d; + + public String getFilePath2d() { + return filePath2d; + } + + public void setFilePath2d(String filePath2d) { + this.filePath2d = filePath2d; + } + + public String getFilePath3d() { + return filePath3d; + } + + public void setFilePath3d(String filePath3d) { + this.filePath3d = filePath3d; + } +} diff --git a/src/main/java/com/yssh/config/InitConfig.java b/src/main/java/com/yssh/config/InitConfig.java new file mode 100644 index 0000000..e38bf06 --- /dev/null +++ b/src/main/java/com/yssh/config/InitConfig.java @@ -0,0 +1,65 @@ +package com.yssh.config; + +import com.yssh.service.WarningAnalyseService; +import com.yssh.utils.CacheUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.stereotype.Component; + +import com.yssh.service.CommonService; +import com.yssh.service.DictRecordService; + +import javax.annotation.Resource; +import java.util.Calendar; + +@Component +public class InitConfig implements ApplicationRunner { + //protected final Log logger = LogFactory.getLog(this.getClass()); + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private CommonService commonService; + + @Autowired + private DictRecordService dictRecordService; + + @Resource + WarningAnalyseService warningAnalyseService; + + @Resource + ScheduleConfig task; + + @Override + public void run(ApplicationArguments args) throws Exception { + CacheUtils.init(); + + boolean tableExists = commonService.checkTableExists("dict_record"); + if (!tableExists) { + dictRecordService.createDictRecoTable(); + } + // 璇诲彇dat鏁版嵁 + commonService.readDatData(); + + //test(); + logger.info("***************** 绯荤粺鍚姩瀹屾瘯 *****************" + "\n"); + } + + private void test() { + //task.corpReserveDataSync(); + + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MONTH, 5); + calendar.set(Calendar.DAY_OF_MONTH, 8); + calendar.set(Calendar.HOUR_OF_DAY, 16); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + + //warningAnalyseService.warningOperationStorage(calendar.getTime()); + } +} diff --git a/src/main/java/com/yssh/config/Knife4jConfig.java b/src/main/java/com/yssh/config/Knife4jConfig.java new file mode 100644 index 0000000..86ae6a4 --- /dev/null +++ b/src/main/java/com/yssh/config/Knife4jConfig.java @@ -0,0 +1,71 @@ +package com.yssh.config; + +import io.swagger.annotations.ApiOperation; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; + +import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; + +/** + * @author wMeng + * @ClassName SwaggerConfig + * @Description TODO + * @date 2022/10/31 18:55 + * @Version 1.0 + */ +@Configuration +@EnableKnife4j +public class Knife4jConfig { + + @Value("${knife4j.enabled}") + private boolean enabled; + + /** + * 璁剧疆璇锋眰鐨勭粺涓�鍓嶇紑 + */ + @Value("${knife4j.pathMapping}") + private String pathMapping; + + @Bean + public Docket createRestApi() { + return new Docket(new DocumentationType("openApi", "3.0")) + // 鏄惁鍚敤Swagger + .enable(enabled) + // 鐢ㄦ潵鍒涘缓璇PI鐨勫熀鏈俊鎭紝灞曠ず鍦ㄦ枃妗g殑椤甸潰涓紙鑷畾涔夊睍绀虹殑淇℃伅锛� + .apiInfo(apiInfo()) + // 鍒嗙粍鍚嶇О + .groupName("鏈嶅姟") + // 璁剧疆鍝簺鎺ュ彛鏆撮湶缁橲wagger灞曠ず + .select() + // 鎵弿鎵�鏈夋湁娉ㄨВ鐨刟pi锛岀敤杩欑鏂瑰紡鏇寸伒娲� + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + // 鎵弿鎸囧畾鍖呬腑鐨剆wagger娉ㄨВ + // .apis(RequestHandlerSelectors.basePackage("com.cn.project.tool.swagger")) + // 鎵弿鎵�鏈� .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build() + /* 璁剧疆瀹夊叏妯″紡锛宻wagger鍙互璁剧疆璁块棶token */ + // .securitySchemes(securitySchemes()) + .pathMapping(pathMapping); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + //鎻忚堪瀛楁鏀寔Markdown璇硶 + .description("鎴戠殑鎺ュ彛娴嬭瘯鏂囨。") + .contact(new Contact("寮犺吘椋�", "http://127.0.0.1:9001/doc.html", "893732661@qq.com")) + .version("2.0.0") + .title("鐕曞北鐭冲寲API鎺ュ彛娴嬭瘯鏂囨。") + .build(); + } +} diff --git a/src/main/java/com/yssh/config/ScheduleConfig.java b/src/main/java/com/yssh/config/ScheduleConfig.java new file mode 100644 index 0000000..4a1aa1e --- /dev/null +++ b/src/main/java/com/yssh/config/ScheduleConfig.java @@ -0,0 +1,191 @@ +package com.yssh.config; + +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import com.yssh.entity.DictRecord; +import com.yssh.entity.SuYuan; +import com.yssh.entity.VocVals; +import com.yssh.service.DictRecordService; +import com.yssh.service.SuYuanService; +import com.yssh.service.VocValsService; +import com.yssh.service.WarningAnalyseService; +import com.yssh.utils.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import com.github.biyanwen.EasyCsv; + +import javax.annotation.Resource; + +@Component +@EnableScheduling +public class ScheduleConfig { + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Resource + private VocValsService vocValsService; + + @Resource + private SuYuanService suYuanService; + + @Resource + private CsvFilePathConfig csvFilePathConfig; + + @Resource + private DictRecordService dictRecordService; + + @Resource + private WarningAnalyseService warningAnalyseService; + + @Value("${csv.voc_max}") + private int vocMax = 96; + + @Value("${csv.cron_max}") + private int cronMax = 48; + + private static boolean isBusy = false; + + private final static List<String> md5List = new ArrayList<>(); + + private final static SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHH"); + + public void corpReserveDataSync() { + loadVocSync(); + loadCsvSync(); + } + + @Scheduled(cron = "${csv.cron}") + private void loadCsvSync() { + if (isBusy) return; + + isBusy = true; + logger.info("***************** 寮�濮嬫墽琛孋SV鍏ュ簱 *****************" + "\n"); + Calendar calendar = getCalendar(1); + for (int i = 0; i < cronMax; i++) { + try { + calendar.add(Calendar.HOUR, -1); + String time = format.format(calendar.getTime()); + String filePath = csvFilePathConfig.getFilePath() + File.separator + time + ".csv"; + + File file = new File(filePath); + if (!file.exists()) { + //logger.info(file.getAbsolutePath() + " is not exist 锛�"); + continue; + } + String newTableName = TableStrategy.getTableStrategy(time); // 鍒涘缓琛� + Integer rows = suYuanService.isTableExists(newTableName); + if (rows > 0) { + continue; + } + + suYuanService.createNewTable(newTableName); + DictRecord dr = dictRecordService.selectByCreateTime(Long.parseLong(time)); + if (null == dr) { + dictRecordService.insertDictRecord(new DictRecord(1L, newTableName, Long.parseLong(time), "")); + } + + logger.info("loadCsvSync: " + filePath); + EasyCsv.read(filePath, SuYuan.class, new CsvParser(suYuanService, time)).doRead(); + warningAnalyseService.warningOperationStorage(calendar.getTime()); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + } + logger.info("***************** CSV鍏ュ簱鎵ц瀹屾垚 *****************" + "\n"); + isBusy = false; + } + + public Calendar getCalendar(int start) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + calendar.add(Calendar.HOUR, start); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + + // 娴嬭瘯 -> 2023-04-23 19:00 + //calendar.set(Calendar.MONTH, 3); + //calendar.set(Calendar.DAY_OF_MONTH, 23); + //calendar.set(Calendar.HOUR_OF_DAY, 20); + + return calendar; + } + + @Scheduled(cron = "${csv.voc}") + private void loadVocSync() { + logger.info("***************** 寮�濮嬪叏鍩烠SV鍏ュ簱 *****************" + "\n"); + vocValsService.deleteLastYear(); + Calendar calendar = getCalendar(96); + for (int i = 0; i < vocMax; i++) { + calendar.add(Calendar.HOUR, -1); + String time = format.format(calendar.getTime()); + String filePath = csvFilePathConfig.getVocPath() + File.separator + time + ".csv"; + + File file = new File(filePath); + if (!file.exists()) { + //logger.info(file.getAbsolutePath() + " is not exist 锛�"); + continue; + } + + String md5 = FileUtils.getFileMd5(filePath); + if (null != md5 && md5List.contains(md5)) { + continue; // csv宸插叆搴� + } + + int count = vocValsService.countByTime(time); + if (count > 0) { + vocValsService.deleteByTime(time); // 鍒犻櫎宸插叆搴� + } + + try { + addFileMd5(md5); + logger.info("loadVocSync: " + filePath); + Date date = (Date) calendar.getTime().clone(); + EasyCsv.read(filePath, VocVals.class, new VocParser(vocValsService, date)).doRead(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + } + logger.info("***************** 鍏ㄥ煙CSV鎵ц瀹屾垚 *****************" + "\n"); + } + + private void addFileMd5(String md5) { + md5List.add(md5); + if (md5List.size() > 512) { + md5List.remove(0); + } + } + + private void loadCsv_old() { + Date date = DateUtils.getNowDate(); + String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, date); + String filePath = csvFilePathConfig.getFilePath() + "\\\\" + time + ".csv"; + File file = new File(filePath); + if (!file.exists()) { + logger.info(file.getAbsolutePath() + " is not exist 锛�"); + return; + } + //鍒涘缓琛� + String newTableName = TableStrategy.getTableStrategy(time); + suYuanService.createNewTable(newTableName); + dictRecordService.insertDictRecord(new DictRecord(1L, newTableName, Long.parseLong(time), "")); + EasyCsv.read(filePath, SuYuan.class, new CsvParser(suYuanService, time)).doRead(); + //璁$畻棰勮/鎶ヨ,骞朵笖杩涜鍏ュ簱鎿嶄綔 + try { + Thread.sleep(60 * 1000); + } catch (InterruptedException e) { + logger.error("鐫$湢涓�鍒嗛挓鍚庢墽琛岄璀�/鎶ヨ璁$畻,骞朵笖杩涜鍏ュ簱鎿嶄綔鍑虹幇寮傚父锛屽紓甯稿師鍥犳槸锛�", e); + e.printStackTrace(); + } + warningAnalyseService.warningOperationStorage(date); + } +} diff --git a/src/main/java/com/yssh/config/ThreadPoolConfig.java b/src/main/java/com/yssh/config/ThreadPoolConfig.java new file mode 100644 index 0000000..1a03fbf --- /dev/null +++ b/src/main/java/com/yssh/config/ThreadPoolConfig.java @@ -0,0 +1,46 @@ +package com.yssh.config; + +import java.util.concurrent.ThreadPoolExecutor; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +/** + * 绾跨▼姹犻厤缃� + * + * @author tam + **/ +@Configuration +@EnableAsync +public class ThreadPoolConfig { + // 鏍稿績绾跨▼姹犲ぇ灏� + private int corePoolSize = 50; + + // 鏈�澶у彲鍒涘缓鐨勭嚎绋嬫暟 + private int maxPoolSize = 200; + + // 闃熷垪鏈�澶ч暱搴� + private int queueCapacity = 1000; + + // 绾跨▼姹犵淮鎶ょ嚎绋嬫墍鍏佽鐨勭┖闂叉椂闂� + private int keepAliveSeconds = 300; + + //閰嶇疆绾跨▼姹犱腑鐨勭嚎绋嬬殑鍚嶇О鍓嶇紑 + private String threadNamePrefix = "async-importDB-"; + + @Bean(name = "threadPoolTaskExecutor") + public ThreadPoolTaskExecutor threadPoolTaskExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setMaxPoolSize(maxPoolSize); + executor.setCorePoolSize(corePoolSize); + executor.setQueueCapacity(queueCapacity); + executor.setKeepAliveSeconds(keepAliveSeconds); + executor.setThreadNamePrefix(threadNamePrefix); + // 绾跨▼姹犲鎷掔粷浠诲姟(鏃犵嚎绋嬪彲鐢�)鐨勫鐞嗙瓥鐣� + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); + return executor; + } + +} diff --git a/src/main/java/com/yssh/config/WebSocketConfig.java b/src/main/java/com/yssh/config/WebSocketConfig.java new file mode 100644 index 0000000..dc02d2e --- /dev/null +++ b/src/main/java/com/yssh/config/WebSocketConfig.java @@ -0,0 +1,20 @@ +package com.yssh.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; +import org.springframework.web.socket.server.standard.ServerEndpointExporter; + +/** + * WebSocket閰嶇疆绫� + * @author WWW + */ +@Component +public class WebSocketConfig { + /** + * 鑷姩娉ㄥ唽浣跨敤@ServerEndpoint + */ + @Bean + public ServerEndpointExporter serverEndpointExporter() { + return new ServerEndpointExporter(); + } +} diff --git a/src/main/java/com/yssh/controller/AlertConfigController.java b/src/main/java/com/yssh/controller/AlertConfigController.java new file mode 100644 index 0000000..026b20f --- /dev/null +++ b/src/main/java/com/yssh/controller/AlertConfigController.java @@ -0,0 +1,82 @@ +package com.yssh.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; + +import java.util.List; + +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.yssh.entity.AlertConfig; +import com.yssh.service.AlertConfigService; +import com.yssh.utils.Result; + +import javax.annotation.Resource; + +@Api(tags="鍛婅閰嶇疆") +@RestController +@RequestMapping("/config") +@SuppressWarnings("rawtypes") +public class AlertConfigController { + @Resource + private AlertConfigService alertConfigService; + + @ApiOperationSupport(order = 1) + @ApiOperation(value = "鏌ヨ鎵�鏈夊憡璀﹂厤缃暟鎹�", notes = "鏌ヨ鎵�鏈夊憡璀﹂厤缃暟鎹�") + @GetMapping("/all") + public Result getAll() { + List<AlertConfig> list = alertConfigService.getAll(); + return Result.OK(list); + } + + @ApiOperationSupport(order = 2) + @ApiImplicitParam(name = "id", value = "鍛婅閰嶇疆缂栧彿", required = true, type = "int") + @ApiOperation(value = "鏍规嵁缂栧彿鏌ヨ鍛婅閰嶇疆鏁版嵁璇︽儏", notes = "鏍规嵁缂栧彿鏌ヨ鍛婅閰嶇疆鏁版嵁璇︽儏") + @GetMapping("/query/{id}") + public Result query(@PathVariable("id") Integer id) { + List<AlertConfig> data = alertConfigService.query(id); + return Result.OK(data); + } + + @ApiOperationSupport(order = 3) + @ApiOperation(value = "鏇存柊鍛婅閰嶇疆鏁版嵁", notes = "鏍规嵁鍛婅閰嶇疆缂栧彿淇敼鍛婅閰嶇疆鏁版嵁鍐呭") + @PutMapping + public Result update(@RequestBody AlertConfig config) { + int row = alertConfigService.update(config); + if (row == 0) { + return Result.error("鏇存柊澶辫触"); + } + return Result.OK("鏇存柊鎴愬姛"); + } + + @ApiOperationSupport(order = 4) + @ApiOperation(value = "鏂板鍛婅閰嶇疆鏁版嵁", notes = "鏂板鍛婅閰嶇疆璇︽儏鏁版嵁") + @PostMapping + public Result add(@RequestBody AlertConfig alert) { + int row = alertConfigService.insert(alert); + if (row == 0) { + return Result.error("鏂板澶辫触"); + } + return Result.OK("鏂板鎴愬姛"); + } + + @ApiOperationSupport(order = 5) + @ApiOperation(value = "鍒犻櫎鍛婅閰嶇疆鏁版嵁", notes = "鍒犻櫎鍛婅閰嶇疆璇︽儏鏁版嵁") + @DeleteMapping("/{id}") + public Result delete(@PathVariable Integer id) { + int row = alertConfigService.delete(id); + if (row == 0) { + return Result.error("鍒犻櫎澶辫触"); + } + return Result.OK("鍒犻櫎鎴愬姛"); + } +} diff --git a/src/main/java/com/yssh/controller/CountController.java b/src/main/java/com/yssh/controller/CountController.java new file mode 100644 index 0000000..81690cb --- /dev/null +++ b/src/main/java/com/yssh/controller/CountController.java @@ -0,0 +1,31 @@ +package com.yssh.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +import java.util.Map; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.yssh.service.CountService; +import com.yssh.utils.Result; + +import javax.annotation.Resource; + +@Api(tags="缁熻") +@RestController +@RequestMapping("/count") +@SuppressWarnings("rawtypes") +public class CountController { + @Resource + private CountService countService; + + @GetMapping("/accuracy") + @ApiOperation(value = "鏌ヨ鍑嗙‘鐜囩粺璁�", notes = "鏌ヨ鍑嗙‘鐜囩粺璁℃暟鎹紝杩斿洖鍙傛暟涓璮orecastRate涓洪娴嬪噯纭巼锛宲racticalRate涓烘函婧愬噯纭巼") + public Result getAccuracyAvg() { + Map<String, Double> accuracyAvg = countService.selectAccuracyAvg(); + return Result.OK(accuracyAvg); + } +} diff --git a/src/main/java/com/yssh/controller/EmissionController.java b/src/main/java/com/yssh/controller/EmissionController.java new file mode 100644 index 0000000..ce8242a --- /dev/null +++ b/src/main/java/com/yssh/controller/EmissionController.java @@ -0,0 +1,72 @@ +package com.yssh.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; + +import java.util.List; + +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.yssh.entity.Emission; +import com.yssh.service.EmissionService; +import com.yssh.utils.Result; + +import javax.annotation.Resource; + +/** + * @author lishijia + * @ClassName YsshPfshController + * @Description TODO + * @date 2022/11/24 14:44 + * @Version 1.0 + */ +@Api(tags="鎺掓斁鐐�") +@RestController +@RequestMapping("/emission") +@SuppressWarnings("rawtypes") +public class EmissionController { + @Resource + private EmissionService emissionService; + + @ApiOperation(value = "鍚嶇О鏌ヨ鎺掓斁鏁版嵁", notes = "鏍规嵁鍚嶇О鏌ヨ鎺掓斁璇︾粏淇℃伅") + @ApiImplicitParam(name = "name", value = "鍚嶇О", required = true, type = "String") + @GetMapping("/query/{name}") + public Result query(@PathVariable("name") String name){ + List<Emission> data = emissionService.query(name); + return Result.OK(data); + } + + @ApiOperation(value = "鏌ヨ鎵�鏈夋帓鏀剧偣鏁版嵁", notes = "鏌ヨ鎵�鏈夊巶鍖烘帓鏀剧偣鏁版嵁") + @GetMapping("/getAll") + public Result getAll(){ + List<Emission> list = emissionService.getAll(); + return Result.OK(list); + } + + @PostMapping("/insert") + @ApiOperation("鎻掑叆鏁版嵁") + public Result insert(@RequestBody Emission emission){ + int i = emissionService.insert(emission); + if(i == 0){ + return Result.error("鎻掑叆澶辫触"); + } + return Result.OK("鎻掑叆鎴愬姛"); + } + + @DeleteMapping("/delete/{id}") + @ApiOperation("鍒犻櫎鏁版嵁") + public Result delete(@PathVariable("id") String id){ + int i = emissionService.delete(id); + if(i == 0){ + return Result.error("鍒犻櫎澶辫触"); + } + return Result.OK("鍒犻櫎鎴愬姛"); + } +} diff --git a/src/main/java/com/yssh/controller/FeedbackController.java b/src/main/java/com/yssh/controller/FeedbackController.java new file mode 100644 index 0000000..eac0676 --- /dev/null +++ b/src/main/java/com/yssh/controller/FeedbackController.java @@ -0,0 +1,31 @@ +package com.yssh.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.yssh.service.FeedbackService; +import com.yssh.utils.Result; + +import javax.annotation.Resource; + +@Api(tags="婧簮鍙嶉") +@RestController +@RequestMapping("/feedback") +@SuppressWarnings("rawtypes") +public class FeedbackController { + @Resource + private FeedbackService feedbackService; + + @GetMapping("/feedback") + @ApiOperation(value = "婧簮鍙嶉", notes = "杩涜婧簮鍙嶉") + public Result suYuanFeedback( + @RequestParam(value = "id", required = true) Long id, @RequestParam(value = "practicalId", required = true) String practicalId, + @RequestParam(value = "practicalVocsName", required = true) String practicalVocsName, @RequestParam(value = "practicalValue", required = true) double practicalValue) { + return Result.OK(feedbackService.suYuanFeedback(id, practicalId, practicalVocsName, practicalValue)); + } +} diff --git a/src/main/java/com/yssh/controller/ForecastAnalyseController.java b/src/main/java/com/yssh/controller/ForecastAnalyseController.java new file mode 100644 index 0000000..c2450b8 --- /dev/null +++ b/src/main/java/com/yssh/controller/ForecastAnalyseController.java @@ -0,0 +1,39 @@ +package com.yssh.controller; + +import com.yssh.entity.ForecastAnalyseVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +import java.util.Date; +import java.util.List; + +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.yssh.service.ForecastAnalyseService; +import com.yssh.utils.Result; + +import javax.annotation.Resource; + +@Api(tags="棰勬祴鍒嗘瀽") +@RestController +@RequestMapping("/forecast") +@SuppressWarnings("rawtypes") +public class ForecastAnalyseController { + @Resource + private ForecastAnalyseService forecastAnalyseService; + + @GetMapping("/forecastAnalyse") + @ApiOperation(value = "鏌ヨ棰勮鍙婂叾瀹為檯鐩戞祴鏁版嵁", notes = "鏍规嵁鎵�閫夌偣浣嶅悕绉板強鍏舵墍閫夋椂闂存锛屾煡璇㈣鐐逛綅鍦ㄦ寚瀹氭椂闂存鍐呯殑鐩戞祴鏁版嵁鍙婂叾棰勬祴鏁版嵁") + public Result getForecastAnalyse( + @RequestParam(value = "name", required = true) String name, + @RequestParam(value = "beginTime", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date beginTime, + @RequestParam(value = "endTime", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) { + List<ForecastAnalyseVo> list = forecastAnalyseService.getForecastAnalyse(name, beginTime, endTime); + + return Result.OK(list); + } +} diff --git a/src/main/java/com/yssh/controller/LocationController.java b/src/main/java/com/yssh/controller/LocationController.java new file mode 100644 index 0000000..9997c8e --- /dev/null +++ b/src/main/java/com/yssh/controller/LocationController.java @@ -0,0 +1,75 @@ +package com.yssh.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +import java.util.List; + +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.yssh.entity.Location; +import com.yssh.service.LocationService; +import com.yssh.utils.Result; + +import javax.annotation.Resource; + +/** + * @author wMeng + * @ClassName YsshLocationController + * @Description YsshLocationController + * @date 2022/10/30 13:21 + * @Version 1.0 + */ +@Api(tags="鍘傚尯鐑偣鐐逛綅") +@RestController +@RequestMapping("/location") +@SuppressWarnings("rawtypes") +public class LocationController { + @Resource + private LocationService locationService; + + @ApiOperation(value = "鏉′欢鏌ヨ鐐逛綅鏁版嵁", notes = "鏍规嵁鍚嶇О鍙婂叾绫诲瀷鏌ヨ鐐逛綅璇︾粏淇℃伅") + @GetMapping("/query") + public Result query( + @RequestParam(value = "name", required = false) String name, + @RequestParam(value = "type", required = true) String type) { + List<Location> data = locationService.query(name, type); + return Result.OK(data); + } + + + @GetMapping("/list") + @ApiOperation(value = "鏌ヨ鎵�鏈夌偣浣嶆暟鎹�", notes = "鏌ヨ鎵�鏈夊巶鍖虹儹鐐圭偣浣嶆暟鎹�") + public Result list() { + List<Location> list = locationService.getAll(); + return Result.OK(list); + } + + + @ApiOperation(value = "鏂板鐐逛綅鏁版嵁", notes = "鏂板鐐逛綅璇︽儏鏁版嵁") + @PostMapping + public Result insertLocation(@RequestBody Location location) { + int i = locationService.insertLocation(location); + if (i == 0) { + return Result.error("鎻掑叆澶辫触"); + } + return Result.OK("鎻掑叆鎴愬姛"); + } + + @ApiOperation(value = "鍒犻櫎鐐逛綅鏁版嵁", notes = "鍒犻櫎鐐逛綅璇︽儏鏁版嵁") + @DeleteMapping("/{id}") + public Result deleteLocation(@PathVariable String id) { + int i = locationService.deleteLocation(id); + if (i == 0) { + return Result.error("鍒犻櫎澶辫触"); + } + return Result.OK("鍒犻櫎鎴愬姛"); + } +} diff --git a/src/main/java/com/yssh/controller/SuYuanController.java b/src/main/java/com/yssh/controller/SuYuanController.java new file mode 100644 index 0000000..4e47744 --- /dev/null +++ b/src/main/java/com/yssh/controller/SuYuanController.java @@ -0,0 +1,190 @@ +package com.yssh.controller; + +import com.yssh.entity.*; +import com.yssh.service.CommonService; +import com.yssh.service.VocValsService; +import com.yssh.utils.StringUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.yssh.service.SuYuanService; +import com.yssh.utils.Result; + +import javax.annotation.Resource; + +/** + * @author lishijia + * @ClassName Yssh2dreliController + * @Description Yssh2dreliController + * @date 2022/12/3 21:21 + * @Version 1.0 + */ +@Api(tags="婧簮淇℃伅") +@RestController +@RequestMapping("/suYuan") +@SuppressWarnings("rawtypes") +public class SuYuanController { + @Resource + private CommonService commonService; + + @Resource + private SuYuanService suYuanService; + + @Resource + private VocValsService vocValsService; + + private final static SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHH"); + + @ApiOperation(value = "鏌ヨ2d鐑姏鍥炬暟鎹�", notes = "鏍规嵁鏃堕棿鏌ヨ2d鐑姏鍥炬暟鎹�") + @ApiOperationSupport(order = 1) + @GetMapping("/get2d") + public Result get2d( + @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) { + List<SuYuan2d> list = suYuanService.selectSuYuan2d(date); + return Result.OK(list); + } + + @ApiOperation(value = "鏌ヨ3d鐑姏鍥炬暟鎹�", notes = "鏍规嵁鏃堕棿鏌ヨ3d鐑姏鍥炬暟鎹�") + @ApiOperationSupport(order = 2) + @GetMapping("/get3d") + public Result get3d( + @RequestParam(value = "name", required = true) String name, + @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) { + List<SuYuan3d> list = suYuanService.selectSuYuan3d(name, date); + return Result.OK(list); + } + + @ApiOperation(value = "鏌ヨ婧簮100鐑姏鍥炬暟鎹�", notes = "鏍规嵁鏃堕棿鏌ヨ婧簮100鐑姏鍥炬暟鎹紝result杩斿洖鍊间腑data瀵瑰簲鍊间负鐑姏鍥炬暟鎹紝feedbackId涓哄弽棣堜富閿紪鍙凤紝鍦ㄨ繘琛屽弽棣堜腑闇�瑕佷紶閫�") + @ApiOperationSupport(order = 3) + @GetMapping("/get100") + public Result get100( + @RequestParam(value = "name", required = true) String name, + @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date + ) { + return Result.OK(suYuanService.selectSuYuan100(name, date)); + } + + @ApiOperation(value = "鏌ヨ婧簮200鐑姏鍥炬暟鎹�", notes = "鏍规嵁鏃堕棿鏌ヨ婧簮200鐑姏鍥炬暟鎹紝result杩斿洖鍊间腑data瀵瑰簲鍊间负鐑姏鍥炬暟鎹紝feedbackId涓哄弽棣堜富閿紪鍙凤紝鍦ㄨ繘琛屽弽棣堜腑闇�瑕佷紶閫�") + @ApiOperationSupport(order = 4) + @GetMapping("/get200") + public Result get200( + @RequestParam(value = "name", required = true) String name, + @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date + ) { + return Result.OK(suYuanService.selectSuYuan200(name, date)); + } + + @ApiOperation(value = "鏌ヨ婧簮300鐑姏鍥炬暟鎹�", notes = "鏍规嵁鏃堕棿鏌ヨ婧簮300鐑姏鍥炬暟鎹紝result杩斿洖鍊间腑data瀵瑰簲鍊间负鐑姏鍥炬暟鎹紝feedbackId涓哄弽棣堜富閿紪鍙凤紝鍦ㄨ繘琛屽弽棣堜腑闇�瑕佷紶閫�") + @ApiOperationSupport(order = 5) + @GetMapping("/get300") + public Result get300( + @RequestParam(value = "name", required = true) String name, + @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date + ) { + return Result.OK(suYuanService.selectSuYuan300(name, date)); + } + + @ApiOperation(value = "鏌ヨ婧簮500鐑姏鍥炬暟鎹�", notes = "鏍规嵁鏃堕棿鏌ヨ婧簮500鐑姏鍥炬暟鎹紝result杩斿洖鍊间腑data瀵瑰簲鍊间负鐑姏鍥炬暟鎹紝feedbackId涓哄弽棣堜富閿紪鍙凤紝鍦ㄨ繘琛屽弽棣堜腑闇�瑕佷紶閫�") + @ApiOperationSupport(order = 6) + @GetMapping("/get500") + public Result get500( + @RequestParam(value = "name", required = true) String name, + @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date + ) { + return Result.OK(suYuanService.selectSuYuan500(name, date)); + } + + @ApiOperation(value = "鑾峰彇鎵�鏈夌洃娴嬫暟鎹�", notes = "鑾峰彇鎵�鏈夌洃娴嬫暟鎹�") + @ApiOperationSupport(order = 7) + @GetMapping("/query/{name}") + public Result getMonitorData(@PathVariable("name") String name) { + List<SuYuanMonitorData> list = suYuanService.getMonitorData(name); + return Result.OK(list); + } + + @ApiOperation(value = "鏇存柊Vocs鍚嶇О", notes = "鏇存柊Vocs鍚嶇О") + @ApiOperationSupport(order = 8) + @GetMapping("/updateVocsName") + public Result updateVocsName(@RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date, + @RequestParam(value = "id", required = true) String id, + @RequestParam(value = "vocsName", required = true) String vocsName + ) { + return Result.OK(suYuanService.updateVocsName(date, id, vocsName)); + } + + @ApiOperation(value = "鏍规嵁鍚嶇О鑾峰彇鍧愭爣鍊�", notes = "鏍规嵁鍚嶇О鑾峰彇鍧愭爣鍊�") + @ApiOperationSupport(order = 9) + @GetMapping("/getCoordByName/{name}") + public Result getCoordByName(@PathVariable("name") String name) { + MonitorPointPosition point = StringUtils.isEmpty(name) ? null : commonService.select3dCheckPointByName(name); + + return Result.OK(point); + } + + @ApiOperation(value = "鏍规嵁Qxsh鍊�", notes = "鏍规嵁Qxsh鍊�") + @ApiOperationSupport(order = 10) + @GetMapping("/queryQxsh") + public Result queryQxsh(@RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) { + List<Qxsh> list = suYuanService.queryQxsh(date); + + return Result.OK(list); + } + + @ApiOperation(value = "鏍规嵁鏃堕棿鏌ヨVoc鍊�", notes = "鏍规嵁鏃堕棿鏌ヨVoc鍊�") + @ApiOperationSupport(order = 11) + @GetMapping("/selectVocByTime") + public Result selectVocByTime(@RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) { + List<VocVals> list = vocValsService.selectByTime(format.format(date)); + + return Result.OK(list); + } + + @ApiOperation(value = "鏍规嵁X锛孻鍊兼煡璇㈠湴鍧�", notes = "鏍规嵁X锛孻鍊兼煡璇㈠湴鍧�") + @ApiOperationSupport(order = 12) + @GetMapping("/selectCoords") + public Result selectVocByTime(@RequestParam(value = "x", required = false) Integer x, @RequestParam(value = "y", required = false) Integer y) { + return Result.OK(vocValsService.selectCoords(x, y)); + } + + @ApiOperation(value = "鏍规嵁X銆乊鍊兼煡璇㈢煩褰㈡", notes = "鏍规嵁X銆乊鍊兼煡璇㈢煩褰㈡") + @ApiOperationSupport(order = 13) + @GetMapping("/selectRects") + public Result selectRects(@RequestParam(value = "x[]", required = true) Double[] x, @RequestParam(value = "y[]", required = true) Double[] y) { + if (null == x || null == y || x.length == 0 || x.length != y.length) return Result.OK(null); + + return Result.OK(suYuanService.selectRects(x, y)); + } + + @ApiOperation(value = "鏍规嵁ID鍜屾棩鏈熸煡璇㈡函婧�700琛�", notes = "鏍规嵁ID鍜屾棩鏈熸煡璇㈡函婧�700琛�") + @ApiOperationSupport(order = 14) + @GetMapping("/selectSuYuan700ById") + public Result selectSuYuan700ById(@RequestParam(value = "id", required = true) String id, @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) { + return Result.OK(suYuanService.selectSuYuan700ById(id, date)); + } + + @ApiOperation(value = "鏍规嵁ID鍜屾棩鏈熸煡璇㈡函婧�46琛�", notes = "鏍规嵁ID鍜屾棩鏈熸煡璇㈡函婧�46琛�") + @ApiOperationSupport(order = 15) + @GetMapping("/selectSuYuan46ById") + public Result selectSuYuan46ById(@RequestParam(value = "id", required = true) String id, @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) { + return Result.OK(suYuanService.selectSuYuan46ById(id, date)); + } + + @ApiOperation(value = "鏍规嵁缁忕含搴︽煡璇㈠湴鍚�", notes = "鏍规嵁缁忕含搴︽煡璇㈠湴鍚�") + @ApiOperationSupport(order = 16) + @GetMapping("/selectAddrByXY") + public Result selectAddrByXY(@RequestParam(value = "x", required = true) double x, @RequestParam(value = "y", required = true) double y) { + return Result.OK(suYuanService.selectAddrByXY(x, y)); + } +} diff --git a/src/main/java/com/yssh/controller/WarningAnalyseController.java b/src/main/java/com/yssh/controller/WarningAnalyseController.java new file mode 100644 index 0000000..632720d --- /dev/null +++ b/src/main/java/com/yssh/controller/WarningAnalyseController.java @@ -0,0 +1,134 @@ +package com.yssh.controller; + +import com.yssh.entity.Qxsh; +import com.yssh.utils.CacheUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.yssh.service.WarningAnalyseService; +import com.yssh.utils.Result; + +import javax.annotation.Resource; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Api(tags = "鍛婅鍒嗘瀽") +@RequestMapping("/warning") +@RestController +@SuppressWarnings("rawtypes") +public class WarningAnalyseController { + @Resource + private WarningAnalyseService warningService; + + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); + + /** + * 1.鏌ヨ褰撳墠鏃堕棿鐨勬墍鏈夌偣浣峷alue鍊硷紙浠�47.dat鏌ヨ鍗冲彲锛� + * 2.绛涢�夊ぇ浜巠ssh_bjyj涓殑jcbj瀛楁鐨勫�� 杩斿洖id+缁忕含搴�+value + */ + @ApiOperationSupport(order = 1) + @ApiOperation(value = "鑾峰彇瀹炴椂鎶ヨ", notes = "鑾峰彇瀹炴椂鎶ヨ鍒嗘瀽鏁版嵁") + @GetMapping("/runAlarm") + public Result alarmAnalyse() { + return Result.OK(warningService.getRunTimeAlarmAnalyse()); + } + + /** + * 1.鏌ヨ褰撳墠鏃堕棿鐨勬墍鏈夌偣浣峷alue鍊硷紙浠�47.dat鏌ヨ鍗冲彲锛� + * 2.绛涢�夊ぇ浜巠ssh_bjyj涓殑jcyj瀛楁鐨勫�� 杩斿洖id+缁忕含搴�+value + */ + @ApiOperationSupport(order = 2) + @ApiOperation(value = "鑾峰彇瀹炴椂棰勮", notes = "鑾峰彇瀹炴椂棰勮鍒嗘瀽鏁版嵁") + @GetMapping("/runWarning") + public Result warningAnalyse() { + return Result.OK(warningService.getRunTimeWarningAnalyse()); + } + + @ApiOperationSupport(order = 3) + @ApiOperation(value = "鏈湀棰勮銆佹姤璀︾粺璁�", notes = "鏈湀棰勮銆佹姤璀︾粺璁★紝杩斿洖鍙傛暟alarmNumber瀵瑰簲鍊间负鏈湀鎶ヨ鏁版嵁閲忥紝鍙傛暟warningNumber瀵瑰簲鍊间负鏈湀棰勮鏁版嵁閲�") + @GetMapping("/monthCount") + public Result thisMonthCount() { + return Result.OK(warningService.countThisMonthAlarmAndWarning()); + } + + @ApiOperationSupport(order = 4) + @ApiOperation(value = "姣忔棩棰勮銆佹姤璀︽暟閲忓彉鍖栬秼鍔�", notes = "涓�鍛ㄦ瘡鏃ラ璀︺�佹姤璀︽暟閲忕粺璁★紝杩斿洖鍙傛暟alarmDayCount涓轰竴鍛ㄦ瘡鏃ユ姤璀︾粺璁℃暟閲忓垪琛紝鍙傛暟warningDayCount涓轰竴鍛ㄦ瘡鏃ラ璀︾粺璁℃暟閲忓垪琛�") + @GetMapping("/everydayCount") + public Result everydayCount() { + return Result.OK(warningService.countEverydayAlarmAndWarning()); + } + + @ApiOperationSupport(order = 4) + @ApiOperation(value = "涓夊皬鏃剁洃娴嬬珯鐐规暟鎹彉鍖栬秼鍔�", notes = "杩斿洖鍊间负涓夊皬鏃剁洃娴嬬珯鐐圭洃娴嬫暟鎹紝杩斿洖鍊间负map闆嗗悎锛屽叾涓璳ey涓虹珯鐐瑰悕绉帮紝value涓簂ist闆嗗悎锛屼繚瀛樻瘡澶╃洃娴嬫暟鍊兼暟鎹�") + @GetMapping("/locationDataChange") + public Result locationDataChange() { + //return Result.OK(warningService.selectEachLocationDataChange()); + + String key = dateFormat.format(new Date()) + "_local"; + Object obj = CacheUtils.get(key); + Map<String, List<Double>> map; + + //if (null != obj) { + // map = (Map<String, List<Double>>) obj; + //} else { + //map = warningService.selectEachLocationDataChange(); + map = warningService.select3Hours(); + // if (null != map && map.size() > 0) { + // CacheUtils.put(key, map); + // } + //} + + return Result.ok(map); + } + + @ApiOperationSupport(order = 4) + @ApiOperation(value = "鑾峰彇鏈湀鐩戞祴澶ф暟鎹珯鐐规渶澶у�糡OP10", notes = "鑾峰彇鏈湀鐩戞祴澶ф暟鎹珯鐐规渶澶у�糡OP10鏁伴噺鍒楄〃") + @GetMapping("/monthTop10") + public Result monthTop10() { + //return Result.OK(warningService.selectThisMonthLocationValueDataTop10()); + + //String key = dateFormat.format(new Date()) + "_top10"; + //Object obj = CacheUtils.get(key); + List<Qxsh> list; + + //if (null != obj) { + // list = (List<Qxsh>) obj; + //} else { + //list = warningService.selectThisMonthLocationValueDataTop10(); + list = warningService.selectMonthTop10(); + // if (null != list && list.size() > 0) { + // CacheUtils.put(key, list); + // } + //} + + return Result.ok(list); + } + + @ApiOperationSupport(order = 5) + @ApiOperation(value = "鏍规嵁鏃堕棿鑾峰彇鎶ヨ鍜岄璀︿俊鎭�", notes = "鏍规嵁鏃堕棿鑾峰彇鎶ヨ鍜岄璀︿俊鎭�") + @GetMapping("/getAlarmAndWarnByTime") + public Result getAlarmAndWarnByTime( + @RequestParam(value = "begin", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date begin, + @RequestParam(value = "end", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date end) { + if (null == begin || null == end) { + return Result.error(null); + } + + if (begin.getTime() > end.getTime()) { + Date tmp = end; + begin = end; + end = tmp; + } + + return Result.OK(warningService.getAlarmAndWarnByTime(begin, end)); + } +} diff --git a/src/main/java/com/yssh/controller/WeatherController.java b/src/main/java/com/yssh/controller/WeatherController.java new file mode 100644 index 0000000..71c1476 --- /dev/null +++ b/src/main/java/com/yssh/controller/WeatherController.java @@ -0,0 +1,90 @@ +package com.yssh.controller; + +import com.yssh.entity.Weather; +import com.yssh.service.WeatherService; +import com.yssh.utils.Result; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; + +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * @author wMeng + * @ClassName YsshWeatherController + * @Description TODO + * @date 2022/10/30 13:21 + * @Version 1.0 + */ +@Api(tags="澶╂皵") +@RestController +@RequestMapping("/weather") +@SuppressWarnings("rawtypes") +public class WeatherController { + @Resource + private WeatherService weatherService; + + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH:00:00"); + + @ApiOperation(value = "鏃堕棿鏌ヨ澶╂皵鏁版嵁", notes = "鏍规嵁寮�濮嬫椂闂村強鍏剁粨鏉熸椂闂存煡璇㈠ぉ姘旇缁嗕俊鎭�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "begin", value = "鐐逛綅鍚嶇О", required = true, type = "String"), + @ApiImplicitParam(name = "end", value = "鐐逛綅绫诲瀷", required = true, type = "String"), + }) + @GetMapping("/query/{begin}/{end}") + public Result query(@PathVariable("begin") String begin, @PathVariable("end") String end) { + List<Weather> data = new ArrayList<>(); + try { + if (null != begin && begin.length() != 19) { + begin = null; + } + if (null != end && end.length() != 19) { + end = null; + } + if (null == begin && null == end) { + begin = dateFormat.format(new Date()); + } + + data = weatherService.query(begin, end); + } catch (Exception e) { + return Result.error(e.getMessage()); + } + return Result.OK(data); + } + + @GetMapping("/getAll") + @ApiOperation(value = "鏌ヨ鎵�鏈夊ぉ姘旀暟鎹�", notes = "鏌ヨ鎵�鏈夊ぉ姘旇缁嗘暟鎹�") + public Result getAll() { + List<Weather> list = weatherService.getAll(); + return Result.OK(list); + } + + @PostMapping("/insert") + @ApiOperation("鎻掑叆鏁版嵁") + public Result insert(@RequestBody Weather ysshWeather) { + int i = weatherService.insert(ysshWeather); + if (i == 0) { + return Result.error("鎻掑叆澶辫触"); + } + return Result.OK("鎻掑叆鎴愬姛"); + } + + @ApiOperation("鍒犻櫎鏁版嵁") + @ApiImplicitParam(name = "id", value = "缂栧彿", required = true, type = "String") + @DeleteMapping("/delete/{id}") + public Result delete(@PathVariable("id") String id) { + int i = weatherService.delete(id); + if (i == 0) { + return Result.error("鍒犻櫎澶辫触"); + } + return Result.OK("鍒犻櫎鎴愬姛"); + } +} diff --git a/src/main/java/com/yssh/entity/AlertConfig.java b/src/main/java/com/yssh/entity/AlertConfig.java new file mode 100644 index 0000000..e071cc4 --- /dev/null +++ b/src/main/java/com/yssh/entity/AlertConfig.java @@ -0,0 +1,74 @@ +package com.yssh.entity; + +import java.io.Serializable; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@ApiModel(value = "鍛婅閰嶇疆鏁版嵁",description = "鍛婅閰嶇疆鏁版嵁") +@NoArgsConstructor +@AllArgsConstructor +@ToString +@Data +public class AlertConfig implements Serializable { + private static final long serialVersionUID = -7332928315187861105L; + + @ApiModelProperty(value = "涓婚敭") + private Integer id; + + @ApiModelProperty(value = "鐩戞祴棰勮鍊�") + private Double jcyj; + + @ApiModelProperty(value = "鐩戞祴鎶ヨ鍊�") + private Double jcbj; + + @ApiModelProperty(value = "鎺掓斁棰勮鍊�") + private Double pfyj; + + @ApiModelProperty(value = "鎺掓斁鎶ヨ鍊�") + private Double pfbj; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Double getJcyj() { + return jcyj; + } + + public void setJcyj(Double jcyj) { + this.jcyj = jcyj; + } + + public Double getJcbj() { + return jcbj; + } + + public void setJcbj(Double jcbj) { + this.jcbj = jcbj; + } + + public Double getPfyj() { + return pfyj; + } + + public void setPfyj(Double pfyj) { + this.pfyj = pfyj; + } + + public Double getPfbj() { + return pfbj; + } + + public void setPfbj(Double pfbj) { + this.pfbj = pfbj; + } +} diff --git a/src/main/java/com/yssh/entity/Coordinate.java b/src/main/java/com/yssh/entity/Coordinate.java new file mode 100644 index 0000000..988cf4d --- /dev/null +++ b/src/main/java/com/yssh/entity/Coordinate.java @@ -0,0 +1,36 @@ +package com.yssh.entity; + +/** + * 鍧愭爣 + * @author WWW + * @date 2023-06-18 + */ +public class Coordinate { + private double x; + + private double y; + + public Coordinate() { + } + + public Coordinate(double x, double y) { + this.x = x; + this.y = y; + } + + public double getX() { + return x; + } + + public void setX(double x) { + this.x = x; + } + + public double getY() { + return y; + } + + public void setY(double y) { + this.y = y; + } +} diff --git a/src/main/java/com/yssh/entity/DictRecord.java b/src/main/java/com/yssh/entity/DictRecord.java new file mode 100644 index 0000000..9183124 --- /dev/null +++ b/src/main/java/com/yssh/entity/DictRecord.java @@ -0,0 +1,88 @@ +package com.yssh.entity; + +import java.io.Serializable; + +import lombok.Data; +import lombok.ToString; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; + +/** + * 瀛楀吀璁板綍瀵硅薄 yssh_dict_record + * + * @author xingjinshuang@smartearth.cn + * @date 2023-02-06 + */ + +@ToString +@Data +public class DictRecord implements Serializable { + /** + * @Fields field:field:{todo}(鐢ㄤ竴鍙ヨ瘽鎻忚堪杩欎釜鍙橀噺琛ㄧず浠�涔�) + */ + private static final long serialVersionUID = -3279329060924610189L; + + /** + * ID + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + /** + * 琛ㄥ悕绉� + */ + private String tableName; + + /** + * 鍒涘缓鏃堕棿 + */ + private Long createTime; + + /** + * 澶囨敞 + */ + private String remarks; + + public DictRecord() { + } + + public DictRecord(Long id, String tableName, Long createTime, String remarks) { + this.id = id; + this.tableName = tableName; + this.createTime = createTime; + this.remarks = remarks; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + public Long getCreateTime() { + return createTime; + } + + public void setCreateTime(Long createTime) { + this.createTime = createTime; + } + + public String getRemarks() { + return remarks; + } + + public void setRemarks(String remarks) { + this.remarks = remarks; + } +} diff --git a/src/main/java/com/yssh/entity/DistanceSuYuan.java b/src/main/java/com/yssh/entity/DistanceSuYuan.java new file mode 100644 index 0000000..c7bc9cc --- /dev/null +++ b/src/main/java/com/yssh/entity/DistanceSuYuan.java @@ -0,0 +1,149 @@ +package com.yssh.entity; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.math.RoundingMode; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.yssh.utils.CalculateUtils; + +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@NoArgsConstructor +@AllArgsConstructor +@ToString +public class DistanceSuYuan implements Serializable, Comparable<DistanceSuYuan> { + private static final long serialVersionUID = -115407591473808022L; + + private String name; + + private String vocsName; + + private double vocsValue; + + private String id; + @JsonIgnore + private Integer x; + @JsonIgnore + private Integer y; + @JsonIgnore + private double u; + @JsonIgnore + private double v; + + private double windSpeed; + + private double windDirection; + + private double lon; + + private double lat; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Integer getX() { + return x; + } + + public void setX(Integer x) { + this.x = x; + } + + public Integer getY() { + return y; + } + + public void setY(Integer y) { + this.y = y; + } + + public double getLon() { + return CalculateUtils.getLon(x, y); + } + + public double getLat() { + return CalculateUtils.getLat(x, y); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVocsName() { + return vocsName; + } + + public void setVocsName(String vocsName) { + this.vocsName = vocsName; + } + + public double getVocsValue() { + return vocsValue; + } + + public void setVocsValue(double vocsValue) { + this.vocsValue = vocsValue; + } + + public void setU(double u) { + this.u = u; + } + + public void setV(double v) { + this.v = v; + } + + public double getWindSpeed() { + return new BigDecimal(CalculateUtils.getWindSpeed(v, u)).setScale(2, RoundingMode.HALF_UP).doubleValue(); + } + + public double getWindDirection() { + return new BigDecimal(CalculateUtils.getWindDirection(v, u)).setScale(2, RoundingMode.HALF_UP).doubleValue(); + } + + @Override + public int compareTo(DistanceSuYuan o) { + if (vocsValue > o.getVocsValue()) { + return -1; + } else if (vocsValue == o.getVocsValue()) { + return 0; + } + return 1; + } + + public double getU() { + return u; + } + + public double getV() { + return v; + } + + public void setWindSpeed(double windSpeed) { + this.windSpeed = windSpeed; + } + + public void setWindDirection(double windDirection) { + this.windDirection = windDirection; + } + + public void setLon(double lon) { + this.lon = lon; + } + + public void setLat(double lat) { + this.lat = lat; + } +} diff --git a/src/main/java/com/yssh/entity/Emission.java b/src/main/java/com/yssh/entity/Emission.java new file mode 100644 index 0000000..9cd5e8e --- /dev/null +++ b/src/main/java/com/yssh/entity/Emission.java @@ -0,0 +1,85 @@ +package com.yssh.entity; + +import java.io.Serializable; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(value = "鎺掓斁鐐圭偣浣�",description = "鎺掓斁鐐圭偣浣�") +public class Emission implements Serializable{ + + private static final long serialVersionUID = -6398611940241117240L; + + @ApiModelProperty(value = "涓婚敭") + private int id; + @ApiModelProperty(value = "鐐逛綅鍚嶇О") + private String name; + @ApiModelProperty(value = "缁忓害") + private double lon; + @ApiModelProperty(value = "绾害") + private float lat; + @ApiModelProperty(value = "鏁板��") + private String value; + @ApiModelProperty(value = "鏃堕棿") + private String time; + @ApiModelProperty(value = "鐘舵�佸��") + private int property; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getLon() { + return lon; + } + + public void setLon(double lon) { + this.lon = lon; + } + + public float getLat() { + return lat; + } + + public void setLat(float lat) { + this.lat = lat; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public int getProperty() { + return property; + } + + public void setProperty(int property) { + this.property = property; + } +} diff --git a/src/main/java/com/yssh/entity/ExpPoint.java b/src/main/java/com/yssh/entity/ExpPoint.java new file mode 100644 index 0000000..bfea555 --- /dev/null +++ b/src/main/java/com/yssh/entity/ExpPoint.java @@ -0,0 +1,144 @@ +package com.yssh.entity; + +import java.util.Date; + +import lombok.Data; + +@Data +public class ExpPoint { + private Long id; + private String expSiteNumber; + private String expPointType; + private double ordinateX; + private double abscissaY; + private double elevation; + private double explorationDepth; + private Date expStartDate; + private Date expEndDate; + private double groundwaterDepth; + private String waveSpeedInstrument; + private String waveVelocityMethod; + private String waveVelocityExcitationDistance; + private String waterDepth; + private int isParticipate; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getExpSiteNumber() { + return expSiteNumber; + } + + public void setExpSiteNumber(String expSiteNumber) { + this.expSiteNumber = expSiteNumber; + } + + public String getExpPointType() { + return expPointType; + } + + public void setExpPointType(String expPointType) { + this.expPointType = expPointType; + } + + public double getOrdinateX() { + return ordinateX; + } + + public void setOrdinateX(double ordinateX) { + this.ordinateX = ordinateX; + } + + public double getAbscissaY() { + return abscissaY; + } + + public void setAbscissaY(double abscissaY) { + this.abscissaY = abscissaY; + } + + public double getElevation() { + return elevation; + } + + public void setElevation(double elevation) { + this.elevation = elevation; + } + + public double getExplorationDepth() { + return explorationDepth; + } + + public void setExplorationDepth(double explorationDepth) { + this.explorationDepth = explorationDepth; + } + + public Date getExpStartDate() { + return expStartDate; + } + + public void setExpStartDate(Date expStartDate) { + this.expStartDate = expStartDate; + } + + public Date getExpEndDate() { + return expEndDate; + } + + public void setExpEndDate(Date expEndDate) { + this.expEndDate = expEndDate; + } + + public double getGroundwaterDepth() { + return groundwaterDepth; + } + + public void setGroundwaterDepth(double groundwaterDepth) { + this.groundwaterDepth = groundwaterDepth; + } + + public String getWaveSpeedInstrument() { + return waveSpeedInstrument; + } + + public void setWaveSpeedInstrument(String waveSpeedInstrument) { + this.waveSpeedInstrument = waveSpeedInstrument; + } + + public String getWaveVelocityMethod() { + return waveVelocityMethod; + } + + public void setWaveVelocityMethod(String waveVelocityMethod) { + this.waveVelocityMethod = waveVelocityMethod; + } + + public String getWaveVelocityExcitationDistance() { + return waveVelocityExcitationDistance; + } + + public void setWaveVelocityExcitationDistance(String waveVelocityExcitationDistance) { + this.waveVelocityExcitationDistance = waveVelocityExcitationDistance; + } + + public String getWaterDepth() { + return waterDepth; + } + + public void setWaterDepth(String waterDepth) { + this.waterDepth = waterDepth; + } + + public int getIsParticipate() { + return isParticipate; + } + + public void setIsParticipate(int isParticipate) { + this.isParticipate = isParticipate; + } +} diff --git a/src/main/java/com/yssh/entity/FeedbackDetail.java b/src/main/java/com/yssh/entity/FeedbackDetail.java new file mode 100644 index 0000000..a12a8bb --- /dev/null +++ b/src/main/java/com/yssh/entity/FeedbackDetail.java @@ -0,0 +1,136 @@ +package com.yssh.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; +import java.util.Date; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@ToString +@Data +@ApiModel(value = "婧簮鍙嶉",description = "婧簮鍙嶉") +public class FeedbackDetail implements Serializable{ + public FeedbackDetail() { + } + + public FeedbackDetail(Long id, String tableName, String locationName, String detectionId, String detectionVocsName, Double detectionValue, String practicalId, String practicalVocsName, Double practicalValue, Date createTime) { + this.id = id; + this.tableName = tableName; + this.locationName = locationName; + this.detectionId = detectionId; + this.detectionVocsName = detectionVocsName; + this.detectionValue = detectionValue; + this.practicalId = practicalId; + this.practicalVocsName = practicalVocsName; + this.practicalValue = practicalValue; + this.createTime = createTime; + } + + private static final long serialVersionUID = 6877008992053903605L; + + @ApiModelProperty(value = "涓婚敭") + private Long id; + @ApiModelProperty(value = "琛ㄥ悕") + private String tableName; + @ApiModelProperty(value = "鐐逛綅鍚嶇О") + private String locationName; + @ApiModelProperty(value = "妫�娴嬬紪鍙�") + private String detectionId; + @ApiModelProperty(value = "妫�娴媣ocs鍚嶇О") + private String detectionVocsName; + @ApiModelProperty(value = "妫�娴嬪��") + private Double detectionValue; + @ApiModelProperty(value = "瀹為檯缂栧彿") + private String practicalId; + @ApiModelProperty(value = "瀹為檯vocs鍚嶇О") + private String practicalVocsName; + @ApiModelProperty(value = "瀹為檯鍊�") + private Double practicalValue; + @ApiModelProperty(value = "鍒涘缓鏃堕棿") + private Date createTime; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + public String getLocationName() { + return locationName; + } + + public void setLocationName(String locationName) { + this.locationName = locationName; + } + + public String getDetectionId() { + return detectionId; + } + + public void setDetectionId(String detectionId) { + this.detectionId = detectionId; + } + + public String getDetectionVocsName() { + return detectionVocsName; + } + + public void setDetectionVocsName(String detectionVocsName) { + this.detectionVocsName = detectionVocsName; + } + + public Double getDetectionValue() { + return detectionValue; + } + + public void setDetectionValue(Double detectionValue) { + this.detectionValue = detectionValue; + } + + public String getPracticalId() { + return practicalId; + } + + public void setPracticalId(String practicalId) { + this.practicalId = practicalId; + } + + public String getPracticalVocsName() { + return practicalVocsName; + } + + public void setPracticalVocsName(String practicalVocsName) { + this.practicalVocsName = practicalVocsName; + } + + public Double getPracticalValue() { + return practicalValue; + } + + public void setPracticalValue(Double practicalValue) { + this.practicalValue = practicalValue; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } +} diff --git a/src/main/java/com/yssh/entity/ForecastAnalyseVo.java b/src/main/java/com/yssh/entity/ForecastAnalyseVo.java new file mode 100644 index 0000000..51db459 --- /dev/null +++ b/src/main/java/com/yssh/entity/ForecastAnalyseVo.java @@ -0,0 +1,53 @@ +package com.yssh.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@ToString +@ApiModel(value="棰勬祴鍒嗘瀽灞曠ず瀵硅薄", description="棰勬祴鍒嗘瀽灞曠ず瀵硅薄") +@Data +public class ForecastAnalyseVo { + public ForecastAnalyseVo() { + } + + public ForecastAnalyseVo(Double forecastValue, Double practicalValue, Long time) { + this.forecastValue = forecastValue; + this.practicalValue = practicalValue; + this.time = time; + } + + @ApiModelProperty(value = "棰勬祴鍊�") + private Double forecastValue; + @ApiModelProperty(value = "瀹為檯鍊�") + private Double practicalValue; + @ApiModelProperty(value = "鏃堕棿") + private Long time; + + public Double getForecastValue() { + return forecastValue; + } + + public void setForecastValue(Double forecastValue) { + this.forecastValue = forecastValue; + } + + public Double getPracticalValue() { + return practicalValue; + } + + public void setPracticalValue(Double practicalValue) { + this.practicalValue = practicalValue; + } + + public Long getTime() { + return time; + } + + public void setTime(Long time) { + this.time = time; + } +} diff --git a/src/main/java/com/yssh/entity/Location.java b/src/main/java/com/yssh/entity/Location.java new file mode 100644 index 0000000..ab5a31d --- /dev/null +++ b/src/main/java/com/yssh/entity/Location.java @@ -0,0 +1,70 @@ +package com.yssh.entity; + +import java.io.Serializable; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 鍘傚尯鐑偣鐐逛綅 + * @author wMeng + * @date 2022/10/30 13:16 + * @version 1.0 + */ +@Data +@ApiModel(value = "鍘傚尯鐑偣鐐逛綅",description = "鍘傚尯鐑偣鐐逛綅") +public class Location implements Serializable { + private static final long serialVersionUID = -2728687771987124891L; + + @ApiModelProperty(value = "涓婚敭") + private int id; + @ApiModelProperty(value = "鐐逛綅鍚嶇О") + private String name; + @ApiModelProperty(value = "鐐逛綅绫诲瀷") + private String type; + @ApiModelProperty(value = "鐐逛綅缁忓害") + private double lon; + @ApiModelProperty(value = "鐐逛綅绾害") + private double lat; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public double getLon() { + return lon; + } + + public void setLon(double lon) { + this.lon = lon; + } + + public double getLat() { + return lat; + } + + public void setLat(double lat) { + this.lat = lat; + } +} diff --git a/src/main/java/com/yssh/entity/MonitorPointPosition.java b/src/main/java/com/yssh/entity/MonitorPointPosition.java new file mode 100644 index 0000000..617972e --- /dev/null +++ b/src/main/java/com/yssh/entity/MonitorPointPosition.java @@ -0,0 +1,86 @@ +package com.yssh.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; + + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@ApiModel(value="鐩戞祴鐐逛綅瀵硅薄", description="鐩戞祴鐐逛綅瀵硅薄") +public class MonitorPointPosition implements Serializable { + private static final long serialVersionUID = -7054999641619312155L; + + private String id; + @ApiModelProperty(value = "鐐逛綅鍚嶇О") + private String name; + private Integer x; + private Integer y; + private Integer z; + @ApiModelProperty(value = "缁忓害") + private Double lon; + @ApiModelProperty(value = "绾害") + private Double lat; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getX() { + return x; + } + + public void setX(Integer x) { + this.x = x; + } + + public Integer getY() { + return y; + } + + public void setY(Integer y) { + this.y = y; + } + + public Integer getZ() { + return z; + } + + public void setZ(Integer z) { + this.z = z; + } + + public Double getLon() { + return lon; + } + + public void setLon(Double lon) { + this.lon = lon; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } +} diff --git a/src/main/java/com/yssh/entity/Qxsh.java b/src/main/java/com/yssh/entity/Qxsh.java new file mode 100644 index 0000000..8fcf7b2 --- /dev/null +++ b/src/main/java/com/yssh/entity/Qxsh.java @@ -0,0 +1,83 @@ +package com.yssh.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author WWW + * @date 2023-05-18 + * qxsh + */ +@Data +@ApiModel(value = "Qxsh",description = "Qxsh") +public class Qxsh { + @ApiModelProperty(value = "涓婚敭") + private Integer id; + + @ApiModelProperty(value = "鍚嶇О") + private String name; + + @ApiModelProperty(value = "缁忓害") + private Double lon; + + @ApiModelProperty(value = "绾害") + private Double lat; + + @ApiModelProperty(value = "鏁板��") + private Double value; + + @ApiModelProperty(value = "鏃堕棿") + private String time; + + public Qxsh() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Double getLon() { + return lon; + } + + public void setLon(Double lon) { + this.lon = lon; + } + + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public Double getValue() { + return value; + } + + public void setValue(Double value) { + this.value = value; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } +} diff --git a/src/main/java/com/yssh/entity/Report.java b/src/main/java/com/yssh/entity/Report.java new file mode 100644 index 0000000..bd41333 --- /dev/null +++ b/src/main/java/com/yssh/entity/Report.java @@ -0,0 +1,199 @@ +package com.yssh.entity; + +import com.yssh.utils.CalculateUtils; +import io.swagger.annotations.ApiModelProperty; + +/** + * 鎶ュ憡 + * @author WWW + * @date 2023-06-18 + */ +public class Report { + @ApiModelProperty(value = "婧簮ID") + private String id; + + @ApiModelProperty(value = "鐐逛綅鍚嶇О") + private String name; + + @ApiModelProperty(value = "缁忓害") + private double lon; + + @ApiModelProperty(value = "绾害") + private double lat; + + @ApiModelProperty(value = "鏁板��") + private double val; + + @ApiModelProperty(value = "鍘诲勾鏁板��") + private Double lastVal; + + @ApiModelProperty(value = "鏃堕棿") + private String time; + + @ApiModelProperty(value = "椋庨��") + private double speed; + + @ApiModelProperty(value = "鏂瑰悜") + private String dir; + + @ApiModelProperty(value = "500m鑼冨洿鏈�澶у��") + private double maxVal; + + @ApiModelProperty(value = "璺濈") + private double dis; + + @ApiModelProperty(value = "500m鑼冨洿鏈�澶у�肩殑椋庡悜") + private String maxDir; + + @ApiModelProperty(value = "鏄惁涓�鑷�") + private int isSame; + + public Report() { + } + + public Report(String id, String name, double lon, double lat, double val, String time, double speed, String dir, double maxVal, double dis, String maxDir, int isSame) { + this.id = id; + this.name = name; + this.lon = lon; + this.lat = lat; + this.val = val; + this.time = time; + this.speed = speed; + this.dir = dir; + this.maxVal = maxVal; + this.dis = dis; + this.maxDir = maxDir; + this.isSame = isSame; + } + + /** + * 璁$畻鐢熸垚鎶ュ憡 + */ + public static Report calcReport(WarningDetail wd, DistanceSuYuan suYuan, DistanceSuYuan suMax) { + Coordinate c1 = CalculateUtils.getCoordinate(suYuan); + Coordinate c2 = CalculateUtils.getCoordinate(suMax); + + String time = wd.getTableName().replace("su_yuan_", ""); + double speed1 = CalculateUtils.round2(CalculateUtils.getWindSpeed(suYuan.getV(), suYuan.getU())); + double direction1 = CalculateUtils.getWindDirection(suYuan.getV(), suYuan.getU()); + String dir = CalculateUtils.getDir(direction1); + + double maxVal = suMax.getVocsValue(); + + //double dis = CalculateUtils.getDistance2(c1.getX(), c1.getY(), c2.getX(), c2.getY()); + double dis1 = CalculateUtils.getDistance1(c1.getX(), c1.getY(), c2.getX(), c2.getY()); + double angle = CalculateUtils.getAngle2(c1.getX(), c1.getY(), c2.getX(), c2.getY()); + + double speed2 = CalculateUtils.getWindSpeed(suMax.getV(), suMax.getU()); + double direction2 = CalculateUtils.getWindDirection(suMax.getV(), suMax.getU()); + String maxDir = CalculateUtils.getDir(direction2); // CalculateUtils.getDir(angle); + int isSame = (Math.abs(direction1 - direction2) <= 45 && Math.abs(speed1 - speed2) <= 0.5) ? 1 : 0; + + return new Report(wd.getSuYuanId(), wd.getLocationName(), c1.getX(), c1.getY(), wd.getValue(), time, + speed1, dir, maxVal, dis1, maxDir, isSame); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getLon() { + return lon; + } + + public void setLon(double lon) { + this.lon = lon; + } + + public double getLat() { + return lat; + } + + public void setLat(double lat) { + this.lat = lat; + } + + public double getVal() { + return val; + } + + public void setVal(double val) { + this.val = val; + } + + public Double getLastVal() { + return lastVal; + } + + public void setLastVal(Double lastVal) { + this.lastVal = lastVal; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public double getSpeed() { + return speed; + } + + public void setSpeed(double speed) { + this.speed = speed; + } + + public String getDir() { + return dir; + } + + public void setDir(String dir) { + this.dir = dir; + } + + public double getMaxVal() { + return maxVal; + } + + public void setMaxVal(double maxVal) { + this.maxVal = maxVal; + } + + public double getDis() { + return dis; + } + + public void setDis(double dis) { + this.dis = dis; + } + + public String getMaxDir() { + return maxDir; + } + + public void setMaxDir(String maxDir) { + this.maxDir = maxDir; + } + + public int getIsSame() { + return isSame; + } + + public void setIsSame(int isSame) { + this.isSame = isSame; + } +} diff --git a/src/main/java/com/yssh/entity/Stratum.java b/src/main/java/com/yssh/entity/Stratum.java new file mode 100644 index 0000000..9083da4 --- /dev/null +++ b/src/main/java/com/yssh/entity/Stratum.java @@ -0,0 +1,99 @@ +package com.yssh.entity; + +import lombok.Data; +import lombok.ToString; + +@Data +@ToString +public class Stratum { + private Long id; + private String expSiteNumber; + private Integer primaryLayerNumber; + private Integer sublayerNumber; + private String geologicalEra; + private String geologicalGenesis; + private Double layerDepth; + private String geotechnicalName; + private String geotechnicalCategory; + private String description; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getExpSiteNumber() { + return expSiteNumber; + } + + public void setExpSiteNumber(String expSiteNumber) { + this.expSiteNumber = expSiteNumber; + } + + public Integer getPrimaryLayerNumber() { + return primaryLayerNumber; + } + + public void setPrimaryLayerNumber(Integer primaryLayerNumber) { + this.primaryLayerNumber = primaryLayerNumber; + } + + public Integer getSublayerNumber() { + return sublayerNumber; + } + + public void setSublayerNumber(Integer sublayerNumber) { + this.sublayerNumber = sublayerNumber; + } + + public String getGeologicalEra() { + return geologicalEra; + } + + public void setGeologicalEra(String geologicalEra) { + this.geologicalEra = geologicalEra; + } + + public String getGeologicalGenesis() { + return geologicalGenesis; + } + + public void setGeologicalGenesis(String geologicalGenesis) { + this.geologicalGenesis = geologicalGenesis; + } + + public Double getLayerDepth() { + return layerDepth; + } + + public void setLayerDepth(Double layerDepth) { + this.layerDepth = layerDepth; + } + + public String getGeotechnicalName() { + return geotechnicalName; + } + + public void setGeotechnicalName(String geotechnicalName) { + this.geotechnicalName = geotechnicalName; + } + + public String getGeotechnicalCategory() { + return geotechnicalCategory; + } + + public void setGeotechnicalCategory(String geotechnicalCategory) { + this.geotechnicalCategory = geotechnicalCategory; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/main/java/com/yssh/entity/SuYuan.java b/src/main/java/com/yssh/entity/SuYuan.java new file mode 100644 index 0000000..93fe990 --- /dev/null +++ b/src/main/java/com/yssh/entity/SuYuan.java @@ -0,0 +1,99 @@ +package com.yssh.entity; + +import java.io.Serializable; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import com.github.biyanwen.annotation.CsvProperty; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SuYuan implements Serializable { + + private static final long serialVersionUID = 2004641202487367361L; + private String id; + @CsvProperty(index = 0) + private Integer x; + @CsvProperty(index = 1) + private Integer y; + @CsvProperty(index = 2) + private Integer z; + @CsvProperty(index = 3) + private Double u; + @CsvProperty(index = 4) + private Double v; + @CsvProperty(index = 5) + private Double w; + @CsvProperty(index = 6) + private Double c; + /*private Double lon; + private Double lat; + private Date time;*/ + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Integer getX() { + return x; + } + + public void setX(Integer x) { + this.x = x; + } + + public Integer getY() { + return y; + } + + public void setY(Integer y) { + this.y = y; + } + + public Integer getZ() { + return z; + } + + public void setZ(Integer z) { + this.z = z; + } + + public Double getU() { + return u; + } + + public void setU(Double u) { + this.u = u; + } + + public Double getV() { + return v; + } + + public void setV(Double v) { + this.v = v; + } + + public Double getW() { + return w; + } + + public void setW(Double w) { + this.w = w; + } + + public Double getC() { + return c; + } + + public void setC(Double c) { + this.c = c; + } +} diff --git a/src/main/java/com/yssh/entity/SuYuan2d.java b/src/main/java/com/yssh/entity/SuYuan2d.java new file mode 100644 index 0000000..742fe00 --- /dev/null +++ b/src/main/java/com/yssh/entity/SuYuan2d.java @@ -0,0 +1,69 @@ +package com.yssh.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.yssh.utils.CalculateUtils; + +import lombok.ToString; + +@ToString +@ApiModel(value="婧簮2d瀵硅薄", description="婧簮2d瀵硅薄") +public class SuYuan2d implements Serializable { + + private static final long serialVersionUID = -4652224366972823014L; + @ApiModelProperty(value = "涓婚敭") + private String id; + @JsonIgnore + private Integer x; + @JsonIgnore + private Integer y; + @ApiModelProperty(value = "缁忓害") + private double lon; + @ApiModelProperty(value = "绾害") + private double lat; + @ApiModelProperty(value = "鏁板��") + private double value; + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public Integer getX() { + return x; + } + public void setX(Integer x) { + this.x = x; + } + public Integer getY() { + return y; + } + public void setY(Integer y) { + this.y = y; + } + public double getLon() { + return CalculateUtils.getLon(x, y); + } + + public double getLat() { + return CalculateUtils.getLat(x, y); + } + + public double getValue() { + return value; + } + public void setValue(double value) { + this.value = value; + } + + public void setLon(double lon) { + this.lon = lon; + } + + public void setLat(double lat) { + this.lat = lat; + } +} diff --git a/src/main/java/com/yssh/entity/SuYuan3d.java b/src/main/java/com/yssh/entity/SuYuan3d.java new file mode 100644 index 0000000..8d0054e --- /dev/null +++ b/src/main/java/com/yssh/entity/SuYuan3d.java @@ -0,0 +1,131 @@ +package com.yssh.entity; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.yssh.utils.CalculateUtils; + +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@NoArgsConstructor +@AllArgsConstructor +@ToString +@ApiModel(value = "3d鏁版嵁",description = "3d鏁版嵁") +public class SuYuan3d implements Serializable{ + + /** + * @Fields field:field:{todo}(鐢ㄤ竴鍙ヨ瘽鎻忚堪杩欎釜鍙橀噺琛ㄧず浠�涔�) + */ + private static final long serialVersionUID = 5955771070977977633L; + @ApiModelProperty(value = "涓婚敭") + private String id; + @JsonIgnore + private Integer x; + @JsonIgnore + private Integer y; + @ApiModelProperty(value = "缁忓害") + private double lon; + @ApiModelProperty(value = "绾害") + private double lat; + private double height0 = 0.0; + private double height10 = 0.0; + private double height20 = 0.0; + private double height30 = 0.0; + private double height40 = 0.0; + private double height50 = 0.0; + private double height60 = 0.0; + private double height70 = 0.0; + private double height80 = 0.0; + private double height90 = 0.0; + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public Integer getX() { + return x; + } + public void setX(Integer x) { + this.x = x; + } + public Integer getY() { + return y; + } + public void setY(Integer y) { + this.y = y; + } + public double getLon() { + return CalculateUtils.getLon(x, y); + } + + public double getLat() { + return CalculateUtils.getLat(x, y); + } + public double getHeight0() { + return height0; + } + public void setHeight0(double height0) { + this.height0 = height0; + } + public double getHeight10() { + return height10; + } + public void setHeight10(double height10) { + this.height10 = height10; + } + public double getHeight20() { + return height20; + } + public void setHeight20(double height20) { + this.height20 = height20; + } + public double getHeight30() { + return height30; + } + public void setHeight30(double height30) { + this.height30 = height30; + } + public double getHeight40() { + return height40; + } + public void setHeight40(double height40) { + this.height40 = height40; + } + public double getHeight50() { + return height50; + } + public void setHeight50(double height50) { + this.height50 = height50; + } + public double getHeight60() { + return height60; + } + public void setHeight60(double height60) { + this.height60 = height60; + } + public double getHeight70() { + return height70; + } + public void setHeight70(double height70) { + this.height70 = height70; + } + public double getHeight80() { + return height80; + } + public void setHeight80(double height80) { + this.height80 = height80; + } + public double getHeight90() { + return height90; + } + public void setHeight90(double height90) { + this.height90 = height90; + } +} diff --git a/src/main/java/com/yssh/entity/SuYuan700.java b/src/main/java/com/yssh/entity/SuYuan700.java new file mode 100644 index 0000000..4f1aa92 --- /dev/null +++ b/src/main/java/com/yssh/entity/SuYuan700.java @@ -0,0 +1,187 @@ +package com.yssh.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 婧簮700琛� + * @author www + * @date 2023-06-23 + */ +@Data +public class SuYuan700 implements Serializable { + private static final long serialVersionUID = 2023062302487367361L; + + @ApiModelProperty(value = "涓婚敭ID") + private Long id; + + @ApiModelProperty(value = "婧簮ID") + private String suYuanId; + + @ApiModelProperty(value = "鍦板潃1") + private String addr1; + + @ApiModelProperty(value = "姒傜巼1") + private Double odds1; + + @ApiModelProperty(value = "X1") + private Double x1; + + @ApiModelProperty(value = "Y1") + private Double y1; + + @ApiModelProperty(value = "鍦板潃2") + private String addr2; + + @ApiModelProperty(value = "姒傜巼2") + private Double odds2; + + @ApiModelProperty(value = "X2") + private Double x2; + + @ApiModelProperty(value = "Y2") + private Double y2; + + @ApiModelProperty(value = "鍦板潃3") + private String addr3; + + @ApiModelProperty(value = "姒傜巼3") + private Double odds3; + + @ApiModelProperty(value = "X3") + private Double x3; + + @ApiModelProperty(value = "Y3") + private Double y3; + + @ApiModelProperty(value = "鏃堕棿") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; + + public SuYuan700() { + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getSuYuanId() { + return suYuanId; + } + + public void setSuYuanId(String suYuanId) { + this.suYuanId = suYuanId; + } + + public String getAddr1() { + return addr1; + } + + public void setAddr1(String addr1) { + this.addr1 = addr1; + } + + public Double getOdds1() { + return odds1; + } + + public void setOdds1(Double odds1) { + this.odds1 = odds1; + } + + public Double getX1() { + return x1; + } + + public void setX1(Double x1) { + this.x1 = x1; + } + + public Double getY1() { + return y1; + } + + public void setY1(Double y1) { + this.y1 = y1; + } + + public String getAddr2() { + return addr2; + } + + public void setAddr2(String addr2) { + this.addr2 = addr2; + } + + public Double getOdds2() { + return odds2; + } + + public void setOdds2(Double odds2) { + this.odds2 = odds2; + } + + public Double getX2() { + return x2; + } + + public void setX2(Double x2) { + this.x2 = x2; + } + + public Double getY2() { + return y2; + } + + public void setY2(Double y2) { + this.y2 = y2; + } + + public String getAddr3() { + return addr3; + } + + public void setAddr3(String addr3) { + this.addr3 = addr3; + } + + public Double getOdds3() { + return odds3; + } + + public void setOdds3(Double odds3) { + this.odds3 = odds3; + } + + public Double getX3() { + return x3; + } + + public void setX3(Double x3) { + this.x3 = x3; + } + + public Double getY3() { + return y3; + } + + public void setY3(Double y3) { + this.y3 = y3; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } +} diff --git a/src/main/java/com/yssh/entity/SuYuanMonitorData.java b/src/main/java/com/yssh/entity/SuYuanMonitorData.java new file mode 100644 index 0000000..586ac6c --- /dev/null +++ b/src/main/java/com/yssh/entity/SuYuanMonitorData.java @@ -0,0 +1,48 @@ +package com.yssh.entity; + +import java.io.Serializable; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@ApiModel(value = "婧簮鐩戞祴鏁版嵁",description = "婧簮鐩戞祴鏁版嵁") +public class SuYuanMonitorData implements Serializable{ + + private static final long serialVersionUID = -7472189043893753483L; + @ApiModelProperty(value = "涓婚敭") + private String id; + @ApiModelProperty(value = "鏁板��") + private Double value; + @ApiModelProperty(value = "鏃堕棿") + private Integer time; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Double getValue() { + return value; + } + + public void setValue(Double value) { + this.value = value; + } + + public Integer getTime() { + return time; + } + + public void setTime(Integer time) { + this.time = time; + } +} diff --git a/src/main/java/com/yssh/entity/Temporary.java b/src/main/java/com/yssh/entity/Temporary.java new file mode 100644 index 0000000..efd6bee --- /dev/null +++ b/src/main/java/com/yssh/entity/Temporary.java @@ -0,0 +1,105 @@ +package com.yssh.entity; + + +import java.io.Serializable; + +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; + +import com.github.biyanwen.annotation.CsvProperty; +import com.yssh.utils.CalculateUtils; + +@NoArgsConstructor +@AllArgsConstructor +public class Temporary implements Serializable { + + private static final long serialVersionUID = 8801687493177033295L; + private Integer x; + private Integer y; + @CsvProperty(index = 0) + private Double lon; + @CsvProperty(index = 1) + private Double lat; + @CsvProperty(index = 2) + private Integer z; + @CsvProperty(index = 3) + private Double u; + @CsvProperty(index = 4) + private Double v; + @CsvProperty(index = 5) + private Double w; + @CsvProperty(index = 6) + private Double c; + + public Integer getX() { + return x; + } + + public void setX(Integer x) { + this.x = x; + } + + public Integer getY() { + return y; + } + + public void setY(Integer y) { + this.y = y; + } + + public Integer getZ() { + return z; + } + + public void setZ(Integer z) { + this.z = z; + } + + public double getLon() { + return CalculateUtils.getLon(x, y); + } + + public double getLat() { + return CalculateUtils.getLat(x, y); + } + + public Double getU() { + return u; + } + + public void setU(Double u) { + this.u = u; + } + + public Double getV() { + return v; + } + + public void setV(Double v) { + this.v = v; + } + + public Double getW() { + return w; + } + + public void setW(Double w) { + this.w = w; + } + + public Double getC() { + return c; + } + + public void setC(Double c) { + this.c = c; + } + + public void setLon(Double lon) { + this.lon = lon; + } + + public void setLat(Double lat) { + this.lat = lat; + } +} diff --git a/src/main/java/com/yssh/entity/ThuAccuracy.java b/src/main/java/com/yssh/entity/ThuAccuracy.java new file mode 100644 index 0000000..a346e60 --- /dev/null +++ b/src/main/java/com/yssh/entity/ThuAccuracy.java @@ -0,0 +1,126 @@ +package com.yssh.entity; + +import java.io.Serializable; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Data +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class ThuAccuracy implements Serializable{ + + private static final long serialVersionUID = 3859561604842988730L; + + private int id; + private String name; + private float lon; + private float lat; + private String value; + private String time; + private int property; + private String wg100; + private String wg200; + private String wg300; + private String wg500; + private Double accuracy; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public float getLon() { + return lon; + } + + public void setLon(float lon) { + this.lon = lon; + } + + public float getLat() { + return lat; + } + + public void setLat(float lat) { + this.lat = lat; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public int getProperty() { + return property; + } + + public void setProperty(int property) { + this.property = property; + } + + public String getWg100() { + return wg100; + } + + public void setWg100(String wg100) { + this.wg100 = wg100; + } + + public String getWg200() { + return wg200; + } + + public void setWg200(String wg200) { + this.wg200 = wg200; + } + + public String getWg300() { + return wg300; + } + + public void setWg300(String wg300) { + this.wg300 = wg300; + } + + public String getWg500() { + return wg500; + } + + public void setWg500(String wg500) { + this.wg500 = wg500; + } + + public Double getAccuracy() { + return accuracy; + } + + public void setAccuracy(Double accuracy) { + this.accuracy = accuracy; + } +} diff --git a/src/main/java/com/yssh/entity/VocCoords.java b/src/main/java/com/yssh/entity/VocCoords.java new file mode 100644 index 0000000..d6d67e9 --- /dev/null +++ b/src/main/java/com/yssh/entity/VocCoords.java @@ -0,0 +1,62 @@ +package com.yssh.entity; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.github.biyanwen.annotation.CsvProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; + +public class VocCoords implements Serializable { + private static final long serialVersionUID = -20230606150000000L; + + @JsonIgnore + @ApiModelProperty(value = "涓婚敭") + private Integer id; + + @CsvProperty(index = 0) + @ApiModelProperty(value = "X") + private Integer x; + + @CsvProperty(index = 1) + @ApiModelProperty(value = "Y") + private Integer y; + + @CsvProperty(index = 2) + @ApiModelProperty(value = "鍦板潃") + private String addr; + + public VocCoords() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getX() { + return x; + } + + public void setX(Integer x) { + this.x = x; + } + + public Integer getY() { + return y; + } + + public void setY(Integer y) { + this.y = y; + } + + public String getAddr() { + return addr; + } + + public void setAddr(String addr) { + this.addr = addr; + } +} diff --git a/src/main/java/com/yssh/entity/VocVals.java b/src/main/java/com/yssh/entity/VocVals.java new file mode 100644 index 0000000..afbfa61 --- /dev/null +++ b/src/main/java/com/yssh/entity/VocVals.java @@ -0,0 +1,94 @@ +package com.yssh.entity; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.github.biyanwen.annotation.CsvProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; +import java.math.BigInteger; +import java.util.Date; + +public class VocVals implements Serializable { + private static final long serialVersionUID = -20230605145412000L; + + @JsonIgnore + @ApiModelProperty(value = "涓婚敭") + private BigInteger id; + + @ApiModelProperty(value = "婧簮ID") + private String suYuanId; + + @CsvProperty(index = 0) + @ApiModelProperty(value = "X") + private Integer x; + + @CsvProperty(index = 1) + @ApiModelProperty(value = "Y") + private Integer y; + + @CsvProperty(index = 2) + @ApiModelProperty(value = "鍊�") + private Double val; + + @JsonIgnore + @ApiModelProperty(value = "鍒涘缓鏃堕棿") + private Date createTime; + + @ApiModelProperty(value = "鍦板潃") + private String addr; + + public VocVals() { + } + + public BigInteger getId() { + return id; + } + + public void setId(BigInteger id) { + this.id = id; + } + + public String getSuYuanId() { + return x + "_" + y + "_0"; + } + + public Integer getX() { + return x; + } + + public void setX(Integer x) { + this.x = x; + } + + public Integer getY() { + return y; + } + + public void setY(Integer y) { + this.y = y; + } + + public Double getVal() { + return val; + } + + public void setVal(Double val) { + this.val = val; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getAddr() { + return addr; + } + + public void setAddr(String addr) { + this.addr = addr; + } +} diff --git a/src/main/java/com/yssh/entity/WarningDetail.java b/src/main/java/com/yssh/entity/WarningDetail.java new file mode 100644 index 0000000..2383fde --- /dev/null +++ b/src/main/java/com/yssh/entity/WarningDetail.java @@ -0,0 +1,101 @@ +package com.yssh.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.ToString; + +@Data +@ToString +@ApiModel(value="鎶ヨ/棰勮瀵硅薄", description="鎶ヨ/棰勮瀵硅薄") +public class WarningDetail implements Serializable { + public WarningDetail() { + } + + public WarningDetail(Long id, String tableName, String suYuanId, String locationName, Date createTime, Integer type, Double value) { + this.id = id; + this.tableName = tableName; + this.suYuanId = suYuanId; + this.locationName = locationName; + this.createTime = createTime; + this.type = type; + this.value = value; + } + + private static final long serialVersionUID = 1610250573910282005L; + @ApiModelProperty(value = "涓婚敭") + private Long id; + @ApiModelProperty(value = "婧簮鏁版嵁琛ㄥ悕") + private String tableName; + @ApiModelProperty(value = "婧簮鏁版嵁缂栧彿") + private String suYuanId; + @ApiModelProperty(value = "鐐逛綅鍚嶇О") + private String locationName; + ; + @ApiModelProperty(value = "鏃堕棿") + private Date createTime; + @ApiModelProperty(value = "绫诲瀷") + private Integer type; + @ApiModelProperty(value = "鏁板��") + private Double value; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + public String getSuYuanId() { + return suYuanId; + } + + public void setSuYuanId(String suYuanId) { + this.suYuanId = suYuanId; + } + + public String getLocationName() { + return locationName; + } + + public void setLocationName(String locationName) { + this.locationName = locationName; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public Double getValue() { + return value; + } + + public void setValue(Double value) { + this.value = value; + } +} diff --git a/src/main/java/com/yssh/entity/WarningVo.java b/src/main/java/com/yssh/entity/WarningVo.java new file mode 100644 index 0000000..6eee0ce --- /dev/null +++ b/src/main/java/com/yssh/entity/WarningVo.java @@ -0,0 +1,95 @@ +package com.yssh.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; + +import lombok.ToString; + +import com.yssh.utils.CalculateUtils; + +@ToString +@ApiModel(value="鎶ヨ/棰勮灞曠ず瀵硅薄", description="鎶ヨ/棰勮灞曠ず瀵硅薄") +public class WarningVo implements Serializable { + public WarningVo() { + } + + public WarningVo(String locationName, String suYuanId, double lon, double lat, double value, String time) { + this.locationName = locationName; + this.suYuanId = suYuanId; + this.lon = lon; + this.lat = lat; + this.value = value; + this.time = time; + } + + private static final long serialVersionUID = 3440478664982471286L; + @ApiModelProperty(value = "鐐逛綅鍚嶇О") + private String locationName; + + //@JsonIgnore + private String suYuanId; + + @ApiModelProperty(value = "缁忓害") + private double lon; + + @ApiModelProperty(value = "绾害") + private double lat; + + @ApiModelProperty(value = "鏁板��") + private double value; + + @ApiModelProperty(value = "鏃堕棿") + private String time; + + public String getLocationName() { + return locationName; + } + + public void setLocationName(String locationName) { + this.locationName = locationName; + } + + public void setSuYuanId(String suYuanId) { + this.suYuanId = suYuanId; + } + + public double getLon() { + String[] split = suYuanId.split("_"); + return CalculateUtils.getLon(Integer.parseInt(split[0]), Integer.parseInt(split[1])); + } + + public double getLat() { + String[] split = suYuanId.split("_"); + return CalculateUtils.getLat(Integer.parseInt(split[0]), Integer.parseInt(split[1])); + } + + public double getValue() { + return value; + } + + public void setValue(double value) { + this.value = value; + } + + public String getSuYuanId() { + return suYuanId; + } + + public void setLon(double lon) { + this.lon = lon; + } + + public void setLat(double lat) { + this.lat = lat; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } +} diff --git a/src/main/java/com/yssh/entity/Weather.java b/src/main/java/com/yssh/entity/Weather.java new file mode 100644 index 0000000..f433771 --- /dev/null +++ b/src/main/java/com/yssh/entity/Weather.java @@ -0,0 +1,69 @@ +package com.yssh.entity; + +import lombok.Data; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * @author wMeng + * @ClassName YsshWeather + * @Description 澶╂皵鏁版嵁 + * @date 2022/10/30 13:18 + * @Version 1.0 + */ +@Data +@ApiModel(value = "澶╂皵鏁版嵁",description = "澶╂皵鏁版嵁") +public class Weather { + @ApiModelProperty(value = "涓婚敭") + private int id; + @ApiModelProperty(value = "鏃堕棿") + private String time; + @ApiModelProperty(value = "椋庨��") + private String windSpeed; + @ApiModelProperty(value = "椋庡悜") + private String windDirection; + @ApiModelProperty(value = "澶╂皵鐘跺喌") + private String weatherCondition; + @ApiModelProperty(value = "姘旀俯") + private String temperature; + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public String getWindSpeed() { + return windSpeed; + } + + public void setWindSpeed(String windSpeed) { + this.windSpeed = windSpeed; + } + + public String getWindDirection() { + return windDirection; + } + + public void setWindDirection(String windDirection) { + this.windDirection = windDirection; + } + + public String getWeatherCondition() { + return weatherCondition; + } + + public void setWeatherCondition(String weatherCondition) { + this.weatherCondition = weatherCondition; + } + + public String getTemperature() { + return temperature; + } + + public void setTemperature(String temperature) { + this.temperature = temperature; + } +} diff --git a/src/main/java/com/yssh/mapper/AlertConfigMapper.java b/src/main/java/com/yssh/mapper/AlertConfigMapper.java new file mode 100644 index 0000000..f16c532 --- /dev/null +++ b/src/main/java/com/yssh/mapper/AlertConfigMapper.java @@ -0,0 +1,23 @@ +package com.yssh.mapper; + +import java.util.List; + +import com.yssh.entity.AlertConfig; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface AlertConfigMapper { + + List<AlertConfig> query(Integer id); + + List<AlertConfig> getAll(); + + String getAlert(); + + int update(AlertConfig alert); + + int insert(AlertConfig alert); + + int delete(Integer id); + +} diff --git a/src/main/java/com/yssh/mapper/BaseMapper.java b/src/main/java/com/yssh/mapper/BaseMapper.java new file mode 100644 index 0000000..fc8ffa1 --- /dev/null +++ b/src/main/java/com/yssh/mapper/BaseMapper.java @@ -0,0 +1,11 @@ +package com.yssh.mapper; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; + + +public interface BaseMapper { + + <T> int batchInsert(@Param("tableName") String tableName, @Param("datas") List<T> datas); +} diff --git a/src/main/java/com/yssh/mapper/CommonMapper.java b/src/main/java/com/yssh/mapper/CommonMapper.java new file mode 100644 index 0000000..e10b16e --- /dev/null +++ b/src/main/java/com/yssh/mapper/CommonMapper.java @@ -0,0 +1,31 @@ +package com.yssh.mapper; + +import java.util.Map; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * @ClassName: CommonMapper + * @Description: 閫氱敤鐨刴apper + * @author zhangtengfei + * @date 2023骞�2鏈�27鏃ヤ笅鍗�2:27:55 + */ +@Mapper +public interface CommonMapper{ + + /** + * 浣跨敤information_schema妫�鏌ヨ〃鏄惁瀛樺湪 + * @param tableSchema + * @param tableName + * @return + */ + Integer checkTableExistsWithSchema(@Param("tableSchema")String tableSchema, @Param("tableName")String tableName); + + /** + * 浣跨敤show tables妫�鏌ヨ〃鏄惁瀛樺湪 + * @param tableName + * @return + */ + Map<String, String> checkTableExistsWithShow(@Param("tableName")String tableName); +} diff --git a/src/main/java/com/yssh/mapper/DictRecordMapper.java b/src/main/java/com/yssh/mapper/DictRecordMapper.java new file mode 100644 index 0000000..2616b01 --- /dev/null +++ b/src/main/java/com/yssh/mapper/DictRecordMapper.java @@ -0,0 +1,57 @@ +package com.yssh.mapper; + +import java.util.List; + +import com.yssh.entity.DictRecord; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 瀛楀吀璁板綍Mapper鎺ュ彛 + * + * @author xingjinshuang@smartearth.cn + * @date 2023-02-06 + */ +@Mapper +public interface DictRecordMapper { + + /** + * 鏌ヨ瀛楀吀璁板綍鍒楄〃 + * @param dictRecord 瀛楀吀璁板綍 + * @return 瀛楀吀璁板綍闆嗗悎 + */ + public List<DictRecord> selectDictRecordList(DictRecord dictRecord); + + public List<DictRecord> selectByTimeDictRecordList(@Param("startTime") Long startTime, @Param("endTime") Long endTime); + + public DictRecord selectByCreateTime(Long createTime); + + public List<DictRecord> selectByTime(String start, String end); + + /** + * 鏂板瀛楀吀璁板綍 + * @param dictRecord 瀛楀吀璁板綍 + * @return 缁撴灉 + */ + public int insertDictRecord(DictRecord dictRecord); + + /** + * 鍒犻櫎瀛楀吀璁板綍 + * @param id 瀛楀吀璁板綍ID + * @return 缁撴灉 + */ + public int deleteDictRecordById(Long id); + + /** + * 鎵归噺鍒犻櫎瀛楀吀璁板綍 + * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁ID + * @return 缁撴灉 + */ + public int deleteDictRecordByIds(Long[] ids); + + /** + * 鍒涘缓瀛楀吀璁板綍琛ㄦ帴鍙� + */ + public int createDictRecoTable(); + +} \ No newline at end of file diff --git a/src/main/java/com/yssh/mapper/EmissionMapper.java b/src/main/java/com/yssh/mapper/EmissionMapper.java new file mode 100644 index 0000000..e0b0769 --- /dev/null +++ b/src/main/java/com/yssh/mapper/EmissionMapper.java @@ -0,0 +1,22 @@ +package com.yssh.mapper; + +import java.util.List; + +import com.yssh.entity.Emission; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * @author wMeng + * @ClassName YsshQxshMapper + * @Description TODO + * @date 2022/10/31 14:45 + * @Version 1.0 + */ +@Mapper +public interface EmissionMapper { + List<Emission> query(@Param("name") String name); + List<Emission> getAll(); + int insert(Emission emission); + int delete(String id); +} diff --git a/src/main/java/com/yssh/mapper/ExpPointMapper.java b/src/main/java/com/yssh/mapper/ExpPointMapper.java new file mode 100644 index 0000000..b72a150 --- /dev/null +++ b/src/main/java/com/yssh/mapper/ExpPointMapper.java @@ -0,0 +1,15 @@ +package com.yssh.mapper; + +import java.util.List; + +import com.yssh.entity.ExpPoint; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +@Mapper +public interface ExpPointMapper { + + List<ExpPoint> selectList(); + + List<ExpPoint> selectByExpSiteNumbers(@Param("expSiteNumbers") List<String> expSiteNumbers); +} diff --git a/src/main/java/com/yssh/mapper/FeedbackMapper.java b/src/main/java/com/yssh/mapper/FeedbackMapper.java new file mode 100644 index 0000000..c7afa1f --- /dev/null +++ b/src/main/java/com/yssh/mapper/FeedbackMapper.java @@ -0,0 +1,16 @@ +package com.yssh.mapper; + +import com.yssh.entity.FeedbackDetail; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface FeedbackMapper { + + int insert(FeedbackDetail feedbackDetail); + + FeedbackDetail selectById(Long id); + + int update(FeedbackDetail feedbackDetail); + + Double selectSevenDayAccuracyAvg(Long beginTime); +} diff --git a/src/main/java/com/yssh/mapper/LocationMapper.java b/src/main/java/com/yssh/mapper/LocationMapper.java new file mode 100644 index 0000000..f2ce02d --- /dev/null +++ b/src/main/java/com/yssh/mapper/LocationMapper.java @@ -0,0 +1,27 @@ +package com.yssh.mapper; + +import com.yssh.entity.Location; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author wMeng + * @date 2022/10/30 13:37 + * @version 1.0 + */ +@Mapper +public interface LocationMapper { + List<Location> query(@Param("name") String name, @Param("type") String type); + + List<Location> getAll(); + + int insertLocation(Location ysshLocation); + + int deleteLocation(String id); + + List<Location> selectByXY(@Param("x") double x, @Param("y") double y); + + List<Location> selectVocAddrs(); +} diff --git a/src/main/java/com/yssh/mapper/QxshMapper.java b/src/main/java/com/yssh/mapper/QxshMapper.java new file mode 100644 index 0000000..ef5329c --- /dev/null +++ b/src/main/java/com/yssh/mapper/QxshMapper.java @@ -0,0 +1,21 @@ +package com.yssh.mapper; + +import com.yssh.entity.Qxsh; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author WWW + * @date 2023-05-18 + * QxshMapper + */ +@Mapper +public interface QxshMapper { + public List<Qxsh> selectByTime(String time); + + public List<Qxsh> selectMonthTop10(String time); + + public List<Qxsh> select3Hours(@Param("times") List<String> times); +} diff --git a/src/main/java/com/yssh/mapper/StratumMapper.java b/src/main/java/com/yssh/mapper/StratumMapper.java new file mode 100644 index 0000000..41d3e28 --- /dev/null +++ b/src/main/java/com/yssh/mapper/StratumMapper.java @@ -0,0 +1,20 @@ +package com.yssh.mapper; + +import java.util.List; +import java.util.Map; + +import com.yssh.entity.Stratum; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +@Mapper +public interface StratumMapper { + + //@Param("expSiteNumber") String expSiteNumber, @Param("begin") Integer begin, @Param("end") Integer end + List<Stratum> select(Map<String, Object> param); + + List<Stratum> selectByExpSiteNumbers(@Param("expSiteNumbers") List<String> expSiteNumbers); + + //@Param("expSiteNumber") String expSiteNumber, @Param("geotechnicalName") String geotechnicalName + Stratum selectByGeotechnicalName(Map<String, Object> param); +} diff --git a/src/main/java/com/yssh/mapper/SuYuanMapper.java b/src/main/java/com/yssh/mapper/SuYuanMapper.java new file mode 100644 index 0000000..f529011 --- /dev/null +++ b/src/main/java/com/yssh/mapper/SuYuanMapper.java @@ -0,0 +1,46 @@ +package com.yssh.mapper; + +import java.util.List; +import java.util.Map; + +import com.yssh.entity.*; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +@Mapper +public interface SuYuanMapper extends BaseMapper { + Integer isTableExists(String tableName); + + int createTable(@Param("tableName") String tableName); + + List<SuYuan2d> get2d(@Param("tableName") String tableName, @Param("ids") List<String> ids); + + List<SuYuan3d> get3d(@Param("tableName") String tableName, @Param("ids") List<String> ids); + + List<DistanceSuYuan> getDistanceSuYuan(@Param("tableName") String tableName, @Param("ids") List<String> ids); + + DistanceSuYuan getSuYuan500Max(@Param("tableName") String tableName, @Param("ids") List<String> ids); + + DistanceSuYuan getSuYuanById(@Param("tableName") String tableName, @Param("id") String id); + + List<Temporary> getTemporary(@Param("tableName") String tableName, @Param("ids") List<String> ids); + + int update(@Param("tableName") String tableName, @Param("id") String id, @Param("value") String value); + + List<SuYuan2d> getAlarmsAnalyse(@Param("tableName") String tableName, @Param("ids") List<String> ids); + + List<SuYuan2d> getWarningAnalyse(@Param("tableName") String tableName, @Param("ids") List<String> ids); + + List<SuYuanMonitorData> getMonitorData(@Param("tableNames") List<String> tableNames, @Param("id") String id); + + List<SuYuanMonitorData> getNewMonitorData(String name, String start, String end); + + //鑾峰彇鏈湀鎸囧畾鐩戞祴绔欑偣鐩戞祴鍊煎澶х殑鏁版嵁 + Map<String, Object> getMonthValueDataMax(@Param("tableNames") List<String> tableNames, @Param("id") String id); + + int updateVocsName(String table, String id, String vocsName); + + SuYuan700 selectSuYuan700ById(@Param("id") String id, @Param("time") String time); + + SuYuan700 selectSuYuan46ById(@Param("id") String id, @Param("time") String time); +} diff --git a/src/main/java/com/yssh/mapper/ThuAccuracyMapper.java b/src/main/java/com/yssh/mapper/ThuAccuracyMapper.java new file mode 100644 index 0000000..1aac682 --- /dev/null +++ b/src/main/java/com/yssh/mapper/ThuAccuracyMapper.java @@ -0,0 +1,17 @@ +package com.yssh.mapper; + + +import java.util.List; +import java.util.Map; + +import com.yssh.entity.ThuAccuracy; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface ThuAccuracyMapper { + + //鏌ヨ杩囧幓涓冨ぉ绮剧‘骞冲潎鍊肩粺璁� + public Double selectSevenDayAccuracyAvg(Long beginTime); + + public List<ThuAccuracy> getForecastData(Map<String, Object> map); +} diff --git a/src/main/java/com/yssh/mapper/VocValsMapper.java b/src/main/java/com/yssh/mapper/VocValsMapper.java new file mode 100644 index 0000000..3878035 --- /dev/null +++ b/src/main/java/com/yssh/mapper/VocValsMapper.java @@ -0,0 +1,72 @@ +package com.yssh.mapper; + +import com.yssh.entity.VocCoords; +import com.yssh.entity.VocVals; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * Voc鍊糓apper鎺ュ彛 + * @author WWW + * @date 2023-06-05 + */ +@Mapper +public interface VocValsMapper { + /** + * 鏍规嵁鏃堕棿鏌ヨ + * + * @param time 鏃堕棿锛堢ず渚嬶細2023060514锛� + * @return + */ + public List<VocVals> selectByTime(@Param("time") String time); + + /** + * 鏍规嵁鏃堕棿缁熻 + * + * @param time 鏃堕棿锛堢ず渚嬶細2023060514锛� + * @return 琛屾暟 + */ + public int countByTime(@Param("time") String time); + + /** + * 鏍规嵁X锛孻鍊兼煡璇㈠湴鍧� + * + * @param x X鍊� + * @param y Y鍊� + * @return 鍦板潃 + */ + public List<VocCoords> selectCoords(@Param("x") Integer x, @Param("y") Integer y); + + /** + * 鎻掑叆涓�鏉℃暟鎹� + * + * @param vv Voc瀹炰綋绫� + * @return 褰卞搷琛屾暟 + */ + public int insert(VocVals vv); + + /** + * 鎻掑叆澶氭潯鏁版嵁 + * + * @param list Voc闆嗗悎 + * @return 褰卞搷琛屾暟 + */ + public int inserts(List<VocVals> list); + + /** + * 鍒犻櫎鍘诲勾鐨勬暟鎹� + * + * @return 褰卞搷琛屾暟 + */ + public int deleteLastYear(); + + /** + * 鏍规嵁鏃堕棿鍒犻櫎鏁版嵁 + * + * @param time 鏃堕棿锛堢ず渚嬶細2023060514锛� + * @return 褰卞搷琛屾暟 + */ + public int deleteByTime(@Param("time") String time); +} diff --git a/src/main/java/com/yssh/mapper/WarningDetailMapper.java b/src/main/java/com/yssh/mapper/WarningDetailMapper.java new file mode 100644 index 0000000..74ecf38 --- /dev/null +++ b/src/main/java/com/yssh/mapper/WarningDetailMapper.java @@ -0,0 +1,34 @@ +package com.yssh.mapper; + +import java.util.List; +import java.util.Map; + +import com.yssh.entity.WarningDetail; +import com.yssh.entity.WarningVo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +@Mapper +public interface WarningDetailMapper extends BaseMapper { + + //List<WarningVo> getRunTimeAlarmAnalyse(); + + //@Param("startTime") Date startTime, + List<WarningVo> selectWarningDetailByType(@Param("type") Integer type); + + List<WarningVo> selectWarningDetailByMap(Map<String, Object> param); + + List<Map<String, Object>> selectWarningDayCountByMap(Map<String, Object> param); + + List<WarningDetail> selectByTime(@Param("startTime") String startTime, @Param("endTime") String endTime); + + List<WarningDetail> selectByTimeForYj(@Param("startTime") String startTime, @Param("endTime") String endTime); + + List<WarningDetail> selectByTimeForBj(@Param("startTime") String startTime, @Param("endTime") String endTime); + + Double getLastYearVal(@Param("id") long id); + + Integer countWarnByMap(Map<String, Object> param); + + Integer countAlarmByMap(Map<String, Object> param); +} diff --git a/src/main/java/com/yssh/mapper/WeatherMapper.java b/src/main/java/com/yssh/mapper/WeatherMapper.java new file mode 100644 index 0000000..27736da --- /dev/null +++ b/src/main/java/com/yssh/mapper/WeatherMapper.java @@ -0,0 +1,22 @@ +package com.yssh.mapper; + +import com.yssh.entity.Weather; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author wMeng + * @ClassName YsshWeatherMapper + * @Description TODO + * @date 2022/10/30 14:16 + * @Version 1.0 + */ +@Mapper +public interface WeatherMapper { + List<Weather> query(@Param("begin") String begin, @Param("end") String end); + List<Weather> getAll(); + int insert(Weather weather); + int delete(String id); +} diff --git a/src/main/java/com/yssh/service/AlertConfigService.java b/src/main/java/com/yssh/service/AlertConfigService.java new file mode 100644 index 0000000..839819f --- /dev/null +++ b/src/main/java/com/yssh/service/AlertConfigService.java @@ -0,0 +1,36 @@ +package com.yssh.service; + +import java.util.List; + +import com.yssh.entity.AlertConfig; +import org.springframework.stereotype.Service; + +import com.yssh.mapper.AlertConfigMapper; + +import javax.annotation.Resource; + +@Service +public class AlertConfigService { + @Resource + private AlertConfigMapper alertConfigMapper; + + public List<AlertConfig> getAll() { + return alertConfigMapper.getAll(); + } + + public List<AlertConfig> query(Integer id) { + return alertConfigMapper.query(id); + } + + public int update(AlertConfig config) { + return alertConfigMapper.update(config); + } + + public int insert(AlertConfig config) { + return alertConfigMapper.insert(config); + } + + public int delete(Integer id) { + return alertConfigMapper.delete(id); + } +} diff --git a/src/main/java/com/yssh/service/AsyncService.java b/src/main/java/com/yssh/service/AsyncService.java new file mode 100644 index 0000000..c33d930 --- /dev/null +++ b/src/main/java/com/yssh/service/AsyncService.java @@ -0,0 +1,24 @@ +package com.yssh.service; + +import java.util.List; +import java.util.concurrent.CountDownLatch; + +import org.springframework.stereotype.Service; + +import com.yssh.mapper.BaseMapper; + +@Service +public class AsyncService { + public static final Integer BATCH_INSERT_NUMBER = 1000; + + public static final Integer BATCH_INSERT_500 = 500; + + public <T> void executeAsync(String tableName, List<T> lists, BaseMapper mapper, CountDownLatch countDownLatch) { + try{ + //寮傛绾跨▼瑕佸仛鐨勪簨鎯� + mapper.batchInsert(tableName, lists); + }finally { + countDownLatch.countDown();// 寰堝叧閿�, 鏃犺涓婇潰绋嬪簭鏄惁寮傚父蹇呴』鎵цcountDown,鍚﹀垯await鏃犳硶閲婃斁 + } + } +} diff --git a/src/main/java/com/yssh/service/CommonService.java b/src/main/java/com/yssh/service/CommonService.java new file mode 100644 index 0000000..087dca6 --- /dev/null +++ b/src/main/java/com/yssh/service/CommonService.java @@ -0,0 +1,166 @@ +package com.yssh.service; + +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.yssh.config.DatFilePathConfig; +import com.yssh.entity.MonitorPointPosition; +import com.yssh.utils.CalculateUtils; +import com.yssh.utils.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import com.yssh.mapper.CommonMapper; + +import javax.annotation.Resource; + +@Service +public class CommonService { + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private static final String TABLE_SCHEMA = "yssh"; + + private List<MonitorPointPosition> checkPoints2d = new ArrayList<>(); + + private List<MonitorPointPosition> checkPoints3d = new ArrayList<>(); + + @Resource + private CommonMapper commonMapper; + + @Resource + protected DatFilePathConfig datFilePathConfig; + + /** + * 妫�鏌ヨ〃鏄惁瀛樺湪 + */ + public boolean checkTableExists(String tableName) { + try { + Integer count = commonMapper.checkTableExistsWithSchema(TABLE_SCHEMA, tableName); + return count == 1; + } catch (Exception e) { + logger.error("浣跨敤information_schema妫�娴嬭〃澶辫触", e); + Map<String, String> list = commonMapper.checkTableExistsWithShow(tableName); + if (StringUtils.isNotEmpty(list)) { + return true; + } + } + return false; + } + + public void readDatData() throws Exception { + File file2d = new File(datFilePathConfig.getFilePath2d()); + BufferedInputStream fis2d = new BufferedInputStream(new FileInputStream(file2d)); + BufferedReader reader2d = new BufferedReader(new InputStreamReader(fis2d, "utf-8"), 7 * 1024 * 1024);// 鐢�7M鐨勭紦鍐茶鍙栨枃鏈枃浠� + long count2d = 1; + String line2d = ""; + while ((line2d = reader2d.readLine()) != null) { + String[] f2d = line2d.split(" "); + Integer x = Integer.parseInt(f2d[0]); + Integer y = Integer.parseInt(f2d[1]); + int z = 0; + try { + z = new Double(Math.round(Integer.parseInt(f2d[2]) * 1.0 / 10)).intValue(); + } catch (Exception e) { + System.out.println(e.getStackTrace()); + } + //if (x <= 699 && y <= 699) + { + MonitorPointPosition monitorPointPosition = new MonitorPointPosition(); + monitorPointPosition.setId(x + "_" + y + "_" + z); + monitorPointPosition.setName("AI-" + (count2d < 10 ? "0" + count2d : count2d + "")); + monitorPointPosition.setX(x); + monitorPointPosition.setY(y); + monitorPointPosition.setZ(z); + monitorPointPosition.setLon(CalculateUtils.getLon(monitorPointPosition.getX(), monitorPointPosition.getY())); + monitorPointPosition.setLat(CalculateUtils.getLat(monitorPointPosition.getX(), monitorPointPosition.getY())); + checkPoints2d.add(monitorPointPosition); + count2d++; + } + } + reader2d.close(); + + File file = new File(datFilePathConfig.getFilePath3d()); + BufferedInputStream fis = new BufferedInputStream(new FileInputStream(file)); + BufferedReader reader = new BufferedReader(new InputStreamReader(fis, "utf-8"), 7 * 1024 * 1024);// 鐢�7M鐨勭紦鍐茶鍙栨枃鏈枃浠� + long count3d = 1; + String line = ""; + while ((line = reader.readLine()) != null) { + String[] f3d = line.split(" "); + Integer x = Integer.parseInt(f3d[0]); + Integer y = Integer.parseInt(f3d[1]); + int z = 0; + try { + z = new Double(Math.round(Integer.parseInt(f3d[2]) * 1.0 / 10)).intValue(); + } catch (Exception e) { + System.out.println(e.getStackTrace()); + } + if (count3d > 46) break; + { //if (x <= 699 && y <= 699) { + MonitorPointPosition monitorPointPosition = new MonitorPointPosition(); + monitorPointPosition.setId(x + "_" + y + "_" + z); + monitorPointPosition.setName("AI-" + (count3d < 10 ? "0" + count3d : count3d + "")); + monitorPointPosition.setX(x); + monitorPointPosition.setY(y); + monitorPointPosition.setZ(z); + monitorPointPosition.setLon(CalculateUtils.getLon(monitorPointPosition.getX(), monitorPointPosition.getY())); + monitorPointPosition.setLat(CalculateUtils.getLat(monitorPointPosition.getX(), monitorPointPosition.getY())); + checkPoints3d.add(monitorPointPosition); + count3d++; + } + } + reader.close(); + } + + public List<MonitorPointPosition> getCheckPoints2d() { + return checkPoints2d; + } + + public List<MonitorPointPosition> getCheckPoints3d() { + return checkPoints3d; + } + + public MonitorPointPosition select2dCheckPointByName(String name) { + for (MonitorPointPosition monitorPointPosition : checkPoints2d) { + if (monitorPointPosition.getName().equals(name)) { + return monitorPointPosition; + } + } + return null; + } + + public MonitorPointPosition select3dCheckPointByName(String name) { + for (MonitorPointPosition monitorPointPosition : checkPoints3d) { + if (monitorPointPosition.getName().equals(name)) { + return monitorPointPosition; + } + } + return null; + } + + public MonitorPointPosition select2dCheckPointById(String id) { + for (MonitorPointPosition monitorPointPosition : checkPoints2d) { + if (monitorPointPosition.getName().equals(id)) { + return monitorPointPosition; + } + } + return null; + } + + public MonitorPointPosition select3dCheckPointById(String id) { + for (MonitorPointPosition monitorPointPosition : checkPoints3d) { + //if (monitorPointPosition.getId().equals(id)) { + String subId = id.substring(0, id.lastIndexOf("_") + 1); + if (monitorPointPosition.getId().contains(subId)) { + return monitorPointPosition; + } + } + return null; + } +} diff --git a/src/main/java/com/yssh/service/CountService.java b/src/main/java/com/yssh/service/CountService.java new file mode 100644 index 0000000..af131f8 --- /dev/null +++ b/src/main/java/com/yssh/service/CountService.java @@ -0,0 +1,38 @@ +package com.yssh.service; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import com.yssh.utils.DateUtils; +import org.springframework.stereotype.Service; + +import com.yssh.mapper.FeedbackMapper; +import com.yssh.mapper.ThuAccuracyMapper; + +import javax.annotation.Resource; + +@Service +public class CountService { + @Resource + private ThuAccuracyMapper thuAccuracyMapper; + + @Resource + private FeedbackMapper feedbackMapper; + + public Map<String, Double> selectAccuracyAvg() { + Map<String, Double> result = new HashMap<String, Double>(); + Date nowDate = DateUtils.getNowDate(); + Long beginTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getAPeriodOfTime(nowDate, -7, Calendar.DATE))); + Double thuAccuracy = thuAccuracyMapper.selectSevenDayAccuracyAvg(beginTime); + Double tempForecast = thuAccuracy == null ? 0.0 : thuAccuracy; + result.put("forecastRate", new BigDecimal(tempForecast).setScale(2, RoundingMode.HALF_UP).doubleValue()); + Double practical = feedbackMapper.selectSevenDayAccuracyAvg(beginTime); + Double tempPractical = practical == null ? 0.0 : practical; + result.put("practicalRate", new BigDecimal(tempPractical * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); + return result; + } +} diff --git a/src/main/java/com/yssh/service/DictRecordService.java b/src/main/java/com/yssh/service/DictRecordService.java new file mode 100644 index 0000000..7f836ab --- /dev/null +++ b/src/main/java/com/yssh/service/DictRecordService.java @@ -0,0 +1,77 @@ +package com.yssh.service; + +import java.util.List; + +import com.yssh.entity.DictRecord; +import lombok.Synchronized; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.yssh.mapper.DictRecordMapper; + +import javax.annotation.Resource; + +/** + * 瀛楀吀璁板綍Service涓氬姟灞傚鐞� + * @author xingjinshuang@smartearth.cn + * @date 2023-02-06 + */ +@Service +public class DictRecordService { + @Resource + private DictRecordMapper dictRecordMapper; + + /** + * 鏌ヨ瀛楀吀璁板綍鍒楄〃 + * + * @param dictRecord 瀛楀吀璁板綍 + * @return 瀛楀吀璁板綍 + */ + public List<DictRecord> selectDictRecordList(DictRecord dictRecord) { + return dictRecordMapper.selectDictRecordList(dictRecord); + } + + public DictRecord selectByCreateTime(Long createTime) { + return dictRecordMapper.selectByCreateTime(createTime); + } + + /** + * 鏂板瀛楀吀璁板綍 + * + * @param dictRecord 瀛楀吀璁板綍 + * @return 缁撴灉 + */ + public int insertDictRecord(DictRecord dictRecord) { + return dictRecordMapper.insertDictRecord(dictRecord); + } + + /** + * 鍒犻櫎瀛楀吀璁板綍瀵硅薄 + * + * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁ID + * @return 缁撴灉 + */ + public int deleteDictRecordByIds(Long[] ids) { + return dictRecordMapper.deleteDictRecordByIds(ids); + } + + /** + * 鍒犻櫎瀛楀吀璁板綍淇℃伅 + * + * @param id 瀛楀吀璁板綍ID + * @return 缁撴灉 + */ + public int deleteDictRecordById(Long id) { + return dictRecordMapper.deleteDictRecordById(id); + } + + /** + * 鍒涘缓瀛楀吀璁板綍淇℃伅琛ㄦ帴鍙� + */ + @Transactional(rollbackFor = Exception.class) + @Synchronized + public int createDictRecoTable() { + return dictRecordMapper.createDictRecoTable(); + } +} diff --git a/src/main/java/com/yssh/service/EmissionService.java b/src/main/java/com/yssh/service/EmissionService.java new file mode 100644 index 0000000..30afba8 --- /dev/null +++ b/src/main/java/com/yssh/service/EmissionService.java @@ -0,0 +1,39 @@ +package com.yssh.service; + +import java.util.List; + +import com.yssh.entity.Emission; +import org.springframework.stereotype.Service; + +import com.yssh.mapper.EmissionMapper; + +import javax.annotation.Resource; + +/** + * @author wMeng + * @ClassName YsshQxshServiceImpl + * @Description TODO + * @date 2022/10/31 14:45 + * @Version 1.0 + */ +@Service +public class EmissionService { + @Resource + private EmissionMapper emissionMapper; + + public List<Emission> query(String name) { + return emissionMapper.query(name); + } + + public List<Emission> getAll() { + return emissionMapper.getAll(); + } + + public int insert(Emission emission) { + return emissionMapper.insert(emission); + } + + public int delete(String id) { + return emissionMapper.delete(id); + } +} diff --git a/src/main/java/com/yssh/service/FeedbackService.java b/src/main/java/com/yssh/service/FeedbackService.java new file mode 100644 index 0000000..b88ae9a --- /dev/null +++ b/src/main/java/com/yssh/service/FeedbackService.java @@ -0,0 +1,31 @@ +package com.yssh.service; + +import com.yssh.entity.FeedbackDetail; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.yssh.mapper.FeedbackMapper; +import com.yssh.mapper.SuYuanMapper; + +import javax.annotation.Resource; + +@Service +public class FeedbackService { + @Resource + private FeedbackMapper feedbackMapper; + + @Resource + private SuYuanMapper suYuanMapper; + + @Transactional + public int suYuanFeedback(Long id, String practicalId, String practicalVocsName, double practicalValue) { + FeedbackDetail feedback = feedbackMapper.selectById(id); + int i = suYuanMapper.update(feedback.getTableName(), practicalId, String.valueOf(practicalValue)); + FeedbackDetail feedbackDetail = new FeedbackDetail(); + feedbackDetail.setId(id); + feedbackDetail.setPracticalId(practicalId); + feedbackDetail.setPracticalVocsName(practicalVocsName); + feedbackDetail.setPracticalValue(practicalValue); + return feedbackMapper.update(feedbackDetail) + i; + } +} diff --git a/src/main/java/com/yssh/service/ForecastAnalyseService.java b/src/main/java/com/yssh/service/ForecastAnalyseService.java new file mode 100644 index 0000000..140ca17 --- /dev/null +++ b/src/main/java/com/yssh/service/ForecastAnalyseService.java @@ -0,0 +1,69 @@ +package com.yssh.service; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.yssh.utils.DateUtils; +import com.yssh.utils.StringUtils; +import org.springframework.stereotype.Service; + +import com.yssh.mapper.DictRecordMapper; +import com.yssh.mapper.SuYuanMapper; +import com.yssh.mapper.ThuAccuracyMapper; +import com.yssh.entity.DictRecord; +import com.yssh.entity.MonitorPointPosition; +import com.yssh.entity.SuYuanMonitorData; +import com.yssh.entity.ThuAccuracy; +import com.yssh.entity.ForecastAnalyseVo; + +import javax.annotation.Resource; + +@Service +public class ForecastAnalyseService { + @Resource + private CommonService commonService; + + @Resource + private SuYuanMapper suYuanMapper; + + @Resource + private DictRecordMapper dictRecordMapper; + + @Resource + private ThuAccuracyMapper thuAccuracyMapper; + + public List<ForecastAnalyseVo> getForecastAnalyse(String name, Date beginTime, Date endTime) { + List<ForecastAnalyseVo> result = new ArrayList<ForecastAnalyseVo>(); + MonitorPointPosition checkPoint = commonService.select3dCheckPointByName(name); + if (StringUtils.isNull(checkPoint)) { + return null; + } + List<DictRecord> dictRecordList = dictRecordMapper.selectByTimeDictRecordList(Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, beginTime)), Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, endTime))); + List<String> tableNames = new ArrayList<String>(); + dictRecordList.forEach(r -> { + tableNames.add(r.getTableName()); + }); + if (StringUtils.isNotEmpty(tableNames)) { + List<SuYuanMonitorData> monitorDatas = suYuanMapper.getMonitorData(tableNames, checkPoint.getId()); + monitorDatas.forEach(m -> { + result.add(new ForecastAnalyseVo(0.0, m.getValue(), new Long(m.getTime()))); + }); + Map<String, Object> param = new HashMap<String, Object>(); + param.put("name", name); + param.put("beginTime", beginTime); + param.put("endTime", endTime); + List<ThuAccuracy> data = thuAccuracyMapper.getForecastData(param); + data.forEach(s -> { + result.forEach(r -> { + if (Long.valueOf(s.getTime()).longValue() == r.getTime().longValue()) { + r.setForecastValue(Double.valueOf(s.getValue())); + } + }); + }); + } + return result; + } +} diff --git a/src/main/java/com/yssh/service/LocationService.java b/src/main/java/com/yssh/service/LocationService.java new file mode 100644 index 0000000..8fe8d60 --- /dev/null +++ b/src/main/java/com/yssh/service/LocationService.java @@ -0,0 +1,61 @@ +package com.yssh.service; + +import com.yssh.entity.Location; +import com.yssh.mapper.LocationMapper; +import com.yssh.utils.CalculateUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +/** + * @author wMeng + * @date 2022/10/30 13:25 + * @version 1.0 + */ +@Service +public class LocationService { + @Resource + private LocationMapper mapper; + + private static List<Location> vocAddrs = null; + + public List<Location> query(String name, String type) { + return mapper.query(name, type); + } + + public List<Location> getAll() { + return mapper.getAll(); + } + + public int insertLocation(Location location) { + return mapper.insertLocation(location); + } + + public int deleteLocation(String id) { + return mapper.deleteLocation(id); + } + + public List<Location> selectVocAddrs(double x, double y) { + if (null == vocAddrs) { + vocAddrs = mapper.selectVocAddrs(); + + for (Location loc : vocAddrs) { + double X = CalculateUtils.getLon((int) loc.getLon(), (int) loc.getLat()); + double Y = CalculateUtils.getLat((int) loc.getLon(), (int) loc.getLat()); + loc.setLon(X); + loc.setLat(Y); + } + } + + List<Location> list = new ArrayList<>(); + for (Location loc : vocAddrs) { + if (Math.abs(loc.getLon() - x) <= 0.00009 && Math.abs(loc.getLat() - y) <= 0.00009) { + list.add(loc); + } + } + + return list; + } +} diff --git a/src/main/java/com/yssh/service/SuYuanService.java b/src/main/java/com/yssh/service/SuYuanService.java new file mode 100644 index 0000000..b9e558c --- /dev/null +++ b/src/main/java/com/yssh/service/SuYuanService.java @@ -0,0 +1,313 @@ +package com.yssh.service; + +import java.util.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicInteger; + +import com.yssh.entity.*; +import com.yssh.mapper.*; +import com.yssh.utils.CalculateUtils; +import com.yssh.utils.DateUtils; +import com.yssh.utils.StringUtils; +import com.yssh.utils.TableStrategy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import com.google.common.collect.Lists; + +import javax.annotation.Resource; + +@Service +public class SuYuanService { + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Resource + private SuYuanMapper suYuanMapper; + + @Resource + private AsyncService asyncService; + + @Resource + private DictRecordMapper dictRecordMapper; + + @Resource + private CommonService commonService; + + @Resource + private FeedbackMapper feedbackMapper; + + @Resource + private QxshMapper qxshMapper; + + @Resource + private LocationMapper locationMapper; + + @Resource + private LocationService locService; + + //@Transactional + @Async("threadPoolTaskExecutor") + public void insertSuYuanDatasAsync(List<SuYuan> lists, String time) throws Exception { + //鎻掑叆鏁版嵁 + List<List<SuYuan>> list = Lists.partition(lists, AsyncService.BATCH_INSERT_NUMBER); + CountDownLatch countDownLatch = new CountDownLatch(list.size()); + for (List<SuYuan> corpReserveList : list) { + asyncService.executeAsync(TableStrategy.getTableStrategy(time), corpReserveList, suYuanMapper, countDownLatch); + } + countDownLatch.await(); + logger.info(lists.size() + "鏉℃暟鎹叆搴撳畬鎴�-----"); + } + + public void insertSuYuanDatas(List<SuYuan> lists, String time) { + List<List<SuYuan>> subLists = Lists.partition(lists, AsyncService.BATCH_INSERT_NUMBER); + for (List<SuYuan> sub : subLists) { + suYuanMapper.batchInsert(TableStrategy.getTableStrategy(time), sub); + } + + logger.info("------ " + time + ".csv锛�" + lists.size() + " 鏉℃暟鎹凡鍏ュ簱 ------"); + } + + public Integer isTableExists(String tableName) { + return suYuanMapper.isTableExists(tableName); + } + + public int createNewTable(String tableName) { + return suYuanMapper.createTable(tableName); + } + + public List<SuYuan2d> selectSuYuan2d(Date date) { + String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, date); + List<String> ids2d = CalculateUtils.assembleId(commonService.getCheckPoints2d()); + DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time)); + if (StringUtils.isNull(dictRecord)) { + return null; + } + return suYuanMapper.get2d(dictRecord.getTableName(), ids2d); + } + + public List<SuYuan3d> selectSuYuan3d(String name, Date date) { + MonitorPointPosition checkPoint = commonService.select3dCheckPointByName(name); + if (StringUtils.isNull(checkPoint)) { + return null; + } + int range = 10; + String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, date); + List<String> ids3d = CalculateUtils.aloneCrosswiseExtend(checkPoint, range); + DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time)); + if (StringUtils.isNull(dictRecord)) { + return null; + } + return suYuanMapper.get3d(dictRecord.getTableName(), ids3d); + } + + public Map<String, Object> selectSuYuan100(String name, Date date) { + Map<String, Object> result = new HashMap<String, Object>(); + MonitorPointPosition checkPoint = commonService.select3dCheckPointByName(name); + if (StringUtils.isNull(checkPoint)) { + return null; + } + int range = 10; + String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, date); + List<String> ids3d = CalculateUtils.aloneCrosswiseExtend(checkPoint, range); + DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time)); + if (StringUtils.isNull(dictRecord)) { + return null; + } + List<DistanceSuYuan> list = suYuanMapper.getDistanceSuYuan(dictRecord.getTableName(), ids3d); + AtomicInteger i = new AtomicInteger(0); + list.stream().forEach(s -> { + s.setName(checkPoint.getName()); + i.getAndIncrement(); + s.setVocsName(checkPoint.getName() + "-" + i.longValue()); + }); + if (StringUtils.isNotEmpty(list)) { + Collections.sort(list); + DistanceSuYuan max = list.get(0); + FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(), + max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, DateUtils.getNowDate()); + feedbackMapper.insert(feedbackDetail); + result.put("feedbackId", feedbackDetail.getId()); + } + result.put("data", list); + return result; + } + + public Map<String, Object> selectSuYuan200(String name, Date date) { + Map<String, Object> result = new HashMap<String, Object>(); + MonitorPointPosition checkPoint = commonService.select3dCheckPointByName(name); + if (StringUtils.isNull(checkPoint)) { + return null; + } + int range = 20; + String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, date); + List<String> ids3d = CalculateUtils.aloneCrosswiseExtend(checkPoint, range); + DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time)); + if (StringUtils.isNull(dictRecord)) { + return null; + } + List<DistanceSuYuan> list = suYuanMapper.getDistanceSuYuan(dictRecord.getTableName(), ids3d); + AtomicInteger i = new AtomicInteger(0); + list.stream().forEach(s -> { + s.setName(checkPoint.getName()); + i.getAndIncrement(); + s.setVocsName(checkPoint.getName() + "-" + i.longValue()); + }); + if (StringUtils.isNotEmpty(list)) { + Collections.sort(list); + DistanceSuYuan max = list.get(0); + FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(), + max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, DateUtils.getNowDate()); + feedbackMapper.insert(feedbackDetail); + result.put("feedbackId", feedbackDetail.getId()); + } + result.put("data", list); + return result; + } + + public Map<String, Object> selectSuYuan300(String name, Date date) { + Map<String, Object> result = new HashMap<String, Object>(); + MonitorPointPosition checkPoint = commonService.select3dCheckPointByName(name); + if (StringUtils.isNull(checkPoint)) { + return null; + } + int range = 30; + String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, date); + List<String> ids3d = CalculateUtils.aloneCrosswiseExtend(checkPoint, range); + DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time)); + if (StringUtils.isNull(dictRecord)) { + return null; + } + List<DistanceSuYuan> list = suYuanMapper.getDistanceSuYuan(dictRecord.getTableName(), ids3d); + AtomicInteger i = new AtomicInteger(0); + list.stream().forEach(s -> { + s.setName(checkPoint.getName()); + i.getAndIncrement(); + s.setVocsName(checkPoint.getName() + "-" + i.longValue()); + }); + if (StringUtils.isNotEmpty(list)) { + Collections.sort(list); + DistanceSuYuan max = list.get(0); + FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(), + max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, DateUtils.getNowDate()); + feedbackMapper.insert(feedbackDetail); + result.put("feedbackId", feedbackDetail.getId()); + } + result.put("data", list); + return result; + } + + public Map<String, Object> selectSuYuan500(String name, Date date) { + Map<String, Object> result = new HashMap<String, Object>(); + MonitorPointPosition checkPoint = commonService.select3dCheckPointByName(name); + if (StringUtils.isNull(checkPoint)) { + return null; + } + int range = 50; + String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, date); + List<String> ids3d = CalculateUtils.aloneCrosswiseExtend(checkPoint, range); + DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time)); + if (StringUtils.isNull(dictRecord)) { + return null; + } + List<DistanceSuYuan> list = suYuanMapper.getDistanceSuYuan(dictRecord.getTableName(), ids3d); + AtomicInteger i = new AtomicInteger(0); + list.stream().forEach(s -> { + s.setName(checkPoint.getName()); + i.getAndIncrement(); + s.setVocsName(checkPoint.getName() + "-" + i.longValue()); + }); + if (StringUtils.isNotEmpty(list)) { + Collections.sort(list); + DistanceSuYuan max = list.get(0); + FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(), + max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, DateUtils.getNowDate()); + feedbackMapper.insert(feedbackDetail); + result.put("feedbackId", feedbackDetail.getId()); + } + result.put("data", list); + return result; + } + + public List<SuYuanMonitorData> getMonitorData(String name) { + MonitorPointPosition checkPoint = commonService.select3dCheckPointByName(name); + if (StringUtils.isNull(checkPoint)) { + return null; + } + + /*List<DictRecord> recordList = dictRecordMapper.selectDictRecordList(new DictRecord()); + + List<String> tableNames = new ArrayList<String>(); + for (DictRecord dr : recordList) { + if (suYuanMapper.isTableExists(dr.getTableName()) > 0) { + tableNames.add(dr.getTableName()); + } + } + + return suYuanMapper.getMonitorData(tableNames, checkPoint.getX() + "_" + checkPoint.getY() + "_" + checkPoint.getZ());*/ + + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.HOUR_OF_DAY, 23); + String end = DateUtils.getYyyyMmDdHh(calendar.getTime()); //dateFormat.format(calendar.getTime()); + + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.add(Calendar.DATE, -7); + String start = DateUtils.getYyyyMmDdHh(calendar.getTime()); + + return suYuanMapper.getNewMonitorData(checkPoint.getName(), start, end); + } + + public int updateVocsName(Date date, String id, String vocsName) { + String table = "su_yuan_" + DateUtils.getYyyyMmDdHh(date); // new Date() + if (isTableExists(table) == 0) { + return 0; + } + + //return suYuanMapper.updateVocsName(table, id, vocsName); + return 1; + } + + public List<Qxsh> queryQxsh(Date date) { + String time = DateUtils.getYyyyMmDdHh(date); + + return qxshMapper.selectByTime(time); + } + + public List<List<Coordinate>> selectRects(Double[] x, Double[] y) { + List<List<Coordinate>> list = new ArrayList<>(); + for (int i = 0; i < x.length; i++) { + list.add(CalculateUtils.calcRect(x[i], y[i])); + } + + return list; + } + + public SuYuan700 selectSuYuan700ById(String id, Date date) { + id = id.substring(0, id.lastIndexOf("_") + 1) + "0"; + String time = DateUtils.getYyyyMmDdHhMmSs(date).substring(0, 13) + ":00:00"; + + return suYuanMapper.selectSuYuan700ById(id, time); + } + + public SuYuan700 selectSuYuan46ById(String id, Date date) { + id = id.substring(0, id.lastIndexOf("_") + 1) + "0"; + String time = DateUtils.getYyyyMmDdHhMmSs(date).substring(0, 13) + ":00:00"; + + return suYuanMapper.selectSuYuan46ById(id, time); + } + + public String selectAddrByXY(double x, double y) { + List<Location> locations = locationMapper.selectByXY(x, y); + if (null != locations && locations.size() > 0) { + return locations.get(0).getName(); + } + + locations = locService.selectVocAddrs(x, y); + if (null != locations && locations.size() > 0) { + return locations.get(0).getName(); + } + + return null; + } +} diff --git a/src/main/java/com/yssh/service/VocValsService.java b/src/main/java/com/yssh/service/VocValsService.java new file mode 100644 index 0000000..c87adc1 --- /dev/null +++ b/src/main/java/com/yssh/service/VocValsService.java @@ -0,0 +1,82 @@ +package com.yssh.service; + +import com.google.common.collect.Lists; +import com.yssh.entity.VocCoords; +import com.yssh.entity.VocVals; +import com.yssh.mapper.VocValsMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.concurrent.CountDownLatch; + +@Service +public class VocValsService { + @Resource + VocValsMapper vocValsMapper; + + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + public List<VocVals> selectByTime(String time) { + return vocValsMapper.selectByTime(time); + } + + public int countByTime(String time) { + return vocValsMapper.countByTime(time); + } + + public List<VocCoords> selectCoords(Integer x, Integer y) { + return vocValsMapper.selectCoords(x, y); + } + + public int insert(VocVals vv) { + return vocValsMapper.insert(vv); + } + + public int inserts(List<VocVals> list) { + return vocValsMapper.inserts(list); + } + + public int deleteLastYear() { + return vocValsMapper.deleteLastYear(); + } + + public int deleteByTime(String time) { + return vocValsMapper.deleteByTime(time); + } + + public void insertVocSync(List<VocVals> list) { + List<List<VocVals>> subLists = Lists.partition(list, 100); + for (List<VocVals> sub : subLists) { + vocValsMapper.inserts(sub); + } + + logger.info("------ VOC.csv锛�" + list.size() + " 鏉℃暟鎹凡鍏ュ簱 ------"); + } + + @Async("threadPoolTaskExecutor") + public void insertVocVals(List<VocVals> list) throws InterruptedException { + List<List<VocVals>> lists = Lists.partition(list, AsyncService.BATCH_INSERT_500); + + CountDownLatch countDownLatch = new CountDownLatch(list.size()); + for (List<VocVals> corpList : lists) { + executeAsync(corpList, countDownLatch); + } + + countDownLatch.await(); + logger.info("------ VOC.csv锛�" + lists.size() + " 鏉℃暟鎹凡鍏ュ簱 ------"); + } + + private void executeAsync(List<VocVals> corpList, CountDownLatch countDownLatch) { + try { + // 寮傛绾跨▼瑕佸仛鐨勪簨鎯� + vocValsMapper.inserts(corpList); + } finally { + // 寰堝叧閿�, 鏃犺涓婇潰绋嬪簭鏄惁寮傚父蹇呴』鎵цcountDown,鍚﹀垯await鏃犳硶閲婃斁 + countDownLatch.countDown(); + } + } +} diff --git a/src/main/java/com/yssh/service/WarningAnalyseService.java b/src/main/java/com/yssh/service/WarningAnalyseService.java new file mode 100644 index 0000000..4e06729 --- /dev/null +++ b/src/main/java/com/yssh/service/WarningAnalyseService.java @@ -0,0 +1,396 @@ +package com.yssh.service; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CountDownLatch; + +import com.yssh.entity.*; +import com.yssh.mapper.DictRecordMapper; +import com.yssh.mapper.QxshMapper; +import com.yssh.mapper.SuYuanMapper; +import com.yssh.mapper.WarningDetailMapper; +import com.yssh.utils.CalculateUtils; +import com.yssh.utils.DateUtils; +import com.yssh.utils.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import com.google.common.collect.Lists; +import com.yssh.entity.WarningVo; + +import javax.annotation.Resource; + +@Service +public class WarningAnalyseService { + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Resource + private WarningDetailMapper warningDetailMapper; + + @Resource + private CommonService commonService; + + @Resource + private SuYuanMapper suYuanMapper; + + @Resource + private DictRecordMapper dictRecordMapper; + + @Resource + private AsyncService asyncService; + + @Resource + private QxshMapper qxshMapper; + + private SimpleDateFormat ym = new SimpleDateFormat("yyyyMM%"); + + @Async("threadPoolTaskExecutor") + public void insertWarningDetails(List<WarningDetail> warning) throws Exception { + //鎻掑叆鏁版嵁 + List<List<WarningDetail>> list = Lists.partition(warning, AsyncService.BATCH_INSERT_NUMBER); + CountDownLatch countDownLatch = new CountDownLatch(list.size()); + for (List<WarningDetail> corpReserveList : list) { + asyncService.executeAsync("", corpReserveList, warningDetailMapper, countDownLatch); + } + countDownLatch.await(); + } + + public List<WarningVo> getRunTimeAlarmAnalyse() { + List<WarningVo> result = new ArrayList<>(); + Date nowDate = DateUtils.getNowDate(); + //String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, nowDate); + //DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time)); + //if (StringUtils.isNull(dictRecord)) { + // nowDate = DateUtils.getAPeriodOfTime(nowDate, -1, Calendar.HOUR_OF_DAY); + //} + //List<WarningDetail> list = alarmAnalyseOperation(nowDate); + + List<WarningDetail> list = new ArrayList<>(); + Calendar calendar = getCalendar(nowDate); + for (int i = 0; i < 6; i++) { + calendar.add(Calendar.HOUR, -1); + List<WarningDetail> rs = getAlarmWarnAnalyse(calendar.getTime(), false); + if (null != rs && rs.size() > 0) { + list.addAll(rs); + } + } + list.forEach(s -> { + String time = DateUtils.getYyyyMmDdHh(s.getCreateTime()); + result.add(new WarningVo(s.getLocationName(), s.getSuYuanId(), 0.0, 0.0, s.getValue(), time)); + }); + return result; + } + + private Calendar getCalendar(Date nowDate) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(nowDate); + calendar.add(Calendar.HOUR, 1); + + return calendar; + } + + public List<WarningVo> getRunTimeWarningAnalyse() { + List<WarningVo> result = new ArrayList<>(); + Date nowDate = DateUtils.getNowDate(); + //String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, nowDate); + //DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time)); + //if (StringUtils.isNull(dictRecord)) { + // nowDate = DateUtils.getAPeriodOfTime(nowDate, -1, Calendar.HOUR_OF_DAY); + //} + //List<WarningDetail> list = warningAnalyseOperation(nowDate); + + List<WarningDetail> list = new ArrayList<>(); + Calendar calendar = getCalendar(nowDate); + for (int i = 0; i < 6; i++) { + calendar.add(Calendar.HOUR, -1); + List<WarningDetail> rs = getAlarmWarnAnalyse(calendar.getTime(), true); + if (null != rs && rs.size() > 0) { + list.addAll(rs); + } + } + list.forEach(s -> { + String time = DateUtils.getYyyyMmDdHh(s.getCreateTime()); + result.add(new WarningVo(s.getLocationName(), s.getSuYuanId(), 0.0, 0.0, s.getValue(), time)); + }); + return result; + } + + private List<WarningDetail> getAlarmWarnAnalyse(Date date, boolean isWarn) { + List<String> ids = CalculateUtils.assembleId(commonService.getCheckPoints3d()); + + String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, date); + DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time)); + if (null == dictRecord) return null; + + String tableName = dictRecord.getTableName(); + if (suYuanMapper.isTableExists(tableName) == 0) return null; + + List<SuYuan2d> list = isWarn ? suYuanMapper.getWarningAnalyse(tableName, ids) : suYuanMapper.getAlarmsAnalyse(tableName, ids); + if (null == list || list.isEmpty()) { + return null; + } + + int type = isWarn ? 1 : 0; + List<WarningDetail> result = new ArrayList<>(); + for (SuYuan2d s : list) { + String locationName = commonService.select3dCheckPointById(s.getId()).getName(); + result.add(new WarningDetail(0L, tableName, s.getId(), locationName, date, type, s.getValue())); + } + + return result; + } + + public void warningOperationStorage(Date date) { + List<WarningDetail> allData = new ArrayList<>(); + List<WarningDetail> alarms = this.getAlarmWarnAnalyse(date, false); + if (StringUtils.isNotEmpty(alarms)) { + allData.addAll(alarms); + } + + List<WarningDetail> warnings = this.getAlarmWarnAnalyse(date, true); + if (StringUtils.isNotEmpty(warnings)) { + allData.addAll(warnings); + } + + if (StringUtils.isNotEmpty(allData)) { + try { + insertWarningDetails(allData); + } catch (Exception e) { + logger.error("鎵归噺鎻掑叆鍛婅鏁版嵁鍑虹幇寮傚父锛侊紒锛�", e); + e.printStackTrace(); + } + } + } + + public Map<String, Integer> countThisMonthAlarmAndWarning() { + Map<String, Integer> result = new HashMap<>(); + Map<String, Object> param = new HashMap<>(); + param.put("startTime", DateUtils.getYyyyMmDdHhMmSs(DateUtils.getMonthStart())); + param.put("endTime", DateUtils.getYyyyMmDdHhMmSs(DateUtils.getMonthEnd())); + + /*param.put("type", 0); + List<WarningVo> alarms = warningDetailMapper.selectWarningDetailByMap(param); + if (StringUtils.isNull(alarms)) { + alarms = new ArrayList<>(); + } + result.put("alarmNumber", alarms.size());*/ + Integer alarmNum = warningDetailMapper.countAlarmByMap(param); + result.put("alarmNumber", null == alarmNum ? 0 : alarmNum); + + param.put("type", 1); + /*List<WarningVo> warnings = warningDetailMapper.selectWarningDetailByMap(param); + if (StringUtils.isNull(warnings)) { + warnings = new ArrayList<>(); + } + result.put("warningNumber", warnings.size());*/ + Integer warnNum = warningDetailMapper.countWarnByMap(param); + result.put("warningNumber", null == warnNum ? 0 : warnNum); + + return result; + } + + public Map<String, List<Map<String, Object>>> countEverydayAlarmAndWarning() { + Map<String, List<Map<String, Object>>> result = new HashMap<>(); + + Map<String, Object> param = new HashMap<String, Object>(); + Date now = new Date(); + Date last = DateUtils.getAPeriodOfTime(now, -7, Calendar.DATE); // 涓婂懆鐨勪粖澶� + param.put("startTime", DateUtils.getYyyyMmDdHhMmSs(last)); + param.put("endTime", DateUtils.getYyyyMmDdHhMmSs(now)); + + param.put("type", 0); + List<Map<String, Object>> alarmDayCount = warningDetailMapper.selectWarningDayCountByMap(param); + result.put("alarmDayCount", alarmDayCount); + + param.put("type", 1); + List<Map<String, Object>> warningDayCount = warningDetailMapper.selectWarningDayCountByMap(param); + result.put("warningDayCount", warningDayCount); + + return result; + } + + public Map<String, List<Double>> selectEachLocationDataChange() { + /*Map<String, List<Double>> result = new LinkedHashMap<>(); + List<MonitorPointPosition> checkPoints = commonService.getCheckPoints3d(); + Date nowDate = DateUtils.getNowDate(); + Long endTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, nowDate)); + Long startTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getAPeriodOfTime(nowDate, -3, Calendar.HOUR_OF_DAY))); + List<DictRecord> recordList = dictRecordMapper.selectByTimeDictRecordList(startTime, endTime); + checkPoints.forEach(c -> { + List<String> tableNames = new ArrayList<>(); + recordList.forEach(r -> { + tableNames.add(r.getTableName()); + }); + List<Double> values = new ArrayList<>(); + if (StringUtils.isNotNull(tableNames)) { + List<SuYuanMonitorData> data = suYuanMapper.getMonitorData(tableNames, c.getId()); + data.forEach(v -> { + values.add(v.getValue()); + }); + result.put(c.getName(), values); + } + }); + return result;*/ + + Map<String, List<Double>> result = new LinkedHashMap<>(); + List<MonitorPointPosition> checkPoints = commonService.getCheckPoints3d(); + Date nowDate = DateUtils.getNowDate(); + Long endTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, nowDate)); + Long startTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getAPeriodOfTime(nowDate, -3, Calendar.HOUR_OF_DAY))); + List<DictRecord> recordList = dictRecordMapper.selectByTimeDictRecordList(startTime, endTime); + + List<String> tableNames = new ArrayList<>(); + for (DictRecord dr : recordList) { + if (suYuanMapper.isTableExists(dr.getTableName()) > 0) { + tableNames.add(dr.getTableName()); + } + } + if (tableNames.isEmpty()) { + return result; + } + + for (MonitorPointPosition c : checkPoints) { + List<Double> values = new ArrayList<>(); + List<SuYuanMonitorData> data = suYuanMapper.getMonitorData(tableNames, c.getId()); + if (null != data && data.size() > 0) { + for (SuYuanMonitorData v : data) { + values.add(v.getValue()); + } + } + result.put(c.getName(), values); + } + return result; + } + + public List<Map<String, Object>> selectThisMonthLocationValueDataTop10() { + /*List<Map<String, Object>> result = new ArrayList<>(); + List<MonitorPointPosition> checkPoints = commonService.getCheckPoints3d(); + Long startTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getMonthStart())); + Long endTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getMonthEnd())); + List<DictRecord> recordList = dictRecordMapper.selectByTimeDictRecordList(startTime, endTime); + checkPoints.forEach(c -> { + List<String> tableNames = new ArrayList<>(); + recordList.forEach(r -> { + tableNames.add(r.getTableName()); + }); + Map<String, Object> map = suYuanMapper.getMonthValueDataMax(tableNames, c.getId()); + if (StringUtils.isNotNull(map) && StringUtils.isNotEmpty(map)) { + String suYuanId = map.get("id").toString(); + map.put("name", commonService.select3dCheckPointById(suYuanId).getName()); + map.remove("id"); + } + result.add(map); + }); + return CalculateUtils.sort(result, "value", true).subList(0, 10);*/ + + List<Map<String, Object>> result = new ArrayList<>(); + List<MonitorPointPosition> checkPoints = commonService.getCheckPoints3d(); + Long startTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getMonthStart())); + Long endTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getMonthEnd())); + //startTime = 2023040100L; + //endTime = 2023043023L; + + List<DictRecord> recordList = dictRecordMapper.selectByTimeDictRecordList(startTime, endTime); + + List<String> tableNames = new ArrayList<>(); + for (DictRecord dr : recordList) { + if (suYuanMapper.isTableExists(dr.getTableName()) > 0) { + tableNames.add(dr.getTableName()); + } + } + if (tableNames.isEmpty()) { + return result; + } + + /*List<String> idList = new ArrayList<>(); + for (MonitorPointPosition c : checkPoints) { + idList.add("'" + c.getId() + "'"); + } + String ids = String.join(",", idList);*/ + + for (MonitorPointPosition c : checkPoints) { + Map<String, Object> map = suYuanMapper.getMonthValueDataMax(tableNames, c.getId()); + if (null != map && map.size() > 0) { + //String suYuanId = map.get("id").toString(); + //map.put("name", commonService.select3dCheckPointById(suYuanId).getName()); + //map.remove("id"); + map.put("name", c.getName()); + result.add(map); + } + } + + return CalculateUtils.sort(result, "value", true).subList(0, 10); + } + + public List<Qxsh> selectMonthTop10() { + String time = DateUtils.getYyyyMm(new Date()); + + List<Qxsh> list = qxshMapper.selectMonthTop10(time + "%"); + + return list; + } + + public Map<String, List<Double>> select3Hours() { + Map<String, List<Double>> map = new LinkedHashMap<>(); + + List<String> times = DateUtils.get3Hours(); + List<Qxsh> list = qxshMapper.select3Hours(times); + if (null == list || list.isEmpty()) { + return map; + } + + for (Qxsh qxsh : list) { + String name = qxsh.getName(); + List<Double> values = map.computeIfAbsent(name, k -> new ArrayList<>()); + values.add(qxsh.getValue()); + } + + return map; + } + + public List<Report> getAlarmAndWarnByTime(Date begin, Date end) { + String startTime = DateUtils.getYyyyMmDdHhMmSs(begin); + String endTime = DateUtils.getYyyyMmDdHhMmSs(end); + + List<WarningDetail> rs = new ArrayList<>(); + List<WarningDetail> rsYj = warningDetailMapper.selectByTimeForYj(startTime, endTime); + if (null != rsYj && rsYj.size() > 0) rs.addAll(rsYj); + + List<WarningDetail> rsBj = warningDetailMapper.selectByTimeForBj(startTime, endTime); + if (null != rsBj && rsBj.size() > 0) rs.addAll(rsBj); + + List<Report> list = new ArrayList<>(); + for (WarningDetail wd : rs) { + //String time = ymdh.format(wd.getCreateTime()); + //list.add(new WarningVo(wd.getLocationName(), wd.getSuYuanId(), 0.0, 0.0, wd.getValue(), time)); + + DistanceSuYuan suYuan = suYuanMapper.getSuYuanById(wd.getTableName(), wd.getSuYuanId()); + Double lastVal = warningDetailMapper.getLastYearVal(wd.getId()); + + int rows = suYuanMapper.isTableExists(wd.getTableName()); + DistanceSuYuan suMax = null; + if (rows > 0) { + MonitorPointPosition point = commonService.select3dCheckPointByName(wd.getLocationName()); + List<String> ids3d = CalculateUtils.aloneCrosswiseExtend(point, 50); + suMax = suYuanMapper.getSuYuan500Max(wd.getTableName(), ids3d); + } else { + suMax = suYuan; + } + + Report report = Report.calcReport(wd, suYuan, suMax); + report.setLastVal(lastVal); + + list.add(report); + } + + return list; + } +} diff --git a/src/main/java/com/yssh/service/WeatherService.java b/src/main/java/com/yssh/service/WeatherService.java new file mode 100644 index 0000000..8ffecb0 --- /dev/null +++ b/src/main/java/com/yssh/service/WeatherService.java @@ -0,0 +1,38 @@ +package com.yssh.service; + +import com.yssh.entity.Weather; +import com.yssh.mapper.WeatherMapper; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author wMeng + * @ClassName YsshWeatherServiceImpl + * @Description TODO + * @date 2022/10/30 14:11 + * @Version 1.0 + */ +@Service +public class WeatherService { + @Resource + private WeatherMapper weatherMapper; + + public List<Weather> query(String begin, String end) { + List<Weather> data = weatherMapper.query(begin, end); + return data; + } + + public List<Weather> getAll() { + return weatherMapper.getAll(); + } + + public int insert(Weather weather) { + return weatherMapper.insert(weather); + } + + public int delete(String id) { + return weatherMapper.delete(id); + } +} diff --git a/src/main/java/com/yssh/utils/AjaxResult.java b/src/main/java/com/yssh/utils/AjaxResult.java new file mode 100644 index 0000000..1d07640 --- /dev/null +++ b/src/main/java/com/yssh/utils/AjaxResult.java @@ -0,0 +1,186 @@ +package com.yssh.utils; + +import java.util.HashMap; + +/** + * 鎿嶄綔娑堟伅鎻愰啋 + * + * @author xingjinshuang@smartearth.cn + * @date 2023-02-06 + */ +public class AjaxResult extends HashMap<String, Object> { + private static final long serialVersionUID = 1L; + + /** 鐘舵�佺爜 */ + public static final String CODE_TAG = "code"; + + /** 杩斿洖鍐呭 */ + public static final String MSG_TAG = "msg"; + + /** 鏁版嵁瀵硅薄 */ + public static final String DATA_TAG = "data"; + + /** + * 鍒濆鍖栦竴涓柊鍒涘缓鐨� AjaxResult 瀵硅薄锛屼娇鍏惰〃绀轰竴涓┖娑堟伅銆� + */ + public AjaxResult() { + } + + /** + * 鍒濆鍖栦竴涓柊鍒涘缓鐨� AjaxResult 瀵硅薄 + * + * @param code + * 鐘舵�佺爜 + * @param msg + * 杩斿洖鍐呭 + */ + public AjaxResult(int code, String msg) { + super.put(CODE_TAG, code); + super.put(MSG_TAG, msg); + } + + /** + * 鍒濆鍖栦竴涓柊鍒涘缓鐨� AjaxResult 瀵硅薄 + * + * @param code + * 鐘舵�佺爜 + * @param msg + * 杩斿洖鍐呭 + * @param data + * 鏁版嵁瀵硅薄 + */ + public AjaxResult(int code, String msg, Object data) { + super.put(CODE_TAG, code); + super.put(MSG_TAG, msg); + if (StringUtils.isNotNull(data)) { + super.put(DATA_TAG, data); + } + } + + /** + * 杩斿洖鎴愬姛娑堟伅 + * + * @return 鎴愬姛娑堟伅 + */ + public static AjaxResult success() { + return AjaxResult.success("鎿嶄綔鎴愬姛"); + } + + /** + * 杩斿洖鎴愬姛鏁版嵁 + * + * @return 鎴愬姛娑堟伅 + */ + public static AjaxResult success(Object data) { + return AjaxResult.success("鎿嶄綔鎴愬姛", data); + } + + /** + * 杩斿洖鎴愬姛娑堟伅 + * + * @param msg + * 杩斿洖鍐呭 + * @return 鎴愬姛娑堟伅 + */ + public static AjaxResult success(String msg) { + return AjaxResult.success(msg, null); + } + + /** + * 杩斿洖鎴愬姛娑堟伅 + * + * @param msg + * 杩斿洖鍐呭 + * @param data + * 鏁版嵁瀵硅薄 + * @return 鎴愬姛娑堟伅 + */ + public static AjaxResult success(String msg, Object data) { + return new AjaxResult(HttpStatus.SUCCESS, msg, data); + } + + /** + * 杩斿洖璀﹀憡娑堟伅 + * + * @param msg + * 杩斿洖鍐呭 + * @return 璀﹀憡娑堟伅 + */ + public static AjaxResult warn(String msg) { + return AjaxResult.warn(msg, null); + } + + /** + * 杩斿洖璀﹀憡娑堟伅 + * + * @param msg + * 杩斿洖鍐呭 + * @param data + * 鏁版嵁瀵硅薄 + * @return 璀﹀憡娑堟伅 + */ + public static AjaxResult warn(String msg, Object data) { + return new AjaxResult(HttpStatus.WARN, msg, data); + } + + /** + * 杩斿洖閿欒娑堟伅 + * + * @return 閿欒娑堟伅 + */ + public static AjaxResult error() { + return AjaxResult.error("鎿嶄綔澶辫触"); + } + + /** + * 杩斿洖閿欒娑堟伅 + * + * @param msg + * 杩斿洖鍐呭 + * @return 閿欒娑堟伅 + */ + public static AjaxResult error(String msg) { + return AjaxResult.error(msg, null); + } + + /** + * 杩斿洖閿欒娑堟伅 + * + * @param msg + * 杩斿洖鍐呭 + * @param data + * 鏁版嵁瀵硅薄 + * @return 閿欒娑堟伅 + */ + public static AjaxResult error(String msg, Object data) { + return new AjaxResult(HttpStatus.ERROR, msg, data); + } + + /** + * 杩斿洖閿欒娑堟伅 + * + * @param code + * 鐘舵�佺爜 + * @param msg + * 杩斿洖鍐呭 + * @return 閿欒娑堟伅 + */ + public static AjaxResult error(int code, String msg) { + return new AjaxResult(code, msg, null); + } + + /** + * 鏂逛究閾惧紡璋冪敤 + * + * @param key + * 閿� + * @param value + * 鍊� + * @return 鏁版嵁瀵硅薄 + */ + @Override + public AjaxResult put(String key, Object value) { + super.put(key, value); + return this; + } +} diff --git a/src/main/java/com/yssh/utils/CacheUtils.java b/src/main/java/com/yssh/utils/CacheUtils.java new file mode 100644 index 0000000..10527b1 --- /dev/null +++ b/src/main/java/com/yssh/utils/CacheUtils.java @@ -0,0 +1,35 @@ +package com.yssh.utils; + +import com.github.benmanes.caffeine.cache.Cache; +import com.github.benmanes.caffeine.cache.Caffeine; +import org.checkerframework.checker.nullness.qual.NonNull; + +import java.util.concurrent.TimeUnit; + +public class CacheUtils { + private static @NonNull Cache<String, Object> cache; + + public static void init() { + cache = Caffeine.newBuilder() + .initialCapacity(2) + .maximumSize(1024) + .expireAfterWrite(24, TimeUnit.HOURS) + .build(); + } + + public static Object get(String key) { + return cache.getIfPresent(key); + } + + public static void put(String key, Object obj) { + cache.put(key, obj); + } + + public static void remove(String key) { + cache.invalidate(key); + } + + public static void clear() { + cache.invalidateAll(); + } +} diff --git a/src/main/java/com/yssh/utils/CalculateUtils.java b/src/main/java/com/yssh/utils/CalculateUtils.java new file mode 100644 index 0000000..73871a4 --- /dev/null +++ b/src/main/java/com/yssh/utils/CalculateUtils.java @@ -0,0 +1,371 @@ +package com.yssh.utils; + +import java.awt.geom.Point2D; +import java.util.*; + +import com.yssh.entity.Coordinate; +import com.yssh.entity.DistanceSuYuan; +import com.yssh.entity.MonitorPointPosition; +import org.geotools.geometry.DirectPosition2D; +import org.geotools.referencing.CRS; +import org.geotools.referencing.GeodeticCalculator; +import org.geotools.referencing.crs.DefaultGeographicCRS; +import org.opengis.referencing.crs.CoordinateReferenceSystem; + +public class CalculateUtils { + /** + * 榛樿鍦扮悆鍗婂緞,璧ら亾鍗婂緞(鍗曚綅m) + */ + private final static double EARTH_RADIUS1 = 6371000; + + /** + * 杞寲涓哄姬搴�(rad) + */ + private static double rad(double d) { + return d * Math.PI / 180.0; + } + + /** + * 璁$畻璺濈1 + */ + public static double getDistance1(double lon1, double lat1, double lon2, double lat2) { + double radLat1 = rad(lat1); + double radLat2 = rad(lat2); + double a = radLat1 - radLat2; + double b = rad(lon1) - rad(lon2); + double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); + + s = s * EARTH_RADIUS1; + + return round2(s); + } + + /** + * 璁$畻璺濈2 + */ + public static double getDistance2(double x1, double y1, double x2, double y2) { + // 84鍧愭爣绯绘瀯閫燝eodeticCalculator + GeodeticCalculator geodeticCalculator = new GeodeticCalculator(DefaultGeographicCRS.WGS84); + + // 璧风偣缁忕含搴� + geodeticCalculator.setStartingGeographicPoint(x1, y1); + + // 鏈偣缁忕含搴� + geodeticCalculator.setDestinationGeographicPoint(x2, y2); + + // 璁$畻璺濈锛屽崟浣嶏細绫� + double distance = geodeticCalculator.getOrthodromicDistance(); + + return round2(distance); + } + + /** + * 淇濈暀2浣嶅皬鏁� + */ + public static double round2(double d) { + return ((long) (d * 100)) / 100D; + } + + /** + * 淇濈暀6浣嶅皬鏁� + */ + public static double round6(double d) { + return ((long) (d * 1000000)) / 1000000D; + } + + /** + * 璁$畻瑙掑害 + */ + public static double getAngle(double x1, double y1, double x2, double y2) { + try { + CoordinateReferenceSystem crs = CRS.decode("EPSG:4326"); + DirectPosition2D p1 = new DirectPosition2D(crs, x1, y1); + DirectPosition2D p2 = new DirectPosition2D(crs, x2, y2); + + GeodeticCalculator gc = new GeodeticCalculator(); + gc.setStartingGeographicPoint(p1); + gc.setDestinationGeographicPoint(p2); + + double angle = gc.getAzimuth(); + + return round2(angle); + } catch (Exception ex) { + return 0; + } + } + + /** + * 璁$畻瑙掑害2 + */ + public static double getAngle2(double x1, double y1, double x2, double y2) { + try { + DirectPosition2D p1 = new DirectPosition2D(x1, y1); + DirectPosition2D p2 = new DirectPosition2D(x2, y2); + + GeodeticCalculator gc = new GeodeticCalculator(); + gc.setStartingGeographicPoint(p1); + gc.setDestinationGeographicPoint(p2); + + double angle = gc.getAzimuth(); + + return round2(angle); + } catch (Exception ex) { + return 0; + } + } + + /** + * 鑾峰彇鍧愭爣 + * + * @param su + * @return + */ + public static Coordinate getCoordinate(DistanceSuYuan su) { + String[] sirs = su.getId().split("_"); + + int x = Integer.parseInt(sirs[0]); + int y = Integer.parseInt(sirs[1]); + double lon = CalculateUtils.getLon(x, y); + double lat = CalculateUtils.getLat(x, y); + + return new Coordinate(lon, lat); + } + + /** + * 璁$畻缁忓害 + * + * @param @param x + * @param @param y + * @param @return 鍙傛暟 + * @return double 杩斿洖绫诲瀷 + * @throws + * @Title: getLon + * @Description: 璁$畻缁忓害 + */ + public static double getLon(int x, int y) { + double lon = 115.9165227 + 0.000116732 * (x - 0.5) + 0.00000116862 * (y - 0.5); + if (lon < 115 || lon > 116) { + System.out.println("lon is invalid"); + } + + return round6(lon); + } + + /** + * 璁$畻缁村害 + * + * @param @param x + * @param @param y + * @param @return 鍙傛暟 + * @return double 杩斿洖绫诲瀷 + * @throws + * @Title: getLat + * @Description: 璁$畻缁村害 + */ + public static double getLat(int x, int y) { + double lat = 39.77250000 + 0.000001000 * (x - 0.5) - 0.00009000000 * (y - 0.5); + if (lat < 39 || lat > 40) { + System.out.println("lat is invalid"); + } + + return round6(lat); + } + + /** + * @param @param checkPoints + * @param @return 鍙傛暟 + * @return List<String> 杩斿洖绫诲瀷 + * @throws + * @Title: assembleId + * @Description: 缁勮id + */ + public static List<String> assembleId(List<MonitorPointPosition> checkPoints) { + List<String> ids2d = new ArrayList<>(); + for (MonitorPointPosition point : checkPoints) { + // ids2d.add(point.getX() + "_" + point.getY() + "_" + point.getZ()); + ids2d.add(point.getX() + "_" + point.getY() + "_" + 0); + } + return ids2d; + } + + /** + * @param @param checkPoint + * @param @param range + * @param @return 鍙傛暟 + * @return List<String> 杩斿洖绫诲瀷 + * @Title: aloneCrosswiseScope + * @Description: 鍗曠嫭鐐逛綅妯悜鑼冨洿鎵╁睍 + * @backup 寮哄埗灏嗗眰绾ф敼涓� 0 + */ + public static List<String> aloneCrosswiseExtend(MonitorPointPosition checkPoint, int range) { + List<String> ids = new ArrayList<>(); + Integer x = checkPoint.getX(); + Integer y = checkPoint.getY(); + for (int i = x - range / 2; i <= x + range / 2; i++) { + for (int j = y - range / 2; j <= y + range / 2; j++) { + // ids.add(i + "_" + j + "_" + checkPoint.getZ()); + ids.add(i + "_" + j + "_" + 0); + } + } + return ids; + } + + public static List<String> temporary(MonitorPointPosition point, int range) { + List<String> ids3d = new ArrayList<>(); + Integer x = point.getX(); + Integer y = point.getY(); + Integer z = point.getZ(); + for (int i = x - range / 2; i <= x + range / 2; i++) { + for (int j = y - range / 2; j <= y + range / 2; j++) { + for (int k = z; k < 100; k++) { + ids3d.add(i + "_" + j + "_" + k); + } + } + } + return ids3d; + } + + /** + * 鑾峰彇鏂瑰悜 + */ + public static String getDir(double direction) { + if (direction < 0) { + direction = direction + 360; + } + if (direction > 360) { + direction = direction - 360; + } + + if (direction >= 22.5 && direction < 67.5) + return "涓滃寳"; + if (direction >= 67.5 && direction < 112.5) + return "涓�"; + if (direction >= 112.5 && direction < 157.5) + return "涓滃崡"; + if (direction >= 157.5 && direction < 202.5) + return "鍗�"; + if (direction >= 202.5 && direction < 247.5) + return "瑗垮崡"; + if (direction >= 247.5 && direction < 292.5) + return "瑗�"; + if (direction >= 292.5 && direction < 337.5) + return "瑗垮寳"; + + return "鍖�"; + } + + /** + * 璁$畻X銆乊鍊肩殑鐭╁舰妗� + */ + public static List<Coordinate> calcRect(double x, double y) { + double buffer = 10; + double dis = round6(Math.sqrt(Math.pow(buffer / 2, 2) * 2)); + + List<Coordinate> list = new ArrayList<>(); + list.add(getPointByDisAndAngle(x, y, 315, dis)); + list.add(getPointByDisAndAngle(x, y, 45, dis)); + list.add(getPointByDisAndAngle(x, y, 135, dis)); + list.add(getPointByDisAndAngle(x, y, 225, dis)); + + return list; + } + + /** + * 鏍规嵁璺濈鍜岃搴﹁幏鍙栫洰鏍囩偣 + */ + private static Coordinate getPointByDisAndAngle(double x, double y, double angle, double dis) { + try { + DirectPosition2D p1 = new DirectPosition2D(x, y); + + GeodeticCalculator gc = new GeodeticCalculator(); + gc.setStartingGeographicPoint(p1); + gc.setDirection(angle, dis); + + Point2D dest = gc.getDestinationGeographicPoint(); + double newX = round6(dest.getX()); + double newY = round6(dest.getY()); + + return new Coordinate(newX, newY); + } catch (Exception ex) { + return new Coordinate(); + } + } + + /** + * @param @return 鍙傛暟 + * @return Double 杩斿洖绫诲瀷 + * @throws + * @Title: getWindSpeed + * @Description: 璁$畻椋庨�� + */ + public static Double getWindSpeed(double v, double u) { + return round6(Math.sqrt(v * v + u * u)); + } + + /** + * @param @param v + * @param @param u + * @param @return 鍙傛暟 + * @return double 杩斿洖绫诲瀷 + * @throws + * @Title: getWindDirection + * @Description: 璁$畻椋庡悜 + */ + public static double getWindDirection(double v, double u) { + double result = Math.atan(u / (v + Math.pow(10, -5))) / Math.PI * 180; + if (result < 0) { + result += 180; + } else if (u < 0 && v > 0) { + result += 360; + } + + return round6(result); + } + + /** + * @param @param list 鎺掑簭瀵硅薄 + * @param @param property 鎺掑簭鍙傛暟 + * @param @param order 鎺掑簭椤哄簭 + * @param @return 鍙傛暟 + * @return List<Map < String, Object>> 杩斿洖绫诲瀷 + * @throws + * @Title: sort + * @Description: 鎺掑簭 + */ + public static List<Map<String, Object>> sort(List<Map<String, Object>> list, final String property, final boolean order) { + if (list == null || property == null) { + return null; + } + Collections.sort(list, new Comparator<Map<String, Object>>() { + @Override + public int compare(Map<String, Object> o1, Map<String, Object> o2) { + try { + Object oo1 = o1.get(property); + Object oo2 = o2.get(property); + if (oo1 == null || "null".equals(oo1.toString()) || "".equals(oo1.toString()) || oo1.toString().endsWith("999")) { + oo1 = 0; + } + if (oo2 == null || "null".equals(oo2.toString()) || "".equals(oo2.toString()) || oo2.toString().endsWith("999")) { + oo2 = 0; + } + if (order) { + if (Double.parseDouble(oo1.toString()) < Double.parseDouble(oo2.toString())) { + return 1; + } + } else { + if (Double.parseDouble(oo1.toString()) > Double.parseDouble(oo2.toString())) { + return 1; + } + } + if (Double.parseDouble(oo1.toString()) == Double.parseDouble(oo2.toString())) { + return 0; + } + } catch (Exception ex) { + System.out.println(ex.getMessage()); + } + return -1; + } + }); + return list; + } +} diff --git a/src/main/java/com/yssh/utils/CommonConstant.java b/src/main/java/com/yssh/utils/CommonConstant.java new file mode 100644 index 0000000..b9eab01 --- /dev/null +++ b/src/main/java/com/yssh/utils/CommonConstant.java @@ -0,0 +1,22 @@ +package com.yssh.utils; + +/** + * @author wMeng + * @ClassName CommonConstant + * @Description TODO + * @date 2022/10/30 13:30 + * @Version 1.0 + */ +public interface CommonConstant { + + /** {@code 500 Server Error} (HTTP/1.0 - RFC 1945) */ + public static final Integer SC_INTERNAL_SERVER_ERROR_500 = 500; + /** {@code 200 OK} (HTTP/1.0 - RFC 1945) */ + public static final Integer SC_OK_200 = 200; + + /**璁块棶鏉冮檺璁よ瘉鏈�氳繃 510*/ + public static final Integer SC_JEECG_NO_AUTHZ=510; + + + +} diff --git a/src/main/java/com/yssh/utils/CsvParser.java b/src/main/java/com/yssh/utils/CsvParser.java new file mode 100644 index 0000000..ff9c396 --- /dev/null +++ b/src/main/java/com/yssh/utils/CsvParser.java @@ -0,0 +1,71 @@ +package com.yssh.utils; + +import java.util.ArrayList; +import java.util.List; + +import com.yssh.entity.SuYuan; +import com.yssh.service.SuYuanService; + +import com.github.biyanwen.impl.AbstractCsvFileParser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CsvParser extends AbstractCsvFileParser<SuYuan> { + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + /** + * 姣忛殧3000鏉″瓨鍌ㄦ暟鎹簱锛岀劧鍚庢竻鐞唋ist 锛屾柟渚垮唴瀛樺洖鏀� + */ + public static final int BATCH_COUNT = 100000; + + /** + * 缂撳瓨鐨勬暟鎹� + */ + private List<SuYuan> cachedData = new ArrayList<>(BATCH_COUNT); + + private SuYuanService suYuanService; + + private String time; + + public CsvParser(SuYuanService suYuanService, String time) { + this.suYuanService = suYuanService; + this.time = time; + } + + /** + * 鎵�鏈夋暟鎹В鏋愬畬鎴愪簡 浼氭潵璋冪敤,闃叉鏈夋暟鎹病鏈夎淇濆瓨 + */ + protected void doAfterAllAnalysed() { + try { + saveSuYuanData(); + } catch (Exception e) { + logger.error("瑙f瀽淇濆瓨鏁版嵁鍑虹幇寮傚父锛屽紓甯稿師鍥犳槸锛�" + e.getMessage(), e); + e.printStackTrace(); + } + } + + protected void invoke(SuYuan t) { + t.setId(t.getX() + "_" + t.getY() + "_" + t.getZ()); + if ("0_0_0".equals(t.getId())) { + return; // 瑙e喅涓婚敭閲嶅 + } + + //System.err.println(t.getId()); + cachedData.add(t); + // 杈惧埌BATCH_COUNT浜嗭紝闇�瑕佸幓瀛樺偍涓�娆℃暟鎹簱锛岄槻姝㈡暟鎹嚑涓囨潯鏁版嵁鍦ㄥ唴瀛橈紝瀹规槗OOM + if (cachedData.size() >= BATCH_COUNT) { + try { + saveSuYuanData(); + } catch (Exception e) { + logger.error("瑙f瀽淇濆瓨鏁版嵁鍑虹幇寮傚父锛屽紓甯稿師鍥犳槸锛�" + e.getMessage(), e); + e.printStackTrace(); + } + // 瀛樺偍瀹屾垚娓呯悊 list + cachedData = new ArrayList<>(BATCH_COUNT); + } + } + + private void saveSuYuanData() throws Exception { + suYuanService.insertSuYuanDatas(cachedData, time); + } +} diff --git a/src/main/java/com/yssh/utils/DateUtils.java b/src/main/java/com/yssh/utils/DateUtils.java new file mode 100644 index 0000000..a812576 --- /dev/null +++ b/src/main/java/com/yssh/utils/DateUtils.java @@ -0,0 +1,267 @@ +package com.yssh.utils; + +import java.lang.management.ManagementFactory; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +import org.apache.commons.lang3.time.DateFormatUtils; + +/** + * 鏃堕棿宸ュ叿绫� + * + * @author tam + */ +public class DateUtils extends org.apache.commons.lang3.time.DateUtils { + public static String YYYY = "yyyy"; + + public static String YYYY_MM = "yyyy-MM"; + + public static String YYYY_MM_DD = "yyyy-MM-dd"; + + public static String YYYYMM = "yyyyMM"; + + public static String YYYYMMDDHH = "yyyyMMddHH"; + + public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss"; + + public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; + + public static String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm"; + + public static String YYYY_MM_DD_HH = "yyyy-MM-dd HH"; + + private static String[] parsePatterns = { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", + "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", + "yyyy.MM.dd HH:mm", "yyyy.MM" }; + + /** + * 鑾峰彇褰撳墠Date鍨嬫棩鏈� + * + * @return Date() 褰撳墠鏃ユ湡 + */ + public static Date getNowDate() { + return new Date(); + } + + /** + * 鑾峰彇褰撳墠鏃ユ湡, 榛樿鏍煎紡涓簓yyy-MM-dd + * + * @return String + */ + public static String getDate() { + return dateTimeNow(YYYY_MM_DD); + } + + public static final String getTime() { + return dateTimeNow(YYYY_MM_DD_HH_MM_SS); + } + + public static final String dateTimeNow() { + return dateTimeNow(YYYYMMDDHHMMSS); + } + + public static final String dateTimeNow(final String format) { + return parseDateToStr(format, new Date()); + } + + public static final String dateTime(final Date date) { + return parseDateToStr(YYYY_MM_DD, date); + } + + public static final String parseDateToStr(final String format, final Date date) { + return new SimpleDateFormat(format).format(date); + } + + public static final Date dateTime(final String format, final String ts) { + try { + return new SimpleDateFormat(format).parse(ts); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + + public static String getYyyyMm(Date date) { + return new SimpleDateFormat(YYYYMM).format(date); + } + + public static String getYyyyMmDdHh(Date date) { + return new SimpleDateFormat(YYYYMMDDHH).format(date); + } + + public static String getYyyyMmDdHhMmSs(Date date) { + return new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS).format(date); + } + + /** + * 鏃ユ湡璺緞 鍗冲勾/鏈�/鏃� 濡�2018/08/08 + */ + public static final String datePath() { + Date now = new Date(); + return DateFormatUtils.format(now, "yyyy/MM/dd"); + } + + /** + * 鏃ユ湡璺緞 鍗冲勾/鏈�/鏃� 濡�20180808 + */ + public static final String dateTime() { + Date now = new Date(); + return DateFormatUtils.format(now, "yyyyMMdd"); + } + + /** + * 鏃ユ湡鍨嬪瓧绗︿覆杞寲涓烘棩鏈� 鏍煎紡 + */ + public static Date parseDate(Object str) { + if (str == null) { + return null; + } + try { + return parseDate(str.toString(), parsePatterns); + } catch (ParseException e) { + return null; + } + } + + /** + * 鑾峰彇鏈嶅姟鍣ㄥ惎鍔ㄦ椂闂� + */ + public static Date getServerStartDate() { + long time = ManagementFactory.getRuntimeMXBean().getStartTime(); + return new Date(time); + } + + /** + * 璁$畻涓や釜鏃堕棿宸� + */ + public static String getDatePoor(Date endDate, Date nowDate) { + long nd = 1000 * 24 * 60 * 60; + long nh = 1000 * 60 * 60; + long nm = 1000 * 60; + // long ns = 1000; + // 鑾峰緱涓や釜鏃堕棿鐨勬绉掓椂闂村樊寮� + long diff = endDate.getTime() - nowDate.getTime(); + // 璁$畻宸灏戝ぉ + long day = diff / nd; + // 璁$畻宸灏戝皬鏃� + long hour = diff % nd / nh; + // 璁$畻宸灏戝垎閽� + long min = diff % nd % nh / nm; + // 璁$畻宸灏戠//杈撳嚭缁撴灉 + // long sec = diff % nd % nh % nm / ns; + return day + "澶�" + hour + "灏忔椂" + min + "鍒嗛挓"; + } + + /** + * @Title: differHour + * @Description: 鑾峰彇涓や釜鏃堕棿宸嚑涓皬鏃� + * @param: @param endDate + * @param: @param nowDate + * @param: @return + * @return: long + * @throws + */ + public static int differDay(Date startDate, Date endDate){ + long nd = 1000 * 24 * 60 * 60; + long diff = endDate.getTime() - startDate.getTime(); + double dd = Double.valueOf(String.valueOf(diff)) / nd; + // 璁$畻宸灏戝ぉ + return Double.valueOf(Math.ceil(dd)).intValue(); + } + + /** + * @Description: 鑾峰彇涓�娈垫椂闂撮棿闅� + * @param:date 闇�瑕佹搷浣滅殑鏃堕棿瀵硅薄 + * @param:day 鎿嶄綔鐨勬椂闂撮棿闅� + * 姝f暟涓轰箣鍚庝竴娈垫椂闂� + * 璐熸暟涓轰箣鍓嶄竴娈垫椂闂� + * @param:dateType 鎿嶄綔鐨勬椂闂存椂鍒嗙澶╅�夋嫨 + * 甯哥敤鏈夛細 + * Calendar.MINUTE 鍒� + * Calendar.HOUR_OF_DAY 鏃� + * Calendar.DATE 澶� + * Calendar.MONTH 鏈� + */ + public static Date getAPeriodOfTime(Date date, int day,int dateType) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(dateType, day); + return calendar.getTime(); + } + + public static List<String> get3Hours() { + List<String> times = new ArrayList<>(); + SimpleDateFormat ymdh = new SimpleDateFormat(YYYYMMDDHH); + + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.HOUR_OF_DAY, 1); + + for (int i = 0; i < 3; i++) { + calendar.add(Calendar.HOUR_OF_DAY, -1); + String time = ymdh.format(calendar.getTime()); + // times.add(time); + times.add(0, time); + } + + return times; + } + + /** + */ + public static Map<Date, Date> segmentationDateByTimeQuantum(Date startDate, Date endDate, int timeQuantum,int dateType){ + LinkedHashMap<Date, Date> result = new LinkedHashMap<Date, Date>(); + long startTimeMillisecond= startDate.getTime(); + long endTimeMillisecond = endDate.getTime(); + Long quantumTimeMillisecond = 0L; + switch (dateType) { + case Calendar.DATE: + quantumTimeMillisecond = new Integer(1000 * 60 * 60 * 24 * timeQuantum).longValue(); + break; + case Calendar.HOUR_OF_DAY: + quantumTimeMillisecond = new Integer(1000 * 60 * 60 * timeQuantum).longValue(); + break; + case Calendar.MINUTE: + quantumTimeMillisecond = new Integer(1000 * 60 * timeQuantum).longValue(); + break; + default: + break; + } + for (long time = startTimeMillisecond; time < endTimeMillisecond; time += quantumTimeMillisecond) { + Date beginDate = new Date(time); + Date finishDate = new Date(time + quantumTimeMillisecond); + if (finishDate.getTime() > endTimeMillisecond) { + finishDate = endDate; + } + result.put(beginDate, finishDate); + } + return result; + } + + /** + * 鑾峰彇鏈湀绗竴澶� + * @return String + **/ + public static Date getMonthStart() { + Calendar cal = Calendar.getInstance(); + //cal.set(Calendar.MONTH, 3); + cal.set(Calendar.DAY_OF_MONTH, 1); + return dateTime(YYYY_MM_DD_HH_MM_SS, parseDateToStr(YYYY_MM_DD, cal.getTime()) + " 00:00:00"); + } + + /** + * 鑾峰彇鏈湀鏈�鍚庝竴澶� + * @return String + **/ + public static Date getMonthEnd() { + Calendar cal = Calendar.getInstance(); + //cal.set(Calendar.MONTH, 3); + cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); + return dateTime(YYYY_MM_DD_HH_MM_SS, parseDateToStr(YYYY_MM_DD, cal.getTime()) + " 23:59:59"); + } + + public static void main(String[] args) { + //System.out.println(parseDateToStr(YYYY_MM_DD_HH_MM_SS, getMonthStart())); + //System.err.println(parseDateToStr(YYYY_MM_DD_HH_MM_SS, getMonthEnd())); + System.out.println(parseDateToStr(YYYY_MM_DD_HH_MM_SS, getAPeriodOfTime(getNowDate(), -7, Calendar.DATE))); + } +} diff --git a/src/main/java/com/yssh/utils/FileUtils.java b/src/main/java/com/yssh/utils/FileUtils.java new file mode 100644 index 0000000..aec2a29 --- /dev/null +++ b/src/main/java/com/yssh/utils/FileUtils.java @@ -0,0 +1,76 @@ +package com.yssh.utils; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; +import java.security.MessageDigest; + +/** + * 鏂囦欢宸ュ叿绫� + * @author WWW + * @date 2023-06-06 + */ +public class FileUtils { + public final static int SIXTEEN = 16; + + public static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + + /** + * 1.鑾峰彇鏂囦欢鐨凪D5 + */ + @SuppressWarnings("unused") + public static String getFileMd5(String filePath) { + FileInputStream fis = null; + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + + fis = new FileInputStream(new File(filePath)); + FileChannel fChannel = fis.getChannel(); + ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 1024); + + while (fChannel.read(buffer) != -1) { + buffer.flip(); + md.update(buffer); + buffer.compact(); + } + byte[] b = md.digest(); + + return byteToHexString(b); + } catch (Exception ex) { + ex.printStackTrace(); + return null; + } finally { + try { + if (null != fis) { + fis.close(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + } + } + + /** + * 瀛楄妭鐮佽浆16杩涘埗 + */ + public static String byteToHexString(byte[] tmp) { + // 姣忎釜瀛楄妭鐢� 16 杩涘埗琛ㄧず鐨勮瘽锛屼娇鐢ㄤ袱涓瓧绗︼紝 + char[] str = new char[16 * 2]; + + // 鎵�浠ヨ〃绀烘垚 16 杩涘埗闇�瑕� 32 涓瓧绗︼紝琛ㄧず杞崲缁撴灉涓搴旂殑瀛楃浣嶇疆 + int k = 0; + // 浠庣涓�涓瓧鑺傚紑濮嬶紝瀵� MD5 鐨勬瘡涓�涓瓧鑺� + for (int i = 0; i < SIXTEEN; i++) { + // 杞崲鎴� 16 杩涘埗瀛楃鐨勮浆鎹� + byte byte0 = tmp[i]; + // 鍙栧瓧鑺備腑楂� 4 浣嶇殑鏁板瓧杞崲 + str[k++] = HEX_DIGITS[byte0 >>> 4 & 0xf]; + // >>> 涓洪�昏緫鍙崇Щ锛屽皢绗﹀彿浣嶄竴璧峰彸绉伙紝 鍙栧瓧鑺備腑浣� 4 浣嶇殑鏁板瓧杞崲 + str[k++] = HEX_DIGITS[byte0 & 0xf]; + } + // 鎹㈠悗鐨勭粨鏋滆浆鎹负瀛楃涓� + return new String(str); + } +} diff --git a/src/main/java/com/yssh/utils/GisUtil.java b/src/main/java/com/yssh/utils/GisUtil.java new file mode 100644 index 0000000..eba5bd6 --- /dev/null +++ b/src/main/java/com/yssh/utils/GisUtil.java @@ -0,0 +1,36 @@ +package com.yssh.utils; + +import org.geotools.geometry.jts.JTS; +import org.geotools.referencing.CRS; +import org.locationtech.jts.geom.Coordinate; +import org.opengis.referencing.crs.CoordinateReferenceSystem; +import org.opengis.referencing.operation.MathTransform; + +public class GisUtil { + + /** + * @param srcNo + * 婧愬潗鏍囩郴EPSG浠e彿 + * @param targetNo + * 鐩爣鍧愭爣绯籈PSG浠e彿 + * @param x + * 婧愬潗鏍噚 + * @param y + * 婧愬潗鏍噛 + * @Description: 鍧愭爣绯昏浆鎹� + */ + public static Coordinate coordinateTransform(String sourceCRS, String targetCRS, + double x, double y) { + Coordinate tar = new Coordinate(); + try { + CoordinateReferenceSystem src = CRS.decode(sourceCRS); + CoordinateReferenceSystem target = CRS.decode(targetCRS); + MathTransform transform = CRS.findMathTransform(src, target, true); + Coordinate sour = new Coordinate(x, y); + return JTS.transform(sour, tar, transform); + } catch (Exception e) { + } + return tar; + + } +} diff --git a/src/main/java/com/yssh/utils/HttpStatus.java b/src/main/java/com/yssh/utils/HttpStatus.java new file mode 100644 index 0000000..ccf4476 --- /dev/null +++ b/src/main/java/com/yssh/utils/HttpStatus.java @@ -0,0 +1,96 @@ +package com.yssh.utils; + + +/** + * 杩斿洖鐘舵�佺爜 + * + * @author xingjinshuang@smartearth.cn + * @date 2023-02-06 + */ +public class HttpStatus +{ + /** + * 鎿嶄綔鎴愬姛 + */ + public static final int SUCCESS = 200; + + /** + * 瀵硅薄鍒涘缓鎴愬姛 + */ + public static final int CREATED = 201; + + /** + * 璇锋眰宸茬粡琚帴鍙� + */ + public static final int ACCEPTED = 202; + + /** + * 鎿嶄綔宸茬粡鎵ц鎴愬姛锛屼絾鏄病鏈夎繑鍥炴暟鎹� + */ + public static final int NO_CONTENT = 204; + + /** + * 璧勬簮宸茶绉婚櫎 + */ + public static final int MOVED_PERM = 301; + + /** + * 閲嶅畾鍚� + */ + public static final int SEE_OTHER = 303; + + /** + * 璧勬簮娌℃湁琚慨鏀� + */ + public static final int NOT_MODIFIED = 304; + + /** + * 鍙傛暟鍒楄〃閿欒锛堢己灏戯紝鏍煎紡涓嶅尮閰嶏級 + */ + public static final int BAD_REQUEST = 400; + + /** + * 鏈巿鏉� + */ + public static final int UNAUTHORIZED = 401; + + /** + * 璁块棶鍙楅檺锛屾巿鏉冭繃鏈� + */ + public static final int FORBIDDEN = 403; + + /** + * 璧勬簮锛屾湇鍔℃湭鎵惧埌 + */ + public static final int NOT_FOUND = 404; + + /** + * 涓嶅厑璁哥殑http鏂规硶 + */ + public static final int BAD_METHOD = 405; + + /** + * 璧勬簮鍐茬獊锛屾垨鑰呰祫婧愯閿� + */ + public static final int CONFLICT = 409; + + /** + * 涓嶆敮鎸佺殑鏁版嵁锛屽獟浣撶被鍨� + */ + public static final int UNSUPPORTED_TYPE = 415; + + /** + * 绯荤粺鍐呴儴閿欒 + */ + public static final int ERROR = 500; + + /** + * 鎺ュ彛鏈疄鐜� + */ + public static final int NOT_IMPLEMENTED = 501; + + /** + * 绯荤粺璀﹀憡娑堟伅 + */ + public static final int WARN = 601; +} diff --git a/src/main/java/com/yssh/utils/Result.java b/src/main/java/com/yssh/utils/Result.java new file mode 100644 index 0000000..f667597 --- /dev/null +++ b/src/main/java/com/yssh/utils/Result.java @@ -0,0 +1,154 @@ +package com.yssh.utils; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.Data; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; + +/** + * @author wMeng + * @ClassName Result + * @Description TODO + * @date 2022/10/30 13:29 + * @Version 1.0 + */ +@Data +@ApiModel(value = "閫氱敤缁撴灉闆�",description = "閫氱敤缁撴灉闆�") +public class Result<T> implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 鎴愬姛鏍囧織 + */ + @ApiModelProperty(value = "鎴愬姛鏍囧織绗�") + private boolean success = true; + + /** + * 杩斿洖澶勭悊娑堟伅 + */ + @ApiModelProperty(value = "澶勭悊娑堟伅") + private String message = "鎿嶄綔鎴愬姛锛�"; + + /** + * 杩斿洖浠g爜 + */ + @ApiModelProperty(value = "缁撴灉浠g爜") + private Integer code = 0; + + /** + * 杩斿洖鏁版嵁瀵硅薄 data + */ + @ApiModelProperty(value = "鏁版嵁瀵硅薄") + private T result; + + /** + * 鏃堕棿鎴� + */ + @ApiModelProperty(value = "鏃堕棿鎴�") + private long timestamp = System.currentTimeMillis(); + + public Result() { + + } + + public Result<T> success(String message) { + this.message = message; + this.code = CommonConstant.SC_OK_200; + this.success = true; + return this; + } + + @Deprecated + public static Result<Object> ok() { + Result<Object> r = new Result<Object>(); + r.setSuccess(true); + r.setCode(CommonConstant.SC_OK_200); + r.setMessage("鎴愬姛"); + return r; + } + + @Deprecated + public static Result<Object> ok(String msg) { + Result<Object> r = new Result<Object>(); + r.setSuccess(true); + r.setCode(CommonConstant.SC_OK_200); + r.setMessage(msg); + return r; + } + + @Deprecated + public static Result<Object> ok(Object data) { + Result<Object> r = new Result<Object>(); + r.setSuccess(true); + r.setCode(CommonConstant.SC_OK_200); + r.setResult(data); + return r; + } + + public static<T> Result<T> OK() { + Result<T> r = new Result<T>(); + r.setSuccess(true); + r.setCode(CommonConstant.SC_OK_200); + r.setMessage("鎴愬姛"); + return r; + } + + public static<T> Result<T> OK(T data) { + Result<T> r = new Result<T>(); + r.setSuccess(true); + r.setCode(CommonConstant.SC_OK_200); + r.setResult(data); + return r; + } + + public static<T> Result<T> OK(String msg, T data) { + Result<T> r = new Result<T>(); + r.setSuccess(true); + r.setCode(CommonConstant.SC_OK_200); + r.setMessage(msg); + r.setResult(data); + return r; + } + + public static<T> Result<T> error(String msg, T data) { + Result<T> r = new Result<T>(); + r.setSuccess(false); + r.setCode(CommonConstant.SC_INTERNAL_SERVER_ERROR_500); + r.setMessage(msg); + r.setResult(data); + return r; + } + + public static Result<Object> error(String msg) { + return error(CommonConstant.SC_INTERNAL_SERVER_ERROR_500, msg); + } + + public static Result<Object> error(int code, String msg) { + Result<Object> r = new Result<Object>(); + r.setCode(code); + r.setMessage(msg); + r.setSuccess(false); + return r; + } + + public Result<T> error500(String message) { + this.message = message; + this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_500; + this.success = false; + return this; + } + /** + * 鏃犳潈闄愯闂繑鍥炵粨鏋� + */ + public static Result<Object> noauth(String msg) { + return error(CommonConstant.SC_JEECG_NO_AUTHZ, msg); + } + + @JsonIgnore + private String onlTable; + + +} diff --git a/src/main/java/com/yssh/utils/ServletInitializer.java b/src/main/java/com/yssh/utils/ServletInitializer.java new file mode 100644 index 0000000..7bd4441 --- /dev/null +++ b/src/main/java/com/yssh/utils/ServletInitializer.java @@ -0,0 +1,27 @@ +package com.yssh.utils; + +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; + +import com.yssh.Application; + +/** + * @author wMeng + * @ClassName ServletInitializer + * @Description TODO + * @date 2022/10/31 18:46 + * @Version 1.0 + */ + +public class ServletInitializer extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + // 浠g爜璁剧疆鏃ュ織 + //System.setProperty("logging.config", "classpath:logback.xml"); + return application.sources(Application.class); + } + +} + + diff --git a/src/main/java/com/yssh/utils/SpringUtils.java b/src/main/java/com/yssh/utils/SpringUtils.java new file mode 100644 index 0000000..48d3a50 --- /dev/null +++ b/src/main/java/com/yssh/utils/SpringUtils.java @@ -0,0 +1,135 @@ +package com.yssh.utils; + +import org.springframework.aop.framework.AopContext; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.beans.factory.config.BeanFactoryPostProcessor; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + + +/** + * spring宸ュ叿绫� 鏂逛究鍦ㄩ潪spring绠$悊鐜涓幏鍙朾ean + * + * @author tam + */ +@Component +public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware { + /** Spring搴旂敤涓婁笅鏂囩幆澧� */ + private static ConfigurableListableBeanFactory beanFactory; + + private static ApplicationContext applicationContext; + + @Override + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { + SpringUtils.beanFactory = beanFactory; + } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + SpringUtils.applicationContext = applicationContext; + } + + /** + * 鑾峰彇瀵硅薄 + * + * @param name + * @return Object 涓�涓互鎵�缁欏悕瀛楁敞鍐岀殑bean鐨勫疄渚� + * @throws org.springframework.beans.BeansException + * + */ + @SuppressWarnings("unchecked") + public static <T> T getBean(String name) throws BeansException { + return (T) beanFactory.getBean(name); + } + + /** + * 鑾峰彇绫诲瀷涓簉equiredType鐨勫璞� + * + * @param clz + * @return + * @throws org.springframework.beans.BeansException + * + */ + public static <T> T getBean(Class<T> clz) throws BeansException { + T result = (T) beanFactory.getBean(clz); + return result; + } + + /** + * 濡傛灉BeanFactory鍖呭惈涓�涓笌鎵�缁欏悕绉板尮閰嶇殑bean瀹氫箟锛屽垯杩斿洖true + * + * @param name + * @return boolean + */ + public static boolean containsBean(String name) { + return beanFactory.containsBean(name); + } + + /** + * 鍒ゆ柇浠ョ粰瀹氬悕瀛楁敞鍐岀殑bean瀹氫箟鏄竴涓猻ingleton杩樻槸涓�涓猵rototype銆� + * 濡傛灉涓庣粰瀹氬悕瀛楃浉搴旂殑bean瀹氫箟娌℃湁琚壘鍒帮紝灏嗕細鎶涘嚭涓�涓紓甯革紙NoSuchBeanDefinitionException锛� + * + * @param name + * @return boolean + * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException + * + */ + public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException { + return beanFactory.isSingleton(name); + } + + /** + * @param name + * @return Class 娉ㄥ唽瀵硅薄鐨勭被鍨� + * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException + * + */ + public static Class<?> getType(String name) throws NoSuchBeanDefinitionException { + return beanFactory.getType(name); + } + + /** + * 濡傛灉缁欏畾鐨刡ean鍚嶅瓧鍦╞ean瀹氫箟涓湁鍒悕锛屽垯杩斿洖杩欎簺鍒悕 + * + * @param name + * @return + * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException + * + */ + public static String[] getAliases(String name) throws NoSuchBeanDefinitionException { + return beanFactory.getAliases(name); + } + + /** + * 鑾峰彇aop浠g悊瀵硅薄 + * + * @param invoker + * @return + */ + @SuppressWarnings("unchecked") + public static <T> T getAopProxy(T invoker) { + return (T) AopContext.currentProxy(); + } + + /** + * 鑾峰彇褰撳墠鐨勭幆澧冮厤缃紝鏃犻厤缃繑鍥瀗ull + * + * @return 褰撳墠鐨勭幆澧冮厤缃� + */ + public static String[] getActiveProfiles() { + return applicationContext.getEnvironment().getActiveProfiles(); + } + + /** + * 鑾峰彇褰撳墠鐨勭幆澧冮厤缃紝褰撴湁澶氫釜鐜閰嶇疆鏃讹紝鍙幏鍙栫涓�涓� + * + * @return 褰撳墠鐨勭幆澧冮厤缃� + */ + public static String getActiveProfile() { + final String[] activeProfiles = getActiveProfiles(); + return StringUtils.isNotEmpty(activeProfiles) ? activeProfiles[0] : null; + } +} diff --git a/src/main/java/com/yssh/utils/StringUtils.java b/src/main/java/com/yssh/utils/StringUtils.java new file mode 100644 index 0000000..3aa0f64 --- /dev/null +++ b/src/main/java/com/yssh/utils/StringUtils.java @@ -0,0 +1,528 @@ +package com.yssh.utils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.springframework.util.AntPathMatcher; + +/** + * 瀛楃涓插伐鍏风被 + * + * @author xingjinshuang@smartearth.cn + * @date 2023-02-06 + */ + +public class StringUtils extends org.apache.commons.lang3.StringUtils { + /** 绌哄瓧绗︿覆 */ + private static final String NULLSTR = ""; + + /** 涓嬪垝绾� */ + private static final char SEPARATOR = '_'; + + /** + * 鑾峰彇鍙傛暟涓嶄负绌哄�� + * + * @param value + * defaultValue 瑕佸垽鏂殑value + * @return value 杩斿洖鍊� + */ + public static <T> T nvl(T value, T defaultValue) { + return value != null ? value : defaultValue; + } + + /** + * * 鍒ゆ柇涓�涓狢ollection鏄惁涓虹┖锛� 鍖呭惈List锛孲et锛孮ueue + * + * @param coll + * 瑕佸垽鏂殑Collection + * @return true锛氫负绌� false锛氶潪绌� + */ + public static boolean isEmpty(Collection<?> coll) { + return isNull(coll) || coll.isEmpty(); + } + + /** + * * 鍒ゆ柇涓�涓狢ollection鏄惁闈炵┖锛屽寘鍚獿ist锛孲et锛孮ueue + * + * @param coll + * 瑕佸垽鏂殑Collection + * @return true锛氶潪绌� false锛氱┖ + */ + public static boolean isNotEmpty(Collection<?> coll) { + return !isEmpty(coll); + } + + /** + * * 鍒ゆ柇涓�涓璞℃暟缁勬槸鍚︿负绌� + * + * @param objects + * 瑕佸垽鏂殑瀵硅薄鏁扮粍 + ** @return true锛氫负绌� false锛氶潪绌� + */ + public static boolean isEmpty(Object[] objects) { + return isNull(objects) || (objects.length == 0); + } + + /** + * * 鍒ゆ柇涓�涓璞℃暟缁勬槸鍚﹂潪绌� + * + * @param objects + * 瑕佸垽鏂殑瀵硅薄鏁扮粍 + * @return true锛氶潪绌� false锛氱┖ + */ + public static boolean isNotEmpty(Object[] objects) { + return !isEmpty(objects); + } + + /** + * * 鍒ゆ柇涓�涓狹ap鏄惁涓虹┖ + * + * @param map + * 瑕佸垽鏂殑Map + * @return true锛氫负绌� false锛氶潪绌� + */ + public static boolean isEmpty(Map<?, ?> map) { + return isNull(map) || map.isEmpty(); + } + + /** + * * 鍒ゆ柇涓�涓狹ap鏄惁涓虹┖ + * + * @param map + * 瑕佸垽鏂殑Map + * @return true锛氶潪绌� false锛氱┖ + */ + public static boolean isNotEmpty(Map<?, ?> map) { + return !isEmpty(map); + } + + /** + * * 鍒ゆ柇涓�涓瓧绗︿覆鏄惁涓虹┖涓� + * + * @param str + * String + * @return true锛氫负绌� false锛氶潪绌� + */ + public static boolean isEmpty(String str) { + return isNull(str) || NULLSTR.equals(str.trim()); + } + + /** + * * 鍒ゆ柇涓�涓瓧绗︿覆鏄惁涓洪潪绌轰覆 + * + * @param str + * String + * @return true锛氶潪绌轰覆 false锛氱┖涓� + */ + public static boolean isNotEmpty(String str) { + return !isEmpty(str); + } + + /** + * * 鍒ゆ柇涓�涓璞℃槸鍚︿负绌� + * + * @param object + * Object + * @return true锛氫负绌� false锛氶潪绌� + */ + public static boolean isNull(Object object) { + return object == null; + } + + /** + * * 鍒ゆ柇涓�涓璞℃槸鍚﹂潪绌� + * + * @param object + * Object + * @return true锛氶潪绌� false锛氱┖ + */ + public static boolean isNotNull(Object object) { + return !isNull(object); + } + + /** + * * 鍒ゆ柇涓�涓璞℃槸鍚︽槸鏁扮粍绫诲瀷锛圝ava鍩烘湰鍨嬪埆鐨勬暟缁勶級 + * + * @param object + * 瀵硅薄 + * @return true锛氭槸鏁扮粍 false锛氫笉鏄暟缁� + */ + public static boolean isArray(Object object) { + return isNotNull(object) && object.getClass().isArray(); + } + + /** + * 鍘荤┖鏍� + */ + public static String trim(String str) { + return (str == null ? "" : str.trim()); + } + + /** + * 鎴彇瀛楃涓� + * + * @param str + * 瀛楃涓� + * @param start + * 寮�濮� + * @return 缁撴灉 + */ + public static String substring(final String str, int start) { + if (str == null) { + return NULLSTR; + } + + if (start < 0) { + start = str.length() + start; + } + + if (start < 0) { + start = 0; + } + if (start > str.length()) { + return NULLSTR; + } + + return str.substring(start); + } + + /** + * 鎴彇瀛楃涓� + * + * @param str + * 瀛楃涓� + * @param start + * 寮�濮� + * @param end + * 缁撴潫 + * @return 缁撴灉 + */ + public static String substring(final String str, int start, int end) { + if (str == null) { + return NULLSTR; + } + + if (end < 0) { + end = str.length() + end; + } + if (start < 0) { + start = str.length() + start; + } + + if (end > str.length()) { + end = str.length(); + } + + if (start > end) { + return NULLSTR; + } + + if (start < 0) { + start = 0; + } + if (end < 0) { + end = 0; + } + + return str.substring(start, end); + } + + /** + * 瀛楃涓茶浆set + * + * @param str + * 瀛楃涓� + * @param sep + * 鍒嗛殧绗� + * @return set闆嗗悎 + */ + public static final Set<String> str2Set(String str, String sep) { + return new HashSet<String>(str2List(str, sep, true, false)); + } + + /** + * 瀛楃涓茶浆list + * + * @param str + * 瀛楃涓� + * @param sep + * 鍒嗛殧绗� + * @param filterBlank + * 杩囨护绾┖鐧� + * @param trim + * 鍘绘帀棣栧熬绌虹櫧 + * @return list闆嗗悎 + */ + public static final List<String> str2List(String str, String sep, + boolean filterBlank, boolean trim) { + List<String> list = new ArrayList<String>(); + if (StringUtils.isEmpty(str)) { + return list; + } + + // 杩囨护绌虹櫧瀛楃涓� + if (filterBlank && StringUtils.isBlank(str)) { + return list; + } + String[] split = str.split(sep); + for (String string : split) { + if (filterBlank && StringUtils.isBlank(string)) { + continue; + } + if (trim) { + string = string.trim(); + } + list.add(string); + } + + return list; + } + + /** + * 鍒ゆ柇缁欏畾鐨剆et鍒楄〃涓槸鍚﹀寘鍚暟缁刟rray 鍒ゆ柇缁欏畾鐨勬暟缁刟rray涓槸鍚﹀寘鍚粰瀹氱殑鍏冪礌value + * + * @param 缁欏畾鐨勯泦鍚� + * @param array + * 缁欏畾鐨勬暟缁� + * @return boolean 缁撴灉 + */ + public static boolean containsAny(Collection<String> collection, + String... array) { + if (isEmpty(collection) || isEmpty(array)) { + return false; + } else { + for (String str : array) { + if (collection.contains(str)) { + return true; + } + } + return false; + } + } + + /** + * 鏌ユ壘鎸囧畾瀛楃涓叉槸鍚﹀寘鍚寚瀹氬瓧绗︿覆鍒楄〃涓殑浠绘剰涓�涓瓧绗︿覆鍚屾椂涓插拷鐣ュぇ灏忓啓 + * + * @param cs + * 鎸囧畾瀛楃涓� + * @param searchCharSequences + * 闇�瑕佹鏌ョ殑瀛楃涓叉暟缁� + * @return 鏄惁鍖呭惈浠绘剰涓�涓瓧绗︿覆 + */ + public static boolean containsAnyIgnoreCase(CharSequence cs, + CharSequence... searchCharSequences) { + if (isEmpty(cs) || isEmpty(searchCharSequences)) { + return false; + } + for (CharSequence testStr : searchCharSequences) { + if (containsIgnoreCase(cs, testStr)) { + return true; + } + } + return false; + } + + /** + * 椹煎嘲杞笅鍒掔嚎鍛藉悕 + */ + public static String toUnderScoreCase(String str) { + if (str == null) { + return null; + } + StringBuilder sb = new StringBuilder(); + // 鍓嶇疆瀛楃鏄惁澶у啓 + boolean preCharIsUpperCase = true; + // 褰撳墠瀛楃鏄惁澶у啓 + boolean curreCharIsUpperCase = true; + // 涓嬩竴瀛楃鏄惁澶у啓 + boolean nexteCharIsUpperCase = true; + for (int i = 0; i < str.length(); i++) { + char c = str.charAt(i); + if (i > 0) { + preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1)); + } else { + preCharIsUpperCase = false; + } + + curreCharIsUpperCase = Character.isUpperCase(c); + + if (i < (str.length() - 1)) { + nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1)); + } + + if (preCharIsUpperCase && curreCharIsUpperCase + && !nexteCharIsUpperCase) { + sb.append(SEPARATOR); + } else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) { + sb.append(SEPARATOR); + } + sb.append(Character.toLowerCase(c)); + } + + return sb.toString(); + } + + /** + * 鏄惁鍖呭惈瀛楃涓� + * + * @param str + * 楠岃瘉瀛楃涓� + * @param strs + * 瀛楃涓茬粍 + * @return 鍖呭惈杩斿洖true + */ + public static boolean inStringIgnoreCase(String str, String... strs) { + if (str != null && strs != null) { + for (String s : strs) { + if (str.equalsIgnoreCase(trim(s))) { + return true; + } + } + } + return false; + } + + /** + * 灏嗕笅鍒掔嚎澶у啓鏂瑰紡鍛藉悕鐨勫瓧绗︿覆杞崲涓洪┘宄板紡銆傚鏋滆浆鎹㈠墠鐨勪笅鍒掔嚎澶у啓鏂瑰紡鍛藉悕鐨勫瓧绗︿覆涓虹┖锛屽垯杩斿洖绌哄瓧绗︿覆銆� + * 渚嬪锛欻ELLO_WORLD->HelloWorld + * + * @param name + * 杞崲鍓嶇殑涓嬪垝绾垮ぇ鍐欐柟寮忓懡鍚嶇殑瀛楃涓� + * @return 杞崲鍚庣殑椹煎嘲寮忓懡鍚嶇殑瀛楃涓� + */ + public static String convertToCamelCase(String name) { + StringBuilder result = new StringBuilder(); + // 蹇�熸鏌� + if (name == null || name.isEmpty()) { + // 娌″繀瑕佽浆鎹� + return ""; + } else if (!name.contains("_")) { + // 涓嶅惈涓嬪垝绾匡紝浠呭皢棣栧瓧姣嶅ぇ鍐� + return name.substring(0, 1).toUpperCase() + name.substring(1); + } + // 鐢ㄤ笅鍒掔嚎灏嗗師濮嬪瓧绗︿覆鍒嗗壊 + String[] camels = name.split("_"); + for (String camel : camels) { + // 璺宠繃鍘熷瀛楃涓蹭腑寮�澶淬�佺粨灏剧殑涓嬫崲绾挎垨鍙岄噸涓嬪垝绾� + if (camel.isEmpty()) { + continue; + } + // 棣栧瓧姣嶅ぇ鍐� + result.append(camel.substring(0, 1).toUpperCase()); + result.append(camel.substring(1).toLowerCase()); + } + return result.toString(); + } + + /** + * 椹煎嘲寮忓懡鍚嶆硶 渚嬪锛歶ser_name->userName + */ + public static String toCamelCase(String s) { + if (s == null) { + return null; + } + s = s.toLowerCase(); + StringBuilder sb = new StringBuilder(s.length()); + boolean upperCase = false; + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + + if (c == SEPARATOR) { + upperCase = true; + } else if (upperCase) { + sb.append(Character.toUpperCase(c)); + upperCase = false; + } else { + sb.append(c); + } + } + return sb.toString(); + } + + /** + * 鏌ユ壘鎸囧畾瀛楃涓叉槸鍚﹀尮閰嶆寚瀹氬瓧绗︿覆鍒楄〃涓殑浠绘剰涓�涓瓧绗︿覆 + * + * @param str + * 鎸囧畾瀛楃涓� + * @param strs + * 闇�瑕佹鏌ョ殑瀛楃涓叉暟缁� + * @return 鏄惁鍖归厤 + */ + public static boolean matches(String str, List<String> strs) { + if (isEmpty(str) || isEmpty(strs)) { + return false; + } + for (String pattern : strs) { + if (isMatch(pattern, str)) { + return true; + } + } + return false; + } + + /** + * 鍒ゆ柇url鏄惁涓庤鍒欓厤缃�: ? 琛ㄧず鍗曚釜瀛楃; * 琛ㄧず涓�灞傝矾寰勫唴鐨勪换鎰忓瓧绗︿覆锛屼笉鍙法灞傜骇; ** 琛ㄧず浠绘剰灞傝矾寰�; + * + * @param pattern + * 鍖归厤瑙勫垯 + * @param url + * 闇�瑕佸尮閰嶇殑url + * @return + */ + public static boolean isMatch(String pattern, String url) { + AntPathMatcher matcher = new AntPathMatcher(); + return matcher.match(pattern, url); + } + + @SuppressWarnings("unchecked") + public static <T> T cast(Object obj) { + return (T) obj; + } + + /** + * 鏁板瓧宸﹁竟琛ラ綈0锛屼娇涔嬭揪鍒版寚瀹氶暱搴︺�傛敞鎰忥紝濡傛灉鏁板瓧杞崲涓哄瓧绗︿覆鍚庯紝闀垮害澶т簬size锛屽垯鍙繚鐣� 鏈�鍚巗ize涓瓧绗︺�� + * + * @param num + * 鏁板瓧瀵硅薄 + * @param size + * 瀛楃涓叉寚瀹氶暱搴� + * @return 杩斿洖鏁板瓧鐨勫瓧绗︿覆鏍煎紡锛岃瀛楃涓蹭负鎸囧畾闀垮害銆� + */ + public static final String padl(final Number num, final int size) { + return padl(num.toString(), size, '0'); + } + + /** + * 瀛楃涓插乏琛ラ綈銆傚鏋滃師濮嬪瓧绗︿覆s闀垮害澶т簬size锛屽垯鍙繚鐣欐渶鍚巗ize涓瓧绗︺�� + * + * @param s + * 鍘熷瀛楃涓� + * @param size + * 瀛楃涓叉寚瀹氶暱搴� + * @param c + * 鐢ㄤ簬琛ラ綈鐨勫瓧绗� + * @return 杩斿洖鎸囧畾闀垮害鐨勫瓧绗︿覆锛岀敱鍘熷瓧绗︿覆宸﹁ˉ榻愭垨鎴彇寰楀埌銆� + */ + public static final String padl(final String s, final int size, final char c) { + final StringBuilder sb = new StringBuilder(size); + if (s != null) { + final int len = s.length(); + if (s.length() <= size) { + for (int i = size - len; i > 0; i--) { + sb.append(c); + } + sb.append(s); + } else { + return s.substring(len - size, len); + } + } else { + for (int i = size; i > 0; i--) { + sb.append(c); + } + } + return sb.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/yssh/utils/TableStrategy.java b/src/main/java/com/yssh/utils/TableStrategy.java new file mode 100644 index 0000000..9595ffc --- /dev/null +++ b/src/main/java/com/yssh/utils/TableStrategy.java @@ -0,0 +1,10 @@ +package com.yssh.utils; + +public class TableStrategy { + + public static final String SU_YUNA_TABLE_PREFIX = "su_yuan"; + + public static String getTableStrategy(String time){ + return SU_YUNA_TABLE_PREFIX + "_" + time; + } +} diff --git a/src/main/java/com/yssh/utils/VocParser.java b/src/main/java/com/yssh/utils/VocParser.java new file mode 100644 index 0000000..85d9889 --- /dev/null +++ b/src/main/java/com/yssh/utils/VocParser.java @@ -0,0 +1,82 @@ +package com.yssh.utils; + +import com.github.biyanwen.impl.AbstractCsvFileParser; +import com.yssh.entity.VocVals; +import com.yssh.service.VocValsService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.math.BigInteger; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * VOC杞崲绫� + * @author WWW + * @date 2023-06-05 + */ +public class VocParser extends AbstractCsvFileParser<VocVals> { + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private final SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHH0000"); + + /** + * 姣忛殧5000鏉″叆搴撲竴娆� + */ + public static final int BATCH_COUNT = 100000; + + private BigInteger startId; + + private VocValsService vocValsService; + + private Date date; + + private List<VocVals> list = new ArrayList<>(BATCH_COUNT); + + public VocParser(VocValsService vocValsService, Date date) { + this.vocValsService = vocValsService; + this.date = date; + this.startId = new BigInteger(format.format(date)); + } + + public BigInteger getId() { + startId = startId.add(BigInteger.valueOf(1)); + + return startId; + } + + @Override + protected void doAfterAllAnalysed() { + inserts(); + } + + @Override + protected void invoke(VocVals vv) { + if (null == vv.getX() || vv.getX() < 0 || null == vv.getY() || vv.getY() < 0 || null == vv.getVal() || vv.getVal() <= 0) { + return; + } + + vv.setCreateTime(this.date); + vv.setId(getId()); + list.add(vv); + + if (list.size() >= BATCH_COUNT) { + inserts(); + list = new ArrayList<>(BATCH_COUNT); + } + } + + private void inserts() { + try { + if (list.size() > 0) { + //this.vocValsService.insertVocVals(list); + this.vocValsService.insertVocSync(list); + } + } catch (Exception e) { + logger.error(e.getMessage(), e); + e.printStackTrace(); + } + } +} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml new file mode 100644 index 0000000..b4b6d33 --- /dev/null +++ b/src/main/resources/application-dev.yml @@ -0,0 +1,47 @@ +# 鏁版嵁婧愰厤缃� +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://192.168.20.228:3306/yssh?useUnicode=true&rewriteBatchedStatements=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: 123456 + # 鍒濆杩炴帴鏁� + initialSize: 10 + # 鏈�灏忚繛鎺ユ睜鏁伴噺 + minIdle: 20 + # 鏈�澶ц繛鎺ユ睜鏁伴噺 + maxActive: 100 + # 閰嶇疆鑾峰彇杩炴帴绛夊緟瓒呮椂鐨勬椂闂� + maxWait: 600000 + # 閰嶇疆闂撮殧澶氫箙鎵嶈繘琛屼竴娆℃娴嬶紝妫�娴嬮渶瑕佸叧闂殑绌洪棽杩炴帴锛屽崟浣嶆槸姣 + timeBetweenEvictionRunsMillis: 60000 + # 閰嶇疆涓�涓繛鎺ュ湪姹犱腑鏈�灏忕敓瀛樼殑鏃堕棿锛屽崟浣嶆槸姣 + minEvictableIdleTimeMillis: 300000 + # 閰嶇疆涓�涓繛鎺ュ湪姹犱腑鏈�澶х敓瀛樼殑鏃堕棿锛屽崟浣嶆槸姣 + maxEvictableIdleTimeMillis: 900000 + # 閰嶇疆妫�娴嬭繛鎺ユ槸鍚︽湁鏁� + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 璁剧疆鐧藉悕鍗曪紝涓嶅~鍒欏厑璁告墍鏈夎闂� + allow: + url-pattern: /druid/* + # 鎺у埗鍙扮鐞嗙敤鎴峰悕鍜屽瘑鐮� + login-username: admin + login-password: admiN_1@# + filter: + stat: + enabled: true + # 鎱QL璁板綍 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true \ No newline at end of file diff --git a/src/main/resources/application-file.yml b/src/main/resources/application-file.yml new file mode 100644 index 0000000..dc439d0 --- /dev/null +++ b/src/main/resources/application-file.yml @@ -0,0 +1,8 @@ +#dat閰嶇疆璺緞 +dat: + filePath2d: 'D:\2022\dat\extract_mesh.dat' + filePath3d: 'D:\2022\dat\correct_jk_47.dat' +#csv閰嶇疆璺緞 +csv: + filePath: 'D:\2022\LBM_New' + vocPath: 'D:\2022\voc_all' diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml new file mode 100644 index 0000000..4830a99 --- /dev/null +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,47 @@ +# 鏁版嵁婧愰厤缃� +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://10.101.5.98:3306/yssh?useUnicode=true&rewriteBatchedStatements=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: 123456 + # 鍒濆杩炴帴鏁� + initialSize: 10 + # 鏈�灏忚繛鎺ユ睜鏁伴噺 + minIdle: 20 + # 鏈�澶ц繛鎺ユ睜鏁伴噺 + maxActive: 100 + # 閰嶇疆鑾峰彇杩炴帴绛夊緟瓒呮椂鐨勬椂闂� + maxWait: 600000 + # 閰嶇疆闂撮殧澶氫箙鎵嶈繘琛屼竴娆℃娴嬶紝妫�娴嬮渶瑕佸叧闂殑绌洪棽杩炴帴锛屽崟浣嶆槸姣 + timeBetweenEvictionRunsMillis: 60000 + # 閰嶇疆涓�涓繛鎺ュ湪姹犱腑鏈�灏忕敓瀛樼殑鏃堕棿锛屽崟浣嶆槸姣 + minEvictableIdleTimeMillis: 300000 + # 閰嶇疆涓�涓繛鎺ュ湪姹犱腑鏈�澶х敓瀛樼殑鏃堕棿锛屽崟浣嶆槸姣 + maxEvictableIdleTimeMillis: 900000 + # 閰嶇疆妫�娴嬭繛鎺ユ槸鍚︽湁鏁� + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 璁剧疆鐧藉悕鍗曪紝涓嶅~鍒欏厑璁告墍鏈夎闂� + allow: + url-pattern: /druid/* + # 鎺у埗鍙扮鐞嗙敤鎴峰悕鍜屽瘑鐮� + login-username: admin + login-password: admin + filter: + stat: + enabled: true + # 鎱QL璁板綍 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true \ No newline at end of file diff --git a/src/main/resources/application-scheduled.yml b/src/main/resources/application-scheduled.yml new file mode 100644 index 0000000..d731d4d --- /dev/null +++ b/src/main/resources/application-scheduled.yml @@ -0,0 +1,8 @@ +csv: + # 221Mb CSV鍏ュ簱鏃堕棿 + cron: '0 42 * * * ? ' + cron_max: 720 + + # 112Kb CSV鍏ュ簱鏃堕棿 + voc: '0 37 * * * ? ' + voc_max: 720 diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml new file mode 100644 index 0000000..1726939 --- /dev/null +++ b/src/main/resources/application-test.yml @@ -0,0 +1,47 @@ +# 鏁版嵁婧愰厤缃� +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://127.0.0.1:3306/yssh?useUnicode=true&rewriteBatchedStatements=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: mysql + # 鍒濆杩炴帴鏁� + initialSize: 10 + # 鏈�灏忚繛鎺ユ睜鏁伴噺 + minIdle: 20 + # 鏈�澶ц繛鎺ユ睜鏁伴噺 + maxActive: 100 + # 閰嶇疆鑾峰彇杩炴帴绛夊緟瓒呮椂鐨勬椂闂� + maxWait: 600000 + # 閰嶇疆闂撮殧澶氫箙鎵嶈繘琛屼竴娆℃娴嬶紝妫�娴嬮渶瑕佸叧闂殑绌洪棽杩炴帴锛屽崟浣嶆槸姣 + timeBetweenEvictionRunsMillis: 60000 + # 閰嶇疆涓�涓繛鎺ュ湪姹犱腑鏈�灏忕敓瀛樼殑鏃堕棿锛屽崟浣嶆槸姣 + minEvictableIdleTimeMillis: 300000 + # 閰嶇疆涓�涓繛鎺ュ湪姹犱腑鏈�澶х敓瀛樼殑鏃堕棿锛屽崟浣嶆槸姣 + maxEvictableIdleTimeMillis: 900000 + # 閰嶇疆妫�娴嬭繛鎺ユ槸鍚︽湁鏁� + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 璁剧疆鐧藉悕鍗曪紝涓嶅~鍒欏厑璁告墍鏈夎闂� + allow: + url-pattern: /druid/* + # 鎺у埗鍙扮鐞嗙敤鎴峰悕鍜屽瘑鐮� + login-username: admin + login-password: admin + filter: + stat: + enabled: true + # 鎱QL璁板綍 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..922a2ca --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,60 @@ +server: + tomcat: + uri-encoding: UTF-8 + max-connections: 1000 + threads: + # tomcat鏈�澶х嚎绋嬫暟锛岄粯璁や负200 + max: 1000 + # Tomcat鍚姩鍒濆鍖栫殑绾跨▼鏁帮紝榛樿鍊�25 + min-spare: 25 + port: 9001 + servlet: + context-path: / + +spring: + application: + name: yssh + # session + session: + timeout: PT20M # 20鍒嗛挓 + profiles: + active: dev + include: scheduled,file + # 璁剧疆涓婁紶鏂囦欢澶у皬 + servlet: + multipart: + enabled: true + max-file-size: 204800MB + max-request-size: 1048576MB + # jackson + jackson: + time-zone: GMT+8 + date-format: yyyy-MM-dd HH:mm:ss + locale: zh_CN + thymeleaf: + cache: false + # 鏈嶅姟妯″潡 + devtools: + restart: + # 鐑儴缃插紑鍏� + enabled: true + +mybatis-plus: + type-aliases-package: com.yssh.entity + config-location: classpath:mybatis.xml + mapper-locations: classpath:mapper/**/*.xml + +# logging +logging: + level: + com.yssh: info + org.springframework: warn + #config: classpath:logback-spring.xml + +knife4j: + # 鏄惁寮�鍚疭wagger + enabled: true + # 璇锋眰鍓嶇紑 + pathMapping: + # 鏄惁寮�鍚疜nife4j澧炲己妯″紡,榛樿鏄� false + enable: true diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000..2ba845d --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="UTF-8"?> +<configuration> + <!-- 鏃ュ織瀛樻斁璺緞 --> + <property name="log.path" value="logs/" /> + <!-- 鏃ュ織杈撳嚭鏍煎紡 --> + <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" /> + + <!-- 鎺у埗鍙拌緭鍑� --> + <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>${log.pattern}</pattern> + </encoder> + </appender> + + <appender name="file_debug" class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${log.path}/sys-debug.log</file> + <!-- 寰幆鏀跨瓥锛氬熀浜庢椂闂村垱寤烘棩蹇楁枃浠� --> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <!-- 鏃ュ織鏂囦欢鍚嶆牸寮� --> + <fileNamePattern>${log.path}/sys-debug.%d{yyyy-MM-dd}.log</fileNamePattern> + <!-- 鏃ュ織鏈�澶х殑鍘嗗彶 60澶� --> + <maxHistory>60</maxHistory> + </rollingPolicy> + <encoder> + <pattern>${log.pattern}</pattern> + </encoder> + <filter class="ch.qos.logback.classic.filter.LevelFilter"> + <!-- 杩囨护鐨勭骇鍒� --> + <level>DEBUG</level> + <!-- 鍖归厤鏃剁殑鎿嶄綔锛氭帴鏀讹紙璁板綍锛� --> + <onMatch>ACCEPT</onMatch> + <!-- 涓嶅尮閰嶆椂鐨勬搷浣滐細鎷掔粷锛堜笉璁板綍锛� --> + <onMismatch>DENY</onMismatch> + </filter> + </appender> + + <!-- 绯荤粺鏃ュ織杈撳嚭 --> + <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${log.path}/sys-info.log</file> + <!-- 寰幆鏀跨瓥锛氬熀浜庢椂闂村垱寤烘棩蹇楁枃浠� --> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <!-- 鏃ュ織鏂囦欢鍚嶆牸寮� --> + <fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern> + <!-- 鏃ュ織鏈�澶х殑鍘嗗彶 60澶� --> + <maxHistory>60</maxHistory> + </rollingPolicy> + <encoder> + <pattern>${log.pattern}</pattern> + </encoder> + <filter class="ch.qos.logback.classic.filter.LevelFilter"> + <!-- 杩囨护鐨勭骇鍒� --> + <level>INFO</level> + <!-- 鍖归厤鏃剁殑鎿嶄綔锛氭帴鏀讹紙璁板綍锛� --> + <onMatch>ACCEPT</onMatch> + <!-- 涓嶅尮閰嶆椂鐨勬搷浣滐細鎷掔粷锛堜笉璁板綍锛� --> + <onMismatch>DENY</onMismatch> + </filter> + </appender> + + <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${log.path}/sys-error.log</file> + <!-- 寰幆鏀跨瓥锛氬熀浜庢椂闂村垱寤烘棩蹇楁枃浠� --> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <!-- 鏃ュ織鏂囦欢鍚嶆牸寮� --> + <fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern> + <!-- 鏃ュ織鏈�澶х殑鍘嗗彶 60澶� --> + <maxHistory>60</maxHistory> + </rollingPolicy> + <encoder> + <pattern>${log.pattern}</pattern> + </encoder> + <filter class="ch.qos.logback.classic.filter.LevelFilter"> + <!-- 杩囨护鐨勭骇鍒� --> + <level>ERROR</level> + <!-- 鍖归厤鏃剁殑鎿嶄綔锛氭帴鏀讹紙璁板綍锛� --> + <onMatch>ACCEPT</onMatch> + <!-- 涓嶅尮閰嶆椂鐨勬搷浣滐細鎷掔粷锛堜笉璁板綍锛� --> + <onMismatch>DENY</onMismatch> + </filter> + </appender> + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>${CONSOLE_LOG_PATTERN}</pattern> + </encoder> + </appender> + + <!-- 绯荤粺妯″潡鏃ュ織绾у埆鎺у埗 --> + <logger name="com.yssh" level="info" /> + <!-- Spring鏃ュ織绾у埆鎺у埗 --> + <logger name="org.springframework" level="error" /> + + <!--绯荤粺鎿嶄綔鏃ュ織--> + <root level="info"> + <appender-ref ref="file_info" /> + <appender-ref ref="file_error" /> + <appender-ref ref="console" /> + </root> +</configuration> \ No newline at end of file diff --git a/src/main/resources/mapper/AlertConfigMapper.xml b/src/main/resources/mapper/AlertConfigMapper.xml new file mode 100644 index 0000000..8afb05e --- /dev/null +++ b/src/main/resources/mapper/AlertConfigMapper.xml @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.yssh.mapper.AlertConfigMapper"> + <resultMap id="AlertConfigResult" type="com.yssh.entity.AlertConfig"> + <id column="id" property="id" /> + <result column="jcyj" property="jcyj" /> + <result column="jcbj" property="jcbj" /> + <result column="pfyj" property="pfyj" /> + <result column="pfbj" property="pfbj" /> + </resultMap> + + <sql id="alertConfigSQL"> + SELECT id, jcyj, jcbj, pfyj, pfbj + FROM alert_config + </sql> + + <select id="getAll" resultMap="AlertConfigResult"> + <include refid="alertConfigSQL"></include> + </select> + + <select id="query" resultMap="AlertConfigResult" parameterType="Integer"> + <include refid="alertConfigSQL"></include> + WHERE id= #{id} + </select> + + <insert id="insert" parameterType="com.yssh.entity.AlertConfig"> + insert into alert_config ( + jcyj, jcbj, pfyj, pfbj + ) + values ( + #{jcyj},#{jcbj},#{pfyj},#{pfbj} + ) + </insert> + + <update id="update" parameterType="com.yssh.entity.AlertConfig"> + update alert_config + <set > + <if test="jcyj != null and jcyj != ''"> + jcyj = #{jcyj}, + </if> + <if test="jcbj != null and jcbj != ''"> + jcbj = #{jcbj}, + </if> + <if test="pfbj != null and pfbj != ''"> + pfbj = #{pfbj}, + </if> + <if test="pfyj != null and pfyj != ''"> + pfyj = #{pfyj}, + </if> + </set> + where id = #{id} + </update> + + <delete id="delete" parameterType="Integer"> + DELETE FROM alert_config WHERE id = #{id} + </delete> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/CommonMapper.xml b/src/main/resources/mapper/CommonMapper.xml new file mode 100644 index 0000000..dcb128b --- /dev/null +++ b/src/main/resources/mapper/CommonMapper.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.yssh.mapper.CommonMapper"> + <select id="checkTableExistsWithSchema" resultType="java.lang.Integer"> + SELECT COUNT(1) FROM information_schema.tables WHERE + table_schema=#{tableSchema} AND table_name = #{tableName} + </select> + + <select id="checkTableExistsWithShow" parameterType="String" resultType="java.util.Map"> + show tables like #{tableName} + </select> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/DictRecordMapper.xml b/src/main/resources/mapper/DictRecordMapper.xml new file mode 100644 index 0000000..2c0a61f --- /dev/null +++ b/src/main/resources/mapper/DictRecordMapper.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.yssh.mapper.DictRecordMapper"> + + <resultMap id="DictRecordResult" type="com.yssh.entity.DictRecord"> + <id property="id" column="id" /> + <result property="tableName" column="table_name" /> + <result property="createTime" column="create_time" /> + <result property="remarks" column="remarks" /> + </resultMap> + + <sql id="selectDictRecordVo"> + SELECT id, table_name, create_time + FROM dict_record + </sql> + + <select id="selectDictRecordList" parameterType="com.yssh.entity.DictRecord" resultMap="DictRecordResult"> + <include refid="selectDictRecordVo"/> + <where> + <if test="tableName != null and tableName != ''"> and table_name like concat('%', #{tableName}, '%')</if> + </where> + ORDER BY create_time ASC + </select> + + <select id="selectByCreateTime" parameterType="Long" resultMap="DictRecordResult"> + SELECT id, table_name, create_time + FROM dict_record + WHERE create_time = #{createTime} + LIMIT 0, 1 + </select> + + <select id="selectByTime" resultMap="DictRecordResult"> + SELECT id, table_name, create_time + FROM dict_record + where str_to_date(create_time, '%Y%m%d%H') between #{start} and #{end} + order by create_time; + </select> + + <select id="selectByTimeDictRecordList" resultMap="DictRecordResult"> + SELECT id, table_name, create_time + FROM dict_record + WHERE create_time > #{startTime} + AND create_time <= #{endTime} + ORDER BY create_time ASC + </select> + + <insert id="insertDictRecord" parameterType="com.yssh.entity.DictRecord" useGeneratedKeys="true" keyProperty="id"> + insert into dict_record + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="tableName != null and tableName != ''">table_name,</if> + <if test="createTime != null">create_time,</if> + <if test="remarks != null">remarks,</if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="tableName != null and tableName != ''">#{tableName},</if> + <if test="createTime != null">#{createTime},</if> + <if test="remarks != null">#{remarks},</if> + </trim> + </insert> + + <delete id="deleteDictRecordById" parameterType="Long"> + delete from dict_record where id = #{id} + </delete> + + <delete id="deleteDictRecordByIds" parameterType="Long"> + delete from dict_record where id in + <foreach item="id" collection="array" open="(" separator="," close=")"> + #{id} + </foreach> + </delete> + + <!--鍒涘缓琛ㄧ殑 SQL 璇彞--> + <update id="createDictRecoTable"> + CREATE TABLE `dict_record` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '缂栧彿', + `table_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '琛ㄥ悕绉�', + `create_time` bigint(20) NULL DEFAULT NULL COMMENT '鍒涘缓鏃堕棿', + `remarks` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '澶囨敞', + PRIMARY KEY (`id`) USING BTREE + ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + </update> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/EmissionMapper.xml b/src/main/resources/mapper/EmissionMapper.xml new file mode 100644 index 0000000..2d96da1 --- /dev/null +++ b/src/main/resources/mapper/EmissionMapper.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.yssh.mapper.EmissionMapper"> + <resultMap id="EmissionResult" type="com.yssh.entity.Emission"> + <id column="id" property="id" /> + <result column="name" property="name" /> + <result column="lon" property="lon" /> + <result column="lat" property="lat" /> + <result column="value" property="value" /> + <result column="time" property="time" /> + <result column="property" property="property" /> + </resultMap> + <select id="query" resultMap="EmissionResult"> + select id, name, lon, lat, format(value, 2) "value", time, property + from emission + <where> + <if test="name != null and name != ''"> + and name = #{name} + </if> + </where> + order by time desc + </select> + + <select id="getAll" resultMap="EmissionResult"> + select id, name, lon, lat, format(value, 2) "value", time, property + from emission + </select> + + <insert id="insert" parameterType="com.yssh.entity.Emission"> + insert into emission ( + name, lon, lat, value, time, property + ) + values ( + #{name},#{lon},#{lat},#{value},#{time},#{property} + ) + </insert> + <delete id="delete"> + delete from emission where id = #{id} + </delete> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/FeedbackMapper.xml b/src/main/resources/mapper/FeedbackMapper.xml new file mode 100644 index 0000000..588235e --- /dev/null +++ b/src/main/resources/mapper/FeedbackMapper.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.yssh.mapper.FeedbackMapper"> + <resultMap id="FeedbackDetailResult" type="com.yssh.entity.FeedbackDetail"> + <id property="id" column="id" /> + <result property="tableName" column="table_name" /> + <result property="locationName" column="location_name" /> + <result property="detectionId" column="detection_id" /> + <result property="detectionVocsName" column="detection_vocs_name" /> + <result property="detectionValue" column="detection_value" /> + <result property="practicalId" column="practical_id" /> + <result property="practicalVocsName" column="practical_vocs_name" /> + <result property="practicalValue" column="practical_value" /> + <result property="createTime" column="create_time" /> + </resultMap> + + <sql id="feedbackDetailSql"> + SELECT id, table_name, location_name, detection_id, detection_vocs_name, format(detection_value, 2) detection_value, + practical_id, practical_vocs_name, format(practical_value, 2) practical_value, create_time + FROM feedback + </sql> + + <select id="selectById" parameterType="java.lang.Long" resultMap="FeedbackDetailResult"> + <include refid="feedbackDetailSql"></include> + WHERE id = #{id} + </select> + + <select id="selectSevenDayAccuracyAvg" parameterType="java.lang.Long" resultType="java.lang.Double"> + SELECT COUNT(id)/(SELECT COUNT(id) FROM feedback + WHERE CONVERT(date_format(create_time, '%Y%m%d%H%'), SIGNED) >= #{beginTime}) FROM feedback + WHERE CONVERT(date_format(create_time, '%Y%m%d%H%'), SIGNED) >= #{beginTime} + AND practical_id IS NULL + </select> + + <insert id="insert" parameterType="com.yssh.entity.FeedbackDetail" useGeneratedKeys="true" keyProperty="id"> + INSERT INTO feedback + (table_name, location_name, detection_id, + detection_vocs_name, detection_value, practical_id, + practical_vocs_name, practical_value, create_time) + VALUES + (#{tableName}, #{locationName}, #{detectionId}, + #{detectionVocsName}, #{detectionValue}, #{practicalId}, + #{practicalVocsName}, #{practicalValue}, #{createTime}) + </insert> + + <update id="update" parameterType="com.yssh.entity.FeedbackDetail"> + UPDATE feedback SET + practical_id = #{practicalId}, practical_vocs_name = #{practicalVocsName}, practical_value = #{practicalValue} + WHERE id = #{id} + </update> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/LocationMapper.xml b/src/main/resources/mapper/LocationMapper.xml new file mode 100644 index 0000000..3ec3770 --- /dev/null +++ b/src/main/resources/mapper/LocationMapper.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.yssh.mapper.LocationMapper"> + <resultMap id="locationResult" type="com.yssh.entity.Location"> + <id column="id" property="id" javaType="java.lang.Integer" /> + <id column="name" property="name" javaType="java.lang.String" jdbcType="VARCHAR" /> + <id column="type" property="type" javaType="java.lang.String" jdbcType="VARCHAR"/> + <id column="lon" property="lon" javaType="java.lang.Float" jdbcType="DOUBLE"/> + <id column="lat" property="lat" javaType="java.lang.Float" jdbcType="DOUBLE"/> + </resultMap> + + <sql id="locationSql"> + SELECT id, name, type, format(lon, 6) lon, format(lat, 6) lat FROM location + </sql> + + <select id="selectByXY" resultMap="locationResult"> + <include refid="locationSql"></include> + <where> + lon between (#{x} - 0.000045) and (#{x} + 0.000045) + and + lat between (#{y} - 0.000045) and (#{y} + 0.000045) + </where> + </select> + + <select id="selectVocAddrs" resultMap="locationResult"> + select id, x "lon", y "lat", addr "name" + from voc_addr + where length(addr) > 0; + </select> + + <select id="query" resultMap="locationResult"> + <include refid="locationSql"></include> + <where> + <if test="name != null and name != ''"> + AND name LIKE concat('%', #{name}, '%') + </if> + <if test="type != null and type != ''"> + AND type = #{type} + </if> + </where> + </select> + + <select id="getAll" resultMap="locationResult"> + <include refid="locationSql"></include> + </select> + + <insert id="insertLocation" parameterType="com.yssh.entity.Location"> + insert into location( + name, type, lon, lat + ) + values ( + #{name},#{type},#{lon},#{lat} + ) + </insert> + + <delete id="deleteLocation"> + delete from location where id = #{id} + </delete> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/QxshMapper.xml b/src/main/resources/mapper/QxshMapper.xml new file mode 100644 index 0000000..b07e71e --- /dev/null +++ b/src/main/resources/mapper/QxshMapper.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.yssh.mapper.QxshMapper"> + <select id="selectByTime" resultType="com.yssh.entity.Qxsh"> + select id, name, lon, lat, format(value, 2) "value", time + from yssh_qxsh + where time = #{time} + order by name; + </select> + + <select id="selectMonthTop10" resultType="com.yssh.entity.Qxsh"> + with rs as ( + select id, name, format(value, 2) "value", time + from yssh_qxsh + where time like #{time} and name like 'AI-%' + ) + select id, name, value, time from rs + order by value desc + limit 10; + </select> + + <select id="select3Hours" resultType="com.yssh.entity.Qxsh"> + select id, name, format(value, 2) "value", time + from yssh_qxsh + where name like 'AI-%' and time in + <foreach collection="times" item="time" open="(" separator="," close=")"> + #{time} + </foreach> + order by name, time; + </select> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/StratumMapper.xml b/src/main/resources/mapper/StratumMapper.xml new file mode 100644 index 0000000..67acf26 --- /dev/null +++ b/src/main/resources/mapper/StratumMapper.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.yssh.mapper.StratumMapper"> + <resultMap id="StratumResult" type="com.yssh.entity.Stratum"> + <id column="id" property="id" /> + <result column="exp_site_number" property="expSiteNumber" /> + <result column="primary_layer_number" property="primaryLayerNumber" /> + <result column="sublayer_number" property="sublayerNumber" /> + <result column="geological_era" property="geologicalEra" /> + <result column="geological_genesis" property="geologicalGenesis" /> + <result column="layer_depth" property="layerDepth" /> + <result column="geotechnical_name" property="geotechnicalName" /> + <result column="geotechnical_category" property="geotechnicalCategory" /> + <result column="description" property="description" /> + </resultMap> + + <select id="select" parameterType="java.util.Map" resultMap="StratumResult"> + SELECT * + FROM stratum + WHERE exp_site_number = #{expSiteNumber} + LIMIT #{begin},#{end} + </select> + + <select id="selectByExpSiteNumbers" resultMap="StratumResult"> + SELECT * + FROM stratum + WHERE exp_site_number IN + <foreach collection="expSiteNumbers" item="expSiteNumber" open="(" separator="," close=")"> + #{expSiteNumber} + </foreach> + GROUP BY exp_site_number + </select> + + <select id="selectByGeotechnicalName" parameterType="java.util.Map" resultMap="StratumResult"> + SELECT * + FROM stratum + WHERE exp_site_number = #{expSiteNumber} + AND geotechnical_name = #{geotechnicalName} + LIMIT #{start}, #{rows} + </select> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/SuYuanMapper.xml b/src/main/resources/mapper/SuYuanMapper.xml new file mode 100644 index 0000000..df67e57 --- /dev/null +++ b/src/main/resources/mapper/SuYuanMapper.xml @@ -0,0 +1,232 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.yssh.mapper.SuYuanMapper"> + <resultMap id="SuYuan2dResult" type="com.yssh.entity.SuYuan2d"> + <result property="id" column="id" /> + <result property="x" column="x" /> + <result property="y" column="y" /> + <result property="value" column="c" /> + </resultMap> + + <resultMap id="SuYuan3dResult" type="com.yssh.entity.SuYuan3d"> + <result property="id" column="id" /> + <result property="x" column="x" /> + <result property="y" column="y" /> + <result property="height0" column="height0" /> + <result property="height10" column="height10" /> + <result property="height20" column="height20" /> + <result property="height30" column="height30" /> + <result property="height40" column="height40" /> + <result property="height50" column="height50" /> + <result property="height60" column="height60" /> + <result property="height70" column="height70" /> + <result property="height80" column="height80" /> + <result property="height90" column="height90" /> + </resultMap> + + <resultMap id="DistanceSuYuanResult" type="com.yssh.entity.DistanceSuYuan"> + <result property="id" column="id" /> + <result property="x" column="x" /> + <result property="y" column="y" /> + <result property="u" column="u" /> + <result property="v" column="v" /> + <result property="vocsValue" column="c" /> + </resultMap> + + <resultMap id="TemporaryResult" type="com.yssh.entity.Temporary"> + <result property="id" column="id" /> + <result property="x" column="x" /> + <result property="y" column="y" /> + <result property="z" column="z" /> + <result property="u" column="u" /> + <result property="v" column="v" /> + <result property="w" column="w" /> + <result property="c" column="c" /> + </resultMap> + + <resultMap id="SuYuanMonitorDataResult" type="com.yssh.entity.SuYuanMonitorData"> + <result property="id" column="id" /> + <result property="value" column="c" /> + <result property="time" column="time" /> + </resultMap> + + <select id="get2d" resultMap="SuYuan2dResult"> + SELECT id, x, y, format(c, 2) "c" + FROM ${tableName} + WHERE id IN + <foreach collection="ids" item="item" open="(" separator="," close=")"> + #{item} + </foreach> + ORDER BY z ASC, x ASC, y DESC + </select> + + <select id="get3d" resultMap="SuYuan3dResult"> + SELECT sy.id, sy.x, sy.y, sy.id, sy.x, sy.y, ( + SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 0) + ) AS height0, ( + SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 1) + ) AS height10, ( + SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 2) + ) AS height20, ( + SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 3) + ) AS height30, ( + SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 4) + ) AS height40, ( + SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 5) + ) AS height50, ( + SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 6) + ) AS height60, ( + SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 7) + ) AS height70, ( + SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 8) + ) AS height80, ( + SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 9) + ) AS height90 + FROM ${tableName} AS sy + WHERE id IN + <foreach collection="ids" item="item" open="(" separator="," close=")"> + #{item} + </foreach> + ORDER BY sy.z ASC, sy.x ASC, sy.y DESC + </select> + + <select id="getDistanceSuYuan" resultMap="DistanceSuYuanResult"> + SELECT id, x, y, format(c, 2) "c", u, v + FROM ${tableName} + WHERE id IN + <foreach collection="ids" item="item" open="(" separator="," close=")"> + #{item} + </foreach> + ORDER BY z ASC, x ASC, y DESC + </select> + + <select id="getSuYuan500Max" resultMap="DistanceSuYuanResult"> + select id, x, y, format(c, 2) "c", u, v + from ${tableName} + where id in + <foreach collection="ids" item="item" open="(" separator="," close=")"> + #{item} + </foreach> + order by c desc + limit 1; + </select> + + <select id="getSuYuanById" resultMap="DistanceSuYuanResult"> + select id, x, y, format(c, 2) "c", u, v + from ${tableName} + where id = #{id} + </select> + + <select id="getAlarmsAnalyse" resultMap="SuYuan2dResult"> + SELECT id, x, y, format(c, 2) "c" + FROM ${tableName} + WHERE id IN + <foreach collection="ids" item="item" open="(" separator="," close=")"> + #{item} + </foreach> + AND c >= (SELECT jcbj FROM alert_config LIMIT 1) + </select> + + <select id="getWarningAnalyse" resultMap="SuYuan2dResult"> + SELECT id, x, y, format(c, 2) "c" + FROM ${tableName} + WHERE id IN + <foreach collection="ids" item="item" open="(" separator="," close=")"> + #{item} + </foreach> + and c >= (select jcyj from alert_config limit 1) and c < (select jcbj from alert_config limit 1) + </select> + + <select id="getMonitorData" resultMap="SuYuanMonitorDataResult"> + <foreach collection="tableNames" item="tableName" separator=" UNION "> + SELECT id, format(c, 2) "c", SUBSTRING_INDEX(#{tableName}, '_', -1) AS time + FROM ${tableName} + WHERE id = #{id} + </foreach> + </select> + + <select id="getNewMonitorData" resultType="com.yssh.entity.SuYuanMonitorData"> + select id, format(value, 2) "value", time + from yssh_qxsh + where name = #{name} and Cast(time as signed) between ${start} and ${end} + order by time desc; + </select> + + <select id="getMonthValueDataMax" resultType="java.util.Map"> + <foreach collection="tableNames" item="tableName" separator=" UNION "> + SELECT format(c, 2) AS value, SUBSTRING_INDEX(#{tableName}, '_', -1) AS time + FROM ${tableName} + WHERE id = #{id} + </foreach> + ORDER BY value DESC + LIMIT 1 + </select> + + <select id="selectSuYuan700ById" resultType="com.yssh.entity.SuYuan700"> + select * from suyuan_700 + where su_yuan_id = #{id} and create_time = #{time} + limit 1; + </select> + + <select id="selectSuYuan46ById" resultType="com.yssh.entity.SuYuan700"> + select * from suyuan_46 + where su_yuan_id = #{id} and create_time = #{time} + limit 1; + </select> + + <select id="getTemporary" resultMap="TemporaryResult"> + SELECT x, y, z, u, v, w, format(c, 2) "c" + FROM ${tableName} + WHERE id IN + <foreach collection="ids" item="item" open="(" separator="," close=")"> + #{item} + </foreach> + ORDER BY z ASC, x ASC, y DESC + </select> + + <insert id="batchInsert"> + INSERT INTO ${tableName} ( + id,x,y,z,u,v,w,c + )VALUES + <foreach collection="datas" item="item" separator=","> + ( + #{item.id}, + #{item.x}, + #{item.y}, + #{item.z}, + #{item.u}, + #{item.v}, + #{item.w}, + #{item.c} + ) + </foreach> + </insert> + + <select id="isTableExists" resultType="java.lang.Integer"> + select count(*) from information_schema.tables where table_name = #{tableName}; + </select> + + <update id="createTable" parameterType="java.lang.String"> + CREATE TABLE ${tableName} ( + `id` varchar(255) NOT NULL COMMENT '涓婚敭', + `x` int(7) NULL DEFAULT NULL, + `y` int(7) NULL DEFAULT NULL, + `z` int(7) NULL DEFAULT NULL, + `u` double NULL DEFAULT NULL, + `v` double NULL DEFAULT NULL, + `w` double NULL DEFAULT NULL, + `c` double NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE + ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + </update> + + <update id="update" > + UPDATE ${tableName} SET c = #{value} WHERE id = #{id} + </update> + + <update id="updateVocsName"> + update ${table} set vocsName = #{vocsName} where id = #{id}; + </update> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/ThuAccuracyMapper.xml b/src/main/resources/mapper/ThuAccuracyMapper.xml new file mode 100644 index 0000000..33037e5 --- /dev/null +++ b/src/main/resources/mapper/ThuAccuracyMapper.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.yssh.mapper.ThuAccuracyMapper"> + <resultMap id="ThuAccuracyResult" type="com.yssh.entity.ThuAccuracy"> + <id column="id" property="id" /> + <result column="name" property="name" /> + <result column="lon" property="lon" /> + <result column="lat" property="lat" /> + <result column="value" property="value" /> + <result column="time" property="time" /> + <result column="property" property="property" /> + <result column="wg100" property="wg100" /> + <result column="wg200" property="wg200" /> + <result column="wg300" property="wg300" /> + <result column="wg500" property="wg500" /> + <result column="accuracy" property="accuracy" /> + </resultMap> + + <sql id="ThuAccuracySql"> + SELECT id, name, lon, lat, value, time, property, wg100, wg200, wg300, wg500, accuracy + FROM thu_accuracy + </sql> + + <select id="selectSevenDayAccuracyAvg" parameterType="java.lang.Long" resultType="java.lang.Double"> + SELECT sum(accuracy)/count(id) AS accuracy + FROM thu_accuracy + <!-- WHERE accuracy > 0 --> + WHERE CONVERT(time, unsigned) >= #{beginTime} + </select> + + <select id="getForecastData" parameterType="java.util.Map" resultMap="ThuAccuracyResult"> + SELECT TRIM(ta.name), ta.value, ta.time + FROM thu_accuracy AS ta + WHERE CONVERT(TRIM(ta.time), SIGNED) >= CONVERT(date_format(#{beginTime}, '%Y%m%d%H%'), SIGNED) + AND CONVERT(TRIM(ta.time), SIGNED) <= CONVERT(date_format(#{endTime}, '%Y%m%d%H%'), SIGNED) + AND ta.name = #{name} + </select> + + + <delete id="delete"> + delete from thu_accuracy where id = #{id} + </delete> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/VocValsMapper.xml b/src/main/resources/mapper/VocValsMapper.xml new file mode 100644 index 0000000..dfadfd2 --- /dev/null +++ b/src/main/resources/mapper/VocValsMapper.xml @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.yssh.mapper.VocValsMapper"> + <resultMap id="selectMap" type="com.yssh.entity.VocVals"> + <id property="id" column="id" /> + <result property="x" column="x" /> + <result property="y" column="y" /> + <result property="val" column="val" /> + <result property="createTime" column="create_time" /> + <result property="addr" column="addr" /> + </resultMap> + + <select id="selectByTime" resultMap="selectMap"> + select a.x, a.y, format(a.val, 2) "val", b.addr + from voc_vals a inner join voc_addr b + on a.x = b.x and a.y = b.y + where date_format(a.create_time, '%Y%m%d%H') = ${time} + and a.val > (select jcyj from alert_config); + </select> + + <select id="countByTime" resultType="java.lang.Integer"> + select count(*) + from voc_vals + where date_format(create_time, '%Y%m%d%H') = ${time}; + </select> + + <select id="selectCoords" resultType="com.yssh.entity.VocCoords"> + select x, y, addr + from voc_addr + <where> + 1 = 1 + <if test="x != null"> + and x = ${x} + </if> + <if test="y != null"> + and y = ${y} + </if> + </where> + </select> + + <insert id="insert" parameterType="com.yssh.entity.VocVals" useGeneratedKeys="false" keyProperty="id"> + insert into voc_vals (id, x, y, val, create_time) values + (${id}, ${x}, ${y}, ${val}, ${createTime}); + </insert> + + <insert id="inserts" parameterType="com.yssh.entity.VocVals" useGeneratedKeys="false" keyProperty="id"> + insert into voc_vals (id, x, y, val, create_time) values + <foreach collection="list" item="item" index="index" separator=","> + (${item.id}, #{item.x},#{item.y},#{item.val},#{item.createTime}) + </foreach> + </insert> + + <delete id="deleteLastYear"> + delete from voc_vals + where create_time < date_sub(now(), interval 1 year); + </delete> + + <delete id="deleteByTime"> + delete from voc_vals + where date_format(create_time, '%Y%m%d%H') = ${time}; + </delete> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/WarningDetailMapper.xml b/src/main/resources/mapper/WarningDetailMapper.xml new file mode 100644 index 0000000..250e611 --- /dev/null +++ b/src/main/resources/mapper/WarningDetailMapper.xml @@ -0,0 +1,128 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.yssh.mapper.WarningDetailMapper"> + <resultMap id="WarningDetailResult" type="com.yssh.entity.WarningDetail"> + <id property="id" column="id" /> + <result property="tableName" column="table_name" /> + <result property="suYuanId" column="su_yuan_id" /> + <result property="locationName" column="location_name" /> + <result property="type" column="type" /> + <result property="createTime" column="create_time" /> + <result property="value" column="value" /> + </resultMap> + + <resultMap id="WarningVoResult" type="com.yssh.entity.WarningVo"> + <result property="location_name" column="locationName" /> + <result property="suYuanId" column="su_yuan_id" /> + <result property="value" column="value" /> + </resultMap> + + <select id="selectWarningDetailByType" resultMap="WarningVoResult"> + SELECT location_name, su_yuan_id, format(value, 2) "value" + FROM warning_detail + WHERE date_format(create_time, '%Y%m%d%H%I') >= date_format(NOW(), '%Y%m%d%H%I') + AND type = #{type} + </select> + + <select id="selectWarningDetailByMap_old" parameterType="java.util.Map" resultMap="WarningVoResult"> + SELECT location_name, su_yuan_id, format(value, 2) "value" + FROM warning_detail + WHERE date_format(create_time, '%Y%m%d%H%I%S') >= date_format(#{startTime}, '%Y%m%d%H%I%S') + AND date_format(create_time, '%Y%m%d%H%I%S') <= date_format(#{endTime}, '%Y%m%d%H%I%S') + AND type = #{type} + </select> + + <select id="selectWarningDetailByMap" parameterType="java.util.Map" resultMap="WarningVoResult"> + select location_name, su_yuan_id, format(value, 2) "value" + from warning_detail + where create_time between #{startTime} and #{endTime} and type = #{type}; + </select> + + <select id="countWarnByMap" resultType="java.lang.Integer"> + with rs as (select jcyj, jcbj from alert_config limit 1) + select count(*) + from warning_detail + where create_time between #{startTime} and #{endTime} + and value >= (select jcyj from rs) and value < (select jcbj from rs); + </select> + + <select id="countAlarmByMap" resultType="java.lang.Integer"> + with rs as (select jcyj, jcbj from alert_config limit 1) + select count(*) + from warning_detail + where create_time between #{startTime} and #{endTime} + and value >= (select jcbj from rs); + </select> + + <select id="selectWarningDayCountByMap_old" parameterType="java.util.Map" resultType="java.util.Map"> + SELECT date_format(create_time,'%Y%m%d') AS createTime, count(id) AS num + FROM warning_detail + WHERE date_format(create_time, '%Y%m%d%H%I%S') >= date_format(#{startTime}, '%Y%m%d%H%I%S') + AND date_format(create_time, '%Y%m%d%H%I%S') <= date_format(#{endTime}, '%Y%m%d%H%I%S') + AND type = #{type} + GROUP BY DATE_FORMAT(create_time,'%Y%m%d%') + ORDER BY create_time ASC + </select> + + <select id="selectWarningDayCountByMap" parameterType="java.util.Map" resultType="java.util.Map"> + with rs as ( + select date_format(create_time, '%Y%m%d') AS ct, id, type + from warning_detail + where create_time between #{startTime} and #{endTime} and type = #{type} + ) + select ct as createTime, count(id) as num + from rs + group by ct + order by ct asc; + </select> + + <select id="selectByTime" resultMap="WarningDetailResult"> + select id, table_name, su_yuan_id, location_name, type, create_time, format(value, 2) "value" + from warning_detail + where create_time between #{startTime} and #{endTime} + order by create_time; + </select> + + <select id="selectByTimeForYj" resultMap="WarningDetailResult"> + with rs as (select jcyj, jcbj from alert_config limit 1) + select id, table_name, su_yuan_id, location_name, 1 "type", create_time, format(value, 2) "value" + from warning_detail + where create_time between #{startTime} and #{endTime} + and value >= (select jcyj from rs) and value < (select jcbj from rs) + order by value; + </select> + + <select id="selectByTimeForBj" resultMap="WarningDetailResult"> + with rs as (select jcyj, jcbj from alert_config limit 1) + select id, table_name, su_yuan_id, location_name, 0 "type", create_time, format(value, 2) "value" + from warning_detail + where create_time between #{startTime} and #{endTime} + and value >= (select jcbj from rs) + order by value; + </select> + + <select id="getLastYearVal" resultType="java.lang.Double"> + with rs as ( + select su_yuan_id "id", date_sub(create_time, interval 1 year) "time" + from warning_detail where id = ${id}) + select format(value, 2) "val" + from warning_detail + where su_yuan_id = (select id from rs) and create_time = (select time from rs); + </select> + + <insert id="batchInsert"> + INSERT INTO warning_detail (table_name, su_yuan_id, location_name, type, create_time, value)VALUES + <foreach collection="datas" item="item" separator=","> + ( + #{item.tableName}, + #{item.suYuanId}, + #{item.locationName}, + #{item.type}, + #{item.createTime}, + #{item.value} + ) + </foreach> + </insert> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/WeatherMapper.xml b/src/main/resources/mapper/WeatherMapper.xml new file mode 100644 index 0000000..3f32373 --- /dev/null +++ b/src/main/resources/mapper/WeatherMapper.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.yssh.mapper.WeatherMapper"> + <resultMap id="WeatherResult" type="com.yssh.entity.Weather"> + <id column="id" property="id" javaType="java.lang.Integer" /> + <id column="time" property="time" javaType="java.lang.String" jdbcType="VARCHAR" /> + <id column="wind_Speed" property="windSpeed" javaType="java.lang.String" jdbcType="VARCHAR"/> + <id column="wind_direction" property="windDirection" javaType="java.lang.String" jdbcType="VARCHAR"/> + <id column="weather_condition" property="weatherCondition" javaType="java.lang.String" jdbcType="VARCHAR"/> + <id column="temperature" property="temperature" javaType="java.lang.String" jdbcType="VARCHAR"/> + </resultMap> + + <select id="query" resultMap="WeatherResult"> + select id, time, format(wind_speed, 2) "wind_speed", wind_direction, weather_condition, format(temperature, 2) "temperature" + from yssh_weather + <where> + 1 = 1 + <if test="begin != null"> + and str_to_date(time, '%Y-%m-%d-%H:%i:%S') >= #{begin} + </if> + <if test="end != null"> + and str_to_date(time, '%Y-%m-%d-%H:%i:%S') <= #{end} + </if> + </where> + </select> + + <select id="getAll" resultMap="WeatherResult"> + select id, time, format(wind_speed, 2) "wind_speed", wind_direction, weather_condition, format(temperature, 2) "temperature" + from yssh_weather + </select> + + <insert id="insert" parameterType="com.yssh.entity.Weather"> + insert into yssh_weather ( + time, wind_speed, wind_direction, weather_condition, temperature + ) + values ( + #{time},#{windSpeed},#{windDirection},#{weatherCondition},#{temperature} + ) + </insert> + <delete id="delete"> + delete from yssh_weather where id = #{id} + </delete> +</mapper> \ No newline at end of file diff --git a/src/main/resources/mybatis.xml b/src/main/resources/mybatis.xml new file mode 100644 index 0000000..cac4d5f --- /dev/null +++ b/src/main/resources/mybatis.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE configuration + PUBLIC "-//mybatis.org//DTD Config 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-config.dtd"> +<configuration> + <settings> + <!--閰嶇疆褰卞搷鎵�鏈夋槧灏勫櫒涓厤缃紦瀛�--> + <setting name="cacheEnabled" value="true"/> + <!--寤惰繜鍔犺浇--> + <setting name="lazyLoadingEnabled" value="true"/> + <!--鏄惁鍏佽鍗曚竴璇彞杩斿洖澶氱粨鏋滈泦--> + <setting name="multipleResultSetsEnabled" value="true"/> + <!--浣跨敤鍒楁爣绛句唬鏇垮垪鍚�--> + <setting name="useColumnLabel" value="true"/> + <!--鍏佽JDBC 鏀寔鑷姩鐢熸垚涓婚敭--> + <setting name="useGeneratedKeys" value="false"/> + <!--璁剧疆SQL瓒呮椂鏃堕棿锛岀--> + <setting name="defaultStatementTimeout" value="360"/> + <!--榛樿杩斿洖鐨勬潯鏁伴檺鍒�--> + <setting name="defaultFetchSize" value="1000"/> + <!--鏄惁寮�鍚嚜鍔ㄩ┘宄板懡鍚嶈鍒欐槧灏勶紝鍗充粠缁忓吀鏁版嵁搴撳垪鍚� A_COLUMN 鍒扮粡鍏� Java 灞炴�у悕 aColumn 鐨勭被浼兼槧灏�--> + <setting name="mapUnderscoreToCamelCase" value="true"/> + <!--MyBatis 鍒╃敤鏈湴缂撳瓨鏈哄埗锛圠ocal Cache锛夐槻姝㈠惊鐜紩鐢紙circular references锛夊拰鍔犻�熻仈澶嶅祵濂楁熁璇€��--> + <setting name="localCacheScope" value="SESSION"/> + <!--褰撴病鏈変负鍙傛暟鎻愪緵鐗瑰畾鐨� JDBC 绫诲瀷鏃讹紝涓虹┖鍊兼寚瀹� JDBC 绫诲瀷--> + <setting name="jdbcTypeForNull" value="NULL"/> + <!--鎸囧畾鍝釜瀵硅薄鐨勬柟娉曡Е鍙戜竴娆″欢杩熷姞杞�--> + <setting name="lazyLoadTriggerMethods" value="equals,clone,hashCode,toString"/> + <!--鎸囧畾褰撶粨鏋滈泦涓�间负 null 鏃讹紝鏄惁璋冪敤鏄犲皠瀵硅薄鐨� setter锛坢ap 瀵硅薄鏃朵负 put锛夋柟娉�--> + <setting name="callSettersOnNulls" value="true"/> + <!--鎸囧畾 MyBatis 鎵�鐢ㄦ棩蹇楃殑鍏蜂綋瀹炵幇锛歀OG4J/LOG4J2/SLF4J/STDOUT_LOGGING/NO_LOGGING--> + <setting name="logImpl" value="NO_LOGGING" /> + </settings> + <typeAliases> + <package name="com.yssh.entity"/> + </typeAliases> +</configuration> \ No newline at end of file -- Gitblit v1.9.3