Ver Fonte

第一次提交
导入TDEngine不好用

小王 há 1 ano atrás
commit
11dad8daa3

+ 33 - 0
.gitignore

@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/

BIN
.mvn/wrapper/maven-wrapper.jar


+ 2 - 0
.mvn/wrapper/maven-wrapper.properties

@@ -0,0 +1,2 @@
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
+wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar

+ 308 - 0
mvnw

@@ -0,0 +1,308 @@
+#!/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.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Apache Maven Wrapper startup batch script, version 3.2.0
+#
+# Required ENV vars:
+# ------------------
+#   JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+#   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
+        JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME
+      else
+        JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
+      fi
+    fi
+    ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+  if [ -r /etc/gentoo-release ] ; then
+    JAVA_HOME=$(java-config --jre-home)
+  fi
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+  [ -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 "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] &&
+    JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); 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 2>/dev/null; \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
+
+# 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/.." || exit 1; pwd)
+    fi
+    # end of workaround
+  done
+  printf '%s' "$(cd "$basedir" || exit 1; pwd)"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+  if [ -f "$1" ]; then
+    # Remove \r in case we run on Windows within Git Bash
+    # and check out the repository with auto CRLF management
+    # enabled. Otherwise, we may read lines that are delimited with
+    # \r\n and produce $'-Xarg\r' rather than -Xarg due to word
+    # splitting rules.
+    tr -s '\r\n' ' ' < "$1"
+  fi
+}
+
+log() {
+  if [ "$MVNW_VERBOSE" = true ]; then
+    printf '%s\n' "$1"
+  fi
+}
+
+BASE_DIR=$(find_maven_basedir "$(dirname "$0")")
+if [ -z "$BASE_DIR" ]; then
+  exit 1;
+fi
+
+MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR
+log "$MAVEN_PROJECTBASEDIR"
+
+##########################################################################################
+# 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.
+##########################################################################################
+wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar"
+if [ -r "$wrapperJarPath" ]; then
+    log "Found $wrapperJarPath"
+else
+    log "Couldn't find $wrapperJarPath, downloading it ..."
+
+    if [ -n "$MVNW_REPOURL" ]; then
+      wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
+    else
+      wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
+    fi
+    while IFS="=" read -r key value; do
+      # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
+      safeValue=$(echo "$value" | tr -d '\r')
+      case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;;
+      esac
+    done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
+    log "Downloading from: $wrapperUrl"
+
+    if $cygwin; then
+      wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
+    fi
+
+    if command -v wget > /dev/null; then
+        log "Found wget ... using wget"
+        [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet"
+        if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+            wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
+        else
+            wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
+        fi
+    elif command -v curl > /dev/null; then
+        log "Found curl ... using curl"
+        [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent"
+        if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+            curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
+        else
+            curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
+        fi
+    else
+        log "Falling back to using Java to download"
+        javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java"
+        javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class"
+        # For Cygwin, switch paths to Windows format before running javac
+        if $cygwin; then
+          javaSource=$(cygpath --path --windows "$javaSource")
+          javaClass=$(cygpath --path --windows "$javaClass")
+        fi
+        if [ -e "$javaSource" ]; then
+            if [ ! -e "$javaClass" ]; then
+                log " - Compiling MavenWrapperDownloader.java ..."
+                ("$JAVA_HOME/bin/javac" "$javaSource")
+            fi
+            if [ -e "$javaClass" ]; then
+                log " - Running MavenWrapperDownloader.java ..."
+                ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath"
+            fi
+        fi
+    fi
+fi
+##########################################################################################
+# End of extension
+##########################################################################################
+
+# If specified, validate the SHA-256 sum of the Maven wrapper jar file
+wrapperSha256Sum=""
+while IFS="=" read -r key value; do
+  case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;;
+  esac
+done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
+if [ -n "$wrapperSha256Sum" ]; then
+  wrapperSha256Result=false
+  if command -v sha256sum > /dev/null; then
+    if echo "$wrapperSha256Sum  $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then
+      wrapperSha256Result=true
+    fi
+  elif command -v shasum > /dev/null; then
+    if echo "$wrapperSha256Sum  $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then
+      wrapperSha256Result=true
+    fi
+  else
+    echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available."
+    echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties."
+    exit 1
+  fi
+  if [ $wrapperSha256Result = false ]; then
+    echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
+    echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2
+    echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2
+    exit 1
+  fi
+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 "$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
+
+# shellcheck disable=SC2086 # safe args
+exec "$JAVACMD" \
+  $MAVEN_OPTS \
+  $MAVEN_DEBUG_OPTS \
+  -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+  "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+  ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

+ 205 - 0
mvnw.cmd

@@ -0,0 +1,205 @@
+@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 Apache Maven Wrapper startup batch script, version 3.2.0
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@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 WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
+
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+    IF "%%A"=="wrapperUrl" SET WRAPPER_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 WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
+    )
+    if "%MVNW_VERBOSE%" == "true" (
+        echo Couldn't find %WRAPPER_JAR%, downloading it ...
+        echo Downloading from: %WRAPPER_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('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
+		"}"
+    if "%MVNW_VERBOSE%" == "true" (
+        echo Finished downloading %WRAPPER_JAR%
+    )
+)
+@REM End of extension
+
+@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
+SET WRAPPER_SHA_256_SUM=""
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+    IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B
+)
+IF NOT %WRAPPER_SHA_256_SUM%=="" (
+    powershell -Command "&{"^
+       "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
+       "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
+       "  Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
+       "  Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
+       "  Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
+       "  exit 1;"^
+       "}"^
+       "}"
+    if ERRORLEVEL 1 goto error
+)
+
+@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%

+ 129 - 0
pom.xml

@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.2.1.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.example</groupId>
+    <artifactId>dataDump</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>dataDump</name>
+    <description>dataDump</description>
+    <properties>
+        <java.version>8</java.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.12.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.5.0</version>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>8.0.25</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-net</groupId>
+            <artifactId>commons-net</artifactId>
+            <version>3.6</version>
+        </dependency>
+        <dependency>
+            <groupId>com.taosdata.jdbc</groupId>
+            <artifactId>taos-jdbcdriver</artifactId>
+            <version>3.2.4</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <resources>
+            <!-- 配置文件复制到target目录下,不然开发调试的时候会报错 -->
+            <resource>
+                <!-- 资源文件的路径,不配置的话默认位于src/main/resources/目录下,  -->
+                <directory>src/main/resources</directory>
+                <!-- 是否对资源文件进行过滤 -->
+                <filtering>true</filtering>
+                <!-- 这里没有配置targetPath,默认复制到outputDirectory目录下  -->
+            </resource>
+            <!-- 配置文件放在target/config目录下 -->
+            <resource>
+                <directory>src/main/resources</directory>
+                <targetPath>${project.build.directory}/config</targetPath>
+            </resource>
+        </resources>
+
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                        <exclude>
+                            <groupId>org.projectlombok</groupId>
+                            <artifactId>lombok</artifactId>
+                        </exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>2.2.1.RELEASE</version>
+                <configuration>
+                    <mainClass>com.example.datadump.DataDumpApplication</mainClass>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <!-- 打包过程忽略Junit测试 -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.17</version>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+        </plugins>
+
+    </build>
+
+</project>

+ 13 - 0
src/main/java/com/example/datadump/DataDumpApplication.java

@@ -0,0 +1,13 @@
+package com.example.datadump;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class DataDumpApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(DataDumpApplication.class, args);
+    }
+
+}

