koul 4 years ago
commit
713949ab6f

+ 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/

+ 118 - 0
.mvn/wrapper/MavenWrapperDownloader.java

@@ -0,0 +1,118 @@
+/*
+ * Copyright 2007-present the original author or authors.
+ *
+ * Licensed 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.
+ */
+
+import java.net.*;
+import java.io.*;
+import java.nio.channels.*;
+import java.util.Properties;
+
+public class MavenWrapperDownloader {
+
+    private static final String WRAPPER_VERSION = "0.5.6";
+    /**
+     * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
+     */
+    private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+            + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
+
+    /**
+     * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
+     * use instead of the default one.
+     */
+    private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
+            ".mvn/wrapper/maven-wrapper.properties";
+
+    /**
+     * Path where the maven-wrapper.jar will be saved to.
+     */
+    private static final String MAVEN_WRAPPER_JAR_PATH =
+            ".mvn/wrapper/maven-wrapper.jar";
+
+    /**
+     * Name of the property which should be used to override the default download url for the wrapper.
+     */
+    private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
+
+    public static void main(String args[]) {
+        System.out.println("- Downloader started");
+        File baseDirectory = new File(args[0]);
+        System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
+
+        // If the maven-wrapper.properties exists, read it and check if it contains a custom
+        // wrapperUrl parameter.
+        File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
+        String url = DEFAULT_DOWNLOAD_URL;
+        if (mavenWrapperPropertyFile.exists()) {
+            FileInputStream mavenWrapperPropertyFileInputStream = null;
+            try {
+                mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
+                Properties mavenWrapperProperties = new Properties();
+                mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
+                url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
+            } catch (IOException e) {
+                System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
+            } finally {
+                try {
+                    if (mavenWrapperPropertyFileInputStream != null) {
+                        mavenWrapperPropertyFileInputStream.close();
+                    }
+                } catch (IOException e) {
+                    // Ignore ...
+                }
+            }
+        }
+        System.out.println("- Downloading from: " + url);
+
+        File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
+        if (!outputFile.getParentFile().exists()) {
+            if (!outputFile.getParentFile().mkdirs()) {
+                System.out.println(
+                        "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
+            }
+        }
+        System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
+        try {
+            downloadFileFromURL(url, outputFile);
+            System.out.println("Done");
+            System.exit(0);
+        } catch (Throwable e) {
+            System.out.println("- Error downloading");
+            e.printStackTrace();
+            System.exit(1);
+        }
+    }
+
+    private static void downloadFileFromURL(String urlString, File destination) throws Exception {
+        if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
+            String username = System.getenv("MVNW_USERNAME");
+            char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
+            Authenticator.setDefault(new Authenticator() {
+                @Override
+                protected PasswordAuthentication getPasswordAuthentication() {
+                    return new PasswordAuthentication(username, password);
+                }
+            });
+        }
+        URL website = new URL(urlString);
+        ReadableByteChannel rbc;
+        rbc = Channels.newChannel(website.openStream());
+        FileOutputStream fos = new FileOutputStream(destination);
+        fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+        fos.close();
+        rbc.close();
+    }
+
+}

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.6.3/apache-maven-3.6.3-bin.zip
+wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

+ 310 - 0
mvnw

@@ -0,0 +1,310 @@
+#!/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 /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="`which 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/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+    else
+      jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.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"
+        else
+            wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$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 \
+  -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+  "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+  ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

+ 182 - 0
mvnw.cmd

@@ -0,0 +1,182 @@
+@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 "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
+if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\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/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+
+FOR /F "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%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.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 "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\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%
+
+exit /B %ERROR_CODE%

+ 84 - 0
pom.xml

@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.4.2</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.uas</groupId>
+    <artifactId>huaxk-huid</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>huaxk-huid</name>
+    <description>华信科和汇顶的对接项目</description>
+
+    <properties>
+        <java.version>1.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-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.6</version>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.17</version>
+        </dependency>
+        <dependency>
+            <groupId>com.jcraft</groupId>
+            <artifactId>jsch</artifactId>
+            <version>0.1.53</version>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.jackson</groupId>
+            <artifactId>jackson-mapper-asl</artifactId>
+            <version>1.9.13</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-net</groupId>
+            <artifactId>commons-net</artifactId>
+            <version>3.6</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.5</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.8.5</version>
+        </dependency>
+        <dependency>
+            <groupId>com.oracle.ojdbc</groupId>
+            <artifactId>ojdbc8</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <finalName>${artifactId}</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 18 - 0
src/main/java/com/uas/HuaxkHuidApplication.java

@@ -0,0 +1,18 @@
+package com.uas;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+@SpringBootApplication
+@EnableCaching
+@EnableScheduling
+public class HuaxkHuidApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(HuaxkHuidApplication.class, args);
+
+    }
+
+}

+ 276 - 0
src/main/java/com/uas/service/Impl/SendHttpImpl.java

