Bläddra i källkod

hcfd 批处理

huangxingxing 3 år sedan
incheckning
b0906d9c2e
35 ändrade filer med 3485 tillägg och 0 borttagningar
  1. 33 0
      .gitignore
  2. 117 0
      .mvn/wrapper/MavenWrapperDownloader.java
  3. BIN
      .mvn/wrapper/maven-wrapper.jar
  4. 2 0
      .mvn/wrapper/maven-wrapper.properties
  5. 310 0
      mvnw
  6. 182 0
      mvnw.cmd
  7. 189 0
      pom.xml
  8. 47 0
      src/main/assembly/assembly.xml
  9. 33 0
      src/main/assembly/bin/start.bat
  10. 81 0
      src/main/assembly/bin/start.sh
  11. 3 0
      src/main/assembly/bin/stop.sh
  12. 15 0
      src/main/java/com/caesolver/CaesolverApplication.java
  13. 33 0
      src/main/java/com/caesolver/controller/SolverController.java
  14. 27 0
      src/main/java/com/caesolver/controller/ThreadConfig.java
  15. 174 0
      src/main/java/com/caesolver/es/BaseElasticService.java
  16. 40 0
      src/main/java/com/caesolver/es/ElasticConfig.java
  17. 35 0
      src/main/java/com/caesolver/es/ElasticEntity.java
  18. 38 0
      src/main/java/com/caesolver/mq/RabbitConfig.java
  19. 68 0
      src/main/java/com/caesolver/mq/Solver.java
  20. 39 0
      src/main/java/com/caesolver/server/BeanConfig.java
  21. 103 0
      src/main/java/com/caesolver/server/SolverBatchHcfd.java
  22. 191 0
      src/main/java/com/caesolver/server/SolverHcfdOrderUtil.java
  23. 269 0
      src/main/java/com/caesolver/server/SolverService.java
  24. 95 0
      src/main/java/com/caesolver/server/util/FileUtils.java
  25. 156 0
      src/main/java/com/caesolver/server/util/HttpDownload.java
  26. 311 0
      src/main/java/com/caesolver/server/util/HttpUtils.java
  27. 21 0
      src/main/java/com/caesolver/server/util/ProcessUtils.java
  28. 255 0
      src/main/java/com/caesolver/server/util/TimeUtils.java
  29. 95 0
      src/main/java/com/caesolver/sftp/FileUtil.java
  30. 272 0
      src/main/java/com/caesolver/sftp/SFTPUtil.java
  31. 78 0
      src/main/java/com/caesolver/xxljob/config/XxlJobConfig.java
  32. 45 0
      src/main/java/com/caesolver/xxljob/job/SolverJob.java
  33. 47 0
      src/main/resources/application.yml
  34. 80 0
      src/main/resources/applicationbak.yml
  35. 1 0
      src/test/.gitignore

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

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

@@ -0,0 +1,117 @@
+/*
+ * 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%

+ 189 - 0
pom.xml

@@ -0,0 +1,189 @@
+<?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.3.4.RELEASE</version>
+		<relativePath/> <!-- lookup parent from repository -->
+	</parent>
+	<groupId>com.caesolver</groupId>
+	<artifactId>caebatchsolver</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<name>caesolver</name>
+	<description>Demo project for Spring Boot</description>
+
+	<properties>
+		<java.version>1.8</java.version>
+	</properties>
+
+	<dependencies>
+		<dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-amqp</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
+			<exclusions>
+				<exclusion>
+					<groupId>org.junit.vintage</groupId>
+					<artifactId>junit-vintage-engine</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+		<dependency> 
+		 <groupId>org.apache.httpcomponents</groupId> 
+          <artifactId>httpclient</artifactId>
+        </dependency> 
+        <dependency> 
+         <groupId>org.apache.httpcomponents</groupId> 
+          <artifactId>httpclient-cache</artifactId>      
+        </dependency> 
+        <dependency> 
+         <groupId>org.apache.httpcomponents</groupId> 
+          <artifactId>httpmime</artifactId> 
+		 </dependency> 
+		<dependency>
+		<groupId>net.sf.json-lib</groupId>
+		<artifactId>json-lib</artifactId>
+		<version>2.4</version>
+		<classifier>jdk15</classifier>
+		</dependency>
+		 <dependency>
+		    <groupId>com.alibaba</groupId>
+		    <artifactId>fastjson</artifactId>
+		    <version>1.2.43</version>
+		</dependency>
+		<dependency>
+		   <groupId>commons-net</groupId>
+		   <artifactId>commons-net</artifactId>
+		   <version>3.6</version>
+		</dependency>
+		 <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-pool2</artifactId>
+        </dependency>
+        <dependency>
+		  <groupId>commons-io</groupId>
+		  <artifactId>commons-io</artifactId>
+		  <version>2.5</version>
+		</dependency>
+	
+
+
+		<dependency>
+		    <groupId>org.elasticsearch.client</groupId>
+		    <artifactId>elasticsearch-rest-high-level-client</artifactId>
+		    <version>7.4.0</version>
+		    <exclusions>
+		        <exclusion>
+		            <groupId>org.elasticsearch</groupId>
+		            <artifactId>elasticsearch</artifactId>
+		        </exclusion>
+		        <exclusion>
+		            <groupId>org.elasticsearch.client</groupId>
+		            <artifactId>elasticsearch-rest-client</artifactId>
+		        </exclusion>
+		    </exclusions>
+		</dependency>
+		<dependency>
+		    <groupId>org.elasticsearch.client</groupId>
+		    <artifactId>elasticsearch-rest-client</artifactId>
+		    <version>7.4.0</version>
+		</dependency>
+		<dependency>
+		    <groupId>org.elasticsearch</groupId>
+		    <artifactId>elasticsearch</artifactId>
+		    <version>7.4.0</version>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.springframework.amqp</groupId>
+			<artifactId>spring-rabbit-test</artifactId>
+			<scope>test</scope>
+		</dependency>
+		
+				
+		<dependency>  
+		      <groupId>com.jcraft</groupId>  
+		      <artifactId>jsch</artifactId>  
+		      <version>0.1.53</version>  
+		</dependency>  
+		
+		<dependency>
+		    <groupId>com.xuxueli</groupId>
+		    <artifactId>xxl-job-core</artifactId>
+		    <version>2.3.0</version>
+		</dependency>
+		
+		
+		
+	</dependencies>
+
+<build>
+       <finalName>${project.artifactId}</finalName>
+       <plugins>
+       	<plugin>
+		    <groupId>org.apache.maven.plugins</groupId>
+		    <artifactId>maven-jar-plugin</artifactId>
+		    <configuration>
+		        <archive>
+		            <manifest>
+		                <!--指定main入口-->
+		                <mainClass>com.caesolver.CaesolverApplication</mainClass>
+		                <addClasspath>true</addClasspath>
+		                <classpathPrefix>lib/</classpathPrefix>
+		            </manifest>
+		        </archive>
+		    </configuration>
+		</plugin>
+           <!-- 编码和编译和JDK版本 -->
+           <plugin>
+               <groupId>org.apache.maven.plugins</groupId>
+               <artifactId>maven-dependency-plugin</artifactId>
+               <executions>
+                    <execution>
+                        <id>copy-dependencies</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                       <configuration>
+                           <outputDirectory>${project.build.directory}/lib</outputDirectory>
+                       </configuration>
+                    </execution>
+                </executions>
+           </plugin>
+           <!--添加打包插件声明 -->
+           <plugin>
+               <artifactId>maven-assembly-plugin</artifactId>
+               <configuration>
+                   <descriptors>
+                       <descriptor>src/main/assembly/assembly.xml</descriptor>
+                   </descriptors>
+               </configuration>
+               <!--执行�?mvn assembly:assembly-->
+               <executions>
+                   <execution>
+                       <!--名字任意 -->
+                       <id>make-assembly</id>
+                       <!-- 绑定到package生命周期阶段�?-->
+                       <phase>package</phase>
+                       <!-- 只运行一�?-->
+                       <goals>
+                           <goal>single</goal>
+                       </goals>
+                   </execution>
+               </executions>
+           </plugin>
+       </plugins>
+   </build>
+</project>

+ 47 - 0
src/main/assembly/assembly.xml

@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<assembly>
+    <id>assembly</id>
+  <!-- 输出格式 -->
+    <formats>
+        <!--  <format>tar.gz</format>-->
+        <format>zip</format>
+    </formats>
+    <includeBaseDirectory>true</includeBaseDirectory>
+  <!-- 指定文件组的组装方式 -->
+    <fileSets>
+      <!-- 将项目中src/bin目录下的脚本文件copy到target目录的bin目录下 -->
+        <fileSet>
+            <directory>src/main/assembly/bin</directory>
+            <outputDirectory>bin</outputDirectory>
+ 		<!--
+            0755->即用户具有读/写/执行权限,组用户和其它用户具有读写权限;
+            0644->即用户具有读写权限,组用户和其它用户具有只读权限;
+        -->
+            <fileMode>0755</fileMode>
+        </fileSet>
+      <!-- 将项目中src/main/resources目录下的资源文件copy到target目录的conf目录下 -->
+        <fileSet>
+            <directory>src/main/resources</directory>
+            <outputDirectory>conf</outputDirectory>
+            <fileMode>0644</fileMode>
+        </fileSet>
+      <!-- 将项目中target目录下的包含jar的文件copy到lib目录下 -->
+        <fileSet>
+            <directory>target</directory>
+            <outputDirectory>/</outputDirectory>
+            <includes>
+                <include>*.jar</include>
+            </includes>
+        </fileSet>
+    </fileSets>
+    
+    <!-- 指定依赖jar包输出的目录 -->
+	<dependencySets>
+	  <dependencySet>
+	      <useProjectArtifact>true</useProjectArtifact>
+	      <outputDirectory>lib</outputDirectory>
+	      <!-- 只包含runtime作用域的依赖 -->
+	      <scope>runtime</scope>
+	  </dependencySet>
+	</dependencySets>
+</assembly>

+ 33 - 0
src/main/assembly/bin/start.bat

@@ -0,0 +1,33 @@
+@echo off
+ 
+set APP_NAME=caesolver.jar
+ 
+set CONFIG= -Dlogging.path=../logs  -Dspring.config.location=../conf/application.yml
+ 
+set DEBUG_OPTS=
+if ""%1"" == ""debug"" (
+   set DEBUG_OPTS= -Xloggc:../logs/gc.log -verbose:gc -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=../logs
+   goto debug
+)
+ 
+set JMX_OPTS=
+if ""%1"" == ""jmx"" (
+   set JMX_OPTS= -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9888 -Dcom.sun.management.jmxremote.ssl=FALSE -Dcom.sun.management.jmxremote.authenticate=FALSE
+   goto jmx
+)
+ 
+echo "Starting the %APP_NAME%"
+java -Xms512m -Xmx512m -server %DEBUG_OPTS% %JMX_OPTS% %CONFIG% -jar ../%APP_NAME%
+goto end
+ 
+:debug
+echo "debug"
+java -Xms512m -Xmx512m -server %DEBUG_OPTS% %CONFIG% -jar ../%APP_NAME%
+goto end
+ 
+:jmx
+java -Xms512m -Xmx512m -server %JMX_OPTS% %CONFIG% -jar ../%APP_NAME%
+goto end
+ 
+:end
+pause

+ 81 - 0
src/main/assembly/bin/start.sh

@@ -0,0 +1,81 @@
+#!/bin/bash
+ 
+SERVER_NAME='caesolver'
+JAR_NAME="$SERVER_NAME.jar"
+CONF_DIR=../conf
+DEPLOY_DIR=../
+ 
+PIDS=`ps -f | grep java | grep "$CONF_DIR" |awk '{print $2}'`
+if [ "$1" = "status" ]; then
+    if [ -n "$PIDS" ]; then
+        echo "The $SERVER_NAME is running...!"
+        echo "PID: $PIDS"
+        exit 0
+    else
+        echo "The $SERVER_NAME is stopped"
+        exit 0
+    fi
+fi
+ 
+if [ -n "$PIDS" ]; then
+    echo "ERROR: The $SERVER_NAME already started!"
+    echo "PID: $PIDS"
+    exit 1
+fi
+ 
+if [ -n "$SERVER_PORT" ]; then
+    SERVER_PORT_COUNT=`netstat -tln | grep $SERVER_PORT | wc -l`
+    if [ $SERVER_PORT_COUNT -gt 0 ]; then
+        echo "ERROR: The $SERVER_NAME port $SERVER_PORT already used!"
+        exit 1
+    fi
+fi
+ 
+LOGS_DIR=/u01/cfd/logs
+if [ ! -d $LOGS_DIR ]; then
+    mkdir $LOGS_DIR
+fi
+STDOUT_FILE=$LOGS_DIR/cfd-solver.log
+ 
+JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
+JAVA_DEBUG_OPTS=""
+if [ "$1" = "debug" ]; then
+    JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
+fi
+ 
+JAVA_JMX_OPTS=""
+if [ "$1" = "jmx" ]; then
+    JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
+fi
+ 
+JAVA_MEM_OPTS=""
+BITS=`java -version 2>&1 | grep -i 64-bit`
+if [ -n "$BITS" ]; then
+    JAVA_MEM_OPTS=" -server -Xmx512m -Xms512m -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
+else
+    JAVA_MEM_OPTS=" -server -Xms512m -Xmx512m -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
+fi
+ 
+CONFIG_FILES=" -Dlogging.path=$LOGS_DIR -Dspring.config.location=$CONF_DIR/application.yml "
+echo -e "Starting the $SERVER_NAME ..."
+nohup java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS $CONFIG_FILES -jar $DEPLOY_DIR/$JAR_NAME > $STDOUT_FILE 2>&1 &
+ 
+COUNT=0
+while [ $COUNT -lt 1 ]; do
+    echo -e ".\c"
+    sleep 1
+    if [ -n "$SERVER_PORT" ]; then
+        COUNT=`netstat -an | grep $SERVER_PORT | wc -l`
+    else
+        COUNT=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l`
+    fi
+    if [ $COUNT -gt 0 ]; then
+        break
+    fi
+done
+ 
+ 
+echo "OK!"
+PIDS=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}'`
+echo "PID: $PIDS"
+echo "STDOUT: $STDOUT_FILE"

+ 3 - 0
src/main/assembly/bin/stop.sh

@@ -0,0 +1,3 @@
+# !/bin/bash
+PID=$(ps -ef | grep "caesolver.jar" | grep -v grep | awk '{ print $2 }')
+kill -9 ${PID}

+ 15 - 0
src/main/java/com/caesolver/CaesolverApplication.java

@@ -0,0 +1,15 @@
+package com.caesolver;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableAsync;
+
+@SpringBootApplication
+@EnableAsync //开启异步调用
+public class CaesolverApplication {
+
+	public static void main(String[] args) {
+		SpringApplication.run(CaesolverApplication.class, args);
+	}
+
+}

+ 33 - 0
src/main/java/com/caesolver/controller/SolverController.java

@@ -0,0 +1,33 @@
+package com.caesolver.controller;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.caesolver.server.SolverService;
+
+import io.netty.util.internal.StringUtil;
+
+@RestController
+public class SolverController {
+	 protected static Logger log=LoggerFactory.getLogger(SolverController.class);
+	@Autowired
+	SolverService solverService;
+	
+	@GetMapping("/test")
+    public String test()  {
+    	return "服务器测试";
+    }
+   
+	/**
+	 *  任务停止 杀死进程
+	 * @param jobId
+	 */
+    @PostMapping("/solverStop") 
+    public void solverStop( String nmlId) throws Exception {
+    	solverService.solverStop(nmlId);
+    }
+}