+ 84 - 0
src/main/java/com/example/datadump/controller/DumpDataController.java

@@ -0,0 +1,84 @@
+package com.example.datadump.controller;
+
+import com.example.datadump.service.DumpMysql;
+import com.example.datadump.service.DumpTDEngine;
+import com.example.datadump.service.ImportMysql;
+import com.example.datadump.service.ImportTDEngine;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@AllArgsConstructor
+@Slf4j
+public class DumpDataController {
+    private final DumpMysql dumpMysql;
+    private final DumpTDEngine dumpTDEngine;
+    private final ImportMysql importMysql;
+    private final ImportTDEngine importTDEngine;
+
+    /**
+     * 备份mysql数据库
+     *
+     * @param userName 用户名
+     * @param passWord 密码
+     * @param ip       IP地址
+     * @param port     端口
+     * @param db       数据库
+     * @param table    表
+     * @param outPath  输出路径
+     * @throws Exception
+     */
+    @GetMapping("/DumpMysql")
+    public void DumpMysql(String userName, String passWord, String ip, String port, String db, String table, String outPath) throws Exception {
+        log.info("MySQL数据备份开始");
+        dumpMysql.dbBackUpMysql(userName, passWord, ip, port, db, table, outPath);
+        log.info("MySQL数据备份结束");
+    }
+
+    /**
+     * 恢复mysql数据库
+     *
+     * @param userName 用户名
+     * @param passWord 密码
+     * @param ip       IP地址
+     * @param port     端口
+     * @param db       数据库
+     * @param table    表
+     * @param outPath  输出路径
+     * @throws Exception
+     */
+    @GetMapping("/ImportMysql")
+    public void ImportMysql(String userName, String passWord, String ip, String port, String db, String table, String outPath) throws Exception {
+        log.info("MySQL数据恢复开始");
+        importMysql.importMysql(userName, passWord, ip, port, db, table, outPath);
+        log.info("MySQL数据恢复结束");
+    }
+
+    /**
+     * TDEngine数据库备份
+     *
+     * @param ip       IP地址
+     * @param port     端口号
+     * @param db       数据库
+     * @param userName 用户名
+     * @param passWord 密码
+     * @param table    表名,如果多个表以逗号分隔
+     * @param path     导出路径
+     * @throws Exception
+     */
+    @GetMapping("/DumpTDEngine")
+    public void DumpTEngine(String ip, String port, String db, String userName, String passWord, String table, String path) throws Exception {
+        log.info("TDEngine数据备份开始");
+        dumpTDEngine.dbBackUpTDEngine(ip, port, db, userName, passWord, table, path);
+        log.info("TDEngine数据备份结束");
+    }
+
+    @GetMapping("/ImportTDEngine")
+    public void ImportTDEngine(String ip, String port, String db, String userName, String passWord, String table, String path) throws Exception {
+        log.info("TDEngine数据恢复开始");
+        importTDEngine.importTDEngine(ip, port, db, userName, passWord, table, path);
+        log.info("TDEngine数据恢复结束");
+    }
+}

