init version hrs for new gitea

This commit is contained in:
terry.wang
2025-11-13 13:52:44 +08:00
commit ab8deba513
657 changed files with 260908 additions and 0 deletions

33
.gitignore vendored Normal file
View File

@@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

92
README.md Normal file
View File

@@ -0,0 +1,92 @@
# hrs
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin http://192.168.10.240/kelfy/hrs.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](http://192.168.10.240/kelfy/hrs/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.

310
mvnw vendored Normal file
View File

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

182
mvnw.cmd vendored Normal file
View File

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

193
pom.xml Normal file
View File

@@ -0,0 +1,193 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.saye</groupId>
<artifactId>hrs</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>hrs</name>
<description>hrs</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<artifactId>log4j-to-slf4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.0</version>
</dependency>
<!--web模板引擎-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!--标签补全-->
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.21</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-autoconfigure</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.73</version>
</dependency>
<!-- excel -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.14</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.14</version>
</dependency>
<!-- 防xss -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.gitee.qdbp.thirdparty</groupId>
<artifactId>ueditor</artifactId>
<version>1.4.3.3</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.6</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.2-jre</version>
</dependency>
</dependencies>
<build>
<plugins>
<!--
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
<configuration>
配置文件的位置
<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
<overwrite>true</overwrite>
<verbose>true</verbose>
</configuration>
</plugin> -->
</plugins>
</build>
</project>

View File

@@ -0,0 +1,127 @@
package com.baidu.ueditor;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.baidu.ueditor.define.ActionMap;
import com.baidu.ueditor.define.AppInfo;
import com.baidu.ueditor.define.BaseState;
import com.baidu.ueditor.define.State;
import com.baidu.ueditor.hunter.FileManager;
import com.baidu.ueditor.hunter.ImageHunter;
import com.baidu.ueditor.upload.Uploader;
public class ActionEnter {
private HttpServletRequest request = null;
private String rootPath = null;
private String contextPath = null;
private String actionType = null;
private ConfigManager configManager = null;
public ActionEnter ( HttpServletRequest request, String rootPath ) {
this.request = request;
this.rootPath = rootPath;
this.actionType = request.getParameter( "action" );
this.contextPath = request.getContextPath();
this.configManager = ConfigManager.getInstance( this.rootPath, this.contextPath, request.getRequestURI() );
}
public String exec () {
String callbackName = this.request.getParameter("callback");
if ( callbackName != null ) {
if ( !validCallbackName( callbackName ) ) {
return new BaseState( false, AppInfo.ILLEGAL ).toJSONString();
}
return callbackName+"("+this.invoke()+");";
} else {
return this.invoke();
}
}
public String invoke() {
if ( actionType == null || !ActionMap.mapping.containsKey( actionType ) ) {
return new BaseState( false, AppInfo.INVALID_ACTION ).toJSONString();
}
if ( this.configManager == null || !this.configManager.valid() ) {
return new BaseState( false, AppInfo.CONFIG_ERROR ).toJSONString();
}
State state = null;
int actionCode = ActionMap.getType( this.actionType );
Map<String, Object> conf = null;
switch ( actionCode ) {
case ActionMap.CONFIG:
return this.configManager.getAllConfig().toString();
case ActionMap.UPLOAD_IMAGE:
case ActionMap.UPLOAD_SCRAWL:
case ActionMap.UPLOAD_VIDEO:
case ActionMap.UPLOAD_FILE:
conf = this.configManager.getConfig( actionCode );
state = new Uploader( request, conf ).doExec();
break;
case ActionMap.CATCH_IMAGE:
conf = configManager.getConfig( actionCode );
String[] list = this.request.getParameterValues( (String)conf.get( "fieldName" ) );
state = new ImageHunter( conf ).capture( list );
break;
case ActionMap.LIST_IMAGE:
case ActionMap.LIST_FILE:
conf = configManager.getConfig( actionCode );
int start = this.getStartIndex();
state = new FileManager( conf ).listFile( start );
break;
}
return state.toJSONString();
}
public int getStartIndex () {
String start = this.request.getParameter( "start" );
try {
return Integer.parseInt( start );
} catch ( Exception e ) {
return 0;
}
}
/**
* callback参数验证
*/
public boolean validCallbackName ( String name ) {
if ( name.matches( "^[a-zA-Z_]+[\\w0-9_]*$" ) ) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,230 @@
package com.baidu.ueditor;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
import com.baidu.ueditor.define.ActionMap;
/**
* 配置管理器
* @author hancong03@baidu.com
*
*/
public final class ConfigManager {
private final String rootPath;
private final String originalPath;
private final String contextPath;
private static final String configFileName = "config.json";
private String parentPath = null;
private JSONObject jsonConfig = null;
// 涂鸦上传filename定义
private final static String SCRAWL_FILE_NAME = "scrawl";
// 远程图片抓取filename定义
private final static String REMOTE_FILE_NAME = "remote";
/*
* 通过一个给定的路径构建一个配置管理器, 该管理器要求地址路径所在目录下必须存在config.properties文件
*/
private ConfigManager ( String rootPath, String contextPath, String uri ) throws FileNotFoundException, IOException {
rootPath = rootPath.replace( "\\", "/" );
this.rootPath = rootPath;
this.contextPath = contextPath;
if ( contextPath.length() > 0 ) {
this.originalPath = this.rootPath + uri.substring( contextPath.length() );
} else {
this.originalPath = this.rootPath + uri;
}
this.initEnv();
}
/**
* 配置管理器构造工厂
* @param rootPath 服务器根路径
* @param contextPath 服务器所在项目路径
* @param uri 当前访问的uri
* @return 配置管理器实例或者null
*/
public static ConfigManager getInstance ( String rootPath, String contextPath, String uri ) {
try {
return new ConfigManager(rootPath, contextPath, uri);
} catch ( Exception e ) {
return null;
}
}
// 验证配置文件加载是否正确
public boolean valid () {
return this.jsonConfig != null;
}
public JSONObject getAllConfig () {
return this.jsonConfig;
}
public Map<String, Object> getConfig ( int type ) {
Map<String, Object> conf = new HashMap<String, Object>();
String savePath = null;
switch ( type ) {
case ActionMap.UPLOAD_FILE:
conf.put( "isBase64", "false" );
conf.put( "maxSize", this.jsonConfig.getLong( "fileMaxSize" ) );
conf.put( "allowFiles", this.getArray( "fileAllowFiles" ) );
conf.put( "fieldName", this.jsonConfig.getString( "fileFieldName" ) );
savePath = this.jsonConfig.getString( "filePathFormat" );
break;
case ActionMap.UPLOAD_IMAGE:
conf.put( "isBase64", "false" );
conf.put( "maxSize", this.jsonConfig.getLong( "imageMaxSize" ) );
conf.put( "allowFiles", this.getArray( "imageAllowFiles" ) );
conf.put( "fieldName", this.jsonConfig.getString( "imageFieldName" ) );
savePath = this.jsonConfig.getString( "imagePathFormat" );
break;
case ActionMap.UPLOAD_VIDEO:
conf.put( "maxSize", this.jsonConfig.getLong( "videoMaxSize" ) );
conf.put( "allowFiles", this.getArray( "videoAllowFiles" ) );
conf.put( "fieldName", this.jsonConfig.getString( "videoFieldName" ) );
savePath = this.jsonConfig.getString( "videoPathFormat" );
break;
case ActionMap.UPLOAD_SCRAWL:
conf.put( "filename", ConfigManager.SCRAWL_FILE_NAME );
conf.put( "maxSize", this.jsonConfig.getLong( "scrawlMaxSize" ) );
conf.put( "fieldName", this.jsonConfig.getString( "scrawlFieldName" ) );
conf.put( "isBase64", "true" );
savePath = this.jsonConfig.getString( "scrawlPathFormat" );
break;
case ActionMap.CATCH_IMAGE:
conf.put( "filename", ConfigManager.REMOTE_FILE_NAME );
conf.put( "filter", this.getArray( "catcherLocalDomain" ) );
conf.put( "maxSize", this.jsonConfig.getLong( "catcherMaxSize" ) );
conf.put( "allowFiles", this.getArray( "catcherAllowFiles" ) );
conf.put( "fieldName", this.jsonConfig.getString( "catcherFieldName" ) + "[]" );
savePath = this.jsonConfig.getString( "catcherPathFormat" );
break;
case ActionMap.LIST_IMAGE:
conf.put( "allowFiles", this.getArray( "imageManagerAllowFiles" ) );
conf.put( "dir", this.jsonConfig.getString( "imageManagerListPath" ) );
conf.put( "count", this.jsonConfig.getInt( "imageManagerListSize" ) );
break;
case ActionMap.LIST_FILE:
conf.put( "allowFiles", this.getArray( "fileManagerAllowFiles" ) );
conf.put( "dir", this.jsonConfig.getString( "fileManagerListPath" ) );
conf.put( "count", this.jsonConfig.getInt( "fileManagerListSize" ) );
break;
}
conf.put( "basePath", this.jsonConfig.getString("basePath") );
conf.put( "savePath", savePath );
conf.put( "rootPath", this.rootPath );
return conf;
}
private void initEnv () throws FileNotFoundException, IOException {
File file = new File( this.originalPath );
if ( !file.isAbsolute() ) {
file = new File( file.getAbsolutePath() );
}
this.parentPath = file.getParent();
String configContent = this.readFile( this.getConfigPath() );
try{
JSONObject jsonConfig = new JSONObject( configContent );
this.jsonConfig = jsonConfig;
} catch ( Exception e ) {
this.jsonConfig = null;
}
}
private String getConfigPath () {
//return this.parentPath + File.separator + ConfigManager.configFileName;
/*=========手动修改部分=========*/
try{
//获取classpath下的config.json路径
return this.getClass().getClassLoader().getResource("config.json").toURI().getPath();
}catch (URISyntaxException e){
return null;
}
}
private String[] getArray ( String key ) {
JSONArray jsonArray = this.jsonConfig.getJSONArray( key );
String[] result = new String[ jsonArray.length() ];
for ( int i = 0, len = jsonArray.length(); i < len; i++ ) {
result[i] = jsonArray.getString( i );
}
return result;
}
private String readFile ( String path ) throws IOException {
StringBuilder builder = new StringBuilder();
try {
InputStreamReader reader = new InputStreamReader( new FileInputStream( path ), "UTF-8" );
BufferedReader bfReader = new BufferedReader( reader );
String tmpContent = null;
while ( ( tmpContent = bfReader.readLine() ) != null ) {
builder.append( tmpContent );
}
bfReader.close();
} catch ( UnsupportedEncodingException e ) {
// 忽略
}
return this.filter( builder.toString() );
}
// 过滤输入字符串, 剔除多行注释以及替换掉反斜杠
private String filter ( String input ) {
return input.replaceAll( "/\\*[\\s\\S]*?\\*/", "" );
}
}

View File

@@ -0,0 +1,24 @@
package com.baidu.ueditor;
public class Encoder {
public static String toUnicode ( String input ) {
StringBuilder builder = new StringBuilder();
char[] chars = input.toCharArray();
for ( char ch : chars ) {
if ( ch < 256 ) {
builder.append( ch );
} else {
builder.append( "\\u" + Integer.toHexString( ch& 0xffff ) );
}
}
return builder.toString();
}
}

View File

@@ -0,0 +1,157 @@
package com.baidu.ueditor;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PathFormat {
private static final String TIME = "time";
private static final String FULL_YEAR = "yyyy";
private static final String YEAR = "yy";
private static final String MONTH = "mm";
private static final String DAY = "dd";
private static final String HOUR = "hh";
private static final String MINUTE = "ii";
private static final String SECOND = "ss";
private static final String RAND = "rand";
private static Date currentDate = null;
public static String parse ( String input ) {
Pattern pattern = Pattern.compile( "\\{([^\\}]+)\\}", Pattern.CASE_INSENSITIVE );
Matcher matcher = pattern.matcher(input);
PathFormat.currentDate = new Date();
StringBuffer sb = new StringBuffer();
while ( matcher.find() ) {
matcher.appendReplacement(sb, PathFormat.getString( matcher.group( 1 ) ) );
}
matcher.appendTail(sb);
return sb.toString();
}
/**
* 格式化路径, 把windows路径替换成标准路径
* @param input 待格式化的路径
* @return 格式化后的路径
*/
public static String format ( String input ) {
return input.replace( "\\", "/" );
}
public static String parse ( String input, String filename ) {
Pattern pattern = Pattern.compile( "\\{([^\\}]+)\\}", Pattern.CASE_INSENSITIVE );
Matcher matcher = pattern.matcher(input);
String matchStr = null;
PathFormat.currentDate = new Date();
StringBuffer sb = new StringBuffer();
while ( matcher.find() ) {
matchStr = matcher.group( 1 );
if ( matchStr.indexOf( "filename" ) != -1 ) {
filename = filename.replace( "$", "\\$" ).replaceAll( "[\\/:*?\"<>|]", "" );
matcher.appendReplacement(sb, filename );
} else {
matcher.appendReplacement(sb, PathFormat.getString( matchStr ) );
}
}
matcher.appendTail(sb);
return sb.toString();
}
private static String getString ( String pattern ) {
pattern = pattern.toLowerCase();
// time 处理
if ( pattern.indexOf( PathFormat.TIME ) != -1 ) {
return PathFormat.getTimestamp();
} else if ( pattern.indexOf( PathFormat.FULL_YEAR ) != -1 ) {
return PathFormat.getFullYear();
} else if ( pattern.indexOf( PathFormat.YEAR ) != -1 ) {
return PathFormat.getYear();
} else if ( pattern.indexOf( PathFormat.MONTH ) != -1 ) {
return PathFormat.getMonth();
} else if ( pattern.indexOf( PathFormat.DAY ) != -1 ) {
return PathFormat.getDay();
} else if ( pattern.indexOf( PathFormat.HOUR ) != -1 ) {
return PathFormat.getHour();
} else if ( pattern.indexOf( PathFormat.MINUTE ) != -1 ) {
return PathFormat.getMinute();
} else if ( pattern.indexOf( PathFormat.SECOND ) != -1 ) {
return PathFormat.getSecond();
} else if ( pattern.indexOf( PathFormat.RAND ) != -1 ) {
return PathFormat.getRandom( pattern );
}
return pattern;
}
private static String getTimestamp () {
return System.currentTimeMillis() + "";
}
private static String getFullYear () {
return new SimpleDateFormat( "yyyy" ).format( PathFormat.currentDate );
}
private static String getYear () {
return new SimpleDateFormat( "yy" ).format( PathFormat.currentDate );
}
private static String getMonth () {
return new SimpleDateFormat( "MM" ).format( PathFormat.currentDate );
}
private static String getDay () {
return new SimpleDateFormat( "dd" ).format( PathFormat.currentDate );
}
private static String getHour () {
return new SimpleDateFormat( "HH" ).format( PathFormat.currentDate );
}
private static String getMinute () {
return new SimpleDateFormat( "mm" ).format( PathFormat.currentDate );
}
private static String getSecond () {
return new SimpleDateFormat( "ss" ).format( PathFormat.currentDate );
}
private static String getRandom ( String pattern ) {
int length = 0;
pattern = pattern.split( ":" )[ 1 ].trim();
length = Integer.parseInt( pattern );
return ( Math.random() + "" ).replace( ".", "" ).substring( 0, length );
}
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}

View File

@@ -0,0 +1,42 @@
package com.baidu.ueditor.define;
import java.util.Map;
import java.util.HashMap;
/**
* 定义请求action类型
* @author hancong03@baidu.com
*
*/
@SuppressWarnings("serial")
public final class ActionMap {
public static final Map<String, Integer> mapping;
// 获取配置请求
public static final int CONFIG = 0;
public static final int UPLOAD_IMAGE = 1;
public static final int UPLOAD_SCRAWL = 2;
public static final int UPLOAD_VIDEO = 3;
public static final int UPLOAD_FILE = 4;
public static final int CATCH_IMAGE = 5;
public static final int LIST_FILE = 6;
public static final int LIST_IMAGE = 7;
static {
mapping = new HashMap<String, Integer>(){{
put( "config", ActionMap.CONFIG );
put( "uploadimage", ActionMap.UPLOAD_IMAGE );
put( "uploadscrawl", ActionMap.UPLOAD_SCRAWL );
put( "uploadvideo", ActionMap.UPLOAD_VIDEO );
put( "uploadfile", ActionMap.UPLOAD_FILE );
put( "catchimage", ActionMap.CATCH_IMAGE );
put( "listfile", ActionMap.LIST_FILE );
put( "listimage", ActionMap.LIST_IMAGE );
}};
}
public static int getType ( String key ) {
return ActionMap.mapping.get( key );
}
}

View File

@@ -0,0 +1,5 @@
package com.baidu.ueditor.define;
public enum ActionState {
UNKNOW_ERROR
}

View File

@@ -0,0 +1,77 @@
package com.baidu.ueditor.define;
import java.util.HashMap;
import java.util.Map;
public final class AppInfo {
public static final int SUCCESS = 0;
public static final int MAX_SIZE = 1;
public static final int PERMISSION_DENIED = 2;
public static final int FAILED_CREATE_FILE = 3;
public static final int IO_ERROR = 4;
public static final int NOT_MULTIPART_CONTENT = 5;
public static final int PARSE_REQUEST_ERROR = 6;
public static final int NOTFOUND_UPLOAD_DATA = 7;
public static final int NOT_ALLOW_FILE_TYPE = 8;
public static final int INVALID_ACTION = 101;
public static final int CONFIG_ERROR = 102;
public static final int PREVENT_HOST = 201;
public static final int CONNECTION_ERROR = 202;
public static final int REMOTE_FAIL = 203;
public static final int NOT_DIRECTORY = 301;
public static final int NOT_EXIST = 302;
public static final int ILLEGAL = 401;
public static Map<Integer, String> info = new HashMap<Integer, String>(){{
put( AppInfo.SUCCESS, "SUCCESS" );
// 无效的Action
put( AppInfo.INVALID_ACTION, "\u65E0\u6548\u7684Action" );
// 配置文件初始化失败
put( AppInfo.CONFIG_ERROR, "\u914D\u7F6E\u6587\u4EF6\u521D\u59CB\u5316\u5931\u8D25" );
// 抓取远程图片失败
put( AppInfo.REMOTE_FAIL, "\u6293\u53D6\u8FDC\u7A0B\u56FE\u7247\u5931\u8D25" );
// 被阻止的远程主机
put( AppInfo.PREVENT_HOST, "\u88AB\u963B\u6B62\u7684\u8FDC\u7A0B\u4E3B\u673A" );
// 远程连接出错
put( AppInfo.CONNECTION_ERROR, "\u8FDC\u7A0B\u8FDE\u63A5\u51FA\u9519" );
// "文件大小超出限制"
put( AppInfo.MAX_SIZE, "\u6587\u4ef6\u5927\u5c0f\u8d85\u51fa\u9650\u5236" );
// 权限不足, 多指写权限
put( AppInfo.PERMISSION_DENIED, "\u6743\u9650\u4E0D\u8DB3" );
// 创建文件失败
put( AppInfo.FAILED_CREATE_FILE, "\u521B\u5EFA\u6587\u4EF6\u5931\u8D25" );
// IO错误
put( AppInfo.IO_ERROR, "IO\u9519\u8BEF" );
// 上传表单不是multipart/form-data类型
put( AppInfo.NOT_MULTIPART_CONTENT, "\u4E0A\u4F20\u8868\u5355\u4E0D\u662Fmultipart/form-data\u7C7B\u578B" );
// 解析上传表单错误
put( AppInfo.PARSE_REQUEST_ERROR, "\u89E3\u6790\u4E0A\u4F20\u8868\u5355\u9519\u8BEF" );
// 未找到上传数据
put( AppInfo.NOTFOUND_UPLOAD_DATA, "\u672A\u627E\u5230\u4E0A\u4F20\u6570\u636E" );
// 不允许的文件类型
put( AppInfo.NOT_ALLOW_FILE_TYPE, "\u4E0D\u5141\u8BB8\u7684\u6587\u4EF6\u7C7B\u578B" );
// 指定路径不是目录
put( AppInfo.NOT_DIRECTORY, "\u6307\u5B9A\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55" );
// 指定路径并不存在
put( AppInfo.NOT_EXIST, "\u6307\u5B9A\u8DEF\u5F84\u5E76\u4E0D\u5B58\u5728" );
// callback参数名不合法
put( AppInfo.ILLEGAL, "Callback\u53C2\u6570\u540D\u4E0D\u5408\u6CD5" );
}};
public static String getStateInfo ( int key ) {
return AppInfo.info.get( key );
}
}

View File

@@ -0,0 +1,90 @@
package com.baidu.ueditor.define;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import com.baidu.ueditor.Encoder;
public class BaseState implements State {
private boolean state = false;
private String info = null;
private Map<String, String> infoMap = new HashMap<String, String>();
public BaseState () {
this.state = true;
}
public BaseState ( boolean state ) {
this.setState( state );
}
public BaseState ( boolean state, String info ) {
this.setState( state );
this.info = info;
}
public BaseState ( boolean state, int infoCode ) {
this.setState( state );
this.info = AppInfo.getStateInfo( infoCode );
}
public boolean isSuccess () {
return this.state;
}
public void setState ( boolean state ) {
this.state = state;
}
public void setInfo ( String info ) {
this.info = info;
}
public void setInfo ( int infoCode ) {
this.info = AppInfo.getStateInfo( infoCode );
}
@Override
public String toJSONString() {
return this.toString();
}
public String toString () {
String key = null;
String stateVal = this.isSuccess() ? AppInfo.getStateInfo( AppInfo.SUCCESS ) : this.info;
StringBuilder builder = new StringBuilder();
builder.append( "{\"state\": \"" + stateVal + "\"" );
Iterator<String> iterator = this.infoMap.keySet().iterator();
while ( iterator.hasNext() ) {
key = iterator.next();
builder.append( ",\"" + key + "\": \"" + this.infoMap.get(key) + "\"" );
}
builder.append( "}" );
return Encoder.toUnicode( builder.toString() );
}
@Override
public void putInfo(String name, String val) {
this.infoMap.put(name, val);
}
@Override
public void putInfo(String name, long val) {
this.putInfo(name, val+"");
}
}

View File

@@ -0,0 +1,31 @@
package com.baidu.ueditor.define;
import java.util.HashMap;
import java.util.Map;
public class FileType {
public static final String JPG = "JPG";
private static final Map<String, String> types = new HashMap<String, String>(){{
put( FileType.JPG, ".jpg" );
}};
public static String getSuffix ( String key ) {
return FileType.types.get( key );
}
/**
* 根据给定的文件名,获取其后缀信息
* @param filename
* @return
*/
public static String getSuffixByFilename ( String filename ) {
return filename.substring( filename.lastIndexOf( "." ) ).toLowerCase();
}
}

View File

@@ -0,0 +1,20 @@
package com.baidu.ueditor.define;
import java.util.HashMap;
import java.util.Map;
public class MIMEType {
public static final Map<String, String> types = new HashMap<String, String>(){{
put( "image/gif", ".gif" );
put( "image/jpeg", ".jpg" );
put( "image/jpg", ".jpg" );
put( "image/png", ".png" );
put( "image/bmp", ".bmp" );
}};
public static String getSuffix ( String mime ) {
return MIMEType.types.get( mime );
}
}

View File

@@ -0,0 +1,112 @@
package com.baidu.ueditor.define;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.baidu.ueditor.Encoder;
/**
* 多状态集合状态
* 其包含了多个状态的集合, 其本身自己也是一个状态
* @author hancong03@baidu.com
*
*/
public class MultiState implements State {
private boolean state = false;
private String info = null;
private Map<String, Long> intMap = new HashMap<String, Long>();
private Map<String, String> infoMap = new HashMap<String, String>();
private List<String> stateList = new ArrayList<String>();
public MultiState ( boolean state ) {
this.state = state;
}
public MultiState ( boolean state, String info ) {
this.state = state;
this.info = info;
}
public MultiState ( boolean state, int infoKey ) {
this.state = state;
this.info = AppInfo.getStateInfo( infoKey );
}
@Override
public boolean isSuccess() {
return this.state;
}
public void addState ( State state ) {
stateList.add( state.toJSONString() );
}
/**
* 该方法调用无效果
*/
@Override
public void putInfo(String name, String val) {
this.infoMap.put(name, val);
}
@Override
public String toJSONString() {
String stateVal = this.isSuccess() ? AppInfo.getStateInfo( AppInfo.SUCCESS ) : this.info;
StringBuilder builder = new StringBuilder();
builder.append( "{\"state\": \"" + stateVal + "\"" );
// 数字转换
Iterator<String> iterator = this.intMap.keySet().iterator();
while ( iterator.hasNext() ) {
stateVal = iterator.next();
builder.append( ",\""+ stateVal +"\": " + this.intMap.get( stateVal ) );
}
iterator = this.infoMap.keySet().iterator();
while ( iterator.hasNext() ) {
stateVal = iterator.next();
builder.append( ",\""+ stateVal +"\": \"" + this.infoMap.get( stateVal ) + "\"" );
}
builder.append( ", list: [" );
iterator = this.stateList.iterator();
while ( iterator.hasNext() ) {
builder.append( iterator.next() + "," );
}
if ( this.stateList.size() > 0 ) {
builder.deleteCharAt( builder.length() - 1 );
}
builder.append( " ]}" );
return Encoder.toUnicode( builder.toString() );
}
@Override
public void putInfo(String name, long val) {
this.intMap.put( name, val );
}
}

View File

@@ -0,0 +1,18 @@
package com.baidu.ueditor.define;
/**
* 处理状态接口
* @author hancong03@baidu.com
*
*/
public interface State {
public boolean isSuccess ();
public void putInfo( String name, String val );
public void putInfo ( String name, long val );
public String toJSONString ();
}

View File

@@ -0,0 +1,112 @@
package com.baidu.ueditor.hunter;
import java.io.File;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import com.baidu.ueditor.PathFormat;
import com.baidu.ueditor.define.AppInfo;
import com.baidu.ueditor.define.BaseState;
import com.baidu.ueditor.define.MultiState;
import com.baidu.ueditor.define.State;
public class FileManager {
private String dir = null;
private String rootPath = null;
private String[] allowFiles = null;
private int count = 0;
public FileManager ( Map<String, Object> conf ) {
this.rootPath = (String)conf.get( "rootPath" );
this.dir = this.rootPath + (String)conf.get( "dir" );
this.allowFiles = this.getAllowFiles( conf.get("allowFiles") );
this.count = (Integer)conf.get( "count" );
}
public State listFile ( int index ) {
File dir = new File( this.dir );
State state = null;
if ( !dir.exists() ) {
return new BaseState( false, AppInfo.NOT_EXIST );
}
if ( !dir.isDirectory() ) {
return new BaseState( false, AppInfo.NOT_DIRECTORY );
}
Collection<File> list = FileUtils.listFiles( dir, this.allowFiles, true );
if ( index < 0 || index > list.size() ) {
state = new MultiState( true );
} else {
Object[] fileList = Arrays.copyOfRange( list.toArray(), index, index + this.count );
state = this.getState( fileList );
}
state.putInfo( "start", index );
state.putInfo( "total", list.size() );
return state;
}
private State getState ( Object[] files ) {
MultiState state = new MultiState( true );
BaseState fileState = null;
File file = null;
for ( Object obj : files ) {
if ( obj == null ) {
break;
}
file = (File)obj;
fileState = new BaseState( true );
fileState.putInfo( "url", PathFormat.format( this.getPath( file ) ) );
state.addState( fileState );
}
return state;
}
private String getPath ( File file ) {
String path = file.getAbsolutePath();
return path.replace( this.rootPath, "/" );
}
private String[] getAllowFiles ( Object fileExt ) {
String[] exts = null;
String ext = null;
if ( fileExt == null ) {
return new String[ 0 ];
}
exts = (String[])fileExt;
for ( int i = 0, len = exts.length; i < len; i++ ) {
ext = exts[ i ];
exts[ i ] = ext.replace( ".", "" );
}
return exts;
}
}

View File

@@ -0,0 +1,144 @@
package com.baidu.ueditor.hunter;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import com.baidu.ueditor.PathFormat;
import com.baidu.ueditor.define.AppInfo;
import com.baidu.ueditor.define.BaseState;
import com.baidu.ueditor.define.MIMEType;
import com.baidu.ueditor.define.MultiState;
import com.baidu.ueditor.define.State;
import com.baidu.ueditor.upload.StorageManager;
/**
* 图片抓取器
* @author hancong03@baidu.com
*
*/
public class ImageHunter {
private String filename = null;
private String savePath = null;
private String rootPath = null;
private List<String> allowTypes = null;
private long maxSize = -1;
private List<String> filters = null;
public ImageHunter ( Map<String, Object> conf ) {
this.filename = (String)conf.get( "filename" );
this.savePath = (String)conf.get( "savePath" );
this.rootPath = (String)conf.get( "rootPath" );
this.maxSize = (Long)conf.get( "maxSize" );
this.allowTypes = Arrays.asList( (String[])conf.get( "allowFiles" ) );
this.filters = Arrays.asList( (String[])conf.get( "filter" ) );
}
public State capture ( String[] list ) {
MultiState state = new MultiState( true );
for ( String source : list ) {
state.addState( captureRemoteData( source ) );
}
return state;
}
public State captureRemoteData ( String urlStr ) {
HttpURLConnection connection = null;
URL url = null;
String suffix = null;
try {
url = new URL( urlStr );
if ( !validHost( url.getHost() ) ) {
return new BaseState( false, AppInfo.PREVENT_HOST );
}
connection = (HttpURLConnection) url.openConnection();
connection.setInstanceFollowRedirects( true );
connection.setUseCaches( true );
if ( !validContentState( connection.getResponseCode() ) ) {
return new BaseState( false, AppInfo.CONNECTION_ERROR );
}
suffix = MIMEType.getSuffix( connection.getContentType() );
if ( !validFileType( suffix ) ) {
return new BaseState( false, AppInfo.NOT_ALLOW_FILE_TYPE );
}
if ( !validFileSize( connection.getContentLength() ) ) {
return new BaseState( false, AppInfo.MAX_SIZE );
}
String savePath = this.getPath( this.savePath, this.filename, suffix );
String physicalPath = this.rootPath + savePath;
State state = StorageManager.saveFileByInputStream( connection.getInputStream(), physicalPath );
if ( state.isSuccess() ) {
state.putInfo( "url", PathFormat.format( savePath ) );
state.putInfo( "source", urlStr );
}
return state;
} catch ( Exception e ) {
return new BaseState( false, AppInfo.REMOTE_FAIL );
}
}
private String getPath ( String savePath, String filename, String suffix ) {
return PathFormat.parse( savePath + suffix, filename );
}
private boolean validHost ( String hostname ) {
try {
InetAddress ip = InetAddress.getByName(hostname);
if (ip.isSiteLocalAddress()) {
return false;
}
} catch (UnknownHostException e) {
return false;
}
return !filters.contains( hostname );
}
private boolean validContentState ( int code ) {
return HttpURLConnection.HTTP_OK == code;
}
private boolean validFileType ( String type ) {
return this.allowTypes.contains( type );
}
private boolean validFileSize ( int size ) {
return size < this.maxSize;
}
}

View File

@@ -0,0 +1,52 @@
package com.baidu.ueditor.upload;
import com.baidu.ueditor.PathFormat;
import com.baidu.ueditor.define.AppInfo;
import com.baidu.ueditor.define.BaseState;
import com.baidu.ueditor.define.FileType;
import com.baidu.ueditor.define.State;
import java.util.Map;
import org.apache.commons.codec.binary.Base64;
public final class Base64Uploader {
public static State save(String content, Map<String, Object> conf) {
byte[] data = decode(content);
long maxSize = ((Long) conf.get("maxSize")).longValue();
if (!validSize(data, maxSize)) {
return new BaseState(false, AppInfo.MAX_SIZE);
}
String suffix = FileType.getSuffix("JPG");
String savePath = PathFormat.parse((String) conf.get("savePath"),
(String) conf.get("filename"));
savePath = savePath + suffix;
String physicalPath = (String) conf.get("rootPath") + savePath;
State storageState = StorageManager.saveBinaryFile(data, physicalPath);
if (storageState.isSuccess()) {
storageState.putInfo("url", PathFormat.format(savePath));
storageState.putInfo("type", suffix);
storageState.putInfo("original", "");
}
return storageState;
}
private static byte[] decode(String content) {
return Base64.decodeBase64(content);
}
private static boolean validSize(byte[] data, long length) {
return data.length <= length;
}
}

View File

@@ -0,0 +1,108 @@
package com.baidu.ueditor.upload;
import com.baidu.ueditor.PathFormat;
import com.baidu.ueditor.define.AppInfo;
import com.baidu.ueditor.define.BaseState;
import com.baidu.ueditor.define.FileType;
import com.baidu.ueditor.define.State;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.FileItemStream;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
public class BinaryUploader {
public static final State save(HttpServletRequest request,
Map<String, Object> conf) {
// FileItemStream fileStream = null;
// boolean isAjaxUpload = request.getHeader( "X_Requested_With" ) != null;
if (!ServletFileUpload.isMultipartContent(request)) {
return new BaseState(false, AppInfo.NOT_MULTIPART_CONTENT);
}
// ServletFileUpload upload = new ServletFileUpload(
// new DiskFileItemFactory());
//
// if ( isAjaxUpload ) {
// upload.setHeaderEncoding( "UTF-8" );
// }
try {
// FileItemIterator iterator = upload.getItemIterator(request);
//
// while (iterator.hasNext()) {
// fileStream = iterator.next();
//
// if (!fileStream.isFormField())
// break;
// fileStream = null;
// }
//
// if (fileStream == null) {
// return new BaseState(false, AppInfo.NOTFOUND_UPLOAD_DATA);
// }
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
MultipartFile multipartFile = multipartRequest.getFile(conf.get("fieldName").toString());
if(multipartFile==null){
return new BaseState(false, AppInfo.NOTFOUND_UPLOAD_DATA);
}
String savePath = (String) conf.get("savePath");
//String originFileName = fileStream.getName();
String originFileName = multipartFile.getOriginalFilename();
String suffix = FileType.getSuffixByFilename(originFileName);
originFileName = originFileName.substring(0,
originFileName.length() - suffix.length());
savePath = savePath + suffix;
long maxSize = ((Long) conf.get("maxSize")).longValue();
if (!validType(suffix, (String[]) conf.get("allowFiles"))) {
return new BaseState(false, AppInfo.NOT_ALLOW_FILE_TYPE);
}
savePath = PathFormat.parse(savePath, originFileName);
String basePath=(String) conf.get("basePath");
String physicalPath = basePath + savePath;
//InputStream is = fileStream.openStream();
InputStream is = multipartFile.getInputStream();
State storageState = StorageManager.saveFileByInputStream(is,
physicalPath, maxSize);
is.close();
if (storageState.isSuccess()) {
storageState.putInfo("url", PathFormat.format(savePath));
storageState.putInfo("type", suffix);
storageState.putInfo("original", originFileName + suffix);
}
return storageState;
// } catch (FileUploadException e) {
// return new BaseState(false, AppInfo.PARSE_REQUEST_ERROR);
} catch (IOException e) {
}
return new BaseState(false, AppInfo.IO_ERROR);
}
private static boolean validType(String type, String[] allowTypes) {
List<String> list = Arrays.asList(allowTypes);
return list.contains(type);
}
}

View File

@@ -0,0 +1,156 @@
package com.baidu.ueditor.upload;
import com.baidu.ueditor.define.AppInfo;
import com.baidu.ueditor.define.BaseState;
import com.baidu.ueditor.define.State;
import org.apache.commons.io.FileUtils;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class StorageManager {
public static final int BUFFER_SIZE = 8192;
public StorageManager() {
}
public static State saveBinaryFile(byte[] data, String path) {
File file = new File(path);
State state = valid(file);
if (!state.isSuccess()) {
return state;
}
try {
BufferedOutputStream bos = new BufferedOutputStream(
new FileOutputStream(file));
bos.write(data);
bos.flush();
bos.close();
} catch (IOException ioe) {
return new BaseState(false, AppInfo.IO_ERROR);
}
state = new BaseState(true, file.getAbsolutePath());
state.putInfo( "size", data.length );
state.putInfo( "title", file.getName() );
return state;
}
public static State saveFileByInputStream(InputStream is, String path,
long maxSize) {
State state = null;
File tmpFile = getTmpFile();
byte[] dataBuf = new byte[ 2048 ];
BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE);
try {
BufferedOutputStream bos = new BufferedOutputStream(
new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE);
int count = 0;
while ((count = bis.read(dataBuf)) != -1) {
bos.write(dataBuf, 0, count);
}
bos.flush();
bos.close();
if (tmpFile.length() > maxSize) {
tmpFile.delete();
return new BaseState(false, AppInfo.MAX_SIZE);
}
state = saveTmpFile(tmpFile, path);
if (!state.isSuccess()) {
tmpFile.delete();
}
return state;
} catch (IOException e) {
}
return new BaseState(false, AppInfo.IO_ERROR);
}
public static State saveFileByInputStream(InputStream is, String path) {
State state = null;
File tmpFile = getTmpFile();
byte[] dataBuf = new byte[ 2048 ];
BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE);
try {
BufferedOutputStream bos = new BufferedOutputStream(
new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE);
int count = 0;
while ((count = bis.read(dataBuf)) != -1) {
bos.write(dataBuf, 0, count);
}
bos.flush();
bos.close();
state = saveTmpFile(tmpFile, path);
if (!state.isSuccess()) {
tmpFile.delete();
}
return state;
} catch (IOException e) {
}
return new BaseState(false, AppInfo.IO_ERROR);
}
private static File getTmpFile() {
File tmpDir = FileUtils.getTempDirectory();
String tmpFileName = (Math.random() * 10000 + "").replace(".", "");
return new File(tmpDir, tmpFileName);
}
private static State saveTmpFile(File tmpFile, String path) {
State state = null;
File targetFile = new File(path);
if (targetFile.canWrite()) {
return new BaseState(false, AppInfo.PERMISSION_DENIED);
}
try {
FileUtils.moveFile(tmpFile, targetFile);
} catch (IOException e) {
return new BaseState(false, AppInfo.IO_ERROR);
}
state = new BaseState(true);
state.putInfo( "size", targetFile.length() );
state.putInfo( "title", targetFile.getName() );
return state;
}
private static State valid(File file) {
File parentPath = file.getParentFile();
if ((!parentPath.exists()) && (!parentPath.mkdirs())) {
return new BaseState(false, AppInfo.FAILED_CREATE_FILE);
}
if (!parentPath.canWrite()) {
return new BaseState(false, AppInfo.PERMISSION_DENIED);
}
return new BaseState(true);
}
}

