Kaynağa Gözat

公共模块

tags/正式3.2.0
雍文秀 2 yıl önce
ebeveyn
işleme
2a8014867c

+ 33
- 0
scommons/.gitignore Dosyayı Görüntüle

@@ -0,0 +1,33 @@
1
+HELP.md
2
+target/
3
+!.mvn/wrapper/maven-wrapper.jar
4
+!**/src/main/**/target/
5
+!**/src/test/**/target/
6
+
7
+### STS ###
8
+.apt_generated
9
+.classpath
10
+.factorypath
11
+.project
12
+.settings
13
+.springBeans
14
+.sts4-cache
15
+
16
+### IntelliJ IDEA ###
17
+.idea
18
+*.iws
19
+*.iml
20
+*.ipr
21
+
22
+### NetBeans ###
23
+/nbproject/private/
24
+/nbbuild/
25
+/dist/
26
+/nbdist/
27
+/.nb-gradle/
28
+build/
29
+!**/src/main/**/build/
30
+!**/src/test/**/build/
31
+
32
+### VS Code ###
33
+.vscode/

BIN
scommons/.mvn/wrapper/maven-wrapper.jar Dosyayı Görüntüle


+ 2
- 0
scommons/.mvn/wrapper/maven-wrapper.properties Dosyayı Görüntüle

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

+ 316
- 0
scommons/mvnw Dosyayı Görüntüle

@@ -0,0 +1,316 @@
1
+#!/bin/sh
2
+# ----------------------------------------------------------------------------
3
+# Licensed to the Apache Software Foundation (ASF) under one
4
+# or more contributor license agreements.  See the NOTICE file
5
+# distributed with this work for additional information
6
+# regarding copyright ownership.  The ASF licenses this file
7
+# to you under the Apache License, Version 2.0 (the
8
+# "License"); you may not use this file except in compliance
9
+# with the License.  You may obtain a copy of the License at
10
+#
11
+#    https://www.apache.org/licenses/LICENSE-2.0
12
+#
13
+# Unless required by applicable law or agreed to in writing,
14
+# software distributed under the License is distributed on an
15
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+# KIND, either express or implied.  See the License for the
17
+# specific language governing permissions and limitations
18
+# under the License.
19
+# ----------------------------------------------------------------------------
20
+
21
+# ----------------------------------------------------------------------------
22
+# Maven Start Up Batch script
23
+#
24
+# Required ENV vars:
25
+# ------------------
26
+#   JAVA_HOME - location of a JDK home dir
27
+#
28
+# Optional ENV vars
29
+# -----------------
30
+#   M2_HOME - location of maven2's installed home dir
31
+#   MAVEN_OPTS - parameters passed to the Java VM when running Maven
32
+#     e.g. to debug Maven itself, use
33
+#       set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34
+#   MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35
+# ----------------------------------------------------------------------------
36
+
37
+if [ -z "$MAVEN_SKIP_RC" ] ; then
38
+
39
+  if [ -f /usr/local/etc/mavenrc ] ; then
40
+    . /usr/local/etc/mavenrc
41
+  fi
42
+
43
+  if [ -f /etc/mavenrc ] ; then
44
+    . /etc/mavenrc
45
+  fi
46
+
47
+  if [ -f "$HOME/.mavenrc" ] ; then
48
+    . "$HOME/.mavenrc"
49
+  fi
50
+
51
+fi
52
+
53
+# OS specific support.  $var _must_ be set to either true or false.
54
+cygwin=false;
55
+darwin=false;
56
+mingw=false
57
+case "`uname`" in
58
+  CYGWIN*) cygwin=true ;;
59
+  MINGW*) mingw=true;;
60
+  Darwin*) darwin=true
61
+    # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
62
+    # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
63
+    if [ -z "$JAVA_HOME" ]; then
64
+      if [ -x "/usr/libexec/java_home" ]; then
65
+        export JAVA_HOME="`/usr/libexec/java_home`"
66
+      else
67
+        export JAVA_HOME="/Library/Java/Home"
68
+      fi
69
+    fi
70
+    ;;
71
+esac
72
+
73
+if [ -z "$JAVA_HOME" ] ; then
74
+  if [ -r /etc/gentoo-release ] ; then
75
+    JAVA_HOME=`java-config --jre-home`
76
+  fi
77
+fi
78
+
79
+if [ -z "$M2_HOME" ] ; then
80
+  ## resolve links - $0 may be a link to maven's home
81
+  PRG="$0"
82
+
83
+  # need this for relative symlinks
84
+  while [ -h "$PRG" ] ; do
85
+    ls=`ls -ld "$PRG"`
86
+    link=`expr "$ls" : '.*-> \(.*\)$'`
87
+    if expr "$link" : '/.*' > /dev/null; then
88
+      PRG="$link"
89
+    else
90
+      PRG="`dirname "$PRG"`/$link"
91
+    fi
92
+  done
93
+
94
+  saveddir=`pwd`
95
+
96
+  M2_HOME=`dirname "$PRG"`/..
97
+
98
+  # make it fully qualified
99
+  M2_HOME=`cd "$M2_HOME" && pwd`
100
+
101
+  cd "$saveddir"
102
+  # echo Using m2 at $M2_HOME
103
+fi
104
+
105
+# For Cygwin, ensure paths are in UNIX format before anything is touched
106
+if $cygwin ; then
107
+  [ -n "$M2_HOME" ] &&
108
+    M2_HOME=`cygpath --unix "$M2_HOME"`
109
+  [ -n "$JAVA_HOME" ] &&
110
+    JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
111
+  [ -n "$CLASSPATH" ] &&
112
+    CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
113
+fi
114
+
115
+# For Mingw, ensure paths are in UNIX format before anything is touched
116
+if $mingw ; then
117
+  [ -n "$M2_HOME" ] &&
118
+    M2_HOME="`(cd "$M2_HOME"; pwd)`"
119
+  [ -n "$JAVA_HOME" ] &&
120
+    JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
121
+fi
122
+
123
+if [ -z "$JAVA_HOME" ]; then
124
+  javaExecutable="`which javac`"
125
+  if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
126
+    # readlink(1) is not available as standard on Solaris 10.
127
+    readLink=`which readlink`
128
+    if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
129
+      if $darwin ; then
130
+        javaHome="`dirname \"$javaExecutable\"`"
131
+        javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
132
+      else
133
+        javaExecutable="`readlink -f \"$javaExecutable\"`"
134
+      fi
135
+      javaHome="`dirname \"$javaExecutable\"`"
136
+      javaHome=`expr "$javaHome" : '\(.*\)/bin'`
137
+      JAVA_HOME="$javaHome"
138
+      export JAVA_HOME
139
+    fi
140
+  fi
141
+fi
142
+
143
+if [ -z "$JAVACMD" ] ; then
144
+  if [ -n "$JAVA_HOME"  ] ; then
145
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
146
+      # IBM's JDK on AIX uses strange locations for the executables
147
+      JAVACMD="$JAVA_HOME/jre/sh/java"
148
+    else
149
+      JAVACMD="$JAVA_HOME/bin/java"
150
+    fi
151
+  else
152
+    JAVACMD="`\\unset -f command; \\command -v java`"
153
+  fi
154
+fi
155
+
156
+if [ ! -x "$JAVACMD" ] ; then
157
+  echo "Error: JAVA_HOME is not defined correctly." >&2
158
+  echo "  We cannot execute $JAVACMD" >&2
159
+  exit 1
160
+fi
161
+
162
+if [ -z "$JAVA_HOME" ] ; then
163
+  echo "Warning: JAVA_HOME environment variable is not set."
164
+fi
165
+
166
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
167
+
168
+# traverses directory structure from process work directory to filesystem root
169
+# first directory with .mvn subdirectory is considered project base directory
170
+find_maven_basedir() {
171
+
172
+  if [ -z "$1" ]
173
+  then
174
+    echo "Path not specified to find_maven_basedir"
175
+    return 1
176
+  fi
177
+
178
+  basedir="$1"
179
+  wdir="$1"
180
+  while [ "$wdir" != '/' ] ; do
181
+    if [ -d "$wdir"/.mvn ] ; then
182
+      basedir=$wdir
183
+      break
184
+    fi
185
+    # workaround for JBEAP-8937 (on Solaris 10/Sparc)
186
+    if [ -d "${wdir}" ]; then
187
+      wdir=`cd "$wdir/.."; pwd`
188
+    fi
189
+    # end of workaround
190
+  done
191
+  echo "${basedir}"
192
+}
193
+
194
+# concatenates all lines of a file
195
+concat_lines() {
196
+  if [ -f "$1" ]; then
197
+    echo "$(tr -s '\n' ' ' < "$1")"
198
+  fi
199
+}
200
+
201
+BASE_DIR=`find_maven_basedir "$(pwd)"`
202
+if [ -z "$BASE_DIR" ]; then
203
+  exit 1;
204
+fi
205
+
206
+##########################################################################################
207
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
208
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
209
+##########################################################################################
210
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
211
+    if [ "$MVNW_VERBOSE" = true ]; then
212
+      echo "Found .mvn/wrapper/maven-wrapper.jar"
213
+    fi
214
+else
215
+    if [ "$MVNW_VERBOSE" = true ]; then
216
+      echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
217
+    fi
218
+    if [ -n "$MVNW_REPOURL" ]; then
219
+      jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
220
+    else
221
+      jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
222
+    fi
223
+    while IFS="=" read key value; do
224
+      case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
225
+      esac
226
+    done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
227
+    if [ "$MVNW_VERBOSE" = true ]; then
228
+      echo "Downloading from: $jarUrl"
229
+    fi
230
+    wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
231
+    if $cygwin; then
232
+      wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
233
+    fi
234
+
235
+    if command -v wget > /dev/null; then
236
+        if [ "$MVNW_VERBOSE" = true ]; then
237
+          echo "Found wget ... using wget"
238
+        fi
239
+        if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
240
+            wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
241
+        else
242
+            wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
243
+        fi
244
+    elif command -v curl > /dev/null; then
245
+        if [ "$MVNW_VERBOSE" = true ]; then
246
+          echo "Found curl ... using curl"
247
+        fi
248
+        if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
249
+            curl -o "$wrapperJarPath" "$jarUrl" -f
250
+        else
251
+            curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
252
+        fi
253
+
254
+    else
255
+        if [ "$MVNW_VERBOSE" = true ]; then
256
+          echo "Falling back to using Java to download"
257
+        fi
258
+        javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
259
+        # For Cygwin, switch paths to Windows format before running javac
260
+        if $cygwin; then
261
+          javaClass=`cygpath --path --windows "$javaClass"`
262
+        fi
263
+        if [ -e "$javaClass" ]; then
264
+            if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
265
+                if [ "$MVNW_VERBOSE" = true ]; then
266
+                  echo " - Compiling MavenWrapperDownloader.java ..."
267
+                fi
268
+                # Compiling the Java class
269
+                ("$JAVA_HOME/bin/javac" "$javaClass")
270
+            fi
271
+            if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
272
+                # Running the downloader
273
+                if [ "$MVNW_VERBOSE" = true ]; then
274
+                  echo " - Running MavenWrapperDownloader.java ..."
275
+                fi
276
+                ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
277
+            fi
278
+        fi
279
+    fi
280
+fi
281
+##########################################################################################
282
+# End of extension
283
+##########################################################################################
284
+
285
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
286
+if [ "$MVNW_VERBOSE" = true ]; then
287
+  echo $MAVEN_PROJECTBASEDIR
288
+fi
289
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
290
+
291
+# For Cygwin, switch paths to Windows format before running java
292
+if $cygwin; then
293
+  [ -n "$M2_HOME" ] &&
294
+    M2_HOME=`cygpath --path --windows "$M2_HOME"`
295
+  [ -n "$JAVA_HOME" ] &&
296
+    JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
297
+  [ -n "$CLASSPATH" ] &&
298
+    CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
299
+  [ -n "$MAVEN_PROJECTBASEDIR" ] &&
300
+    MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
301
+fi
302
+
303
+# Provide a "standardized" way to retrieve the CLI args that will
304
+# work with both Windows and non-Windows executions.
305
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
306
+export MAVEN_CMD_LINE_ARGS
307
+
308
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
309
+
310
+exec "$JAVACMD" \
311
+  $MAVEN_OPTS \
312
+  $MAVEN_DEBUG_OPTS \
313
+  -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
314
+  "-Dmaven.home=${M2_HOME}" \
315
+  "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
316
+  ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