+ 68 - 0
src/main/java/com/example/datadump/service/DumpMysql.java

@@ -0,0 +1,68 @@
+package com.example.datadump.service;
+
+import cn.hutool.core.io.FileUtil;
+import com.example.datadump.util.FileUtils;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.sql.*;
+
+@Service
+public class DumpMysql {
+    /**
+     * 备份mysql数据库
+     *
+     * @param userName 用户名
+     * @param passWord 密码
+     * @param ip       IP地址
+     * @param port     端口
+     * @param db       数据库
+     * @param table    表
+     * @param outPath  输出路径
+     */
+    public void dbBackUpMysql(String userName, String passWord, String ip, String port, String db, String table, String outPath) throws Exception {
+        Connection conn = null;
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        String SQL = null;
+        String url = "jdbc:mysql://" + ip + ":" + port + "/" + db + "?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true";
+        //加载数据库驱动
+        Class.forName("com.mysql.cj.jdbc.Driver");
+        //创建连接
+        conn = DriverManager.getConnection(url, userName, passWord);
+        String regex = ",|,";
+        String[] tables = table.split(regex);
+        for (String table1 : tables) {
+            String filePath = outPath + File.separator;
+            if (!new File(filePath).exists()) {
+                FileUtil.mkdir(filePath);
+            }
+            File[] files = FileUtils.searchFile(new File(filePath), table1);
+            for (File file : files) {
+                file.delete();
+            }
+            String fileName = table1 + ".csv";
+            //执行语句
+            SQL = "SELECT \r\n" +
+                    "   *\r\n" +
+                    "FROM \r\n" +
+                    "   " + table1 + "\r\n" +
+                    "into outfile '" + filePath + fileName + "'" +
+                    "fields terminated by ',' " +
+                    "lines terminated by '\\r\\n'";
+            ps = conn.prepareStatement(SQL);
+            rs = ps.executeQuery();
+        }
+        //关闭连接
+        try {
+            if (rs != null)
+                rs.close();
+            if (ps != null)
+                ps.close();
+            if (conn != null)
+                conn.close();
+        } catch (SQLException se) {
+            se.printStackTrace();
+        }
+    }
+}

+ 145 - 0
src/main/java/com/example/datadump/service/DumpTDEngine.java

