湛江重耗材采集器

master
linjj 9 months ago
commit 823ef3f870

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 potter fu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

@ -0,0 +1,4 @@
# springboot-mybatis2datasource-demo
[![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu)
Spring Boot整合MyBatis双数据源Demo

286
mvnw vendored

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

161
mvnw.cmd vendored

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

@ -0,0 +1,131 @@
<?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 http://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.1.1.RELEASE</version>
</parent>
<groupId>com.example</groupId>
<artifactId>consumables_zj</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>springbootDemo</name>
<description>springbootDemo</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- Java Native Access (JNA) -->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.13.0</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>5.13.0</version>
</dependency>
<!-- Apache Commons Lang -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<!-- Apache HttpClient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<!-- swaggerui相关依赖 -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>2.0.9</version>
</dependency>
<!-- mysql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.23</version>
</dependency>
<!-- Apache PDFBox的依赖 -->
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.27</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-metadata</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
<!-- sqlserver相关依赖 -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,16 @@
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author potter.fu
* @date 2018-12-07 15:40
*/
@SpringBootApplication
public class MainApplication {
public static void main(String[] args) {
SpringApplication.run(MainApplication.class, args);
}
}

@ -0,0 +1,58 @@
package com.example.config;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
@Configuration
@MapperScan(basePackages = "com.example.db1.dao", sqlSessionTemplateRef = "db1SqlSessionTemplate")
public class DataSource1Config {
/**
* . @Primary
*/
@Bean(name = "db1DataSource")
@ConfigurationProperties(prefix = "spring.datasource.hikari.db1")
@Primary
public DataSource testDataSource() {
return DataSourceBuilder.create().build();
}
/**
* SqlSessionFactory
*/
@Bean(name = "db1SqlSessionFactory")
@Primary
public SqlSessionFactory testSqlSessionFactory(@Qualifier("db1DataSource") DataSource dataSource) throws Exception {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(dataSource);
bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/db1/*.xml"));
return bean.getObject();
}
/**
*
*/
@Bean(name = "db1TransactionManager")
@Primary
public DataSourceTransactionManager testTransactionManager(@Qualifier("db1DataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
@Bean(name = "db1SqlSessionTemplate")
@Primary
public SqlSessionTemplate testSqlSessionTemplate(@Qualifier("db1SqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
return new SqlSessionTemplate(sqlSessionFactory);
}
}

@ -0,0 +1,45 @@
package com.example.config;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
@Configuration
@MapperScan(basePackages = "com.example.db2.dao", sqlSessionTemplateRef = "db2SqlSessionTemplate")
public class DataSource2Config {
@Bean(name = "db2DataSource")
@ConfigurationProperties(prefix = "spring.datasource.hikari.db2")
public DataSource testDataSource() {
return DataSourceBuilder.create().build();
}
@Bean(name = "db2SqlSessionFactory")
public SqlSessionFactory testSqlSessionFactory(@Qualifier("db2DataSource") DataSource dataSource) throws Exception {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(dataSource);
bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/db2/*.xml"));
return bean.getObject();
}
@Bean(name = "db2TransactionManager")
public DataSourceTransactionManager testTransactionManager(@Qualifier("db2DataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
@Bean(name = "db2SqlSessionTemplate")
public SqlSessionTemplate testSqlSessionTemplate(@Qualifier("db2SqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
return new SqlSessionTemplate(sqlSessionFactory);
}
}

@ -0,0 +1,57 @@
package com.example.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
import java.util.ArrayList;
import java.util.List;
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfiguration {
/**
* controller
*/
String controllerPackagePath = "com.example";
@Bean(value = "defaultApi2")
public Docket defaultApi2() {
List<Parameter> pars = new ArrayList<>();
ParameterBuilder tokenPar = new ParameterBuilder();
tokenPar.name("token")
.description("用户token")
.defaultValue("")
.modelRef(new ModelRef("string"))
.parameterType("header")
.required(false)
.build();
pars.add(tokenPar.build());
//添加head参数end
Docket docket=new Docket(DocumentationType.SWAGGER_2)
.apiInfo(new ApiInfoBuilder()
//.title("swagger-bootstrap-ui-demo RESTful APIs")
.description("# swagger-bootstrap-ui-demo RESTful APIs")
.termsOfServiceUrl("www.codeleader.top")
.version("1.0")
.build())
.globalOperationParameters(pars)
//分组名称
.groupName("2.X版本")
.select()
//这里指定Controller扫描包路径
.apis(RequestHandlerSelectors.basePackage(controllerPackagePath))
.paths(PathSelectors.any())
.build();
return docket;
}
}

@ -0,0 +1,35 @@
package com.example.controller;
import com.example.service.MedicaRecordService;
import com.example.util.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @ClassName MedRecordController
* @Description
* @Author linjj
* @Date 2025/3/25 16:45
* @Version 1.0
*/
@RestController
@RequestMapping("/task")
@Api(value = "重耗材任务接口", tags = "重耗材任务对外接口")
@Slf4j
public class MedRecordController {
@Autowired
private MedicaRecordService medicaRecordService;
@PostMapping("/getTask")
@ApiOperation("获取任务接口")
@ResponseBody
public CommonResult<?> GetTask() {
medicaRecordService.gatherMedicaRecord();
return CommonResult.success("完成");
}
}

@ -0,0 +1,55 @@
package com.example.db1.dao;
import com.example.dto.ArchiveDetailDto;
import com.example.vo.ArchiveDetailVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @InterfaceName ArchiveDetailDao
* @Description
* @Author linjj
* @Date 2024/1/19 9:01
* @Version 1.0
*/
@Mapper
public interface ArchiveDetailDao {
/**
* @Author: linjj
* @Description:
* @DateTime: 2025/3/25 14:56
* @Params: [archiveDetailDto]
* @Return boolean
*/
boolean addArchiveDetailParam(@Param("list") List<ArchiveDetailDto> list);
/**
* @Author: linjj
* @Description:
* @DateTime: 2025/3/25 14:56
* @Params: [archiveDetailDto]
* @Return boolean
*/
boolean addArchiveDetail(ArchiveDetailDto archiveDetailDto);
/**
* @Author: linjj
* @Description:
* @DateTime: 2025/3/26 16:34
* @Params: [C2]
* @Return java.util.List<java.lang.String>
*/
List<String> getPdfPath(String C1);
/**
* @Author: linjj
* @Description:
* @DateTime: 2025/3/26 16:37
* @Params: [C1]
* @Return boolean
*/
boolean delPdfPath(String C1);
}

@ -0,0 +1,27 @@
package com.example.db1.dao;
import com.example.vo.ArchiveDetailVo;
import com.example.vo.ArchiveMasterVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @InterfaceName ArchiveMasterDao
* @Description sql
* @Author linjj
* @Date 2024/1/18 9:47
* @Version 1.0
*/
@Mapper
public interface ArchiveMasterDao {
/**
* @Author: linjj
* @Description:
* @DateTime: 2025/3/27 17:03
* @Params:
* @Return java.util.List<java.lang.String>
*/
List<String> getMasterId(@Param("patientId")String patientId, @Param("visitId")String visitId);
}

@ -0,0 +1,52 @@
package com.example.db1.dao;
import com.example.dto.ArchiveOtherExtDto;
import com.example.dto.UpdateOtherDao;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
* @ClassName ArchiveOtherDao
* @Description
* @Author linjj
* @Date 2025/3/26 15:13
* @Version 1.0
*/
@Mapper
public interface ArchiveOtherDao {
/**
* @Author: linjj
* @Description: c2
* @DateTime: 2025/3/26 15:15
* @Params: [C2]
* @Return java.util.List<java.lang.String>
*/
List<String> getArchiveOtherExt(String C2);
/**
* @Author: linjj
* @Description: //查询任务表中C2字段跟时间是否都一致一致不需要重新采集
* @DateTime: 2025/3/27 17:29
* @Params: [C2]
* @Return java.util.List<java.lang.String>
*/
List<String> getArchiveOtherExtAndTime(@Param("C2")String C2, @Param("SycTime") Date SycTime);
/**
* @Author: linjj
* @Description:
* @DateTime: 2025/3/26 15:29
* @Params: [archiveOtherExtDto]
* @Return java.lang.Boolean
*/
Boolean addArchiveOtherExt(ArchiveOtherExtDto archiveOtherExtDto);
/**
* @Author: linjj
* @Description:
* @DateTime: 2025/3/26 15:44
* @Params: [updateOtherDao]
* @Return java.lang.Boolean
*/
Boolean updateArchiveOtherExt(UpdateOtherDao updateOtherDao);
}

@ -0,0 +1,24 @@
package com.example.db2.dao;
import com.example.vo.MedicaRecordVo;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @ClassName MedicaRecordDao
* @Description
* @Author linjj
* @Date 2025/3/25 12:34
* @Version 1.0
*/
@Mapper
public interface MedicaRecordDao {
/**
* @Author: linjj
* @Description:
* @DateTime: 2025/3/25 12:36
* @Return java.util.List<com.example.vo.MedicaRecordVo>
*/
List<MedicaRecordVo> getMedicaRecord();
}

@ -0,0 +1,34 @@
package com.example.dto;
import lombok.Data;
import java.util.Date;
/**
* @ClassName ArchiveDetailDto
* @Description dto
* @Author linjj
* @Date 2024/1/18 17:29
* @Version 1.0
*/
@Data
public class ArchiveDetailDto {
//文件id
private String id;
//文件路径
private String pdfPath;
//病案id
private String masterId;
//生成时间
private Date upLoadDateTime;
//分段id
private String assortId;
//来源
private String source;
//文件名
private String title;
private String flag;
private String sys;
//扩展字段存储平台唯一id
private String C1;
}

@ -0,0 +1,26 @@
package com.example.dto;
import lombok.Data;
/**
* @ClassName ArchiveMasterVo
* @Description
* @Author linjj
* @Date 2024/1/18 9:33
* @Version 1.0
*/
@Data
public class ArchiveMasterDto {
//病案id
private String id;
//患者姓名
private String name;
//住院次数
private String visitId;
//住院号
private String inpNo;
//入院时间
private String admissionDateTime;
//出院时间
private String dischargeDateTime;
}

@ -0,0 +1,49 @@
package com.example.dto;
import lombok.Data;
import java.math.BigInteger;
import java.util.Date;
/**
* @ClassName ArchiveOtherExtDto
* @Description
* @Author linjj
* @Date 2025/3/26 15:07
* @Version 1.0
*/
@Data
public class ArchiveOtherExtDto {
//任务id
private String id;
//创建时间
private Date SycTime;
//下载地址
private String SycObj;
//默认0
private BigInteger otherID;
//采集器标识重耗材21
private BigInteger sysFlag;
//更新时间
private Date sysUpdateTime;
//住院号
private String jzh;
//开始时间
private Date stime;
//结束时间
private Date eTime;
//任务状态0为开始、2采集失败、3成功
private BigInteger statusFlag;
//任务状态说明
private String pResult;
//主键id
private String MID;
//文件id
private String DID;
//文件名
private String C1;
//平台唯一id
private String C2;
}

@ -0,0 +1,34 @@
package com.example.dto;
import lombok.Data;
import java.math.BigInteger;
import java.util.Date;
/**
* @ClassName updateOtherDao
* @Description
* @Author linjj
* @Date 2025/3/26 15:42
* @Version 1.0
*/
@Data
public class UpdateOtherDao {
//更新时间
private Date sysUpdateTime;
//开始时间
private Date stime;
//结束时间
private Date eTime;
//任务状态0为开始、2采集失败、3成功
private BigInteger statusFlag;
//任务状态说明
private String pResult;
//文件名
private String C1;
//平台唯一id
private String C2;
//文件id
private String DID;
}

@ -0,0 +1,25 @@
package com.example.quartz;
import com.example.service.MedicaRecordService;
import org.quartz.JobExecutionContext;
import org.springframework.scheduling.quartz.QuartzJobBean;
import javax.annotation.Resource;
/**
* @description:
* @author linjj
* @date: 2025/3/18 9:22
*/
public class ConsumablesQuartz extends QuartzJobBean {
@Resource
private MedicaRecordService medicaRecordService;
@Override
protected void executeInternal(JobExecutionContext jobExecutionContext) {
//根据试图中时间采集患者高耗材数据
medicaRecordService.gatherMedicaRecord();
}
}

@ -0,0 +1,46 @@
package com.example.quartz;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @ClassName QuartzConfig
* @Description
* @Author linjj
* @Date 2025/3/14 15:47
* @Version 1.0
*/
@Configuration
public class QuartzConfig {
@Value("${quartzTime}")
private String quartzTime;
@Bean
public JobDetail teatQuartzDetail() {
return JobBuilder.newJob(ConsumablesQuartz.class).withIdentity("ConsumablesQuartz").storeDurably().build();
}
@Bean
public Trigger testQuartzTrigger() {
return TriggerBuilder.newTrigger().forJob(teatQuartzDetail())
.withIdentity("ConsumablesQuartz")
.withSchedule(CronScheduleBuilder.cronSchedule(quartzTime))
.build();
}
}

@ -0,0 +1,18 @@
package com.example.service;
/**
* @ClassName MedicaRecordService
* @Description
* @Author linjj
* @Date 2025/3/25 12:55
* @Version 1.0
*/
public interface MedicaRecordService {
/**
* @Author: linjj
* @Description:
* @DateTime: 2025/3/25 12:58
*/
void gatherMedicaRecord();
}

@ -0,0 +1,267 @@
package com.example.service.serviceImpl;
import com.example.db1.dao.ArchiveDetailDao;
import com.example.db1.dao.ArchiveMasterDao;
import com.example.db1.dao.ArchiveOtherDao;
import com.example.db2.dao.MedicaRecordDao;
import com.example.dto.ArchiveDetailDto;
import com.example.dto.ArchiveOtherExtDto;
import com.example.dto.UpdateOtherDao;
import com.example.service.MedicaRecordService;
import com.example.vo.MedicaRecordVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
* @ClassName MedicaRecordServiceImpl
* @Description
* @Author linjj
* @Date 2025/3/25 12:55
* @Version 1.0
*/
@Service
@Slf4j
public class MedicaRecordServiceImpl implements MedicaRecordService {
@Autowired
private MedicaRecordDao medicaRecordDao;
@Autowired
private ArchiveMasterDao archiveMasterDao;
@Value("${savePath}")
private String savePath;
@Autowired
private ArchiveDetailDao archiveDetailDao;
@Autowired
private ArchiveOtherDao archiveOtherDao;
@Override
public void gatherMedicaRecord() {
//根据时间段查询当前时间需要采集的患者信息
List<MedicaRecordVo> patientInfos = medicaRecordDao.getMedicaRecord();
if (CollectionUtils.isEmpty(patientInfos)) {
log.info("当前时间段内无需要采集的数据");
return;
}
log.info("当前时间需要采集:" + patientInfos.size() + "份重耗材");
PollingGather(patientInfos);
}
/**
* @Author: linjj
* @Description:
* @DateTime: 2025/3/25 14:45
* @Params: [patientInfos]
* @Return void
*/
private void PollingGather(List<MedicaRecordVo> patientInfos) {
//更新任务表
UpdateOtherDao updateOtherDao=new UpdateOtherDao();
//轮询采集
for (MedicaRecordVo patientInfo : patientInfos) {
try {
//记帐号
String medicaRecord = patientInfo.getMedicaRecord();
//住院次数
String visitId = patientInfo.getVisitId();
//http下载地址
String pdfPath = patientInfo.getPdfPath();
//文件表
ArchiveDetailDto archiveDetailDto = new ArchiveDetailDto();
//任务表
ArchiveOtherExtDto archiveOtherExtDto = new ArchiveOtherExtDto();
//使用yyyyMMddHHmmssSSS格式作为文件名,文件id
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
String newDate = format.format(date);
//生成保存地址路径
String newSavePath = GenerateSavePath(medicaRecord, visitId,newDate);
log.info("当前采集患者记帐号为:"+medicaRecord+",住院次数为:"+visitId);
//根据记帐号住院次数查询患者是否存在归档数据库中
List<String> masterIds = archiveMasterDao.getMasterId(medicaRecord, visitId);
if (CollectionUtils.isEmpty(masterIds)) {
log.info("当前采集患者基础信息不存在归档数据库中采集失败记帐号为:"+medicaRecord+",住院次数为:"+visitId);
continue;
}
//查询任务表中C2字段跟时间是否都一致一致不需要重新采集
List<String> archiveOtherExtAndTime = archiveOtherDao.getArchiveOtherExtAndTime(patientInfo.getId(), patientInfo.getExportTime());
if (!CollectionUtils.isEmpty(archiveOtherExtAndTime)){
log.info("已经存在文件表跳过采集:"+medicaRecord+",住院次数为:"+visitId);
continue;
}
//查询任务表中c2字段是否已经存在存在直接下载文件不存在新增任务
List<String> archiveOtherExt = archiveOtherDao.getArchiveOtherExt(patientInfo.getId());
if (CollectionUtils.isEmpty(archiveOtherExt)) {
archiveOtherExtDto.setId(newDate);
archiveOtherExtDto.setSycTime(patientInfo.getExportTime());
archiveOtherExtDto.setSycObj(patientInfo.getPdfPath());
archiveOtherExtDto.setOtherID(BigInteger.valueOf(0));
archiveOtherExtDto.setSysFlag(BigInteger.valueOf(21));
archiveOtherExtDto.setSysUpdateTime(new Date());
archiveOtherExtDto.setJzh(medicaRecord);
archiveOtherExtDto.setStime(new Date());
archiveOtherExtDto.setETime(new Date());
archiveOtherExtDto.setStatusFlag(BigInteger.valueOf(0));
archiveOtherExtDto.setPResult("未开始");
archiveOtherExtDto.setMID(masterIds.get(0));
archiveOtherExtDto.setC2(patientInfo.getId());
archiveOtherDao.addArchiveOtherExt(archiveOtherExtDto);
}
updateDetail(patientInfo);
//下载图像
if (!DownloadFile(pdfPath, newSavePath)){
log.info("当前文件下载失败记帐号为:"+medicaRecord+",住院次数为:"+visitId);
failOther(updateOtherDao, patientInfo);
continue;
}
//下载成功保存文件表信息
archiveDetailDto.setId(newDate);
archiveDetailDto.setPdfPath(newSavePath);
archiveDetailDto.setMasterId(masterIds.get(0));
archiveDetailDto.setUpLoadDateTime(new Date());
archiveDetailDto.setAssortId("61");
archiveDetailDto.setSource("重耗材采集服务");
archiveDetailDto.setFlag("0");
archiveDetailDto.setSys("1");
archiveDetailDto.setTitle("高价值耗材清单");
archiveDetailDto.setC1(patientInfo.getId());
//插入到文件表中
if (!archiveDetailDao.addArchiveDetail(archiveDetailDto)){
log.info("插入文件表失败,采集失败记帐号为:"+medicaRecord+",住院次数为:"+visitId);
}
log.info("插入文件表成功,采集成功记帐号为:"+medicaRecord+",住院次数为:"+visitId);
succeedOther(updateOtherDao, patientInfo, newDate);
} catch (Exception e) {
//下载失败更新任务表中任务状态
failOther(updateOtherDao, patientInfo);
log.error("系统异常,下载失败记帐号为:"+patientInfo.getMedicaRecord()+",住院次数为:"+patientInfo.getVisitId()+"异常信息为:"+e.getMessage(),e);
}
}
}
private void updateDetail(MedicaRecordVo patientInfo) {
//判断文件表是否有记录,有记录先删除后更新
List<String> pdfPathS = archiveDetailDao.getPdfPath(patientInfo.getId());
if (!CollectionUtils.isEmpty(pdfPathS)) {
//不为空删除对应记录
if (archiveDetailDao.delPdfPath(patientInfo.getId())){
//删除对应文件
for (String path:pdfPathS){
File file1 = new File(path);
try {
file1.delete(); // 删除照片
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
/**
* @Author: linjj
* @Description:
* @DateTime: 2025/3/26 16:07
* @Params: [updateOtherDao, patientInfo, newDate]
* @Return void
*/
private void succeedOther(UpdateOtherDao updateOtherDao, MedicaRecordVo patientInfo, String newDate) {
//下载成功更新任务表中任务状态
updateOtherDao.setSysUpdateTime(new Date());
updateOtherDao.setStime(new Date());
updateOtherDao.setETime(new Date());
updateOtherDao.setStatusFlag(BigInteger.valueOf(3));
updateOtherDao.setPResult("Done");
updateOtherDao.setDID(newDate);
updateOtherDao.setC1(newDate +".pdf");
updateOtherDao.setC2(patientInfo.getId());
archiveOtherDao.updateArchiveOtherExt(updateOtherDao);
}
/**
* @Author: linjj
* @Description:
* @DateTime: 2025/3/26 16:07
* @Params: [updateOtherDao, patientInfo]
* @Return void
*/
private void failOther(UpdateOtherDao updateOtherDao, MedicaRecordVo patientInfo) {
//下载失败更新任务表中任务状态
updateOtherDao.setSysUpdateTime(new Date());
updateOtherDao.setStime(new Date());
updateOtherDao.setETime(new Date());
updateOtherDao.setStatusFlag(BigInteger.valueOf(2));
updateOtherDao.setPResult("文件下载失败");
updateOtherDao.setC2(patientInfo.getId());
archiveOtherDao.updateArchiveOtherExt(updateOtherDao);
}
/**
* @Author: linjj
* @Description:
* @DateTime: 2025/3/25 13:58
* @Params: [inpNo, visitId]
* @Return java.lang.String
*/
private String GenerateSavePath(String inpNo,String visitId,String newDate){
//保存目录
String saveDirectory=savePath+ File.separatorChar+inpNo+ File.separatorChar+visitId;
//保存地址
String newSavePath=saveDirectory+File.separatorChar + newDate + ".pdf";
// 检查目录是否存在,不存在则创建目录
File directory = new File(saveDirectory);
if (!directory.exists()) {
boolean isCreated = directory.mkdirs(); // 创建所有必需的父目录
if (!isCreated) {
// 处理创建目录失败的情况
log.info("目录创建失败,下载失败记帐号为:"+inpNo+",住院次数为:"+visitId);
}
}
return newSavePath;
}
/**
* @Author: linjj
* @Description:
* @DateTime: 2025/3/25 14:50
* @Params: [fileURL, savePath]
* @Return java.lang.Boolean
*/
private Boolean DownloadFile(String fileURL,String savePath) {
try {
CloseableHttpClient httpClient = HttpClients.createDefault();
try (CloseableHttpResponse response = httpClient.execute(new HttpGet(fileURL))) {
HttpEntity entity = response.getEntity();
try (InputStream in = entity.getContent();
FileOutputStream fileOutputStream = new FileOutputStream(savePath)) {
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = in.read(buffer)) != -1) {
fileOutputStream.write(buffer, 0, bytesRead);
}
return true;
}
}
} catch (Exception e) {
log.error("文件下载失败"+e.getMessage(),e);
return false;
}
}
}

@ -0,0 +1,42 @@
package com.example.text;
import com.example.MainApplication;
import com.example.service.MedicaRecordService;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
/**
* @ClassName test
* @Description
* @Author linjj
* @Date 2024/1/18 9:54
* @Version 1.0
*/
@SpringBootTest(classes = MainApplication.class)
@RunWith(SpringRunner.class)
@Slf4j
public class test {
@Resource
private MedicaRecordService medicaRecordService;
@Value("${savePath}")
private String savePath;
private final static Logger logger = LoggerFactory.getLogger(test.class);
@Test
public void testDemo() {
medicaRecordService.gatherMedicaRecord();
}
}

@ -0,0 +1,26 @@
package com.example.util;
/**
* @description:
* @author: ChenJ
* @date: 2022/5/9 17:29
* @param:
* @return:
**/
public class BusinessException extends Exception {
/**
* ,codemsg
*/
private final ExceptionCode exceptionCode;
public ExceptionCode getExceptionCode() {
return exceptionCode;
}
public BusinessException(ExceptionCode exceptionCode) {
super(exceptionCode.getMessage());
this.exceptionCode = exceptionCode;
}
}

@ -0,0 +1,152 @@
package com.example.util;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* @author docus
* @date 2020/3/28 16:23
*/
@Data
@ApiModel("响应")
@AllArgsConstructor
@NoArgsConstructor
public class CommonResult<T> {
@ApiModelProperty("响应码")
private Integer code;
@ApiModelProperty("响应消息")
private String msg;
@ApiModelProperty("响应实体")
private T data;
public CommonResult(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
/**
*
*
* @param data
* @param <T>
* @return
*/
public static <T> CommonResult<T> success(T data) {
return new CommonResult<T>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(), data);
}
/**
*
*
* @param data
* @param message
* @param <T>
* @return
*/
public static <T> CommonResult<T> success(T data, String message) {
return new CommonResult<T>(ResultCode.SUCCESS.getCode(), message, data);
}
/**
*
*
* @param errorCode
* @param <T>
* @return
*/
public static <T> CommonResult<T> failed(IErrorCode errorCode) {
return new CommonResult<T>(errorCode.getCode(), errorCode.getMessage(), null);
}
/**
*
*
* @param errorCode
* @param message
* @param <T>
* @return
*/
public static <T> CommonResult<T> failed(IErrorCode errorCode, String message) {
return new CommonResult<T>(errorCode.getCode(), message, null);
}
/**
*
*
* @param message
* @param <T>
* @return
*/
public static <T> CommonResult<T> failed(String message) {
return new CommonResult<T>(ResultCode.FAILED.getCode(), message, null);
}
/**
*
*
* @param <T>
* @return
*/
public static <T> CommonResult<T> failed() {
return failed(ResultCode.FAILED);
}
/**
*
*
* @param <T>
* @return
*/
public static <T> CommonResult<T> validateFailed() {
return failed(ResultCode.VALIDATE_FAILED);
}
/**
*
*
* @param message
* @param <T>
* @return
*/
public static <T> CommonResult<T> validateFailed(String message) {
return new CommonResult<T>(ResultCode.VALIDATE_FAILED.getCode(), message, null);
}
/**
*
*
* @param data
* @param <T>
* @return
*/
public static <T> CommonResult<T> unauthorized(T data) {
return new CommonResult<T>(ResultCode.UNAUTHORIZED.getCode(), ResultCode.UNAUTHORIZED.getMessage(), data);
}
/**
*
*
* @param data
* @param <T>
* @return
*/
public static <T> CommonResult<T> preventreplay(T data) {
return new CommonResult<T>(ResultCode.PREVENT_REPLAY.getCode(), ResultCode.PREVENT_REPLAY.getMessage(), data);
}
/**
*
*
* @param data
* @param <T>
* @return
*/
public static <T> CommonResult<T> forbidden(T data) {
return new CommonResult<T>(ResultCode.FORBIDDEN.getCode(), ResultCode.FORBIDDEN.getMessage(), data);
}
}

@ -0,0 +1,26 @@
package com.example.util;
public enum ExceptionCode {
/**
*
*/
WRONG_PARAMS("参数不对", 1001);
private final String message;
private final Integer code;
ExceptionCode(String message, int code) {
this.message = message;
this.code = code;
}
public String getMessage() {
return message;
}
public Integer getCode() {
return code;
}
}

@ -0,0 +1,12 @@
package com.example.util;
/**
* @Description API
* @Author JacksonTu
* @Date 2020/3/28 16:26
*/
public interface IErrorCode {
Integer getCode();
String getMessage();
}

@ -0,0 +1,51 @@
package com.example.util;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
* fastJSON/jackson
*/
public class JsonResult implements Serializable {
private Map<String, Object> dataMap = new HashMap<>(3);
public JsonResult() {
}
public String getCode() {
return dataMap.get("code").toString();
}
public void setCode(String code) {
this.dataMap.put("code", code);
}
public String getMsg() {
return dataMap.get("msg").toString();
}
public void setMsg(String msg) {
this.dataMap.put("msg", msg);
}
public Object getData() {
return dataMap.get("data");
}
public void setData(Object data) {
this.dataMap.put("data", data);
}
public Map<String, Object> getDataMap() {
return dataMap;
}
public void setDataMap(Map<String, Object> dataMap) {
this.dataMap = dataMap;
}
public void put(String name, Object value) {
this.dataMap.put(name, value);
}
}

@ -0,0 +1,71 @@
/**
*
*/
package com.example.util;
import java.util.HashMap;
import java.util.Map;
/**
* <p>Title:Msg </p>
* <p>Description:common return class </p>
* <p>Company: </p>
* @author hu
* @date
*/
public class Msg {
//state:100-success 200-fail
private int code;
//提示信息
private String msg;
//用户要返回给浏览器的数据
private Map<String,Object> extend=new HashMap<String,Object>();
public static Msg fail(String msg){
Msg result=new Msg();
result.setCode(100);
result.setMsg(msg);
return result;
}
public static Msg success(String msg){
Msg result=new Msg();
result.setCode(200);
result.setMsg(msg);
return result;
}
public Msg add(String key, Object value){
this.getExtend().put(key, value);
return this;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Map<String, Object> getExtend() {
return extend;
}
public void setExtend(Map<String, Object> extend) {
this.extend = extend;
}
}

@ -0,0 +1,42 @@
package com.example.util;
/**
* @Description API
* @Author JacksonTu
* @Date 2020/3/28 16:26
*/
public enum ResultCode implements IErrorCode {
SUCCESS(0, "操作成功"),
FAILED(500, "操作失败"),
VALIDATE_FAILED(404, "参数检验失败"),
UNAUTHORIZED(401, "暂未登录或token已经过期"),
FORBIDDEN(403, "没有相关权限"),
PREVENT_REPLAY(405,"重复请求"),
NOT_EXIST(601,"数据不存在"),
NOT_ENABLE(600,"数据未启用");
private Integer code;
private String message;
private ResultCode(Integer code, String message) {
this.code = code;
this.message = message;
}
@Override
public Integer getCode() {
return code;
}
@Override
public String getMessage() {
return message;
}
}

@ -0,0 +1,18 @@
package com.example.vo;
import lombok.Data;
/**
* @ClassName Archive_detail
* @Author linjj
* @Date 2024/3/10 20:59
* @Version 1.0
*/
@Data
public class ArchiveDetailVo {
private String id;
private String pdfPath;
}

@ -0,0 +1,30 @@
package com.example.vo;
import lombok.Data;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* @ClassName ArchiveMasterVo
* @Description
* @Author linjj
* @Date 2024/1/18 9:33
* @Version 1.0
*/
@Data
public class ArchiveMasterVo {
//病案id
private String id;
//患者姓名
private String name;
//住院次数
private String visitId;
//住院号
private String inpNo;
//入院时间
private String admissionDateTime;
//出院时间
private String dischargeDateTime;
//记帐号
private String patientId;
}

@ -0,0 +1,30 @@
package com.example.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
/**
* @ClassName MedicaRecordVo
* @Author linjj
* @Date 2025/3/25 12:03
* @Version 1.0
*/
@Data
@TableName("v_select_medica_record")
public class MedicaRecordVo {
private String id;
//记帐号
private String medicaRecord;
//住院次数
private String visitId;
//患者姓名
private String patientName;
//导出时间
private Date exportTime;
//pdf下载地址
private String pdfPath;
}

@ -0,0 +1,17 @@
server.port=3397
# SQL Server ?????
spring.datasource.hikari.db1.jdbc-url=jdbc:sqlserver://127.0.0.1:1433;DatabaseName=DB_PrivilegeManagement_GYFY
spring.datasource.hikari.db1.username=sa
spring.datasource.hikari.db1.password=docus@702
spring.datasource.hikari.db1.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
# MySQL??
spring.datasource.hikari.db2.jdbc-url=jdbc:mysql://10.6.3.80:3306/gzykd_spd
spring.datasource.hikari.db2.username=baxt
spring.datasource.hikari.db2.password=123456
spring.datasource.hikari.db2.driver-class-name=com.mysql.cj.jdbc.Driver
# MyBatis-Plus ??
mybatis-plus.mapper-locations=classpath:mapper/db1/*.xml,classpath:mapper/db2/*.xml
mybatis-plus.type-aliases-package=com.example.vo

@ -0,0 +1,4 @@
#文件保存路径
savePath: Z:\Consumables\reload
#定时补偿任务时间
quartzTime: 0 0/30 * * * ?

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<contextName>logback</contextName>
<!--输出到控制台-->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!--按天生成日志,即一天只生成一个文件夹和一个日志文件-->
<appender name="logFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<Prudent>true</Prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>
consumables_zj/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log
</FileNamePattern>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} -%msg%n
</Pattern>
</layout>
</appender>
<!-- logger节点可选节点作用是指明具体的包或类的日志输出级别
以及要使用的<appender>(可以把<appender>理解为一个日志模板)。
addtivity非必写属性是否向上级loger传递打印信息。默认是true-->
<logger name="com.framework.job" additivity="false">
<appender-ref ref="console"/>
<appender-ref ref="logFile"/>
</logger>
<!--项目的整体的日志打印级别为info-->
<root level="info">
<appender-ref ref="console"/>
<appender-ref ref="logFile"/>
</root>
</configuration>

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.db1.dao.ArchiveDetailDao">
<insert id="addArchiveDetail">
insert into archive_detail(ID, PDF_PATH, MasterID, UpLoadDateTime, AssortID, Source, Title, flag, Sys,C1)
values (#{id}, #{pdfPath}, #{masterId}, #{upLoadDateTime}, #{assortId},
#{source},
#{title}, #{flag}, #{sys}, #{C1})
</insert>
<insert id="addArchiveDetailParam">
insert into
archive_detail(id,PDF_PATH,MasterID,UpLoadDateTime,AssortID,Source,Title,flag,Sys,C1
)
values
<foreach collection="list" item="item" separator=",">
(replace(newid(), '-', ''),#{item.pdfPath},#{item.masterId},#{item.uploadDateTime},#{item.assortId},#{item.source},
#{item.title},#{item.flag},#{item.sys})
</foreach>
</insert>
<delete id="delPdfPath">
delete from archive_detail
where c1 = #{C1} AND AssortID='61'
</delete>
<select id="getPdfPath" resultType="java.lang.String">
select PDF_PATH FROM Archive_Detail WHERE c1=#{C1} AND AssortID='61'
</select>
</mapper>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.db1.dao.ArchiveMasterDao">
<select id="getMasterId" resultType="java.lang.String">
select ID from Archive_Master where patient_id=#{patientId} and visit_id=#{visitId}
</select>
</mapper>

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.db1.dao.ArchiveOtherDao">
<insert id="addArchiveOtherExt">
insert into archive_other_ext(ID, SycTime, SycObj, otherID, sysFlag, sysUpdateTime, jzh, stime, eTime,statusFlag,pResult,MID,C2)
values (#{id}, #{SycTime}, #{SycObj}, #{otherID}, #{sysFlag},
#{sysUpdateTime},#{jzh}, #{stime}, #{eTime}, #{statusFlag}, #{pResult}, #{MID}, #{C2})
</insert>
<update id="updateArchiveOtherExt">
update archive_other_ext
<set>
<if test="sysUpdateTime != null">
sysUpdateTime = #{sysUpdateTime},
</if>
<if test="stime != null">
stime = #{stime},
</if>
<if test="eTime != null">
eTime = #{eTime},
</if>
<if test="statusFlag != null">
statusFlag = #{statusFlag},
</if>
<if test="pResult != null">
pResult = #{pResult},
</if>
<if test="C1 != null">
C1 = #{C1},
</if>
<if test="DID != null">
DID = #{DID},
</if>
</set>
where C2 = #{C2}
</update>
<select id="getArchiveOtherExt" resultType="java.lang.String">
select ID from archive_other_ext where C2=#{C2}
</select>
<select id="getArchiveOtherExtAndTime" resultType="java.lang.String">
select ID from archive_other_ext where C2=#{C2} AND SycTime=#{SycTime}
</select>
</mapper>

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.db2.dao.MedicaRecordDao">
<select id="getMedicaRecord" resultType="com.example.vo.MedicaRecordVo">
SELECT id,medica_record as medicaRecord,Visit_id as visitId,patient_name as patientName,exportTime,pdfpath as pdfPath
FROM `v_select_medica_record`
WHERE medica_record is not null
AND visit_id is not null
AND exporttime >= DATE_ADD(NOW(), INTERVAL -6 HOUR)
AND exporttime &lt;= NOW()
</select>
</mapper>
Loading…
Cancel
Save