+ 188
- 0
scommons/mvnw.cmd Dosyayı Görüntüle

@@ -0,0 +1,188 @@
1
+@REM ----------------------------------------------------------------------------
2
+@REM Licensed to the Apache Software Foundation (ASF) under one
3
+@REM or more contributor license agreements.  See the NOTICE file
4
+@REM distributed with this work for additional information
5
+@REM regarding copyright ownership.  The ASF licenses this file
6
+@REM to you under the Apache License, Version 2.0 (the
7
+@REM "License"); you may not use this file except in compliance
8
+@REM with the License.  You may obtain a copy of the License at
9
+@REM
10
+@REM    https://www.apache.org/licenses/LICENSE-2.0
11
+@REM
12
+@REM Unless required by applicable law or agreed to in writing,
13
+@REM software distributed under the License is distributed on an
14
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+@REM KIND, either express or implied.  See the License for the
16
+@REM specific language governing permissions and limitations
17
+@REM under the License.
18
+@REM ----------------------------------------------------------------------------
19
+
20
+@REM ----------------------------------------------------------------------------
21
+@REM Maven Start Up Batch script
22
+@REM
23
+@REM Required ENV vars:
24
+@REM JAVA_HOME - location of a JDK home dir
25
+@REM
26
+@REM Optional ENV vars
27
+@REM M2_HOME - location of maven2's installed home dir
28
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
30
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31
+@REM     e.g. to debug Maven itself, use
32
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34
+@REM ----------------------------------------------------------------------------
35
+
36
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37
+@echo off
38
+@REM set title of command window
39
+title %0
40
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
41
+@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%
42
+
43
+@REM set %HOME% to equivalent of $HOME
44
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45
+
46
+@REM Execute a user defined script before this one
47
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
49
+if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
50
+if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
51
+:skipRcPre
52
+
53
+@setlocal
54
+
55
+set ERROR_CODE=0
56
+
57
+@REM To isolate internal variables from possible post scripts, we use another setlocal
58
+@setlocal
59
+
60
+@REM ==== START VALIDATION ====
61
+if not "%JAVA_HOME%" == "" goto OkJHome
62
+
63
+echo.
64
+echo Error: JAVA_HOME not found in your environment. >&2
65
+echo Please set the JAVA_HOME variable in your environment to match the >&2
66
+echo location of your Java installation. >&2
67
+echo.
68
+goto error
69
+
70
+:OkJHome
71
+if exist "%JAVA_HOME%\bin\java.exe" goto init
72
+
73
+echo.
74
+echo Error: JAVA_HOME is set to an invalid directory. >&2
75
+echo JAVA_HOME = "%JAVA_HOME%" >&2
76
+echo Please set the JAVA_HOME variable in your environment to match the >&2
77
+echo location of your Java installation. >&2
78
+echo.
79
+goto error
80
+
81
+@REM ==== END VALIDATION ====
82
+
83
+:init
84
+
85
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86
+@REM Fallback to current working directory if not found.
87
+
88
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90
+
91
+set EXEC_DIR=%CD%
92
+set WDIR=%EXEC_DIR%
93
+:findBaseDir
94
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
95
+cd ..
96
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
97
+set WDIR=%CD%
98
+goto findBaseDir
99
+
100
+:baseDirFound
101
+set MAVEN_PROJECTBASEDIR=%WDIR%
102
+cd "%EXEC_DIR%"
103
+goto endDetectBaseDir
104
+
105
+:baseDirNotFound
106
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107
+cd "%EXEC_DIR%"
108
+
109
+:endDetectBaseDir
110
+
111
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112
+
113
+@setlocal EnableExtensions EnableDelayedExpansion
114
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116
+
117
+:endReadAdditionalConfig
118
+
119
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122
+
123
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
124
+
125
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126
+    IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127
+)
128
+
129
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131
+if exist %WRAPPER_JAR% (
132
+    if "%MVNW_VERBOSE%" == "true" (
133
+        echo Found %WRAPPER_JAR%
134
+    )
135
+) else (
136
+    if not "%MVNW_REPOURL%" == "" (
137
+        SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
138
+    )
139
+    if "%MVNW_VERBOSE%" == "true" (
140
+        echo Couldn't find %WRAPPER_JAR%, downloading it ...
141
+        echo Downloading from: %DOWNLOAD_URL%
142
+    )
143
+
144
+    powershell -Command "&{"^
145
+		"$webclient = new-object System.Net.WebClient;"^
146
+		"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147
+		"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148
+		"}"^
149
+		"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150
+		"}"
151
+    if "%MVNW_VERBOSE%" == "true" (
152
+        echo Finished downloading %WRAPPER_JAR%
153
+    )
154
+)
155
+@REM End of extension
156
+
157
+@REM Provide a "standardized" way to retrieve the CLI args that will
158
+@REM work with both Windows and non-Windows executions.
159
+set MAVEN_CMD_LINE_ARGS=%*
160
+
161
+%MAVEN_JAVA_EXE% ^
162
+  %JVM_CONFIG_MAVEN_PROPS% ^
163
+  %MAVEN_OPTS% ^
164
+  %MAVEN_DEBUG_OPTS% ^
165
+  -classpath %WRAPPER_JAR% ^
166
+  "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
167
+  %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
168
+if ERRORLEVEL 1 goto error
169
+goto end
170
+
171
+:error
172
+set ERROR_CODE=1
173
+
174
+:end
175
+@endlocal & set ERROR_CODE=%ERROR_CODE%
176
+
177
+if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
178
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
179
+if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
180
+if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
181
+:skipRcPost
182
+
183
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
184
+if "%MAVEN_BATCH_PAUSE%"=="on" pause
185
+
186
+if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
187
+
188
+cmd /C exit /B %ERROR_CODE%

+ 48
- 0
scommons/pom.xml Dosyayı Görüntüle

@@ -0,0 +1,48 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4
+    <modelVersion>4.0.0</modelVersion>
5
+    <parent>
6
+        <groupId>org.springframework.boot</groupId>
7
+        <artifactId>spring-boot-starter-parent</artifactId>
8
+        <version>2.6.3</version>
9
+        <relativePath/> <!-- lookup parent from repository -->
10
+    </parent>
11
+    <groupId>com.xhkjedu</groupId>
12
+    <artifactId>scommons</artifactId>
13
+    <version>0.0.1-SNAPSHOT</version>
14
+    <name>scommons</name>
15
+    <description>scommons</description>
16
+    <dependencies>
17
+        <dependency>
18
+            <groupId>org.projectlombok</groupId>
19
+            <artifactId>lombok</artifactId>
20
+            <optional>true</optional>
21
+        </dependency>
22
+        <!--分页插件-->
23
+        <dependency>
24
+            <groupId>com.github.pagehelper</groupId>
25
+            <artifactId>pagehelper-spring-boot-starter</artifactId>
26
+            <version>1.2.10</version>
27
+        </dependency>
28
+    </dependencies>
29
+
30
+    <build>
31
+        <plugins>
32
+            <plugin>
33
+                <groupId>org.springframework.boot</groupId>
34
+                <artifactId>spring-boot-maven-plugin</artifactId>
35
+                <configuration>
36
+                    <skip>true</skip>
37
+                    <excludes>
38
+                        <exclude>
39
+                            <groupId>org.projectlombok</groupId>
40
+                            <artifactId>lombok</artifactId>
41
+                        </exclude>
42
+                    </excludes>
43
+                </configuration>
44
+            </plugin>
45
+        </plugins>
46
+    </build>
47
+
48
+</project>

+ 10
- 0
scommons/src/main/java/com/xhkjedu/config/MissingParametersException.java Dosyayı Görüntüle

@@ -0,0 +1,10 @@
1
+package com.xhkjedu.config;
2
+
3
+public class MissingParametersException extends RuntimeException{
4
+    public MissingParametersException() {
5
+    }
6
+
7
+    public MissingParametersException(String message) {
8
+        super(message);
9
+    }
10
+}

+ 134
- 0
scommons/src/main/java/com/xhkjedu/utils/AES.java Dosyayı Görüntüle