@@ -0,0 +1,145 @@
+package com.example.datadump.service;
+
+import com.example.datadump.util.DateTimeUtil;
+import com.example.datadump.util.FileUtils;
+import com.taosdata.jdbc.TSDBDriver;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.sql.*;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.*;
+
+@Service
+public class DumpTDEngine {
+    private static List<Map<String, String>> convertList(ResultSet rs) throws Exception {
+        List<Map<String, String>> list = new ArrayList<>();
+        ResultSetMetaData md = rs.getMetaData();//获取键名
+        int columnCount = md.getColumnCount();//获取行的数量
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
+        while (rs.next()) {
+            Map<String, String> rowData = new LinkedHashMap<>();//声明Map
+            for (int i = 1; i <= columnCount; i++) {
+                if ("ts".equals(md.getColumnName(i))) {
+                    //把2021-01-01 00:10:00.0 转换成 2021-01-01T08:00:00.000+08:00'
+                    Date date = format.parse(rs.getString(i));
+                    rowData.put(md.getColumnName(i), format1.format(date));
+                } else {
+                    rowData.put(md.getColumnName(i), rs.getString(i) == null ? "NULL" : rs.getString(i));//获取键名及值
+                }
+            }
+            list.add(rowData);
+        }
+        return list;
+    }
+
+    /**
+     * 获取列头
+     *
+     * @param a
+     * @return
+     */
+    private static List<String[]> getList(List<Map<String, String>> a) {
+        //表头数据
+        List<String[]> newResult = new ArrayList<>();
+        if (!a.isEmpty()) {
+            for (Map<String, String> map : a) {
+                String[] colName = new String[a.get(0).size()];
+                int i = 0;
+                for (Map.Entry<String, String> entry : map.entrySet()) {
+                    colName[i] = entry.getValue();
+                    i++;
+                }
+                newResult.add(colName);
+            }
+
+        }
+        return newResult;
+    }
+
+
+    /**
+     * TDEngine数据库备份
+     *
+     * @param ip       IP地址
+     * @param port     端口号
+     * @param db       数据库
+     * @param userName 用户名
+     * @param passWord 密码
+     * @param table    表名,如果多个表以逗号分隔
+     * @param path     导出路径
+     * @throws Exception
+     */
+    public void dbBackUpTDEngine(String ip, String port, String db, String userName, String passWord, String table, String path) throws Exception {
+        String jdbcUrl = "jdbc:TAOS://" + ip + ":" + port + "/" + db + "?user=" + userName + "&password=" + passWord;
+        Properties connProps = new Properties();
+        connProps.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
+        connProps.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
+        connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
+        Connection conn = DriverManager.getConnection(jdbcUrl, connProps);
+        //--------------------------------------------------
+        Statement ps;
+        ps = conn.createStatement();
+        //所有数据
+        ResultSet rs = null;
+        //转换过后的数据
+        List<Map<String, String>> a;
+        /*Timestamp timestamp = new Timestamp(DateTimeUtil.getDayStartTime(1586880000000L).getTime());
+        Timestamp ytimestamp = new Timestamp(DateTimeUtil.getDayLastTime(1586966400000L - 1000).getTime());
+        String start = timestamp.toString();
+        String end = ytimestamp.toString();*/
+        String start = DateTimeUtil.yesterdayStart();
+        String end = DateTimeUtil.yesterdayEnd();
+        //---------创建文件----------
+        String[] csvNames = table.split(",");
+        //根据表名循环
+        for (String tableName : csvNames) {
+            String filePath = path + File.separator + tableName;
+            //如果目录下没有这个表的文件,那么就是第一次执行,只有第一次执行的时候才会导出所有的数据
+            if (FileUtils.searchFile(new File(path), tableName).length == 0) {
+                String sql = "select ts from " + tableName + " limit 0,1";
+                rs = ps.executeQuery(sql);
+                String startTime = "";
+                while (rs.next()) {
+                    startTime = rs.getString("ts");
+                }
+                String endTime = DateTimeUtil.yesterdayEnd();
+                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//首先定义待转换的时间格式
+                long startDate = format.parse(startTime).getTime();//将带转换的时间字符串转换为date类型,然后使用getTime即可获取对应的时间戳
+                long endDate = format.parse(endTime).getTime();//将带转换的时间字符串转换为date类型,然后使用getTime即可获取对应的时间戳
+                for (long time = startDate; time <= endDate; time += 60 * 60 * 24 * 1000) {
+                    Timestamp timestamp1 = new Timestamp(DateTimeUtil.getDayStartTime(time).getTime());
+                    Timestamp timestamp2 = new Timestamp(DateTimeUtil.getDayLastTime(time + 60 * 60 * 24 * 1000 - 1000).getTime());
+                    String start1 = timestamp1.toString();
+                    String end1 = timestamp2.toString();
+                    sql = "select * from " + tableName + " where ts between '" + start1 + "' and '" + end1 + "'";
+                    rs = ps.executeQuery(sql);
+                    a = convertList(rs);
+                    if (!a.isEmpty()) {
+                        List<String[]> newResult = getList(a);
+                        FileUtils.createCsvFile(newResult, filePath + " " + start1 + ".csv");
+                    }
+                }
+            } else {
+                String sql = "select * from " + tableName + " where ts between '" + start + "' and '" + end + "'";
+                rs = ps.executeQuery(sql);
+                //转换过后的数据
+                a = convertList(rs);
+                //表头数据
+                if (!a.isEmpty()) {
+                    List<String[]> newResult = getList(a);
+                    FileUtils.createCsvFile(newResult, filePath + " " + start + ".csv");
+                }
+            }
+        }
+        if (rs != null)
+            rs.close();
+        if (ps != null)
+            ps.close();
+        conn.close();
+    }
+
+
+}

+ 58 - 0
src/main/java/com/example/datadump/service/ImportMysql.java

@@ -0,0 +1,58 @@
+package com.example.datadump.service;
+
+import cn.hutool.core.io.FileUtil;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.sql.*;
+
+@Service
+public class ImportMysql {
+    /**
+     * MySQL恢复
+     *
+     * @param userName 用户名
+     * @param passWord 密码
+     * @param ip       ip地址
+     * @param port     端口号
+     * @param db       数据库
+     * @param table    表
+     * @param outPath  输出路径
+     * @throws Exception
+     */
+    public void importMysql(String userName, String passWord, String ip, String port, String db, String table, String outPath) throws Exception {
+        Connection conn = null;
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        String SQL = null;
+        String url = "jdbc:mysql://" + ip + ":" + port + "/" + db + "?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true";
+        //加载数据库驱动
+        Class.forName("com.mysql.cj.jdbc.Driver");
+        //创建连接
+        conn = DriverManager.getConnection(url, userName, passWord);
+        String regex = ",|,";
+        String[] tables = table.split(regex);
+        for (String table1 : tables) {
+            String filePath = outPath + File.separator;
+            if (!new File(filePath).exists()) {
+                FileUtil.mkdir(filePath);
+            }
+            String fileName = table1 + ".csv";
+            //执行语句
+            SQL = "LOAD DATA INFILE '" + filePath + fileName + "'  INTO TABLE " + table1 + " fields terminated by ',' ";
+            ps = conn.prepareStatement(SQL);
+            rs = ps.executeQuery();
+        }
+        //关闭连接
+        try {
+            if (rs != null)
+                rs.close();
+            if (ps != null)
+                ps.close();
+            if (conn != null)
+                conn.close();
+        } catch (SQLException se) {
+            se.printStackTrace();
+        }
+    }
+}

