diff --git a/.gitignore b/.gitignore index 82416ef..5a413ad 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,9 @@ buildNumber.properties # JDT-specific (Eclipse Java Development Tools) .classpath + +/weather/target +/weather/target/* +/storm_zj_hz/target +/storm_zj_hz/target/* + diff --git a/jpahefengweather/pom.xml b/jpahefengweather/pom.xml index 070f431..3727fcb 100644 --- a/jpahefengweather/pom.xml +++ b/jpahefengweather/pom.xml @@ -31,10 +31,11 @@ mybatis-spring-boot-starter 2.2.0 - + mysql mysql-connector-java + 8.0.26 runtime @@ -94,7 +95,7 @@ com.liuhuiyu util - 2021.2.0 + 2022.1.0 com.liuhuiyu diff --git a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledService.java b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledService.java index feb6755..129328d 100644 --- a/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledService.java +++ b/jpahefengweather/src/main/java/com/rehome/jpahefengweather/service/ScheduledService.java @@ -109,7 +109,7 @@ public class ScheduledService { /** * @date 2022-03-16 09:41 - * @description: 定时任务, 从和风天气获取实时天气预报 + * @description: 定时任务, 从和风天气获取实时天气预报,OkHttpClient异步获取,工具类封装网络请求 * @Param: null */ //@Scheduled(cron = "0 0 10,14,18,20,22 * * *")//每天10,14,18,20,22点各执行一次,一天总共执行五次 @@ -207,7 +207,7 @@ public class ScheduledService { /** * @date 2022-03-16 09:41 - * @description: 定时任务, 从和风天气获取实时天气预报 + * @description: 定时任务, 从和风天气获取城市列表 * @Param: null */ //@Scheduled(cron = "*/5 * * * * *")//每天0,8,16点各执行一次,一天总共执行三次 @@ -234,7 +234,7 @@ public class ScheduledService { /** * @date 2022-03-16 09:41 - * @description: 定时任务, 从和风天气获取实时天气预报 + * @description: 定时任务, 从和风天气获取实时天气预报,OkHttpClient同步获取 * @Param: null */ //@Scheduled(cron = "*/10 * * * * *")//每天0,8,16点各执行一次,一天总共执行三次 @@ -279,7 +279,7 @@ public class ScheduledService { /** * @date 2022-03-16 09:41 - * @description: 定时任务, 从和风天气获取实时天气预报 + * @description: 定时任务, 从和风天气获取实时天气预报,OkHttpClient异步获取 * @Param: null */ //@Scheduled(cron = "*/10 * * * * *")//每天0,8,16点各执行一次,一天总共执行三次 @@ -328,7 +328,7 @@ public class ScheduledService { /** * @date 2022-03-16 09:41 - * @description: 定时任务, 从和风天气获取实时天气预报 + * @description: 定时任务, 获取本地保存的实时天气预报,只获取最新一条数据 * @Param: null */ //@Scheduled(cron = "*/10 * * * * *")//每天0,8,16点各执行一次,一天总共执行三次 @@ -380,7 +380,7 @@ public class ScheduledService { /** * @date 2022-03-16 09:41 - * @description: 定时任务, 从和风天气获取实时天气预报 + * @description: 定时任务, 从本地获取天气预报 * @Param: null */ //@Scheduled(cron = "*/10 * * * * *")//每天0,8,16点各执行一次,一天总共执行三次 @@ -518,10 +518,10 @@ public class ScheduledService { /** * @date 2022-03-16 09:41 - * @description: 从中央气象台获取天气数据 + * @description: 从中央气象台获取实时天气数据 * @Param: null */ - @Scheduled(cron = "0 15 * * * *") + //@Scheduled(cron = "0 15 * * * *") public void getNmcNowWeather() { System.out.println("scheduledGetWeather"); System.out.println("=====>>>>>使用cron:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); @@ -591,12 +591,23 @@ public class ScheduledService { } } + /** + * @date 2022-03-16 09:41 + * @description: 从浙江省水利厅获取历史台风列表数据和对应的台风详情 + * @Param: null + */ +// @Scheduled(cron = "0 48 * * * *") +// public void getZjsltHistoryStormList() { +// for(int i=1940;i<2025;i++){ +// getZjsltStormList(String.valueOf(i)); +// } +// } /** * @date 2022-03-16 09:41 * @description: 从浙江省水利厅获取台风列表 * @Param: null */ - @Scheduled(cron = "0 10 * * * *") + //@Scheduled(cron = "0 30 * * * *") public void getZjsltStormList() { System.out.println("getZjsltStormList"); String strNow = String.valueOf(System.currentTimeMillis()); @@ -608,12 +619,12 @@ public class ScheduledService { .readTimeout(30, TimeUnit.SECONDS) .build(); try { - //Thread.sleep(10000); + Thread.sleep(5000); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy"); String nowDate = sdf.format(new Date()); String nowYear = sdfYear.format(new Date()); - //nowYear = String.valueOf(i); + Random random = new Random();//以系统自身时间为种子数 int iRandom = random.nextInt(); Long nowLong = 13728353350362976L; @@ -681,7 +692,7 @@ public class ScheduledService { } } } - } catch (IOException e) { + } catch (IOException | InterruptedException e) { e.printStackTrace(); } } @@ -767,8 +778,21 @@ public class ScheduledService { * @description: 从温州气象台获取台风列表 * @Param: null */ - @Scheduled(cron = "0 12 * * * *") - public void getWztfStormList() { + @Scheduled(cron = "0 30 * * * *") + public void getWztfHistoryStormList() { + for(int i=1945;i<2025;i++){ + getWztfStormList(String.valueOf(i)); + } + //getWztfStormList(String.valueOf(1944)); + } + + /** + * @date 2022-03-16 09:41 + * @description: 从温州气象台获取台风列表 + * @Param: null + */ + //@Scheduled(cron = "0 15 * * * *") + public void getWztfStormList(String nowYear) { // 初始化 OkHttpClient OkHttpClient client = new OkHttpClient.Builder() .connectTimeout(10, TimeUnit.SECONDS) @@ -777,11 +801,11 @@ public class ScheduledService { .build(); try { - //Thread.sleep(1000); + Thread.sleep(3000); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy"); String nowDate = sdf.format(new Date()); - String nowYear = sdfYear.format(new Date()); + //String nowYear = sdfYear.format(new Date()); //nowYear = String.valueOf(i); String url = "http://data.istrongcloud.com/v2/data/complex/" + nowYear + ".json?v=" + String.valueOf(System.currentTimeMillis()); @@ -794,7 +818,7 @@ public class ScheduledService { // 得到返回Response Response response = client.newCall(request).execute(); String body = response.body().string(); - //System.out.println(body); + System.out.println(body); if (StringUtils.hasText(body)) { if (body.length() > 2) { Gson gson = new Gson(); @@ -840,7 +864,7 @@ public class ScheduledService { } } } - } catch (IOException e) { + } catch (IOException | InterruptedException e) { e.printStackTrace(); } } diff --git a/jpahefengweather/src/main/resources/application.yml b/jpahefengweather/src/main/resources/application.yml index 17fb5ee..7fbe63f 100644 --- a/jpahefengweather/src/main/resources/application.yml +++ b/jpahefengweather/src/main/resources/application.yml @@ -13,10 +13,10 @@ spring: #url: jdbc:mysql://121.36.143.201:33400/hefengweather?useUnicode=true&characterEncoding=utf-8&useSSL=false #url: jdbc:mysql://192.168.1.28:3340/hefengweather?useUnicode=true&characterEncoding=utf-8&useSSL=false # url: jdbc:mysql://192.168.1.71:2881/hefengweather?useUnicode=true&characterEncoding=utf-8&useSSL=false -# driverClassName: com.mysql.jdbc.Driver #com.mysql.cj.jdbc.Driver com.mysql.jdbc.Driver -# url: jdbc:mysql://192.168.5.21:3306/nmcweather?useUnicode=true&characterEncoding=utf-8&useSSL=false -# username: root -# password: Skyinno251, + driverClassName: com.mysql.cj.jdbc.Driver #com.mysql.cj.jdbc.Driver com.mysql.jdbc.Driver + url: jdbc:mysql://192.168.2.18:3306/nmcweather?useUnicode=true&characterEncoding=utf-8&useSSL=false + username: root + password: Skyinno251, # driverClassName: oracle.jdbc.driver.OracleDriver # url: jdbc:oracle:thin:@192.168.2.18:1521/orcl # username: maximo @@ -33,10 +33,10 @@ spring: # url: jdbc:oracle:thin:@192.168.1.13:1521/ORCLCDB # username: c##maximo # password: maximo - driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver - url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=weather;encrypt=false; - username: sa - password: Skyinno251, +# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver +# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=weather;encrypt=false; +# username: sa +# password: Skyinno251, # 配置 DBMS 类型 #database: sql_server #url: jdbc:mysql://192.168.1.71:2881/hefengweather?useUnicode=true&characterEncoding=utf-8&useSSL=false @@ -66,7 +66,7 @@ spring: # password: maximo jpa: # 配置 DBMS 类型 - database: sql_server + database: mysql # 配置是否将执行的 SQL 输出到日志 show-sql: false open-in-view: true diff --git a/storm_zj_hz/.gitignore b/storm_zj_hz/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/storm_zj_hz/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/storm_zj_hz/.mvn/wrapper/maven-wrapper.jar b/storm_zj_hz/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..c1dd12f Binary files /dev/null and b/storm_zj_hz/.mvn/wrapper/maven-wrapper.jar differ diff --git a/storm_zj_hz/.mvn/wrapper/maven-wrapper.properties b/storm_zj_hz/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..b7cb93e --- /dev/null +++ b/storm_zj_hz/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar diff --git a/storm_zj_hz/mvnw b/storm_zj_hz/mvnw new file mode 100644 index 0000000..8a8fb22 --- /dev/null +++ b/storm_zj_hz/mvnw @@ -0,0 +1,316 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`\\unset -f command; \\command -v java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/storm_zj_hz/mvnw.cmd b/storm_zj_hz/mvnw.cmd new file mode 100644 index 0000000..1d8ab01 --- /dev/null +++ b/storm_zj_hz/mvnw.cmd @@ -0,0 +1,188 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/storm_zj_hz/pom.xml b/storm_zj_hz/pom.xml new file mode 100644 index 0000000..d6660b8 --- /dev/null +++ b/storm_zj_hz/pom.xml @@ -0,0 +1,178 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.5.4 + + + com.rehome + storm_zj_hz + 1.0.0 + war + storm_zj_hz + storm_zj_hz + + 1.8 + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-web + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 2.2.0 + + + + mysql + mysql-connector-java + 8.0.26 + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + org.projectlombok + lombok + 1.18.20 + true + + + + org.apache.logging.log4j + log4j-api + 2.17.1 + + + + org.apache.logging.log4j + log4j-core + 2.17.1 + + + + org.apache.poi + poi + 3.14 + + + org.apache.poi + poi-ooxml + 3.14 + + + com.google.code.gson + gson + 2.8.2 + + + com.squareup.okhttp3 + okhttp + 3.6.0 + + + org.apache.commons + commons-lang3 + 3.9 + + + org.jetbrains + annotations + 19.0.0 + + + com.liuhuiyu + util + 2022.1.0 + + + com.liuhuiyu + spring-util + 2021.1.0 + + + com.liuhuiyu + web + 2022.1.0 + + + com.liuhuiyu + jpa + 2021.1.0 + + + com.liuhuiyu + okhttp3util + 2021.2.2 + + + com.liuhuiyu + test + 2021.1.0 + + + javax.validation + validation-api + 2.0.1.Final + + + com.oracle + ojdbc6 + 11.2.0.1.0 + + + + + io.swagger + swagger-annotations + 1.5.20 + + + com.alibaba + fastjson + 1.2.47 + + + + com.microsoft.sqlserver + mssql-jdbc + 11.2.0.jre8 + + + + + + + + + + + + + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + + \ No newline at end of file diff --git a/storm_zj_hz/settings1.xml b/storm_zj_hz/settings1.xml new file mode 100644 index 0000000..3ef4596 --- /dev/null +++ b/storm_zj_hz/settings1.xml @@ -0,0 +1,94 @@ + + + + + C:\Users\Administrator\.m2\repository + + + + + + + + + + + pds-repo + admin + admin1234 + + + + + + + pds-repo + pds-repo + http://192.168.1.28:8081/nexus/content/groups/public/ + * + + + + + + + dev + + + pds-repo + http://192.168.1.28:8081/nexus/content/groups/public/ + + true + + + true + + + + + + + dev + + + diff --git a/storm_zj_hz/settings3.xml b/storm_zj_hz/settings3.xml new file mode 100644 index 0000000..c192750 --- /dev/null +++ b/storm_zj_hz/settings3.xml @@ -0,0 +1,94 @@ + + + + + C:\Users\Administrator\.m2\repository + + + + + + + + + + + pds-repo + admin + admin1234 + + + + + + + pds-repo + pds-repo + http://192.168.1.28:8081/repository/maven-public/ + * + + + + + + + dev + + + pds-repo + http://192.168.1.28:8081/repository/maven-public/ + + true + + + true + + + + + + + dev + + + diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/JpahefengweatherApplication.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/JpahefengweatherApplication.java new file mode 100644 index 0000000..3e368b3 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/JpahefengweatherApplication.java @@ -0,0 +1,33 @@ +package com.rehome.jpahefengweather; + +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 org.springframework.cache.annotation.EnableCaching; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.transaction.annotation.EnableTransactionManagement; + + +@EnableJpaAuditing +@EnableScheduling +@SpringBootApplication +public class JpahefengweatherApplication extends SpringBootServletInitializer { + + public static void main(String[] args) { + SpringApplication.run(JpahefengweatherApplication.class, args); + } + + /** + * @date 2022-03-14 15:20 + * @description: 容器配置,springboot打war包布署必须添加这个配置 为了打包springboot项目 + * @Param: SpringApplicationBuilder + */ + @Override + protected SpringApplicationBuilder configure( + SpringApplicationBuilder builder) { + return builder.sources(JpahefengweatherApplication.class); + } +} \ No newline at end of file diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/controller/TyphoonController.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/controller/TyphoonController.java new file mode 100644 index 0000000..36ba0f9 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/controller/TyphoonController.java @@ -0,0 +1,71 @@ +package com.rehome.jpahefengweather.controller; + +import com.liuhuiyu.util.model.Result; +import com.rehome.jpahefengweather.dto.TyphoonBaseDto; +import com.rehome.jpahefengweather.dto.TyphoonTfidDto; +import com.rehome.jpahefengweather.dto.WztfStormInfoDto; +import com.rehome.jpahefengweather.entity.*; +import com.rehome.jpahefengweather.service.WztfStormService; +import com.rehome.jpahefengweather.service.ZjsltStormService; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@RequestMapping("/typhoon") +public class TyphoonController { + @Resource + private ZjsltStormService zjsltStormService; + @Resource + private WztfStormService wztfStormService; + + + //region 根据年份获取台风列表 + @PostMapping("/getStormListByYear") + @ApiOperation(value = "获取台风列表", notes = "获取台风列表") + @ApiImplicitParams(value = { + @ApiImplicitParam(name = "dto", value = "获取台风列表", dataTypeClass = TyphoonBaseDto.class, paramType = "body", required = true), + }) + public Result> getStormListByYear(@Validated @RequestBody TyphoonBaseDto dto){ + return Result.of(this.zjsltStormService.findByYear(dto.getYear())); + } + //endregion + + //region 根据台风id获取单条台风数据 + @PostMapping("/getTyphoonInfoByTfid") + @ApiOperation(value = "根据台风id获取单条台风数据", notes = "根据台风id获取单条台风数据") + @ApiImplicitParams(value = { + @ApiImplicitParam(name = "dto", value = "根据台风id获取单条台风数据", dataTypeClass = TyphoonTfidDto.class, paramType = "body", required = true), + }) + public Result getTyphoonInfoByTfid(@Validated @RequestBody TyphoonTfidDto dto){ + return Result.of(this.zjsltStormService.findTyphoonInfoByTfid(dto.getTfid())); + } + //endregion + //region 根据年份获取台风列表 + @PostMapping("/getWztfStormListByYear") + @ApiOperation(value = "获取台风列表", notes = "获取台风列表") + @ApiImplicitParams(value = { + @ApiImplicitParam(name = "dto", value = "获取台风列表", dataTypeClass = TyphoonBaseDto.class, paramType = "body", required = true), + }) + public Result> getWztfStormListByYear(@Validated @RequestBody TyphoonBaseDto dto){ + return Result.of(this.wztfStormService.findByYear(dto.getYear())); + } + //endregion + + //region 根据台风id获取单条台风数据 + @PostMapping("/getWztfStormInfoByTfbh") + @ApiOperation(value = "根据台风id获取单条台风数据", notes = "根据台风id获取单条台风数据") + @ApiImplicitParams(value = { + @ApiImplicitParam(name = "dto", value = "根据台风id获取单条台风数据", dataTypeClass = WztfStormInfoDto.class, paramType = "body", required = true), + }) + public Result getWztfStormInfoByTfbh(@Validated @RequestBody WztfStormInfoDto dto){ + return Result.of(this.wztfStormService.findWztfStormInfoByTfbh(dto.getTfbh())); + } + //endregion + +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/BaseDataCenterView.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/BaseDataCenterView.java new file mode 100644 index 0000000..a07b445 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/BaseDataCenterView.java @@ -0,0 +1,129 @@ +package com.rehome.jpahefengweather.dao; + +import com.liuhuiyu.jpa.BaseView; +import com.liuhuiyu.jpa.DaoOperator; +import com.rehome.jpahefengweather.utils.DaoUtil; +import com.rehome.jpahefengweather.utils.IPaging; +import org.springframework.data.domain.PageImpl; +import javax.sql.DataSource; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author LiuHuiYu + * @version v1.0.0.0 + * Created DateTime 2022-02-21 16:16 + */ +public abstract class BaseDataCenterView extends BaseView { + public BaseDataCenterView(DataSource dataSource) { + super(dataSource); + } + + /** + * 数量查询 + * + * @param t 条件 + * @param sql 原始语句 + * @param fullWhere 填充条件 + * @param 分页查询的条件 + * @return java.lang.Long + * @author LiuHuiYu + * Created DateTime 2022-02-21 16:24 + */ + protected Long count(T t, String sql, String baseWhere, FullWhere fullWhere) { + StringBuilder sqlBuilder = new StringBuilder(sql); + sqlBuilder.append(baseWhere); + Map parameterMap = new HashMap<>(0); + fullWhere.fullWhere(t, sqlBuilder, parameterMap); + DaoUtil.countOracleSql(sqlBuilder); + return super.selectCount(sqlBuilder.toString(), parameterMap); + } + + /** + * 获取分页列表数据 + * @author LiuHuiYu + * Created DateTime 2022-04-25 10:29 + * @param b 获取数据后的转换 + * @param t 获取条件 + * @param sql 基础查询语句 + * @param baseWhere 基础查询条件 + * @param order 排序 + * @param fullWhere 填充查询条件 + * @param 返回分页的数据类型 + * @param 分页查询的条件 + * @return java.util.List + */ + protected List pageList(DaoOperator b, T t, String sql, String baseWhere, String order, FullWhere fullWhere) { + StringBuilder sqlBuilder = new StringBuilder(sql); + sqlBuilder.append(baseWhere); + Map parameterMap = new HashMap<>(0); + fullWhere.fullWhere(t, sqlBuilder, parameterMap); + sqlBuilder.append(" ").append(order); + DaoUtil.paginationOracleSql(sqlBuilder, t.getPaging()); + return super.getResultList(b, sqlBuilder.toString(), parameterMap); + } + + protected PageImpl page(DaoOperator b, T t, String sql, FullWhere fullWhere, String order) { + return page(b, t, sql, " WHERE(1=1) ", order, fullWhere); + } + + /** + * 获取列表数据 + * @author LiuHuiYu + * Created DateTime 2022-04-25 10:29 + * @param b 获取数据后的转换 + * @param t 获取条件 + * @param sql 基础查询语句 + * @param baseWhere 基础查询条件 + * @param order 排序 + * @param fullWhere 填充查询条件 + * @param 返回分页的数据类型 + * @param 分页查询的条件 + * @return java.util.List + */ + protected List list(DaoOperator b, T t, String sql, String baseWhere, String order, FullWhere fullWhere) { + StringBuilder sqlBuilder = new StringBuilder(sql); + sqlBuilder.append(baseWhere); + Map parameterMap = new HashMap<>(0); + fullWhere.fullWhere(t, sqlBuilder, parameterMap); + sqlBuilder.append(" ").append(order); + return super.getResultList(b, sqlBuilder.toString(), parameterMap); + } + + /** + * 功能描述 + * + * @param b 查询结果转换实例的实现 + * @param t 分页查询条件 + * @param sql 基础语句 + * @param baseWhere 基础查询(带where) + * @param order 排序(带 order by) + * @param fullWhere void fullWhere(T find, StringBuilder sqlBuilder, Map parameterMap) 实现 + * @param 返回分页的数据类型 + * @param 分页查询的条件 + * @return org.springframework.data.domain.PageImpl + * @author LiuHuiYu + * Created DateTime 2022-04-09 11:41 + */ + protected PageImpl page(DaoOperator b, T t, String sql, String baseWhere, String order, FullWhere fullWhere) { + Long total = this.count(t, sql, baseWhere, fullWhere); + final List gatekeeperCarLogDtoList; + if (total == 0) { + gatekeeperCarLogDtoList = Collections.emptyList(); + } + else if (t.getPaging().isAllInOne()) { + gatekeeperCarLogDtoList = this.list(b, t, sql, baseWhere, order, fullWhere); + } + else if (t.getPaging().getPageSize() == 0) { + gatekeeperCarLogDtoList = Collections.emptyList(); + } + else { + //记录查询 + gatekeeperCarLogDtoList = pageList(b, t, sql, baseWhere, order, fullWhere); + } + return new PageImpl<>(gatekeeperCarLogDtoList, t.getPaging().getPageRequest(), total); + } + +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/FullWhere.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/FullWhere.java new file mode 100644 index 0000000..f61ed4c --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/FullWhere.java @@ -0,0 +1,22 @@ +package com.rehome.jpahefengweather.dao; + +import java.util.Map; + +/** + * @author LiuHuiYu + * @version v1.0.0.0 + * Created DateTime 2022-02-21 16:17 + */ +@FunctionalInterface +public interface FullWhere { + /** + * 功能描述 + * + * @param find 查询条件 + * @param sqlBuilder sql + * @param parameterMap 参数列表 + * @author LiuHuiYu + * Created DateTime 2022-02-21 16:19 + */ + void fullWhere(T find, StringBuilder sqlBuilder, Map parameterMap); +} \ No newline at end of file diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/TyphoonInfoRepository.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/TyphoonInfoRepository.java new file mode 100644 index 0000000..0fc011c --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/TyphoonInfoRepository.java @@ -0,0 +1,17 @@ +package com.rehome.jpahefengweather.dao; + + + +import com.rehome.jpahefengweather.entity.TyphoonInfo; +import org.springframework.data.jpa.repository.JpaRepository; + +/** + * 参数一 T :当前需要映射的实体 + * 参数二 ID :当前映射的实体中的OID的类型 + * + */ +public interface TyphoonInfoRepository extends JpaRepository { + + //方法名称必须要遵循驼峰式命名规则,findBy(关键字)+属性名称(首字母大写)+查询条件(首字母大写) + TyphoonInfo findByTfid(String tfid); +} \ No newline at end of file diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/WztfStormInfoRepository.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/WztfStormInfoRepository.java new file mode 100644 index 0000000..9209da5 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/WztfStormInfoRepository.java @@ -0,0 +1,18 @@ +package com.rehome.jpahefengweather.dao; + +import com.rehome.jpahefengweather.entity.WztfStorm; +import com.rehome.jpahefengweather.entity.WztfStormInfo; +import org.springframework.data.jpa.repository.JpaRepository; +import java.util.List; + + +/** + * 参数一 T :当前需要映射的实体 + * 参数二 ID :当前映射的实体中的OID的类型 + * + */ +public interface WztfStormInfoRepository extends JpaRepository { + + //方法名称必须要遵循驼峰式命名规则,findBy(关键字)+属性名称(首字母大写)+查询条件(首字母大写) + WztfStormInfo findByTfbh(String tfbh); +} \ No newline at end of file diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/WztfStormRepository.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/WztfStormRepository.java new file mode 100644 index 0000000..df8a01f --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/WztfStormRepository.java @@ -0,0 +1,20 @@ +package com.rehome.jpahefengweather.dao; + +import com.rehome.jpahefengweather.entity.WztfStorm; +import org.springframework.data.jpa.repository.JpaRepository; +import java.util.List; + + +/** + * 参数一 T :当前需要映射的实体 + * 参数二 ID :当前映射的实体中的OID的类型 + * + */ +public interface WztfStormRepository extends JpaRepository { + + //方法名称必须要遵循驼峰式命名规则,findBy(关键字)+属性名称(首字母大写)+查询条件(首字母大写) + WztfStorm findByTfbh(String tfbh); + + List findByYear(String year); +} + diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/ZjsltStormRepository.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/ZjsltStormRepository.java new file mode 100644 index 0000000..e10f215 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dao/ZjsltStormRepository.java @@ -0,0 +1,23 @@ +package com.rehome.jpahefengweather.dao; + + + + + +import com.rehome.jpahefengweather.entity.ZjsltStorm; +import org.springframework.data.jpa.repository.JpaRepository; +import java.util.List; + + +/** + * 参数一 T :当前需要映射的实体 + * 参数二 ID :当前映射的实体中的OID的类型 + * + */ +public interface ZjsltStormRepository extends JpaRepository { + + //方法名称必须要遵循驼峰式命名规则,findBy(关键字)+属性名称(首字母大写)+查询条件(首字母大写) + ZjsltStorm findByTfid(String tfid); + + List findByYear(String year); +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/BaseDto.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/BaseDto.java new file mode 100644 index 0000000..aefaa4a --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/BaseDto.java @@ -0,0 +1,59 @@ +package com.rehome.jpahefengweather.dto; + +import com.liuhuiyu.util.map.MapUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Map; + +/** + * @author HuangWenFei + * @version v1.0.0.0 + * Created DateTime 2022-05-01 16:22 + */ +@ApiModel(value = "BaseDto", description = "接收数据") +public class BaseDto { + @ApiModelProperty("API状态码,具体含义请参考状态码 200请求成功") + private String code; + @ApiModelProperty("当前API的最近更新时间") + private String updateTime; + @ApiModelProperty("当前数据的响应式页面,便于嵌入网站或应用") + private String fxLink; + + + /** + * 根据 map 还原 MaintenanceTemporaryFindDto + * + * @param map 映射map + * @return com.rehome.jpahefengweather.dto.BaseDto + * @author HuangWenFei + * Created DateTime 2022-04-19 10:02 + */ + public static BaseDto ofSelfMap(Map map) { + return MapUtil.fromMap(map, BaseDto.class); + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getFxLink() { + return fxLink; + } + + public void setFxLink(String fxLink) { + this.fxLink = fxLink; + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/BaseFindDto.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/BaseFindDto.java new file mode 100644 index 0000000..72762cb --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/BaseFindDto.java @@ -0,0 +1,37 @@ +package com.rehome.jpahefengweather.dto; + +import com.liuhuiyu.util.map.MapUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Map; + +/** + * @author HuangWenFei + * @version v1.0.0.0 + * Created DateTime 2022-05-01 16:22 + */ +@ApiModel(value = "BaseFindDto", description = "接收数据") +public class BaseFindDto{ + @ApiModelProperty("位置id,从城市列表获取") + private String locationId; + + /** + * 根据 map 还原 MaintenanceTemporaryFindDto + * + * @param map 映射map + * @return cc.rehome.zhanjiang.data_center_model.domain.security.authorize.maintenance_temporary.in.MaintenanceTemporaryFindDto + * @author HuangWenFei + * Created DateTime 2022-04-19 10:02 + */ + public static BaseFindDto ofSelfMap(Map map) { + return MapUtil.fromMap(map, BaseFindDto.class); + } + + public String getLocationId() { + return locationId; + } + + public void setLocationId(String locationId) { + this.locationId = locationId; + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/BaseWeatherFindDto.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/BaseWeatherFindDto.java new file mode 100644 index 0000000..cbdbe71 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/BaseWeatherFindDto.java @@ -0,0 +1,38 @@ +package com.rehome.jpahefengweather.dto; + +import com.liuhuiyu.util.map.MapUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Map; + +/** + * @author HuangWenFei + * @version v1.0.0.0 + * Created DateTime 2022-05-01 16:22 + */ +@ApiModel(value = "BaseWeatherFindDto", description = "接收数据") +public class BaseWeatherFindDto extends BaseFindDto{ + @ApiModelProperty("查询天气的日期") + private String weatherDate; + + /** + * 根据 map 还原 MaintenanceTemporaryFindDto + * + * @param map 映射map + * @return cc.rehome.zhanjiang.data_center_model.domain.security.authorize.maintenance_temporary.in.MaintenanceTemporaryFindDto + * @author HuangWenFei + * Created DateTime 2022-04-19 10:02 + */ + public static BaseWeatherFindDto ofSelfMap(Map map) { + return MapUtil.fromMap(map, BaseWeatherFindDto.class); + } + + public String getWeatherDate() { + return weatherDate; + } + + public void setWeatherDate(String weatherDate) { + this.weatherDate = weatherDate; + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/ForecastDto.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/ForecastDto.java new file mode 100644 index 0000000..a860b3d --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/ForecastDto.java @@ -0,0 +1,301 @@ +package com.rehome.jpahefengweather.dto; + + +import com.liuhuiyu.util.map.MapUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Map; + +/** + * @author HuangWenFei + * @version v1.0.0.0 + * Created DateTime 2022-05-01 16:22 + */ +@ApiModel(value = "ForecastDto", description = "实时天气数据") +public class ForecastDto { + + @ApiModelProperty("预报日期") + private String fxDate; + @ApiModelProperty("日出时间") + private String sunrise; + @ApiModelProperty("日落时间") + private String sunset; + @ApiModelProperty("月升时间") + private String moonrise; + @ApiModelProperty("月落时间") + private String moonset; + @ApiModelProperty("月相名称") + private String moonPhase; + @ApiModelProperty("月相图标代码,图标可通过天气状况和图标下载") + private String moonPhaseIcon; + @ApiModelProperty("预报当天最高温度") + private String tempMax; + @ApiModelProperty("预报当天最低温度") + private String tempMin; + @ApiModelProperty("预报白天天气状况的图标代码,图标可通过天气状况和图标下载") + private String iconDay; + @ApiModelProperty("预报白天天气状况文字描述,包括阴晴雨雪等天气状态的描述") + private String textDay; + @ApiModelProperty("预报夜间天气状况的图标代码,图标可通过天气状况和图标下载") + private String iconNight; + @ApiModelProperty("预报晚间天气状况文字描述,包括阴晴雨雪等天气状态的描述") + private String textNight; + @ApiModelProperty("预报白天风向360角度") + private String wind360Day; + @ApiModelProperty("预报白天风向") + private String windDirDay; + @ApiModelProperty("预报白天风力等级") + private String windScaleDay; + @ApiModelProperty("预报白天风速,公里/小时") + private String windSpeedDay; + @ApiModelProperty("预报夜间风向360角度") + private String wind360Night; + @ApiModelProperty("预报夜间当天风向") + private String windDirNight; + @ApiModelProperty("预报夜间风力等级") + private String windScaleNight; + @ApiModelProperty("预报夜间风速,公里/小时") + private String windSpeedNight; + @ApiModelProperty("预报当天总降水量,默认单位:毫米") + private String precip; + @ApiModelProperty("紫外线强度指数") + private String uvIndex; + @ApiModelProperty("相对湿度,百分比数值") + private String humidity; + @ApiModelProperty("大气压强,默认单位:百帕") + private String pressure; + @ApiModelProperty("能见度,默认单位:公里") + private String vis; + @ApiModelProperty("云量,百分比数值。可能为空") + private String cloud; + + + /** + * 根据 map 还原 MaintenanceTemporaryFindDto + * + * @param map 映射map + * @return com.rehome.jpahefengweather.dto.BaseDto + * @author HuangWenFei + * Created DateTime 2022-04-19 10:02 + */ + public static ForecastDto ofSelfMap(Map map) { + return MapUtil.fromMap(map, ForecastDto.class); + } + + public String getFxDate() { + return fxDate; + } + + public void setFxDate(String fxDate) { + this.fxDate = fxDate; + } + + public String getSunrise() { + return sunrise; + } + + public void setSunrise(String sunrise) { + this.sunrise = sunrise; + } + + public String getSunset() { + return sunset; + } + + public void setSunset(String sunset) { + this.sunset = sunset; + } + + public String getMoonrise() { + return moonrise; + } + + public void setMoonrise(String moonrise) { + this.moonrise = moonrise; + } + + public String getMoonset() { + return moonset; + } + + public void setMoonset(String moonset) { + this.moonset = moonset; + } + + public String getMoonPhase() { + return moonPhase; + } + + public void setMoonPhase(String moonPhase) { + this.moonPhase = moonPhase; + } + + public String getMoonPhaseIcon() { + return moonPhaseIcon; + } + + public void setMoonPhaseIcon(String moonPhaseIcon) { + this.moonPhaseIcon = moonPhaseIcon; + } + + public String getTempMax() { + return tempMax; + } + + public void setTempMax(String tempMax) { + this.tempMax = tempMax; + } + + public String getTempMin() { + return tempMin; + } + + public void setTempMin(String tempMin) { + this.tempMin = tempMin; + } + + public String getIconDay() { + return iconDay; + } + + public void setIconDay(String iconDay) { + this.iconDay = iconDay; + } + + public String getTextDay() { + return textDay; + } + + public void setTextDay(String textDay) { + this.textDay = textDay; + } + + public String getIconNight() { + return iconNight; + } + + public void setIconNight(String iconNight) { + this.iconNight = iconNight; + } + + public String getTextNight() { + return textNight; + } + + public void setTextNight(String textNight) { + this.textNight = textNight; + } + + public String getWind360Day() { + return wind360Day; + } + + public void setWind360Day(String wind360Day) { + this.wind360Day = wind360Day; + } + + public String getWindDirDay() { + return windDirDay; + } + + public void setWindDirDay(String windDirDay) { + this.windDirDay = windDirDay; + } + + public String getWindScaleDay() { + return windScaleDay; + } + + public void setWindScaleDay(String windScaleDay) { + this.windScaleDay = windScaleDay; + } + + public String getWindSpeedDay() { + return windSpeedDay; + } + + public void setWindSpeedDay(String windSpeedDay) { + this.windSpeedDay = windSpeedDay; + } + + public String getWind360Night() { + return wind360Night; + } + + public void setWind360Night(String wind360Night) { + this.wind360Night = wind360Night; + } + + public String getWindDirNight() { + return windDirNight; + } + + public void setWindDirNight(String windDirNight) { + this.windDirNight = windDirNight; + } + + public String getWindScaleNight() { + return windScaleNight; + } + + public void setWindScaleNight(String windScaleNight) { + this.windScaleNight = windScaleNight; + } + + public String getWindSpeedNight() { + return windSpeedNight; + } + + public void setWindSpeedNight(String windSpeedNight) { + this.windSpeedNight = windSpeedNight; + } + + public String getPrecip() { + return precip; + } + + public void setPrecip(String precip) { + this.precip = precip; + } + + public String getUvIndex() { + return uvIndex; + } + + public void setUvIndex(String uvIndex) { + this.uvIndex = uvIndex; + } + + public String getHumidity() { + return humidity; + } + + public void setHumidity(String humidity) { + this.humidity = humidity; + } + + public String getPressure() { + return pressure; + } + + public void setPressure(String pressure) { + this.pressure = pressure; + } + + public String getVis() { + return vis; + } + + public void setVis(String vis) { + this.vis = vis; + } + + public String getCloud() { + return cloud; + } + + public void setCloud(String cloud) { + this.cloud = cloud; + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/ForecastWeatherDto.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/ForecastWeatherDto.java new file mode 100644 index 0000000..cf904df --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/ForecastWeatherDto.java @@ -0,0 +1,40 @@ +package com.rehome.jpahefengweather.dto; + + +import com.liuhuiyu.util.map.MapUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; +import java.util.Map; + +/** + * @author HuangWenFei + * @version v1.0.0.0 + * Created DateTime 2022-05-01 16:22 + */ +@ApiModel(value = "ForecastWeatherDto", description = "接收数据") +public class ForecastWeatherDto extends BaseDto{ + @ApiModelProperty("天气预报数据") + private List daily; + + /** + * 根据 map 还原 MaintenanceTemporaryFindDto + * + * @param map 映射map + * @return com.rehome.jpahefengweather.dto.BaseDto + * @author HuangWenFei + * Created DateTime 2022-04-19 10:02 + */ + public static ForecastWeatherDto ofSelfMap(Map map) { + return MapUtil.fromMap(map, ForecastWeatherDto.class); + } + + public List getDaily() { + return daily; + } + + public void setDaily(List daily) { + this.daily = daily; + } +} \ No newline at end of file diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/NmcBaseDto.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/NmcBaseDto.java new file mode 100644 index 0000000..bbfd4bd --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/NmcBaseDto.java @@ -0,0 +1,48 @@ +package com.rehome.jpahefengweather.dto; + +import com.liuhuiyu.util.map.MapUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Map; + +/** + * @author HuangWenFei + * @version v1.0.0.0 + * Created DateTime 2022-05-01 16:22 + */ +@ApiModel(value = "NmcBaseDto", description = "接收数据") +public class NmcBaseDto { + @ApiModelProperty("API状态码,具体含义请参考状态码 0请求成功") + private int code; + @ApiModelProperty("当前API的最近更新时间") + private String msg; + + /** + * 根据 map 还原 NmcBaseDto + * + * @param map 映射map + * @return com.rehome.jpahefengweather.dto.NmcBaseDto + * @author HuangWenFei + * Created DateTime 2022-04-19 10:02 + */ + public static NmcBaseDto ofSelfMap(Map map) { + return MapUtil.fromMap(map, NmcBaseDto.class); + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/NmcForecastWeatherDto.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/NmcForecastWeatherDto.java new file mode 100644 index 0000000..9cc82af --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/NmcForecastWeatherDto.java @@ -0,0 +1,38 @@ +package com.rehome.jpahefengweather.dto; + +import com.liuhuiyu.util.map.MapUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.List; +import java.util.Map; + +/** + * @author HuangWenFei + * @version v1.0.0.0 + * Created DateTime 2022-05-01 16:22 + */ +@ApiModel(value = "NmcForecastWeatherDto", description = "接收数据") +public class NmcForecastWeatherDto extends NmcBaseDto{ + @ApiModelProperty("实时天气数据") + private List> data; + + /** + * 根据 map 还原 NmcNowWeatherDto + * + * @param map 映射map + * @return com.rehome.jpahefengweather.dto.NmcNowWeatherDto + * @author HuangWenFei + * Created DateTime 2022-04-19 10:02 + */ + public static NmcForecastWeatherDto ofSelfMap(Map map) { + return MapUtil.fromMap(map, NmcForecastWeatherDto.class); + } + + public List> getData() { + return data; + } + + public void setData(List> data) { + this.data = data; + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/NmcNowWeatherDto.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/NmcNowWeatherDto.java new file mode 100644 index 0000000..f4023b7 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/NmcNowWeatherDto.java @@ -0,0 +1,39 @@ +package com.rehome.jpahefengweather.dto; + +import com.liuhuiyu.util.map.MapUtil; +import com.rehome.jpahefengweather.dto.bean.NmcNowData; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Map; + +/** + * @author HuangWenFei + * @version v1.0.0.0 + * Created DateTime 2022-05-01 16:22 + */ +@ApiModel(value = "NmcNowWeatherDto", description = "接收数据") +public class NmcNowWeatherDto extends NmcBaseDto{ + @ApiModelProperty("实时天气数据") + private NmcNowData data; + + /** + * 根据 map 还原 NmcNowWeatherDto + * + * @param map 映射map + * @return com.rehome.jpahefengweather.dto.NmcNowWeatherDto + * @author HuangWenFei + * Created DateTime 2022-04-19 10:02 + */ + public static NmcNowWeatherDto ofSelfMap(Map map) { + return MapUtil.fromMap(map, NmcNowWeatherDto.class); + } + + public NmcNowData getData() { + return data; + } + + public void setData(NmcNowData data) { + this.data = data; + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/NowDto.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/NowDto.java new file mode 100644 index 0000000..380cb01 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/NowDto.java @@ -0,0 +1,179 @@ +package com.rehome.jpahefengweather.dto; + +import com.liuhuiyu.util.map.MapUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Map; + +/** + * @author HuangWenFei + * @version v1.0.0.0 + * Created DateTime 2022-05-01 16:22 + */ +@ApiModel(value = "NowDto", description = "实时天气数据") +public class NowDto { + @ApiModelProperty("数据观测时间") + private String obsTime; + @ApiModelProperty("温度,默认单位:摄氏度") + private String temp; + @ApiModelProperty("体感温度,默认单位:摄氏度") + private String feelsLike; + @ApiModelProperty("天气状况和图标的代码,图标可通过天气状况和图标下载") + private String icon; + @ApiModelProperty("天气状况的文字描述,包括阴晴雨雪等天气状态的描述") + private String text; + @ApiModelProperty("风向360角度") + private String wind360; + @ApiModelProperty("风向") + private String windDir; + @ApiModelProperty("风力等级") + private String windScale; + @ApiModelProperty("风速,公里/小时") + private String windSpeed; + @ApiModelProperty("相对湿度,百分比数值") + private String humidity; + @ApiModelProperty("当前小时累计降水量,默认单位:毫米") + private String precip; + @ApiModelProperty("大气压强,默认单位:百帕") + private String pressure; + @ApiModelProperty("能见度,默认单位:公里") + private String vis; + @ApiModelProperty("云量,百分比数值。可能为空") + private String cloud; + @ApiModelProperty("露点温度。可能为空") + private String dew; + + + /** + * 根据 map 还原 MaintenanceTemporaryFindDto + * + * @param map 映射map + * @return com.rehome.jpahefengweather.dto.BaseDto + * @author HuangWenFei + * Created DateTime 2022-04-19 10:02 + */ + public static NowDto ofSelfMap(Map map) { + return MapUtil.fromMap(map, NowDto.class); + } + + public String getObsTime() { + return obsTime; + } + + public void setObsTime(String obsTime) { + this.obsTime = obsTime; + } + + public String getTemp() { + return temp; + } + + public void setTemp(String temp) { + this.temp = temp; + } + + public String getFeelsLike() { + return feelsLike; + } + + public void setFeelsLike(String feelsLike) { + this.feelsLike = feelsLike; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getWind360() { + return wind360; + } + + public void setWind360(String wind360) { + this.wind360 = wind360; + } + + public String getWindDir() { + return windDir; + } + + public void setWindDir(String windDir) { + this.windDir = windDir; + } + + public String getWindScale() { + return windScale; + } + + public void setWindScale(String windScale) { + this.windScale = windScale; + } + + public String getWindSpeed() { + return windSpeed; + } + + public void setWindSpeed(String windSpeed) { + this.windSpeed = windSpeed; + } + + public String getHumidity() { + return humidity; + } + + public void setHumidity(String humidity) { + this.humidity = humidity; + } + + public String getPrecip() { + return precip; + } + + public void setPrecip(String precip) { + this.precip = precip; + } + + public String getPressure() { + return pressure; + } + + public void setPressure(String pressure) { + this.pressure = pressure; + } + + public String getVis() { + return vis; + } + + public void setVis(String vis) { + this.vis = vis; + } + + public String getCloud() { + return cloud; + } + + public void setCloud(String cloud) { + this.cloud = cloud; + } + + public String getDew() { + return dew; + } + + public void setDew(String dew) { + this.dew = dew; + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/NowWeatherDto.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/NowWeatherDto.java new file mode 100644 index 0000000..b2b7b63 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/NowWeatherDto.java @@ -0,0 +1,38 @@ +package com.rehome.jpahefengweather.dto; + +import com.liuhuiyu.util.map.MapUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Map; + +/** + * @author HuangWenFei + * @version v1.0.0.0 + * Created DateTime 2022-05-01 16:22 + */ +@ApiModel(value = "NowWeatherDto", description = "接收数据") +public class NowWeatherDto extends BaseDto{ + @ApiModelProperty("实时天气数据") + private NowDto now; + + /** + * 根据 map 还原 MaintenanceTemporaryFindDto + * + * @param map 映射map + * @return com.rehome.jpahefengweather.dto.BaseDto + * @author HuangWenFei + * Created DateTime 2022-04-19 10:02 + */ + public static NowWeatherDto ofSelfMap(Map map) { + return MapUtil.fromMap(map, NowWeatherDto.class); + } + + public NowDto getNow() { + return now; + } + + public void setNow(NowDto now) { + this.now = now; + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/StormDataDto.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/StormDataDto.java new file mode 100644 index 0000000..252ce65 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/StormDataDto.java @@ -0,0 +1,41 @@ +package com.rehome.jpahefengweather.dto; + +import com.liuhuiyu.util.map.MapUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * @author HuangWenFei + * @version v1.0.0.0 + * Created DateTime 2022-05-01 16:22 + */ +@ApiModel(value = "StormDataDto", description = "接收数据") +@Data +public class StormDataDto extends BaseDto{ + @ApiModelProperty("获取台风列表数据") + List> typhoonList; + + /** + * 根据 map 还原 MaintenanceTemporaryFindDto + * + * @param map 映射map + * @return com.rehome.jpahefengweather.dto.BaseDto + * @author HuangWenFei + * Created DateTime 2022-04-19 10:02 + */ + public static StormDataDto ofSelfMap(Map map) { + return MapUtil.fromMap(map, StormDataDto.class); + } + + public List> getTyphoonList() { + return typhoonList; + } + + public void setTyphoonList(List> typhoonList) { + this.typhoonList = typhoonList; + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/TyhoonActivityDto.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/TyhoonActivityDto.java new file mode 100644 index 0000000..621caa9 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/TyhoonActivityDto.java @@ -0,0 +1,190 @@ +package com.rehome.jpahefengweather.dto; + +import com.liuhuiyu.util.map.MapUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Map; + +/** + * @author HuangWenFei + * @version v1.0.0.0 + * Created DateTime 2022-08-23 11:13 + */ +@ApiModel(value = "TyhoonActivityDto", description = "实时活跃台风") +public class TyhoonActivityDto { + + @ApiModelProperty("台风英文名") + private String enname; + @ApiModelProperty("纬度") + private String lat; + @ApiModelProperty("经度") + private String lng; + @ApiModelProperty("台风移动方向") + private String movedirection; + @ApiModelProperty("台风移动速速") + private String movespeed; + @ApiModelProperty("台风中文名") + private String name; + @ApiModelProperty("台风风力等级") + private String power; + @ApiModelProperty("中心气压,大气压强,默认单位:百帕") + private String pressure; + @ApiModelProperty("七级风速圈半径") + private String radius7; + @ApiModelProperty("十级风速圈半径") + private String radius10; + @ApiModelProperty("十二级风速圈半径") + private String radius12; + @ApiModelProperty("台风风速") + private String speed; + @ApiModelProperty("台风等级名称") + private String strong; + @ApiModelProperty("台风id") + private String tfid; + @ApiModelProperty("发布时间") + private String time; + @ApiModelProperty("发布时间格式化") + private String timeformate; + + + /** + * 根据 map 还原 TyhoonActivityDto + * + * @param map 映射map + * @return com.rehome.jpahefengweather.dto.TyhoonActivityDto + * @author HuangWenFei + * Created DateTime 2022-08-23 11:13 + */ + public static TyhoonActivityDto ofSelfMap(Map map) { + return MapUtil.fromMap(map, TyhoonActivityDto.class); + } + + public String getEnname() { + return enname; + } + + public void setEnname(String enname) { + this.enname = enname; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getMovedirection() { + return movedirection; + } + + public void setMovedirection(String movedirection) { + this.movedirection = movedirection; + } + + public String getMovespeed() { + return movespeed; + } + + public void setMovespeed(String movespeed) { + this.movespeed = movespeed; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPower() { + return power; + } + + public void setPower(String power) { + this.power = power; + } + + public String getPressure() { + return pressure; + } + + public void setPressure(String pressure) { + this.pressure = pressure; + } + + public String getRadius7() { + return radius7; + } + + public void setRadius7(String radius7) { + this.radius7 = radius7; + } + + public String getRadius10() { + return radius10; + } + + public void setRadius10(String radius10) { + this.radius10 = radius10; + } + + public String getRadius12() { + return radius12; + } + + public void setRadius12(String radius12) { + this.radius12 = radius12; + } + + public String getSpeed() { + return speed; + } + + public void setSpeed(String speed) { + this.speed = speed; + } + + public String getStrong() { + return strong; + } + + public void setStrong(String strong) { + this.strong = strong; + } + + public String getTfid() { + return tfid; + } + + public void setTfid(String tfid) { + this.tfid = tfid; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public String getTimeformate() { + return timeformate; + } + + public void setTimeformate(String timeformate) { + this.timeformate = timeformate; + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/TyphoonBaseDto.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/TyphoonBaseDto.java new file mode 100644 index 0000000..94e489d --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/TyphoonBaseDto.java @@ -0,0 +1,40 @@ +package com.rehome.jpahefengweather.dto; + + +import com.liuhuiyu.util.map.MapUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Map; + +/** + * @author HuangWenFei + * @version v1.0.0.0 + * Created DateTime 2022-05-01 16:22 + */ +@ApiModel(value = "TyphoonBaseDto", description = "实时天气数据") +public class TyphoonBaseDto { + @ApiModelProperty("数据观测时间") + private String year; + + + /** + * 根据 map 还原 MaintenanceTemporaryFindDto + * + * @param map 映射map + * @return com.rehome.jpahefengweather.dto.BaseDto + * @author HuangWenFei + * Created DateTime 2022-04-19 10:02 + */ + public static TyphoonBaseDto ofSelfMap(Map map) { + return MapUtil.fromMap(map, TyphoonBaseDto.class); + } + + public String getYear() { + return year; + } + + public void setYear(String year) { + this.year = year; + } +} \ No newline at end of file diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/TyphoonTfidDto.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/TyphoonTfidDto.java new file mode 100644 index 0000000..6e7d1ac --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/TyphoonTfidDto.java @@ -0,0 +1,40 @@ +package com.rehome.jpahefengweather.dto; + + +import com.liuhuiyu.util.map.MapUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Map; + +/** + * @author HuangWenFei + * @version v1.0.0.0 + * Created DateTime 2022-05-01 16:22 + */ +@ApiModel(value = "TyphoonTfidDto", description = "实时天气数据") +public class TyphoonTfidDto { + @ApiModelProperty("数据观测时间") + private String tfid; + + + /** + * 根据 map 还原 MaintenanceTemporaryFindDto + * + * @param map 映射map + * @return com.rehome.jpahefengweather.dto.BaseDto + * @author HuangWenFei + * Created DateTime 2022-04-19 10:02 + */ + public static TyphoonTfidDto ofSelfMap(Map map) { + return MapUtil.fromMap(map, TyphoonTfidDto.class); + } + + public String getTfid() { + return tfid; + } + + public void setTfid(String tfid) { + this.tfid = tfid; + } +} \ No newline at end of file diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/WztfStormInfoDto.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/WztfStormInfoDto.java new file mode 100644 index 0000000..7476170 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/WztfStormInfoDto.java @@ -0,0 +1,40 @@ +package com.rehome.jpahefengweather.dto; + + +import com.liuhuiyu.util.map.MapUtil; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Map; + +/** + * @author HuangWenFei + * @version v1.0.0.0 + * Created DateTime 2022-05-01 16:22 + */ +@ApiModel(value = "WztfStormInfoDto", description = "实时天气数据") +public class WztfStormInfoDto { + @ApiModelProperty("数据观测时间") + private String tfbh; + + + /** + * 根据 map 还原 MaintenanceTemporaryFindDto + * + * @param map 映射map + * @return com.rehome.jpahefengweather.dto.BaseDto + * @author HuangWenFei + * Created DateTime 2022-04-19 10:02 + */ + public static WztfStormInfoDto ofSelfMap(Map map) { + return MapUtil.fromMap(map, WztfStormInfoDto.class); + } + + public String getTfbh() { + return tfbh; + } + + public void setTfbh(String tfbh) { + this.tfbh = tfbh; + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Air.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Air.java new file mode 100644 index 0000000..95a452f --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Air.java @@ -0,0 +1,12 @@ +package com.rehome.jpahefengweather.dto.bean; + +import lombok.Data; + +@Data +public class Air { + private String forecasttime; + private int aqi; + private int aq; + private String text; + private String aqiCode; +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/NmcForecastData.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/NmcForecastData.java new file mode 100644 index 0000000..7a48cfd --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/NmcForecastData.java @@ -0,0 +1,4 @@ +package com.rehome.jpahefengweather.dto.bean; + +public class NmcForecastData { +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/NmcNowData.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/NmcNowData.java new file mode 100644 index 0000000..5298acc --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/NmcNowData.java @@ -0,0 +1,16 @@ +package com.rehome.jpahefengweather.dto.bean; + +import com.rehome.jpahefengweather.dto.NmcBaseDto; +import lombok.Data; + +import java.util.List; + +@Data +public class NmcNowData { + //实时天气 + Real real; + //空气 + Air air; + //温度变化图表曲线图数据 + List tempchart; +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Real.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Real.java new file mode 100644 index 0000000..c2065b2 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Real.java @@ -0,0 +1,12 @@ +package com.rehome.jpahefengweather.dto.bean; + +import lombok.Data; + +@Data +public class Real { + private String publish_time; + private Station station; + private Weather weather; + private Wind wind; + private Warn warn; +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Station.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Station.java new file mode 100644 index 0000000..576904d --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Station.java @@ -0,0 +1,11 @@ +package com.rehome.jpahefengweather.dto.bean; + +import lombok.Data; + +@Data +public class Station { + private String code; + private String province; + private String city; + private String url; +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Tempchart.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Tempchart.java new file mode 100644 index 0000000..62e7c37 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Tempchart.java @@ -0,0 +1,14 @@ +package com.rehome.jpahefengweather.dto.bean; + +import lombok.Data; + +@Data +public class Tempchart { + private String time; + private int max_temp; + private int min_temp; + private String day_img; + private String day_text; + private String night_img; + private String night_text; +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Warn.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Warn.java new file mode 100644 index 0000000..6b8fe9d --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Warn.java @@ -0,0 +1,17 @@ +package com.rehome.jpahefengweather.dto.bean; + +import lombok.Data; + +@Data +public class Warn { + private String alert; + private String pic; + private String province; + private String city; + private String url; + private String issuecontent; + private String fmeans; + private String signaltype; + private String signallevel; + private String pic2; +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Weather.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Weather.java new file mode 100644 index 0000000..777c7be --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Weather.java @@ -0,0 +1,17 @@ +package com.rehome.jpahefengweather.dto.bean; + +import lombok.Data; + +@Data +public class Weather { + private double temperature; + private double temperatureDiff; + private int airpressure; + private int humidity; + private int rain; + private int rcomfort; + private int icomfort; + private String info; + private String img; + private double feelst; +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Wind.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Wind.java new file mode 100644 index 0000000..fc80e5b --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/dto/bean/Wind.java @@ -0,0 +1,11 @@ +package com.rehome.jpahefengweather.dto.bean; + +import lombok.Data; + +@Data +public class Wind { + private String direct; + private int degree; + private String power; + private double speed; +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/entity/TyphoonInfo.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/entity/TyphoonInfo.java new file mode 100644 index 0000000..f5f0dfb --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/entity/TyphoonInfo.java @@ -0,0 +1,31 @@ +package com.rehome.jpahefengweather.entity; + + + +import lombok.Data; +import org.hibernate.annotations.Proxy; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; +import javax.persistence.*; +import java.io.Serializable; +import java.util.Date; + +@EntityListeners(AuditingEntityListener.class) +@Proxy(lazy = false) +@Data +@Entity +public class TyphoonInfo implements Serializable { + @Id + private String tfid; + + //存放长文本 + @Lob + @Basic(fetch=FetchType.LAZY) + private String stormData; + + @Temporal(TemporalType.TIMESTAMP) + private Date createDate; + + @Temporal(TemporalType.TIMESTAMP) + private Date lastUpdateDate; + +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/entity/WztfStorm.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/entity/WztfStorm.java new file mode 100644 index 0000000..ae69008 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/entity/WztfStorm.java @@ -0,0 +1,44 @@ +package com.rehome.jpahefengweather.entity; + + + +import lombok.Data; +import org.hibernate.annotations.Proxy; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; +import javax.persistence.*; +import java.io.Serializable; +import java.util.Date; + +@EntityListeners(AuditingEntityListener.class) +@Proxy(lazy = false) +@Data +@Entity +public class WztfStorm implements Serializable { + @Id + private String tfbh; + + //台风中文名称 + private String name ; + + //台风英文名称 + private String ename; + + //台风结束时间 + private String end_time ; + + //台风开始时间 + private String begin_time ; + + //台风标识 + private String ident; + + //是否为活跃台风 1:活跃台风 0:台风已停止 + private int is_current ; + + //台风所处年份 + private String year ; + + @Temporal(TemporalType.TIMESTAMP) + private Date createDate; + +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/entity/WztfStormInfo.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/entity/WztfStormInfo.java new file mode 100644 index 0000000..d24c3b0 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/entity/WztfStormInfo.java @@ -0,0 +1,31 @@ +package com.rehome.jpahefengweather.entity; + + + +import lombok.Data; +import org.hibernate.annotations.Proxy; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; +import javax.persistence.*; +import java.io.Serializable; +import java.util.Date; + +@EntityListeners(AuditingEntityListener.class) +@Proxy(lazy = false) +@Data +@Entity +public class WztfStormInfo implements Serializable { + @Id + private String tfbh; + + //存放长文本 + @Lob + @Basic(fetch=FetchType.LAZY) + private String stormData; + + @Temporal(TemporalType.TIMESTAMP) + private Date createDate; + + @Temporal(TemporalType.TIMESTAMP) + private Date lastUpdateDate; + +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/entity/ZjsltStorm.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/entity/ZjsltStorm.java new file mode 100644 index 0000000..f389b45 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/entity/ZjsltStorm.java @@ -0,0 +1,44 @@ +package com.rehome.jpahefengweather.entity; + + + +import lombok.Data; +import org.hibernate.annotations.Proxy; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; +import javax.persistence.*; +import java.io.Serializable; +import java.util.Date; + +@EntityListeners(AuditingEntityListener.class) +@Proxy(lazy = false) +@Data +@Entity +public class ZjsltStorm implements Serializable { + @Id + private String tfid; + + //台风英文名称 + private String enname; + + //台风中文名称 + private String name ; + + //台风结束时间 + private String endtime ; + + //台风开始时间 + private String starttime ; + + //提示等级 + private String warnlevel; + + //是否为活跃台风 1:活跃台风 0:台风已停止 + private String isactive ; + + //台风所处年份 + private String year ; + + @Temporal(TemporalType.TIMESTAMP) + private Date createDate; + +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/service/Impl/WztfStormServiceImpl.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/service/Impl/WztfStormServiceImpl.java new file mode 100644 index 0000000..cb8424b --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/service/Impl/WztfStormServiceImpl.java @@ -0,0 +1,47 @@ +package com.rehome.jpahefengweather.service.Impl; + +import com.rehome.jpahefengweather.dao.TyphoonInfoRepository; +import com.rehome.jpahefengweather.dao.WztfStormInfoRepository; +import com.rehome.jpahefengweather.dao.WztfStormRepository; +import com.rehome.jpahefengweather.dao.ZjsltStormRepository; +import com.rehome.jpahefengweather.entity.WztfStorm; +import com.rehome.jpahefengweather.entity.WztfStormInfo; +import com.rehome.jpahefengweather.service.WztfStormService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +@Service +public class WztfStormServiceImpl implements WztfStormService { + + @Resource + private WztfStormRepository wztfStormRepository; + @Resource + private WztfStormInfoRepository wztfStormInfoRepository; + + @Override + public WztfStorm findByTfbh(String tfbh) { + return this.wztfStormRepository.findByTfbh(tfbh); + } + + @Override + public List findByYear(String year) { + return this.wztfStormRepository.findByYear(year); + } + + @Override + public void saveWztfStorm(WztfStorm wztfStorm) { + this.wztfStormRepository.save(wztfStorm); + } + + @Override + public WztfStormInfo findWztfStormInfoByTfbh(String tfbh) { + return this.wztfStormInfoRepository.findByTfbh(tfbh); + } + + @Override + public void saveWztfStormInfo(WztfStormInfo wztfStormInfo) { + this.wztfStormInfoRepository.save(wztfStormInfo); + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/service/Impl/ZjsltStormServiceImpl.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/service/Impl/ZjsltStormServiceImpl.java new file mode 100644 index 0000000..c388ccf --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/service/Impl/ZjsltStormServiceImpl.java @@ -0,0 +1,45 @@ +package com.rehome.jpahefengweather.service.Impl; + +import com.rehome.jpahefengweather.dao.TyphoonInfoRepository; +import com.rehome.jpahefengweather.dao.ZjsltStormRepository; +import com.rehome.jpahefengweather.entity.TyphoonInfo; +import com.rehome.jpahefengweather.entity.ZjsltStorm; +import com.rehome.jpahefengweather.service.ZjsltStormService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +@Service +public class ZjsltStormServiceImpl implements ZjsltStormService { + @Resource + private ZjsltStormRepository zjsltStormRepository; + @Resource + private TyphoonInfoRepository typhoonInfoRepository; + + + @Override + public ZjsltStorm findByTfid(String tfid) { + return this.zjsltStormRepository.findByTfid(tfid); + } + + @Override + public List findByYear(String year) { + return this.zjsltStormRepository.findByYear(year); + } + + @Override + public void saveZjsltStorm(ZjsltStorm zjsltStorm) { + this.zjsltStormRepository.save(zjsltStorm); + } + + @Override + public TyphoonInfo findTyphoonInfoByTfid(String tfid) { + return this.typhoonInfoRepository.findByTfid(tfid); + } + + @Override + public void saveTyphoonInfo(TyphoonInfo typhoonInfo) { + this.typhoonInfoRepository.save(typhoonInfo); + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/service/ScheduledService.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/service/ScheduledService.java new file mode 100644 index 0000000..2b4a0d6 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/service/ScheduledService.java @@ -0,0 +1,384 @@ +package com.rehome.jpahefengweather.service; + + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.liuhuiyu.spring_util.SpringUtil; +import com.rehome.jpahefengweather.dto.NmcBaseDto; +import com.rehome.jpahefengweather.entity.*; + +import com.rehome.jpahefengweather.utils.OkHttpUtil; +import okhttp3.*; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +import javax.annotation.Resource; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Type; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.TimeUnit; + +/** + * @author huangwenfei + * @version v1.0.0.0 + * Created DateTime 2021-04-26 14:35 + * @description: 定时任务服务 + */ +@Component +public class ScheduledService { + + @Value("${rehome.resources-path}") + private String resourcesPath; + + @Resource + private ZjsltStormService zjsltStormService; + @Resource + private WztfStormService wztfStormService; + + + /** + * @date 2022-03-16 09:41 + * @description: 从浙江省水利厅获取历史台风列表数据和对应的台风详情 + * @Param: null + */ +// @Scheduled(cron = "0 48 * * * *") +// public void getZjsltHistoryStormList() { +// for(int i=1940;i<2025;i++){ +// getZjsltStormList(String.valueOf(i)); +// } +// } + /** + * @date 2022-03-16 09:41 + * @description: 从浙江省水利厅获取台风列表 + * @Param: null + */ + @Scheduled(cron = "0 2 * * * *") + public void getZjsltStormList() { + System.out.println("getZjsltStormList"); + String strNow = String.valueOf(System.currentTimeMillis()); + + // 初始化 OkHttpClient + OkHttpClient client = new OkHttpClient.Builder() + .connectTimeout(10, TimeUnit.SECONDS) + .writeTimeout(30, TimeUnit.SECONDS) + .readTimeout(30, TimeUnit.SECONDS) + .build(); + try { + Thread.sleep(5000); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy"); + String nowDate = sdf.format(new Date()); + String nowYear = sdfYear.format(new Date()); + + Random random = new Random();//以系统自身时间为种子数 + int iRandom = random.nextInt(); + Long nowLong = 13728353350362976L; + Long nowLongTemp = nowLong + iRandom; + String url = "https://typhoon.slt.zj.gov.cn/Api/TyphoonList/" + nowYear + "?callback=jQuery" + "1830" + String.valueOf(nowLongTemp) + "_" + strNow + "&_=" + String.valueOf(System.currentTimeMillis()); + System.out.println(url); + // 初始化请求体 + Request request = new Request.Builder() + .get() + .url(url) + .build(); + // 得到返回Response + Response response = client.newCall(request).execute(); + String body = response.body().string(); + //System.out.println(body); + if (StringUtils.hasText(body)) { + if (body.length() > 0) { + Gson gson = new Gson(); + int startIndex = body.indexOf("["); + int endIndex = body.lastIndexOf("]"); +// System.out.println(body.indexOf("[")); +// System.out.println(body.lastIndexOf("]")); + String stormStr = body.substring(startIndex, endIndex + 1); + //System.out.println(stormStr); + if (stormStr != null && stormStr.length() > 2) { + Type type = new TypeToken>() { + }.getType(); + List stormList = gson.fromJson(stormStr, type); + //打印测试 + for (ZjsltStorm storm : stormList) { + storm.setYear(nowYear); + storm.setCreateDate(new Date()); + System.out.println(gson.toJson(storm)); + ZjsltStorm stormDB = this.zjsltStormService.findByTfid(storm.getTfid()); + if (stormDB == null) { + //数据库无数据,第一次插入,同时从第三方平台拉取台风路径数据入库 + this.zjsltStormService.saveZjsltStorm(storm); + this.saveOrUpdateTyphoonInfo(storm); + } else { + //数据库有数据 + if (stormDB.getIsactive().equals("1")) { + if (storm.getIsactive().equals("0")) { + //数据库里面台风数据是活跃状态,第三方平台台风数据已变成不活跃状态,更新数据库台风状态,同时更新台风路径 + stormDB.setIsactive(storm.getIsactive()); + this.zjsltStormService.saveZjsltStorm(stormDB); + this.saveOrUpdateTyphoonInfo(stormDB); + } else { + //数据库里面台风数据是活跃状态,第三方平台台风数据也是活跃状态 + if ((!storm.getEndtime().equals(stormDB.getEndtime())) || (!storm.getEnname().equals(stormDB.getEnname())) || (!storm.getName().equals(stormDB.getName()))) { + //台风列表数据有变化,更新台风列表数据 + stormDB.setEndtime(storm.getEndtime()); + stormDB.setEnname(storm.getEnname()); + stormDB.setName(storm.getName()); + this.zjsltStormService.saveZjsltStorm(stormDB); + } + //更新台风路径 + this.saveOrUpdateTyphoonInfo(stormDB); + } + } else { + //数据库里面台风数据是不活跃状态,无需做任何事情 + //this.saveOrUpdateTyphoonInfo(storm); + } + } + } + } + } + } + } catch (IOException | InterruptedException e) { + e.printStackTrace(); + } + } + + /** + * @date 2022-03-16 09:41 + * @description: 从浙江省水利厅获取台风详情数据,保存或更新台风路径 + * @Param: null + */ + public void saveOrUpdateTyphoonInfo(ZjsltStorm storm) { + System.out.println("saveOrUpdateTyphoonInfo"); + String strNow = String.valueOf(System.currentTimeMillis()); + + // 初始化 OkHttpClient + OkHttpClient client = new OkHttpClient.Builder() + .connectTimeout(10, TimeUnit.SECONDS) + .writeTimeout(30, TimeUnit.SECONDS) + .readTimeout(30, TimeUnit.SECONDS) + .build(); + + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy"); + String nowDate = sdf.format(new Date()); + String nowYear = sdfYear.format(new Date()); + Random random = new Random();//以系统自身时间为种子数 + int iRandom = random.nextInt(); + Long nowLong = 25528353350362976L; + Long nowLongTemp = nowLong + iRandom; + String url = "https://typhoon.slt.zj.gov.cn/Api/TyphoonInfo/" + storm.getTfid() + "?callback=jQuery" + "1830" + String.valueOf(nowLongTemp) + "_" + strNow + "&_=" + String.valueOf(System.currentTimeMillis()); + System.out.println(url); + // 初始化请求体 + Request request = new Request.Builder() + .get() + .url(url) + .build(); + // 得到返回Response + Response response = client.newCall(request).execute(); + String body = response.body().string(); + //System.out.println(body); + if (StringUtils.hasText(body)) { + if (body.length() > 0) { + Gson gson = new Gson(); + int startIndex = body.indexOf("["); + int endIndex = body.lastIndexOf("]"); +// System.out.println(body.indexOf("[")); +// System.out.println(body.lastIndexOf("]")); + String typhoonInfoArryStr = body.substring(startIndex, endIndex + 1); + //System.out.println(typhoonInfoArryStr); + if (typhoonInfoArryStr != null && typhoonInfoArryStr.length() > 2) { + int startIndex0 = typhoonInfoArryStr.indexOf("{"); + int endIndex0 = typhoonInfoArryStr.lastIndexOf("}"); +// System.out.println(startIndex0); +// System.out.println(endIndex0); + String typhoonInfoStr = typhoonInfoArryStr.substring(startIndex0, endIndex0 + 1); + //System.out.println(typhoonInfoStr); + + TyphoonInfo typhoonInfoDB = this.zjsltStormService.findTyphoonInfoByTfid(storm.getTfid()); + TyphoonInfo typhoonInfo = new TyphoonInfo(); + if (typhoonInfoDB == null) { + //数据库无数据,保存风路径数据入库 + typhoonInfo.setTfid(storm.getTfid()); + typhoonInfo.setStormData(typhoonInfoStr); + typhoonInfo.setCreateDate(new Date()); + typhoonInfo.setLastUpdateDate(new Date()); + this.zjsltStormService.saveTyphoonInfo(typhoonInfo); + } else { + //数据库有数据,更新台风路径数据 + typhoonInfoDB.setStormData(typhoonInfoStr); + typhoonInfoDB.setLastUpdateDate(new Date()); + this.zjsltStormService.saveTyphoonInfo(typhoonInfoDB); + } + } + } + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * @date 2022-03-16 09:41 + * @description: 从温州气象台获取台风列表 + * @Param: null + */ +// @Scheduled(cron = "0 30 * * * *") +// public void getWztfHistoryStormList() { +// for(int i=1945;i<2025;i++){ +// getWztfStormList(String.valueOf(i)); +// } +// //getWztfStormList(String.valueOf(1944)); +// } + + /** + * @date 2022-03-16 09:41 + * @description: 从温州气象台获取台风列表 + * @Param: null + */ + @Scheduled(cron = "0 3 * * * *") + public void getWztfStormList() { + // 初始化 OkHttpClient + OkHttpClient client = new OkHttpClient.Builder() + .connectTimeout(10, TimeUnit.SECONDS) + .writeTimeout(30, TimeUnit.SECONDS) + .readTimeout(30, TimeUnit.SECONDS) + .build(); + + try { + Thread.sleep(3000); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy"); + String nowDate = sdf.format(new Date()); + String nowYear = sdfYear.format(new Date()); + + + String url = "http://data.istrongcloud.com/v2/data/complex/" + nowYear + ".json?v=" + String.valueOf(System.currentTimeMillis()); + System.out.println(url); + // 初始化请求体 + Request request = new Request.Builder() + .get() + .url(url) + .build(); + // 得到返回Response + Response response = client.newCall(request).execute(); + String body = response.body().string(); + System.out.println(body); + if (StringUtils.hasText(body)) { + if (body.length() > 2) { + Gson gson = new Gson(); + Type type = new TypeToken>() { + }.getType(); + List stormList = gson.fromJson(body, type); + //打印测试 + for (WztfStorm storm : stormList) { + storm.setYear(nowYear); + storm.setCreateDate(new Date()); + //System.out.println(gson.toJson(storm)); + WztfStorm stormDB = this.wztfStormService.findByTfbh(storm.getTfbh()); + if (stormDB == null) { + //数据库无数据,第一次插入,同时从第三方平台拉取台风路径数据入库 + this.wztfStormService.saveWztfStorm(storm); + this.saveOrUpdateWztfStormInfo(storm); + } else { + //数据库有数据 + if (stormDB.getIs_current() == 1) { + if (storm.getIs_current() == 0) { + //数据库里面台风数据是活跃状态,第三方平台台风数据已变成不活跃状态,更新数据库台风状态,同时更新台风路径 + stormDB.setIs_current(storm.getIs_current()); + this.wztfStormService.saveWztfStorm(stormDB); + this.saveOrUpdateWztfStormInfo(stormDB); + } else { + //数据库里面台风数据是活跃状态,第三方平台台风数据也是活跃状态 + if ((!storm.getEnd_time().equals(stormDB.getEnd_time())) || (!storm.getEname().equals(stormDB.getEname())) || (!storm.getName().equals(stormDB.getName())) || (!storm.getIdent().equals(stormDB.getIdent()))) { + //台风列表数据有变化,更新台风列表数据 + stormDB.setEnd_time(storm.getEnd_time()); + stormDB.setEname(storm.getEname()); + stormDB.setName(storm.getName()); + stormDB.setIdent(storm.getIdent()); + this.wztfStormService.saveWztfStorm(stormDB); + } + //更新台风路径 + this.saveOrUpdateWztfStormInfo(stormDB); + } + } else { + //数据库里面台风数据是不活跃状态,无需做任何事情 + //this.saveOrUpdateWztfStormInfo(storm); + } + } + } + } + } + } catch (IOException | InterruptedException e) { + e.printStackTrace(); + } + } + + /** + * @date 2022-03-16 09:41 + * @description: 从温州气象台获取台风路径,同时保存或更新台风路径 + * @Param: null + */ + public void saveOrUpdateWztfStormInfo(WztfStorm storm) { + System.out.println("saveOrUpdateTyphoonInfo"); + + // 初始化 OkHttpClient + OkHttpClient client = new OkHttpClient.Builder() + .connectTimeout(10, TimeUnit.SECONDS) + .writeTimeout(30, TimeUnit.SECONDS) + .readTimeout(30, TimeUnit.SECONDS) + .build(); + + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy"); + String nowDate = sdf.format(new Date()); + String nowYear = sdfYear.format(new Date()); + + String url = "http://data.istrongcloud.com/v2/data/complex/" + storm.getTfbh() + ".json?v=" + String.valueOf(System.currentTimeMillis()); + System.out.println(url); + + // 初始化请求体 + Request request = new Request.Builder() + .get() + .url(url) + .build(); + // 得到返回Response + Response response = client.newCall(request).execute(); + String body = response.body().string(); + //System.out.println(body); + if (StringUtils.hasText(body)) { + if (body.length() > 2) { + Gson gson = new Gson(); + int startIndex0 = body.indexOf("{"); + int endIndex0 = body.lastIndexOf("}"); + String typhoonInfoStr = body.substring(startIndex0, endIndex0 + 1); + //System.out.println(typhoonInfoStr); + + WztfStormInfo wztfStormInfoDB = this.wztfStormService.findWztfStormInfoByTfbh(storm.getTfbh()); + WztfStormInfo wztfStormInfo = new WztfStormInfo(); + if (wztfStormInfoDB == null) { + //数据库无数据,保存风路径数据入库 + wztfStormInfo.setTfbh(storm.getTfbh()); + wztfStormInfo.setStormData(typhoonInfoStr); + wztfStormInfo.setCreateDate(new Date()); + wztfStormInfo.setLastUpdateDate(new Date()); + this.wztfStormService.saveWztfStormInfo(wztfStormInfo); + } else { + //数据库有数据,更新台风路径数据 + wztfStormInfoDB.setStormData(typhoonInfoStr); + wztfStormInfoDB.setLastUpdateDate(new Date()); + this.wztfStormService.saveWztfStormInfo(wztfStormInfoDB); + } + } + } + } catch (IOException e) { + e.printStackTrace(); + } + } + +} \ No newline at end of file diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/service/WztfStormService.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/service/WztfStormService.java new file mode 100644 index 0000000..2ba93b2 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/service/WztfStormService.java @@ -0,0 +1,24 @@ +package com.rehome.jpahefengweather.service; + + +import com.rehome.jpahefengweather.entity.WztfStorm; +import com.rehome.jpahefengweather.entity.WztfStormInfo; + +import java.util.List; + +public interface WztfStormService { + //根据id查询台风 + WztfStorm findByTfbh(String tfbh); + //根据年份查询台风列表 + List findByYear(String year); + /** + * 保存台风数据 + */ + void saveWztfStorm(WztfStorm wztfStorm); + + WztfStormInfo findWztfStormInfoByTfbh(String tfbh); + /** + * 保存台风路径数据 + */ + void saveWztfStormInfo(WztfStormInfo wztfStormInfo); +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/service/ZjsltStormService.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/service/ZjsltStormService.java new file mode 100644 index 0000000..f795eae --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/service/ZjsltStormService.java @@ -0,0 +1,25 @@ +package com.rehome.jpahefengweather.service; + + +import com.rehome.jpahefengweather.entity.TyphoonInfo; +import com.rehome.jpahefengweather.entity.ZjsltStorm; + +import java.util.List; + +public interface ZjsltStormService { + //根据id查询台风 + ZjsltStorm findByTfid(String tfid); + //根据年份查询台风列表 + List findByYear(String year); + /** + * 保存台风数据 + */ + void saveZjsltStorm(ZjsltStorm zjsltStorm); + + TyphoonInfo findTyphoonInfoByTfid(String tfid); + /** + * 保存台风路径数据 + */ + void saveTyphoonInfo(TyphoonInfo typhoonInfo); + +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/DaoUtil.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/DaoUtil.java new file mode 100644 index 0000000..6404873 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/DaoUtil.java @@ -0,0 +1,88 @@ +package com.rehome.jpahefengweather.utils; + + +import java.util.Arrays; +import java.util.Locale; + +/** + * dao工具类 + * + * @author LiuHuiYu + * @version v1.0.0.0 + * Created DateTime 2022-01-12 9:38 + */ +public class DaoUtil { + /** + * oracle分页查询 + * + * @param sqlBuilder 原始sql + * @param paging 分页信息 + * @author LiuHuiYu + * Created DateTime 2022-01-12 9:39 + */ + public static void paginationOracleSql(StringBuilder sqlBuilder, Paging paging) { + String rowNumName; + for(int i=0;;i++){ + rowNumName = "rowno_" + i; + if(!sqlBuilder.toString().toLowerCase(Locale.ROOT).contains(rowNumName)){ + break; + } + } + sqlBuilder.insert(0, "SELECT * FROM (SELECT t_pagination.*, ROWNUM AS " + rowNumName + " FROM("); + sqlBuilder.append(") t_pagination WHERE ROWNUM <= ") + .append(paging.endRowNo()) + .append(") table_alias WHERE table_alias.") + .append(rowNumName) + .append(" >= ") + .append(paging.beginRowNo()); + } + + /** + * 将当前 sql查询语句转换成 统计数量的语句 + * + * @param sqlBuilder sql 字符串的 StringBuilder + * @author LiuHuiYu + * Created DateTime 2022-01-12 9:57 + */ + public static void countOracleSql(StringBuilder sqlBuilder) { + int index = sqlBuilder.toString().toLowerCase().indexOf(" from "); + sqlBuilder.replace(0, index, "select count(1)"); + } + + /** + * 将当前 sql查询语句转换成 统计数量的语句 + * + * @param sqlBuilder sql 字符串的 StringBuilder + * @author LiuHuiYu + * @deprecated 未启用字符串分析 + * Created DateTime 2022-01-12 9:57 + */ + @Deprecated + public static void countOracleSql2(StringBuilder sqlBuilder) { + String fromString = " from "; + int f = 0; + int level = 0; + for (int i = 0; i < sqlBuilder.length(); i++) { + //字符串检测 + if (Arrays.asList('\'', '\"').contains(sqlBuilder.charAt(i))) { + throw new RuntimeException("当前解析无法解析包含字符串的sql语句"); + } + //包含检测 + if (sqlBuilder.charAt(i) == '(') { + level++; + } + else if (sqlBuilder.charAt(i) == ')') { + level--; + } + if (level < 0) { + throw new RuntimeException("输入的sql语句异常"); + } + +// if (f == fromString.length() && level == 0) { +// ; +// } + } + int index = sqlBuilder.toString().toLowerCase().indexOf(" from "); + sqlBuilder.replace(0, index, "select count(1)"); + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/ExcelUtil.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/ExcelUtil.java new file mode 100644 index 0000000..b5c8657 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/ExcelUtil.java @@ -0,0 +1,100 @@ +package com.rehome.jpahefengweather.utils; + +import org.apache.poi.hssf.usermodel.*; + +import java.util.List; + +/** + * @author LiuHuiYu + * @version v1.0.0.0 + * Created DateTime 2022-03-24 15:19 + */ +public class ExcelUtil { + + /** + * 导出Excel + * + * @param sheetName sheet名称 + * @param title 标题 + * @param values 内容 + * @param wb HSSFWorkbook对象 + * @return HSSFWorkbook + */ + public static HSSFWorkbook getWorkbook(String sheetName, String[] title, String[][] values, HSSFWorkbook wb) { + + // 第一步,创建一个HSSFWorkbook,对应一个Excel文件 + if (wb == null) { + wb = new HSSFWorkbook(); + } + + // 第二步,在workbook中添加一个sheet,对应Excel文件中的sheet + HSSFSheet sheet = wb.createSheet(sheetName); + + // 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制 + HSSFRow row = sheet.createRow(0); + + // 第四步,创建单元格,并设置值表头 设置表头居中 + HSSFCellStyle style = wb.createCellStyle(); + // 创建一个居中格式 + style.setAlignment(HSSFCellStyle.ALIGN_CENTER); + + //声明列对象 + HSSFCell cell; + + //创建标题 + for (int i = 0; i < title.length; i++) { + cell = row.createCell(i); + cell.setCellValue(title[i]); + cell.setCellStyle(style); + } + + //创建内容 + for (int i = 0; i < values.length; i++) { + row = sheet.createRow(i + 1); + for (int j = 0; j < values[i].length; j++) { + //将内容按顺序赋给对应的列对象 + row.createCell(j).setCellValue(values[i][j]); + } + } + return wb; + } + + public static HSSFWorkbook getWorkbook(String sheetName, String[] title, List values, HSSFWorkbook wb) { + + // 第一步,创建一个HSSFWorkbook,对应一个Excel文件 + if (wb == null) { + wb = new HSSFWorkbook(); + } + + // 第二步,在workbook中添加一个sheet,对应Excel文件中的sheet + HSSFSheet sheet = wb.createSheet(sheetName); + + // 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制 + HSSFRow row = sheet.createRow(0); + + // 第四步,创建单元格,并设置值表头 设置表头居中 + HSSFCellStyle style = wb.createCellStyle(); + // 创建一个居中格式 + style.setAlignment(HSSFCellStyle.ALIGN_CENTER); + + //声明列对象 + HSSFCell cell; + + //创建标题 + for (int i = 0; i < title.length; i++) { + cell = row.createCell(i); + cell.setCellValue(title[i]); + cell.setCellStyle(style); + } + + //创建内容 + for (int i = 0; i < values.size(); i++) { + row = sheet.createRow(i + 1); + for (int j = 0; j < values.get(i).length; j++) { + //将内容按顺序赋给对应的列对象 + row.createCell(j).setCellValue(values.get(i)[j]); + } + } + return wb; + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/IPaging.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/IPaging.java new file mode 100644 index 0000000..b8e8aa9 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/IPaging.java @@ -0,0 +1,38 @@ +package com.rehome.jpahefengweather.utils; + +/** + * 分页接口 + *
+ *     @ApiModelProperty("分页信息")
+ *     private Paging paging = new Paging();
+ *
+ *     @Override
+ *     public Paging getPaging() {
+ *         return paging;
+ *     }
+ *
+ *     @Override
+ *     public void setPaging(Paging paging) {
+ *         this.paging = paging;
+ *     }
+ * 
+ * @author LiuHuiYu + * @version v1.0.0.0 + * Created DateTime 2022-01-12 10:22 + */ +public interface IPaging { + /** + * 获取分页信息 + * @author LiuHuiYu + * Created DateTime 2022-01-20 15:29 + * @return cc.rehome.zhanjiang.data_center_model.domain.Paging + */ + Paging getPaging(); + /** + * 设置分页信息 + * @author LiuHuiYu + * Created DateTime 2022-01-20 15:29 + * @param paging 分页信息 + */ + void setPaging(Paging paging); +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/ISerializationJson.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/ISerializationJson.java new file mode 100644 index 0000000..59c28f0 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/ISerializationJson.java @@ -0,0 +1,18 @@ +package com.rehome.jpahefengweather.utils; + +import java.io.Serializable; + +/** + * @author LiuHuiYu + * @version v1.0.0.0 + * Created DateTime 2022-01-08 9:45 + */ +public interface ISerializationJson extends Serializable { + /** + * 将当前类序列化成json字符串 + * @author LiuHuiYu + * Created DateTime 2022-01-20 15:30 + * @return java.lang.String + */ + String toJson(); +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/OkHttpConfig.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/OkHttpConfig.java new file mode 100644 index 0000000..d30da45 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/OkHttpConfig.java @@ -0,0 +1,86 @@ +package com.rehome.jpahefengweather.utils; + +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.concurrent.TimeUnit; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; + +import com.liuhuiyu.spring_util.SpringUtil; +import okhttp3.ConnectionPool; +import okhttp3.OkHttpClient; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Created by qhong on 2018/7/3 16:52 + **/ +@Configuration +public class OkHttpConfig { + + public static OkHttpConfig getInstance() { + return SpringUtil.getBean(OkHttpConfig.class); + } + public OkHttpConfig() {} + public OkHttpClient okHttpClient; + public OkHttpClient getOkHttpClient(){ + if(okHttpClient==null){ + okHttpClient=OkHttpConfig.getInstance().okHttpClient(); + } + return okHttpClient; + } + + + @Bean + public X509TrustManager x509TrustManager() { + return new X509TrustManager() { + @Override + public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { + } + @Override + public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { + } + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + }; + } + @Bean + public SSLSocketFactory sslSocketFactory() { + try { + //信任任何链接 + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(null, new TrustManager[]{x509TrustManager()}, new SecureRandom()); + return sslContext.getSocketFactory(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (KeyManagementException e) { + e.printStackTrace(); + } + return null; + } + /** + * Create a new connection pool with tuning parameters appropriate for a single-user application. + * The tuning parameters in this pool are subject to change in future OkHttp releases. Currently + */ + @Bean + public ConnectionPool pool() { + return new ConnectionPool(200, 5, TimeUnit.MINUTES); + } + @Bean + public OkHttpClient okHttpClient() { + return new OkHttpClient.Builder() + .sslSocketFactory(sslSocketFactory(), x509TrustManager()) + .retryOnConnectionFailure(true)//是否开启缓存 + .connectionPool(pool())//连接池 + .connectTimeout(10L, TimeUnit.SECONDS) + .readTimeout(30L, TimeUnit.SECONDS) + .build(); + } +} \ No newline at end of file diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/OkHttpUtil.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/OkHttpUtil.java new file mode 100644 index 0000000..2f40152 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/OkHttpUtil.java @@ -0,0 +1,133 @@ +package com.rehome.jpahefengweather.utils; + +import java.util.Iterator; +import java.util.Map; + +import com.liuhuiyu.spring_util.SpringUtil; +import okhttp3.FormBody; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; + +/** + * Created by qhong on 2018/7/3 16:55 + **/ +public class OkHttpUtil{ + + + /** + * 根据map获取get请求参数 + * @param queries + * @return + */ + public static StringBuffer getQueryString(String url,Map queries){ + StringBuffer sb = new StringBuffer(url); + if (queries != null && queries.keySet().size() > 0) { + boolean firstFlag = true; + Iterator iterator = queries.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = (Map.Entry) iterator.next(); + if (firstFlag) { + sb.append("?" + entry.getKey() + "=" + entry.getValue()); + firstFlag = false; + } else { + sb.append("&" + entry.getKey() + "=" + entry.getValue()); + } + } + } + return sb; + } + + /** + * 调用okhttp的newCall方法 + * @param request + * @return + */ + private static String execNewCall(Request request){ + Response response = null; + try { + OkHttpClient okHttpClient = OkHttpConfig.getInstance().getOkHttpClient(); + response = okHttpClient.newCall(request).execute(); + int status = response.code(); + if (response.isSuccessful()&&status==200) { + return response.body().string(); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (response != null) { + response.close(); + } + } + return ""; + } + + /** + * get + * @param url 请求的url + * @param queries 请求的参数,在浏览器?后面的数据,没有可以传null + * @return + */ + public static String get(String url, Map queries) { + StringBuffer sb = getQueryString(url,queries); + Request request = new Request.Builder() + .url(sb.toString()) + .build(); + return execNewCall(request); + } + + /** + * post + * + * @param url 请求的url + * @param params post form 提交的参数 + * @return + */ + public static String postFormParams(String url, Map params) { + FormBody.Builder builder = new FormBody.Builder(); + //添加参数 + if (params != null && params.keySet().size() > 0) { + for (String key : params.keySet()) { + builder.add(key, params.get(key)); + } + } + Request request = new Request.Builder() + .url(url) + .post(builder.build()) + .build(); + return execNewCall(request); + } + + + /** + * Post请求发送JSON数据....{"name":"zhangsan","pwd":"123456"} + * 参数一:请求Url + * 参数二:请求的JSON + * 参数三:请求回调 + */ + public static String postJsonParams(String url, String jsonParams) { + RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jsonParams); + Request request = new Request.Builder() + .url(url) + .post(requestBody) + .build(); + return execNewCall(request); + } + + /** + * Post请求发送xml数据.... + * 参数一:请求Url + * 参数二:请求的xmlString + * 参数三:请求回调 + */ + public static String postXmlParams(String url, String xml) { + RequestBody requestBody = RequestBody.create(MediaType.parse("application/xml; charset=utf-8"), xml); + Request request = new Request.Builder() + .url(url) + .post(requestBody) + .build(); + return execNewCall(request); + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/Paging.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/Paging.java new file mode 100644 index 0000000..a6a7a90 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/Paging.java @@ -0,0 +1,82 @@ +package com.rehome.jpahefengweather.utils; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.springframework.data.domain.PageRequest; + +/** + * 分页查询信息 + * + * @author LiuHuiYu + * @version v1.0.0.0 + * Created DateTime 2021-12-20 16:13 + */ +@ApiModel(value = "Paging", description = "分页信息") +public class Paging { + @ApiModelProperty("当前页面索引(0开始)") + private int pageIndex; + @ApiModelProperty("页面大小(0,表示不会有列表信息)") + private int pageSize; + @ApiModelProperty("全部数据放入一个页面不分页") + private boolean allInOne; + public static final int FIRST_PAGE_INDEX = 0; + public static final int DEFAULT_PAGE_SIZE = 20; + public static final int MIN_PAGE_SIZE = 0; + + public Paging() { + pageIndex = FIRST_PAGE_INDEX; + pageSize = DEFAULT_PAGE_SIZE; + } + + public int getPageIndex() { + return pageIndex; + } + + public void setPageIndex(int pageIndex) { + this.pageIndex = Math.max(pageIndex, FIRST_PAGE_INDEX); + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize < MIN_PAGE_SIZE ? DEFAULT_PAGE_SIZE : pageSize; + } + public boolean isAllInOne() { + return allInOne; + } + + public void setAllInOne(boolean allInOne) { + this.allInOne = allInOne; + } + + /** + * Pageable 实现 bean + * + * @return org.springframework.data.domain.PageRequest + * @author LiuHuiYu + * Created DateTime 2022-02-11 11:19 + */ + public PageRequest getPageRequest() { + return PageRequest.of(this.pageIndex, this.pageSize == 0 ? 1 : this.pageSize); + } + /** + * 获取起始数据NO(1开始) + * @author LiuHuiYu + * Created DateTime 2022-04-01 16:00 + * @return java.lang.Integer + */ + public Integer beginRowNo() { + return this.pageIndex * pageSize + 1; + } + /** + * 获取结束数据NO(包含此NO的数据) + * @author LiuHuiYu + * Created DateTime 2022-04-01 16:01 + * @return java.lang.Integer + */ + public Integer endRowNo() { + return beginRowNo() + pageSize - 1; + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/PagingImplDto.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/PagingImplDto.java new file mode 100644 index 0000000..688451b --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/PagingImplDto.java @@ -0,0 +1,33 @@ +package com.rehome.jpahefengweather.utils; + +import com.google.gson.Gson; + +/** + * 简单的分页实现类 + * + * @author LiuHuiYu + * @version v1.0.0.0 + * Created DateTime 2022-03-21 17:28 + */ +public class PagingImplDto implements IPaging, ISerializationJson { + Paging paging; + + public PagingImplDto() { + this.paging = new Paging(); + } + + @Override + public Paging getPaging() { + return this.paging; + } + + @Override + public void setPaging(Paging paging) { + this.paging = paging; + } + + @Override + public String toJson() { + return new Gson().toJson(this); + } +} diff --git a/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/TimestampUtil.java b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/TimestampUtil.java new file mode 100644 index 0000000..17f1294 --- /dev/null +++ b/storm_zj_hz/src/main/java/com/rehome/jpahefengweather/utils/TimestampUtil.java @@ -0,0 +1,107 @@ +package com.rehome.jpahefengweather.utils; + +import java.sql.Timestamp; +import java.text.SimpleDateFormat; + +/** + * @author LiuHuiYu + * @version v1.0.0.0 + * Created DateTime 2022-01-06 15:35 + */ +public class TimestampUtil { + public static final String FORMAT_YEAR_MONTH_DAY = "yyyy-MM-dd"; + public static final String FORMAT_YEAR_MONTH_DAY_HOUR = "yyyy-MM-dd HH"; + public static final String FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE = "yyyy-MM-dd HH:mm"; + public static final String FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND = "yyyy-MM-dd HH:mm:ss"; + + /** + * 转换成开始时间 + * + * @param value 字符串 + * @return java.sql.Timestamp + * @author LiuHuiYu + * Created DateTime 2022-01-06 15:38 + */ + public static Timestamp beginTime(String value) { + try { + String tempV = value; + if (tempV.length() == FORMAT_YEAR_MONTH_DAY.length()) { + tempV += " 00:00:00"; + } + else if (tempV.length() == FORMAT_YEAR_MONTH_DAY_HOUR.length()) { + tempV += ":00:00"; + } + else if (tempV.length() == FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE.length()) { + tempV += ":00"; + } + return Timestamp.valueOf(tempV); + } + catch (Exception e) { + return null; + } + } + + /** + * 转换成结束时间 + * + * @param value 字符串 + * @return java.sql.Timestamp + * @author LiuHuiYu + * Created DateTime 2022-01-06 15:38 + */ + public static Timestamp endTime(String value) { + try { + String tempV = value; + if (tempV.length() == FORMAT_YEAR_MONTH_DAY.length()) { + tempV += " 23:59:59"; + } + else if (tempV.length() == FORMAT_YEAR_MONTH_DAY_HOUR.length()) { + tempV += ":59:59"; + } + else if (tempV.length() == FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE.length()) { + tempV += ":59"; + } + return Timestamp.valueOf(tempV); + } + catch (Exception e) { + return null; + } + } + + /** + * 可以转换为 Timestamp 的字符串 + * + * @param value 字符串 + * @return boolean + * @author LiuHuiYu + * Created DateTime 2022-01-06 15:37 + */ + public static boolean isTimestampString(String value) { + try { + String tempV = value; + if (tempV.length() == FORMAT_YEAR_MONTH_DAY.length()) { + tempV += " 23:59:59"; + } + else if (tempV.length() == FORMAT_YEAR_MONTH_DAY_HOUR.length()) { + tempV += ":59:59"; + } + else if (tempV.length() == FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE.length()) { + tempV += ":59"; + } + Timestamp.valueOf(tempV); + return true; + } + catch (Exception e) { + return false; + } + } + + public static String toString(Timestamp timestamp, String format) { + try { + return new SimpleDateFormat(format).format(timestamp); + } + catch (Exception ex) { + return ""; + } + } +} diff --git a/storm_zj_hz/src/main/resources/application.yml b/storm_zj_hz/src/main/resources/application.yml new file mode 100644 index 0000000..5e083de --- /dev/null +++ b/storm_zj_hz/src/main/resources/application.yml @@ -0,0 +1,77 @@ +#1.项目启动的端口 +server: + port: 48080 + +spring: + datasource: + type: com.zaxxer.hikari.HikariDataSource + #driverClassName: com.mysql.jdbc.Driver #com.mysql.cj.jdbc.Driver com.mysql.jdbc.Driver + #driverClassName: com.mysql.cj.jdbc.Driver #com.mysql.cj.jdbc.Driver com.mysql.jdbc.Driver + #url: jdbc:mysql://localhost:3306/head_office_data_center?characterEncoding=utf-8&serverTimezone=UTC&autoReconnect=true + #url: jdbc:mysql://127.0.0.1:3306/head_office_data_center?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true + #url: jdbc:mysql://localhost:3306/head_office_data_center?useUnicode=true&characterEncoding=utf-8&useSSL=true&nullCatalogMeansCurrent=true&serverTimezone=UTC + #url: jdbc:mysql://121.36.143.201:33400/hefengweather?useUnicode=true&characterEncoding=utf-8&useSSL=false + #url: jdbc:mysql://192.168.1.28:3340/hefengweather?useUnicode=true&characterEncoding=utf-8&useSSL=false +# url: jdbc:mysql://192.168.1.71:2881/hefengweather?useUnicode=true&characterEncoding=utf-8&useSSL=false + #url: jdbc:mysql://192.168.2.18:3306/nmcweather?useUnicode=true&characterEncoding=utf-8&useSSL=false + driverClassName: com.mysql.cj.jdbc.Driver #com.mysql.cj.jdbc.Driver com.mysql.jdbc.Driver + url: jdbc:mysql://192.168.3.7:3306/nmcweather?useUnicode=true&characterEncoding=utf-8&useSSL=false + username: root + password: Skyinno251, +# driverClassName: oracle.jdbc.driver.OracleDriver +# url: jdbc:oracle:thin:@192.168.2.18:1521/orcl +# username: maximo +# password: maximo +# driverClassName: oracle.jdbc.driver.OracleDriver +# url: jdbc:oracle:thin:@192.168.1.9:1521/orcl +# username: huangwenfei +# password: huangwenfei +# driverClassName: oracle.jdbc.driver.OracleDriver +# url: jdbc:oracle:thin:@192.168.1.40:1521/orcl +# username: maximo +# password: maximo +# driverClassName: oracle.jdbc.driver.OracleDriver +# url: jdbc:oracle:thin:@192.168.1.13:1521/ORCLCDB +# username: c##maximo +# password: maximo +# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver +# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=weather;encrypt=false; +# username: sa +# password: Skyinno251, + # 配置 DBMS 类型 + #database: sql_server + #url: jdbc:mysql://192.168.1.71:2881/hefengweather?useUnicode=true&characterEncoding=utf-8&useSSL=false +# driverClassName: com.mysql.cj.jdbc.Driver #com.mysql.cj.jdbc.Driver com.mysql.jdbc.Driver +# url: jdbc:mysql://192.168.5.21:3306/weather?useUnicode=true&characterEncoding=utf-8&useSSL=false +# username: root +# password: Skyinno251, + # driverClassName: oracle.jdbc.driver.OracleDriver + # url: jdbc:oracle:thin:@192.168.2.18:1521/orcl + # username: maximo + # password: maximo + # driverClassName: oracle.jdbc.driver.OracleDriver + # url: jdbc:oracle:thin:@192.168.1.9:1521/orcl + # username: huangwenfei + # password: huangwenfei + # driverClassName: oracle.jdbc.driver.OracleDriver + # url: jdbc:oracle:thin:@192.168.1.40:1521/orcl + # username: maximo + # password: maximo + # driverClassName: oracle.jdbc.driver.OracleDriver + # url: jdbc:oracle:thin:@192.168.1.13:1521/ORCLCDB + # username: c##maximo + # password: maximo + # driverClassName: oracle.jdbc.driver.OracleDriver + # url: jdbc:oracle:thin:@192.168.5.9:1521/orcl + # username: maximo + # password: maximo + jpa: + # 配置 DBMS 类型 + database: mysql + # 配置是否将执行的 SQL 输出到日志 + show-sql: false + open-in-view: true + hibernate: + ddl-auto: update # 第一次建表create 后面用update,要不然每次重启都会新建表 +rehome: + resources-path: /Users/wenfeihuang/storage # 外部资源文件存储路径 格式:/Users/edao/storage \ No newline at end of file diff --git a/storm_zj_hz/src/main/resources/index.html b/storm_zj_hz/src/main/resources/index.html new file mode 100644 index 0000000..566549b --- /dev/null +++ b/storm_zj_hz/src/main/resources/index.html @@ -0,0 +1,10 @@ + + + + + Title + + + + + \ No newline at end of file diff --git a/storm_zj_hz/src/test/java/com/rehome/jpahefengweather/JpahefengweatherApplicationTests.java b/storm_zj_hz/src/test/java/com/rehome/jpahefengweather/JpahefengweatherApplicationTests.java new file mode 100644 index 0000000..c399c68 --- /dev/null +++ b/storm_zj_hz/src/test/java/com/rehome/jpahefengweather/JpahefengweatherApplicationTests.java @@ -0,0 +1,13 @@ +package com.rehome.jpahefengweather; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class JpahefengweatherApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/storm_zj_hz/storage/China-City-List-latest.xls b/storm_zj_hz/storage/China-City-List-latest.xls new file mode 100644 index 0000000..fccfe79 Binary files /dev/null and b/storm_zj_hz/storage/China-City-List-latest.xls differ diff --git a/storm_zj_hz/storage/China-City-List-latest.xlsx b/storm_zj_hz/storage/China-City-List-latest.xlsx new file mode 100644 index 0000000..d8f8241 Binary files /dev/null and b/storm_zj_hz/storage/China-City-List-latest.xlsx differ diff --git a/storm_zj_hz/storage/writeExcel.xlsx b/storm_zj_hz/storage/writeExcel.xlsx new file mode 100644 index 0000000..23c41b4 Binary files /dev/null and b/storm_zj_hz/storage/writeExcel.xlsx differ