@@ -0,0 +1,134 @@
1
+package com.xhkjedu.utils;
2
+
3
+import javax.crypto.BadPaddingException;
4
+import javax.crypto.Cipher;
5
+import javax.crypto.IllegalBlockSizeException;
6
+import javax.crypto.KeyGenerator;
7
+import javax.crypto.NoSuchPaddingException;
8
+import javax.crypto.SecretKey;
9
+import javax.crypto.spec.SecretKeySpec;
10
+import java.io.UnsupportedEncodingException;
11
+import java.security.InvalidAlgorithmParameterException;
12
+import java.security.InvalidKeyException;
13
+import java.security.NoSuchAlgorithmException;
14
+
15
+/**
16
+ * @ClassName AES
17
+ * Description TODO
18
+ * Author WN
19
+ * Date 2021/5/12 17:57
20
+ **/
21
+public class AES {
22
+    private static String Algorithm = "AES";
23
+    private static String AlgorithmProvider = "AES/ECB/PKCS5Padding"; // 算法/模式/补码方式
24
+
25
+    public static byte[] generatorKey() throws NoSuchAlgorithmException {
26
+        KeyGenerator keyGenerator = KeyGenerator.getInstance(Algorithm);
27
+        keyGenerator.init(256);//默认128,获得无政策权限后可为192或256
28
+        SecretKey secretKey = keyGenerator.generateKey();
29
+        return secretKey.getEncoded();
30
+    }
31
+
32
+    public static String encrypt(String str, String keystr) throws NoSuchAlgorithmException, NoSuchPaddingException,
33
+            InvalidKeyException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException, InvalidAlgorithmParameterException {
34
+        byte[] key = keystr.getBytes("utf-8");
35
+        SecretKey secretKey = new SecretKeySpec(key, Algorithm);
36
+        Cipher cipher = Cipher.getInstance(AlgorithmProvider);
37
+        cipher.init(Cipher.ENCRYPT_MODE, secretKey);
38
+        byte[] cipherBytes = cipher.doFinal(str.getBytes("utf-8"));
39
+        return byteToHexString(cipherBytes);
40
+    }
41
+
42
+    public static String decrypt(String src, String keystr) throws Exception {
43
+        byte[] key = keystr.getBytes("utf-8");
44
+        SecretKey secretKey = new SecretKeySpec(key, Algorithm);
45
+        Cipher cipher = Cipher.getInstance(AlgorithmProvider);
46
+        cipher.init(Cipher.DECRYPT_MODE, secretKey);
47
+        byte[] hexBytes = hexStringToBytes(src);
48
+        byte[] plainBytes = cipher.doFinal(hexBytes);
49
+        return new String(plainBytes, "utf-8");
50
+    }
51
+
52
+    public static byte[] decryptForByte(String src, String keystr) throws Exception {
53
+        byte[] key = keystr.getBytes("utf-8");
54
+        SecretKey secretKey = new SecretKeySpec(key, Algorithm);
55
+        Cipher cipher = Cipher.getInstance(AlgorithmProvider);
56
+        cipher.init(Cipher.DECRYPT_MODE, secretKey);
57
+        byte[] hexBytes = hexStringToBytes(src);
58
+        byte[] plainBytes = cipher.doFinal(hexBytes);
59
+        return plainBytes;
60
+    }
61
+
62
+
63
+    /**
64
+     * 将byte转换为16进制字符串
65
+     *
66
+     * @param src
67
+     * @return
68
+     */
69
+    public static String byteToHexString(byte[] src) {
70
+        StringBuilder sb = new StringBuilder();
71
+        for (int i = 0; i < src.length; i++) {
72
+            int v = src[i] & 0xff;
73
+            String hv = Integer.toHexString(v);
74
+            if (hv.length() < 2) {
75
+                sb.append("0");
76
+            }
77
+            sb.append(hv);
78
+        }
79
+        return sb.toString();
80
+    }
81
+
82
+    /**
83
+     * 将16进制字符串装换为byte数组
84
+     *
85
+     * @param hexString
86
+     * @return
87
+     */
88
+    public static byte[] hexStringToBytes(String hexString) {
89
+        hexString = hexString.toUpperCase();
90
+        int length = hexString.length() / 2;
91
+        char[] hexChars = hexString.toCharArray();
92
+        byte[] b = new byte[length];
93
+        for (int i = 0; i < length; i++) {
94
+            int pos = i * 2;
95
+            b[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
96
+        }
97
+        return b;
98
+    }
99
+
100
+    private static byte charToByte(char c) {
101
+        return (byte) "0123456789ABCDEF".indexOf(c);
102
+    }
103
+
104
+    public static void main(String[] args) {
105
+        try {
106
+            // 密钥必须是16的倍数
107
+            String keystr = "XINGHUOLIAOYUAN7";
108
+            String src = "{\"level\": 1}";
109
+
110
+            System.out.println("密钥:" + keystr);
111
+            System.out.println("原字符串:" + src);
112
+
113
+            String enc = encrypt(src, keystr);
114
+            System.out.println("加密:" + enc);
115
+
116
+            String dec = new String(decryptForByte(enc, keystr));
117
+            System.out.println("解密:" + dec);
118
+        } catch (InvalidKeyException e) {
119
+            e.printStackTrace();
120
+        } catch (NoSuchAlgorithmException e) {
121
+            e.printStackTrace();
122
+        } catch (NoSuchPaddingException e) {
123
+            e.printStackTrace();
124
+        } catch (IllegalBlockSizeException e) {
125
+            e.printStackTrace();
126
+        } catch (BadPaddingException e) {
127
+            e.printStackTrace();
128
+        } catch (UnsupportedEncodingException e) {
129
+            e.printStackTrace();
130
+        } catch (Exception e) {
131
+            e.printStackTrace();
132
+        }
133
+    }
134
+}

+ 105
- 0
scommons/src/main/java/com/xhkjedu/utils/DESUtils.java Dosyayı Görüntüle

@@ -0,0 +1,105 @@
1
+package com.xhkjedu.utils;
2
+
3
+import javax.crypto.Cipher;
4
+import javax.crypto.SecretKey;
5
+import javax.crypto.spec.SecretKeySpec;
6
+
7
+/**
8
+ * 3DES加密工具类
9
+ */
10
+public class DESUtils {
11
+	
12
+	/**
13
+	 * 加密
14
+	 * @param inStr 需要加密的内容
15
+	 * @param secretKey 密钥
16
+	 * @return 加密后的数据
17
+	 */
18
+	public static String encrypt(String inStr, String secretKey) {
19
+		SecretKey deskey = new SecretKeySpec(secretKey.getBytes(), "DESede");
20
+		Cipher cipher;
21
+		String outStr = null;
22
+		try {
23
+			cipher = Cipher.getInstance("DESede");
24
+			cipher.init(Cipher.ENCRYPT_MODE, deskey);
25
+			outStr = byte2hex(cipher.doFinal(inStr.getBytes()));
26
+		} catch (Exception e) {
27
+			outStr = "default";
28
+			System.err.println("3DES加密失败!加密内容[" + inStr + "]");
29
+			e.printStackTrace();
30
+		}
31
+		return outStr;
32
+	}
33
+	
34
+	/**
35
+	 * 解密
36
+	 * @param inStr 需要解密的内容
37
+	 * @param secretKey 密钥
38
+	 * @return 解密后的数据
39
+	 */
40
+	public static String decrypt(String inStr, String secretKey) {
41
+		SecretKey deskey = new SecretKeySpec(secretKey.getBytes(), "DESede");
42
+		Cipher cipher;
43
+		String outStr = null;
44
+		try {
45
+			cipher = Cipher.getInstance("DESede");
46
+			cipher.init(Cipher.DECRYPT_MODE, deskey);
47
+			outStr = new String(cipher.doFinal(hex2byte(inStr)));
48
+		} catch (Exception e) {
49
+			outStr = "default";
50
+			System.err.println("3DES解密失败!解密内容[" + inStr + "]");
51
+			e.printStackTrace();
52
+		}
53
+		return outStr;
54
+	}
55
+	
56
+	/**
57
+	 * 转化为16进制字符串方法
58
+	 * @param digest 需要转换的字节组
59
+	 * @return 转换后的字符串
60
+	 */
61
+	public static String byte2hex(byte[] digest) {
62
+		StringBuffer hs = new StringBuffer();
63
+		String stmp = "";
64
+		for (int n = 0; n < digest.length; n++) {
65
+			stmp = Integer.toHexString(digest[n] & 0XFF);
66
+			if (stmp.length() == 1) {
67
+				hs.append("0" + stmp);
68
+			} else {
69
+				hs.append(stmp);
70
+			}
71
+		}
72
+		return hs.toString().toUpperCase();
73
+	}
74
+	
75
+	/**
76
+	 * 十六进转二进制
77
+	 * @param hexStr 待转换16进制字符串
78
+	 * @return 二进制字节组
79
+	 */
80
+	public static byte[] hex2byte(String hexStr){
81
+		if (hexStr == null)
82
+			return null;
83
+		hexStr = hexStr.trim();
84
+		int len = hexStr.length();
85
+		if (len == 0 || len % 2 == 1)
86
+			return null;
87
+		byte[] digest = new byte[len / 2];
88
+		try {
89
+			for (int i = 0; i < hexStr.length(); i += 2) {
90
+				digest[i / 2] = (byte) Integer.decode("0x" + hexStr.substring(i, i + 2)).intValue();
91
+			}
92
+			return digest;
93
+		} catch (Exception e) {
94
+			return null;
95
+		}
96
+	}
97
+	
98
+	public static void main(String[] args) {
99
+		String secretKey = "111111112222222233333333";
100
+		System.out.println(encrypt("{patternID : '1001', raq : 'test.raq'}", secretKey));
101
+		System.out.println(encrypt("{patternID : '0', username : 'zhangsan', password : '1'}", secretKey));
102
+		System.out.println(encrypt("{patternID : '0', username : 'zhangsan', password : '2'}", secretKey));
103
+	}
104
+	
105
+}

+ 178
- 0
scommons/src/main/java/com/xhkjedu/utils/DatesUtil.java Dosyayı Görüntüle

@@ -0,0 +1,178 @@
1
+package com.xhkjedu.utils;
2
+
3
+import java.text.ParseException;
4
+import java.text.SimpleDateFormat;
5
+import java.util.Calendar;
6
+import java.util.Date;
7
+import java.util.GregorianCalendar;
8
+
9
+/**
10
+ * 日期工具类
11
+ */
12
+public class DatesUtil {
13
+    public static SimpleDateFormat sdf() {
14
+//        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
15
+        return new SimpleDateFormat("yyyy-MM-dd");
16
+    }
17
+
18
+    public static Integer getTimestamp(String time) {
19
+        try {
20
+            return Integer.valueOf(sdf().parse(time).getTime()/1000+"");
21
+        } catch (ParseException e) {
22
+            return null;
23
+        }
24
+    }
25
+
26
+    //获取当天的开始时间
27
+    public static String getDayBegin() {
28
+        Calendar cal = new GregorianCalendar();
29
+        cal.set(Calendar.HOUR_OF_DAY, 0);
30
+        cal.set(Calendar.MINUTE, 0);
31
+        cal.set(Calendar.SECOND, 0);
32
+        cal.set(Calendar.MILLISECOND, 0);
33
+        return sdf().format(cal.getTime());
34
+    }
35
+
36
+    //获取当天的结束时间
37
+    public static String getDayEnd() {
38
+        Calendar cal = new GregorianCalendar();
39
+        cal.set(Calendar.HOUR_OF_DAY, 23);
40
+        cal.set(Calendar.MINUTE, 59);
41
+        cal.set(Calendar.SECOND, 59);
42
+        return sdf().format(cal.getTime());
43
+    }
44
+
45
+    //获取昨天的开始时间
46
+    public static String getBeginDayOfYesterday() {
47
+        Calendar cal = new GregorianCalendar();
48
+        cal.set(Calendar.HOUR_OF_DAY, 0);
49
+        cal.set(Calendar.MINUTE, 0);
50
+        cal.set(Calendar.SECOND, 0);
51
+        cal.set(Calendar.MILLISECOND, 0);
52
+        cal.add(Calendar.DAY_OF_MONTH, -1);
53
+        return sdf().format(cal.getTime());
54
+    }
55
+
56
+    //获取昨天的结束时间
57
+    public static String getEndDayOfYesterday() {
58
+        Calendar cal = new GregorianCalendar();
59
+        cal.set(Calendar.HOUR_OF_DAY, 23);
60
+        cal.set(Calendar.MINUTE, 59);
61
+        cal.set(Calendar.SECOND, 59);
62
+        cal.add(Calendar.DAY_OF_MONTH, -1);
63
+        return sdf().format(cal.getTime());
64
+    }
65
+
66
+    // 获得本周一0点时间
67
+    public static String getBeginDayOfWeek() {
68
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
69
+        Calendar c = Calendar.getInstance();
70
+        int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
71
+        if (day_of_week == 0)
72
+            day_of_week = 7;
73
+        c.add(Calendar.DATE, -day_of_week + 1);
74
+        return format.format(c.getTime());
75
+    }
76
+
77
+    // 获得本周日24点时间
78
+    public static String getEndDayOfWeek() {
79
+        SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd 23:59:59");
80
+        Calendar c = Calendar.getInstance();
81
+        int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
82
+        if (day_of_week == 0)
83
+            day_of_week = 7;
84
+        c.add(Calendar.DATE, -day_of_week + 7);
85
+        return formatDate.format(c.getTime());
86
+    }
87
+
88
+    //根据当前日期获得最近n周的日期区间(不包含本周)
89
+    public static String getFromToDate(SimpleDateFormat sdf, Date date, int n, int option, int k) {
90
+        Calendar calendar = Calendar.getInstance();
91
+        calendar.setTime(date);
92
+        int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK) - 1;
93
+        int offset = 0 == option ? 1 - dayOfWeek : 7 - dayOfWeek;
94
+        int amount = 0 == option ? offset - (n - 1  + k) * 7 : offset - k * 7;
95
+        calendar.add(Calendar.DATE, amount);
96
+        return sdf.format(calendar.getTime());
97
+    }
98
+
99
+    // 获取上周的开始时间
100
+    public static String getBeginDayOfLastWeek(Integer basenum) {
101
+        //上周日期
102
+        SimpleDateFormat sdf = sdf();
103
+        String beginDate = getFromToDate(sdf, new Date(), basenum, 0, 1);
104
+
105
+        Calendar calendar = Calendar.getInstance();
106
+        try {
107
+            calendar.setTime(sdf.parse(beginDate));
108
+        }catch (Exception e){
109
+            e.printStackTrace();
110
+        }
111
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
112
+        calendar.set(Calendar.MINUTE, 0);
113
+        calendar.set(Calendar.SECOND, 0);
114
+        calendar.set(Calendar.MILLISECOND, 0);
115
+        return sdf.format(calendar.getTime());
116
+    }
117
+
118
+    // 获取上周的结束时间
119
+    public static String getEndDayOfLastWeek(Integer basenum) {
120
+        //上周日期
121
+        SimpleDateFormat sdf = sdf();
122
+        String endDate = getFromToDate(sdf, new Date(), basenum, 1, basenum);
123
+
124
+        Calendar calendar = Calendar.getInstance();
125
+        try {
126
+            calendar.setTime(sdf.parse(endDate));
127
+        }catch (Exception e){
128
+            e.printStackTrace();
129
+        }
130
+        calendar.set(Calendar.HOUR_OF_DAY, 23);
131
+        calendar.set(Calendar.MINUTE, 59);
132
+        calendar.set(Calendar.SECOND, 59);
133
+        return sdf.format(calendar.getTime());
134
+    }
135
+
136
+    // 获得本月第一天0点时间
137
+    public static String getBeginDayOfMonth() {
138
+        Calendar cal = Calendar.getInstance();
139
+        cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
140
+        cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
141
+        return sdf().format(cal.getTime());
142
+    }
143
+
144
+    // 获得本月最后一天24点时间
145
+    public static String getEndDayOfMonth() {
146
+        Calendar cal = Calendar.getInstance();
147
+        cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), cal.get(Calendar.DAY_OF_MONTH), 23, 59, 59);
148
+        cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
149
+        cal.set(Calendar.HOUR_OF_DAY, 23);
150
+        return sdf().format(cal.getTime());
151
+    }
152
+
153
+    // 获得上月第一天0点时间
154
+    public static String getBeginDayOfLastMonth(Integer basenum) {
155
+        //上月日期
156
+        Calendar c=Calendar.getInstance();
157
+        c.add(Calendar.MONTH, -basenum);
158
+        int lastMonthMaxDay=c.getActualMinimum(Calendar.DAY_OF_MONTH);
159
+        c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), lastMonthMaxDay, 0, 0, 0);
160
+
161
+        //按格式输出
162
+        String gtime = sdf().format(c.getTime()); //上月第一天
163
+        return gtime;
164
+    }
165
+    // 获得上月最后一天24点时间
166
+    public static String getEndDayOfLastMonth(Integer basenum) {
167
+        //上月日期
168
+        Calendar c=Calendar.getInstance();
169
+        c.add(Calendar.MONTH, -basenum);
170
+        int lastMonthMaxDay=c.getActualMaximum(Calendar.DAY_OF_MONTH);
171
+        c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), lastMonthMaxDay, 23, 59, 59);
172
+
173
+        //按格式输出
174
+        String gtime = sdf().format(c.getTime()); //上月最后一天
175
+        return gtime;
176
+    }
177
+
178
+}