+ 64 - 0
src/main/java/com/example/datadump/service/ImportTDEngine.java

@@ -0,0 +1,64 @@
+package com.example.datadump.service;
+
+import com.example.datadump.util.FileUtils;
+import com.taosdata.jdbc.TSDBDriver;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+@Service
+public class ImportTDEngine {
+    /**
+     * TDEngine数据库恢复
+     *
+     * @param ip       IP地址
+     * @param port     端口号
+     * @param db       数据库
+     * @param userName 用户名
+     * @param passWord 密码
+     * @param table    表名,如果多个表以逗号分隔
+     * @param path     导出路径
+     * @throws Exception
+     */
+    public void importTDEngine(String ip, String port, String db, String userName, String passWord, String table, String path) throws Exception {
+        String jdbcUrl = "jdbc:TAOS://" + ip + ":" + port + "/" + db + "?user=" + userName + "&password=" + passWord;
+        Properties connProps = new Properties();
+        connProps.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
+        connProps.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
+        connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
+        Connection conn = DriverManager.getConnection(jdbcUrl, connProps);
+        //--------------------------------------------------
+        Statement ps;
+        ps = conn.createStatement();
+        //所有数据
+        ResultSet rs = null;
+        //转换过后的数据
+        List<Map<String, String>> a;
+        //---------创建文件----------
+        String[] csvNames = table.split(",");
+        //根据表名循环
+        for (String tableName : csvNames) {
+            String filePath = path + File.separator + tableName;
+            //如果目录下没有这个表的文件,那么就是第一次执行,只有第一次执行的时候才会导出所有的数据
+            File[] files = FileUtils.searchFile(new File(path), tableName);
+            for (File file : files) {
+                String sql = "insert into " + tableName + " file '" + file.getPath() + "';";
+                rs = ps.executeQuery(sql);
+            }
+
+            //转换过后的数据
+        }
+        if (rs != null)
+            rs.close();
+        if (ps != null)
+            ps.close();
+        conn.close();
+    }
+}

+ 5 - 0
src/main/java/com/example/datadump/util/CsvUtil.java

@@ -0,0 +1,5 @@
+package com.example.datadump.util;
+
+public class CsvUtil {
+    
+}

+ 220 - 0
src/main/java/com/example/datadump/util/DateTimeUtil.java