+ 27 - 0
src/main/java/com/caesolver/controller/ThreadConfig.java

@@ -0,0 +1,27 @@
+package com.caesolver.controller;
+
+import java.util.concurrent.Executor;
+
+import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.AsyncConfigurer;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+@Configuration
+@EnableAsync
+public class ThreadConfig implements AsyncConfigurer {
+	@Override
+	  public Executor getAsyncExecutor() {
+	    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+	    executor.setCorePoolSize(8);
+	    executor.setMaxPoolSize(1000);
+	    executor.setQueueCapacity(500);
+	    executor.setKeepAliveSeconds(30000);
+	    executor.initialize();
+	    return executor;
+	  }
+	  @Override
+	  public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
+	    return null;
+	  }
+}

+ 174 - 0
src/main/java/com/caesolver/es/BaseElasticService.java

@@ -0,0 +1,174 @@
+package com.caesolver.es;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.elasticsearch.action.index.IndexRequest;
+import org.elasticsearch.action.index.IndexResponse;
+import org.elasticsearch.action.search.SearchRequest;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.client.indices.CreateIndexRequest;
+import org.elasticsearch.client.indices.CreateIndexResponse;
+import org.elasticsearch.client.indices.GetIndexRequest;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.xcontent.XContentType;
+import org.elasticsearch.search.SearchHit;
+import org.elasticsearch.search.builder.SearchSourceBuilder;
+import org.elasticsearch.search.sort.SortOrder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.alibaba.fastjson.JSON;
+
+import net.sf.json.JSONObject;
+
+//@Component
+public class BaseElasticService {
+
+    @Autowired
+    RestHighLevelClient restHighLevelClient;
+    protected static Logger log=LoggerFactory.getLogger(BaseElasticService.class);    
+
+    /** 创建索引
+     * 
+     * @param idxName
+     */
+    public void createIndex(String idxName){
+        try {
+            if (this.isExistsIndex(idxName)) {
+//                log.error(" idxName={} 已经存在",idxName);
+                return;
+            }
+            CreateIndexRequest request = new CreateIndexRequest(idxName);
+            buildSetting(request);
+//            request.mapping(idxSQL, XContentType.JSON);
+            buildIndexMapping(request);
+//            request.settings() 手工指定Setting
+            CreateIndexResponse res = restHighLevelClient.indices().create(request, RequestOptions.DEFAULT);
+            if (!res.isAcknowledged()) {
+                throw new RuntimeException("初始化失败");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            System.exit(0);
+        }
+    }
+    
+  //设置index的mapping
+    public void buildIndexMapping(CreateIndexRequest request){
+        Map<String, Object> projectId = new HashMap<>();
+        projectId.put("type", "text");
+        Map<String, Object> log = new HashMap<>();
+        log.put("type", "text");
+        Map<String, Object> time = new HashMap<>();
+        time.put("type", "text");
+        Map<String, Object> properties = new HashMap<>();
+        properties.put("projectId", projectId);
+        properties.put("log", log);
+        properties.put("time", time);
+        Map<String, Object> logs = new HashMap<>();
+        logs.put("properties", properties);
+
+        request.mapping(logs);
+    }
+
+    /** 断某个index是否存在
+     * @param idxName index名
+     * @return boolean
+     * @throws
+     * @since
+     */
+    public boolean isExistsIndex(String idxName) throws Exception {
+        return restHighLevelClient.indices().exists(new GetIndexRequest(idxName),RequestOptions.DEFAULT);
+    }
+
+    /** 设置分片
+     * @param request
+     * @return void
+     * @throws
+     * @since
+     */
+    public void buildSetting(CreateIndexRequest request){
+        request.settings(Settings.builder().put("index.number_of_shards",3)
+                .put("index.number_of_replicas",2));
+    }
+    /** 插入对象
+     * @param idxName index
+     * @param entity    对象
+     * @return void
+     * @throws
+     * @since
+     */
+    public String insertOrUpdateOne(String idxName, ElasticEntity entity) {
+        IndexRequest request = new IndexRequest(idxName);
+//        log.error("Data : id={},entity={}",entity.getId(),JSON.toJSONString(entity.getData()));
+        request.id(entity.getId());
+//        request.source(entity.getData(), XContentType.JSON);
+        request.source(JSON.toJSONString(entity.getData()), XContentType.JSON);
+        try {
+        	IndexResponse response= restHighLevelClient.index(request, RequestOptions.DEFAULT);
+        	return response.getResult().toString();
+        } catch (Exception e) {
+             return "";
+        }
+    }
+    /**
+     * @param idxName index
+     * @param builder   查询参数
+     * @param c 结果类对象
+     * @return java.util.List<T>
+     * @throws
+     * @since
+     */
+    public List<String> search(String idxName,int from ,int size) {
+        SearchRequest request = new SearchRequest(idxName);
+        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
+        searchSourceBuilder.sort("_id",SortOrder.DESC);     
+        searchSourceBuilder.from(from);
+        searchSourceBuilder.size(size);
+        request.source(searchSourceBuilder);
+        try {
+            SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
+            SearchHit[] hits = response.getHits().getHits();
+            List<String> res = new ArrayList<String>(hits.length);
+            for (SearchHit hit : hits) {
+//            	System.out.println(hit.getSourceAsString());
+            	JSONObject jb=JSONObject.fromObject(hit.getSourceAsString());
+            	res.add(jb.getString("log"));
+            }
+            return res;
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * @param idxName index
+     * @param builder   查询参数
+     * @param c 结果类对象
+     * @return java.util.List<T>
+     * @throws
+     * @since
+     */
+    public <T> List<T> search(String idxName, SearchSourceBuilder builder, Class<T> c) {
+        SearchRequest request = new SearchRequest(idxName);
+        request.source(builder);
+        try {
+            SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
+            SearchHit[] hits = response.getHits().getHits();
+            List<T> res = new ArrayList<>(hits.length);
+            for (SearchHit hit : hits) {
+                res.add(JSON.parseObject(hit.getSourceAsString(), c));
+            }
+            return res;
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+}

+ 40 - 0
src/main/java/com/caesolver/es/ElasticConfig.java

@@ -0,0 +1,40 @@
+package com.caesolver.es;
+
+import org.apache.http.HttpHost;
+import org.elasticsearch.client.RestClient;
+import org.elasticsearch.client.RestClientBuilder;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+//@Configuration
+public class ElasticConfig {
+
+    @Value("${es.host}")
+    public String host;
+    @Value("${es.port}")
+    public int port;
+    @Value("${es.scheme}")
+    public String scheme;
+
+    @Bean
+    public RestClientBuilder restClientBuilder() {
+        return RestClient.builder(makeHttpHost());
+    }
+
+    @Bean
+    public RestClient elasticsearchRestClient(){
+        return RestClient.builder(new HttpHost(host, port, scheme)).build();
+    }
+
+    private HttpHost makeHttpHost() {
+        return new HttpHost(host, port, scheme);
+    }
+
+    @Bean
+    public RestHighLevelClient restHighLevelClient(@Autowired RestClientBuilder restClientBuilder){
+        return new RestHighLevelClient(restClientBuilder);
+    }
+}

+ 35 - 0
src/main/java/com/caesolver/es/ElasticEntity.java

@@ -0,0 +1,35 @@
+package com.caesolver.es;
+
+import java.util.Map;
+
+
+public class ElasticEntity {
+
+    /**
+               * 主键标识,用户ES持久化
+     */
+    private String id;
+
+    /**
+     * JSON对象,实际存储数据
+     */
+    private Map<String,Object> data;
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public Map<String, Object> getData() {
+		return data;
+	}
+
+	public void setData(Map<String, Object> data) {
+		this.data = data;
+	}
+    
+    
+}

+ 38 - 0
src/main/java/com/caesolver/mq/RabbitConfig.java

@@ -0,0 +1,38 @@
+package com.caesolver.mq;
+
+
+import org.springframework.amqp.core.Binding;
+import org.springframework.amqp.core.BindingBuilder;
+import org.springframework.amqp.core.Queue;
+import org.springframework.amqp.core.TopicExchange;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+
+@Configuration
+public class RabbitConfig  {
+	/**
+	 * 	主题交换机 消息  队列名称 为 资源编号 (ip)/资源ID
+	 */
+    public static final String QUEUENAME = "solver.hcfd.sbatch";
+    public static final String PROJECTTYPE ="hcfd";
+    public static final String RESOURECODE = "sbatch";
+    public static final String DIRECT="solver.#";
+    public static final String EXCHANGENAME = "solver";
+    
+    //声明队列
+    @Bean
+    public Queue que(){
+        return new Queue(QUEUENAME,true);
+    }
+    //主题交换机
+    @Bean
+    TopicExchange exchange() {
+        return new TopicExchange(EXCHANGENAME,true,false);
+    } 
+    //队列绑定交换机
+    @Bean
+    Binding binding(){
+        return BindingBuilder.bind(que()).to(exchange()).with(DIRECT);
+    }
+}

+ 68 - 0
src/main/java/com/caesolver/mq/Solver.java

@@ -0,0 +1,68 @@
+package com.caesolver.mq;
+
+import java.io.IOException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.RabbitHandler;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+import com.caesolver.server.SolverBatchHcfd;
+import com.caesolver.server.SolverService;
+import com.rabbitmq.client.Channel;
+
+import io.netty.util.internal.StringUtil;
+import net.sf.json.JSONObject;
+
+@Component
+@RabbitListener(queues = RabbitConfig.QUEUENAME)
+public class Solver {
+	protected static Logger log=LoggerFactory.getLogger(Solver.class);
+	@Autowired
+	SolverService solverService;
+	@RabbitHandler
+    public void process(byte[] msgByte, Channel channel, Message message) throws IOException  {
+		log.info("收到消息");
+		try {
+			if(!solverService.isRun()) {
+				SolverService.ISRUN=true;
+				//挂起任务、失效任务 不执行
+				String testMessage = new String(msgByte);
+				log.info(testMessage);
+		    	JSONObject param= JSONObject.fromObject(testMessage);
+		        SolverBatchHcfd vo=(SolverBatchHcfd)JSONObject.toBean(param, SolverBatchHcfd.class);
+				if(!StringUtil.isNullOrEmpty(vo.getVfreq())) {
+					vo.setVfreq("100");
+				}
+				if(!StringUtil.isNullOrEmpty(vo.getAfreq())) {
+					vo.setAfreq("100");
+				}
+				if(solverService.isWait(vo.getNmlId())) {//挂起和停止状态不执行
+					SolverService.ISRUN=false;
+					channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);//消息确认
+					log.info("挂起 不处理消息");
+				}else {
+					solverService.precessController(vo);
+					SolverService.ISRUN=false;
+			        log.info("消息处理成功");
+			        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);//消息确认
+				}
+				
+			}else {//正在运行的任务不执行
+				log.info("系统已存在运行 不处理消息");
+				channel.basicReject(message.getMessageProperties().getDeliveryTag(),false);//消息确认
+			}
+		} catch (Exception e) {
+			log.info("消息处理异常 不处理消息 退出");
+			SolverService.ISRUN=false;
+			// TODO: handle exception
+			channel.basicReject(message.getMessageProperties().getDeliveryTag(),false);//消息确认
+		}
+		
+
+    }
+}

+ 39 - 0
src/main/java/com/caesolver/server/BeanConfig.java

@@ -0,0 +1,39 @@
+package com.caesolver.server;
+
+import java.util.concurrent.ThreadPoolExecutor;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.task.TaskExecutor;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+@Configuration
+@EnableAsync
+public class BeanConfig {
+	protected static Logger log=LoggerFactory.getLogger(BeanConfig.class);   
+
+	@Bean
+    public TaskExecutor taskExecutor() {
+		log.info("taskExecutor start");
+        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+        // 设置核心线程数
+        executor.setCorePoolSize(1);
+        // 设置最大线程数
+        executor.setMaxPoolSize(2);
+        // 设置队列容量
+        executor.setQueueCapacity(20);
+        // 设置线程活跃时间(秒)
+        executor.setKeepAliveSeconds(60);
+        // 设置默认线程名称
+        executor.setThreadNamePrefix("solver-");
+        // 设置拒绝策略
+        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+        // 等待所有任务结束后再关闭线程池
+        executor.setWaitForTasksToCompleteOnShutdown(true);
+        log.info("taskExecutor end");
+        return executor;
+    }
+}

+ 103 - 0
src/main/java/com/caesolver/server/SolverBatchHcfd.java

@@ -0,0 +1,103 @@
+package com.caesolver.server;
+
+public class SolverBatchHcfd {
+    private String batchId;
+    private String gridName;
+    private String boundaryName;
+    private String gridFileId;
+    private String boundaryFileId;
+    private String uid;
+    private String nmlId;
+    private String nmlFname;
+    private String nmlFileId;
+    private String vfreq;
+    private String afreq;
+
+    public String getBatchId() {
+        return batchId;
+    }
+
+    public void setBatchId(String batchId) {
+        this.batchId = batchId;
+    }
+
+    public String getGridName() {
+        return gridName;
+    }
+
+    public void setGridName(String gridName) {
+        this.gridName = gridName;
+    }
+
+    public String getBoundaryName() {
+        return boundaryName;
+    }
+
+    public void setBoundaryName(String boundaryName) {
+        this.boundaryName = boundaryName;
+    }
+
+    public String getGridFileId() {
+        return gridFileId;
+    }
+
+    public void setGridFileId(String gridFileId) {
+        this.gridFileId = gridFileId;
+    }
+
+    public String getBoundaryFileId() {
+        return boundaryFileId;
+    }
+
+    public void setBoundaryFileId(String boundaryFileId) {
+        this.boundaryFileId = boundaryFileId;
+    }
+
+    public String getUid() {
+        return uid;
+    }
+
+    public void setUid(String uid) {
+        this.uid = uid;
+    }
+
+    public String getNmlId() {
+        return nmlId;
+    }
+
+    public void setNmlId(String nmlId) {
+        this.nmlId = nmlId;
+    }
+
+    public String getNmlFname() {
+        return nmlFname;
+    }
+
+    public void setNmlFname(String nmlFname) {
+        this.nmlFname = nmlFname;
+    }
+
+    public String getNmlFileId() {
+        return nmlFileId;
+    }
+
+    public void setNmlFileId(String nmlFileId) {
+        this.nmlFileId = nmlFileId;
+    }
+
+    public String getVfreq() {
+        return vfreq;
+    }
+
+    public void setVfreq(String vfreq) {
+        this.vfreq = vfreq;
+    }
+
+    public String getAfreq() {
+        return afreq;
+    }
+
+    public void setAfreq(String afreq) {
+        this.afreq = afreq;
+    }
+}

+ 191 - 0
src/main/java/com/caesolver/server/SolverHcfdOrderUtil.java

@@ -0,0 +1,191 @@
+package com.caesolver.server;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+@Component
+public class SolverHcfdOrderUtil {
+	   @Value("${HCFD.workdir}")
+	   private  String HCFD_workdir;
+	   @Value("${HCFD.MPICHPATH}")
+	   private  String  MPICHPATH;
+	   @Value("${HCFD.UNIXPath}")
+	   private  String  HCFDUNIXpath;
+	   @Value("${HCFD.RootPath}")
+	   private  String  RootPath;
+	   @Value("${HCFD.ExePath}")
+	   private  String  ExePath;
+	   public String createOrder(SolverBatchHcfd vo) throws IOException {
+			String jobOrder="";
+			Integer vfreq =Integer.valueOf(vo.getVfreq());
+			Integer afreq =Integer.valueOf(vo.getAfreq());
+		   if(this.isWindows()) {//windows
+			   jobOrder=createWindowBat(vo.getNmlId(),vfreq,afreq);
+	  		}else {//Linux
+	  		   jobOrder=createUnixexe(vo.getNmlId(),vfreq,afreq);
+	  		}
+			return jobOrder;
+		  }
+
+	    /**
+	                 * 创建 unix  执行文件
+	     * @param caeProject
+	     * @param reader
+	     * @return
+	     */
+	    private String createUnixexe(String projectId,Integer vfreq,Integer afreq) throws IOException {
+	        String exeorder;
+	        exeorder= getUnixRunOrder(projectId,vfreq,afreq);
+	        Path pFilePaths = Files.walk(Paths.get(this.HCFD_workdir+"/"+projectId))
+	        		.filter(path -> path.toFile().isDirectory())
+	        		.filter(path->path.endsWith("test"))
+	        		.collect(Collectors.toList()).get(0);
+	        String flow_dir =pFilePaths.toString();
+	        File batFile = new File(flow_dir+"/runhcfd.sh");
+	        FileWriter writer =null;
+	        try {
+	            if (!batFile.exists()) {
+	                batFile.createNewFile();
+	            }else{
+	                batFile.delete();
+	                batFile.createNewFile();
+	            }
+	            writer = new FileWriter(batFile,true);
+	            writer.write("#!/bin/bash -f");
+	            writer.write("\n");//换行
+	            writer.write("cd "+HCFDUNIXpath);
+	            writer.write("\n");//换行
+	            writer.write("export PATH="+MPICHPATH+":$PATH");
+	            writer.write("\n");//换行
+	            writer.write("export LD_LIBRARY_PATH="+MPICHPATH+":$LD_LIBRARY_PATH");
+	            writer.write("\n");//换行
+	            writer.write("export F_UFMTENDIAN=little");
+	            writer.write("\n");//换行r UNix 格式文件 换行
+	            writer.write(exeorder);
+	            writer.close();
+	        }catch (Exception o){
+	            o.printStackTrace();
+	        }finally {
+	            if (writer != null) {
+	                try {
+	                    writer.close();
+	                } catch (IOException e1) {
+	                    e1.printStackTrace();
+	                }
+	            }
+	        }
+	        Runtime runtime = Runtime.getRuntime();
+	        Process p =null;
+	        p= runtime.exec("chmod 777 "+batFile.getPath());
+	        return "sh "+ batFile.getPath();
+	    }
+
+
+	    /**
+	     * 获取 unix 下的执行命令
+	     * @param caeProject
+	     * @return
+	     * @throws IOException 
+	     */
+	    public String getUnixRunOrder(String projectId,Integer volume_animation_freq,Integer animation_freq) throws IOException{
+	        String order = "mpirun";
+	        order +=" -np 2 ./NHCFD ";
+	        Path pFilePaths = Files.walk(Paths.get(this.HCFD_workdir+"/"+projectId))
+	        		.filter(path -> path.toFile().isDirectory())
+	        		.filter(path->path.endsWith("test"))
+	        		.collect(Collectors.toList()).get(0);
+	        String flow_dir =pFilePaths.toString();
+	        order +=" --flow_dir \""+flow_dir+"\" ";
+//	        Integer volume_animation_freq = 100;
+	        order +=" --volume_animation_freq "+volume_animation_freq+" ";
+//	        Integer  animation_freq =100;
+	        order +=" --animation_freq "+animation_freq+" ";
+	        order +=" --ascii_tecplot_output ";
+	        return order;
+	    }
+	    
+	    
+	    /**
+	     * 创建 windows 下bat 执行文件
+	     * @param caeProject
+	     * @param reader
+	     * @return
+	     * @throws IOException 
+	     */
+	    private  String createWindowBat(String projectId,Integer vfreq,Integer afreq) throws IOException {
+	        String exeorder;
+	        exeorder= getWindowRunOrder(projectId,vfreq,vfreq);
+	        Path pFilePaths = Files.walk(Paths.get(this.HCFD_workdir+"/"+projectId))
+	        		.filter(path -> path.toFile().isDirectory())
+	        		.filter(path->path.endsWith("test"))
+	        		.collect(Collectors.toList()).get(0);
+	        String flow_dir =pFilePaths.toString();
+	        File batFile = new File(flow_dir+"/hcfd.bat");
+	        FileWriter writer =null;
+	        try {
+	            if (!batFile.exists()) {
+	                batFile.createNewFile();
+	            }else{
+	                batFile.delete();
+	                batFile.createNewFile();
+	            }
+	            writer = new FileWriter(batFile,true);
+	            writer.write(RootPath+":");
+	            writer.write("\r\n");//换行
+	            writer.write("cd "+ExePath);
+	            writer.write("\r\n");//换行
+	            writer.write(exeorder);
+	            writer.close();
+	        }catch (Exception o){
+	            o.printStackTrace();
+	        }finally {
+	            if (writer != null) {
+	                try {
+	                    writer.close();
+	                } catch (IOException e1) {
+	                    e1.printStackTrace();
+	                }
+	            }
+	        }
+	        return  batFile.getPath();
+	    }
+
+	    /**
+	     * 获取 windows 下的执行命令
+	     * @param caeProject
+	     * @return
+	     * @throws IOException 
+	     */
+	    public String getWindowRunOrder(String projectId,Integer vfreq,Integer afreq) throws IOException{
+	        String order ="mpiexec.exe";
+	        order +=" -n 2  NHCFD.exe ";
+	        Path pFilePaths = Files.walk(Paths.get(this.HCFD_workdir+"/"+projectId))
+	        		.filter(path -> path.toFile().isDirectory())
+	        		.filter(path->path.endsWith("test"))
+	        		.collect(Collectors.toList()).get(0);
+	        String flow_dir =pFilePaths.toString().replace("\\test", "/test");
+	        order +=" --flow_dir \""+flow_dir+"\" ";
+	        order +=" --volume_animation_freq "+vfreq+" ";
+	        order +=" --animation_freq "+afreq+" ";
+	        return order;
+	    }
+
+	    
+	    public static boolean isWindows() {
+			return System.getProperty("os.name").toUpperCase().indexOf("WINDOWS")>=0?true:false;	
+	    }
+	    
+	    
+	    
+
+}	

+ 269 - 0
src/main/java/com/caesolver/server/SolverService.java

@@ -0,0 +1,269 @@
+package com.caesolver.server;
+
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+import com.caesolver.server.util.HttpDownload;
+import com.caesolver.server.util.HttpUtils;
+import com.caesolver.sftp.FileUtil;
+import com.caesolver.sftp.SFTPUtil;
+
+import net.sf.json.JSONObject;
+ 
+@Component
+public class SolverService {
+	@Value("${caeserverurl}")
+	String url;
+	@Value("${esserverurl}")
+	String esurl;
+	@Value("${solverBatchStopUrl}")
+	String solverBatchStopUrl;
+	
+	@Autowired
+	SolverHcfdOrderUtil hcfdOrderUtil;
+	@Autowired
+	SFTPUtil sftpUtil;
+	@Value("${HCFD.workdir}")
+	String hcfdWorkDir ;
+	
+	public static boolean ISRUN =false;
+    protected static Logger log=LoggerFactory.getLogger(SolverService.class);
+  
+    public boolean isRun() {
+    	return ISRUN;
+    }
+    
+    public void precessController(SolverBatchHcfd vo) 
+    		throws IOException, Exception {
+    	
+		//logPut(vo,"Solver start");
+		filehHcfdDown(vo);//下载文件
+		String jobOrder =hcfdOrderUtil.createOrder(vo);
+		jobExec( jobOrder, vo);	
+		sftpUtil.uploadBatchDataOut(vo);
+//		//求解结束
+		logPut(vo,"Solver end");
+	}
+    
+    
+     
+	private void jobExec( String jobOrder, SolverBatchHcfd vo) throws Exception {
+		Process p =null;
+		Runtime runtime = Runtime.getRuntime();
+		p= runtime.exec(jobOrder);
+		jobStateLine(vo.getNmlId(), solverBatchStopUrl);//修改状态 为求解中
+		InputStream fis = p.getInputStream();
+		InputStreamReader isr = new InputStreamReader(fis);
+		BufferedReader br = new BufferedReader(isr);
+		String line = null;
+		boolean isSuccess=true;
+		while ((line = br.readLine()) != null) {
+			log.info(line);
+			 if(!line.trim().equals("")) {
+				 logPut(vo,line);
+			 }
+			 if(isSuccess&&line.contains("Error")) {//包含Error
+				 isSuccess=false;
+			 }
+		}
+		p.waitFor();
+		if(isSuccess) {//成功
+			jobStateSuccess(vo.getNmlId());//修改状态 为求解成功
+		}else {//失败
+			jobStateError(vo.getNmlId());;//修改状态 为求解失败
+		}
+	}
+	
+
+	//日志文件输入
+	private void  logPut(SolverBatchHcfd vo,String line) throws Exception {
+		String gridFristName =vo.getGridName().split("\\.")[0];
+		File workerDataDataout =new File(hcfdWorkDir+"/"+vo.getNmlId()+"/"+gridFristName+"/test/"+"data_out");
+		File f = new File(workerDataDataout+"/run.log");
+		if(!f.exists()) {
+			f.createNewFile();
+		}
+		FileWriter writer = new FileWriter(f,true);
+		writer.append(line);
+		writer.write("\n");//换行
+		writer.flush();
+        writer.close();	
+	}
+
+	
+	/**
+	 *  	文件下载
+	 * 		
+	 */
+	private void filehHcfdDown(SolverBatchHcfd vo) throws Exception {
+		String boundaryFileId= vo.getBoundaryFileId();
+		String boundaryName =vo.getBoundaryName();
+		String gridFileId =vo.getGridFileId();
+		String gridName =vo.getGridName();
+		String nmlFileId =vo.getNmlFileId();
+		//删除历史
+		FileUtil.deleteDir(hcfdWorkDir+"/"+vo.getNmlId());
+		String gridFristName =gridName.split("\\.")[0];
+		//创建文件夹
+		File workerDir =new File(hcfdWorkDir+"/"+vo.getNmlId());
+		if(!workerDir.isDirectory()) {
+			workerDir.mkdirs();
+		}
+		File workerDataIn =new File(hcfdWorkDir+"/"+vo.getNmlId()+"/"+gridFristName+"/"+"data_in");
+		if(!workerDataIn.isDirectory()) {
+			workerDataIn.mkdirs();
+		}
+		File workerDataDataout =new File(hcfdWorkDir+"/"+vo.getNmlId()+"/"+gridFristName+"/test/"+"data_out");
+		if(!workerDataDataout.isDirectory()) {
+			workerDataDataout.mkdirs();
+		}	
+		
+		fileDown(gridFileId, workerDataIn+"/"+gridName);
+		fileDown(boundaryFileId, workerDataIn+"/"+boundaryName);
+		fileDown(nmlFileId,hcfdWorkDir+"/"+vo.getNmlId()+"/"+gridFristName+"/test/hcfd.nml");
+	}
+	/**
+	 *  	文件下载
+	 * 		
+	 */
+	private void fileDown(String fileId,String saveFilePath) throws Exception {
+        String downUrl=url+"?channelNo=service&transCode=B00022&clientToken=e47b87eec69545559d1e81e56626da68&id="+fileId;  
+        HttpDownload.download(downUrl, saveFilePath);  
+	}
+
+	/**
+	 *  	任务状态为执行中
+	 * 		
+	 */
+	@Async
+	private void jobStateLine(String nmlId,String solverIp) throws Exception {
+		Map<String, String> paramMap=new HashMap<>();
+		paramMap.put("channelNo", "service");
+		paramMap.put("clientToken", "e47b87eec69545559d1e81e56626da68");
+		paramMap.put("transCode", "SBH011");
+		paramMap.put("nmlId", nmlId);
+		paramMap.put("solverIp", solverIp);
+		paramMap.put("userId","5f06c8bc77234f969d13e160b54c27e3");
+		HttpUtils.doPost(url,"","",new HashMap<String, String>(),new HashMap<String, String>(),paramMap);
+	}
+	/**
+	 *  	任务状态为成功
+	 * 
+	 */
+	@Async
+	private void jobStateSuccess(String nmlId) throws Exception {
+		Map<String, String> paramMap=new HashMap<>();
+		paramMap.put("channelNo", "service");
+		paramMap.put("clientToken", "e47b87eec69545559d1e81e56626da68");
+		paramMap.put("transCode", "SBH009");
+		paramMap.put("nmlId", nmlId);
+		paramMap.put("userId","5f06c8bc77234f969d13e160b54c27e3");
+		HttpUtils.doPost(url,"","",new HashMap<String, String>(),new HashMap<String, String>(),paramMap);
+	}
+	/**
+	 *  任务状态为失败
+	 * 
+	 */
+	@Async
+	private void jobStateError(String nmlId) throws Exception {
+		Map<String, String> paramMap=new HashMap<>();
+		paramMap.put("channelNo", "service");
+		paramMap.put("clientToken", "e47b87eec69545559d1e81e56626da68");
+		paramMap.put("transCode", "SBH010");
+		paramMap.put("nmlId", nmlId);
+		paramMap.put("userId","5f06c8bc77234f969d13e160b54c27e3");
+		HttpUtils.doPost(url,"","",new HashMap<String, String>(),new HashMap<String, String>(),paramMap);
+	}
+    public boolean isWait(String nmlId) {//挂起任务 不执行
+    	Map<String, String> paramMap=new HashMap<>();
+		paramMap.put("channelNo", "service");
+		paramMap.put("clientToken", "e47b87eec69545559d1e81e56626da68");
+		paramMap.put("transCode", "SBH014");
+		paramMap.put("nmlId", nmlId);
+		paramMap.put("userId","5f06c8bc77234f969d13e160b54c27e3");
+		try {
+			HttpResponse response= HttpUtils.doPost(url,"","",new HashMap<String, String>(),new HashMap<String, String>(),paramMap);
+			JSONObject jsonObject = JSONObject.fromObject(EntityUtils.toString(response.getEntity())); 
+			JSONObject result = JSONObject.fromObject(jsonObject.get("result"));
+			String state = String.valueOf(jsonObject.get("state"));
+			String returnCode = String.valueOf(jsonObject.get("returnCode"));
+			if ("000000000".equals(returnCode)) {//调用成功
+			  if("3".equals(state)) {////挂起任务
+				  return true;
+			  }else{
+				  return false;
+			  }
+			} else {//调用失败
+				return false;
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+			return false;
+		}
+    }
+		
+	/**
+	 *  
+	 * @param youNumber
+	 * @return
+	 */
+	public static String int2String(int youNumber) {
+	    String str = String.format("%010d", youNumber);  
+	    return str;
+	}
+	/**
+	 * 强制停止进程
+	 * @param jobId
+	 * @throws InterruptedException 
+	 * @throws IOException 
+	 */
+	public void solverStop(String nmlId) throws Exception{
+		 if(SolverHcfdOrderUtil.isWindows()) {//windows
+			 //winows 
+		 }else {
+			 
+			 log.info("stop:: "+nmlId);
+			 Process p =null;
+			 Runtime runtime = Runtime.getRuntime();
+			 String[] command = { "/bin/sh", "-c", "ps -ef|grep "+nmlId+"|grep mpirun|awk '{print $2}'"};
+			// String[] command = { "/bin/sh", "-c", "ps -ef|grep java |awk '{print $2}'"};
+			 log.info("ps -ef|grep "+nmlId+"|grep mpirun|awk '{print $2}'");
+//			 p= runtime.exec("ps -ef|grep "+nmlId+"|grep mpirun|awk '{print $2}'");
+			 p= runtime.exec(command);
+			 InputStream fis = p.getInputStream();
+			 InputStreamReader isr = new InputStreamReader(fis);
+			 BufferedReader br = new BufferedReader(isr);
+			 String line = null;
+			 List<String> pids =new ArrayList<>();
+			 while ((line = br.readLine()) != null) {
+				 log.info(line);
+				 pids.add(line);
+			 } 
+			 p.waitFor();
+			 for (String pid : pids) {
+				 log.info("kill -9 "+pid);
+				 p= runtime.exec("kill -9 "+pid);
+			 }
+		 }
+		
+	}
+	
+}

+ 95 - 0
src/main/java/com/caesolver/server/util/FileUtils.java

@@ -0,0 +1,95 @@
+package com.caesolver.server.util;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+public class FileUtils {
+	public static String AsciiToBinary(String asciiString){  
+        byte[] bytes = asciiString.getBytes();  
+        StringBuilder binary = new StringBuilder();  
+        for (byte b : bytes)  
+        {  
+           int val = b;  
+           for (int i = 0; i < 8; i++)  
+           {  
+              binary.append((val & 128) == 0 ? 0 : 1);  
+              val <<= 1;  
+           }  
+        }  
+        return binary.toString();  
+	}
+	
+	/**
+	 * 	根据文件路径读取byte[] 数组
+     */
+    public static byte[] readFileByBytes(String filePath) throws IOException {
+        File file = new File(filePath);
+        if (!file.exists()) {
+            throw new FileNotFoundException(filePath);
+        } else {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream((int) file.length());
+            BufferedInputStream in = null;
+
+            try {
+                in = new BufferedInputStream(new FileInputStream(file));
+                short bufSize = 1024;
+                byte[] buffer = new byte[bufSize];
+                int len1;
+                while (-1 != (len1 = in.read(buffer, 0, bufSize))) {
+                    bos.write(buffer, 0, len1);
+                }
+
+                byte[] var7 = bos.toByteArray();
+                return var7;
+            } finally {
+                try {
+                    if (in != null) {
+                        in.close();
+                    }
+                } catch (IOException var14) {
+                    var14.printStackTrace();
+                }
+
+                bos.close();
+            }
+        }
+    }
+    /**
+     * 	删除空目录
+     * @param dir 将要删除的目录路径
+     */
+    private static void doDeleteEmptyDir(String dir) {
+        boolean success = (new File(dir)).delete();
+        if (success) {
+            System.out.println("Successfully deleted empty directory: " + dir);
+        } else {
+            System.out.println("Failed to delete empty directory: " + dir);
+        }
+    }
+
+    /**
+     * 	递归删除目录下的所有文件及子目录下所有文件
+     * @param dir 将要删除的文件目录
+     * @return boolean Returns "true" if all deletions were successful.
+     *                 If a deletion fails, the method stops attempting to
+     *                 delete and returns "false".
+     */
+    private static boolean deleteDir(File dir) {
+        if (dir.isDirectory()) {
+            String[] children = dir.list();
+            //递归删除目录中的子目录下
+            for (int i=0; i<children.length; i++) {
+                boolean success = deleteDir(new File(dir, children[i]));
+                if (!success) {
+                    return false;
+                }
+            }
+        }
+        // 目录此时为空,可以删除
+        return dir.delete();
+    }
+}

+ 156 - 0
src/main/java/com/caesolver/server/util/HttpDownload.java

@@ -0,0 +1,156 @@
+package com.caesolver.server.util;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+
+import org.apache.http.Header;
+import org.apache.http.HeaderElement;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;  
+  
+/** 
+ * 说明 
+ * 利用httpclient下载文件 
+ * maven依赖 
+ * <dependency> 
+*           <groupId>org.apache.httpcomponents</groupId> 
+*           <artifactId>httpclient</artifactId> 
+*           <version>4.0.1</version> 
+*       </dependency> 
+*  可下载http文件、图片、压缩文件 
+*  bug:获取response header中Content-Disposition中filename中文乱码问题 
+ * @author tanjundong 
+ * 
+ */  
+public class HttpDownload {  
+  
+    public static final int cache = 10 * 1024;  
+    public static final boolean isWindows;  
+    public static final String splash;  
+    public static final String root;  
+    static {  
+        if (System.getProperty("os.name") != null && System.getProperty("os.name").toLowerCase().contains("windows")) {  
+            isWindows = true;  
+            splash = "\\";  
+            root="D:";  
+        } else {  
+            isWindows = false;  
+            splash = "/";  
+            root="/search";  
+        }  
+    }  
+      
+    /** 
+     * 根据url下载文件,文件名从response header头中获取 
+     * @param url 
+     * @return 
+     */  
+    public static String download(String url) {  
+        return download(url, null);  
+    }  
+  
+    /** 
+     * 根据url下载文件,保存到filepath中 
+     * @param url 
+     * @param filepath 
+     * @return 
+     */  
+    public static String download(String url, String filepath) {  
+        try {  
+            HttpClient client = new DefaultHttpClient();  
+            HttpGet httpget = new HttpGet(url);  
+            HttpResponse response = client.execute(httpget);  
+  
+            HttpEntity entity = response.getEntity();  
+            InputStream is = entity.getContent();  
+            if (filepath == null)  
+                filepath = getFilePath(response);  
+            File file = new File(filepath);  
+            file.getParentFile().mkdirs();  
+            FileOutputStream fileout = new FileOutputStream(file);  
+            /** 
+             * 根据实际运行效果 设置缓冲区大小 
+             */  
+            byte[] buffer=new byte[cache];  
+            int ch = 0;  
+            while ((ch = is.read(buffer)) != -1) {  
+                fileout.write(buffer,0,ch);  
+            }  
+            is.close();  
+            fileout.flush();  
+            fileout.close();  
+  
+        } catch (Exception e) {  
+            e.printStackTrace();  
+        }  
+        return null;  
+    }  
+    /** 
+     * 获取response要下载的文件的默认路径 
+     * @param response 
+     * @return 
+     */  
+    public static String getFilePath(HttpResponse response) {  
+        String filepath = root + splash;  
+        String filename = getFileName(response);  
+  
+        if (filename != null) {  
+            filepath += filename;  
+        } else {  
+            filepath += getRandomFileName();  
+        }  
+        return filepath;  
+    }  
+    /** 
+     * 获取response header中Content-Disposition中的filename值 
+     * @param response 
+     * @return 
+     */  
+    public static String getFileName(HttpResponse response) {  
+        Header contentHeader = response.getFirstHeader("Content-Disposition");  
+        String filename = null;  
+        if (contentHeader != null) {  
+            HeaderElement[] values = contentHeader.getElements();  
+            if (values.length == 1) {  
+                NameValuePair param = values[0].getParameterByName("filename");  
+                if (param != null) {  
+                    try {  
+                        //filename = new String(param.getValue().toString().getBytes(), "utf-8");  
+                        //filename=URLDecoder.decode(param.getValue(),"utf-8");  
+                        filename = param.getValue();  
+                    } catch (Exception e) {  
+                        e.printStackTrace();  
+                    }  
+                }  
+            }  
+        }  
+        return filename;  
+    }  
+    /** 
+     * 获取随机文件名 
+     * @return 
+     */  
+    public static String getRandomFileName() {  
+        return String.valueOf(System.currentTimeMillis());  
+    }  
+    public static void outHeaders(HttpResponse response) {  
+        Header[] headers = response.getAllHeaders();  
+        for (int i = 0; i < headers.length; i++) {  
+            System.out.println(headers[i]);  
+        }  
+    }  
+    public static void main(String[] args) {  
+//      String url = "http://localhost:8081/?channelNo=service&transCode=B00022&clientToken=e47b87eec69545559d1e81e56626da68&id=84a1c028825a4f61b10543a729f79f0c";  
+////        String url="http://localhost:8081/?channelNo=service&transCode=B00022&clientToken=e47b87eec69545559d1e81e56626da68&id=968d5926dd6b42fe8925895230bc87b7";  
+////      String filepath = "D:\\test\\a.torrent";  
+//        String filepath = "D:\\t.txt";  
+//        HttpDownload.download(url, filepath);  
+    	String nmlId="121212";
+    	String t ="ps -ef|grep "+nmlId+"|grep mpi";
+    	System.out.println(t);
+    }  
+} 

+ 311 - 0
src/main/java/com/caesolver/server/util/HttpUtils.java

@@ -0,0 +1,311 @@
+package com.caesolver.server.util;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.message.BasicNameValuePair;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class HttpUtils {
+	
+	/**
+	 * get
+	 * 
+	 * @param host
+	 * @param path
+	 * @param method
+	 * @param headers
+	 * @param querys
+	 * @return
+	 * @throws Exception
+	 */
+	public static HttpResponse doGet(String host, String path, String method, 
+			Map<String, String> headers, 
+			Map<String, String> querys)
+            throws Exception {    	
+    	HttpClient httpClient = wrapClient(host);
+
+    	HttpGet request = new HttpGet(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+        	request.addHeader(e.getKey(), e.getValue());
+        }
+        
+        return httpClient.execute(request);
+    }
+	
+	/**
+	 * post form
+	 * 
+	 * @param host
+	 * @param path
+	 * @param method
+	 * @param headers
+	 * @param querys
+	 * @param bodys
+	 * @return
+	 * @throws Exception
+	 */
+	public static HttpResponse doPost(String host, String path, String method, 
+			Map<String, String> headers, 
+			Map<String, String> querys, 
+			Map<String, String> bodys)
+            throws Exception {    	
+    	HttpClient httpClient = wrapClient(host);
+
+    	HttpPost request = new HttpPost(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+        	request.addHeader(e.getKey(), e.getValue());
+        }
+
+        if (bodys != null) {
+            List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
+
+            for (String key : bodys.keySet()) {
+                nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
+            }
+            UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
+            formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
+            request.setEntity(formEntity);
+        }
+
+        return httpClient.execute(request);
+    }	
+	
+	/**
+	 * Post String
+	 * 
+	 * @param host
+	 * @param path
+	 * @param method
+	 * @param headers
+	 * @param querys
+	 * @param body
+	 * @return
+	 * @throws Exception
+	 */
+	public static HttpResponse doPost(String host, String path, String method, 
+			Map<String, String> headers, 
+			Map<String, String> querys, 
+			String body)
+            throws Exception {    	
+    	HttpClient httpClient = wrapClient(host);
+
+    	HttpPost request = new HttpPost(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+        	request.addHeader(e.getKey(), e.getValue());
+        }
+
+        if (StringUtils.isNotBlank(body)) {
+        	request.setEntity(new StringEntity(body, "utf-8"));
+        }
+
+        return httpClient.execute(request);
+    }
+	
+	/**
+	 * Post stream
+	 * 
+	 * @param host
+	 * @param path
+	 * @param method
+	 * @param headers
+	 * @param querys
+	 * @param body
+	 * @return
+	 * @throws Exception
+	 */
+	public static HttpResponse doPost(String host, String path, String method, 
+			Map<String, String> headers, 
+			Map<String, String> querys, 
+			byte[] body)
+            throws Exception {    	
+    	HttpClient httpClient = wrapClient(host);
+
+    	HttpPost request = new HttpPost(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+        	request.addHeader(e.getKey(), e.getValue());
+        }
+
+        if (body != null) {
+        	request.setEntity(new ByteArrayEntity(body));
+        }
+
+        return httpClient.execute(request);
+    }
+	
+	/**
+	 * Put String
+	 * @param host
+	 * @param path
+	 * @param method
+	 * @param headers
+	 * @param querys
+	 * @param body
+	 * @return
+	 * @throws Exception
+	 */
+	public static HttpResponse doPut(String host, String path, String method, 
+			Map<String, String> headers, 
+			Map<String, String> querys, 
+			String body)
+            throws Exception {    	
+    	HttpClient httpClient = wrapClient(host);
+
+    	HttpPut request = new HttpPut(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+        	request.addHeader(e.getKey(), e.getValue());
+        }
+
+        if (StringUtils.isNotBlank(body)) {
+        	request.setEntity(new StringEntity(body, "utf-8"));
+        }
+
+        return httpClient.execute(request);
+    }
+	
+	/**
+	 * Put stream
+	 * @param host
+	 * @param path
+	 * @param method
+	 * @param headers
+	 * @param querys
+	 * @param body
+	 * @return
+	 * @throws Exception
+	 */
+	public static HttpResponse doPut(String host, String path, String method, 
+			Map<String, String> headers, 
+			Map<String, String> querys, 
+			byte[] body)
+            throws Exception {    	
+    	HttpClient httpClient = wrapClient(host);
+
+    	HttpPut request = new HttpPut(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+        	request.addHeader(e.getKey(), e.getValue());
+        }
+
+        if (body != null) {
+        	request.setEntity(new ByteArrayEntity(body));
+        }
+
+        return httpClient.execute(request);
+    }
+	
+	/**
+	 * Delete
+	 *  
+	 * @param host
+	 * @param path
+	 * @param method
+	 * @param headers
+	 * @param querys
+	 * @return
+	 * @throws Exception
+	 */
+	public static HttpResponse doDelete(String host, String path, String method, 
+			Map<String, String> headers, 
+			Map<String, String> querys)
+            throws Exception {    	
+    	HttpClient httpClient = wrapClient(host);
+
+    	HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+        	request.addHeader(e.getKey(), e.getValue());
+        }
+        
+        return httpClient.execute(request);
+    }
+	
+	private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {
+    	StringBuilder sbUrl = new StringBuilder();
+    	sbUrl.append(host);
+    	if (!StringUtils.isBlank(path)) {
+    		sbUrl.append(path);
+        }
+    	if (null != querys) {
+    		StringBuilder sbQuery = new StringBuilder();
+        	for (Map.Entry<String, String> query : querys.entrySet()) {
+        		if (0 < sbQuery.length()) {
+        			sbQuery.append("&");
+        		}
+        		if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {
+        			sbQuery.append(query.getValue());
+                }
+        		if (!StringUtils.isBlank(query.getKey())) {
+        			sbQuery.append(query.getKey());
+        			if (!StringUtils.isBlank(query.getValue())) {
+        				sbQuery.append("=");
+        				sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8"));
+        			}        			
+                }
+        	}
+        	if (0 < sbQuery.length()) {
+        		sbUrl.append("?").append(sbQuery);
+        	}
+        }
+    	
+    	return sbUrl.toString();
+    }
+	
+	private static HttpClient wrapClient(String host) {
+		HttpClient httpClient = new DefaultHttpClient();
+		if (host.startsWith("https://")) {
+			sslClient(httpClient);
+		}
+		
+		return httpClient;
+	}
+	
+	private static void sslClient(HttpClient httpClient) {
+        try {
+            SSLContext ctx = SSLContext.getInstance("TLS");
+            X509TrustManager tm = new X509TrustManager() {
+                public X509Certificate[] getAcceptedIssuers() {
+                    return null;
+                }
+                public void checkClientTrusted(X509Certificate[] xcs, String str) {
+                	
+                }
+                public void checkServerTrusted(X509Certificate[] xcs, String str) {
+                	
+                }
+            };
+            ctx.init(null, new TrustManager[] { tm }, null);
+            SSLSocketFactory ssf = new SSLSocketFactory(ctx);
+            ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+            ClientConnectionManager ccm = httpClient.getConnectionManager();
+            SchemeRegistry registry = ccm.getSchemeRegistry();
+            registry.register(new Scheme("https", 443, ssf));
+        } catch (KeyManagementException ex) {
+            throw new RuntimeException(ex);
+        } catch (NoSuchAlgorithmException ex) {
+        	throw new RuntimeException(ex);
+        }
+    }
+}

+ 21 - 0
src/main/java/com/caesolver/server/util/ProcessUtils.java

@@ -0,0 +1,21 @@
+package com.caesolver.server.util;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+
+public class ProcessUtils {
+	
+	public static int getPid() {
+        RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();        
+        String name = runtime.getName(); // format: "[email protected]"
+        try {
+            return Integer.parseInt(name.substring(0, name.indexOf('@')));
+        } catch (Exception e) {
+            return -1;
+        }
+    }
+	public static void main(String[] args) {
+		System.out.println(getPid());
+	}
+
+}

+ 255 - 0
src/main/java/com/caesolver/server/util/TimeUtils.java

@@ -0,0 +1,255 @@
+package com.caesolver.server.util;
+
+import org.springframework.util.StringUtils;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+/*
+ * 向超级账本发送报文使用
+ */
+public class TimeUtils {
+	
+	private static Calendar cal;
+	public static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+	public static SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+	public static SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
+	public static SimpleDateFormat sdf3 = new SimpleDateFormat("yyMMddHHmm");
+	public static SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+	
+	private static final long ONE_MINUTE = 60000L;
+    private static final long ONE_HOUR = 3600000L;
+    private static final long ONE_DAY = 86400000L;
+    private static final long ONE_WEEK = 604800000L;
+
+    private static final String ONE_SECOND_AGO = "秒前";
+    private static final String ONE_MINUTE_AGO = "分钟前";
+    private static final String ONE_HOUR_AGO = "小时前";
+    private static final String ONE_DAY_AGO = "天前";
+    private static final String ONE_MONTH_AGO = "月前";
+    private static final String ONE_YEAR_AGO = "年前";
+
+	//获得当前时间
+	public static String getNow(){ 
+		return sdf1.format(new Date());
+	}
+
+	public static String getTimeStr(Date date){
+		return sdf1.format(date);
+	}
+
+	public static List<String> getNowForNumber(){
+		List<String> strList=new ArrayList<>();
+		Date date=new Date();
+
+		strList.add(sdf1.format(date));
+		strList.add(sdf3.format(date));
+		strList.add(sdf4.format(date));
+
+		return strList;
+	}
+
+	//获得当天的0点
+	public static Calendar getTodayStart(){ 
+		cal = Calendar.getInstance(); 
+		cal.set(Calendar.HOUR_OF_DAY, 0); 
+		cal.set(Calendar.MINUTE, 0);
+		cal.set(Calendar.SECOND, 0);
+		cal.set(Calendar.MILLISECOND, 0); 
+		return cal;
+		//return (int) (cal.getTimeInMillis()/1000); 
+	} 
+	
+	public static String getTodayStartStr() {
+		return sdf1.format(getTodayStart().getTime());
+	}
+	
+	//获得昨天的0点
+	public static Calendar getYesterdayStart(){
+		cal = Calendar.getInstance();
+		cal.setTime(new Date());
+		cal.add(Calendar.DAY_OF_MONTH, -1);
+		cal.set(Calendar.HOUR_OF_DAY, 0);
+		cal.set(Calendar.MINUTE, 0);
+		cal.set(Calendar.SECOND, 0);
+		cal.set(Calendar.MILLISECOND, 0);
+		return cal;
+		//return (int) (cal.getTimeInMillis()/1000);
+	}
+	//获得昨天的0点
+	public static String getYesterdayStartStr(){
+		cal = Calendar.getInstance();
+		cal.setTime(new Date());
+		cal.add(Calendar.DAY_OF_MONTH, -1);
+		cal.set(Calendar.HOUR_OF_DAY, 0);
+		cal.set(Calendar.MINUTE, 0);
+		cal.set(Calendar.SECOND, 0);
+		cal.set(Calendar.MILLISECOND, 0);
+		return sdf1.format(cal.getTime());
+	}
+	//获得昨天的24点
+	public static Calendar getYesterdayEnd(){
+		cal = Calendar.getInstance();
+		cal.setTime(new Date());
+		cal.add(Calendar.DAY_OF_MONTH, -1);
+		cal.set(Calendar.HOUR_OF_DAY, 23);
+		cal.set(Calendar.MINUTE, 59);
+		cal.set(Calendar.SECOND, 59);
+		cal.set(Calendar.MILLISECOND, 0);
+		return cal;
+	}
+	//获得昨天的24点
+	public static String getYesterdayEndStr(){
+		cal = Calendar.getInstance();
+		cal.setTime(new Date());
+		cal.add(Calendar.DAY_OF_MONTH, -1);
+		cal.set(Calendar.HOUR_OF_DAY, 23);
+		cal.set(Calendar.MINUTE, 59);
+		cal.set(Calendar.SECOND, 59);
+		cal.set(Calendar.MILLISECOND, 0);
+		return sdf1.format(cal.getTime());
+	}
+	//获得今天24点
+	public static Calendar getTodayEnd(){ 
+		cal = Calendar.getInstance(); 
+		cal.set(Calendar.HOUR_OF_DAY, 23); 
+		cal.set(Calendar.MINUTE, 23); 
+		cal.set(Calendar.SECOND, 59); 
+		cal.set(Calendar.MILLISECOND, 999); 
+		return cal;
+		//return (int) (cal.getTimeInMillis()/1000); 
+	} 
+	
+	//获得跑批起始时间
+	public static Calendar getBatchStart(){ 
+		cal = Calendar.getInstance(); 
+		cal.set(Calendar.MINUTE, 0);
+		cal.set(Calendar.SECOND, 0); 
+		cal.set(Calendar.MILLISECOND, 0); 
+		return cal;
+	} 
+	
+	//距今多少分/小时/天/月/年
+	public static String fromToday(String time) {
+		if (StringUtils.isEmpty(time)) {
+			return "";
+		}
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date date = null;
+        try {
+            date = format.parse(time);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        long delta = new Date().getTime() - date.getTime();
+        if (delta < 1L * ONE_MINUTE) {
+            long seconds = toSeconds(delta);
+            return (seconds <= 0 ? 1 : seconds) + ONE_SECOND_AGO;
+        }
+        if (delta < 45L * ONE_MINUTE) {
+            long minutes = toMinutes(delta);
+            return (minutes <= 0 ? 1 : minutes) + ONE_MINUTE_AGO;
+        }
+        if (delta < 24L * ONE_HOUR) {
+            long hours = toHours(delta);
+            return (hours <= 0 ? 1 : hours) + ONE_HOUR_AGO;
+        }
+//        错误代码
+//        if (delta < 48L * ONE_HOUR) {
+//            return "昨天";
+//        }
+        //因为你不知道这个月是30天还是31天
+        //后面的算法也有问题,但其实也不用这么精确,大致算一下;毕竟需求也只是大致的时间
+        if (delta < 31L * ONE_DAY) {
+            long days = toDays(delta);
+            return (days <= 0 ? 1 : days) + ONE_DAY_AGO;
+        }
+        //一年也不一定是365
+        if (delta < 365L * ONE_DAY) {
+            long months = toMonths(delta);
+            return (months <= 0 ? 1 : months) + ONE_MONTH_AGO;
+        } else {
+            long years = toYears(delta);
+            return (years <= 0 ? 1 : years) + ONE_YEAR_AGO;
+        }
+    }
+	
+	// 获取当月第一天
+	public static String firstDay(String year, String month) {
+		// 获取前月的第一天
+		Calendar cale = Calendar.getInstance();
+		cale.set(Calendar.YEAR, Integer.parseInt(year));
+		cale.set(Calendar.MONTH, Integer.parseInt(month) - 1);
+        cale.add(Calendar.MONTH, 0);  
+		cale.set(Calendar.DAY_OF_MONTH, 1);
+		cale.set(Calendar.HOUR_OF_DAY, 0);
+		cale.set(Calendar.MINUTE, 0);
+		cale.set(Calendar.SECOND, 0);
+		return sdf1.format(cale.getTime());
+	}
+	// 获取当月最后一天
+	public static String lastDay(String year, String month) {
+		// 获取前月的第一天
+		Calendar cale = Calendar.getInstance();
+		cale.set(Calendar.YEAR, Integer.parseInt(year));
+		cale.set(Calendar.MONTH, Integer.parseInt(month) - 1);
+        cale.add(Calendar.MONTH, 1);  
+        cale.set(Calendar.DAY_OF_MONTH, 0);  
+		cale.set(Calendar.HOUR_OF_DAY, 23);
+		cale.set(Calendar.MINUTE, 59);
+		cale.set(Calendar.SECOND, 59);
+		return sdf1.format(cale.getTime());
+	}
+
+    private static long toSeconds(long date) {
+        return date / 1000L;
+    }
+
+    private static long toMinutes(long date) {
+        return toSeconds(date) / 60L;
+    }
+
+    private static long toHours(long date) {
+        return toMinutes(date) / 60L;
+    }
+
+    private static long toDays(long date) {
+        return toHours(date) / 24L;
+    }
+
+    private static long toMonths(long date) {
+        return toDays(date) / 30L;
+    }
+
+    private static long toYears(long date) {
+        return toMonths(date) / 365L;
+    }
+
+    public static String getDateTimeByStr(String str){
+		SimpleDateFormat format = new SimpleDateFormat("yyyymmddhhmmss");
+		Date date = null;
+		try {
+			date = format.parse(str);
+		} catch (ParseException e) {
+			e.printStackTrace();
+		}
+
+		return sdf1.format(date);
+	}
+
+	public static Date getDateTime(String str){
+		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		Date date = null;
+		try {
+			date = format.parse(str);
+		} catch (ParseException e) {
+			e.printStackTrace();
+		}
+
+		return date;
+	}
+}

+ 95 - 0
src/main/java/com/caesolver/sftp/FileUtil.java

@@ -0,0 +1,95 @@
+package com.caesolver.sftp;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+
+public class FileUtil {
+	 /**
+	   	递归删除目录下的所有文件及子目录下所有文件
+     * @param filepath 将要删除的文件目录
+     */
+	public static void deleteDir(String  filepath) {
+		File f = new File(filepath);//定义文件路径         
+		 if(f.exists() && f.isDirectory()){//目录 
+		     if(f.listFiles().length==0){//若目录下没有文件则直接删除  
+		         f.delete();  
+		     }else{//若有则把文件放进数组,并判断是否有下级目录  
+		         File delFile[]=f.listFiles();  
+		         int i =f.listFiles().length;  
+		         for(int j=0;j<i;j++){  
+		             if(delFile[j].isDirectory()){  
+		            	 deleteDir(delFile[j].getAbsolutePath());//递归调用del方法并取得子目录路径  
+		             }  
+		             delFile[j].delete();//删除文件  
+		         }  
+		     }  
+		 }else if(f.exists()){
+			  f.delete();  
+		 }    
+    }
+    /**
+     * 	获取文件夹下的所有文件列表
+     * @param path
+     * @throws IOException 
+     */
+    public static List<File> ListDataOutFiles(String path,String projectType) {
+    	List<File> files =new ArrayList<File>();
+    	sonFiles(path, files,projectType);
+    	return files;
+    }
+
+	private static void sonFiles(String path, List<File> files,String projectType) {
+		File rootFile = new File(path);
+    	File[] listFiles=rootFile.listFiles();
+    	if(listFiles!=null&&listFiles.length>0) {
+    		for (File file : listFiles) {
+				if(file.isDirectory()) {
+					sonFiles(file.getPath(),files,projectType);
+				}else { 
+					switch (projectType) {
+						case "hcfd":
+							if(file.getParent().indexOf("data_out")>0) {
+								files.add(file);
+							};
+							break;
+						case "fem":
+							if(file.getParent().indexOf("data_out")>0) {
+								files.add(file);
+							}
+							break;
+						case "cfd":
+							if(file.getName().endsWith(".out")) {
+								files.add(file);
+							}
+							break;
+						case "mpm":
+							if(file.getParent().indexOf("dataout")>0) {
+								files.add(file);
+							}
+							break;
+						case "bladesign":
+							if(
+								file.getName().endsWith(".K")||
+								file.getName().endsWith(".v0")||
+								file.getName().endsWith(".opt")||
+								file.getName().endsWith(".ech")||
+								file.getName().endsWith(".v1S")||
+								file.getName().endsWith(".out")||
+								file.getParent().indexOf("OPT")>0
+							) {
+								files.add(file);
+							}
+							break;
+						default:
+							break;
+					}		
+				}
+			}
+    	}
+	}
+	
+
+}

+ 272 - 0
src/main/java/com/caesolver/sftp/SFTPUtil.java

@@ -0,0 +1,272 @@
+package com.caesolver.sftp;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Vector;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import com.caesolver.server.SolverBatchHcfd;
+import com.jcraft.jsch.Channel;
+import com.jcraft.jsch.ChannelSftp;
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.Session;
+import com.jcraft.jsch.SftpException;
+/**
+ * 
+ * @ClassName: SFTPUtil
+ * @Description: sftp连接工具类
+ * @date 2017年5月22日 下午11:17:21
+ * @version 1.0.0
+ */
+@Component
+public class SFTPUtil {
+	private transient Logger log = LoggerFactory.getLogger(this.getClass());
+    
+    private ChannelSftp sftp;
+      
+    private Session session;
+    /** FTP 登录用户名*/  
+    @Value("${sftp.username}")
+    private String username;
+    /** FTP 登录密码*/  
+    @Value("${sftp.password}")
+    private String password;
+    /** 私钥 */  
+    @Value("${sftp.privatekey}")
+    private String privateKey;
+    /** FTP 服务器地址IP地址*/  
+    @Value("${sftp.host}")
+    private String host;
+    /** FTP 端口*/
+    @Value("${sftp.port}")
+    private int port;
+    
+    @Value("${sftp.workdir}")
+    private String sftp_workdir;
+    @Value("${HCFD.workdir}")
+    private String HCFD_workdir;
+    
+    
+    
+    
+      
+    public SFTPUtil(){}
+  
+    /**
+                * 连接sftp服务器
+     *
+     * @throws Exception 
+     */
+    public void login(){
+        try {
+            JSch jsch = new JSch();
+            if (privateKey != null&&!StringUtils.isEmpty(privateKey)) {
+                jsch.addIdentity(privateKey);// 设置私钥
+                log.info("sftp connect,path of private key file:{}" , privateKey);
+            }
+            log.info("sftp connect by host:{} username:{}",host,username);
+  
+            session = jsch.getSession(username, host, port);
+            log.info("Session is build");
+            if (password != null) {
+                session.setPassword(password);  
+            }
+            Properties config = new Properties();
+            config.put("StrictHostKeyChecking", "no");
+              
+            session.setConfig(config);
+            session.connect();
+            log.info("Session is connected");
+            
+            Channel channel = session.openChannel("sftp");
+            channel.connect();
+            log.info("channel is connected");
+  
+            sftp = (ChannelSftp) channel;
+            log.info(String.format("sftp server host:[%s] port:[%s] is connect successfull", host, port));
+        } catch (JSchException e) {
+            log.error("Cannot connect to specified sftp server : {}:{} \n Exception message is: {}", new Object[]{host, port, e.getMessage()});  
+        }
+    }  
+  
+    /**
+     * 关闭连接 server 
+     */
+    public void logout(){
+        if (sftp != null) {
+            if (sftp.isConnected()) {
+                sftp.disconnect();
+                log.info("sftp is closed already");
+            }
+        }
+        if (session != null) {
+            if (session.isConnected()) {
+                session.disconnect();
+                log.info("sshSession is closed already");
+            }
+        }
+    }
+  
+    /** 
+     * 将输入流的数据上传到sftp作为文件 
+     *  
+     * @param directory 
+     *            上传到该目录 
+     * @param sftpFileName 
+     *            sftp端文件名 
+     * @param in 
+     *            输入流 
+     * @throws SftpException  
+     * @throws Exception 
+     */  
+    public void upload(String directory, String sftpFileName, InputStream input) throws SftpException{
+        try {  
+        	log.info("directory "+directory);
+            sftp.cd(directory);
+        } catch (SftpException e) {
+            log.warn("directory is not exist");
+            sftp.mkdir(directory);
+            sftp.cd(directory);
+        }
+        sftp.put(input, sftpFileName,ChannelSftp.OVERWRITE);//覆盖上传
+        log.info("file:{} is upload successful" , sftpFileName);
+    }
+    
+    
+    
+    /** 
+     	* 上传单个文件
+     *
+     * @param directory 
+     *            上传到sftp目录 
+     * @param uploadFile
+     *            要上传的文件,包括路径 
+     * @throws FileNotFoundException
+     * @throws SftpException
+     * @throws Exception
+     */
+    public void upload(String directory, String uploadFile) throws FileNotFoundException, SftpException{
+        File file = new File(uploadFile);
+        upload(directory, file.getName(), new FileInputStream(file));
+    }
+ 
+     
+  
+	
+	/**
+	 * 根据项目类型项目ID 上传结果文件
+	 * @param projectId
+	 * @param projectType
+	 * @throws SftpException 
+	 * @throws FileNotFoundException 
+	 */
+	public  void uploadByProjectId(String projectId,String projectType) throws FileNotFoundException, SftpException {
+		this.login();
+		String saveDirectory="";
+		log.info("uploadByProjectId 1:{} {}" , projectId,projectType);
+		log.info("uploadByProjectId 2: saveDirectory ={} " , saveDirectory);
+		List<File> listFiles=FileUtil.ListDataOutFiles(saveDirectory+projectId,projectType);
+		for (File file : listFiles) {
+			log.info("file:{} upload start " , file.getPath());
+			FileInputStream fileinput =null;
+			try {
+				fileinput =new FileInputStream(file);
+				String directory =sftp_workdir+"/"+file.getParent().replace("\\","/").replace(saveDirectory, "");
+				upload(directory, file.getName(), fileinput);
+				log.info("file:{} upload sucess " , file.getPath());
+				fileinput.close();
+			}catch (Exception e) {
+				e.printStackTrace();
+				// TODO: handle exception
+			}finally {
+				if(fileinput!=null) {
+					try {
+						fileinput.close();
+					} catch (IOException e) {
+						// TODO Auto-generated catch block
+						e.printStackTrace();
+					}
+				}
+			}
+			
+		}  
+		this.logout();
+	}
+	
+
+    /**
+   
+  
+    /**
+     * 删除文件
+     *  
+     * @param directory
+     *            要删除文件所在目录
+     * @param deleteFile
+     *            要删除的文件
+     * @throws SftpException
+     * @throws Exception
+     */
+    public void delete(String directory, String deleteFile) throws SftpException{
+        sftp.cd(directory);
+        sftp.rm(deleteFile);
+    }
+    
+    /**
+     * batch 文件上传
+     * @param vo
+     */
+	public void uploadBatchDataOut(SolverBatchHcfd vo) {
+		// TODO Auto-generated method stub
+		this.login();
+		String saveDirectory=HCFD_workdir;
+		log.info("up 1:{} {}" , vo.getNmlId());
+		log.info("uploadByProjectId 2: saveDirectory ={} " , saveDirectory);
+		List<File> listFiles=FileUtil.ListDataOutFiles(saveDirectory+"/"+vo.getNmlId(),"hcfd");
+		for (File file : listFiles) {
+			log.info("file:{} upload start " , file.getPath());
+			FileInputStream fileinput =null;
+			try {
+				fileinput =new FileInputStream(file);
+				String directory =sftp_workdir+vo.getNmlId();
+				upload(directory, file.getName(), fileinput);
+				log.info("file:{} upload sucess " , file.getPath());
+				fileinput.close();
+			}catch (Exception e) {
+				e.printStackTrace();
+				// TODO: handle exception
+			}finally {
+				if(fileinput!=null) {
+					try {
+						fileinput.close();
+					} catch (IOException e) {
+						// TODO Auto-generated catch block
+						e.printStackTrace();
+					}
+				}
+			}
+			
+		}  
+		this.logout();
+	}
+  
+    
+}

+ 78 - 0
src/main/java/com/caesolver/xxljob/config/XxlJobConfig.java

@@ -0,0 +1,78 @@
+package com.caesolver.xxljob.config;
+
+import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * xxl-job config
+ *
+ * @author xuxueli 2017-04-28
+ */
+//@Configuration
+public class XxlJobConfig {
+    private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
+    
+    @Value("${xxl.job.admin.addresses}")
+    private String adminAddresses;
+
+    @Value("${xxl.job.accessToken}")
+    private String accessToken;
+
+    @Value("${xxl.job.executor.appname}")
+    private String appname;
+
+    @Value("${xxl.job.executor.address}")
+    private String address;
+
+    @Value("${xxl.job.executor.ip}")
+    private String ip;
+
+    @Value("${xxl.job.executor.port}")
+    private int port;
+
+    @Value("${xxl.job.executor.logpath}")
+    private String logPath;
+
+    @Value("${xxl.job.executor.logretentiondays}")
+    private int logRetentionDays;
+
+
+    @Bean
+    public XxlJobSpringExecutor xxlJobExecutor() {
+        logger.info(">>>>>>>>>>> xxl-job config init.");
+        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
+        xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
+        xxlJobSpringExecutor.setAppname(appname);
+        xxlJobSpringExecutor.setAddress(address);
+        xxlJobSpringExecutor.setIp(ip);
+        xxlJobSpringExecutor.setPort(port);
+        xxlJobSpringExecutor.setAccessToken(accessToken);
+        xxlJobSpringExecutor.setLogPath(logPath);
+        xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
+
+        return xxlJobSpringExecutor;
+    }
+
+    /**
+     * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP;
+     *
+     *      1、引入依赖:
+     *          <dependency>
+     *             <groupId>org.springframework.cloud</groupId>
+     *             <artifactId>spring-cloud-commons</artifactId>
+     *             <version>${version}</version>
+     *         </dependency>
+     *
+     *      2、配置文件,或者容器启动变量
+     *          spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
+     *
+     *      3、获取IP
+     *          String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
+     */
+
+
+}

+ 45 - 0
src/main/java/com/caesolver/xxljob/job/SolverJob.java

@@ -0,0 +1,45 @@
+package com.caesolver.xxljob.job;
+
+import java.util.concurrent.TimeUnit;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.caesolver.server.SolverBatchHcfd;
+import com.caesolver.server.SolverService;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+
+import io.netty.util.internal.StringUtil;
+import net.sf.json.JSONObject;
+
+//@Component
+public class SolverJob {
+	private static Logger logger = LoggerFactory.getLogger(SolverJob.class);
+	@Autowired
+	private SolverService solverService;
+	/**
+     * 	简单任务(Bean模式)
+     *   	求解
+     */
+    @XxlJob("solverJobHandler")
+    public void solverJobHandler() throws Exception {
+        JSONObject param= JSONObject.fromObject(XxlJobHelper.getJobParam());
+        SolverBatchHcfd vo=(SolverBatchHcfd)JSONObject.toBean(param, SolverBatchHcfd.class);
+		if(!StringUtil.isNullOrEmpty(vo.getVfreq())) {
+			vo.setVfreq("100");
+		}
+		if(!StringUtil.isNullOrEmpty(vo.getAfreq())) {
+			vo.setAfreq("100");
+		}
+        try {
+    		solverService.precessController(vo);
+    	} catch (Exception e) {
+			e.printStackTrace();
+			XxlJobHelper.log(e.getMessage());
+			XxlJobHelper.handleFail();
+    	}
+    }
+}

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

@@ -0,0 +1,47 @@
+server:
+  port: 8083
+spring:
+  #MQ 配置
+  rabbitmq:
+    host: 192.168.0.43
+    port: 5672
+    username: admin
+    password: admin
+    listener:
+      simple:
+        acknowledge-mode: manual #手动确认
+        concurrency: 1 #消费者线程数配置 消费者最小数量
+        max-concurrency: 1 #消费者线程数配置 消费者最大数量
+        prefetch:  1  #消费者线程数配置 消费者最大数量
+        
+
+esserverurl: http://192.168.0.43:8031/
+caeserverurl: http://192.168.0.43:8081/
+solverBatchStopUrl: http://192.168.0.43:8183/solverStop
+sftp:
+  host: 192.168.0.43
+  port: 22
+  username: root
+  password: Xicae@root
+  privatekey:
+  workdir: /opt/sbach/
+  
+HCFD:
+  workdir: D:/hcfd/solverdown/
+  MPICHPATH: /home/mpi/mpich2_141_gnu/bin
+  UNIXPath: /home/hcfdlab/mavric/test
+  RootPath: D
+  ExePath: D:/Program Files/HCFDLab_example/windows/mavric/test/
+
+xxl:
+  job:
+    admin:
+      addresses:  http://192.168.0.43:8000/xxl-job-admin
+    accessToken: 
+    executor:
+      appname: solver-hcfdbat-executor
+      address: 
+      ip: 
+      port: 9999
+      logpath: /data/applogs/xxl-job/jobhandler
+      logretentiondays: 30

+ 80 - 0
src/main/resources/applicationbak.yml

@@ -0,0 +1,80 @@
+server:
+  port: 8082
+#spring:
+#  #MQ 配置
+#  rabbitmq:
+#    host: 192.168.0.43
+#    port: 5672
+#    username: admin
+#    password: admin 
+#es:
+#  host: 192.168.0.43
+#  port: 9200
+#  scheme: http
+
+esserverurl: http://192.168.88.3:8031/
+caeserverurl: http://192.168.88.3:8081/
+#
+#ftp:
+#  host: 192.168.0.43
+#  port: 2231
+#  username: ftpmain
+#  password: 123456
+#  encoding: utf-8
+#  MaxTotal: 100
+#  MinIdel: 2
+#  MaxWaitMillis: 3000
+#  root: /
+#  workDir: D:/FEM/
+
+sftp:
+  host: 192.168.88.3
+  port: 32222
+  username: root
+  password: Adi987654321!
+  privatekey:
+  workdir: /upload/
+
+FEM:
+  workdir: C:/FEM/
+  exePath: C:/FEMLab_example/ADI_FE.exe
+  postPath: C:/FEMLab_example/FEMPost.exe
+  rootPath: C
+  
+HCFD:
+  workdir: /home/hcfd/solverdown/
+  MPICHPATH: /home/mpi/mpich2_141_gnu/bin
+  UNIXPath: /home/hcfdlab/mavric/test
+  RootPath: D
+  ExePath: D:/Program Files/HCFDLab_example/windows/mavric/test/
+  
+CFD:
+  workdir: /home/cfd/solverdown/
+#  workdir: D:/cfd_down
+  UNIXPath: /home/OverCFD_Apollo/
+  MPICHPATH: /home/mpi/mpich2_141_gnu/bin
+
+MPM:
+  workdir: C:/mpm_down/
+  exePath: C:/MPM/windows_exe/
+  
+BLADESIGN:
+  workdir: C:/bladesign_down/
+  VABSexe: C:/bladesign/VABS_R/VABS.exe
+  GEBTexe: C:/bladesign/GEBT/GEBT.exe
+  RootPath: C
+  POTexe: C:/bladesign/OPT/
+  POTInitialGEBT: C:/bladesign/OPT/OPT/InitialGEBT.dat
+
+xxl:
+  job:
+    admin:
+      addresses:  http://192.168.88.3:8000/xxl-job-admin
+    accessToken: 
+    executor:
+      appname: solver-window-executor
+      address: 
+      ip: 
+      port: 9999
+      logpath: /data/applogs/xxl-job/jobhandler
+      logretentiondays: 30

+ 1 - 0
src/test/.gitignore

@@ -0,0 +1 @@
+/java/