View File

@@ -0,0 +1,29 @@
package com.baidu.ueditor.upload;
import com.baidu.ueditor.define.State;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
public class Uploader {
private HttpServletRequest request = null;
private Map<String, Object> conf = null;
public Uploader(HttpServletRequest request, Map<String, Object> conf) {
this.request = request;
this.conf = conf;
}
public final State doExec() {
String filedName = (String) this.conf.get("fieldName");
State state = null;
if ("true".equals(this.conf.get("isBase64"))) {
state = Base64Uploader.save(this.request.getParameter(filedName),
this.conf);
} else {
state = BinaryUploader.save(this.request, this.conf);
}
return state;
}
}

View File

@@ -0,0 +1,20 @@
package com.saye.hrs;
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.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@MapperScan("com.saye.hrs.mapper")
@EnableTransactionManagement //开启事务
@EnableScheduling
public class HrsApplication {
public static void main(String[] args) {
SpringApplication.run(HrsApplication.class, args);
}
}

View File

@@ -0,0 +1,13 @@
package com.saye.hrs;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(HrsApplication.class);
}
}

View File

@@ -0,0 +1,120 @@
package com.saye.hrs.commons;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.Serializable;
/**
* 用于封装AJAX调用以后的JSON返回值
* 其中正确返回值:
* {state:0, data:返回数据, message:错误消息}
* 错误返回值:
* {state:1, data:null, message:错误消息}
**/
public class JsonResult implements Serializable {
private static final long serialVersionUID = -3644950655568598241L;
//定义jackson对象
private static final ObjectMapper MAPPER = new ObjectMapper();
/**
* 返回是否成功的状态, 0表示成功,
* 1或其他值 表示失败
*/
private boolean state;
/**
* 成功时候,返回的JSON数据
*/
private Object data;
/**
* 是错误时候的错误消息
*/
private String message;
public JsonResult() {
}
public JsonResult(boolean state, Object data, String message) {
this.state = state;
this.data = data;
this.message = message;
}
public JsonResult(Throwable e){
state = false;
data=null;
message=e.getMessage();
}
public JsonResult(Object data){
state = true;
this.data=data;
message="";
}
public boolean isState() {
return state;
}
public void setState(boolean state) {
this.state = state;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public static String jsonResultSuccess(Object data, String message){
JsonResult jsonResult=new JsonResult();
jsonResult.setState(true);
jsonResult.setMessage(message);
jsonResult.setData(data);
return ObjectToJson(jsonResult);
}
public static String jsonResultFalse(String message){
JsonResult jsonResult=new JsonResult();
jsonResult.setState(false);
jsonResult.setMessage(message);
return ObjectToJson(jsonResult);
}
/**
* 将对象转化为json字符串
* @param data
* @return
*/
public static String ObjectToJson(Object data){
try{
String string = MAPPER.writeValueAsString(data);
return string;
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return null;
}
@Override
public String toString() {
return "JsonResult [state=" + state + ", data=" + data + ", message=" + message + "]";
}
}

View File

@@ -0,0 +1,95 @@
package com.saye.hrs.commons;
import org.apache.commons.codec.CharEncoding;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
/**
* <p>
* token生成工具类
* </p>
*
* @author caoshiyan
* @version V1.0
* @date 2015年12月29日 上午10:16:14
* @modificationHistory=========================逻辑或功能性重大变更记录
* @modify by user: {修改人} 2015年12月29日
* @since
*/
public class TokenGenerateUtil {
/**
* <p>
* MD5加密工具类
* </p>
* @author caoshiyan
* @version V1.0
* @date 2015年11月30日 下午4:40:16
* @param s
* @return
*
* @modificationHistory=========================逻辑或功能性重大变更记录
* @modify by user: {修改人} 2015年11月30日
* @modify by reason:{方法名}:{原因}
* @since
*/
public final static String md5(String s) {
char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
try {
MessageDigest mdTemp = MessageDigest.getInstance("MD5");
try {
// 最重要的是这句,需要加上编码类型
mdTemp.update(s.getBytes(CharEncoding.UTF_8));
} catch (UnsupportedEncodingException e) {
mdTemp.update(s.getBytes());
}
byte[] md = mdTemp.digest();
int j = md.length;
char str[] = new char[j * 2];
int k = 0;
for (int i = 0; i < j; i++) {
byte byte0 = md[i];
str[k++] = hexDigits[byte0 >>> 4 & 0xf];
str[k++] = hexDigits[byte0 & 0xf];
}
return new String(str).toUpperCase();
} catch (Exception e) {
return null;
}
}
/**
* <p>
* 生成token
* </p>
* @author caoshiyan
* @version V1.0
* @date 2015年11月18日 下午6:28:01
* @param url GET请求URL带参数串POST请求URL不带参数串参数以JSON格式传入paramJson
* @param paramJson POST参数JSON格式
* @param secret 加密secret
* @return String 生成的token值
*
* @modificationHistory=========================逻辑或功能性重大变更记录
* @modify by user: {修改人} 2015年11月18日
* @modify by reason:{方法名}:{原因}
* @since
*/
public final static String buildToken(String url, String paramJson, String secret) {
String tempUrl = null;
tempUrl = url.substring("http://".length());
int index = tempUrl.indexOf("/");
String URI = tempUrl.substring(index);
String[] ss = URI.split("\\?");
if (ss.length > 1) {
return md5(ss[0] + ss[1] + secret);
} else {
return md5(ss[0] + paramJson + secret);
}
}
public static void main(String[] args) {
System.out.println(md5("/webapi/service/vss/getPlatEncodeDeviceResList{\"pageNo\":1,\"pageSize\":1000,\"appkey\":\"8a3018ac\",\"time\":1610594097178}69befa1eca0644af8000fd23d7b8c0f7"));
}
}
///webapi/service/vss/getPlatEncodeDeviceResList{"pageNo":1,"pageSize":1000,"appkey":"8a3018ac","time":1610594044620}69befa1eca0644af8000fd23d7b8c0f7

View File

@@ -0,0 +1,329 @@
package com.saye.hrs.commons.date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class DateDUtil {
public static String yyyy_MM_dd = "yyyy-MM-dd";
public static String yyyyMMdd = "yyyyMMdd";
public static String yyyyMM = "yyyyMM";
public static String yyyy_MM = "yyyy-MM";
public static String yyyy_MM_dd_HH_00 = "yyyy-MM-dd HH:00";
public static String yyyy_MM_dd_HH_mm = "yyyy-MM-dd HH:mm";
public static String yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
public static String yyyy_MM_dd_HH_mm_ss_SS = "yyyy-MM-dd HH:mm:ss.SS";
public static String yyyyMMddHHmm = "yyyyMMddHHmm";
public static String yyyyMMddHHmmss = "yyyyMMddHHmmss";
public static String yyyyMMddHHmmssSS = "yyyyMMddHHmmssSS";
public static String yyMMdd = "yyMMdd";
public static String yyyy_MM_dd_00_00 = "yyyy-MM-dd 00:00";
/**
* 将字符串时间改成Date类型
* @param format
* @param dateStr
* @return
*/
public static Date strToDate(String format,String dateStr) {
Date date = null;
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
date = simpleDateFormat.parse(dateStr);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
/**
* 将Date时间转成字符串
* @param format
* @param date
* @return
*/
public static String DateToStr(String format,Date date){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
return simpleDateFormat.format(date);
}
/**
* 获取2个字符日期的天数差
* @param p_startDate
* @param p_endDate
* @return 天数差
*/
public static long getDaysOfTowDiffDate( String p_startDate, String p_endDate ){
Date l_startDate = DateDUtil.strToDate(DateDUtil.yyyy_MM_dd, p_startDate);
Date l_endDate = DateDUtil.strToDate(DateDUtil.yyyy_MM_dd, p_endDate);
long l_startTime = l_startDate.getTime();
long l_endTime = l_endDate.getTime();
long betweenDays = (long) ( ( l_endTime - l_startTime ) / ( 1000 * 60 * 60 * 24 ) );
return betweenDays;
}
/**
* 获取2个字符日期的天数差
* @param l_startDate
* @param l_endDate
* @return 天数差
*/
public static long getDaysOfTowDiffDate( Date l_startDate, Date l_endDate ){
long l_startTime = l_startDate.getTime();
long l_endTime = l_endDate.getTime();
long betweenDays = (long) ( ( l_endTime - l_startTime ) / ( 1000 * 60 * 60 * 24 ) );
return betweenDays;
}
/**
* 给出日期添加一段时间后的日期
* @param dateStr
* @param plus
* @return
*/
public static String getPlusDays(String format,String dateStr,long plus){
Date date = DateDUtil.strToDate(format, dateStr);
long time = date.getTime()+ plus*24*60*60*1000;
return DateDUtil.DateToStr(format,new Date(time));
}
/**
* 给出日期添加一段时间后的日期
* @param format
* @param date
* @param plus
* @return
*/
public static String getPlusDays(String format,Date date,long plus){
long time = date.getTime()+ plus*24*60*60*1000;
return DateDUtil.DateToStr(format,new Date(time));
}
/**
* 给出日期添加一段时间前的日期
* @param format
* @param date
* @param forth
* @return
*/
public static String getForthDays(String format,Date date,long forth){
long time = date.getTime()- forth*24*60*60*1000;
return DateDUtil.DateToStr(format,new Date(time));
}
/**
* 给出时间添加几个小时后的时间
* @param format
* @param dateStr
* @param plus
* @return
*/
public static String getPlusHours(String format,String dateStr,long plus){
Date date = DateDUtil.strToDate(format, dateStr);
long time = date.getTime()+ plus*60*60*1000;
return DateDUtil.DateToStr(format,new Date(time));
}
/**
* 给出时间添加几个分钟后的时间
* @param format
* @param dateStr
* @param plus
* @return
*/
public static String getPlusMinutes(String format,String dateStr,long plus){
Date date = DateDUtil.strToDate(format, dateStr);
long time = date.getTime()+ plus*60*1000;
return DateDUtil.DateToStr(format,new Date(time));
}
/**
* 得到当前时间格式如yyyy-MM-dd HH:mm:ss:SS
* @return
*/
public static String getCurrentTime(){
String nowTime = DateDUtil.DateToStr(DateDUtil.yyyy_MM_dd_HH_mm_ss_SS, new Date());
return nowTime;
}
/**
* 得到当前时间格式如yyyy-MM-dd HH:mm:ss
* @return
*/
public static String getTheCurrentTime(){
String nowTime = DateDUtil.DateToStr(DateDUtil.yyyy_MM_dd_HH_mm_ss, new Date());
return nowTime;
}
/**
* 得到当前日期格式如yyyyMMdd
* @return
*/
public static String getCurrentDate(){
String nowDate = DateDUtil.DateToStr(DateDUtil.yyyyMMdd, new Date());
return nowDate;
}
/**
* 得到当前日期格式如yyyyMMdd
* @return
*/
public static String getCurrentDate(String format){
String nowDate = DateDUtil.DateToStr(format, new Date());
return nowDate;
}
/**
* 获取2个字符日期的分钟数差
* @param p_startDate
* @param p_endDate
* @return 相差的分钟
*/
public static long getMinutesOfTowDiffDate(String p_startDate, String p_endDate ){
Date l_startDate = DateDUtil.strToDate(DateDUtil.yyyy_MM_dd_HH_mm_ss_SS, p_startDate);
Date l_endDate = DateDUtil.strToDate(DateDUtil.yyyy_MM_dd_HH_mm_ss_SS, p_endDate);
long l_startTime = l_startDate.getTime();
long l_endTime = l_endDate.getTime();
long betweenMinutes = (long) ( ( l_endTime - l_startTime ) / ( 1000 * 60) );
return betweenMinutes;
}
/**
* 获取2个字符日期的分钟数差
* @param p_startDate
* @param p_endDate
* @return 相差的分钟
*/
public static long getMinutesOfTowDiffDateMin(String format,String p_startDate, String p_endDate ){
Date l_startDate = DateDUtil.strToDate(format, p_startDate);
Date l_endDate = DateDUtil.strToDate(format, p_endDate);
long l_startTime = l_startDate.getTime();
long l_endTime = l_endDate.getTime();
long betweenMinutes = (long) ( ( l_endTime - l_startTime ) / ( 1000 * 60) );
return betweenMinutes;
}
public static long getMonthIntervalOfTowDiffDate(String p_startMonth, String p_endMonth){
Date l_startDate = DateDUtil.strToDate(DateDUtil.yyyy_MM, p_startMonth);
Date l_endDate = DateDUtil.strToDate(DateDUtil.yyyy_MM, p_endMonth);
Calendar calender = Calendar.getInstance();
calender.setTime(l_startDate);
long l_startMonth = calender.get(Calendar.MONTH)+1;
long l_startYear = calender.get(Calendar.YEAR);
calender.setTime(l_endDate);
long l_endMonth =calender.get(Calendar.MONTH)+1;
long l_endYear = calender.get(Calendar.YEAR);
long betweenYear = l_endYear - l_startYear;
long betweenMonth = (long) ( l_endMonth - l_startMonth ) ;
return betweenYear * 12 + betweenMonth;
}
/**
* 将字符串日期转为cron表达式
*/
public static String getCron(String execute_time) throws Exception{
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(yyyy_MM_dd_HH_mm_ss);
Date date = simpleDateFormat.parse(execute_time);
SimpleDateFormat dateFormat = new SimpleDateFormat("ss mm HH dd MM ? yyyy");
return dateFormat.format(date);
}
/**
* 获取当前年月日日期
*/
public static String getCDate(){
Calendar now = Calendar.getInstance();
String year=now.get(Calendar.YEAR)+"";
String month=(now.get(Calendar.MONTH) + 1) + "";
String day=now.get(Calendar.DAY_OF_MONTH)+"";
if ((now.get(Calendar.MONTH) + 1) < 10) month = "0" + month;
if (now.get(Calendar.DAY_OF_MONTH) < 10) day= "0" + day;
String nowDate = year+""+month+""+day+"";
return nowDate;
}
public static List<String> findWeekDays(String week) {
List<String> list = new ArrayList<String>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
// 今天是一周中的第几天
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
if (c.getFirstDayOfWeek() == Calendar.SUNDAY) {
c.add(Calendar.DAY_OF_MONTH, 1);
}
if("lastWeek".equals(week)){
dayOfWeek = -dayOfWeek-7;
}else if("thisWeek".equals(week)){
dayOfWeek = -dayOfWeek;
}else if("nextWeek".equals(week)){
dayOfWeek = -dayOfWeek+7;
}
// 计算一周开始的日期
c.add(Calendar.DAY_OF_MONTH, dayOfWeek);
for (int i = 1; i <= 7; i++) {
c.add(Calendar.DAY_OF_MONTH, 1);
list.add(sdf.format(c.getTime()));
}
return list;
}
public static void main(String[] args) {
System.out.println();
}
}

View File

@@ -0,0 +1,68 @@
package com.saye.hrs.commons.encrypt;
import org.apache.commons.codec.binary.Base64;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class EncryptUtil {
// AES ecb模式解密 key:秘钥 initVector:偏移量 encrypted加密内容
public static String decrypt(String key,String initVector,String encrypted) {
try {
IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
byte[] original = cipher.doFinal(Base64.decodeBase64(encrypted));
return new String(original);
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
public static void main(String[] args) throws Exception {
System.out.println(decrypt("a6xdabhysfescfbu","encryptionIntVec","oYzamqnnyJ8GG6646PDYBQ=="));
}
public static String getSHA256Str(String str){
MessageDigest messageDigest;
String encodeStr = "";
try {
messageDigest = MessageDigest.getInstance("SHA-256");
messageDigest.update(str.getBytes("UTF-8"));
encodeStr = byte2Hex(messageDigest.digest());
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return encodeStr;
}
/**
* 将byte转为16进制
* @param bytes
* @return
*/
private static String byte2Hex(byte[] bytes){
StringBuffer stringBuffer = new StringBuffer();
String temp = null;
for (int i=0;i<bytes.length;i++){
temp = Integer.toHexString(bytes[i] & 0xFF);
if (temp.length()==1){
//1得到一位的进行补0操作
stringBuffer.append("0");
}
stringBuffer.append(temp);
}
return stringBuffer.toString();
}
}

View File

@@ -0,0 +1,785 @@
package com.saye.hrs.commons.excel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.util.CellRangeAddress;
import javax.servlet.http.HttpServletResponse;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
public class ExportXLS implements IExport ,ISetExport{
Log logger = LogFactory.getLog(this.getClass());
public final static short ROWHEIGHT = 20; /*行高*/
public final static double PAGEMARGIN = 0.1;/*页边距*/
public final static short TITLESIZE = 16;/*标题文字大小*/
public final static short HEADERSIZE = 12;/*列头文字大小*/
public final static short DATA_CHARACTERSIZE = 9;/*汉字大小*/
public final static short DATA_NUMSIZE = 9;/*数字大小*/
public final static short DATA_DATESIZE = 9;/*日期大小*/
public final static String ALIGN_LEFT = "LEFT";/*水平居左*/
public final static String ALIGN_RIGHT = "RIGHT";/*水平居右*/
public final static String ALIGN_CENTER = "CENTER";/*水平居右*/
public final static String VERTICAL_TOP = "TOP";/*垂直居上*/
public final static String VERTICAL_CENTER = "MIDDLE";/*垂直居中*/
public final static String VERTICAL_BOTTOM = "BOTTOM";/*垂直居下*/
public final static short A4 = HSSFPrintSetup.A4_PAPERSIZE;
public final static short A5 = HSSFPrintSetup.A5_PAPERSIZE;
public final static short A3 = 8;
public final static String MERGEDEND = "_mergedend_";//表示合并次单元格
private List<Object> data;
private Object[] statisticData;
private String titleName;
private short titleHeight = 500;
private short headerHeight = 300;
private short cellHeight = 300;
private HSSFWorkbook wb;
private HSSFSheet sheet;
private HSSFCellStyle headerCellStyle;
private HSSFCellStyle cellStyle;
private String[] header;
private String[] subHeader;
private String[] width;
private String[] sqlKey;
private IConversionByExport conversion;
private List<int[]> mergeRanges = new ArrayList<int[]>();
private Boolean isHeaderMergeTwo = Boolean.FALSE;
private int headerRowIndex = 1;
private int subHeaderRowIndex = 2;
private int titleMergeColumnIndex = 0;
private HashMap<Integer, Integer> modifiedDataHeightHM = new HashMap<Integer, Integer>(); //要修改的数据行的高度
private short subHeaderHeight = 300;
private Boolean isCreateFreezePane = true;
private HashMap<Integer, Integer> skipedDataIndexMap; //要空行的数据列序号:KEY为data的序号 VALUE默认为1
private List<HashMap<Integer, Integer>> resetCellStyleList = new ArrayList<HashMap<Integer,Integer>>(); //要重新设置样式的单元格:KEY为行号,VALUE为列号
private HSSFCellStyle resetCellStyle;
/**
*
*构造函数:得到一个纵向打印在A4纸上的xls
*
*/
public ExportXLS(String[] header){
this.wb = new HSSFWorkbook();
this.sheet = this.createSheet(false, ExportXLS.A4);
this.headerCellStyle = this.createCellStyle(ExportXLS.ALIGN_CENTER, VERTICAL_CENTER, 1111, HEADERSIZE, new HSSFColor.GREY_25_PERCENT().getIndex());
this.cellStyle = this.createCellStyle(ExportXLS.ALIGN_CENTER, VERTICAL_CENTER, 1111, HEADERSIZE, new HSSFColor.WHITE().getIndex());
this.setTitleName("export");
this.setHeader(header);
}
/**
* 设置打印纸大小,横向还是纵向
* @param header
* @param sqlKey
* @param pageSize
* @param landscapeFlag
*/
public ExportXLS(String[] header,String[] sqlKey,Short pageSize,boolean landscapeFlag){
this.wb = new HSSFWorkbook();
this.sheet = this.createSheet(landscapeFlag, pageSize);
this.headerCellStyle = this.createCellStyle(ExportXLS.ALIGN_CENTER, VERTICAL_CENTER, 1111, HEADERSIZE, new HSSFColor.GREY_25_PERCENT().getIndex());
HSSFFont titlefont = this.wb.createFont(); //设置字体
titlefont.setFontHeightInPoints(ExportXLS.HEADERSIZE);
titlefont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
headerCellStyle.setFont(titlefont);
this.cellStyle = this.createCellStyle(ExportXLS.ALIGN_CENTER, VERTICAL_CENTER, 1111, HEADERSIZE, new HSSFColor.WHITE().getIndex());
this.setTitleName("export");
this.setHeader(header);
this.setSqlKey(sqlKey);
}
private void setHeader(String[] header){
this.header = header;
//默认设置每个单元格的宽度为3500
int length = this.header.length;
this.width = new String[length];
for(int i=0;i<length;i++){
this.width[i] = "3500";
}
}
public void setSqlKey(String[] sqlKey) {
this.sqlKey = sqlKey;
}
/**
* 创建工作簿
* @param
* @param landscapeFlag 横向标记 // true横向 false纵向
* @param pageSize 纸张大小
* @return
*/
private HSSFSheet createSheet(boolean landscapeFlag,Short pageSize) {
HSSFPrintSetup ps = null;
HSSFSheet sheet = null;
sheet = this.wb.createSheet();
sheet.setHorizontallyCenter(true);
sheet.setMargin(HSSFSheet.LeftMargin,PAGEMARGIN); //设置页边距
sheet.setMargin(HSSFSheet.RightMargin,PAGEMARGIN);
sheet.setMargin(HSSFSheet.TopMargin,PAGEMARGIN*3);
sheet.setMargin(HSSFSheet.BottomMargin,PAGEMARGIN*3);
ps = sheet.getPrintSetup();
ps.setLandscape(landscapeFlag);
ps.setPaperSize(pageSize);
return sheet;
}
/**
* 创建单元格格式
*/
private HSSFCellStyle createCellStyle(String alignPosition,String verticalPosotion,Integer border,short fontSize,short color) {
HSSFCellStyle cellStyle = wb.createCellStyle();
/*
* 设置水平位置
*/
if(alignPosition.equals(ALIGN_LEFT)){
cellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
}
if(alignPosition.equals(ALIGN_RIGHT)){
cellStyle.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
}
if(alignPosition.equals(ALIGN_CENTER)){
cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
}
/*
* 设置垂直位置
*/
if(alignPosition.equals(VERTICAL_TOP)){
cellStyle.setAlignment(HSSFCellStyle.VERTICAL_TOP);
}
if(alignPosition.equals(VERTICAL_CENTER)){
cellStyle.setAlignment(HSSFCellStyle.VERTICAL_CENTER);
}
if(alignPosition.equals(VERTICAL_BOTTOM)){
cellStyle.setAlignment(HSSFCellStyle.VERTICAL_BOTTOM);
}
/*
* 设置边框
*/
if((border/1000)%10==1){
cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框
}
if((border/100)%10==1){
cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框
}
if((border/10)%10==1){
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);// 下边框
}
if(border%10==1){
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框
}
/*
* 设置字体大小
*/
HSSFFont font = wb.createFont();
font.setFontHeightInPoints(fontSize);// 字体大小
cellStyle.setFont(font);
/*
* 设置背景色
*/
cellStyle.setFillForegroundColor(color);
cellStyle.setFillBackgroundColor(color);
cellStyle.setFillPattern(HSSFCellStyle.SPARSE_DOTS);
/*
* 自动换行
*/
cellStyle.setWrapText(true);
return cellStyle;
}
/**
* 根据不同的类型给cell赋值
*
* @param data 数据
* @param cell
* @throws SQLException
*/
private void obtainPropList(Object data, HSSFCell cell){
if(data == null){
data = "";
}
String type = data.getClass().getName();
if(type.equalsIgnoreCase("java.lang.String")) {
String value = (String)data;
cell.setCellValue(new HSSFRichTextString(value));
}else if(type.equalsIgnoreCase("java.lang.Integer") || type.equalsIgnoreCase("int")) {
int value = (Integer)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Long") || type.equalsIgnoreCase("long")) {
long value = (Long)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Float") || type.equalsIgnoreCase("float")){
float value = (Float)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Double") || type.equalsIgnoreCase("double")){
double value = (Double)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Byte") || type.equalsIgnoreCase("byte")) {
byte value = (Byte)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Character") || type.equalsIgnoreCase("char")) {
char value = (Character)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Boolean") || type.equalsIgnoreCase("boolean")) {
boolean value = (Boolean)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.math.BigDecimal")) {
BigDecimal value = (BigDecimal)data;
cell.setCellValue(value.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
}else if(type.equalsIgnoreCase("java.util.Date")) {
Date value = (Date)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.sql.Timestamp")) {
Timestamp timestamp = (Timestamp)data;
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String value = dateFormat.format(timestamp.getTime());
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Short") || type.equalsIgnoreCase("short")) {
short value = (Short)data;
cell.setCellValue(value);
}
}
private void fillSheet(){
int addRowNum = 1;
if(!isHeaderMergeTwo){
addRowNum = 0;
}
if(isCreateFreezePane){
sheet.createFreezePane(0,this.headerRowIndex + addRowNum + 1);
}
//设置行宽
for(int i=0;i<this.width.length;i++){
this.sheet.setColumnWidth(i,Integer.parseInt(this.width[i]));
}
//填入抬头数据
HSSFRow titleRow = this.sheet.createRow(0);
titleRow.setHeight(this.titleHeight);
HSSFCell titleCell = titleRow.createCell(0);
titleCell.setCellValue(new HSSFRichTextString(this.titleName));
HSSFCellStyle titleCellStyle = this.wb.createCellStyle(); //设置单元格style
titleCellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
titleCellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
HSSFFont titlefont = this.wb.createFont(); //设置字体
titlefont.setFontHeightInPoints(ExportXLS.TITLESIZE);
titlefont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
titleCellStyle.setFont(titlefont);
titleCellStyle.setWrapText(true);
titleCell.setCellStyle(titleCellStyle);
if(0 == this.titleMergeColumnIndex){
this.titleMergeColumnIndex = this.header.length-1;
}
this.sheet.addMergedRegion(new CellRangeAddress(0,addRowNum,0,this.titleMergeColumnIndex));
//填入标题数据
HSSFRow headerRow = this.sheet.createRow(this.headerRowIndex);
headerRow.setHeight(this.headerHeight);
for(int i=0;i<this.header.length;i++){
HSSFCell headerCell = headerRow.createCell(i);
headerCell.setCellStyle(this.headerCellStyle);
this.obtainPropList(this.header[i], headerCell);
}
Integer dataBeginIndex = this.headerRowIndex + 1;
if(null != subHeader && 0 != subHeader.length){
if(this.subHeader.length > this.header.length){
for (int i = this.header.length; i < this.subHeader.length; i++) {
HSSFCell headerCell = headerRow.createCell(i);
headerCell.setCellStyle(this.headerCellStyle);
headerCell.setCellValue("");
}
}
//填入副标题数据
HSSFRow subHeaderRow = this.sheet.createRow(this.subHeaderRowIndex);
subHeaderRow.setHeight(this.subHeaderHeight);
for(int i=0;i<this.subHeader.length;i++){
HSSFCell headerCell = subHeaderRow.createCell(i);
headerCell.setCellStyle(this.headerCellStyle);
this.obtainPropList(this.subHeader[i], headerCell);
}
if(isCreateFreezePane){
this.sheet.createFreezePane(0,this.subHeaderRowIndex+1);
}
dataBeginIndex++;
}
//填入数据
if(this.data != null){
for(int i=0;i<this.data.size();i++){
Boolean tf = true;
if(null != skipedDataIndexMap){
if(!skipedDataIndexMap.isEmpty() && null != skipedDataIndexMap.get(i)){
tf = false;
}
}
if(tf){
//将数据转为数组类型数据
Object[] array = null;
//如果不存在转换对象,则使用默认的转换方法
if(this.conversion != null){
array = this.conversion.conversion(this.data.get(i), this.sqlKey);
}else{
array = this.conversion(this.data.get(i));
}
HSSFRow dataRow = this.sheet.createRow(dataBeginIndex+i);
dataRow.setHeight(this.cellHeight);
if(null != this.modifiedDataHeightHM){
Integer rowHeight = this.modifiedDataHeightHM.get(i);
if(null != rowHeight){
dataRow.setHeight(Short.valueOf(rowHeight.toString()));
}
}
for(int j=0;j<array.length;j++){
HSSFCell dataCell = dataRow.createCell(j);
dataCell.setCellStyle(this.cellStyle);
this.obtainPropList(array[j],dataCell);
}
}else {
HSSFRow dataRow = this.sheet.createRow(dataBeginIndex+i);
}
}
}
if(null != resetCellStyleList && !resetCellStyleList.isEmpty()){
int len = resetCellStyleList.size();
for (int i = 0; i < len; i++) {
HashMap<Integer, Integer> resetCellStyleHM = resetCellStyleList.get(i);
Iterator<Map.Entry<Integer, Integer>> it = resetCellStyleHM.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Integer, Integer> entry = it.next();
Integer rowIndex = entry.getKey();
Integer columnIndex = entry.getValue();
this.sheet.getRow(rowIndex).getCell(columnIndex).setCellStyle(this.resetCellStyle);
}
}
}
//设置合并开始标识
boolean mergedStartFlag = false;
int[] startAndEnd = null;
List mergedIndex = new ArrayList();
if(null != this.statisticData){
//追加统计行
HSSFRow appendRow = this.sheet.createRow(this.sheet.getLastRowNum()+1);
for(int i=0;i<this.statisticData.length;i++){
//记录合并开始位置
if(!mergedStartFlag){
mergedStartFlag = true;
startAndEnd = new int[2];
startAndEnd[0] = i;
}
//记录合并结束位置
if(ExportXLS.MERGEDEND.equals(this.statisticData[i]) && mergedStartFlag){
mergedStartFlag = false;
startAndEnd[1] = i;
mergedIndex.add(startAndEnd);
}
//生成单元格,如果是合并单元格,内容置空
HSSFCell dataCell = appendRow.createCell(i);
dataCell.setCellStyle(this.cellStyle);
if(!ExportXLS.MERGEDEND.equals(this.statisticData[i])){
this.obtainPropList(this.statisticData[i],dataCell);
}
}
}
//根据合并位置记录 合并单元格
for(int i=0;i<mergedIndex.size();i++){
startAndEnd = (int[])mergedIndex.get(i);
this.sheet.addMergedRegion(new CellRangeAddress(this.sheet.getLastRowNum(),this.sheet.getLastRowNum(),startAndEnd[0],startAndEnd[1]));
}
//处理要合并的单元格区域
if(null != this.mergeRanges && 0 != this.mergeRanges.size()){
for (int i = 0; i < this.mergeRanges.size(); i++) {
int[] ranges = this.mergeRanges.get(i);
this.sheet.addMergedRegion(new CellRangeAddress(ranges[0], ranges[1], ranges[2], ranges[3]));
}
}
}
/**
* 默认数据转换方法(只转换数组类型对象)
* @return
*/
private Object[] conversion(Object obj){
try {
return (Object[])obj;
} catch (ClassCastException e) {
if(this.logger.isErrorEnabled()){
this.logger.error("导出工具转换数据对象错误!要转换的数据不是数组型的!");
}
}
return null;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#setConversion(IConversionByExport conversion)
*/
public void setConversion(IConversionByExport conversion){
this.conversion = conversion;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#setTitleName(java.lang.String)
*/
public void setTitleName(String titleName){
this.titleName = titleName;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#modifyHeader(java.lang.String, int)
*/
public void modifyHeader(String header, int index){
this.header[index] = header;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#modifyWidthOfHeader(java.lang.String, int)
*/
public void modifyWidthOfHeader(String width, int index){
this.width[index] = width;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#setData(java.util.List)
*/
public void setData(List<Object> dataList){
this.data = dataList;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#appendStatisticRow(Object StatisticData)
*/
public void appendStatisticRow(Object statisticData) {
//如果不存在转换对象,则使用默认的转换方法
if(this.conversion != null){
this.statisticData = this.conversion.conversion(statisticData, this.sqlKey);
}else{
this.statisticData = this.conversion(statisticData);
}
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#returnClientDownload(javax.servlet.http.HttpServletResponse)
*/
public void returnClientDownload(HttpServletResponse response) throws IOException{
//将数据装填到sheet中
this.fillSheet();
response.reset();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","attachment; filename=" + new String(this.titleName.getBytes("gb2312"),"ISO8859-1")+".xls");
OutputStream os = null;
try {
os = response.getOutputStream();
this.wb.write(os);
} catch (Exception e) {
} finally {
if(os != null) {
os.close();
os = null;
}
}
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#returnClientOpen(javax.servlet.http.HttpServletResponse)
*/
public void returnClientOpen(HttpServletResponse response) throws IOException{
//将数据装填到sheet中
this.fillSheet();
response.reset();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","online; filename=" + new String(this.titleName.getBytes("gb2312"),"ISO8859-1")+".xls");
try {
wb.write(response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#modifTitleHeight(short height)
*/
public void modifTitleHeight(short height) {
this.titleHeight = height;
}
/**
* 设置副标题
* @param subHeader
*/
public void setSubHeader(String[] subHeader){
this.subHeader = subHeader;
//默认设置每个单元格的宽度为3500
int headerLength = this.header.length;
int subHeaderLength = 0;
if(null != subHeader && 0 != subHeader.length){
subHeaderLength = this.subHeader.length;
}
int length = headerLength > subHeaderLength ? headerLength : subHeaderLength;
this.width = new String[length];
for(int i=0;i<length;i++){
this.width[i] = "3500";
}
}
/**
* 设置要合并的单元格区域
* @param firstRow 开始行
* @param lastRow 结束行
* @param firstCol 开始列
* @param lastCol 结束列
*/
public void setMergeRange(int firstRow, int lastRow, int firstCol, int lastCol){
int[] range = new int[4];
range[0] = firstRow;
range[1] = lastRow;
range[2] = firstCol;
range[3] = lastCol;
this.mergeRanges.add(range);
}
/*
*
*/
public void execGenerateExcel(String exportFilePath) throws IOException{
//将数据装填到sheet中
this.fillSheet();
// 设置输入流
FileOutputStream fOut = new FileOutputStream(exportFilePath);
// 将模板的内容写到输出文件上
wb.write(fOut);
fOut.flush();
// 操作结束,关闭文件
fOut.close();
}
/**
* 设置头部高度
* @param height
*/
public void modifyHeaderHeight(short height) {
this.headerHeight = height;
}
/**
* 设置头部标题所处行序号
* @param headerRowIndex
*/
public void modifyHeaderRowIndex(short headerRowIndex) {
this.headerRowIndex = headerRowIndex;
}
/**
* 设置头部副标题序号
* @param subHeaderRowIndex
*/
public void modifySubHeaderRowIndex(short subHeaderRowIndex) {
this.subHeaderRowIndex = subHeaderRowIndex;
}
/**
* 设置标题合并列号
* @param titleMergeColumnIndex
*/
public void setTitleMergeColumnIndex(int titleMergeColumnIndex) {
this.titleMergeColumnIndex = titleMergeColumnIndex;
}
/**
* 设置数据行高
* @param modifiedDataHeightHM数据序号和行高
*/
public void setModifiedDataHeightHM(HashMap<Integer, Integer> modifiedDataHeightHM) {
this.modifiedDataHeightHM = modifiedDataHeightHM;
}
/**
* 设置头部副标题高度
* @param subHeaderHeight
*/
public void modifySubHeaderHeight(short subHeaderHeight) {
this.subHeaderHeight = subHeaderHeight;
}
/**
* 设置是否创建冻结窗体
* @param isCreateFreezePane
*/
public void setIsCreateFreezePane(Boolean isCreateFreezePane) {
this.isCreateFreezePane = isCreateFreezePane;
}
/**
* 设置要空行的数据列序号
* @param skipedDataIndexMap
*/
public void setSkipedDataIndexMap(HashMap<Integer, Integer> skipedDataIndexMap) {
this.skipedDataIndexMap = skipedDataIndexMap;
}
/**
* 设置 重新设置样式的单元格序号及样式:样式为空时,默认为头部标题样式
* @param resetCellStyleList
* @param resetCellStyle
*/
public void resetCellForCellStyle(List<HashMap<Integer, Integer>> resetCellStyleList, HSSFCellStyle resetCellStyle) {
this.resetCellStyleList = resetCellStyleList;
if(null == resetCellStyle){
resetCellStyle = this.headerCellStyle;
}
this.resetCellStyle = resetCellStyle;
}
/**
* 设置 工作薄 密码保护
* @param pwd
*/
public void protectSheet(String pwd) {
this.sheet.protectSheet(pwd);
}
/**
* 设定抬头是否合并两行:在new ExportXLS之后就SET
* @param isHeaderMergeTwo
*/
public void setIsHeaderMergeTwo(Boolean isHeaderMergeTwo) {
this.isHeaderMergeTwo = isHeaderMergeTwo;
if(!this.isHeaderMergeTwo){
this.headerRowIndex = 1;
this.subHeaderRowIndex = 2;
}
}
}

View File

@@ -0,0 +1,790 @@
package com.saye.hrs.commons.excel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.*;
public class ExportXLSX implements IExport ,ISetExport{
Log logger = LogFactory.getLog(this.getClass());
public final static short ROWHEIGHT = 20; /*行高*/
public final static double PAGEMARGIN = 0.1;/*页边距*/
public final static short TITLESIZE = 16;/*标题文字大小*/
public final static short HEADERSIZE = 12;/*列头文字大小*/
public final static short DATA_CHARACTERSIZE = 9;/*汉字大小*/
public final static short DATA_NUMSIZE = 9;/*数字大小*/
public final static short DATA_DATESIZE = 9;/*日期大小*/
public final static String ALIGN_LEFT = "LEFT";/*水平居左*/
public final static String ALIGN_RIGHT = "RIGHT";/*水平居右*/
public final static String ALIGN_CENTER = "CENTER";/*水平居右*/
public final static String VERTICAL_TOP = "TOP";/*垂直居上*/
public final static String VERTICAL_CENTER = "MIDDLE";/*垂直居中*/
public final static String VERTICAL_BOTTOM = "BOTTOM";/*垂直居下*/
public final static short A4 = XSSFPrintSetup.A4_PAPERSIZE;
public final static short A5 = XSSFPrintSetup.A5_PAPERSIZE;
public final static short A3 = 8;
public final static String MERGEDEND = "_mergedend_";//表示合并次单元格
private List<Object> data;
private Object[] statisticData;
private String titleName;
private short titleHeight = 500;
private short headerHeight = 300;
private short cellHeight = 300;
private XSSFWorkbook wb;
private XSSFSheet sheet;
private XSSFCellStyle headerCellStyle;
private XSSFCellStyle cellStyle;
private String[] header;
private String[] subHeader;
private String[] width;
private String[] sqlKey;
private IConversionByExport conversion;
private List<int[]> mergeRanges = new ArrayList<int[]>();
private Boolean isHeaderMergeTwo = Boolean.FALSE;
private int headerRowIndex = 1;
private int subHeaderRowIndex = 2;
private int titleMergeColumnIndex = 0;
private HashMap<Integer, Integer> modifiedDataHeightHM = new HashMap<Integer, Integer>(); //要修改的数据行的高度
private short subHeaderHeight = 300;
private Boolean isCreateFreezePane = true;
private HashMap<Integer, Integer> skipedDataIndexMap; //要空行的数据列序号:KEY为data的序号 VALUE默认为1
private List<HashMap<Integer, Integer>> resetCellStyleList = new ArrayList<HashMap<Integer,Integer>>(); //要重新设置样式的单元格:KEY为行号,VALUE为列号
private XSSFCellStyle resetCellStyle;
/**
*
*构造函数:得到一个纵向打印在A4纸上的xlsx
*
*/
public ExportXLSX(String[] header){
this.wb = new XSSFWorkbook();
this.sheet = this.createSheet(false, ExportXLSX.A4);
this.headerCellStyle = this.createCellStyle(ExportXLSX.ALIGN_CENTER, VERTICAL_CENTER, 1111, HEADERSIZE, new XSSFColor(new Color(192, 192, 192)));
this.cellStyle = this.createCellStyle(ExportXLSX.ALIGN_CENTER, VERTICAL_CENTER, 1111, HEADERSIZE, new XSSFColor(new Color(255, 255, 255)));
this.setTitleName("export");
this.setHeader(header);
}
/**
* 设置打印纸大小,横向还是纵向
* @param header
* @param sqlKey
* @param pageSize
* @param landscapeFlag
*/
public ExportXLSX(String[] header,String[] sqlKey,Short pageSize,boolean landscapeFlag){
XSSFWorkbook x= new XSSFWorkbook();
this.wb = x;
this.sheet = this.createSheet(landscapeFlag, pageSize);
this.headerCellStyle = this.createCellStyle(ExportXLSX.ALIGN_CENTER, VERTICAL_CENTER, 1111, HEADERSIZE, new XSSFColor(new Color(192, 192, 192)));
XSSFFont titlefont = this.wb.createFont(); //设置字体
titlefont.setFontHeightInPoints(ExportXLSX.HEADERSIZE);
titlefont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
headerCellStyle.setFont(titlefont);
this.cellStyle = this.createCellStyle(ExportXLSX.ALIGN_CENTER, VERTICAL_CENTER, 1111, HEADERSIZE, new XSSFColor(new Color(255, 255, 255)));
this.setTitleName("export");
this.setHeader(header);
this.setSqlKey(sqlKey);
}
private void setHeader(String[] header){
this.header = header;
//默认设置每个单元格的宽度为3500
int length = this.header.length;
this.width = new String[length];
for(int i=0;i<length;i++){
this.width[i] = "3500";
}
}
public void setSqlKey(String[] sqlKey) {
this.sqlKey = sqlKey;
}
/**
* 创建工作簿
* @param landscapeFlag 横向标记 // true横向 false纵向
* @param pageSize 纸张大小
* @return
*/
private XSSFSheet createSheet(boolean landscapeFlag,Short pageSize) {
XSSFPrintSetup ps = null;
XSSFSheet sheet = null;
sheet = this.wb.createSheet();
sheet.setHorizontallyCenter(true);
sheet.setMargin(XSSFSheet.LeftMargin,PAGEMARGIN); //设置页边距
sheet.setMargin(XSSFSheet.RightMargin,PAGEMARGIN);
sheet.setMargin(XSSFSheet.TopMargin,PAGEMARGIN*3);
sheet.setMargin(XSSFSheet.BottomMargin,PAGEMARGIN*3);
ps = sheet.getPrintSetup();
ps.setLandscape(landscapeFlag);
ps.setPaperSize(pageSize);
return sheet;
}
/**
* 创建单元格格式
*/
private XSSFCellStyle createCellStyle(String alignPosition,String verticalPosotion,Integer border,short fontSize,XSSFColor color) {
XSSFCellStyle cellStyle = wb.createCellStyle();
/*
* 设置水平位置
*/
if(alignPosition.equals(ALIGN_LEFT)){
cellStyle.setAlignment(XSSFCellStyle.ALIGN_LEFT);
}
if(alignPosition.equals(ALIGN_RIGHT)){
cellStyle.setAlignment(XSSFCellStyle.ALIGN_RIGHT);
}
if(alignPosition.equals(ALIGN_CENTER)){
cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
}
/*
* 设置垂直位置
*/
if(alignPosition.equals(VERTICAL_TOP)){
cellStyle.setAlignment(XSSFCellStyle.VERTICAL_TOP);
}
if(alignPosition.equals(VERTICAL_CENTER)){
cellStyle.setAlignment(XSSFCellStyle.VERTICAL_CENTER);
}
if(alignPosition.equals(VERTICAL_BOTTOM)){
cellStyle.setAlignment(XSSFCellStyle.VERTICAL_BOTTOM);
}
/*
* 设置边框
*/
if((border/1000)%10==1){
cellStyle.setBorderTop(XSSFCellStyle.BORDER_THIN);// 上边框
}
if((border/100)%10==1){
cellStyle.setBorderRight(XSSFCellStyle.BORDER_THIN);// 右边框
}
if((border/10)%10==1){
cellStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN);// 下边框
}
if(border%10==1){
cellStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN);// 左边框
}
/*
* 设置字体大小
*/
XSSFFont font = wb.createFont();
font.setFontHeightInPoints(fontSize);// 字体大小
cellStyle.setFont(font);
/*
* 设置背景色
*/
cellStyle.setFillForegroundColor(color);
cellStyle.setFillBackgroundColor(color);
cellStyle.setFillPattern(XSSFCellStyle.SPARSE_DOTS);
/*
* 自动换行
*/
cellStyle.setWrapText(true);
return cellStyle;
}
/**
* 根据不同的类型给cell赋值
*
* @param data 数据
* @param cell
* @throws SQLException
*/
private void obtainPropList(Object data, XSSFCell cell){
if(data == null){
data = "";
}
String type = data.getClass().getName();
if(type.equalsIgnoreCase("java.lang.String")) {
String value = (String)data;
cell.setCellValue(new XSSFRichTextString(value));
}else if(type.equalsIgnoreCase("java.lang.Integer") || type.equalsIgnoreCase("int")) {
int value = (Integer)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Long") || type.equalsIgnoreCase("long")) {
long value = (Long)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Float") || type.equalsIgnoreCase("float")){
float value = (Float)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Double") || type.equalsIgnoreCase("double")){
double value = (Double)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Byte") || type.equalsIgnoreCase("byte")) {
byte value = (Byte)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Character") || type.equalsIgnoreCase("char")) {
char value = (Character)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Boolean") || type.equalsIgnoreCase("boolean")) {
boolean value = (Boolean)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.math.BigDecimal")) {
BigDecimal value = (BigDecimal)data;
cell.setCellValue(value.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
}else if(type.equalsIgnoreCase("java.util.Date")) {
Date value = (Date)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.sql.Timestamp")) {
Timestamp timestamp = (Timestamp)data;
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String value = dateFormat.format(timestamp.getTime());
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Short") || type.equalsIgnoreCase("short")) {
short value = (Short)data;
cell.setCellValue(value);
}
}
private void fillSheet(){
int addRowNum = 1;
if(!isHeaderMergeTwo){
addRowNum = 0;
}
if(isCreateFreezePane){
sheet.createFreezePane(0,this.headerRowIndex + addRowNum + 1);
}
//设置行宽
for(int i=0;i<this.width.length;i++){
this.sheet.setColumnWidth(i,Integer.parseInt(this.width[i]));
}
//填入抬头数据
XSSFRow titleRow = this.sheet.createRow(0);
titleRow.setHeight(this.titleHeight);
XSSFCell titleCell = titleRow.createCell(0);
titleCell.setCellValue(new XSSFRichTextString(this.titleName));
XSSFCellStyle titleCellStyle = this.wb.createCellStyle(); //设置单元格style
titleCellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
titleCellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
XSSFFont titlefont = this.wb.createFont(); //设置字体
titlefont.setFontHeightInPoints(ExportXLSX.TITLESIZE);
titlefont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
titleCellStyle.setFont(titlefont);
titleCellStyle.setWrapText(true);
titleCell.setCellStyle(titleCellStyle);
if(0 == this.titleMergeColumnIndex){
this.titleMergeColumnIndex = this.header.length-1;
}
this.sheet.addMergedRegion(new CellRangeAddress(0,addRowNum,0,this.titleMergeColumnIndex));
//填入标题数据
XSSFRow headerRow = this.sheet.createRow(this.headerRowIndex);
headerRow.setHeight(this.headerHeight);
for(int i=0;i<this.header.length;i++){
XSSFCell headerCell = headerRow.createCell(i);
headerCell.setCellStyle(this.headerCellStyle);
this.obtainPropList(this.header[i], headerCell);
}
Integer dataBeginIndex = this.headerRowIndex + 1;
if(null != subHeader && 0 != subHeader.length){
if(this.subHeader.length > this.header.length){
for (int i = this.header.length; i < this.subHeader.length; i++) {
XSSFCell headerCell = headerRow.createCell(i);
headerCell.setCellStyle(this.headerCellStyle);
headerCell.setCellValue("");
}
}
//填入副标题数据
XSSFRow subHeaderRow = this.sheet.createRow(this.subHeaderRowIndex);
subHeaderRow.setHeight(this.subHeaderHeight);
for(int i=0;i<this.subHeader.length;i++){
XSSFCell headerCell = subHeaderRow.createCell(i);
headerCell.setCellStyle(this.headerCellStyle);
this.obtainPropList(this.subHeader[i], headerCell);
}
if(isCreateFreezePane){
this.sheet.createFreezePane(0,this.subHeaderRowIndex+1);
}
dataBeginIndex++;
}
//填入数据
if(this.data != null){
for(int i=0;i<this.data.size();i++){
Boolean tf = true;
if(null != skipedDataIndexMap){
if(!skipedDataIndexMap.isEmpty() && null != skipedDataIndexMap.get(i)){
tf = false;
}
}
if(tf){
//将数据转为数组类型数据
Object[] array = null;
//如果不存在转换对象,则使用默认的转换方法
if(this.conversion != null){
array = this.conversion.conversion(this.data.get(i), this.sqlKey);
}else{
array = this.conversion(this.data.get(i));
}
XSSFRow dataRow = this.sheet.createRow(dataBeginIndex+i);
dataRow.setHeight(this.cellHeight);
if(null != this.modifiedDataHeightHM){
Integer rowHeight = this.modifiedDataHeightHM.get(i);
if(null != rowHeight){
dataRow.setHeight(Short.valueOf(rowHeight.toString()));
}
}
for(int j=0;j<array.length;j++){
XSSFCell dataCell = dataRow.createCell(j);
dataCell.setCellStyle(this.cellStyle);
this.obtainPropList(array[j],dataCell);
}
}else {
XSSFRow dataRow = this.sheet.createRow(dataBeginIndex+i);
}
}
}
if(null != resetCellStyleList && !resetCellStyleList.isEmpty()){
int len = resetCellStyleList.size();
for (int i = 0; i < len; i++) {
HashMap<Integer, Integer> resetCellStyleHM = resetCellStyleList.get(i);
Iterator<Map.Entry<Integer, Integer>> it = resetCellStyleHM.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Integer, Integer> entry = it.next();
Integer rowIndex = entry.getKey();
Integer columnIndex = entry.getValue();
this.sheet.getRow(rowIndex).getCell(columnIndex).setCellStyle(this.resetCellStyle);
}
}
}
//设置合并开始标识
boolean mergedStartFlag = false;
int[] startAndEnd = null;
List mergedIndex = new ArrayList();
if(null != this.statisticData){
//追加统计行
XSSFRow appendRow = this.sheet.createRow(this.sheet.getLastRowNum()+1);
for(int i=0;i<this.statisticData.length;i++){
//记录合并开始位置
if(!mergedStartFlag){
mergedStartFlag = true;
startAndEnd = new int[2];
startAndEnd[0] = i;
}
//记录合并结束位置
if(ExportXLSX.MERGEDEND.equals(this.statisticData[i]) && mergedStartFlag){
mergedStartFlag = false;
startAndEnd[1] = i;
mergedIndex.add(startAndEnd);
}
//生成单元格,如果是合并单元格,内容置空
XSSFCell dataCell = appendRow.createCell(i);
dataCell.setCellStyle(this.cellStyle);
if(!ExportXLSX.MERGEDEND.equals(this.statisticData[i])){
this.obtainPropList(this.statisticData[i],dataCell);
}
}
}
//根据合并位置记录 合并单元格
for(int i=0;i<mergedIndex.size();i++){
startAndEnd = (int[])mergedIndex.get(i);
this.sheet.addMergedRegion(new CellRangeAddress(this.sheet.getLastRowNum(),this.sheet.getLastRowNum(),startAndEnd[0],startAndEnd[1]));
}
//处理要合并的单元格区域
if(null != this.mergeRanges && 0 != this.mergeRanges.size()){
for (int i = 0; i < this.mergeRanges.size(); i++) {
int[] ranges = this.mergeRanges.get(i);
this.sheet.addMergedRegion(new CellRangeAddress(ranges[0], ranges[1], ranges[2], ranges[3]));
}
}
}
/**
* 默认数据转换方法(只转换数组类型对象)
* @return
*/
private Object[] conversion(Object obj){
try {
return (Object[])obj;
} catch (ClassCastException e) {
if(this.logger.isErrorEnabled()){
this.logger.error("导出工具转换数据对象错误!要转换的数据不是数组型的!");
}
}
return null;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#setConversion(IConversionByExport conversion)
*/
public void setConversion(IConversionByExport conversion){
this.conversion = conversion;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#setTitleName(java.lang.String)
*/
public void setTitleName(String titleName){
this.titleName = titleName;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#modifyHeader(java.lang.String, int)
*/
public void modifyHeader(String header, int index){
this.header[index] = header;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#modifyWidthOfHeader(java.lang.String, int)
*/
public void modifyWidthOfHeader(String width, int index){
this.width[index] = width;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#setData(java.util.List)
*/
public void setData(List<Object> dataList){
this.data = dataList;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#appendStatisticRow(Object StatisticData)
*/
public void appendStatisticRow(Object statisticData) {
//如果不存在转换对象,则使用默认的转换方法
if(this.conversion != null){
this.statisticData = this.conversion.conversion(statisticData, this.sqlKey);
}else{
this.statisticData = this.conversion(statisticData);
}
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#returnClientDownload(javax.servlet.http.HttpServletResponse)
*/
public void returnClientDownload(HttpServletResponse response) throws IOException{
//将数据装填到sheet中
this.fillSheet();
response.reset();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","attachment; filename=" + new String(this.titleName.getBytes("gb2312"),"ISO8859-1")+".xlsx");
OutputStream os = null;
try {
os = response.getOutputStream();
this.wb.write(os);
} catch (Exception e) {
} finally {
if(os != null) {
os.close();
os = null;
}
}
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#returnClientOpen(javax.servlet.http.HttpServletResponse)
*/
public void returnClientOpen(HttpServletResponse response) throws IOException{
//将数据装填到sheet中
this.fillSheet();
response.reset();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","online; filename=" + new String(this.titleName.getBytes("gb2312"),"ISO8859-1")+".xlsx");
try {
wb.write(response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#modifTitleHeight(short height)
*/
public void modifTitleHeight(short height) {
this.titleHeight = height;
}
/**
* 设置副标题
* @param subHeader
*/
public void setSubHeader(String[] subHeader){
this.subHeader = subHeader;
//默认设置每个单元格的宽度为3500
int headerLength = this.header.length;
int subHeaderLength = 0;
if(null != subHeader && 0 != subHeader.length){
subHeaderLength = this.subHeader.length;
}
int length = headerLength > subHeaderLength ? headerLength : subHeaderLength;
this.width = new String[length];
for(int i=0;i<length;i++){
this.width[i] = "3500";
}
}
/**
* 设置要合并的单元格区域
* @param firstRow 开始行
* @param lastRow 结束行
* @param firstCol 开始列
* @param lastCol 结束列
*/
public void setMergeRange(int firstRow, int lastRow, int firstCol, int lastCol){
int[] range = new int[4];
range[0] = firstRow;
range[1] = lastRow;
range[2] = firstCol;
range[3] = lastCol;
this.mergeRanges.add(range);
}
/*
*
*/
public void execGenerateExcel(String exportFilePath) throws IOException{
//将数据装填到sheet中
this.fillSheet();
// 设置输入流
FileOutputStream fOut = new FileOutputStream(exportFilePath);
// 将模板的内容写到输出文件上
wb.write(fOut);
fOut.flush();
// 操作结束,关闭文件
fOut.close();
}
/**
* 设置头部高度
* @param height
*/
public void modifyHeaderHeight(short height) {
this.headerHeight = height;
}
/**
* 设置头部标题所处行序号
* @param headerRowIndex
*/
public void modifyHeaderRowIndex(short headerRowIndex) {
this.headerRowIndex = headerRowIndex;
}
/**
* 设置头部副标题序号
* @param subHeaderRowIndex
*/
public void modifySubHeaderRowIndex(short subHeaderRowIndex) {
this.subHeaderRowIndex = subHeaderRowIndex;
}
/**
* 设置标题合并列号
* @param titleMergeColumnIndex
*/
public void setTitleMergeColumnIndex(int titleMergeColumnIndex) {
this.titleMergeColumnIndex = titleMergeColumnIndex;
}
/**
* 设置数据行高
* @param modifiedDataHeightHM数据序号和行高
*/
public void setModifiedDataHeightHM(HashMap<Integer, Integer> modifiedDataHeightHM) {
this.modifiedDataHeightHM = modifiedDataHeightHM;
}
/**
* 设置头部副标题高度
* @param subHeaderHeight
*/
public void modifySubHeaderHeight(short subHeaderHeight) {
this.subHeaderHeight = subHeaderHeight;
}
/**
* 设置是否创建冻结窗体
* @param isCreateFreezePane
*/
public void setIsCreateFreezePane(Boolean isCreateFreezePane) {
this.isCreateFreezePane = isCreateFreezePane;
}
/**
* 设置要空行的数据列序号
* @param skipedDataIndexMap
*/
public void setSkipedDataIndexMap(HashMap<Integer, Integer> skipedDataIndexMap) {
this.skipedDataIndexMap = skipedDataIndexMap;
}
/**
* 设置 重新设置样式的单元格序号及样式:样式为空时,默认为头部标题样式
* @param resetCellStyleList
* @param resetCellStyle
*/
public void resetCellForCellStyle(List<HashMap<Integer, Integer>> resetCellStyleList, XSSFCellStyle resetCellStyle) {
this.resetCellStyleList = resetCellStyleList;
if(null == resetCellStyle){
resetCellStyle = this.headerCellStyle;
}
this.resetCellStyle = resetCellStyle;
}
/**
* 设置 工作薄 密码保护
* @param pwd
*/
public void protectSheet(String pwd) {
this.sheet.protectSheet(pwd);
}
/**
* 设定抬头是否合并两行:在new ExportXLS之后就SET
* @param isHeaderMergeTwo
*/
public void setIsHeaderMergeTwo(Boolean isHeaderMergeTwo) {
this.isHeaderMergeTwo = isHeaderMergeTwo;
if(!this.isHeaderMergeTwo){
this.headerRowIndex = 1;
this.subHeaderRowIndex = 2;
}
}
}

View File

@@ -0,0 +1,27 @@
package com.saye.hrs.commons.excel;
import java.util.HashMap;
public class HashMapConversionImpl implements IConversionByExport {
@Override
public Object[] conversion(Object obj) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object[] conversion(Object obj, String[] sqlArray) {
HashMap<Object, Object> hm = (HashMap<Object, Object>) obj;
int len = sqlArray.length;
Object[] result = new Object[len];
for (int i = 0; i < len; i++) {
result[i] = hm.get(sqlArray[i]);
}
return result;
}
}

View File

@@ -0,0 +1,6 @@
package com.saye.hrs.commons.excel;
public interface IConversionByExport {
public Object[] conversion(Object obj);
public Object[] conversion(Object obj, String[] sqlArray);
}

View File

@@ -0,0 +1,53 @@
package com.saye.hrs.commons.excel;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
public interface IExport {
/**
* 设置转换对象
* @param conversion
*/
public void setConversion(IConversionByExport conversion);
/**
* 设置数据数据
* @param dataList
* @throws SQLException
*/
public void setData(List<Object> dataList);
/**
* 在表格尾部追加数据,主要用于统计数据
*/
public void appendStatisticRow(Object statisticData);
/**
* 以下载形式导出
* @param response
* @throws IOException
*/
public void returnClientDownload(HttpServletResponse response)
throws IOException;
/**
* 以打开方式导出
* @param response
*/
public void returnClientOpen(HttpServletResponse response)
throws IOException;
/**
* 后台生成EXCEL文件
* @param exportFilePath
* @throws IOException
*/
public void execGenerateExcel(String exportFilePath) throws IOException;
}

View File

@@ -0,0 +1,58 @@
package com.saye.hrs.commons.excel;
public interface ISetExport {
/**
* 设置台头
* @param titleName
*/
public void setTitleName(String titleName);
/**
* 设置标题高
* @param height
*/
public void modifTitleHeight(short height);
/**
* 修改某个位置的标题栏名称
* @param header
* @param index
*/
public void modifyHeader(String header, int index);
/**
* 修改某个位置的标题栏宽度
* @param width
* @param index
*/
public void modifyWidthOfHeader(String width, int index);
/**
* 设置副标题
* @param subHeader
*/
public void setSubHeader(String[] subHeader);
/**
* 设置要合并的单元格区域
* @param firstRow 开始行
* @param lastRow 结束行
* @param firstCol 开始列
* @param lastCol 结束列
*/
public void setMergeRange(int firstRow, int lastRow, int firstCol, int lastCol);
/**
* 设置 工作薄 密码保护
* @param pwd
*/
public void protectSheet(String pwd);
/**
* 设定抬头是否合并两行:在new ExportXLS之后就SET
* @param isHeaderMergeTwo
*/
public void setIsHeaderMergeTwo(Boolean isHeaderMergeTwo);
}

View File

@@ -0,0 +1,27 @@
package com.saye.hrs.commons.exprot;
import java.util.HashMap;
public class HashMapConversionImpl implements IConversionByExport {
@Override
public Object[] conversion(Object obj) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object[] conversion(Object obj, String[] sqlArray) {
HashMap<Object, Object> hm = (HashMap<Object, Object>) obj;
int len = sqlArray.length;
Object[] result = new Object[len];
for (int i = 0; i < len; i++) {
result[i] = hm.get(sqlArray[i]);
}
return result;
}
}

View File

@@ -0,0 +1,6 @@
package com.saye.hrs.commons.exprot;
public interface IConversionByExport {
public Object[] conversion(Object obj);
public Object[] conversion(Object obj, String[] sqlArray);
}

View File

@@ -0,0 +1,36 @@
package com.saye.hrs.commons.file;
import java.io.File;
public class FileDUtil {
/**
* 得到文件的扩展名:大写字母的自动转换为小写字母
* @param f
* @return
*/
public static String getExtension(File f) {
return (f != null) ? getExtension(f.getName()) : "";
}
public static String getExtension(String filename) {
return getExtension(filename,"");
}
public static String getExtension(String filename, String defExt) {
if ((filename != null) && (filename.length() > 0)) {
int i = filename.lastIndexOf('.');
if ((i >-1) && (i < (filename.length() - 1))) {
return filename.substring(i + 1).trim().toLowerCase();
}
}
return defExt;
}
public static void main(String[] args) {
File f = new File("d:\test.XLSX");
System.out.println(getExtension(f));
}
}

View File

@@ -0,0 +1,29 @@
package com.saye.hrs.commons.getBean;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class BeanUtil implements ApplicationContextAware {
protected static ApplicationContext applicationContext ;
@Override
public void setApplicationContext(ApplicationContext arg0) throws BeansException {
if (applicationContext == null) {
applicationContext = arg0;
}
}
public static Object getBean(String name) {
//name表示其他要注入的注解name名
return applicationContext.getBean(name);
}
/**
* 拿到ApplicationContext对象实例后就可以手动获取Bean的注入实例对象
*/
public static <T> T getBean(Class<T> clazz) {
return applicationContext.getBean(clazz);
}
}

View File

@@ -0,0 +1,150 @@
package com.saye.hrs.commons.image;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* Description: 图片与base64的转换
* @author dqzhang
* @created 2018-10-9 下午4:07:55
*/
public class ImageBase64DUtil {
/**
* 本地图片转换成base64字符串
* @param imgFile 图片本地路径
* @return
* @dateTime 2018-02-23 14:40:46
*/
public static String ImageToBase64ByLocal(String imgFile) throws Exception{// 将图片文件转化为字节数组字符串并对其进行Base64编码处理
InputStream in = null;
byte[] data = null;
// 读取图片字节数组
try {
in = new FileInputStream(imgFile);
data = new byte[in.available()];
in.read(data);
in.close();
} catch (IOException e) {
// e.printStackTrace();
}
// 对字节数组Base64编码
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(data);// 返回Base64编码过的字节数组字符串
}
/**
* 在线图片转换成base64字符串
* @param imgURL 图片线上路径
* @return
* @dateTime 2018-02-23 14:43:18
*/
public static String ImageToBase64ByOnline(String imgURL) {
ByteArrayOutputStream data = new ByteArrayOutputStream();
try {
// 创建URL
URL url = new URL(imgURL);
byte[] by = new byte[1024];
// 创建链接
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setConnectTimeout(5000);
InputStream is = conn.getInputStream();
// 将内容读取内存中
int len = -1;
while ((len = is.read(by)) != -1) {
data.write(by, 0, len);
}
// 关闭流
is.close();
} catch (IOException e) {
e.printStackTrace();
}
// 对字节数组Base64编码
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(data.toByteArray());
}
/**
* base64字符串转换成图片
* @param imgStr base64字符串
* @param imgFilePath 图片存放路径
* @return
* @dateTime 2018-02-23 14:42:17
*/
public static boolean Base64ToImage(String imgStr,String imgFilePath) { // 对字节数组字符串进行Base64解码并生成图片
BASE64Decoder decoder = new BASE64Decoder();
try {
// Base64解码
byte[] b = decoder.decodeBuffer(imgStr);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {// 调整异常数据
b[i] += 256;
}
}
OutputStream out = new FileOutputStream(imgFilePath);
out.write(b);
out.flush();
out.close();
return true;
} catch (Exception e) {
return false;
}
}
/**
* @description 下载在线图片到本地
*/
public static void readInputStream(URL url,File file) throws Exception {
// 打开链接
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// 设置请求方式为"GET"
conn.setRequestMethod("GET");
// 超时响应时间为5秒
conn.setConnectTimeout(5 * 1000);
// 通过输入流获取图片数据
InputStream inStream = conn.getInputStream();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
// 创建一个Buffer字符串
byte[] buffer = new byte[1024];
// 每次读取的字符串长度,如果为-1代表全部读取完毕
int len = 0;
// 使用一个输入流从buffer里把数据读取出来
while ((len = inStream.read(buffer)) != -1) {
// 用输出流往buffer里写入数据中间参数代表从哪个位置开始读len代表读取的长度
outStream.write(buffer, 0, len);
}
// 关闭输入流
inStream.close();
// 创建输出流
FileOutputStream outStream2 = new FileOutputStream(file);
// 写入数据
outStream2.write(outStream.toByteArray());
// 关闭输出流
outStream2.close();
}
public static void main(String[] args) throws Exception{
}
}

View File

@@ -0,0 +1,27 @@
package com.saye.hrs.commons.log;
public class ExceptionDUtil {
/**
* 返回异常的详细信息
* @param e
* @return
*/
public static String getDetailExceptionMsg(Exception e){
StringBuffer exceptionMessage = new StringBuffer();
StackTraceElement[] stackTraceElementes = e.getStackTrace();
int length = stackTraceElementes.length;
StackTraceElement ste;
//只要最顶上的错误栈
for(int i=0;i<length;i++){
ste = stackTraceElementes[i];
exceptionMessage.append(ste.getClassName()+":"+ste.getLineNumber()+"\r\n");
//break;
}
String result = e.toString()+"\r\n"+exceptionMessage.toString();
return result;
}
}

View File

@@ -0,0 +1,128 @@
package com.saye.hrs.commons.log;
import com.saye.hrs.commons.date.DateDUtil;
import com.saye.hrs.mapper.system.LoggerMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
@Component
public class LogUtil {
private static LoggerMapper loggerMapper;
@Autowired
public void setLoggerMapper(LoggerMapper loggerMapper) {
LogUtil.loggerMapper = loggerMapper;
}
public static void debug(Class c,String msg) {
Logger logger=LoggerFactory.getLogger(c);
logger.debug(msg);
}
// public static void info(Class c,String msg) {
// Logger logger=LoggerFactory.getLogger(c);
// logger.info(msg);
// }
//
// public static void error(Class c,String msg) {
// Logger logger=LoggerFactory.getLogger(c);
// logger.error(msg);
// }
public static void info(Class c,String msg){
HashMap<Object, Object> map=new HashMap<Object, Object>();
try {
String name = c.getName();
if(name.indexOf("Controller")!=-1){
map.put("logtype", "INFO");
map.put("information",msg);
map.put("create_time", DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss));
map.put("user_id","");
map.put("ip", "");
loggerMapper.addLog(map);
}
} catch (Exception e) {
e.printStackTrace();
}finally {
Logger logger=LoggerFactory.getLogger(c);
logger.info(msg);
}
}
public static void info(Class c,String msg,String ip,String userName){
HashMap<Object, Object> map=new HashMap<Object, Object>();
try {
String name = c.getName();
if(name.indexOf("Controller")!=-1){
map.put("logtype", "INFO");
map.put("information",msg);
map.put("create_time", DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss));
map.put("user_id",userName);
map.put("ip", ip);
loggerMapper.addLog(map);
}
} catch (Exception e) {
e.printStackTrace();
}finally {
Logger logger=LoggerFactory.getLogger(c);
logger.info(msg);
}
}
public static void error(Class c,String msg){
HashMap<Object, Object> map=new HashMap<Object, Object>();
try {
String name = c.getName();
if(name.indexOf("Controller")!=-1){
map.put("logtype", "ERROR");
map.put("information",msg);
map.put("create_time", DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss));
map.put("user_id","");
map.put("ip", "");
loggerMapper.addLog(map);
}
} catch (Exception e) {
e.printStackTrace();
}finally {
Logger logger=LoggerFactory.getLogger(c);
logger.error(msg);
}
}
public static void error(Class c,String msg,String ip,String userName){
HashMap<Object, Object> map=new HashMap<Object, Object>();
try {
String name = c.getName();
if(name.indexOf("Controller")!=-1){
map.put("logtype", "ERROR");
map.put("information",msg);
map.put("create_time", DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss));
map.put("user_id",userName);
map.put("ip", ip);
loggerMapper.addLog(map);
}
} catch (Exception e) {
e.printStackTrace();
}finally {
Logger logger=LoggerFactory.getLogger(c);
logger.error(msg);
}
}
}

View File

@@ -0,0 +1,23 @@
package com.saye.hrs.commons.page;
import com.github.pagehelper.PageInfo;
import java.util.List;
public class PageUtil {
public static TemplatePage loadJsonPage(PageInfo pageInfo){
TemplatePage templetJson = new TemplatePage();
try {
List list = pageInfo.getList();
int i = (int) pageInfo.getTotal();
templetJson.setCount(i);
templetJson.setCode(0);
templetJson.setMsg("");
templetJson.setData(list);
} catch (Exception e) {
templetJson.setCode(1);
}
return templetJson;
}
}

View File

@@ -0,0 +1,44 @@
package com.saye.hrs.commons.page;
/**
* layui 的模板数据bean
*/
public class TemplatePage {
private Integer code;
private String msg;
private Integer count;
private Object data;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
}

View File

@@ -0,0 +1,416 @@
package com.saye.hrs.commons.string;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.regex.Pattern;
public class StringDUtil {
/**
* 去掉给定字符串前和后的空格,返回干净的字符串
* @param str
* @return String
*/
public static String removeSpaces(Object args) {
String argsStr = changeNullToEmpty(args);
if(args!=null){
args = argsStr.trim();
while (argsStr.startsWith(" ")) {
argsStr = argsStr.substring(1, argsStr.length()).trim();
}
while (argsStr.endsWith(" ")) {
argsStr = argsStr.substring(0, argsStr.length() - 1).trim();
}
}else{
argsStr = "";
}
return argsStr;
}
/**
* 转全角的函数
* @param str
* @return String
*/
public static String toSBC(String input) {
//半角转全角:
char[] c = input.toCharArray();
for (int i = 0; i < c.length; i++) {
if (c[i] == 32) {
c[i] = (char) 12288;
continue;
}
if (c[i] < 127) {
c[i] = (char) (c[i] + 65248);
}
}
return new String(c);
}
/**
* 转半角的函数
* @param str
* @return String
*/
public static String toDBC(String input) {
char[] c = input.toCharArray();
for (int i = 0; i < c.length; i++) {
if (c[i] == 12288) {
c[i] = (char) 32;
continue;
}
if (c[i] > 65280 && c[i] < 65375){
c[i] = (char) (c[i] - 65248);
}
}
return new String(c);
}
/**
* 为每添加一个元素前面增加指定的分隔 除第一个元素之外
* @param str
* @param appStr
* @param compart
* @return
*/
public static StringBuffer appendElement(StringBuffer strB,String appStr,String compart){
//当出入参数为NULL时
if(strB == null){
return new StringBuffer(appStr);
}
//当没有元素时直接添加追加元素 否则先添加分隔符
if(strB.length() == 0){
strB.append(appStr);
}else{
strB.append(compart);
strB.append(appStr);
}
return strB;
}
/**
* 移除元素
* @param str
* @param moveStr
* @param compart
* @return
*/
public static StringBuffer moveElement(StringBuffer strB,String moveStr,String compart){
//当出入参数为NULL时
if(strB == null){
return strB;
}
StringBuffer newStrB = new StringBuffer();
String[] strArray = strB.toString().split(compart);
for(int i=0;i<strArray.length;i++){
if(moveStr.equals(strArray[i])){
continue;
}
if(i == 0){
newStrB.append(strArray[i]);
}else{
newStrB.append(compart);
newStrB.append(strArray[i]);
}
}
return newStrB;
}
/**
* 移除第一个匹配的元素
* @param str
* @param moveStr
* @param compart
* @return
*/
public static StringBuffer moveFirstElement(StringBuffer strB,String moveStr,String compart){
//当出入参数为NULL时
if(strB == null){
return strB;
}
StringBuffer newStrB = new StringBuffer();
String[] strArray = strB.toString().split(compart);
boolean tag = false;
for(int i=0;i<strArray.length;i++){
if(moveStr.equals(strArray[i]) == true && tag == false){
tag = true;
continue;
}
if(i == 0){
newStrB.append(strArray[i]);
}else{
newStrB.append(compart);
newStrB.append(strArray[i]);
}
}
return newStrB;
}
/**
* 从给定字符中 返回所含的中文字符 并按每组以以字符串数组的形式返回
* @param src
* @return
*/
public static String[] getChinese(String src){
List list = new ArrayList();
byte[] srcByte = src.getBytes();
int srcLength = srcByte.length;
int begin = -1;
int end = -1;
for(int i=0;i<srcLength;i++){
//设置中文的开始位
if(srcByte[i] < 0 && begin == -1){
begin = i;
}
//设置中文的结束位
if(srcByte[i] > 0 && begin != -1 && end == -1){
end = i;
}
//如果已经找到中文的开始 但直到最后也没找到中文的结束,则将字符的结束位当成中文的截止位
if(begin != -1 && i == srcLength - 1){
end = i;
}
//将中文提取出来
if(begin != -1 && end != -1){
int tempLength = end-begin+1;
if(tempLength % 2 != 0){
tempLength = tempLength - 1;
}
byte[] tempByte = new byte[tempLength];
System.arraycopy(srcByte, begin, tempByte, 0, tempLength);
list.add(new String(tempByte));
begin = -1;
end = -1;
}
}
//将中文以数组输出
int size = list.size();
String[] chineseArray = new String[size];
for(int i=0;i<size;i++){
chineseArray[i] = list.get(i).toString();
}
return chineseArray;
}
/**
* 产生指定长度的随机码(由字母和数字组成)
* @param len
* @return
*/
public static String generateRandomCodeForLength(int len){
String s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
StringBuffer sRand = new StringBuffer();
Random random=new Random();
for (int i = 0; i < len; i++) {
String ch = String.valueOf(s.charAt(random.nextInt(s.length())));
sRand.append(ch);
}
return sRand.toString();
}
/**
* 将字符串NULL转换为空:""
* @param args
* @return
*/
public static String changeNullToEmpty(Object args) {
String result = null == args ? "" : String.valueOf(args);
if("\"null\"".equals(result) || "null".equals(result)){
result = "";
}
return result;
}
/**
* 将字符串NULL转换为空:"",并且去字符串中的转义字符
* @param args
* @return
*/
public static String changeNullToEmptyReplaceEscape(Object args) {
String result = null == args ? "" : String.valueOf(args);
result = result.replaceAll("'", "");
result = result.replaceAll("", "{");
result = result.replaceAll("", "}");
return result;
}
/**
* 验证字符串是否为空NULL或""
* @param str
* @return 返回值为true说明是为空。
*/
public static Boolean isEmpty(Object args) {
String result = "";
String str = changeNullToEmpty(args);
if("".equals(removeSpaces(str)) || "\"null\"".equals(removeSpaces(str)) || "null".equals(removeSpaces(str))){
return true;
}
return false;
}
/**
* 验证MAP中要验证的字段是否为空NULL或""
* @param hm 要验证的MAP
* @param fieldString 传入方式(以,将字段进行分割)personid,sysid
* @return 返回值为空,则验证成功,说明都不为空;否则返回为空的该字段名。
*/
public static String isExistEmpty(Map<Object, Object> hm, String fieldString) {
String[] strArr = fieldString.split(",");
for (int i = 0; i < strArr.length; i++) {
String key = strArr[i];
Object obj = hm.get(key);
if(isEmpty(obj)){
return key;
}
}
return "";
}
/**
* 判断字符串是否为正整数
* @param str
* @return
*/
public static boolean isPositiveInteger (String str){
Pattern pattern = Pattern.compile("^[0-9]*[1-9][0-9]*$");
return pattern.matcher(str).matches();
}
/**
* 判断字符串是否为正整数或正浮点数
* @param str
* @return
*/
public static boolean isPositiveIntegerOrPositiveFloat (String str){
Pattern pattern = Pattern.compile("^(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*))$");
return pattern.matcher(str).matches();
}
/**
*
* @description 截取字符串
* @author mczheng
* @created 2016-6-25 下午6:13:29
* @param str 要截取的字符串
* @param maxLength 字符长度英文字符算0.5个长度当截取剩下最后一位是0.5个长度而最后一个字符是中文时,则舍弃掉。
* @return
*/
public static String substring(String str, int maxLength) {
if (!hasLength(str))
return str;
int subSLength = maxLength * 2;
int tempSubLength = subSLength;//截取字符数
String subStr = "";
try {
int strLen = str.getBytes("GBK").length;
if (strLen <= subSLength) return str;
subStr = str.substring(0, str.length() < subSLength ? str.length() : subSLength); //截取的子串
int subStrByetsL = subStr.getBytes("GBK").length; //截取子串的字节长度
//说明截取的字符串中包含有汉字
while (subStrByetsL > tempSubLength) {
int subSLengthTemp = --subSLength;
subStr = str.substring(0, subSLengthTemp > str.length() ? str.length() : subSLengthTemp);
subStrByetsL = subStr.getBytes("GBK").length;
}
subStr += "...";
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return subStr;
}
public static boolean hasLength(String str) {
return (str != null) && (str.length() > 0);
}
public static void main(String[] args) {
//
// StringBuffer str = new StringBuffer("a,c,d,c");
// str = StringDUtil.moveFirstElement(str, "c", ",");
// System.out.println(str.toString());
//
// System.out.println(isEmpty("\"null\""));
System.out.println("11111111111");
System.out.println(StringDUtil.substring("一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十", 15));
}
/**
* @description 判断字符串是否有值且值不为空格
* @author thuang
* @created 2020年1月7日 下午1:09:49
* @param str
* @return
*/
public static boolean isNotBlank(String str) {
if (str != null && str.length() > 0 && str.trim().length() > 0) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,24 @@
package com.saye.hrs.commons.uuid;
import java.util.UUID;
public class UUIDGenerator {
public UUIDGenerator() {
}
/**
* 获得一个UUID
* @return String UUID
*/
public static String getUUID(){
String s = UUID.randomUUID().toString();
//去掉“-”符号
return s.substring(0,8)+s.substring(9,13)+s.substring(14,18)+s.substring(19,23)+s.substring(24);
}
public static void main(String[] args){
String ss = UUIDGenerator.getUUID();
System.out.println(ss);
System.out.println(ss.length());
}
}

View File

@@ -0,0 +1,363 @@
package com.saye.hrs.commons.webservice;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;
import com.saye.hrs.commons.getBean.BeanUtil;
import com.saye.hrs.mapper.system.LoggerMapper;
import com.saye.hrs.service.system.LoggerService;
public class WSUtil {
private static final Logger logger = LoggerFactory.getLogger(WSUtil.class);
public static RestTemplate restTemplate = new RestTemplate();
/** 调用webservice接口
* @param url
* @param tranCode
* @param inputXml
* @return
*/
public static HashMap<String,String> webserviceRequest(String url, String tranCode, String inputXml) {
logger.info("请求参数----------"+inputXml);
HashMap<String,String> resultMap=new HashMap<>();
String errCode="0";
String errMsg="";
try {
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("text/xml;charset=UTF-8");
// 请求类型ContentType text/xml;charset=UTF-8
headers.setContentType(type);
//请求数据体
StringBuffer soapRequestData = new StringBuffer("");
soapRequestData.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:kws=\"http://www.winning.com.cn/KWS/\">");
soapRequestData.append("<soapenv:Header/>");
soapRequestData.append("<soapenv:Body>");
soapRequestData.append("<kws:WebBusiness>");
soapRequestData.append("<kws:TranCode>");
//交易码
soapRequestData.append(tranCode);
soapRequestData.append("</kws:TranCode>");
soapRequestData.append("<kws:InXml>");
//<>符号要转码
inputXml=inputXml.replaceAll("<","&lt;");
inputXml=inputXml.replaceAll(">","&gt;");
soapRequestData.append(inputXml);
soapRequestData.append("</kws:InXml>");
soapRequestData.append("</kws:WebBusiness>");
soapRequestData.append("</soapenv:Body>");
soapRequestData.append("</soapenv:Envelope>");
// 请求
HttpEntity<String> request = new HttpEntity<String>(soapRequestData + "", headers);
// 返回结果
String str = restTemplate.postForObject(url, request, String.class);
logger.info("返回结果----------"+str);
Document document= DocumentHelper.parseText(str);
Element rootElt = document.getRootElement();
//解析
Iterator body = rootElt.elementIterator("Body");
Element recordEless = (Element) body.next();
Iterator callHisResponse = recordEless.elementIterator("WebBusinessResponse");
Element hisResponse = (Element) callHisResponse.next();
Iterator callHisResult = hisResponse.elementIterator("OutXml");
Element hisResult = (Element)callHisResult.next();
String text = hisResult.getText();
resultMap.put("outXml",text);
} catch (Exception e) {
logger.info("返回结果异常----------"+e.toString());
errCode="999";
errMsg=e.getMessage();
}
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* @description 门诊充值
*/
public static HashMap<Object, Object> mzRecharge(String patid, String czje, String czlx, String cardno,
String cardtype, String czyh, String zzjjylsh, String czlsh, String tradeNo, String outerOrderNo,
String innerOrderNo, String paytype) throws Exception{
String errMsg = "";
List<HashMap<Object,Object>> list = new ArrayList<>();
String inputXml = "<request><partner>320582467223232</partner><sign></sign><timestamp>20170704000513</timestamp>" +
"<operid>01</operid><password></password><kfsdm></kfsdm>" +
"<params><patid>"+patid+"</patid>" + //病人id
"<czje>"+czje+"</czje>" + //充值金额
"<czlx>"+czlx+"</czlx>" + //1 自助机现金4 软 POS 戒扫码付
"<cardno>"+cardno+"</cardno>" + //卡号
"<cardtype>"+cardtype+"</cardtype>" + //卡类型1、磁卡 2、保障卡 3、IC卡
"<czyh>"+czyh+"</czyh>" + //操作员号
"<zzjjylsh>"+zzjjylsh+"</zzjjylsh>" + //自助机交易流水号,902 接口返回,非卫宁付可为空
"<czlsh>"+czlsh+"</czlsh>" + //充值流水号,每次交易必须唯一
"<tradeNo>"+tradeNo+"</tradeNo>" + //三方支付流水号
"<outerOrderNo>"+outerOrderNo+"</outerOrderNo>" + //商户订单号(商户传给支付平台的单据号,卫宁付和 zzjjylsh 相同)
"<innerOrderNo>"+innerOrderNo+"</innerOrderNo>" + //平台订单号
"<paytype>"+paytype+"</paytype>" + //支付方式卫宁支付平台8:支付宝 9:微信其他支付方式如软POS由 HIS 分配)
"</params></request>";
HashMap<String,String> map = webserviceRequest("http://168.168.0.23:10062/KWSService.asmx?wsdl","501",inputXml);
LoggerService log = BeanUtil.getBean(LoggerService.class);
HashMap<Object,Object> hisMap = new HashMap<Object,Object>();
hisMap.put("title", "门诊充值");
hisMap.put("requestContent", inputXml);
hisMap.put("responseContent", map.get("outXml"));
log.addHisLog(hisMap);
String errCode = map.get("errCode");
if("0".equals(errCode)){
String outXml = map.get("outXml");
Document document= DocumentHelper.parseText(outXml);
Element rootElt = document.getRootElement();
Iterator iterator = rootElt.elementIterator();
Element codeElm = (Element) iterator.next();
Element msgElm = (Element) iterator.next();
errCode = codeElm.getText();
errMsg = msgElm.getText();
if ("0".equals(errCode)){
Element Items = (Element) iterator.next();
Iterator itemIterator = Items.elementIterator();
while (itemIterator.hasNext()){
HashMap<Object,Object> addMap=new HashMap<>();
Element item = (Element) itemIterator.next();
//
Element lshEl = item.element("lsh");
String lsh = lshEl==null?"":lshEl.getText();
//
Element lrrqEl = item.element("lrrq");
String lrrq = lrrqEl==null?"":lrrqEl.getText();
//
Element yjyeEl = item.element("yjye");
String yjye = yjyeEl==null?"":yjyeEl.getText();
Element kyjlshEl = item.element("kyjlsh");
String kyjlsh = kyjlshEl==null?"":kyjlshEl.getText();
Element kyjjeEl = item.element("kyjje");
String kyjje = kyjjeEl==null?"":kyjjeEl.getText();
Element kyjzffsEl = item.element("kyjzffs");
String kyjzffs = kyjzffsEl==null?"":kyjzffsEl.getText();
addMap.put("lsh",lsh);
addMap.put("lrrq",lrrq);
addMap.put("yjye",yjye);
addMap.put("kyjlsh",kyjlsh);
addMap.put("kyjje",kyjje);
addMap.put("kyjzffs",kyjzffs);
list.add(addMap);
}
}
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("list",list);
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/** 获取账户日志
* @param
* @return
*/
public static HashMap<Object,Object> getAccountRecord(String ksrq, String jsrq) throws DocumentException {
List<HashMap<Object,Object>> list = null;
String inputXml = "<request><partner>320582467223232</partner><sign></sign><timestamp>20170704000513</timestamp>" +
"<operid>01</operid><password></password><kfsdm></kfsdm>" +
"<params><ksrq>"+ksrq+"</ksrq>" + //开始日期
"<jsrq>"+jsrq+"</jsrq>" + //结束日期
"<czyh>"+0421+"</czyh>" + //类别
"</params></request>";
HashMap<String,String> map = webserviceRequest("http://168.168.0.23:10062/KWSService.asmx?wsdl","701",inputXml);
String errCode = map.get("errCode");
String errMsg = map.get("errMsg");
if("0".equals(errCode)){
String outXml = map.get("outXml");
Document document= DocumentHelper.parseText(outXml);
Element rootElt = document.getRootElement();
Iterator iterator = rootElt.elementIterator();
Element codeElm = (Element) iterator.next();
Element msgElm = (Element) iterator.next();
errCode = codeElm.getText();
errMsg = msgElm.getText();
if ("0".equals(errCode)){
list = new ArrayList<>();
Element Items = (Element) iterator.next();
Iterator itemIterator = Items.elementIterator();
while (itemIterator.hasNext()){
HashMap<Object,Object> addMap=new HashMap<>();
Element item = (Element) itemIterator.next();
Element patidEl = item.element("patid");
String patid = patidEl==null?"":patidEl.getText();
Element jyjeEl = item.element("jyje");
String jyje = jyjeEl==null?"":jyjeEl.getText();
Element zflshEl = item.element("zflsh");
String zflsh = zflshEl==null?"":zflshEl.getText();
Element jyrqEl = item.element("jyrq");
String jyrq = jyrqEl==null?"":jyrqEl.getText();
Element jylxEl = item.element("jylx");
String jylx = jylxEl==null?"":jylxEl.getText();
Element czyhEl = item.element("czyh");
String czyh = czyhEl==null?"":czyhEl.getText();
Element tyjeEl = item.element("tyje");
String tyje = tyjeEl==null?null:tyjeEl.getText();
addMap.put("patid",patid);
addMap.put("jyje",jyje);
addMap.put("zflsh",zflsh);
addMap.put("jyrq",jyrq);
addMap.put("jylx",jylx);
addMap.put("czyh",czyh);
addMap.put("tyje",tyje);
list.add(addMap);
}
}
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("list",list);
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 住院充值
* @return
*/
public static HashMap<Object, Object> zyRecharge(String patid, String czje, String czlx, String cardno,
String cardtype, String czyh, String zzjjylsh, String czlsh, String tradeNo, String outerOrderNo,
String innerOrderNo, String paytype) throws Exception {
String errMsg = "";
List<HashMap<Object,Object>> list = new ArrayList<>();
String inputXml = "<request><partner>320582467223232</partner><sign></sign><timestamp>20170704000513</timestamp>" +
"<operid>01</operid><password></password><kfsdm></kfsdm>" +
"<params><patid>"+patid+"</patid>" + //病人id
"<czje>"+czje+"</czje>" + //充值金额
"<czlx>"+czlx+"</czlx>" + //1 自助机现金4 软 POS 戒扫码付
"<cardno>"+cardno+"</cardno>" + //卡号
"<cardtype>"+cardtype+"</cardtype>" + //卡类型1、磁卡 2、保障卡 3、IC卡
"<czyh>"+czyh+"</czyh>" + //操作员号
"<zzjjylsh>"+zzjjylsh+"</zzjjylsh>" + //自助机交易流水号,902 接口返回,非卫宁付可为空
"<czlsh>"+czlsh+"</czlsh>" + //充值流水号,每次交易必须唯一
"<tradeNo>"+tradeNo+"</tradeNo>" + //三方支付流水号
"<outerOrderNo>"+outerOrderNo+"</outerOrderNo>" + //商户订单号(商户传给支付平台的单据号,卫宁付和 zzjjylsh 相同)
"<innerOrderNo>"+innerOrderNo+"</innerOrderNo>" + //平台订单号
"<paytype>"+paytype+"</paytype>" + //支付方式卫宁支付平台8:支付宝 9:微信其他支付方式如软POS由 HIS 分配)
"</params></request>";
HashMap<String,String> map = webserviceRequest("http://168.168.0.23:10062/KWSService.asmx?wsdl","501",inputXml);
LoggerService log = BeanUtil.getBean(LoggerService.class);
HashMap<Object,Object> hisMap = new HashMap<Object,Object>();
hisMap.put("title", "住院充值");
hisMap.put("requestContent", inputXml);
hisMap.put("responseContent", map.get("outXml"));
log.addHisLog(hisMap);
String errCode = map.get("errCode");
if("0".equals(errCode)){
String outXml = map.get("outXml");
Document document= DocumentHelper.parseText(outXml);
Element rootElt = document.getRootElement();
Iterator iterator = rootElt.elementIterator();
Element codeElm = (Element) iterator.next();
Element msgElm = (Element) iterator.next();
errCode = codeElm.getText();
errMsg = msgElm.getText();
if ("0".equals(errCode)){
Element Items = (Element) iterator.next();
Iterator itemIterator = Items.elementIterator();
while (itemIterator.hasNext()){
HashMap<Object,Object> addMap=new HashMap<>();
Element item = (Element) itemIterator.next();
//
Element lshEl = item.element("lsh");
String lsh = lshEl==null?"":lshEl.getText();
//
Element lrrqEl = item.element("lrrq");
String lrrq = lrrqEl==null?"":lrrqEl.getText();
//
Element yjyeEl = item.element("yjye");
String yjye = yjyeEl==null?"":yjyeEl.getText();
Element kyjlshEl = item.element("kyjlsh");
String kyjlsh = kyjlshEl==null?"":kyjlshEl.getText();
Element kyjjeEl = item.element("kyjje");
String kyjje = kyjjeEl==null?"":kyjjeEl.getText();
Element kyjzffsEl = item.element("kyjzffs");
String kyjzffs = kyjzffsEl==null?"":kyjzffsEl.getText();
addMap.put("lsh",lsh);
addMap.put("lrrq",lrrq);
addMap.put("yjye",yjye);
addMap.put("kyjlsh",kyjlsh);
addMap.put("kyjje",kyjje);
addMap.put("kyjzffs",kyjzffs);
list.add(addMap);
}
}
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("list",list);
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
}

View File

@@ -0,0 +1,50 @@
package com.saye.hrs.config;
import com.saye.hrs.model.ServiceParams;
import com.saye.hrs.model.StatusDefine;
import com.saye.hrs.service.system.ServiceParamsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
@Component
public class LoadStatusDefine implements ApplicationRunner {
@Autowired
private ServiceParamsService serviceParamsService;
@Override
public void run(ApplicationArguments args) throws Exception {
System.out.println(/************************************开始加载系统默认参数*************************************************/);
/*StatusDefine sd=new StatusDefine();
List<ServiceParams> paramsList = this.serviceParamsService.selectServiceParams(new HashMap<String, String>());
for (int i = 0; i < paramsList.size(); i++) {
ServiceParams param = paramsList.get(i);
String paramName = param.getParamCode();
Field declaredField = null;
try {
declaredField = sd.getClass().getDeclaredField(paramName);
} catch (Exception e) {
//e.printStackTrace();
}
if(declaredField !=null){
declaredField.setAccessible(true);
declaredField.set(sd,param.getParamVal());
}
}*/
System.out.println(/************************************加载系统默认参数完成*************************************************/);
}
}

View File

@@ -0,0 +1,74 @@
package com.saye.hrs.config;
import com.saye.hrs.commons.getBean.BeanUtil;
import com.saye.hrs.commons.string.StringDUtil;
import com.saye.hrs.mapper.system.MenuMapper;
import com.saye.hrs.model.Users;
import org.apache.catalina.User;
import org.springframework.stereotype.Component;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Component
public class LoginFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
static List<String> list= null;
static {
list = new ArrayList<String>();
list.add("/getCode");
list.add("/toLogin");
list.add("/login");
list.add("/logout");
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
MenuMapper menuMapper = BeanUtil.getBean(MenuMapper.class);
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
String url = request.getRequestURI();
System.out.println("this is MyFilter,url :"+url);
if(!list.contains(url) && url.indexOf("/layui/")==-1 && url.indexOf("/showFile/")==-1 && url.indexOf("/js")==-1 && url.indexOf("/css")==-1 && url.indexOf("/image")==-1 && url.indexOf("/api")==-1 && url.indexOf("/showImg")==-1) {
Users user = (Users) request.getSession().getAttribute("user");
if(user == null) {
response.sendRedirect("/toLogin");
}else {
//判断用户是否有此菜单权限
HashMap<Object,Object> map = new HashMap<Object,Object>();
map.put("userid", user.getUserId());
map.put("url", url);
List<HashMap<Object,Object>> menuList = menuMapper.findMenuByUrl(map);
if(!menuList.isEmpty()) {
String menu_id = StringDUtil.changeNullToEmpty(menuList.get(0).get("MENU_ID"));
map.put("menu_id", menu_id);
List<HashMap<Object,Object>> roleList = menuMapper.findRoleByUserAndMenu(map);
if(roleList.isEmpty()) {
response.sendRedirect("/toNoAuthority");
}else{
filterChain.doFilter(request, response);
}
}else{
filterChain.doFilter(request, response);
}
}
}else{
filterChain.doFilter(request, response);
}
}
@Override
public void destroy() {
}
}

View File

@@ -0,0 +1,58 @@
package com.saye.hrs.config;
import org.apache.ibatis.executor.result.ResultMapException;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* Description: 实体类数据返回时将null转成"" <result column="name" property="name" jdbcType="VARCHAR" typeHandler="com.saye.hrs.config.StringTypeHandler"/>
* @author dqzhang
* @created 2021年3月10日 下午3:29:00
*/
@MappedTypes({String.class})
@MappedJdbcTypes(JdbcType.VARCHAR)
public class StringTypeHandler extends BaseTypeHandler<String> {
@Override
public String getResult(ResultSet rs, String columnName) {
String result;
try {
result = getNullableResult(rs, columnName);
} catch (Exception e) {
throw new ResultMapException("Error attempting to get column '" + columnName + "' from result set. Cause: " + e, e);
}
return result;
}
@Override
public void setNonNullParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType)
throws SQLException {
ps.setString(i, parameter);
}
@Override
public String getNullableResult(ResultSet rs, String columnName)
throws SQLException {
return rs.getString(columnName) == null? "" : rs.getString(columnName);
}
@Override
public String getNullableResult(ResultSet rs, int columnIndex)
throws SQLException {
return rs.getString(columnIndex) == null? "" : rs.getString(columnIndex);
}
@Override
public String getNullableResult(CallableStatement cs, int columnIndex)
throws SQLException {
return cs.getString(columnIndex) == null? "" : cs.getString(columnIndex);
}
}

View File

@@ -0,0 +1,40 @@
package com.saye.hrs.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
/**
* Description: 配置虚拟路径
* @author dqzhang
* @created 2019年11月19日 下午3:26:06
*/
@Configuration
public class VirtualPathConfig extends WebMvcConfigurationSupport{
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
// TODO Auto-generated method stub
// registry.addResourceHandler("/images/**").addResourceLocations("file:d:/saye/");
registry.addResourceHandler("/showFile/**").addResourceLocations("file:/E:/saye/");
registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
registry.addResourceHandler("/webjars/**").addResourceLocations(
"classpath:/META-INF/resources/webjars/");
super.addResourceHandlers(registry);
}
@Override
protected void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("GET", "HEAD", "POST","PUT", "DELETE", "OPTIONS")
.allowedHeaders("*")
.exposedHeaders("access-control-allow-headers",
"access-control-allow-methods",
"access-control-allow-origin",
"access-control-max-age",
"X-Frame-Options")
.allowCredentials(false).maxAge(3600);
super.addCorsMappings(registry);
}
}

View File

@@ -0,0 +1,32 @@
package com.saye.hrs.config;
import org.springframework.stereotype.Component;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
@Component
public class XssFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
//XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper((HttpServletRequest) request);
//filterChain.doFilter(xssRequest, response);
filterChain.doFilter(request, response);
}
@Override
public void destroy() {
}
@Override
public void init(FilterConfig filterConfig) {
}
}

View File

@@ -0,0 +1,131 @@
package com.saye.hrs.config;
import com.alibaba.fastjson.JSONObject;
import com.saye.hrs.commons.string.StringDUtil;
import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;
import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.io.ByteArrayInputStream;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper{
HttpServletRequest orgRequest = null;
private static final Whitelist whitelist = Whitelist.basicWithImages();
public XssHttpServletRequestWrapper(HttpServletRequest request) {
super(request);
orgRequest = request;
}
@Override
public ServletInputStream getInputStream() throws IOException {
ServletInputStream stream = null;
try {
stream = orgRequest.getInputStream();
String requestBody = IOUtils.toString(stream, "utf-8");
requestBody = Jsoup.clean(requestBody,whitelist);
JSONObject resultJson = JSONObject.parseObject(requestBody);
byte[] array = resultJson.toString().getBytes("utf-8");
if (array == null) {
array = new byte[0];
}
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(array);
return new ServletInputStream() {
@Override
public boolean isFinished() {
return false;
}
@Override
public boolean isReady() {
return false;
}
@Override
public void setReadListener(ReadListener readListener) {
}
@Override
public int read() {
return byteArrayInputStream.read();
}
};
} catch (IOException e) {
e.printStackTrace();
}
return super.getInputStream();
}
/**
* 覆盖getParameter方法将参数名和参数值都做xss过滤.
* 如果需要获得原始的值则通过super.getParameterValues(name)来获取
* getParameterNames,getParameterValues和getParameterMap也可能需要覆盖
*/
@Override
public String getParameter(String name) {
if (("content".equals(name) || name.endsWith("WithHtml"))) {
return super.getParameter(name);
}
name = Jsoup.clean(name,whitelist);
String value = super.getParameter(name);
if (StringDUtil.isNotBlank(value)) {
value = Jsoup.clean(value,whitelist);
}
return value;
}
@Override
public String[] getParameterValues(String name) {
String[] arr = super.getParameterValues(name);
if (arr != null) {
for (int i = 0; i < arr.length; i++) {
arr[i] = Jsoup.clean(arr[i],whitelist);
}
}
return arr;
}
/**
* 覆盖getHeader方法将参数名和参数值都做xss过滤。<br/>
* 如果需要获得原始的值则通过super.getHeaders(name)来获取<br/>
* getHeaderNames 也可能需要覆盖
*/
@Override
public String getHeader(String name) {
name = Jsoup.clean(name,whitelist);
String value = super.getHeader(name);
if (StringDUtil.isNotBlank(value)) {
value = Jsoup.clean(value,whitelist);
}
return value;
}
/**
* 获取最原始的request
*
* @return
*/
public HttpServletRequest getOrgRequest() {
return orgRequest;
}
/**
* 获取最原始的request的静态方法
*
* @return
*/
public static HttpServletRequest getOrgRequest(HttpServletRequest req) {
if (req instanceof XssHttpServletRequestWrapper) {
return ((XssHttpServletRequestWrapper) req).getOrgRequest();
}
return req;
}
}

View File

@@ -0,0 +1,23 @@
package com.saye.hrs.config.dataSourceConfig;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.wrapper.MapWrapper;
import java.util.Map;
/**
* @author thuang
* @version 1.0
* @description: 用来将查询结果的key全转为大写
* @date 2021/5/8 10:05
*/
public class MapKeyUpperWrapper extends MapWrapper {
public MapKeyUpperWrapper(MetaObject metaObject, Map<String, Object> map) {
super(metaObject, map);
}
@Override
public String findProperty(String name, boolean useCamelCaseMapping) {
return name==null?"":name.toUpperCase() ;
}
}

View File

@@ -0,0 +1,26 @@
package com.saye.hrs.config.dataSourceConfig;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.wrapper.ObjectWrapper;
import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory;
import java.util.Map;
/**
* @author thuang
* @version 1.0
* @description: 重写工厂类使用自定义的MapKeyUpperWrapper
* @date 2021/5/8 10:08
*/
public class MapWrapperFactory implements ObjectWrapperFactory {
@Override
public boolean hasWrapperFor(Object object) {
return object != null && object instanceof Map;
}
@Override
public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
return new MapKeyUpperWrapper(metaObject, (Map) object);
}
}

View File

@@ -0,0 +1,25 @@
package com.saye.hrs.config.dataSourceConfig;
import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory;
import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
/**
* @author thuang
* @version 1.0
* @description: 自定义Convert 转换类 springboot只认ObjectWrapperFactory 自定义的那名字不认
* @date 2021/5/8 10:27
*/
@Component
@ConfigurationPropertiesBinding
public class ObjectWrapperFactoryConverter implements Converter<String, ObjectWrapperFactory> {
@Override
public ObjectWrapperFactory convert(String source) {
try {
return (ObjectWrapperFactory) Class.forName(source).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -0,0 +1,120 @@
package com.saye.hrs.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hrs.commons.log.ExceptionDUtil;
import com.saye.hrs.commons.log.LogUtil;
import com.saye.hrs.commons.page.PageUtil;
import com.saye.hrs.commons.page.TemplatePage;
import com.saye.hrs.service.BlackListService;
import com.saye.hrs.service.system.ServiceParamsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.List;
/**
* @description: 黑名单管理
* @author: Mr.zs
* @create: 2024-04-11 19:53
**/
@Controller
@RequestMapping("/blackList")
public class BlackListController {
@Autowired
BlackListService blackListService;
@Autowired
ServiceParamsService serviceParamsService;
@RequestMapping("toBlackList")
public String toBlackList(ModelMap modelMap, Model model) {
List<HashMap<Object, Object>> is_blackList = serviceParamsService.findParamValByParamCode("is_blackList");
String isBlackList = "";
for (HashMap<Object, Object> objectObjectHashMap : is_blackList) {
isBlackList = objectObjectHashMap.get("PARAM_VAL").toString();
}
model.addAttribute("isBlackList", isBlackList);
return "/blacklist/blackList";
}
@RequestMapping("/findAllBlackList")
@ResponseBody
public TemplatePage findAllBlackList(Integer page, Integer limit, String cardNo) {
HashMap<Object, Object> searchMap = new HashMap<>();
searchMap.put("cardNo", cardNo);
// searchMap.put("isThird", isThird);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> appsPageInfo = new PageInfo<>(blackListService.findAllBlackList(searchMap));
return PageUtil.loadJsonPage(appsPageInfo);
}
@RequestMapping("/modifyBlackList")
@ResponseBody
public HashMap<Object, Object> modifyBlackList(@RequestBody HashMap<Object, Object> map) {
String errCode = "0";
String errMsg = "";
try {
blackListService.modifyBlackList(map);
} catch (Exception e) {
errCode = "999";
errMsg = "修改黑名单失败";
LogUtil.error(this.getClass(), "修改黑名单失败,原因:" + ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
@RequestMapping("/delBlackList")
@ResponseBody
public HashMap<Object, Object> delBlackList(@RequestBody HashMap<Object, Object> map) {
String errCode = "0";
String errMsg = "";
try {
blackListService.delBlackList(map);
} catch (Exception e) {
errCode = "999";
errMsg = "删除黑名单失败";
LogUtil.error(this.getClass(), "删除黑名单失败,原因:" + ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
@RequestMapping("/changeBlackListStatus")
@ResponseBody
public HashMap<Object, Object> changeBlackListStatus(@RequestBody HashMap<String, String> map) {
String errCode = "0";
String errMsg = "";
// HashMap<String, String> operateMap = new HashMap<>();
// operateMap.put("param_code", map.get("param_code").toString());
// operateMap.put("param_val", map.get("param_val").toString());
try {
serviceParamsService.updateServiceParamsValBycode(map);
} catch (Exception e) {
errCode = "999";
errMsg = "修改黑名单状态失败";
LogUtil.error(this.getClass(), "修改黑名单状态失败,原因:" + ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
}

View File

@@ -0,0 +1,73 @@
package com.saye.hrs.controller;
import com.google.common.base.Joiner;
import com.saye.hrs.service.CountAuthService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.List;
/**
* @author Mr.zs
* @date 2025/2/8
*/
@Controller
@RequestMapping("/api")
@RequiredArgsConstructor
@Slf4j
public class CountAuthController {
private final CountAuthService countAuthService;
// 查询有权限的用户列表
@RequestMapping("/getAutho")
@ResponseBody
public HashMap<String, Object> getAutho() {
HashMap<String, Object> resMap = new HashMap<>();
resMap.put("code", 200);
resMap.put("msg", "查询有权限的用户列表");
List<String> list = countAuthService.getAutherList();
if (list != null) {
resMap.put("data", list);
return resMap;
}
return null;
}
// 查询用户的权限列表
@RequestMapping("/getAuthoList")
@ResponseBody
public Object getAuthoList(String openid) {
HashMap<String, Object> resMap = new HashMap<>();
resMap.put("code", 200);
resMap.put("msg", "查询用户的权限列表");
List<String> list = countAuthService.getAuthoList(openid);
if (list != null) {
resMap.put("data", list);
return resMap;
}
return null;
}
// 查询用户的科室权限列表
@RequestMapping("/getDeptAuthList")
@ResponseBody
public Object getDeptAuthList(String openid) {
HashMap<String, Object> resMap = new HashMap<>();
resMap.put("code", 200);
resMap.put("msg", "查询用户的权限列表");
List<String> depts = countAuthService.getDeptAuthList(openid);
String result = Joiner.on(",").skipNulls().join(depts);
System.out.println("list " + result);
if (depts != null) {
resMap.put("data", result);
return resMap;
}
return null;
}
}

View File

@@ -0,0 +1,180 @@
package com.saye.hrs.controller;
import javax.annotation.Resource;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hrs.commons.date.DateDUtil;
import com.saye.hrs.commons.log.ExceptionDUtil;
import com.saye.hrs.commons.log.LogUtil;
import com.saye.hrs.commons.page.PageUtil;
import com.saye.hrs.commons.page.TemplatePage;
import com.saye.hrs.service.HospitalService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.saye.hrs.service.DoctorService;
import java.util.HashMap;
import java.util.List;
import org.springframework.ui.ModelMap;
/**
*
*
* @author dqzhang
* @since 2021-09-16 15:17:12
*/
@RequestMapping("doctor")
@Controller
public class DoctorController {
@Resource
private DoctorService doctorService;
@Resource
private HospitalService hospitalService;
/**
* 跳转页面
* @param modelMap
* @param
* @return
*/
@RequestMapping("/toDoctor")
public String toUserManager(ModelMap modelMap){
//查询所有角色
return "hospital/doctor";
}
/**
* 分页查询列表
* @param page limit
* @param
* @return 查询结果
*/
@RequestMapping("/findDoctorPageList")
@ResponseBody
public TemplatePage findDoctorPageList(Integer page,Integer limit) {
HashMap<Object,Object> map=new HashMap<Object,Object>();
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object,Object>> appsPageInfo = new PageInfo<HashMap<Object,Object>>(this.doctorService.findDoctorList(map));
return PageUtil.loadJsonPage(appsPageInfo);
}
/**
* 通过主键查询单条数据
* @param map
* @return 单条数据
*/
@RequestMapping("/findDoctorById")
@ResponseBody
public HashMap<Object,Object> findDoctorById(@RequestBody HashMap<Object,Object> map) {
return this.doctorService.findDoctorById(map);
}
/**
* 新增数据
* @param map
* @return map
*/
@RequestMapping("/insertDoctor")
@ResponseBody
public HashMap<Object,Object> insertDoctor(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.doctorService.insertDoctor(map);
} catch (Exception e) {
errCode = "999";
errMsg = "新增失败";
LogUtil.error(this.getClass(), "新增失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 编辑数据
* @param map
* @return map
*/
@RequestMapping("/updateDoctor")
@ResponseBody
public HashMap<Object,Object> updateDoctor(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.doctorService.updateDoctor(map);
} catch (Exception e) {
errCode = "999";
errMsg = "修改失败";
LogUtil.error(this.getClass(), "修改失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 删除数据
* @param map
* @return map
*/
@RequestMapping("/deleteDoctorById")
@ResponseBody
public HashMap<Object,Object> deleteDoctorById(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.doctorService.deleteDoctorById(map);
} catch (Exception e) {
errCode = "999";
errMsg = "删除失败";
LogUtil.error(this.getClass(), "删除失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
@RequestMapping("/toDoctorSc")
public String toDoctorSc(ModelMap modelMap){
//查询所有角色
return "hospital/doctorSc";
}
/** 去医生排班页面
* @param modelMap
* @return
*/
@RequestMapping("/toDoctorSchedual")
public String toDoctorSchedual(ModelMap modelMap){
modelMap.addAttribute("list", this.hospitalService.findHospitalList(new HashMap<Object, Object>()));
//查询所有角色
return "hospital/doctorSchedual";
}
/** 查询医生排班列表
* @param hospital_id week
* @return
*/
@RequestMapping("/findDoctorSchedualList")
@ResponseBody
public HashMap<Object, Object> findDoctorSchedualList(String hospital_id, String week) {
HashMap<Object,Object> map = new HashMap<Object,Object>();
map.put("hospital_id",hospital_id);
List<String> array = DateDUtil.findWeekDays(week);
map.put("dayList", array);
List<HashMap<Object, Object>> list = this.doctorService.findDoctorSchedualList(map);
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("dayList",array);
resultMap.put("list",list);
return resultMap;
}
}

View File

@@ -0,0 +1,635 @@
package com.saye.hrs.controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hrs.commons.date.DateDUtil;
import com.saye.hrs.commons.log.ExceptionDUtil;
import com.saye.hrs.commons.log.LogUtil;
import com.saye.hrs.commons.page.PageUtil;
import com.saye.hrs.commons.page.TemplatePage;
import com.saye.hrs.commons.uuid.UUIDGenerator;
import com.saye.hrs.model.StatusDefine;
import com.saye.hrs.model.Users;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.saye.hrs.service.HospitalService;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
/**
*
*
* @author dqzhang
* @since 2021-09-15 09:43:02
*/
@RequestMapping("hospital")
@Controller
public class HospitalController {
@Resource
private HospitalService hospitalService;
/**
* 跳转页面
* @param modelMap
* @param
* @return
*/
@RequestMapping("/toHospital")
public String toUserManager(ModelMap modelMap){
//查询所有角色
return "hospital/hospital";
}
/**
* 分页查询列表
* @param page limit
* @param
* @return 查询结果
*/
@RequestMapping("/findHospitalPageList")
@ResponseBody
public TemplatePage findHospitalPageList(Integer page,Integer limit) {
HashMap<Object,Object> map=new HashMap<Object,Object>();
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object,Object>> appsPageInfo = new PageInfo<HashMap<Object,Object>>(this.hospitalService.findHospitalList(map));
return PageUtil.loadJsonPage(appsPageInfo);
}
/**
* 通过主键查询单条数据
* @param map
* @return 单条数据
*/
@RequestMapping("/findHospitalById")
@ResponseBody
public HashMap<Object,Object> findHospitalById(@RequestBody HashMap<Object,Object> map) {
return this.hospitalService.findHospitalById(map);
}
/**
* 新增数据
* @param map
* @return map
*/
@RequestMapping("/insertHospital")
@ResponseBody
public HashMap<Object,Object> insertHospital(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.hospitalService.insertHospital(map);
} catch (Exception e) {
errCode = "999";
errMsg = "新增失败";
LogUtil.error(this.getClass(), "新增失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 编辑数据
* @param map
* @return map
*/
@RequestMapping("/updateHospital")
@ResponseBody
public HashMap<Object,Object> updateHospital(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.hospitalService.updateHospital(map);
} catch (Exception e) {
errCode = "999";
errMsg = "修改失败";
LogUtil.error(this.getClass(), "修改失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 删除数据
* @param map
* @return map
*/
@RequestMapping("/deleteHospitalById")
@ResponseBody
public HashMap<Object,Object> deleteHospitalById(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.hospitalService.deleteHospitalById(map);
} catch (Exception e) {
errCode = "999";
errMsg = "删除失败";
LogUtil.error(this.getClass(), "删除失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 去医院介绍页面
* @param modelMap
* @param
* @return
*/
@RequestMapping("/toHospitalAbout")
public String toHospitalAbout(ModelMap modelMap){
List<HashMap<Object, Object>> list = this.hospitalService.findHospitalList(new HashMap<Object,Object>());
modelMap.addAttribute("list",list);
return "hospital/hospitalAbout";
}
/**
* 查询医院信息列表
* @return 查询结果
*/
@RequestMapping("/findHospitalAbout")
@ResponseBody
public List<HashMap<Object, Object>> findHospitalAbout() {
return this.hospitalService.findHospitalList(new HashMap<Object,Object>());
}
/**
* 更新医院介绍
* @param map
* @return map
*/
@RequestMapping("/updateHospitalAbout")
@ResponseBody
public HashMap<Object,Object> updateHospitalAbout(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.hospitalService.updateHospitalAbout(map);
} catch (Exception e) {
errCode = "999";
errMsg = "删除失败";
LogUtil.error(this.getClass(), "删除失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 去医院通知页面
* @param modelMap
* @param
* @return
*/
@RequestMapping("/toHospitalNotice")
public String toHospitalNotice(ModelMap modelMap){
return "hospital/hospitalNotice";
}
/** 查询医院通知列表
* @param title
* @return
*/
@RequestMapping("/findHospitalNoticeList")
@ResponseBody
public TemplatePage findHospitalNoticeList(String title) {
HashMap<Object,Object> map = new HashMap<Object,Object>();
map.put("title",title);
List<HashMap<Object, Object>> list = this.hospitalService.findHospitalNoticeList(map);
TemplatePage templetJson = new TemplatePage();
templetJson.setCode(0);
templetJson.setMsg("");
templetJson.setData(list);
templetJson.setCount(list.size());
return templetJson;
}
/** 查询医院通知列表
* @param title
* @return
*/
@RequestMapping("/findHospitalNotice")
@ResponseBody
public List<HashMap<Object, Object>> findHospitalNotice(String title) {
HashMap<Object,Object> map = new HashMap<Object,Object>();
map.put("title",title);
return this.hospitalService.findHospitalNoticeList(map);
}
@RequestMapping("/uploadImg")
@ResponseBody
public HashMap<Object, Object> uploadImg(MultipartFile file) {
HashMap<String,String> map=new HashMap<String,String>();
String errCode = "0";
String errMsg = "";
String relative_path = "";
String uuid = UUIDGenerator.getUUID();
try {
String realFileName = file.getOriginalFilename();//获取文件名称
String suffix = realFileName.substring(realFileName.lastIndexOf(".") + 1);//获取文件后缀名
String create_date= DateDUtil.getCurrentDate();
relative_path = "hospitalNotice" + "/" + create_date + "/" + System.currentTimeMillis() + "." + suffix;
String real_path = StatusDefine.filePath + relative_path;
Path path = Paths.get(real_path);//设置保存路径
File f = new File(real_path);
if (!f.getParentFile().exists()) {
f.getParentFile().mkdirs();
}
byte[] bytes = file.getBytes();
Files.write(path, bytes);
} catch (IOException e) {
errCode = "999";
errMsg = "上传图片失败!";
LogUtil.error(this.getClass(), errMsg+",原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resMap = new HashMap<Object,Object>();
resMap.put("relative_path",relative_path);
resMap.put("errCode", errCode);
resMap.put("errMsg", errMsg);
return resMap;
}
/**
* 新增医院通知
* @param map
* @return
*/
@RequestMapping("/addHospitalNotice")
@ResponseBody
public HashMap<Object,Object> addHospitalNotice(HttpServletRequest request, @RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
Users user = (Users) request.getSession().getAttribute("user");
map.put("user_name",user.getUserName());
this.hospitalService.addHospitalNotice(map);
} catch (Exception e) {
errCode = "999";
errMsg = "新增医院通知失败";
LogUtil.error(this.getClass(), "新增医院通知失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 修改医院通知
* @param map
* @return
*/
@RequestMapping("/updateHospitalNotice")
@ResponseBody
public HashMap<Object,Object> updateHospitalNotice(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.hospitalService.updateHospitalNotice(map);
} catch (Exception e) {
errCode = "999";
errMsg = "修改医院通知失败";
LogUtil.error(this.getClass(), "修改医院通知失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 删除医院通知
* @param map
* @return
*/
@RequestMapping("/deleteHospitalNotice")
@ResponseBody
public HashMap<Object,Object> deleteHospitalNotice(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.hospitalService.deleteHospitalNotice(map);
} catch (Exception e) {
errCode = "999";
errMsg = "删除医院通知失败";
LogUtil.error(this.getClass(), "删除医院通知失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 去健康百科页面
* @param modelMap
* @param
* @return
*/
@RequestMapping("/toHospitalArticle")
public String toHospitalArticle(ModelMap modelMap){
return "hospital/hospitalArticle";
}
/** 查询健康百科列表
* @param title
* @return
*/
@RequestMapping("/findHospitalArticleList")
@ResponseBody
public TemplatePage findHospitalArticleList(String title) {
HashMap<Object,Object> map = new HashMap<Object,Object>();
map.put("title",title);
List<HashMap<Object, Object>> list = this.hospitalService.findHospitalArticleList(map);
TemplatePage templetJson = new TemplatePage();
templetJson.setCode(0);
templetJson.setMsg("");
templetJson.setData(list);
templetJson.setCount(list.size());
return templetJson;
}
/**
* 新增健康百科
* @param map
* @return
*/
@RequestMapping("/addHospitalArticle")
@ResponseBody
public HashMap<Object,Object> addHospitalArticle(HttpServletRequest request,@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.hospitalService.addHospitalArticle(map);
} catch (Exception e) {
errCode = "999";
errMsg = "新增健康百科失败";
LogUtil.error(this.getClass(), "新增健康百科失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 修改健康百科
* @param map
* @return
*/
@RequestMapping("/updateHospitalArticle")
@ResponseBody
public HashMap<Object,Object> updateHospitalArticle(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.hospitalService.updateHospitalArticle(map);
} catch (Exception e) {
errCode = "999";
errMsg = "修改健康百科失败";
LogUtil.error(this.getClass(), "修改健康百科失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 删除健康百科
* @param map
* @return
*/
@RequestMapping("/deleteHospitalArticle")
@ResponseBody
public HashMap<Object,Object> deleteHospitalArticle(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.hospitalService.deleteHospitalArticle(map);
} catch (Exception e) {
errCode = "999";
errMsg = "删除健康百科失败";
LogUtil.error(this.getClass(), "删除健康百科失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* @description 去就医指南配置页面
* @author dqzhang
* @created 2021年11月15日 下午4:04:23
* @param modelMap
* @return
*/
@RequestMapping("/toMedicalGuide")
public String toMedicalGuide(ModelMap modelMap){
//查询所有角色
return "hospital/medicalGuide";
}
/** 查询健康百科列表
* @param title
* @return
*/
@RequestMapping("/findMedicalGuideList")
@ResponseBody
public TemplatePage findMedicalGuideList(String name) {
HashMap<Object,Object> map = new HashMap<Object,Object>();
map.put("name",name);
List<HashMap<Object, Object>> list = this.hospitalService.findMedicalGuideList(map);
TemplatePage templetJson = new TemplatePage();
templetJson.setCode(0);
templetJson.setMsg("");
templetJson.setData(list);
templetJson.setCount(list.size());
return templetJson;
}
/**
* 新增就医指南
* @param map
* @return
*/
@RequestMapping("/addMedicalGuide")
@ResponseBody
public HashMap<Object,Object> addMedicalGuide(HttpServletRequest request,@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
Users user = (Users) request.getSession().getAttribute("user");
map.put("user_name",user.getUserName());
this.hospitalService.addMedicalGuide(map);
} catch (Exception e) {
errCode = "999";
errMsg = "新增就医指南失败";
LogUtil.error(this.getClass(), "新增就医指南失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 修改就医指南
* @param map
* @return
*/
@RequestMapping("/updateMedicalGuide")
@ResponseBody
public HashMap<Object,Object> updateMedicalGuide(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.hospitalService.updateMedicalGuide(map);
} catch (Exception e) {
errCode = "999";
errMsg = "修改就医指南失败";
LogUtil.error(this.getClass(), "修改就医指南失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 删除就医指南
* @param map
* @return
*/
@RequestMapping("/deleteMedicalGuide")
@ResponseBody
public HashMap<Object,Object> deleteMedicalGuide(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.hospitalService.deleteMedicalGuide(map);
} catch (Exception e) {
errCode = "999";
errMsg = "删除就医指南失败";
LogUtil.error(this.getClass(), "删除就医指南失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/** 查询医院楼层信息
* @param title
* @return
*/
@RequestMapping("/findHospitalFloorList")
@ResponseBody
public TemplatePage findHospitalFloorList(String hospital_id) {
HashMap<Object,Object> map = new HashMap<Object,Object>();
map.put("HOSPITAL_ID",hospital_id);
List<HashMap<Object, Object>> list = this.hospitalService.findHospitalFloorList(map);
TemplatePage templetJson = new TemplatePage();
templetJson.setCode(0);
templetJson.setMsg("");
templetJson.setData(list);
templetJson.setCount(list.size());
return templetJson;
}
/** 新增医院楼层信息
* @param title
* @return
*/
@RequestMapping("/addHospitalFloor")
@ResponseBody
public HashMap<Object, Object> addHospitalFloor(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.hospitalService.addHospitalFloor(map);
} catch (Exception e) {
errCode = "999";
errMsg = "新增楼层信息失败";
LogUtil.error(this.getClass(), "新增楼层信息失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/** 修改医院楼层信息
* @param title
* @return
*/
@RequestMapping("/updateHospitalFloor")
@ResponseBody
public HashMap<Object, Object> updateHospitalFloor(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.hospitalService.updateHospitalFloor(map);
} catch (Exception e) {
errCode = "999";
errMsg = "修改楼层信息失败";
LogUtil.error(this.getClass(), "修改楼层信息失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/** 删除医院楼层信息
* @param title
* @return
*/
@RequestMapping("/deleteHospitalFloor")
@ResponseBody
public HashMap<Object, Object> deleteHospitalFloor(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.hospitalService.deleteHospitalFloor(map);
} catch (Exception e) {
errCode = "999";
errMsg = "删除楼层失败";
LogUtil.error(this.getClass(), "删除楼层失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
}

View File

@@ -0,0 +1,566 @@
package com.saye.hrs.controller;
import com.saye.hrs.commons.date.DateDUtil;
import com.saye.hrs.commons.log.LogUtil;
import com.saye.hrs.commons.string.StringDUtil;
import com.saye.hrs.service.HospitalService;
import com.saye.hrs.service.OrderService;
import com.saye.hrs.service.PatientService;
import com.saye.hrs.service.system.LoggerService;
import com.saye.hrs.service.system.ServiceParamsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RequestMapping("api")
@Controller
public class HttpController {
@Resource
private PatientService patientService;
@Resource
private HospitalService hospitalService;
@Resource
private OrderService orderService;
@Resource
private ServiceParamsService serviceParamsService;
@Autowired
private LoggerService loggerService;
/**
* 根据openid获取患者信息
* @return
* @throws Exception
*/
@RequestMapping("/getPatientByOpenid")
@ResponseBody
public List<HashMap<Object,Object>> getPatientByOpenid(@RequestBody HashMap<Object,Object> map) throws Exception{
List<HashMap<Object,Object>> list = this.patientService.findPatientByOpenid(map);
return list;
}
/**
* 通过主键查询单条数据
* @param map
* @return 单条数据
*/
@RequestMapping("/findPatientById")
@ResponseBody
public HashMap<Object,Object> findPatientById(@RequestBody HashMap<Object,Object> map) {
return this.patientService.findPatientById(map);
}
/**
* 根据openid获取住院患者信息
* @return
* @throws Exception
*/
@RequestMapping("/getZyPatientByOpenid")
@ResponseBody
public List<HashMap<Object,Object>> getZyPatientByOpenid(@RequestBody HashMap<Object,Object> map) throws Exception{
return this.patientService.getZyPatientByOpenid(map);
}
/**
* 微信用户绑定患者
* @return
* @throws Exception
*/
@RequestMapping("/patientBindWXUser")
@ResponseBody
public HashMap<Object,Object> patientBindWXUser(@RequestBody HashMap<Object,Object> map) throws Exception{
String errCode = "0";
String errMsg = "";
try {
this.patientService.patientBindWXUser(map);
}catch(Exception e){
errCode = "999";
errMsg = e.toString();
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 微信用户绑定患者
* @return
* @throws Exception
*/
@RequestMapping("/zyPatientBindWXUser")
@ResponseBody
public HashMap<Object,Object> zyPatientBindWXUser(@RequestBody HashMap<Object,Object> map) throws Exception{
String errCode = "0";
String errMsg = "";
try {
this.patientService.zyPatientBindWXUser(map);
}catch(Exception e){
errCode = "999";
errMsg = e.toString();
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**设为默认
* @return
* @throws Exception
*/
@RequestMapping("/setPatientTypeByOpenid")
@ResponseBody
public HashMap<Object,Object> setPatientTypeByOpenid(@RequestBody HashMap<Object,Object> map) throws Exception{
String errCode = "0";
String errMsg = "";
try {
this.patientService.setPatientTypeByOpenid(map);
}catch(Exception e){
errCode = "999";
errMsg = e.toString();
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 微信用户解除绑定患者
* @return
* @throws Exception
*/
@RequestMapping("/patientUnbindWXUser")
@ResponseBody
public HashMap<Object,Object> patientUnbindWXUser(@RequestBody HashMap<Object,Object> map) throws Exception{
String errCode = "0";
String errMsg = "";
try {
this.patientService.patientUnbindWXUser(map);
}catch(Exception e){
errCode = "999";
errMsg = e.toString();
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 修改患者信息
* @return
* @throws Exception
*/
@RequestMapping("/updatePatientByOpenid")
@ResponseBody
public HashMap<Object,Object> updatePatientByOpenid(@RequestBody HashMap<Object,Object> map) throws Exception{
String errCode = "0";
String errMsg = "";
try {
this.patientService.updatePatientByOpenid(map);
}catch(Exception e){
errCode = "999";
errMsg = e.toString();
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/** 查询医院信息
* @return
* @throws Exception
*/
@RequestMapping("/findHospital")
@ResponseBody
public HashMap<Object,Object> findHospital() throws Exception{
return this.hospitalService.findHospitalList(new HashMap<Object,Object>()).get(0);
}
/** 查询医院通知列表
* @param
* @return
*/
@RequestMapping("/findHospitalNotice")
@ResponseBody
public List<HashMap<Object, Object>> findHospitalNotice(@RequestBody HashMap<Object,Object> map) {
return this.hospitalService.findHospitalNoticeList(map);
}
/**查询医院信息列表
* @return 查询结果
*/
@RequestMapping("/findHospitalAbout")
@ResponseBody
public List<HashMap<Object, Object>> findHospitalAbout() {
return this.hospitalService.findHospitalList(new HashMap<Object,Object>());
}
/**查询预约须知
* @return 查询结果
*/
@RequestMapping("/findOrderNotice")
@ResponseBody
public HashMap<Object, Object> findOrderNotice() {
return this.orderService.findOrderNotice();
}
/** 查询就医指导
* @return
* @throws Exception
*/
@RequestMapping("/findMedicalGuide")
@ResponseBody
public List<HashMap<Object,Object>> findMedicalGuide() throws Exception{
return this.hospitalService.findMedicalGuide();
}
/**
* 查询就医指导明细
* @return
* @throws Exception
*/
@RequestMapping("/findMedicalGuideById")
@ResponseBody
public List<HashMap<Object,Object>> findMedicalGuideById(@RequestBody HashMap<Object,Object> map) throws Exception{
return this.hospitalService.findMedicalGuideById(map);
}
/**
* 查询医院健康百科
* @return
* @throws Exception
*/
@RequestMapping("/findHospitalArticle")
@ResponseBody
public List<HashMap<Object, Object>> findHospitalArticle(@RequestBody HashMap map) throws Exception{
return this.hospitalService.findHospitalArticleList(map);
}
/**问题反馈
* @return
* @return
* @throws Exception
*/
@RequestMapping("/problemFeedback")
@ResponseBody
public HashMap<Object, Object> problemFeedback(@RequestBody Map map) throws Exception{
String errCode = "0";
String errMsg = "";
try {
this.hospitalService.problemFeedback(map);
} catch (Exception e) {
errCode = "999";
errMsg = "系统异常!";
LogUtil.error(this.getClass(), "问题反馈异常:"+e.toString());
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
/**
* @description 查询消息通知
* @author dqzhang
* @created 2021年11月23日 下午2:59:02
* @param map
* @return
* @throws Exception
*/
@RequestMapping("/findMessageNotice")
@ResponseBody
public List<HashMap<Object, Object>> findMessageNotice(@RequestBody HashMap<Object, Object> map) throws Exception{
map.put("status", "0");
return this.hospitalService.findMessageNotice(map);
}
@RequestMapping("/findAllMessageNotice")
@ResponseBody
public List<HashMap<Object, Object>> findMessageAllNotice(@RequestBody HashMap<Object, Object> map) throws Exception {
return this.hospitalService.findMessageNotice(map);
}
/**
* @description 设置消息已读
* @author dqzhang
* @created 2021年11月23日 下午2:58:43
* @param map
* @return
* @throws Exception
*/
@RequestMapping("/setMessageNoticeRead")
@ResponseBody
public HashMap<Object, Object> setMessageNoticeRead(@RequestBody Map map) throws Exception{
String errCode = "0";
String errMsg = "";
try {
this.hospitalService.setMessageNoticeRead(map);
} catch (Exception e) {
errCode = "999";
errMsg = "系统异常!";
LogUtil.error(this.getClass(), "设置消息已读失败:"+e.toString());
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
/**
* @param map
* @return
* @throws Exception
* @description 设置消息已读
* @author dqzhang
* @created 2021年11月23日 下午2:58:43
*/
@RequestMapping("/setMessageNoticeAllRead")
@ResponseBody
public HashMap<Object, Object> setMessageNoticeAllRead(@RequestBody Map map) throws Exception {
String errCode = "0";
String errMsg = "";
try {
this.hospitalService.setMessageNoticeAllRead(map);
} catch (Exception e) {
errCode = "999";
errMsg = "系统异常!";
LogUtil.error(this.getClass(), "设置消息已读失败:" + e.toString());
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
/**
* @description 写入银商下单接口信息
* @author dqzhang
* @created 2021年11月22日 下午3:43:14
* @param map
* @return
* @throws Exception
*/
@RequestMapping("/addPayRequest")
@ResponseBody
public HashMap<Object, Object> addPayRequest(@RequestBody Map map) throws Exception{
String errCode = "0";
String errMsg = "";
try {
map.put("create_time", DateDUtil.DateToStr("yyyy-MM-dd HH:mm:ss", new Date()));
this.hospitalService.addPayRequest(map);
} catch (Exception e) {
errCode = "999";
errMsg = "写入下单信息失败!";
LogUtil.error(this.getClass(), "写入下单信息失败:"+e.toString());
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
/**
* @description 支付成功写入his充值接口
* @author dqzhang
* @created 2021年11月22日 下午3:43:14
* @param map
* @return
* @throws Exception
*/
@RequestMapping("/addHisRecharge")
@ResponseBody
public HashMap<Object, Object> addHisRecharge(@RequestBody Map map) throws Exception{
String errCode = "0";
String errMsg = "";
String hisStatus = "";
try {
HashMap<Object, Object> respMap = this.hospitalService.addHisRecharge(map);
hisStatus = StringDUtil.changeNullToEmpty(respMap.get("hisStatus"));
} catch (Exception e) {
errCode = "999";
errMsg = "支付成功,调用调用充值接口失败!";
LogUtil.error(this.getClass(), "写入his充值接口失败"+e.toString());
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
resultMap.put("hisStatus", hisStatus);
return resultMap;
}
/**
* @description 预约成功记录写入数据库
* @author dqzhang
* @created 2021年11月23日 下午3:06:26
* @param map
* @return
* @throws Exception
*/
@RequestMapping("/insertOrder")
@ResponseBody
public HashMap<Object, Object> insertOrder(@RequestBody HashMap<Object,Object> map) throws Exception{
String errCode = "0";
String errMsg = "";
try {
this.orderService.insertOrder(map);
} catch (Exception e) {
errCode = "999";
errMsg = "预约失败!";
LogUtil.error(this.getClass(), "预约成功记录写入数据库失败:"+e.toString());
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
/**
* @description 取消预约
* @author dqzhang
* @created 2021年11月23日 下午3:59:40
* @param map
* @return
* @throws Exception
*/
@RequestMapping("/cancelOrder")
@ResponseBody
public HashMap<Object, Object> cancelOrder(@RequestBody HashMap<Object,Object> map) throws Exception{
String errCode = "0";
String errMsg = "";
try {
this.orderService.cancelOrder(map);
} catch (Exception e) {
errCode = "999";
errMsg = "取消预约!";
LogUtil.error(this.getClass(), "取消预约失败:"+e.toString());
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
/**
* @description 设置微信小程序最后登录时间
* @author dqzhang
* @created 2021年11月24日 上午10:04:10
* @param map
* @return
* @throws Exception
*/
@RequestMapping("/setWXLoginTime")
@ResponseBody
public HashMap<Object, Object> setWXLoginTime(@RequestBody HashMap<Object,Object> map) throws Exception{
String errCode = "0";
String errMsg = "";
try {
this.orderService.setWXLoginTime(map);
} catch (Exception e) {
errCode = "999";
errMsg = "更新最后登录时间!";
LogUtil.error(this.getClass(), "更新最后登录时间失败:"+e.toString());
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
/**
* @description 查询待支付订单
* @author dqzhang
* @created 2021年11月30日 上午8:59:50
* @param
* @return
* @throws Exception
*/
@RequestMapping("/findRechargeWait")
@ResponseBody
public List<HashMap<Object, Object>> findRechargeWait() throws Exception{
return this.orderService.findRechargeWait();
}
/**
* @description 新增退款记录
* @author dqzhang
* @created 2021年11月24日 上午10:04:10
* @param map
* @return
* @throws Exception
*/
@RequestMapping("/addRefund")
@ResponseBody
public HashMap<Object, Object> addRefund(@RequestBody HashMap<Object,Object> map) throws Exception{
String errCode = "0";
String errMsg = "";
try {
map.put("create_time", DateDUtil.DateToStr("yyyy-MM-dd HH:mm:ss", new Date()));
this.orderService.addRefund(map);
} catch (Exception e) {
errCode = "999";
errMsg = "新增退款记录失败!";
LogUtil.error(this.getClass(), errMsg+e.toString());
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
/**
* @description 获取退款时间
* @author dqzhang
* @created 2022年2月7日 下午2:33:39
* @return
* @throws Exception
*/
@RequestMapping("/getRefundTime")
@ResponseBody
public String getRefundTime() throws Exception{
List<HashMap<Object, Object>> list = serviceParamsService.findParamValByParamCode("REFUND_TIME");
if(list.isEmpty()) {
return "";
}
return StringDUtil.changeNullToEmpty(list.get(0).get("PARAM_VAL"));
}
/**
* @description 写入充值不成功且退款失败的消息提醒
* @author dqzhang
* @created 2022年2月7日 下午2:37:15
* @return
* @throws Exception
*/
@RequestMapping("/addRefundMessageNotice")
@ResponseBody
public void addRefundMessageNotice(@RequestBody HashMap<Object,Object> map) throws Exception{
this.orderService.addRefundMessageNotice(map);
}
/**
* @description 添加his日志
* @author dqzhang
* @created 2022年2月7日 下午2:37:15
* @return
* @throws Exception
*/
@RequestMapping("/addHisLog")
@ResponseBody
public void addHisLog(@RequestBody HashMap<Object,Object> map) throws Exception{
this.loggerService.addHisLog(map);
}
}

View File

@@ -0,0 +1,134 @@
package com.saye.hrs.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hrs.commons.log.ExceptionDUtil;
import com.saye.hrs.commons.log.LogUtil;
import com.saye.hrs.commons.page.PageUtil;
import com.saye.hrs.commons.page.TemplatePage;
import com.saye.hrs.model.BodyDivision;
import com.saye.hrs.service.IssueService;
import com.saye.hrs.service.SymptomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.List;
/**
* @description: 导诊问题管理
* @author: Mr.zs
* @create: 2024-04-09 13:02
**/
@Controller
@RequestMapping("/issue")
public class IssueController {
@Autowired
IssueService issueService;
@Autowired
SymptomService symptomService;
@RequestMapping("/toIssue")
public String toIssue(ModelMap modelMap) {
List<BodyDivision> bodyDivisions = symptomService.findAllBodyArea();
modelMap.put("bodyAreaList", bodyDivisions);
return "guidance/issue";
}
@RequestMapping("/findAllQuestions")
@ResponseBody
public TemplatePage findAllQuestions(Integer page, Integer limit, String questions, String symptomName, String bodyArea, String gender, String adultOrChild) {
System.out.println("questions is :" + questions);
HashMap<Object, Object> searchMap = new HashMap<>();
searchMap.put("questions", questions);
searchMap.put("symptom", symptomName);
searchMap.put("bodyArea", bodyArea);
searchMap.put("gender", gender);
searchMap.put("adultOrChild", adultOrChild);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> appsPageInfo = new PageInfo<>(issueService.findAllQuestions(searchMap));
return PageUtil.loadJsonPage(appsPageInfo);
}
@RequestMapping("/getSymptomByAreaType")
@ResponseBody
public HashMap<Object, Object> getSymptomByAreaType(ModelMap modelMap, String bodyAreaType) {
HashMap<Object, Object> resultMap = new HashMap<>();
String errCode = "0";
String errMsg = "";
HashMap<Object, Object> searchMap = new HashMap<>();
searchMap.put("bodyAreaType", bodyAreaType);
try {
List<HashMap<Object, Object>> result = symptomService.getSymptomByAreaType(searchMap);
resultMap.put("data", result);
} catch (Exception e) {
e.printStackTrace();
errCode = "999";
errMsg = "查询症状失败,原因:" + e.getMessage();
}
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
@RequestMapping("/addQuestions")
@ResponseBody
public HashMap<Object, Object> addQuestions(@RequestBody HashMap<Object, Object> map) {
String errCode = "0";
String errMsg = "";
try {
issueService.addQuestions(map);
} catch (Exception e) {
errCode = "999";
errMsg = "新增问题信息失败";
LogUtil.error(this.getClass(), "新增问题信息失败,原因:" + ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
@RequestMapping("/delQuestions")
@ResponseBody
public HashMap<Object, Object> delQuestions(@RequestBody HashMap<Object, Object> map) {
String errCode = "0";
String errMsg = "";
try {
issueService.delQuestions(map);
} catch (Exception e) {
errCode = "999";
errMsg = "删除问题信息失败";
LogUtil.error(this.getClass(), "删除问题信息失败,原因:" + ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
@RequestMapping("/modifyQuestions")
@ResponseBody
public HashMap<Object, Object> modifyQuestions(@RequestBody HashMap<Object, Object> map) {
String errCode = "0";
String errMsg = "";
try {
issueService.modifyQuestions(map);
} catch (Exception e) {
errCode = "999";
errMsg = "修改问题信息失败";
LogUtil.error(this.getClass(), "修改问题信息失败,原因:" + ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
}

View File

@@ -0,0 +1,86 @@
package com.saye.hrs.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hrs.commons.log.ExceptionDUtil;
import com.saye.hrs.commons.log.LogUtil;
import com.saye.hrs.commons.page.PageUtil;
import com.saye.hrs.commons.page.TemplatePage;
import com.saye.hrs.commons.string.StringDUtil;
import com.saye.hrs.service.BlackListService;
import com.saye.hrs.service.MissedAppointRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
/**
* @description: 爽约记录管理
* @author: Mr.zs
* @create: 2024-04-11 19:47
**/
@Controller
@RequestMapping("/missedAppointRecord")
public class MissedAppointRecordController {
@Autowired
BlackListService blackListService;
@Autowired
MissedAppointRecordService missedAppointRecordService;
@RequestMapping("/toMissedAppointRecord")
public String toMissedAppointRecord(ModelMap modelMap) {
return "/blacklist/missedAppointRecord";
}
@RequestMapping("/findAllMissedAppointRecord")
@ResponseBody
public TemplatePage findAllMissedAppointRecord(Integer page, Integer limit, String cardNo, String startTime, String endTime, String isThird) {
HashMap<Object, Object> searchMap = new HashMap<>();
searchMap.put("cardNo", cardNo);
if (StringDUtil.isNotBlank(startTime)) {
searchMap.put("startTime", startTime.replace("-", ""));
}
if (StringDUtil.isNotBlank(endTime)) {
searchMap.put("endTime", endTime.replace("-", ""));
}
searchMap.put("isThird", isThird);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> appsPageInfo = new PageInfo<>(missedAppointRecordService.findAllMissedAppointRecord(searchMap));
return PageUtil.loadJsonPage(appsPageInfo);
}
@RequestMapping("/addBlackList")
@ResponseBody
public HashMap<Object, Object> addBlackList(@RequestBody HashMap<Object, Object> map) {
String errCode = "0";
String errMsg = "";
try {
Integer i = blackListService.fetchCountByCardNo(map);
if (i > 0) {
errCode = "999";
errMsg = "该人员已被添加";
} else {
blackListService.addBlackList(map);
}
} catch (Exception e) {
errCode = "999";
errMsg = "添加黑名单失败";
LogUtil.error(this.getClass(), "添加黑名单失败,原因:" + ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
}

View File

@@ -0,0 +1,153 @@
package com.saye.hrs.controller;
import javax.annotation.Resource;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hrs.commons.log.ExceptionDUtil;
import com.saye.hrs.commons.log.LogUtil;
import com.saye.hrs.commons.page.PageUtil;
import com.saye.hrs.commons.page.TemplatePage;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.saye.hrs.service.OfficeService;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.springframework.ui.ModelMap;
/**
*
*
* @author dqzhang
* @since 2021-09-16 08:46:32
*/
@RequestMapping("office")
@Controller
public class OfficeController {
@Resource
private OfficeService officeService;
/**
* 跳转页面
* @param modelMap
* @param
* @return
*/
@RequestMapping("/toOffice")
public String toUserManager(ModelMap modelMap){
//查询所有角色
return "hospital/office";
}
/**
* 分页查询列表
* @param
* @param
* @return 查询结果
*/
@RequestMapping("/findOfficePageList")
@ResponseBody
public TemplatePage findOfficePageList() {
HashMap<Object,Object> map=new HashMap<Object,Object>();
List<HashMap<Object, Object>> list = this.officeService.findOfficeList(map);
TemplatePage templetJson = new TemplatePage();
templetJson.setCode(0);
templetJson.setMsg("");
templetJson.setData(list);
templetJson.setCount(list.size());
return templetJson;
}
/**
* 通过主键查询单条数据
* @param map
* @return 单条数据
*/
@RequestMapping("/findOfficeById")
@ResponseBody
public HashMap<Object,Object> findOfficeById(@RequestBody HashMap<Object,Object> map) {
return this.officeService.findOfficeById(map);
}
/**
* 新增数据
* @param map
* @return map
*/
@RequestMapping("/insertOffice")
@ResponseBody
public HashMap<Object,Object> insertOffice(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.officeService.insertOffice(map);
} catch (Exception e) {
errCode = "999";
errMsg = "新增失败";
LogUtil.error(this.getClass(), "新增失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 编辑数据
* @param map
* @return map
*/
@RequestMapping("/updateOffice")
@ResponseBody
public HashMap<Object,Object> updateOffice(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.officeService.updateOffice(map);
} catch (Exception e) {
errCode = "999";
errMsg = "修改失败";
LogUtil.error(this.getClass(), "修改失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 删除数据
* @param map
* @return map
*/
@RequestMapping("/deleteOfficeById")
@ResponseBody
public HashMap<Object,Object> deleteOfficeById(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.officeService.deleteOfficeById(map);
} catch (Exception e) {
errCode = "999";
errMsg = "删除失败";
LogUtil.error(this.getClass(), "删除失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
public static void main(String[] args) {
List list = new ArrayList();
list.add("aaa");
list.add(0,"dsa");
System.out.println(list);
}
}

View File

@@ -0,0 +1,284 @@
package com.saye.hrs.controller;
import javax.annotation.Resource;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hrs.commons.date.DateDUtil;
import com.saye.hrs.commons.excel.ExportXLSX;
import com.saye.hrs.commons.excel.HashMapConversionImpl;
import com.saye.hrs.commons.excel.IConversionByExport;
import com.saye.hrs.commons.log.ExceptionDUtil;
import com.saye.hrs.commons.log.LogUtil;
import com.saye.hrs.commons.page.PageUtil;
import com.saye.hrs.commons.page.TemplatePage;
import com.saye.hrs.commons.string.StringDUtil;
import com.saye.hrs.model.StatusDefine;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.saye.hrs.service.OrderService;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import org.springframework.ui.ModelMap;
/**
*
*
* @author dqzhang
* @since 2021-09-16 16:26:19
*/
@RequestMapping("order")
@Controller
public class OrderController {
@Resource
private OrderService orderService;
/**
* 跳转页面
* @param modelMap
* @param
* @return
*/
@RequestMapping("/toOrder")
public String toUserManager(ModelMap modelMap){
//查询科室
List<HashMap<Object, Object>> distinctOrderOffice = this.orderService.findDistinctOrderOffice();
modelMap.addAttribute("list", distinctOrderOffice);
//查询所有角色
return "order/order";
}
/**
* 分页查询列表
* @param page limit
* @param
* @return 查询结果
*/
@RequestMapping("/findOrderPageList")
@ResponseBody
public TemplatePage findOrderPageList(Integer page,Integer limit,String name,String startTime,String endTime,String ksdm) {
HashMap<Object,Object> map=new HashMap<Object,Object>();
map.put("name",name);
map.put("startTime",startTime.replace("-",""));
map.put("endTime",endTime.replace("-",""));
map.put("ksdm",ksdm);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object,Object>> appsPageInfo = new PageInfo<HashMap<Object,Object>>(this.orderService.findOrderList(map));
return PageUtil.loadJsonPage(appsPageInfo);
}
/**
* 通过主键查询单条数据
* @param map
* @return 单条数据
*/
@RequestMapping("/findOrderById")
@ResponseBody
public HashMap<Object,Object> findOrderById(@RequestBody HashMap<Object,Object> map) {
return this.orderService.findOrderById(map);
}
/**
* 新增数据
* @param map
* @return map
*/
@RequestMapping("/insertOrder")
@ResponseBody
public HashMap<Object,Object> insertOrder(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.orderService.insertOrder(map);
} catch (Exception e) {
errCode = "999";
errMsg = "新增失败";
LogUtil.error(this.getClass(), "新增失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 编辑数据
* @param map
* @return map
*/
@RequestMapping("/updateOrder")
@ResponseBody
public HashMap<Object,Object> updateOrder(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.orderService.updateOrder(map);
} catch (Exception e) {
errCode = "999";
errMsg = "修改失败";
LogUtil.error(this.getClass(), "修改失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 删除数据
* @param map
* @return map
*/
@RequestMapping("/deleteOrderById")
@ResponseBody
public HashMap<Object,Object> deleteOrderById(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.orderService.deleteOrderById(map);
} catch (Exception e) {
errCode = "999";
errMsg = "删除失败";
LogUtil.error(this.getClass(), "删除失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 去预约须知页面
*/
@RequestMapping("/toOrderNotice")
public String toOrderNotice(ModelMap modelMap){
return "order/orderNotice";
}
/**
* @description 查询预约须知
* @author dqzhang
* @created 2022年4月26日 下午1:54:59
* @return
*/
@RequestMapping("/findOrderNotice")
@ResponseBody
public HashMap<Object, Object> findOrderNotice() {
return this.orderService.findOrderNotice();
}
/**
* @description 更新预约须知
* @author dqzhang
* @created 2022年4月26日 下午5:00:08
* @param map
* @return
*/
@RequestMapping("/updateOrderNotice")
@ResponseBody
public HashMap<Object,Object> updateOrderNotice(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.orderService.updateOrderNotice(map);
} catch (Exception e) {
errCode = "999";
errMsg = "修改失败";
LogUtil.error(this.getClass(), "修改失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* @description: 导出预约挂号明细
* @author thuang
* @date 2023/04/07 15:12
* @version 1.0
*/
@RequestMapping("/exportOrderDetail")
@ResponseBody
public HashMap<Object, Object> exportOrderDetail(@RequestBody HashMap<Object, Object> map){
HashMap<Object, Object> responseMap=new HashMap<Object, Object>();
String errCode = "0";
String errMsg = "";
String dlName = "";
String fileName="";
String dowloadName = StringDUtil.changeNullToEmpty(map.get("dowloadName"));
try{
String startTime = StringDUtil.changeNullToEmpty(map.get("startTime"));
String endTime = StringDUtil.changeNullToEmpty(map.get("endTime"));
map.put("startTime",startTime.replace("-",""));
map.put("endTime",endTime.replace("-",""));
List<HashMap<Object, Object>> list = this.orderService.findOrderList(map);
if (list.size()>0) {
//定义标题头和文件名
String[] DISTANCE_HEADERNAME = {"科室名称","预约日期","预约序号","时间段","患者姓名","就诊卡","身份证"};
String[] sqlKey = {"KSMC","YYRQ","YYHX","SJD","TRUE_NAME","MEDICAL_CARD","ID_CARD"};
List<Object> rulList = new ArrayList<Object>(list);
//创建工作表
ExportXLSX exportXLS = new ExportXLSX(DISTANCE_HEADERNAME, sqlKey, ExportXLSX.A3, false);
exportXLS.setTitleName(dowloadName);
IConversionByExport conversion = new HashMapConversionImpl();
exportXLS.setConversion(conversion);
exportXLS.setData(rulList);
exportXLS.modifyWidthOfHeader("5000", 0);
exportXLS.modifyWidthOfHeader("5000", 1);
exportXLS.modifyWidthOfHeader("5000", 2);
exportXLS.modifyWidthOfHeader("5000", 3);
exportXLS.modifyWidthOfHeader("5000", 4);
exportXLS.modifyWidthOfHeader("5000", 5);
exportXLS.modifyWidthOfHeader("5000", 6);
// 文件名称
//产生4位长度的随机码由字母和数字组成
String randomStr = StringDUtil.generateRandomCodeForLength(4);
dlName = DateDUtil.DateToStr(DateDUtil.yyyyMMddHHmmss, new Date()) + randomStr;
fileName = dlName + ".xlsx";
String uploadPath = StatusDefine.filePath + "/order/";
File uploadPathFile = new File(uploadPath);
if(!uploadPathFile.exists()) uploadPathFile.mkdirs();
String savePath = uploadPath + fileName ;
exportXLS.execGenerateExcel(savePath);
}
} catch (Exception e) {
errCode = "999";
errMsg = "未知异常:" + ExceptionDUtil.getDetailExceptionMsg(e);
LogUtil.error(this.getClass(), "@@@系统出错!【" + errMsg + "");
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
responseMap.put("dlName", "order/"+fileName);
return responseMap;
}
}

View File

@@ -0,0 +1,278 @@
package com.saye.hrs.controller;
import javax.annotation.Resource;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hrs.commons.log.ExceptionDUtil;
import com.saye.hrs.commons.log.LogUtil;
import com.saye.hrs.commons.page.PageUtil;
import com.saye.hrs.commons.page.TemplatePage;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.saye.hrs.service.PatientService;
import java.util.HashMap;
import org.springframework.ui.ModelMap;
/**
*
*
* @author dqzhang
* @since 2021-09-27 10:24:47
*/
@RequestMapping("patient")
@Controller
public class PatientController {
@Resource
private PatientService patientService;
/**
* 跳转页面
* @param modelMap
* @param
* @return
*/
@RequestMapping("/toPatient")
public String toUserManager(ModelMap modelMap){
//查询所有角色
return "Patient/Patient";
}
/**
* 分页查询列表
* @param page limit
* @param
* @return 查询结果
*/
@RequestMapping("/findPatientPageList")
@ResponseBody
public TemplatePage findPatientPageList(Integer page,Integer limit) {
HashMap<Object,Object> map=new HashMap<Object,Object>();
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object,Object>> appsPageInfo = new PageInfo<HashMap<Object,Object>>(this.patientService.findPatientList(map));
return PageUtil.loadJsonPage(appsPageInfo);
}
/**
* 通过主键查询单条数据
* @param map
* @return 单条数据
*/
@RequestMapping("/findPatientById")
@ResponseBody
public HashMap<Object,Object> findPatientById(@RequestBody HashMap<Object,Object> map) {
return this.patientService.findPatientById(map);
}
/**
* 新增数据(貌似没有用)
* @param map
* @return map
*/
@RequestMapping("/insertPatient")
@ResponseBody
public HashMap<Object,Object> insertPatient(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.patientService.insertPatient(map);
} catch (Exception e) {
errCode = "999";
errMsg = "新增失败";
LogUtil.error(this.getClass(), "新增失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 编辑数据
* @param map
* @return map
*/
@RequestMapping("/updatePatient")
@ResponseBody
public HashMap<Object,Object> updatePatient(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.patientService.updatePatient(map);
} catch (Exception e) {
errCode = "999";
errMsg = "修改失败";
LogUtil.error(this.getClass(), "修改失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 删除数据
* @param map
* @return map
*/
@RequestMapping("/deletePatientById")
@ResponseBody
public HashMap<Object,Object> deletePatientById(@RequestBody HashMap<Object,Object> map) {
String errCode = "0";
String errMsg = "";
try{
this.patientService.deletePatientById(map);
} catch (Exception e) {
errCode = "999";
errMsg = "删除失败";
LogUtil.error(this.getClass(), "删除失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
/**
* 跳转到患者消费记录页面
* @param modelMap
* @param
* @return
*/
@RequestMapping("/toPatientConsume")
public String toPatientConsume(ModelMap modelMap){
return "patient/patientConsume";
}
/**
* 跳转到患者消费记录页面
*/
@RequestMapping("/toPatientRecharge")
public String toPatientRecharge(ModelMap modelMap){
return "patient/patientRecharge";
}
/**
* 跳转到患者住院消费记录页面
*/
@RequestMapping("/toZyPatientRecharge")
public String toZyPatientRecharge(ModelMap modelMap){
return "patient/zyPatientRecharge";
}
/**
* @description跳转到患者消费记录页面
*/
@RequestMapping("/toPatientRefund")
public String toPatientRefund(ModelMap modelMap){
return "patient/patientRefund";
}
/**
* @description 分页查询患者消费列表
*/
@RequestMapping("/findPatientAccountPageList")
@ResponseBody
public TemplatePage findPatientAccountPageList(Integer page,Integer limit,String type) {
HashMap<Object,Object> map=new HashMap<Object,Object>();
map.put("type", type);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object,Object>> appsPageInfo = new PageInfo<HashMap<Object,Object>>(this.patientService.findPatientAccountPageList(map));
return PageUtil.loadJsonPage(appsPageInfo);
}
/**
* @description 分页查询患者消费列表
*/
@RequestMapping("/findZyPatientAccountPageList")
@ResponseBody
public TemplatePage findZyPatientAccountPageList(Integer page,Integer limit,String type) {
HashMap<Object,Object> map=new HashMap<Object,Object>();
map.put("type", type);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object,Object>> appsPageInfo = new PageInfo<HashMap<Object,Object>>(this.patientService.findZyPatientAccountPageList(map));
return PageUtil.loadJsonPage(appsPageInfo);
}
/**
* @description跳转到银联商务退款记录页面
*/
@RequestMapping("/toRefund")
public String toRefund(ModelMap modelMap){
return "patient/refund";
}
/**
* @description 分页查询银联商务退款信息
*/
@RequestMapping("/findRefundPageList")
@ResponseBody
public TemplatePage findRefundPageList(Integer page,Integer limit) {
HashMap<Object,Object> map=new HashMap<Object,Object>();
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object,Object>> appsPageInfo = new PageInfo<HashMap<Object,Object>>(this.patientService.findRefundList(map));
return PageUtil.loadJsonPage(appsPageInfo);
}
/**
* @description跳转到银联商务充值记录页面
*/
@RequestMapping("/toPayRequest")
public String toPayRequest(ModelMap modelMap){
return "patient/payRequest";
}
/**
* @description 分页查询银联商务充值记录
*/
@RequestMapping("/findPayRequestPageList")
@ResponseBody
public TemplatePage findPayRequestPageList(Integer page,Integer limit) {
HashMap<Object,Object> map=new HashMap<Object,Object>();
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object,Object>> appsPageInfo = new PageInfo<HashMap<Object,Object>>(this.patientService.findPayRequestList(map));
return PageUtil.loadJsonPage(appsPageInfo);
}
/**
* @description 去绑定患者日志页面
* @author dqzhang
* @created 2021年12月17日 下午3:43:39
* @param modelMap
* @return
*/
@RequestMapping("/toBindCardLog")
public String toBindCardLog(ModelMap modelMap){
return "patient/bindCardLog";
}
/**
* @description 一句话描述方法作用
* @author dqzhang
* @created 2021年12月17日 下午3:51:09
* @param page
* @param limit
* @return
*/
@RequestMapping("/findBindCardLogList")
@ResponseBody
public TemplatePage findBindCardLogList(Integer page,Integer limit,String start_date,String end_date,String status) {
HashMap<Object,Object> map=new HashMap<Object,Object>();
map.put("start_date", start_date);
map.put("end_date", end_date);
map.put("status", status);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object,Object>> appsPageInfo = new PageInfo<HashMap<Object,Object>>(this.patientService.findBindCardLogList(map));
return PageUtil.loadJsonPage(appsPageInfo);
}
}

View File

@@ -0,0 +1,157 @@
package com.saye.hrs.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hrs.commons.log.ExceptionDUtil;
import com.saye.hrs.commons.log.LogUtil;
import com.saye.hrs.commons.page.PageUtil;
import com.saye.hrs.commons.page.TemplatePage;
import com.saye.hrs.model.BodyDivision;
import com.saye.hrs.service.SymptomService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @description: 智能导诊症状管理
* @author: Mr.zs
* @create: 2024-04-09 12:49
**/
@Controller
@RequestMapping("/symptom")
@Slf4j
public class SymptomController {
@Autowired
SymptomService symptomService;
@RequestMapping("/toSymptomManager")
public String toSymptomManager(ModelMap modelMap) {
// List<BodyDivision> bodyDivisions = symptomService.findAllBodyArea();
// modelMap.put("bodyAreaList", bodyDivisions);
return "guidance/symptomManager";
}
@RequestMapping("/findAllSymptom")
@ResponseBody
public TemplatePage findAllSymptom(Integer page, Integer limit, String symptom, String bodyArea, String gender, String adultOrChild) {
Map<String, String> searchMap = new HashMap<>();
searchMap.put("symptom", symptom);
searchMap.put("bodyArea", bodyArea);
searchMap.put("gender", gender);
searchMap.put("adultOrChild", adultOrChild);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> appsPageInfo = new PageInfo<>(symptomService.findAllSymptom(searchMap));
return PageUtil.loadJsonPage(appsPageInfo);
}
@PostMapping("/addSymptom")
@ResponseBody
public HashMap<Object, Object> addSymptom(@RequestBody HashMap<Object, Object> map) {
String errCode = "0";
String errMsg = "";
String bodyArea = "";
List<BodyDivision> bodyDivisions = symptomService.findAllBodyArea();
Integer i = symptomService.findMaxId();
Integer newId = i + 1;
map.put("childId", newId + "_" + map.get("bodyAreaType").toString());
for (BodyDivision bodyDivision : bodyDivisions) {
if (bodyDivision.getBODY_AREA_TYPE().equals(map.get("bodyAreaType"))) {
bodyArea = bodyDivision.getBODY_AREA();
}
}
map.put("bodyArea", bodyArea);
try {
symptomService.addSymptom(map);
} catch (Exception e) {
errCode = "999";
errMsg = "新增症状失败";
LogUtil.error(this.getClass(), "新增症状失败,原因:" + ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
// @RequestMapping("/findAllBodyArea")
// @ResponseBody
// public List<HashMap<Object,Object>> findAllBodyArea (){
//
// }
@RequestMapping("/modifySymptom")
@ResponseBody
public HashMap<Object, Object> modifySymptom(@RequestBody HashMap<Object, Object> map) {
String errCode = "0";
String errMsg = "";
try {
symptomService.modifySymptom(map);
} catch (Exception e) {
errCode = "999";
errMsg = "修改症状失败";
LogUtil.error(this.getClass(), "修改症状失败,原因:" + ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
@RequestMapping("/delSymptom")
@ResponseBody
public HashMap<Object, Object> delSymptom(@RequestBody HashMap<Object, Object> map) {
String errCode = "0";
String errMsg = "";
try {
symptomService.delSymptom(map);
} catch (Exception e) {
errCode = "999";
errMsg = "修改症状失败";
LogUtil.error(this.getClass(), "修改症状失败,原因:" + ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
@RequestMapping("/getAreaTypeBySexAdult")
@ResponseBody
public HashMap<Object, Object> getAreaTypeBySexAdult(@RequestBody HashMap<String, String> searchMap) {
HashMap<Object, Object> resultMap = new HashMap<>();
String errCode = "0";
String errMsg = "";
log.info("searchMap is :" + searchMap);
// Map<String, String> searchMap = new HashMap<>();
// searchMap.put("sex", sex);
// searchMap.put("isAdult", isAdult);
try {
List<BodyDivision> bodyDivisions = symptomService.findAreaTypeBySexAdult(searchMap);
resultMap.put("data", bodyDivisions);
} catch (Exception e) {
e.printStackTrace();
errCode = "999";
errMsg = "查询身体区域失败,原因:" + e.getMessage();
}
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
}

View File

@@ -0,0 +1,37 @@
package com.saye.hrs.controller;
import com.baidu.ueditor.ActionEnter;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
/**
* Created by ldb on 2017/4/9.
*/
@Controller
public class UEditorController {
@RequestMapping("/index1")
private String showPage(){
return "demo";
}
@RequestMapping(value="/config")
public void config(HttpServletRequest request, HttpServletResponse response) {
response.setContentType("application/json");
String rootPath = request.getSession().getServletContext().getRealPath("/");
try {
String exec = new ActionEnter(request, rootPath).exec();
PrintWriter writer = response.getWriter();
writer.write(exec);
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,251 @@
package com.saye.hrs.controller;
import com.saye.hrs.commons.log.LogUtil;
import com.saye.hrs.model.WxResult;
import com.saye.hrs.model.WxybResult;
import com.saye.hrs.service.WxPayService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
/***
* @title WxPayController
* @description TODO 请填写注释
* @author thuang
* @create 2023/8/15 9:34
**/
@RestController
public class WxPayController {
@Resource
private WxPayService wxPayService;
@PostMapping("/api/addWxPayInfo")
public HashMap<Object,Object> addWxPayInfo(@RequestBody WxResult reqDTO){
HashMap<Object,Object> resultMap=new HashMap<>();
String errCode="0";
String errMsg="";
try {
wxPayService.addWxPayInfo(reqDTO);
}catch (Exception e){
e.printStackTrace();
errCode="999";
errMsg="保存微信门诊及医保支付记录失败,原因:"+e.getMessage();
}
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
@PostMapping("/api/findWxPayInfo")
public HashMap<Object,Object> findWxPayInfo(@RequestBody WxResult reqDTO){
HashMap<Object,Object> resultMap=new HashMap<>();
String errCode="0";
String errMsg="";
try {
WxResult map = wxPayService.findWxPayInfo(reqDTO);
resultMap.put("data",map);
}catch (Exception e){
e.printStackTrace();
errCode="999";
errMsg="查询微信门诊及医保支付记录失败,原因:"+e.getMessage();
}
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
@PostMapping("/api/addWxybPayInfo")
public HashMap<Object,Object> addWxybPayInfo(@RequestBody WxybResult reqDTO){
HashMap<Object,Object> resultMap=new HashMap<>();
String errCode="0";
String errMsg="";
try {
wxPayService.addWxybPayInfo(reqDTO);
}catch (Exception e){
e.printStackTrace();
errCode="999";
errMsg="保存微信医保支付记录失败,原因:"+e.getMessage();
}
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
@PostMapping("/api/findWxybPayInfo")
public HashMap<Object,Object> findWxybPayInfo(@RequestBody WxybResult reqDTO){
HashMap<Object,Object> resultMap=new HashMap<>();
String errCode="0";
String errMsg="";
try {
WxybResult map = wxPayService.findWxybPayInfo(reqDTO);
resultMap.put("data",map);
}catch (Exception e){
e.printStackTrace();
errCode="999";
errMsg="查询微信医保支付记录失败,原因:"+e.getMessage();
}
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
@PostMapping("/api/getWxNotSendInfo")
public HashMap<Object,Object> getWxNotSendInfo(@RequestBody HashMap<Object,Object> map){
HashMap<Object,Object> resultMap=new HashMap<>();
String errCode="0";
String errMsg="";
try {
List<WxResult> list = wxPayService.getWxNotSendInfo(map);
resultMap.put("List",list);
}catch (Exception e){
e.printStackTrace();
errCode="999";
errMsg="查询微信未支付记录失败,原因:"+e.getMessage();
}
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
@PostMapping("/api/getWxybNotSendInfo")
public HashMap<Object,Object> getWxybNotSendInfo(@RequestBody HashMap<Object,Object> map){
HashMap<Object,Object> resultMap=new HashMap<>();
String errCode="0";
String errMsg="";
try {
List<WxybResult> list = wxPayService.getWxybNotSendInfo(map);
resultMap.put("List",list);
}catch (Exception e){
e.printStackTrace();
errCode="999";
errMsg="查询微信医保未支付记录失败,原因:"+e.getMessage();
}
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
@PostMapping("/api/addOrderInfo")
public HashMap<Object,Object> addOrderInfo(@RequestBody HashMap<Object,Object> map){
HashMap<Object,Object> resultMap=new HashMap<>();
String errCode="0";
String errMsg="";
try {
wxPayService.addOrderInfo(map);
}catch (Exception e){
e.printStackTrace();
errCode="999";
errMsg="保存订单支付状态失败,原因:"+e.getMessage();
}
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
@PostMapping("/api/updateOrderInfoPay")
public HashMap<Object,Object> updateOrderInfoPay(@RequestBody HashMap<Object,Object> map){
HashMap<Object,Object> resultMap=new HashMap<>();
String errCode="0";
String errMsg="";
try {
wxPayService.updateOrderInfoPay(map);
}catch (Exception e){
e.printStackTrace();
errCode="999";
errMsg="保存订单支付状态失败,原因:"+e.getMessage();
}
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
@PostMapping("/api/updateYBOrderInfoPay")
public HashMap<Object,Object> updateYBOrderInfoPay(@RequestBody HashMap<Object,Object> map){
HashMap<Object,Object> resultMap=new HashMap<>();
String errCode="0";
String errMsg="";
try {
wxPayService.updateYBOrderInfoPay(map);
}catch (Exception e){
e.printStackTrace();
errCode="999";
errMsg="更新订单支付状态失败,原因:"+e.getMessage();
}
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
@PostMapping("/api/updateOrderInfoComplete")
public HashMap<Object,Object> updateOrderInfoComplete(@RequestBody HashMap<Object,Object> map){
HashMap<Object,Object> resultMap=new HashMap<>();
String errCode="0";
String errMsg="";
try {
wxPayService.updateOrderInfoComplete(map);
}catch (Exception e){
e.printStackTrace();
errCode="999";
errMsg="更新订单状态为完成失败,原因:"+e.getMessage();
}
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
@PostMapping("/api/findOrderInfo")
public HashMap<Object,Object> findOrderInfo(@RequestBody HashMap<Object,Object> map){
HashMap<Object,Object> resultMap=new HashMap<>();
String errCode="0";
String errMsg="";
try {
List<HashMap<Object,Object>> list = wxPayService.findOrderInfo(map);
resultMap.put("list",list);
}catch (Exception e){
e.printStackTrace();
errCode="999";
errMsg="查询未完成订单内容失败,原因:"+e.getMessage();
}
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
@PostMapping("/api/updateOrderInfoEnd")
public HashMap<Object,Object> updateOrderInfoEnd(@RequestBody HashMap<Object,Object> map){
HashMap<Object,Object> resultMap=new HashMap<>();
String errCode="0";
String errMsg="";
try {
wxPayService.updateOrderInfoEnd(map);
}catch (Exception e){
e.printStackTrace();
errCode="999";
errMsg="查询未完成订单内容失败,原因:"+e.getMessage();
}
resultMap.put("errCode",errCode);
resultMap.put("errMsg",errMsg);
return resultMap;
}
}

View File

@@ -0,0 +1,266 @@
package com.saye.hrs.controller.system;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hrs.commons.JsonResult;
import com.saye.hrs.commons.date.DateDUtil;
import com.saye.hrs.commons.log.ExceptionDUtil;
import com.saye.hrs.commons.log.LogUtil;
import com.saye.hrs.commons.page.PageUtil;
import com.saye.hrs.commons.page.TemplatePage;
import com.saye.hrs.commons.string.StringDUtil;
import com.saye.hrs.commons.uuid.UUIDGenerator;
import com.saye.hrs.model.Dicinfo;
import com.saye.hrs.model.ResourceInfo;
import com.saye.hrs.model.Users;
import com.saye.hrs.service.system.DicinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
public class DicinfoController {
@Autowired
private DicinfoService dicinfoService;
/**
*
* @description 跳转到字典管理页面
* @author qfqi
* @created 2019年12月23日 下午1:47:21
* @param modelMap
* @return
*/
@RequestMapping("/toDicinfoManager")
public String toDepartManager(ModelMap modelMap){
String parentCode="0";
List<Dicinfo> list= dicinfoService.findDicinfoTreeNodeList(parentCode);
ResourceInfo resource = new ResourceInfo();
resource.setTitle("字典");
resource.setId("0");
for (Dicinfo dicinfo : list) {
//生成主节点
ResourceInfo resourceInfo = new ResourceInfo();
resourceInfo.setTitle(dicinfo.getDicname());
resourceInfo.setId(dicinfo.getDiccode());
resourceInfo.setSysid(dicinfo.getParentCode());
resource.getChildren().add(resourceInfo);
}
String jsonString = JSONObject.toJSONString(resource);
modelMap.addAttribute("departInfo", jsonString);
return "system/dicinfoManage";
}
/**
*
* @description 新增字典
* @author qfqi
* @created 2019年12月19日 下午5:20:28
* @param requestMap
* @return
*/
@RequestMapping("/dicinfoManager/addDicinfoManager")
@ResponseBody
public JsonResult addDicinfoManager(HttpServletRequest request, String dicname,String diccode,String dicvalue,String parentCode,String sortNo){
HashMap<String,String> map=new HashMap<String,String>();
JsonResult j=new JsonResult();
map.put("dicname", dicname);
map.put("dicvalue", dicvalue);
map.put("parentCode", parentCode);
map.put("sortNo", sortNo);
if(diccode!=null && !"".equals(diccode)){
//代表新增的是字典树父级 需要验证字点编码是否重复
map.put("diccode", diccode);
List<Dicinfo> list= dicinfoService.findDicinfoBydiccode(diccode);
if(list.size()>0){
//代表在相同的父类下有相同的value值
j.setState(false);
j.setMessage("字典编码重复,请重新输入!");
return j;
}
}else{
//代表新增的是子类需要查询该父类下是否存在相同的val值
map.put("diccode", UUIDGenerator.getUUID());
List<Dicinfo> list= dicinfoService.findDicinfoTreeByCode(map);
if(list.size()>0){
//代表在相同的父类下有相同的value值
j.setState(false);
j.setMessage("字典值重复,请重新输入!");
return j;
}
}
int result=0;
try {
Users user = (Users) request.getSession().getAttribute("user");
result = dicinfoService.addDicinfo(map);
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"新增字典map:"+map.toString());
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(this.getClass(), "新增字典失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
if(result>0){
j.setState(true);
j.setMessage("新增成功!");
}else{
j.setState(false);
j.setMessage("新增失败!");
}
return j;
}
/**
*
* @description 修改字典名称
* @author qfqi
* @created 2019年12月19日 下午5:50:45
* @param requestMap
* @return
*/
@RequestMapping("/dicinfoManager/updateDicinfoManager")
@ResponseBody
public JsonResult updateDicinfoManager(HttpServletRequest request, String diccode,String dicname,String parentCode,String dicvalue,String sortNo){
HashMap<String,String> map=new HashMap<String,String>();
JsonResult j=new JsonResult();
map.put("dicname", dicname);
map.put("diccode", diccode);
map.put("modifyTime", DateDUtil.getTheCurrentTime());
map.put("dicvalue", dicvalue);
map.put("parentCode", parentCode);
map.put("sortNo", sortNo);
int result=0;
try {
Users user = (Users) request.getSession().getAttribute("user");
result = dicinfoService.modifyDicinfo(map);
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"修改字典map:"+map.toString());
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(this.getClass(), "修改字典失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
if(result>0){
j.setState(true);
j.setMessage("修改成功!");
}else{
j.setState(false);
j.setMessage("修改失败!");
}
return j;
}
/**
*
* @description 删除字典
* @author qfqi
* @created 2019年12月19日 下午5:50:25
* @param requestMap
* @return
*/
@RequestMapping("/dicinfoManager/deleteDicinfoManager")
@ResponseBody
public JsonResult deleteDicinfoManager(HttpServletRequest request, @RequestBody Map requestMap){
String diccode= StringDUtil.changeNullToEmpty(requestMap.get("diccode"));
int result=0;
JsonResult j=new JsonResult();
try {
Users user = (Users) request.getSession().getAttribute("user");
result = dicinfoService.deleteDicinfo(diccode);
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"删除字典diccode:"+diccode);
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(this.getClass(), "删除字典失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
if(result>0){
j.setState(true);
j.setMessage("删除成功!");
}else{
j.setState(false);
j.setMessage("删除失败!");
}
return j;
}
//根据父id分页查询字典
@RequestMapping("/dicinfoManager/selectDicinfoManager")
@ResponseBody
public TemplatePage selectDicinfoManager(String parentCode,Integer page,Integer limit){
PageHelper.startPage(page, limit);
PageInfo<Dicinfo> appsPageInfo = new PageInfo<Dicinfo>(dicinfoService.findDicinfoTreeNodeList(parentCode));
return PageUtil.loadJsonPage(appsPageInfo);
}
//根据上级编码查询所有数据
@RequestMapping("/dicinfoManager/selectDicinfoListByCode")
@ResponseBody
public List<HashMap<Object, Object>> selectDicinfoListByCode(String parent_code){
List<HashMap<Object, Object>> list = this.dicinfoService.selectDicinfoListByCode(parent_code);
return list;
}
//根据条件分页查询字典
@RequestMapping("/dicinfoManager/selectDicinfoPageListByCondition")
@ResponseBody
public TemplatePage selectDicinfoPageListByCondition(String parentCode,String dicname,Integer page,Integer limit){
HashMap<String, String> map = new HashMap<String,String>();
map.put("parentCode", parentCode);
map.put("dicname", dicname);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> appsPageInfo = new PageInfo<HashMap<Object, Object>>(dicinfoService.selectDicinfoListByCondition(map));
return PageUtil.loadJsonPage(appsPageInfo);
}
//根据条件查询所有字典
@RequestMapping("/dicinfoManager/selectDicinfoListByCondition")
@ResponseBody
public List<HashMap<Object, Object>> selectDicinfoListByCondition(@RequestBody HashMap<String, String> map){
List<HashMap<Object, Object>> list = this.dicinfoService.selectDicinfoListByCondition(map);
return list;
}
/**
*
* @description 获取最大字典顺序
* @author qfqi
* @created 2021年1月13日 下午2:56:03
* @param requestMap
* @return
*/
@RequestMapping("/dicinfoManager/getMaxDicValue")
@ResponseBody
public JsonResult getMaxDicValue(@RequestBody Map requestMap){
String diccode= StringDUtil.changeNullToEmpty(requestMap.get("diccode"));
JsonResult j=new JsonResult();
try {
HashMap<String, String> map = new HashMap<String,String>();
map.put("parentCode", diccode);
HashMap<Object, Object> result = dicinfoService.getMaxDicValue(map);
j.setState(true);
j.setData(result.get("MAXDICVALUE"));
j.setMessage("成功!");
} catch (Exception e) {
j.setState(false);
j.setMessage("查询字典最大值失败!");
e.printStackTrace();
LogUtil.error(this.getClass(), "查询字典最大值失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
return j;
}
}

View File

@@ -0,0 +1,107 @@
package com.saye.hrs.controller.system;
import java.util.Date;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hrs.commons.date.DateDUtil;
import com.saye.hrs.commons.log.ExceptionDUtil;
import com.saye.hrs.commons.log.LogUtil;
import com.saye.hrs.commons.page.PageUtil;
import com.saye.hrs.commons.page.TemplatePage;
import com.saye.hrs.model.Logger;
import com.saye.hrs.service.system.LoggerService;
@Controller
public class LoggerController {
@Autowired
private LoggerService loggerService;
/**
* @description 到日志管理页面
* @author thuang
* @created 2019年11月13日 下午5:27:29
* @param modelMap
* @return
*/
@RequestMapping("/toLogger")
public String toLogger(ModelMap modelMap){
return "system/logger";
}
/**
* @description 查询所有日志数据
* @author thuang
* @created 2019年11月13日 下午5:41:56
* @return
*/
@RequestMapping("/findLogger")
@ResponseBody
public HashMap<String, Object> findLogger(String loggerType,String startTime,String endTime,Integer page,Integer limit ){
HashMap<Object, Object> map=new HashMap<Object, Object>();
map.put("loggerType", loggerType);
map.put("startTime", startTime);
map.put("endTime", endTime);
HashMap<String, Object> responseMap = new HashMap<String,Object>();
try {
PageHelper.startPage(page, limit);
PageInfo<Logger> appsPageInfo = new PageInfo<Logger>(loggerService.findLogger(map));
responseMap.put("code", 0);
responseMap.put("msg", "");
responseMap.put("count", appsPageInfo.getTotal());
responseMap.put("data", appsPageInfo.getList());
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(this.getClass(), "查询所有日志数据失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
return responseMap;
}
/**
* @description 去his日志页面
* @author dqzhang
* @created 2022年2月25日 上午9:26:19
* @param modelMap
* @return
*/
@RequestMapping("/toHisLog")
public String toHisLog(ModelMap modelMap){
Date date = new Date();
modelMap.addAttribute("startTime",DateDUtil.getPlusDays("yyyy-MM-dd", date, -7));
modelMap.addAttribute("endTime",DateDUtil.DateToStr("yyyy-MM-dd", date));
return "system/hisLog";
}
/**
* @description 查询所有his日志数据
* @author thuang
* @created 2019年11月13日 下午5:41:56
* @return
*/
@RequestMapping("/findHisLog")
@ResponseBody
public TemplatePage findHisLogList(String title,String startTime,String endTime,Integer page,Integer limit ){
HashMap<Object, Object> map=new HashMap<Object, Object>();
map.put("title", title);
map.put("startTime", startTime);
map.put("endTime", endTime);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> appsPageInfo = new PageInfo<HashMap<Object, Object>>(loggerService.findHisLogList(map));
return PageUtil.loadJsonPage(appsPageInfo);
}
}

View File

@@ -0,0 +1,272 @@
package com.saye.hrs.controller.system;
import com.alibaba.fastjson.JSON;
import com.saye.hrs.commons.log.ExceptionDUtil;
import com.saye.hrs.commons.log.LogUtil;
import com.saye.hrs.commons.string.StringDUtil;
import com.saye.hrs.model.ResourceInfo;
import com.saye.hrs.model.StatusDefine;
import com.saye.hrs.model.Users;
import com.saye.hrs.service.OrderService;
import com.saye.hrs.service.system.MenuService;
import com.saye.hrs.service.system.ServiceParamsService;
import com.saye.hrs.service.system.UsersService;
import org.apache.commons.io.IOUtils;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
@Controller
public class LoginController {
@Autowired
private MenuService menuService;
@Autowired
private UsersService usersService;
@Autowired
private ServiceParamsService serviceParamsService;
@Autowired
private OrderService orderService;
/**
* @description 去登录页面
* @author dqzhang
* @created 2019年11月13日 下午4:22:48
* @param map
* @return
*/
@RequestMapping("/toLogin")
public String toLogin(ModelMap map) {
List<HashMap<Object, Object>> list = serviceParamsService.findParamValByParamCode("prj_name");
map.addAttribute("prj_name",list.get(0).get("PARAM_VAL"));
return "login";
}
/**
* @description 登录
* @author dqzhang
* @created 2019年11月13日 下午5:03:11
* @return
*/
@PostMapping("/login")
@ResponseBody
public HashMap<Object,Object> login(HttpServletRequest request,@RequestBody Map map) {
String username = StringDUtil.removeSpaces(map.get("username"));
String password = StringDUtil.removeSpaces(map.get("password"));
String vercode = StringDUtil.removeSpaces(map.get("vercode"));
String errCode = "0";
String errMsg = "";
try {
String code = (String) request.getSession().getAttribute("verify_code");
if(!code.equalsIgnoreCase(vercode)) {
errCode = "CodeError";
errMsg = "验证码不正确!";
}
if("0".equals(errCode)) {
List<Users> list = usersService.searchByName(username);
if(list.isEmpty()){
errCode = "userError";
errMsg = "用户名或密码错误!";
}
if("0".equals(errCode)) {
Users user = list.get(0);
String encryptPassword = new Md5Hash(password,"hrs",2).toString();
if(user.getPassword().equals(encryptPassword)) {
LogUtil.info(getClass(), "用户:"+username+"登录系统");
request.getSession().setAttribute("user",user);
}else{
errCode = "userError";
errMsg = "用户名或密码错误!";
}
}
}
} catch (Exception e) {
errCode = e.getLocalizedMessage();
errMsg = "未知异常!";
LogUtil.error(this.getClass(), "登录失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
/**
* @description 首页
* @author dqzhang
* @created 2019年11月13日 下午5:10:21
* @param request
* @return
*/
@RequestMapping("/index")
public String index(HttpServletRequest request,ModelMap modelMap) throws Exception {
HashMap<Object,Object> map = new HashMap<Object,Object>();
Users user = (Users) request.getSession().getAttribute("user");
String user_id = user.getUserId();
map.put("user_id", user_id);
ResourceInfo resourceInfo=null;
modelMap.addAttribute("expired",false);
try {
//上次密码修改时间
resourceInfo = this.menuService.getMenuByRole(map);
String userTrueName = user.getTrueName();
String userName = user.getUserName();
modelMap.addAttribute("userTrueName",userTrueName);
modelMap.addAttribute("userName",userName);
modelMap.addAttribute("userId",user_id);
List<HashMap<Object, Object>> list = serviceParamsService.findParamValByParamCode("prj_name");
modelMap.addAttribute("prj_name",list.get(0).get("PARAM_VAL"));
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(this.getClass(), "跳转首页失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
modelMap.addAttribute("resourceInfo", resourceInfo.getChildren());
return "index";
}
@RequestMapping("/logout")
public void logout(HttpServletRequest request,HttpServletResponse response) throws IOException {
if(request.getSession().getAttribute("user")!=null) {
request.getSession().invalidate();
}
response.sendRedirect("/toLogin");
}
@RequestMapping("/home")
public String home() throws IOException {
return "home";
}
@RequestMapping("/findHomeData")
@ResponseBody
public HashMap<Object,Object> findHomeData() throws IOException {
//String s ="{\"fwrs\":1,\"rechargeOrder\":[{\"NUM\":3,\"NOWDATE\":\"20211124\"},{\"NUM\":1,\"NOWDATE\":\"20211125\"},{\"NUM\":0,\"NOWDATE\":\"20211126\"},{\"NUM\":5,\"NOWDATE\":\"20211127\"},{\"NUM\":0,\"NOWDATE\":\"20211128\"},{\"NUM\":0,\"NOWDATE\":\"20211129\"},{\"NUM\":0,\"NOWDATE\":\"20211130\"}],\"bkrs\":1,\"yyrs\":1,\"weekOrder\":[{\"NUM\":3,\"NOWDATE\":\"20211124\"},{\"NUM\":6,\"NOWDATE\":\"20211125\"},{\"NUM\":0,\"NOWDATE\":\"20211126\"},{\"NUM\":0,\"NOWDATE\":\"20211127\"},{\"NUM\":0,\"NOWDATE\":\"20211128\"},{\"NUM\":0,\"NOWDATE\":\"20211129\"},{\"NUM\":0,\"NOWDATE\":\"20211130\"}],\"czzh\":1,\"office\":[{\"NUM\":1,\"KSMC\":null}]}";
return this.orderService.findHomeData();
}
/**
* @description 获取验证码
* @author dqzhang
* @created 2019年11月27日 下午3:15:32
* @param request
* @param response
* @throws Exception
*/
@RequestMapping("/getCode")
public void verify(HttpServletRequest request,HttpServletResponse response) throws Exception {
String name = request.getParameter("name");
String str = request.getQueryString();
BufferedReader bufferedReader = request.getReader();
char[] c = new char[100];
IOUtils.read(bufferedReader,c);
System.out.println("bodyStr = " + new String(c));
response.setContentType("image/jpeg");
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0L);
HttpSession session = request.getSession();
int width = 73;
int height = 27;
BufferedImage image = new BufferedImage(width, height, 1);
Graphics g = image.getGraphics();
Random random = new Random();
g.setColor(getRandColor(200, 250));
g.fillRect(0, 0, width, height);
g.setFont(new Font("Times New Roman", 0, 24));
g.setColor(getRandColor(160, 200));
for (int i = 0; i < 155; i++) {
int x = random.nextInt(width);
int y = random.nextInt(height);
int xl = random.nextInt(12);
int yl = random.nextInt(12);
g.drawLine(x, y, x + xl, y + yl);
}
String sRand = "";
for (int i = 0; i < 4; i++) {
String rand = randomInt(1).toUpperCase();
sRand = sRand + rand;
g.setColor(new Color(20 + random.nextInt(110), 20 + random
.nextInt(110), 20 + random.nextInt(110)));
g.drawString(rand, 13 * i + 6, 24);
}
if (StringDUtil.changeNullToEmpty(name).equals(""))
session.setAttribute("verify_code", sRand);
else {
session.setAttribute(name, sRand);
}
g.dispose();
ServletOutputStream responseOutputStream = response.getOutputStream();
ImageIO.write(image, "JPEG", responseOutputStream);
responseOutputStream.flush();
responseOutputStream.close();
}
private Color getRandColor(int fc, int bc) {
Random random = new Random();
if (fc > 255)
fc = 255;
if (bc > 255)
bc = 255;
int r = fc + random.nextInt(bc - fc);
int g = fc + random.nextInt(bc - fc);
int b = fc + random.nextInt(bc - fc);
return new Color(r, g, b);
}
public static final String randomInt(int length) {
if (length < 1) {
return null;
}
Random randGen = new Random();
char[] numbersAndLetters = "0123456789abcdefghijklmnopqrstuvwxyz".toCharArray();
char[] randBuffer = new char[length];
for (int i = 0; i < randBuffer.length; i++) {
randBuffer[i] = numbersAndLetters[randGen.nextInt(36)];
}
return new String(randBuffer);
}
@RequestMapping("/toDemo")
public String toDemo(ModelMap map) {
return "demo";
}
}

View File

@@ -0,0 +1,194 @@
package com.saye.hrs.controller.system;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hrs.commons.JsonResult;
import com.saye.hrs.commons.date.DateDUtil;
import com.saye.hrs.commons.log.ExceptionDUtil;
import com.saye.hrs.commons.log.LogUtil;
import com.saye.hrs.model.MenuRole;
import com.saye.hrs.model.ResourceInfo;
import com.saye.hrs.model.Role;
import com.saye.hrs.model.Users;
import com.saye.hrs.service.system.MenuService;
import com.saye.hrs.service.system.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Controller
public class RoleController {
@Autowired
private RoleService roleService;
@Autowired
private MenuService menuService;
/**
* @description 到角色管理页面
* @author thuang
* @created 2019年11月11日 上午10:50:40
* @return
*/
@RequestMapping("/toRoleManager")
public String toRoleManager(ModelMap modelMap){
HashMap<Object,Object> responseMap = new HashMap<Object,Object>();
responseMap.put("firstNode", "0");
ResourceInfo resourceInfo=null;
try {
resourceInfo = this.menuService.getMenuByRole(responseMap);
} catch (Exception e) {
e.printStackTrace();
}
modelMap.addAttribute("resourceInfo", resourceInfo);
return "system/roleManager";
}
/**
*
* @description 查询列表
* @author qfqi
* @created 2019年11月5日 下午3:07:41
* @return
*/
@RequestMapping("/searchRole")
@ResponseBody
public HashMap<String, Object> searchRole(String roleName, String date, Integer page, Integer limit){
HashMap<String,String> map=new HashMap<String,String>();
map.put("roleName", roleName);
map.put("date", date);
PageHelper.startPage(page, limit);
PageInfo<Role> appsPageInfo = new PageInfo<Role>(roleService.searchRole(map));
HashMap<String, Object> map1 = new HashMap<String,Object>();
map1.put("code", 0);
map1.put("msg", "你好");
map1.put("count", appsPageInfo.getTotal());
map1.put("data", appsPageInfo.getList());
return map1;
}
/**
* @description 添加角色
* @author thuang
* @created 2019年11月11日 下午3:58:24
* @return
*/
@RequestMapping("/insertRoles")
@ResponseBody
public HashMap<Object, Object> insertRoles(HttpServletRequest request,@RequestBody HashMap<String, String> map){
String errCode="0";
String errMsg="";
Users user = (Users) request.getSession().getAttribute("user");
//新增角色
try {
map.put("createTime", DateDUtil.getTheCurrentTime());
roleService.addRole(map);
LogUtil.info(this.getClass(),"用户"+ user.getTrueName()+"添加角色map:"+map.toString());
} catch (Exception e) {
errCode="999";
errMsg=e.getMessage();
LogUtil.error(this.getClass(), "新增角色失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
/**
*
* @description 删除用户角色
* @author qfqi
* @created 2019年11月5日 下午3:07:54
* @return
*/
@RequestMapping("/deleteRole")
@ResponseBody
public HashMap<Object, Object> deleteRole(HttpServletRequest request, String roleId){
Users user = (Users) request.getSession().getAttribute("user");
String errCode="0";
String errMsg="";
try {
roleService.deleteRole(roleId);
LogUtil.info(this.getClass(),"用户"+ user.getTrueName()+"删除角色roleId:"+roleId);
} catch (Exception e) {
errCode = "999";
errMsg = "删除失败";
LogUtil.error(this.getClass(), "删除角色失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object, Object> resultMap = new HashMap<Object, Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
/**
* @description 根据角色id获取角色权限菜单id
* @author thuang
* @created 2019年11月12日 上午9:51:08
* @return
*/
@RequestMapping("/getSelectMenuId")
@ResponseBody
public List<String> getSelectMenuId(String roleId){
HashMap<Object, Object> map=new HashMap<Object, Object>();
map.put("roleId",roleId);
List<MenuRole> menuIdByRoleId = menuService.getMenuIdByRoleId(map);
List<String> menuIdList=new ArrayList<String>();
for (int i = 0; i < menuIdByRoleId.size(); i++) {
MenuRole menuRole = menuIdByRoleId.get(i);
menuIdList.add(menuRole.getMenuId());
}
return menuIdList;
}
@RequestMapping("/getMenuList")
@ResponseBody
public ArrayList<ResourceInfo> getMenuList() throws Exception {
ResourceInfo resourceInfo=null;
resourceInfo = menuService.getMenuByRole(new HashMap<Object, Object>());
return resourceInfo.getChildren();
}
/**
*
* @description 修改用户角色权限信息
* @author qfqi
* @created 2019年11月5日 下午3:08:05
* @return
*/
@RequestMapping("/modifyRoleResource")
@ResponseBody
public JsonResult modifyRoleResource(HttpServletRequest request,@RequestBody HashMap<String, String> map) {
Users user = (Users) request.getSession().getAttribute("user");
int result=roleService.modifyRoleResource(map);
LogUtil.info(this.getClass(),"用户"+ user.getTrueName()+"修改用户角色权限信息map:"+map.toString());
JsonResult j=new JsonResult();
if(result>0){
j.setState(true);
j.setMessage("修改成功!");
}else{
j.setState(false);
j.setMessage("修改失败!");
}
return j;
}
}

View File

@@ -0,0 +1,189 @@
package com.saye.hrs.controller.system;
import java.util.HashMap;
import com.saye.hrs.commons.JsonResult;
import com.saye.hrs.commons.date.DateDUtil;
import com.saye.hrs.commons.log.ExceptionDUtil;
import com.saye.hrs.commons.log.LogUtil;
import com.saye.hrs.commons.page.PageUtil;
import com.saye.hrs.commons.page.TemplatePage;
import com.saye.hrs.model.ServiceParams;
import com.saye.hrs.model.Users;
import com.saye.hrs.service.system.ServiceParamsService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletRequest;
@Controller
public class ServiceParamsController {
@Autowired
private ServiceParamsService serviceParamsService;
/**
*
* @description 跳转到业务参数列表
* @author qfqi
* @created 2019年12月18日 上午11:27:48
* @param modelMap
* @return
*/
@RequestMapping("/toServiceParams")
public String toServiceParams(ModelMap modelMap){
return "system/serviceParams";
}
/**
*
* @description 多条件查询业务参数列表
* @author qfqi
* @created 2019年12月18日 上午11:35:20
* @param paramName
* @param page
* @param limit
* @return
*/
@RequestMapping("/serviceParams/selectServiceParams")
@ResponseBody
public TemplatePage selectServiceParams(String paramName, Integer page, Integer limit){
HashMap<String,String> map=new HashMap<String,String>();
map.put("paramName", paramName);
PageHelper.startPage(page, limit);
PageInfo<ServiceParams> appsPageInfo = new PageInfo<ServiceParams>(serviceParamsService.selectServiceParams(map));
return PageUtil.loadJsonPage(appsPageInfo);
}
/**
*
* @description 新增业务参数列表
* @author qfqi
* @created 2019年12月18日 下午3:59:34
* @param sp
* @return
*/
@RequestMapping("/serviceParams/insertServiceParams")
@ResponseBody
public JsonResult insertServiceParams(HttpServletRequest request, ServiceParams sp){
int result=0;
try {
Users user = (Users) request.getSession().getAttribute("user");
String userName = user.getUserName();
String userTrueName = user.getTrueName();
sp.setModifyUserName(userName);
sp.setModifyTrueName(userTrueName);
result = serviceParamsService.insertServiceParams(sp);
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"新增业务参数列表ServiceParams:"+sp.toString());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
LogUtil.error(this.getClass(), "新增业务参数失败,原因:"+ ExceptionDUtil.getDetailExceptionMsg(e));
}
JsonResult j=new JsonResult();
if(result>0){
j.setState(true);
j.setMessage("新增成功!");
}else if(result==-1){
j.setState(false);
j.setMessage("参数编码已存在!");
}else{
j.setState(false);
j.setMessage("新增失败!");
}
return j;
}
/**
*
* @description 修改业务参数列表
* @author qfqi
* @created 2019年12月18日 下午3:59:51
* @param sp
* @return
*/
@RequestMapping("/serviceParams/updateServiceParams")
@ResponseBody
public JsonResult updateServiceParams(HttpServletRequest request,ServiceParams sp){
int result=0;
JsonResult j=new JsonResult();
try {
Users user = (Users) request.getSession().getAttribute("user");
String userName = user.getUserName();
String userTrueName = user.getTrueName();
sp.setModifyUserName(userName);
sp.setModifyTrueName(userTrueName);
sp.setModifyTime(DateDUtil.getCurrentTime());
// 进行判断,如果是修改的假期提醒时间则进行加入计时器
if(sp.getParamCode().equals("HOLIDAY_REMINDER")){
HashMap<String,String> map=new HashMap<String,String>();
map.put("paramId", sp.getParamId());
map.put("remindTime", sp.getParamVal().split("-")[0]);
String regex="^(?:0|[0-2][0-9]?|30)$";
if(sp.getParamVal().split("-")[0].matches(regex)){
j.setState(false);
j.setMessage("修改失败提醒日期不能大于30或小于0");
return j;
}
}
result = serviceParamsService.updateServiceParams(sp);
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"修改业务参数列表ServiceParams:"+sp.toString());
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(this.getClass(), "修改业务参数失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
if(result>0){
j.setState(true);
j.setMessage("修改成功!");
}else{
j.setState(false);
j.setMessage("修改失败!");
}
return j;
}
/**
*
* @description 删除业务参数列表
* @author qfqi
* @created 2019年12月18日 下午4:00:18
* @param paramId
* @return
*/
@RequestMapping("/serviceParams/deleteServiceParams")
@ResponseBody
public JsonResult deleteServiceParams(String paramId){
int result=0;
try {
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
result = serviceParamsService.deleteServiceParams(paramId);
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"删除业务参数列表paramId:"+paramId);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
LogUtil.error(this.getClass(), "删除业务参数失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
JsonResult j=new JsonResult();
if(result>0){
j.setState(true);
j.setMessage("删除成功!");
}else{
j.setState(false);
j.setMessage("删除失败!");
}
return j;
}
}

View File

@@ -0,0 +1,640 @@
package com.saye.hrs.controller.system;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hrs.commons.JsonResult;
import com.saye.hrs.commons.date.DateDUtil;
import com.saye.hrs.commons.log.ExceptionDUtil;
import com.saye.hrs.commons.log.LogUtil;
import com.saye.hrs.commons.page.PageUtil;
import com.saye.hrs.commons.page.TemplatePage;
import com.saye.hrs.commons.string.StringDUtil;
import com.saye.hrs.model.*;
import com.saye.hrs.service.system.RoleService;
import com.saye.hrs.service.system.UsersService;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Controller
public class UsersController {
@Autowired
private UsersService usersService;
@Autowired
private RoleService roleService;
/**
* @description 到用户管理页面
* @author thuang
* @created 2019年11月15日 上午10:12:12
* @return
*/
@RequestMapping("/toUserManager")
public String toUserManager(ModelMap modelMap){
//查询所有角色
List<Role> roleList = this.roleService.findRoleList();
modelMap.addAttribute("roleList",roleList);
return "system/userManager";
}
/**
*
* @description user表分页查询
* @author qfqi
* @created 2019年11月5日 下午3:06:12
* @return
*/
@RequestMapping("/selectUser")
@ResponseBody
public TemplatePage searchUsers(String trueName, String isactive, String roleId, Integer page, Integer limit) {
HashMap<Object,Object> map=new HashMap<Object,Object>();
map.put("trueName", trueName);
map.put("isactive", isactive);
map.put("roleId", roleId);
PageHelper.startPage(page, limit);
PageInfo<Users> appsPageInfo = new PageInfo<Users>(usersService.searchUsers(map));
return PageUtil.loadJsonPage(appsPageInfo);
}
/**
*
* @description 新增用户
* @author qfqi
* @created 2019年11月5日 下午3:05:10
* @return
*/
@RequestMapping("/insertUsers")
@ResponseBody
public HashMap<Object, Object> insertUsers(HttpServletRequest request, @RequestBody HashMap<Object, Object> requestMap){
String errCode = "0";
String errMsg = "";
try {
Users user = (Users) request.getSession().getAttribute("user");
String userName = user.getUserName();
String userTrueName = user.getTrueName();
requestMap.put("modifyUserName", userName);
requestMap.put("modifyTrueName", userTrueName);
usersService.insertUser(requestMap);
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"新增用户的方法requestMap:"+requestMap.toString());
} catch (Exception e) {
errCode = "0";
errMsg = "添加失败,"+ExceptionDUtil.getDetailExceptionMsg(e);
LogUtil.error(this.getClass(), "新增用户失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
/**
*
* @description 修改用户
* @author qfqi
* @created 2019年11月5日 下午3:04:28
* @return
*/
@RequestMapping("/modifyUsers")
@ResponseBody
public HashMap<Object,Object> modifyUsers(HttpServletRequest request, @RequestBody HashMap<Object, Object> requestMap){
String errCode = "0";
String errMsg = "";
Users user = (Users) request.getSession().getAttribute("user");
String userName = user.getUserName();
String userTrueName = user.getTrueName();
requestMap.put("userName", userName);
requestMap.put("userTrueName", userTrueName);
String createTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
String createDate = DateDUtil.getCurrentDate();
requestMap.put("createTime", createTime);
requestMap.put("createDate", createDate);
try {
usersService.modifyUsers(requestMap);
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"修改用户的方法requestMap:"+requestMap.toString());
} catch (Exception e) {
errCode = "999";
errMsg = "修改用户失败!";
LogUtil.error(this.getClass(), "修改用户失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
/**
*
* @description 密码重置
* @author qfqi
* @created 2019年11月5日 下午3:06:37
* @return
*/
@RequestMapping("/reSetPassword")
@ResponseBody
public JsonResult reSetPassword(HttpServletRequest request, @RequestBody HashMap<Object, Object> requestMap){
JsonResult j=new JsonResult();
try {
Users user = (Users) request.getSession().getAttribute("user");
String userName = user.getUserName();
String userTrueName = user.getTrueName();
requestMap.put("modifyUserName", userName);
requestMap.put("modifyTrueName", userTrueName);
String createTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
String createDate = DateDUtil.getCurrentDate();
requestMap.put("createTime", createTime);
requestMap.put("createDate", createDate);
//产生6位长度的随机密码由字母和数字组成
String password = StringDUtil.generateRandomCodeForLength(6);
String addPasswordMd5 = new Md5Hash(password,"hrs",2).toString();
requestMap.put("password", addPasswordMd5);
int result=usersService.reSetPassword(requestMap);
if(result>0){
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"重置用户的密码方法requestMap:"+requestMap.toString());
j.setState(true);
j.setMessage("修改成功!");
j.setData(password);
}else{
j.setState(false);
j.setMessage("修改失败!");
}
} catch (Exception e) {
e.printStackTrace();
j.setState(false);
j.setMessage(e.getMessage());
LogUtil.error(this.getClass(), "密码重置失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
return j;
}
/**
*
* @description 启用/禁用
* @author qfqi
* @created 2019年11月5日 下午3:06:54
* @return
*/
@RequestMapping("/unableUser")
@ResponseBody
public JsonResult unableUser(HttpServletRequest request, @RequestBody HashMap<Object, Object> requestMap){
JsonResult j=new JsonResult();
try{
Users user = (Users) request.getSession().getAttribute("user");
String userName = user.getUserName();
String userTrueName = user.getTrueName();
requestMap.put("modifyUserName", userName);
requestMap.put("modifyTrueName", userTrueName);
String createTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
String createDate = DateDUtil.getCurrentDate();
requestMap.put("createTime", createTime);
requestMap.put("createDate", createDate);
int result=usersService.unableUser(requestMap);
if(result>0){
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"启用禁用用户的方法requestMap:"+requestMap.toString());
j.setState(true);
j.setMessage("修改成功!");
}else{
j.setState(false);
j.setMessage("修改失败!");
}
}catch (Exception e) {
e.printStackTrace();
j.setState(false);
j.setMessage(e.getMessage());
LogUtil.error(this.getClass(), "禁用启用失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
return j;
}
/**
*
* @description 查询角色
* @author qfqi
* @created 2019年11月5日 下午3:07:09
* @return
*/
// @RequestMapping("/findRoleList")
// @ResponseBody
// public JsonResult findRoleList(){
// List<Role> list =roleService.findRoleList();
// JsonResult j=new JsonResult();
// j.setState(true);
// j.setMessage("查询成功");
// j.setData(list);
// return j;
// }
/**
*
* @description 新增用户名验证
* @author qfqi
* @created 2019年11月5日 下午3:07:22
* @param userName
* @return
*/
@RequestMapping("/searchByName")
@ResponseBody
public JsonResult searchByName(String userName){
List<Users> list=usersService.searchByName(userName);
JsonResult j=new JsonResult();
j.setState(true);
j.setMessage("查询成功");
j.setData(list);
return j;
}
/**
* @description 修改密码
* @author thuang
* @created 2019年11月27日 下午6:13:05
* @param requestMap
* @return
*/
@RequestMapping("/modifyPassword")
@ResponseBody
public JsonResult modifyPassword(HttpServletRequest request, @RequestBody HashMap<Object, Object> requestMap){
String password = StringDUtil.changeNullToEmpty(requestMap.get("password"));
String key = StringDUtil.removeSpaces(requestMap.get("key"));
String initVector = StringDUtil.removeSpaces(requestMap.get("initVector"));
JsonResult j=new JsonResult();
try {
Users user = (Users) request.getSession().getAttribute("user");
String username = user.getUserName();
String passwordMd5 = new Md5Hash(password,"hrs",2).toString();
String addPasswordMd5 = new Md5Hash(password,"hrs",2).toString();
String modifyTime = DateDUtil.getTheCurrentTime();
this.usersService.modifyPassword(username,passwordMd5,modifyTime);
j.setState(true);
j.setMessage("更改密码成功");
LogUtil.debug(this.getClass(),"用户修改用户的密码方法requestMap:"+requestMap.toString());
} catch (Exception e) {
j.setState(false);
j.setMessage("更改密码失败");
e.printStackTrace();
LogUtil.error(this.getClass(), "修改密码失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
return j;
}
/**
* @description: 导入人员信息
* @author thuang
* @date 2021/5/19 9:57
* @version 1.0
*/
@RequestMapping("/uploadUsers")
@ResponseBody
public HashMap<Object, Object> uploadUsers(@RequestParam("spareFile") MultipartFile file, HttpServletRequest request, HttpServletResponse response)throws Exception{
HashMap<Object, Object> responseMap=new HashMap<Object, Object>();
String errCode="0";
String errMsg="";
if (!file.isEmpty()) {
XSSFWorkbook workbook =null;
//创建Excel读取文件内容
workbook = new XSSFWorkbook(file.getInputStream());
//获取第一个工作表
XSSFSheet sheet = workbook.getSheetAt(0);
//获取sheet中第一行行号
int firstRowNum = sheet.getFirstRowNum();
//获取sheet中最后一行行号
int lastRowNum = sheet.getLastRowNum();
try {
//查询部门
HashMap<String,HashMap<Object,Object>> departTreeMap=new HashMap<>();
HashMap<String,List<HashMap<Object,Object>>> parentIdMap=new HashMap<>();
HashMap<String,HashMap<Object,Object>> departIdMap=new HashMap<>();
//处理部门组织方便查询
for (String key : parentIdMap.keySet()){
List<HashMap<Object, Object>> list = parentIdMap.get(key);
HashMap<Object, Object> map = departIdMap.get(key);
map.put("childen",list);
}
//时间
String create_time = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
String create_date = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd);
//添加人员
Users user = (Users) request.getSession().getAttribute("user");
String modify_user_name = user.getUserName();
String modify_true_name = user.getTrueName();
//循环插入数据
int errNum=0;
List<String> errNumList=new ArrayList<String>();
List<HashMap<Object,Object>> addList=new ArrayList<>();
for(int i=firstRowNum+2;i<=lastRowNum;i++){//因为表格中第一行为标题,第二行为列标题
XSSFRow row = sheet.getRow(i);
HashMap<Object, Object> addMap=new HashMap<Object, Object>();
//用户id
XSSFCell user_id = row.getCell(0);
if(user_id==null){
errNum++;
errNumList.add(""+(i+1));
continue;
}else {
user_id.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("user_id",user_id.getStringCellValue());
addMap.put("user_name",user_id.getStringCellValue());
}
//姓名
XSSFCell true_name = row.getCell(1);
if(true_name==null){
errNum++;
errNumList.add(""+(i+1));
continue;
}else {
true_name.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("true_name",true_name.getStringCellValue());
}
//性别
XSSFCell sex = row.getCell(2);
if(sex==null){
addMap.put("sex","");
}else {
sex.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("sex",sex.getStringCellValue());
}
//公司
String companyId="";
XSSFCell company = row.getCell(3);
if(company==null){
errNum++;
errNumList.add(""+(i+1));
continue;
}else {
company.setCellType(Cell.CELL_TYPE_STRING);
String companyStr = company.getStringCellValue();
//第一层是最上一级
boolean isHas=false;
for(String key:departTreeMap.keySet()){
HashMap<Object, Object> hashMap = departTreeMap.get(key);
List<HashMap<Object,Object>> departList = (List<HashMap<Object,Object>>)hashMap.get("childen");
//要循环的级别
for (int j=0;j<departList.size();j++){
HashMap<Object, Object> departObj = departList.get(j);
String depart_id = StringDUtil.changeNullToEmpty(departObj.get("DEPART_ID"));
String depart_name = StringDUtil.changeNullToEmpty(departObj.get("DEPART_NAME"));
if(companyStr.equals(depart_name)){
addMap.put("company",depart_id);
companyId=depart_id;
isHas=true;
break;
}
}
}
//判断对错 错的错误记录加1
if (!isHas){
errNum++;
errNumList.add(""+(i+1));
continue;
}
}
//部门
XSSFCell depart = row.getCell(4);
if(depart==null){
errNum++;
errNumList.add(""+(i+1));
continue;
}else {
depart.setCellType(Cell.CELL_TYPE_STRING);
String departStr = depart.getStringCellValue();
//从部门树中找到部门
HashMap<Object, Object> hashMap = departIdMap.get(companyId);
List<HashMap<Object,Object>> departList = (List<HashMap<Object,Object>>)hashMap.get("childen");
List<String> data=new ArrayList<>();
getDepartIdByMapTree(data,departStr,departList);
if (data.size()>0){
addMap.put("depart_id",data.get(0));
}else{
errNum++;
errNumList.add(""+(i+1));
continue;
}
}
//岗位
XSSFCell post = row.getCell(5);
if(post==null){
addMap.put("post","");
}else {
post.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("post",post.getStringCellValue());
}
//政治面貌
XSSFCell policital_status = row.getCell(6);
if(policital_status==null){
addMap.put("policital_status","");
}else {
policital_status.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("policital_status",policital_status.getStringCellValue());
}
//专业技术资格
XSSFCell positional_titles = row.getCell(7);
if(positional_titles==null){
addMap.put("positional_titles","");
}else {
positional_titles.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("positional_titles",positional_titles.getStringCellValue());
}
//学历
XSSFCell education = row.getCell(8);
if(education==null){
addMap.put("education","");
}else {
education.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("education",education.getStringCellValue());
}
//职业技能名称
XSSFCell vocational_name = row.getCell(9);
if(vocational_name==null){
addMap.put("vocational_name","");
}else {
vocational_name.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("vocational_name",vocational_name.getStringCellValue());
}
//职业技术等级级别
XSSFCell level = row.getCell(10);
if(level==null){
addMap.put("level","");
}else {
level.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("level",level.getStringCellValue());
}
//把固定的参数添加到map 默认密码先设置123
addMap.put("password",new Md5Hash("123","hrs",2).toString());
addMap.put("isactive", "1");
addMap.put("modify_user_name", modify_user_name);
addMap.put("modify_true_name", modify_true_name);
addMap.put("create_time", create_time);
addMap.put("create_date", create_date);
addList.add(addMap);
}
if(errNum>0){
errCode="999";
errMsg="导入失败,有"+errNum+"行导入错误";
responseMap.put("errNumList", errNumList);
}else{
try {
usersService.insertExcelUsers(addList);//往数据库插入数据
} catch (Exception e) {
LogUtil.error(this.getClass(), "上传人员列表失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
}
} catch (Exception e) {
errCode="999";
errMsg="上传备件列表失败!"+e.getMessage();
e.printStackTrace();
LogUtil.error(this.getClass(), "上传人员列表失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
} finally {
workbook.close();
}
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
/**
* @description: 根据部门id查询相关人员
* @author thuang
* @date 2021/8/3 10:15
* @version 1.0
*/
@RequestMapping("/findUserByDepartId")
@ResponseBody
public HashMap<Object,Object> findUserByDepartId(@RequestBody HashMap<Object,Object> map){
HashMap<Object, Object> responseMap=new HashMap<Object, Object>();
String errCode="0";
String errMsg="";
try {
String departIds = StringDUtil.changeNullToEmpty(map.get("departIds"));
//如果是空的就直接返回个空集合 不查询
if ("".equals(departIds)){
responseMap.put("userList",new ArrayList<>());
}else {
String[] split = departIds.split(",");
List<String> idList=new ArrayList<>();
for (int i = 0; i < split.length; i++) {
idList.add(split[i]);
}
List<HashMap<Object, Object>> userByDepartIds = usersService.findUserByDepartIds(idList);
//循环数据生成所要格式 list 中 {namevalue}
List<HashMap<Object, Object>> userList =new ArrayList<>();
for (int i = 0; i < userByDepartIds.size(); i++) {
HashMap<Object, Object> hashMap = userByDepartIds.get(i);
HashMap<Object, Object> selectObj=new HashMap<>();
selectObj.put("name",hashMap.get("TRUE_NAME"));
selectObj.put("value",hashMap.get("USER_ID"));
userList.add(selectObj);
}
responseMap.put("userList",userList);
}
}catch (Exception e){
e.printStackTrace();
errCode="999";
errMsg="查询部门相关人员失败,原因:"+e.getMessage();
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
/**
* @description: 从上面生成的部门Map中根据部门名称获取部门id
* @author thuang
* @date 2021/7/14 13:45
* @version 1.0
* @param data
*/
public void getDepartIdByMapTree(List<String> data, String departStr, List<HashMap<Object, Object>> departList){
for (int i=0;i<departList.size();i++){
HashMap<Object, Object> departObj = departList.get(i);
String depart_id = StringDUtil.changeNullToEmpty(departObj.get("DEPART_ID"));
String depart_name = StringDUtil.changeNullToEmpty(departObj.get("DEPART_NAME"));
List<HashMap<Object,Object>> departChildenList = (List<HashMap<Object,Object>>)departObj.get("childen");
if(departStr.equals(depart_name)){
data.add(depart_id);
return;
}
if(departChildenList!=null && departChildenList.size()>0){
getDepartIdByMapTree(data,departStr,departChildenList);
}
}
}
}

View File

@@ -0,0 +1,50 @@
package com.saye.hrs.controller.system;
import com.saye.hrs.commons.date.DateDUtil;
import com.saye.hrs.model.StatusDefine;
import com.saye.hrs.commons.string.StringDUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
/**
* @author thuang
* @version 1.0
* @description: TODO
* @date 2021/5/24 13:56
*/
@Controller
public class downloadController {
@RequestMapping("/download")
public void downloadFile(HttpServletRequest request, HttpServletResponse response) throws Exception{
try {
String fileName = StringDUtil.changeNullToEmpty(request.getParameter("fileName"));
String dowloadName = StringDUtil.changeNullToEmpty(request.getParameter("dowloadName"));
//过滤相对路径../
int lastIndex = fileName.lastIndexOf(".");
//fileName = fileName.substring(0, lastIndex).replaceAll(".", "")+fileName.substring(lastIndex);
String savePath = StatusDefine.filePath + fileName ;
File file = new File(savePath);
FileInputStream fis = new FileInputStream(file);
response.setContentType("application/force-download");
response.addHeader("Content-disposition", "attachment;fileName=" + URLEncoder.encode(dowloadName+ DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd)+".xlsx", "UTF-8"));
OutputStream os = response.getOutputStream();
byte[] buf = new byte[1024];
int len = 0;
while((len = fis.read(buf)) != -1) {
os.write(buf, 0, len);
}
fis.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,26 @@
package com.saye.hrs.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
/**
* @description: 黑名单Mapper
* @author: Mr.zs
* @create: 2024-04-12 13:46
**/
@Mapper
public interface BlackListMapper {
void addBlackList(HashMap<Object, Object> map);
Integer fetchCountByCardNo(HashMap<Object, Object> map);
List<HashMap<Object, Object>> findAllBlackList(HashMap<Object, Object> searchMap);
void modifyBlackList(HashMap<Object, Object> map);
void delBlackList(HashMap<Object, Object> map);
}

View File

@@ -0,0 +1,18 @@
package com.saye.hrs.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author Mr.zs
* @date 2025/2/8
*/
@Mapper
public interface CountAuthMapper {
List<String> getAutherList();
List<String> getAuthoList(String openid);
List<String> getDeptAuthList(String openid);
}

View File

@@ -0,0 +1,27 @@
package com.saye.hrs.mapper;
import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
import java.util.List;
/**
* (Doctor)表数据库访问层
*
* @author makejava
* @since 2021-09-16 15:17:12
*/
public interface DoctorMapper {
HashMap<Object,Object> findDoctorById(HashMap<Object,Object> map);
List<HashMap<Object, Object>> findDoctorList(HashMap<Object,Object> map);
int insertDoctor(HashMap<Object,Object> map);
int updateDoctor(HashMap<Object,Object> map);
int deleteDoctorById(HashMap<Object,Object> map);
List<HashMap<Object, Object>> findDoctorSchedualList(HashMap<Object, Object> map);
}

View File

@@ -0,0 +1,75 @@
package com.saye.hrs.mapper;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* (Hospital)表数据库访问层
*
* @author makejava
* @since 2021-09-15 09:38:39
*/
public interface HospitalMapper {
HashMap<Object,Object> findHospitalById(HashMap<Object,Object> map);
List<HashMap<Object, Object>> findHospitalList(HashMap<Object,Object> map);
int insertHospital(HashMap<Object,Object> map);
int updateHospital(HashMap<Object,Object> map);
int deleteHospitalById(HashMap<Object,Object> map);
void updateHospitalAbout(HashMap<Object, Object> map);
List<HashMap<Object, Object>> findHospitalNoticeList(HashMap<Object, Object> map);
void addHospitalNotice(HashMap<Object, Object> map);
void updateHospitalNotice(HashMap<Object, Object> map);
void deleteHospitalNotice(HashMap<Object, Object> map);
List<HashMap<Object, Object>> findHospitalArticleList(HashMap<Object, Object> map);
void addHospitalArticle(HashMap<Object, Object> map);
void updateHospitalArticle(HashMap<Object, Object> map);
void deleteHospitalArticle(HashMap<Object, Object> map);
void addMedicalGuide(HashMap<Object, Object> map);
void updateMedicalGuide(HashMap<Object, Object> map);
void deleteMedicalGuide(HashMap<Object, Object> map);
List<HashMap<Object, Object>> findMedicalGuideList(HashMap<Object, Object> map);
List<HashMap<Object, Object>> findMedicalGuideType();
List<HashMap<Object, Object>> findHospitalFloorList(HashMap<Object, Object> map);
void updateHospitalFloor(HashMap<Object, Object> map);
void deleteHospitalFloor(HashMap<Object, Object> map);
void addHospitalFloor(HashMap<Object, Object> map);
void problemFeedback(Map map);
List<HashMap<Object, Object>> findMessageNotice(HashMap<Object, Object> map);
void setMessageNoticeRead(Map map);
List<HashMap<Object, Object>> findMedicalGuideById(HashMap<Object, Object> map);
void addPayRequest(Map map);
void updatePayRequestResultText(Map map);
void setMessageNoticeAllRead(Map map);
}

View File

@@ -0,0 +1,24 @@
package com.saye.hrs.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
/**
* @description: 问题Mapper
* @author: Mr.zs
* @create: 2024-04-10 13:00
**/
@Mapper
public interface IssueMapper {
List<HashMap<Object, Object>> findAllQuestions(HashMap<Object, Object> map);
void addQuestions(HashMap<Object, Object> map);
void delQuestions(HashMap<Object, Object> map);
void modifyQuestions(HashMap<Object, Object> map);
}

View File

@@ -0,0 +1,16 @@
package com.saye.hrs.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
/**
* @description: 爽约记录Mapper
* @author: Mr.zs
* @create: 2024-04-12 11:29
**/
@Mapper
public interface MissedAppointRecordMapper {
List<HashMap<Object, Object>> findAllMissedAppointRecord(HashMap<Object, Object> searchMap);
}

View File

@@ -0,0 +1,29 @@
package com.saye.hrs.mapper;
import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
import java.util.List;
/**
* (Office)表数据库访问层
*
* @author makejava
* @since 2021-09-16 08:46:32
*/
public interface OfficeMapper {
HashMap<Object,Object> findOfficeById(HashMap<Object,Object> map);
List<HashMap<Object, Object>> findOfficeList(HashMap<Object,Object> map);
int insertOffice(HashMap<Object,Object> map);
int updateOffice(HashMap<Object,Object> map);
int deleteOfficeById(HashMap<Object,Object> map);
List<HashMap<Object, Object>> findFirstStageOffice(HashMap<Object, Object> map);
List<HashMap<Object, Object>> findSecondStageOffice(HashMap<Object, Object> map);
}

View File

@@ -0,0 +1,53 @@
package com.saye.hrs.mapper;
import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
import java.util.List;
/**
* 预约挂号记录(Order)表数据库访问层
*
* @author makejava
* @since 2021-09-16 16:26:19
*/
public interface OrderMapper {
HashMap<Object,Object> findOrderById(HashMap<Object,Object> map);
List<HashMap<Object, Object>> findOrderList(HashMap<Object,Object> map);
int insertOrder(HashMap<Object,Object> map);
int updateOrder(HashMap<Object,Object> map);
int deleteOrderById(HashMap<Object,Object> map);
void cancelOrder(HashMap<Object, Object> map);
List<HashMap<Object, Object>> findOrderWeekNum(String[] array);
List<HashMap<Object, Object>> findRechargeWeekNum(String[] array);
List<HashMap<Object, Object>> findhospitalizedWeekNum(String[] array);
List<HashMap<Object, Object>> findOfficeOrderNum();
void setWXLoginTime(HashMap<Object, Object> map);
HashMap<Object, Object> findHomeData(HashMap<Object, Object> requestMap);
void generateOrderNotice(HashMap<Object, Object> map);
List<HashMap<Object, Object>> findRechargeWait();
void addRefund(HashMap<Object, Object> map);
void addRefundMessageNotice(HashMap<Object, Object> map);
HashMap<Object, Object> findOrderNotice();
void updateOrderNotice(HashMap<Object, Object> map);
List<HashMap<Object, Object>> findDistinctOrderOffice();
}

View File

@@ -0,0 +1,74 @@
package com.saye.hrs.mapper;
import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* (Patient)表数据库访问层
*
* @author makejava
* @since 2021-09-27 10:24:47
*/
public interface PatientMapper {
HashMap<Object,Object> findPatientById(HashMap<Object,Object> map);
List<HashMap<Object, Object>> findPatientList(HashMap<Object,Object> map);
int insertPatient(HashMap<Object,Object> map);
int updatePatient(HashMap<Object,Object> map);
int deletePatientById(HashMap<Object,Object> map);
List<HashMap<Object, Object>> findPatientAccountPageList(HashMap<Object, Object> map);
List<HashMap<Object, Object>> findPatientByOpenid(HashMap<Object, Object> map);
void insertWXUser(HashMap<Object, Object> map);
void insertOrUpdatePatientByHis(HashMap<Object, Object> map);
void patientBindWXUser(HashMap<Object, Object> map);
void setOtherPatientNotDefault(HashMap<Object, Object> map);
void setPatientDefault(HashMap<Object, Object> map);
void updatePatientByOpenid(HashMap<Object, Object> map);
void deleteWXUserPatnent(HashMap<Object, Object> map);
HashMap<Object, Object> findPatientByMerOrderId(Map map);
int updatePayRequestHisStatus(Map map);
void addAccount(HashMap map);
List<HashMap<Object, Object>> findRefundList(HashMap<Object, Object> map);
List<HashMap<Object, Object>> findPayRequestList(HashMap<Object, Object> map);
void addBindCardLog(HashMap<Object, Object> map);
List<HashMap<Object, Object>> findBindCardLogList(HashMap<Object, Object> map);
void updatePayRequestHisStatus1(Map map);
void delCardNotBind(HashMap<Object, Object> map);
List<HashMap<Object, Object>> getZyPatientByOpenid(HashMap<Object, Object> map);
void insertOrUpdateZyPatientByHis(HashMap<Object, Object> map);
List<HashMap<Object, Object>> findZyPatientAccountPageList(HashMap<Object, Object> map);
void zyPatientBindWXUser(HashMap<Object, Object> map);
void addZyBindCardLog(HashMap<Object, Object> map);
void delZyCardNotBind(HashMap<Object, Object> map);
}

View File

@@ -0,0 +1,34 @@
package com.saye.hrs.mapper;
import com.saye.hrs.model.BodyDivision;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @description: 症状管理业务接口Mapper
* @author: Mr.zs
* @create: 2024-04-09 17:11
**/
@Mapper
public interface SymptomMapper {
List<HashMap<Object, Object>> findAllSymptom(Map<String, String> symptom);
List<BodyDivision> findAllBodyArea();
void addSymptom(HashMap<Object, Object> map);
Integer findMaxId();
void modifySymptom(HashMap<Object, Object> map);
void delSymptom(HashMap<Object, Object> map);
List<HashMap<Object, Object>> getSymptomByAreaType(HashMap<Object, Object> searchMap);
List<BodyDivision> findAreaTypeBySexAdult(Map<String, String> searchMap);
}

View File

@@ -0,0 +1,41 @@
package com.saye.hrs.mapper;
import com.saye.hrs.model.WxResult;
import com.saye.hrs.model.WxybResult;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
/***
* @title WxPayMapper
* @description TODO 请填写注释
* @author thuang
* @create 2023/8/15 9:42
**/
@Mapper
public interface WxPayMapper {
void addWxPayInfo(WxResult reqDTO);
WxResult findWxPayInfo(WxResult reqDTO);
void addWxybPayInfo(WxybResult reqDTO);
WxybResult findWxybPayInfo(WxybResult reqDTO);
List<WxResult> getWxNotSendInfo(HashMap<Object,Object> map);
List<WxybResult> getWxybNotSendInfo(HashMap<Object,Object> map);
void addOrderInfo(HashMap<Object, Object> map);
void updateOrderInfoPay(HashMap<Object, Object> map);
void updateYBOrderInfoPay(HashMap<Object, Object> map);
void updateOrderInfoComplete(HashMap<Object, Object> map);
List<HashMap<Object, Object>> findOrderInfo(HashMap<Object, Object> map);
void updateOrderInfoEnd(HashMap<Object, Object> map);
}

View File

@@ -0,0 +1,35 @@
package com.saye.hrs.mapper.system;
import com.saye.hrs.model.Dicinfo;
import java.util.HashMap;
import java.util.List;
public interface DicinfoMapper {
//字典表管理
//通过父节点查询
public List<Dicinfo> findDicinfoTreeNodeList(String parentCode);
//通过diccode查询字典
public List<Dicinfo> findDicinfoBydiccode(String diccode);
//新增
public int addDicinfo(HashMap<String,String> map);
//修改
public int modifyDicinfo(HashMap<String,String> map);
//删除
public int deleteDicinfo(String diccode);
public List<HashMap<Object, Object>> selectDicinfoListByCode(String parent_code);
//通过parentCode和val值查询该父类下值是否重复
public List<Dicinfo> findDicinfoTreeByCode(HashMap<String,String> map);
public List<HashMap<Object, Object>> selectDicinfoListByCondition(HashMap<String, String> map);
//通过parentCode查询该字典下的最大值
public HashMap<Object, Object> getMaxDicValue(HashMap<String,String> map) throws Exception;
}

View File

@@ -0,0 +1,20 @@
package com.saye.hrs.mapper.system;
import java.util.HashMap;
import java.util.List;
import org.springframework.stereotype.Repository;
import com.saye.hrs.model.Logger;
@Repository
public interface LoggerMapper {
public List<Logger> findLoggers(HashMap<Object, Object> map);
public void addLog(HashMap<Object, Object> map) throws Exception;
public void addHisLog(HashMap<Object, Object> map);
public List<HashMap<Object, Object>> findHisLogList(HashMap<Object, Object> map);
}

View File

@@ -0,0 +1,19 @@
package com.saye.hrs.mapper.system;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
@Mapper
public interface MenuMapper {
public List<HashMap<Object,Object>> findMenuByRole(HashMap<Object, Object> map);
public List<HashMap<Object, Object>> findMenuByUrl(HashMap<Object, Object> map);
public List<HashMap<Object, Object>> findRoleByUserAndMenu(HashMap<Object, Object> map);
public List<HashMap<Object, Object>> findMenuList();
}

View File

@@ -0,0 +1,26 @@
package com.saye.hrs.mapper.system;
import com.saye.hrs.model.MenuRole;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
@Mapper
public interface MenuRoleMapper {
/**删除角色权限信息 通过roleID
* */
public int deleteMenuRole(String roleId);
//插入角色权限表记录
public int insertMenuRole(String roleId,String menuId);
/**
* @description 根据角色id获取信息
* @author thuang
* @created 2019年11月12日 上午11:26:33
* @param map
* @return
*/
public List<MenuRole> getMenuRolesByRoleId(HashMap<Object, Object> map);
}

View File

@@ -0,0 +1,48 @@
package com.saye.hrs.mapper.system;
import com.saye.hrs.model.Role;
import java.util.HashMap;
import java.util.List;
public interface RoleMapper {
/**查询角色列表
* */
public List<Role> findRoleList();
/**多条件查询角色列表
* */
public List<Role> searchRole(HashMap<String,String>map);
/**删除角色
* */
public int deleteRole(String roleId);
/**
* @description 添加角色
* @author thuang
* @created 2019年11月11日 下午4:47:47
* @param map
* @return
*/
public int addRole(HashMap<String,String>map);
/**
* 根据条件查询人员是否在管理员角色下
* @param map
* @return
* @throws Exception
*/
public List<HashMap<Object, Object>> findUserRoleListByParam(HashMap<Object, Object> map) throws Exception;
void updateRole(HashMap<String, String> map) ;
/**
* @description: 根据用户id 查询用户权限
* @author thuang
* @date 2021/5/24 17:11
* @version 1.0
*/
List<HashMap<Object, Object>> findUserRoleListByUserId(HashMap<Object, Object> map) throws Exception;
}

View File

@@ -0,0 +1,28 @@
package com.saye.hrs.mapper.system;
import com.saye.hrs.model.ServiceParams;
import java.util.HashMap;
import java.util.List;
public interface ServiceParamsMapper {
//对业务参数列表进行增删查改
public List<ServiceParams> selectServiceParams(HashMap<String,String> map);
//新增
public int insertServiceParams(ServiceParams sp);
//修改
public int updateServiceParams(ServiceParams sp);
//删除
public int deleteServiceParams(String paramId);
public List<HashMap<Object,Object>> findParamVal()throws Exception;
public List<HashMap<Object, Object>> findParamValByParamCode(String code) throws Exception;
public void updateServiceParamsValBycode(HashMap<String, String> map);
}

View File

@@ -0,0 +1,23 @@
package com.saye.hrs.mapper.system;
import com.saye.hrs.model.UserRole;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface UserRoleMapper {
/**插入用户角色表
* */
public int insertUserRole(String userId,String roleId);
/**根据userId删除记录
* */
public void deleteUserRole(String userId);
//根据userId查询记录
public List<UserRole> selectUserRoleByUserId(String userId);
//根据roleId查询记录
public List<UserRole> selectUserRoleByRoleId(String roleId);
}

View File

@@ -0,0 +1,67 @@
package com.saye.hrs.mapper.system;
import com.saye.hrs.model.Users;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
import java.util.List;
@Mapper
public interface UsersMapper {
/**
* 分页查询用户列表
* */
public List<Users> searchUsers(HashMap<Object, Object> map);
/**新增用户
* */
public int insertUser(HashMap<Object, Object> map);
/**修改用户信息
* */
public int modifyUsers(HashMap<Object, Object> map);
/**user用户密码重置
* */
public int modifyPassword(HashMap<Object, Object> map);
/**
* 修改状态 启用禁用
* */
public int unableUser(HashMap<Object, Object> map);
/**新增用户名验证
* */
public List<Users> searchByName(String userName);
/**
* @description 修改用户密码
* @author thuang
* @created 2019年11月28日 上午8:41:34
* @param password
* @throws Exception
*/
public void modifyPassword(String username, String password, String modifyTime) throws Exception;
public void modifyLockTime(String username, String lockTime);
void insertExcelUsers(List<HashMap<Object, Object>> list);
List<HashMap<Object, Object>> findUserByDepartIds(@Param("idList") List<String> idList)throws Exception;
/**
* @description: 根据部门id查询人员信息
* @author thuang
* @date 2021/8/24 10:33
* @version 1.0
*/
List<HashMap<Object, Object>> findUserByDepartIdsAndIsactive(@Param("idList") List<String> idList) throws Exception;
/**
* @description: 查询用户及部门的详细信息
* @author thuang
* @date 2021/8/24 10:21
* @version 1.0
*/
List<HashMap<Object, Object>> findUserAndIsactive() throws Exception;
}

View File

@@ -0,0 +1,22 @@
package com.saye.hrs.model;
import lombok.Data;
/**
* @description: 症状实体类
* @author: Mr.zs
* @create: 2024-04-09 17:07
**/
@Data
public class BodyDivision {
private String ID;
private String BODY_AREA;
private String BODY_AREA_TYPE;
private String SEX;
private String SEX_NAME;
private String IS_ADULT;
private String IS_ADULT_NAME;
}

View File

@@ -0,0 +1,56 @@
package com.saye.hrs.model;
public class Dicinfo {
private String diccode;
private String dicname;
private String dicvalue;
private String parentCode;
private String createTime;
private String modifyTime;
private Integer sortNo;
public String getDiccode() {
return diccode;
}
public void setDiccode(String diccode) {
this.diccode = diccode;
}
public String getDicname() {
return dicname;
}
public void setDicname(String dicname) {
this.dicname = dicname;
}
public String getDicvalue() {
return dicvalue;
}
public void setDicvalue(String dicvalue) {
this.dicvalue = dicvalue;
}
public String getParentCode() {
return parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getModifyTime() {
return modifyTime;
}
public void setModifyTime(String modifyTime) {
this.modifyTime = modifyTime;
}
public Integer getSortNo() {
return sortNo;
}
public void setSortNo(Integer sortNo) {
this.sortNo = sortNo;
}
}

View File

@@ -0,0 +1,137 @@
package com.saye.hrs.model;
import java.math.BigDecimal;
import java.io.Serializable;
/**
* (Doctor)实体类
*
* @author makejava
* @since 2021-09-03 14:06:05
*/
public class Doctor implements Serializable {
private static final long serialVersionUID = -55008974522512825L;
/**
* 医生id
*/
private Integer doctorId;
/**
* 医生姓名
*/
private String doctorName;
/**
* 性别
*/
private String doctorSex;
/**
* 所属医院
*/
private String hospitalName;
/**
* 所属科室
*/
private String officesName;
/**
* 医生照片
*/
private String doctorImg;
/**
* 医生职称
*/
private String doctorTitle;
/**
* 医生特长
*/
private String doctorForte;
/**
* 挂号费
*/
private BigDecimal registerFee;
/**
* 医生简介
*/
private String doctorAbout;
public Integer getDoctorId() {
return doctorId;
}
public void setDoctorId(Integer doctorId) {
this.doctorId = doctorId;
}
public String getDoctorName() {
return doctorName;
}
public void setDoctorName(String doctorName) {
this.doctorName = doctorName;
}
public String getDoctorSex() {
return doctorSex;
}
public void setDoctorSex(String doctorSex) {
this.doctorSex = doctorSex;
}
public String getHospitalName() {
return hospitalName;
}
public void setHospitalName(String hospitalName) {
this.hospitalName = hospitalName;
}
public String getOfficesName() {
return officesName;
}
public void setOfficesName(String officesName) {
this.officesName = officesName;
}
public String getDoctorImg() {
return doctorImg;
}
public void setDoctorImg(String doctorImg) {
this.doctorImg = doctorImg;
}
public String getDoctorTitle() {
return doctorTitle;
}
public void setDoctorTitle(String doctorTitle) {
this.doctorTitle = doctorTitle;
}
public String getDoctorForte() {
return doctorForte;
}
public void setDoctorForte(String doctorForte) {
this.doctorForte = doctorForte;
}
public BigDecimal getRegisterFee() {
return registerFee;
}
public void setRegisterFee(BigDecimal registerFee) {
this.registerFee = registerFee;
}
public String getDoctorAbout() {
return doctorAbout;
}
public void setDoctorAbout(String doctorAbout) {
this.doctorAbout = doctorAbout;
}
}

View File

@@ -0,0 +1,50 @@
package com.saye.hrs.model;
public class Logger {
public String loggerId;
public String logType;
public String information;
public String create_time;
public String user_id;
public String ip;
public String getLoggerId() {
return loggerId;
}
public void setLoggerId(String loggerId) {
this.loggerId = loggerId;
}
public String getLogType() {
return logType;
}
public void setLogType(String logType) {
this.logType = logType;
}
public String getInformation() {
return information;
}
public void setInformation(String information) {
this.information = information;
}
public String getCreate_time() {
return create_time;
}
public void setCreate_time(String create_time) {
this.create_time = create_time;
}
public String getUser_id() {
return user_id;
}
public void setUser_id(String user_id) {
this.user_id = user_id;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
}

View File

@@ -0,0 +1,77 @@
package com.saye.hrs.model;
public class Menu {
private String menuId;
private String menuName;
private String parentId;
private Integer seq;
private String linkUrl;
private String isactive;
private String createTime;
private String reslevel;
private String linkImg;
private Integer linkImgSize;
public String getMenuId() {
return menuId;
}
public void setMenuId(String menuId) {
this.menuId = menuId;
}
public String getMenuName() {
return menuName;
}
public void setMenuName(String menuName) {
this.menuName = menuName;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public Integer getSeq() {
return seq;
}
public void setSeq(Integer seq) {
this.seq = seq;
}
public String getLinkUrl() {
return linkUrl;
}
public void setLinkUrl(String linkUrl) {
this.linkUrl = linkUrl;
}
public String getIsactive() {
return isactive;
}
public void setIsactive(String isactive) {
this.isactive = isactive;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getReslevel() {
return reslevel;
}
public void setReslevel(String reslevel) {
this.reslevel = reslevel;
}
public String getLinkImg() {
return linkImg;
}
public void setLinkImg(String linkImg) {
this.linkImg = linkImg;
}
public Integer getLinkImgSize() {
return linkImgSize;
}
public void setLinkImgSize(Integer linkImgSize) {
this.linkImgSize = linkImgSize;
}
}

Some files were not shown because too many files have changed in this diff Show More