@@ -0,0 +1,220 @@
+package com.example.datadump.util;
+
+
+import javax.validation.constraints.NotNull;
+import java.sql.Timestamp;
+import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * 时间工具类
+ *
+ * @author zzy
+ * @version 1.0
+ * @since 2019/8/2 13:09
+ */
+public class DateTimeUtil {
+    public static String yesterdayStart() {
+        Date day = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24);
+        Timestamp timestamp = new Timestamp(DateTimeUtil.getDayStartTime(day.getTime()).getTime());
+        return timestamp.toString();
+    }
+
+    public static String yesterdayEnd() {
+        Date day = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24);
+        Timestamp ytimestamp = new Timestamp(DateTimeUtil.getDayLastTime(day.getTime()).getTime());
+        return ytimestamp.toString();
+    }
+
+    /**
+     * 获取月份
+     *
+     * @param dateTime 时间,单位:毫秒
+     * @return 月份
+     */
+    public static int getMonth(@NotNull final Long dateTime) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeInMillis(dateTime);
+        return calendar.get(Calendar.MONTH) + 1;
+    }
+
+    /**
+     * 获取指定时间在当天所处于的时刻(15分钟为一个时刻)
+     * 例如:dateTime:2018-10-22 16:44:00
+     * 从0点0分开始计算,0点0分-0点15为第一个时刻,依次类推该时间的时刻数为67
+     *
+     * @param dateTime 时间,单位:毫秒
+     * @return 时刻
+     */
+    public static int getMomentFor15Minute(@NotNull final Long dateTime) {
+        return (int) ((dateTime - DateTimeUtil.getDayStartTime(dateTime).getTime()) / (15 * 60 * 1000)) + 1;
+    }
+
+    /**
+     * 获取指定时间在当天所处于的时刻(5分钟为一个时刻)
+     * 例如:dateTime:2018-10-22 01:44:00
+     * 从0点0分开始计算,0点0分-0点5为第一个时刻,依次类推该时间的时刻数为
+     *
+     * @param dateTime 时间,单位:毫秒
+     * @return 时刻
+     */
+    public static int getMomentFor5Minute(@NotNull final Long dateTime) {
+        return (int) ((dateTime - DateTimeUtil.getDayStartTime(dateTime).getTime()) / (5 * 60 * 1000)) + 1;
+    }
+
+    /**
+     * 获取指定时间所在时刻的标记时间(15分钟为一个时刻)<br>
+     * 例如:dateTime:2018-10-22 16:44:00 <br>
+     * 标记时间为2018-10-22 16:30:00
+     *
+     * @param dateTime 时间,单位:毫秒
+     * @return 指定时间所在时刻的标记时间,单位:毫秒
+     */
+    public static Date getMomentTimeFor15Minute(@NotNull final Long dateTime) {
+        int moment = DateTimeUtil.getMomentFor15Minute(dateTime);// 获取指定时间所在时刻数
+        long differentTime = (long) moment * 15 * 60 * 1000;// 获取从0分0秒开始到现在的时间间隔,单位:毫秒
+        long dayStartTime = DateTimeUtil.getDayStartTime(dateTime).getTime();
+        return new Date(dayStartTime + differentTime - 15 * 60 * 1000);
+    }
+
+    /**
+     * 获取指定时间所在时刻的标记时间(5分钟为一个时刻)<br>
+     * 例如:dateTime:2018-10-22 16:44:00 <br>
+     * 标记时间为2018-10-22 16:40:00
+     *
+     * @param dateTime 时间,单位:毫秒
+     * @return 指定时间所在时刻的标记时间,单位:毫秒
+     */
+    public static Date getMomentTimeFor5Minute(@NotNull final Long dateTime) {
+        int moment = DateTimeUtil.getMomentFor15Minute(dateTime);// 获取指定时间所在时刻数
+        long differentTime = (long) moment * 5 * 60 * 1000;// 获取从0分0秒开始到现在的时间间隔,单位:毫秒
+        long dayStartTime = DateTimeUtil.getDayStartTime(dateTime).getTime();
+        return new Date(dayStartTime + differentTime - 5 * 60 * 1000);
+    }
+
+    /**
+     * 获取当前时间(时间粒度分钟)
+     *
+     * @return 当前时间
+     */
+    public static Date getCurrentTimeForMinute() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        return calendar.getTime();
+    }
+
+    /**
+     * 获取指定时间所在天的0点0分
+     *
+     * @param dateTime 时间毫秒
+     * @return 0点0分的毫秒
+     */
+    public static Date getDayStartTime(@NotNull final Long dateTime) {
+        Calendar date = Calendar.getInstance();
+        date.setTimeInMillis(dateTime);
+        date.set(Calendar.HOUR_OF_DAY, 0);
+        date.set(Calendar.MINUTE, 0);
+        date.set(Calendar.SECOND, 0);
+        date.set(Calendar.MILLISECOND, 0);
+        return date.getTime();
+    }
+
+
+    /**
+     * 获取指定时间所在天的23点59分59秒
+     *
+     * @param dateTime 时间毫秒
+     * @return 23点59分59秒的毫秒
+     */
+    public static Date getDayLastTime(@NotNull final Long dateTime) {
+        Calendar date = Calendar.getInstance();
+        date.setTimeInMillis(dateTime);
+        date.set(Calendar.HOUR_OF_DAY, 23);
+        date.set(Calendar.MINUTE, 59);
+        date.set(Calendar.SECOND, 59);
+        date.set(Calendar.MILLISECOND, 999);
+        return date.getTime();
+    }
+
+    /**
+     * 获取两个时间间的间隔天数(自然天)
+     *
+     * @param dateFrom 开始时间
+     * @param dateTo   结束时间
+     * @return 自然天数
+     */
+    public static int getDaysBetweenTwoDate(Long dateFrom, Long dateTo) {
+        return (int) ((DateTimeUtil.getDayStartTime(dateTo).getTime() - DateTimeUtil.getDayStartTime(dateFrom).getTime()) / (1000 * 60 * 60 * 24L));
+    }
+
+    /**
+     * 获取两个时间间的间隔间隔时刻数(15分钟一个时刻)
+     *
+     * @param dateFrom 开始时间
+     * @param dateTo   结束时间
+     * @return 间隔时刻数
+     */
+    public static int getMomentsBetweenTwoDate(Long dateFrom, Long dateTo) {
+        return (int) ((dateTo - dateFrom) / (15 * 60 * 1000));
+    }
+
+
+    /**
+     * 获取现在时间
+     *
+     * @return 返回字符串格式 yyyy-MM-dd HH:mm:ss
+     */
+    public static String getStringDate() {
+        Date currentTime = new Date();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String dateString = formatter.format(currentTime);
+        return dateString;
+    }
+
+    /**
+     * 将长时间格式时间转换为字符串 yyyy-MM-dd HH:mm:ss
+     *
+     * @param dateDate
+     * @return
+     */
+    public static String dateToStrLong(Date dateDate) {
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String dateString = formatter.format(dateDate);
+        return dateString;
+    }
+
+    /**
+     * 将时间格式字符串转换为时间 HH:mm
+     *
+     * @param strDate
+     * @return
+     */
+    public static Date strToDateLongHM(String strDate) {
+        SimpleDateFormat formatter = new SimpleDateFormat("HH:mm");
+        ParsePosition pos = new ParsePosition(0);
+        Date strtodate = formatter.parse(strDate, pos);
+        return strtodate;
+    }
+
+
+    /**
+     * 判断时间是不是今天
+     *
+     * @param date
+     * @return 是返回true,不是返回false
+     */
+    public static boolean isNow(Date date) {
+        //当前时间
+        Date now = new Date();
+        SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");
+        //获取今天的日期
+        String nowDay = sf.format(now);
+        //对比的时间
+        String day = sf.format(date);
+        return day.equals(nowDay);
+    }
+
+}

