first commit
parent
3c207b9b1d
commit
06f7fa23f1
@ -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 "$@"
|
||||
@ -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%
|
||||
@ -0,0 +1,103 @@
|
||||
package com.rehome.jpahefengweather.controller;
|
||||
|
||||
|
||||
import com.rehome.jpahefengweather.dto.*;
|
||||
import com.rehome.jpahefengweather.entity.HefengCity;
|
||||
import com.rehome.jpahefengweather.entity.NowWeather;
|
||||
import com.rehome.jpahefengweather.service.CityService;
|
||||
import com.rehome.jpahefengweather.service.HefengWeatherService;
|
||||
import com.rehome.jpahefengweather.utils.Result;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/hefengWeather/service")
|
||||
public class HefengWeatherController {
|
||||
|
||||
@Resource
|
||||
private CityService cityService;
|
||||
@Resource
|
||||
private HefengWeatherService hefengWeatherService;
|
||||
|
||||
/**
|
||||
* @date 2022-05-01 14:42
|
||||
* @description: 获取支持天气查询的城市
|
||||
* @Param:
|
||||
*/
|
||||
@GetMapping("/getCityList")
|
||||
public Result<List<HefengCity>> getCityList(){
|
||||
return Result.of(this.cityService.findAllCity());
|
||||
}
|
||||
|
||||
//region 获取历史天气
|
||||
@PostMapping("/getNowWeatherEntity")
|
||||
// @ApiOperation(value = "获取历史天气数据", notes = "获取历史天气数据")
|
||||
// @ApiImplicitParams(value = {
|
||||
// @ApiImplicitParam(name = "dto", value = "获取历史天气处理", dataTypeClass = BaseWeatherFindDto.class, paramType = "body", required = true),
|
||||
// })
|
||||
public Result<List<NowWeather>> getNowWeatherEntity(@Validated @RequestBody BaseWeatherFindDto dto){
|
||||
List<NowWeather> weathers = this.hefengWeatherService.findNowWeatherByLocationIdAndDate(dto.getLocationId(),dto.getWeatherDate());
|
||||
return Result.of(weathers);
|
||||
}
|
||||
//endregion
|
||||
//region 获取历史天气
|
||||
@PostMapping("/getNowWeatherDto")
|
||||
// @ApiOperation(value = "获取历史天气数据", notes = "获取历史天气数据")
|
||||
// @ApiImplicitParams(value = {
|
||||
// @ApiImplicitParam(name = "dto", value = "获取历史天气处理", dataTypeClass = BaseWeatherFindDto.class, paramType = "body", required = true),
|
||||
// })
|
||||
public Result<List<NowWeatherDto>> getNowWeatherDto(@Validated @RequestBody BaseWeatherFindDto dto){
|
||||
List<NowWeatherDto> weathers = this.hefengWeatherService.findHistoryWeatherByLocationIdAndDateDto(dto.getLocationId(),dto.getWeatherDate());
|
||||
return Result.of(weathers);
|
||||
}
|
||||
//endregion
|
||||
//region 获取实时天气
|
||||
@PostMapping("/getNowWeatherDtoOne")
|
||||
// @ApiOperation(value = "获取实时天气数据", notes = "获取实时天气数据")
|
||||
// @ApiImplicitParams(value = {
|
||||
// @ApiImplicitParam(name = "dto", value = "实时天气数据处理", dataTypeClass = BaseFindDto.class, paramType = "body", required = true),
|
||||
// })
|
||||
public Result<NowWeatherDto> getNowWeatherDtoOne(@Validated @RequestBody BaseFindDto dto){
|
||||
NowWeatherDto nowWeatherDto=this.hefengWeatherService.findNowWeatherByLocationIdAndDateDto(dto.getLocationId());
|
||||
return Result.of(nowWeatherDto);
|
||||
}
|
||||
//endregion
|
||||
//region 获取历史天气
|
||||
@PostMapping("/getForecastWeatherDto")
|
||||
// @ApiOperation(value = "获取天气预报数据", notes = "获取天气预报数据")
|
||||
// @ApiImplicitParams(value = {
|
||||
// @ApiImplicitParam(name = "dto", value = "天气预报处理", dataTypeClass = BaseWeatherFindDto.class, paramType = "body", required = true),
|
||||
// })
|
||||
public Result<List<ForecastWeatherDto>> getForecastWeatherDto(@Validated @RequestBody BaseWeatherFindDto dto){
|
||||
List<ForecastWeatherDto> weathers = this.hefengWeatherService.findForecastWeatherByLocationIdAndDateDto(dto.getLocationId(),dto.getWeatherDate());
|
||||
return Result.of(weathers);
|
||||
}
|
||||
//endregion
|
||||
//region 获取本地保存的和风天气平台,实时天气和天气预报
|
||||
@PostMapping("/getHefengWeatherResultDtoByLocationIdAndDateDto")
|
||||
// @ApiOperation(value = "获取本地保存的和风天气平台,实时天气和天气预报", notes = "获取本地保存的和风天气平台,实时天气和天气预报")
|
||||
// @ApiImplicitParams(value = {
|
||||
// @ApiImplicitParam(name = "dto", value = "天气预报处理", dataTypeClass = BaseWeatherFindDto.class, paramType = "body", required = true),
|
||||
// })
|
||||
public HefengWeatherResultDto getHefengWeatherResultDtoByLocationIdAndDateDto(@Validated @RequestBody BaseWeatherFindDto dto){
|
||||
HefengWeatherResultDto hefengWeatherResultDto = this.hefengWeatherService.getHefengWeatherResultDtoByLocationIdAndDateDto(dto.getLocationId(),dto.getWeatherDate());
|
||||
return hefengWeatherResultDto;
|
||||
}
|
||||
//endregion
|
||||
//region 获取本地保存的和风天气平台,实时天气和天气预报
|
||||
@PostMapping("/getHefengWeatherResultDtoByLocationId")
|
||||
// @ApiOperation(value = "获取本地保存的和风天气平台,实时天气和天气预报", notes = "获取本地保存的和风天气平台,实时天气和天气预报")
|
||||
// @ApiImplicitParams(value = {
|
||||
// @ApiImplicitParam(name = "dto", value = "天气预报处理", dataTypeClass = BaseFindDto.class, paramType = "body", required = true),
|
||||
// })
|
||||
public HefengWeatherResultDto getHefengWeatherResultDtoByLocationId(@Validated @RequestBody BaseFindDto dto){
|
||||
String currentDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||
HefengWeatherResultDto hefengWeatherResultDto = this.hefengWeatherService.getHefengWeatherResultDtoByLocationIdAndDateDto(dto.getLocationId(),currentDate);
|
||||
return hefengWeatherResultDto;
|
||||
}
|
||||
//endregion
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
package com.rehome.jpahefengweather.controller;
|
||||
|
||||
import com.rehome.jpahefengweather.dto.TyphoonBaseDto;
|
||||
import com.rehome.jpahefengweather.dto.WztfStormInfoDto;
|
||||
import com.rehome.jpahefengweather.entity.*;
|
||||
import com.rehome.jpahefengweather.service.WztfStormService;
|
||||
import com.rehome.jpahefengweather.utils.Result;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/typhoon")
|
||||
public class WztfwStormController {
|
||||
|
||||
@Resource
|
||||
private WztfStormService wztfStormService;
|
||||
|
||||
|
||||
//endregion
|
||||
//region 根据年份获取台风列表
|
||||
@PostMapping("/getWztfStormListByYear")
|
||||
// @ApiOperation(value = "获取台风列表", notes = "获取台风列表")
|
||||
// @ApiImplicitParams(value = {
|
||||
// @ApiImplicitParam(name = "dto", value = "获取台风列表", dataTypeClass = TyphoonBaseDto.class, paramType = "body", required = true),
|
||||
// })
|
||||
public Result<List<WztfStorm>> 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<WztfStormInfo> getWztfStormInfoByTfbh(@Validated @RequestBody WztfStormInfoDto dto){
|
||||
return Result.of(this.wztfStormService.findWztfStormInfoByTfbh(dto.getTfbh()));
|
||||
}
|
||||
//endregion
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.rehome.jpahefengweather.dao;
|
||||
|
||||
import com.rehome.jpahefengweather.entity.HefengCity;
|
||||
import com.rehome.jpahefengweather.entity.HefengRealtimeWeather;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
* 参数一 T :当前需要映射的实体
|
||||
* 参数二 ID :当前映射的实体中的OID的类型
|
||||
*
|
||||
*/
|
||||
public interface HefengRealtimeWeatherRepository extends JpaRepository<HefengRealtimeWeather,Long> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.rehome.jpahefengweather.dto;
|
||||
|
||||
|
||||
import com.rehome.jpahefengweather.utils.MapUtil;
|
||||
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<String, Object> map) {
|
||||
return MapUtil.fromMap(map, BaseFindDto.class);
|
||||
}
|
||||
|
||||
public String getLocationId() {
|
||||
return locationId;
|
||||
}
|
||||
|
||||
public void setLocationId(String locationId) {
|
||||
this.locationId = locationId;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.rehome.jpahefengweather.dto;
|
||||
|
||||
|
||||
import com.rehome.jpahefengweather.utils.MapUtil;
|
||||
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<String, Object> map) {
|
||||
return MapUtil.fromMap(map, BaseWeatherFindDto.class);
|
||||
}
|
||||
|
||||
public String getWeatherDate() {
|
||||
return weatherDate;
|
||||
}
|
||||
|
||||
public void setWeatherDate(String weatherDate) {
|
||||
this.weatherDate = weatherDate;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,299 @@
|
||||
package com.rehome.jpahefengweather.dto;
|
||||
|
||||
|
||||
|
||||
import com.rehome.jpahefengweather.utils.MapUtil;
|
||||
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<String, Object> 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;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package com.rehome.jpahefengweather.dto;
|
||||
|
||||
|
||||
|
||||
import com.rehome.jpahefengweather.utils.MapUtil;
|
||||
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<ForecastDto> 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<String, Object> map) {
|
||||
return MapUtil.fromMap(map, ForecastWeatherDto.class);
|
||||
}
|
||||
|
||||
public List<ForecastDto> getDaily() {
|
||||
return daily;
|
||||
}
|
||||
|
||||
public void setDaily(List<ForecastDto> daily) {
|
||||
this.daily = daily;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.rehome.jpahefengweather.dto;
|
||||
|
||||
import com.rehome.jpahefengweather.entity.HefengFutureWeather;
|
||||
import com.rehome.jpahefengweather.entity.HefengRealtimeWeather;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HefengFutureWeatherDto {
|
||||
//状态码
|
||||
private String code;
|
||||
//当前API的最近更新时间
|
||||
private String updateTime;
|
||||
//当前数据的响应式页面,便于嵌入网站或应用
|
||||
private String fxLink ;
|
||||
//每日天气预报
|
||||
private List<HefengFutureWeather> daily;
|
||||
//数据来源,可能为空
|
||||
private HefengWeatherRefer refer;
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.rehome.jpahefengweather.dto;
|
||||
|
||||
import com.rehome.jpahefengweather.entity.HefengRealtimeWeather;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HefengRealtimeWeatherDto {
|
||||
//状态码
|
||||
private String code;
|
||||
//当前API的最近更新时间
|
||||
private String updateTime;
|
||||
//当前数据的响应式页面,便于嵌入网站或应用
|
||||
private String fxLink ;
|
||||
//实时天气
|
||||
private HefengRealtimeWeather now;
|
||||
//数据来源,可能为空
|
||||
private HefengWeatherRefer refer;
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.rehome.jpahefengweather.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HefengWeatherRefer {
|
||||
|
||||
//原始数据来源,或数据源说明,可能为空
|
||||
private List<String> sources;
|
||||
|
||||
// 数据许可或版权声明,可能为空
|
||||
private List<String> license;
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.rehome.jpahefengweather.dto;
|
||||
|
||||
import com.rehome.jpahefengweather.entity.HefengFutureWeather;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@Data
|
||||
public class HefengWeatherResultDto extends HefengRealtimeWeatherDto{
|
||||
//每日天气预报
|
||||
private List<HefengFutureWeather> daily;
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.rehome.jpahefengweather.dto;
|
||||
|
||||
|
||||
import com.rehome.jpahefengweather.utils.MapUtil;
|
||||
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<List<String>> 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<String, Object> map) {
|
||||
return MapUtil.fromMap(map, NmcForecastWeatherDto.class);
|
||||
}
|
||||
|
||||
public List<List<String>> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(List<List<String>> data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.rehome.jpahefengweather.dto;
|
||||
|
||||
import com.rehome.jpahefengweather.dto.bean.NmcNowData;
|
||||
import com.rehome.jpahefengweather.utils.MapUtil;
|
||||
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<String, Object> map) {
|
||||
return MapUtil.fromMap(map, NmcNowWeatherDto.class);
|
||||
}
|
||||
|
||||
public NmcNowData getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(NmcNowData data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,177 @@
|
||||
package com.rehome.jpahefengweather.dto;
|
||||
|
||||
|
||||
import com.rehome.jpahefengweather.utils.MapUtil;
|
||||
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<String, Object> 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;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.rehome.jpahefengweather.dto;
|
||||
|
||||
|
||||
import com.rehome.jpahefengweather.utils.MapUtil;
|
||||
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<String, Object> map) {
|
||||
return MapUtil.fromMap(map, NowWeatherDto.class);
|
||||
}
|
||||
|
||||
public NowDto getNow() {
|
||||
return now;
|
||||
}
|
||||
|
||||
public void setNow(NowDto now) {
|
||||
this.now = now;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package com.rehome.jpahefengweather.dto;
|
||||
|
||||
|
||||
import com.rehome.jpahefengweather.utils.MapUtil;
|
||||
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<List<String>> 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<String, Object> map) {
|
||||
return MapUtil.fromMap(map, StormDataDto.class);
|
||||
}
|
||||
|
||||
public List<List<String>> getTyphoonList() {
|
||||
return typhoonList;
|
||||
}
|
||||
|
||||
public void setTyphoonList(List<List<String>> typhoonList) {
|
||||
this.typhoonList = typhoonList;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,188 @@
|
||||
package com.rehome.jpahefengweather.dto;
|
||||
|
||||
|
||||
import com.rehome.jpahefengweather.utils.MapUtil;
|
||||
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<String, Object> 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;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package com.rehome.jpahefengweather.dto;
|
||||
|
||||
|
||||
|
||||
import com.rehome.jpahefengweather.utils.MapUtil;
|
||||
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<String, Object> map) {
|
||||
return MapUtil.fromMap(map, TyphoonBaseDto.class);
|
||||
}
|
||||
|
||||
public String getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
public void setYear(String year) {
|
||||
this.year = year;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.rehome.jpahefengweather.dto;
|
||||
|
||||
|
||||
import com.rehome.jpahefengweather.utils.MapUtil;
|
||||
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<String, Object> map) {
|
||||
return MapUtil.fromMap(map, TyphoonTfidDto.class);
|
||||
}
|
||||
|
||||
public String getTfid() {
|
||||
return tfid;
|
||||
}
|
||||
|
||||
public void setTfid(String tfid) {
|
||||
this.tfid = tfid;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.rehome.jpahefengweather.dto;
|
||||
|
||||
|
||||
import com.rehome.jpahefengweather.utils.MapUtil;
|
||||
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<String, Object> map) {
|
||||
return MapUtil.fromMap(map, WztfStormInfoDto.class);
|
||||
}
|
||||
|
||||
public String getTfbh() {
|
||||
return tfbh;
|
||||
}
|
||||
|
||||
public void setTfbh(String tfbh) {
|
||||
this.tfbh = tfbh;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
package com.rehome.jpahefengweather.dto.bean;
|
||||
|
||||
public class NmcForecastData {
|
||||
}
|
||||
@ -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> tempchart;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package com.rehome.jpahefengweather.entity;
|
||||
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
//@Table(name="t_users")
|
||||
public class ForecastWeather implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String locationId;
|
||||
|
||||
private String province;
|
||||
|
||||
private String city ;
|
||||
|
||||
private String locationNameZh;
|
||||
|
||||
//存放长文本
|
||||
@Column(columnDefinition = "TEXT")
|
||||
private String weather;
|
||||
|
||||
private String weatherDate;
|
||||
|
||||
// @CreatedDate
|
||||
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate;
|
||||
|
||||
// @LastModifiedDate
|
||||
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastUpdateDate;
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package com.rehome.jpahefengweather.entity;
|
||||
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Temporal;
|
||||
import jakarta.persistence.TemporalType;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class HefengCity implements Serializable {
|
||||
// 区、县位置id
|
||||
@Id
|
||||
private String locationId;
|
||||
//区、县位置 英文名称
|
||||
private String locationNameEn;
|
||||
//区、县位置 中文名称
|
||||
private String locationNameZh;
|
||||
//ISO_3166_1 国家编码
|
||||
private String countryCode;
|
||||
//国家英文名称
|
||||
private String countryNameEn ;
|
||||
//国家中文名称
|
||||
private String countryNameZh ;
|
||||
//省份英文名称
|
||||
private String adm1NameEn;
|
||||
//省份中文名称
|
||||
private String adm1NameZh;
|
||||
//城市英文名称
|
||||
private String adm2NameEn;
|
||||
//城市中文名称
|
||||
private String adm2NameZh ;
|
||||
//时区
|
||||
private String timezone ;
|
||||
//纬度
|
||||
private String latitude;
|
||||
//经度
|
||||
private String longitude;
|
||||
//区、县位置编码(仅限中国城市))
|
||||
private String adcode;
|
||||
|
||||
// @CreatedDate
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate;
|
||||
|
||||
// @LastModifiedDate
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastUpdateDate;
|
||||
}
|
||||
@ -0,0 +1,150 @@
|
||||
package com.rehome.jpahefengweather.entity;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(indexes = {@Index(name = "idx_location_id_future", columnList = "locationId")})
|
||||
public class HefengFutureWeather {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(length=20)
|
||||
private String locationId;
|
||||
|
||||
@Column(length=20)
|
||||
private String province;
|
||||
|
||||
@Column(length=20)
|
||||
private String city ;
|
||||
|
||||
@Column(length=20)
|
||||
private String locationNameZh;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createTime;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updateTime;
|
||||
|
||||
//预报日期
|
||||
@Column(length=20)
|
||||
private String fxDate ;
|
||||
//日出时间,在高纬度地区可能为空
|
||||
@Column(length=20)
|
||||
private String sunrise ;
|
||||
//日落时间,在高纬度地区可能为空
|
||||
@Column(length=20)
|
||||
private String sunset ;
|
||||
@Column(length=20)
|
||||
//当天月升时间,可能为空
|
||||
private String moonrise ;
|
||||
@Column(length=20)
|
||||
//当天月落时间,可能为空
|
||||
private String moonset ;
|
||||
@Column(length=20)
|
||||
// 月相名称
|
||||
private String moonPhase ;
|
||||
@Column(length=20)
|
||||
//月相图标代码,另请参考天气图标项目
|
||||
private String moonPhaseIcon ;
|
||||
@Column(length=20)
|
||||
//预报当天最高温度
|
||||
private double tempMax ;
|
||||
//预报当天最低温度
|
||||
private double tempMin ;
|
||||
@Column(length=20)
|
||||
//预报白天天气状况的图标代码,另请参考天气图标项目
|
||||
private String iconDay ;
|
||||
@Column(length=20)
|
||||
//预报白天天气状况文字描述,包括阴晴雨雪等天气状态的描述
|
||||
private String textDay ;
|
||||
@Column(length=20)
|
||||
//预报夜间天气状况的图标代码,另请参考天气图标项目
|
||||
private String iconNight ;
|
||||
@Column(length=20)
|
||||
//预报晚间天气状况文字描述,包括阴晴雨雪等天气状态的描述
|
||||
private String textNight ;
|
||||
@Column(length=20)
|
||||
//预报白天风向360角度
|
||||
private String wind360Day ;
|
||||
@Column(length=20)
|
||||
//预报白天风向
|
||||
private String windDirDay ;
|
||||
@Column(length=20)
|
||||
//预报白天风力等级
|
||||
private String windScaleDay ;
|
||||
@Column(length=20)
|
||||
//预报白天风速,公里/小时
|
||||
private String windSpeedDay ;
|
||||
@Column(length=20)
|
||||
//预报夜间风向360角度
|
||||
private String wind360Night ;
|
||||
@Column(length=20)
|
||||
//预报夜间当天风向
|
||||
private String windDirNight ;
|
||||
@Column(length=20)
|
||||
//预报夜间风力等级
|
||||
private String windScaleNight ;
|
||||
@Column(length=20)
|
||||
//预报夜间风速,公里/小时
|
||||
private String windSpeedNight ;
|
||||
@Column(length=20)
|
||||
//相对湿度,百分比数值
|
||||
private double humidity ;
|
||||
@Column(length=20)
|
||||
//预报当天总降水量,默认单位:毫米
|
||||
private String precip ;
|
||||
@Column(length=20)
|
||||
//大气压强,默认单位:百帕
|
||||
private String pressure ;
|
||||
@Column(length=20)
|
||||
//能见度,默认单位:公里
|
||||
private String vis ;
|
||||
@Column(length=20)
|
||||
//云量,百分比数值。可能为空
|
||||
private String cloud ;
|
||||
//紫外线强度指数
|
||||
@Column(length=20)
|
||||
private String uvIndex ;
|
||||
//当前数据的响应式页面,便于嵌入网站或应用
|
||||
@Column(length=100)
|
||||
private String fxLink ;
|
||||
}
|
||||
|
||||
// code 请参考状态码
|
||||
// updateTime 当前API的最近更新时间
|
||||
// fxLink 当前数据的响应式页面,便于嵌入网站或应用
|
||||
// daily.fxDate 预报日期
|
||||
// daily.sunrise 日出时间,在高纬度地区可能为空
|
||||
// daily.sunset 日落时间,在高纬度地区可能为空
|
||||
// daily.moonrise 当天月升时间,可能为空
|
||||
// daily.moonset 当天月落时间,可能为空
|
||||
// daily.moonPhase 月相名称
|
||||
// daily.moonPhaseIcon 月相图标代码,另请参考天气图标项目
|
||||
// daily.tempMax 预报当天最高温度
|
||||
// daily.tempMin 预报当天最低温度
|
||||
// daily.iconDay 预报白天天气状况的图标代码,另请参考天气图标项目
|
||||
// daily.textDay 预报白天天气状况文字描述,包括阴晴雨雪等天气状态的描述
|
||||
// daily.iconNight 预报夜间天气状况的图标代码,另请参考天气图标项目
|
||||
// daily.textNight 预报晚间天气状况文字描述,包括阴晴雨雪等天气状态的描述
|
||||
// daily.wind360Day 预报白天风向360角度
|
||||
// daily.windDirDay 预报白天风向
|
||||
// daily.windScaleDay 预报白天风力等级
|
||||
// daily.windSpeedDay 预报白天风速,公里/小时
|
||||
// daily.wind360Night 预报夜间风向360角度
|
||||
// daily.windDirNight 预报夜间当天风向
|
||||
// daily.windScaleNight 预报夜间风力等级
|
||||
// daily.windSpeedNight 预报夜间风速,公里/小时
|
||||
// daily.precip 预报当天总降水量,默认单位:毫米
|
||||
// daily.uvIndex 紫外线强度指数
|
||||
// daily.humidity 相对湿度,百分比数值
|
||||
// daily.pressure 大气压强,默认单位:百帕
|
||||
// daily.vis 能见度,默认单位:公里
|
||||
// daily.cloud 云量,百分比数值。可能为空
|
||||
// refer.sources 原始数据来源,或数据源说明,可能为空
|
||||
// refer.license 数据许可或版权声明,可能为空
|
||||
@ -0,0 +1,27 @@
|
||||
package com.rehome.jpahefengweather.entity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Temporal;
|
||||
import jakarta.persistence.TemporalType;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class HefengProvince implements Serializable{
|
||||
//省份编号
|
||||
@Id
|
||||
private String code;
|
||||
//省份中文名称
|
||||
private String name;
|
||||
//url
|
||||
private String url;
|
||||
//创建时间
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate;
|
||||
//最后一次更新时间
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastUpdateDate;
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.rehome.jpahefengweather.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class NmcCity implements Serializable{
|
||||
@Id
|
||||
private String code;
|
||||
|
||||
private String province;
|
||||
|
||||
private String city;
|
||||
|
||||
private String url;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastUpdateDate;
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package com.rehome.jpahefengweather.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@Proxy(lazy = false)
|
||||
@Data
|
||||
@Entity
|
||||
public class NmcForecastWeather implements Serializable{
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
//存放长文本
|
||||
@Lob
|
||||
@Basic(fetch=FetchType.LAZY)
|
||||
private String weather;
|
||||
|
||||
private String weatherDate;
|
||||
|
||||
private String code;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastUpdateDate;
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.rehome.jpahefengweather.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class NmcNowWeather implements Serializable{
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
//存放长文本
|
||||
@Column(columnDefinition = "TEXT")
|
||||
private String weather;
|
||||
|
||||
private String weatherDate;
|
||||
|
||||
private String code;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastUpdateDate;
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.rehome.jpahefengweather.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class NmcProvince implements Serializable{
|
||||
@Id
|
||||
private String code;
|
||||
|
||||
private String name;
|
||||
|
||||
private String url;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastUpdateDate;
|
||||
}
|
||||
//1655455805800
|
||||
//1655455830002
|
||||
@ -0,0 +1,42 @@
|
||||
package com.rehome.jpahefengweather.entity;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class NmcStorm implements Serializable {
|
||||
@Id
|
||||
private Long code;
|
||||
|
||||
//台风接入平台
|
||||
private String ename;
|
||||
|
||||
//台风名称
|
||||
private String name ;
|
||||
|
||||
//台风编号
|
||||
private Long tfNo ;
|
||||
|
||||
//台风编号字符串
|
||||
private String tfNoString ;
|
||||
|
||||
//台风描述
|
||||
private String nameDesc;
|
||||
|
||||
//是否为活跃台风 1:活跃台风 0:台风已停止
|
||||
private Long isActive ;
|
||||
|
||||
//台风所处年份
|
||||
private String year ;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastUpdateDate;
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.rehome.jpahefengweather.entity;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
//@Table(name="t_users")
|
||||
public class NowWeather implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
private String locationId;
|
||||
|
||||
private String province;
|
||||
|
||||
private String city ;
|
||||
|
||||
private String locationNameZh;
|
||||
|
||||
//存放长文本
|
||||
@Column(columnDefinition = "TEXT")
|
||||
private String weather;
|
||||
|
||||
private String weatherDate;
|
||||
|
||||
// @CreatedDate
|
||||
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate;
|
||||
|
||||
// @LastModifiedDate
|
||||
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastUpdateDate;
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.rehome.jpahefengweather.entity;
|
||||
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class TyphoonInfo implements Serializable {
|
||||
@Id
|
||||
private String tfid;
|
||||
|
||||
//存放长文本
|
||||
@Column(columnDefinition = "TEXT")
|
||||
private String stormData;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastUpdateDate;
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.rehome.jpahefengweather.entity;
|
||||
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.rehome.jpahefengweather.entity;
|
||||
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class WztfStormInfo implements Serializable {
|
||||
@Id
|
||||
private String tfbh;
|
||||
|
||||
//存放长文本
|
||||
@Column(columnDefinition = "TEXT")
|
||||
private String stormData;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate;
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastUpdateDate;
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package com.rehome.jpahefengweather.entity;
|
||||
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import jakarta.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
package com.rehome.jpahefengweather.service;
|
||||
|
||||
import com.rehome.jpahefengweather.entity.HefengCity;
|
||||
import com.rehome.jpahefengweather.entity.HefengProvince;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CityService {
|
||||
/**
|
||||
* 保存省份列表
|
||||
* @param provinceList
|
||||
*/
|
||||
void saveProvinceList(List<HefengProvince> provinceList);
|
||||
/**
|
||||
* 保存城市列表
|
||||
* @param cityList
|
||||
*/
|
||||
void saveCityList(List<HefengCity> cityList);
|
||||
/**
|
||||
* 查询全国3000+个市县区
|
||||
* @return List
|
||||
*/
|
||||
List<HefengCity> findAllCity();
|
||||
/**
|
||||
* 省份编号查城市列表
|
||||
* @return List
|
||||
*/
|
||||
List<HefengCity> findCityByProvinceCode(String provinceCode);
|
||||
/**
|
||||
* 城市编号查区县和城市列表
|
||||
* @return List
|
||||
*/
|
||||
List<HefengCity> findCityByCityCode(String cityCode);
|
||||
/**
|
||||
* 区、县位置 英文名称查区县和城市列表
|
||||
* @return List
|
||||
*/
|
||||
List<HefengCity> findByLocationNameEn(String locationNameEn);
|
||||
/**
|
||||
* 查询全国3000+个市县区
|
||||
* @return List
|
||||
*/
|
||||
List<HefengProvince> findAllProvince();
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
package com.rehome.jpahefengweather.service.Impl;
|
||||
|
||||
import com.rehome.jpahefengweather.dao.CityRepository;
|
||||
import com.rehome.jpahefengweather.dao.ProvinceRepository;
|
||||
import com.rehome.jpahefengweather.entity.HefengCity;
|
||||
import com.rehome.jpahefengweather.entity.HefengProvince;
|
||||
import com.rehome.jpahefengweather.service.CityService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CityServiceImpl implements CityService {
|
||||
@Resource
|
||||
private CityRepository cityRepository;
|
||||
|
||||
@Resource
|
||||
private ProvinceRepository provinceRepository;
|
||||
|
||||
@Override
|
||||
public void saveProvinceList(List<HefengProvince> provinceList) {
|
||||
Date nowTime = new Date();
|
||||
for (HefengProvince province : provinceList) {
|
||||
HefengProvince provinceDb = this.provinceRepository.findByCode(province.getCode());
|
||||
if (provinceDb != null) {
|
||||
provinceDb.setName(province.getName());
|
||||
provinceDb.setLastUpdateDate(nowTime);
|
||||
this.provinceRepository.save(provinceDb);
|
||||
}else{
|
||||
province.setLastUpdateDate(nowTime);
|
||||
province.setCreateDate(nowTime);
|
||||
this.provinceRepository.save(province);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveCityList(List<HefengCity> cityList) {
|
||||
Date now = new Date();
|
||||
for (HefengCity city : cityList) {
|
||||
HefengCity cityDB = this.cityRepository.findByLocationId(city.getLocationId());
|
||||
if (cityDB != null) {
|
||||
cityDB.setLocationNameEn(city.getLocationNameEn());
|
||||
cityDB.setLocationNameZh(city.getLocationNameZh());
|
||||
cityDB.setCountryCode(city.getCountryCode());
|
||||
cityDB.setCountryNameEn(city.getCountryNameEn());
|
||||
cityDB.setCountryNameZh(city.getCountryNameZh());
|
||||
cityDB.setAdm1NameEn(city.getAdm1NameEn());
|
||||
cityDB.setAdm1NameZh(city.getAdm1NameZh());
|
||||
cityDB.setAdm2NameEn(city.getAdm2NameEn());
|
||||
cityDB.setAdm2NameZh(city.getAdm2NameZh());
|
||||
cityDB.setTimezone(city.getTimezone());
|
||||
cityDB.setLatitude(city.getLatitude());
|
||||
cityDB.setLongitude(city.getLongitude());
|
||||
cityDB.setAdcode(city.getAdcode());
|
||||
cityDB.setLastUpdateDate(now);
|
||||
this.cityRepository.save(cityDB);
|
||||
} else {
|
||||
city.setLastUpdateDate(now);
|
||||
city.setCreateDate(now);
|
||||
this.cityRepository.save(city);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HefengCity> findAllCity() {
|
||||
return this.cityRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HefengCity> findCityByProvinceCode(String provinceCode) {
|
||||
return this.cityRepository.findByAdm1NameEn(provinceCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HefengCity> findCityByCityCode(String cityCode) {
|
||||
return this.cityRepository.findByAdm2NameEn(cityCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HefengCity> findByLocationNameEn(String locationNameEn) {
|
||||
return this.cityRepository.findByLocationNameEn(locationNameEn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HefengProvince> findAllProvince() {
|
||||
return this.provinceRepository.findAll();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,282 @@
|
||||
package com.rehome.jpahefengweather.service.Impl;
|
||||
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.rehome.jpahefengweather.dao.ForecastWeatherRepository;
|
||||
import com.rehome.jpahefengweather.dao.HefengFutureWeatherRepository;
|
||||
import com.rehome.jpahefengweather.dao.HefengRealtimeWeatherRepository;
|
||||
import com.rehome.jpahefengweather.dao.NowWeatherRepository;
|
||||
import com.rehome.jpahefengweather.dto.*;
|
||||
import com.rehome.jpahefengweather.entity.*;
|
||||
import com.rehome.jpahefengweather.service.CityService;
|
||||
import com.rehome.jpahefengweather.service.HefengWeatherService;
|
||||
import com.rehome.jpahefengweather.utils.OkHttpUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@Service
|
||||
public class HefengWeatherServiceImpl implements HefengWeatherService {
|
||||
private Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Resource
|
||||
private NowWeatherRepository nowWeatherRepository;
|
||||
@Resource
|
||||
private ForecastWeatherRepository forecastWeatherRepository;
|
||||
@Resource
|
||||
private HefengRealtimeWeatherRepository hefengRealtimeWeatherRepository;
|
||||
@Resource
|
||||
private HefengFutureWeatherRepository hefengFutureWeatherRepository;
|
||||
|
||||
@Resource
|
||||
private CityService cityService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<NowWeather> findNowWeatherByLocationIdAndDate(String locationId, String date) {
|
||||
return this.nowWeatherRepository.findByLocationIdAndWeatherDateOrderByIdDesc(locationId,date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NowWeather> findNowWeatherByLocationIdAndDateOrderByCreateDateDesc(String locationId, String date) {
|
||||
return this.nowWeatherRepository.findByLocationIdAndWeatherDateOrderByIdDesc(locationId,date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveNowWeather(NowWeather nowWeather) {
|
||||
this.nowWeatherRepository.save(nowWeather);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveHefengWeatherByLocationNameEn(String locationNameEn) {
|
||||
List<HefengCity> cityList = this.cityService.findByLocationNameEn(locationNameEn);
|
||||
log.info(new Gson().toJson(cityList));
|
||||
log.info("查询实时天气总数:"+String.valueOf(cityList.size()));
|
||||
if (cityList != null && cityList.size() > 0) {
|
||||
Date now = new Date();
|
||||
log.info(String.valueOf(cityList.size()));
|
||||
for (int i = 0; i < cityList.size(); i++) {
|
||||
HefengCity city = cityList.get(i);
|
||||
Map<String, String> params = new HashMap<>();
|
||||
//我的帐号: c67db396fcdb416c959933d29e30db3d
|
||||
//克金帐号: 3522d7d5736947d7a63e8d7d95316406
|
||||
//params.put("key", "c67db396fcdb416c959933d29e30db3d");
|
||||
params.put("location", city.getLocationId());
|
||||
String realtimeWeatherData = OkHttpUtil.get("https://m573jftdb9.re.qweatherapi.com/v7/weather/now", params);
|
||||
log.info(realtimeWeatherData);
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (realtimeWeatherData!=null&&realtimeWeatherData.trim().length()>0) {
|
||||
SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy");
|
||||
SimpleDateFormat sdfYearMonth = new SimpleDateFormat("yyyy-MM");
|
||||
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
|
||||
NowWeather nowWeather = new NowWeather();
|
||||
nowWeather.setWeatherDate(sdfDate.format(now));
|
||||
nowWeather.setLocationId(city.getLocationId());
|
||||
nowWeather.setWeather(realtimeWeatherData);
|
||||
nowWeather.setCreateDate(now);
|
||||
nowWeather.setLastUpdateDate(now);
|
||||
nowWeather.setProvince(city.getAdm1NameZh());
|
||||
nowWeather.setCity(city.getAdm2NameZh());
|
||||
nowWeather.setLocationNameZh(city.getLocationNameZh());
|
||||
this.saveNowWeather(nowWeather);
|
||||
|
||||
Gson gson = new Gson();
|
||||
HefengRealtimeWeatherDto hefengRealtimeWeatherDto = gson.fromJson(realtimeWeatherData,HefengRealtimeWeatherDto.class);
|
||||
if((!ObjectUtils.isEmpty(hefengRealtimeWeatherDto))&&"200".equals(hefengRealtimeWeatherDto.getCode())){
|
||||
log.info("----------");
|
||||
log.info(gson.toJson(hefengRealtimeWeatherDto));
|
||||
HefengRealtimeWeather realtimeWeather = hefengRealtimeWeatherDto.getNow();
|
||||
if(!ObjectUtils.isEmpty(realtimeWeather)){
|
||||
realtimeWeather.setLocationId(city.getLocationId());
|
||||
realtimeWeather.setProvince(city.getAdm1NameZh());
|
||||
realtimeWeather.setCity(city.getAdm2NameZh());
|
||||
realtimeWeather.setLocationNameZh(city.getLocationNameZh());
|
||||
realtimeWeather.setCreateTime(now);
|
||||
|
||||
realtimeWeather.setFxLink(hefengRealtimeWeatherDto.getFxLink());
|
||||
realtimeWeather.setYear(sdfYear.format(now));
|
||||
realtimeWeather.setYearAndMonth(sdfYearMonth.format(now));
|
||||
realtimeWeather.setDate(sdfDate.format(now));
|
||||
hefengRealtimeWeatherRepository.save(realtimeWeather);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.info("-->");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveHefengFutureWeatherByLocationNameEn(String locationNameEn) {
|
||||
List<HefengCity> cityList = this.cityService.findByLocationNameEn(locationNameEn);
|
||||
log.info(new Gson().toJson(cityList));
|
||||
log.info("查询天气预报总数:"+String.valueOf(cityList.size()));
|
||||
if (cityList != null && cityList.size() > 0) {
|
||||
Date now = new Date();
|
||||
log.info(String.valueOf(cityList.size()));
|
||||
for (int i = 0; i < cityList.size(); i++) {
|
||||
HefengCity city = cityList.get(i);
|
||||
Map<String, String> params = new HashMap<>();
|
||||
//c67db396fcdb416c959933d29e30db3d
|
||||
//params.put("key", "c67db396fcdb416c959933d29e30db3d");
|
||||
params.put("location", city.getLocationId());
|
||||
String futureWeatherData = OkHttpUtil.get("https://m573jftdb9.re.qweatherapi.com/v7/weather/7d", params);
|
||||
log.info(futureWeatherData);
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (futureWeatherData!=null&&futureWeatherData.trim().length()>0) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
ForecastWeather forecastWeather = new ForecastWeather();
|
||||
forecastWeather.setWeatherDate(sdf.format(now));
|
||||
forecastWeather.setLocationId(city.getLocationId());
|
||||
forecastWeather.setWeather(futureWeatherData);
|
||||
forecastWeather.setLastUpdateDate(now);
|
||||
forecastWeather.setCreateDate(now);
|
||||
forecastWeather.setProvince(city.getAdm1NameZh());
|
||||
forecastWeather.setCity(city.getAdm2NameZh());
|
||||
forecastWeather.setLocationNameZh(city.getLocationNameZh());
|
||||
this.saveForecastWeather(forecastWeather);
|
||||
|
||||
Gson gson = new Gson();
|
||||
HefengFutureWeatherDto hefengFutureWeatherDto = gson.fromJson(futureWeatherData, HefengFutureWeatherDto.class);
|
||||
if((!ObjectUtils.isEmpty(hefengFutureWeatherDto))&&"200".equals(hefengFutureWeatherDto.getCode())){
|
||||
log.info("----------");
|
||||
log.info(gson.toJson(hefengFutureWeatherDto));
|
||||
List<HefengFutureWeather> dailyHefengFutureWeather = hefengFutureWeatherDto.getDaily();
|
||||
if(!ObjectUtils.isEmpty(dailyHefengFutureWeather)){
|
||||
for(HefengFutureWeather daily:dailyHefengFutureWeather){
|
||||
HefengFutureWeather dailyDB = this.hefengFutureWeatherRepository.findByLocationIdAndFxDate(city.getLocationId(),daily.getFxDate());
|
||||
if(dailyDB==null){
|
||||
daily.setLocationId(city.getLocationId());
|
||||
daily.setProvince(city.getAdm1NameZh());
|
||||
daily.setCity(city.getAdm2NameZh());
|
||||
daily.setLocationNameZh(city.getLocationNameZh());
|
||||
daily.setCreateTime(now);
|
||||
|
||||
daily.setUpdateTime(now);
|
||||
daily.setFxLink(hefengFutureWeatherDto.getFxLink());
|
||||
hefengFutureWeatherRepository.save(daily);
|
||||
log.info("-----和风天气预报数据保存成功-----");
|
||||
log.info(gson.toJson(daily));
|
||||
}else{
|
||||
daily.setId(dailyDB.getId());
|
||||
daily.setLocationId(city.getLocationId());
|
||||
daily.setProvince(city.getAdm1NameZh());
|
||||
daily.setCity(city.getAdm2NameZh());
|
||||
daily.setLocationNameZh(city.getLocationNameZh());
|
||||
|
||||
daily.setCreateTime(dailyDB.getCreateTime());
|
||||
daily.setUpdateTime(now);
|
||||
daily.setFxLink(hefengFutureWeatherDto.getFxLink());
|
||||
hefengFutureWeatherRepository.save(daily);
|
||||
log.info("-----和风天气预报数据更新成功-----");
|
||||
log.info(gson.toJson(daily));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.info("-->");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ForecastWeather> findForecastWeatherByLocationIdAndDate(String locationId, String date) {
|
||||
return this.forecastWeatherRepository.findByLocationIdAndWeatherDate(locationId,date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ForecastWeather> findForecastWeatherByLocationIdAndDateOrderByCreateDateDesc(String locationId, String date) {
|
||||
return this.forecastWeatherRepository.findByLocationIdAndWeatherDateOrderByIdDesc(locationId,date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveForecastWeather(ForecastWeather forecastWeather) {
|
||||
this.forecastWeatherRepository.save(forecastWeather);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NowWeatherDto findNowWeatherByLocationIdAndDateDto(String locationId) {
|
||||
SimpleDateFormat sdFormat=new SimpleDateFormat("yyyy-MM-dd");
|
||||
String now = sdFormat.format(new Date());
|
||||
List<NowWeather> nowWeatherList = this.nowWeatherRepository.findByLocationIdAndWeatherDateOrderByIdDesc(locationId,now);
|
||||
if(nowWeatherList!=null&&nowWeatherList.size()>0){
|
||||
NowWeather nowWeather=nowWeatherList.get(0);
|
||||
Gson gson = new Gson();
|
||||
NowWeatherDto nowWeatherDto = gson.fromJson(nowWeather.getWeather(),NowWeatherDto.class);
|
||||
return nowWeatherDto;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NowWeatherDto> findHistoryWeatherByLocationIdAndDateDto(String locationId, String date) {
|
||||
List<NowWeather> weathers = this.findNowWeatherByLocationIdAndDateOrderByCreateDateDesc(locationId,date);
|
||||
if(weathers!=null&&weathers.size()>0){
|
||||
List<NowWeatherDto> dtos = new ArrayList<>();
|
||||
for (NowWeather weather:weathers) {
|
||||
Gson gson = new Gson();
|
||||
NowWeatherDto nowWeatherDto = gson.fromJson(weather.getWeather(),NowWeatherDto.class);
|
||||
dtos.add(nowWeatherDto);
|
||||
}
|
||||
return dtos;
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ForecastWeatherDto> findForecastWeatherByLocationIdAndDateDto(String locationId, String date) {
|
||||
List<ForecastWeather> weathers = this.findForecastWeatherByLocationIdAndDateOrderByCreateDateDesc(locationId,date);
|
||||
if(weathers!=null&&weathers.size()>0){
|
||||
List<ForecastWeatherDto> dtos = new ArrayList<>();
|
||||
for (ForecastWeather weather:weathers) {
|
||||
Gson gson = new Gson();
|
||||
ForecastWeatherDto forecastWeatherDto = gson.fromJson(weather.getWeather(),ForecastWeatherDto.class);
|
||||
dtos.add(forecastWeatherDto);
|
||||
}
|
||||
return dtos;
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HefengWeatherResultDto getHefengWeatherResultDtoByLocationIdAndDateDto(String locationId, String date) {
|
||||
NowWeatherDto nowWeatherDto=this.findNowWeatherByLocationIdAndDateDto(locationId);
|
||||
//System.out.println(new Gson().toJson(nowWeatherDto));
|
||||
if(nowWeatherDto!=null){
|
||||
Gson gson = new Gson();
|
||||
String nowWeatherDtoStr = gson.toJson(nowWeatherDto);
|
||||
HefengWeatherResultDto hefengWeatherResultDto=gson.fromJson(nowWeatherDtoStr,HefengWeatherResultDto.class);
|
||||
//System.out.println("-----------hefengWeatherResultDto------------");
|
||||
//System.out.println(new Gson().toJson(hefengWeatherResultDto));
|
||||
|
||||
List<ForecastWeatherDto> forecastWeatherDtoList=this.findForecastWeatherByLocationIdAndDateDto(locationId,date);
|
||||
//System.out.println(new Gson().toJson(forecastWeatherDtoList));
|
||||
|
||||
if(forecastWeatherDtoList!=null&&forecastWeatherDtoList.size()>0){
|
||||
String futureWeatherData = gson.toJson(forecastWeatherDtoList.get(0));
|
||||
HefengFutureWeatherDto hefengFutureWeatherDto = gson.fromJson(futureWeatherData, HefengFutureWeatherDto.class);
|
||||
if(hefengFutureWeatherDto!=null){
|
||||
hefengWeatherResultDto.setDaily(hefengFutureWeatherDto.getDaily());
|
||||
return hefengWeatherResultDto;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package com.rehome.jpahefengweather.service.Impl;
|
||||
|
||||
|
||||
import com.rehome.jpahefengweather.dao.NmcCityRepository;
|
||||
import com.rehome.jpahefengweather.dao.NmcProvinceRepository;
|
||||
import com.rehome.jpahefengweather.entity.NmcCity;
|
||||
import com.rehome.jpahefengweather.entity.NmcProvince;
|
||||
import com.rehome.jpahefengweather.service.NmcCityService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class NmcCityServiceImpl implements NmcCityService {
|
||||
|
||||
@Resource
|
||||
private NmcCityRepository nmcCityRepository;
|
||||
@Resource
|
||||
private NmcProvinceRepository nmcProvinceRepository;
|
||||
|
||||
@Override
|
||||
public NmcProvince findProvinceByCode(String code) {
|
||||
return this.nmcProvinceRepository.findByCode(code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NmcCity findCityByCode(String code) {
|
||||
return this.nmcCityRepository.findByCode(code);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void saveProvince(NmcProvince province) {
|
||||
if(province!=null){
|
||||
Date now = new Date();
|
||||
NmcProvince provinceDB=this.nmcProvinceRepository.findByCode(province.getCode());
|
||||
if(provinceDB!=null){
|
||||
provinceDB.setName(province.getName());
|
||||
provinceDB.setUrl(province.getUrl());
|
||||
provinceDB.setLastUpdateDate(now);
|
||||
this.nmcProvinceRepository.save(provinceDB);
|
||||
}else{
|
||||
province.setLastUpdateDate(now);
|
||||
province.setCreateDate(now);
|
||||
this.nmcProvinceRepository.save(province);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveCity(NmcCity city) {
|
||||
if(city!=null){
|
||||
Date now = new Date();
|
||||
NmcCity cityDB=this.nmcCityRepository.findByCode(city.getCode());
|
||||
if(cityDB!=null){
|
||||
cityDB.setCity(city.getCity());
|
||||
cityDB.setProvince(city.getProvince());
|
||||
cityDB.setUrl(city.getUrl());
|
||||
cityDB.setLastUpdateDate(now);
|
||||
this.nmcCityRepository.save(cityDB);
|
||||
}else{
|
||||
city.setLastUpdateDate(now);
|
||||
city.setCreateDate(now);
|
||||
this.nmcCityRepository.save(city);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NmcCity> findAllCityList() {
|
||||
return this.nmcCityRepository.findAll();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package com.rehome.jpahefengweather.service.Impl;
|
||||
|
||||
import com.rehome.jpahefengweather.dao.NmcNowWeatherRepository;
|
||||
import com.rehome.jpahefengweather.dao.NmcStormRepository;
|
||||
import com.rehome.jpahefengweather.entity.NmcStorm;
|
||||
import com.rehome.jpahefengweather.service.NmcStormService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class NmcStormServiceImpl implements NmcStormService {
|
||||
|
||||
@Resource
|
||||
private NmcStormRepository nmcStormRepository;
|
||||
|
||||
@Override
|
||||
public NmcStorm findById(Long code) {
|
||||
return this.nmcStormRepository.findByCode(code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NmcStorm> findListByYear(String year) {
|
||||
return this.nmcStormRepository.findByYear(year);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveNmcStorm(NmcStorm nmcStorm) {
|
||||
this.nmcStormRepository.save(nmcStorm);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.rehome.jpahefengweather.service.Impl;
|
||||
|
||||
import com.rehome.jpahefengweather.dao.ForecastWeatherRepository;
|
||||
import com.rehome.jpahefengweather.dao.NmcForecastWeatherRepository;
|
||||
import com.rehome.jpahefengweather.dao.NmcNowWeatherRepository;
|
||||
import com.rehome.jpahefengweather.dao.NowWeatherRepository;
|
||||
import com.rehome.jpahefengweather.entity.NmcForecastWeather;
|
||||
import com.rehome.jpahefengweather.entity.NmcNowWeather;
|
||||
import com.rehome.jpahefengweather.service.NmcWeatherService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class NmcWeatherServiceImpl implements NmcWeatherService {
|
||||
@Resource
|
||||
private NmcNowWeatherRepository nmcNowWeatherRepository;
|
||||
@Resource
|
||||
private NmcForecastWeatherRepository nmcForecastWeatherRepository;
|
||||
|
||||
|
||||
@Override
|
||||
public void saveNowWeather(NmcNowWeather nowWeather) {
|
||||
this.nmcNowWeatherRepository.save(nowWeather);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveForecastWeather(NmcForecastWeather forecastWeather) {
|
||||
this.nmcForecastWeatherRepository.save(forecastWeather);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
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 jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
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<WztfStorm> 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);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
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 jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
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<ZjsltStorm> findByYear(String year) {
|
||||
return this.zjsltStormRepository.findByYear(year);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ZjsltStorm> getTyhoonActivity() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
|
||||
List<ZjsltStorm> list = this.zjsltStormRepository.findByYearAndIsactiveOrderByCreateDateDesc(sdf.format(new Date()),"1");
|
||||
if(list!=null&&list.size()>0){
|
||||
return list;
|
||||
}
|
||||
return new ArrayList();
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.rehome.jpahefengweather.service;
|
||||
|
||||
|
||||
import com.rehome.jpahefengweather.entity.NmcCity;
|
||||
import com.rehome.jpahefengweather.entity.NmcProvince;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface NmcCityService {
|
||||
//code查询所有省份
|
||||
NmcProvince findProvinceByCode(String code);
|
||||
//根据code查询城市
|
||||
NmcCity findCityByCode(String code);
|
||||
//保存省份
|
||||
void saveProvince(NmcProvince province);
|
||||
//保存城市
|
||||
void saveCity(NmcCity city);
|
||||
//查询所有城市
|
||||
List<NmcCity> findAllCityList();
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.rehome.jpahefengweather.service;
|
||||
|
||||
|
||||
import com.rehome.jpahefengweather.entity.NmcNowWeather;
|
||||
import com.rehome.jpahefengweather.entity.NmcStorm;
|
||||
import java.util.List;
|
||||
|
||||
public interface NmcStormService {
|
||||
//根据id查询台风
|
||||
NmcStorm findById(Long id);
|
||||
//根据年份查询台风列表
|
||||
List<NmcStorm> findListByYear(String year);
|
||||
/**
|
||||
* 保存台风数据
|
||||
*/
|
||||
void saveNmcStorm(NmcStorm nmcStorm);
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.rehome.jpahefengweather.service;
|
||||
|
||||
|
||||
import com.rehome.jpahefengweather.entity.NmcForecastWeather;
|
||||
import com.rehome.jpahefengweather.entity.NmcNowWeather;
|
||||
|
||||
public interface NmcWeatherService {
|
||||
|
||||
/**
|
||||
* 保存实时天气数据
|
||||
*/
|
||||
void saveNowWeather(NmcNowWeather nowWeather);
|
||||
/**
|
||||
* 保存实时天气数据
|
||||
*/
|
||||
void saveForecastWeather(NmcForecastWeather forecastWeather);
|
||||
}
|
||||
@ -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<WztfStorm> findByYear(String year);
|
||||
/**
|
||||
* 保存台风数据
|
||||
*/
|
||||
void saveWztfStorm(WztfStorm wztfStorm);
|
||||
|
||||
WztfStormInfo findWztfStormInfoByTfbh(String tfbh);
|
||||
/**
|
||||
* 保存台风路径数据
|
||||
*/
|
||||
void saveWztfStormInfo(WztfStormInfo wztfStormInfo);
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
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<ZjsltStorm> findByYear(String year);
|
||||
//根据年份查询台风列表
|
||||
List<ZjsltStorm> getTyhoonActivity();
|
||||
/**
|
||||
* 保存台风数据
|
||||
*/
|
||||
void saveZjsltStorm(ZjsltStorm zjsltStorm);
|
||||
|
||||
TyphoonInfo findTyphoonInfoByTfid(String tfid);
|
||||
/**
|
||||
* 保存台风路径数据
|
||||
*/
|
||||
void saveTyphoonInfo(TyphoonInfo typhoonInfo);
|
||||
|
||||
}
|
||||
@ -0,0 +1,118 @@
|
||||
package com.rehome.jpahefengweather.service.excel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import org.apache.poi.hssf.util.HSSFColor;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
public class CellStyle {
|
||||
public static void main(String[] args)throws Exception
|
||||
{
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet spreadsheet = workbook.createSheet("cellstyle");
|
||||
XSSFRow row = spreadsheet.createRow((short) 1);
|
||||
row.setHeight((short) 800);
|
||||
XSSFCell cell = (XSSFCell) row.createCell((short) 1);
|
||||
cell.setCellValue("test of merging");
|
||||
//MEARGING CELLS
|
||||
//this statement for merging cells
|
||||
spreadsheet.addMergedRegion(new CellRangeAddress(
|
||||
1, //first row (0-based)
|
||||
1, //last row (0-based)
|
||||
1, //first column (0-based)
|
||||
4 //last column (0-based)
|
||||
));
|
||||
//CELL Alignment
|
||||
row = spreadsheet.createRow(5);
|
||||
cell = (XSSFCell) row.createCell(0);
|
||||
row.setHeight((short) 800);
|
||||
// Top Left alignment
|
||||
XSSFCellStyle style1 = workbook.createCellStyle();
|
||||
spreadsheet.setColumnWidth(0, 8000);
|
||||
style1.setAlignment(XSSFCellStyle.ALIGN_LEFT);
|
||||
style1.setVerticalAlignment(XSSFCellStyle.VERTICAL_TOP);
|
||||
cell.setCellValue("Top Left");
|
||||
cell.setCellStyle(style1);
|
||||
row = spreadsheet.createRow(6);
|
||||
cell = (XSSFCell) row.createCell(1);
|
||||
row.setHeight((short) 800);
|
||||
// Center Align Cell Contents
|
||||
XSSFCellStyle style2 = workbook.createCellStyle();
|
||||
style2.setAlignment(XSSFCellStyle.ALIGN_CENTER);
|
||||
style2.setVerticalAlignment(
|
||||
XSSFCellStyle.VERTICAL_CENTER);
|
||||
cell.setCellValue("Center Aligned");
|
||||
cell.setCellStyle(style2);
|
||||
row = spreadsheet.createRow(7);
|
||||
cell = (XSSFCell) row.createCell(2);
|
||||
row.setHeight((short) 800);
|
||||
// Bottom Right alignment
|
||||
XSSFCellStyle style3 = workbook.createCellStyle();
|
||||
style3.setAlignment(XSSFCellStyle.ALIGN_RIGHT);
|
||||
style3.setVerticalAlignment(
|
||||
XSSFCellStyle.VERTICAL_BOTTOM);
|
||||
cell.setCellValue("Bottom Right");
|
||||
cell.setCellStyle(style3);
|
||||
row = spreadsheet.createRow(8);
|
||||
cell = (XSSFCell) row.createCell(3);
|
||||
// Justified Alignment
|
||||
XSSFCellStyle style4 = workbook.createCellStyle();
|
||||
style4.setAlignment(XSSFCellStyle.ALIGN_JUSTIFY);
|
||||
style4.setVerticalAlignment(
|
||||
XSSFCellStyle.VERTICAL_JUSTIFY);
|
||||
cell.setCellValue("Contents are Justified in Alignment");
|
||||
cell.setCellStyle(style4);
|
||||
//CELL BORDER
|
||||
row = spreadsheet.createRow((short) 10);
|
||||
row.setHeight((short) 800);
|
||||
cell = (XSSFCell) row.createCell((short) 1);
|
||||
cell.setCellValue("BORDER");
|
||||
XSSFCellStyle style5 = workbook.createCellStyle();
|
||||
style5.setBorderBottom(XSSFCellStyle.BORDER_THICK);
|
||||
style5.setBottomBorderColor(
|
||||
IndexedColors.BLUE.getIndex());
|
||||
style5.setBorderLeft(XSSFCellStyle.BORDER_DOUBLE);
|
||||
style5.setLeftBorderColor(
|
||||
IndexedColors.GREEN.getIndex());
|
||||
style5.setBorderRight(XSSFCellStyle.BORDER_HAIR);
|
||||
style5.setRightBorderColor(
|
||||
IndexedColors.RED.getIndex());
|
||||
style5.setBorderTop(XSSFCellStyle.BIG_SPOTS);
|
||||
style5.setTopBorderColor(
|
||||
IndexedColors.CORAL.getIndex());
|
||||
cell.setCellStyle(style5);
|
||||
//Fill Colors
|
||||
//background color
|
||||
row = spreadsheet.createRow((short) 10 );
|
||||
cell = (XSSFCell) row.createCell((short) 1);
|
||||
XSSFCellStyle style6 = workbook.createCellStyle();
|
||||
style6.setFillBackgroundColor(
|
||||
HSSFColor.LEMON_CHIFFON.index );
|
||||
style6.setFillPattern(XSSFCellStyle.LESS_DOTS);
|
||||
style6.setAlignment(XSSFCellStyle.ALIGN_FILL);
|
||||
spreadsheet.setColumnWidth(1,8000);
|
||||
cell.setCellValue("FILL BACKGROUNG/FILL PATTERN");
|
||||
cell.setCellStyle(style6);
|
||||
//Foreground color
|
||||
row = spreadsheet.createRow((short) 12);
|
||||
cell = (XSSFCell) row.createCell((short) 1);
|
||||
XSSFCellStyle style7=workbook.createCellStyle();
|
||||
style7.setFillForegroundColor(HSSFColor.BLUE.index);
|
||||
style7.setFillPattern( XSSFCellStyle.LESS_DOTS);
|
||||
style7.setAlignment(XSSFCellStyle.ALIGN_FILL);
|
||||
cell.setCellValue("FILL FOREGROUND/FILL PATTERN");
|
||||
cell.setCellStyle(style7);
|
||||
FileOutputStream out = new FileOutputStream(
|
||||
new File("D:\\cellstyle.xlsx"));
|
||||
workbook.write(out);
|
||||
out.close();
|
||||
System.out.println("cellstyle.xlsx written successfully");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package com.rehome.jpahefengweather.service.excel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
public class ExcelDatabase
|
||||
{
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
Connection connect = DriverManager.getConnection(
|
||||
"jdbc:mysql://localhost:3306/test" ,
|
||||
"root" ,
|
||||
"root"
|
||||
);
|
||||
Statement statement = connect.createStatement();
|
||||
ResultSet resultSet = statement
|
||||
.executeQuery("select * from emp_tbl");
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet spreadsheet = workbook
|
||||
.createSheet("employe db");
|
||||
XSSFRow row=spreadsheet.createRow(1);
|
||||
XSSFCell cell;
|
||||
cell=row.createCell(1);
|
||||
cell.setCellValue("EMP ID");
|
||||
cell=row.createCell(2);
|
||||
cell.setCellValue("EMP NAME");
|
||||
cell=row.createCell(3);
|
||||
cell.setCellValue("DEG");
|
||||
cell=row.createCell(4);
|
||||
cell.setCellValue("SALARY");
|
||||
cell=row.createCell(5);
|
||||
cell.setCellValue("DEPT");
|
||||
int i=2;
|
||||
while(resultSet.next())
|
||||
{
|
||||
row=spreadsheet.createRow(i);
|
||||
cell=row.createCell(1);
|
||||
cell.setCellValue(resultSet.getInt("eid"));
|
||||
cell=row.createCell(2);
|
||||
cell.setCellValue(resultSet.getString("ename"));
|
||||
cell=row.createCell(3);
|
||||
cell.setCellValue(resultSet.getString("deg"));
|
||||
cell=row.createCell(4);
|
||||
cell.setCellValue(resultSet.getString("salary"));
|
||||
cell=row.createCell(5);
|
||||
cell.setCellValue(resultSet.getString("dept"));
|
||||
i++;
|
||||
}
|
||||
FileOutputStream out = new FileOutputStream(
|
||||
new File("exceldatabase.xlsx"));
|
||||
workbook.write(out);
|
||||
out.close();
|
||||
System.out.println(
|
||||
"exceldatabase.xlsx written successfully");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package com.rehome.jpahefengweather.service.excel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import org.apache.poi.hssf.util.HSSFColor;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
||||
import org.apache.poi.xssf.usermodel.XSSFFont;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
public class FontStyle {
|
||||
public static void main(String[] args)throws Exception
|
||||
{
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet spreadsheet = workbook.createSheet("Fontstyle");
|
||||
XSSFRow row = spreadsheet.createRow(2);
|
||||
//Create a new font and alter it.
|
||||
XSSFFont font = workbook.createFont();
|
||||
font.setFontHeightInPoints((short) 30);
|
||||
font.setFontName("IMPACT");
|
||||
font.setItalic(true);
|
||||
font.setColor(HSSFColor.BRIGHT_GREEN.index);
|
||||
//Set font into style
|
||||
XSSFCellStyle style = workbook.createCellStyle();
|
||||
style.setFont(font);
|
||||
// Create a cell with a value and set style to it.
|
||||
XSSFCell cell = row.createCell(1);
|
||||
cell.setCellValue("Font Style");
|
||||
cell.setCellStyle(style);
|
||||
FileOutputStream out = new FileOutputStream(
|
||||
new File("D:\\fontstyle.xlsx"));
|
||||
workbook.write(out);
|
||||
out.close();
|
||||
System.out.println(
|
||||
"fontstyle.xlsx written successfully");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
package com.rehome.jpahefengweather.service.excel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
public class TextDirection
|
||||
{
|
||||
public static void main(String[] args)throws Exception
|
||||
{
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet spreadsheet = workbook.createSheet(
|
||||
"Text direction");
|
||||
XSSFRow row = spreadsheet.createRow(2);
|
||||
XSSFCellStyle myStyle = workbook.createCellStyle();
|
||||
myStyle.setRotation((short) 0);
|
||||
XSSFCell cell = row.createCell(1);
|
||||
cell.setCellValue("0D angle");
|
||||
cell.setCellStyle(myStyle);
|
||||
//30 degrees
|
||||
myStyle=workbook.createCellStyle();
|
||||
myStyle.setRotation((short) 30);
|
||||
cell = row.createCell(3);
|
||||
cell.setCellValue("30D angle");
|
||||
cell.setCellStyle(myStyle);
|
||||
//90 degrees
|
||||
myStyle=workbook.createCellStyle();
|
||||
myStyle.setRotation((short) 90);
|
||||
cell = row.createCell(5);
|
||||
cell.setCellValue("90D angle");
|
||||
cell.setCellStyle(myStyle);
|
||||
//120 degrees
|
||||
myStyle=workbook.createCellStyle();
|
||||
myStyle.setRotation((short) 120);
|
||||
cell = row.createCell(7);
|
||||
cell.setCellValue("120D angle");
|
||||
cell.setCellStyle(myStyle);
|
||||
//270 degrees
|
||||
myStyle = workbook.createCellStyle();
|
||||
myStyle.setRotation((short) 270);
|
||||
cell = row.createCell(9);
|
||||
cell.setCellValue("270D angle");
|
||||
cell.setCellStyle(myStyle);
|
||||
//360 degrees
|
||||
myStyle=workbook.createCellStyle();
|
||||
myStyle.setRotation((short) 360);
|
||||
cell = row.createCell(12);
|
||||
cell.setCellValue("360D angle");
|
||||
cell.setCellStyle(myStyle);
|
||||
FileOutputStream out = new FileOutputStream(
|
||||
new File("textdirection.xlsx"));
|
||||
workbook.write(out);
|
||||
out.close();
|
||||
System.out.println(
|
||||
"textdirection.xlsx written successfully");
|
||||
}
|
||||
}
|
||||
@ -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)");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package com.rehome.jpahefengweather.utils;
|
||||
|
||||
/**
|
||||
* 分页接口
|
||||
* <pre>
|
||||
* @ApiModelProperty("分页信息")
|
||||
* private Paging paging = new Paging();
|
||||
*
|
||||
* @Override
|
||||
* public Paging getPaging() {
|
||||
* return paging;
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public void setPaging(Paging paging) {
|
||||
* this.paging = paging;
|
||||
* }
|
||||
* </pre>
|
||||
* @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);
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
package com.rehome.jpahefengweather.utils;
|
||||
|
||||
import net.i2p.crypto.eddsa.EdDSAEngine;
|
||||
import net.i2p.crypto.eddsa.EdDSAPrivateKey;
|
||||
import net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable;
|
||||
import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.Signature;
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Base64;
|
||||
|
||||
public class JwtUtils {
|
||||
public static String getJwt(){
|
||||
try {
|
||||
// Private key
|
||||
String privateKeyString = "MC4CAQAwBQYDK2VwBCIEIOtI2Yuhkyor4Zfny9OUMbzMmZCEJ7hqIpuoDhk0zYcy";
|
||||
privateKeyString = privateKeyString.trim().replace("-----BEGIN PRIVATE KEY-----", "").replace("-----END PRIVATE KEY-----", "").trim();
|
||||
byte[] privateKeyBytes = Base64.getDecoder().decode(privateKeyString);
|
||||
PKCS8EncodedKeySpec encoded = new PKCS8EncodedKeySpec(privateKeyBytes);
|
||||
PrivateKey privateKey = new EdDSAPrivateKey(encoded);
|
||||
|
||||
// Header
|
||||
String headerJson = "{\"alg\": \"EdDSA\", \"kid\": \"C4B98RHV2D\"}";
|
||||
|
||||
// Payload
|
||||
long iat = ZonedDateTime.now(ZoneOffset.UTC).toEpochSecond() - 30;
|
||||
long exp = iat + 900;
|
||||
String payloadJson = "{\"sub\": \"278AVHGU9W\", \"iat\": " + iat + ", \"exp\": " + exp + "}";
|
||||
|
||||
// Base64url header+payload
|
||||
String headerEncoded = Base64.getUrlEncoder().encodeToString(headerJson.getBytes(StandardCharsets.UTF_8));
|
||||
String payloadEncoded = Base64.getUrlEncoder().encodeToString(payloadJson.getBytes(StandardCharsets.UTF_8));
|
||||
String data = headerEncoded + "." + payloadEncoded;
|
||||
|
||||
EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.ED_25519);
|
||||
|
||||
// Sign
|
||||
final Signature s = new EdDSAEngine(MessageDigest.getInstance(spec.getHashAlgorithm()));
|
||||
s.initSign(privateKey);
|
||||
s.update(data.getBytes(StandardCharsets.UTF_8));
|
||||
byte[] signature = s.sign();
|
||||
|
||||
String signatureString = Base64.getUrlEncoder().encodeToString(signature);
|
||||
|
||||
System.out.println("Signature: \n" + signatureString);
|
||||
|
||||
// Print Token
|
||||
String jwt = data + "." + signatureString;
|
||||
System.out.println("JWT: \n" + jwt);
|
||||
return jwt;
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,142 @@
|
||||
package com.rehome.jpahefengweather.utils;
|
||||
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @author LiuHuiYu
|
||||
* @version v1.0.0.0
|
||||
* Created DateTime 2020-09-10 8:41
|
||||
*/
|
||||
public class LhyAssert {
|
||||
static Function<String, RuntimeException> exceptionProxy;
|
||||
|
||||
private static RuntimeException throwEx(String message) {
|
||||
if (exceptionProxy == null) {
|
||||
return new RuntimeException(message);
|
||||
}
|
||||
else {
|
||||
return exceptionProxy.apply(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接受到异常信息后的异常抛出处理
|
||||
*
|
||||
* @param proxy 接受到异常信息后的代理。
|
||||
* @author LiuHuiYu
|
||||
* Created DateTime 2021-12-10 14:43
|
||||
*/
|
||||
public static void exceptionProxy(Function<String, RuntimeException> proxy) {
|
||||
exceptionProxy = proxy;
|
||||
}
|
||||
//region assertTrue
|
||||
|
||||
public static void assertTrue(boolean value, RuntimeException exception) {
|
||||
if (!value) {
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
public static void assertTrue(boolean value, String message) {
|
||||
assertTrue(value, throwEx(message));
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region assertFalse
|
||||
|
||||
public static void assertFalse(boolean value, String message) {
|
||||
assertTrue(!value, message);
|
||||
}
|
||||
|
||||
public static void assertFalse(boolean value, RuntimeException exception) {
|
||||
assertTrue(!value, exception);
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region assertNotNull
|
||||
public static void assertNotNull(Object object, RuntimeException exception) {
|
||||
assertTrue(object != null, exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象为空则抛出异常
|
||||
*
|
||||
* @param object 对象
|
||||
*/
|
||||
public static void assertNotNull(Object object, String message) {
|
||||
assertTrue(object != null, message);
|
||||
}
|
||||
|
||||
|
||||
//endregion
|
||||
|
||||
//region assertNull
|
||||
|
||||
/**
|
||||
* 对象不为空则抛出异常
|
||||
*
|
||||
* @param object 对象
|
||||
*/
|
||||
public static void assertNull(Object object, RuntimeException exception) {
|
||||
assertTrue(object == null, exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象不为空则抛出异常
|
||||
*
|
||||
* @param object 对象
|
||||
*/
|
||||
public static void assertNull(Object object, String message) {
|
||||
assertTrue(object == null, message);
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region 枚举模式拦截
|
||||
|
||||
/**
|
||||
* 对象不为空则抛出异常
|
||||
*
|
||||
* @param value 对象
|
||||
* @param resultEnum 错误枚举
|
||||
*/
|
||||
public static void assertTrue(boolean value, ResultEnum resultEnum) {
|
||||
if (!value) {
|
||||
throw new LhyException(resultEnum);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象为空则抛出异常
|
||||
*
|
||||
* @param object 对象
|
||||
* @param resultEnum 错误枚举
|
||||
*/
|
||||
public static void assertNotNull(Object object, ResultEnum resultEnum) {
|
||||
assertTrue(object != null, resultEnum);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象不为空则抛出异常
|
||||
*
|
||||
* @param object 对象
|
||||
* @param resultEnum 错误枚举
|
||||
*/
|
||||
public static void assertNull(Object object, ResultEnum resultEnum) {
|
||||
assertTrue(object == null, resultEnum);
|
||||
}
|
||||
//endregion
|
||||
|
||||
|
||||
public static void assertLen(String value, int min, int max, String message) {
|
||||
assertNotNull(value, message + "未设定");
|
||||
assertTrue(
|
||||
(min <= 0 || value.length() >= min) &&
|
||||
(max < 0 || value.length() <= max), message + "(长度范围[" + min + "-" + max + "])");
|
||||
}
|
||||
|
||||
public static void assertLen(String value, int min, int max, RuntimeException exception) {
|
||||
assertNotNull(value, exception);
|
||||
assertTrue(value.length() >= min && value.length() <= max, exception);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package com.rehome.jpahefengweather.utils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* 自定义报错类
|
||||
*
|
||||
* @author LiuHuiYu
|
||||
* @version v1.0.0.0
|
||||
* Created DateTime 2020-06-23 13:27
|
||||
*/
|
||||
public class LhyException extends RuntimeException {
|
||||
private Integer errId;
|
||||
/*
|
||||
public ArchivesManagementException(Integer code, String message) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
}
|
||||
*/
|
||||
|
||||
public LhyException(@NotNull ResultEnum resultEnum) {
|
||||
super(resultEnum.getMessage());
|
||||
this.errId = resultEnum.getCode();
|
||||
}
|
||||
|
||||
public LhyException(@NotNull ResultEnum resultEnum, String message) {
|
||||
super(resultEnum.getMessage() + ":" + message);
|
||||
this.errId = resultEnum.getCode();
|
||||
}
|
||||
|
||||
public LhyException(String message, @NotNull ResultEnum resultEnum) {
|
||||
super(message + resultEnum.getMessage());
|
||||
this.errId = resultEnum.getCode();
|
||||
}
|
||||
|
||||
public LhyException(String message, @NotNull ResultEnum resultEnum, String message1) {
|
||||
super(message + resultEnum.getMessage() + message1);
|
||||
this.errId = resultEnum.getCode();
|
||||
}
|
||||
|
||||
public LhyException(String message) {
|
||||
super(message);
|
||||
this.errId = 0;
|
||||
}
|
||||
|
||||
public Integer getErrId() {
|
||||
return errId;
|
||||
}
|
||||
|
||||
public void setErrId(Integer errId) {
|
||||
this.errId = errId;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue