Ver Fonte

1、source code commit

guanz há 3 anos atrás
commit
0c3bf86087
30 ficheiros alterados com 1841 adições e 0 exclusões
  1. 310 0
      mvnw
  2. 182 0
      mvnw.cmd
  3. 161 0
      pom.xml
  4. 17 0
      src/main/java/com/pavis/app/disk/DiskApplication.java
  5. 31 0
      src/main/java/com/pavis/app/disk/common/config/CorsFilterConfig.java
  6. 88 0
      src/main/java/com/pavis/app/disk/common/config/DiskRemindScheduleConfig.java
  7. 21 0
      src/main/java/com/pavis/app/disk/common/config/MybatisPlusConfig.java
  8. 42 0
      src/main/java/com/pavis/app/disk/common/config/Swagger2Config.java
  9. 16 0
      src/main/java/com/pavis/app/disk/common/config/constants/Constants.java
  10. 22 0
      src/main/java/com/pavis/app/disk/common/exception/AlertException.java
  11. 37 0
      src/main/java/com/pavis/app/disk/common/exception/BaseException.java
  12. 106 0
      src/main/java/com/pavis/app/disk/common/http/ErrorCode.java
  13. 155 0
      src/main/java/com/pavis/app/disk/common/http/ResultBody.java
  14. 33 0
      src/main/java/com/pavis/app/disk/common/utils/DateUtils.java
  15. 137 0
      src/main/java/com/pavis/app/disk/common/utils/DiskUtils.java
  16. 24 0
      src/main/java/com/pavis/app/disk/common/utils/IgnoreUtils.java
  17. 47 0
      src/main/java/com/pavis/app/disk/controller/DiskController.java
  18. 14 0
      src/main/java/com/pavis/app/disk/mapper/CronMapper.java
  19. 22 0
      src/main/java/com/pavis/app/disk/model/Cron.java
  20. 14 0
      src/main/java/com/pavis/app/disk/service/DiskService.java
  21. 53 0
      src/main/java/com/pavis/app/disk/service/MailService.java
  22. 40 0
      src/main/java/com/pavis/app/disk/service/impl/DiskServiceImpl.java
  23. 128 0
      src/main/java/com/pavis/app/disk/service/impl/MailServiceImpl.java
  24. 18 0
      src/main/resources/application-dev.yml
  25. 18 0
      src/main/resources/application-prod.yml
  26. 18 0
      src/main/resources/application-test.yml
  27. 19 0
      src/main/resources/application.yml
  28. 22 0
      src/main/resources/error.properties
  29. 33 0
      src/main/resources/templates/notify.html
  30. 13 0
      src/test/java/com/pavis/app/disk/DiskApplicationTests.java

+ 310 - 0
mvnw