+ 157 - 0
src/main/java/com/example/datadump/util/FileUtils.java

@@ -0,0 +1,157 @@
+package com.example.datadump.util;
+
+import cn.hutool.core.text.csv.CsvUtil;
+import cn.hutool.core.text.csv.CsvWriter;
+import cn.hutool.core.util.CharsetUtil;
+import cn.hutool.core.util.StrUtil;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class FileUtils {
+    /**
+     * 查找目录下是否有文件
+     *
+     * @param folder
+     * @param keyWord
+     * @return
+     */
+    public static File[] searchFile(File folder, final String keyWord) {// 递归查找包含关键字的文件
+
+        File[] subFolders = folder.listFiles(new FileFilter() {// 运用内部匿名类获得文件
+            @Override
+            public boolean accept(File pathname) {// 实现FileFilter类的accept方法
+                // 目录或文件包含关键字
+                return pathname.isDirectory()
+                        || (pathname.isFile() && pathname.getName().toLowerCase().contains(keyWord.toLowerCase()));
+            }
+        });
+
+        List<File> result = new ArrayList<File>();// 声明一个集合
+        if (subFolders != null) {
+            for (File subFolder : subFolders) {// 循环显示文件夹或文件
+                if (subFolder.isFile()) {// 如果是文件则将文件添加到结果列表中
+                    result.add(subFolder);
+                } else {// 如果是文件夹,则递归调用本方法,然后把所有的文件加到结果列表中
+                    File[] foldResult = searchFile(subFolder, keyWord);
+                    Collections.addAll(result, foldResult);
+                }
+            }
+        }
+
+        File[] files = new File[result.size()];// 声明文件数组,长度为集合的长度
+        result.toArray(files);// 集合数组化
+        return files;
+    }
+
+    /**
+     * CSV文件生成方法  字符流追加:FileWriter writer = new FileWriter(file,true)
+     *
+     * @param headLabel 头部标签
+     * @param dataList  数据列表
+     * @param filePath  文件路径
+     * @param addFlag   是否追加
+     */
+    public static void writeToCsv(String headLabel, List<String> dataList, String filePath, boolean addFlag) {
+        BufferedWriter buffWriter = null;
+        try {
+            //根据指定路径构建文件对象
+            File csvFile = new File(filePath);
+            //文件输出流对象,第二个参数时boolean类型,为true表示文件追加(在已有的文件中追加内容)
+            FileWriter writer = new FileWriter(csvFile, addFlag);
+            //构建缓存字符输出流(不推荐使用OutputStreamWriter)
+            buffWriter = new BufferedWriter(writer, 1024);
+            //头部不为空则写入头部,并且换行
+            if (StrUtil.isNotBlank(headLabel)) {
+                buffWriter.write(headLabel);
+                buffWriter.newLine();
+            }
+            //遍历list
+            for (String rowStr : dataList) {
+                //如果数据不为空,则写入文件内容,并且换行
+                if (StrUtil.isNotBlank(rowStr)) {
+                    buffWriter.write(rowStr);
+                    buffWriter.newLine();//文件写完最后一个换行不用处理
+                }
+            }
+            //刷新流,也就是把缓存中剩余的内容输出到文件
+            buffWriter.flush();
+        } catch (Exception e) {
+            System.out.println("写入csv出现异常");
+            e.printStackTrace();
+        } finally {
+            try {
+                //关闭流
+                if (buffWriter != null) {
+                    buffWriter.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * 导出csv格式工具类
+     * 创建文件并放置数据  这里放置了表头一行数据
+     *
+     * @param result   导出数据
+     * @param fileName 文件名
+     */
+    public static void createCsvFile(List result, String fileName) {
+        try {
+            File csvFile = new File(fileName);  //构造文件
+            //导入HuTool中CSV工具包的CsvWriter类
+            //设置导出字符类型, CHARSET_UTF_8
+            CsvWriter writer = CsvUtil.getWriter(csvFile, CharsetUtil.CHARSET_UTF_8);
+            writer.write(result);  //通过CsvWriter中的write方法写入数据
+            writer.close();   //关闭CsvWriter
+            //保存文件
+            /*FileInputStream fileInputStream = new FileInputStream(csvFile);
+            saveFile(fileInputStream, csvFile.getName());*/
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 文件保存 覆盖保存
+     *
+     * @param inputStream
+     * @param fileName
+     */
+    public static void saveFile(InputStream inputStream, String fileName) {
+        OutputStream os = null;
+        try {
+            //保存文件路径
+            // 1K的数据缓冲 1024000 1M
+            byte[] bs = new byte[1024000];
+            // 读取到的数据长度
+            int len;
+            // 输出的文件流保存到本地文件
+            File tempFile = new File("/Users/xiaowang/Downloads");
+            if (!tempFile.exists()) {
+                tempFile.mkdirs();
+            }
+            os = new FileOutputStream(tempFile.getPath() + File.separator + fileName);
+            // 开始读取
+            while ((len = inputStream.read(bs)) != -1) {
+                os.write(bs, 0, len);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            // 完毕,关闭所有链接
+            try {
+                if (os != null) {
+                    os.close();
+                }
+                inputStream.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+}

+ 118 - 0
src/main/java/com/example/datadump/util/FtpUtil.java

@@ -0,0 +1,118 @@
+package com.example.datadump.util;
+
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.extra.ftp.Ftp;
+import cn.hutool.extra.ftp.FtpMode;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author :
+ * @description :
+ * @date : 2023/3/10 14:42
+ */
+public class FtpUtil {
+    /**
+     * 下载ftp服务器上的文件到本地
+     *
+     * @param remoteFile
+     * @param localFile
+     * @param ip
+     * @param port
+     * @param username
+     * @param password
+     * @param ftpMode
+     * @return 成功则返回字符串:success
+     */
+    public static String download(String remoteFile, String localFile, String ip, Integer port, String username, String password, FtpMode ftpMode) {
+        if (StrUtil.isBlank(localFile)) {
+            return "本地保存路径及名称不能为空";
+        }
+        File lFile = FileUtil.file(localFile);
+        Ftp ftp = null;
+        try {
+            //匿名登录(无需帐号密码的FTP服务器)
+            ftp = new Ftp(ip, port == null ? 21 : port, username, password);
+            //ftp.cd("/home/mysqlDump");
+            if (ftpMode != null) {
+                ftp.setMode(ftpMode);
+            }
+            ftp.download(remoteFile, lFile);
+        } catch (Exception e) {
+            return e.getMessage();
+        } finally {
+            //关闭连接
+            try {
+                if (ftp != null) ftp.close();
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        if (lFile.exists() && lFile.length() > 0) {
+            return "success";
+        } else {
+            lFile.delete();
+            return "download failure," + remoteFile + " maybe not exists !!";
+        }
+    }
+
+    /**
+     * 此方法不指定上传后保存的名称, 则按本地文件的名称保存
+     *
+     * @param remoteDir
+     * @param localFile
+     * @param ip
+     * @param port
+     * @param username
+     * @param password
+     * @return 成功则返回字符串:success
+     */
+    public static String upload(String remoteDir, String localFile, String ip, Integer port, String username, String password, FtpMode ftpMode) {
+        return upload(remoteDir, null, localFile, ip, port, username, password, ftpMode);
+    }
+
+    /**
+     * @param remoteDir      上传的ftp目录
+     * @param remoteFileName 保存到ftp服务器上的名称
+     * @param localFile      本地文件全名称
+     * @param ip
+     * @param port
+     * @param username
+     * @param password
+     * @return 成功则返回字符串:success
+     */
+    public static String upload(String remoteDir, String remoteFileName, String localFile, String ip, Integer port, String username, String password, FtpMode ftpMode) {
+        if (StrUtil.isBlank(localFile)) {
+            return "本地文件名称不能为空";
+        }
+        File lFile = FileUtil.file(localFile);
+        if (!lFile.exists()) {
+            return "本地文件不存在";
+        }
+        Ftp ftp = null;
+        try {
+            //匿名登录(无需帐号密码的FTP服务器)
+            ftp = new Ftp(ip, port == null ? 21 : port, username, password);
+            if (ftpMode != null) {
+                ftp.setMode(ftpMode);
+            }
+            if (StrUtil.isBlank(remoteFileName)) {
+                ftp.upload(remoteDir, lFile);
+            } else {
+                ftp.upload(remoteDir, remoteFileName, lFile);
+            }
+        } catch (Exception e) {
+            return e.getMessage();
+        } finally {
+            //关闭连接
+            try {
+                if (ftp != null) ftp.close();
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+        return "success";
+    }
+}

+ 8 - 0
src/main/resources/application.yml

@@ -0,0 +1,8 @@
+mysql.username: root
+mysql.password: '!QAZ2root'
+mysql.url: jdbc:mysql://192.168.1.205:3306/ipp?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
+mysql.table: di_tunnel,idp_nwp
+file.outpath: '/home/mysqlDump'
+td.url: jdbc:TAOS://192.168.1.208:6030/nerp_db?user=root&password=123456
+td.table: prophase_anemometry_data
+td.outpath: '/Users/xiaowang/Downloads'

+ 19 - 0
src/main/test/jiayue/service/TestDump.java

@@ -0,0 +1,19 @@
+package jiayue.service;
+
+import org.junit.Test;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class TestDump {
+
+    @Test
+    public void importTDEngine() throws Exception {
+        String s = "2020-12-31 00:10:00.0";
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
+        Date a = format.parse(s);
+        format1.format(a);
+        System.out.println(1);
+    }
+}

+ 13 - 0
src/test/java/com/example/datadump/DataDumpApplicationTests.java

@@ -0,0 +1,13 @@
+package com.example.datadump;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class DataDumpApplicationTests {
+
+    @Test
+    void contextLoads() {
+    }
+
+}