commit 9c1d137fb0c6224e94b687e96256d851d7fa6c80 Author: ma <1062634917@qq.com> Date: Tue Oct 26 11:52:54 2021 +0800 yanyuan diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000..a45eb6b --- /dev/null +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,118 @@ +/* + * 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(); + } + +} diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..2cc7d4a Binary files /dev/null and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..a9f1ef8 --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/mvnw b/mvnw new file mode 100644 index 0000000..3c8a553 --- /dev/null +++ b/mvnw @@ -0,0 +1,322 @@ +#!/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 "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..1b24751 --- /dev/null +++ b/pom.xml @@ -0,0 +1,86 @@ + + + 4.0.0 + + ccsenscloud + com.ccsens + 1.0-SNAPSHOT + + + com.ccsens + + yanyuan + + 0.0.1-SNAPSHOT + + yanyuan + + Demo project for Spring Boot + + 1.8 + + + + + + cloudutil + com.ccsens + 1.0-SNAPSHOT + + + + common + com.ccsens + 1.0-SNAPSHOT + + + + com.ccsens + util + 1.0-SNAPSHOT + compile + + + + + + + + + org.mybatis.generator + mybatis-generator-maven-plugin + 1.3.7 + + ${basedir}/src/main/resources/mbg.xml + true + + + + mysql + mysql-connector-java + 5.1.34 + + + + + org.springframework.boot + spring-boot-maven-plugin + + com.ccsens.yanyuan.YanyuanApplication + + + + + + repackage + + + + + + + + + + diff --git a/src/main/java/com/ccsens/yanyuan/YanyuanApplication.java b/src/main/java/com/ccsens/yanyuan/YanyuanApplication.java new file mode 100644 index 0000000..f0c7dc8 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/YanyuanApplication.java @@ -0,0 +1,29 @@ +package com.ccsens.yanyuan; + +import com.ccsens.cloudutil.ribbon.RibbonConfiguration; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; +import org.springframework.scheduling.annotation.EnableAsync; + +@MapperScan(basePackages = {"com.ccsens.yanyuan.persist.*","com.ccsens.common.persist.*"}) +@ServletComponentScan +@EnableAsync +//开启断路器功能 +@EnableCircuitBreaker +@EnableFeignClients(basePackages = "com.ccsens.cloudutil.feign") +@SpringBootApplication +@ComponentScan(basePackages = "com.ccsens", excludeFilters = { @ComponentScan.Filter(type= FilterType.ASSIGNABLE_TYPE, value = RibbonConfiguration.class)}) + +public class YanyuanApplication { + + public static void main(String[] args) { + SpringApplication.run(YanyuanApplication.class, args); + } + +} diff --git a/src/main/java/com/ccsens/yanyuan/api/DebugController.java b/src/main/java/com/ccsens/yanyuan/api/DebugController.java new file mode 100644 index 0000000..9e8eb89 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/api/DebugController.java @@ -0,0 +1,29 @@ +package com.ccsens.yanyuan.api; + +import com.ccsens.util.JsonResponse; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; + +@Api(tags = "DEBUG" , description = "DebugController | ") +@RestController +@RequestMapping("/debug") +@Slf4j +public class DebugController { + + @ApiOperation(value = "/测试",notes = "") + @ApiImplicitParams({ + }) + @RequestMapping(value="",method = RequestMethod.GET,produces = {"application/json;charset=UTF-8"}) + public JsonResponse debug(HttpServletRequest request) throws Exception { + + return JsonResponse.newInstance().ok("测试"); + } + +} diff --git a/src/main/java/com/ccsens/yanyuan/api/PluginController.java b/src/main/java/com/ccsens/yanyuan/api/PluginController.java new file mode 100644 index 0000000..21c5d3b --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/api/PluginController.java @@ -0,0 +1,39 @@ +package com.ccsens.yanyuan.api; + +import com.ccsens.cloudutil.annotation.MustLogin; +import com.ccsens.common.bean.dto.CPluginDto; +import com.ccsens.common.service.IPluginService; +import com.ccsens.util.JsonResponse; +import com.ccsens.util.bean.dto.QueryDto; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author 逗 + */ +@Api(tags = "插件相关" , description = "DebugController | ") +@RestController +@RequestMapping("/plugin") +@Slf4j +public class PluginController { + @Resource + private IPluginService pluginService; + + @MustLogin + @ApiOperation(value = "给任务添加插件", notes = "") + @RequestMapping(value = "/save", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse queryPatientList(@ApiParam @Validated @RequestBody QueryDto> params) throws Exception{ + pluginService.updateTaskPlugin(params.getParam()); + return JsonResponse.newInstance().ok(); + } +} diff --git a/src/main/java/com/ccsens/yanyuan/api/PowerController.java b/src/main/java/com/ccsens/yanyuan/api/PowerController.java new file mode 100644 index 0000000..6aba675 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/api/PowerController.java @@ -0,0 +1,38 @@ +package com.ccsens.yanyuan.api; + +import com.ccsens.common.bean.dto.CProjectDto; +import com.ccsens.common.service.IPowerService; +import com.ccsens.util.JsonResponse; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * @author 逗 + */ +@Api(tags = "权限相关" , description = "") +@RestController +@RequestMapping("/power") +@Slf4j +public class PowerController { + + @Resource + private IPowerService powerService; + + + @ApiOperation(value = "查询用户在项目中的权限", notes = "") + @RequestMapping(value = "/query", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse queryPatientList(@ApiParam @Validated @RequestBody CProjectDto.QueryPower params) throws Exception{ + Integer power = powerService.queryUserPower(params.getProjectId(), params.getUserId()); + return JsonResponse.newInstance().ok(power); + } + +} diff --git a/src/main/java/com/ccsens/yanyuan/api/ProjectController.java b/src/main/java/com/ccsens/yanyuan/api/ProjectController.java new file mode 100644 index 0000000..1b742e3 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/api/ProjectController.java @@ -0,0 +1,66 @@ +package com.ccsens.yanyuan.api; + +import com.ccsens.common.bean.dto.CProjectDto; +import com.ccsens.common.bean.vo.CProjectVo; +import com.ccsens.common.service.IProjectService; +import com.ccsens.util.JsonResponse; +import com.ccsens.util.bean.dto.QueryDto; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author 逗 + */ +@Api(tags = "项目相关" , description = "DebugController | ") +@RestController +@RequestMapping("/project") +@Slf4j +public class ProjectController { + + @Resource + private IProjectService projectService; + + @ApiOperation(value = "根据id查询项目信息", notes = "根据id查询项目信息") + @RequestMapping(value = "/findProjectById", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse findProjectById(@ApiParam @Validated @RequestBody QueryDto params) throws Exception{ + CProjectVo.ProjectInfo projectById = projectService.findProjectById(params.getParam(), params.getUserId()); + return JsonResponse.newInstance().ok(projectById); + } + + @ApiOperation(value = "查询子项目", notes = "查询子项目") + @RequestMapping(value = "/findSonProject", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse> findSonProject(@ApiParam @Validated @RequestBody QueryDto params) throws Exception{ + log.info("查询子项目开始"); + List projectInfoList = projectService.findSonProject(params.getParam(), params.getUserId()); + log.info("查询子项目结束{}",projectInfoList); + return JsonResponse.newInstance().ok(projectInfoList); + } + + + @ApiOperation(value = "删除项目", notes = "删除项目") + @RequestMapping(value = "/deleteProject", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse deleteProject(@ApiParam @Validated @RequestBody QueryDto params) throws Exception{ + log.info("删除项目开始"); + projectService.deleteProjectById(params.getParam(), params.getUserId()); + log.info("删除项目结束"); + return JsonResponse.newInstance().ok(); + } + + @RequestMapping(value = "/tallDelProject", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse deleteProject(@ApiParam @Validated @RequestBody CProjectDto.ProjectById params) throws Exception{ + log.info("删除项目开始"); + projectService.deleteProjectById(params,null); + log.info("删除项目结束"); + return JsonResponse.newInstance().ok(); + } +} diff --git a/src/main/java/com/ccsens/yanyuan/api/RoleController.java b/src/main/java/com/ccsens/yanyuan/api/RoleController.java new file mode 100644 index 0000000..93155a6 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/api/RoleController.java @@ -0,0 +1,59 @@ +package com.ccsens.yanyuan.api; + +import com.ccsens.cloudutil.annotation.MustLogin; +import com.ccsens.common.bean.dto.CRoleDto; +import com.ccsens.common.bean.vo.CRoleVo; +import com.ccsens.common.service.IProRoleService; +import com.ccsens.util.JsonResponse; +import com.ccsens.util.bean.dto.QueryDto; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author 逗 + */ +@Api(tags = "角色相关" , description = "DebugController | ") +@RestController +@RequestMapping("/role") +@Slf4j +public class RoleController { + @Resource + private IProRoleService roleService; + + @MustLogin + @ApiOperation(value = "根据项目id查找角色", notes = "") + @RequestMapping(value = "/show", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse queryByProjectId(@ApiParam @Validated @RequestBody QueryDto params) { + CRoleVo.QueryRole queryRole = roleService.queryShowRole(params.getParam(), params.getUserId()); + return JsonResponse.newInstance().ok(queryRole); + } + + @MustLogin + @ApiOperation(value = "修改角色展示", notes = "") + @RequestMapping(value = "/updateShow", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse updateShow(@ApiParam @Validated @RequestBody QueryDto params) { + roleService.updateShowRole(params.getParam(),params.getUserId()); + return JsonResponse.newInstance().ok(); + } + + @MustLogin + @ApiOperation(value = "查询角色下的所有成员", notes = "") + @RequestMapping(value = "/queryMemberOfRole", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse> queryMemberOfRole(@ApiParam @Validated @RequestBody QueryDto params) { + log.info("查询角色下的所有成员开始{}",params); + List member = roleService.queryMemberOfRole(params.getParam(),params.getUserId()); + log.info("查询角色下的所有成员开始{}",params); + return JsonResponse.newInstance().ok(member); + } + +} diff --git a/src/main/java/com/ccsens/yanyuan/api/ShareController.java b/src/main/java/com/ccsens/yanyuan/api/ShareController.java new file mode 100644 index 0000000..4bbea2a --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/api/ShareController.java @@ -0,0 +1,48 @@ +package com.ccsens.yanyuan.api; + +import com.ccsens.cloudutil.annotation.MustLogin; +import com.ccsens.common.bean.dto.CShareDto; +import com.ccsens.common.bean.vo.CShareVo; +import com.ccsens.common.service.IShareService; +import com.ccsens.util.JsonResponse; +import com.ccsens.util.bean.dto.QueryDto; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * @author AUSU + */ +@Api(tags = "分享相关") +@RestController +@RequestMapping("/share") +@Slf4j +public class ShareController { + + @Resource + private IShareService shareService; + + @MustLogin + @ApiOperation(value = "创建分享连接", notes = "") + @RequestMapping(value = "/create", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse createShareUrl(@ApiParam @Validated @RequestBody QueryDto params) { + CShareVo.CreateShareUrl shareUrl = shareService.createShareUrl(params.getParam(), params.getUserId()); + return JsonResponse.newInstance().ok(shareUrl); + } + + @MustLogin + @ApiOperation(value = "点击分享连接", notes = "") + @RequestMapping(value = "/click", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse queryByProjectId(@ApiParam @Validated @RequestBody QueryDto params) { + CShareVo.ClickShareInfo clickShareInfo = shareService.clickShareUrl(params.getParam(), params.getUserId(),params.getUserName(),params.getPhone()); + return JsonResponse.newInstance().ok(clickShareInfo); + } +} diff --git a/src/main/java/com/ccsens/yanyuan/api/TaskController.java b/src/main/java/com/ccsens/yanyuan/api/TaskController.java new file mode 100644 index 0000000..8c80bc7 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/api/TaskController.java @@ -0,0 +1,91 @@ +package com.ccsens.yanyuan.api; + +import com.ccsens.cloudutil.annotation.MustLogin; +import com.ccsens.common.bean.dto.CTaskDto; +import com.ccsens.common.bean.vo.CTaskVo; +import com.ccsens.common.service.ITaskService; +import com.ccsens.util.JsonResponse; +import com.ccsens.util.bean.dto.QueryDto; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author 逗 + */ +@Api(tags = "任务相关" , description = "DebugController | ") +@RestController +@RequestMapping("/task") +@Slf4j +public class TaskController { + @Resource + private ITaskService taskService; + + @MustLogin + @ApiOperation(value = "查找永久日常任务", notes = "") + @RequestMapping(value = "/permanent", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse> queryPermanentGlobalTask(@ApiParam @Validated @RequestBody QueryDto params) { + List queryTasks = taskService.queryPermanentGlobalTask(params.getParam(), params.getUserId()); + return JsonResponse.newInstance().ok(queryTasks); + } + + @MustLogin + @ApiOperation(value = "查找带时间的日常任务", notes = "") + @RequestMapping(value = "/global", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse> queryGlobalTask(@ApiParam @Validated @RequestBody QueryDto params) { + List queryTasks = taskService.queryGlobalTask(params.getParam(), params.getUserId()); + return JsonResponse.newInstance().ok(queryTasks); + } + + @MustLogin + @ApiOperation(value = "查找定期任务", notes = "") + @RequestMapping(value = "/regular", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse> queryRegularTask(@ApiParam @Validated @RequestBody QueryDto params) { + List queryTasks = taskService.queryRegularTask(params.getParam(), params.getUserId()); + return JsonResponse.newInstance().ok(queryTasks); + } + + @MustLogin + @ApiOperation(value = "修改任务状态", notes = "") + @RequestMapping(value = "/type", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse updateTaskType(@ApiParam @Validated @RequestBody QueryDto params) throws Exception { + taskService.updateTaskType(params.getParam(),params.getUserId()); + return JsonResponse.newInstance().ok(); + } + + @ApiOperation(value = "查询子任务", notes = "") + @RequestMapping(value = "/findSonTask", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse> findSonTask(@ApiParam @Validated @RequestBody QueryDto params) throws Exception { + log.info("查询子任务开始"); + List sonTask = taskService.findSonTask(params.getParam(), params.getUserId()); + log.info("查询子任务开始{}",sonTask); + return JsonResponse.newInstance().ok(sonTask); + } + + @ApiOperation(value = "添加任务", notes = "") + @RequestMapping(value = "/save", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse> saveTask(@ApiParam @Validated @RequestBody QueryDto params) throws Exception { + log.info("添加任务开始"); + List taskList = taskService.saveTask(params.getParam(), params.getUserId()); + log.info("添加任务结束{}",taskList); + return JsonResponse.newInstance().ok(taskList); + } + + @ApiOperation(value = "查找项目下的任务", notes = "") + @RequestMapping(value = "/queryTaskOfProject", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse> queryTaskOfProject(@ApiParam @Validated @RequestBody QueryDto params) throws Exception { + log.info("查找项目下的任务开始{}",params); + List taskList = taskService.queryTaskOfProject(params.getParam(), params.getUserId()); + log.info("查找项目下的任务结束{}",taskList); + return JsonResponse.newInstance().ok(taskList); + } +} diff --git a/src/main/java/com/ccsens/yanyuan/api/UserController.java b/src/main/java/com/ccsens/yanyuan/api/UserController.java new file mode 100644 index 0000000..8b2e435 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/api/UserController.java @@ -0,0 +1,46 @@ +package com.ccsens.yanyuan.api; + +import com.ccsens.common.bean.dto.CMemberDto; +import com.ccsens.yanyuan.service.IUserService; +import com.ccsens.util.JsonResponse; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@Api(tags = "DEBUG" , description = "DebugController | ") +@RestController +@RequestMapping("/user") +@Slf4j +public class UserController { + @Resource + private IUserService userService; + + @ApiOperation(value = "根据手机号更新成员的userId",notes = "") + @ApiImplicitParams({ + }) + @RequestMapping(value="/memberWithPhone",method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"}) + public JsonResponse memberWithPhone(@ApiParam @Validated @RequestBody CMemberDto.PhoneAndUserId params) throws Exception { + log.info("根据手机号更新成员userId"); + userService.memberWithPhone(params); + return JsonResponse.newInstance().ok(); + } + + @ApiOperation(value = "合并用户后修改userId",notes = "") + @ApiImplicitParams({ + }) + @RequestMapping(value="/mergeUser",method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"}) + public JsonResponse mergeUser(@ApiParam @Validated @RequestBody CMemberDto.MergeUser params) throws Exception { + log.info("合并用户后修改userId"); + userService.mergeUser(params); + return JsonResponse.newInstance().ok(); + } +} diff --git a/src/main/java/com/ccsens/yanyuan/api/WbsController.java b/src/main/java/com/ccsens/yanyuan/api/WbsController.java new file mode 100644 index 0000000..d834177 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/api/WbsController.java @@ -0,0 +1,74 @@ +package com.ccsens.yanyuan.api; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; +import com.ccsens.yanyuan.util.BasicsConstant; +import com.ccsens.yanyuan.util.BasicsCodeError; +import com.ccsens.cloudutil.annotation.MustLogin; +import com.ccsens.yanyuan.bean.vo.ProjectVo; +import com.ccsens.yanyuan.service.IImportService; +import com.ccsens.util.JsonResponse; +import com.ccsens.util.WebConstant; +import com.ccsens.util.bean.dto.QueryDto; +import com.ccsens.util.exception.BaseException; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.io.File; +import java.util.Date; + +/** + * @author 逗 + */ +@Api(tags = "导入wbs" , description = "DebugController | ") +@RestController +@RequestMapping("/wbs") +@Slf4j +public class WbsController { + + @Resource + private IImportService importService; + + + + @MustLogin + @ApiOperation(value = "导入WBS",notes = "文件大小不能超过20M,支持后缀:.xls|.xlsx") + @ApiImplicitParams({ +// @ApiImplicitParam(name = "file", value = "WBS表", required = true, paramType = "form",dataType = "__file") + }) + @RequestMapping(value = "", method = RequestMethod.POST) + public JsonResponse importWbs(QueryDto params, Long projectId) throws Exception { + + MultipartFile f = params.getParam(); + String ext = FileUtil.extName(f.getOriginalFilename()); + if(StrUtil.isEmpty(ext) || !BasicsConstant.WbsExcel.WBS_FILE_FORMAT.contains(ext)){ + throw new BaseException(BasicsCodeError.FILE_FORMAT_ERROR); + } + //文件路径 + String dir = WebConstant.UPLOAD_PROJECT_WBS + File.separator; + String extraPath = DateUtil.format(new Date(), "yyyyMMdd"); + String path = extraPath + File.separator + IdUtil.simpleUUID() + "." + ext; + //转成file + File file = new File(dir + extraPath); + if (!file.exists()) { + file.mkdirs(); + } + String fullPath = dir + File.separator + path; + FileUtil.writeFromStream(f.getInputStream(), fullPath); + + //导入数据库 + ProjectVo.ProjectInfo projectInfo = importService.importWbs(fullPath,params.getUserId(),projectId); + + return JsonResponse.newInstance().ok(projectInfo); + } + +} diff --git a/src/main/java/com/ccsens/yanyuan/bean/dto/RoleDto.java b/src/main/java/com/ccsens/yanyuan/bean/dto/RoleDto.java new file mode 100644 index 0000000..6ef61bd --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/bean/dto/RoleDto.java @@ -0,0 +1,20 @@ +package com.ccsens.yanyuan.bean.dto; + +import lombok.Data; + +@Data +public class RoleDto { + + @Data + public static class WbsMember{ + //成员id + private Long id; + //userId + private Long userId; + + public WbsMember(Long id, Long userId) { + this.id = id; + this.userId = userId; + } + } +} diff --git a/src/main/java/com/ccsens/yanyuan/bean/dto/TaskDto.java b/src/main/java/com/ccsens/yanyuan/bean/dto/TaskDto.java new file mode 100644 index 0000000..008a8ae --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/bean/dto/TaskDto.java @@ -0,0 +1,29 @@ +package com.ccsens.yanyuan.bean.dto; + +import lombok.Data; + +/** + * @author 逗 + */ +@Data +public class TaskDto { + + /** + * 导入wbs--插件关联表id + */ + @Data + public static class TaskPluginId{ + private Long taskPluginId1; + private Long taskPluginId2; + private Long taskPluginId3; + + public TaskPluginId(Long id1, Long id2,Long id3) { + this.taskPluginId1 = id1; + this.taskPluginId2 = id2; + this.taskPluginId3 = id3; + } + + public TaskPluginId() { + } + } +} diff --git a/src/main/java/com/ccsens/yanyuan/bean/vo/ProjectVo.java b/src/main/java/com/ccsens/yanyuan/bean/vo/ProjectVo.java new file mode 100644 index 0000000..49d02d5 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/bean/vo/ProjectVo.java @@ -0,0 +1,60 @@ +package com.ccsens.yanyuan.bean.vo; + +import cn.hutool.core.util.ObjectUtil; +import com.ccsens.util.WebConstant; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author AUSU + */ +@Data +public class ProjectVo { + @Data + @ApiModel("项目信息defaultProject") + public static class ProjectInfo{ + @ApiModelProperty("id") + private Long id; + @ApiModelProperty("项目名") + private String name; + @ApiModelProperty("开始时间") + private Long startTime; + @ApiModelProperty("结束时间") + private Long endTime; + @ApiModelProperty("项目完成状态(0-未开始,1-进行中,2-暂停,3-已完成)") + private byte status; + @ApiModelProperty("访问路径)") + private String url; + + public Byte getStatus() { + long current = System.currentTimeMillis(); + if(ObjectUtil.isNull(getStartTime()) || ObjectUtil.isNull(getEndTime())) { + return null; + } + if(getStartTime() > current){ + this.status = (byte) WebConstant.EVENT_PROCESS.Pending.value; + }else if(getEndTime() < current){ + this.status = (byte) WebConstant.EVENT_PROCESS.Expired.value; + }else{ + this.status = (byte) WebConstant.EVENT_PROCESS.Processing.value; + } + return this.status; + } + + } + + @Data + public static class SysProject{ + @ApiModelProperty("项目id") + private Long id; + @ApiModelProperty("项目名称") + private String name; + @ApiModelProperty("开始时间") + private Long beginTime; + @ApiModelProperty("结束时间") + private Long endTime; + @ApiModelProperty("导入类型(0-第一次导入,1-修改WBS)") + private Byte importType = 0;; + } +} diff --git a/src/main/java/com/ccsens/yanyuan/config/BeanConfig.java b/src/main/java/com/ccsens/yanyuan/config/BeanConfig.java new file mode 100644 index 0000000..443d4e8 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/config/BeanConfig.java @@ -0,0 +1,22 @@ +package com.ccsens.yanyuan.config; + +import com.ccsens.yanyuan.intercept.MybatisInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/03 18:01 + */ +@Configuration +public class BeanConfig { + /** + * 注册拦截器 + */ + @Bean + public MybatisInterceptor mybatisInterceptor() { + MybatisInterceptor interceptor = new MybatisInterceptor(); + return interceptor; + } +} diff --git a/src/main/java/com/ccsens/yanyuan/config/SpringConfig.java b/src/main/java/com/ccsens/yanyuan/config/SpringConfig.java new file mode 100644 index 0000000..157152d --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/config/SpringConfig.java @@ -0,0 +1,126 @@ +package com.ccsens.yanyuan.config; + + +import cn.hutool.core.lang.Snowflake; +import cn.hutool.core.util.IdUtil; +import com.ccsens.util.config.DruidProps; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.StringHttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.servlet.config.annotation.*; + +import javax.annotation.Resource; +import javax.sql.DataSource; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; + +@Configuration +public class SpringConfig implements WebMvcConfigurer { + @Resource + private DruidProps druidPropsUtil; + @Value("${spring.snowflake.workerId}") + private String workerId; + @Value("${spring.snowflake.datacenterId}") + private String datacenterId; + + /** + * 配置Converter + * @return + */ + @Bean + public HttpMessageConverter responseStringConverter() { + StringHttpMessageConverter converter = new StringHttpMessageConverter( + Charset.forName("UTF-8")); + return converter; + } + + @Bean + public HttpMessageConverter responseJsonConverter(){ + MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); + List mediaTypeList = new ArrayList<>(); + mediaTypeList.add(MediaType.TEXT_HTML); + mediaTypeList.add(MediaType.APPLICATION_JSON_UTF8); + converter.setSupportedMediaTypes(mediaTypeList); + + ObjectMapper objectMapper = new ObjectMapper(); + SimpleModule simpleModule = new SimpleModule(); + simpleModule.addSerializer(Long.class, ToStringSerializer.instance); + simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); + objectMapper.registerModule(simpleModule); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + converter.setObjectMapper(objectMapper); + + return converter; + } + + @Override + public void configureMessageConverters(List> converters) { + converters.add(responseStringConverter()); + converters.add(responseJsonConverter()); + } + + @Override + public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { + configurer.favorPathExtension(false); + } + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**").allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") +// .allowedMethods("*") // 允许提交请求的方法,*表示全部允许 + .allowedOrigins("*") // #允许向该服务器提交请求的URI,*表示全部允许 + .allowCredentials(true) // 允许cookies跨域 + .allowedHeaders("*") // #允许访问的头信息,*表示全部 + .maxAge(18000L); // 预检请求的缓存时间(秒),即在这个时间段里,对于相同的跨域请求不会再预检了 + + } + + + + + /** + * 配置静态资源 + */ + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("swagger-ui.html") + .addResourceLocations("classpath:/META-INF/resources/"); + registry.addResourceHandler("/webjars/**") + .addResourceLocations("classpath:/META-INF/resources/webjars/"); + + registry.addResourceHandler("/uploads/**") + .addResourceLocations("file:///home/cloud/yanyuan/uploads/"); + } + + /** + * 配置拦截器 + * @param registry + */ + @Override + public void addInterceptors(InterceptorRegistry registry) { + + } + + + /** + * 配置数据源(单数据源) + */ + @Bean + public DataSource dataSource(){ + return druidPropsUtil.createDruidDataSource(); + } + + @Bean + public Snowflake snowflake(){ + return IdUtil.createSnowflake(Long.valueOf(workerId),Long.valueOf(datacenterId)); + } +} \ No newline at end of file diff --git a/src/main/java/com/ccsens/yanyuan/config/SwaggerConfigure.java b/src/main/java/com/ccsens/yanyuan/config/SwaggerConfigure.java new file mode 100644 index 0000000..1ed46d8 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/config/SwaggerConfigure.java @@ -0,0 +1,56 @@ +package com.ccsens.yanyuan.config; + +import com.ccsens.util.WebConstant; +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ParameterBuilder; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.schema.ModelRef; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Parameter; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import java.util.ArrayList; +import java.util.List; + +@Configuration +@EnableSwagger2 +@ConditionalOnExpression("${swagger.enable}") +//public class SwaggerConfigure extends WebMvcConfigurationSupport { +public class SwaggerConfigure /*implements WebMvcConfigurer*/ { + @Bean + public Docket customDocket() { + // + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors + .basePackage("com.ccsens.yanyuan.api")) + .build() + .globalOperationParameters(setHeaderToken()); + } + + private ApiInfo apiInfo() { + return new ApiInfo("Swagger Tall-game",//大标题 title + "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",//小标题 + "1.0.0",//版本 + "http://swagger.io/terms/",//termsOfServiceUrl + "zhangsan",//作者 + "Apache 2.0",//链接显示文字 + "http://www.apache.org/licenses/LICENSE-2.0.html"//网站链接 + ); + } + + private List setHeaderToken() { + ParameterBuilder tokenPar = new ParameterBuilder(); + List pars = new ArrayList<>(); + tokenPar.name(WebConstant.HEADER_KEY_TOKEN).description("token") + .defaultValue(WebConstant.HEADER_KEY_TOKEN_PREFIX) + .modelRef(new ModelRef("string")).parameterType("header").required(false).build(); + pars.add(tokenPar.build()); + return pars; + } +} diff --git a/src/main/java/com/ccsens/yanyuan/intercept/MybatisInterceptor.java b/src/main/java/com/ccsens/yanyuan/intercept/MybatisInterceptor.java new file mode 100644 index 0000000..0600fc9 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/intercept/MybatisInterceptor.java @@ -0,0 +1,159 @@ +package com.ccsens.yanyuan.intercept; + +import cn.hutool.core.collection.CollectionUtil; +import com.ccsens.util.WebConstant; +import org.apache.ibatis.executor.Executor; +import org.apache.ibatis.mapping.BoundSql; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.mapping.ResultMap; +import org.apache.ibatis.mapping.SqlSource; +import org.apache.ibatis.plugin.*; +import org.apache.ibatis.reflection.DefaultReflectorFactory; +import org.apache.ibatis.reflection.MetaObject; +import org.apache.ibatis.reflection.factory.DefaultObjectFactory; +import org.apache.ibatis.reflection.wrapper.DefaultObjectWrapperFactory; +import org.apache.ibatis.session.ResultHandler; +import org.apache.ibatis.session.RowBounds; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +/** + * @description: + * @author: wuHuiJuan + * @create: 2019/12/11 10:58 + */ +@Intercepts({ + @Signature( + type = Executor.class, + method = "query", + args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class} + ) +}) +public class MybatisInterceptor implements Interceptor { + @Override + public Object intercept(Invocation invocation) throws Throwable { + + + String selectByExample = "selectByExample"; + String countByExample = "countByExample"; + String countByExample2 = "selectByExample_COUNT"; + String selectByPrimaryKey = "selectByPrimaryKey"; + + Object[] args = invocation.getArgs(); + MappedStatement statement = (MappedStatement) args[0]; + if (statement.getId().endsWith(selectByExample) + || statement.getId().endsWith(countByExample) + || statement.getId().endsWith(countByExample2)) { + //XXXExample + Object example = args[1]; + + addCondition(statement, example); + + + + + } else if (statement.getId().endsWith(selectByPrimaryKey)) { + BoundSql boundSql = statement.getBoundSql(args[1]); + String sql = boundSql.getSql() + " and rec_status = 0"; + MappedStatement newStatement = newMappedStatement(statement, new BoundSqlSqlSource(boundSql)); + MetaObject msObject = MetaObject.forObject(newStatement, new DefaultObjectFactory(), new DefaultObjectWrapperFactory(),new DefaultReflectorFactory()); + msObject.setValue("sqlSource.boundSql.sql", sql); + args[0] = newStatement; + } + + return invocation.proceed(); + } + + private void addCondition(MappedStatement statement, Object example) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, ClassNotFoundException { + if (example instanceof Map) { + example = ((Map) example).get("_ORIGINAL_PARAMETER_OBJECT"); + } + + + Method method = example.getClass().getMethod("getOredCriteria", null); + //获取到条件数组,第一个是Criteria + List list = (List) method.invoke(example); + if (CollectionUtil.isEmpty(list)) { + Class clazz = ((ResultMap) statement.getResultMaps().get(0)).getType(); + String exampleName = clazz.getName() + "Example"; + Object paramExample = Class.forName(exampleName).newInstance(); + Method createCriteria = paramExample.getClass().getMethod("createCriteria"); + Object criteria = createCriteria.invoke(paramExample); + Method andIsDelEqualTo = criteria.getClass().getMethod("andRecStatusEqualTo", Byte.class); + andIsDelEqualTo.invoke(criteria, WebConstant.REC_STATUS.Normal.value); + list.add(criteria); + } else { + Object criteria = list.get(0); + Method getCriteria = criteria.getClass().getMethod("getCriteria"); + List params = (List) getCriteria.invoke(criteria); + boolean hasDel = false; + for (Object param : params) { + Method getCondition = param.getClass().getMethod("getCondition"); + Object condition = getCondition.invoke(param); + if ("rec_status =".equals(condition)) { + hasDel = true; + } + } + if (!hasDel) { + Method andIsDelEqualTo = criteria.getClass().getMethod("andRecStatusEqualTo", Byte.class); + andIsDelEqualTo.invoke(criteria, WebConstant.REC_STATUS.Normal.value); + } + + } + + } + + @Override + public Object plugin(Object target) { + return Plugin.wrap(target, this); + } + + @Override + public void setProperties(Properties properties) { + + } + + private MappedStatement newMappedStatement(MappedStatement ms, SqlSource newSqlSource) { + MappedStatement.Builder builder = + new MappedStatement.Builder(ms.getConfiguration(), ms.getId(), newSqlSource, ms.getSqlCommandType()); + builder.resource(ms.getResource()); + builder.fetchSize(ms.getFetchSize()); + builder.statementType(ms.getStatementType()); + builder.keyGenerator(ms.getKeyGenerator()); + if (ms.getKeyProperties() != null && ms.getKeyProperties().length != 0) { + StringBuilder keyProperties = new StringBuilder(); + for (String keyProperty : ms.getKeyProperties()) { + keyProperties.append(keyProperty).append(","); + } + keyProperties.delete(keyProperties.length() - 1, keyProperties.length()); + builder.keyProperty(keyProperties.toString()); + } + builder.timeout(ms.getTimeout()); + builder.parameterMap(ms.getParameterMap()); + builder.resultMaps(ms.getResultMaps()); + builder.resultSetType(ms.getResultSetType()); + builder.cache(ms.getCache()); + builder.flushCacheRequired(ms.isFlushCacheRequired()); + builder.useCache(ms.isUseCache()); + + return builder.build(); + } + + + // 定义一个内部辅助类,作用是包装sq + class BoundSqlSqlSource implements SqlSource { + private BoundSql boundSql; + public BoundSqlSqlSource(BoundSql boundSql) { + this.boundSql = boundSql; + } + @Override + public BoundSql getBoundSql(Object parameterObject) { + return boundSql; + } + } + +} diff --git a/src/main/java/com/ccsens/yanyuan/persist/dao/SPluginDao.java b/src/main/java/com/ccsens/yanyuan/persist/dao/SPluginDao.java new file mode 100644 index 0000000..a93f9d5 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/persist/dao/SPluginDao.java @@ -0,0 +1,12 @@ +package com.ccsens.yanyuan.persist.dao; + +import org.apache.ibatis.annotations.Param; + +/** + * @author 逗 + */ +public interface SPluginDao { + Long getPluginIdByName(@Param("pluginName") String pluginName); + + void updateParamById(@Param("param")String param,@Param("taskPluginId")Long taskPluginId); +} diff --git a/src/main/java/com/ccsens/yanyuan/persist/dao/SProjectDao.java b/src/main/java/com/ccsens/yanyuan/persist/dao/SProjectDao.java new file mode 100644 index 0000000..325434d --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/persist/dao/SProjectDao.java @@ -0,0 +1,29 @@ +package com.ccsens.yanyuan.persist.dao; + +import com.ccsens.yanyuan.bean.vo.ProjectVo; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * @author 逗 + */ +@Repository +public interface SProjectDao { + + List queryByCreator(@Param("userId") Long userId); + + /** + * 根据项目id查询项目 + * @param projectId 项目id + * @return 项目信息 + */ + ProjectVo.SysProject selectById(@Param("projectId") Long projectId); + + /** + * 逻辑删除项目 + * @param projectId 项目id + */ + void updateStatusById(@Param("projectId") Long projectId); +} diff --git a/src/main/java/com/ccsens/yanyuan/persist/dao/STaskDao.java b/src/main/java/com/ccsens/yanyuan/persist/dao/STaskDao.java new file mode 100644 index 0000000..a6a06a1 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/persist/dao/STaskDao.java @@ -0,0 +1,23 @@ +package com.ccsens.yanyuan.persist.dao; + +import com.ccsens.common.bean.po.ProTaskSub; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author 逗 + */ +public interface STaskDao { + + void insertSelectiveList(@Param("proTaskSubList") List proTaskSubList); + + /** + * 根据任务名和项目id查找当前时间下的任务的分解id + * @param taskName 任务名 + * @param projectId 项目id + * @param now 当前时间 + * @return 返回任务分解id + */ + Long getNowTask(@Param("taskName") String taskName, @Param("projectId") Long projectId, @Param("now") long now); +} diff --git a/src/main/java/com/ccsens/yanyuan/persist/dao/SubLabelDao.java b/src/main/java/com/ccsens/yanyuan/persist/dao/SubLabelDao.java new file mode 100644 index 0000000..3d06944 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/persist/dao/SubLabelDao.java @@ -0,0 +1,15 @@ +package com.ccsens.yanyuan.persist.dao; + +import com.ccsens.common.persist.dao.LabelDao; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +/** + * @author 逗 + */ +@Repository +public interface SubLabelDao extends LabelDao { + Long getLabelByName(@Param("type") int type, @Param("sysRole") String sysRole); + + Long getLabelByTypeAndLevel(@Param("type") int type, @Param("level") int level); +} diff --git a/src/main/java/com/ccsens/yanyuan/service/IImportService.java b/src/main/java/com/ccsens/yanyuan/service/IImportService.java new file mode 100644 index 0000000..a6f04e2 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/service/IImportService.java @@ -0,0 +1,18 @@ +package com.ccsens.yanyuan.service; + + +import com.ccsens.yanyuan.bean.vo.ProjectVo; + +/** + * @author 逗 + */ +public interface IImportService { + /** + * 读取excel + * @param path 路径 + * @param userId userId + * @throws Exception 异常 + */ + ProjectVo.ProjectInfo importWbs(String path, Long userId, Long projectId) throws Exception; + +} diff --git a/src/main/java/com/ccsens/yanyuan/service/IUserService.java b/src/main/java/com/ccsens/yanyuan/service/IUserService.java new file mode 100644 index 0000000..706a8d4 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/service/IUserService.java @@ -0,0 +1,17 @@ +package com.ccsens.yanyuan.service; + +import com.ccsens.common.bean.dto.CMemberDto; + +public interface IUserService { + /** + * 根据手机号修改成员的userId + * @param params 手机号和userId + */ + void memberWithPhone(CMemberDto.PhoneAndUserId params); + + /** + * 合并用户后修改userId + * @param params 新旧userId + */ + void mergeUser(CMemberDto.MergeUser params); +} diff --git a/src/main/java/com/ccsens/yanyuan/service/ImportService.java b/src/main/java/com/ccsens/yanyuan/service/ImportService.java new file mode 100644 index 0000000..ffb8a3e --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/service/ImportService.java @@ -0,0 +1,896 @@ +package com.ccsens.yanyuan.service; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.lang.Snowflake; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.ccsens.yanyuan.util.BasicsCodeError; +import com.ccsens.cloudutil.bean.tall.dto.ProjectDto; +import com.ccsens.cloudutil.feign.Tall3FeignClient; +import com.ccsens.common.bean.po.*; +import com.ccsens.common.persist.dao.*; +import com.ccsens.common.persist.mapper.ProMemberStakeholderMapper; +import com.ccsens.yanyuan.bean.dto.RoleDto; +import com.ccsens.yanyuan.bean.dto.TaskDto; +import com.ccsens.yanyuan.bean.vo.ProjectVo; +import com.ccsens.yanyuan.persist.dao.SPluginDao; +import com.ccsens.yanyuan.persist.dao.SProjectDao; +import com.ccsens.yanyuan.persist.dao.STaskDao; +import com.ccsens.yanyuan.persist.dao.SubLabelDao; +import com.ccsens.yanyuan.util.BasicsConstant; +import com.ccsens.util.ExcelUtil; +import com.ccsens.util.JsonResponse; +import com.ccsens.util.PropUtil; +import com.ccsens.util.StringUtil; +import com.ccsens.util.cron.CronConstant; +import com.ccsens.util.cron.NatureToDate; +import com.ccsens.util.exception.BaseException; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author 逗 + */ +@Slf4j +@Service +@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) +public class ImportService implements IImportService { + + @Resource + private Snowflake snowflake; + @Resource + private ProTaskDetailDao taskDetailDao; + @Resource + private ProTaskSubDao taskSubDao; + @Resource + private ProTaskVersionDao taskVersionMapper; + @Resource + private SubLabelDao subLabelDao; + @Resource + private LabelDao labelDao; + @Resource + private ProRoleDao roleDao; + @Resource + private ProMemberDao memberDao; + @Resource + private ProRoleMemberDao roleMemberDao; + @Resource + private ProMemberStakeholderMapper memberStakeholderMapper; + @Resource + private ProRoleRepulsionDao repulsionDao; + @Resource + private LabelBusinessDao labelBusinessDao; + @Resource + private ProParentTaskDao parentTaskMapper; + @Resource + private ProRoleTaskDao roleTaskMapper; + @Resource + private UserDao userDao; + @Resource + private SProjectDao projectDao; + @Resource + private STaskDao sTaskDao; + @Resource + private SPluginDao sTaskPluginDao; + @Resource + private ProTaskPluginDao proTaskPluginDao; + @Resource + private Tall3FeignClient tall3FeignClient; + + /** + * 读取wbs文件 + * @param path 路径 + * @param userId userId + * @throws Exception 异常 + */ + @Override + public ProjectVo.ProjectInfo importWbs(String path, Long userId,Long projectId) throws Exception { + ProjectVo.ProjectInfo projectInfo = new ProjectVo.ProjectInfo(); + //获取excel文件 + InputStream is = new FileInputStream(path); + XSSFWorkbook xssfWorkbook = new XSSFWorkbook(is); + //角色 + Map roleMap = new HashMap<>(); + //成员 + Map memberMap = new HashMap<>(); + //任务 + Map taskMap = new HashMap<>(); + + //读取文件 + readExcel(xssfWorkbook, userId, roleMap, memberMap, taskMap,projectId,projectInfo); + + //读取插件配置表 + readPluginConfig(xssfWorkbook,taskMap); + + return projectInfo; + } + + /** + * 读取插件配置表 + */ + private void readPluginConfig(XSSFWorkbook wb, Map taskMap) { + //获取插件配置表Sheet + XSSFSheet wbsSheet = wb.getSheet(BasicsConstant.WbsExcel.WBS_PLUGIN_CONFIG); + if (ObjectUtil.isNotNull(wbsSheet)) { + for (int i = 0; i <= wbsSheet.getLastRowNum(); i++) { + //获取行 + XSSFRow row = wbsSheet.getRow(i); + if (row == null) { + continue; + } + //序号 + String sequence = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(0))); + //任务名 + String taskName = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(1))); + if(StrUtil.isEmpty(taskName)){ + continue; + } + //插件1 + String pluginParam1 = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(2))); + //插件2 + String pluginParam2 = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(3))); + //插件3 + String pluginParam3 = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(4))); + Object o = taskMap.get(sequence + "_" + taskName); + if(ObjectUtil.isNull(o)){ + continue; + } + TaskDto.TaskPluginId taskPlugin = (TaskDto.TaskPluginId) o; + if(StrUtil.isNotEmpty(pluginParam1)){ + //修改插件表的param + sTaskPluginDao.updateParamById(pluginParam1,taskPlugin.getTaskPluginId1()); + } + if(StrUtil.isNotEmpty(pluginParam2)){ + //修改插件表的param + sTaskPluginDao.updateParamById(pluginParam2,taskPlugin.getTaskPluginId2()); + } + if(StrUtil.isNotEmpty(pluginParam3)){ + //修改插件表的param + sTaskPluginDao.updateParamById(pluginParam3,taskPlugin.getTaskPluginId3()); + } + } + } + } + + /** + * 读取每个sheet + */ + private void readExcel(XSSFWorkbook wb, Long userId, Map roleMap, Map memberMap, Map taskMap,Long projectId,ProjectVo.ProjectInfo projectInfo) { + //获取wbsSheet + XSSFSheet wbsSheet = wb.getSheet(BasicsConstant.WbsExcel.WBS_SHEET); + if (ObjectUtil.isNull(wbsSheet)) { + throw new BaseException(BasicsCodeError.NOT_WBS_SHEET); + } + //获取项目成员表 + XSSFSheet memberSheet = wb.getSheet(BasicsConstant.WbsExcel.MEMBER_SHEET); + if (ObjectUtil.isNull(memberSheet)) { + throw new BaseException(BasicsCodeError.NOT_MEMBER_SHEET); + } + //读取项目信息和任务分解信息的开始结束行 + int projectStart = 0; + int taskStart = 0; + for (int i = 0; i <= wbsSheet.getLastRowNum(); i++) { + //获取行 + XSSFRow xssfRow = wbsSheet.getRow(i); + if (xssfRow == null) { + continue; + } + //获取第一列 + XSSFCell xssfCell = xssfRow.getCell(0); + if (xssfCell == null) { + continue; + } + String s = ExcelUtil.getCellValue(xssfCell); + //获取项目开始行 + if (s.indexOf(BasicsConstant.WbsExcel.PROJECT_INFO_TITLE) == 0) { + projectStart = i + 1; + } + //获取任务开始行 + if (s.indexOf(BasicsConstant.WbsExcel.TASK_INFO_TITLE) == 0) { + taskStart = i + 1; + } + } + if (projectStart == 0) { + throw new BaseException(BasicsCodeError.WSB_NOT_PROJECT_HEADER); + } + if (taskStart == 0) { + throw new BaseException(BasicsCodeError.WSB_NOT_TASK_HEADER); + } + //添加项目 + ProjectVo.SysProject project = readProject(wbsSheet, projectStart, userId,projectId); + if(ObjectUtil.isNull(project)){ + throw new BaseException(BasicsCodeError.WSB_NOT_PROJECT_HEADER); + } + //读取成员表 + readMemberSheet(memberSheet,project,roleMap,memberMap); + //添加任务 + readTask(wbsSheet,taskStart,project,roleMap,taskMap); + //获取用户列表 + Set userIdSet = new HashSet<>(); + userIdSet.add(userId); + //处理创建人的权限问题(添加创建人角色) + //查找创建者标签id + Long roleLabelId = labelDao.getLabelByTypeAndLevel(5, 5); + //添加创建者角色 + ProRole role = new ProRole(); + role.setId(snowflake.nextId()); + role.setName("创建者"); + role.setProjectId(project.getId()); + role.setLabelId(roleLabelId); + roleDao.insertSelective(role); + //查找创建者在项目下的成员信息 + Long memberId = null; + if(CollectionUtil.isNotEmpty(memberMap)){ + for(RoleDto.WbsMember member : memberMap.values()){ + if(ObjectUtil.isNotNull(member.getUserId())){ + if(member.getUserId().equals(userId)){ + memberId = member.getId(); + } + userIdSet.add(member.getUserId()); + } + } + } + //如果当前用户不是项目成员,则添加为成员 + if(ObjectUtil.isNull(memberId)){ + //添加成员至数据库 + ProMember proMember = new ProMember(); + proMember.setId(snowflake.nextId()); + proMember.setProjectId(projectId); + proMember.setUserId(userId); + memberDao.insertSelective(proMember); + memberId = proMember.getId(); + } + //添加当前用户未创建者 + //添加角色成员关联信息 + ProRoleMember roleMember = new ProRoleMember(); + roleMember.setId(snowflake.nextId()); + roleMember.setRoleId(role.getId()); + roleMember.setMemberId(memberId); + roleMemberDao.insertSelective(roleMember); + + //TODO 在tall客户端添加项目和用户的关联信息 + ProjectDto.SaveProjectDto saveProjectDto = new ProjectDto.SaveProjectDto(); + saveProjectDto.setId(project.getId()); + saveProjectDto.setName(project.getName()); + saveProjectDto.setStartTime(project.getBeginTime()); + saveProjectDto.setEndTime(project.getEndTime()); + saveProjectDto.setUrl(PropUtil.domain); + + saveProjectDto.setUserIdList(userIdSet); + JsonResponse jsonResponse = tall3FeignClient.saveProjectList(saveProjectDto); + if (null == jsonResponse){ + throw new BaseException(BasicsCodeError.FEIGN_ERROR); + } + + //获取项目信息 + BeanUtil.copyProperties(saveProjectDto,projectInfo); + } + + /** + * 读取项目信息 + */ + private ProjectVo.SysProject readProject(XSSFSheet wbsSheet, int projectStart, Long userId,Long projectId) { + ProjectVo.SysProject project = new ProjectVo.SysProject(); + // TODO 查询是否项目是否存在 + if (ObjectUtil.isNotNull(projectId)) { + project = projectDao.selectById(projectId); + if (ObjectUtil.isNotNull(project)) { + project.setId(projectId); + project.setImportType((byte)1); + //删除之前的项目详情 + projectDao.updateStatusById(projectId); + //删除之前的项目分解 + ProTaskSubExample taskSubExample = new ProTaskSubExample(); + taskSubExample.createCriteria().andTaskDetailIdEqualTo(projectId); + ProTaskSub taskSub = new ProTaskSub(); + taskSub.setRecStatus((byte)2); + taskSubDao.updateByExampleSelective(taskSub,taskSubExample); + //删除之前的版本信息 + ProTaskVersion taskVersion = new ProTaskVersion(); + taskVersion.setRecStatus((byte)2); + ProTaskVersionExample taskVersionExample = new ProTaskVersionExample(); + taskVersionExample.createCriteria().andTaskDetailIdEqualTo(projectId); + taskVersionMapper.updateByExampleSelective(taskVersion,taskVersionExample); + //删除项目标签相关的 + LabelBusiness labelBusiness = new LabelBusiness(); + labelBusiness.setRecStatus((byte)2); + LabelBusinessExample labelBusinessExample = new LabelBusinessExample(); + labelBusinessExample.createCriteria().andBusinessIdEqualTo(projectId); + labelBusinessDao.updateByExampleSelective(labelBusiness,labelBusinessExample); + } + } + //获取项目信息的那一行 + XSSFRow row = wbsSheet.getRow(projectStart + 1); + if (ObjectUtil.isNull(row)) { + throw new BaseException(BasicsCodeError.WSB_NOT_PROJECT_HEADER); + } + //项目名 + String projectName = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(0))); + //详情 + String description = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(1))); + //项目时间 + String address = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(2))); + //开始时间 + String beginTime = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(3))); + //结束时间 + String endTime = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(4))); + //版本 + String version = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(5))); + if (StrUtil.isEmpty(projectName)) { + throw new BaseException(BasicsCodeError.WBS_NOT_PROJECT_NAME.addMsg(wbsSheet.getSheetName(),projectStart+1)); + } + //项目名不能重复(当前用户创建的项目内名字不能重复) + //根据userId查找已创建的项目 + List sysProjectList = projectDao.queryByCreator(userId); + if(CollectionUtil.isNotEmpty(sysProjectList)){ + sysProjectList.forEach(p -> { + if(projectName.equalsIgnoreCase(p.getName())){ + //如果名称重复则提示错误信息 + throw new BaseException(BasicsCodeError.PROJECT_NAME_REPEAT.addMsg(wbsSheet.getSheetName(),projectStart+1,projectName)); + } + }); + } + //判断时间是否正确 + String begin = ExcelUtil.getCellValue(row.getCell(3)); + String end = ExcelUtil.getCellValue(row.getCell(4)); + if (StrUtil.isEmpty(begin) || StrUtil.isEmpty(end)) { + throw new BaseException(BasicsCodeError.WBS_NOT_PROJECT_TIME.addMsg(wbsSheet.getSheetName(),projectStart+1)); + } + long bTime; + long eTime; + try { + bTime = Long.parseLong(beginTime); + eTime = Long.parseLong(endTime); + } catch (Exception e) { + //日期格式错误 + throw new BaseException(BasicsCodeError.WBS_PROJECT_TIME_ERROR.addMsg(wbsSheet.getSheetName(),projectStart+1)); + } + //添加项目信息(任务详情) + ProTaskDetail taskDetail = new ProTaskDetail(); + if (0 == project.getImportType()) { + taskDetail.setId(snowflake.nextId()); + } + if (1 == project.getImportType()) { + taskDetail.setId(projectId); + } + taskDetail.setName(projectName); + taskDetail.setDescription(description); + if (0 == project.getImportType()){ + taskDetailDao.insertSelective(taskDetail); + } + if (1 == project.getImportType()){ + taskDetailDao.updateByPrimaryKeySelective(taskDetail); + } + project.setId(taskDetail.getId()); + project.setName(projectName); + //添加(任务分解) + ProTaskSub taskSub = new ProTaskSub(); + taskSub.setId(snowflake.nextId()); + taskSub.setTaskDetailId(taskDetail.getId()); + taskSub.setPlanStartTime(bTime); + taskSub.setPlanEndTime(eTime); + taskSub.setPlanDuration(eTime - bTime); + taskSubDao.insertSelective(taskSub); + project.setBeginTime(bTime); + project.setEndTime(eTime); + //添加版本信息 + ProTaskVersion taskVersion = new ProTaskVersion(); + taskVersion.setId(snowflake.nextId()); + taskVersion.setTaskDetailId(taskDetail.getId()); + taskVersion.setTaskVersionInfo(version); + taskVersion.setAddress(address); + taskVersionMapper.insertSelective(taskVersion); + //查找项目标签 + Long labelId = labelDao.getLabelByTypeAndLevel(1, 0); + //添加任务标签关联信息 + saveLabelTask(taskDetail.getId(), labelId); + + return project; + } + + /** + * 添加任务标签关联 + */ + private void saveLabelTask(Long taskDetailId,Long labelId) { + //添加标签 + LabelBusiness labelBusiness = new LabelBusiness(); + labelBusiness.setId(snowflake.nextId()); + labelBusiness.setBusinessType((byte) 0); + labelBusiness.setBusinessId(taskDetailId); + labelBusiness.setLabelId(labelId); + labelBusinessDao.insertSelective(labelBusiness); + } + + /** + * 读取项目成员表 + */ + private void readMemberSheet(XSSFSheet memberSheet,ProjectVo.SysProject project, Map roleMap, Map memberMap) { + //系统角色id + Long sysRoleId = null; + //项目角色id + Long roleId = null; + //如果是修改WBS,先进行删除 + if (1 == project.getImportType()){ + //删除角色和成员 + List roleIdList = roleDao.queryRoleListOfProject(project.getId()); + ProRole role = new ProRole(); + role.setRecStatus((byte)2); + ProRoleExample roleExample = new ProRoleExample(); + roleExample.createCriteria().andIdIn(roleIdList); + roleDao.updateByExampleSelective(role,roleExample); + List memberIdList = memberDao.queryMembersOfProject(project.getId()); + ProMember member = new ProMember(); + member.setRecStatus((byte)2); + ProMemberExample memberExample = new ProMemberExample(); + memberExample.createCriteria().andIdIn(memberIdList); + memberDao.updateByExampleSelective(member,memberExample); + //删除奖惩干系人 + ProMemberStakeholder memberStakeholder = new ProMemberStakeholder(); + memberStakeholder.setRecStatus((byte)2); + ProMemberStakeholderExample memberStakeholderExample = new ProMemberStakeholderExample(); + memberStakeholderExample.createCriteria().andMemeberIdIn(memberIdList); + memberStakeholderMapper.updateByExampleSelective(memberStakeholder,memberStakeholderExample); + //删除对谁不可见 + ProRoleRepulsion roleRepulsion = new ProRoleRepulsion(); + roleRepulsion.setRecStatus((byte)2); + ProRoleRepulsionExample roleRepulsionExample = new ProRoleRepulsionExample(); + roleRepulsionExample.createCriteria().andRoleIdIn(roleIdList); + repulsionDao.updateByExampleSelective(roleRepulsion,roleRepulsionExample); + //删除角色成员关联 + ProRoleMember roleMember = new ProRoleMember(); + roleMember.setRecStatus((byte)2); + ProRoleMemberExample roleMemberExample = new ProRoleMemberExample(); + roleMemberExample.createCriteria().andRoleIdIn(roleIdList); + roleMemberDao.updateByExampleSelective(roleMember,roleMemberExample); + } + + for (int i = 2; i <= memberSheet.getLastRowNum(); i++) { + //获取当前行 + XSSFRow row = memberSheet.getRow(i); + if(ObjectUtil.isNull(row)){ continue; } + //系统角色名 + String sysRole = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(1))); + if(StrUtil.isEmpty(sysRole) && ObjectUtil.isNull(sysRoleId)){ + continue; + } + //验证系统角色(查询标签) + if(StrUtil.isNotEmpty(sysRole) && !"/".equalsIgnoreCase(sysRole)){ + Long labelId = subLabelDao.getLabelByName(5,sysRole); + if(ObjectUtil.isNull(labelId)){ + throw new BaseException(BasicsCodeError.WBS_NOT_FIRST_ROLE.addMsg(memberSheet.getSheetName(),i+1,sysRole)); + } + sysRoleId = labelId; + } + //项目角色 + String roleName = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(2))); + if((StrUtil.isEmpty(roleName) || "/".equalsIgnoreCase(roleName)) && ObjectUtil.isNull(roleId)){ continue; } + //成员 + String memberName = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(3))); + + //角色手机号 + String memberPhone = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(4))); + if((StrUtil.isNotEmpty(memberName) && !"/".equalsIgnoreCase(memberName)) && (StrUtil.isEmpty(memberPhone) || !memberPhone.matches(BasicsConstant.PHONE_REGEX))){ + throw new BaseException(BasicsCodeError.WBS_PHONE_ERROR.addMsg(memberSheet.getSheetName(),i+1,memberPhone)); + } + //奖惩干系人 + String stakeholderName = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(5))); + //干系人电话 + String stakeholderPhone = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(6))); + if((StrUtil.isNotEmpty(stakeholderName) && !"/".equalsIgnoreCase(stakeholderName)) && (StrUtil.isEmpty(stakeholderPhone) || !stakeholderPhone.matches(BasicsConstant.PHONE_REGEX))){ + throw new BaseException(BasicsCodeError.WBS_PHONE_ERROR.addMsg(memberSheet.getSheetName(),i+1,stakeholderName)); + } + //添加角色 + if(StrUtil.isNotEmpty(roleName) && !"/".equalsIgnoreCase(roleName)){ + ProRole role = new ProRole(); + role.setId(snowflake.nextId()); + role.setName(roleName); + role.setProjectId(project.getId()); + role.setLabelId(sysRoleId); + roleDao.insertSelective(role); + roleId = role.getId(); + roleMap.put(roleName,role.getId()); + } + //添加成员 + if(StrUtil.isNotEmpty(memberName) && !"/".equalsIgnoreCase(roleName)){ + //如果成员名和手机号重复当做一个人来处理 + RoleDto.WbsMember wbsMembers = memberMap.get(memberName + "_" + memberPhone); + Long memberId = null; + if(ObjectUtil.isNotNull(wbsMembers)){ + memberId = wbsMembers.getId(); + } + if(ObjectUtil.isNull(memberId)){ + //根据成员手机号查找userId 成员关联userId + Long userId = userDao.getUserIdByPhone(memberPhone); + //添加成员至数据库 + ProMember proMember = new ProMember(); + proMember.setId(snowflake.nextId()); + proMember.setName(memberName); + proMember.setPhone(memberPhone); + proMember.setProjectId(project.getId()); + proMember.setUserId(userId); + memberDao.insertSelective(proMember); + RoleDto.WbsMember member = new RoleDto.WbsMember(proMember.getId(),userId); + memberMap.put(memberName+"_"+memberPhone,member); + memberId = proMember.getId(); + } + //添加角色成员关联信息 + ProRoleMember roleMember = new ProRoleMember(); + roleMember.setId(snowflake.nextId()); + roleMember.setRoleId(roleId); + roleMember.setMemberId(memberId); + roleMemberDao.insertSelective(roleMember); + //添加奖惩干系人 + if(StrUtil.isNotEmpty(stakeholderName) && !"/".equalsIgnoreCase(roleName)){ + //根据干系人手机号查找userId 奖惩干系人关联userId + Long userId = userDao.getUserIdByPhone(memberPhone); + ProMemberStakeholder memberStakeholder = new ProMemberStakeholder(); + memberStakeholder.setId(snowflake.nextId()); + memberStakeholder.setMemeberId(memberId); + memberStakeholder.setStakeholderName(stakeholderName); + memberStakeholder.setStakeholderPhone(stakeholderPhone); + memberStakeholder.setUserId(userId); + memberStakeholderMapper.insertSelective(memberStakeholder); + } + } + } + //添加对谁不可见 + roleRepulsion(memberSheet, roleMap); + + } + + /** + * 处理对谁不可见 + */ + private void roleRepulsion(XSSFSheet memberSheet, Map roleMap) { + //角色排斥表需要的角色id + Long roleIdRepulsion = null; + for (int i = 2; i <= memberSheet.getLastRowNum(); i++) { + //获取当前行 + XSSFRow row = memberSheet.getRow(i); + if(ObjectUtil.isNull(row)){ continue; } + //项目角色 + String roleName = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(2))); + if(StrUtil.isNotEmpty(roleName)){ + roleIdRepulsion = roleMap.get(roleName); + } + if(ObjectUtil.isNull(roleIdRepulsion)){ + continue; + } + //对谁不可见 + String repulsion = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(7))); + if(StrUtil.isEmpty(repulsion)){ + continue; + } + //分解对谁不可见 + String[] split = repulsion.split(BasicsConstant.STRING_REGEX); + for (String repulsionName : split) { + Long repulsionId = roleMap.get(repulsionName); + if (ObjectUtil.isNull(repulsionId)) { + throw new BaseException(BasicsCodeError.WBS_NOT_FIND_ROLE.addMsg(memberSheet.getSheetName(),i+1,repulsionName)); + } + //添加数据 + ProRoleRepulsion roleRepulsion = new ProRoleRepulsion(); + roleRepulsion.setId(snowflake.nextId()); + roleRepulsion.setRoleId(roleIdRepulsion); + roleRepulsion.setRepulsionRoleId(repulsionId); + repulsionDao.insertSelective(roleRepulsion); + } + } + } + + /** + * 读取任务信息 + */ + private void readTask(XSSFSheet wbsSheet, int taskStart, ProjectVo.SysProject project, Map roleMap, Map taskMap) { + + //一级任务id + Long firstTaskId = null; + Long taskStartTime = project.getBeginTime(); + + //如果是修改WBS需要先删除 + if (1 == project.getImportType()) { + List allTaskId = parentTaskMapper.queryAllTaskIdByProjectId(project.getId()); + //删除所有的任务详情 + ProTaskDetail taskDetail = new ProTaskDetail(); + taskDetail.setRecStatus((byte)2); + ProTaskDetailExample taskDetailExample = new ProTaskDetailExample(); + taskDetailExample.createCriteria().andIdIn(allTaskId); + taskDetailDao.updateByExampleSelective(taskDetail,taskDetailExample); + //删除所有的分解任务 + ProTaskSub taskSub = new ProTaskSub(); + taskSub.setRecStatus((byte)2); + ProTaskSubExample taskSubExample = new ProTaskSubExample(); + taskSubExample.createCriteria().andTaskDetailIdIn(allTaskId); + taskSubDao.updateByExampleSelective(taskSub,taskSubExample); + //删除所有的任务标签 + LabelBusiness labelBusiness = new LabelBusiness(); + labelBusiness.setRecStatus((byte)2); + LabelBusinessExample labelBusinessExample = new LabelBusinessExample(); + labelBusinessExample.createCriteria().andBusinessIdIn(allTaskId); + labelBusinessDao.updateByExampleSelective(labelBusiness,labelBusinessExample); + //删除任务角色关联表 + ProRoleTask roleTask = new ProRoleTask(); + roleTask.setRecStatus((byte)2); + ProRoleTaskExample roleTaskExample = new ProRoleTaskExample(); + roleTaskExample.createCriteria().andTaskIdIn(allTaskId); + roleTaskMapper.updateByExampleSelective(roleTask,roleTaskExample); + //删除任务插件关联信息 + ProTaskPlugin taskPlugin = new ProTaskPlugin(); + taskPlugin.setRecStatus((byte)2); + ProTaskPluginExample taskPluginExample = new ProTaskPluginExample(); + taskPluginExample.createCriteria().andTaskDetailIdIn(allTaskId); + proTaskPluginDao.updateByExampleSelective(taskPlugin,taskPluginExample); + //删除任务关系表 + allTaskId.add(project.getId()); + ProParentTask parentTask = new ProParentTask(); + parentTask.setRecStatus((byte)2); + ProParentTaskExample parentTaskExample = new ProParentTaskExample(); + parentTaskExample.createCriteria().andTaskDetailIdIn(allTaskId); + parentTaskMapper.updateByExampleSelective(parentTask,parentTaskExample); + } + + for (int i = taskStart + 1; i <= wbsSheet.getLastRowNum(); i++) { + //获取当前行 + XSSFRow row = wbsSheet.getRow(i); + if(ObjectUtil.isNull(row)){ continue; } + //序号 + String sequence = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(0))); + //一级任务名 + String firstTaskName = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(1))); + if(StrUtil.isEmpty(firstTaskName) && ObjectUtil.isNull(firstTaskId)){ + continue; + } + if(StrUtil.isNotEmpty(firstTaskName)){ + //添加一级任务 + firstTaskId = saveFirstTask(project, firstTaskName); + } + //二级任务名 + String taskName = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(2))); + if(StrUtil.isEmpty(taskName)){ + continue; + } + //任务描述 + String description = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(3))); + //重要性标签 + String vitalLabel = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(7))); + //负责人 + String executorRole = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(8))); + //开始时间 + String beginTime = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(4))); + //结束时间 + String endTime = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(5))); + //时长 + String duration = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(6))); + //插件 + String plugin1 = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(12))); + String plugin2 = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(13))); + String plugin3 = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(14))); + if(StrUtil.isNotEmpty(taskName)){ + //添加二级任务信息(任务详情) + ProTaskDetail taskDetail = new ProTaskDetail(); + taskDetail.setId(snowflake.nextId()); + taskDetail.setName(taskName); + taskDetail.setDescription(description); + taskDetailDao.insertSelective(taskDetail); + //任务关联信息(关联一级任务) + ProParentTask parentTask = new ProParentTask(); + parentTask.setId(snowflake.nextId()); + parentTask.setTaskDetailId(taskDetail.getId()); + parentTask.setParentTaskDetailId(firstTaskId); + parentTaskMapper.insertSelective(parentTask); + //查找重要性标签 + Long labelId = subLabelDao.getLabelByName(2,vitalLabel); + if(ObjectUtil.isNull(labelId)){ + throw new BaseException(BasicsCodeError.TASK_VITAL_LABEL_ERROR.addMsg(wbsSheet.getSheetName(),i+1,vitalLabel)); + } + LabelBusiness labelBusiness = new LabelBusiness(); + labelBusiness.setId(snowflake.nextId()); + labelBusiness.setBusinessType((byte) 0); + labelBusiness.setBusinessId(taskDetail.getId()); + labelBusiness.setLabelId(labelId); + labelBusinessDao.insertSelective(labelBusiness); + //任务和角色关联 + if(StrUtil.isEmpty(executorRole)){ + throw new BaseException(BasicsCodeError.WBS_NOT_FIND_ROLE.addMsg(wbsSheet.getSheetName(),i+1,executorRole)); + } + String[] split = executorRole.split(BasicsConstant.STRING_REGEX); + for (String repulsionName : split) { + Long executorRoleId = roleMap.get(repulsionName); + if(ObjectUtil.isNull(executorRoleId)){ + throw new BaseException(BasicsCodeError.WBS_NOT_FIND_ROLE.addMsg(wbsSheet.getSheetName(),i+1,repulsionName)); + } + ProRoleTask roleTask = new ProRoleTask(); + roleTask.setId(snowflake.nextId()); + roleTask.setRoleId(executorRoleId); + roleTask.setTaskId(taskDetail.getId()); + roleTaskMapper.insertSelective(roleTask); + } + + //处理时间、添加任务分解、添加任务标签 + taskStartTime = taskSaveTime(taskStartTime, project, beginTime, endTime, duration, taskDetail.getId(),wbsSheet,i+1); + //添加时间颗粒度标签并关联 + Long timeLabel = labelDao.getLabelByTypeAndLevel(0, 4); + saveLabelTask(taskDetail.getId(),timeLabel); + //插件 + Long taskPlugin1 = plugin(plugin1,taskDetail.getId(),1,wbsSheet,i+1); + Long taskPlugin2 = plugin(plugin2,taskDetail.getId(),2,wbsSheet,i+1); + Long taskPlugin3 = plugin(plugin3,taskDetail.getId(),3,wbsSheet,i+1); + TaskDto.TaskPluginId taskPlugin = new TaskDto.TaskPluginId(taskPlugin1,taskPlugin2,taskPlugin3); + taskMap.put(sequence + "_" + taskName, taskPlugin); + } + //TODO 检查人 + //TODO 及时奖惩 + //TODO 交付物 + //TODO 添加默认插件 + } + } + private Long plugin(String plugin,Long taskId,int row,XSSFSheet wbsSheet,int errorRow) { + Long taskPlugin = null; + if(StrUtil.isNotEmpty(plugin)){ + //根据插件名称查找插件id + Long pluginId = sTaskPluginDao.getPluginIdByName(plugin); + if(ObjectUtil.isNull(pluginId)){ + throw new BaseException(BasicsCodeError.PLUGIN_NAME_ERROR.addMsg(wbsSheet.getSheetName(),errorRow,plugin)); + } + //添加插件 + ProTaskPlugin proTaskPlugin = new ProTaskPlugin(); + proTaskPlugin.setId(snowflake.nextId()); + proTaskPlugin.setTaskDetailId(taskId); + proTaskPlugin.setPluginId(pluginId); + proTaskPlugin.setPlginRow(row); + proTaskPlugin.setPlginCol(1); + proTaskPlugin.setRowspan(1); + proTaskPlugin.setColspan(1); + proTaskPluginDao.insertSelective(proTaskPlugin); + taskPlugin = proTaskPlugin.getId(); + } + return taskPlugin; + } + + private Long taskSaveTime(Long taskStartTime,ProjectVo.SysProject project, String beginTime, String endTime, String duration, Long taskDetailId,XSSFSheet wbsSheet,int row) { + + if(StrUtil.isEmpty(beginTime) || "日常".equalsIgnoreCase(beginTime)){ + if(StrUtil.isEmpty(beginTime) && StrUtil.isNotEmpty(duration)){ + //获取时长内的字符串 + String str = "[0-9]"; + Pattern pStr = Pattern.compile(str); + Matcher mStr = pStr.matcher(duration); + String trimStr = mStr.replaceAll("").trim(); + Long aLong = BasicsConstant.WBS_DURATION.get(trimStr); + if(ObjectUtil.isNull(aLong)){ + throw new BaseException(BasicsCodeError.WBS_PROJECT_TIME_ERROR.addMsg(wbsSheet.getSheetName(),row)); + } + //获取字符串内的数字 + String num = "[^0-9]"; + Pattern pNum = Pattern.compile(num); + Matcher mNum = pNum.matcher(duration); + String trimNum = mNum.replaceAll("").trim(); + //计算时长 + Long durationTime = Long.parseLong(trimNum) * aLong; + //添加任务分解 + ProTaskSub taskSub = new ProTaskSub(); + taskSub.setId(snowflake.nextId()); + taskSub.setTaskDetailId(taskDetailId); + taskSub.setPlanDuration(durationTime); + taskSub.setPlanStartTime(taskStartTime); + taskStartTime += durationTime; + taskSub.setPlanEndTime(taskStartTime); + taskSubDao.insertSelective(taskSub); + //查找定期任务标签并关联任务 + Long taskLabel = labelDao.getLabelByTypeAndLevel(1, 3); + saveLabelTask(taskDetailId,taskLabel); + + }else { + //添加任务分解 + ProTaskSub taskSub = new ProTaskSub(); + taskSub.setId(snowflake.nextId()); + taskSub.setTaskDetailId(taskDetailId); + taskSubDao.insertSelective(taskSub); + //查找日常任务标签并关联信息 + Long label = labelDao.getLabelByTypeAndLevel(1, 2); + saveLabelTask(taskDetailId,label); + } + }else { + Long bTime; + Long eTime; + try { + bTime = Long.parseLong(beginTime); + eTime = StrUtil.isEmpty(endTime) ? project.getEndTime() : Long.parseLong(endTime); + //添加任务分解 + ProTaskSub taskSub = new ProTaskSub(); + taskSub.setId(snowflake.nextId()); + taskSub.setTaskDetailId(taskDetailId); + taskSub.setPlanEndTime(eTime); + taskSub.setPlanStartTime(bTime); + taskSub.setPlanDuration(eTime - bTime); + taskSubDao.insertSelective(taskSub); + //查找定期任务标签并关联任务 + Long taskLabel = labelDao.getLabelByTypeAndLevel(1, 3); + saveLabelTask(taskDetailId,taskLabel); +// //添加时间颗粒度标签并关联 +// Long timeLabel = subLabelDao.getLabelByTypeAndLevel(0, 4); +// saveLabelTask(taskDetailId,timeLabel); + }catch (Exception e){ + Date startDate = new Date(project.getBeginTime()); + Date endDate = new Date(project.getEndTime()); + try { + List taskDateList = + NatureToDate.generateDates(beginTime, startDate, endDate); + if (CollectionUtil.isEmpty(taskDateList)) { + return taskStartTime; + } + List proTaskSubList = new ArrayList<>(); + for (CronConstant.TaskDate taskDate : taskDateList) { + + ProTaskSub proTaskSub = new ProTaskSub(); + proTaskSub.setId(snowflake.nextId()); + proTaskSub.setTaskDetailId(taskDetailId); + proTaskSub.setPlanStartTime(taskDate.getStartDate().getTime()); + proTaskSub.setPlanEndTime(taskDate.getEndDate().getTime()); + proTaskSub.setPlanDuration(proTaskSub.getPlanEndTime() - proTaskSub.getPlanStartTime()); + proTaskSubList.add(proTaskSub); + } + if(CollectionUtil.isNotEmpty(proTaskSubList)){ + sTaskDao.insertSelectiveList(proTaskSubList); + } + //查找定期任务标签并关联任务 + Long taskLabel = labelDao.getLabelByTypeAndLevel(1, 3); + saveLabelTask(taskDetailId,taskLabel); + }catch (Exception e1){ + throw new BaseException(String.valueOf(e1)); +// throw new BaseException(SportsCodeError.WBS_PROJECT_TIME_ERROR); + } + } + } + return taskStartTime; + } + + + /** + * 添加一级任务 + */ + private Long saveFirstTask(ProjectVo.SysProject project, String firstTaskName) { + //TODO 一级任务负责人是项目经理 + Long firstTaskId; + ProTaskDetail taskDetail = new ProTaskDetail(); + taskDetail.setId(snowflake.nextId()); + taskDetail.setName(firstTaskName); + taskDetailDao.insertSelective(taskDetail); + firstTaskId = taskDetail.getId(); + //添加任务分解 + ProTaskSub taskSub = new ProTaskSub(); + taskSub.setId(snowflake.nextId()); + taskSub.setTaskDetailId(taskDetail.getId()); + taskSub.setPlanStartTime(project.getBeginTime()); + taskSub.setPlanEndTime(project.getEndTime()); + taskSub.setPlanDuration(project.getEndTime() - project.getBeginTime()); + taskSubDao.insertSelective(taskSub); + //任务关联信息(关联项目) + ProParentTask parentTask = new ProParentTask(); + parentTask.setId(snowflake.nextId()); + parentTask.setTaskDetailId(taskDetail.getId()); + parentTask.setParentTaskDetailId(project.getId()); + parentTaskMapper.insertSelective(parentTask); + //查找一级任务标签 + Long labelId = labelDao.getLabelByTypeAndLevel(1, 1); + //添加任务标签关联信息 + saveLabelTask(taskDetail.getId(), labelId); + return firstTaskId; + } +} + + diff --git a/src/main/java/com/ccsens/yanyuan/service/UserService.java b/src/main/java/com/ccsens/yanyuan/service/UserService.java new file mode 100644 index 0000000..00383a7 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/service/UserService.java @@ -0,0 +1,33 @@ +package com.ccsens.yanyuan.service; + +import com.ccsens.common.bean.dto.CMemberDto; +import com.ccsens.common.service.IMemberService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; + +@Slf4j +@Service +@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) +public class UserService implements IUserService{ + + @Resource + private IMemberService memberService; + + @Override + public void memberWithPhone(CMemberDto.PhoneAndUserId params) { + memberService.relevancePhone(params); + } + + @Override + public void mergeUser(CMemberDto.MergeUser params) { + //最小项目关联的userId + memberService.mergeUser(params); + //TODO 其他业务 + } + + +} diff --git a/src/main/java/com/ccsens/yanyuan/util/BasicsCodeError.java b/src/main/java/com/ccsens/yanyuan/util/BasicsCodeError.java new file mode 100644 index 0000000..b6bbf77 --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/util/BasicsCodeError.java @@ -0,0 +1,42 @@ +package com.ccsens.yanyuan.util; + +import com.ccsens.util.CodeError; + +/** + * @author 逗 + */ +public class BasicsCodeError extends CodeError { + + public static final Code NOT_WBS_SHEET = new Code(501,"找不到wbs表",true); + public static final Code NOT_MEMBER_SHEET = new Code(502,"找不到项目成员表",true); + public static final Code WSB_NOT_PROJECT_HEADER = new Code(503,"读取项目信息异常",true); + public static final Code WSB_NOT_TASK_HEADER = new Code(504,"读取任务分解异常",true); + public static final Code WBS_PROJECT_TIME_ERROR = new Code(505,"时间格式异常", true); + public static final Code WBS_PHONE_ERROR = new Code(506,"手机号格式错误", true); + public static final Code WBS_NOT_FIRST_ROLE = new Code(507,"系统角色名称错误", true); + public static final Code WBS_NOT_FIND_ROLE = new Code(508,"未找到对应的角色", true); + public static final Code FILE_FORMAT_ERROR = new Code(509,"不支持的格式类型", true); + public static final Code WBS_NOT_PROJECT_TIME = new Code(510,"项目时间不能为空", true); + public static final Code TASK_VITAL_LABEL_ERROR = new Code(511,"任务标签异常", true); + public static final Code WBS_NOT_PROJECT_NAME = new Code(512,"项目名称不能为空", true); + public static final Code PROJECT_NAME_REPEAT = new Code(513,"项目名称重复", true); + public static final Code PLUGIN_NAME_ERROR = new Code(514,"请填写正确的插件名称", true); + public static final Code FEIGN_ERROR = new Code(515,"导入项目失败", true); + + public static final Code NOT_ORGANIZATION = new Code(516,"您不属于任何体育机构,请联系运维人员", true); + public static final Code NO_POWER = new Code(517,"权限不足", true); + public static final Code NOT_TRAINING_PLAN = new Code(518,"未找到培训计划", true); + public static final Code TRAINING_NOT_CHECK = new Code(519,"培训计划未审核通过", true); + public static final Code NOT_TRAINING_TEACHER = new Code(520,"未找到对应的委派通知", true); + public static final Code TRAINING_TEACHER_NOT_MINE = new Code(521,"您不是被委托人,无法接受", true); + public static final Code NOT_PLAYER = new Code(522,"未找到对应的运动员信息", true); + public static final Code NOT_PLAYER_APPLY = new Code(523,"未找到报名信息信息", true); + public static final Code ID_CODE_ERROR = new Code(524,"请输入正确的身份证", true); + public static final Code NOT_FILE = new Code(525,"找不到文件", true); + + + + + + +} diff --git a/src/main/java/com/ccsens/yanyuan/util/BasicsConstant.java b/src/main/java/com/ccsens/yanyuan/util/BasicsConstant.java new file mode 100644 index 0000000..71b43fb --- /dev/null +++ b/src/main/java/com/ccsens/yanyuan/util/BasicsConstant.java @@ -0,0 +1,50 @@ +package com.ccsens.yanyuan.util; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author 逗 + */ +public class BasicsConstant { + + /**图片类型*/ + public static final String FILE_TYPE_IMG = "bmp,jpg,jpeg,png,tif,gif,pcx,tga,exif,fpx,svg,psd,cdr,pcd,dxf,ufo,eps,ai,raw,WMF,webp"; + /**文档类型*/ + public static final String FILE_TYPE_DOCUMENT = "doc, dot, wps, wpt, docx, dotx, docm, dotm, xls, xlt, et, xlsx, xltx, csv, xlsm, xltm, ppt,pptx,pptm,ppsx,ppsm,pps,potx,potm,dpt,dps, pdf"; + + + /**验证手机正则*/ + public static final String PHONE_REGEX = "^[1]([3-9])[0-9]{9}$"; + /**字符串分隔符*/ + public static final String STRING_REGEX = ",|,|;|;|、|/"; + /**wbs相关*/ + public static final class WbsExcel { + /**wbsSheet*/ + public static final String WBS_SHEET = "WBS"; + /**项目成员Sheet*/ + public static final String MEMBER_SHEET = "项目成员表"; + /**项目信息头*/ + public static final String PROJECT_INFO_TITLE = "项目信息"; + /**任务信息头*/ + public static final String TASK_INFO_TITLE = "项目任务分解"; + /**excel文件格式验证*/ + public static final String WBS_FILE_FORMAT = "xls,xlsx"; + /**插件配置表*/ + public static final String WBS_PLUGIN_CONFIG = "插件配置表"; + } + + /**wbs表时长对应关系表*/ + public static final Map WBS_DURATION = new HashMap<>(); + static { + WBS_DURATION.put("s",1000L); + WBS_DURATION.put("min",60 * 1000L); + WBS_DURATION.put("h",60 * 60 * 1000L); + WBS_DURATION.put("d",24 * 60 * 60 * 1000L); + WBS_DURATION.put("w",7 * 24 * 60 * 60 * 1000L); + WBS_DURATION.put("m",30 * 24 * 60 * 60 * 1000L); + WBS_DURATION.put("y",365 * 24 * 60 * 60 * 1000L); + } + + +} diff --git a/src/main/resources/application-common.yml b/src/main/resources/application-common.yml new file mode 100644 index 0000000..7cedeec --- /dev/null +++ b/src/main/resources/application-common.yml @@ -0,0 +1,30 @@ +logging: + level: + com: + favorites: DEBUG + org: + hibernate: ERROR + springframework: + web: DEBUG +mybatis: + config-location: classpath:mybatis/mybatis-config.xml + mapper-locations: classpath*:mapper_*/*.xml +# type-aliases-package: com.ccsens.mtpro.bean +#server: +# tomcat: +# uri-encoding: UTF-8 +spring: + http: + encoding: + charset: UTF-8 + enabled: true + force: true + log-request-details: true + servlet: + multipart: + max-file-size: 10MB + max-request-size: 100MB + snowflake: + datacenterId: 2 + workerId: 2 + diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml new file mode 100644 index 0000000..ab34b7c --- /dev/null +++ b/src/main/resources/application-dev.yml @@ -0,0 +1,50 @@ +server: + port: 7260 + servlet: + context-path: +spring: + application: + name: yanyuan + datasource: + type: com.alibaba.druid.pool.DruidDataSource +# rabbitmq: +# host: 192.168.0.99 +# password: 111111 +# port: 5672 +# username: admin + rabbitmq: + host: 127.0.0.1 + password: guest + port: 5672 + username: guest + redis: + database: 0 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 + password: '' + port: 6379 + timeout: 1000ms +swagger: + enable: true +mybatisCache: + database: 1 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1 + min-idle: 0 + password: '' + port: 6379 + timeout: 1000 + +file: + path: /home/cloud/yanyuan/uploads/ + domain: https://test.tall.wiki/gateway/yanyuan + imgDomain: https://test.tall.wiki/gateway/yanyuan/uploads/ diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml new file mode 100644 index 0000000..8bf8dc7 --- /dev/null +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,40 @@ +server: + port: 7260 + servlet: + context-path: +spring: + application: + name: yanyuan + datasource: + type: com.alibaba.druid.pool.DruidDataSource + rabbitmq: + host: 121.36.3.207 + password: 111111 + port: 5672 + username: admin + redis: + database: 0 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 + password: '' +# password: 'areowqr!@43ef' + port: 6379 + timeout: 1000ms +swagger: + enable: true +eureka: + instance: + ip-address: 121.36.106.168 + +gatewayUrl: https://www.tall.wiki/gateway/ +notGatewayUrl: https://www.tall.wiki/ +apiUrl: https://www.tall.wiki/ +file: + path: /home/cloud/yanyuan/uploads/ + domain: https://www.tall.wiki/gateway/yanyuan + imgDomain: https://www.tall.wiki/gateway/yanyuan/uploads/ diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml new file mode 100644 index 0000000..53c1f23 --- /dev/null +++ b/src/main/resources/application-test.yml @@ -0,0 +1,48 @@ +server: + port: 7260 + servlet: + context-path: +spring: + application: + name: yanyuan + datasource: + type: com.alibaba.druid.pool.DruidDataSource + rabbitmq: + host: dd.tall.wiki + password: 111111 + port: 5672 + username: admin + redis: + database: 0 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1ms + min-idle: 0 + password: '' + port: 6379 + timeout: 1000ms +swagger: + enable: true +mybatisCache: + database: 1 + host: 127.0.0.1 + jedis: + pool: + max-active: 200 + max-idle: 10 + max-wait: -1 + min-idle: 0 + password: '' + port: 6379 + timeout: 1000 +eureka: + instance: + ip-address: 127.0.0.1 + +file: + path: /home/cloud/yanyuan/uploads/ + domain: https://test.tall.wiki/gateway/yanyuan + imgDomain: https://test.tall.wiki/gateway/yanyuan/uploads/ diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..2fb38e5 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,4 @@ +spring: + profiles: + active: dev + include: common, util-dev diff --git a/src/main/resources/druid-dev.yml b/src/main/resources/druid-dev.yml new file mode 100644 index 0000000..0e658fd --- /dev/null +++ b/src/main/resources/druid-dev.yml @@ -0,0 +1,37 @@ +spring: + datasource: + druid: + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + driverClassName: com.mysql.cj.jdbc.Driver + dynamicUrl: jdbc:mysql://localhost:3306/${schema} + filterExclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' + filterName: druidFilter + filterProfileEnable: true + filterUrlPattern: /* + filters: stat,wall + initialSize: 5 + maxActive: 20 + maxPoolPreparedStatementPerConnectionSize: 20 + maxWait: 60000 + minEvictableIdleTimeMillis: 300000 + minIdle: 5 +# password: 37080c1f223685592316b02dad8816c019290a476e54ebb638f9aa3ba8b6bdb9 + password: 68073a279b399baa1fa12cf39bfbb65bfc1480ffee7b659ccc81cf19be8c4473 + poolPreparedStatements: true + servletLogSlowSql: true + servletLoginPassword: 111111 + servletLoginUsername: druid + servletName: druidServlet + servletResetEnable: true + servletUrlMapping: /druid/* + testOnBorrow: false + testOnReturn: false + testWhileIdle: true + timeBetweenEvictionRunsMillis: 60000 + url: jdbc:mysql://49.233.89.188:3306/defaultwbs?useUnicode=true&characterEncoding=UTF-8 +# url: jdbc:mysql://www.tall.wiki/defaultwbs?useUnicode=true&characterEncoding=UTF-8 +# url: jdbc:mysql://127.0.0.1/mt?useUnicode=true&characterEncoding=UTF-8 + username: root + validationQuery: SELECT 1 FROM DUAL +# env: CCSENS_GAME + env: CCSENS_TALL \ No newline at end of file diff --git a/src/main/resources/druid-prod.yml b/src/main/resources/druid-prod.yml new file mode 100644 index 0000000..38da4d9 --- /dev/null +++ b/src/main/resources/druid-prod.yml @@ -0,0 +1,35 @@ +spring: + datasource: + druid: + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + driverClassName: com.mysql.cj.jdbc.Driver + dynamicUrl: jdbc:mysql://localhost:3306/${schema} + filterExclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' + filterName: druidFilter + filterProfileEnable: true + filterUrlPattern: /* + filters: stat,wall + initialSize: 5 + maxActive: 20 + maxPoolPreparedStatementPerConnectionSize: 20 + maxWait: 60000 + minEvictableIdleTimeMillis: 300000 + minIdle: 5 +# password: + password: 68073a279b399baa1fa12cf39bfbb65bfc1480ffee7b659ccc81cf19be8c4473 + poolPreparedStatements: true + servletLogSlowSql: true + servletLoginPassword: 111111 + servletLoginUsername: druid + servletName: druidServlet + servletResetEnable: true + servletUrlMapping: /druid/* + testOnBorrow: false + testOnReturn: false + testWhileIdle: true + timeBetweenEvictionRunsMillis: 60000 +# url: jdbc:mysql://127.0.0.1/defaultwbs?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true + url: jdbc:mysql://www.tall.wiki/yanyuan?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true + username: root + validationQuery: SELECT 1 FROM DUAL + env: CCSENS_TALL \ No newline at end of file diff --git a/src/main/resources/druid-test.yml b/src/main/resources/druid-test.yml new file mode 100644 index 0000000..32df6c6 --- /dev/null +++ b/src/main/resources/druid-test.yml @@ -0,0 +1,33 @@ +spring: + datasource: + druid: + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + driverClassName: com.mysql.cj.jdbc.Driver + dynamicUrl: jdbc:mysql://localhost:3306/${schema} + filterExclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*' + filterName: druidFilter + filterProfileEnable: true + filterUrlPattern: /* + filters: stat,wall + initialSize: 5 + maxActive: 20 + maxPoolPreparedStatementPerConnectionSize: 20 + maxWait: 60000 + minEvictableIdleTimeMillis: 300000 + minIdle: 5 + password: 68073a279b399baa1fa12cf39bfbb65bfc1480ffee7b659ccc81cf19be8c4473 + poolPreparedStatements: true + servletLogSlowSql: true + servletLoginPassword: 111111 + servletLoginUsername: druid + servletName: druidServlet + servletResetEnable: true + servletUrlMapping: /druid/* + testOnBorrow: false + testOnReturn: false + testWhileIdle: true + timeBetweenEvictionRunsMillis: 60000 + url: jdbc:mysql://test.tall.wiki/yanyuan?useUnicode=true&characterEncoding=UTF-8 + username: root + validationQuery: SELECT 1 FROM DUAL + env: CCSENS_TALL \ No newline at end of file diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..90141ba --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,196 @@ + + + + + + + + + + logback + + + + + + + + + + + + + + + + + info + + + ${CONSOLE_LOG_PATTERN} + + UTF-8 + + + + + + + + + + ${log.path}/log_debug.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + debug + ACCEPT + DENY + + + + + + + ${log.path}/log_info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + info + ACCEPT + DENY + + + + + + + ${log.path}/log_warn.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + warn + ACCEPT + DENY + + + + + + + + ${log.path}/log_error.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper_dao/SPluginDao.xml b/src/main/resources/mapper_dao/SPluginDao.xml new file mode 100644 index 0000000..a48eec1 --- /dev/null +++ b/src/main/resources/mapper_dao/SPluginDao.xml @@ -0,0 +1,25 @@ + + + + + + + + update + t_pro_task_plugin + set + param = #{param} + where + id = #{taskPluginId} + and rec_status = 0 + + \ No newline at end of file diff --git a/src/main/resources/mapper_dao/SProjectDao.xml b/src/main/resources/mapper_dao/SProjectDao.xml new file mode 100644 index 0000000..7c37349 --- /dev/null +++ b/src/main/resources/mapper_dao/SProjectDao.xml @@ -0,0 +1,50 @@ + + + + + + UPDATE t_pro_task_detail + SET rec_status = 2 + WHERE + id = #{projectId} + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper_dao/STaskDao.xml b/src/main/resources/mapper_dao/STaskDao.xml new file mode 100644 index 0000000..4e917f1 --- /dev/null +++ b/src/main/resources/mapper_dao/STaskDao.xml @@ -0,0 +1,38 @@ + + + + + + INSERT INTO t_pro_task_sub + ( + id, + task_detail_id, + plan_start_time, + plan_end_time, + plan_duration + ) + VALUES + + (#{item.id},#{item.taskDetailId},#{item.planStartTime},#{item.planEndTime},#{item.planDuration}) + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper_dao/SubLableDao.xml b/src/main/resources/mapper_dao/SubLableDao.xml new file mode 100644 index 0000000..df9c3b3 --- /dev/null +++ b/src/main/resources/mapper_dao/SubLableDao.xml @@ -0,0 +1,29 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mbg.xml b/src/main/resources/mbg.xml new file mode 100644 index 0000000..ff7c16a --- /dev/null +++ b/src/main/resources/mbg.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + +
+
\ No newline at end of file diff --git a/src/main/resources/mybatis/mybatis-config.xml b/src/main/resources/mybatis/mybatis-config.xml new file mode 100644 index 0000000..e5a218d --- /dev/null +++ b/src/main/resources/mybatis/mybatis-config.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file