commit 9418f4289f3009309fb96c16c0c1f939614d3d68
Author: lishipeng <1572427111@qq.com>
Date: Sun Apr 23 09:35:17 2023 +0800
first commit
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a2a3040
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### 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/
+
+### VS Code ###
+.vscode/
diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java
new file mode 100644
index 0000000..a45eb6b
--- /dev/null
+++ b/.mvn/wrapper/MavenWrapperDownloader.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2007-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.net.*;
+import java.io.*;
+import java.nio.channels.*;
+import java.util.Properties;
+
+public class MavenWrapperDownloader {
+
+ private static final String WRAPPER_VERSION = "0.5.6";
+ /**
+ * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
+ */
+ private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
+
+ /**
+ * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
+ * use instead of the default one.
+ */
+ private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
+ ".mvn/wrapper/maven-wrapper.properties";
+
+ /**
+ * Path where the maven-wrapper.jar will be saved to.
+ */
+ private static final String MAVEN_WRAPPER_JAR_PATH =
+ ".mvn/wrapper/maven-wrapper.jar";
+
+ /**
+ * Name of the property which should be used to override the default download url for the wrapper.
+ */
+ private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
+
+ public static void main(String args[]) {
+ System.out.println("- Downloader started");
+ File baseDirectory = new File(args[0]);
+ System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
+
+ // If the maven-wrapper.properties exists, read it and check if it contains a custom
+ // wrapperUrl parameter.
+ File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
+ String url = DEFAULT_DOWNLOAD_URL;
+ if (mavenWrapperPropertyFile.exists()) {
+ FileInputStream mavenWrapperPropertyFileInputStream = null;
+ try {
+ mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
+ Properties mavenWrapperProperties = new Properties();
+ mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
+ url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
+ } catch (IOException e) {
+ System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
+ } finally {
+ try {
+ if (mavenWrapperPropertyFileInputStream != null) {
+ mavenWrapperPropertyFileInputStream.close();
+ }
+ } catch (IOException e) {
+ // Ignore ...
+ }
+ }
+ }
+ System.out.println("- Downloading from: " + url);
+
+ File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
+ if (!outputFile.getParentFile().exists()) {
+ if (!outputFile.getParentFile().mkdirs()) {
+ System.out.println(
+ "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
+ }
+ }
+ System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
+ try {
+ downloadFileFromURL(url, outputFile);
+ System.out.println("Done");
+ System.exit(0);
+ } catch (Throwable e) {
+ System.out.println("- Error downloading");
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ private static void downloadFileFromURL(String urlString, File destination) throws Exception {
+ if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
+ String username = System.getenv("MVNW_USERNAME");
+ char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
+ Authenticator.setDefault(new Authenticator() {
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(username, password);
+ }
+ });
+ }
+ URL website = new URL(urlString);
+ ReadableByteChannel rbc;
+ rbc = Channels.newChannel(website.openStream());
+ FileOutputStream fos = new FileOutputStream(destination);
+ fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+ fos.close();
+ rbc.close();
+ }
+
+}
diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar
new file mode 100644
index 0000000..2cc7d4a
Binary files /dev/null and b/.mvn/wrapper/maven-wrapper.jar differ
diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
new file mode 100644
index 0000000..642d572
--- /dev/null
+++ b/.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
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..a814dcb
--- /dev/null
+++ b/README.md
@@ -0,0 +1,6 @@
+# 工程简介
+
+### 冠县冠宏安全态势平台对接
+
+# 延伸阅读
+
diff --git a/mvnw b/mvnw
new file mode 100644
index 0000000..a16b543
--- /dev/null
+++ b/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 "$@"
diff --git a/mvnw.cmd b/mvnw.cmd
new file mode 100644
index 0000000..c8d4337
--- /dev/null
+++ b/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%
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..ccfa504
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,109 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.6.11
+
+
+ com.example
+ upSecurityData
+ 0.0.1-SNAPSHOT
+ upSecurityData
+ upSecurityData
+
+
+ 1.8
+
+
+
+
+
+ com.xuxueli
+ xxl-job-core
+ 2.3.0
+
+
+ org.apache.velocity
+ velocity
+ 1.7
+ provided
+
+
+ commons-codec
+ commons-codec
+ 1.15
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ com.alibaba
+ fastjson
+ 2.0.12
+
+
+
+ com.jcraft
+ jsch
+ 0.1.54
+
+
+
+ cn.hutool
+ hutool-all
+ 5.8.12
+
+
+
+
+ mysql
+ mysql-connector-java
+ 8.0.30
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ com.baomidou
+ mybatis-plus-boot-starter
+ 3.5.0
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+ 1.8
+ 1.8
+ UTF-8
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/src/main/java/com/example/upsecuritydata/UpSecurityDataApplication.java b/src/main/java/com/example/upsecuritydata/UpSecurityDataApplication.java
new file mode 100644
index 0000000..9ea2106
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/UpSecurityDataApplication.java
@@ -0,0 +1,13 @@
+package com.example.upsecuritydata;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class UpSecurityDataApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(UpSecurityDataApplication.class, args);
+ }
+
+}
diff --git a/src/main/java/com/example/upsecuritydata/cache/CodeCache.java b/src/main/java/com/example/upsecuritydata/cache/CodeCache.java
new file mode 100644
index 0000000..8489ca4
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/cache/CodeCache.java
@@ -0,0 +1,35 @@
+package com.example.upsecuritydata.cache;
+
+
+import com.example.upsecuritydata.entity.SysDict;
+import com.example.upsecuritydata.service.SysDictService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class CodeCache {
+ public static Map codeMap = new HashMap();
+
+ @Autowired
+ private SysDictService codeService;
+
+ @PostConstruct
+ public void init(){
+ System.out.println("系统启动中。。。加载codeMap");
+ List codeList = codeService.selectAll();
+ for (SysDict code : codeList) {
+ codeMap.put(code.getDictCode(), code.getDictValue());
+ }
+ }
+
+ @PreDestroy
+ public void destroy(){
+ System.out.println("系统运行结束");
+ }
+}
diff --git a/src/main/java/com/example/upsecuritydata/config/XxlJobConfig.java b/src/main/java/com/example/upsecuritydata/config/XxlJobConfig.java
new file mode 100644
index 0000000..0739f11
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/config/XxlJobConfig.java
@@ -0,0 +1,78 @@
+package com.example.upsecuritydata.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、引入依赖:
+ *
+ * org.springframework.cloud
+ * spring-cloud-commons
+ * ${version}
+ *
+ *
+ * 2、配置文件,或者容器启动变量
+ * spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
+ *
+ * 3、获取IP
+ * String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
+ */
+
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/example/upsecuritydata/controller/SSHRemoteCall.java b/src/main/java/com/example/upsecuritydata/controller/SSHRemoteCall.java
new file mode 100644
index 0000000..9608d07
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/controller/SSHRemoteCall.java
@@ -0,0 +1,389 @@
+package com.example.upsecuritydata.controller;
+
+import com.jcraft.jsch.*;
+import com.xxl.job.core.context.XxlJobHelper;
+
+import java.io.*;
+import java.util.*;
+
+
+public class SSHRemoteCall {
+
+ private static final int DEFAULT_PORT = 30020;// 默认端口号
+ // 私有的对象
+ private static SSHRemoteCall sshRemoteCall;
+
+ // 懒汉式,线程不安全,适合单线程
+// public static SSHRemoteCall getInstance() {
+// if (sshRemoteCall == null) {
+// sshRemoteCall = new SSHRemoteCall();
+// }
+// return sshRemoteCall;
+// }
+ private static String ipAddress = "223.99.228.240";// ip地址
+ private static String userName = "root";// 账号
+ private static String password = "Qingniao@123!";// 密码
+ private int port;// 端口号
+ private Session session;// JSCH session
+ private boolean logined = false;// 是否登陆
+
+ /**
+ * 私有的构造方法
+ */
+ private SSHRemoteCall() {
+ }
+
+ /**
+ * 构造方法,可以直接使用DEFAULT_PORT
+ *
+ * @param ipAddress
+ * @param userName
+ * @param password
+ */
+ public SSHRemoteCall(String ipAddress, String userName, String password) {
+ this(ipAddress, DEFAULT_PORT, userName, password);
+ }
+
+ /**
+ * 构造方法,方便直接传入ipAddress,userName,password进行调用
+ *
+ * @param ipAddress
+ * @param port
+ * @param userName
+ * @param password
+ */
+ public SSHRemoteCall(String ipAddress, int port, String userName, String password) {
+ super();
+ this.ipAddress = ipAddress;
+ this.userName = userName;
+ this.password = password;
+ this.port = port;
+ }
+
+ // 懒汉式,线程安全,适合多线程
+ public static synchronized SSHRemoteCall getInstance() {
+ if (sshRemoteCall == null) {
+ sshRemoteCall = new SSHRemoteCall();
+ }
+ return sshRemoteCall;
+ }
+
+ /**
+ * 远程登陆
+ *
+ * @throws Exception
+ */
+ public void sshRemoteCallLogin(String ipAddress, String userName, String password) throws Exception {
+ // 如果登陆就直接返回
+ if (logined) {
+ return;
+ }
+ // 创建jSch对象
+ JSch jSch = new JSch();
+ try {
+ // 获取到jSch的session, 根据用户名、主机ip、端口号获取一个Session对象
+ session = jSch.getSession(userName, ipAddress, 22102); //22102
+ // 设置密码
+ session.setPassword(password);
+
+ // 方式一,通过Session建立连接
+ // session.setConfig("StrictHostKeyChecking", "no");
+ // session.connect();
+
+ // 方式二,通过Session建立连接
+ // java.util.Properties;
+// Properties config = new Properties();
+// config.put("StrictHostKeyChecking", "no");
+// session.setConfig(config);// 为Session对象设置properties
+ // session.setTimeout( );// 设置超时
+// session.setConfig("StrictHostKeyChecking", "no");
+ Properties config = new Properties();
+ config.put("StrictHostKeyChecking", "no");
+ config.put("PreferredAuthentications", "password");
+ session.setConfig(config);
+ session.connect(3000000);//// 通过Session建立连接
+
+ // 设置登陆状态
+ logined = true;
+ } catch (JSchException e) {
+ // 设置登陆状态为false
+ logined = false;
+ throw new Exception(
+ "主机登录失败, IP = " + ipAddress + ", USERNAME = " + userName + ", Exception:" + e.getMessage());
+ }
+ }
+
+ /**
+ * 关闭连接
+ */
+ public void closeSession() {
+ // 调用session的关闭连接的方法
+ if (session != null) {
+ // 如果session不为空,调用session的关闭连接的方法
+ session.disconnect();
+ }
+
+ }
+
+ /**
+ * 执行相关的命令
+ *
+ * @param command
+ * @throws IOException
+ */
+ public String execCommand(String command) throws IOException {
+ InputStream in = null;// 输入流(读)
+ Channel channel = null;// 定义channel变量
+ try {
+ // 如果命令command不等于null
+ if (command != null) {
+ // 打开channel
+ //说明:exec用于执行命令;sftp用于文件处理
+ channel = session.openChannel("exec");
+ // 设置command
+ ((ChannelExec) channel).setCommand(command);
+ // channel进行连接
+ channel.connect();
+ // 获取到输入流
+ in = channel.getInputStream();
+ // 执行相关的命令
+ String processDataStream = processDataStream(in);
+ // 打印相关的命令
+ return processDataStream;
+ }
+ } catch (JSchException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ if (channel != null) {
+ channel.disconnect();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 对将要执行的linux的命令进行遍历
+ *
+ * @param in
+ * @return
+ * @throws Exception
+ */
+ public String processDataStream(InputStream in) throws Exception {
+ StringBuffer sb = new StringBuffer();
+ BufferedReader br = new BufferedReader(new InputStreamReader(in));
+ String result = "";
+ try {
+ while ((result = br.readLine()) != null) {
+ sb.append(result);
+ // System.out.println(sb.toString());
+ }
+ } catch (Exception e) {
+ throw new Exception("获取数据流失败: " + e);
+ } finally {
+ br.close();
+ }
+ return sb.toString();
+ }
+
+ /**
+ * 上传文件 可参考:https://www.cnblogs.com/longyg/archive/ / / / .html
+ *
+ * @param directory 上传文件的目录
+ * @param uploadFile 将要上传的文件
+ */
+ public void uploadFile(String directory, String uploadFile) {
+ try {
+ // 打开channelSftp
+ ChannelSftp channelSftp = (ChannelSftp) session.openChannel("sftp");
+ // 远程连接
+ channelSftp.connect(6000);
+ // 创建一个文件名称问uploadFile的文件
+ File file = new File(uploadFile);
+ // 将文件进行上传(sftp协议)
+ // 将本地文件名为src的文件上传到目标服务器,目标文件名为dst,若dst为目录,则目标文件名将与src文件名相同.
+ // 采用默认的传输模式:OVERWRITE
+ channelSftp.put(new FileInputStream(file), directory, ChannelSftp.OVERWRITE);
+ // 切断远程连接
+ channelSftp.exit();
+ XxlJobHelper.log("上传文件:" + file.getName());
+ } catch (JSchException e) {
+ e.printStackTrace();
+ } catch (SftpException e) {
+ e.printStackTrace();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * 下载文件 采用默认的传输模式:OVERWRITE
+ *
+ * @param src linux服务器文件地址
+ * @param dst 本地存放地址
+ * @throws JSchException
+ * @throws SftpException
+ */
+ public void fileDownload(String src, String dst) throws JSchException, SftpException {
+ // src 是linux服务器文件地址,dst 本地存放地址
+ ChannelSftp channelSftp = (ChannelSftp) session.openChannel("sftp");
+ // 远程连接
+ channelSftp.connect();
+ // 下载文件,多个重载方法
+ channelSftp.get(src, dst);
+ // 切断远程连接,quit()等同于exit(),都是调用disconnect()
+ channelSftp.quit();
+ // channelSftp.disconnect();
+ System.out.println("下载文件:" + src);
+ }
+
+ /**
+ * 删除文件
+ *
+ * @throws SftpException
+ * @throws JSchException
+ */
+ public void deleteFile(String directoryFile) throws SftpException, JSchException {
+ // 打开openChannel的sftp
+ ChannelSftp channelSftp = (ChannelSftp) session.openChannel("sftp");
+ // 远程连接
+ channelSftp.connect();
+ // 删除文件
+ channelSftp.rm(directoryFile);
+ // 切断远程连接
+ channelSftp.exit();
+ System.out.println("删除文件:" + directoryFile);
+ }
+
+ /**
+ * 如果此目录不存在将新建目录
+ */
+ public void directory(String path) {
+ // 打开openChannel的sftp
+ ChannelSftp channelSftp = null;
+ try {
+ channelSftp = (ChannelSftp) session.openChannel("sftp");
+ // 远程连接
+ channelSftp.connect(6000);
+ // 切换到主目录
+// channelSftp.cd("/");
+ } catch (JSchException e) {
+ throw new RuntimeException(e);
+ }
+
+ String[] folders = path.split("/");
+ for (String folder : folders) {
+ if (folder.length() > 0) {
+ try {
+ channelSftp.cd(folder);
+// XxlJobHelper.log("切换目录" + folder);
+ } catch (SftpException e) {
+ try {
+ channelSftp.mkdir(folder);
+ XxlJobHelper.log("生成目录" + folder);
+ channelSftp.cd(folder);
+ } catch (SftpException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ }
+ }
+// channelSftp.disconnect();
+ }
+
+
+ /**
+ * 列出目录下的文件
+ *
+ * @param directory 要列出的目录
+ * @return
+ * @throws SftpException
+ * @throws JSchException
+ */
+ public Vector listFilesBack(String directory) throws JSchException, SftpException {
+ ChannelSftp channelSftp = (ChannelSftp) session.openChannel("sftp");
+ // 远程连接
+ channelSftp.connect();
+ // 显示目录信息
+ Vector ls = channelSftp.ls(directory);
+
+ Iterator iterator = ls.iterator();
+
+ Map fileMap = new HashMap<>();
+
+ try {
+
+ while (iterator.hasNext()) {
+ ChannelSftp.LsEntry file = (ChannelSftp.LsEntry) iterator.next();
+ //文件名称
+ String fileName = file.getFilename();
+ System.out.println(fileName);
+ //todo 这里可使用if或正则不下载一些文件
+ InputStream inputStream = channelSftp.get(directory + fileName);
+ if (inputStream != null) {
+ File newFile = new File(fileName);
+ //将InputStream转File
+// FileUtils.copyToFile(inputStream, newFile);
+ fileMap.put(fileName, newFile);
+ }
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ // 切断连接
+ channelSftp.exit();
+ }
+
+ return ls;
+ }
+
+ /**
+ * 列出目录下的文件
+ *
+ * @param directory 要列出的目录
+ * @return
+ * @throws SftpException
+ * @throws JSchException
+ */
+ public List listFiles(String directory) throws JSchException, SftpException {
+ ChannelSftp channelSftp = (ChannelSftp) session.openChannel("sftp");
+ // 远程连接
+ channelSftp.connect();
+ // 显示目录信息
+ Vector ls = channelSftp.ls(directory);
+
+
+ Iterator iterator = ls.iterator();
+
+ try {
+ ArrayList list = new ArrayList<>();
+ while (iterator.hasNext()) {
+ ChannelSftp.LsEntry file = (ChannelSftp.LsEntry) iterator.next();
+ //文件名称
+ String fileName = file.getFilename();
+ //移除上级目录和根目录:"." ".."
+ if (".".equals(fileName) || "..".equals(fileName)) {
+ continue;
+ }
+ list.add(fileName);
+ }
+ return list;
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ // 切断连接
+ channelSftp.exit();
+ }
+ return null;
+ }
+
+
+}
diff --git a/src/main/java/com/example/upsecuritydata/entity/Identification.java b/src/main/java/com/example/upsecuritydata/entity/Identification.java
new file mode 100644
index 0000000..4321850
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/entity/Identification.java
@@ -0,0 +1,32 @@
+package com.example.upsecuritydata.entity;
+
+import lombok.Data;
+
+/**
+ * @author laifeng
+ * @since 2022/11/25
+ */
+@Data
+public class Identification {
+ // 标识码企业前缀
+ private String companyCode;
+ //标识解析节点经营主体名称
+ private String companyName;
+ //标识解析系统级别
+ private int level;
+ //接入省份
+ private String accessProvince;
+ //接入地市
+ private String accessCity;
+ //注册时间
+ private String registerTime;
+ //经营主体行业门类
+ private String categoryA;
+ //经营主体行业大类
+ private String categoryB;
+ //公司性质
+ private String companyType;
+ //节点服务行业
+ private String serviceProfession;
+
+}
diff --git a/src/main/java/com/example/upsecuritydata/entity/NbmsEnprefix.java b/src/main/java/com/example/upsecuritydata/entity/NbmsEnprefix.java
new file mode 100644
index 0000000..d19b1dc
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/entity/NbmsEnprefix.java
@@ -0,0 +1,60 @@
+package com.example.upsecuritydata.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+@TableName("nbms_ent_prefix")
+public class NbmsEnprefix implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+
+ // @ApiModelProperty(value = "主键ID")
+ private Long id;
+ // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+// @ApiModelProperty(value = "")
+ private Date createDate;
+ // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+// @ApiModelProperty(value = "")
+ private Date updateDate;
+
+ // @ApiModelProperty(value = "企业通用id")
+ private String entGeneralId;
+
+ // @ApiModelProperty(value = "企业名称")
+ private String entName;
+
+ // @ApiModelProperty(value = "企业用户ID")
+ private Long userId;
+
+ // @ApiModelProperty(value = "标识前缀")
+ private String entPrefix;
+
+ // @ApiModelProperty(value = "状态是否有效 1启用2停用")
+ private Integer state;
+
+ // @ApiModelProperty(value = "托管状态 1未托管2托管申请中3托管被驳回4已托管")
+ private Integer proxyState;
+
+ // @ApiModelProperty(value = "前缀历史状态是否有效 0停用1启用")
+ private Integer historyState;
+
+ // @ApiModelProperty(value = "路由 0:否,1:是")
+ private Integer isDeleted;
+
+ // @ApiModelProperty(value = "路由xml创建状态")
+ private Integer xmlCreated;
+ // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+// @ApiModelProperty(value = "路由最新上传时间")
+ private Date xmlUpdateTime;
+
+ // @ApiModelProperty(value = "路由xml删除状态")
+ private Integer xmlDeleted;
+
+ // @ApiModelProperty(value = "路由同步状态1同步,0待同步,2同步中")
+ private Integer xmlSync;
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/example/upsecuritydata/entity/NbmsEnt.java b/src/main/java/com/example/upsecuritydata/entity/NbmsEnt.java
new file mode 100644
index 0000000..3f58d79
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/entity/NbmsEnt.java
@@ -0,0 +1,76 @@
+package com.example.upsecuritydata.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author laifeng
+ * @since 2022/11/28
+ */
+@TableName("nbms_ent")
+@Data
+public class NbmsEnt {
+ private long id;
+ private Date createDate;
+ private Date updateDate;
+ private String contactEmail;
+ private String orgAddr;
+ private String orgAddrCity;
+ private String orgAddrCounty;
+ private String orgCrtCode;
+ private int orgCrtType;
+ private String orgDesc;
+ private String entGeneralId;
+ private String industryCategory;
+ private String orgName;
+ private String orgAddrProvince;
+ private String industrySpecific;
+ private int orgNature;
+ private String website;
+ private String legalCrtNo;
+ private int legalCrtType;
+ private String legalName;
+ private String contactPhone;
+ private Integer operateType;
+ private Long userId;
+ private String userName;
+ private String contactName;
+ private Integer sync;
+ private Integer contactCrtType;
+ private String contactCrtNo;
+ private String regAuthority;
+ private Long regCapital;
+ private Date establishDate;
+ private Date periodValidity;
+ private String legalEmail;
+ private String legalPhone;
+ private String legalFax;
+ private Integer servSysBuildType;
+ private String servSysBuildName;
+ private Integer servSysOperType;
+ private String servSysOperName;
+ private String dataHostingOrg;
+ private String servHostingOrg;
+ private Integer regRealNaImpType;
+ private String regRealNaImpName;
+ private String idRegNaImp;
+ private String extWebName;
+ private String extDomain;
+ private String extIpAddr;
+ private Long orgCrtImgRid;
+ private Long contactCrtFrontImgRid;
+ private Long contactCrtBackImgRid;
+ private Long legalCrtFrontImgRid;
+ private Long legalCrtBackImgRid;
+ private Long servSysBuildContractFileRid;
+ private Long servSysOperContractFileRid;
+ private Long dataHostingContractFileRid;
+ private Long servHostingContractFileRid;
+ private Integer isDeleted;
+ private Integer xmlCreated;
+ private Date xmlUpdateTime;
+ private Integer xmlDeleted;
+ private Integer xmlSync;
+}
diff --git a/src/main/java/com/example/upsecuritydata/entity/NbmsEntApply.java b/src/main/java/com/example/upsecuritydata/entity/NbmsEntApply.java
new file mode 100644
index 0000000..0be05fb
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/entity/NbmsEntApply.java
@@ -0,0 +1,220 @@
+package com.example.upsecuritydata.entity;
+
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@TableName("nbms_ent_apply")
+@Data
+public class NbmsEntApply implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+
+ // @ApiModelProperty(value = "主键ID")
+ private Long id;
+ // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+// @ApiModelProperty(value = "")
+ private Date createDate;
+ // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+// @ApiModelProperty(value = "")
+ private Date updateDate;
+
+ // @ApiModelProperty(value = "1注册2部分修改3全量修改4分配前缀")
+ private Integer applyType;
+
+ // @ApiModelProperty(value = "联系人邮箱,正则表达式:")
+ private String contactEmail;
+
+ // @ApiModelProperty(value = "单位地址,详细地址")
+ private String orgAddr;
+
+ // @ApiModelProperty(value = "单位地址,市,取值遵从全国省市区行政编码,如北京市则展示为直辖市,取值110100")
+ private String orgAddrCity;
+
+ // @ApiModelProperty(value = "单位地址,县,取值遵从全国省市区行政编码,如北京的东城区110101")
+ private String orgAddrCounty;
+
+ // @ApiModelProperty(value = "单位证件号")
+ private String orgCrtCode;
+
+ // @ApiModelProperty(value = "单位证件类型,统一社会信用代码、其他,对应取值1-2")
+ private Integer orgCrtType;
+
+ // @ApiModelProperty(value = "单位简介,200字左右企业简介,包括公司名称、成立时间、所在省市、主营业务、主要用户群体、行业地位等信息。")
+ private String orgDesc;
+
+ // @ApiModelProperty(value = "企业通用id,注册时为空")
+ private String entGeneralId;
+
+ // @ApiModelProperty(value = "服务行业,行业门类,参考《GB/T 4754—2017国民经济行业分类》,如门类“农、林、牧、渔业”对应“A”")
+ private String industryCategory;
+
+ // @ApiModelProperty(value = "单位名称")
+ private String orgName;
+
+ // @ApiModelProperty(value = "单位地址,省,取值遵从全国省市区行政编码,如北京110000")
+ private String orgAddrProvince;
+
+ // @ApiModelProperty(value = "服务行业,行业大类,参考《GB/T 4754—2017国民经济行业分类》,如大类“农业”对应“01”。和门类有级联关系")
+ private String industrySpecific;
+
+ // @ApiModelProperty(value = "单位性质,国有控股、民营控股、外商控股、事业单位、民营非盈利,对应取值1-5")
+ private Integer orgNature;
+
+ // @ApiModelProperty(value = "官方网站")
+ private String website;
+
+ // @ApiModelProperty(value = "")
+ private String industry;
+
+ // @ApiModelProperty(value = "0未提交1已提交")
+ private Integer isSubmit;
+
+ // @ApiModelProperty(value = "法定代表人证件号")
+ private String legalCrtNo;
+
+ // @ApiModelProperty(value = "法定代表人证件类型,中国居民身份证、护照、其他,对应取值1-3")
+ private Integer legalCrtType;
+
+ // @ApiModelProperty(value = "法定代表人姓名")
+ private String legalName;
+
+ // @ApiModelProperty(value = "联系人手机号,正则表达式")
+ private String contactPhone;
+
+ // @ApiModelProperty(value = "企业前缀")
+ private String entPrefix;
+
+ // @ApiModelProperty(value = "节点用户给出的审核状态:1待审核2审核通过3被驳回")
+ private Integer firstAuditStatus;
+
+ // @ApiModelProperty(value = "节点用户给出的审核结果描述")
+ private String firstAuditMsg;
+
+ // @ApiModelProperty(value = "实名核验结果")
+ private Integer thirdServiceStatus;
+
+ // @ApiModelProperty(value = "实名核验结果说明")
+ private String thirdServiceMsg;
+
+ // @ApiModelProperty(value = "企业用户名称不能为空")
+ private String userName;
+
+ // @ApiModelProperty(value = "顶级bms给出的审核状态:1待审核2审核通过3被驳回")
+ private Integer finalAuditStatus;
+
+ // @ApiModelProperty(value = "顶级bms企业审核员对企业信息的审核结果描述")
+ private String finalAuditMsg;
+
+ // @ApiModelProperty(value = "svTRId: 服务端id自动生成")
+ @TableField("svTRId")
+ private String svTRId;
+
+ // @ApiModelProperty(value = "clTRId: 客户端Id")
+ @TableField("clTRId")
+ private String clTRId;
+
+ // @ApiModelProperty(value = "联系人姓名")
+ private String contactName;
+
+ // @ApiModelProperty(value = "企业用户id")
+ private Long userId;
+
+ // @ApiModelProperty(value = "申请前缀执行到的第几步")
+ private Integer applyStep;
+
+ // @ApiModelProperty(value = "联系人证件类型,中国居民身份证、护照、其他,对应取值1-3")
+ private Integer contactCrtType;
+
+ // @ApiModelProperty(value = "联系人证件号")
+ private String contactCrtNo;
+
+ // @ApiModelProperty(value = "注册机关")
+ private String regAuthority;
+
+ // @ApiModelProperty(value = "注册资本,单位元")
+ private Long regCapital;
+ // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+// @ApiModelProperty(value = "成立日期,时间格式:yyyy-MM-dd ")
+ private Date establishDate;
+ // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+// @ApiModelProperty(value = "有效期")
+ private Date periodValidity;
+
+ // @ApiModelProperty(value = "法人代表人邮箱,正则表达式:")
+ private String legalEmail;
+
+ // @ApiModelProperty(value = "法人代表人手机号,正则表达式")
+ private String legalPhone;
+
+ // @ApiModelProperty(value = "法人代表人传真")
+ private String legalFax;
+
+ // @ApiModelProperty(value = "服务系统建设,建设类型,□自营 □委托 描述对应的编码取值1-2")
+ private Integer servSysBuildType;
+
+ // @ApiModelProperty(value = "委托机构名称,委托机构名称,建设类型选“委托”,该字段必填")
+ private String servSysBuildName;
+
+ // @ApiModelProperty(value = "服务系统运营,运营类型,□自营 □委托 描述对应的编码取值1-2")
+ private Integer servSysOperType;
+
+ // @ApiModelProperty(value = "服务系统运营,委托机构名称,建设类型选“委托”,该字段必填")
+ private String servSysOperName;
+
+ // @ApiModelProperty(value = "数据托管单位,例:国家顶级节点(北京)")
+ private String dataHostingOrg;
+
+ // @ApiModelProperty(value = "服务托管单位,例:南京ZB节点")
+ private String servHostingOrg;
+
+ // @ApiModelProperty(value = "注册实名核验实施,实施类型□自营 □委托 描述对应的编码取值1-2")
+ private Integer regRealNaImpType;
+
+ // @ApiModelProperty(value = "注册实名核验实施,委托机构名称,建设类型选“委托”,该字段必填")
+ private String regRealNaImpName;
+
+ // @ApiModelProperty(value = "标识注册名称合规实施")
+ private String idRegNaImp;
+
+ // @ApiModelProperty(value = "对外提供标识服务的网站名称、域名、IP地址,网站名称")
+ private String extWebName;
+
+ // @ApiModelProperty(value = "对外提供标识服务的网站名称、域名、IP地址,域名")
+ private String extDomain;
+
+ // @ApiModelProperty(value = "对外提供标识服务的网站名称、域名、IP地址,IP地址,支持IPv4和IPv6,多个IP间以;分割")
+ private String extIpAddr;
+
+ // @ApiModelProperty(value = "营业执照")
+ private Long orgCrtImgRid;
+
+ // @ApiModelProperty(value = "联系人证件照正面")
+ private Long contactCrtFrontImgRid;
+
+ // @ApiModelProperty(value = "联系人证件照反面")
+ private Long contactCrtBackImgRid;
+
+ // @ApiModelProperty(value = "法人证件照正面")
+ private Long legalCrtFrontImgRid;
+
+ // @ApiModelProperty(value = "法人证件照反面")
+ private Long legalCrtBackImgRid;
+
+ // @ApiModelProperty(value = "服务系统建设合同")
+ private Long servSysBuildContractFileRid;
+
+ // @ApiModelProperty(value = "服务系统运营合同")
+ private Long servSysOperContractFileRid;
+
+ // @ApiModelProperty(value = "数据托管合同")
+ private Long dataHostingContractFileRid;
+
+ // @ApiModelProperty(value = "服务托管合同")
+ private Long servHostingContractFileRid;
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/example/upsecuritydata/entity/SysDict.java b/src/main/java/com/example/upsecuritydata/entity/SysDict.java
new file mode 100644
index 0000000..7198ff4
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/entity/SysDict.java
@@ -0,0 +1,22 @@
+package com.example.upsecuritydata.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author laifeng
+ * @since 2022/11/28
+ */
+@Data
+@TableName("sys_dict")
+public class SysDict {
+ private Long id;
+ private String dictKey;
+ private String dictCode;
+ private String dictValue;
+ private Long parentId;
+ private Date createDate;
+ private Date updateDate;
+}
diff --git a/src/main/java/com/example/upsecuritydata/mapper/NbmsEnprefixMapper.java b/src/main/java/com/example/upsecuritydata/mapper/NbmsEnprefixMapper.java
new file mode 100644
index 0000000..24e5694
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/mapper/NbmsEnprefixMapper.java
@@ -0,0 +1,14 @@
+package com.example.upsecuritydata.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.upsecuritydata.entity.NbmsEnprefix;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @author laifeng
+ * @since 2022/11/28
+ */
+@Mapper
+public interface NbmsEnprefixMapper extends BaseMapper {
+
+}
diff --git a/src/main/java/com/example/upsecuritydata/mapper/NbmsEntApplyMapper.java b/src/main/java/com/example/upsecuritydata/mapper/NbmsEntApplyMapper.java
new file mode 100644
index 0000000..3bea3c9
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/mapper/NbmsEntApplyMapper.java
@@ -0,0 +1,19 @@
+package com.example.upsecuritydata.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.upsecuritydata.entity.NbmsEntApply;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * NbmsEnapplyMapper
+ *
+ * @author fuce_自动生成
+ * @email ${email}
+ * @date 2022-11-28 17:12:08
+ */
+@Mapper
+public interface NbmsEntApplyMapper extends BaseMapper {
+
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/example/upsecuritydata/mapper/NbmsEntMapper.java b/src/main/java/com/example/upsecuritydata/mapper/NbmsEntMapper.java
new file mode 100644
index 0000000..3ecebdc
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/mapper/NbmsEntMapper.java
@@ -0,0 +1,13 @@
+package com.example.upsecuritydata.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.upsecuritydata.entity.NbmsEnt;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @author laifeng
+ * @since 2022/11/28
+ */
+@Mapper
+public interface NbmsEntMapper extends BaseMapper {
+}
diff --git a/src/main/java/com/example/upsecuritydata/mapper/SysDictMapper.java b/src/main/java/com/example/upsecuritydata/mapper/SysDictMapper.java
new file mode 100644
index 0000000..52665f6
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/mapper/SysDictMapper.java
@@ -0,0 +1,13 @@
+package com.example.upsecuritydata.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.upsecuritydata.entity.SysDict;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @author laifeng
+ * @since 2022/11/28
+ */
+@Mapper
+public interface SysDictMapper extends BaseMapper {
+}
diff --git a/src/main/java/com/example/upsecuritydata/service/IdentificationIp.java b/src/main/java/com/example/upsecuritydata/service/IdentificationIp.java
new file mode 100644
index 0000000..17a3e5c
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/service/IdentificationIp.java
@@ -0,0 +1,39 @@
+package com.example.upsecuritydata.service;
+
+import lombok.AllArgsConstructor;
+
+import java.io.File;
+
+/**
+ * 四、 标识解析节点使用IP段上报
+ *
+ * @author laifeng
+ * @since 2022/11/27
+ */
+@AllArgsConstructor
+public class IdentificationIp {
+
+ private final Method method;
+ public static void main(String[] args) throws Exception {
+
+// String fileName = "d://aaa//test.txt";
+// // 要上传的目录
+// String upSrc = "/002/" + DateUtil.format(DateUtil.now(), "yyyyMMdd");
+// // 表名(文件名的一部分)
+// String tableName = "SDQN-basic_identification_ip-";
+// // 操作类型为新增
+// String operationName = "-add.bin";
+// method.upMethod(fileName, upSrc, tableName, operationName);
+
+
+ }
+
+ public static void deleteFile(String src) {
+
+ System.out.println(src);
+ File file = new File(src);
+ boolean delete = file.delete();
+ System.out.println(delete);
+ }
+
+}
diff --git a/src/main/java/com/example/upsecuritydata/service/Method.java b/src/main/java/com/example/upsecuritydata/service/Method.java
new file mode 100644
index 0000000..b5b6213
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/service/Method.java
@@ -0,0 +1,24 @@
+package com.example.upsecuritydata.service;
+
+import java.io.IOException;
+
+/**
+ * @author laifeng
+ * @since 2022/11/27
+ */
+public interface Method {
+ void upMethod(String readFile, String upSrc, String tableName, String operationName) throws Exception;
+
+ Boolean creatIdentificationUpFile(Integer type, String yyyyMMdd, String yyyyMMddToday) throws IOException;
+
+ Boolean creatForUpFile(Integer type, String yyyyMMdd, String yyyyMMddToday) throws IOException;
+
+ Boolean creatFiveUpFile(Integer type, String yyyyMMdd, String yyyyMMddToday) throws IOException;
+
+ void creatSixUpFileAndUp(String yesterday) throws Exception;
+
+ void creatSevenUpFileAndUp(String yesterday) throws Exception;
+
+ // 删除上传文件
+ void deletUpFile(String localPackage);
+}
diff --git a/src/main/java/com/example/upsecuritydata/service/NbmsEnprefixService.java b/src/main/java/com/example/upsecuritydata/service/NbmsEnprefixService.java
new file mode 100644
index 0000000..8eb2cd1
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/service/NbmsEnprefixService.java
@@ -0,0 +1,11 @@
+package com.example.upsecuritydata.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.example.upsecuritydata.entity.NbmsEnprefix;
+
+/**
+ * @author laifeng
+ * @since 2022/11/28
+ */
+public interface NbmsEnprefixService extends IService {
+}
diff --git a/src/main/java/com/example/upsecuritydata/service/NbmsEntApplyServcie.java b/src/main/java/com/example/upsecuritydata/service/NbmsEntApplyServcie.java
new file mode 100644
index 0000000..36801c7
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/service/NbmsEntApplyServcie.java
@@ -0,0 +1,11 @@
+package com.example.upsecuritydata.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.example.upsecuritydata.entity.NbmsEntApply;
+
+/**
+ * @author laifeng
+ * @since 2022/11/28
+ */
+public interface NbmsEntApplyServcie extends IService {
+}
diff --git a/src/main/java/com/example/upsecuritydata/service/NbmsEntServcie.java b/src/main/java/com/example/upsecuritydata/service/NbmsEntServcie.java
new file mode 100644
index 0000000..0b0516b
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/service/NbmsEntServcie.java
@@ -0,0 +1,12 @@
+package com.example.upsecuritydata.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.example.upsecuritydata.entity.NbmsEnt;
+
+/**
+ * @author laifeng
+ * @since 2022/11/28
+ */
+public interface NbmsEntServcie extends IService {
+}
diff --git a/src/main/java/com/example/upsecuritydata/service/SysDictService.java b/src/main/java/com/example/upsecuritydata/service/SysDictService.java
new file mode 100644
index 0000000..5a09f0c
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/service/SysDictService.java
@@ -0,0 +1,14 @@
+package com.example.upsecuritydata.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.example.upsecuritydata.entity.SysDict;
+
+import java.util.List;
+
+/**
+ * @author laifeng
+ * @since 2022/11/28
+ */
+public interface SysDictService extends IService {
+ List selectAll();
+}
diff --git a/src/main/java/com/example/upsecuritydata/service/impl/MethodImpl.java b/src/main/java/com/example/upsecuritydata/service/impl/MethodImpl.java
new file mode 100644
index 0000000..78fe4c4
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/service/impl/MethodImpl.java
@@ -0,0 +1,515 @@
+package com.example.upsecuritydata.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.example.upsecuritydata.cache.CodeCache;
+import com.example.upsecuritydata.entity.NbmsEnprefix;
+import com.example.upsecuritydata.entity.NbmsEntApply;
+import com.example.upsecuritydata.service.Method;
+import com.example.upsecuritydata.service.NbmsEnprefixService;
+import com.example.upsecuritydata.service.NbmsEntApplyServcie;
+import com.example.upsecuritydata.util.Constant;
+import com.example.upsecuritydata.util.Encrypt;
+import com.example.upsecuritydata.util.JschUtil;
+import com.jcraft.jsch.*;
+import com.xxl.job.core.context.XxlJobHelper;
+import lombok.AllArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.io.*;
+import java.util.*;
+import java.util.zip.GZIPInputStream;
+
+/**
+ * @author laifeng
+ * @since 2022/11/27
+ */
+@Service
+@AllArgsConstructor
+public class MethodImpl implements Method {
+ private final NbmsEntApplyServcie nbmsEntApplyServcie;
+
+ private final NbmsEnprefixService enprefixService;
+
+ @Override
+ public void upMethod(String readFile, String upSrc, String tableName, String operationName) throws Exception {
+
+
+ File file = new File(readFile);
+ BufferedReader br = new BufferedReader(new InputStreamReader(
+ new FileInputStream(file)));
+ StringBuilder sb = new StringBuilder();
+ String line = null;
+ while ((line = br.readLine()) != null) {
+ sb.append(line).append("\n");
+ }
+ br.close();
+ // 将字符串压缩成zip文件并获得字节数据
+ byte[] bytes = Encrypt.zipToBytes(Constant.zipPath, sb.toString());
+ // upload是压缩加密后的内容
+ byte[] upload = Encrypt.encryptAlgorithm("1", bytes, "1234567890abcDEF",
+ "1234567890abcDEF");
+
+ // 生成文件名
+ String dateStr = Long.toString(System.currentTimeMillis()); // 生成13位时间戳
+ String fileName = tableName + dateStr + operationName;
+ String src = Constant.localPackage + fileName;
+ // 写入文件
+ FileOutputStream stream = new FileOutputStream(src);
+ stream.write(upload);
+ XxlJobHelper.log("写入成功:" + fileName);
+ // 关闭输出流
+ stream.close();
+
+ // 远程连接服务器
+ JschUtil jschUtil = new JschUtil(Constant.ipAddress, 22102, Constant.userName, Constant.password);
+ jschUtil.connect();
+
+ // 确保目录一定存在
+ jschUtil.directory(upSrc);
+ // 上传文件到指定目录
+ // TODO: 2023/3/1 上传路径这里需要改
+ jschUtil.upload("/data1/guanxianguanhong/" + upSrc + "/" + fileName, src);
+
+ }
+
+ /**
+ * 生成三、 标识解析企业主体信息上报文件
+ *
+ * @param type 0 代表注册 1 代表修改
+ * @return
+ */
+ @Override
+ public Boolean creatIdentificationUpFile(Integer type, String yyyyMMdd, String yyyyMMddToday) throws IOException {
+ String companyCode; //标识码企业前缀
+ String companyName; // 标识解析节点经营主体名称
+ String level; // 标识解析系统级别
+ String accessProvince; // 接入省份
+ String accessCity; // 接入地市
+ String registerTime; // 注册时间
+ String categoryA; // 经营主体行业门类
+ String categoryB; // 经营主体行业大类
+ String companyType; // 公司性质
+ String serviceProfession; //节点服务行业
+
+ List list = null;
+ // 新增操作
+ if (type == 0) {
+ list = nbmsEntApplyServcie.lambdaQuery().eq(NbmsEntApply::getFirstAuditStatus, 2)
+ .eq(NbmsEntApply::getApplyType, 1)
+ .eq(NbmsEntApply::getApplyStep, 4)
+ .ge(NbmsEntApply::getUpdateDate, yyyyMMdd)
+ .lt(NbmsEntApply::getUpdateDate, yyyyMMddToday)
+ .list();
+ }
+ // 修改操作
+ if (type == 1) {
+ list = nbmsEntApplyServcie.lambdaQuery().eq(NbmsEntApply::getFirstAuditStatus, 2)
+ .eq(NbmsEntApply::getApplyType, 2)
+ .eq(NbmsEntApply::getApplyType, 3)
+ .eq(NbmsEntApply::getApplyStep, 4)
+ .ge(NbmsEntApply::getUpdateDate, yyyyMMdd)
+ .lt(NbmsEntApply::getUpdateDate, yyyyMMddToday)
+ .list();
+ }
+ // 全量操作
+ if (type == 2) {
+ list = nbmsEntApplyServcie.lambdaQuery().eq(NbmsEntApply::getFirstAuditStatus, 2)
+ .eq(NbmsEntApply::getApplyType, 1)
+ .eq(NbmsEntApply::getApplyStep, 4)
+ .list();
+ }
+ // 创建输出流
+ FileOutputStream stream = new FileOutputStream(Constant.localNotEncryFileNamePath);
+ if (CollUtil.isNotEmpty(list)) {
+ for (NbmsEntApply nbmsEnapply : list) {
+ companyCode = nbmsEnapply.getEntPrefix();
+ companyName = nbmsEnapply.getOrgName();
+ level = "4";
+ accessProvince = nbmsEnapply.getOrgAddrProvince();
+ accessProvince = CodeCache.codeMap.get(accessProvince);
+
+ accessCity = nbmsEnapply.getOrgAddrCity();
+ accessCity = CodeCache.codeMap.get(accessCity);
+
+ registerTime = DateUtil.format(nbmsEnapply.getUpdateDate(), "yyyy-MM-dd HH:mm:ss");
+
+ categoryA = nbmsEnapply.getIndustrySpecific();
+ categoryA = CodeCache.codeMap.get(categoryA);
+
+ categoryB = nbmsEnapply.getIndustryCategory();
+ categoryB = CodeCache.codeMap.get(categoryB);
+
+ companyType = judge(nbmsEnapply.getOrgNature());
+ serviceProfession = categoryB;
+
+ String template = companyCode + "|" + companyName + "|" + level + "|" + accessProvince + "|" + accessCity + "|" + registerTime + "|" + categoryA + "|" + categoryB + "|" + companyType + "|" + serviceProfession + "\n";
+ byte[] bytes = template.getBytes();
+ stream.write(bytes);
+ }
+ stream.flush();
+ stream.close();
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * 四、 标识解析企业主体信息上报
+ *
+ * @param type 0 代表注册 1 代表修改
+ */
+ @Override
+ public Boolean creatForUpFile(Integer type, String yyyyMMdd, String yyyyMMddToday) throws IOException {
+ String companyName; // 标识解析节点经营主体名称
+ String startIP = Constant.startIP;
+ String endIP = Constant.endIP;
+ String position = Constant.position;
+ List list = null;
+ if (type == 0) {
+ list = enprefixService.query()
+ .select("DISTINCT(ent_name)")
+ .eq("proxy_state", 4)
+ .ge("update_date", yyyyMMdd)
+ .lt("update_date", yyyyMMddToday)
+ .list();
+ }
+ if (type == 2) {
+ list = enprefixService.query()
+ .select("DISTINCT(ent_name)")
+ .eq("proxy_state", 4)
+ .list();
+ }
+ if (CollUtil.isEmpty(list)) {
+ return false;
+ }
+ // 创建输出流
+ FileOutputStream stream = new FileOutputStream(Constant.localNotEncryFileNamePath);
+ for (NbmsEnprefix enprefix : list) {
+ companyName = enprefix.getEntName();
+ String template = companyName + "|" + startIP + "|" + endIP + "|" + position + "\n";
+ byte[] bytes = template.getBytes();
+ stream.write(bytes);
+ }
+ stream.flush();
+ stream.close();
+ return true;
+ }
+
+ /**
+ * 五、 标识注册企业主体信息上报
+ *
+ * @param type
+ * @param yyyyMMdd
+ * @param yyyyMMddToday
+ * @return
+ */
+ @Override
+ public Boolean creatFiveUpFile(Integer type, String yyyyMMdd, String yyyyMMddToday) throws IOException {
+ String companyCode; //标识码企业前缀
+ String companyName; // 标识解析节点经营主体名称
+ String level; // 标识解析系统级别
+ String accessProvince; // 接入省份
+ String accessCity; // 接入地市
+ String registerTime; // 注册时间
+ String categoryA; // 经营主体行业门类
+ String categoryB; // 经营主体行业大类
+ String companyType; // 公司性质
+ String serviceProfession; //节点服务行业
+
+ List list = null;
+ // 新增操作
+ if (type == 0) {
+ list = nbmsEntApplyServcie.lambdaQuery().eq(NbmsEntApply::getFirstAuditStatus, 2)
+ .eq(NbmsEntApply::getApplyType, 1)
+ .eq(NbmsEntApply::getApplyStep, 4)
+ .ge(NbmsEntApply::getUpdateDate, yyyyMMdd)
+ .lt(NbmsEntApply::getUpdateDate, yyyyMMddToday)
+ .list();
+ }
+ // 修改操作
+ if (type == 1) {
+ list = nbmsEntApplyServcie.lambdaQuery().eq(NbmsEntApply::getFirstAuditStatus, 2)
+ .eq(NbmsEntApply::getApplyType, 2)
+ .eq(NbmsEntApply::getApplyType, 3)
+ .eq(NbmsEntApply::getApplyStep, 4)
+ .ge(NbmsEntApply::getUpdateDate, yyyyMMdd)
+ .lt(NbmsEntApply::getUpdateDate, yyyyMMddToday)
+ .list();
+ }
+ // 全量操作
+ if (type == 2) {
+ list = nbmsEntApplyServcie.lambdaQuery().eq(NbmsEntApply::getFirstAuditStatus, 2)
+ .eq(NbmsEntApply::getApplyType, 1)
+ .eq(NbmsEntApply::getApplyStep, 4)
+ .list();
+ }
+ // 创建输出流
+ FileOutputStream stream = new FileOutputStream(Constant.localNotEncryFileNamePath);
+ if (CollUtil.isNotEmpty(list)) {
+ for (NbmsEntApply nbmsEnapply : list) {
+ companyCode = nbmsEnapply.getEntPrefix();
+ companyName = nbmsEnapply.getOrgName();
+// level = "4";
+ accessProvince = nbmsEnapply.getOrgAddrProvince();
+ accessProvince = CodeCache.codeMap.get(accessProvince);
+
+ accessCity = nbmsEnapply.getOrgAddrCity();
+ accessCity = CodeCache.codeMap.get(accessCity);
+
+ registerTime = DateUtil.format(nbmsEnapply.getUpdateDate(), "yyyy-MM-dd HH:mm:ss");
+
+ categoryA = nbmsEnapply.getIndustrySpecific();
+ categoryA = CodeCache.codeMap.get(categoryA);
+
+ categoryB = nbmsEnapply.getIndustryCategory();
+ categoryB = CodeCache.codeMap.get(categoryB);
+
+ companyType = judge(nbmsEnapply.getOrgNature());
+ serviceProfession = categoryB;
+
+ String template = companyCode + "|" + companyName + "|" + accessProvince + "|" + accessCity + "|" + registerTime + "|" + categoryA + "|" + categoryB + "|" + companyType + "|" + serviceProfession + "\n";
+ byte[] bytes = template.getBytes();
+ stream.write(bytes);
+ }
+ stream.flush();
+ stream.close();
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void creatSixUpFileAndUp(String yesterday) throws Exception {
+ JSch jsch = new JSch();
+ Session session = jsch.getSession(Constant.user, Constant.host, 22);
+ session.setPassword(Constant.password1);
+ session.setConfig("StrictHostKeyChecking", "no");
+ session.connect(2000000);
+
+ ChannelSftp sftp = (ChannelSftp) session.openChannel("sftp");
+ sftp.connect(2000000);
+
+ // 连接远程服务器,日志存放地
+ String yesterdayStr = DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd");
+ String directoryPath = Constant.sixRemoteLogPackage + yesterdayStr;
+ List allFile = listFiles(directoryPath, sftp);
+
+ if (CollUtil.isEmpty(allFile)) {
+// System.out.println("表4:昨日无日志文件夹!");
+ XxlJobHelper.log("表4:昨日无日志文件夹!");
+ return;
+ }
+ for (String filePath : allFile) {
+ // 读取远程服务器上的日志文件 gz压缩格式
+ GZIPInputStream gzipInputStream = new GZIPInputStream(sftp.get(directoryPath + "/" + filePath));
+ Reader decoder = new InputStreamReader(gzipInputStream, "UTF-8");
+ BufferedReader reader = new BufferedReader(decoder);
+ // 创建输出流
+ FileOutputStream outputStream = new FileOutputStream(Constant.localNotEncryFileNamePath);
+ String tempString;
+ //一次读一行,读入null时文件结束
+ while ((tempString = reader.readLine()) != null) {
+ // 获得请求时间
+ JSONObject jsonObject = JSON.parseObject(tempString);
+ String operatorTime = jsonObject.getString("operatorTime");
+ Date date1 = DateUtil.parse(operatorTime, "yyyyMMddHHmmss");
+ String requestTime = DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss");
+ // 获得响应时间
+ String responseTime = requestTime;
+ // 获得源IP
+ String sourceIP = jsonObject.getString("userIp");
+ // 端口
+ String port = "80";
+ // 获得目的IP
+ String destinationIP = jsonObject.getString("idisIp");
+ // 方法
+ String method = "HTTPM_GET";
+ // 企业标识码
+ String companyCode = jsonObject.getString("prefix");
+ // 标识编码
+ String ideCode = jsonObject.getString("handleName");
+ //
+
+ // 组装字符串
+ tempString = requestTime + "|" + responseTime + "|" + sourceIP + "|" + port + "|" + destinationIP + "|" + port + "|" + method + "|" + companyCode + "|" + ideCode + "|" + "|" + "|" + "|" + "http://code.qnaiot.com" + "|" + "http://code.qnaiot.com" + "|" + "\n";
+
+ byte[] bytes = tempString.getBytes();
+ outputStream.write(bytes);
+
+ }
+ outputStream.flush();
+ outputStream.close();
+ decoder.close();
+ gzipInputStream.close();
+ // 上传
+ String fileName = Constant.localNotEncryFileNamePath;
+ // 要上传的目录
+ String upSrc = "/004/" + yesterday;
+ // 表名(文件名的一部分)
+ String tableName = Constant.companyName + "-basic_registered_log-";
+ String operationName = ".bin";
+ this.upMethod(fileName, upSrc, tableName, operationName);
+ }
+ sftp.disconnect();
+// session.disconnect();
+
+
+ }
+
+ @Override
+ public void creatSevenUpFileAndUp(String yesterday) throws Exception {
+ JSch jsch = new JSch();
+ Session session = jsch.getSession(Constant.user, Constant.host, 22);
+ session.setPassword(Constant.password1);
+ session.setConfig("StrictHostKeyChecking", "no");
+ session.connect(200000);
+
+ ChannelSftp sftp = (ChannelSftp) session.openChannel("sftp");
+ sftp.connect(200000);
+
+ // 连接远程服务器,日志存放地
+ String yesterdayStr = DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd");
+ String directoryPath = Constant.sixRemoteLogPackage + yesterdayStr;
+ List allFile = listFiles(directoryPath, sftp);
+
+ if (CollUtil.isEmpty(allFile)) {
+ XxlJobHelper.log("表4:昨日无日志文件夹!");
+ return;
+ }
+ for (String filePath : allFile) {
+ // 读取远程服务器上的日志文件 gz压缩格式
+ GZIPInputStream gzipInputStream = new GZIPInputStream(sftp.get(directoryPath + "/" + filePath));
+ Reader decoder = new InputStreamReader(gzipInputStream, "UTF-8");
+ BufferedReader reader = new BufferedReader(decoder);
+ // 创建输出流
+ FileOutputStream outputStream = new FileOutputStream(Constant.localNotEncryFileNamePath);
+ String tempString;
+ //一次读一行,读入null时文件结束
+ while ((tempString = reader.readLine()) != null) {
+ // 获得请求时间
+ JSONObject jsonObject = JSON.parseObject(tempString);
+ String operatorTime = jsonObject.getString("operatorTime");
+ Date date1 = DateUtil.parse(operatorTime, "yyyyMMddHHmmss");
+ String requestTime = DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss");
+ // 获得响应时间
+ String responseTime = requestTime;
+ // 获得源IP
+ String sourceIP = jsonObject.getString("userIp");
+ // 端口
+ String port = "80";
+ // 获得目的IP
+ String destinationIP = jsonObject.getString("idisIp");
+ // 方法
+ String method = "HTTPM_GET";
+ // 企业标识码
+ String companyCode = jsonObject.getString("prefix");
+ // 标识编码
+ String ideCode = jsonObject.getString("handleName");
+ //
+
+ // 组装字符串
+ tempString = requestTime + "|" + responseTime + "|" + sourceIP + "|" + port + "|" + destinationIP + "|" + port + "|" + method + "|" + companyCode + "|" + ideCode + "|" + "|" + "|" + "|" + "http://code.qnaiot.com" + "|" + "http://code.qnaiot.com" + "|" + "\n";
+
+ byte[] bytes = tempString.getBytes();
+ outputStream.write(bytes);
+
+ }
+ outputStream.flush();
+ outputStream.close();
+ decoder.close();
+ gzipInputStream.close();
+ // 上传
+ String fileName = Constant.localNotEncryFileNamePath;
+ // 要上传的目录
+ String upSrc = "/005/" + yesterday;
+ // 表名(文件名的一部分)
+ String tableName = Constant.companyName + "-basic_identification_log-";
+ String operationName = ".bin";
+ this.upMethod(fileName, upSrc, tableName, operationName);
+ }
+ sftp.disconnect();
+ }
+
+ @Override
+ public void deletUpFile(String localPackage) {
+ File directory = new File(localPackage);
+ for (File file : Objects.requireNonNull(directory.listFiles())) {
+ if (!file.isDirectory()) {
+ file.delete();
+ }
+ }
+
+ }
+
+
+// private void deleteFile(String src) {
+//
+// System.out.println(src);
+// File file = new File( src);
+// boolean delete = file.delete();
+// System.out.println(delete);
+// }
+
+ private String judge(int companyType) {
+ //单位性质,国有控股、民营控股、外商控股、事业单位、民营非盈利
+ if (companyType == 1) {
+ return "国有控股";
+ }
+ if (companyType == 2) {
+ return "民营控股";
+ }
+ if (companyType == 3) {
+ return "外商控股";
+ }
+ if (companyType == 4) {
+ return "事业单位";
+ }
+ if (companyType == 5) {
+ return "民营非盈利";
+ }
+
+ return null;
+ }
+
+ /**
+ * 列出目录下的文件
+ *
+ * @param directory 要列出的目录
+ * @return
+ * @throws SftpException
+ * @throws JSchException
+ */
+ private List listFiles(String directory, ChannelSftp channelSftp) {
+ // 显示目录信息
+ Vector ls = null;
+ try {
+ ls = channelSftp.ls(directory);
+ } catch (SftpException e) {
+ return null;
+ }
+
+
+ Iterator iterator = ls.iterator();
+
+ try {
+ ArrayList list = new ArrayList<>();
+ while (iterator.hasNext()) {
+ ChannelSftp.LsEntry file = (ChannelSftp.LsEntry) iterator.next();
+ //文件名称
+ String fileName = file.getFilename();
+ //移除上级目录和根目录:"." ".."
+ if (".".equals(fileName) || "..".equals(fileName)) {
+ continue;
+ }
+ list.add(fileName);
+ }
+ return list;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/com/example/upsecuritydata/service/impl/NbmsEnprefixServiceImpl.java b/src/main/java/com/example/upsecuritydata/service/impl/NbmsEnprefixServiceImpl.java
new file mode 100644
index 0000000..b18b209
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/service/impl/NbmsEnprefixServiceImpl.java
@@ -0,0 +1,16 @@
+package com.example.upsecuritydata.service.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.upsecuritydata.entity.NbmsEnprefix;
+import com.example.upsecuritydata.mapper.NbmsEnprefixMapper;
+import com.example.upsecuritydata.service.NbmsEnprefixService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author laifeng
+ * @since 2022/11/28
+ */
+@Service
+public class NbmsEnprefixServiceImpl extends ServiceImpl implements NbmsEnprefixService {
+}
diff --git a/src/main/java/com/example/upsecuritydata/service/impl/NbmsEntApplyServcieImpl.java b/src/main/java/com/example/upsecuritydata/service/impl/NbmsEntApplyServcieImpl.java
new file mode 100644
index 0000000..154418b
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/service/impl/NbmsEntApplyServcieImpl.java
@@ -0,0 +1,17 @@
+package com.example.upsecuritydata.service.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.upsecuritydata.entity.NbmsEntApply;
+import com.example.upsecuritydata.mapper.NbmsEntApplyMapper;
+import com.example.upsecuritydata.service.NbmsEntApplyServcie;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * @author laifeng
+ * @since 2022/11/28
+ */
+@Service
+public class NbmsEntApplyServcieImpl extends ServiceImpl implements NbmsEntApplyServcie {
+}
diff --git a/src/main/java/com/example/upsecuritydata/service/impl/NbmsEntServiceImpl.java b/src/main/java/com/example/upsecuritydata/service/impl/NbmsEntServiceImpl.java
new file mode 100644
index 0000000..ddbb823
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/service/impl/NbmsEntServiceImpl.java
@@ -0,0 +1,17 @@
+package com.example.upsecuritydata.service.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.upsecuritydata.entity.NbmsEnt;
+import com.example.upsecuritydata.mapper.NbmsEntMapper;
+import com.example.upsecuritydata.service.NbmsEntServcie;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * @author laifeng
+ * @since 2022/11/28
+ */
+@Service
+public class NbmsEntServiceImpl extends ServiceImpl implements NbmsEntServcie {
+}
diff --git a/src/main/java/com/example/upsecuritydata/service/impl/SysDictServiceImpl.java b/src/main/java/com/example/upsecuritydata/service/impl/SysDictServiceImpl.java
new file mode 100644
index 0000000..bc919dc
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/service/impl/SysDictServiceImpl.java
@@ -0,0 +1,24 @@
+package com.example.upsecuritydata.service.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.upsecuritydata.entity.SysDict;
+import com.example.upsecuritydata.mapper.SysDictMapper;
+import com.example.upsecuritydata.service.SysDictService;
+import org.springframework.stereotype.Service;
+
+
+import java.util.List;
+
+/**
+ * @author laifeng
+ * @since 2022/11/28
+ */
+@Service
+public class SysDictServiceImpl extends ServiceImpl implements SysDictService {
+ @Override
+ public List selectAll() {
+ List list = baseMapper.selectList(null);
+ return list;
+ }
+}
diff --git a/src/main/java/com/example/upsecuritydata/task/IdentificationUpTask.java b/src/main/java/com/example/upsecuritydata/task/IdentificationUpTask.java
new file mode 100644
index 0000000..6e8c0d7
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/task/IdentificationUpTask.java
@@ -0,0 +1,234 @@
+package com.example.upsecuritydata.task;
+
+import cn.hutool.core.date.DateUtil;
+import com.example.upsecuritydata.service.Method;
+import com.example.upsecuritydata.service.NbmsEntApplyServcie;
+import com.example.upsecuritydata.util.Constant;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.AllArgsConstructor;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StopWatch;
+
+import java.io.IOException;
+import java.util.Date;
+
+/**
+ * 三、 标识解析企业主体信息上报
+ *
+ * @author laifeng
+ * @since 2022/11/29
+ */
+@Component
+@AllArgsConstructor
+//@EnableScheduling
+public class IdentificationUpTask {
+ private final NbmsEntApplyServcie nbmsEntApplyServcie;
+ private final Method method;
+
+ // @Scheduled(cron = "0/20 * * * * ? ")
+ @XxlJob("upSecurityDataJob")
+ public void refreshAliDeviceStatus() {
+ StopWatch stopWatch = new StopWatch("task");
+ stopWatch.start();
+ // 标识解析企业主体信息上报检测新增并上传
+ threePackMethod(0);
+ // 标识解析企业主体信息上报检测更新并上传
+ threePackMethod(1);
+
+ fourPackMethod(0);
+ fourPackMethod(1);
+
+ fivePackMethod(0);
+ fivePackMethod(1);
+
+ String yesterday = DateUtil.format(DateUtil.yesterday(), "yyyyMMdd");
+ // 注册数据上报
+ try {
+ method.creatSixUpFileAndUp(yesterday);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ // 解析数据上报
+ try {
+ method.creatSevenUpFileAndUp(yesterday);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ // 删除上传生成的文件
+ method.deletUpFile(Constant.localPackage);
+
+ stopWatch.stop();
+ double seconds = stopWatch.getTotalTimeSeconds();
+ XxlJobHelper.log("XXL-JOB, 上传日志成功! 共花费:" + seconds);
+ System.out.println("XXL-JOB, 上传日志成功! 共花费:" + seconds);
+
+ }
+
+ /**
+ * 三、 标识解析企业主体信息上报
+ *
+ * @param type 0 新增 1 更新
+ */
+ private void threePackMethod(Integer type) {
+ // 时间格式化
+ Date date = DateUtil.yesterday();
+ String yyyyMMdd = DateUtil.format(date, "yyyyMMdd");
+ String yyyyMMddToday = DateUtil.format(DateUtil.date(), "yyyyMMdd");
+ Boolean temp = false;
+
+ try {
+ temp = method.creatIdentificationUpFile(type, yyyyMMdd, yyyyMMddToday);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ // 如果没有生成文件,可直接结束
+ if (!temp) {
+ String logName = "";
+ if (type == 0) {
+ logName = "新增";
+ } else if (type == 1) {
+ logName = "更新";
+ } else {
+ logName = "全量";
+ }
+ XxlJobHelper.log("表1:昨日无" + logName + "数据日志!");
+ return;
+ }
+
+
+ String fileName = Constant.localNotEncryFileNamePath;
+ // 要上传的目录
+ String upSrc = "/001/" + yyyyMMdd;
+ // 表名(文件名的一部分)
+ String tableName = Constant.companyName + "-basic_identification-";
+ String operationName = "";
+ if (type == 0) {
+ // 操作类型为新增
+ operationName = "-add.bin";
+ } else if (type == 1) {
+ // 操作类型为更新
+ operationName = "-update.bin";
+ } else {
+ // 操作类型为全量上传
+ operationName = "-update.bin";
+ }
+
+ try {
+ method.upMethod(fileName, upSrc, tableName, operationName);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ /**
+ * 四、 标识解析企业主体信息上报
+ *
+ * @param type 0 新增 1 更新
+ */
+ private void fourPackMethod(Integer type) {
+ // 时间格式化
+ Date date = DateUtil.yesterday();
+ String yyyyMMdd = DateUtil.format(date, "yyyyMMdd");
+ String yyyyMMddToday = DateUtil.format(DateUtil.date(), "yyyyMMdd");
+ Boolean temp = false;
+
+ try {
+ temp = method.creatForUpFile(type, yyyyMMdd, yyyyMMddToday);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ // 如果没有生成文件,可直接结束
+ if (!temp) {
+ String logName = "";
+ if (type == 0) {
+ logName = "新增";
+ } else if (type == 1) {
+ logName = "更新";
+ } else {
+ logName = "全量";
+ }
+ XxlJobHelper.log("表2:昨日无" + logName + "数据日志!");
+ return;
+ }
+
+ String fileName = Constant.localNotEncryFileNamePath;
+ // 要上传的目录
+ String upSrc = "/002/" + yyyyMMdd;
+ // 表名(文件名的一部分)
+ String tableName = Constant.companyName + "-basic_identification_ip-";
+ String operationName = "";
+ if (type == 0) {
+ // 操作类型为新增
+ operationName = "-add.bin";
+ }
+ if (type == 1) {
+ // 操作类型为更新
+ operationName = "-update.bin";
+ } else if (type == 2) {
+ // 操作类型为全量
+ operationName = "-all.bin";
+ }
+ try {
+ method.upMethod(fileName, upSrc, tableName, operationName);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * 五、 标识注册企业主体信息上报
+ *
+ * @param type
+ */
+ private void fivePackMethod(Integer type) {
+ // 时间格式化
+ Date date = DateUtil.yesterday();
+ String yyyyMMdd = DateUtil.format(date, "yyyyMMdd");
+ String yyyyMMddToday = DateUtil.format(DateUtil.date(), "yyyyMMdd");
+ Boolean temp = false;
+
+ try {
+ temp = method.creatFiveUpFile(type, yyyyMMdd, yyyyMMddToday);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ // 如果没有生成文件,可直接结束
+ if (!temp) {
+ String logName = "";
+ if (type == 0) {
+ logName = "新增";
+ } else if (type == 1) {
+ logName = "更新";
+ } else {
+ logName = "全量";
+ }
+ XxlJobHelper.log("表3:昨日无" + logName + "数据日志!");
+ return;
+ }
+
+
+ String fileName = Constant.localNotEncryFileNamePath;
+ // 要上传的目录
+ String upSrc = "/003/" + yyyyMMdd;
+ // 表名(文件名的一部分)
+ String tableName = Constant.companyName + "-basic_registered-";
+ String operationName = "";
+ if (type == 0) {
+ // 操作类型为新增
+ operationName = "-add.bin";
+ } else if (type == 1) {
+ // 操作类型为更新
+ operationName = "-update.bin";
+ } else {
+ // 操作类型为全量
+ operationName = "-all.bin";
+ }
+ try {
+ method.upMethod(fileName, upSrc, tableName, operationName);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/src/main/java/com/example/upsecuritydata/task/TestTask.java b/src/main/java/com/example/upsecuritydata/task/TestTask.java
new file mode 100644
index 0000000..fb6a565
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/task/TestTask.java
@@ -0,0 +1,210 @@
+package com.example.upsecuritydata.task;
+
+import cn.hutool.core.date.DateUtil;
+import com.example.upsecuritydata.service.Method;
+import com.example.upsecuritydata.util.Constant;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.AllArgsConstructor;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StopWatch;
+
+import java.io.IOException;
+import java.util.Date;
+
+/**
+ * @author laifeng
+ * @since 2022/12/1
+ */
+@Component
+@AllArgsConstructor
+@EnableScheduling
+public class TestTask {
+ private final Method method;
+
+
+// @Scheduled(cron = "0 0/1 * * * ?")
+ @XxlJob("upSecurityDataTest")
+ public void refreshAliDeviceStatus() throws Exception {
+ StopWatch stopWatch = new StopWatch("task");
+ stopWatch.start();
+ threePackMethod(2);
+ fourPackMethod(2);
+ fivePackMethod(2);
+
+ stopWatch.stop();
+ double seconds = stopWatch.getTotalTimeSeconds();
+
+ System.out.println("XXL-JOB, 上传日志成功! 共花费:" + seconds);
+
+ }
+
+ /**
+ * 三、 标识解析企业主体信息上报
+ *
+ * @param type 0 新增 1 更新
+ */
+ private void threePackMethod(Integer type) {
+ // 时间格式化
+ Date date = DateUtil.yesterday();
+ String yyyyMMdd = DateUtil.format(date, "yyyyMMdd");
+ String yyyyMMddToday = DateUtil.format(DateUtil.date(), "yyyyMMdd");
+ Boolean temp = false;
+
+ try {
+ temp = method.creatIdentificationUpFile(type, yyyyMMdd, yyyyMMddToday);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ // 如果没有生成文件,可直接结束
+ if (!temp) {
+ String logName = "";
+ if (type == 0) {
+ logName = "新增";
+ } else if (type == 1) {
+ logName = "更新";
+ } else {
+ logName = "全量";
+ }
+ XxlJobHelper.log("表1:昨日无" + logName + "数据日志!");
+ return;
+ }
+
+
+ String fileName = Constant.localNotEncryFileNamePath;
+ // 要上传的目录
+ String upSrc = "/001/" + yyyyMMdd;
+ // 表名(文件名的一部分)
+ String tableName = Constant.companyName + "-basic_identification-";
+ String operationName = "";
+ if (type == 0) {
+ // 操作类型为新增
+ operationName = "-add.bin";
+ } else if (type == 1) {
+ // 操作类型为更新
+ operationName = "-update.bin";
+ } else {
+ // 操作类型为全量上传
+ operationName = "-all.bin";
+ }
+
+ try {
+ method.upMethod(fileName, upSrc, tableName, operationName);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ /**
+ * 四、 标识解析企业主体信息上报
+ *
+ * @param type 0 新增 1 更新
+ */
+ private void fourPackMethod(Integer type) {
+ // 时间格式化
+ Date date = DateUtil.yesterday();
+ String yyyyMMdd = DateUtil.format(date, "yyyyMMdd");
+ String yyyyMMddToday = DateUtil.format(DateUtil.date(), "yyyyMMdd");
+ Boolean temp = false;
+
+ try {
+ temp = method.creatForUpFile(type, yyyyMMdd, yyyyMMddToday);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ // 如果没有生成文件,可直接结束
+ if (!temp) {
+ String logName = "";
+ if (type == 0) {
+ logName = "新增";
+ } else if (type == 1) {
+ logName = "更新";
+ } else {
+ logName = "全量";
+ }
+ XxlJobHelper.log("表2:昨日无" + logName + "数据日志!");
+ return;
+ }
+
+ String fileName = Constant.localNotEncryFileNamePath;
+ // 要上传的目录
+ String upSrc = "/002/" + yyyyMMdd;
+ // 表名(文件名的一部分)
+ String tableName = Constant.companyName + "-basic_identification_ip-";
+ String operationName = "";
+ if (type == 0) {
+ // 操作类型为新增
+ operationName = "-add.bin";
+ }
+ if (type == 1) {
+ // 操作类型为更新
+ operationName = "-update.bin";
+ } else if (type == 2) {
+ // 操作类型为全量
+ operationName = "-all.bin";
+ }
+ try {
+ method.upMethod(fileName, upSrc, tableName, operationName);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * 五、 标识注册企业主体信息上报
+ *
+ * @param type
+ */
+ private void fivePackMethod(Integer type) {
+ // 时间格式化
+ Date date = DateUtil.yesterday();
+ String yyyyMMdd = DateUtil.format(date, "yyyyMMdd");
+ String yyyyMMddToday = DateUtil.format(DateUtil.date(), "yyyyMMdd");
+ Boolean temp = false;
+
+ try {
+ temp = method.creatFiveUpFile(type, yyyyMMdd, yyyyMMddToday);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ // 如果没有生成文件,可直接结束
+ if (!temp) {
+ String logName = "";
+ if (type == 0) {
+ logName = "新增";
+ } else if (type == 1) {
+ logName = "更新";
+ } else {
+ logName = "全量";
+ }
+ XxlJobHelper.log("表3:昨日无" + logName + "数据日志!");
+ return;
+ }
+
+
+ String fileName = Constant.localNotEncryFileNamePath;
+ // 要上传的目录
+ String upSrc = "/003/" + yyyyMMdd;
+ // 表名(文件名的一部分)
+ String tableName = Constant.companyName + "-basic_registered-";
+ String operationName = "";
+ if (type == 0) {
+ // 操作类型为新增
+ operationName = "-add.bin";
+ } else if (type == 1) {
+ // 操作类型为更新
+ operationName = "-update.bin";
+ } else {
+ // 操作类型为全量
+ operationName = "-all.bin";
+ }
+ try {
+ method.upMethod(fileName, upSrc, tableName, operationName);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/src/main/java/com/example/upsecuritydata/task/TestTask1.java b/src/main/java/com/example/upsecuritydata/task/TestTask1.java
new file mode 100644
index 0000000..5a4ad5f
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/task/TestTask1.java
@@ -0,0 +1,28 @@
+package com.example.upsecuritydata.task;
+
+import cn.hutool.core.date.DateUtil;
+import com.example.upsecuritydata.service.Method;
+import com.xxl.job.core.context.XxlJobHelper;
+import lombok.AllArgsConstructor;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author laifeng
+ * @since 2022/12/1
+ */
+@Component
+@EnableScheduling
+@AllArgsConstructor
+public class TestTask1 {
+ private final Method method;
+
+
+ // 做个空任务,让其一直运行
+ @Scheduled(cron = "0 15 10 L * ? ")
+ public void refreshAliDeviceStatus() throws Exception {
+ String format = DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd");
+ System.out.println(format);
+ }
+}
diff --git a/src/main/java/com/example/upsecuritydata/util/Constant.java b/src/main/java/com/example/upsecuritydata/util/Constant.java
new file mode 100644
index 0000000..da0dc23
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/util/Constant.java
@@ -0,0 +1,47 @@
+package com.example.upsecuritydata.util;
+
+/**
+ * @author laifeng
+ * @since 2022/11/27
+ */
+public interface Constant {
+ // 安全态势平台服务器信息
+ String ipAddress = "124.128.7.186";// ip地址
+ String userName = "guanxianguanhong";// 账号
+ String password = "SDguzRp@#GXGH";// 密码
+
+
+ /**
+ * 二级节点解析服务
+ */
+// String host = "192.168.1.3";// ip地址
+// String user = "root";// 账号
+// String password1 = "Gxgxj0919#";// 密码
+ //-----------------外网-----------
+ String host = "36.137.33.121";// ip地址
+ String user = "root";// 账号
+ String password1 = "Gxgxj0919#";// 密码
+
+ // 表6 本地文件生成地址
+ String localNotEncryFileNamePath = "/opt/uplog/test.txt";
+// String localNotEncryFileNamePath = "D:\\aaa\\test.txt";
+
+ // 生成zip文件地址
+ String zipPath = "/opt/uplog/logdata";
+// String zipPath = "D:\\aaa";
+
+ // 生成本地文件地址:目录 加密(服务器地址需要修改)
+ String localPackage = "/opt/uplog/logdata/";
+// String localPackage = "D:\\aaa\\";
+
+ // 远程服务器源日志存放地
+ String sixRemoteLogPackage = "/opt/idhub/logs/idhub-idis/oplog/";
+
+ // 二级节点上传文件前缀
+ String companyName ="GXGH";
+
+ //* 四、 标识解析企业主体信息上报
+ String startIP = "36.137.33.121";
+ String endIP = "36.137.33.121";
+ String position = "山东省济南市历城区春阳路188号中国移动济南IDC数据中心";
+}
diff --git a/src/main/java/com/example/upsecuritydata/util/Decrypt.java b/src/main/java/com/example/upsecuritydata/util/Decrypt.java
new file mode 100644
index 0000000..c2418fc
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/util/Decrypt.java
@@ -0,0 +1,327 @@
+package com.example.upsecuritydata.util;
+
+
+import cn.hutool.core.util.StrUtil;
+import org.apache.commons.codec.binary.Base64;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+public class Decrypt {
+ public static void main(String[] args) throws Exception {
+ File file = new File("D:\\aaa\\GXGH-basic_registered-1682072666671-all.bin");
+ long fileSize = file.length();
+ FileInputStream fi = new FileInputStream(file);
+ byte[] dataArray = new byte[(int) fileSize];
+ int offset = 0;
+ int numRead = 0;
+ while (offset < dataArray.length
+ && (numRead = fi.read(dataArray, offset, dataArray.length - offset)) >= 0) {
+ offset += numRead;
+ }
+ fi.close();
+ // 确保所有数据均被读取
+ if (offset != dataArray.length) {
+ throw new RuntimeException("Could not completely read file "
+ + file.getName());
+ }
+
+ // 解密
+ dataArray = decryptAlgorithm("1", dataArray, "1234567890abcDEF",
+ "1234567890abcDEF");
+ String xmlInfo = unZipCompression("1", dataArray);
+ // xmlInfo为解密后内容
+ System.out.println(xmlInfo);
+ }
+
+ public static List getFiles(File[] files) {
+ List list = new ArrayList();
+ for (File file : files) {
+ if (file.isFile() && file.getName().endsWith(".txt")
+ && !file.getName().endsWith("-0.txt")) {
+
+ list.add(file);
+ } else if (file.isDirectory()) {
+ list.addAll(getFiles(file.listFiles()));
+ }
+ }
+ return list;
+ }
+
+ // 解密
+ public static void decrypt(File file, String aesKey, String aesOffset)
+ throws Exception {
+ BufferedReader br = new BufferedReader(new InputStreamReader(
+ new FileInputStream(file)));
+ StringBuilder sb = new StringBuilder();
+ String line = null;
+ while ((line = br.readLine()) != null) {
+ sb.append(line);
+ }
+ br.close();
+ String dataUpload = sb.toString();
+ byte[] dataArray = getByteByBaseString(dataUpload);
+ dataArray = decryptAlgorithm("1", dataArray, aesKey, aesOffset);
+ String xmlInfo = unZipCompression("1", dataArray);
+ File file1 = new File(file.getAbsolutePath().substring(0,
+ file.getAbsolutePath().lastIndexOf("."))
+ + "-0.txt");
+ FileWriter fw = new FileWriter(file1);
+ fw.write(xmlInfo);
+ fw.close();
+ }
+
+ /**
+ * BASE64解码
+ *
+ * @param str
+ * @return
+ */
+ public static byte[] getByteByBaseString(String str) {
+ byte[] bArray = null;
+ try {
+ bArray = str.getBytes("utf-8");
+ if (Base64.isArrayByteBase64(bArray)) {
+ bArray = Base64.decodeBase64(bArray);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return bArray;
+ }
+
+ /**
+ * 对称解密
+ *
+ * @param encryptType 加密类型
+ * @param basexml 指令文件压缩后的结果
+ * @param aesKey AES加密钥匙
+ * @param aesOffsets AES加密偏移量
+ * @return
+ */
+ public static byte[] decryptAlgorithm(String encryptType, byte[] basexml,
+ String aesKey, String aesOffsets) throws Exception {
+ byte[] command = null;
+
+ if (encryptType != null && encryptType.equals("0")) { // 不加密
+ command = basexml;
+ } else { // AES加密算法
+ command = decrypt(basexml, aesKey, aesOffsets);
+ }
+ return command;
+ }
+
+ /**
+ * 对AES算法加密的数据解密
+ *
+ * @param cipherText 要解密的字节数组
+ * @param aeskey 密钥
+ * @return 解密后的字节数组
+ */
+ public static byte[] decrypt(byte[] cipherText, String aeskey,
+ String aesOffsets) throws Exception {
+ byte[] aesBytes = aeskey.getBytes("utf-8");
+ if (aeskey.length() > 16) {
+ aesBytes = parseHexStr2Byte(aeskey);
+
+ }
+ SecretKeySpec skeySpec = new SecretKeySpec(aesBytes, "AES");
+ Cipher cipher = null;
+ if (aesOffsets != null && !(aesOffsets.trim()).equals("")) {
+ cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+ byte[] bytes = aesOffsets.getBytes("utf-8");
+ if (aesOffsets.length() > 16) {
+ bytes = parseHexStr2Byte(aesOffsets);
+ }
+ IvParameterSpec iv = new IvParameterSpec(bytes);
+ cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
+ } else {
+ cipher = Cipher.getInstance("AES");
+ cipher.init(Cipher.DECRYPT_MODE, skeySpec);
+ }
+ byte[] plainText = null;
+ if (cipher != null) {
+ plainText = cipher.doFinal(cipherText);
+ }
+ return plainText;
+ }
+
+ /**
+ * 将16进制转换为二进制
+ */
+ public static byte[] parseHexStr2Byte(String hexStr) {
+ if (hexStr.length() < 1)
+ return null;
+ byte[] result = new byte[hexStr.length() / 2];
+ for (int i = 0; i < hexStr.length() / 2; i++) {
+ int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16);
+ int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2),
+ 16);
+ result[i] = (byte) (high * 16 + low);
+ }
+ return result;
+ }
+
+ /**
+ * zip解压缩
+ *
+ * @param compressType
+ * @param dataArray
+ * @return
+ * @throws Exception
+ */
+ public static String unZipCompression(String compressType, byte[] dataArray)
+ throws Exception {
+ String xmlData = null;
+ if (compressType != null && compressType.equals("0")) { // 无压缩
+ try {
+ xmlData = new String(dataArray, "utf-8");
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ } else { // zip解压缩
+ xmlData = unzipToString(dataArray);
+ }
+ return xmlData;
+ }
+
+ /**
+ * 根据zip文件的字节数组,解析出zip文件中第一个压缩文件内容的字符串
+ *
+ * @param info
+ * @return
+ */
+ public static String unzipToString(byte[] info) throws Exception {
+ String strInfo = "";
+
+ byte[] bytes = unzip(info);
+ if (bytes != null) {
+ try {
+ strInfo = new String(bytes, "utf-8");
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ }
+
+ return strInfo;
+ }
+
+ /**
+ * 根据zip文件的字节数组,解析出zip文件中第一个压缩文件内容的字节数组
+ *
+ * @param info
+ * @return
+ */
+ public static byte[] unzip(byte[] info) throws Exception {
+ byte[] bytes = null;
+
+ if (info != null) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ ZipInputStream in = new ZipInputStream(new ByteArrayInputStream(
+ info));
+ ZipEntry z = null;
+ if ((z = in.getNextEntry()) != null) {// zip中只有一个文件
+ if (!z.isDirectory()) {
+ int len = -1;
+ byte data[] = new byte[1024];
+ while ((len = in.read(data)) != -1) {
+ baos.write(data, 0, len);
+ }
+ }
+ }
+ baos.flush();
+ bytes = baos.toByteArray();
+ }
+
+ return bytes;
+ }
+
+
+ /**
+ * 读取gz文件
+ *
+ * @param fileName
+ */
+ public static void readFileByLines(String fileName) {
+ GZIPInputStream gzipInputStream;
+ BufferedReader reader = null;
+ try {
+ gzipInputStream = new GZIPInputStream(new FileInputStream(fileName));
+ Reader decoder = new InputStreamReader(gzipInputStream, "UTF-8");
+ reader = new BufferedReader(decoder);
+ String tempString;
+ //一次读一行,读入null时文件结束
+ while ((tempString = reader.readLine()) != null) {
+ //把当前行号显示出来
+ System.out.println(tempString);
+ }
+ reader.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException e1) {
+ }
+ }
+ }
+ }
+
+
+ /**
+ * 获取指定文件夹下所有文件,不含文件夹里的文件
+ *
+ * @param dirFilePath 文件夹路径
+ * @return
+ */
+ public static List getAllFile(String dirFilePath) {
+ if (StrUtil.isBlank(dirFilePath))
+ return null;
+ return getAllFile(new File(dirFilePath));
+ }
+
+
+ /**
+ * 获取指定文件夹下所有文件,不含文件夹里的文件
+ *
+ * @param dirFile 文件夹
+ * @return
+ */
+ public static List getAllFile(File dirFile) {
+ // 如果文件夹不存在或着不是文件夹,则返回 null
+ if (Objects.isNull(dirFile) || !dirFile.exists() || dirFile.isFile())
+ return null;
+
+ File[] childrenFiles = dirFile.listFiles();
+ if (Objects.isNull(childrenFiles) || childrenFiles.length == 0)
+ return null;
+
+ List files = new ArrayList<>();
+ for (File childFile : childrenFiles) {
+ // 如果是文件,直接添加到结果集合
+ if (childFile.isFile()) {
+ files.add(childFile);
+ }
+ //以下几行代码取消注释后可以将所有子文件夹里的文件也获取到列表里
+// else {
+// // 如果是文件夹,则将其内部文件添加进结果集合
+// List cFiles = getAllFile(childFile);
+// if (Objects.isNull(cFiles) || cFiles.isEmpty()) continue;
+// files.addAll(cFiles);
+// }
+ }
+ return files;
+ }
+
+
+}
diff --git a/src/main/java/com/example/upsecuritydata/util/Encrypt.java b/src/main/java/com/example/upsecuritydata/util/Encrypt.java
new file mode 100644
index 0000000..4ad37d7
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/util/Encrypt.java
@@ -0,0 +1,293 @@
+package com.example.upsecuritydata.util;
+
+import org.apache.commons.codec.binary.Base64;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.*;
+import java.util.Date;
+import java.util.Random;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class Encrypt {
+ public static void main(String[] args) throws Exception {
+ String readFile = "C:\\Users\\Reborn\\Desktop\\test.txt";
+
+ File file = new File(readFile);
+ BufferedReader br = new BufferedReader(new InputStreamReader(
+ new FileInputStream(file)));
+ StringBuilder sb = new StringBuilder();
+ String line = null;
+ while ((line = br.readLine()) != null) {
+ sb.append(line).append("\n");
+ }
+ br.close();
+
+ byte[] zip = zipToBytes("D:\\aaa", sb.toString());
+ // dataUpload是压缩加密后的内容
+ byte[] upload = encryptAlgorithm("1", zip, "1234567890abcDEF",
+ "1234567890abcDEF");
+ // 写文件
+ FileOutputStream fos = new FileOutputStream(new File("d:\\aaa\\test.bin"));
+ fos.write(upload);
+ fos.close();
+
+ }
+
+ /**
+ * 将字符数组base64后转字符串
+ *
+ * @param bArray
+ * 字符数组
+ * @return 字符转
+ */
+ public static String getBaseByByte(byte[] bArray) {
+ String str = null;
+ bArray = Base64.encodeBase64(bArray);
+ try {
+ str = new String(bArray, "utf-8");
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ return str;
+ }
+
+ /**
+ * 将字符串压缩成zip文件并获得字节数据
+ *
+ * @param path
+ * @param info
+ * @return
+ */
+ public static byte[] zipToBytes(String path, String info) {
+ String zipFileName = zip(path, info);
+ byte[] zipBytes = getBytes(zipFileName);
+
+ return zipBytes;
+ }
+
+ static AtomicInteger count = new AtomicInteger(0);
+
+ /**
+ * 根据文件内容生成zip文件
+ *
+ * @param path
+ * @param info
+ * @return
+ */
+ public static String zip(String path, String info) {
+ if (count.get() / 10000 == 0) {
+ count.getAndSet(0);
+ }
+ int t = count.getAndIncrement();
+ Long time = new Date().getTime();
+ String commandId = String.valueOf(time & 0xffffffffl);
+ // 添加4位随机数,ID重复问题。
+ commandId = commandId + randomString(4);
+ String filename = commandId + t;
+ String zipFileName = path + "/" + filename + ".zip";
+ if (info != null) {
+
+ if (!checkDir(path)) {
+ createDir(path);
+ }
+
+ File zipFile = new File(zipFileName);
+ ZipOutputStream out = null;
+ try {
+ out = new ZipOutputStream(new FileOutputStream(zipFile));
+ Date date = new Date();
+ out.putNextEntry(new ZipEntry(date.getTime() + filename
+ + ".xml"));
+
+ out.write(info.getBytes("utf-8"));
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ if (out != null) {
+ out.flush();
+ out.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return zipFileName;
+ }
+
+ /**
+ * 对称加密
+ *
+ * @param encryptType
+ * 加密类型
+ * @param zipxml
+ * 指令文件压缩后的结果
+ * @param aesKey
+ * AES加密钥匙
+ * @param aesOffsets
+ * AES加密偏移量
+ * @return
+ */
+ public static byte[] encryptAlgorithm(String encryptType, byte[] zipxml,
+ String aesKey, String aesOffsets) {
+ byte[] command = null;
+
+ if (encryptType != null && encryptType.equals("0")) { // 不加密
+ command = zipxml;
+ } else { // AES加密算法
+ command = aes(zipxml, aesKey, aesOffsets);
+ }
+ return command;
+ }
+
+ /**
+ * 获得指定文件的byte数组
+ */
+ public static byte[] getBytes(String filePath) {
+ byte[] buffer = null;
+ try {
+ File file = new File(filePath);
+ if (file.exists()) {
+ FileInputStream fis = new FileInputStream(file);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
+ byte[] b = new byte[1000];
+ int n;
+ while ((n = fis.read(b)) != -1) {
+ bos.write(b, 0, n);
+ }
+ fis.close();
+ bos.close();
+ buffer = bos.toByteArray();
+ }
+ file.delete();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return buffer;
+ }
+
+ /**
+ * aes加密
+ *
+ * @param plainText
+ * @param aeskey
+ * @param aesOffsets
+ * @return
+ */
+ public static byte[] aes(byte[] plainText, String aeskey, String aesOffsets) {
+ try {
+ byte[] aesBytes = aeskey.getBytes("utf-8");
+ if (aeskey.length() > 16) {
+ aesBytes = parseHexStr2Byte(aeskey);
+ System.out.println(111);
+ }
+ SecretKeySpec skeySpec = new SecretKeySpec(aesBytes, "AES");
+ Cipher cipher = null;
+ if (aesOffsets != null && !(aesOffsets.trim()).equals("")) {
+ cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+ byte[] bytes = aesOffsets.getBytes("utf-8");
+ if (aesOffsets.length() > 16) {
+ bytes = parseHexStr2Byte(aesOffsets);
+ }
+ IvParameterSpec iv = new IvParameterSpec(bytes);
+ cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
+ } else {
+ cipher = Cipher.getInstance("AES");
+ cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
+ }
+
+ byte[] decryptText = null;
+ if (cipher != null) {
+ decryptText = cipher.doFinal(plainText);
+ }
+ return decryptText;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * 将16进制转换为二进制
+ */
+ public static byte[] parseHexStr2Byte(String hexStr) {
+ if (hexStr.length() < 1)
+ return null;
+ byte[] result = new byte[hexStr.length() / 2];
+ for (int i = 0; i < hexStr.length() / 2; i++) {
+ int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16);
+ int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2),
+ 16);
+ result[i] = (byte) (high * 16 + low);
+ }
+ return result;
+ }
+
+ // 生成n个字节的随机字符串
+ public static String randomString(int length) {
+ Random randGen = null;
+ char[] numbersAndLetters = null;
+ if (length < 1) {
+ return null;
+ }
+ if (randGen == null) {
+ randGen = new Random();
+ numbersAndLetters = ("0123456789abcdefghijklmnopqrstuvwxyz"
+ + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ").toCharArray();
+ // numbersAndLetters =
+ // ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ").toCharArray();
+ }
+ char[] randBuffer = new char[length];
+ for (int i = 0; i < randBuffer.length; i++) {
+ randBuffer[i] = numbersAndLetters[randGen.nextInt(71)];
+ // randBuffer[i] = numbersAndLetters[randGen.nextInt(35)];
+ }
+ return new String(randBuffer);
+ }
+
+ /**
+ * 目录是否存在
+ *
+ * @param dirName
+ * @return
+ */
+ public static boolean checkDir(String dirName) {
+ File dir = new File(dirName);
+ if (dir.exists()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * 创建目录
+ *
+ * @param dirName
+ * @return
+ */
+ public static boolean createDir(String dirName) {
+ File dir = new File(dirName);
+
+ if (!dirName.endsWith(File.separator)) {
+ dirName = dirName + File.separator;
+ }
+ // 创建目录
+ if (dir.mkdirs()) {
+ System.out.println("创建目录" + dirName + "成功!");
+ return true;
+ } else {
+ System.out.println("创建目录" + dirName + "失败!");
+ return false;
+ }
+ }
+
+}
diff --git a/src/main/java/com/example/upsecuritydata/util/JschUtil.java b/src/main/java/com/example/upsecuritydata/util/JschUtil.java
new file mode 100644
index 0000000..60112d3
--- /dev/null
+++ b/src/main/java/com/example/upsecuritydata/util/JschUtil.java
@@ -0,0 +1,338 @@
+package com.example.upsecuritydata.util;
+
+import com.jcraft.jsch.*;
+import com.xxl.job.core.context.XxlJobHelper;
+
+import java.io.*;
+import java.util.Properties;
+
+public class JschUtil {
+
+ // sftp通道
+ ChannelSftp chSftp;
+ private JSch jSch;
+ // session对象
+ private Session session;
+ // JAVA与主机的连接通道
+ private Channel channel;
+ // 主机ip
+ private String host;
+
+ // 主机端口号
+ private int port;
+
+ // 主机账号
+ private String username;
+
+ // 主机密码
+ private String password;
+
+ public JschUtil(String host, int port, String username, String password) {
+ this.host = host;
+ this.port = port;
+ this.username = username;
+ this.password = password;
+ }
+
+ public JschUtil() {
+ }
+
+ /**
+ * 检测是否可以和主机通信
+ *
+ * @return
+ */
+ public boolean connect() {
+
+ jSch = new JSch();
+
+ boolean reulst = false;
+
+ try {
+
+ // 根据主机账号、ip、端口获取一个Session对象
+ session = jSch.getSession(username, host, port);
+
+ // 存放主机密码
+ session.setPassword(password);
+
+ // 首次连接,去掉公钥确认
+ Properties config = new Properties();
+ config.put("StrictHostKeyChecking", "no");
+ session.setConfig(config);
+
+ // 超时连接时间为30秒
+ session.setTimeout(300000);
+
+ // 进行连接
+ session.connect();
+
+ // 获取连接结果
+ reulst = session.isConnected();
+
+ if (!reulst) {
+ XxlJobHelper.log("【连接】获取连接失败");
+ }
+
+ } catch (JSchException e) {
+ XxlJobHelper.log(e.getMessage());
+ } finally {
+ close();
+ }
+ return reulst;
+ }
+
+ /**
+ * 关闭连接
+ */
+ public void close() {
+
+ if (channel != null && channel.isConnected()) {
+ channel.disconnect();
+ }
+
+ if (session != null && session.isConnected()) {
+ session.disconnect();
+ }
+
+ if (chSftp != null && chSftp.isConnected()) {
+ chSftp.quit();
+ }
+
+ }
+
+ /**
+ * 执行shell命令
+ *
+ * @param command
+ * @return
+ */
+ public String execCommand(String command) {
+
+ jSch = new JSch();
+
+ // 存放执行命令结果
+ StringBuffer result = new StringBuffer();
+ int exitStatus = 0;
+
+ try {
+
+ // 根据主机账号、ip、端口获取一个Session对象
+ session = jSch.getSession(username, host, port);
+
+ // 存放主机密码
+ session.setPassword(password);
+
+ // 去掉首次连接确认
+ Properties config = new Properties();
+ config.put("StrictHostKeyChecking", "no");
+ session.setConfig(config);
+
+ // 超时连接时间为3秒
+ session.setTimeout(3000);
+
+ // 进行连接
+ session.connect();
+
+ channel = session.openChannel("exec");
+ ((ChannelExec) channel).setCommand(command);
+
+ channel.setInputStream(null);
+ // 错误信息输出流,用于输出错误的信息,当exitstatus<0的时候
+ ((ChannelExec) channel).setErrStream(System.err);
+
+ // 执行命令,等待执行结果
+ channel.connect();
+
+ // 获取命令执行结果
+ InputStream in = channel.getInputStream();
+
+ /**
+ * 通过channel获取信息的方式,采用官方Demo代码
+ */
+ byte[] tmp = new byte[1024];
+ while (true) {
+ while (in.available() > 0) {
+ int i = in.read(tmp, 0, 1024);
+ if (i < 0) {
+ break;
+ }
+ result.append(new String(tmp, 0, i));
+ }
+ // 从channel获取全部信息之后,channel会自动关闭
+ if (channel.isClosed()) {
+ if (in.available() > 0) {
+ continue;
+ }
+ exitStatus = channel.getExitStatus();
+ break;
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (Exception ee) {
+ }
+ }
+
+
+ } catch (IOException e) {
+ XxlJobHelper.log(e.getMessage());
+ } catch (JSchException e) {
+ XxlJobHelper.log(e.getMessage());
+ } finally {
+ close();
+ }
+
+ XxlJobHelper.log("退出码为:" + exitStatus);
+ return result.toString();
+ }
+
+ /**
+ * 文件上传至主机
+ *
+ * @param directory 当前文件路径
+ * @param uploadFile 上传至主机的路径
+ */
+ public void upload(String directory, String uploadFile) {
+ // 创建JSch对象
+ jSch = new JSch();
+
+ try {
+ // 根据主机账号、ip、端口获取一个Session对象
+ session = jSch.getSession(username, host, port);
+ // 存放主机密码
+ session.setPassword(password);
+ // 去掉首次连接确认
+ Properties config = new Properties();
+ config.put("StrictHostKeyChecking", "no");
+ session.setConfig(config);
+ // 超时连接时间为60秒
+ session.setTimeout(60000);
+ // 进行连接
+ session.connect();
+ // 打开SFTP通道
+ chSftp = (ChannelSftp) session.openChannel("sftp");
+ // 建立STFP连接
+ chSftp.connect(60000);
+ // 设置编码格式
+ chSftp.setFilenameEncoding("UTF-8");
+ // 创建一个文件名称问uploadFile的文件
+ File file = new File(uploadFile);
+ chSftp.put(new FileInputStream(file), directory, ChannelSftp.OVERWRITE);
+ XxlJobHelper.log("文件上传成功到:" + file.getName());
+ } catch (JSchException | SftpException | FileNotFoundException e) {
+ XxlJobHelper.log(e.getMessage());
+ } finally {
+ close();
+ }
+ }
+
+ /**
+ * 将主机文件下载至本地
+ *
+ * @param directory 下载到本地的位置
+ * @param downloadFile 下载文件在虚拟机的位置
+ */
+ public void download(String directory, String downloadFile) {
+
+ try {
+ jSch = new JSch();
+
+ // 根据主机账号、ip、端口获取一个Session对象
+ session = jSch.getSession(username, host, port);
+
+ // 存放主机密码
+ session.setPassword(password);
+
+ // 去掉首次连接确认
+ Properties config = new Properties();
+ config.put("StrictHostKeyChecking", "no");
+ session.setConfig(config);
+
+ // 超时连接时间为3秒
+ session.setTimeout(30000);
+
+ // 进行连接
+ session.connect();
+
+ // 打开SFTP通道
+ chSftp = (ChannelSftp) session.openChannel("sftp");
+
+ // 建立SFTP通道的连接
+ chSftp.connect();
+
+ // 设置编码格式
+ chSftp.setFilenameEncoding("UTF-8");
+
+ /**
+ * 说明:
+ * 1、当前上读取文件信息没有任何反馈,如果没有异常则代表成功
+ * 2、如果需要判断是否读取成功的进度,可参考https://blog.csdn.net/coding99/article/details/52416373?locationNum=13&fps=1
+ * 3、将src文件下载到dst路径中
+ */
+ chSftp.get(directory, downloadFile);
+
+ XxlJobHelper.log("文件下载成功");
+ } catch (JSchException | SftpException e) {
+ XxlJobHelper.log(e.getMessage());
+ } finally {
+ close();
+ }
+ }
+
+ /**
+ * 如果此目录不存在将新建目录
+ */
+ public void directory(String path) {
+
+ try {
+ jSch = new JSch();
+
+ // 根据主机账号、ip、端口获取一个Session对象
+ session = jSch.getSession(username, host, port);
+
+ // 存放主机密码
+ session.setPassword(password);
+
+ // 去掉首次连接确认
+ Properties config = new Properties();
+ config.put("StrictHostKeyChecking", "no");
+ session.setConfig(config);
+
+ // 超时连接时间为3秒
+ session.setTimeout(30000);
+
+ // 进行连接
+ session.connect();
+
+ // 打开SFTP通道
+ chSftp = (ChannelSftp) session.openChannel("sftp");
+
+ // 建立SFTP通道的连接
+ chSftp.connect();
+
+ String[] folders = path.split("/");
+ for (String folder : folders) {
+ if (folder.length() > 0) {
+ try {
+ chSftp.cd(folder);
+ } catch (SftpException e) {
+ try {
+ chSftp.mkdir(folder);
+ XxlJobHelper.log("生成目录" + folder);
+ chSftp.cd(folder);
+ } catch (SftpException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ }
+ }
+
+ } catch (JSchException e) {
+ throw new RuntimeException(e);
+ } finally {
+ close();
+ }
+ }
+
+}
+
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
new file mode 100644
index 0000000..e7170ae
--- /dev/null
+++ b/src/main/resources/application.yml
@@ -0,0 +1,34 @@
+server:
+ port: 8080
+spring:
+ datasource:
+ username: idis_user
+ password: Teleinfo-88
+ url: jdbc:mysql://192.168.1.11:3306/snms?characterEncoding=utf8&useSSL=false&serverTimezone=UTC
+# url: jdbc:mysql://172.28.12.102:3306/snms?characterEncoding=utf8&useSSL=false&serverTimezone=UTC
+ driver-class-name: com.mysql.cj.jdbc.Driver
+
+# job执行器配置
+xxl:
+ job:
+ enabled: true
+ executor:
+ appname: xxl-job-executor-sample
+ address:
+ ip:
+ port: 9998
+ logpath: /opt/uplog/xxljob/log
+ logretentiondays: 90
+ accessToken: Teleinfo-88
+ admin:
+# addresses: http://112.6.110.61:8000/xxl-job-admin
+ addresses: http://192.168.1.7:8080/xxl-job-admin
+
+
+logging:
+ config: classpath:logback.xml
+ level:
+ root: info
+
+
+
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
new file mode 100644
index 0000000..d5a0d2c
--- /dev/null
+++ b/src/main/resources/logback.xml
@@ -0,0 +1,29 @@
+
+
+
+ logback
+
+
+
+
+ %d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n
+
+
+
+
+ ${log.path}
+
+ ${log.path}.%d{yyyy-MM-dd}.zip
+
+
+ %date %level [%thread] %logger{36} [%file : %line] %msg%n
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/java/com/example/upsecuritydata/UpSecurityDataApplicationTests.java b/src/test/java/com/example/upsecuritydata/UpSecurityDataApplicationTests.java
new file mode 100644
index 0000000..f875ff2
--- /dev/null
+++ b/src/test/java/com/example/upsecuritydata/UpSecurityDataApplicationTests.java
@@ -0,0 +1,13 @@
+package com.example.upsecuritydata;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class UpSecurityDataApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}