@@ -0,0 +1,276 @@
+package com.uas.service.Impl;
+
+import com.google.gson.Gson;
+import com.uas.service.SendHttp;
+import com.uas.util.JdbcUtil;
+import com.uas.util.MyX509TrustManager;
+import org.apache.http.NameValuePair;
+import org.apache.http.message.BasicNameValuePair;
+import org.springframework.stereotype.Service;
+import sun.misc.BASE64Encoder;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @author koul
+ * @email koul@usoftchina.com
+ * @date 2021-01-18 13:59
+ */
+@Service
+public class SendHttpImpl implements SendHttp {
+    /**
+     * API测试地址
+     */
+    private static final String TESTURL = "https://api-uat.goodix.com/prm-uat/goodix/agent/aDelivery/agentAutoDelivery";
+    /**
+     * API地址
+     */
+    private static final String URL = "https://api.goodix.com/prm-api/goodix/agent/aDelivery/agentAutoDelivery";
+    /**
+     * HTTPS地址
+     */
+    private static final String UR = "https://prm.goodix.com/goodix/agent/aDelivery/agentAutoDelivery";
+
+    @Override
+    public void sendCHData() {
+        //华信科深圳
+        sendPost("HUAXK_P", "SZHuaXK_I", "Z^qES&62zp");
+        //华信科苏州
+        sendPost("HXK_SU_P", "SZHuaXK_I", "Z^qES&62zp");
+        //联合无线香港
+        sendPost("LHWX_HK_P", "XGlhwx_I", "XHe3t4hlJ$Z");
+        //华信科绍兴
+        sendPost("HXK_SX", "SZHuaXK_I", "Z^qES&62zp");
+    }
+    /**
+     * 向指定 URL 发送POST方法的请求
+     *
+     * @return 所代表远程资源的响应结果
+     */
+    public void sendPost(String sob, String username, String password) {
+        PrintWriter out = null;
+        BufferedReader in = null;
+        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
+        String formatdate = format.format(new Date());
+        Connection connect = null;
+        Statement statement = null;
+        try {
+            connect = JdbcUtil.getConnectBySob(sob);
+            statement = connect.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
+            List<Map<String, String>> maps = getDate(statement, sob);
+            for (Map<String, String> map : maps) {
+                List<NameValuePair> params = new ArrayList<NameValuePair>();
+                ResultSet result = null;
+                try {
+                    String name = "";
+                    String cd_varchar50_9 = map.get("cd_varchar50_9");
+                    String cd_varchar50_1 = map.get("cd_varchar50_1");
+                    String cd_varchar50_4 = map.get("cd_varchar50_4");
+                    if (cd_varchar50_9 != null) {
+                        cd_varchar50_9 = cd_varchar50_9.replace(";", ",").substring(0, cd_varchar50_9.length() - 1);
+                        result = statement.executeQuery("select fp_path from " + sob + ".filepath where fp_id in (" + cd_varchar50_9 + ")");
+
+                        if (result.getRow() == 0) {
+                            while (result.next()) {
+                                String path = result.getString("fp_path");
+                                String substring = path.substring(path.lastIndexOf("."));
+                                name = name + cd_varchar50_4 + "_" + formatdate + substring;
+                            }
+                        } else {
+                            while (result.next()) {
+                                String path = result.getString("fp_path");
+                                String substring = path.substring(path.lastIndexOf("."));
+                                name = name + cd_varchar50_4 + "_" + formatdate + substring + ";";
+                            }
+                        }
+                    }
+                    if (map.get("cd_varchar50_2") != null) {
+                        params.add(new BasicNameValuePair("screenCustomerNo", map.get("cd_varchar50_2")));
+                    }
+                    if (map.get("cd_varchar50_6") != null) {
+                        params.add(new BasicNameValuePair("softCustomerNo", map.get("cd_varchar50_6")));
+                    }
+                    params.add(new BasicNameValuePair("terminalCustomerNo", map.get("cd_varchar50_7")));
+                    if (map.get("cd_varchar50_8") != null) {
+                        params.add(new BasicNameValuePair("whiteCustomerName", map.get("cd_varchar50_8")));
+                    }
+                    params.add(new BasicNameValuePair("modelName", cd_varchar50_1));
+                    params.add(new BasicNameValuePair("agentOrderCode", map.get("cd_varchar50_4")));
+                    params.add(new BasicNameValuePair("deliveryTime", map.get("cd_date_1")));
+                    params.add(new BasicNameValuePair("deliveryAmount", map.get("cd_number_1")));
+                    params.add(new BasicNameValuePair("fileName", name));
+                    if (map.get("cd_remark") != null) {
+                        params.add(new BasicNameValuePair("note", map.get("cd_remark")));
+                    }
+
+                } catch (SQLException e) {
+                    e.printStackTrace();
+                } finally {
+                    try {
+                        result.close();
+                    } catch (SQLException e) {
+                        e.printStackTrace();
+                    }
+                }
+                // 创建SSLContext对象,并使用我们指定的信任管理器初始化
+                TrustManager[] tm = {new MyX509TrustManager()};
+                SSLContext sslContext = SSLContext.getInstance("SSL");
+                sslContext.init(null, tm, new java.security.SecureRandom());
+
+                // 从上述SSLContext对象中得到SSLSocketFactory对象
+                SSLSocketFactory ssf = sslContext.getSocketFactory();
+
+                // 打开和URL之间的连接
+                String s="";
+                for (NameValuePair nv:params) {
+                    s = s +nv.getName()+"="+ URLEncoder.encode(nv.getValue(), "UTF-8") + "&" ;
+                }
+                String ss = URL + "?" +s.substring(0,s.length()-1);
+                URL realUrl = new URL(ss);
+                HttpsURLConnection conn = (HttpsURLConnection) realUrl.openConnection();
+                conn.setSSLSocketFactory(ssf);
+
+                // 设置通用的请求属性
+                conn.setRequestProperty("accept", "*/*");
+                conn.setRequestProperty("connection", "Keep-Alive");
+                conn.setRequestProperty("content-Type", "application/json");
+                conn.setRequestProperty("user-agent",
+                        "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+                String user = String.format("%s:%s", new Object[]{username, password});
+                String auth = new BASE64Encoder().encode(user.getBytes("UTF-8"));
+                conn.setRequestProperty("Authorization", "Basic " + auth);
+                // 发送POST请求必须设置如下两行
+                conn.setDoOutput(true);
+                conn.setDoInput(true);
+                // 获取URLConnection对象对应的输出流
+                out = new PrintWriter(conn.getOutputStream());
+                // 发送请求参数
+                out.print(params);
+                // flush输出流的缓冲
+                out.flush();
+                // 定义BufferedReader输入流来读取URL的响应
+                in = new BufferedReader(
+                        new InputStreamReader(conn.getInputStream()));
+                String line;
+                String res = "";
+                while ((line = in.readLine()) != null) {
+                    res += line;
+                }
+                Gson gson = new Gson();
+                Map<String, Object> map1 = new HashMap<String, Object>();
+                map1 = gson.fromJson(res, map1.getClass());
+                /*JSONObject object = JSONObject.parseObject(res);*/
+                Boolean statu = (Boolean) map1.get("state");
+                Integer cd_id = Integer.valueOf(map.get("cd_id"));
+                if (statu) {
+                    statement.execute("update " + sob + ".customtabledetail set cd_number_12 = -1,cd_varchar200_1 = '' where cd_id = " + cd_id);
+                } else {
+                    String stateInfo = (String) map1.get("stateInfo");
+                    if (stateInfo.indexOf(":") != -1) {
+                        stateInfo = stateInfo.substring(0, stateInfo.indexOf(":"));
+                    }
+                    statement.execute("update " + sob + ".customtabledetail set cd_varchar200_1 = '" + stateInfo + "' " +
+                            "where cd_id = " + cd_id);
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                statement.close();
+                connect.close();
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
+
+            try {
+                if (out != null) {
+                    out.close();
+                }
+                if (in != null) {
+                    in.close();
+                }
+            } catch (IOException ex) {
+                ex.printStackTrace();
+            }
+
+        }
+
+    }
+
+    private List<Map<String, String>> getDate(Statement statement, String sob) {
+        List<Map<String, String>> maps = new ArrayList<>();
+        ResultSet rs = null;
+        try {
+            rs = statement.executeQuery("select ct_id,cd_id,cd_varchar50_1,cd_varchar50_2,cd_varchar50_3," +
+                    "cd_varchar50_4,cd_varchar50_5,cd_varchar50_6,cd_varchar50_7,cd_varchar50_8,cd_varchar50_9,cd_number_1," +
+                    "cd_date_1,cd_varchar50_10,cd_number_2,cd_varchar50_11,cd_varchar50_12 from " + sob +
+                    ".customtabledetail left join " + sob + ".customtable on ct_id = cd_ctid where nvl(cd_number_12,0)= 0 " +
+                    "and ct_status = '已审核' and ct_caller = 'HDXHCHMXB' and cd_varchar100_1 = '出货单' and nvl(cd_number_1,0)>0");
+            while (rs.next()) {
+                Map<String, String> map = new HashMap<>();
+                int cd_id = rs.getInt("cd_id");
+                String cd_date_1 = rs.getString("cd_date_1");
+                cd_date_1 = cd_date_1.substring(0, 10);
+                String cd_varchar50_5 = rs.getString("cd_varchar50_5");
+                String cd_varchar50_6 = rs.getString("cd_varchar50_6");
+                String cd_varchar50_7 = rs.getString("cd_varchar50_7");
+                String cd_varchar50_8 = rs.getString("cd_varchar50_8");
+                String cd_varchar50_1 = rs.getString("cd_varchar50_1");
+                String cd_varchar50_4 = rs.getString("cd_varchar50_4");
+                String cd_varchar50_2 = rs.getString("cd_varchar50_2");
+                //String cd_remark = rs.getString("cd_remark");
+                int cd_number_1 = rs.getInt("cd_number_1");
+                int cd_number_2 = rs.getInt("cd_number_2");
+                String cd_varchar50_9 = rs.getString("cd_varchar50_9");
+                String cd_varchar50_10 = rs.getString("cd_varchar50_10");
+                map.put("cd_id", cd_id + "");
+                map.put("cd_date_1", cd_date_1);
+                map.put("cd_varchar50_5", cd_varchar50_5);
+                map.put("cd_varchar50_6", cd_varchar50_6);
+                map.put("cd_varchar50_7", cd_varchar50_7);
+                map.put("cd_varchar50_8", cd_varchar50_8);
+                if (cd_varchar50_1 != null) {
+                    cd_varchar50_1 = cd_varchar50_1.contains("(") && cd_varchar50_1.contains(")") ?
+                            cd_varchar50_1.replace("(", "(") : cd_varchar50_1;
+                    cd_varchar50_1 = cd_varchar50_1.contains("(") ? cd_varchar50_1.substring(0,
+                            cd_varchar50_1.indexOf("(")) : cd_varchar50_1;
+                }
+                map.put("cd_varchar50_1", cd_varchar50_1);
+                map.put("cd_varchar50_4", cd_varchar50_4);
+                //map.put("cd_remark", cd_remark);
+                map.put("cd_number_1", cd_number_1 + "");
+                map.put("cd_number_2", cd_number_2 + "");
+                map.put("cd_varchar50_9", cd_varchar50_9);
+                map.put("cd_varchar50_10", cd_varchar50_10);
+                map.put("cd_varchar50_2", cd_varchar50_2);
+                maps.add(map);
+            }
+        } catch (SQLException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                rs.close();
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }
+        }
+        return maps;
+    }
+}

+ 144 - 0
src/main/java/com/uas/service/Impl/UploadAttachImpl.java

@@ -0,0 +1,144 @@
+package com.uas.service.Impl;
+
+import com.uas.service.UploadAttach;
+import com.uas.util.BaseUtil;
+import com.uas.util.FtpUtil;
+import com.uas.util.JdbcUtil;
+import org.apache.commons.net.ftp.FTPClient;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @author koul
+ * @email koul@usoftchina.com
+ * @date 2021-01-18 14:53
+ */
+@Service
+public class UploadAttachImpl implements UploadAttach {
+
+    @Override
+    public void uploadAttach() {
+        //华信科深圳
+        uploadBySob("HUAXK_P","HDSZ");
+        //华信科苏州
+        uploadBySob("HXK_SU_P","HDSZ");
+        //联合无线香港
+        uploadBySob("LHWX_HK_P","HDSZ");
+        //华信科绍兴
+        uploadBySob("HXK_SX","HDSZ");
+    }
+
+    public void uploadBySob(String sob,String depot) {
+        Statement statement = null;
+        FTPClient client = null;
+        Map<String,Object> ftpConfig = JdbcUtil.getFtpConfigs();
+        Map<String,Object> config = null;
+        Connection connect = null;
+        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
+        String s = format.format(new Date());
+        try{
+            connect = JdbcUtil.getConnectBySob(sob);
+            if(connect!=null){
+                statement = connect.createStatement();
+                //注意上传位置是数据库名+depot
+                config = (Map<String, Object>) ftpConfig.get(sob + "-" + depot);
+                client = FtpUtil.connect(config,config.get("in").toString());
+                String folder = "/"+config.get("in").toString()+"/"+s.substring(0,4)+"/"+s.substring(4,6);
+                String dir = "/"+config.get("in").toString()+"/"+s.substring(0,4);
+                client.makeDirectory(dir);
+                client.makeDirectory(folder);
+                List<Map<String, String>> maps = getData(statement, sob);
+                for (Map<String, String> map:maps) {
+                    String cd_varchar50_9 = map.get("cd_varchar50_9");
+                    String cd_id = map.get("cd_id");
+                    String cd_varchar50_1 = map.get("cd_varchar50_1");
+                    String cd_varchar50_4 = map.get("cd_varchar50_4");
+                    if (cd_varchar50_9!=null) {
+                        cd_varchar50_9 = cd_varchar50_9.replace(";", ",").substring(0, cd_varchar50_9.length() - 1);
+                        ResultSet result = statement.executeQuery("select fp_path from " + sob + ".filepath where fp_id in (" + cd_varchar50_9 + ")");
+                        while (result.next()) {
+                            String path = result.getString("fp_path");
+                            String substring = path.substring(path.lastIndexOf("."));
+                            File file = new File(path);
+                            if (client != null) {
+                                String name = cd_varchar50_4+ "_" + s + substring;
+                                boolean ip = upload(client, config.get("ip").toString(), folder, file, name);
+                                if (ip){
+                                    statement.execute("update "+sob+".customtabledetail set cd_number_10 = -1 where cd_id = "+cd_id);
+                                }
+                            }
+
+                        }
+                    }
+                }
+            }
+        }catch(Exception e){
+            BaseUtil.getLogger().error(e.toString());
+            e.printStackTrace();
+        }finally{
+            if(statement!=null){
+                try {
+                    statement.close();
+                } catch (SQLException e1) {
+                    BaseUtil.getLogger().error(e1.toString());
+                    e1.printStackTrace();
+                }
+                statement = null;
+            }
+            //把当前的连接关闭
+            try {
+                if(connect!=null){
+                    connect.close();
+                }
+            } catch (SQLException e) {
+                e.printStackTrace();
+            }finally{
+                connect = null;
+            }
+        }
+
+    }
+
+    private List<Map<String, String>> getData(Statement statement,String sob) throws SQLException{
+        List<Map<String, String>> maps = new ArrayList<>();
+        ResultSet resultSet = statement.executeQuery("select cd_id,cd_varchar50_9,cd_varchar50_10,cd_number_2," +
+                "cd_varchar50_1,cd_varchar50_4 from " + sob +".customtabledetail left " +
+                "join " + sob + ".customtable on ct_id = cd_ctid where ct_status = '已审核' and " +
+                "ct_caller = 'HDXHCHMXB' and cd_varchar100_1 = '出货单' and nvl(cd_number_1,0)>0 and nvl(cd_number_10,0)" +
+                "=0 and cd_number_12 = -1");
+        while (resultSet.next()){
+            Map<String, String> map = new HashMap<>();
+            map.put("cd_id",resultSet.getInt("cd_id")+"");
+            map.put("cd_varchar50_9",resultSet.getString("cd_varchar50_9"));
+            map.put("cd_varchar50_10",resultSet.getString("cd_varchar50_10"));
+            map.put("cd_number_2",resultSet.getInt("cd_number_2")+"");
+            String cd_varchar50_1 = resultSet.getString("cd_varchar50_1");
+            if (cd_varchar50_1!=null){
+                cd_varchar50_1=cd_varchar50_1.contains("(") && cd_varchar50_1.contains(")")?
+                        cd_varchar50_1.replace("(", "("):cd_varchar50_1;
+                cd_varchar50_1 = cd_varchar50_1.contains("(")?cd_varchar50_1.substring(0,
+                        cd_varchar50_1.indexOf("(")):cd_varchar50_1;
+            }
+            map.put("cd_varchar50_1",cd_varchar50_1);
+            map.put("cd_varchar50_4",resultSet.getString("cd_varchar50_4"));
+            maps.add(map);
+        }
+        return maps;
+    }
+
+    private boolean upload(FTPClient client,String ip,String folder,File file,String name){
+        boolean flag = false;
+        if(client!=null){
+            flag = FtpUtil.uploadFile(client, folder,file,name);
+        }
+        BaseUtil.getLogger().info("upload " + file.getName() + " to " + ip + ":" + folder + " " + (flag?"success":"fail")+"");
+        return flag;
+    }
+}

+ 10 - 0
src/main/java/com/uas/service/SendHttp.java

@@ -0,0 +1,10 @@
+package com.uas.service;
+
+/**
+ * @author koul
+ * @email koul@usoftchina.com
+ * @date 2021-01-18 13:57
+ */
+public interface SendHttp {
+    void sendCHData();
+}

+ 10 - 0
src/main/java/com/uas/service/UploadAttach.java

@@ -0,0 +1,10 @@
+package com.uas.service;
+
+/**
+ * @author koul
+ * @email koul@usoftchina.com
+ * @date 2021-01-18 14:52
+ */
+public interface UploadAttach {
+    void uploadAttach();
+}

+ 37 - 0
src/main/java/com/uas/task/ScheduleTask.java

@@ -0,0 +1,37 @@
+package com.uas.task;
+
+import com.uas.service.SendHttp;
+import com.uas.service.UploadAttach;
+import com.uas.util.BaseUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author koul
+ * @email koul@usoftchina.com
+ * @date 2020-10-27 15:42
+ */
+@Component("scheduleTask")
+public class ScheduleTask {
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    @Autowired
+    private SendHttp sendHttp;
+    @Autowired
+    private UploadAttach uploadAttach;
+
+    /**
+     * 文件处理
+     */
+    @Scheduled(cron = "0 0 1 * * ? ")
+    public void ediSendAndReceive() {
+        BaseUtil.getLogger().info("文件处理开始");
+        long timeMillis = System.currentTimeMillis();
+        sendHttp.sendCHData();
+        uploadAttach.uploadAttach();
+        BaseUtil.getLogger().info("文件处理结束:用时" + ((System.currentTimeMillis() - timeMillis) / 1000));
+    }
+}

+ 35 - 0
src/main/java/com/uas/util/BaseUtil.java

@@ -0,0 +1,35 @@
+package com.uas.util;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.PropertyConfigurator;
+
+import java.io.IOException;
+import java.util.Properties;
+
+
+public class BaseUtil {
+	public static Logger logger;
+	
+	/**
+	 * 获取日志类
+	 * @return 日志类
+	 */
+	public static Logger getLogger(){
+		if(logger==null){
+			logger = Logger.getLogger(BaseUtil.class);
+		    //loger所需的配置文件路径   
+			Properties prop = new Properties();
+		    try {
+				prop.load(BaseUtil.class.getResourceAsStream("/log4j.properties"));
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		    PropertyConfigurator.configure(prop); 
+		}
+		return logger;
+	}
+	
+	public static void logDownload(String fileName,String ip,String downloadpath){
+		getLogger().info("download " + fileName + " from " + ip + " path:" + downloadpath);
+	}
+}

+ 199 - 0
src/main/java/com/uas/util/FtpUtil.java

@@ -0,0 +1,199 @@
+package com.uas.util;
+
+import com.jcraft.jsch.JSchException;
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPFile;
+import org.apache.commons.net.ftp.FTPReply;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author usoft
+ */
+public class FtpUtil {
+	/**
+	 * 连接到ftp站点,判断是否可以连接
+	 * @param path  要连接到的目录
+	 * @param addr  站点地址
+	 * @param port  端口
+	 * @param username 用户名
+	 * @param password 密码
+	 * @return
+	 * @throws Exception
+	 */
+	public static boolean connect(String path, String addr, int port, String username,
+			String password) {
+		boolean result = false;
+		try {
+			FTPClient ftp = new FTPClient();
+			int reply;
+			ftp.connect(addr, port);
+			ftp.login(username, password);
+			ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
+			reply = ftp.getReplyCode();
+			if (!FTPReply.isPositiveCompletion(reply)) {
+				ftp.disconnect();
+				return result;
+			}
+			ftp.changeWorkingDirectory(path);
+			result = true;
+			return result;
+		}catch (Exception e){
+			SFTPUtil sftp = new SFTPUtil(username, password, addr, port);
+			try {
+				sftp.login();
+				result = true;
+			} catch (JSchException e1) {
+				e1.printStackTrace();
+			}
+			return result;
+		}
+	}
+	
+	/**
+	 * 获取ftp连接,该连接指向ftp配置中的downloadpath文件夹
+	 * @param map 包含ftp连接配置的map
+	 */
+	public static FTPClient connect(Map<String,Object> map) throws Exception {
+		return connect(map,map.get("downloadpath").toString());
+	}
+
+	/**
+	 * 获取ftp连接,该连接指向ftp配置中的downloadpath文件夹
+	 * @param map 包含ftp连接配置的map
+	 */
+	public static FTPClient connect(Map<String,Object> map,String path){
+		FTPClient ftp = null;
+		String addr = null;
+		try{
+			addr = map.get("ip").toString();
+			int port = Integer.parseInt(map.get("port").toString());
+			String username = map.get("user").toString();
+			String password = map.get("password").toString();
+			ftp = new FTPClient();
+			int reply;
+            ftp.setDefaultTimeout(30*1000);
+            ftp.setConnectTimeout(30*1000);
+            ftp.setDataTimeout(30*1000);
+            //设置ftp为被动模式,解决有时候ftp会卡住问题
+            ftp.enterLocalPassiveMode();
+			ftp.connect(addr, port);
+			if(!ftp.login(username, password)){
+				return null;
+			}
+			ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
+			reply = ftp.getReplyCode();
+			if (!FTPReply.isPositiveCompletion(reply)) {
+				ftp.disconnect();
+				return null;
+			}
+			ftp.changeWorkingDirectory(path);
+			return ftp;			
+		}catch(Exception e){ 
+			e.printStackTrace();
+			BaseUtil.getLogger().error("ip:" + addr + e.toString());
+			return null;
+		}
+	}
+
+	/**
+	 * 上传文件
+	 * @param ftpClient 已连接的ftp客户端
+	 * @param pathname 路径
+	 * @param file 待上传的文件
+	 * @return 上传结果
+	 */
+	public static boolean uploadFile(FTPClient ftpClient, String pathname, File file,String name) {
+		boolean flag = false;
+		ftpClient.setControlEncoding("UTF-8");
+		try {
+			ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
+			boolean change = ftpClient.changeWorkingDirectory(pathname+"/");
+			if(!change){
+				BaseUtil.getLogger().info("change to " + pathname + " fail");
+				return false;
+			}
+			InputStream inputStream = new FileInputStream(file);
+			ftpClient.enterLocalPassiveMode();
+			ftpClient.storeFile(name, inputStream);
+			inputStream.close();
+			//ftpClient.logout();
+			flag = true;
+		} catch (Exception e) {
+			e.printStackTrace();
+			BaseUtil.getLogger().error(e.toString());
+			if (ftpClient.isConnected()) {
+				try {
+					ftpClient.disconnect();
+				} catch (IOException e1) {
+					BaseUtil.getLogger().error(e1.toString());
+					e1.printStackTrace();
+				}
+			}
+		}
+		return flag;
+	}
+	
+	/**
+	 * 删除后关闭ftp连接
+	 * @param ftpClient 
+	 * @param filename 要删除的文件名
+	 * @return 删除结果
+	 */
+	public static boolean deleteFile(FTPClient ftpClient,String filename) {
+		boolean flag = false;
+		try {
+			ftpClient.dele(filename);
+			flag = true;
+		} catch (Exception e) {
+			BaseUtil.getLogger().error(e.toString());
+			e.printStackTrace();
+		}
+		return flag;
+	}
+
+	/**
+	 * 
+	 * @param ftpClient
+	 * fileType 需要下载的文件类型
+	 * @return 获取连接到的ftp站点下的文件夹所有文件
+	 */
+	public static List<File> downloadAllFileByType(FTPClient ftpClient,String fileType) {
+		List<File> files = new ArrayList<File>();	
+		try {
+			ftpClient.enterLocalPassiveMode();
+			FTPFile[] ftpFiles = ftpClient.listFiles();
+			for (FTPFile file : ftpFiles) {
+				if(file.getName().toUpperCase().endsWith("." + fileType)){
+					File localFile = new File(System.getProperty("java.io.tmpdir") + File.separator + file.getName());
+					OutputStream os = new FileOutputStream(localFile);
+					ftpClient.retrieveFile(file.getName(), os);
+					os.close();
+					files.add(localFile);					
+				}
+			}
+		} catch (Exception e) {
+			BaseUtil.getLogger().error(e.toString());
+			e.printStackTrace();
+		}
+		return files;
+	}
+	
+	/**
+	 * 关闭ftp连接
+	 * @param ftpClient
+	 */
+	public static void closeFtpClient(FTPClient ftpClient){
+		if (ftpClient.isConnected()) {
+			try {
+				ftpClient.logout();
+			} catch (IOException e) {
+				BaseUtil.getLogger().error(e.toString());
+			}
+		}		
+	}
+	
+}

+ 256 - 0
src/main/java/com/uas/util/JdbcUtil.java

@@ -0,0 +1,256 @@
+package com.uas.util;
+
+
+import org.codehaus.jackson.map.ObjectMapper;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.*;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+public class JdbcUtil {
+	public static Map<String,Object> ftpConfigs;
+	public static Map<String,Object> dbConfigs;
+	public static Connection connection;	
+	
+	/**
+	 * 从ftpconfigs配置文件中获取ftp站点配置信息
+	 * @return Map<String,Object>
+	 */
+	@SuppressWarnings("unchecked")
+	public static Map<String,Object> getFtpConfigs(){
+		if(ftpConfigs==null){
+			try {
+				ftpConfigs = new ObjectMapper().readValue(JdbcUtil.class.getResourceAsStream("/ftpconfig.properties"), HashMap.class);
+			}catch (Exception e) {
+				BaseUtil.getLogger().error(e.toString());
+				e.printStackTrace();
+			}			
+		}
+		return ftpConfigs;
+	}
+	
+	/**
+	 * 从dbconfig配置文件中获取数据库配置信息
+	 * @return Map<String,Object>
+	 */
+	@SuppressWarnings("unchecked")
+	public static Map<String,Object> getDBConfigs(){
+		if(dbConfigs==null){
+			try {
+				dbConfigs = new ObjectMapper().readValue(JdbcUtil.class.getResourceAsStream("/dbconfig.properties"), HashMap.class);
+			}catch (Exception e) {
+				BaseUtil.getLogger().error(e.toString());
+				e.printStackTrace();
+			}			
+		}
+		return dbConfigs;
+	}
+	
+	/**
+	 * 连接到数据库
+	 * @param url 地址
+	 * @param user 用户名
+	 * @param password 密码
+	 * @return 返回一个连接
+	 * @throws Exception
+	 */
+	public static Connection getConnect(String url,String user,String password) throws Exception{
+        Class.forName("oracle.jdbc.driver.OracleDriver");// 加载Oracle驱动程序
+        connection = DriverManager.getConnection(url, user, password);// 获取连接
+        return connection;	       
+	}
+	
+	/**
+	 * 从dbconfig配置文件中获取数据库连接
+	 * @return 返回数据库连接
+	 */
+	public static Connection getConnect(){
+		if(connection==null){
+		    try{
+				InputStream dbinput = JdbcUtil.class.getResourceAsStream("/dbconfig.properties");
+				Properties prop = new Properties();
+				prop.load(dbinput);
+				connection = JdbcUtil.getConnect(prop.getProperty("url"), prop.getProperty("user"), prop.getProperty("password"));
+		    }catch (Exception e){
+		    	try {
+					System.in.read();
+				} catch (IOException e2) {
+					// TODO Auto-generated catch block
+					e2.printStackTrace();
+				}
+		    	BaseUtil.getLogger().error(e.toString());
+		    	try {
+		    		if(connection!=null){
+		    			connection.close();
+		    		}				
+				} catch (SQLException e1) {
+					BaseUtil.getLogger().error(e1.toString());
+					e1.printStackTrace();
+				}finally{
+					connection = null;
+				}
+		        e.printStackTrace();
+		    } 			
+		}
+		return connection;
+	}
+	
+	/**
+	 * 从dbconfig配置文件中获取数据库连接
+	 * @return 返回数据库连接
+	 */
+	@SuppressWarnings("unchecked")
+	public static Connection getConnectBySob(String sob){
+		Map<String,Object> dbServMaps = getDBConfigs();
+		Map<String,Object> dbServMap = (Map<String,Object>)dbServMaps.get(sob);
+		//先把当前的连接关闭
+		try {
+			if(connection!=null){
+				connection.close();
+			}
+		} catch (SQLException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}finally{
+			connection = null;
+		}
+		
+	    try{
+			connection = JdbcUtil.getConnect(dbServMap.get("url").toString(), dbServMap.get("user").toString(), dbServMap.get("password").toString());
+	    }catch (Exception e){
+	    	try {
+				System.in.read();
+			} catch (IOException e2) {
+				// TODO Auto-generated catch block
+				e2.printStackTrace();
+			}
+	    	BaseUtil.getLogger().error(e.toString());
+	    	try {
+	    		if(connection!=null){
+	    			connection.close();
+	    		}				
+			} catch (SQLException e1) {
+				BaseUtil.getLogger().error(e1.toString());
+				e1.printStackTrace();
+			}finally{
+				connection = null;
+			}
+	        e.printStackTrace();
+	    } 
+		
+		return connection;
+	}
+	
+	/**
+	 * 关闭连接
+	 * @param con
+	 * @param pre
+	 * @param result
+	 * @return
+	 */
+	public static boolean closeCn(Connection con,PreparedStatement pre,ResultSet result){
+        try{
+            if (result != null) {
+				result.close();
+				result = null;
+			}
+            if (pre != null) {
+				pre.close();
+				pre = null;
+			}
+            if (con != null) {
+				con.close();
+			}
+        }
+        catch (Exception e){
+        	BaseUtil.getLogger().error(e.toString());
+            e.printStackTrace();
+        }
+		return true;
+	}
+	
+	/**
+	 * 执行多条sql语句
+	 * @param connection 连接
+	 * @param str 多条sqls语句
+	 * @return
+	 */
+	@SuppressWarnings("finally")
+	public static boolean executeSqls(Connection connection,List<String> str){
+		Statement statement = null;
+		boolean bol = true;
+		try{		
+			statement = connection.createStatement();		
+			for(String sql:str){
+				statement.addBatch(sql);
+			}
+			try {
+				statement.setQueryTimeout(180);
+				statement.executeBatch();
+			} catch (SQLException e) {
+				bol = false;
+				BaseUtil.getLogger().error(e.toString());
+				try {
+					statement.close();
+				} catch (SQLException e1) {
+					BaseUtil.getLogger().error(e1.toString());
+					e1.printStackTrace();
+				}
+				e.printStackTrace();
+			}
+			statement.close();
+		}catch(Exception e){
+			bol = false;
+			BaseUtil.getLogger().error(e.toString());
+			try {
+				if(connection!=null){
+					connection.rollback();
+				}				
+			} catch (SQLException e1) {
+				BaseUtil.getLogger().error(e1.toString());
+				e1.printStackTrace();
+			}
+			e.printStackTrace();
+		}finally{
+			statement = null;
+			return bol;
+		}
+	}
+	
+	@SuppressWarnings("finally")
+	public static int getIdBySeq(String seq){
+		connection = getConnect();
+		Statement statement = null;
+		int id = 0;
+		if(seq!=null&!"".equals(seq)){
+			try{			
+				statement = connection.createStatement();		
+				ResultSet rs = statement.executeQuery("select " + seq + ".nextval id from dual");
+				if(rs.next()){
+					id = rs.getInt("id");
+				}
+				rs.close();
+				statement.close();
+			}catch(Exception e){
+				BaseUtil.getLogger().error(e.toString());
+				try {
+					if(connection!=null){
+						connection.rollback();
+					}				
+				} catch (SQLException e1) {
+					BaseUtil.getLogger().error(e1.toString());
+					e1.printStackTrace();
+				}
+				e.printStackTrace();
+			}finally{
+				statement = null;
+				return id;
+			}			
+		}
+		return id;
+	}
+}

+ 28 - 0
src/main/java/com/uas/util/MyX509TrustManager.java

@@ -0,0 +1,28 @@
+package com.uas.util;
+
+import javax.net.ssl.X509TrustManager;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+/**
+ * @author koul
+ * @email koul@usoftchina.com
+ * @date 2020-08-26 9:06
+ */
+public class MyX509TrustManager implements X509TrustManager{
+
+    @Override
+    public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+
+    }
+
+    @Override
+    public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+
+    }
+
+    @Override
+    public X509Certificate[] getAcceptedIssuers() {
+        return null;
+    }
+}

+ 579 - 0
src/main/java/com/uas/util/SFTPUtil.java

@@ -0,0 +1,579 @@
+package com.uas.util;
+
+import com.jcraft.jsch.*;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
+import java.util.*;
+
+
+/**
+ * 类说明 sftp工具类
+ */
+public class SFTPUtil {
+    private transient Logger log = LoggerFactory.getLogger(this.getClass());
+
+    private ChannelSftp sftp;
+
+    private Session session;
+    /** SFTP 登录用户名*/
+    private String username;
+    /** SFTP 登录密码*/
+    private String password;
+    /** 私钥 */
+    private String privateKey;
+    /** SFTP 服务器地址IP地址*/
+    private String host;
+    /** SFTP 端口*/
+    private int port;
+
+
+    /**
+     * 构造基于密码认证的sftp对象
+     */
+    public SFTPUtil(String username, String password, String host, int port) {
+        this.username = username;
+        this.password = password;
+        this.host = host;
+        this.port = port;
+    }
+
+    /**
+     * 构造基于秘钥认证的sftp对象
+     */
+    public SFTPUtil(String username, String host, int port, String privateKey) {
+        this.username = username;
+        this.host = host;
+        this.port = port;
+        this.privateKey = privateKey;
+    }
+
+    public SFTPUtil(){}
+
+    /**
+     * 连接sftp服务器
+     */
+    public boolean login() throws JSchException {
+        boolean result = false;
+        JSch jsch = new JSch();
+        if (privateKey != null) {
+            jsch.addIdentity(privateKey);// 设置私钥
+        }
+
+        session = jsch.getSession(username, host, port);
+
+        if (password != null) {
+            session.setPassword(password);
+        }
+        Properties config = new Properties();
+        config.put("StrictHostKeyChecking", "no");
+
+        session.setConfig(config);
+        session.connect();
+
+        Channel channel = session.openChannel("sftp");
+        channel.connect();
+
+        sftp = (ChannelSftp) channel;
+        result = true;
+        return result;
+    }
+
+    /**
+     * 关闭连接 server
+     */
+    public void logout(){
+        if (sftp != null) {
+            if (sftp.isConnected()) {
+                sftp.disconnect();
+            }
+        }
+        if (session != null) {
+            if (session.isConnected()) {
+                session.disconnect();
+            }
+        }
+    }
+
+
+    /**
+     * 将输入流的数据上传到sftp作为文件。文件完整路径=basePath+directory
+     * @param basePath  服务器的基础路径
+     * @param directory  上传到该目录
+     * @param sftpFileName  sftp端文件名
+     * @param input   输入流
+     */
+    public boolean upload(String basePath,String directory, String sftpFileName, InputStream input) throws SftpException{
+        boolean flag =false;
+        try {
+            sftp.cd(basePath);
+            sftp.cd(directory);
+            flag = true;
+            sftp.put(input, sftpFileName);  //上传文件
+        } catch (SftpException e) {
+            //目录不存在,则创建文件夹
+           /* String [] dirs=directory.split("/");
+            String tempPath=basePath;
+            for(String dir:dirs){
+                if(null== dir || "".equals(dir)) continue;
+                tempPath+="/"+dir;
+                try{
+                    sftp.cd(tempPath);
+                }catch(SftpException ex){
+                    sftp.mkdir(tempPath);
+                    sftp.cd(tempPath);
+                }
+            }*/
+            flag = false;
+        }
+        return flag;
+    }
+
+
+    /**
+     * 下载文件。
+     * @param directory 下载目录
+     * @param downloadFile 下载的文件
+     * @param saveFile 存在本地的路径
+     */
+    public void download(String directory, String downloadFile, String saveFile) throws SftpException, FileNotFoundException{
+        if (directory != null && !"".equals(directory)) {
+            sftp.cd(directory);
+        }
+        File file = new File(saveFile);
+        sftp.get(downloadFile, new FileOutputStream(file));
+    }
+
+    /**
+     * 下载文件
+     * @param directory 下载目录
+     * @param downloadFile 下载的文件名
+     * @return 字节数组
+     */
+    public byte[] download(String directory, String downloadFile) throws SftpException, IOException{
+        if (directory != null && !"".equals(directory)) {
+            sftp.cd(directory);
+        }
+        InputStream is = sftp.get(downloadFile);
+
+        byte[] fileData = IOUtils.toByteArray(is);
+
+        return fileData;
+    }
+
+
+    /**
+     * 删除文件
+     * @param directory 要删除文件所在目录
+     * @param deleteFile 要删除的文件
+     */
+    public void delete(String directory, String deleteFile) throws SftpException{
+        sftp.cd(directory);
+        sftp.rm(deleteFile);
+    }
+
+
+    /**
+     * 列出目录下的文件
+     * @param
+     * @param directory 要列出的目录
+     */
+    public List<File> listFiles(String directory) throws SftpException {
+        Vector<ChannelSftp.LsEntry> list = sftp.ls(directory);
+        List<File> files = new ArrayList<>();
+        if (list.size()>0&&list!=null) {
+            for (ChannelSftp.LsEntry entry : list) {
+                if (!".".equals(entry.getFilename()) && !"..".equals(entry.getFilename())) {
+                    File file = new File("/"+directory+"/");
+                    files.add(file);
+                }
+            }
+        }
+        return files;
+    }
+
+    /**
+     * 下载流
+     * @param
+     * @param directory 下载目录
+     */
+    public List<File> download(String directory) {
+        try {
+            Vector<ChannelSftp.LsEntry> list = sftp.ls(directory);
+            List<File> ls = new ArrayList<File>();
+            if (list.size()>0&&list!=null) {
+                for (ChannelSftp.LsEntry entry : list) {
+                    if (!".".equals(entry.getFilename()) && !"..".equals(entry.getFilename())) {
+                        if (entry.getFilename().endsWith(".xml")) {
+                            InputStream is = sftp.get(directory+"/"+entry.getFilename());
+                            File temp= File.createTempFile(entry.getFilename(),"");
+                            OutputStream os = new FileOutputStream(temp);
+                            int bytesRead = 0;
+                            byte[] buffer = new byte[102400];
+                            while ((bytesRead = is.read(buffer, 0, 102400)) != -1) {
+                                os.write(buffer, 0, bytesRead);
+                            }
+                            is.close();
+                            os.close();
+                            ls.add(temp);
+                        }
+                    }
+                }
+            }
+            return ls;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 根目录
+     *
+     * @return String
+     */
+    private String homeDir()
+    {
+        try {
+            return sftp.getHome();
+        } catch (Exception e) {
+            return "/";
+        }
+    }
+
+    public String currentDir()
+   {
+        try {
+            String pwd = sftp.pwd();
+            System.err.println(pwd);
+            return pwd;
+
+        } catch (Exception e) {
+           log.error("failed to get current dir", e);
+            return homeDir();
+         }
+    }
+
+    /**
+     * 切换工作目录
+     *
+     * @param pathName 路径
+     * @return boolean
+     */
+   public boolean changeDir(String pathName)
+   {
+       if (pathName == null || pathName.trim().equals("")) {
+           log.debug("invalid pathName");
+           return false;
+       }
+       try {
+           sftp.cd(pathName.replaceAll("\\\\", "/"));
+           log.debug("directory successfully changed,current dir=" + sftp.pwd());
+           return true;
+       } catch (SftpException e) {
+           log.error("failed to change directory", e);
+           return false;
+       }
+   }
+
+    /**
+     * 列出当前目录下的文件及文件夹
+     *
+     * @param filter 过滤参数
+     * @return String[]
+     */
+    @SuppressWarnings("unchecked")
+    private String[] list(String filter)
+    {
+        Vector<ChannelSftp.LsEntry> list = null;
+        try {
+            //ls方法会返回两个特殊的目录,当前目录(.)和父目录(..)
+            list = sftp.ls(sftp.pwd());
+        } catch (SftpException e) {
+            log.error("can not list directory", e);
+            return new String[0];
+        }
+        List<String> resultList = new ArrayList<String>();
+        for (ChannelSftp.LsEntry entry : list) {
+            resultList.add(entry.getFilename());
+        }
+        return resultList.toArray(new String[0]);
+    }
+    /**
+     * 指定目录下文件名称列表
+     *
+     * @return String[]
+     */
+    public String[] lsFiles(String pathName) {
+        String currentDir = currentDir();
+         if (!changeDir(pathName)) {
+             return new String[0];
+         }
+        String[] result = list("File");
+         if (!changeDir(currentDir)) {
+             return new String[0];
+        }
+        return result;
+    }
+
+
+    /**
+     * 批量下载文件
+     * @param remotePath:远程下载目录(以路径符号结束,可以为相对路径eg:/assess/sftp/jiesuan_2/2014/)
+     * @param localPath:本地保存目录(以路径符号结束,D:\Duansha\sftp\)
+     * @param fileFormat:下载文件格式(以特定字符开头,为空不做检验)
+     * @param fileEndFormat:下载文件格式(文件格式)
+     * @param del:下载后是否删除sftp文件
+     * @return
+     */
+    public List<String> batchDownLoadFile(String remotePath, String localPath,
+                                          String fileFormat, String fileEndFormat, boolean del)
+    {
+        List<String> filenames = new ArrayList<String>();
+        try
+        {
+            // connect();
+            Vector v = sftp.ls(remotePath);
+            // sftp.cd(remotePath);
+            if (v.size() > 0)
+            {
+                System.out.println("本次处理文件个数不为零,开始下载...fileSize=" + v.size());
+                Iterator it = v.iterator();
+                while (it.hasNext())
+                {
+                    ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) it.next();
+                    String filename = entry.getFilename();
+                    SftpATTRS attrs = entry.getAttrs();
+                    if (!attrs.isDir())
+                    {
+                        boolean flag = false;
+                        String localFileName = localPath + filename;
+                        fileFormat = fileFormat == null ? "" : fileFormat
+                                .trim();
+                        fileEndFormat = fileEndFormat == null ? ""
+                                : fileEndFormat.trim();
+                        // 三种情况
+                        if (fileFormat.length() > 0 && fileEndFormat.length() > 0)
+                        {
+                            if (filename.startsWith(fileFormat) && filename.endsWith(fileEndFormat))
+                            {
+                                flag = downloadFile(remotePath, filename,localPath, filename);
+                                if (flag)
+                                {
+                                    filenames.add(localFileName);
+                                    if (flag && del)
+                                    {
+                                        //deleteSFTP(remotePath, filename);
+                                    }
+                                }
+                            }
+                        }
+                        else if (fileFormat.length() > 0 && "".equals(fileEndFormat))
+                        {
+                            if (filename.startsWith(fileFormat))
+                            {
+                                flag = downloadFile(remotePath, filename, localPath, filename);
+                                if (flag)
+                                {
+                                    filenames.add(localFileName);
+                                    if (flag && del)
+                                    {
+                                        //sftp.deleteSFTP(remotePath, filename);
+                                    }
+                                }
+                            }
+                        }
+                        else if (fileEndFormat.length() > 0 && "".equals(fileFormat))
+                        {
+                            if (filename.endsWith(fileEndFormat))
+                            {
+                                flag = downloadFile(remotePath, filename,localPath, filename);
+                                if (flag)
+                                {
+                                    filenames.add(localFileName);
+                                    if (flag && del)
+                                    {
+                                        //deleteSFTP(remotePath, filename);
+                                    }
+                                }
+                            }
+                        }
+                        else
+                        {
+                            flag = downloadFile(remotePath, filename,localPath, filename);
+                            if (flag)
+                            {
+                                filenames.add(localFileName);
+                                if (flag && del)
+                                {
+                                    //deleteSFTP(remotePath, filename);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            if (log.isInfoEnabled())
+            {
+                log.info("download file is success:remotePath=" + remotePath
+                        + "and localPath=" + localPath + ",file size is"
+                        + v.size());
+            }
+        }
+        catch (SftpException e)
+        {
+            e.printStackTrace();
+        }
+        finally
+        {
+            // this.disconnect();
+        }
+        return filenames;
+    }
+
+    /**
+     * 下载单个文件
+     * @param remotePath:远程下载目录(以路径符号结束)
+     * @param remoteFileName:下载文件名
+     * @param localPath:本地保存目录(以路径符号结束)
+     * @param localFileName:保存文件名
+     * @return
+     */
+    public boolean downloadFile(String remotePath, String remoteFileName,String localPath, String localFileName)
+    {
+        FileOutputStream fieloutput = null;
+        try
+        {
+            // sftp.cd(remotePath);
+            File file = new File(localPath + localFileName);
+            // mkdirs(localPath + localFileName);
+            fieloutput = new FileOutputStream(file);
+            sftp.get(remotePath + remoteFileName, fieloutput);
+            if (log.isInfoEnabled())
+            {
+                log.info("===DownloadFile:" + remoteFileName + " success from sftp.");
+            }
+            return true;
+        }
+        catch (FileNotFoundException e)
+        {
+            e.printStackTrace();
+        }
+        catch (SftpException e)
+        {
+            e.printStackTrace();
+        }
+        finally
+        {
+            if (null != fieloutput)
+            {
+                try
+                {
+                    fieloutput.close();
+                }
+                catch (IOException e)
+                {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return false;
+    }
+
+    public Boolean rename(String name, String path) {
+        Boolean result = false;
+        try {
+            sftp.rename(name, path);
+            result = true;
+        } catch (SftpException e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+    public boolean copyfile(String src, String path){
+        boolean result = false;
+        try {
+            InputStream tInputStream = null;
+
+            //tChannelSftp.mkdir(路径);
+            System.err.println(src);
+            tInputStream = sftp.get(src);
+
+            //拷贝读取到的文件流
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+            byte[] buffer = new byte[1024];
+            int len;
+            while ((len = tInputStream.read(buffer)) > -1 ) {
+                baos.write(buffer, 0, len);
+            }
+            baos.flush();
+
+            InputStream nInputStream = new ByteArrayInputStream(baos.toByteArray());
+
+            sftp.put(nInputStream, path);
+
+            nInputStream.close();
+            baos.close();
+            tInputStream.close();
+            result = true;
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+       return result;
+    }
+
+    //上传文件测试
+    /*public static void main(String[] args) throws SftpException, IOException {
+        SFTPUtil sftp = new SFTPUtil("wms_ufct", "ZjJ05GFV", "218.17.248.243", 45301);
+       //FtpUtil.connect("/To_XN_TEST/","218.4.62.135",21,"hsltoxn", "HtxN527%#");
+        try {
+            sftp.login();
+        } catch (JSchException e) {
+            e.printStackTrace();
+        }
+        /*File file = new File("C:\\Users\\usoft\\Downloads\\视图字段.xls");
+        InputStream is = new FileInputStream(file);
+
+        sftp.upload("/","To_XN_TEST", "uas_sftp.xls", is);*//*
+        //sftp.listFiles("/stockout/data/");
+        String ss = "/stockout/data/";
+        String addr = "D:/BaiduNetdiskDownload\\";
+        *//*String[] strings = sftp.lsFiles(ss);
+        for (String s:strings) {
+            System.err.println(s);
+            if (!".".equals(s)&&!"..".equals(s)) {
+                *//**//*sftp.download(ss,s,addr);
+                File file = new File(ss+s);
+                InputStream inputStream = new FileInputStream(file);*//**//*
+                boolean bat = sftp.downloadFile(ss, s, "D:/", s);
+                System.err.println(bat);
+            }
+        }
+
+        sftp.logout();*//*
+        String sss = "GR_20190521121137B.xml";
+        String str = "\\stockout\\data\\";
+        String str1= str.replace("\\","/");
+        System.err.println(str);
+        *//*try {
+            InputStream in = new FileInputStream(sss);
+            SAXReader reader = new SAXReader();
+            Document doc = reader.read(in);
+            in.close();
+            Element element = doc.getRootElement();
+            System.err.println(element);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }*//*
+        //String src = "/stockout/data/GR_20190521121137B.xml";
+        //sftp.copyfile(src,"/stockout/backup/GR_20190521121137B.xml");
+        //sftp.logout();
+        boolean connect = FtpUtil.connect("From_QF", "112.74.205.182", 21, "YTZH02", "Ytzh)@2018");
+        System.err.println(connect);
+        FtpUtil.closeFtpClient(new FTPClient());
+    }*/
+}

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

@@ -0,0 +1,4 @@
+server:
+  tomcat:
+    uri-encoding: UTF-8
+  port: 80811

+ 22 - 0
src/main/resources/dbconfig.properties

@@ -0,0 +1,22 @@
+{
+	"HUAXK_P":{
+		"url":"jdbc:oracle:thin:@127.0.0.1:1521:orcl",
+		"user":"HUAXK_P",
+		"password":"select!#%*("
+	},
+	"HXK_SU_P":{
+		"url":"jdbc:oracle:thin:@127.0.0.1:1521:orcl",
+		"user":"HXK_SU_P",
+		"password":"select!#%*("
+	},
+	"LHWX_HK_P":{
+		"url":"jdbc:oracle:thin:@127.0.0.1:1521:orcl",
+		"user":"LHWX_HK_P",
+		"password":"select!#%*("
+	},
+	"HXK_SX":{
+		"url":"jdbc:oracle:thin:@127.0.0.1:1521:orcl",
+		"user":"HXK_SX",
+		"password":"select!#%*("
+	}
+}

+ 34 - 0
src/main/resources/ftpconfig.properties

@@ -0,0 +1,34 @@
+{
+	"HUAXK_P-HDSZ":{
+		"ip":"58.250.26.203",
+		"port":21,
+		"user":"Szhuaxinke",
+		"password":"Hzfek93T**",
+		"in":"Szhuaxinke",
+		"file":""
+	},
+	"HXK_SU_P-HDSZ":{
+		"ip":"58.250.26.203",
+		"port":21,
+		"user":"Szhuaxinke",
+		"password":"Hzfek93T**",
+		"in":"Szhuaxinke",
+		"file":""
+	},
+	"LHWX_HK_P-HDSZ":{
+		"ip":"58.250.26.203",
+		"port":21,
+		"user":"XGlianheWX",
+		"password":"Enakx53T**",
+		"in":"Hklhwx",
+		"file":""
+	},
+	"HXK_SX-HDSZ":{
+		"ip":"58.250.26.203",
+		"port":21,
+		"user":"Szhuaxinke",
+		"password":"Hzfek93T**",
+		"in":"Szhuaxinke",
+		"file":""
+	}
+}

+ 6 - 0
src/main/resources/log4j.properties

@@ -0,0 +1,6 @@
+log4j.rootLogger=DEBUG, R     
+log4j.appender.R=org.apache.log4j.FileAppender   
+log4j.appender.R.file=my.log     
+log4j.appender.R.Append=true   
+log4j.appender.R.layout=org.apache.log4j.PatternLayout   
+log4j.appender.R.layout.ConversionPattern=%n%n%d%p[%c]-%m%n   

+ 13 - 0
src/test/java/com/uas/HuaxkHuidApplicationTests.java

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