+ 425
- 0
scommons/src/main/java/com/xhkjedu/utils/MD5.java Dosyayı Görüntüle

@@ -0,0 +1,425 @@
1
+package com.xhkjedu.utils;
2
+
3
+import lombok.extern.slf4j.Slf4j;
4
+
5
+import java.security.MessageDigest;
6
+import java.security.NoSuchAlgorithmException;
7
+
8
+/************************************************
9
+ MD5 算法的Java Bean
10
+ *************************************************/
11
+@Slf4j
12
+public class MD5 {
13
+
14
+    /*
15
+     * 下面这些S11-S44实际上是一个4*4的矩阵,在原始的C实现中是用#define 实现的, 这里把它们实现成为static
16
+     * final是表示了只读,切能在同一个进程空间内的多个 Instance间共享
17
+     */
18
+    static final int S11 = 7;
19
+
20
+    static final int S12 = 12;
21
+
22
+    static final int S13 = 17;
23
+
24
+    static final int S14 = 22;
25
+
26
+    static final int S21 = 5;
27
+
28
+    static final int S22 = 9;
29
+
30
+    static final int S23 = 14;
31
+
32
+    static final int S24 = 20;
33
+
34
+    static final int S31 = 4;
35
+
36
+    static final int S32 = 11;
37
+
38
+    static final int S33 = 16;
39
+
40
+    static final int S34 = 23;
41
+
42
+    static final int S41 = 6;
43
+
44
+    static final int S42 = 10;
45
+
46
+    static final int S43 = 15;
47
+
48
+    static final int S44 = 21;
49
+
50
+    static final byte[] PADDING = {-128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
51
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
52
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
53
+            0, 0, 0, 0, 0, 0, 0};
54
+
55
+    /*
56
+     * 下面的三个成员是MD5计算过程中用到的3个核心数据,在原始的C实现中 被定义到MD5_CTX结构中
57
+     */
58
+    private long[] state = new long[4]; // state (ABCD)
59
+
60
+    private long[] count = new long[2]; // number of bits, modulo 2^64 (lsb
61
+
62
+    private byte[] buffer = new byte[64]; // input buffer
63
+
64
+    /*
65
+     * digestHexStr是MD5的唯一一个公共成员,是最新一次计算结果的 16进制ASCII表示.
66
+     */
67
+    public String digestHexStr;
68
+
69
+    /*
70
+     * digest,是最新一次计算结果的2进制内部表示,表示128bit的MD5值.
71
+     */
72
+    private byte[] digest = new byte[16];
73
+
74
+    /*
75
+     * getMD5ofStr是类MD5最主要的公共方法,入口参数是你想要进行MD5变换的字符串
76
+     * 返回的是变换完的结果,这个结果是从公共成员digestHexStr取得的.
77
+     */
78
+    public String getMD5ofStr(String inbuf) {
79
+        md5Init();
80
+        md5Update(inbuf.getBytes(), inbuf.length());
81
+        md5Final();
82
+
83
+        digestHexStr = "";
84
+        for (int i = 0; i < 16; i++) {
85
+            digestHexStr += byteHEX(digest[i]);
86
+        }
87
+
88
+        return digestHexStr;
89
+    }
90
+
91
+    /**
92
+     * 获取加密后的32位小写字符串
93
+     * @Param [str]
94
+     * @Author ywx
95
+     * @Date 2020/12/11 16:02
96
+     * @return java.lang.String
97
+     **/
98
+    public String getMD5ofStr2(String str) {
99
+        return getMD5ofStr(str).toLowerCase();
100
+    }
101
+
102
+    // 这是MD5这个类的标准构造函数,JavaBean要求有一个public的并且没有参数的构造函数
103
+    public MD5() {
104
+        md5Init();
105
+        return;
106
+    }
107
+
108
+    /* md5Init是一个初始化函数,初始化核心变量,装入标准的幻数 */
109
+    private void md5Init() {
110
+        count[0] = 0L;
111
+        count[1] = 0L;
112
+        // /* Load magic initialization constants.
113
+
114
+        state[0] = 0x67452301L;
115
+        state[1] = 0xefcdab89L;
116
+        state[2] = 0x98badcfeL;
117
+        state[3] = 0x10325476L;
118
+
119
+        return;
120
+    }
121
+
122
+    /*
123
+     * F, G, H ,I 是4个基本的MD5函数,在原始的MD5的C实现中,由于它们是
124
+     * 简单的位运算,可能出于效率的考虑把它们实现成了宏,在java中,我们把它们 实现成了private方法,名字保持了原来C中的。
125
+     */
126
+
127
+    private long F(long x, long y, long z) {
128
+        return (x & y) | ((~x) & z);
129
+
130
+    }
131
+
132
+    private long G(long x, long y, long z) {
133
+        return (x & z) | (y & (~z));
134
+
135
+    }
136
+
137
+    private long H(long x, long y, long z) {
138
+        return x ^ y ^ z;
139
+    }
140
+
141
+    private long I(long x, long y, long z) {
142
+        return y ^ (x | (~z));
143
+    }
144
+
145
+    /*
146
+     * FF,GG,HH和II将调用F,G,H,I进行近一步变换 FF, GG, HH, and II transformations for
147
+     * rounds 1, 2, 3, and 4. Rotation is separate from addition to prevent
148
+     * recomputation.
149
+     */
150
+
151
+    private long FF(long a, long b, long c, long d, long x, long s, long ac) {
152
+        a += F(b, c, d) + x + ac;
153
+        a = ((int) a << s) | ((int) a >>> (32 - s));
154
+        a += b;
155
+        return a;
156
+    }
157
+
158
+    private long GG(long a, long b, long c, long d, long x, long s, long ac) {
159
+        a += G(b, c, d) + x + ac;
160
+        a = ((int) a << s) | ((int) a >>> (32 - s));
161
+        a += b;
162
+        return a;
163
+    }
164
+
165
+    private long HH(long a, long b, long c, long d, long x, long s, long ac) {
166
+        a += H(b, c, d) + x + ac;
167
+        a = ((int) a << s) | ((int) a >>> (32 - s));
168
+        a += b;
169
+        return a;
170
+    }
171
+
172
+    private long II(long a, long b, long c, long d, long x, long s, long ac) {
173
+        a += I(b, c, d) + x + ac;
174
+        a = ((int) a << s) | ((int) a >>> (32 - s));
175
+        a += b;
176
+        return a;
177
+    }
178
+
179
+    /*
180
+     * md5Update是MD5的主计算过程,inbuf是要变换的字节串,inputlen是长度,这个
181
+     * 函数由getMD5ofStr调用,调用之前需要调用md5init,因此把它设计成private的
182
+     */
183
+    private void md5Update(byte[] inbuf, int inputLen) {
184
+
185
+        int i, index, partLen;
186
+        byte[] block = new byte[64];
187
+        index = (int) (count[0] >>> 3) & 0x3F;
188
+        // /* Update number of bits */
189
+        if ((count[0] += (inputLen << 3)) < (inputLen << 3))
190
+            count[1]++;
191
+        count[1] += (inputLen >>> 29);
192
+
193
+        partLen = 64 - index;
194
+
195
+        // Transform as many times as possible.
196
+        if (inputLen >= partLen) {
197
+            md5Memcpy(buffer, inbuf, index, 0, partLen);
198
+            md5Transform(buffer);
199
+
200
+            for (i = partLen; i + 63 < inputLen; i += 64) {
201
+
202
+                md5Memcpy(block, inbuf, 0, i, 64);
203
+                md5Transform(block);
204
+            }
205
+            index = 0;
206
+
207
+        } else
208
+
209
+            i = 0;
210
+
211
+        // /* Buffer remaining input */
212
+        md5Memcpy(buffer, inbuf, index, i, inputLen - i);
213
+    }
214
+
215
+    /*
216
+     * md5Final整理和填写输出结果
217
+     */
218
+    private void md5Final() {
219
+        byte[] bits = new byte[8];
220
+        int index, padLen;
221
+
222
+        // /* Save number of bits */
223
+        Encode(bits, count, 8);
224
+
225
+        // /* Pad out to 56 mod 64.
226
+        index = (int) (count[0] >>> 3) & 0x3f;
227
+        padLen = (index < 56) ? (56 - index) : (120 - index);
228
+        md5Update(PADDING, padLen);
229
+
230
+        // /* Append length (before padding) */
231
+        md5Update(bits, 8);
232
+
233
+        // /* Store state in digest */
234
+        Encode(digest, state, 16);
235
+    }
236
+
237
+    /*
238
+     * md5Memcpy是一个内部使用的byte数组的块拷贝函数,从input的inpos开始把len长度的
239
+     * 字节拷贝到output的outpos位置开始
240
+     */
241
+
242
+    private void md5Memcpy(byte[] output, byte[] input, int outpos, int inpos,
243
+                           int len) {
244
+        int i;
245
+
246
+        for (i = 0; i < len; i++)
247
+            output[outpos + i] = input[inpos + i];
248
+    }
249
+
250
+    /*
251
+     * md5Transform是MD5核心变换程序,有md5Update调用,block是分块的原始字节
252
+     */
253
+    private void md5Transform(byte block[]) {
254
+        long a = state[0], b = state[1], c = state[2], d = state[3];
255
+        long[] x = new long[16];
256
+
257
+        Decode(x, block, 64);
258
+
259
+        /* Round 1 */
260
+        a = FF(a, b, c, d, x[0], S11, 0xd76aa478L); /* 1 */
261
+        d = FF(d, a, b, c, x[1], S12, 0xe8c7b756L); /* 2 */
262
+        c = FF(c, d, a, b, x[2], S13, 0x242070dbL); /* 3 */
263
+        b = FF(b, c, d, a, x[3], S14, 0xc1bdceeeL); /* 4 */
264
+        a = FF(a, b, c, d, x[4], S11, 0xf57c0fafL); /* 5 */
265
+        d = FF(d, a, b, c, x[5], S12, 0x4787c62aL); /* 6 */
266
+        c = FF(c, d, a, b, x[6], S13, 0xa8304613L); /* 7 */
267
+        b = FF(b, c, d, a, x[7], S14, 0xfd469501L); /* 8 */
268
+        a = FF(a, b, c, d, x[8], S11, 0x698098d8L); /* 9 */
269
+        d = FF(d, a, b, c, x[9], S12, 0x8b44f7afL); /* 10 */
270
+        c = FF(c, d, a, b, x[10], S13, 0xffff5bb1L); /* 11 */
271
+        b = FF(b, c, d, a, x[11], S14, 0x895cd7beL); /* 12 */
272
+        a = FF(a, b, c, d, x[12], S11, 0x6b901122L); /* 13 */
273
+        d = FF(d, a, b, c, x[13], S12, 0xfd987193L); /* 14 */
274
+        c = FF(c, d, a, b, x[14], S13, 0xa679438eL); /* 15 */
275
+        b = FF(b, c, d, a, x[15], S14, 0x49b40821L); /* 16 */
276
+
277
+        /* Round 2 */
278
+        a = GG(a, b, c, d, x[1], S21, 0xf61e2562L); /* 17 */
279
+        d = GG(d, a, b, c, x[6], S22, 0xc040b340L); /* 18 */
280
+        c = GG(c, d, a, b, x[11], S23, 0x265e5a51L); /* 19 */
281
+        b = GG(b, c, d, a, x[0], S24, 0xe9b6c7aaL); /* 20 */
282
+        a = GG(a, b, c, d, x[5], S21, 0xd62f105dL); /* 21 */
283
+        d = GG(d, a, b, c, x[10], S22, 0x2441453L); /* 22 */
284
+        c = GG(c, d, a, b, x[15], S23, 0xd8a1e681L); /* 23 */
285
+        b = GG(b, c, d, a, x[4], S24, 0xe7d3fbc8L); /* 24 */
286
+        a = GG(a, b, c, d, x[9], S21, 0x21e1cde6L); /* 25 */
287
+        d = GG(d, a, b, c, x[14], S22, 0xc33707d6L); /* 26 */
288
+        c = GG(c, d, a, b, x[3], S23, 0xf4d50d87L); /* 27 */
289
+        b = GG(b, c, d, a, x[8], S24, 0x455a14edL); /* 28 */
290
+        a = GG(a, b, c, d, x[13], S21, 0xa9e3e905L); /* 29 */
291
+        d = GG(d, a, b, c, x[2], S22, 0xfcefa3f8L); /* 30 */
292
+        c = GG(c, d, a, b, x[7], S23, 0x676f02d9L); /* 31 */
293
+        b = GG(b, c, d, a, x[12], S24, 0x8d2a4c8aL); /* 32 */
294
+
295
+        /* Round 3 */
296
+        a = HH(a, b, c, d, x[5], S31, 0xfffa3942L); /* 33 */
297
+        d = HH(d, a, b, c, x[8], S32, 0x8771f681L); /* 34 */
298
+        c = HH(c, d, a, b, x[11], S33, 0x6d9d6122L); /* 35 */
299
+        b = HH(b, c, d, a, x[14], S34, 0xfde5380cL); /* 36 */
300
+        a = HH(a, b, c, d, x[1], S31, 0xa4beea44L); /* 37 */
301
+        d = HH(d, a, b, c, x[4], S32, 0x4bdecfa9L); /* 38 */
302
+        c = HH(c, d, a, b, x[7], S33, 0xf6bb4b60L); /* 39 */
303
+        b = HH(b, c, d, a, x[10], S34, 0xbebfbc70L); /* 40 */
304
+        a = HH(a, b, c, d, x[13], S31, 0x289b7ec6L); /* 41 */
305
+        d = HH(d, a, b, c, x[0], S32, 0xeaa127faL); /* 42 */
306
+        c = HH(c, d, a, b, x[3], S33, 0xd4ef3085L); /* 43 */
307
+        b = HH(b, c, d, a, x[6], S34, 0x4881d05L); /* 44 */
308
+        a = HH(a, b, c, d, x[9], S31, 0xd9d4d039L); /* 45 */
309
+        d = HH(d, a, b, c, x[12], S32, 0xe6db99e5L); /* 46 */
310
+        c = HH(c, d, a, b, x[15], S33, 0x1fa27cf8L); /* 47 */
311
+        b = HH(b, c, d, a, x[2], S34, 0xc4ac5665L); /* 48 */
312
+
313
+        /* Round 4 */
314
+        a = II(a, b, c, d, x[0], S41, 0xf4292244L); /* 49 */
315
+        d = II(d, a, b, c, x[7], S42, 0x432aff97L); /* 50 */
316
+        c = II(c, d, a, b, x[14], S43, 0xab9423a7L); /* 51 */
317
+        b = II(b, c, d, a, x[5], S44, 0xfc93a039L); /* 52 */
318
+        a = II(a, b, c, d, x[12], S41, 0x655b59c3L); /* 53 */
319
+        d = II(d, a, b, c, x[3], S42, 0x8f0ccc92L); /* 54 */
320
+        c = II(c, d, a, b, x[10], S43, 0xffeff47dL); /* 55 */
321
+        b = II(b, c, d, a, x[1], S44, 0x85845dd1L); /* 56 */
322
+        a = II(a, b, c, d, x[8], S41, 0x6fa87e4fL); /* 57 */
323
+        d = II(d, a, b, c, x[15], S42, 0xfe2ce6e0L); /* 58 */
324
+        c = II(c, d, a, b, x[6], S43, 0xa3014314L); /* 59 */
325
+        b = II(b, c, d, a, x[13], S44, 0x4e0811a1L); /* 60 */
326
+        a = II(a, b, c, d, x[4], S41, 0xf7537e82L); /* 61 */
327
+        d = II(d, a, b, c, x[11], S42, 0xbd3af235L); /* 62 */
328
+        c = II(c, d, a, b, x[2], S43, 0x2ad7d2bbL); /* 63 */
329
+        b = II(b, c, d, a, x[9], S44, 0xeb86d391L); /* 64 */
330
+
331
+        state[0] += a;
332
+        state[1] += b;
333
+        state[2] += c;
334
+        state[3] += d;
335
+    }
336
+
337
+    /*
338
+     * Encode把long数组按顺序拆成byte数组,因为java的long类型是64bit的, 只拆低32bit,以适应原始C实现的用途
339
+     */
340
+    private void Encode(byte[] output, long[] input, int len) {
341
+        int i, j;
342
+
343
+        for (i = 0, j = 0; j < len; i++, j += 4) {
344
+            output[j] = (byte) (input[i] & 0xffL);
345
+            output[j + 1] = (byte) ((input[i] >>> 8) & 0xffL);
346
+            output[j + 2] = (byte) ((input[i] >>> 16) & 0xffL);
347
+            output[j + 3] = (byte) ((input[i] >>> 24) & 0xffL);
348
+        }
349
+    }
350
+
351
+    /*
352
+     * Decode把byte数组按顺序合成成long数组,因为java的long类型是64bit的,
353
+     * 只合成低32bit,高32bit清零,以适应原始C实现的用途
354
+     */
355
+    private void Decode(long[] output, byte[] input, int len) {
356
+        int i, j;
357
+
358
+        for (i = 0, j = 0; j < len; i++, j += 4)
359
+            output[i] = b2iu(input[j]) | (b2iu(input[j + 1]) << 8)
360
+                    | (b2iu(input[j + 2]) << 16) | (b2iu(input[j + 3]) << 24);
361
+
362
+        return;
363
+    }
364
+
365
+    /*
366
+     * b2iu是我写的一个把byte按照不考虑正负号的原则的"升位"程序,因为java没有unsigned运算
367
+     */
368
+    public static long b2iu(byte b) {
369
+        return b < 0 ? b & 0x7F + 128 : b;
370
+    }
371
+
372
+    /*
373
+     * byteHEX(),用来把一个byte类型的数转换成十六进制的ASCII表示,
374
+     * 因为java中的byte的toString无法实现这一点,我们又没有C语言中的 sprintf(outbuf,"%02X",ib)
375
+     */
376
+    public static String byteHEX(byte ib) {
377
+        char[] Digit = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A',
378
+                'B', 'C', 'D', 'E', 'F'};
379
+        char[] ob = new char[2];
380
+        ob[0] = Digit[(ib >>> 4) & 0X0F];
381
+        ob[1] = Digit[ib & 0X0F];
382
+        String s = new String(ob);
383
+        return s;
384
+    }
385
+
386
+    /**
387
+     * js-md5加密用户密码
388
+     */
389
+    public String getJsMD5(String password) {
390
+        try {
391
+            // 得到一个信息摘要器
392
+            MessageDigest digest = MessageDigest.getInstance("md5");
393
+            byte[] result = digest.digest(password.getBytes());
394
+            StringBuffer buffer = new StringBuffer();
395
+            // 把没一个byte 做一个与运算 0xff;
396
+            for (byte b : result) {
397
+                // 与运算
398
+                int number = b & 0xff;// 加盐
399
+                String str = Integer.toHexString(number);
400
+                if (str.length() == 1) {
401
+                    buffer.append("0");
402
+                }
403
+                buffer.append(str);
404
+            }
405
+
406
+            // 标准的md5加密后的结果
407
+            return buffer.toString();
408
+        } catch (NoSuchAlgorithmException e) {
409
+            e.printStackTrace();
410
+            return "";
411
+        }
412
+    }
413
+
414
+    public static void main(String args[]) {
415
+        MD5 m = new MD5();
416
+        String str = "Xhkjedu007";
417
+        str = m.getMD5ofStr(str);
418
+        System.out.println(str);
419
+        str = m.getMD5ofStr(str+1607671633);
420
+        System.out.println(str);
421
+        System.out.println(m.getMD5ofStr("08ce360f3e87fc23fe4ca362748816441607671633"));
422
+
423
+    }
424
+
425
+}

