From 3d76350edd87d84910d57ca9591eabd0a094c369 Mon Sep 17 00:00:00 2001
From: baishou_zjx <2710684311@qq.com>
Date: Tue, 30 Jul 2019 17:14:08 +0800
Subject: [PATCH] robot inerface
---
springboot/morning-check/.gitignore | 31 +++++++++++++++++++++++++++++++
springboot/morning-check/.mvn/wrapper/MavenWrapperDownloader.java | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/.mvn/wrapper/maven-wrapper.jar | Bin 0 -> 48337 bytes
springboot/morning-check/.mvn/wrapper/maven-wrapper.properties | 1 +
springboot/morning-check/mvnw | 286 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/mvnw.cmd | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/pom.xml | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/MorningCheckApplication.java | 35 +++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/common/EhcacheUtil.java | 230 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/common/Encript.java | 45 +++++++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/common/ImgType.java | 31 +++++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/common/MD5.java | 40 ++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/common/ResponseCode.java | 29 +++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/common/ServerResponse.java | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/config/MessageProperties.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/config/Swagger2.java | 38 ++++++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/controller/MorningCheckController.java | 407 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/dao/StudentDao.java | 25 +++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/dao/UserDao.java | 22 ++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/model/FileEntity.java | 29 +++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/model/Photo.java | 9 +++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/model/School.java | 15 +++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/model/Student.java | 14 ++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/model/User.java | 13 +++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/platform/MorningCheckResult.java | 15 +++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/service/FileUpAndDownService.java | 10 ++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/service/StudentService.java | 15 +++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/service/UserServer.java | 15 +++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/FileUpAndDownServiceImpl.java | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/StudentServiceImpl.java | 34 ++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/UserServerImp.java | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/ApiHelper.java | 297 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/DataConvertHelper.java | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/FileUtils.java | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/LogUtil.java | 45 +++++++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/resources/application.properties | 14 ++++++++++++++
springboot/morning-check/src/main/resources/file-message.properties | 8 ++++++++
springboot/morning-check/src/main/resources/logback.xml | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/resources/mapper/studentmapper.xml | 47 +++++++++++++++++++++++++++++++++++++++++++++++
springboot/morning-check/src/main/resources/mapper/usermapper.xml | 34 ++++++++++++++++++++++++++++++++++
springboot/morning-check/src/test/java/com/sincere/morningcheck/MorningCheckApplicationTests.java | 16 ++++++++++++++++
springboot/morning-check/src/test/java/com/sincere/morningcheck/MorningCheckControllerApplicationTests.java | 16 ++++++++++++++++
42 files changed, 2882 insertions(+), 0 deletions(-)
create mode 100644 springboot/morning-check/.gitignore
create mode 100644 springboot/morning-check/.mvn/wrapper/MavenWrapperDownloader.java
create mode 100644 springboot/morning-check/.mvn/wrapper/maven-wrapper.jar
create mode 100644 springboot/morning-check/.mvn/wrapper/maven-wrapper.properties
create mode 100644 springboot/morning-check/mvnw
create mode 100644 springboot/morning-check/mvnw.cmd
create mode 100644 springboot/morning-check/pom.xml
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/MorningCheckApplication.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/common/EhcacheUtil.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/common/Encript.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/common/ImgType.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/common/MD5.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/common/ResponseCode.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/common/ServerResponse.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/config/MessageProperties.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/config/Swagger2.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/controller/MorningCheckController.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/dao/StudentDao.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/dao/UserDao.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/model/FileEntity.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/model/Photo.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/model/School.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/model/Student.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/model/User.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/platform/MorningCheckResult.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/service/FileUpAndDownService.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/service/StudentService.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/service/UserServer.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/FileUpAndDownServiceImpl.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/StudentServiceImpl.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/UserServerImp.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/ApiHelper.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/DataConvertHelper.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/FileUtils.java
create mode 100644 springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/LogUtil.java
create mode 100644 springboot/morning-check/src/main/resources/application.properties
create mode 100644 springboot/morning-check/src/main/resources/file-message.properties
create mode 100644 springboot/morning-check/src/main/resources/logback.xml
create mode 100644 springboot/morning-check/src/main/resources/mapper/studentmapper.xml
create mode 100644 springboot/morning-check/src/main/resources/mapper/usermapper.xml
create mode 100644 springboot/morning-check/src/test/java/com/sincere/morningcheck/MorningCheckApplicationTests.java
create mode 100644 springboot/morning-check/src/test/java/com/sincere/morningcheck/MorningCheckControllerApplicationTests.java
diff --git a/springboot/morning-check/.gitignore b/springboot/morning-check/.gitignore
new file mode 100644
index 0000000..a2a3040
--- /dev/null
+++ b/springboot/morning-check/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/springboot/morning-check/.mvn/wrapper/MavenWrapperDownloader.java b/springboot/morning-check/.mvn/wrapper/MavenWrapperDownloader.java
new file mode 100644
index 0000000..7f91a56
--- /dev/null
+++ b/springboot/morning-check/.mvn/wrapper/MavenWrapperDownloader.java
@@ -0,0 +1,114 @@
+/*
+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.
+*/
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
+import java.util.Properties;
+
+public class MavenWrapperDownloader {
+
+ /**
+ * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
+ */
+ private static final String DEFAULT_DOWNLOAD_URL =
+ "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
+
+ /**
+ * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
+ * use instead of the default one.
+ */
+ private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
+ ".mvn/wrapper/maven-wrapper.properties";
+
+ /**
+ * Path where the maven-wrapper.jar will be saved to.
+ */
+ private static final String MAVEN_WRAPPER_JAR_PATH =
+ ".mvn/wrapper/maven-wrapper.jar";
+
+ /**
+ * Name of the property which should be used to override the default download url for the wrapper.
+ */
+ private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
+
+ public static void main(String args[]) {
+ System.out.println("- Downloader started");
+ File baseDirectory = new File(args[0]);
+ System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
+
+ // If the maven-wrapper.properties exists, read it and check if it contains a custom
+ // wrapperUrl parameter.
+ File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
+ String url = DEFAULT_DOWNLOAD_URL;
+ if (mavenWrapperPropertyFile.exists()) {
+ FileInputStream mavenWrapperPropertyFileInputStream = null;
+ try {
+ mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
+ Properties mavenWrapperProperties = new Properties();
+ mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
+ url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
+ } catch (IOException e) {
+ System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
+ } finally {
+ try {
+ if (mavenWrapperPropertyFileInputStream != null) {
+ mavenWrapperPropertyFileInputStream.close();
+ }
+ } catch (IOException e) {
+ // Ignore ...
+ }
+ }
+ }
+ System.out.println("- Downloading from: : " + url);
+
+ File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
+ if (!outputFile.getParentFile().exists()) {
+ if (!outputFile.getParentFile().mkdirs()) {
+ System.out.println(
+ "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
+ }
+ }
+ System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
+ try {
+ downloadFileFromURL(url, outputFile);
+ System.out.println("Done");
+ System.exit(0);
+ } catch (Throwable e) {
+ System.out.println("- Error downloading");
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ private static void downloadFileFromURL(String urlString, File destination) throws Exception {
+ URL website = new URL(urlString);
+ ReadableByteChannel rbc;
+ rbc = Channels.newChannel(website.openStream());
+ FileOutputStream fos = new FileOutputStream(destination);
+ fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+ fos.close();
+ rbc.close();
+ }
+
+}
diff --git a/springboot/morning-check/.mvn/wrapper/maven-wrapper.jar b/springboot/morning-check/.mvn/wrapper/maven-wrapper.jar
new file mode 100644
index 0000000..01e6799
Binary files /dev/null and b/springboot/morning-check/.mvn/wrapper/maven-wrapper.jar differ
diff --git a/springboot/morning-check/.mvn/wrapper/maven-wrapper.properties b/springboot/morning-check/.mvn/wrapper/maven-wrapper.properties
new file mode 100644
index 0000000..cd0d451
--- /dev/null
+++ b/springboot/morning-check/.mvn/wrapper/maven-wrapper.properties
@@ -0,0 +1 @@
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
diff --git a/springboot/morning-check/mvnw b/springboot/morning-check/mvnw
new file mode 100644
index 0000000..8b9da3b
--- /dev/null
+++ b/springboot/morning-check/mvnw
@@ -0,0 +1,286 @@
+#!/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.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven2 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)`"
+ # TODO classpath?
+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
+ jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
+ 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 command -v wget > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found wget ... using wget"
+ fi
+ wget "$jarUrl" -O "$wrapperJarPath"
+ elif command -v curl > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found curl ... using curl"
+ fi
+ curl -o "$wrapperJarPath" "$jarUrl"
+ else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Falling back to using Java to download"
+ fi
+ javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+ 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
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+exec "$JAVACMD" \
+ $MAVEN_OPTS \
+ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/springboot/morning-check/mvnw.cmd b/springboot/morning-check/mvnw.cmd
new file mode 100644
index 0000000..fef5a8f
--- /dev/null
+++ b/springboot/morning-check/mvnw.cmd
@@ -0,0 +1,161 @@
+@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 Maven2 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 key stroke 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 my 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.4.2/maven-wrapper-0.4.2.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% (
+ echo Found %WRAPPER_JAR%
+) else (
+ echo Couldn't find %WRAPPER_JAR%, downloading it ...
+ echo Downloading from: %DOWNLOAD_URL%
+ powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
+ echo Finished downloading %WRAPPER_JAR%
+)
+@REM End of extension
+
+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%" == "on" pause
+
+if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
+
+exit /B %ERROR_CODE%
diff --git a/springboot/morning-check/pom.xml b/springboot/morning-check/pom.xml
new file mode 100644
index 0000000..a11ea48
--- /dev/null
+++ b/springboot/morning-check/pom.xml
@@ -0,0 +1,129 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.1.6.RELEASE
+
+
+ com.sincere
+ morning-check
+ 0.0.1-SNAPSHOT
+ Morning-Check
+ MorningCheckMachine project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.json
+ json
+ 20180813
+
+
+
+
+ io.springfox
+ springfox-swagger-ui
+ 2.9.2
+
+
+
+ io.springfox
+ springfox-swagger2
+ 2.9.2
+
+
+
+ org.apache.commons
+ commons-lang3
+
+
+
+
+ org.projectlombok
+ lombok
+ 1.16.18
+
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.3
+
+
+
+ org.apache.httpcomponents
+ httpmime
+ 4.5.6
+
+
+
+ com.alibaba
+ fastjson
+ 1.2.58
+
+
+
+ org.springframework.boot
+ spring-boot-starter-cache
+
+
+
+ net.sf.ehcache
+ ehcache
+
+
+
+
+ commons-fileupload
+ commons-fileupload
+ 1.3.1
+
+
+
+ net.coobird
+ thumbnailator
+ 0.4.8
+
+
+
+
+ com.microsoft.sqlserver
+ mssql-jdbc
+ runtime
+
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ 2.0.0
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/MorningCheckApplication.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/MorningCheckApplication.java
new file mode 100644
index 0000000..44871e9
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/MorningCheckApplication.java
@@ -0,0 +1,35 @@
+package com.sincere.morningcheck;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.web.multipart.MultipartResolver;
+import org.springframework.web.multipart.commons.CommonsMultipartResolver;
+
+//exclude表示自动配置时不包括Multipart配置
+//@EnableAutoConfiguration(exclude = {MultipartAutoConfiguration.class}),这样写法会有警告,改成下面的写法
+@SpringBootApplication(exclude = {MultipartAutoConfiguration.class})
+public class MorningCheckApplication {
+
+
+ public static void main(String[] args) {
+ SpringApplication.run(MorningCheckApplication.class, args);
+ }
+
+ /**
+ * 显示声明CommonsMultipartResolver为mutipartResolver
+ */
+ @Bean(name = "multipartResolver")
+ public MultipartResolver multipartResolver() {
+ CommonsMultipartResolver resolver = new CommonsMultipartResolver();
+ //resolver.setDefaultEncoding("UTF-8");
+ //resolveLazily属性启用是为了推迟文件解析,以在在UploadAction中捕获文件大小异常
+ resolver.setResolveLazily(true);
+ resolver.setMaxInMemorySize(40960);
+ resolver.setMaxUploadSize(50 * 1024 * 1024);//上传文件大小 50 10*1024*1024
+ return resolver;
+ }
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/EhcacheUtil.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/EhcacheUtil.java
new file mode 100644
index 0000000..4319692
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/EhcacheUtil.java
@@ -0,0 +1,230 @@
+package com.sincere.morningcheck.common;
+
+import com.alibaba.fastjson.JSON;
+import net.sf.ehcache.CacheException;
+import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.Ehcache;
+import net.sf.ehcache.Element;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class EhcacheUtil {
+
+ /**
+ * CacheManage是Ehcache框架的核心接口和类,负责管理一个或多个Cache对象
+ */
+ private static final CacheManager CACHE_MANAGER = createCacheManager();
+
+ /**
+ * 描 述: 根据ehcache.xml,创建CacheManager生产器
+ * 参 数:
+ * 返回值: net.sf.ehcache.CacheManager
+ * 创建时间: 2018/5/23
+ */
+ private static CacheManager createCacheManager() {
+ CacheManager cacheManager;
+ InputStream input = EhcacheUtil.class.getResourceAsStream("/ehcache.xml");
+
+ if (input != null) {
+ try {
+ cacheManager = CacheManager.create(input);
+ } catch (Throwable t) {
+ cacheManager = CacheManager.create();
+ } finally {
+ try {
+ input.close();
+ } catch (IOException e) {
+ }
+ }
+ } else {
+ cacheManager = CacheManager.create();
+ }
+
+ return cacheManager;
+ }
+
+ /**
+ * The cache id. 缓存所在的位置标识
+ */
+ private final String id;
+
+ /**
+ * 创建EhCache
+ */
+ public EhcacheUtil(){
+ this.id = this.getClass().getName();
+ if (!CACHE_MANAGER.cacheExists(this.id)) {
+ CACHE_MANAGER.addCache(this.id);
+ }
+ }
+
+ /**
+ * 得到当前缓存
+ * @return
+ */
+ private Ehcache getCache() {
+ return CACHE_MANAGER.getCache(this.id);
+ }
+
+ /**
+ * 写入EhCache,当前实例对象T,同时转成Json格式
+ * @param key
+ * @param value
+ * @param
+ */
+ public void set(String key, T value){
+ setObject(key, JSON.toJSONString(value));
+ }
+
+ /**
+ * 写入EhCache,字符串对象
+ * @param key
+ * @param value
+ */
+ public void set(String key, String value){
+ setObject(key,value);
+ }
+
+ /**
+ * 写入EhCache,当前实例对象T, 同时转成Json格式,并设置失效时间
+ * @param key
+ * @param value
+ * @param time
+ * @param
+ */
+ public void setex(String key, T value, int time){
+ setexObject(key, JSON.toJSONString(value),time);
+ }
+
+ /**
+ * 写入EhCache,字符串对象,并设置失效时间
+ * @param key
+ * @param value
+ * @param time
+ */
+ public void setex(String key, String value, int time){
+ setexObject(key,value,time);
+ }
+
+ /**
+ * 存入EhCache缓存
+ * @param key
+ * @param value
+ */
+ public void setObject(String key, Object value) {
+ try {
+ this.getCache().put(new Element(key, value));
+ } catch (Throwable t) {
+ throw new CacheException(t.getMessage(),t);
+ }
+ }
+
+ /**
+ * 存入EhCache缓存,并设置失效时间
+ * @param key
+ * @param value
+ * @param time
+ */
+ public void setexObject(String key, Object value, int time) {
+ Element element = new Element(key, value);
+ element.setTimeToLive(time);
+ try {
+ this.getCache().put(element);
+ } catch (Throwable t) {
+ throw new CacheException(t.getMessage(),t);
+ }
+ }
+
+ /**
+ * 获取EhCache对象,字符串对象
+ * @param key
+ * @return
+ */
+ public String get(String key){
+ Object value = getObject(key);
+ return value == null ? "" : value.toString();
+ }
+
+ /**
+ * 获取EhCache对象,当前实例对象T
+ * @param key
+ * @param clazz
+ * @param
+ * @return
+ */
+ public T get(String key, Class clazz){
+ Object obj = getObject(key);
+ if(obj == null){
+ return null;
+ }
+ return JSON.parseObject(getObject(key).toString(),clazz);
+ }
+
+ /**
+ * 根据Key获取缓存对象
+ * @param key
+ * @return
+ */
+ public Object getObject(String key) {
+ try {
+ Element cachedElement = this.getCache().get(key);
+ if (cachedElement == null) {
+ return null;
+ }
+ return cachedElement.getObjectValue();
+ } catch (Exception t) {
+ throw new CacheException(t.getMessage(),t);
+ }
+ }
+
+ /**
+ * 删除当前Cache的key
+ * @param key
+ */
+ public void remove(String key) {
+ try {
+ this.getCache().remove(key);
+ } catch (Throwable t) {
+ throw new CacheException(t.getMessage(),t);
+ }
+ }
+
+ /**
+ * 获取当前Cache的数目
+ * @return
+ */
+ public Long dbSize() {
+ try {
+ return Long.valueOf(this.getCache().getSize());
+ } catch (Throwable t) {
+ throw new CacheException(t.getMessage(),t);
+ }
+ }
+
+ /**
+ * 清空当前Cache的所有缓存
+ */
+ public void flushDB() {
+ this.getCache().removeAll();
+ }
+
+
+ /**
+ * 重写hashCode
+ * @return
+ */
+ @Override
+ public int hashCode() {
+ return this.id.hashCode();
+ }
+
+ /**
+ * 重写toString
+ * @return
+ */
+ @Override
+ public String toString() {
+ return "EHCache {" + this.id + "}";
+ }
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/Encript.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/Encript.java
new file mode 100644
index 0000000..da880c7
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/Encript.java
@@ -0,0 +1,45 @@
+package com.sincere.morningcheck.common;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+
+public class Encript {
+
+ /**
+ * 将加密后的字节数组转换成字符串(原始64位)
+ *
+ * @param b 字节数组
+ * @return 字符串
+ */
+ public static String byteArrayToHexString(byte[] b) {
+ StringBuilder hs = new StringBuilder();
+ String stmp;
+ for (int n = 0; b!=null && n < b.length; n++) {
+ stmp = Integer.toHexString(b[n] & 0XFF);
+ if (stmp.length() == 1)
+ hs.append('0');
+ hs.append(stmp);
+ }
+ return hs.toString().toLowerCase();
+ }
+
+ /**
+ * sha256_HMAC加密
+ * @param message 消息
+ * @param secret 秘钥
+ * @return 加密后字符串
+ * */
+ public static String sha256_HMAC(String message, String secret) {
+ String hash = "";
+ try {
+ Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
+ SecretKeySpec secret_key = new SecretKeySpec(secret.getBytes(), "HmacSHA256");
+ sha256_HMAC.init(secret_key);
+ byte[] bytes = sha256_HMAC.doFinal(message.getBytes());
+ hash = byteArrayToHexString(bytes);
+ } catch (Exception e) {
+ System.out.println("Error HmacSHA256 ===========" + e.getMessage());
+ }
+ return hash;
+ }
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/ImgType.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/ImgType.java
new file mode 100644
index 0000000..08e11d8
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/ImgType.java
@@ -0,0 +1,31 @@
+package com.sincere.morningcheck.common;
+
+public enum ImgType {
+
+ // hand
+ // 口部图片类型名:mouth
+ // 眼部图片类型名: face
+ // 接送图片类型名: card
+
+ hand(0,"hand"),
+ mouth(1,"mouth"),
+ face(2,"face"),
+ card(3,"card");
+
+ private final int type;
+ private final String value;
+
+
+ ImgType(int type, String value) {
+ this.type = type;
+ this.value = value;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/MD5.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/MD5.java
new file mode 100644
index 0000000..f70a353
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/MD5.java
@@ -0,0 +1,40 @@
+package com.sincere.morningcheck.common;
+
+import org.apache.commons.codec.digest.DigestUtils;
+
+public class MD5 {
+
+ /**
+ * MD5方法
+ *
+ * @param text 明文
+ * @param key 密钥
+ * @return 密文
+ * @throws Exception
+ */
+ public static String md5(String text, String key) throws Exception {
+ //加密后的字符串
+ String encodeStr= DigestUtils.md5Hex(text + key);
+ return encodeStr;
+ }
+
+ /**
+ * MD5验证方法
+ *
+ * @param text 明文
+ * @param key 密钥
+ * @param md5 密文
+ * @return true/false
+ * @throws Exception
+ */
+ public static boolean verify(String text, String key, String md5) throws Exception {
+ //根据传入的密钥进行验证
+ String md5Text = md5(text, key);
+ if(md5Text.equalsIgnoreCase(md5))
+ {
+ return true;
+ }
+
+ return false;
+ }
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/ResponseCode.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/ResponseCode.java
new file mode 100644
index 0000000..74599a2
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/ResponseCode.java
@@ -0,0 +1,29 @@
+package com.sincere.morningcheck.common;
+
+/**
+ * Created by Ziv
+ */
+public enum ResponseCode {
+
+ SUCCESS(1, "SUCCESS"),
+ ERROR(0, "ERROR");
+
+
+ private final int code;
+ private final String desc;
+
+
+ ResponseCode(int code, String desc) {
+ this.code = code;
+ this.desc = desc;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public String getDesc() {
+ return desc;
+ }
+
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/ServerResponse.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/ServerResponse.java
new file mode 100644
index 0000000..8e3ba80
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/common/ServerResponse.java
@@ -0,0 +1,105 @@
+package com.sincere.morningcheck.common;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+
+import java.io.Serializable;
+
+/**
+ * Created by Ziv
+ */
+@JsonInclude(JsonInclude.Include.NON_EMPTY)
+
+public class ServerResponse implements Serializable {
+
+ /**
+ * 操作状态码
+ */
+ private int code;
+ /**
+ * 状态信息
+ */
+ private String message;
+ /**
+ * 返回的数据包
+ */
+ private T data;
+
+ private ServerResponse(int code) {
+ this.code = code;
+ }
+
+ private ServerResponse(int code, T data) {
+ this.code = code;
+ this.data = data;
+ }
+
+
+ private ServerResponse(int code, String message, T data) {
+ this.code = code;
+ this.message = message;
+ this.data = data;
+ }
+ private ServerResponse(int code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ @JsonIgnore
+ //使之不在json序列化结果当中
+ public boolean isSuccess() {
+ return this.code == ResponseCode.SUCCESS.getCode();
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public T getData() {
+ return data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+
+ public static ServerResponse createBySuccess() {
+ return new ServerResponse(ResponseCode.SUCCESS.getCode());
+ }
+
+ /*
+ 该方法对应的是private ServerResponse(int code,String msg)的构造方法
+ */
+ public static ServerResponse createBySuccessMessage(String message) {
+ return new ServerResponse(ResponseCode.SUCCESS.getCode(), message);
+ }
+
+ /*
+ 该方法对应的是private ServerResponse(int code,T data)构造方法
+ */
+ public static ServerResponse createBySuccess(T data) {
+ return new ServerResponse(ResponseCode.SUCCESS.getCode(), data);
+ }
+
+ public static ServerResponse createBySuccess(String message, T data) {
+ return new ServerResponse(ResponseCode.SUCCESS.getCode(), message, data);
+ }
+
+
+
+ public static ServerResponse createByError() {
+ return new ServerResponse(ResponseCode.ERROR.getCode(), ResponseCode.ERROR.getDesc());
+ }
+
+
+ public static ServerResponse createByErrorMessage(String errorMessage) {
+ return new ServerResponse(ResponseCode.ERROR.getCode(), errorMessage);
+ }
+
+ public static ServerResponse createByErrorCodeMessage(int errorCode, String errorMessage) {
+ return new ServerResponse(errorCode, errorMessage);
+ }
+
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/config/MessageProperties.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/config/MessageProperties.java
new file mode 100644
index 0000000..9a38081
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/config/MessageProperties.java
@@ -0,0 +1,52 @@
+package com.sincere.morningcheck.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix="message")
+@PropertySource("classpath:file-message.properties")
+public class MessageProperties {
+
+ private long fileSize; //压缩大小
+
+ private double scaleRatio; //压缩比例
+
+ private String upPath; //保存路径
+
+ private String imageType; //图片类型
+
+ public long getFileSize() {
+ return fileSize;
+ }
+
+ public void setFileSize(long fileSize) {
+ this.fileSize = fileSize;
+ }
+
+ public double getScaleRatio() {
+ return scaleRatio;
+ }
+
+ public void setScaleRatio(double scaleRatio) {
+ this.scaleRatio = scaleRatio;
+ }
+
+ public String getUpPath() {
+ return upPath;
+ }
+
+ public void setUpPath(String upPath) {
+ this.upPath = upPath;
+ }
+
+ public String getImageType() {
+ return imageType;
+ }
+
+ public void setImageType(String imageType) {
+ this.imageType = imageType;
+ }
+
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/config/Swagger2.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/config/Swagger2.java
new file mode 100644
index 0000000..399f377
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/config/Swagger2.java
@@ -0,0 +1,38 @@
+package com.sincere.morningcheck.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+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
+public class Swagger2 {
+
+ @Bean
+ public Docket createRestApi() {
+ return new Docket(DocumentationType.SWAGGER_2)
+ .apiInfo(apiInfo())
+ .select()
+ .apis(RequestHandlerSelectors.basePackage("com.sincere.morningcheck.controller"))
+ .paths(PathSelectors.any())
+ .build();
+ }
+
+ private ApiInfo apiInfo() {
+ return new ApiInfoBuilder()
+ .title("晨检机使用的WebApi说明文档")
+ .contact(new Contact("Ziv","localhost:8080/swagger-ui.html",""))
+ .description("")
+ .termsOfServiceUrl("")
+ .version("2.0")
+ .build();
+ }
+
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/controller/MorningCheckController.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/controller/MorningCheckController.java
new file mode 100644
index 0000000..8e8bfc6
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/controller/MorningCheckController.java
@@ -0,0 +1,407 @@
+package com.sincere.morningcheck.controller;
+
+import com.sincere.morningcheck.common.EhcacheUtil;
+import com.sincere.morningcheck.common.MD5;
+import com.sincere.morningcheck.common.ServerResponse;
+import com.sincere.morningcheck.model.School;
+import com.sincere.morningcheck.model.Student;
+import com.sincere.morningcheck.model.User;
+import com.sincere.morningcheck.service.FileUpAndDownService;
+import com.sincere.morningcheck.service.StudentService;
+import com.sincere.morningcheck.service.UserServer;
+import com.sincere.morningcheck.service.impl.FileUpAndDownServiceImpl;
+import com.sincere.morningcheck.utils.DataConvertHelper;
+import com.sincere.morningcheck.utils.LogUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+@RestController
+@RequestMapping("user")
+@Api(value = "MorningCheckController", tags = "晨检机晨检接口说明")
+public class MorningCheckController {
+
+ private String token = "CESHI651BB2B8AEBBF0DB2FFC9B4EAD5F04E2";
+
+ @Value("${salt}")
+ private String salt;
+
+ EhcacheUtil ehcacheUtil = new EhcacheUtil();
+ @Autowired
+ UserServer userServer;
+
+ @Autowired
+ StudentService studentService;
+
+ @Autowired
+ FileUpAndDownService fileUpAndDownService;
+
+ @ApiOperation("设备请求登陆接口")
+ @ApiImplicitParams ({
+ @ApiImplicitParam(name = "deviceNo", value = "设备号", dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name = "password", value = "密码", dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name = "authSign", value = "签名", dataType = "String",required = true,paramType = "query"),
+ })
+ @PostMapping("login")
+ public ServerResponse login(@RequestParam String deviceNo, @RequestParam String password,@RequestParam String authSign){
+
+// System.out.println("传入的参数:设备号"+deviceNo+",密码:"+password+",签名"+authSign);
+ ServerResponse serverResponse = null;
+
+ Map map = new HashMap();
+ map.put("password", password);
+ map.put("deviceNo", deviceNo);
+
+ String queryUrl = DataConvertHelper.mapAscSortToUrl(map);
+ System.out.println(queryUrl);
+ try {
+ String signUrl = queryUrl.replace("&","");
+ System.out.println(signUrl);
+// String md5 = MD5.md5(signUrl, salt);
+ boolean verify = MD5.verify(signUrl,salt,authSign);
+ System.out.println("签名是否正确"+verify);
+
+ if(verify) {
+
+ User user = userServer.getDeviceUser(deviceNo);
+ user.setParameter("0");
+ user.setToken(token);
+ ehcacheUtil.set("deviceId",user.getDeviceId());
+ serverResponse = ServerResponse.createBySuccess("success",user);
+
+ }else{
+
+ serverResponse = ServerResponse.createByErrorMessage("签名校验失败");
+ LogUtil.printInfoLog("签名校验失败");
+
+ }
+ }
+ catch (Exception ex){
+ ex.printStackTrace();
+ serverResponse = ServerResponse.createByErrorMessage(ex.getMessage());
+ }
+
+ return serverResponse;
+ }
+
+ @ApiOperation("获取学生、卡号信息")
+ @ApiImplicitParams ({
+ @ApiImplicitParam(name = "token", value = "令牌", dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name = "schoolId", value = "学校ID", dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name = "authSign", value = "签名", dataType = "String",required = true,paramType = "query")
+ })
+ @PostMapping("getStudents")
+ public ServerResponse getStudents(@RequestParam String token,@RequestParam Integer schoolId,@RequestParam String authSign){
+
+ ServerResponse serverResponse = null;
+
+ Map map = new HashMap();
+ map.put("token", token);
+ map.put("schoolId", String.valueOf(schoolId));
+
+ String queryUrl = DataConvertHelper.mapAscSortToUrl(map);
+ try {
+ String signUrl = queryUrl.replace("&","");
+ //验证签名,看签名是否正确
+ boolean verify = MD5.verify(signUrl,salt,authSign);
+// boolean verify = true;
+ System.out.println("签名是否正确"+verify);
+ if(verify) {
+
+ School school = userServer.getSchoolById(schoolId);
+ serverResponse = ServerResponse.createBySuccess("success",school);
+ }
+ else{
+
+ serverResponse = ServerResponse.createByErrorMessage("签名校验失败");
+ }
+ }
+ catch (Exception ex){
+ ex.printStackTrace();
+ serverResponse = ServerResponse.createByErrorMessage(ex.getMessage());
+ }
+
+ return serverResponse;
+ }
+
+
+ @ApiOperation("刷卡签到")
+ @ApiImplicitParams ({
+ @ApiImplicitParam(name = "token", value = "令牌", dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name = "cardNo", value = "十进制卡号", dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name = "imageId", value = "接送图像类型对应的photoId", dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name = "authSign", value = "签名", dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name = "date", value = "晨检日期(上传历史签到数据才有这个参数,不是当天的签到)\n" +
+ "时间格式为 : yyyy-MM-dd-HH-mm-ss", dataType = "String",paramType = "query")
+ })
+ @PostMapping("signByCard")
+ public ServerResponse swipeCard(@RequestParam String token,@RequestParam String cardNo,@RequestParam Integer imageId,@RequestParam String authSign,@RequestParam(required = false) String date){
+
+// System.out.println("刷卡签到传入的参数:卡号"+cardNo+",图片ID:"+imageId+",签名"+authSign);
+ LogUtil.printInfoLog("刷卡签到传入的参数:卡号"+cardNo+",图片ID:"+imageId+",签名"+authSign);
+ ServerResponse serverResponse = null;
+
+ String card = DataConvertHelper.distToX(Long.valueOf(cardNo));
+
+ Map map = new HashMap();
+ map.put("token", token);
+ map.put("cardNo", cardNo);//传入的是10进制的卡号
+ map.put("imageId",String.valueOf(imageId));
+
+ Date dateIn = null;
+ if(StringUtils.isBlank(date)){
+ Calendar calendar= Calendar.getInstance();
+// SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
+// date = dateFormat.format(calendar.getTime());
+ dateIn= calendar.getTime();
+
+ }else{
+ map.put("date",date);//当date存在的时候再传
+ try {
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
+ dateIn = dateFormat.parse(date);
+ System.out.println(date);//2019-07-30-10-43-41
+ }catch (ParseException px){
+ px.printStackTrace();
+ }
+ }
+ String queryUrl = DataConvertHelper.mapAscSortToUrl(map);
+ try {
+ String signUrl = queryUrl.replace("&","");
+// boolean verify = true;
+ boolean verify = MD5.verify(signUrl,salt,authSign);
+ System.out.println("签名是否正确"+verify);
+ if(verify) {
+ int index = imageId -1;
+ if(FileUpAndDownServiceImpl.globalFileEntities.size()>0) {
+ System.out.println("对应图像地址:" + FileUpAndDownServiceImpl.globalFileEntities.get(index).getImgObPath());
+ }
+ //卡号,图片,刷卡时间(如果没有, 当前时间),设备号
+ System.out.println("卡号:"+cardNo+",图片ID"+imageId+",设备标识:"+ehcacheUtil.get("deviceId")+",当前时间"+date+",刷进设备的卡号是:"+card);
+
+ Map hashMap = new HashMap<>();
+ //设备编号
+ hashMap.put("att_id",ehcacheUtil.get("deviceId"));
+ hashMap.put("card_num",card);
+ hashMap.put("func_no","08");
+ hashMap.put("flag",0);
+ hashMap.put("intime",dateIn);
+ System.out.println(dateIn);
+
+ studentService.swipeCard(hashMap);
+ System.out.println("集合数量:"+hashMap.size());
+ System.out.println(hashMap.get("arr"));
+ System.out.println(hashMap.get("iscuccess"));
+
+ //message: 学生姓名你好
+ Student student = studentService.getStudentByCardNo(card);
+ String msg = String.format("学生%s你好",student.getStuName());
+ serverResponse = ServerResponse.createBySuccessMessage(msg);
+ } else{
+
+ serverResponse = ServerResponse.createByErrorMessage("签名校验失败");
+ }
+ }
+ catch (Exception ex){
+ ex.printStackTrace();
+ serverResponse = ServerResponse.createByErrorMessage(ex.getMessage());
+ }
+
+ return serverResponse;
+ }
+
+
+ @ApiOperation("离园签到")
+ @ApiImplicitParams ({
+ @ApiImplicitParam(name = "token", value = "令牌", dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name = "cardNo", value = "卡号", dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name = "imageId", value = "接送图像类型对应的photoId", dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name = "authSign", value = "签名", dataType = "String",required = true,paramType = "query")
+ })
+ @PostMapping("signOutByCard")
+ public ServerResponse signOutByCard(@RequestParam String token,@RequestParam String cardNo,@RequestParam Integer imageId,@RequestParam String authSign){
+
+// System.out.println("离园签到传入的参数:卡号"+cardNo+",图片ID:"+imageId+",签名"+authSign);
+ ServerResponse serverResponse = null;
+ LogUtil.printInfoLog("离园签到传入的参数:卡号"+cardNo+",图片ID:"+imageId+",签名"+authSign);
+
+ String card = DataConvertHelper.distToX(Long.valueOf(cardNo));
+
+ Map map = new HashMap();
+ map.put("token", token);
+ map.put("cardNo", cardNo);//传入的是10进制的卡号
+ map.put("imageId",String.valueOf(imageId));
+
+ String queryUrl = DataConvertHelper.mapAscSortToUrl(map);
+ try {
+ String signUrl = queryUrl.replace("&","");
+ boolean verify = MD5.verify(signUrl,salt,authSign);
+ System.out.println("签名是否正确"+verify);
+ if(verify) {
+
+ int index = imageId -1;
+ if(FileUpAndDownServiceImpl.globalFileEntities.size()>0) {
+ System.out.println("对应图像地址:" + FileUpAndDownServiceImpl.globalFileEntities.get(index).getImgObPath());
+ }
+ //卡号,图片,刷卡时间(如果没有, 当前时间),设备号
+ System.out.println("卡号:"+cardNo+",图片ID"+imageId+",设备标识:"+ehcacheUtil.get("deviceId")+",刷进设备的卡号是:"+card);
+ Map hashMap = new HashMap<>();
+ hashMap.put("att_id",ehcacheUtil.get("deviceId"));
+ hashMap.put("card_num",card);
+ hashMap.put("func_no","08");
+ hashMap.put("flag",0);
+ hashMap.put("intime",new Date());
+ studentService.swipeCard(hashMap);
+ System.out.println(hashMap.get("arr"));
+ System.out.println(hashMap.get("iscuccess"));
+ //message: 学生姓名你好
+ Student student = studentService.getStudentByCardNo(card);
+ String msg = String.format("学生%s你好",student.getStuName());
+ serverResponse = ServerResponse.createBySuccessMessage(msg);
+ }else{
+
+ serverResponse = ServerResponse.createByErrorMessage("签名失败");
+ }
+ }
+ catch (Exception ex){
+ ex.printStackTrace();
+ serverResponse = ServerResponse.createByErrorMessage(ex.getMessage());
+ }
+
+ return serverResponse;
+ }
+ @RequestMapping(value = "/uploadImg", method = RequestMethod.POST)
+ @ApiOperation("上传多个文件")
+ @ApiImplicitParams ({
+ @ApiImplicitParam(name = "token", value = "令牌", dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name = "file", value = "文件列表", dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name = "type", value = "图像类型", dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name = "authSign", value = "签名", dataType = "String",required = true,paramType = "query")
+ })
+ public ServerResponse moreFileUpload(@RequestParam(value = "file", required = false) MultipartFile[] file, @RequestParam(value = "token") String token, @RequestParam(value="type") String type,@RequestParam String authSign) {
+
+
+ LogUtil.printInfoLog("上传多个文件传入的类型:"+type+",签名:"+authSign);
+// System.out.println("上传多个文件传入的类型:"+type+",签名:"+authSign);
+
+ System.out.println("文件数量:"+file.length);
+
+ ServerResponse serverResponse = null;
+ Map map = new HashMap();
+ map.put("token", token);
+ map.put("type", type);
+
+ String[] fileNames = type.split("_");
+ if(fileNames.length != file.length){
+ System.out.println("类型数量和文件数量不一致,程序中断");
+ return ServerResponse.createByErrorMessage("类型数量和文件数量不一致,程序中断");
+ }else {
+ System.out.println("类型数量和文件数量一致,文件已经上传");
+ }
+ String queryUrl = DataConvertHelper.mapAscSortToUrl(map);
+ try {
+ String signUrl = queryUrl.replace("&","");
+// String md5 = MD5.md5(signUrl, salt);
+ boolean verify = MD5.verify(signUrl,salt,authSign);
+ System.out.println("签名是否正确"+verify);
+ if(verify) {
+ try {
+ serverResponse = fileUpAndDownService.uploadPicture(file,fileNames);
+ } catch (Exception e) {
+ System.out.println(">>>>>>图片上传异常,ex="+e.getMessage());
+ serverResponse = ServerResponse.createByErrorMessage(String.format(">>>>>>图片上传异常,e=%s", e.getMessage()));
+ }
+ }
+ }
+ catch (Exception ex){
+ ex.printStackTrace();
+ serverResponse = ServerResponse.createByErrorMessage(ex.getMessage());
+ }
+
+ return serverResponse;
+ }
+
+
+ @ApiOperation("晨检报告")
+ @ApiImplicitParams ({
+ @ApiImplicitParam(name = "token", value = "令牌", dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name = "cardNo", value = "卡号", dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name = "result", value = "检查结果,32位字符串", dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name="robotResult",value = "晨检机器判断结果。3位字符串",dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name="access",value = "入园许可。 Y : 入园 N:离园",dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name="temperature",value = "体温(小于35.2时显示LOW;大于42.2时,显示HIGH)",dataType = "String",required = true,paramType = "query"),
+ @ApiImplicitParam(name="handImgId",value = "手部异常图像ID",dataType = "String",paramType = "query"),
+ @ApiImplicitParam(name = "mouthImgId", value = "嘴部异常头像ID", dataType = "String",paramType = "query"),
+ @ApiImplicitParam(name = "eyeImgId", value = "眼部异常头像ID", dataType = "String",paramType = "query"),
+ @ApiImplicitParam(name = "authSign", value = "签名", dataType = "String",required = true,paramType = "query"),
+ })
+ @PostMapping("uploadCheckReport")
+ public ServerResponse uploadCheckReport(@RequestParam String token,@RequestParam String cardNo,@RequestParam String result,@RequestParam String robotResult,@RequestParam String access,@RequestParam String temperature,@RequestParam(required = false) String handImgId,@RequestParam(required = false) String mouthImgId,@RequestParam(required = false) String eyeImgId,@RequestParam String authSign){
+
+// System.out.println("传入的参数:卡号"+cardNo+",检查结果:"+result+",检查机判断结果:"+robotResult+",签名"+authSign);
+ LogUtil.printInfoLog("传入的参数:卡号"+cardNo+",检查结果:"+result+",检查机判断结果:"+robotResult+",签名"+authSign);
+ System.out.println("嘴部异常图片ID:"+mouthImgId);
+ System.out.println("手部异常图片ID:"+handImgId);
+ System.out.println("眼部异常图片ID:"+eyeImgId);
+ System.out.println("入园许可。 Y : 入园 N:离园:入园情况:"+access);
+
+ ServerResponse serverResponse = null;
+
+ String card = DataConvertHelper.distToX(Long.valueOf(cardNo));
+
+ Map map = new HashMap();
+ map.put("token", token);
+ map.put("cardNo", cardNo);//传入的是10进制的卡号
+ map.put("result",result);
+ map.put("robotResult",robotResult);
+ map.put("access",access);
+ map.put("temperature",temperature);
+ map.put("handImgId",handImgId);
+ map.put("mouthImgId",mouthImgId);
+ map.put("eyeImgId",eyeImgId);
+
+ String queryUrl = DataConvertHelper.mapAscSortToUrl(map);
+ try {
+ String signUrl = queryUrl.replace("&","");
+ boolean verify = MD5.verify(signUrl,salt,authSign);
+ System.out.println("签名是否正确"+verify);
+ if(verify) {
+
+// int index = handImgId -1;
+// System.out.println("手部异常图像地址:"+FileUpAndDownServiceImpl.globalFileEntities.get(index).getImgObPath());
+// index = mouthImgId -1;
+// System.out.println("嘴部异常图像地址:"+FileUpAndDownServiceImpl.globalFileEntities.get(index).getImgObPath());
+// index = eyeImgId -1;
+// System.out.println("眼部异常图像地址:"+FileUpAndDownServiceImpl.globalFileEntities.get(index).getImgObPath());
+ //卡号,图片,刷卡时间(如果没有, 当前时间),设备号
+ System.out.println("卡号:"+cardNo+",图片ID"+handImgId+",设备标识:"+ehcacheUtil.get("deviceId")+",刷进设备的卡号是:"+card);
+ //message: 学生姓名你好
+ Student student = studentService.getStudentByCardNo(card);
+ String msg = String.format("学生%s你好,你的晨检报告已经自动生成",student.getStuName());
+ serverResponse = ServerResponse.createBySuccessMessage(msg);
+ }else{
+
+ serverResponse = ServerResponse.createByErrorMessage("签名校验失败");
+ }
+ }
+ catch (Exception ex){
+ ex.printStackTrace();
+ serverResponse = ServerResponse.createByErrorMessage(ex.getMessage());
+ }
+
+ return serverResponse;
+ }
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/dao/StudentDao.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/dao/StudentDao.java
new file mode 100644
index 0000000..46e23b6
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/dao/StudentDao.java
@@ -0,0 +1,25 @@
+package com.sincere.morningcheck.dao;
+
+
+import com.sincere.morningcheck.model.Student;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+@Repository
+public interface StudentDao {
+
+ List getStudents(@Param("schoolId") Integer schoolId);
+
+ Student getStudentByCardNo(@Param("cardNo") String cardNo);
+
+ /**
+ * 传入的参数和返回的结果都在map集合参数params中
+ * @param params
+ */
+ void swipeCard(Map params);
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/dao/UserDao.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/dao/UserDao.java
new file mode 100644
index 0000000..1b72413
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/dao/UserDao.java
@@ -0,0 +1,22 @@
+package com.sincere.morningcheck.dao;
+
+import com.sincere.morningcheck.model.School;
+import com.sincere.morningcheck.model.User;
+
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface UserDao {
+
+ User getUser(@Param("deviceNo") String deviceNo);
+
+ School getSchoolById(@Param("schoolId") Integer schoolId);
+
+// boolean register(@Param("username") String username, @Param("password") String password);
+
+// User isExit(@Param("username") String username);
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/model/FileEntity.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/model/FileEntity.java
new file mode 100644
index 0000000..0e4f95e
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/model/FileEntity.java
@@ -0,0 +1,29 @@
+package com.sincere.morningcheck.model;
+
+import com.sincere.morningcheck.common.ImgType;
+import lombok.Data;
+
+@Data
+public class FileEntity {
+
+ /**
+ * 头像ID(自增)
+ */
+ private Integer photoId;
+ /**
+ * 头像存储的位置(绝对路径)
+ */
+ private String imgObPath;
+ /**
+ * 文件新名称
+ */
+ private String fileName;
+ /**
+ * 文件储存的类型
+ */
+ private ImgType imgType;
+ /**
+ * 文件旧名称
+ */
+ private String oldFileName;
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/model/Photo.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/model/Photo.java
new file mode 100644
index 0000000..b4eeaf0
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/model/Photo.java
@@ -0,0 +1,9 @@
+package com.sincere.morningcheck.model;
+
+import lombok.Data;
+
+@Data
+public class Photo {
+
+ private Integer photoId;
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/model/School.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/model/School.java
new file mode 100644
index 0000000..314fa2b
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/model/School.java
@@ -0,0 +1,15 @@
+package com.sincere.morningcheck.model;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class School {
+
+ private Integer schoolId;
+
+ private String schoolName;
+
+ private List students;
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/model/Student.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/model/Student.java
new file mode 100644
index 0000000..7340f14
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/model/Student.java
@@ -0,0 +1,14 @@
+package com.sincere.morningcheck.model;
+
+
+import lombok.Data;
+
+@Data
+public class Student {
+
+ private Integer classId;
+ private Integer stuId;
+ private String stuName;
+ private String className;
+ private String cardNos;
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/model/User.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/model/User.java
new file mode 100644
index 0000000..c4d7749
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/model/User.java
@@ -0,0 +1,13 @@
+package com.sincere.morningcheck.model;
+
+import lombok.Data;
+
+@Data
+public class User {
+
+ private Integer schoolId;
+ private String parameter;
+ private String schoolName;
+ private String deviceId;
+ private String token;
+}
\ No newline at end of file
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/platform/MorningCheckResult.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/platform/MorningCheckResult.java
new file mode 100644
index 0000000..77938fc
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/platform/MorningCheckResult.java
@@ -0,0 +1,15 @@
+package com.sincere.morningcheck.platform;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+@Data
+@JsonInclude(JsonInclude.Include.NON_EMPTY)
+public class MorningCheckResult {
+
+ private String code;
+
+ private String message;
+
+ private T data;
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/FileUpAndDownService.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/FileUpAndDownService.java
new file mode 100644
index 0000000..31253e5
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/FileUpAndDownService.java
@@ -0,0 +1,10 @@
+package com.sincere.morningcheck.service;
+
+import com.sincere.morningcheck.common.ServerResponse;
+import org.springframework.web.multipart.MultipartFile;
+
+
+public interface FileUpAndDownService {
+
+ ServerResponse uploadPicture(MultipartFile[] file, String[] file_Types) throws Exception;
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/StudentService.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/StudentService.java
new file mode 100644
index 0000000..d71f508
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/StudentService.java
@@ -0,0 +1,15 @@
+package com.sincere.morningcheck.service;
+
+import com.sincere.morningcheck.model.Student;
+
+import java.util.List;
+import java.util.Map;
+
+public interface StudentService {
+
+ List getStudents(Integer schoolId);
+
+ Student getStudentByCardNo(String cardNo);
+
+ void swipeCard(Map params);
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/UserServer.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/UserServer.java
new file mode 100644
index 0000000..9543956
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/UserServer.java
@@ -0,0 +1,15 @@
+package com.sincere.morningcheck.service;
+
+import com.sincere.morningcheck.model.School;
+import com.sincere.morningcheck.model.User;
+import org.apache.ibatis.annotations.Param;
+
+
+public interface UserServer {
+
+ User getDeviceUser(String deviceNo);
+
+ School getSchoolById(Integer schoolId);
+
+ User isExit(String username);
+}
\ No newline at end of file
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/FileUpAndDownServiceImpl.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/FileUpAndDownServiceImpl.java
new file mode 100644
index 0000000..4b70396
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/FileUpAndDownServiceImpl.java
@@ -0,0 +1,115 @@
+package com.sincere.morningcheck.service.impl;
+
+import com.sincere.morningcheck.common.ImgType;
+import com.sincere.morningcheck.common.ServerResponse;
+import com.sincere.morningcheck.config.MessageProperties;
+import com.sincere.morningcheck.model.FileEntity;
+import com.sincere.morningcheck.model.Photo;
+import com.sincere.morningcheck.service.FileUpAndDownService;
+import net.coobird.thumbnailator.Thumbnails;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@Service
+public class FileUpAndDownServiceImpl implements FileUpAndDownService {
+ @Autowired
+ private MessageProperties config; //用来获取file-message.properties配置文件中的信息
+
+ static Integer photoId = 0;
+ public static List globalFileEntities = new LinkedList<>();
+ @Override
+ public ServerResponse uploadPicture(MultipartFile[] files, String[] file_types) throws Exception {
+
+ System.out.println("进入上传文件方法。");
+ List fileEntities = new LinkedList<>();
+ int i = 0;
+ for(MultipartFile file : files) {
+ System.out.println(file.getOriginalFilename());
+
+ try {
+ photoId++; //每进一次方法自增一次,模拟主键自增
+ Map resMap = new HashMap<>();
+ String[] IMAGE_TYPE = config.getImageType().split(",");
+ String path = null;
+ boolean flag = false;
+ for (String type : IMAGE_TYPE) {
+ if (StringUtils.endsWithIgnoreCase(file.getOriginalFilename(), type)) {
+ flag = true;
+ break;
+ }
+ }
+ if (flag) {
+
+ // 获得文件类型
+ String fileType = file.getContentType();
+ // 原名称
+ String oldFileName = file.getOriginalFilename();
+ // 获得文件后缀名称
+ String suffix = oldFileName.substring(oldFileName.lastIndexOf("."));//带逗号,不带逗号加1
+ // 新名称
+ String imgType = file_types[i];
+ String newFileName = imgType + "_photoId"+photoId+suffix;
+ i++;
+ // 年月日文件夹
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+ String basedir = sdf.format(new Date());
+ // 进行压缩(大于4M)
+ if (file.getSize() > config.getFileSize()) {
+ path = config.getUpPath() + "/" + basedir + "/" + newFileName;
+ // 如果目录不存在则创建目录
+ File oldFile = new File(path);
+ if (!oldFile.exists()) {
+ oldFile.mkdirs();
+ }
+ file.transferTo(oldFile);
+ // 压缩图片
+ Thumbnails.of(oldFile).scale(config.getScaleRatio()).toFile(path);
+
+ } else {
+ path = config.getUpPath() + "/" + basedir + "/" + newFileName;
+ // 如果目录不存在则创建目录
+ File uploadFile = new File(path);
+ if (!uploadFile.exists()) {
+ uploadFile.mkdirs();
+ }
+ file.transferTo(uploadFile);
+ }
+
+ FileEntity fileEntity = new FileEntity();
+ fileEntity.setPhotoId(photoId);
+ fileEntity.setFileName(newFileName);
+ fileEntity.setImgObPath(path);
+ fileEntity.setOldFileName(oldFileName);
+ fileEntity.setImgType(ImgType.valueOf(imgType));
+
+ fileEntities.add(fileEntity);
+
+ } else {
+ System.out.println("result:图片格式不正确,支持png|jpg|jpeg");
+ return ServerResponse.createByErrorMessage("result:图片格式不正确,支持png|jpg|jpeg");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new Exception(e.getMessage());
+ }
+ }
+ globalFileEntities.addAll(fileEntities);
+ Map map = new HashMap<>();
+
+ List photoIds = new ArrayList<>();
+
+ for (FileEntity fileEntity : fileEntities){
+ Photo photo = new Photo();
+ photo.setPhotoId(fileEntity.getPhotoId());
+ photoIds.add(photo);
+ }
+ map.put("photoIds",photoIds);
+ return ServerResponse.createBySuccess(map);
+ }
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/StudentServiceImpl.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/StudentServiceImpl.java
new file mode 100644
index 0000000..ad93c35
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/StudentServiceImpl.java
@@ -0,0 +1,34 @@
+package com.sincere.morningcheck.service.impl;
+
+import com.sincere.morningcheck.dao.StudentDao;
+import com.sincere.morningcheck.model.Student;
+import com.sincere.morningcheck.service.StudentService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class StudentServiceImpl implements StudentService {
+
+ @Autowired
+ StudentDao studentDao;
+
+
+ @Override
+ public List getStudents(Integer schoolId) {
+ return studentDao.getStudents(schoolId);
+ }
+
+ @Override
+ public Student getStudentByCardNo(String cardNo) {
+ return studentDao.getStudentByCardNo(cardNo);
+ }
+
+ @Override
+ public void swipeCard(Map params) {
+
+ studentDao.swipeCard(params);
+ }
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/UserServerImp.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/UserServerImp.java
new file mode 100644
index 0000000..d5d93eb
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/UserServerImp.java
@@ -0,0 +1,63 @@
+package com.sincere.morningcheck.service.impl;
+
+import com.sincere.morningcheck.dao.UserDao;
+import com.sincere.morningcheck.model.School;
+import com.sincere.morningcheck.model.Student;
+import com.sincere.morningcheck.model.User;
+import com.sincere.morningcheck.service.StudentService;
+import com.sincere.morningcheck.service.UserServer;
+
+import com.sincere.morningcheck.utils.DataConvertHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+
+@Service
+public class UserServerImp implements UserServer {
+
+ @Autowired
+ UserDao userDao;
+
+ @Autowired
+ StudentService studentService;
+
+ @Override
+ public User getDeviceUser(String deviceNo) {
+ return userDao.getUser(deviceNo);
+ }
+
+ @Override
+ public School getSchoolById(Integer schoolId) {
+
+ School school = userDao.getSchoolById(schoolId);
+
+ List students = studentService.getStudents(schoolId);
+
+ for (Student student : students){
+
+ if(student.getCardNos().contains(",")) {
+
+ String[] cards = student.getCardNos().split(",");
+ String distCards = "";
+ for(String card:cards){
+
+ distCards +=DataConvertHelper.XToDist(card).toString()+",";
+ }
+ student.setCardNos(distCards.substring(0,distCards.length()-1));
+ }else {
+ student.setCardNos(DataConvertHelper.XToDist(student.getCardNos()).toString());
+ }
+
+ }
+ school.setStudents(students);
+
+ return school;
+ }
+
+ @Override
+ public User isExit(String username) {
+ return null;
+ }
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/ApiHelper.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/ApiHelper.java
new file mode 100644
index 0000000..a3f312a
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/ApiHelper.java
@@ -0,0 +1,297 @@
+package com.sincere.morningcheck.utils;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.entity.mime.HttpMultipartMode;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.apache.http.entity.mime.content.FileBody;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.*;
+
+public class ApiHelper {
+
+ public static String doGet(String url,Map headerParamMap) {
+ CloseableHttpClient httpClient = null;
+ CloseableHttpResponse response = null;
+ String result = "";
+ try {
+ // 通过址默认配置创建一个httpClient实例
+ httpClient = HttpClients.createDefault();
+ // 创建httpGet远程连接实例
+ HttpGet httpGet = new HttpGet(url);
+ // 设置请求头信息,
+ for (Map.Entry entry : headerParamMap.entrySet()) {
+ httpGet.setHeader(entry.getKey(),entry.getValue());
+ }
+
+ // 设置配置请求参数
+ RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000)// 连接主机服务超时时间
+ .setConnectionRequestTimeout(35000)// 请求超时时间
+ .setSocketTimeout(60000)// 数据读取超时时间
+ .build();
+ // 为httpGet实例设置配置
+ httpGet.setConfig(requestConfig);
+ // 执行get请求得到返回对象
+ response = httpClient.execute(httpGet);
+ // 通过返回对象获取返回数据
+ HttpEntity entity = response.getEntity();
+ // 通过EntityUtils中的toString方法将结果转换为字符串
+ result = EntityUtils.toString(entity);
+ } catch (ClientProtocolException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ // 关闭资源
+ if (null != response) {
+ try {
+ response.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ if (null != httpClient) {
+ try {
+ httpClient.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ return result;
+ }
+
+
+ public static String doDelete(String url,Map headerParamMap) {
+ CloseableHttpClient httpClient = null;
+ CloseableHttpResponse response = null;
+ String result = "";
+ try {
+ // 通过址默认配置创建一个httpClient实例
+ httpClient = HttpClients.createDefault();
+ // 创建HttpDelete远程连接实例
+ HttpDelete httpDelete = new HttpDelete(url);
+ // 设置请求头信息,
+ for (Map.Entry entry : headerParamMap.entrySet()) {
+ httpDelete.setHeader(entry.getKey(),entry.getValue());
+ }
+
+ // 设置配置请求参数
+ RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000)// 连接主机服务超时时间
+ .setConnectionRequestTimeout(35000)// 请求超时时间
+ .setSocketTimeout(60000)// 数据读取超时时间
+ .build();
+ // 为httpGet实例设置配置
+ httpDelete.setConfig(requestConfig);
+ // 执行get请求得到返回对象
+ response = httpClient.execute(httpDelete);
+ // 通过返回对象获取返回数据
+ HttpEntity entity = response.getEntity();
+ // 通过EntityUtils中的toString方法将结果转换为字符串
+ result = EntityUtils.toString(entity);
+ } catch (ClientProtocolException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ // 关闭资源
+ if (null != response) {
+ try {
+ response.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ if (null != httpClient) {
+ try {
+ httpClient.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * 表单格式的post请求
+ *
+ * @param url 接口地址
+ * @param headerParamMap 设置请求头
+ * @param paramMap 设置请求值,表单格式的请求值
+ * @return
+ */
+ public static String doPost(String url, Map headerParamMap, Map paramMap) {
+ CloseableHttpClient httpClient;
+ String result;
+ // 创建httpClient实例
+ httpClient = HttpClients.createDefault();
+ // 创建httpPost远程连接实例
+ HttpPost httpPost = new HttpPost(url);
+ // 设置请求头
+ httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded");
+ for (Map.Entry entry : headerParamMap.entrySet()) {
+ httpPost.setHeader(entry.getKey(), entry.getValue());
+ }
+ // 配置请求参数实例
+ RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000)// 设置连接主机服务超时时间
+ .setConnectionRequestTimeout(35000)// 设置连接请求超时时间
+ .setSocketTimeout(60000)// 设置读取数据连接超时时间
+ .build();
+ // 为httpPost实例设置配置
+ httpPost.setConfig(requestConfig);
+
+ // 封装post请求参数
+ if (null != paramMap && paramMap.size() > 0) {
+ List nvps = new ArrayList();
+ // 通过map集成entrySet方法获取entity
+ Set> entrySet = paramMap.entrySet();
+ // 循环遍历,获取迭代器
+ Iterator> iterator = entrySet.iterator();
+ while (iterator.hasNext()) {
+ Map.Entry mapEntry = iterator.next();
+ nvps.add(new BasicNameValuePair(mapEntry.getKey(), mapEntry.getValue().toString()));
+ }
+
+ // 为httpPost设置封装好的请求参数
+ try {
+ UrlEncodedFormEntity entity = new UrlEncodedFormEntity(nvps, "UTF-8");
+ httpPost.setEntity(entity);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ }
+ result = closeHttpAndResult(httpClient, httpPost);
+ return result;
+ }
+ /**
+ * post请求,内容体比较灵活,任意字符串格式的内容
+ * @param url
+ * @param headerParamMap
+ * @param jsonParam
+ * @return
+ */
+ public static String doPost(String url, Map headerParamMap, String jsonParam) {
+ CloseableHttpClient httpClient;
+// CloseableHttpResponse httpResponse = null;
+ String result;
+ // 创建httpClient实例
+ httpClient = HttpClients.createDefault();
+ // 创建httpPost远程连接实例
+ HttpPost httpPost = new HttpPost(url);
+ // 设置请求头
+ httpPost.addHeader("Content-Type", "application/json");
+ for (Map.Entry entry : headerParamMap.entrySet()) {
+ httpPost.setHeader(entry.getKey(),entry.getValue());
+ }
+ // 配置请求参数实例
+ RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000)// 设置连接主机服务超时时间
+ .setConnectionRequestTimeout(35000)// 设置连接请求超时时间
+ .setSocketTimeout(60000)// 设置读取数据连接超时时间
+ .build();
+ // 为httpPost实例设置配置
+ httpPost.setConfig(requestConfig);
+ StringEntity stringEntity = new StringEntity(jsonParam, ContentType.create("application/json","UTF-8"));
+ httpPost.setEntity(stringEntity);
+ result = closeHttpAndResult(httpClient,httpPost);
+ return result;
+ }
+
+
+ public static String doPost(String url, Map headerParamMap, List files) {
+ CloseableHttpClient httpClient;
+
+ String result;
+ // 创建httpClient实例
+ httpClient = HttpClients.createDefault();
+ // 创建httpPost远程连接实例
+ HttpPost httpPost = new HttpPost(url);
+ // 设置请求头
+ httpPost.addHeader("Content-Type", "multipart/form-data");
+ httpPost.setHeader("Accept-Encoding","gzip");
+ httpPost.setHeader("charset", "utf-8");
+
+
+ if(headerParamMap != null) {
+ for (Map.Entry entry : headerParamMap.entrySet()) {
+ httpPost.setHeader(entry.getKey(), entry.getValue());
+ }
+ }
+ // 配置请求参数实例
+ RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000)// 设置连接主机服务超时时间
+ .setConnectionRequestTimeout(35000)// 设置连接请求超时时间
+ .setSocketTimeout(60000)// 设置读取数据连接超时时间
+ .build();
+ // 为httpPost实例设置配置
+ httpPost.setConfig(requestConfig);
+ //创建Mime类型的类
+ MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+
+ /* example for setting a HttpMultipartMode */
+ builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
+
+ /* example for adding an image part */
+ FileBody fileBody = new FileBody(new File(files.get(0))); //image should be a String
+ builder.addPart("file", fileBody);
+
+ HttpEntity entity = builder.build();
+
+ httpPost.setEntity(entity);
+ httpPost.setEntity(entity);
+
+ result = closeHttpAndResult(httpClient,httpPost);
+ return result;
+ }
+
+ private static String closeHttpAndResult(CloseableHttpClient httpClient,HttpPost httpPost){
+ CloseableHttpResponse httpResponse = null;
+ String result = null;
+ try {
+ // httpClient对象执行post请求,并返回响应参数对象
+ httpResponse = httpClient.execute(httpPost);
+ // 从响应对象中获取响应内容
+ HttpEntity entity = httpResponse.getEntity();
+ result = EntityUtils.toString(entity);
+ } catch (ClientProtocolException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ // 关闭资源
+ if (null != httpResponse) {
+ try {
+ httpResponse.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ if (null != httpClient) {
+ try {
+ httpClient.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return result;
+ }
+}
+
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/DataConvertHelper.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/DataConvertHelper.java
new file mode 100644
index 0000000..06fb70f
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/DataConvertHelper.java
@@ -0,0 +1,87 @@
+package com.sincere.morningcheck.utils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.math.BigInteger;
+import java.util.*;
+
+public class DataConvertHelper {
+
+ /**
+ * key-value集合转换为url键值对字符串
+ * @param keyValues
+ * @return
+ */
+ private static String keyValueToString(List> keyValues) {
+
+ StringBuffer buff = new StringBuffer();
+ for (Map.Entry entry : keyValues) {
+ if (buff.length() > 0) {
+ buff.append("&");
+ }
+ buff.append(entry.getKey()).append("=").append(entry.getValue());
+ }
+ return buff.toString();
+
+ }
+
+ public static String mapAscSortToUrl(Map aMap){
+
+ Set> set=aMap.entrySet();
+
+ List> aList=new LinkedList<>(set);
+
+ //o1在前是升序,反之是降序
+ Collections.sort(aList,(o1,o2)-> { return o1.getKey().compareTo(o2.getKey()); });
+
+ return keyValueToString(aList);
+ }
+
+
+ /**
+ * 8位16进制的卡号转为10进制卡号
+ * @param cardNo
+ * @return
+ */
+ public static BigInteger XToDist(String cardNo){
+ String newCard = "";
+ BigInteger card = new BigInteger("0");
+ try {
+
+ if (StringUtils.isNotBlank(cardNo) && cardNo.length() == 8) {
+
+ newCard += cardNo.substring(6, 8);
+ newCard += cardNo.substring(4, 6);
+ newCard += cardNo.substring(2, 4);
+ newCard += cardNo.substring(0, 2);
+ card = new BigInteger(newCard, 16);
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ return card;
+ }
+
+ public static String distToX(Long num) {
+ String newCard = "";
+ try {
+ Long valueTen = num;
+ //将十六进制格式化8位输出
+ String cardNo = String.format("%08x", valueTen).toUpperCase();
+ System.out.println(valueTen + " [十进制]---->[十六进制] " + cardNo);
+
+ newCard += cardNo.substring(6, 8);
+ newCard += cardNo.substring(4, 6);
+ newCard += cardNo.substring(2, 4);
+ newCard += cardNo.substring(0, 2);
+
+ System.out.println("两两换位之后的新卡号:"+newCard);
+
+ }catch (Exception e){
+ newCard = "00000000";
+ e.printStackTrace();
+ }
+
+ return newCard;
+ }
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/FileUtils.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/FileUtils.java
new file mode 100644
index 0000000..55da0c6
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/FileUtils.java
@@ -0,0 +1,90 @@
+package com.sincere.morningcheck.utils;
+
+import org.springframework.web.multipart.MultipartFile;
+import sun.misc.BASE64Decoder;
+import sun.misc.BASE64Encoder;
+
+import javax.imageio.stream.FileImageInputStream;
+import java.io.*;
+import java.util.HashMap;
+import java.util.Map;
+
+public class FileUtils {
+
+
+ /**
+ * @param imgStr base64编码字符串
+ * @param path 图片路径-具体到文件
+ * @return
+ * @Description: 将base64编码字符串转换为图片
+ * @Author:
+ * @CreateTime:
+ */
+ public static boolean generateImage(String imgStr, String path) {
+ if (imgStr == null)
+ return false;
+ BASE64Decoder decoder = new BASE64Decoder();
+ try {
+// 解密
+ byte[] b = decoder.decodeBuffer(imgStr);
+// 处理数据
+ for (int i = 0; i < b.length; ++i) {
+ if (b[i] < 0) {
+ b[i] += 256;
+ }
+ }
+ OutputStream out = new FileOutputStream(path);
+ out.write(b);
+ out.flush();
+ out.close();
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ /**
+ * @return
+ * @Description: 根据图片地址转换为base64编码字符串
+ * @Author:
+ * @CreateTime:
+ */
+ public static String getImageStr(String imgFile) {
+ InputStream inputStream = null;
+ byte[] data = null;
+ try {
+ inputStream = new FileInputStream(imgFile);
+ data = new byte[inputStream.available()];
+ inputStream.read(data);
+ inputStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ // 加密
+ BASE64Encoder encoder = new BASE64Encoder();
+ return encoder.encode(data);
+ }
+
+ //图片到byte数组
+ public static byte[] image2byte(String path) {
+ byte[] data = null;
+ FileImageInputStream input = null;
+ try {
+ input = new FileImageInputStream(new File(path));
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ byte[] buf = new byte[1024];
+ int numBytesRead = 0;
+ while ((numBytesRead = input.read(buf)) != -1) {
+ output.write(buf, 0, numBytesRead);
+ }
+ data = output.toByteArray();
+ output.close();
+ input.close();
+ } catch (FileNotFoundException ex1) {
+ ex1.printStackTrace();
+ } catch (IOException ex1) {
+ ex1.printStackTrace();
+ }
+ return data;
+ }
+}
diff --git a/springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/LogUtil.java b/springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/LogUtil.java
new file mode 100644
index 0000000..9e64f12
--- /dev/null
+++ b/springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/LogUtil.java
@@ -0,0 +1,45 @@
+package com.sincere.morningcheck.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @Description: 日志工具类
+ * @Author: Ziv
+ */
+public class LogUtil {
+
+ /**
+ * 将信息打印到自定义日志(my_info.log)中
+ * @param message 需要被打印的信息
+ */
+ public static void printInfoLog(String message){
+ Logger logger = LoggerFactory.getLogger("my_info");
+ logger.info(message);
+ }
+
+ /**
+ * 将信息打印到自定义日志(system_error.log)中
+ * @param e 异常信息
+ */
+ public static void printErrorLog(Exception e, Class> clazz){
+ Logger logger = LoggerFactory.getLogger(clazz);
+
+ StringBuffer logOut = new StringBuffer();
+ logOut.append(e.toString());
+
+
+ StackTraceElement[] errorList = e.getStackTrace();
+ for (StackTraceElement stackTraceElement : errorList) {
+ logOut.append(stackTraceElement.toString());
+ logOut.append("\n");
+ }
+
+ logger.error(logOut.toString());
+ }
+
+ public static void printErrorLog(Class> clazz,String message){
+ Logger logger = LoggerFactory.getLogger(clazz);
+ logger.error(message);
+ }
+}
diff --git a/springboot/morning-check/src/main/resources/application.properties b/springboot/morning-check/src/main/resources/application.properties
new file mode 100644
index 0000000..142e1cb
--- /dev/null
+++ b/springboot/morning-check/src/main/resources/application.properties
@@ -0,0 +1,14 @@
+salt = sincere
+
+server.port=8999
+
+spring.datasource.username=szjxtuser
+spring.datasource.password=RQminVCJota3H1u8bBYH
+spring.datasource.url=jdbc:sqlserver://116.62.155.137:33419;database=smartcampus
+spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
+
+mybatis.mapper-locations=classpath:/mapper/*.xml
+mybatis.type-aliases-package=com.sincere.morningcheck.model
+
+# springboot ѡȡ
+spring.profiles.active=dev
diff --git a/springboot/morning-check/src/main/resources/file-message.properties b/springboot/morning-check/src/main/resources/file-message.properties
new file mode 100644
index 0000000..193c1b9
--- /dev/null
+++ b/springboot/morning-check/src/main/resources/file-message.properties
@@ -0,0 +1,8 @@
+#ļѹС(5ѹ)
+message.fileSize=5242880
+#ͼƬ·
+message.upPath=D:\\MorningRobot\\UploadData\\images
+#ѹ
+message.scaleRatio=0.90f
+#ͼƬ
+message.imageType=png,jpg,jpeg
\ No newline at end of file
diff --git a/springboot/morning-check/src/main/resources/logback.xml b/springboot/morning-check/src/main/resources/logback.xml
new file mode 100644
index 0000000..c6a748a
--- /dev/null
+++ b/springboot/morning-check/src/main/resources/logback.xml
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] %highlight([%-5level] %logger{50} - %msg%n)
+ UTF-8
+
+
+
+
+
+
+
+
+ ERROR
+ ACCEPT
+ DENY
+
+
+
+ ${LOG_HOME}/${PROJECT_NAME}.system_error.%d{yyyy-MM-dd}.%i.log
+
+ 15
+
+ 10MB
+
+
+
+
+ [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] %logger{50} - %msg%n
+ UTF-8
+
+
+
+
+
+
+
+
+
+
+ INFO
+ ACCEPT
+ DENY
+
+
+
+ ${LOG_HOME}\authjwt.my_info.%d{yyyy-MM-dd}.%i.log
+
+ 15
+
+ 10MB
+
+
+
+
+ [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] %logger{50} - %msg%n
+ UTF-8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springboot/morning-check/src/main/resources/mapper/studentmapper.xml b/springboot/morning-check/src/main/resources/mapper/studentmapper.xml
new file mode 100644
index 0000000..d4fa244
--- /dev/null
+++ b/springboot/morning-check/src/main/resources/mapper/studentmapper.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springboot/morning-check/src/main/resources/mapper/usermapper.xml b/springboot/morning-check/src/main/resources/mapper/usermapper.xml
new file mode 100644
index 0000000..3a482f5
--- /dev/null
+++ b/springboot/morning-check/src/main/resources/mapper/usermapper.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springboot/morning-check/src/test/java/com/sincere/morningcheck/MorningCheckApplicationTests.java b/springboot/morning-check/src/test/java/com/sincere/morningcheck/MorningCheckApplicationTests.java
new file mode 100644
index 0000000..f2dabcd
--- /dev/null
+++ b/springboot/morning-check/src/test/java/com/sincere/morningcheck/MorningCheckApplicationTests.java
@@ -0,0 +1,16 @@
+package com.sincere.morningcheck;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class MorningCheckApplicationTests {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/springboot/morning-check/src/test/java/com/sincere/morningcheck/MorningCheckControllerApplicationTests.java b/springboot/morning-check/src/test/java/com/sincere/morningcheck/MorningCheckControllerApplicationTests.java
new file mode 100644
index 0000000..d868b2f
--- /dev/null
+++ b/springboot/morning-check/src/test/java/com/sincere/morningcheck/MorningCheckControllerApplicationTests.java
@@ -0,0 +1,16 @@
+package com.sincere.morningcheck;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class MorningCheckControllerApplicationTests {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
--
libgit2 0.21.0