@@ -0,0 +1,310 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+#   JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+#   M2_HOME - location of maven2's installed home dir
+#   MAVEN_OPTS - parameters passed to the Java VM when running Maven
+#     e.g. to debug Maven itself, use
+#       set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+#   MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+  if [ -f /etc/mavenrc ] ; then
+    . /etc/mavenrc
+  fi
+
+  if [ -f "$HOME/.mavenrc" ] ; then
+    . "$HOME/.mavenrc"
+  fi
+
+fi
+
+# OS specific support.  $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "`uname`" in
+  CYGWIN*) cygwin=true ;;
+  MINGW*) mingw=true;;
+  Darwin*) darwin=true
+    # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+    # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+    if [ -z "$JAVA_HOME" ]; then
+      if [ -x "/usr/libexec/java_home" ]; then
+        export JAVA_HOME="`/usr/libexec/java_home`"
+      else
+        export JAVA_HOME="/Library/Java/Home"
+      fi
+    fi
+    ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+  if [ -r /etc/gentoo-release ] ; then
+    JAVA_HOME=`java-config --jre-home`
+  fi
+fi
+
+if [ -z "$M2_HOME" ] ; then
+  ## resolve links - $0 may be a link to maven's home
+  PRG="$0"
+
+  # need this for relative symlinks
+  while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+      PRG="$link"
+    else
+      PRG="`dirname "$PRG"`/$link"
+    fi
+  done
+
+  saveddir=`pwd`
+
+  M2_HOME=`dirname "$PRG"`/..
+
+  # make it fully qualified
+  M2_HOME=`cd "$M2_HOME" && pwd`
+
+  cd "$saveddir"
+  # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME=`cygpath --unix "$M2_HOME"`
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+  [ -n "$CLASSPATH" ] &&
+    CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# For Mingw, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME="`(cd "$M2_HOME"; pwd)`"
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+  javaExecutable="`which javac`"
+  if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+    # readlink(1) is not available as standard on Solaris 10.
+    readLink=`which readlink`
+    if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
+      if $darwin ; then
+        javaHome="`dirname \"$javaExecutable\"`"
+        javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+      else
+        javaExecutable="`readlink -f \"$javaExecutable\"`"
+      fi
+      javaHome="`dirname \"$javaExecutable\"`"
+      javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+      JAVA_HOME="$javaHome"
+      export JAVA_HOME
+    fi
+  fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+  if [ -n "$JAVA_HOME"  ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+      # IBM's JDK on AIX uses strange locations for the executables
+      JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+      JAVACMD="$JAVA_HOME/bin/java"
+    fi
+  else
+    JAVACMD="`which java`"
+  fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+  echo "Error: JAVA_HOME is not defined correctly." >&2
+  echo "  We cannot execute $JAVACMD" >&2
+  exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+  echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+
+  if [ -z "$1" ]
+  then
+    echo "Path not specified to find_maven_basedir"
+    return 1
+  fi
+
+  basedir="$1"
+  wdir="$1"
+  while [ "$wdir" != '/' ] ; do
+    if [ -d "$wdir"/.mvn ] ; then
+      basedir=$wdir
+      break
+    fi
+    # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+    if [ -d "${wdir}" ]; then
+      wdir=`cd "$wdir/.."; pwd`
+    fi
+    # end of workaround
+  done
+  echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+  if [ -f "$1" ]; then
+    echo "$(tr -s '\n' ' ' < "$1")"
+  fi
+}
+
+BASE_DIR=`find_maven_basedir "$(pwd)"`
+if [ -z "$BASE_DIR" ]; then
+  exit 1;
+fi
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
+    if [ "$MVNW_VERBOSE" = true ]; then
+      echo "Found .mvn/wrapper/maven-wrapper.jar"
+    fi
+else
+    if [ "$MVNW_VERBOSE" = true ]; then
+      echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
+    fi
+    if [ -n "$MVNW_REPOURL" ]; then
+      jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+    else
+      jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+    fi
+    while IFS="=" read key value; do
+      case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
+      esac
+    done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
+    if [ "$MVNW_VERBOSE" = true ]; then
+      echo "Downloading from: $jarUrl"
+    fi
+    wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
+    if $cygwin; then
+      wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
+    fi
+
+    if command -v wget > /dev/null; then
+        if [ "$MVNW_VERBOSE" = true ]; then
+          echo "Found wget ... using wget"
+        fi
+        if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+            wget "$jarUrl" -O "$wrapperJarPath"
+        else
+            wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
+        fi
+    elif command -v curl > /dev/null; then
+        if [ "$MVNW_VERBOSE" = true ]; then
+          echo "Found curl ... using curl"
+        fi
+        if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+            curl -o "$wrapperJarPath" "$jarUrl" -f
+        else
+            curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
+        fi
+
+    else
+        if [ "$MVNW_VERBOSE" = true ]; then
+          echo "Falling back to using Java to download"
+        fi
+        javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+        # For Cygwin, switch paths to Windows format before running javac
+        if $cygwin; then
+          javaClass=`cygpath --path --windows "$javaClass"`
+        fi
+        if [ -e "$javaClass" ]; then
+            if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+                if [ "$MVNW_VERBOSE" = true ]; then
+                  echo " - Compiling MavenWrapperDownloader.java ..."
+                fi
+                # Compiling the Java class
+                ("$JAVA_HOME/bin/javac" "$javaClass")
+            fi
+            if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+                # Running the downloader
+                if [ "$MVNW_VERBOSE" = true ]; then
+                  echo " - Running MavenWrapperDownloader.java ..."
+                fi
+                ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
+            fi
+        fi
+    fi
+fi
+##########################################################################################
+# End of extension
+##########################################################################################
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+if [ "$MVNW_VERBOSE" = true ]; then
+  echo $MAVEN_PROJECTBASEDIR
+fi
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+  [ -n "$M2_HOME" ] &&
+    M2_HOME=`cygpath --path --windows "$M2_HOME"`
+  [ -n "$JAVA_HOME" ] &&
+    JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+  [ -n "$CLASSPATH" ] &&
+    CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+  [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+    MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
+fi
+
+# Provide a "standardized" way to retrieve the CLI args that will
+# work with both Windows and non-Windows executions.
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
+export MAVEN_CMD_LINE_ARGS
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+exec "$JAVACMD" \
+  $MAVEN_OPTS \
+  -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+  "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+  ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

+ 182 - 0
mvnw.cmd

@@ -0,0 +1,182 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements.  See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership.  The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License.  You may obtain a copy of the License at
+@REM
+@REM    https://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied.  See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Maven Start Up Batch script
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM M2_HOME - location of maven2's installed home dir
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM     e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
+if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+
+FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+    IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+    if "%MVNW_VERBOSE%" == "true" (
+        echo Found %WRAPPER_JAR%
+    )
+) else (
+    if not "%MVNW_REPOURL%" == "" (
+        SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
+    )
+    if "%MVNW_VERBOSE%" == "true" (
+        echo Couldn't find %WRAPPER_JAR%, downloading it ...
+        echo Downloading from: %DOWNLOAD_URL%
+    )
+
+    powershell -Command "&{"^
+		"$webclient = new-object System.Net.WebClient;"^
+		"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
+		"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
+		"}"^
+		"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
+		"}"
+    if "%MVNW_VERBOSE%" == "true" (
+        echo Finished downloading %WRAPPER_JAR%
+    )
+)
+@REM End of extension
+
+@REM Provide a "standardized" way to retrieve the CLI args that will
+@REM work with both Windows and non-Windows executions.
+set MAVEN_CMD_LINE_ARGS=%*
+
+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%" == "on" pause
+
+if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
+
+exit /B %ERROR_CODE%

+ 161 - 0
pom.xml

@@ -0,0 +1,161 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.3.3.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.pavis.app</groupId>
+    <artifactId>disk</artifactId>
+    <version>1.0</version>
+    <name>disk</name>
+    <description>磁盘使用率检测平台</description>
+
+    <properties>
+        <java.version>1.8</java.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jdbc</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-mail</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-thymeleaf</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-quartz</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.junit.vintage</groupId>
+                    <artifactId>junit-vintage-engine</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <!-- 通用包 -->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>2.9.2</version>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>2.9.2</version>
+        </dependency>
+
+        <!-- https://mvnrepository.com/artifact/com.github.xiaoymin/knife4j-spring-ui -->
+        <dependency>
+            <groupId>com.github.xiaoymin</groupId>
+            <artifactId>knife4j-spring-ui</artifactId>
+            <version>2.0.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.github.xiaoymin</groupId>
+            <artifactId>knife4j-spring-boot-starter</artifactId>
+            <!--在引用时请在maven中央仓库搜索最新版本号-->
+            <version>2.0.2</version>
+        </dependency>
+
+
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>27.0.1-jre</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.47</version>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.validation</groupId>
+            <artifactId>validation-api</artifactId>
+            <version>2.0.1.Final</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+            <version>3.2.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>1.14</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-text</artifactId>
+            <version>1.8</version>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-beanutils</groupId>
+            <artifactId>commons-beanutils</artifactId>
+            <version>1.9.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.3.1</version>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 17 - 0
src/main/java/com/pavis/app/disk/DiskApplication.java

@@ -0,0 +1,17 @@
+package com.pavis.app.disk;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableAsync;
+
+@MapperScan("com.pavis.app.disk.mapper")
+@EnableAsync
+@SpringBootApplication
+public class DiskApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(DiskApplication.class, args);
+    }
+
+}