+ 993
- 0
scommons/src/main/java/com/xhkjedu/utils/N_Utils.java Dosyayı Görüntüle

@@ -0,0 +1,993 @@
1
+package com.xhkjedu.utils;
2
+
3
+import com.xhkjedu.config.MissingParametersException;
4
+import lombok.extern.slf4j.Slf4j;
5
+import org.springframework.util.CollectionUtils;
6
+
7
+import java.io.BufferedReader;
8
+import java.io.IOException;
9
+import java.io.InputStreamReader;
10
+import java.io.OutputStreamWriter;
11
+import java.math.BigDecimal;
12
+import java.net.URL;
13
+import java.net.URLConnection;
14
+import java.text.ParseException;
15
+import java.text.SimpleDateFormat;
16
+import java.time.Instant;
17
+import java.time.LocalDate;
18
+import java.time.LocalDateTime;
19
+import java.time.ZoneId;
20
+import java.util.ArrayList;
21
+import java.util.Date;
22
+import java.util.List;
23
+import java.util.regex.Matcher;
24
+import java.util.regex.Pattern;
25
+import java.util.stream.Collectors;
26
+
27
+/**
28
+ * @author WN
29
+ * @className N_Utils
30
+ * @description 工具类
31
+ * @date 2019/4/3 14:13
32
+ **/
33
+@Slf4j
34
+public class N_Utils {
35
+
36
+    /**
37
+     * 字符串是否为空
38
+     *
39
+     * @param: @param obj
40
+     * @param: @return
41
+     * @author WN
42
+     */
43
+    public static boolean isNotEmpty(Object obj) {
44
+        if (null == obj || "".equals(obj.toString().trim())) {
45
+            return false;
46
+        } else {
47
+            return true;
48
+        }
49
+    }
50
+
51
+    /**
52
+     * 字符串是否为空
53
+     *
54
+     * @param: @param obj
55
+     * @param: @return
56
+     * @author zj
57
+     */
58
+    public static boolean isEmpty(Object obj) {
59
+        if (null == obj || "".equals(obj.toString().trim()) || "null".equals(obj.toString().trim())) {
60
+            return true;
61
+        } else {
62
+            return false;
63
+        }
64
+    }
65
+
66
+    /**
67
+     * json字符串是否不为空
68
+     * @Param [jsonStr]
69
+     * @Author ywx
70
+     * @Date 2020/5/13 16:06
71
+     * @return boolean
72
+     **/
73
+    public static boolean isJsonStrNotEmpty(String jsonStr) {
74
+        if (isNotEmpty(jsonStr) && !jsonStr.equals("[]")){
75
+            return true;
76
+        } else {
77
+            return false;
78
+        }
79
+    }
80
+
81
+
82
+    /**
83
+     * 功能描述  integer 是否是有效的类型
84
+     *
85
+     * @param * @param obj
86
+     * @return boolean
87
+     * @author WN
88
+     * @date 2019/7/15
89
+     */
90
+    public static boolean isTrueInteger(Integer obj) {
91
+        if (null != obj && obj > 0) {
92
+            return true;
93
+        } else {
94
+            return false;
95
+        }
96
+    }
97
+
98
+    /**
99
+     * 获取当前时间精确到秒的时间戳
100
+     *
101
+     * @param @return 设定文件
102
+     * @return int    返回类型
103
+     * @Title: getSecondTimestamp
104
+     * @author WN
105
+     * @date 2019年3月6日 下午10:13:50
106
+     */
107
+    public static int getSecondTimestamp(){
108
+        String timestamp = String.valueOf(System.currentTimeMillis()/1000);
109
+        return Integer.valueOf(timestamp);
110
+    }
111
+
112
+    public static String getStrtimeTimestamp(Integer seconds,String format){
113
+        if(seconds == null || seconds==0){
114
+            return "";
115
+        }
116
+        if(format == null || format.isEmpty()){
117
+            format = "yyyy-MM-dd HH:mm:ss";
118
+        }
119
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
120
+        return sdf.format(new Date(Long.valueOf(seconds+"000")));
121
+    }
122
+
123
+    //计算两个时间戳相差的天数
124
+    public static Integer getTimestampDay(Integer begintime,Integer endtime){
125
+        Integer day = 0;
126
+
127
+        Integer cha = endtime - begintime;
128
+        day = cha / (3600 * 24);
129
+
130
+        return day;
131
+    }
132
+
133
+    /**
134
+     * 字符串转数字
135
+     * @Param [str]
136
+     * @Author ywx
137
+     * @Date 2020/6/3 17:01
138
+     * @return java.lang.Integer
139
+     **/
140
+    public static Integer str2Int(String str){
141
+        if (isNotEmpty(str)){
142
+            return Integer.parseInt(str);
143
+        } else {
144
+            return 0;
145
+        }
146
+    }
147
+
148
+    /**
149
+     * 日期转时间戳(秒)
150
+     * @Param [data, strType]
151
+     * @Author ywx
152
+     * @Date 2020/6/4 17:47
153
+     * @return int
154
+     **/
155
+    public static int getDataToTimestamp(String data,String strType) {
156
+        try {
157
+            SimpleDateFormat format =  new SimpleDateFormat(strType);
158
+            Date date = format.parse(data);
159
+            //日期转时间戳(毫秒)
160
+            return Integer.valueOf((date.getTime()/1000)+"");
161
+        } catch (ParseException e) {
162
+            log.error("日期转时间戳失败",e.getMessage());
163
+            return 0;
164
+        }
165
+    }
166
+
167
+    /**
168
+     * 判断集合中数据同一个位置是否相同
169
+     *
170
+     * @param @param  oldlst
171
+     * @param @param  newlst
172
+     * @param @return 设定文件
173
+     * @return boolean    返回类型
174
+     * @Title: listNeworder
175
+     * @author WN
176
+     * @date 2018年8月2日 下午6:02:59
177
+     */
178
+    public static boolean listNeworder(List<Integer> oldlst, List<Integer> newlst) {
179
+        for (int i = 0; i < oldlst.size(); i++) {
180
+            int oldid = oldlst.get(i);
181
+            int newid = newlst.get(i);
182
+            if (oldid == newid) {
183
+                return true;
184
+            }
185
+        }
186
+        return false;
187
+    }
188
+
189
+    /**
190
+     * 将一个list均分成n个list,主要通过偏移量来实现的
191
+     * @param source
192
+     * @return
193
+     */
194
+    public static List<List<Integer>> averageAssignList(List<Integer> source,int n){
195
+        List<List<Integer>> result=new ArrayList<List<Integer>>();
196
+        int remaider=source.size()%n;  //(先计算出余数)
197
+        int number=source.size()/n;  //然后是商
198
+        int offset=0;//偏移量
199
+        for(int i=0;i<n;i++){
200
+            List<Integer> value=null;
201
+            if(remaider>0){
202
+                value=source.subList(i*number+offset, (i+1)*number+offset+1);
203
+                remaider--;
204
+                offset++;
205
+            }else{
206
+                value=source.subList(i*number+offset, (i+1)*number+offset);
207
+            }
208
+            result.add(value);
209
+        }
210
+        return result;
211
+    }
212
+
213
+    /**
214
+     * 判断集合是否不为空
215
+     * @Param [list]
216
+     * @Author ywx
217
+     * @Date 2020/6/15 10:50
218
+     * @return boolean
219
+     **/
220
+    public static boolean isListNotEmpty(List list) {
221
+        if (CollectionUtils.isEmpty(list)){
222
+            return false;
223
+        } else {
224
+            return true;
225
+        }
226
+    }
227
+
228
+    /**
229
+     * 判断集合是否为空
230
+     * @Param [list]
231
+     * @Author ywx
232
+     * @Date 2020/7/14 8:48
233
+     * @return boolean
234
+     **/
235
+    public static boolean isListEmpty(List list) {
236
+        if (CollectionUtils.isEmpty(list)){
237
+            return true;
238
+        } else {
239
+            return false;
240
+        }
241
+    }
242
+
243
+    //获取当前日期的节点时间(年,月,日,时,分,秒)
244
+    public static Integer getNodeDateTime(String node) {
245
+        LocalDateTime today = LocalDateTime.now();
246
+        Integer resultNode = null;
247
+        switch (node) {
248
+            case "year":
249
+                resultNode = today.getYear();
250
+                break;
251
+            case "month":
252
+                resultNode = today.getMonthValue();
253
+                break;
254
+            case "day":
255
+                resultNode = today.getDayOfMonth();
256
+                break;
257
+            case "hour":
258
+                resultNode = today.getHour();
259
+                break;
260
+            case "minute":
261
+                resultNode = today.getMinute();
262
+                break;
263
+            case "second":
264
+                resultNode = today.getSecond();
265
+                break;
266
+            default:
267
+                // 当前日期是当前年的第几天。例如:2019/1/3是2019年的第三天
268
+                resultNode = today.getDayOfYear();
269
+                break;
270
+        }
271
+        return resultNode;
272
+    }
273
+
274
+    /**
275
+     * 数字转字母 1-26 : A-Z
276
+     * @param num
277
+     * @return
278
+     */
279
+    public static String numberToLetter(int num) {
280
+        if (num <= 0) {
281
+            return null;
282
+        }
283
+        String letter = "";
284
+        num--;
285
+        do {
286
+            if (letter.length() > 0) {
287
+                num--;
288
+            }
289
+            letter = ((char) (num % 26 + (int) 'A')) + letter;
290
+            num = (int) ((num - num % 26) / 26);
291
+        } while (num > 0);
292
+
293
+        return letter;
294
+    }
295
+
296
+    /**
297
+     * 获取指定个数的英文字母数组
298
+     * @Param [num]
299
+     * @Author ywx
300
+     * @Date 2019/11/25 17:06
301
+     * @return java.lang.String[]
302
+     **/
303
+    public static String[] getLetter(Integer num){
304
+        String[] sections = new String[num];
305
+        if(num!=null && num>0){
306
+            for(int i=1;i<=num;i++){
307
+                sections[i-1] = numberToLetter(i);
308
+            }
309
+        }
310
+        return sections;
311
+    }
312
+
313
+    /**
314
+     * 集合1不包含在集合2中的数字集合
315
+     * @Param [nums1, nums2]
316
+     * @Author ywx
317
+     * @Date 2020/7/8 13:01
318
+     * @return java.util.List<java.lang.Integer>
319
+     **/
320
+    public static String listNotInList2(List<String> nums1,List<String> nums2){
321
+        List<String> nums = new ArrayList<>();
322
+        for (String num : nums1) {
323
+            if (!nums2.contains(num)){
324
+                nums.add(num);
325
+            }
326
+        }
327
+
328
+        return String.join(",",nums);
329
+    }
330
+
331
+    /**
332
+     * 集合1不包含在集合2中的数字集合
333
+     * @Param [nums1, nums2]
334
+     * @Author ywx
335
+     * @Date 2021/3/24 15:42
336
+     * @return java.util.List<java.lang.String>
337
+     **/
338
+    public static List<String> listNotInList3(List<String> nums1,List<String> nums2){
339
+        List<String> nums = new ArrayList<>();
340
+        for (String num : nums1) {
341
+            if (!nums2.contains(num)){
342
+                nums.add(num);
343
+            }
344
+        }
345
+        return nums;
346
+    }
347
+
348
+    /**
349
+     * 数字是否包含在集合中的数字集合
350
+     * @Param [num, nums]
351
+     * @Author ywx
352
+     * @Date 2020/7/14 11:18
353
+     * @return boolean
354
+     **/
355
+    public static boolean numInList(Integer num,List<Integer> nums){
356
+        if (isListEmpty(nums)) return false;
357
+        if (nums.contains(new Integer(num))){
358
+            return true;
359
+        } else {
360
+            return false;
361
+        }
362
+    }
363
+
364
+    /**
365
+     * 集合去重
366
+     * @Param [list]
367
+     * @Author ywx
368
+     * @Date 2020/7/11 9:59
369
+     * @return java.util.List
370
+     **/
371
+    public static List listDistinct(List<?> list){
372
+        return list.stream().distinct().collect(Collectors.toList());
373
+    }
374
+
375
+    /**
376
+     * 功能描述  判断integer类型不为null和0
377
+     *
378
+     * @param * @param strint
379
+     * @return boolean
380
+     * @author WN
381
+     * @date 2019/10/15
382
+     */
383
+    public static boolean isEmptyInteger(Integer strint) {
384
+        if (null != strint && strint != 0) {
385
+            return false;
386
+        } else {
387
+            return true;
388
+        }
389
+    }
390
+
391
+    /**
392
+     * 去除字符串中前后的全、半角空格
393
+     * @Param [str]
394
+     * @Author ywx
395
+     * @Date 2020/4/1 9:57
396
+     * @return java.lang.String
397
+     **/
398
+    public static String strTrim(String str) {
399
+        str = str.trim();//去除字符串前后的半角空格
400
+        while (str.startsWith(" ")) {//去除字符串前的全角空格
401
+            str = str.substring(1, str.length()).trim();
402
+        }
403
+        while (str.endsWith(" ")) {//去除字符串后的全角空格
404
+            str = str.substring(0, str.length() - 1).trim();
405
+        }
406
+        return str;
407
+    }
408
+
409
+
410
+
411
+    /**
412
+     * 验证手机号
413
+     * @param phone
414
+     * @return
415
+     */
416
+    public static boolean isPhone(String phone) {
417
+        //String regex = "^((13[0-9])|(14[5,6,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[8|9]))\\d{8}$";
418
+        String regex = "^1\\d{10}$";
419
+        if (phone == null) {
420
+            return false;
421
+        } else {
422
+            Pattern p = Pattern.compile(regex);
423
+            Matcher m = p.matcher(phone);
424
+            boolean isMatch = m.matches();
425
+            return isMatch;
426
+        }
427
+
428
+    }
429
+
430
+    /**
431
+     * 参数校验,为空的话提示定义的提示信息
432
+     * @Param [strs] strs={"filename","msg","type","filename2","msg2","type2"}
433
+     * @Author ywx
434
+     * @Date 2020/4/26 15:08
435
+     * @return void
436
+     **/
437
+    public static void validation(Object[] strs) {
438
+        for (int i = 0; i < strs.length; i+=3) {
439
+            Object filename = strs[i];
440
+            String msg = strs[i+1].toString()+"不能为空";
441
+            Integer type = Integer.parseInt(strs[i+2].toString());
442
+            if(type == 1){//Integer类型参数
443
+                if (!N_Utils.isNotEmpty(filename) || filename.equals(0)) {
444
+                    throw new MissingParametersException(msg);
445
+                }
446
+            } else {//String类型参数
447
+                if (!N_Utils.isNotEmpty(filename)) {
448
+                    throw new MissingParametersException(msg);
449
+                }
450
+            }
451
+        }
452
+    }
453
+
454
+
455
+    /**
456
+     *功能描述  获取当前年月日的时间戳
457
+     * @author WN
458
+     * @date 2020/8/9
459
+     * @param  * @param
460
+     * @return java.lang.Long
461
+     */
462
+    public static Long getNowtimestamp(){
463
+        LocalDate localDate = LocalDate.now();
464
+
465
+        ZoneId zone = ZoneId.systemDefault();
466
+        LocalDateTime ldt = localDate.atTime(23,59,59);
467
+        Instant instant = ldt.atZone(zone).toInstant();
468
+        Long stamp =instant.toEpochMilli()/1000;
469
+        return stamp;
470
+    }
471
+
472
+    public static Long getNowtimestamp2(){
473
+        LocalDate localDate = LocalDate.now();
474
+
475
+        ZoneId zone = ZoneId.systemDefault();
476
+        LocalDateTime ldt = localDate.atTime(00,00,00);
477
+        Instant instant = ldt.atZone(zone).toInstant();
478
+        Long stamp =instant.toEpochMilli()/1000;
479
+        return stamp;
480
+    }
481
+
482
+    /**
483
+     *功能描述  根据当前时间获取指定日期的时间戳
484
+     * @author WN
485
+     * @date 2020/8/9
486
+     * @param  * @param type
487
+     * @return java.lang.String
488
+     */
489
+    public static Long getLongGoTime(Integer type){
490
+        LocalDate localDate = LocalDate.now();
491
+        ZoneId zone = ZoneId.systemDefault();
492
+        Long stamp = null;
493
+
494
+        LocalDate godate = null;
495
+
496
+        if(type==1){
497
+            //过去一周
498
+            godate = localDate.minusWeeks(1);
499
+        }else if(type==2){
500
+            //过去一月
501
+            godate = localDate.minusMonths(1);
502
+        }else if(type==3){
503
+            //过去三个月
504
+            godate = localDate.minusMonths(3);
505
+        }else if(type==4){
506
+            //过去六个月
507
+            godate = localDate.minusMonths(6);
508
+
509
+        }else{
510
+            //过去一年
511
+            godate = localDate.minusYears(1);
512
+        }
513
+        stamp = godate.atStartOfDay(zone).toInstant().toEpochMilli()/1000;
514
+
515
+
516
+        return stamp;
517
+    }
518
+
519
+    /**
520
+     * @author ywx
521
+     * @description 去除a标签
522
+     * @date 2020/8/26 20:30
523
+     **/
524
+    public static String delATag(String str){
525
+        if (isEmpty(str)){
526
+            return null;
527
+        } else {
528
+            return str.replaceAll("<a[^>]*>|</a>","");
529
+        }
530
+    }
531
+
532
+
533
+    /**
534
+     *功能描述 两个数相除并乘以100.保留2位小数
535
+     * @author WN
536
+     * @date 2020/8/8
537
+     * @param  * @param linecount
538
+     * @param studentnum
539
+     * @return java.math.BigDecimal
540
+     */
541
+    public static double getIntegerDivideAndMulitiply(Integer linecount, Integer studentnum){
542
+        if (isEmptyInteger(studentnum)) {
543
+            return 0;
544
+        }
545
+        BigDecimal b1 = new BigDecimal(linecount.toString());
546
+        BigDecimal b2 = new BigDecimal(studentnum.toString());
547
+        BigDecimal b = new BigDecimal(100);
548
+
549
+        BigDecimal count = b1.divide(b2,4,BigDecimal.ROUND_DOWN).multiply(b);
550
+        return count.doubleValue();
551
+    }
552
+
553
+    //两个数相除并乘以100.保留2位小数
554
+    public static double getDoubleDivideAndMulitiply(Double linecount, Double studentnum){
555
+        if (studentnum.compareTo(new Double(0)) == 0) {
556
+            return 0;
557
+        }
558
+        BigDecimal b1 = new BigDecimal(linecount.toString());
559
+        BigDecimal b2 = new BigDecimal(studentnum.toString());
560
+        BigDecimal b = new BigDecimal(100);
561
+
562
+        BigDecimal count = b1.divide(b2,4,BigDecimal.ROUND_DOWN).multiply(b);
563
+        return count.doubleValue();
564
+    }
565
+
566
+    //两个数相除并乘以100.保留2位小数
567
+    public static double getDoubleDivideAndMulitiply(Double linecount, Integer studentnum){
568
+        if (isEmptyInteger(studentnum)) {
569
+            return 0;
570
+        }
571
+        BigDecimal b1 = new BigDecimal(linecount.toString());
572
+        BigDecimal b2 = new BigDecimal(studentnum.toString());
573
+        BigDecimal b = new BigDecimal(100);
574
+
575
+        BigDecimal count = b1.divide(b2,4,BigDecimal.ROUND_DOWN).multiply(b);
576
+        return count.doubleValue();
577
+    }
578
+
579
+    //计算比例向下取整
580
+    public static Integer floorDiv(Integer num,Integer totalNum) {
581
+        if (isEmptyInteger(totalNum)) return 0;
582
+        return Math.floorDiv(num * 100, totalNum);
583
+    }
584
+
585
+    /**
586
+     * 格式化百分比
587
+     * @Param [num, totalNum]
588
+     * @Author ywx
589
+     * @Date 2020/9/22 10:26
590
+     * @return java.lang.Integer
591
+     **/
592
+    public static Integer formatProportion(Integer num,Integer totalNum){
593
+        if (isEmptyInteger(totalNum)) return 0;
594
+        BigDecimal countBigDecimal = new BigDecimal(num);
595
+        BigDecimal totalCountBigDecimal = new BigDecimal(totalNum);
596
+        BigDecimal divide = countBigDecimal.divide(totalCountBigDecimal, 20, BigDecimal.ROUND_HALF_UP);
597
+        divide=divide.setScale(2,BigDecimal.ROUND_HALF_UP);
598
+        return divide.multiply(new BigDecimal("100")).intValue();
599
+    }
600
+
601
+    public static Integer formatAvg(Integer num,Integer totalNum){
602
+        if (isEmptyInteger(totalNum)) return 0;
603
+        BigDecimal countBigDecimal = new BigDecimal(num);
604
+        BigDecimal totalCountBigDecimal = new BigDecimal(totalNum);
605
+        BigDecimal divide = countBigDecimal.divide(totalCountBigDecimal, 0, BigDecimal.ROUND_UP);
606
+        return divide.intValue();
607
+    }
608
+
609
+    /**
610
+     * 格式化数值
611
+     * @Param [num数值, decimalNum保留小数位数]
612
+     * @Author ywx
613
+     * @Date 2021/5/28 9:57
614
+     * @return java.lang.Double
615
+     **/
616
+    public static Double formatDouble(Double num,Integer decimalNum){
617
+        BigDecimal bg = new BigDecimal(num);
618
+        double num2 = bg.setScale(decimalNum, BigDecimal.ROUND_DOWN).doubleValue();
619
+        return num2;
620
+    }
621
+
622
+    /**
623
+     * 格式化百分比
624
+     * @Param [arr]
625
+     * @Author ywx
626
+     * @Date 2020/10/12 11:58
627
+     * @return double[]
628
+     **/
629
+    public static double[] getPercentValue(int[] arr){
630
+        //求和
631
+        double sum = 0;
632
+        if(sum <= 0){
633
+            for (int i = 0; i < arr.length; i++) {
634
+                sum += arr[i];
635
+            }
636
+        }
637
+        //10的2次幂是100,用于计算精度。
638
+        double digits = 1;
639
+        //扩大比例100
640
+        double[] votesPerQuota = new double[arr.length];
641
+        for(int i = 0; i < arr.length; i++){
642
+            double val = arr[i] / sum * digits * 100;
643
+            votesPerQuota[i] = val;
644
+        }
645
+        //总数,扩大比例意味的总数要扩大
646
+        double targetSeats = digits * 100;
647
+        //再向下取值,组成数组
648
+        double[] seats = new double[arr.length];
649
+        for(int i = 0; i < votesPerQuota.length; i++){
650
+            seats[i] = Math.floor(votesPerQuota[i]);
651
+        }
652
+        //再新计算合计,用于判断与总数量是否相同,相同则占比会100%
653
+        double currentSum = 0;
654
+        for (int i = 0; i < seats.length; i++) {
655
+            currentSum += seats[i];
656
+        }
657
+        //余数部分的数组:原先数组减去向下取值的数组,得到余数部分的数组
658
+        double[] remainder = new double[arr.length];
659
+        for(int i = 0; i < seats.length; i++){
660
+            remainder[i] = votesPerQuota[i] - seats[i];
661
+        }
662
+        while(currentSum < targetSeats){
663
+            double max = 0;
664
+            int maxId = 0;
665
+            for(int i = 0;i < remainder.length;++i){
666
+                if(remainder[i] > max){
667
+                    max = remainder[i];
668
+                    maxId = i;
669
+                }
670
+            }
671
+            //对最大项余额加1
672
+            ++seats[maxId];
673
+            //已经增加最大余数加1,则下次判断就可以不需要再判断这个余额数。
674
+            remainder[maxId] = 0;
675
+            //总的也要加1,为了判断是否总数是否相同,跳出循环。
676
+            ++currentSum;
677
+        }
678
+        // 这时候的seats就会总数占比会100%
679
+        return seats;
680
+    }
681
+
682
+    /**
683
+     *功能描述 字符串是否包含中文
684
+     * @author WN
685
+     * @date 2020/11/21
686
+     * @param  * @param str 待校验字符串
687
+     * @return true 包含中文字符 false 不包含中文字符
688
+     */
689
+    public static boolean isContainChinese(String str){
690
+        Pattern p = Pattern.compile("[\u4E00-\u9FA5|\\!|\\,|\\。|\\(|\\)|\\《|\\》|\\“|\\”|\\?|\\:|\\;|\\【|\\】]");
691
+        Matcher m = p.matcher(str);
692
+        if(m.find()){
693
+            return true;
694
+        }
695
+        return false;
696
+
697
+    }
698
+
699
+
700
+    /**
701
+     * 随机生成4位随机码
702
+     * @Param []
703
+     * @Author ywx
704
+     * @Date 2020/5/8 9:29
705
+     * @return java.lang.Integer
706
+     **/
707
+    public static Integer messageCode(){
708
+        return (int) ((Math.random()*9+1)*1000);
709
+    }
710
+
711
+    /**
712
+     * 向指定 URL 发送POST方法的请求
713
+     * @param url   发送请求的 URL
714
+     * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
715
+     * @return 所代表远程资源的响应结果
716
+     */
717
+    public static String sendPost(String url, String param) {
718
+        OutputStreamWriter out = null;
719
+        BufferedReader in = null;
720
+        String result = "";
721
+        try {
722
+            URL realUrl = new URL(url);
723
+            // 打开和URL之间的连接
724
+            URLConnection conn = realUrl.openConnection();
725
+            // 设置通用的请求属性
726
+            conn.setRequestProperty("accept", "application/x-www-form-urlencoded");
727
+            conn.setRequestProperty("connection", "Keep-Alive");
728
+            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
729
+            // 发送POST请求必须设置如下两行
730
+            conn.setDoOutput(true);
731
+            conn.setDoInput(true);
732
+            //设置请求编码格式
733
+            conn.setRequestProperty("Accept-Charset", "UTF-8");
734
+            // 文件流编码设置
735
+            out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
736
+            out.write(param);
737
+            // flush输出流的缓冲
738
+            out.flush();
739
+            // 定义BufferedReader输入流来读取URL的响应
740
+            in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
741
+            String line;
742
+            while ((line = in.readLine()) != null) {
743
+                result += line;
744
+            }
745
+        } catch (Exception e) {
746
+            log.error("发送 POST 请求出现异常!" + e.getMessage());
747
+        }
748
+        // 使用finally块来关闭输出流、输入流
749
+        finally {
750
+            try {
751
+                if (out != null) {
752
+                    out.close();
753
+                }
754
+                if (in != null) {
755
+                    in.close();
756
+                }
757
+            } catch (IOException ex) {
758
+                log.error("关闭输入输出流异常", ex.getMessage());
759
+            }
760
+        }
761
+        return result;
762
+    }
763
+
764
+    /**
765
+     * 向指定 URL 发送POST方法的请求
766
+     * @Param [url, param]
767
+     * @Author ywx
768
+     * @Date 2021/5/6 16:01
769
+     * @return java.lang.String
770
+     **/
771
+    public static String sendJsonPost(String url, String param) {
772
+        OutputStreamWriter out = null;
773
+        BufferedReader in = null;
774
+        String result = "";
775
+        try {
776
+            URL realUrl = new URL(url);
777
+            // 打开和URL之间的连接
778
+            URLConnection conn = realUrl.openConnection();
779
+            // 设置通用的请求属性
780
+            conn.setRequestProperty("accept", "application/json");
781
+            conn.setRequestProperty("Content-Type","application/json;charset=UTF-8");
782
+            conn.setRequestProperty("connection", "Keep-Alive");
783
+            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
784
+            // 发送POST请求必须设置如下两行
785
+            conn.setDoOutput(true);
786
+            conn.setDoInput(true);
787
+            //设置请求编码格式
788
+            conn.setRequestProperty("Accept-Charset", "UTF-8");
789
+            // 文件流编码设置
790
+            out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
791
+            out.write(param);
792
+            // flush输出流的缓冲
793
+            out.flush();
794
+            // 定义BufferedReader输入流来读取URL的响应
795
+            in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
796
+            String line;
797
+            while ((line = in.readLine()) != null) {
798
+                result += line;
799
+            }
800
+        } catch (Exception e) {
801
+            System.out.println("发送 POST 请求出现异常!" + e.getMessage());
802
+        }
803
+        // 使用finally块来关闭输出流、输入流
804
+        finally {
805
+            try {
806
+                if (out != null) {
807
+                    out.close();
808
+                }
809
+                if (in != null) {
810
+                    in.close();
811
+                }
812
+            } catch (IOException ex) {
813
+                System.out.println("关闭输入输出流异常" + ex.getMessage());
814
+            }
815
+        }
816
+        return result;
817
+    }
818
+
819
+    /**
820
+     * 发送form-data请求返回json结果
821
+     * @Param [apiUrl, param]
822
+     * @Author ywx
823
+     * @Date 2021/5/14 17:41
824
+     * @return java.lang.String
825
+     **/
826
+    /*public static String sendFormData(String apiUrl, MultiValueMap<String, String> param) {
827
+        try {
828
+            HttpHeaders headers = new HttpHeaders();
829
+            headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
830
+            List<MediaType> acceptableMediaTypes = new ArrayList<>();
831
+            acceptableMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED);
832
+            acceptableMediaTypes.add(MediaType.APPLICATION_PROBLEM_JSON_UTF8);
833
+            HttpEntity<MultiValueMap<String, String>> requestParams = new HttpEntity<>(param, headers);
834
+            ResponseEntity<String> response = new RestTemplate().postForEntity(apiUrl, requestParams, String.class);
835
+            String result = response.getBody();
836
+            return result;
837
+        } catch (RestClientException e) {
838
+            log.error("发送form-data请求失败",e.getMessage());
839
+            return null;
840
+        }
841
+    }*/
842
+
843
+    static String CHN_NUMBER[] = { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" };
844
+    static String CHN_UNIT[] = { "", "十", "百", "千" }; // 权位
845
+    static String CHN_UNIT_SECTION[] = { "", "万", "亿", "万亿" }; // 节权位
846
+
847
+    /**
848
+     * 阿拉伯数字转换为中文数字的核心算法实现。
849
+     * @return
850
+     */
851
+    public static String NumberToChn(int num) {
852
+        StringBuffer returnStr = new StringBuffer();
853
+        Boolean needZero = false;
854
+        int pos = 0; // 节权位的位置
855
+        if (num == 0) {
856
+            // 如果num为0,进行特殊处理。
857
+            returnStr.insert(0, CHN_NUMBER[0]);
858
+        }
859
+        while (num > 0) {
860
+            int section = num % 10000;
861
+            if (needZero) {
862
+                returnStr.insert(0, CHN_NUMBER[0]);
863
+            }
864
+            String sectionToChn = SectionNumToChn(section);
865
+            // 判断是否需要节权位
866
+            sectionToChn += (section != 0) ? CHN_UNIT_SECTION[pos] : CHN_UNIT_SECTION[0];
867
+            returnStr.insert(0, sectionToChn);
868
+            needZero = ((section < 1000 && section > 0) ? true : false); // 判断section中的千位上是不是为零,若为零应该添加一个零。
869
+            pos++;
870
+            num = num / 10000;
871
+        }
872
+        return returnStr.toString().replace("一十", "十");
873
+    }
874
+
875
+    /**
876
+     * 将四位的section转换为中文数字
877
+     *
878
+     * @param section
879
+     * @return
880
+     */
881
+    public static String SectionNumToChn(int section) {
882
+        StringBuffer returnStr = new StringBuffer();
883
+        int unitPos = 0; // 节权位的位置编号,0-3依次为个十百千;
884
+
885
+        Boolean zero = true;
886
+        while (section > 0) {
887
+
888
+            int v = (section % 10);
889
+            if (v == 0) {
890
+                if ((section == 0) || !zero) {
891
+                    zero = true; /* 需要补0,zero的作用是确保对连续的多个0,只补一个中文零 */
892
+                    // chnStr.insert(0, chnNumChar[v]);
893
+                    returnStr.insert(0, CHN_NUMBER[v]);
894
+                }
895
+            } else {
896
+                zero = false; // 至少有一个数字不是0
897
+                StringBuffer tempStr = new StringBuffer(CHN_NUMBER[v]);// 数字v所对应的中文数字
898
+                tempStr.append(CHN_UNIT[unitPos]); // 数字v所对应的中文权位
899
+                returnStr.insert(0, tempStr);
900
+            }
901
+            unitPos++; // 移位
902
+            section = section / 10;
903
+        }
904
+        return returnStr.toString();
905
+    }
906
+
907
+    /**
908
+     * 生成id
909
+     * @Param []
910
+     * @Author ywx
911
+     * @Date 2020/12/24 15:02
912
+     * @return java.lang.String
913
+     **/
914
+    public static String getId(Integer id,Integer nummin,Integer nummax,Integer numadd){
915
+        if (id == 0 || id.equals(nummax)) {
916
+            id = nummin;
917
+        } else {
918
+            id ++;
919
+        }
920
+        String _num = (getSecondTimestamp() + numadd) +"" + id;
921
+        long num = Long.parseLong(_num);
922
+        return Long.toString(num,36).toUpperCase();
923
+    }
924
+
925
+    /**
926
+     * 字符串是否包含在集合中的字符串集合
927
+     * @Param [num, nums]
928
+     * @Author ywx
929
+     * @Date 2020/12/24 14:10
930
+     * @return boolean
931
+     **/
932
+    public static boolean strInList(String num,List<String> nums){
933
+        if (nums.contains(num)){
934
+            return true;
935
+        } else {
936
+            return false;
937
+        }
938
+    }
939
+
940
+    //计算比例
941
+    public static String getFs(int a, int b){  // 设置分子和分母
942
+        int numerator;  // 分子
943
+        int denominator; // 分母
944
+        if(a == 0 || b == 0){
945
+            numerator = a;
946
+            denominator = b;
947
+        }else{
948
+            int c = f(Math.abs(a),Math.abs(b));         // 计算最大公约数
949
+            numerator = a / c;
950
+            denominator = b / c;
951
+            if(numerator<0 && denominator<0){
952
+                numerator = - numerator;
953
+                denominator = - denominator;
954
+            }
955
+        }
956
+        return numerator + ":" + denominator;
957
+    }
958
+
959
+    static int f(int a,int b){  // 求a和b的最大公约数
960
+        if(a < b){
961
+            int c = a;
962
+            a = b;
963
+            b = c;
964
+        }
965
+        int r = a % b;
966
+        while(r != 0){
967
+            a = b;
968
+            b = r;;
969
+            r = a % b;
970
+        }
971
+        return b;
972
+    }
973
+
974
+    //求一个数组的最大公约数
975
+    public static int getArrMaxGys(int nums[]){
976
+        int a=nums[0];int b=nums[1];int i=0;
977
+        int temp;
978
+        if(a<b){
979
+            temp=a;
980
+            a=b;
981
+            b=temp;
982
+            temp=a%b;
983
+            while(temp!=0){
984
+                a=b;
985
+                b=temp;
986
+                temp=a%b;
987
+            }
988
+            nums[i+1]=b;
989
+        }
990
+        return nums[nums.length-1];
991
+    }
992
+
993
+}

+ 19
- 0
scommons/src/main/java/com/xhkjedu/utils/PageUtil.java Dosyayı Görüntüle

@@ -0,0 +1,19 @@
1
+package com.xhkjedu.utils;
2
+
3
+import com.github.pagehelper.PageInfo;
4
+import com.xhkjedu.vo.PageResult;
5
+
6
+/**
7
+ * @author ywx
8
+ * @className PageUtil
9
+ * @description
10
+ * @date 2020/5/20 14:57
11
+ **/
12
+public class PageUtil {
13
+    public static PageResult getPageResult(PageInfo<?> pageInfo) {
14
+        PageResult pageResult = new PageResult();
15
+        pageResult.setTotal(pageInfo.getTotal());
16
+        pageResult.setList(pageInfo.getList());
17
+        return pageResult;
18
+    }
19
+}

+ 17
- 0
scommons/src/main/java/com/xhkjedu/vo/PageResult.java Dosyayı Görüntüle

@@ -0,0 +1,17 @@
1
+package com.xhkjedu.vo;
2
+
3
+import lombok.Data;
4
+
5
+import java.util.List;
6
+
7
+/**
8
+ * @author ywx
9
+ * @className PageResult
10
+ * @description 分页返回结果
11
+ * @date 2020/5/20 14:58
12
+ **/
13
+@Data
14
+public class PageResult {
15
+    private long total;//记录总数
16
+    private List<?> list;//数据模型
17
+}

+ 30
- 0
scommons/src/main/java/com/xhkjedu/vo/ResultVo.java Dosyayı Görüntüle

@@ -0,0 +1,30 @@
1
+package com.xhkjedu.vo;
2
+
3
+import lombok.AllArgsConstructor;
4
+import lombok.Data;
5
+import lombok.NoArgsConstructor;
6
+
7
+/**
8
+ * 返回值
9
+ *
10
+ * @author WN
11
+ * @Date 2018年3月28日 下午5:14:31
12
+ */
13
+@Data
14
+@AllArgsConstructor
15
+@NoArgsConstructor
16
+public class ResultVo {
17
+    private int code = 0;// 返回是否成功  0成功 1失败
18
+    private String msg = "";// 返回提示信息
19
+    private Object obj;// 返回对象或者对象列表
20
+
21
+    public ResultVo(int code, String msg) {
22
+        this.code = code;
23
+        this.msg = msg;
24
+    }
25
+
26
+    public ResultVo(Object obj, String msg) {
27
+        this.obj = obj;
28
+        this.msg = msg;
29
+    }
30
+}

Loading…
İptal
Kaydet