提交 bb04c140 authored 作者: 邓砥奕's avatar 邓砥奕

Initial commit

上级
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/
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
#!/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 "$@"
@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%
<?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.1.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>removetolocal</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>removetolocal</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.github.wenhao</groupId>
<artifactId>jpa-spec</artifactId>
<version>3.1.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.example.removetolocal;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class RemovetolocalApplication {
public static void main(String[] args) {
SpringApplication.run(RemovetolocalApplication.class, args);
}
}
package com.example.removetolocal.newdevice.dao;
import com.example.removetolocal.newdevice.domin.DeviceLibrary;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.Date;
import java.util.List;
/**
* @author dengdiyi
*/
@SuppressWarnings("SqlResolve")
public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>, JpaSpecificationExecutor<DeviceLibrary> {
DeviceLibrary findByOldId(Integer oldId);
List<DeviceLibrary> getAllByModel(String model);
List<DeviceLibrary> getAllByOwnUnit(String unit);
List<DeviceLibrary> getAllByTypeAndNameAndModel(Integer type, String name, String model);
/**
* 根据装备型号与装备所在地(多个地区)查询装备数量
*
* @param model 装备型号
* @param locations 装备所在地列表
* @return 装备数量
*/
int countByModelAndLocationUnitIn(String model, List<String> locations);
/**
* 根据装备型号与装备所在地(一个地区)查询装备数量
*
* @param model 装备型号
* @param location 装备所在地
* @return 装备数量
*/
int countByModelAndLocationUnit(String model, String location);
List<DeviceLibrary> getAllByPartParentIdAndIsPart(Integer parentId, Integer isPart);
List<DeviceLibrary> getAllByRfidCardId(String rfidCardId);
@Query(nativeQuery = true, value = "select * from device_library where id in :idList")
List<DeviceLibrary> getDeviceLibraryEntitiesByIdIn(@Param("idList") List<Integer> idList);
List<DeviceLibrary> getAllByRfidSurfaceId(String rfid);
@Query("select o from DeviceLibrary o where o.ownUnit= :unitName and o.createTime >= :startTime and o.createTime <= :endTime")
List<DeviceLibrary> findAllByUnitBetweenTime(String unitName, Date startTime, Date endTime);
List<DeviceLibrary> getAllByPackingId(Integer packingId);
}
package com.example.removetolocal.newdevice.dao;
import com.example.removetolocal.newdevice.domin.PackingLibrary;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
/**
* @author dengdiyi
*/
public interface PackingLibraryDao extends JpaRepository<PackingLibrary, Integer>, JpaSpecificationExecutor<PackingLibrary> {
List<PackingLibrary> findAllByPartParentId(Integer id);
PackingLibrary findByOldId(Integer oldId);
}
package com.example.removetolocal.newdevice.domin;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* entity class for device_library
* 装备库
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update device_library set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@Table(name = "device_library")
public class DeviceLibrary {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 入库单id
*/
@Column(name = "storage_bill_id")
private Integer storageBillId;
/**
* 列装id
*/
@Column(name = "packing_id")
private Integer packingId;
/**
* 是不是配件(0:不是,1:是)
*/
@Column(name = "is_part")
private Integer isPart;
/**
* 配件对应装备id
*/
@Column(name = "part_parent_id")
private Integer partParentId;
/**
* 型号
*/
private String model;
/**
* 密级
*/
@Column(name = "secret_level")
private Integer secretLevel;
/**
* 装备名称
*/
private String name;
/**
* 装备序列号
*/
@Column(name = "seq_number")
private String seqNumber;
/**
* 生产序列号
*/
@Column(name = "prod_number")
private String prodNumber;
/**
* rfid表面号
*/
@Column(name = "rfid_surface_id")
private String rfidSurfaceId;
/**
* rfid卡号
*/
@Column(name = "rfid_card_id")
private String rfidCardId;
/**
* 所在单位
*/
@Column(name = "location_unit")
private String locationUnit;
/**
* 所属单位
*/
@Column(name = "own_unit")
private String ownUnit;
/**
* 配用范围,1-省对下纵向
*/
@Column(name = "matching_range")
private Integer matchingRange;
/**
* 可见范围
*/
@Column(name = "invisible_range")
private Integer invisibleRange;
/**
* 类型
*/
private Integer type;
/**
* 入库类型,1-横向,2-纵向
*/
@Column(name = "storage_type")
private Integer storageType;
/**
* 管理状态,0-不再所属单位,1-在所属单位
*/
@Column(name = "manage_status")
private Integer manageStatus;
/**
* 生命状态,0-入库待审核,1-入库审核失败,2-在库,3-配发,4-维修,5,维修失败,6-退回,7-待退装,8-退装,9-待销毁,10-已销毁,11-丢失
*/
@Column(name = "life_status")
private Integer lifeStatus;
/**
* 锁定状态,0-未锁定可用,1-锁定不可用
*/
@Column(name = "lock_status")
private Integer lockStatus = 0;
/**
* 图片名称
*/
@Column(name = "image_name")
private String imageName;
/**
* 图片url地址
*/
@Column(name = "image_url")
private String imageUrl;
/**
* 货架位置
*/
private String position;
/**
* 创建用户id
*/
@CreatedBy
@Column(name = "create_user_id")
private Integer createUserId;
/**
* 创建时间
*/
@CreatedDate
@Column(name = "create_time")
private Date createTime;
/**
* 更新用户id
*/
@LastModifiedBy
@Column(name = "update_user_id")
private Integer updateUserId;
/**
* 更新时间
*/
@LastModifiedDate
@Column(name = "update_time")
private Date updateTime;
/**
* 删除标记(0:未删除,1:已删除)
*/
@Column(name = "delete_tag")
private Integer deleteTag = 0;
@Column(name = "record_id")
private String recordId;
@Column(name = "old_id")
private Integer oldId;
}
package com.example.removetolocal.newdevice.domin;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* entity class for packing_library
* 列装库
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update packing_library set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@Table(name = "packing_library")
public class PackingLibrary {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 经办人省A岗id
*/
@Column(name = "usera_id")
private Integer useraId;
/**
* 审核人省B岗id
*/
@Column(name = "userb_id")
private Integer userbId;
/**
* 是不是配件(0:不是,1:是)
*/
@Column(name = "is_part")
private Integer isPart;
@Column(name = "is_root")
private Integer isRoot;
@Column(name = "show_order")
private Integer showOrder;
private Integer style;
/**
* 配件对应装备列装id
*/
@Column(name = "part_parent_id")
private Integer partParentId;
/**
* 列装状态(0:待审核,1:审核失败,2:审核成功待确认,3:已列装,4:已退装)
*/
@Column(name = "packing_status")
private Integer packingStatus;
/**
* 型号
*/
private String model;
/**
* 密级
*/
@Column(name = "secret_level")
private Integer secretLevel;
/**
* 名称
*/
private String name;
/**
* 应用类型
*/
@Column(name = "apply_type")
private Integer applyType;
/**
* 配用范围
*/
@Column(name = "matching_range")
private Integer matchingRange;
/**
* 可见范围
*/
@Column(name = "invisible_range")
private Integer invisibleRange;
/**
* 形态
*/
private Integer type;
/**
* 列装性质
*/
private Integer nature;
/**
* 列装状态
*/
private Integer status;
/**
* 生产单位
*/
@Column(name = "prod_unit")
private String prodUnit;
/**
* 创建单位
*/
@Column(name = "create_unit")
private String createUnit;
/**
* 价格
*/
private String price;
/**
* 图片名称
*/
@Column(name = "image_name")
private String imageName;
/**
* 图片url地址
*/
@Column(name = "image_url")
private String imageUrl;
/**
* 附件名称
*/
@Column(name = "file_name")
private String fileName;
/**
* 附件url地址
*/
@Column(name = "file_url")
private String fileUrl;
/**
* 退装时间
*/
@Column(name = "exit_time")
private java.sql.Timestamp exitTime;
@Column(name = "record_id")
private String recordId;
/**
* 创建用户id
*/
@CreatedBy
@Column(name = "create_user_id")
private Integer createUserId;
/**
* 创建时间
*/
@CreatedDate
@Column(name = "create_time")
private Date createTime;
/**
* 更新用户id
*/
@LastModifiedBy
@Column(name = "update_user_id")
private Integer updateUserId;
/**
* 更新时间
*/
@LastModifiedDate
@Column(name = "update_time")
private Date updateTime;
/**
* 删除标记(0:未删除,1:已删除)
*/
@Column(name = "delete_tag")
private Integer deleteTag = 0;
/**
* 装备和配件对应关系 相同的是一套设备
*/
private Integer oldId;
}
package com.example.removetolocal.newuser.dao;
import com.example.removetolocal.newuser.domin.Area;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author zjm
* @version 1.0.0
* @ClassName AreaDao.java
* @Description TODO
* @createTime 2020年07月28日 10:01:00
*/
@Repository
public interface AreaDao extends JpaRepository<Area, Integer>, JpaSpecificationExecutor<Area> {
List<Area> findAllByFatherId(Integer areaId);
List<Area> findByFatherId(Integer fatherId);
List<Area> findAreasByType(Integer type);
@Query("select o.name from Area o where o.id=?1")
String findNameById(int id);
List<Area> findAllByTypeInOrderByTypeAsc(List<Integer> types);
}
package com.example.removetolocal.newuser.dao;
import com.example.removetolocal.newuser.domin.Mgrcert;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
@Repository
public interface MgrcertDao extends JpaRepository<Mgrcert, Integer>, JpaSpecificationExecutor<Mgrcert> {
Mgrcert findByUserId(Integer userId);
}
package com.example.removetolocal.newuser.dao;
import com.example.removetolocal.newuser.domin.Units;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface UnitsDao extends JpaRepository<Units, Integer>, JpaSpecificationExecutor<Units> {
List<Units> findAllByLevel(Integer level);
List<Units> findAllByAreaId(Integer areaId);
Units findByName(String unitName);
List<Units> findAllByLevelGreaterThanEqual(Integer level);
List<Units> findByAreaIdIn(List<Integer> areaIds);
List<Units> findAllByAreaIdIn(List<Integer> ids);
List<Units> findByAreaId(Integer area);
List<Units> findByIdDel(Integer idDel);
@Query("select o.areaId from Units o where o.name = ?1")
int findAreaIdByName(String unitName);
@Query("select o.areaId from Units o where o.unitId=?1")
int findAreaId(int id);
Units findByAreaIdAndLevel(Integer areaId, Integer level);
Units findByAreaIdEquals(Integer areaId);
List<Units> findAllByLevelIn(List<Integer> levels);
Units findByOldId(String oldId);
}
package com.example.removetolocal.newuser.dao;
import com.example.removetolocal.newuser.domin.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface UserDao extends JpaRepository<User, Integer>, JpaSpecificationExecutor<User> {
User findByUsername(String userName);
List<User> findAllByUnitsId(Integer unitsId);
List<User> findAllByUnitsIdIn(List<Integer> ids);
List<User> findAllByUserIdIn(List<Integer> userIds);
User findByOldCode(String code);
User findByOldId(String oldId);
}
package com.example.removetolocal.newuser.domin;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
/**
* @author zjm
* @version 1.0.0
* @ClassName Area.java
* @Description 地区
* @createTime 2020年07月28日 09:46:00
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
public class Area {
/**
* 区域id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 区域名称
*/
private String name;
/**
* 等级 等级 0国家级 1省级 2市级 3县级
*/
private Integer type;
/**
* 排序
*/
private String orders;
/**
* 父类id
*/
@Column(name = "father_id")
private Integer fatherId;
@Column(name = "old_id")
private String oldId;
// @Transient
// private List<Units> units;
}
package com.example.removetolocal.newuser.domin;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.Date;
/**
* @author zjm
* @version 1.0.0
* @ClassName Mgrcert.java
* @Description 证书
* @createTime 2020年08月06日 14:48:00
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
public class Mgrcert {
/**
* id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 持件人名称
*/
private String name;
/**
* 持件人id
*/
@Column(name = "user_id")
private Integer userId;
/**
* 证书编号
*/
@Column(name = "cert_num")
private Integer certNum = 123412312;
/**
* 颁发日期
*/
@Column(name = "cert_date")
private Date issueDate;
/**
* 失效日期
*/
@Column(name = "expiry_date")
private Date expiryDate;
/**
* 是否失效 默认0 1失效
*/
@Column(name = "is_expiry")
private Integer isExpiry;
/**
* 证书名称
*/
@Column(name = "cert_name")
private String certName;
@Column(name = "old_id")
private Integer oldId;
}
package com.example.removetolocal.newuser.domin;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
/**
* @author zjm
* @version 1.0.0
* @ClassName Units.java
* @Description 单位对象
* @createTime 2020年07月28日 09:23:00
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
public class Units {
/**
* 单位id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "unit_id")
// @GeneratedValue(generator="UserIdentityGenerator",strategy = GenerationType.AUTO)
// @GenericGenerator(name = "UserIdentityGenerator", strategy = "UserIdentityGenerator")
private Integer unitId;
/**
* 单位名称
*/
private String name;
/**
* 单位描述
*/
@Column(name = "unit_desc")
private String unitDesc;
/**
* 等级
*/
private Integer level;
/**
* 是否删除
*/
@Column(name = "id_del")
private Integer idDel;
/**
* 序列号
*/
private String code;
/**
* 区域id
*/
@Column(name = "area_id")
private Integer areaId;
@Column(name = "old_id")
private String oldId;
}
package com.example.removetolocal.newuser.domin;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
/**
* @author zjm
* @version 1.0.0
* @ClassName User.java
* @Description 用户对象
* @createTime 2020年07月27日 11:19:00
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
public class User {
/**
* 用户
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_id")
// @GeneratedValue(generator="UserIdentityGenerator",strategy = GenerationType.AUTO)
// @GenericGenerator(name = "UserIdentityGenerator", strategy = "UserIdentityGenerator")
private Integer userId;
/**
* 真实名称
*/
private String name;
/**
* 加密后密码
*/
private String password;
/**
* 未加密密码
*/
@Column(name = "no_password")
private String noPassword;
/**
* 用户名
*/
private String username;
/**
* 排序
*/
@Column(name = "show_order")
private Integer showOrder;
/**
* 移动电话
*/
private String mobile;
/**
* 机座
*/
private String telphone;
/**
* 邮箱
*/
private String email;
/**
* 真传
*/
private String fax;
/**
* 状态 默认0、1表示冻结
*/
@Column(name = "is_del")
private Integer isDel = 0;
/**
* 身份证
*/
@Column(name = "id_card")
private String idCard;
/**
* 性别
*/
private Integer sex;
/**
* 用户单位
*/
@Column(name = "units_id")
private Integer unitsId;
/**
* 职务
*/
private Integer position;
/**
* 培训状态 0.已培训 1.已过期 2.未培训 3.快过期
*/
@Column(name = "train_status")
private Integer trainStatus;
/**
* 单位对象
*/
@Column(name = "old_id")
private String oldId;
@Column(name = "old_code")
private String oldCode;
}
package com.example.removetolocal.olddevice.dao;
import com.example.removetolocal.olddevice.domin.DevCatalogEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface DevCatalogDao extends JpaRepository<DevCatalogEntity,Integer> {
}
package com.example.removetolocal.olddevice.dao;
import com.example.removetolocal.olddevice.domin.DevModelEntity;
import com.example.removetolocal.olduser.domin.DevManagerEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface DevModelDao extends JpaRepository<DevModelEntity,Integer> {
DevModelEntity findByModel(String model);
}
package com.example.removetolocal.olddevice.dao;
import com.example.removetolocal.olddevice.domin.DevRecordEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface DevRecordDao extends JpaRepository<DevRecordEntity,Integer> {
}
package com.example.removetolocal.olddevice.domin;
import lombok.Data;
import javax.persistence.*;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import java.util.Date;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
/**
* entity class for dev_catalog
* 设备目录表
*/
@Data
@Entity
@Table(name = "dev_catalog")
public class DevCatalogEntity {
/**
* id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Integer id;
/**
* pid
*/
@Column(name = "pid")
private Integer pid;
/**
* 型号
*/
@Column(name = "model")
private String model;
/**
* 代号
*/
@Column(name = "code")
private String code;
/**
* 配用范围
*/
@Column(name = "MatchingArea")
private Integer matchingArea;
/**
* 应用类型
*/
@Column(name = "appType")
private Integer appType;
/**
* 密级
*/
@Column(name = "Secretclass")
private Integer secretclass;
/**
* 列装日期
*/
@Column(name = "startDate")
private String startDate;
/**
* 退装日期
*/
@Column(name = "endDate")
private String endDate;
/**
* 类型
*/
@Column(name = "devType")
private Integer devType;
/**
* 形态
*/
@Column(name = "style")
private Integer style;
/**
* 单位
*/
@Column(name = "unit")
private Integer unit;
/**
* 单价
*/
@Column(name = "Price")
private Double price;
/**
* 列装性质
*/
@Column(name = "PackingProperty")
private Integer packingProperty;
/**
* 列装状态
*/
@Column(name = "status")
private Integer status;
/**
* 可见范围
*/
@Column(name = "VisibleRange")
private Integer visibleRange;
/**
* 1.型号目录。 0:具体列装
*/
@Column(name = "isModelDir")
private Integer isModelDir;
/**
* 生产单位
*/
@Column(name = "Production")
private String production;
/**
* 附件
*/
@Column(name = "annex")
private String annex;
/**
* 图片
*/
@Column(name = "img")
private String img;
/**
* 创建单位
*/
@Column(name = "createSup")
private String createSup;
/**
* 创建用户
*/
@Column(name = "createuser")
private String createuser;
/**
* 创建时间
*/
@Column(name = "createtime")
private java.util.Date createtime;
/**
* 更新用户
*/
@Column(name = "updateuser")
private String updateuser;
/**
* 更新时间
*/
@Column(name = "updatetime")
private java.util.Date updatetime;
}
package com.example.removetolocal.olddevice.domin;
import lombok.Data;
import javax.persistence.*;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import java.util.Date;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
/**
* entity class for dev_model
*/
@Data
@Entity
@Table(name = "dev_model")
public class DevModelEntity {
/**
* 主键
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Integer id;
/**
* 型号
*/
@Column(name = "model")
private String model;
/**
* 排序
*/
@Column(name = "showorder")
private Integer showorder;
/**
* createuser
*/
@Column(name = "createuser")
private String createuser;
/**
* createtime
*/
@Column(name = "createtime")
private java.util.Date createtime;
/**
* updateuser
*/
@Column(name = "updateuser")
private String updateuser;
/**
* updatetime
*/
@Column(name = "updatetime")
private java.util.Date updatetime;
/**
* secretclass
*/
@Column(name = "SECRETCLASS")
private Integer secretclass;
/**
* status
*/
@Column(name = "status")
private Integer status;
/**
* visibleRange
*/
@Column(name = "visibleRange")
private Integer visibleRange;
}
package com.example.removetolocal.olddevice.domin;
import lombok.Data;
import javax.persistence.*;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import java.util.Date;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
/**
* entity class for dev_record
* 设备档案
*/
@Data
@Entity
@Table(name = "dev_record")
public class DevRecordEntity {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Integer id;
/**
* 主键id
*/
@Column(name = "pid")
private Integer pid;
/**
* 列装设备id
*/
@Column(name = "catalogId")
private Integer catalogId;
/**
* model
*/
@Column(name = "model")
private String model;
/**
* 装备序列号
*/
@Column(name = "serNum")
private String serNum;
/**
* 生产序列号
*/
@Column(name = "proNum")
private String proNum;
/**
* 默认RFIDEPC区内容
*/
@Column(name = "rfid")
private String rfid;
/**
* 所在单位
*/
@Column(name = "whereUnit")
private String whereUnit;
/**
* 所属单位
*/
@Column(name = "ownUnit")
private String ownUnit;
/**
* 使用状态
*/
@Column(name = "useStatus")
private Integer useStatus;
/**
* 生命状态
*/
@Column(name = "lifeStatus")
private Integer lifeStatus;
/**
* instorageType
*/
@Column(name = "instorageType")
private Integer instorageType;
/**
* 是否苏定
*/
@Column(name = "islock")
private Integer islock;
/**
* 创建人
*/
@Column(name = "createUser")
private String createUser;
/**
* createTime
*/
@Column(name = "createTime")
private java.util.Date createTime;
/**
* updateUser
*/
@Column(name = "updateUser")
private String updateUser;
/**
* updateTime
*/
@Column(name = "updateTime")
private java.util.Date updateTime;
/**
* 备注
*/
@Column(name = "remark")
private String remark;
/**
* 逻辑删除标志
*/
@Column(name = "isDel")
private Integer isDel;
/**
* 锁定类型
*/
@Column(name = "lockType")
private Integer lockType;
}
package com.example.removetolocal.olduser.dao;
import com.example.removetolocal.olduser.domin.DevAreaEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface DevAreaDao extends JpaRepository<DevAreaEntity,String> {
DevAreaEntity findByPid(String pid);
List<DevAreaEntity> findAllByPid(String pid);
}
package com.example.removetolocal.olduser.dao;
import com.example.removetolocal.olduser.domin.DevManagerEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface DevManagerDao extends JpaRepository<DevManagerEntity,String> {
List<DevManagerEntity> findAllById(String id);
}
package com.example.removetolocal.olduser.dao;
import com.example.removetolocal.olduser.domin.DevMgrcertEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface DevMgrcertDao extends JpaRepository<DevMgrcertEntity,Integer> {
DevMgrcertEntity findByCertMgr(String s);
}
package com.example.removetolocal.olduser.dao;
import com.example.removetolocal.olduser.domin.SysCompanyEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface SysCompanyDao extends JpaRepository<SysCompanyEntity,String> {
List<SysCompanyEntity> findAllByAreaId(String areaId);
}
package com.example.removetolocal.olduser.dao;
import com.example.removetolocal.olduser.domin.SysUserEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface SysUserDao extends JpaRepository<SysUserEntity,String> {
List<SysUserEntity> findAllByCompanyId(String companyId);
}
package com.example.removetolocal.olduser.domin;
import lombok.AllArgsConstructor;
import lombok.Data;
import javax.persistence.*;
import lombok.NoArgsConstructor;
/**
* entity class for dev_area
*/
@Data
@Entity
@Table(name = "dev_area")
@NoArgsConstructor
@AllArgsConstructor
public class DevAreaEntity {
/**
* id
*/
@Id
private String id;
/**
* areaname
*/
@Column(name = "areaname")
private String areaname;
/**
* pid
*/
private String pid;
/**
* showorder
*/
@Column(name = "showorder", precision = 11, scale = 0)
private Double showorder;
/**
* 0 正常 1禁用
*/
private Integer status;
/**
* 拼音
*/
private String pinyin;
/**
* 等级 0国家级 1省级 2市级 3县级
*/
private Integer level;
}
package com.example.removetolocal.olduser.domin;
import lombok.AllArgsConstructor;
import lombok.Data;
import javax.persistence.*;
import lombok.NoArgsConstructor;
/**
* entity class for dev_manager
*/
@Data
@Entity
@Table(name = "dev_manager")
@NoArgsConstructor
@AllArgsConstructor
public class DevManagerEntity {
/**
* id
*/
@Id
private String id;
/**
* username
*/
private String username;
/**
* sex
*/
private Integer sex;
/**
* mobile
*/
private String mobile;
/**
* tel
*/
private String tel;
/**
* ownsup
*/
private String ownsup;
/**
* showorder
*/
@Column(name = "showorder", precision = 11, scale = 0)
private Double showorder;
/**
* 1: 启用 2:删除 0:禁用
*/
private Integer status;
/**
* 拼音
*/
private String pinyin;
/**
* lastEditTime
*/
@Column(name = "lastEditTime")
private java.util.Date lastEditTime;
/**
* createTime
*/
@Column(name = "createTime")
private java.util.Date createTime;
/**
* 是否锁住 0未锁 1已锁
*/
@Column(name = "isLock")
private Integer isLock;
/**
* 是否在任
*/
@Column(name = "isOffice")
private Integer isOffice;
/**
* 头像
*/
@Column(name = "miniHeadPic")
private String miniHeadPic;
}
package com.example.removetolocal.olduser.domin;
import lombok.AllArgsConstructor;
import lombok.Data;
import javax.persistence.*;
import lombok.NoArgsConstructor;
/**
* entity class for dev_mgrcert
* 证书管理
*/
@Data
@Entity
@Table(name = "dev_mgrcert")
@NoArgsConstructor
@AllArgsConstructor
public class DevMgrcertEntity {
/**
* id
*/
@Id
private Integer id;
/**
* 证书持有人
*/
@Column(name = "certMgr")
private String certMgr;
/**
* 证书编号
*/
@Column(name = "certNum")
private Integer certNum;
/**
* 颁发日期
*/
@Column(name = "issueDate")
private java.util.Date issueDate;
/**
* 失效日期
*/
@Column(name = "expiryDate")
private java.util.Date expiryDate;
/**
* 是否失效|0:否 1:是
*/
@Column(name = "isExpiry")
private Integer isExpiry;
/**
* 证书名称
*/
private String name;
}
package com.example.removetolocal.olduser.domin;
import lombok.AllArgsConstructor;
import lombok.Data;
import javax.persistence.*;
import lombok.NoArgsConstructor;
/**
* entity class for sys_company
*/
@Data
@Entity
@Table(name = "sys_company")
@NoArgsConstructor
@AllArgsConstructor
public class SysCompanyEntity {
/**
* companyId
*/
@Id
@Column(name = "companyId")
private String companyId;
/**
* companyName
*/
@Column(name = "companyName")
private String companyName;
/**
* 简称
*/
@Column(name = "companyDesc")
private String companyDesc;
/**
* pid
*/
private String pid;
/**
* level
*/
private Integer level;
/**
* showorder
*/
@Column(name = "showorder", precision = 11, scale = 0)
private Double showorder;
/**
* 拼音
*/
private String pinyin;
/**
* 默认为0, 1表示已经删除
*/
private Integer isdel;
/**
* 编号
*/
private String code;
/**
* 是否有系统 1有 2没有
*/
@Column(name = "isHaveSystem")
private Integer isHaveSystem;
/**
* areaId
*/
@Column(name = "areaId")
private String areaId;
}
package com.example.removetolocal.olduser.domin;
import lombok.AllArgsConstructor;
import lombok.Data;
import javax.persistence.*;
import lombok.NoArgsConstructor;
/**
* entity class for sys_user
*/
@Data
@Entity
@Table(name = "sys_user")
@NoArgsConstructor
@AllArgsConstructor
public class SysUserEntity {
/**
* userId
*/
@Id
@Column(name = "userId")
private String userId;
/**
* loginid
*/
private String loginid;
/**
* mPassword
*/
@Column(name = "mPassword")
private String mPassword;
/**
* loginIp
*/
@Column(name = "loginIp")
private String loginIp;
/**
* lastLoginTime
*/
@Column(name = "lastLoginTime")
private java.util.Date lastLoginTime;
/**
* userName
*/
@Column(name = "userName")
private String userName;
/**
* companyId
*/
@Column(name = "companyId")
private String companyId;
/**
* 排序号
*/
@Column(name = "showorder", precision = 11, scale = 0)
private Double showorder;
/**
* 移动电话
*/
private String mobile;
/**
* 机座
*/
private String telphone;
/**
* 邮箱
*/
private String email;
/**
* 真传
*/
private String fax;
/**
* 默认为0, 1表示已经删除
*/
private Integer isdel;
/**
* pinyin
*/
private String pinyin;
/**
* userType
*/
@Column(name = "userType")
private Integer userType;
/**
* 指纹信息
*/
@Column(name = "fingerprint")
private String fingerprint;
/**
* 人脸信息
*/
@Column(name = "faceinfo")
private String faceinfo;
/**
* 身份证号码
*/
@Column(name = "IDCARDNO")
private String idcardno;
/**
* 值班类型(1办报 2通信 3办报+通信)
*/
@Column(name = "LOGINtYPE")
private Integer logiNtYpe;
/**
* 性别 0:男 1:女
*/
private Integer sex;
/**
* 编号字段
*/
private String code;
/**
* 1寸照头像
*/
@Column(name = "miniHeadPic")
private String miniHeadPic;
}
package com.example.removetolocal.service;
public interface DeviceService {
/**
* 列装和装备库转换
*/
void deviceChange();
}
package com.example.removetolocal.service;
public interface UserService {
/**
* 区域、部门、用户
*/
void changeEntity();
}
package com.example.removetolocal.service.impl;
import com.example.removetolocal.newdevice.dao.DeviceLibraryDao;
import com.example.removetolocal.newdevice.dao.PackingLibraryDao;
import com.example.removetolocal.newdevice.domin.DeviceLibrary;
import com.example.removetolocal.newdevice.domin.PackingLibrary;
import com.example.removetolocal.newuser.dao.UnitsDao;
import com.example.removetolocal.newuser.dao.UserDao;
import com.example.removetolocal.olddevice.dao.DevCatalogDao;
import com.example.removetolocal.olddevice.dao.DevModelDao;
import com.example.removetolocal.olddevice.dao.DevRecordDao;
import com.example.removetolocal.olddevice.domin.DevCatalogEntity;
import com.example.removetolocal.olddevice.domin.DevRecordEntity;
import com.example.removetolocal.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.sql.Timestamp;
import java.util.List;
@Service
public class DeviceServiceImpl implements DeviceService {
@Autowired
PackingLibraryDao packingLibraryDao;
@Autowired
DeviceLibraryDao deviceLibraryDao;
@Autowired
DevCatalogDao devCatalogDao;
@Autowired
DevRecordDao devRecordDao;
@Autowired
UserDao userDao;
@Autowired
UnitsDao unitsDao;
@Autowired
DevModelDao devModelDao;
/**
* 列装和装备库转换
*/
@Override
public void deviceChange() {
//转换列装信息
List<DevCatalogEntity> devCatalogEntities = devCatalogDao.findAll();
devCatalogEntities.forEach(devCatalogEntity -> {
PackingLibrary packingLibrary = new PackingLibrary();
packingLibrary.setCreateTime(devCatalogEntity.getCreatetime());
packingLibrary.setUpdateTime(devCatalogEntity.getUpdatetime());
if (devCatalogEntity.getCreateuser() != null) {
if (userDao.findByOldCode(devCatalogEntity.getCreateuser()) != null || userDao.findByOldId(devCatalogEntity.getCreateuser()) != null) {
packingLibrary.setCreateUserId(userDao.findByOldCode(devCatalogEntity.getCreateuser()) == null ? userDao.findByOldId(devCatalogEntity.getCreateuser()).getUserId() : userDao.findByOldCode(devCatalogEntity.getCreateuser()).getUserId());
}
}
if (devCatalogEntity.getUpdateuser() != null) {
if (userDao.findByOldCode(devCatalogEntity.getUpdateuser()) != null || userDao.findByOldId(devCatalogEntity.getUpdateuser()) != null) {
packingLibrary.setUpdateUserId(userDao.findByOldCode(devCatalogEntity.getUpdateuser()) == null ? userDao.findByOldId(devCatalogEntity.getUpdateuser()).getUserId() : userDao.findByOldCode(devCatalogEntity.getUpdateuser()).getUserId());
}
}
if (devCatalogEntity.getEndDate() != null) {
packingLibrary.setExitTime(Timestamp.valueOf(devCatalogEntity.getEndDate() + " 00:00:00"));
}
packingLibrary.setPrice(String.valueOf(devCatalogEntity.getPrice()));
if (devCatalogEntity.getCreateSup() != null && unitsDao.findByOldId(devCatalogEntity.getCreateSup()) != null) {
packingLibrary.setCreateUnit(unitsDao.findByOldId(devCatalogEntity.getCreateSup()).getName());
}
packingLibrary.setProdUnit(devCatalogEntity.getProduction());
packingLibrary.setStatus(devCatalogEntity.getStatus());
packingLibrary.setNature(devCatalogEntity.getPackingProperty());
if (devCatalogEntity.getStyle()!=null) {
switch (devCatalogEntity.getStyle()) {
case 1:
packingLibrary.setType(7);
break;
case 2:
packingLibrary.setType(1);
break;
case 3:
packingLibrary.setType(2);
break;
case 4:
packingLibrary.setType(3);
break;
case 5:
packingLibrary.setType(8);
break;
case 6:
packingLibrary.setType(4);
break;
case 7:
packingLibrary.setType(5);
break;
case 8:
packingLibrary.setType(6);
break;
default:
packingLibrary.setType(devCatalogEntity.getStyle());
break;
}
}
if (devCatalogEntity.getVisibleRange()!=null) {
switch (devCatalogEntity.getVisibleRange()) {
case 1:
packingLibrary.setInvisibleRange(4);
break;
case 2:
packingLibrary.setInvisibleRange(1);
break;
case 3:
packingLibrary.setInvisibleRange(2);
break;
case 4:
packingLibrary.setInvisibleRange(3);
break;
default:
packingLibrary.setInvisibleRange(devCatalogEntity.getVisibleRange());
break;
}
}
if (devCatalogEntity.getMatchingArea()!=null) {
switch (devCatalogEntity.getMatchingArea()) {
case 1:
packingLibrary.setMatchingRange(2);
break;
case 2:
packingLibrary.setMatchingRange(1);
break;
case 3:
packingLibrary.setMatchingRange(2);
break;
case 4:
packingLibrary.setMatchingRange(5);
break;
case 5:
packingLibrary.setMatchingRange(4);
break;
default:
packingLibrary.setMatchingRange(devCatalogEntity.getMatchingArea());
break;
}
}
if (devCatalogEntity.getAppType()!=null) {
switch (devCatalogEntity.getAppType()) {
case 4:
packingLibrary.setApplyType(5);
break;
case 5:
packingLibrary.setApplyType(4);
break;
default:
packingLibrary.setApplyType(devCatalogEntity.getAppType());
break;
}
}
packingLibrary.setName(devCatalogEntity.getCode());
if (devCatalogEntity.getSecretclass()!=null) {
switch (devCatalogEntity.getSecretclass()) {
case 1:
packingLibrary.setSecretLevel(2);
break;
case 2:
packingLibrary.setSecretLevel(3);
break;
case 3:
packingLibrary.setSecretLevel(1);
break;
default:
packingLibrary.setSecretLevel(4);
break;
}
}
packingLibrary.setModel(devCatalogEntity.getModel());
if (devCatalogEntity.getEndDate() != null){
packingLibrary.setPackingStatus(4);
}
else {
packingLibrary.setPackingStatus(3);
}
packingLibrary.setStyle(devCatalogEntity.getDevType());
if (devCatalogEntity.getIsModelDir()==1) {
packingLibrary.setIsRoot(1);
if (devModelDao.findByModel(devCatalogEntity.getModel())!=null) {
packingLibrary.setShowOrder(devModelDao.findByModel(devCatalogEntity.getModel()).getShoworder());
}
}
else {
packingLibrary.setIsRoot(0);
if (devCatalogDao.findById(devCatalogEntity.getPid()).get().getIsModelDir()==1){
packingLibrary.setIsPart(0);
}
else {
packingLibrary.setIsPart(1);
}
}
packingLibrary.setOldId(devCatalogEntity.getId());
packingLibraryDao.save(packingLibrary);
});
List<PackingLibrary> packingLibraries = packingLibraryDao.findAll();
packingLibraries.forEach(packingLibrary -> {
DevCatalogEntity devCatalogEntity = devCatalogDao.findById(packingLibrary.getOldId()).get();
if (devCatalogEntity.getPid()!=null&&devCatalogEntity.getPid()>0){
packingLibrary.setPartParentId(packingLibraryDao.findByOldId(devCatalogEntity.getPid()).getId());
packingLibraryDao.save(packingLibrary);
}
});
//转换装备信息
List<DevRecordEntity> devRecordEntities = devRecordDao.findAll();
devRecordEntities.forEach(devRecordEntity -> {
//对应列装
PackingLibrary packingLibrary = packingLibraryDao.findByOldId(devRecordEntity.getPid());
DeviceLibrary deviceLibrary = new DeviceLibrary();
deviceLibrary.setCreateTime(devRecordEntity.getCreateTime());
deviceLibrary.setUpdateTime(devRecordEntity.getUpdateTime());
if (devRecordEntity.getCreateUser()!=null){
if (userDao.findByOldCode(devRecordEntity.getCreateUser()) != null || userDao.findByOldId(devRecordEntity.getCreateUser()) != null) {
deviceLibrary.setCreateUserId(userDao.findByOldCode(devRecordEntity.getCreateUser()) == null ? userDao.findByOldId(devRecordEntity.getCreateUser()).getUserId() : userDao.findByOldCode(devRecordEntity.getCreateUser()).getUserId());
}
}
if (devRecordEntity.getUpdateUser() != null) {
if (userDao.findByOldCode(devRecordEntity.getUpdateUser()) != null || userDao.findByOldId(devRecordEntity.getUpdateUser()) != null) {
deviceLibrary.setUpdateUserId(userDao.findByOldCode(devRecordEntity.getUpdateUser()) == null ? userDao.findByOldId(devRecordEntity.getUpdateUser()).getUserId() : userDao.findByOldCode(devRecordEntity.getUpdateUser()).getUserId());
}
}
deviceLibrary.setModel(devRecordEntity.getModel());
deviceLibrary.setPackingId(packingLibrary.getId());
deviceLibrary.setOldId(devRecordEntity.getId());
deviceLibrary.setIsPart(packingLibrary.getIsPart());
deviceLibrary.setSecretLevel(packingLibrary.getSecretLevel());
deviceLibrary.setName(packingLibrary.getName());
deviceLibrary.setSeqNumber(devRecordEntity.getSerNum());
deviceLibrary.setProdNumber(devRecordEntity.getProNum());
deviceLibrary.setRfidCardId(devRecordEntity.getRfid());
deviceLibrary.setRfidSurfaceId(makeRfidNumber(String.valueOf(packingLibrary.getType()),devRecordEntity.getSerNum(),devRecordEntity.getProNum(),devRecordEntity.getModel()));
if (devRecordEntity.getWhereUnit()!=null){
deviceLibrary.setLocationUnit(unitsDao.findByOldId(devRecordEntity.getWhereUnit()).getName());
}
if (devRecordEntity.getOwnUnit()!=null){
deviceLibrary.setOwnUnit(unitsDao.findByOldId(devRecordEntity.getOwnUnit()).getName());
}
deviceLibrary.setMatchingRange(packingLibrary.getMatchingRange());
deviceLibrary.setInvisibleRange(packingLibrary.getInvisibleRange());
deviceLibrary.setType(packingLibrary.getType());
if (devRecordEntity.getInstorageType()!=null) {
switch (devRecordEntity.getInstorageType()) {
case 1:
deviceLibrary.setStorageType(2);
break;
case 2:
deviceLibrary.setStorageType(1);
break;
case 3:
deviceLibrary.setStorageType(3);
break;
case 4:
deviceLibrary.setStorageType(5);
break;
case 5:
deviceLibrary.setStorageType(4);
break;
default:
deviceLibrary.setStorageType(5);
break;
}
}
if (devRecordEntity.getUseStatus()!=null) {
switch (devRecordEntity.getUseStatus()) {
case 1:
deviceLibrary.setManageStatus(1);
break;
case 2:
deviceLibrary.setManageStatus(0);
break;
case 3:
deviceLibrary.setManageStatus(0);
break;
default:
deviceLibrary.setManageStatus(1);
break;
}
}
if (devRecordEntity.getLifeStatus()!=null) {
switch (devRecordEntity.getLifeStatus()) {
case 1:
deviceLibrary.setLifeStatus(2);
break;
case 2:
deviceLibrary.setLifeStatus(4);
break;
case 3:
deviceLibrary.setLifeStatus(7);
break;
case 4:
deviceLibrary.setLifeStatus(10);
break;
case 5:
deviceLibrary.setLifeStatus(12);
break;
case 6:
deviceLibrary.setLifeStatus(11);
break;
default:
deviceLibrary.setLifeStatus(1);
break;
}
}
deviceLibrary.setLockStatus(devRecordEntity.getIslock());
deviceLibrary.setDeleteTag(devRecordEntity.getIsDel());
deviceLibraryDao.save(deviceLibrary);
});
List<DeviceLibrary> deviceLibraries = deviceLibraryDao.findAll();
deviceLibraries.forEach(deviceLibrary -> {
DevRecordEntity devRecordEntity = devRecordDao.findById(deviceLibrary.getOldId()).get();
if (devRecordEntity.getPid()!=null&&devRecordEntity.getPid()>0){
deviceLibrary.setPartParentId(deviceLibraryDao.findByOldId(devRecordEntity.getPid()).getId());
deviceLibraryDao.save(deviceLibrary);
}
});
}
/**
* 描述:生成装备的RFID表面号
*
* @param deviceType 装备类型 共10位
* @param partType 配件类型 主体为0 共1位
* @param deviceNumber 装备序列号 由用户填写
* @param produceNumber 生产序列号 用户填写
* @return 生成的RFID表面号
*/
public String makeRfidNumber(String partType, String deviceNumber, String produceNumber, String deviceType) {
//配件类型的长度只能为1
if (partType.length() > 1) {
throw new IllegalArgumentException("配件类型字段过长");
}
StringBuilder stringBuffer = new StringBuilder();
if (deviceType.length() <= 10) {
for (int i = 0; i < 10 - deviceType.length(); i++) {
stringBuffer.append("0");
}
stringBuffer.append(deviceType);
} else {
stringBuffer.append(deviceType.substring(deviceType.length() - 10));
}
stringBuffer.append("p");
stringBuffer.append(partType);
if (deviceNumber.length() < 4) {
for (int i = 0; i < 4 - deviceNumber.length(); i++) {
stringBuffer.append("0");
}
stringBuffer.append(deviceNumber);
} else {
stringBuffer.append(deviceNumber.substring(deviceNumber.length() - 4));
}
if (produceNumber.length() < 4) {
for (int i = 0; i < 4 - produceNumber.length(); i++) {
stringBuffer.append("0");
}
stringBuffer.append(produceNumber);
} else {
stringBuffer.append(produceNumber.substring(produceNumber.length() - 4));
}
return stringBuffer.toString();
}
}
package com.example.removetolocal.service.impl;
import com.example.removetolocal.newuser.dao.AreaDao;
import com.example.removetolocal.newuser.dao.MgrcertDao;
import com.example.removetolocal.newuser.dao.UnitsDao;
import com.example.removetolocal.newuser.dao.UserDao;
import com.example.removetolocal.newuser.domin.Area;
import com.example.removetolocal.newuser.domin.Mgrcert;
import com.example.removetolocal.newuser.domin.Units;
import com.example.removetolocal.newuser.domin.User;
import com.example.removetolocal.olduser.dao.*;
import com.example.removetolocal.olduser.domin.*;
import com.example.removetolocal.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public class UserServiceImpl implements UserService {
@Autowired
DevAreaDao devAreaDao;
@Autowired
DevManagerDao devManagerDao;
@Autowired
DevMgrcertDao devMgrcertDao;
@Autowired
SysCompanyDao sysCompanyDao;
@Autowired
SysUserDao sysUserDao;
@Autowired
UserDao userDao;
@Autowired
UnitsDao unitsDao;
@Autowired
MgrcertDao mgrcertDao;
@Autowired
AreaDao areaDao;
/**
* 区域、部门、用户
*/
@Override
public void changeEntity() {
//转换区域
//找到最高级
DevAreaEntity devAreaEntity = devAreaDao.findByPid("0");
//浙江省
DevAreaEntity devAreaEntity1 = devAreaDao.findByPid(devAreaEntity.getId());
Area area = new Area();
area.setName(devAreaEntity1.getAreaname());
area.setOrders(String.valueOf(devAreaEntity1.getShoworder()));
area.setOldId(devAreaEntity1.getId());
area.setType(devAreaEntity1.getLevel());
Area area1 = areaDao.save(area);
Integer fatherId = area1.getId();
changeUnitsByArea(devAreaEntity1.getId(),fatherId);
changeByFatherArea(devAreaEntity1.getId(),fatherId);
}
/**
* @param oldFatherId 旧表父类Id
* @param newFatherId 新表父类id
* 递归转换父类旗下所有区域
*/
void changeByFatherArea(String oldFatherId,Integer newFatherId){
List<DevAreaEntity> devAreaEntityList = devAreaDao.findAllByPid(oldFatherId);
if (devAreaEntityList.size()>0){
devAreaEntityList.forEach(areaEntity -> {
Area area2 = new Area();
area2.setName(areaEntity.getAreaname());
area2.setOrders(String.valueOf(areaEntity.getShoworder()));
area2.setOldId(areaEntity.getId());
area2.setType(areaEntity.getLevel());
area2.setFatherId(newFatherId);
Area area = areaDao.save(area2);
changeByFatherArea(areaEntity.getId(),area.getId());
changeUnitsByArea(areaEntity.getId(),area.getId());
});
}
}
/**
* @param oldAreaId 旧表区域Id
* @param newAreaId 新表区域Id
* 转换区域下所有单位
*/
void changeUnitsByArea(String oldAreaId,Integer newAreaId){
List<SysCompanyEntity> sysCompanyEntities = sysCompanyDao.findAllByAreaId(oldAreaId);
if (sysCompanyEntities.size()>0){
sysCompanyEntities.forEach(sysCompanyEntity -> {
Units units = new Units();
units.setName(sysCompanyEntity.getCompanyName());
units.setUnitDesc(sysCompanyEntity.getCompanyDesc());
units.setLevel(sysCompanyEntity.getLevel());
units.setIdDel(sysCompanyEntity.getIsdel());
units.setCode(sysCompanyEntity.getCode());
units.setOldId(sysCompanyEntity.getCompanyId());
if (sysCompanyEntity.getLevel()==2) {
units.setAreaId(newAreaId);
}
//区县
else if (sysCompanyEntity.getLevel()==3){
//添加新区域
Area area = new Area();
area.setType(3);
area.setOrders("1");
area.setFatherId(newAreaId);
area.setName(sysCompanyEntity.getCompanyName().substring(0,3));
Area area1 = areaDao.save(area);
units.setAreaId(area1.getId());
}
Units units1 = unitsDao.save(units);
changeUsersByUnit(sysCompanyEntity.getCompanyId(), units1.getUnitId());
});
}
}
/**
* @param oldUnitId 旧表单位Id
* @param newUnitId 新表单位Id
* 转换单位下所有专管员及证书
*/
void changeUsersByUnit(String oldUnitId,Integer newUnitId){
List<SysUserEntity> sysUserEntities = sysUserDao.findAllByCompanyId(oldUnitId);
if (sysUserEntities.size()>0){
sysUserEntities.forEach(sysUserEntity -> {
User user = new User();
List<DevManagerEntity> devManagerEntities = devManagerDao.findAllById(sysUserEntity.getCode());
if (sysUserEntity.getCode()!=null&&!devManagerEntities.isEmpty()){
DevManagerEntity devManagerEntity = devManagerEntities.get(0);
user.setName(sysUserEntity.getUserName());
user.setPassword("123456");
user.setNoPassword("123456");
user.setUsername(sysUserEntity.getLoginid());
user.setShowOrder(sysUserEntity.getShoworder().intValue());
user.setMobile(devManagerEntity.getMobile());
user.setTelphone(devManagerEntity.getTel());
user.setEmail(sysUserEntity.getEmail());
user.setFax(sysUserEntity.getFax());
user.setIsDel(sysUserEntity.getIsdel());
user.setIdCard(sysUserEntity.getIdcardno());
user.setSex(sysUserEntity.getSex());
user.setUnitsId(newUnitId);
user.setPosition(1);
user.setOldId(sysUserEntity.getUserId());
user.setOldCode(devManagerEntity.getId());
}
else {
user.setName(sysUserEntity.getUserName());
user.setPassword("123456");
user.setNoPassword("123456");
user.setUsername(sysUserEntity.getLoginid());
user.setShowOrder(sysUserEntity.getShoworder().intValue());
user.setMobile(sysUserEntity.getMobile());
user.setTelphone(sysUserEntity.getTelphone());
user.setEmail(sysUserEntity.getEmail());
user.setFax(sysUserEntity.getFax());
user.setIsDel(sysUserEntity.getIsdel());
user.setIdCard(sysUserEntity.getIdcardno());
user.setSex(sysUserEntity.getSex());
user.setUnitsId(newUnitId);
user.setPosition(1);
user.setOldId(sysUserEntity.getUserId());
user.setOldCode("0");
}
User user1 = userDao.save(user);
if (devMgrcertDao.findByCertMgr(String.valueOf(user1.getOldCode()))!=null&&devMgrcertDao.findByCertMgr(user1.getOldId())!=null){
DevMgrcertEntity devMgrcertEntity = devMgrcertDao.findByCertMgr(String.valueOf(user1.getOldCode()))==null?devMgrcertDao.findByCertMgr(user1.getOldId()):devMgrcertDao.findByCertMgr(String.valueOf(user1.getOldCode()));
user1.setTrainStatus(0);
userDao.save(user1);
Mgrcert mgrcert = new Mgrcert();
mgrcert.setCertName(devMgrcertEntity.getName());
mgrcert.setUserId(user1.getUserId());
mgrcert.setCertNum(devMgrcertEntity.getCertNum());
mgrcert.setIssueDate(devMgrcertEntity.getIssueDate());
mgrcert.setExpiryDate(devMgrcertEntity.getExpiryDate());
mgrcert.setIsExpiry(devMgrcertEntity.getIsExpiry());
mgrcert.setName(user1.getName());
mgrcert.setOldId(devMgrcertEntity.getId());
mgrcertDao.save(mgrcert);
}
});
}
}
}
package com.example.removetolocal.task;
import com.example.removetolocal.service.DeviceService;
import com.example.removetolocal.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class changeRun implements CommandLineRunner {
@Autowired
UserService userService;
@Autowired
DeviceService deviceService;
/**
* Callback used to run the bean.
*
* @param args incoming main method arguments
* @throws Exception on error
*/
@Override
public void run(String... args) throws Exception {
userService.changeEntity();
log.info("用户模块数据迁移完成");
deviceService.deviceChange();
log.info("zb模块数据迁移完成");
}
}
spring.datasource.url=jdbc:mysql://localhost:3306/old2?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=false
spring.jpa.open-in-view=true
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
package com.example.removetolocal;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class RemovetolocalApplicationTests {
@Test
void contextLoads() {
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论