+ 31 - 0
src/main/java/com/pavis/app/disk/common/config/CorsFilterConfig.java

@@ -0,0 +1,31 @@
+package com.pavis.app.disk.common.config;
+
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@Component
+@Order(Ordered.HIGHEST_PRECEDENCE)
+public class CorsFilterConfig implements Filter {
+
+    @Override
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+        HttpServletResponse httpServletResponse = (HttpServletResponse) response;
+        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
+        httpServletResponse.setHeader("Access-Control-Allow-Origin", "*");
+        httpServletResponse.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
+        httpServletResponse.setHeader("Access-Control-Max-Age", "3600");
+        httpServletResponse.setHeader("Access-Control-Allow-Credentials", "true");
+        httpServletResponse.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
+        if ("OPTIONS".equalsIgnoreCase(httpServletRequest.getMethod())) {
+            httpServletResponse.setStatus(HttpServletResponse.SC_OK);
+        } else {
+            chain.doFilter(httpServletRequest, httpServletResponse);
+        }
+    }
+}

+ 88 - 0
src/main/java/com/pavis/app/disk/common/config/DiskRemindScheduleConfig.java

@@ -0,0 +1,88 @@
+package com.pavis.app.disk.common.config;
+
+import com.pavis.app.disk.common.config.constants.Constants;
+import com.pavis.app.disk.common.utils.DateUtils;
+import com.pavis.app.disk.mapper.CronMapper;
+import com.pavis.app.disk.model.Cron;
+import com.pavis.app.disk.service.DiskService;
+import com.pavis.app.disk.service.MailService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.SchedulingConfigurer;
+import org.springframework.scheduling.config.ScheduledTaskRegistrar;
+import org.springframework.scheduling.support.CronTrigger;
+import org.thymeleaf.TemplateEngine;
+import org.thymeleaf.context.Context;
+
+@Configuration
+@EnableScheduling
+@Slf4j
+public class DiskRemindScheduleConfig implements SchedulingConfigurer {
+
+    @Autowired
+    private CronMapper cronMapper;
+
+    @Autowired
+    private DiskService diskService;
+
+    @Autowired
+    private MailService mailService;
+
+    @Autowired
+    private TemplateEngine templateEngine;
+
+    @Value("${spring.profiles.active}")
+    private String activeUrl;
+
+    @Override
+    public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
+        scheduledTaskRegistrar.addTriggerTask(
+                () -> {
+                    // 开启定时任务
+                    String currentFromatDate = DateUtils.getCurrentTime();
+                    log.info("curr time:{}",currentFromatDate);
+                    try {
+                        log.info("<******* 磁盘空间检测定时任务 START *******> :{}" , DateUtils.getCurrentTime());
+                        // String startDate = DateUtils.getCurrenStartDateAppend(currentFromatDate);
+                        // String endDate = DateUtils.getCurrenEndDateAppend(currentFromatDate);
+                        // birthRemindService.ScheduleTaskCount(startDate,endDate);
+                        boolean flag = diskService.checkDiskSpace();
+                        if (flag == true){
+                            // 通知邮件
+                            Context context = new Context();
+                            String url = "";
+                            log.info("activeUrl:{}",activeUrl);
+                            switch (activeUrl){
+                                case "dev":
+                                    url = "本地环境(192.168.1.37)";
+                                    break;
+                                case "test":
+                                    url = "测试环境(180.76.146.227)";
+                                    break;
+                                case "prod":
+                                    url = "生产环境(47.104.109.52)";
+                                    break;
+                                default:
+                            }
+                            log.info("url:{}",url);
+                            context.setVariable("url", url);
+                            String emailTemplate = templateEngine.process("notify", context);
+                            mailService.sendHtmlMail(Constants.ZK_MAIL, "磁盘空间使用量通知", emailTemplate);
+                            mailService.sendHtmlMail(Constants.GHJ_MAIL, "富士通OCR识别-磁盘使用率通知", emailTemplate);
+                        }
+                        log.info("<******* 磁盘空间检测定时任务 END  *******> :{}" , DateUtils.getCurrentTime());
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                },
+                triggerContext -> {
+                    // 设置执行周期 每隔1小时执行一次。
+                    Cron selectedCron = cronMapper.selectById(1255044800520916993L);
+                    String cron = selectedCron.getCron();
+                    return new CronTrigger(cron).nextExecutionTime(triggerContext);
+                });
+    }
+}

+ 21 - 0
src/main/java/com/pavis/app/disk/common/config/MybatisPlusConfig.java

@@ -0,0 +1,21 @@
+package com.pavis.app.disk.common.config;
+
+import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+@Configuration
+@EnableTransactionManagement
+public class MybatisPlusConfig {
+
+    @Bean
+    public PaginationInterceptor paginationInterceptor() {
+        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
+        // 设置请求的页面大于最大页后操作,true调回到首页,false 继续请求  默认false
+        paginationInterceptor.setOverflow(false);
+        // 设置最大单页限制数量,默认 500 条,-1 不受限制
+        paginationInterceptor.setLimit(-1);
+        return paginationInterceptor;
+    }
+}

+ 42 - 0
src/main/java/com/pavis/app/disk/common/config/Swagger2Config.java

@@ -0,0 +1,42 @@
+package com.pavis.app.disk.common.config;
+
+import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Contact;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Configuration
+@EnableSwagger2
+@EnableKnife4j
+@Import(BeanValidatorPluginsConfiguration.class)
+public class Swagger2Config {
+
+    @Bean
+    public Docket createRestApi() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(apiInfo())
+                .select()
+                .apis(RequestHandlerSelectors.basePackage("com.pavis.app.disk.controller"))
+                .paths(PathSelectors.any())
+                .build();
+    }
+
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+                .title("富士通磁盘检测平台")
+                .description("接口文档说明<生产环境>")
+                .contact(new Contact("管慧娟", "", "ghj@s-privacy.com"))
+                .version("1.3")
+                .build();
+    }
+}
+

+ 16 - 0
src/main/java/com/pavis/app/disk/common/config/constants/Constants.java

@@ -0,0 +1,16 @@
+package com.pavis.app.disk.common.config.constants;
+
+public class Constants {
+
+    public static final String DEFAULT_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
+
+    /**
+     * 张坤邮箱
+     */
+    public static final String ZK_MAIL = "zhangk@s-privacy.com";
+
+    /**
+     * 管邮箱。
+     */
+    public static final String GHJ_MAIL = "ghj@s-privacy.com";
+}

+ 22 - 0
src/main/java/com/pavis/app/disk/common/exception/AlertException.java

@@ -0,0 +1,22 @@
+package com.pavis.app.disk.common.exception;
+
+/**
+ * 消息提示异常
+ */
+public class AlertException extends BaseException {
+
+    public AlertException() {
+    }
+
+    public AlertException(String msg) {
+        super(msg);
+    }
+
+    public AlertException(int code, String msg) {
+        super(code, msg);
+    }
+
+    public AlertException(int code, String msg, Throwable cause) {
+        super(code, msg, cause);
+    }
+}

+ 37 - 0
src/main/java/com/pavis/app/disk/common/exception/BaseException.java

@@ -0,0 +1,37 @@
+package com.pavis.app.disk.common.exception;
+
+
+import com.pavis.app.disk.common.http.ErrorCode;
+
+/**
+ * 基础错误异常
+ */
+public class BaseException extends RuntimeException {
+
+    private int code = ErrorCode.ERROR.getCode();
+
+    public BaseException() {
+    }
+
+    public BaseException(String msg) {
+        super(msg);
+    }
+
+    public BaseException(int code, String msg) {
+        super(msg);
+        this.code = code;
+    }
+
+    public BaseException(int code, String msg, Throwable cause) {
+        super(msg, cause);
+        this.code = code;
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+    public void setCode(int code) {
+        this.code = code;
+    }
+}

+ 106 - 0
src/main/java/com/pavis/app/disk/common/http/ErrorCode.java

@@ -0,0 +1,106 @@
+package com.pavis.app.disk.common.http;
+
+/**
+ * 自定义返回码
+ */
+
+public enum ErrorCode {
+
+    /**
+     * 成功
+     */
+    OK(0, "success"),
+    FAIL(1000, "fail"),
+    ALERT(1001, "alert"),
+
+    /**
+     * oauth2返回码
+     */
+    INVALID_TOKEN(2000, "invalid_token"),
+    INVALID_SCOPE(2001, "invalid_scope"),
+    INVALID_REQUEST(2002, "invalid_request"),
+    INVALID_CLIENT(2003, "invalid_client"),
+    INVALID_GRANT(2004, "invalid_grant"),
+    REDIRECT_URI_MISMATCH(2005, "redirect_uri_mismatch"),
+    UNAUTHORIZED_CLIENT(2006, "unauthorized_client"),
+    EXPIRED_TOKEN(2007, "expired_token"),
+    UNSUPPORTED_GRANT_TYPE(2008, "unsupported_grant_type"),
+    UNSUPPORTED_RESPONSE_TYPE(2009, "unsupported_response_type"),
+    UNAUTHORIZED(2012, "unauthorized"),
+    SIGNATURE_DENIED(2013, "signature_denied"),
+
+    ACCESS_DENIED(4030, "access_denied"),
+    ACCESS_DENIED_BLACK_LIMITED(4031, "access_denied_black_limited"),
+    ACCESS_DENIED_WHITE_LIMITED(4032, "access_denied_white_limited"),
+    ACCESS_DENIED_AUTHORITY_EXPIRED(4033, "access_denied_authority_expired"),
+    ACCESS_DENIED_UPDATING(4034, "access_denied_updating"),
+    ACCESS_DENIED_DISABLED(4035, "access_denied_disabled"),
+    ACCESS_DENIED_NOT_OPEN(4036, "access_denied_not_open"),
+
+    /**
+     * 账号错误
+     */
+    BAD_CREDENTIALS(3000, "bad_credentials"),
+    ACCOUNT_DISABLED(3001, "account_disabled"),
+    ACCOUNT_EXPIRED(3002, "account_expired"),
+    CREDENTIALS_EXPIRED(3003, "credentials_expired"),
+    ACCOUNT_LOCKED(3004, "account_locked"),
+    USERNAME_NOT_FOUND(3005, "username_not_found"),
+
+    /**
+     * 请求错误
+     */
+    BAD_REQUEST(4000, "bad_request"),
+    NOT_FOUND(4004, "not_found"),
+    METHOD_NOT_ALLOWED(4005, "method_not_allowed"),
+    MEDIA_TYPE_NOT_ACCEPTABLE(4006, "media_type_not_acceptable"),
+    TOO_MANY_REQUESTS(4029, "too_many_requests"),
+
+    /**
+     * 系统错误
+     */
+    ERROR(5000, "error"),
+    GATEWAY_TIMEOUT(5004, "gateway_timeout"),
+    SERVICE_UNAVAILABLE(5003, "service_unavailable");
+
+
+    private int code;
+    private String message;
+
+    ErrorCode() {
+    }
+
+    private ErrorCode(int code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public static ErrorCode getResultEnum(int code) {
+        for (ErrorCode type : ErrorCode.values()) {
+            if (type.getCode() == code) {
+                return type;
+            }
+        }
+        return ERROR;
+    }
+
+    public static ErrorCode getResultEnum(String message) {
+        for (ErrorCode type : ErrorCode.values()) {
+            if (type.getMessage().equals(message)) {
+                return type;
+            }
+        }
+        return ERROR;
+    }
+
+
+    public int getCode() {
+        return code;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+
+}

+ 155 - 0
src/main/java/com/pavis/app/disk/common/http/ResultBody.java

@@ -0,0 +1,155 @@
+package com.pavis.app.disk.common.http;
+
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.google.common.collect.Maps;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Map;
+import java.util.ResourceBundle;
+
+@ApiModel(value = "响应结果")
+public class ResultBody {
+
+    /**
+     * 响应编码
+     */
+    @ApiModelProperty(value = "响应编码:0-请求处理成功")
+    private int code = 0;
+
+    /**
+     * 提示消息
+     */
+    @ApiModelProperty(value = "提示消息")
+    private String message;
+
+    /**
+     * 请求路径
+     */
+    @ApiModelProperty(value = "请求路径")
+    private String path;
+
+    /**
+     * 响应数据
+     */
+    @ApiModelProperty(value = "响应数据")
+    private Object data;
+
+    /**
+     * http状态码
+     */
+    private int httpStatus;
+
+    /**
+     * 附加数据
+     */
+    @ApiModelProperty(value = "附加数据")
+    private Map<String, Object> extra;
+
+    /**
+     * 响应时间
+     */
+    @ApiModelProperty(value = "响应时间")
+    private long timestamp = System.currentTimeMillis();
+
+    public ResultBody() {
+
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public Object getData() {
+        return data;
+    }
+
+    public Map<String, Object> getExtra() {
+        return extra;
+    }
+
+    public long getTimestamp() {
+        return timestamp;
+    }
+
+    @JSONField(serialize = false, deserialize = false)
+    @JsonIgnore
+    public int getHttpStatus() {
+        return httpStatus;
+    }
+
+    @JSONField(serialize = false, deserialize = false)
+    @JsonIgnore
+    public boolean isOk() {
+        return this.code == ErrorCode.OK.getCode();
+    }
+
+
+    public static ResultBody ok() {
+        return new ResultBody().code(ErrorCode.OK.getCode()).msg(ErrorCode.OK.getMessage());
+    }
+
+    public static ResultBody failed() {
+        return new ResultBody().code(ErrorCode.FAIL.getCode()).msg(ErrorCode.FAIL.getMessage());
+    }
+
+    public ResultBody code(int code) {
+        this.code = code;
+        return this;
+    }
+
+    public ResultBody msg(String message) {
+        this.message = i18n(ErrorCode.getResultEnum(this.code).getMessage(), message);
+        return this;
+    }
+
+    public ResultBody data(Object data) {
+        this.data = data;
+        return this;
+    }
+
+    public ResultBody path(String path) {
+        this.path = path;
+        return this;
+    }
+
+    public ResultBody httpStatus(int httpStatus) {
+        this.httpStatus = httpStatus;
+        return this;
+    }
+
+    public ResultBody put(String key, Object value) {
+        if (this.extra == null) {
+            this.extra = Maps.newHashMap();
+        }
+        this.extra.put(key, value);
+        return this;
+    }
+
+    /**
+     * 错误信息配置
+     */
+    @JSONField(serialize = false, deserialize = false)
+    @JsonIgnore
+    private static ResourceBundle resourceBundle = ResourceBundle.getBundle("error");
+
+    /**
+     * 提示信息国际化
+     */
+    @JSONField(serialize = false, deserialize = false)
+    @JsonIgnore
+    private static String i18n(String message, String defaultMessage) {
+        return resourceBundle.containsKey(message) ? resourceBundle.getString(message) : defaultMessage;
+    }
+
+}

+ 33 - 0
src/main/java/com/pavis/app/disk/common/utils/DateUtils.java

@@ -0,0 +1,33 @@
+package com.pavis.app.disk.common.utils;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+
+public class DateUtils {
+
+
+
+    /**
+     * 获取当前时间并格式化。
+     * @return
+     */
+    public static String getCurrentTime(){
+        LocalDate today = LocalDate.now();
+        LocalTime time = LocalTime.now();
+        LocalDateTime now = LocalDateTime.of(today, time);
+        return now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+    }
+
+    /**
+     * 获取程序执行时间。
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    public static String getExcTime(Long startTime,Long endTime){
+        float excTime=(float)(endTime-startTime);
+        return excTime + "ms";
+    }
+}

+ 137 - 0
src/main/java/com/pavis/app/disk/common/utils/DiskUtils.java

@@ -0,0 +1,137 @@
+package com.pavis.app.disk.common.utils;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.File;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TreeMap;
+
+@Slf4j
+public class DiskUtils {
+
+    /**
+     * 执行系统命令
+     *
+     * @param cmd 命令
+     * @return 字符串结果
+     */
+    public static String runCommand(String cmd) {
+        StringBuilder info = new StringBuilder();
+        try {
+            Process pos = Runtime.getRuntime().exec(cmd);
+            pos.waitFor();
+            InputStreamReader isr = new InputStreamReader(pos.getInputStream());
+            LineNumberReader lnr = new LineNumberReader(isr);
+            String line;
+            while ((line = lnr.readLine()) != null) {
+                info.append(line).append("\n");
+            }
+        } catch (Exception e) {
+            info = new StringBuilder(e.toString());
+        }
+        return info.toString();
+    }
+
+    /**
+     * 判断系统是否为windows
+     *
+     * @return 是否
+     */
+    public static boolean isWindows() {
+        Properties prop = System.getProperties();
+        String os = prop.getProperty("os.name");
+        log.info("os:{}",os);
+        return os.toUpperCase().contains("WINDOWS");
+    }
+
+    public static String sysPath(){
+        File directory = new File(".");//设定为当前文件夹
+        String canPath = "";
+        String absPath = "";
+        try{
+            canPath = directory.getCanonicalPath();//获取标准的路径
+            absPath = directory.getAbsolutePath();//获取绝对路径
+        }catch(Exception e){
+            e.getMessage();
+        }
+        log.info("canPath:{}",canPath);
+        log.info("abdPath:{}",absPath);
+        return canPath;
+    }
+
+    /**
+     * 磁盘使用率
+     *
+     * @return 磁盘使用率
+     */
+    public static double getDiskStoresInfo(String path) {
+        double unit = Math.pow(1024, 3);
+        //系统为windows
+        if(isWindows()) {
+            String dirName = path.substring(0, path.indexOf("\\") + 1);
+            File win = new File(dirName);
+            if (win.exists()) {
+                double freespace = win.getFreeSpace() / unit;
+                freespace = Math.ceil((freespace * 10)) / 10;
+                System.err.println(freespace);
+                long total = win.getTotalSpace();
+                long usableSpace = win.getUsableSpace();
+                double space = (double)(total - usableSpace) / total;
+                System.out.println(space);
+                // if(space > 0.8){
+                //     return space;
+                // }
+                return space;
+
+            }
+        }else {
+            //系统为Unix
+            String ioCmdStr = "df -h /";
+            String resultInfo = runCommand(ioCmdStr);
+            String[] data = resultInfo.split(" +");
+            double total = Double.parseDouble(data[10].replace("%", ""));
+            // if(total / 100 > 0.8){
+            //     return total;
+            // }
+            return total;
+        }
+        return 0;
+    }
+
+    public static double commonDiskSpace(){
+        File win = new File("/");
+        double space = 0.0;
+        if (win.exists()) {
+            long total = win.getTotalSpace();
+            long usableSpace = win.getUsableSpace();
+            space = (double)(total - usableSpace) / total;
+        }
+
+        return space;
+    }
+
+    /**
+     * @return Map<String, String>: key:磁盘盘符, value:磁盘剩余空间
+     */
+    public static Map<String, String> getHdInfo() {
+        Map<String, String> map = new TreeMap<String, String>();
+        File[] roots = File.listRoots();
+        double unit = Math.pow(1024, 3);
+
+        for (int i = 0; i < roots.length; i++) {
+
+            String hd = roots[i].getPath();
+
+            double freespace = roots[i].getFreeSpace() / unit;
+
+            freespace = Math.ceil((freespace * 10)) / 10;
+
+            map.put(hd, String.valueOf(freespace));
+        }
+
+        return map;
+    }
+}

+ 24 - 0
src/main/java/com/pavis/app/disk/common/utils/IgnoreUtils.java

@@ -0,0 +1,24 @@
+package com.pavis.app.disk.common.utils;
+
+import org.springframework.beans.BeanWrapper;
+import org.springframework.beans.BeanWrapperImpl;
+
+import java.beans.PropertyDescriptor;
+import java.util.HashSet;
+import java.util.Set;
+
+public class IgnoreUtils {
+    public static String[] getNullPropertyNames(Object source) {
+        BeanWrapper src = new BeanWrapperImpl(source);
+        PropertyDescriptor[] pds = src.getPropertyDescriptors();
+        Set<String> emptyNames = new HashSet<>();
+        for (PropertyDescriptor pd : pds) {
+            Object srcValue = src.getPropertyValue(pd.getName());
+            if (srcValue == null){
+                emptyNames.add(pd.getName());
+            }
+        }
+        return emptyNames.toArray(new String[emptyNames.size()]);
+    }
+
+}

+ 47 - 0
src/main/java/com/pavis/app/disk/controller/DiskController.java

@@ -0,0 +1,47 @@
+package com.pavis.app.disk.controller;
+
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.github.xiaoymin.knife4j.annotations.ApiSort;
+import com.pavis.app.disk.common.config.constants.Constants;
+import com.pavis.app.disk.common.http.ResultBody;
+import com.pavis.app.disk.service.MailService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.thymeleaf.TemplateEngine;
+import org.thymeleaf.context.Context;
+
+import javax.mail.MessagingException;
+
+@Slf4j
+@RestController
+@Api(tags = "pavis磁盘检测接口")
+@ApiSort(1)
+@RequestMapping("/api")
+public class DiskController {
+
+
+    @Autowired
+    private MailService mailService;
+
+    @Autowired
+    private TemplateEngine templateEngine;
+
+
+    @ApiOperation("历史版本获取接口")
+    @ApiOperationSupport(order = 1)
+    @GetMapping("/disk")
+    public ResultBody version() throws MessagingException {
+        Context context = new Context();
+        String url = "test disk";
+        context.setVariable("url", url);
+        String emailTemplate = templateEngine.process("notify", context);
+        // mailService.sendHtmlMail(Constants.ZK_MAIL, "磁盘空间使用量通知", emailTemplate);
+        mailService.sendHtmlMail(Constants.GHJ_MAIL, "获取历史版本通知", emailTemplate);
+        return ResultBody.ok().data(url);
+    }
+}

+ 14 - 0
src/main/java/com/pavis/app/disk/mapper/CronMapper.java

@@ -0,0 +1,14 @@
+package com.pavis.app.disk.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.pavis.app.disk.model.Cron;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author guanhuijuan
+ * @create 2020-09-16 9:15
+ * @desc CronMapper
+ **/
+@Component
+public interface CronMapper extends BaseMapper<Cron> {
+}

+ 22 - 0
src/main/java/com/pavis/app/disk/model/Cron.java

@@ -0,0 +1,22 @@
+package com.pavis.app.disk.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+/**
+ * 定时
+ */
+@Getter
+@Setter
+@NoArgsConstructor
+@AllArgsConstructor
+public class Cron {
+    @TableId(type = IdType.ID_WORKER_STR)
+    private String id;
+    private String cron;
+    private String description;
+}

+ 14 - 0
src/main/java/com/pavis/app/disk/service/DiskService.java

@@ -0,0 +1,14 @@
+package com.pavis.app.disk.service;
+
+/**
+ * @author guanhuijuan
+ * @create 2020-07-08 19:26
+ * @desc OtherService
+ **/
+public interface DiskService {
+    /**
+     * 磁盘空间检测。
+     * @return
+     */
+    boolean checkDiskSpace();
+}

+ 53 - 0
src/main/java/com/pavis/app/disk/service/MailService.java

@@ -0,0 +1,53 @@
+package com.pavis.app.disk.service;
+
+import javax.mail.MessagingException;
+
+
+public interface MailService {
+    /**
+     * 发送文本邮件
+     *
+     * @param to      收件人地址
+     * @param subject 邮件主题
+     * @param content 邮件内容
+     * @param cc      抄送地址
+     */
+    void sendSimpleMail(String to, String subject, String content, String... cc);
+
+    /**
+     * 发送HTML邮件
+     *
+     * @param to      收件人地址
+     * @param subject 邮件主题
+     * @param content 邮件内容
+     * @param cc      抄送地址
+     * @throws MessagingException 邮件发送异常
+     */
+    void sendHtmlMail(String to, String subject, String content, String... cc) throws MessagingException;
+
+    /**
+     * 发送带附件的邮件
+     *
+     * @param to       收件人地址
+     * @param subject  邮件主题
+     * @param content  邮件内容
+     * @param filePath 附件地址
+     * @param cc       抄送地址
+     * @throws MessagingException 邮件发送异常
+     */
+    void sendAttachmentsMail(String to, String subject, String content, String filePath, String... cc) throws MessagingException;
+
+    /**
+     * 发送正文中有静态资源的邮件
+     *
+     * @param to      收件人地址
+     * @param subject 邮件主题
+     * @param content 邮件内容
+     * @param rscPath 静态资源地址
+     * @param rscId   静态资源id
+     * @param cc      抄送地址
+     * @throws MessagingException 邮件发送异常
+     */
+    void sendResourceMail(String to, String subject, String content, String rscPath, String rscId, String... cc) throws MessagingException;
+
+} 

+ 40 - 0
src/main/java/com/pavis/app/disk/service/impl/DiskServiceImpl.java

@@ -0,0 +1,40 @@
+package com.pavis.app.disk.service.impl;
+
+import com.pavis.app.disk.service.DiskService;
+import com.pavis.app.disk.common.utils.DiskUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @author guanhuijuan
+ * @create 2020-07-08 19:27
+ * @desc OtherServiceImpl
+ **/
+
+@Slf4j
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class DiskServiceImpl implements DiskService {
+
+    @Override
+    public boolean checkDiskSpace() {
+        boolean os = DiskUtils.isWindows();
+        String path = DiskUtils.sysPath();
+        if(os == true){
+            // win系统
+            double space = DiskUtils.getDiskStoresInfo(path);
+            if (space > 0.8){
+                return true;
+            }
+
+        }else {
+            // linux系统
+            double space = DiskUtils.getDiskStoresInfo(path);
+            if (space > 80){
+                return true;
+            }
+        }
+        return false;
+    }
+}

+ 128 - 0
src/main/java/com/pavis/app/disk/service/impl/MailServiceImpl.java

@@ -0,0 +1,128 @@
+package com.pavis.app.disk.service.impl;
+
+import cn.hutool.core.util.ArrayUtil;
+import com.pavis.app.disk.service.MailService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.mail.SimpleMailMessage;
+import org.springframework.mail.javamail.JavaMailSender;
+import org.springframework.mail.javamail.MimeMessageHelper;
+import org.springframework.stereotype.Service;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+import java.io.File;
+
+
+@Service
+public class MailServiceImpl implements MailService {
+
+    @Autowired
+    private JavaMailSender mailSender;
+
+    @Value("${spring.mail.username}")
+    private String from;
+
+    /**
+     * 发送文本邮件
+     *
+     * @param to      收件人地址
+     * @param subject 邮件主题
+     * @param content 邮件内容
+     * @param cc      抄送地址
+     */
+    @Override
+    public void sendSimpleMail(String to, String subject, String content, String... cc) {
+        SimpleMailMessage message = new SimpleMailMessage();
+        message.setFrom(from);
+        message.setTo(to);
+        message.setSubject(subject);
+        message.setText(content);
+        if (ArrayUtil.isNotEmpty(cc)) {
+            message.setCc(cc);
+        }
+        mailSender.send(message);
+    }
+
+    /**
+     * 发送HTML邮件
+     *
+     * @param to      收件人地址
+     * @param subject 邮件主题
+     * @param content 邮件内容
+     * @param cc      抄送地址
+     * @throws MessagingException 邮件发送异常
+     */
+    @Override
+    public void sendHtmlMail(String to, String subject, String content, String... cc) throws MessagingException {
+        MimeMessage message = mailSender.createMimeMessage();
+        MimeMessageHelper helper = new MimeMessageHelper(message, true);
+        helper.setFrom(from);
+        helper.setTo(to);
+        helper.setSubject(subject);
+        helper.setText(content, true);
+        if (ArrayUtil.isNotEmpty(cc)) {
+            helper.setCc(cc);
+        }
+        mailSender.send(message);
+    }
+
+    /**
+     * 发送带附件的邮件
+     *
+     * @param to       收件人地址
+     * @param subject  邮件主题
+     * @param content  邮件内容
+     * @param filePath 附件地址
+     * @param cc       抄送地址
+     * @throws MessagingException 邮件发送异常
+     */
+    @Override
+    public void sendAttachmentsMail(String to, String subject, String content, String filePath, String... cc) throws MessagingException {
+        MimeMessage message = mailSender.createMimeMessage();
+
+        MimeMessageHelper helper = new MimeMessageHelper(message, true);
+        helper.setFrom(from);
+        helper.setTo(to);
+        helper.setSubject(subject);
+        helper.setText(content, true);
+        if (ArrayUtil.isNotEmpty(cc)) {
+            helper.setCc(cc);
+        }
+        FileSystemResource file = new FileSystemResource(new File(filePath));
+        String fileName = filePath.substring(filePath.lastIndexOf(File.separator));
+        helper.addAttachment(fileName, file);
+
+        mailSender.send(message);
+    }
+
+    /**
+     * 发送正文中有静态资源的邮件
+     *
+     * @param to      收件人地址
+     * @param subject 邮件主题
+     * @param content 邮件内容
+     * @param rscPath 静态资源地址
+     * @param rscId   静态资源id
+     * @param cc      抄送地址
+     * @throws MessagingException 邮件发送异常
+     */
+    @Override
+    public void sendResourceMail(String to, String subject, String content, String rscPath, String rscId, String... cc) throws MessagingException {
+        MimeMessage message = mailSender.createMimeMessage();
+
+        MimeMessageHelper helper = new MimeMessageHelper(message, true);
+        helper.setFrom(from);
+        helper.setTo(to);
+        helper.setSubject(subject);
+        helper.setText(content, true);
+        if (ArrayUtil.isNotEmpty(cc)) {
+            helper.setCc(cc);
+        }
+        FileSystemResource res = new FileSystemResource(new File(rscPath));
+        helper.addInline(rscId, res);
+
+        mailSender.send(message);
+    }
+}

+ 18 - 0
src/main/resources/application-dev.yml

@@ -0,0 +1,18 @@
+spring:
+  datasource:
+    url: jdbc:mysql://192.168.1.37:20086/fjs_disk?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    username: root
+    password: Semi.1001
+  mail:
+    host: smtp.163.com
+    username: guanhuijuan_ghj@163.com
+    password: SFSKSCHIUIXSGAOA
+    default-encoding: utf-8
+    protocol: smtps
+    port: 465
+logging:
+  level:
+    org.springframework.cloud: debug
+    org.springframework.boot: debug
+    com.pavis.app.disk.mapper: debug

+ 18 - 0
src/main/resources/application-prod.yml

@@ -0,0 +1,18 @@
+spring:
+  datasource:
+    url: jdbc:mysql://47.104.109.52:20086/fjs_disk?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    username: root
+    password: Semi.1001
+  mail:
+    host: smtp.163.com
+    username: guanhuijuan_ghj@163.com
+    password: SFSKSCHIUIXSGAOA
+    default-encoding: utf-8
+    protocol: smtps
+    port: 465
+logging:
+  level:
+    org.springframework.cloud: info
+    org.springframework.boot: info
+    com.pavis.app.disk.mapper: trace

+ 18 - 0
src/main/resources/application-test.yml

@@ -0,0 +1,18 @@
+spring:
+  datasource:
+    url: jdbc:mysql://180.76.146.227:10086/fjs_disk?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    username: root
+    password: root
+  mail:
+    host: smtp.163.com
+    username: guanhuijuan_ghj@163.com
+    password: SFSKSCHIUIXSGAOA
+    default-encoding: utf-8
+    protocol: smtps
+    port: 465
+logging:
+  level:
+    org.springframework.cloud: debug
+    org.springframework.boot: debug
+    com.pavis.app.disk.mapper: trace

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

@@ -0,0 +1,19 @@
+server:
+#  测试环境
+  port: 10087
+#  生产环境
+#  port: 18000
+spring:
+  application:
+    name: fujisu-disk-server
+  profiles:
+    active: dev
+#    active: test
+#    active: prod
+  servlet:
+    multipart:
+      max-file-size: 50MB
+      max-request-size: 50MB
+mybatis-plus:
+  mapper-locations: classpath*:/mapper/*Mapper.xml
+  typeAliasesPackage: com.pavis.app.disk.model

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

@@ -0,0 +1,22 @@
+credentials_expired=\u51ED\u8BC1\u5DF2\u8FC7\u671F!
+bad_request=\u65E0\u6548\u7684\u8BF7\u6C42!
+not_found=\u65E0\u6548\u7684\u8BBF\u95EE\u5730\u5740\uFF01
+service_unavailable=\u670D\u52A1\u6682\u65F6\u65E0\u6CD5\u8BBF\u95EE\uFF01
+method_not_allowed=\u8BF7\u6C42\u65B9\u5F0F\u4E0D\u652F\u6301!
+media_type_not_acceptable=\u5A92\u4F53\u7C7B\u578B\u4E0D\u652F\u6301!
+username_not_found=\u8D26\u53F7\u4E0D\u5B58\u5728!
+bad_credentials=\u8D26\u53F7\u6216\u5BC6\u7801\u9519\u8BEF!
+account_disabled=\u8D26\u53F7\u5DF2\u88AB\u7981\u7528!
+account_expired=\u8D26\u53F7\u5DF2\u8FC7\u671F!
+account_locked=\u8D26\u53F7\u5DF2\u88AB\u9501\u5B9A!
+error=\u670D\u52A1\u5668\u7E41\u5FD9,\u8BF7\u7A0D\u540E\u518D\u8BD5!
+unauthorized=\u8BA4\u8BC1\u5931\u8D25,\u8BF7\u91CD\u65B0\u767B\u5F55!
+too_many_requests=\u8BBF\u95EE\u592A\u8FC7\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5!
+access_denied=\u6743\u9650\u4E0D\u8DB3,\u62D2\u7EDD\u8BBF\u95EE!
+access_denied_black_limited=IP\u6216\u57DF\u540D\u62D2\u7EDD\u8BBF\u95EE!
+access_denied_white_limited=IP\u6216\u57DF\u540D\u4E0D\u5728\u767D\u540D\u5355\u5185,\u62D2\u7EDD\u8BBF\u95EE!
+access_denied_authority_expired=\u6388\u6743\u5DF2\u8FC7\u671F,\u62D2\u7EDD\u8BBF\u95EE!
+access_denied_updating=\u6B63\u5728\u5347\u7EA7\u7EF4\u62A4\u4E2D,\u8BF7\u7A0D\u540E\u518D\u8BD5!
+access_denied_disabled=\u8BF7\u6C42\u5730\u5740,\u7981\u6B62\u8BBF\u95EE!
+access_denied_not_open=\u8BF7\u6C42\u5730\u5740,\u62D2\u7EDD\u8BBF\u95EE!
+invalid_token=\u65E0\u6548\u7684\u8BBF\u95EE\u4EE4\u724C!

+ 33 - 0
src/main/resources/templates/notify.html

@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8">
+    <title>富士通OCR识别-磁盘使用率通知</title>
+    <style>
+        body {
+            width:80%;
+            margin:100px auto;
+        }
+
+        #welcome {
+            text-align: center;
+        }
+    </style>
+</head>
+<body>
+<div id="notify">
+    <div style="text-align: left;margin-left: 32px">
+        <strong>您好:</strong>
+    </div>
+    <div style="padding: 10px;margin:0 0 0 22px;">
+        <a style="text-decoration: none;" href="#" th:href="@{${url}}" target="_bank">
+            <strong style="color: red">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前系统的磁盘使用量已达80%,请尽快登录系统做好磁盘备份与删除。</strong>
+        </a>
+    </div>
+    <div style="margin-left:32px;padding: 4px">
+        这是一封来自富士通平台<strong style="color: blue" th:text="${url}"></strong>的紧急通知邮件...
+    </div>
+    <hr style=" width:100%;margin:15px 0 15px 20px; color:#987cb9;" size=1>
+</div>
+</body>
+</html>

+ 13 - 0
src/test/java/com/pavis/app/disk/DiskApplicationTests.java

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