first commit

This commit is contained in:
“FiboAI”
2021-12-02 18:33:17 +08:00
parent 49016794cc
commit 70fb3743ee
312 changed files with 30833 additions and 0 deletions

34
jar-enginex-runner/.gitignore vendored Normal file
View File

@@ -0,0 +1,34 @@
HELP.md
target/
logs/
!.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/

View File

@@ -0,0 +1,3 @@
# jar-enginex-runner
enginex后端执行器

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

310
jar-enginex-runner/mvnw vendored Normal file
View File

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

182
jar-enginex-runner/mvnw.cmd vendored Normal file
View File

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

311
jar-enginex-runner/pom.xml Normal file
View File

@@ -0,0 +1,311 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.baoying</groupId>
<artifactId>enginex-runner</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>jar-enginex-runner</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<log4j.version>1.2.12</log4j.version>
<drools.version>6.4.0.Final</drools.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!--<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.1</version>
</dependency>-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.21</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-lgpl</artifactId>
<version>1.7.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.0</version>
</dependency>
<!-- start drools -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-spring</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>knowledge-api</artifactId>
<version>6.4.0.Final</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.4.3</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext-asian</artifactId>
<version>5.2.0</version>
</dependency>
<!-- end drools -->
<!-- 本地缓存 -->
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>2.8.4</version>
</dependency>
<!-- 连接池 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.0</version>
</dependency>
<!-- jedis集成 -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.4.2</version>
</dependency>
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>-->
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<!-- groovy脚本 -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.15</version>
</dependency>
<!--python脚本-->
<dependency>
<groupId>org.python</groupId>
<artifactId>jython-standalone</artifactId>
<version>2.7.0</version>
</dependency>
<!-- pmml模型文件 -->
<dependency>
<groupId>org.jpmml</groupId>
<artifactId>pmml-evaluator</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>org.jpmml</groupId>
<artifactId>pmml-evaluator-extension</artifactId>
<version>1.4.1</version>
</dependency>
<!--spring boot集成javamail-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>transmittable-thread-local</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
<scope>compile</scope>
</dependency>
<!--hbase相关-->
<!-- https://mvnrepository.com/artifact/com.spring4all/spring-boot-starter-hbase -->
<dependency>
<groupId>com.spring4all</groupId>
<artifactId>spring-boot-starter-hbase</artifactId>
<version>1.0.0.RELEASE</version>
<!--版本冲突-->
<exclusions>
<exclusion>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.hbase/hbase-client -->
<!--<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>1.3.1</version>
</dependency>-->
<!--hbase-shaded , 用来更改hbase中的一些包名解决protobuf的冲突问题-->
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-shaded-client</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<!-- 特别注意版本问题 -->
<version>1.2.3</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</exclusion>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- canal -->
<dependency>
<groupId>com.alibaba.otter</groupId>
<artifactId>canal.client</artifactId>
<version>1.1.4</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.5.1</version>
</dependency>
<!--hutool工具包-->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.5.2</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<!-- 此配置不可缺否则mybatis的Mapper.xml将会丢失 -->
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<!--指定资源的位置-->
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,19 @@
package com.baoying.enginex.executor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@EnableTransactionManagement
@MapperScan("com.baoying.enginex.executor.*.mapper")
@ComponentScan(basePackages = "com.baoying.enginex.executor.**")
public class JarEnginexRunnerApplication {
public static void main(String[] args) {
SpringApplication.run(JarEnginexRunnerApplication.class, args);
}
}

View File

@@ -0,0 +1,119 @@
package com.baoying.enginex.executor.canal;
import com.baoying.enginex.executor.datamanage.mapper.SimpleMapper;
import com.baoying.enginex.executor.redis.RedisManager;
import com.baoying.enginex.executor.redis.RedisUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/cache")
public class CacheController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Resource
private SimpleMapper simpleMapper;
@Autowired
private RedisManager redisManager;
@RequestMapping(value = "initCache", method = RequestMethod.GET)
public void initCache() {
logger.info("===================== 缓存初始化开始 =====================");
long start = System.currentTimeMillis();
// 遍历表
for (TableEnum tableEnum : TableEnum.values()) {
String tableName = tableEnum.getTableName();
logger.info("===================== 开始初始化缓存表[{}] =====================", tableName);
String sqlStr = "select * from " + tableName;
Map<String, Object> parameterMap = new HashMap<>();
parameterMap.put("sqlStr", sqlStr);
List<LinkedHashMap<String, Object>> result = simpleMapper.customSelect(parameterMap);
// 遍历行
for (LinkedHashMap<String, Object> map : result) {
row(tableEnum, map);
}
logger.info("===================== 结束初始化缓存表[{}],共[{}]条数据 =====================", tableName, result.size());
}
long end = System.currentTimeMillis();
logger.info("===================== 缓存初始化成功!!耗时:{}ms =====================", (end - start));
}
private void row(TableEnum tableEnum, LinkedHashMap<String, Object> map) {
String tableName = tableEnum.getTableName();
String primaryKey = null;
String foreignKey = null;
if (StringUtils.isNotBlank(tableEnum.getPrimaryId())) {
String primaryId = map.get(tableEnum.getPrimaryId()).toString();
primaryKey = RedisUtils.getPrimaryKey(tableName, primaryId);
}
if (StringUtils.isNotBlank(tableEnum.getForeignId())) {
Object obj = map.get(tableEnum.getForeignId());
if (obj != null && !"".equals(obj.toString())) {
String foreignId = obj.toString();
foreignKey = RedisUtils.getForeignKey(tableName, foreignId);
}
}
if (StringUtils.isNotBlank(primaryKey)) {
// 遍历列
for (String field : map.keySet()) {
String value = map.get(field) == null ? null : map.get(field).toString();
setColumnCache(primaryKey, field, value);
}
}
if (StringUtils.isNotBlank(foreignKey)) {
setForeignKeyCache(primaryKey, foreignKey);
}
// 指标表特殊处理
dealSpecialTable(tableName, map);
}
private void setColumnCache(String primaryKey, String field, String value) {
logger.info("开始主键缓存设置, primaryKey:{}, field:{}, value:{}", primaryKey, field, value);
redisManager.hset(primaryKey, field, value);
logger.info("结束主键缓存设置, primaryKey:{}, field:{}, value:{}", primaryKey, field, value);
}
private void setForeignKeyCache(String primaryKey, String foreignKey) {
logger.info("开始外键缓存设置, primaryKey:{}, foreignKey:{}", primaryKey, foreignKey);
redisManager.sadd(foreignKey, primaryKey);
logger.info("结束外键缓存设置, primaryKey:{}, foreignKey:{}", primaryKey, foreignKey);
}
private void dealSpecialTable(String tableName, LinkedHashMap<String, Object> map) {
if(tableName.equals(TableEnum.T_FIELD.getTableName())){
String fieldEn = "field_en:" + map.get("organ_id") + ":" + map.get("field_en");
String fieldEnKey = RedisUtils.getPrimaryKey(tableName, fieldEn);
String fieldCn = "field_cn:" + map.get("organ_id") + ":" + map.get("field_cn");
String fieldCnKey = RedisUtils.getPrimaryKey(tableName, fieldCn);
for (String field : map.keySet()) {
String value = map.get(field) == null ? null : map.get(field).toString();
setColumnCache(fieldEnKey, field, value);
setColumnCache(fieldCnKey, field, value);
}
}
}
}

View File

@@ -0,0 +1,246 @@
package com.baoying.enginex.executor.canal;
import com.alibaba.otter.canal.client.CanalConnector;
import com.alibaba.otter.canal.client.CanalConnectors;
import com.alibaba.otter.canal.protocol.CanalEntry;
import com.alibaba.otter.canal.protocol.Message;
import com.baoying.enginex.executor.common.constants.Constants;
import com.baoying.enginex.executor.config.ConfigHolder;
import com.baoying.enginex.executor.redis.RedisManager;
import com.baoying.enginex.executor.redis.RedisUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import java.net.InetSocketAddress;
import java.util.List;
import java.util.Optional;
/**
* Canal数据同步
* 实现ApplicationRunner接口springboot启动成功后会执行run方法
*/
@Component
public class CanalClient implements ApplicationRunner {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final static int BATCH_SIZE = 1000;
@Autowired
private ConfigHolder configHolder;
@Autowired
private RedisManager redisManager;
@Override
public void run(ApplicationArguments args) throws Exception {
if(Constants.switchFlag.OFF.equals(configHolder.getCanalCacheSwitch())){
return;
}
// 创建链接
CanalConnector connector = CanalConnectors.newSingleConnector(
new InetSocketAddress(configHolder.getCanalHostName(), configHolder.getCanalPort()),
"example", "", "");
try {
//打开连接
connector.connect();
//订阅数据库表,全部表
connector.subscribe(".*\\..*");
//回滚到未进行ack的地方下次fetch的时候可以从最后一个没有ack的地方开始拿
connector.rollback();
while (true) {
logger.info("canal数据同步监听中...");
// 获取指定数量的数据
Message message = connector.getWithoutAck(BATCH_SIZE);
//获取批量ID
long batchId = message.getId();
//获取批量的数量
int size = message.getEntries().size();
//如果没有数据
if (batchId == -1 || size == 0) {
try {
//线程休眠2秒
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
//如果有数据,处理数据
printEntry(message.getEntries());
}
//进行 batch id 的确认。确认之后,小于等于此 batchId 的 Message 都会被确认。
connector.ack(batchId);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
connector.disconnect();
}
}
/**
* 解析binlog获得的实体类信息
*/
private void printEntry(List<CanalEntry.Entry> entrys) {
for (CanalEntry.Entry entry : entrys) {
if (entry.getEntryType() == CanalEntry.EntryType.TRANSACTIONBEGIN || entry.getEntryType() == CanalEntry.EntryType.TRANSACTIONEND) {
//开启/关闭事务的实体类型,跳过
continue;
}
String tableName = entry.getHeader().getTableName();
TableEnum tableEnum = TableEnum.getByTableName(tableName);
if(tableEnum == null){
// 没有在枚举中定义的表,跳过
continue;
}
//RowChange对象包含了一行数据变化的所有特征
//比如isDdl 是否是ddl变更操作 sql 具体的ddl sql beforeColumns afterColumns 变更前后的数据字段等等
CanalEntry.RowChange rowChage;
try {
rowChage = CanalEntry.RowChange.parseFrom(entry.getStoreValue());
} catch (Exception e) {
throw new RuntimeException("ERROR ## parser of eromanga-event has an error , data:" + entry.toString(), e);
}
//获取操作类型insert/update/delete类型
CanalEntry.EventType eventType = rowChage.getEventType();
//打印Header信息
logger.info(String.format("============= binlog[%s:%s] , name[%s,%s] , eventType : %s =============",
entry.getHeader().getLogfileName(), entry.getHeader().getLogfileOffset(),
entry.getHeader().getSchemaName(), entry.getHeader().getTableName(),
eventType));
//判断是否是DDL语句
if (rowChage.getIsDdl()) {
logger.info("============= isDdl: true,sql:" + rowChage.getSql());
}
//获取RowChange对象里的每一行数据
for (CanalEntry.RowData rowData : rowChage.getRowDatasList()) {
//如果是删除语句
if (eventType == CanalEntry.EventType.DELETE) {
row(rowData.getBeforeColumnsList(), tableName);
//如果是新增语句
} else if (eventType == CanalEntry.EventType.INSERT) {
row(rowData.getAfterColumnsList(), tableName);
//如果是更新的语句
} else {
//变更前的数据
// printColumn(rowData.getBeforeColumnsList(), tableName);
//变更后的数据
row(rowData.getAfterColumnsList(), tableName);
}
}
}
}
private void row(List<CanalEntry.Column> columns, String tableName) {
Optional<CanalEntry.Column> keyColumn = columns.stream().filter(item -> item.getIsKey()).findFirst();
if(keyColumn.isPresent()){
// 获取主键id
String id = keyColumn.get().getValue();
// 拼接主键key
String key = RedisUtils.getPrimaryKey(tableName, id);
// 拼接外键key
String foreignKey = null;
// 子表的redis key需要拼接上主表的id
TableEnum tableEnum = TableEnum.getByTableName(tableName);
if(tableEnum != null){
Optional<CanalEntry.Column> foreignKeyColumn = columns.stream().filter(item -> item.getName().equals(tableEnum.getForeignId())).findFirst();
if(foreignKeyColumn.isPresent()){
String foreignKeyValue = foreignKeyColumn.get().getValue();
foreignKey = RedisUtils.getForeignKey(tableName, foreignKeyValue);
}
}
for (CanalEntry.Column column : columns) {
// 更新发生改变的字段缓存
setUpdatedColumnCache(column, key, foreignKey);
}
// 指标表特殊处理
dealSpecialTable(columns, tableName);
}
}
private void setUpdatedColumnCache(CanalEntry.Column column, String key, String foreignKey){
if(column.getUpdated()) {
logger.info("开始主键缓存更新, {}, {}, {}", key, column.getName(), column.getValue());
redisManager.hset(key, column.getName(), column.getValue());
logger.info("结束主键缓存更新, {}, {}, {}", key, column.getName(), column.getValue());
if(foreignKey != null){
logger.info("开始外键缓存更新, {}, {}", key, foreignKey);
redisManager.sadd(foreignKey, key);
logger.info("结束外键缓存更新, {}, {}", key, foreignKey);
}
}
}
private void setAllColumnCache(CanalEntry.Column column, String key){
logger.info("开始主键缓存更新, {}, {}, {}", key, column.getName(), column.getValue());
redisManager.hset(key, column.getName(), column.getValue());
logger.info("结束主键缓存更新, {}, {}, {}", key, column.getName(), column.getValue());
}
private void dealSpecialTable(List<CanalEntry.Column> columns, String tableName){
if(tableName.equals(TableEnum.T_FIELD.getTableName())){
String organ_id = null;
String field_en = null;
String field_cn = null;
for (CanalEntry.Column column : columns) {
String name = column.getName();
switch (name) {
case "organ_id":
organ_id = column.getValue();
break;
case "field_en":
field_en = column.getValue();
break;
case "field_cn":
field_cn = column.getValue();
break;
default:
break;
}
}
String fieldEn = "field_en:" + organ_id + ":" + field_en;
String fieldEnKey = RedisUtils.getPrimaryKey(tableName, fieldEn);
String fieldCn = "field_cn:" + organ_id + ":" + field_cn;
String fieldCnKey = RedisUtils.getPrimaryKey(tableName, fieldCn);
// 如果field_en或field_cn发生变化则对应的key为新生成的需要保存所有字段缓存
Optional<CanalEntry.Column> fieldEnOptional = columns.stream().filter(item -> item.getName().equals("field_en") && item.getUpdated()).findFirst();
Optional<CanalEntry.Column> fieldCnOptional = columns.stream().filter(item -> item.getName().equals("field_cn") && item.getUpdated()).findFirst();
for (CanalEntry.Column column : columns) {
if(fieldEnOptional.isPresent()){
// 更新所有字段缓存
setAllColumnCache(column, fieldEnKey);
} else {
// 更新发生改变的字段缓存
setUpdatedColumnCache(column, fieldEnKey, null);
}
if(fieldCnOptional.isPresent()){
setAllColumnCache(column, fieldCnKey);
} else {
setUpdatedColumnCache(column, fieldCnKey, null);
}
}
}
}
}

View File

@@ -0,0 +1,77 @@
package com.baoying.enginex.executor.canal;
/**
* 缓存数据同步表
*/
public enum TableEnum {
/**
* 引擎
*/
T_ENGINE("t_engine", "id", ""),
T_ENGINE_VERSION("t_engine_version", "version_id", "engine_id"),
T_ENGINE_NODE("t_engine_node", "node_id", "version_id"),
/**
* 指标
*/
T_FIELD("t_field", "id", ""),
T_FIELD_INTERFACE("t_field_interface", "id", ""),
T_FIELD_DATA_SOURCE("t_field_data_source", "id", ""),
/**
* 规则
*/
T_RULE("t_rule", "id", ""),
T_RULE_VERSION("t_rule_version", "id", "rule_id"),
T_RULE_CONDITION("t_rule_condition", "id", "version_id"),
T_RULE_LOOP_GROUP_ACTION("t_rule_loop_group_action", "id", "condition_for_id"),
T_RULE_FIELD("t_rule_field", "id", "rule_id"),
/**
* 策略输出
*/
T_TACTICS_OUTPUT("t_tactics_output", "id", "tactics_id");
private String tableName;
private String primaryId;
private String foreignId;
TableEnum(String tableName, String primaryId, String foreignId) {
this.tableName = tableName;
this.primaryId = primaryId;
this.foreignId = foreignId;
}
public static TableEnum getByTableName(String tableName) {
for (TableEnum tableEnum : TableEnum.values()) {
if (tableName.equals(tableEnum.getTableName())) {
return tableEnum;
}
}
return null;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public String getPrimaryId() {
return primaryId;
}
public void setPrimaryId(String primaryId) {
this.primaryId = primaryId;
}
public String getForeignId() {
return foreignId;
}
public void setForeignId(String foreignId) {
this.foreignId = foreignId;
}
}

View File

@@ -0,0 +1,17 @@
package com.baoying.enginex.executor.common.basefactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public final class CustomBeanFactory {
public static ApplicationContext getContext() {
final String[] applicationXML = { "applicationContext.xml"};
ApplicationContext context = getSpringContext(applicationXML);
return context;
}
public static ApplicationContext getSpringContext(String[] paths) {
return new ClassPathXmlApplicationContext(paths);
}
}

View File

@@ -0,0 +1,31 @@
package com.baoying.enginex.executor.common.constants;
public class CommonConst {
/**
* 逗号
*/
public static final String SYMBOL_COMMA = ",";
/**
* 单引号
*/
public static final String SYMBOL_SINGLE_QUOTA = "\'";
/**
* 空格
*/
public static final String SYMBOL_BLANK = " ";
/**
* 空字符串
*/
public static final String STRING_EMPTY = "";
/**
* 30分钟(s)
* */
public static final long MINUTE_30 = 1800000;
public static String DROOLS_KSESSION_KEY_PREFIX = "DROOLS_KSESSION#";
}

View File

@@ -0,0 +1,30 @@
package com.baoying.enginex.executor.common.constants;
/**
* 公共变量约定
*/
public class Constants {
// 规则集节点相关常量
public interface ruleNode {
// 互斥组(串行)
int MUTEXGROUP = 1;
// 执行组(并行)
int EXECUTEGROUP = 2;
}
public interface switchFlag {
// 开关打开
String ON = "on";
// 开关关闭
String OFF = "off";
}
public interface fieldName {
// 字段英文名
String fieldEn = "field_en";
//字段中文名
String fieldCn = "field_cn";
}
}

View File

@@ -0,0 +1,10 @@
package com.baoying.enginex.executor.common.constants;
public class ParamTypeConst {
public static final int CONSTANT = 1;
public static final int VARIABLE = 2;
public static final int CUSTOM = 3;
public static final int REGEX = 4;
}

View File

@@ -0,0 +1,60 @@
package com.baoying.enginex.executor.common.ksession;
import com.baoying.enginex.executor.redis.RedisManager;
import org.apache.commons.pool2.BaseKeyedPooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.*;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* kSession工厂类
*/
@Component
public class KSessionFactory extends BaseKeyedPooledObjectFactory<String, StatefulKnowledgeSession> {
@Autowired
private RedisManager redisManager;
@Override
public StatefulKnowledgeSession create(String key) throws Exception {
StatefulKnowledgeSession kSession = null;
try {
String ruleString = redisManager.get(key);
if(ruleString == null){
throw new Exception("create kSession fail, key is "+ key + ", ruleString is null");
}
long start = System.currentTimeMillis();
KnowledgeBuilder kb = KnowledgeBuilderFactory.newKnowledgeBuilder();
kb.add(ResourceFactory.newByteArrayResource(ruleString.getBytes("utf-8")), ResourceType.DRL);
KnowledgeBuilderErrors errors = kb.getErrors();
for (KnowledgeBuilderError error : errors) {
System.out.println(error);
}
KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
kBase.addKnowledgePackages(kb.getKnowledgePackages());
kSession = kBase.newStatefulKnowledgeSession();
long end = System.currentTimeMillis();
System.out.println("------------------drools kSession创建耗时" + (end - start) + " ----------------------");
} catch (Exception e) {
throw e;
}
return kSession;
}
@Override
public PooledObject<StatefulKnowledgeSession> wrap(StatefulKnowledgeSession kSession) {
return new DefaultPooledObject<StatefulKnowledgeSession>(kSession);
}
public void setRedisManager(RedisManager redisManager) {
this.redisManager = redisManager;
}
}

View File

@@ -0,0 +1,67 @@
package com.baoying.enginex.executor.common.ksession;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
import org.drools.runtime.StatefulKnowledgeSession;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* kSession连接池
*/
@Component
public class KSessionPool implements InitializingBean {
private GenericKeyedObjectPool<String, StatefulKnowledgeSession> pool;
@Autowired
private KSessionFactory kSessionFactory;
/**
* 初始化方法
* @throws Exception
*/
@Override
public void afterPropertiesSet() throws Exception {
initPool();
}
/**
* 初始化连接池
* @return
* @throws Exception
*/
public void initPool() throws Exception {
GenericKeyedObjectPoolConfig poolConfig = new GenericKeyedObjectPoolConfig();
poolConfig.setMaxTotalPerKey(200);
poolConfig.setMaxIdlePerKey(50);
poolConfig.setMinIdlePerKey(5);
poolConfig.setMaxTotal(2000);
this.pool = new GenericKeyedObjectPool(kSessionFactory, poolConfig);
}
/**
* 获取一个连接对象
* @return
* @throws Exception
*/
public StatefulKnowledgeSession borrowObject(String key) throws Exception {
return pool.borrowObject(key);
}
/**
* 归还一个连接对象
* @param ftpClient
*/
public void returnObject(String key, StatefulKnowledgeSession kSession) {
if(kSession != null){
pool.returnObject(key, kSession);
}
}
public void setkSessionFactory(KSessionFactory kSessionFactory) {
this.kSessionFactory = kSessionFactory;
}
}

View File

@@ -0,0 +1,55 @@
package com.baoying.enginex.executor.common.mapper;
import java.util.List;
public abstract interface BaseMapper<IdEntity> {
/**
* @Description: 根据对象删除数据
* @param entity 对象
* @return 是否删除成功
*/
int deleteByExample(IdEntity entity);
/**
* @Description: 根据对象主键ID删除数据
* @param id 对象id编号
* @return 是否删除成功
*/
int deleteByPrimaryKey(Long id);
/**
* @Description: 插入一条新的数据
* @param entity 对象
* @return 是否插入成功
*/
int insertSelective(IdEntity entity);
/**
* @Description: 根据对象主键更新对象信息
* @param entity 对象
* @return 是否修改成功标志
*/
int updateByPrimaryKeySelective(IdEntity entity);
/**
* @Description: 根据对象获取数据条数
* @param entity 对象
* @return 返回行数
*/
int countByExample(IdEntity entity);
/**
* @Description: 根据对象主键ID获取指定数据多个
* @param entity 对象
* @return 对象列表
*/
List<IdEntity> selectByExample(IdEntity entity);
/**
* @Description: 根据对象主键ID获取指定数据单个
* @param id id编号
* @return 返回单个对象
*/
IdEntity selectByPrimaryKey(Long id);
}

View File

@@ -0,0 +1,39 @@
package com.baoying.enginex.executor.common.mapper;
import com.baoying.enginex.executor.common.model.EmailTemplate;
import com.baoying.enginex.executor.common.model.EmailTemplateExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface EmailTemplateMapper {
long countByExample(EmailTemplateExample example);
int deleteByExample(EmailTemplateExample example);
int deleteByPrimaryKey(Integer templateId);
int insert(EmailTemplate record);
int insertSelective(EmailTemplate record);
List<EmailTemplate> selectByExampleWithBLOBs(EmailTemplateExample example);
List<EmailTemplate> selectByExample(EmailTemplateExample example);
EmailTemplate selectByPrimaryKey(Integer templateId);
int updateByExampleSelective(@Param("record") EmailTemplate record, @Param("example") EmailTemplateExample example);
int updateByExampleWithBLOBs(@Param("record") EmailTemplate record, @Param("example") EmailTemplateExample example);
int updateByExample(@Param("record") EmailTemplate record, @Param("example") EmailTemplateExample example);
int updateByPrimaryKeySelective(EmailTemplate record);
int updateByPrimaryKeyWithBLOBs(EmailTemplate record);
int updateByPrimaryKey(EmailTemplate record);
EmailTemplate selectTemplateByNid(String nid);
}

View File

@@ -0,0 +1,345 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.common.mapper.EmailTemplateMapper">
<resultMap id="BaseResultMap" type="com.baoying.enginex.executor.common.model.EmailTemplate">
<constructor>
<idArg column="template_id" javaType="java.lang.Integer" jdbcType="INTEGER" />
<arg column="subject" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="nid" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="status" javaType="java.lang.Byte" jdbcType="TINYINT" />
<arg column="address" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="use_type" javaType="java.lang.Byte" jdbcType="TINYINT" />
<arg column="create_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
<arg column="update_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
</constructor>
</resultMap>
<resultMap id="ResultMapWithBLOBs" type="com.baoying.enginex.executor.common.model.EmailTemplate">
<constructor>
<idArg column="template_id" javaType="java.lang.Integer" jdbcType="INTEGER" />
<arg column="subject" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="nid" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="status" javaType="java.lang.Byte" jdbcType="TINYINT" />
<arg column="address" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="use_type" javaType="java.lang.Byte" jdbcType="TINYINT" />
<arg column="create_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
<arg column="update_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
<arg column="content" javaType="java.lang.String" jdbcType="LONGVARCHAR" />
</constructor>
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
template_id, subject, nid, status, address, use_type, create_time, update_time
</sql>
<sql id="Blob_Column_List">
content
</sql>
<select id="selectByExampleWithBLOBs" parameterType="com.baoying.enginex.executor.common.model.EmailTemplateExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from t_email_template
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="com.baoying.enginex.executor.common.model.EmailTemplateExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from t_email_template
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from t_email_template
where template_id = #{templateId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from t_email_template
where template_id = #{templateId,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.baoying.enginex.executor.common.model.EmailTemplateExample">
delete from t_email_template
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.baoying.enginex.executor.common.model.EmailTemplate">
insert into t_email_template (template_id, subject, nid,
status, address, use_type,
create_time, update_time, content
)
values (#{templateId,jdbcType=INTEGER}, #{subject,jdbcType=VARCHAR}, #{nid,jdbcType=VARCHAR},
#{status,jdbcType=TINYINT}, #{address,jdbcType=VARCHAR}, #{useType,jdbcType=TINYINT},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{content,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.baoying.enginex.executor.common.model.EmailTemplate">
insert into t_email_template
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="templateId != null">
template_id,
</if>
<if test="subject != null">
subject,
</if>
<if test="nid != null">
nid,
</if>
<if test="status != null">
status,
</if>
<if test="address != null">
address,
</if>
<if test="useType != null">
use_type,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="content != null">
content,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="templateId != null">
#{templateId,jdbcType=INTEGER},
</if>
<if test="subject != null">
#{subject,jdbcType=VARCHAR},
</if>
<if test="nid != null">
#{nid,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=TINYINT},
</if>
<if test="address != null">
#{address,jdbcType=VARCHAR},
</if>
<if test="useType != null">
#{useType,jdbcType=TINYINT},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.baoying.enginex.executor.common.model.EmailTemplateExample" resultType="java.lang.Long">
select count(*) from t_email_template
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update t_email_template
<set>
<if test="record.templateId != null">
template_id = #{record.templateId,jdbcType=INTEGER},
</if>
<if test="record.subject != null">
subject = #{record.subject,jdbcType=VARCHAR},
</if>
<if test="record.nid != null">
nid = #{record.nid,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
status = #{record.status,jdbcType=TINYINT},
</if>
<if test="record.address != null">
address = #{record.address,jdbcType=VARCHAR},
</if>
<if test="record.useType != null">
use_type = #{record.useType,jdbcType=TINYINT},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.content != null">
content = #{record.content,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update t_email_template
set template_id = #{record.templateId,jdbcType=INTEGER},
subject = #{record.subject,jdbcType=VARCHAR},
nid = #{record.nid,jdbcType=VARCHAR},
status = #{record.status,jdbcType=TINYINT},
address = #{record.address,jdbcType=VARCHAR},
use_type = #{record.useType,jdbcType=TINYINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
content = #{record.content,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update t_email_template
set template_id = #{record.templateId,jdbcType=INTEGER},
subject = #{record.subject,jdbcType=VARCHAR},
nid = #{record.nid,jdbcType=VARCHAR},
status = #{record.status,jdbcType=TINYINT},
address = #{record.address,jdbcType=VARCHAR},
use_type = #{record.useType,jdbcType=TINYINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.baoying.enginex.executor.common.model.EmailTemplate">
update t_email_template
<set>
<if test="subject != null">
subject = #{subject,jdbcType=VARCHAR},
</if>
<if test="nid != null">
nid = #{nid,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=TINYINT},
</if>
<if test="address != null">
address = #{address,jdbcType=VARCHAR},
</if>
<if test="useType != null">
use_type = #{useType,jdbcType=TINYINT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="content != null">
content = #{content,jdbcType=LONGVARCHAR},
</if>
</set>
where template_id = #{templateId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.baoying.enginex.executor.common.model.EmailTemplate">
update t_email_template
set subject = #{subject,jdbcType=VARCHAR},
nid = #{nid,jdbcType=VARCHAR},
status = #{status,jdbcType=TINYINT},
address = #{address,jdbcType=VARCHAR},
use_type = #{useType,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
content = #{content,jdbcType=LONGVARCHAR}
where template_id = #{templateId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.baoying.enginex.executor.common.model.EmailTemplate">
update t_email_template
set subject = #{subject,jdbcType=VARCHAR},
nid = #{nid,jdbcType=VARCHAR},
status = #{status,jdbcType=TINYINT},
address = #{address,jdbcType=VARCHAR},
use_type = #{useType,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where template_id = #{templateId,jdbcType=INTEGER}
</update>
<select id="selectTemplateByNid" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from t_email_template
where nid = #{nid}
</select>
</mapper>

View File

@@ -0,0 +1,81 @@
package com.baoying.enginex.executor.common.model;
public class BasePage {
/**
* 当前页数
*/
private int page;
/**
* 每页显示的行数
*/
private int rows;
/**
* 开始行数
*/
private Integer curRow;
/**
* 结束行数
*/
private Integer endRow;
/**
* 总行数
*/
private Integer total;
public BasePage() {
}
public Integer getTotal() {
return total;
}
public void setTotal(Integer total) {
this.total = total;
}
/**
* setPagination:(设置当前页面和每页显示行数). <br/>
* @author wz
* @param page 当前页数
* @param rows 每页显示的行数
*/
public void setPagination(int page,int rows){
this.page = page;
this.rows = rows;
this.curRow = (page-1)*rows;
this.endRow = (page)*rows;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getRows() {
return rows;
}
public void setRows(int rows) {
this.rows = rows;
}
public void setCurRow(Integer curRow) {
this.curRow = curRow;
}
public void setEndRow(Integer endRow) {
this.endRow = endRow;
}
}

View File

@@ -0,0 +1,122 @@
package com.baoying.enginex.executor.common.model;
import java.util.Date;
public class EmailTemplate {
private Integer templateId;
private String subject;
private String nid;
private Byte status;
private String address;
private Byte useType;
private Date createTime;
private Date updateTime;
private String content;
public EmailTemplate(Integer templateId, String subject, String nid, Byte status, String address, Byte useType, Date createTime, Date updateTime) {
this.templateId = templateId;
this.subject = subject;
this.nid = nid;
this.status = status;
this.address = address;
this.useType = useType;
this.createTime = createTime;
this.updateTime = updateTime;
}
public EmailTemplate(Integer templateId, String subject, String nid, Byte status, String address, Byte useType, Date createTime, Date updateTime, String content) {
this.templateId = templateId;
this.subject = subject;
this.nid = nid;
this.status = status;
this.address = address;
this.useType = useType;
this.createTime = createTime;
this.updateTime = updateTime;
this.content = content;
}
public EmailTemplate() {
super();
}
public Integer getTemplateId() {
return templateId;
}
public void setTemplateId(Integer templateId) {
this.templateId = templateId;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject == null ? null : subject.trim();
}
public String getNid() {
return nid;
}
public void setNid(String nid) {
this.nid = nid == null ? null : nid.trim();
}
public Byte getStatus() {
return status;
}
public void setStatus(Byte status) {
this.status = status;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address == null ? null : address.trim();
}
public Byte getUseType() {
return useType;
}
public void setUseType(Byte useType) {
this.useType = useType;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content == null ? null : content.trim();
}
}

View File

@@ -0,0 +1,711 @@
package com.baoying.enginex.executor.common.model;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class EmailTemplateExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public EmailTemplateExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andTemplateIdIsNull() {
addCriterion("template_id is null");
return (Criteria) this;
}
public Criteria andTemplateIdIsNotNull() {
addCriterion("template_id is not null");
return (Criteria) this;
}
public Criteria andTemplateIdEqualTo(Integer value) {
addCriterion("template_id =", value, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdNotEqualTo(Integer value) {
addCriterion("template_id <>", value, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdGreaterThan(Integer value) {
addCriterion("template_id >", value, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdGreaterThanOrEqualTo(Integer value) {
addCriterion("template_id >=", value, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdLessThan(Integer value) {
addCriterion("template_id <", value, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdLessThanOrEqualTo(Integer value) {
addCriterion("template_id <=", value, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdIn(List<Integer> values) {
addCriterion("template_id in", values, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdNotIn(List<Integer> values) {
addCriterion("template_id not in", values, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdBetween(Integer value1, Integer value2) {
addCriterion("template_id between", value1, value2, "templateId");
return (Criteria) this;
}
public Criteria andTemplateIdNotBetween(Integer value1, Integer value2) {
addCriterion("template_id not between", value1, value2, "templateId");
return (Criteria) this;
}
public Criteria andSubjectIsNull() {
addCriterion("subject is null");
return (Criteria) this;
}
public Criteria andSubjectIsNotNull() {
addCriterion("subject is not null");
return (Criteria) this;
}
public Criteria andSubjectEqualTo(String value) {
addCriterion("subject =", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectNotEqualTo(String value) {
addCriterion("subject <>", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectGreaterThan(String value) {
addCriterion("subject >", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectGreaterThanOrEqualTo(String value) {
addCriterion("subject >=", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectLessThan(String value) {
addCriterion("subject <", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectLessThanOrEqualTo(String value) {
addCriterion("subject <=", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectLike(String value) {
addCriterion("subject like", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectNotLike(String value) {
addCriterion("subject not like", value, "subject");
return (Criteria) this;
}
public Criteria andSubjectIn(List<String> values) {
addCriterion("subject in", values, "subject");
return (Criteria) this;
}
public Criteria andSubjectNotIn(List<String> values) {
addCriterion("subject not in", values, "subject");
return (Criteria) this;
}
public Criteria andSubjectBetween(String value1, String value2) {
addCriterion("subject between", value1, value2, "subject");
return (Criteria) this;
}
public Criteria andSubjectNotBetween(String value1, String value2) {
addCriterion("subject not between", value1, value2, "subject");
return (Criteria) this;
}
public Criteria andNidIsNull() {
addCriterion("nid is null");
return (Criteria) this;
}
public Criteria andNidIsNotNull() {
addCriterion("nid is not null");
return (Criteria) this;
}
public Criteria andNidEqualTo(String value) {
addCriterion("nid =", value, "nid");
return (Criteria) this;
}
public Criteria andNidNotEqualTo(String value) {
addCriterion("nid <>", value, "nid");
return (Criteria) this;
}
public Criteria andNidGreaterThan(String value) {
addCriterion("nid >", value, "nid");
return (Criteria) this;
}
public Criteria andNidGreaterThanOrEqualTo(String value) {
addCriterion("nid >=", value, "nid");
return (Criteria) this;
}
public Criteria andNidLessThan(String value) {
addCriterion("nid <", value, "nid");
return (Criteria) this;
}
public Criteria andNidLessThanOrEqualTo(String value) {
addCriterion("nid <=", value, "nid");
return (Criteria) this;
}
public Criteria andNidLike(String value) {
addCriterion("nid like", value, "nid");
return (Criteria) this;
}
public Criteria andNidNotLike(String value) {
addCriterion("nid not like", value, "nid");
return (Criteria) this;
}
public Criteria andNidIn(List<String> values) {
addCriterion("nid in", values, "nid");
return (Criteria) this;
}
public Criteria andNidNotIn(List<String> values) {
addCriterion("nid not in", values, "nid");
return (Criteria) this;
}
public Criteria andNidBetween(String value1, String value2) {
addCriterion("nid between", value1, value2, "nid");
return (Criteria) this;
}
public Criteria andNidNotBetween(String value1, String value2) {
addCriterion("nid not between", value1, value2, "nid");
return (Criteria) this;
}
public Criteria andStatusIsNull() {
addCriterion("status is null");
return (Criteria) this;
}
public Criteria andStatusIsNotNull() {
addCriterion("status is not null");
return (Criteria) this;
}
public Criteria andStatusEqualTo(Byte value) {
addCriterion("status =", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotEqualTo(Byte value) {
addCriterion("status <>", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThan(Byte value) {
addCriterion("status >", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThanOrEqualTo(Byte value) {
addCriterion("status >=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThan(Byte value) {
addCriterion("status <", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThanOrEqualTo(Byte value) {
addCriterion("status <=", value, "status");
return (Criteria) this;
}
public Criteria andStatusIn(List<Byte> values) {
addCriterion("status in", values, "status");
return (Criteria) this;
}
public Criteria andStatusNotIn(List<Byte> values) {
addCriterion("status not in", values, "status");
return (Criteria) this;
}
public Criteria andStatusBetween(Byte value1, Byte value2) {
addCriterion("status between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andStatusNotBetween(Byte value1, Byte value2) {
addCriterion("status not between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andAddressIsNull() {
addCriterion("address is null");
return (Criteria) this;
}
public Criteria andAddressIsNotNull() {
addCriterion("address is not null");
return (Criteria) this;
}
public Criteria andAddressEqualTo(String value) {
addCriterion("address =", value, "address");
return (Criteria) this;
}
public Criteria andAddressNotEqualTo(String value) {
addCriterion("address <>", value, "address");
return (Criteria) this;
}
public Criteria andAddressGreaterThan(String value) {
addCriterion("address >", value, "address");
return (Criteria) this;
}
public Criteria andAddressGreaterThanOrEqualTo(String value) {
addCriterion("address >=", value, "address");
return (Criteria) this;
}
public Criteria andAddressLessThan(String value) {
addCriterion("address <", value, "address");
return (Criteria) this;
}
public Criteria andAddressLessThanOrEqualTo(String value) {
addCriterion("address <=", value, "address");
return (Criteria) this;
}
public Criteria andAddressLike(String value) {
addCriterion("address like", value, "address");
return (Criteria) this;
}
public Criteria andAddressNotLike(String value) {
addCriterion("address not like", value, "address");
return (Criteria) this;
}
public Criteria andAddressIn(List<String> values) {
addCriterion("address in", values, "address");
return (Criteria) this;
}
public Criteria andAddressNotIn(List<String> values) {
addCriterion("address not in", values, "address");
return (Criteria) this;
}
public Criteria andAddressBetween(String value1, String value2) {
addCriterion("address between", value1, value2, "address");
return (Criteria) this;
}
public Criteria andAddressNotBetween(String value1, String value2) {
addCriterion("address not between", value1, value2, "address");
return (Criteria) this;
}
public Criteria andUseTypeIsNull() {
addCriterion("use_type is null");
return (Criteria) this;
}
public Criteria andUseTypeIsNotNull() {
addCriterion("use_type is not null");
return (Criteria) this;
}
public Criteria andUseTypeEqualTo(Byte value) {
addCriterion("use_type =", value, "useType");
return (Criteria) this;
}
public Criteria andUseTypeNotEqualTo(Byte value) {
addCriterion("use_type <>", value, "useType");
return (Criteria) this;
}
public Criteria andUseTypeGreaterThan(Byte value) {
addCriterion("use_type >", value, "useType");
return (Criteria) this;
}
public Criteria andUseTypeGreaterThanOrEqualTo(Byte value) {
addCriterion("use_type >=", value, "useType");
return (Criteria) this;
}
public Criteria andUseTypeLessThan(Byte value) {
addCriterion("use_type <", value, "useType");
return (Criteria) this;
}
public Criteria andUseTypeLessThanOrEqualTo(Byte value) {
addCriterion("use_type <=", value, "useType");
return (Criteria) this;
}
public Criteria andUseTypeIn(List<Byte> values) {
addCriterion("use_type in", values, "useType");
return (Criteria) this;
}
public Criteria andUseTypeNotIn(List<Byte> values) {
addCriterion("use_type not in", values, "useType");
return (Criteria) this;
}
public Criteria andUseTypeBetween(Byte value1, Byte value2) {
addCriterion("use_type between", value1, value2, "useType");
return (Criteria) this;
}
public Criteria andUseTypeNotBetween(Byte value1, Byte value2) {
addCriterion("use_type not between", value1, value2, "useType");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Date value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Date value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Date value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Date value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Date> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Date> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Date value1, Date value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@@ -0,0 +1,18 @@
package com.baoying.enginex.executor.common.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
//表达式的参数实体类
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ExpressionParam {
private String fieldEn;//表达式中key字段en
private String operator;//表达式的操作符
private Integer variableType;//表达式中value类型1常量 2变量,3自定义
private String fieldValue;//表达式中对应常量value值或者变量key
private String executionLogic;//执行逻辑
private Integer conditionType;//规则节点的类型1-关系节点2-表达式节点
}

View File

@@ -0,0 +1,15 @@
package com.baoying.enginex.executor.common.session;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = false)
public class SessionData {
private Long organId; // 组织id
private Long engineId; // 引擎id
private Integer reqType;//请求类型
}

View File

@@ -0,0 +1,20 @@
package com.baoying.enginex.executor.common.session;
import com.alibaba.ttl.TransmittableThreadLocal;
/**
* session管理类
*/
public class SessionManager {
private static TransmittableThreadLocal<SessionData> session = new TransmittableThreadLocal<SessionData>() {
};
public static SessionData getSession() {
return session.get();
}
public static void setSession(SessionData conn) {
session.set(conn);
}
}

View File

@@ -0,0 +1,72 @@
package com.baoying.enginex.executor.config;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
@Configuration
@Data
public class ConfigHolder {
//redisConfig
@Value("${redis.host}")
private String redisHost;
@Value("${redis.port}")
private int redisPort;
@Value("${redis.db}")
private int redisDb;
@Value("${redis.password}")
private String redisPwd;
@Value("${redis.pool.maxTotal}")
private int redisMaxTotal;
@Value("${redis.pool.maxIdle}")
private int redisMaxIdle;
@Value("${redis.pool.maxWait}")
private int redisMaxWait;
@Value("${redis.pool.timeout}")
private int redisTimeout;
// 业务逻辑是否使用缓存
@Value("${switch.use.cache}")
private String cacheSwitch;
// canal缓存同步是否开启
@Value("${switch.canal.cache}")
private String canalCacheSwitch;
// canal主机地址
@Value("${canal.hostname}")
private String canalHostName;
// canal端口
@Value("${canal.port}")
private int canalPort;
//jdbcConfig
/*@Value("${jdbc.url}")
private String jdbcUrl;
@Value("${jdbc.driver}")
private String DriverName;
@Value("${pool.maxPoolSize}")
private int maxPoolSize;
@Value("${jdbc.username}")
private String jdbcUserName;
@Value("${jdbc.password}")
private String jdbcPwd;
@Value("${pool.maxWait}")
private int jdbcMaxWait;
@Value("${pool.timeBetweenEvictionRunsMillis}")
private int timeBetweenEvictionRunsMillis;
@Value("${pool.minEvictableIdleTimeMillis}")
private int minEvictableIdleTimeMillis;
@Value("${pool.validationQuery}")
private String validationQuery;
//rabbitconfig
@Value("${rabbitMQ.host}")
private String rabbitHost;
@Value("${rabbitMQ.port}")
private int rabbitPort;
@Value("${rabbitMQ.username}")
private String rabbitUsername;
@Value("${rabbitMQ.password}")
private String rabbitPassword;*/
}

View File

@@ -0,0 +1,46 @@
package com.baoying.enginex.executor.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import javax.annotation.Resource;
import java.util.concurrent.ThreadPoolExecutor;
@Configuration
public class ConfigurationContainor {
@Resource
private ConfigHolder configHolder;
@Bean(name = "threadPoolTaskExecutor")
ThreadPoolTaskExecutor threadPoolTaskExecutor(){
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(2000);
executor.setMaxPoolSize(10000);
executor.setQueueCapacity(100000);
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
return executor;
}
@Bean(name = "jedisPool")
public JedisPool jedisPool(){
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxTotal(configHolder.getRedisMaxTotal());
config.setMaxIdle(configHolder.getRedisMaxIdle());
config.setMaxWaitMillis(configHolder.getRedisMaxWait());
config.setTestOnBorrow(true);
// config.setTestOnReturn(true);
JedisPool pool = new JedisPool(config,
configHolder.getRedisHost(),
configHolder.getRedisPort(),
configHolder.getRedisTimeout(),
configHolder.getRedisPwd(),
configHolder.getRedisDb());
return pool;
}
}

View File

@@ -0,0 +1,61 @@
package com.baoying.enginex.executor.config;
import com.alibaba.druid.pool.DruidDataSource;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import javax.sql.DataSource;
@Configuration
public class DataSourceConfig {
@Value("${spring.datasource.default.url}")
private String defaultDBUrl;
@Value("${spring.datasource.default.username}")
private String defaultDBUser;
@Value("${spring.datasource.default.password}")
private String defaultDBPassword;
@Value("${spring.datasource.default.driver-class-name}")
private String defaultDBDreiverName;
@Bean
public DruidDataSource druidDataSource(){
DruidDataSource defaultDataSource = new DruidDataSource();
defaultDataSource.setUrl(defaultDBUrl);
defaultDataSource.setUsername(defaultDBUser);
defaultDataSource.setPassword(defaultDBPassword);
defaultDataSource.setDriverClassName(defaultDBDreiverName);
return defaultDataSource;
}
@Bean
public SqlSessionFactory sqlSessionFactory(
@Qualifier("druidDataSource") DataSource druidDataSource)
throws Exception {
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource[] mapperXmlResource = resolver.getResources("classpath*:com/baoying/enginex/executor/*/mapper/*Mapper.xml");
bean.setDataSource(druidDataSource);
bean.setMapperLocations(mapperXmlResource);
bean.setTypeAliasesPackage("com.baoying.enginex.executor.**.model");
bean.getObject().getConfiguration().setMapUnderscoreToCamelCase(true);
bean.getObject().getConfiguration().setCacheEnabled(false);
return bean.getObject();
}
@Bean(name = "sqlSessionTemplate")
public SqlSessionTemplate sqlSessionTemplate(
@Qualifier("sqlSessionFactory") SqlSessionFactory sqlSessionFactory)
throws Exception {
return new SqlSessionTemplate(sqlSessionFactory);
}
}

View File

@@ -0,0 +1,52 @@
package com.baoying.enginex.executor.config;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.http.client.AsyncClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.AsyncRestTemplate;
import org.springframework.web.client.RestTemplate;
/**
* RestTemplate配置
*/
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate(@Qualifier("clientHttpRequestFactory") ClientHttpRequestFactory factory){
return new RestTemplate(factory);
}
@Bean
public AsyncRestTemplate asyncRestTemplate(@Qualifier("asyncClientHttpRequestFactory") AsyncClientHttpRequestFactory factory){
return new AsyncRestTemplate(factory);
}
@Bean
public ClientHttpRequestFactory clientHttpRequestFactory(){
// 创建一个 httpCilent 简单工厂
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
// 设置连接超时
factory.setConnectTimeout(15000);
// 设置读取超时
factory.setReadTimeout(5000);
return factory;
}
@Bean
public AsyncClientHttpRequestFactory asyncClientHttpRequestFactory(){
// 创建一个 httpCilent 简单工厂
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
// 设置连接超时
// factory.setConnectTimeout(15000);
// 设置读取超时
// factory.setReadTimeout(5000);
//设置异步任务(线程不会重用,每次调用时都会重新启动一个新的线程)
factory.setTaskExecutor(new SimpleAsyncTaskExecutor());
return factory;
}
}

View File

@@ -0,0 +1,57 @@
package com.baoying.enginex.executor.datamanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baoying.enginex.executor.datamanage.model.Field;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@Mapper
public interface FieldMapper extends BaseMapper<Field> {
/**
* findFieldByIds:(找出一批字段id对应的字段列表). <br/>
* @author caowenyu
* @param paramMap 参数集合
* @return 字段列表
*/
public List<Field> findFieldByIdsbyorganId(Map<String, Object> paramMap);
/**
* findByFieldEn:(根据引擎和字段英文名找出引擎所用字段对象). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 字段对象
*/
public Field findByFieldEnbyorganId(Map<String, Object> paramMap);
/**
* findByFieldCn:(根据字段中文名找出字段对象). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 字段对象
*/
public Field findByFieldCnbyorganId(Map<String, Object> paramMap);
/**
* findByFieldCn:(按中文名查找通用字段). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 字段对象
*/
public Field findByFieldCnNoEngineIdbyorganId(Map<String, Object> paramMap);
/**
* findByFieldId:(根据字段Id查找字段对象). <br/>
* @author caowenyu
* @param paramMap 参数集合
* @return 字段对象
*/
public Field findByFieldIdbyorganId(Map<String, Object> paramMap);
List<Field> selectFieldListByIds(@Param("ids") List<Long> ids);
List<Field> selectFieldListByEns(@Param("ens")List<String> ens);
}

View File

@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.datamanage.mapper.FieldMapper">
<cache></cache>
<resultMap type="com.baoying.enginex.executor.datamanage.model.Field" id="fieldMap">
<id column="id" property="id"/>
<result column="field_en" property="fieldEn"/>
<result column="field_cn" property="fieldCn"/>
<result column="field_typeid" property="fieldTypeId"/>
<result column="value_type" property="valueType"/>
<result column="value_scope" property="valueScope"/>
<result column="is_derivative" property="isDerivative"/>
<result column="is_output" property="isOutput"/>
<result column="is_common" property="isCommon"/>
<result column="formula" property="formula"/>
<result column="formula_show" property="formulaShow"/>
<result column="orig_fieldid" property="origFieldId"/>
<result column="used_fieldid" property="usedFieldId"/>
<result column="author" property="author"/>
<result column="nickName" property="nickName"/>
<result column="created" property="created"/>
<result column="field_type" property="fieldType"/>
<result column="engine_id" property="engineId"/>
<result column="engineName" property="engineName"/>
<result column="status" property="status"/>
<result column="fieldRelId" property="fieldRelId"/>
<result column="is_use_sql" property="isUseSql"/>
<result column="data_source_id" property="dataSourceId"/>
<result column="sql_statement" property="sqlStatement"/>
<result column="dict_variable" property="dictVariable"/>
</resultMap>
<select id="findByFieldIdbyorganId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en, f.field_cn , f.field_typeid
, f.value_type , f.value_scope, f.is_derivative
, f.is_output , f.is_common , f.formula, f.formula_show
, f.orig_fieldid , used_fieldid
, r.engine_id
, p.field_type
, f.is_use_sql, f.data_source_id, f.sql_statement, f.dict_variable
from t_field f,t_field_user_rel r,t_field_type p
where f.id = r.field_id
and f.field_typeid = p.id
and r.organ_id = #{organId}
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and f.id = #{id}
</select>
<select id="findFieldByIdsbyorganId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en , f.field_cn , f.field_typeid
, f.value_type , f.value_scope , f.is_derivative
, f.is_output , f.is_common , f.formula, f.formula_show
, r.engine_id
, f.orig_fieldid
, p.field_type
, f.is_use_sql, f.data_source_id, f.sql_statement, f.sql_variable, f.is_interface, f.interface_id, f.interface_parse_field, f.json_value, f.dict_variable
from t_field f,t_field_user_rel r,t_field_type p
where f.id = r.field_id
and f.field_typeid = p.id
and r.organ_id = #{organId}
<if test="isDerivative != null">
and f.is_derivative = #{isDerivative}
</if>
and f.id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="findByFieldEnbyorganId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en , f.field_cn , f.field_typeid
, f.value_type , f.value_scope , f.is_derivative
, f.is_output , f.is_common , f.formula, f.formula_show, f.dict_variable
from t_field f,t_field_user_rel r
where f.id = r.field_id
and f.field_en = #{fieldEn}
and r.organ_id = #{organId}
and r.status = 1
</select>
<select id="findByFieldCnbyorganId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en , f.field_cn , f.field_typeid
, f.value_type , f.value_scope , f.is_derivative
, f.is_output , f.is_common , f.formula, f.formula_show
, f.orig_fieldid, f.dict_variable
from t_field f,t_field_user_rel r
where f.id = r.field_id
and f.field_cn = #{fieldCn}
and r.organ_id = #{organId}
and r.status = 1
</select>
<select id="findByFieldCnNoEngineIdbyorganId" parameterType="map" resultMap="fieldMap">
select f.id, f.field_en as fieldEn, f.field_cn as fieldCn, f.field_typeid as fieldTypeId
, f.value_type as valueType, f.value_scope as valueScope, f.is_derivative as isDerivative
, f.is_output as isOutput, f.is_common as isCommon, f.formula, f.formula_show as formulaShow
, f.orig_fieldid as origFieldId, f.dict_variable as dictVariable
from t_field f,t_field_user_rel r
where f.id = r.field_id
and f.field_cn = #{fieldCn}
and r.organ_id = #{organId}
and r.engine_id is null
and r.status = 1
</select>
<select id="selectFieldListByIds" parameterType="list" resultMap="fieldMap">
select f.id, f.field_en , f.field_cn , f.field_typeid
, f.value_type , f.value_scope , f.is_derivative
, f.is_output , f.is_common , f.formula, f.formula_show
, f.orig_fieldid
, p.field_type
, f.is_use_sql, f.data_source_id, f.sql_statement, f.dict_variable
from t_field f,t_field_type p
where f.field_typeid=p.id
and f.id in
<foreach collection="ids" item="id" separator="," open="(" close=")" >
#{id}
</foreach>
</select>
<select id="selectFieldListByEns" parameterType="list" resultMap="fieldMap">
select f.id, f.field_en , f.field_cn , f.field_typeid
, f.value_type , f.value_scope , f.is_derivative
, f.is_output , f.is_common , f.formula, f.formula_show
, f.orig_fieldid
, p.field_type
, f.is_use_sql, f.data_source_id, f.sql_statement, f.dict_variable
from t_field f,t_field_type p
where f.field_typeid=p.id
and f.field_en in
<foreach collection="ens" item="en" separator="," open="(" close=")" >
#{en}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,128 @@
package com.baoying.enginex.executor.datamanage.mapper;
import com.baoying.enginex.executor.common.mapper.BaseMapper;
import com.baoying.enginex.executor.datamanage.model.FieldType;
import java.util.List;
import java.util.Map;
public interface FieldTypeMapper extends BaseMapper<FieldType> {
/**
* getFieldTypeList:(查找用户的字段类型列表). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 字段类型列表
*/
public List<FieldType> getFieldTypeList(Map<String, Object> paramMap);
/**
* getSubFieldTypeList:(根据传入的字段父类型查找子类型列表). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 字段类型列表
*/
public List<FieldType> getSubFieldTypeList(Map<String, Object> paramMap);
/**
* findFieldTypeById:(根据传入的字段类型ID查找字段类型名). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 字段类型列表
*/
public FieldType findFieldTypeById(Map<String, Object> paramMap);
/**
* findTypeIdByParentId:(根据传入的字段类型父ID查找子类型ID). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 子字段类型ID
*/
public String findTypeIdByParentId(Map<String, Object> paramMap);
/**
* findTypeIdByParentId:(根据传入的字段类型类型ID查找父ID). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 子字段类型ID
*/
public String findParentIdByTypeId(Map<String, Object> paramMap);
/**
* findFieldType:(查找用户可用的字段类型列表,通用组织所有,引擎只有自定义). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 字段类型列表
*/
public List<FieldType> findFieldType(Map<String, Object> paramMap);
/**
* createFieldType:(新增字段类型). <br/>
* @author yuanlinfeng
* @param fieldTypeVo 字段类型实体类
* @return 插入成功
*/
public boolean createFieldType(FieldType fieldTypeVo);
/**
* findIdByFieldType:(新增字段类型). <br/>
* @author yuanlinfeng
* @param paramMap paramMap
* @return 字段类型编号
*/
public long findIdByFieldType(Map<String, Object> paramMap);
/**
* updateFieldType:(更新字段类型名). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新成功
*/
public boolean updateFieldType(Map<String, Object> paramMap);
/**
* updateFieldTypeByTypeIds:(更新字段类型为删除状态(-1)). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新成功
*/
public boolean updateFieldTypeByTypeIds(Map<String, Object> paramMap);
/**
* deleteFieldTypeByTypeIds:(删除字段类型下没有字段的空节点)). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新成功
*/
public boolean deleteFieldTypeByTypeIds(Map<String, Object> paramMap);
/**
* backFieldTypeByTypeIds:(更新字段类型状态为启用状态(1)). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新成功
*/
public boolean backFieldTypeByTypeIds(Map<String, Object> paramMap);
/**
* isExists:(查找字段名是否存在). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 存在的记录条数
*/
public int isExists(Map<String, Object> paramMap);
/**
* isExistsDefaultTreeName:(查找默认节点名是否存在). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 存在的记录条数
*/
public int isExistsDefaultTreeName(Map<String, Object> paramMap);
}

View File

@@ -0,0 +1,201 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.datamanage.mapper.FieldTypeMapper">
<cache></cache>
<resultMap type="fieldType" id="fieldTypeMap">
<id column="id" property="id"/>
<result column="field_type" property="fieldType"/>
<result column="parent_id" property="parentId"/>
<result column="is_common" property="isCommon"/>
<result column="engine_id" property="engineId"/>
</resultMap>
<select id="getFieldTypeList" parameterType="map" resultType="fieldType">
select r.field_typeid as id,t.field_type as fieldType,t.parent_id as parentId,t.is_common as isCommon,#{engineId} as engineId
from t_field_type_user_rel r, t_field_type t
where r.field_typeid = t.id
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="isCommon != null">
and t.is_common = #{isCommon}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="parentId == null">
and t.parent_id = 0
</if>
<if test="parentId != null">
and t.parent_id = #{parentId}
</if>
<if test="status != null">
and r.status = #{status}
</if>
order by t.is_common desc,r.created,t.id
</select>
<select id='findIdByFieldType' parameterType="map" resultType="java.lang.Long">
select IFNULL(MAX(t.id),0) as id
from t_field_type t,t_field_type_user_rel r
where t.id = r.field_typeid
and t.field_type = #{fieldType}
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
<if test="parentId == null">
and t.parent_id = 0
</if>
<if test="parentId != null">
and t.parent_id = #{parentId}
</if>
</select>
<select id='findFieldTypeById' parameterType="java.lang.Integer" resultType="fieldType">
select id, field_type as fieldType, parent_id as parentId
from t_field_type
where id = #{id}
</select>
<select id='findTypeIdByParentId' parameterType="map" resultType="String">
select group_concat(t.id) as id
from t_field_type t,t_field_type_user_rel r
where t.id = r.field_typeid
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and r.engine_id = #{engineId}
and t.parent_id = #{parentId}
</select>
<select id='findParentIdByTypeId' parameterType="map" resultType="String">
select t.parent_id as parentId
from t_field_type t,t_field_type_user_rel r
where t.id = r.field_typeid
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and t.id = ${fieldTypeId}
</select>
<select id='findFieldType' parameterType="java.lang.Integer" resultType="fieldType">
select t.id, t.field_type as fieldType, t.parent_id as parentId
from t_field_type t,t_field_type_user_rel r
where t.id = r.field_typeid
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and r.engine_id = #{engineId}
and r.field_typeid not in ( select field_typeid from t_field_type_user_rel where engine_id is null )
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
</select>
<insert id="createFieldType" useGeneratedKeys="true" keyProperty="id" parameterType="fieldType">
insert into t_field_type ( field_type, parent_id, is_common )
values ( #{fieldType}, #{parentId}, #{isCommon} )
</insert>
<update id="updateFieldType" parameterType="map">
update t_field_type
set field_type = #{fieldType}
where id = (select field_typeid
from t_field_type_user_rel
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and engine_id = #{engineId}
</if>
<if test="engineId == null">
and engine_id is null
</if>
and field_typeid = #{id}
)
</update>
<update id="updateFieldTypeByTypeIds" parameterType="map">
update t_field_type_user_rel
set status = -1
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and status = 1
</update>
<update id="deleteFieldTypeByTypeIds" parameterType="map">
delete from t_field_type_user_rel
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and field_typeid not in
( select field_typeid
from t_field f,t_field_user_rel r
where f.id = r.field_id
and f.field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
)
</update>
<update id="backFieldTypeByTypeIds" parameterType="map">
update t_field_type_user_rel
set status = 1
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and status = -1
</update>
<select id="isExists" parameterType="map" resultType="java.lang.Integer">
select count(ft.id)
from t_field_type ft,t_field_type_user_rel r
where ft.id = r.field_typeid
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and ft.field_type = #{fieldType}
<if test="Id != null">
and ft.id != #{Id}
</if>
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and ft.parent_id = #{parentId}
</select>
<select id="isExistsDefaultTreeName" parameterType="map" resultType="java.lang.Integer">
select count(ft.id)
from t_field_type ft,t_field_type_user_rel r
where ft.id = r.field_typeid
and r.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and ft.field_type = #{fieldType}
<if test="engineId != null">
and r.engine_id = #{engineId}
</if>
<if test="engineId == null">
and r.engine_id is null
</if>
and ft.parent_id = #{parentId}
</select>
</mapper>

View File

@@ -0,0 +1,54 @@
package com.baoying.enginex.executor.datamanage.mapper;
import com.baoying.enginex.executor.common.mapper.BaseMapper;
import com.baoying.enginex.executor.datamanage.model.FieldTypeUser;
import java.util.Map;
public interface FieldTypeUserMapper extends BaseMapper<FieldTypeUser> {
/**
* createFieldTypeUserRel:(新增字段类型). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 插入成功
*/
public boolean createFieldTypeUserRel(Map<String, Object> paramMap);
/**
* batchBindEngineFieldTypeUserRel:(把一批通用字段类型id中不存在的类型id批量绑定到引擎). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 插入成功
*/
public boolean batchBindEngineFieldTypeUserRel(Map<String, Object> paramMap);
/**
* deleteFieldTypeUserRel:(取消字段类型). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 删除成功
*/
public boolean deleteFieldTypeUserRel(Map<String, Object> paramMap);
/**
* updateFieldTypeUserRel:(更新字段类型名). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新成功
*/
public boolean updateFieldTypeUserRel(Map<String, Object> paramMap);
/**
* findNodeIds:(查找引擎在用的节点集合). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return
*/
public String findNodeIds(Map<String, Object> paramMap);
}

View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.datamanage.mapper.FieldTypeUserMapper">
<cache></cache>
<resultMap type="fieldTypeUser" id="fieldTypeUserMap">
<id column="id" property="id"/>
<result column="field_typeid" property="fieldTypeId"/>
<result column="organ_id" property="organId"/>
<result column="engine_id" property="engineId"/>
<result column="user_id" property="userId"/>
</resultMap>
<insert id="createFieldTypeUserRel" useGeneratedKeys="true" keyProperty="id" parameterType="fieldTypeUser">
insert into t_field_type_user_rel ( field_typeid, organ_id, engine_id, user_id, created )
values ( #{fieldTypeId}, #{organId}, #{engineId}, #{userId}, now() )
</insert>
<insert id="batchBindEngineFieldTypeUserRel" parameterType="map">
insert into t_field_type_user_rel ( field_typeid, organ_id, engine_id, user_id, created )
select field_typeid, organ_id, #{engineId}, #{userId}, now()
from t_field_type_user_rel r
where r.field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and field_typeid not in ( select field_typeid from t_field_type_user_rel where engine_id = #{engineId})
and engine_id is null
</insert>
<select id="findNodeIds" parameterType="map" resultType="String">
select group_concat(field_typeid)
from t_field_type_user_rel x
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and exists (select field_typeid
from t_field_type_user_rel y
where x.field_typeid = y.field_typeid
and y.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and y.engine_id is null
)
</select>
<insert id="deleteFieldTypeUserRel" parameterType="map">
delete from t_field_type_user_rel
where
organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and engine_id = #{engineId}
</if>
<if test="engineId == null">
and engine_id is null
</if>
and field_typeid = #{fieldTypeId}
</insert>
<update id="updateFieldTypeUserRel" parameterType="map">
update t_field_type_user_rel
set user_id = #{userId}, created = now()
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and engine_id = #{engineId}
</if>
<if test="engineId == null">
and engine_id is null
</if>
and field_typeid = #{id}
</update>
</mapper>

View File

@@ -0,0 +1,77 @@
package com.baoying.enginex.executor.datamanage.mapper;
import com.baoying.enginex.executor.common.mapper.BaseMapper;
import com.baoying.enginex.executor.datamanage.model.FieldUser;
import java.util.Map;
public interface FieldUserMapper extends BaseMapper<FieldUser> {
/**
* createFieldUserRel:(绑定字段和用户关系). <br/>
* @author yuanlinfeng
* @param fieldUser 用户字段实体类
* @return 插入成功
* */
public boolean createFieldUserRel(FieldUser fieldUserVo);
/**
* batchCreateFieldUserRel:(批量导入字段信息后批量绑定字段和用户关系). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 插入成功
* */
public boolean batchCreateFieldUserRel(Map<String, Object> paramMap);
/**
* batchBindEngineFieldUserRel:(把一批通用字段id中未绑定的字段id批量绑定到引擎). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 插入成功
* */
public boolean batchBindEngineFieldUserRel(Map<String, Object> paramMap);
/**
* batchCreateEngineFieldUserRel:(把id、英文名、中文名不重复的组织字段批量绑定到引擎). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 插入成功
* */
public boolean batchCreateEngineFieldUserRel(Map<String, Object> paramMap);
/**
* updateFieldUserRel:(更新字段). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新成功
* */
public boolean updateFieldUserRel(Map<String, Object> paramMap);
/**
* updateStatus:(单个或批量更新用户字段关系). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新成功
* */
public boolean updateStatus(Map<String, Object> paramMap);
/**
* deleteFieldByIds:(批量修改字段启用状态为删除状态(-1)). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新是否成功
*/
public boolean deleteFieldByIds(Map<String, Object> paramMap);
/**
* deleteFieldByIds:(批量修改字段删除状态为启用状态(1)). <br/>
* @author yuanlinfeng
* @param paramMap 参数集合
* @return 更新是否成功
*/
public boolean backFieldByIds(Map<String, Object> paramMap);
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.datamanage.mapper.FieldUserMapper">
<cache></cache>
<resultMap type="fieldUser" id="fieldUserMap">
<id column="id" property="id"/>
<result column="field_id" property="fieldId"/>
<result column="organ_id" property="organId"/>
<result column="engine_id" property="engineId"/>
<result column="user_id" property="userId"/>
<result column="status" property="status"/>
</resultMap>
<insert id="createFieldUserRel" useGeneratedKeys="true" keyProperty="id" parameterType="fieldUser">
insert into t_field_user_rel (field_id, organ_id, engine_id, user_id, status, created, updated)
values (#{fieldId}, #{organId}, #{engineId}, #{userId}, #{status}, now(), now())
</insert>
<insert id="batchCreateFieldUserRel" parameterType="map">
insert into t_field_user_rel (field_id, organ_id, engine_id, user_id, status, created, updated)
select id, #{organId}, #{engineId}, #{userId}, #{status}, now(), now()
from t_field t
where t.author = #{author}
and not exists ( select r.field_id from t_field_user_rel r where t.id = r.field_id )
</insert>
<insert id="batchCreateEngineFieldUserRel" parameterType="map">
insert into t_field_user_rel (field_id, organ_id, engine_id, user_id, status, created, updated)
select id, #{organId}, #{engineId}, #{userId}, #{status}, now(), now()
from t_field f
where f.field_typeid in
<foreach collection="fieldTypeIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and not exists ( select 1
from ( select f.id,f.field_en,f.field_cn
from t_field f,t_field_user_rel fu
where f.id = fu.field_id
and fu.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and fu.engine_id = ${engineId} )y
where f.field_en = y.field_en or f.field_cn = y.field_cn or f.id = y.id
)
</insert>
<insert id="batchBindEngineFieldUserRel" parameterType="map">
insert into t_field_user_rel (field_id, organ_id, engine_id, user_id, status, created, updated)
select id, #{organId}, #{engineId}, #{userId}, 1, now(), now()
from t_field f
where f.id in
<foreach collection="fieldIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and not exists ( select 1
from ( select f.id,f.field_en,f.field_cn
from t_field f,t_field_user_rel fu
where f.id = fu.field_id
and fu.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and fu.engine_id = ${engineId} )y
where f.field_en = y.field_en or f.field_cn = y.field_cn or f.id = y.id
)
</insert>
<update id="updateFieldUserRel" parameterType="map">
update t_field_user_rel
set user_id = #{userId} , updated = now()
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and engine_id = #{engineId}
</if>
<if test="engineId == null">
and engine_id is null
</if>
and field_id = #{Id}
</update>
<update id="updateStatus" parameterType="map">
update t_field_user_rel
set status=#{status}
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
<if test="engineId != null">
and engine_id = #{engineId}
</if>
<if test="engineId == null and status!=-1 and status!=0">
and engine_id is null
</if>
and field_id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<update id="deleteFieldByIds" parameterType="map">
update t_field_user_rel
set status = -1
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and field_id in
<foreach collection="fieldIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and status = 1
</update>
<update id="backFieldByIds" parameterType="map">
update t_field_user_rel
set status = 1
where organ_id = ( select organ_id from t_user where user_id = #{userId} )
and engine_id = #{engineId}
and field_id in
<foreach collection="Ids" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and status = -1
</update>
</mapper>

View File

@@ -0,0 +1,11 @@
package com.baoying.enginex.executor.datamanage.mapper;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public interface SimpleMapper {
List<LinkedHashMap<String, Object>> customSelect(Map<String, Object> paramsMap);
List<LinkedHashMap<String, Object>> test(Map<String, Object> paramsMap);
}

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.datamanage.mapper.SimpleMapper">
<select id="customSelect" resultType="java.util.LinkedHashMap">
${sqlStr}
</select>
<select id="test" resultType="java.util.LinkedHashMap">
${sqlStr}
</select>
</mapper>

View File

@@ -0,0 +1,236 @@
package com.baoying.enginex.executor.datamanage.model;
import com.baoying.enginex.executor.common.model.BasePage;
import java.io.Serializable;
import java.util.Date;
public class CustList extends BasePage implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Long id;
/**
* 以下20个t开头为匿名字段
* */
private String t0;
private String t1;
private String t2;
private String t3;
private String t4;
private String t5;
private String t6;
private String t7;
private String t8;
private String t9;
private String t10;
private String t11;
private String t12;
private String t13;
private String t14;
private String t15;
private String t16;
private String t17;
private String t18;
private String t19;
/**
* 创建人编号
* */
private Long userId;
/**
* 创建人昵称
* */
private String nickName;
/**
* 创建时间
* */
private Date created;
/**
* 检索客户信息是否存在的定制条件
*/
private String checkCol;
/**
* 检索名单库的表名称
*/
private String tableName;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getT0() {
return t0;
}
public void setT0(String t0) {
this.t0 = t0;
}
public String getT1() {
return t1;
}
public void setT1(String t1) {
this.t1 = t1;
}
public String getT2() {
return t2;
}
public void setT2(String t2) {
this.t2 = t2;
}
public String getT3() {
return t3;
}
public void setT3(String t3) {
this.t3 = t3;
}
public String getT4() {
return t4;
}
public void setT4(String t4) {
this.t4 = t4;
}
public String getT5() {
return t5;
}
public void setT5(String t5) {
this.t5 = t5;
}
public String getT6() {
return t6;
}
public void setT6(String t6) {
this.t6 = t6;
}
public String getT7() {
return t7;
}
public void setT7(String t7) {
this.t7 = t7;
}
public String getT8() {
return t8;
}
public void setT8(String t8) {
this.t8 = t8;
}
public String getT9() {
return t9;
}
public void setT9(String t9) {
this.t9 = t9;
}
public String getT10() {
return t10;
}
public void setT10(String t10) {
this.t10 = t10;
}
public String getT11() {
return t11;
}
public void setT11(String t11) {
this.t11 = t11;
}
public String getT12() {
return t12;
}
public void setT12(String t12) {
this.t12 = t12;
}
public String getT13() {
return t13;
}
public void setT13(String t13) {
this.t13 = t13;
}
public String getT14() {
return t14;
}
public void setT14(String t14) {
this.t14 = t14;
}
public String getT15() {
return t15;
}
public void setT15(String t15) {
this.t15 = t15;
}
public String getT16() {
return t16;
}
public void setT16(String t16) {
this.t16 = t16;
}
public String getT17() {
return t17;
}
public void setT17(String t17) {
this.t17 = t17;
}
public String getT18() {
return t18;
}
public void setT18(String t18) {
this.t18 = t18;
}
public String getT19() {
return t19;
}
public void setT19(String t19) {
this.t19 = t19;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getCheckCol() {
return checkCol;
}
public void setCheckCol(String checkCol) {
this.checkCol = checkCol;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
@Override
public String toString() {
return "CustList [id=" + id + ", t0=" + t0 + ", t1=" + t1 + ", t2=" + t2
+ ", t3=" + t3 + ", t4=" + t4 + ", t5=" + t5 + ", t6=" + t6
+ ", t7=" + t7 + ", t8=" + t8 + ", t9=" + t9 + ", t10=" + t10
+ ", t11=" + t11 + ", t12=" + t12 + ", t13=" + t13 + ", t14="
+ t14 + ", t15=" + t15 + ", t16=" + t16 + ", t17=" + t17
+ ", t18=" + t18 + ", t19=" + t19 + ", userId=" + userId
+ ", nickName=" + nickName + ", created=" + created
+ ", checkCol=" + checkCol + ", tableName=" + tableName + "]";
}
}

View File

@@ -0,0 +1,203 @@
package com.baoying.enginex.executor.datamanage.model;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
@TableName("t_field")
public class Field implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Long id;
/**
* 字段英文名
* */
private String fieldEn;
/**
* 字段中文名
* */
private String fieldCn;
/**
* 字段类型编号
* */
@TableField("field_typeid")
private Long fieldTypeId;
/**
* 字段类型名
* */
@TableField(exist = false)
private String fieldType;
/**
* 字段存值类型
* */
private Integer valueType;
/**
* 字段存值类型中文
* */
@TableField(exist = false)
private String valueTypeName;
/**
* 字段约束范围
* */
private String valueScope;
/**
* 是否衍生字段
* */
private Integer isDerivative;
/**
* 是否衍生字段
* */
@TableField(exist = false)
private String isDerivativeName;
/**
* 是否输出字段
* */
private Integer isOutput;
/**
* 是否输出字段
* */
@TableField(exist = false)
private String isOutputName;
/**
* 是否组织定义的通用字段
* */
private Integer isCommon;
/**
* 衍生字段公式
* */
private String formula;
/**
* 衍生字段公式回显信息
* */
private String formulaShow;
/**
* 衍生字段引用的字段id
* */
@TableField("used_fieldid")
private String usedFieldId;
/**
* 衍生字段引用的原生字段id
* */
@TableField("orig_fieldid")
private String origFieldId;
/**
* 创建人
* */
private Long author;
/**
* 创建人昵称
* */
@TableField(exist = false)
private String nickName;
/**
* 创建时间
* */
private Date created;
/**
* 归属的引擎ID
* */
@TableField(exist = false)
private Long engineId;
/**
* 归属的引擎名称
* */
@TableField(exist = false)
private String engineName;
/**
* 字段状态(启用、停用、删除、未知)
* */
@TableField(exist = false)
private String status;
/**
* 字段条件设置集合
* */
@TableField(exist = false)
private List<FieldCond> fieldCondList;
/**
* 字段用户关系编号
* */
@TableField(exist = false)
private Long fieldRelId;
/**
* 是否使用sql获取指标
*/
private Boolean isUseSql;
/**
* 使用sql获取指标时对应的数据源
*/
private Integer dataSourceId;
/**
* 使用sql获取指标时对应的sql语句
*/
private String sqlStatement;
/**
* sql变量配置
*/
private String sqlVariable;
/**
* 是否使用接口
*/
private Boolean isInterface;
/**
* 接口id
*/
private Integer interfaceId;
/**
* 接口解析指标
*/
private String interfaceParseField;
/**
* json类型对应的json值
*/
private String jsonValue;
/**
* 字典变量例如 日期date
*/
private String dictVariable;
/**
* 该字段归属的组织编号
* */
private Long organId;
}

View File

@@ -0,0 +1,142 @@
package com.baoying.enginex.executor.datamanage.model;
import com.baoying.enginex.executor.common.model.BasePage;
import com.baoying.enginex.executor.datamanage.vo.FieldSubCondVo;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
public class FieldCond extends BasePage implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 条件编号
* */
private Long id;
/**
* 字段编号
* */
private Long fieldId;
/**
* 字段条件值
* */
private String conditionValue;
/**
* 字段条件区域设置json格式
* */
private String content;
/**
* 条件字段编号
* */
private Long condFieldId;
/**
* 条件字段的运算符
* */
private String condFieldOperator;
/**
* 条件字段的条件设置值
* */
private String condFieldValue;
/**
* 条件字段间的逻辑符
* */
private String condFieldLogical;
/**
* 创建时间
* */
private Date created;
private List<FieldSubCondVo> fieldSubCond;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getFieldId() {
return fieldId;
}
public void setFieldId(Long fieldId) {
this.fieldId = fieldId;
}
public String getConditionValue() {
return conditionValue;
}
public void setConditionValue(String conditionValue) {
this.conditionValue = conditionValue;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Long getCondFieldId() {
return condFieldId;
}
public void setCondFieldId(Long condFieldId) {
this.condFieldId = condFieldId;
}
public String getCondFieldOperator() {
return condFieldOperator;
}
public void setCondFieldOperator(String condFieldOperator) {
this.condFieldOperator = condFieldOperator;
}
public String getCondFieldValue() {
return condFieldValue;
}
public void setCondFieldValue(String condFieldValue) {
this.condFieldValue = condFieldValue;
}
public String getCondFieldLogical() {
return condFieldLogical;
}
public void setCondFieldLogical(String condFieldLogical) {
this.condFieldLogical = condFieldLogical;
}
public List<FieldSubCondVo> getFieldSubCond() {
return fieldSubCond;
}
public void setFieldSubCond(List<FieldSubCondVo> fieldSubCond) {
this.fieldSubCond = fieldSubCond;
}
}

View File

@@ -0,0 +1,104 @@
package com.baoying.enginex.executor.datamanage.model;
import com.baoying.enginex.executor.common.model.BasePage;
import java.io.Serializable;
public class FieldInter extends BasePage implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Integer id;
/**
* 衍生字段编号
* */
private Integer fieldRelId;
/**
* 公式引用的字段编号
* */
private Integer interFieldId;
/**
* 公式引用的字段用户关系编号
* */
private Integer interFieldRelId;
/**
* 同名字段的顺序
* */
private Integer seq;
/**
* 字段值区间划分
* */
private String interval;
/**
* 对应区间的值定义
* */
private String value;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getFieldRelId() {
return fieldRelId;
}
public void setFieldRelId(Integer fieldRelId) {
this.fieldRelId = fieldRelId;
}
public Integer getInterFieldId() {
return interFieldId;
}
public void setInterFieldId(Integer interFieldId) {
this.interFieldId = interFieldId;
}
public Integer getInterFieldRelId() {
return interFieldRelId;
}
public void setInterFieldRelId(Integer interFieldRelId) {
this.interFieldRelId = interFieldRelId;
}
public Integer getSeq() {
return seq;
}
public void setSeq(Integer seq) {
this.seq = seq;
}
public String getInterval() {
return interval;
}
public void setInterval(String interval) {
this.interval = interval;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@@ -0,0 +1,106 @@
package com.baoying.enginex.executor.datamanage.model;
import com.baoying.enginex.executor.common.model.BasePage;
import java.io.Serializable;
public class FieldType extends BasePage implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Integer id;
/**
* 字段类型名
* */
private String fieldType;
/**
* 父节点编号
* */
private Integer parentId;
/**
* 是否组织定义的通用字段类型
* */
private Integer isCommon;
/**
* 字段类型的子类集合
* */
private FieldType[] children;
/**
* 是否为父类
* */
private String isParent = "true";
/**
* 引擎编号
* */
private Integer engineId;
/**
*文件夹图片路径
* */
private String icon;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getFieldType() {
return fieldType;
}
public void setFieldType(String fieldType) {
this.fieldType = fieldType;
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public Integer getIsCommon() {
return isCommon;
}
public void setIsCommon(Integer isCommon) {
this.isCommon = isCommon;
}
public FieldType[] getChildren() {
return children;
}
public void setChildren(FieldType[] children) {
this.children = children;
}
public String getIsParent() {
return isParent;
}
public void setIsParent(String isParent) {
this.isParent = isParent;
}
public Integer getEngineId() {
return engineId;
}
public void setEngineId(Integer engineId) {
this.engineId = engineId;
}
public String getIcon() {
// if(engineId!=null)
// icon = "../../resource/images/authority/folder.png";
// else
icon = "../resource/images/authority/folder.png";
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
}

View File

@@ -0,0 +1,80 @@
package com.baoying.enginex.executor.datamanage.model;
import com.baoying.enginex.executor.common.model.BasePage;
import java.io.Serializable;
import java.util.Date;
public class FieldTypeUser extends BasePage implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Integer id;
/**
* 字段类型编号(表主键)
* */
private Integer fieldTypeId;
/**
* 该字段类型归属的组织编号
* */
private Long organId;
/**
* 该字段类型归属的引擎id表主键
* */
private Integer engineId;
/**
* 创建或修改该字段的用户编号
* */
private Long userId;
/**
* 创建时间
* */
private Date created;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getFieldTypeId() {
return fieldTypeId;
}
public void setFieldTypeId(Integer fieldTypeId) {
this.fieldTypeId = fieldTypeId;
}
public Long getOrganId() {
return organId;
}
public void setOrganId(Long organId) {
this.organId = organId;
}
public Integer getEngineId() {
return engineId;
}
public void setEngineId(Integer engineId) {
this.engineId = engineId;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
}

View File

@@ -0,0 +1,102 @@
package com.baoying.enginex.executor.datamanage.model;
import com.baoying.enginex.executor.common.model.BasePage;
import java.io.Serializable;
import java.util.Date;
public class FieldUser extends BasePage implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Long id;
/**
* 字段编号(表主键)
* */
private Long fieldId;
/**
* 该字段归属的组织编号
* */
private Long organId;
/**
* 该字段归属的引擎id表主键
* */
private Long engineId;
/**
* 创建或修改该字段的用户编号
* */
private Long userId;
/**
* 启用停用删除标志
* */
private int status;
/**
* 创建时间
* */
private Date created;
/**
* 更新时间
* */
private Date updated;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getFieldId() {
return fieldId;
}
public void setFieldId(Long fieldId) {
this.fieldId = fieldId;
}
public Long getOrganId() {
return organId;
}
public void setOrganId(Long organId) {
this.organId = organId;
}
public Long getEngineId() {
return engineId;
}
public void setEngineId(Long engineId) {
this.engineId = engineId;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getUpdated() {
return updated;
}
public void setUpdated(Date updated) {
this.updated = updated;
}
}

View File

@@ -0,0 +1,45 @@
package com.baoying.enginex.executor.datamanage.model;
import com.baoying.enginex.executor.common.model.BasePage;
import java.io.Serializable;
public class FormulaField extends BasePage implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
* */
private Long id;
/**
* 字段编号(表主键)
* */
private Long fieldId;
/**
* 公式用到的字段编号(表主键)
* */
private Long formulaFieldId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getFieldId() {
return fieldId;
}
public void setFieldId(Long fieldId) {
this.fieldId = fieldId;
}
public Long getFormulaFieldId() {
return formulaFieldId;
}
public void setFormulaFieldId(Long formulaFieldId) {
this.formulaFieldId = formulaFieldId;
}
}

View File

@@ -0,0 +1,19 @@
package com.baoying.enginex.executor.datamanage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baoying.enginex.executor.datamanage.model.Field;
import java.util.List;
public interface FieldService extends IService<Field> {
Field queryById(Long id);
List<Field> findFieldByIdsbyorganId(Long organId, List<Long> ids);
List<Field> selectFieldListByEns(List<String> fieldEnList);
Field findByFieldEnbyorganId(Long organId, String fieldEn);
Field findByFieldCnbyorganId(Long organId, String fieldCn);
}

View File

@@ -0,0 +1,112 @@
package com.baoying.enginex.executor.datamanage.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baoying.enginex.executor.canal.TableEnum;
import com.baoying.enginex.executor.common.constants.Constants;
import com.baoying.enginex.executor.common.session.SessionManager;
import com.baoying.enginex.executor.config.ConfigHolder;
import com.baoying.enginex.executor.datamanage.mapper.FieldMapper;
import com.baoying.enginex.executor.datamanage.model.Field;
import com.baoying.enginex.executor.datamanage.service.FieldService;
import com.baoying.enginex.executor.redis.RedisManager;
import com.baoying.enginex.executor.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class FieldServiceImpl extends ServiceImpl<FieldMapper, Field> implements FieldService {
@Autowired
public FieldMapper fieldMapper;
@Autowired
private ConfigHolder configHolder;
@Autowired
private RedisManager redisManager;
@Override
public Field queryById(Long id) {
Field field = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
String key = RedisUtils.getPrimaryKey(TableEnum.T_FIELD, id);
field = redisManager.getByPrimaryKey(key, Field.class);
} else {
field = fieldMapper.selectById(id);
}
return field;
}
@Override
public List<Field> findFieldByIdsbyorganId(Long organId, List<Long> ids) {
List<Field> fieldList = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
List<String> keys = RedisUtils.getPrimaryKey(TableEnum.T_FIELD, ids);
fieldList = redisManager.hgetAllBatchByPrimaryKeys(keys, Field.class);
} else {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("organId", organId);
paramMap.put("Ids", ids);
fieldList = fieldMapper.findFieldByIdsbyorganId(paramMap);
}
return fieldList;
}
@Override
public List<Field> selectFieldListByEns(List<String> fieldEnList) {
List<Field> fieldList = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
Long organId = SessionManager.getSession().getOrganId();
List<String> keys = fieldEnList.stream().map(item -> {
String fieldEnStr = Constants.fieldName.fieldEn + ":" + organId + ":" + item;
String fieldEnKey = RedisUtils.getPrimaryKey(TableEnum.T_FIELD, fieldEnStr);
return fieldEnKey;
}).collect(Collectors.toList());
fieldList = redisManager.hgetAllBatchByPrimaryKeys(keys, Field.class);
} else {
fieldList = fieldMapper.selectFieldListByEns(fieldEnList);
}
return fieldList;
}
@Override
public Field findByFieldEnbyorganId(Long organId, String fieldEn) {
Field field = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
String fieldEnStr = Constants.fieldName.fieldEn + ":" + organId + ":" + fieldEn;
String fieldEnKey = RedisUtils.getPrimaryKey(TableEnum.T_FIELD, fieldEnStr);
field = redisManager.getByPrimaryKey(fieldEnKey, Field.class);
// todo 是否需要status = 1判断
} else {
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("organId", organId);
paramMap.put("fieldEn", fieldEn);
field = fieldMapper.findByFieldEnbyorganId(paramMap);
}
return field;
}
@Override
public Field findByFieldCnbyorganId(Long organId, String fieldCn) {
Field field = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
String fieldCnStr = Constants.fieldName.fieldCn + ":" + organId + ":" + fieldCn;
String fieldCnKey = RedisUtils.getPrimaryKey(TableEnum.T_FIELD, fieldCnStr);
field = redisManager.getByPrimaryKey(fieldCnKey, Field.class);
// todo 是否需要status = 1判断
} else {
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("organId", organId);
paramMap.put("fieldCn", fieldCn);
field = fieldMapper.findByFieldCnbyorganId(paramMap);
}
return field;
}
}

View File

@@ -0,0 +1,29 @@
package com.baoying.enginex.executor.datamanage.vo;
import com.baoying.enginex.executor.datamanage.model.Field;
import java.util.List;
public class FieldEnumVo {
private Field field;
private List<String> enums;
public Field getField() {
return field;
}
public void setField(Field field) {
this.field = field;
}
public List<String> getEnums() {
return enums;
}
public void setEnums(List<String> enums) {
this.enums = enums;
}
}

View File

@@ -0,0 +1,150 @@
package com.baoying.enginex.executor.datamanage.vo;
import java.util.Date;
public class FieldExcelVo {
/**
* 主键
* */
private Integer id;
/**
* 字段英文名
* */
private String fieldEn;
/**
* 字段中文名
* */
private String fieldCn;
/**
* 字段类型名称
* */
private String fieldType;
/**
* 字段存值类型
* */
private String valueType;
/**
* 字段约束范围
* */
private String valueScope;
/**
* 是否衍生字段
* */
private String isDerivative;
/**
* 是否输出字段
* */
private String isOutput;
/**
* 衍生字段公式
* */
private String formula;
/**
* 创建人
* */
private String author;
/**
* 创建时间
* */
private Date created;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getFieldEn() {
return fieldEn;
}
public void setFieldEn(String fieldEn) {
this.fieldEn = fieldEn;
}
public String getFieldCn() {
return fieldCn;
}
public void setFieldCn(String fieldCn) {
this.fieldCn = fieldCn;
}
public String getFieldType() {
return fieldType;
}
public void setFieldType(String fieldType) {
this.fieldType = fieldType;
}
public String getValueType() {
return valueType;
}
public void setValueType(String valueType) {
this.valueType = valueType;
}
public String getValueScope() {
return valueScope;
}
public void setValueScope(String valueScope) {
this.valueScope = valueScope;
}
public String getIsDerivative() {
return isDerivative;
}
public void setIsDerivative(String isDerivative) {
this.isDerivative = isDerivative;
}
public String getIsOutput() {
return isOutput;
}
public void setIsOutput(String isOutput) {
this.isOutput = isOutput;
}
public String getFormula() {
return formula;
}
public void setFormula(String formula) {
this.formula = formula;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
}

View File

@@ -0,0 +1,89 @@
package com.baoying.enginex.executor.datamanage.vo;
import java.io.Serializable;
public class FieldFormulaVo implements Serializable {
private static final long serialVersionUID = 1L;
// [{fvalue: "0",formula: "a",farr: [{fieldCN:"引擎字段1-1",fieldCond:[{"inputOne":"c","inputThree":"5"},{"inputOne":"b","inputThree":"12"}]},{fieldCN:"通用字段2贷前",fieldCond:[{"inputOne":"(30,40]","inputThree":"5"},{"inputOne":"[45,51)","inputThree":"12"}]}]}];
/**
* 衍生字段公式设置对应的值
* */
private String fvalue;
/**
* 衍生字段公式
* */
private String formula;
/**
* 衍生字段公式里字段的条件区域设置
* */
private Integer idx;
/**
* 衍生字段公式里字段的条件区域设置
* */
private String farr;
/**
* 衍生字段公式里条件区域设置的某个字段中文名
* */
private String fieldCN;
/**
* 衍生字段公式里条件区域设置的某个字段的具体设置
* */
private String fieldCond;
public String getFvalue() {
return fvalue;
}
public void setFvalue(String fvalue) {
this.fvalue = fvalue;
}
public String getFormula() {
return formula;
}
public void setFormula(String formula) {
this.formula = formula;
}
public Integer getIdx() {
return idx;
}
public void setIdx(Integer idx) {
this.idx = idx;
}
public String getFarr() {
return farr;
}
public void setFarr(String farr) {
this.farr = farr;
}
public String getFieldCN() {
return fieldCN;
}
public void setFieldCN(String fieldCN) {
this.fieldCN = fieldCN;
}
public String getFieldCond() {
return fieldCond;
}
public void setFieldCond(String fieldCond) {
this.fieldCond = fieldCond;
}
}

View File

@@ -0,0 +1,108 @@
package com.baoying.enginex.executor.datamanage.vo;
import java.io.Serializable;
public class FieldSubCondVo implements Serializable{
private static final long serialVersionUID = 1L;
//[{"fieldId":"43","operator":"in","fieldValue":"b","logical":"and"}]
/**
* 条件字段编号
* */
private Integer fieldId;
/**
* 条件字段的运算符
* */
private String operator;
/**
* 条件字段的条件设置值
* */
private String fieldValue;
/**
* 条件字段间的逻辑符
* */
private String logical;
/**
* 条件字段的值类型
* */
private Integer valueType;
/**
* 条件字段的取值范围
* */
private String valueScope;
/**
* 条件字段的取值范围拆解后的数组
* */
private String[] values;
/**
* 条件字段的字段名
*/
private String fieldCn;
public Integer getFieldId() {
return fieldId;
}
public void setFieldId(Integer fieldId) {
this.fieldId = fieldId;
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public String getFieldValue() {
return fieldValue;
}
public void setFieldValue(String fieldValue) {
this.fieldValue = fieldValue;
}
public String getLogical() {
return logical;
}
public void setLogical(String logical) {
this.logical = logical;
}
public Integer getValueType() {
return valueType;
}
public void setValueType(Integer valueType) {
this.valueType = valueType;
}
public String getValueScope() {
return valueScope;
}
public void setValueScope(String valueScope) {
this.valueScope = valueScope;
}
public String[] getValues() {
if(valueType == 3){
values = valueScope.split(",");
}else{
values = new String[]{valueScope};
}
return values;
}
public void setValues(String[] values) {
this.values = values;
}
public String getFieldCn() {
return fieldCn;
}
public void setFieldCn(String fieldCn) {
this.fieldCn = fieldCn;
}
}

View File

@@ -0,0 +1,20 @@
package com.baoying.enginex.executor.engine.consts;
public class EngineConst {
/**
* 版本部署状态
*/
public static final int BOOT_STATE_DEPLOY = 1;
/**
* 版本未部署状态
*/
public static final int BOOT_STATE_UNDEPLOY = 0;
/**
* 决策选项结果集key
*/
public static final String DECISION_COLLECTION_KEY = "formulaList";
}

View File

@@ -0,0 +1,29 @@
package com.baoying.enginex.executor.engine.consts;
public class EngineMsg {
/**
* 部署成功
*/
public static final int STATUS_SUCCESS = 1;
public static final String DEPLOY_SUCCESS = "部署成功!";
public static final String UNDEPLOY_SUCCESS = "当前版本已停用!";
/**
* 部署失败
*/
public static final int STATUS_FAILED = 0;
public static final String DEPLOY_FAILED = "部署失败!";
public static final String UNDEPLOY_FAILED = "停用当前版本失败!";
public static final String DELETE_RUNNING_FAILED = "当前版本正在运行,不能删除!";
public static final String DELETE_VERSION_SUCCESS = "当前版本删除成功!";
public static final String DELETE_VERSION_FAILED = "未知异常,当前版本删除失败!";
}

View File

@@ -0,0 +1,151 @@
package com.baoying.enginex.executor.engine.consts;
public class EngineOperator {
/*---------------------------- 关系运算符 ----------------------------*/
public static final String OPERATOR_AND_RELATION = "&&";
public static final String OPERATOR_OR_RELATION = "||";
public static final String OPERATOR_NOT_RELATION = "!";
public static final String OPERATOR_EQUALS_RELATION = "==";
public static final String OPERATOR_GREATER_RELATION = ">";
public static final String OPERATOR_GREATER_EQUALS_RELATION = ">=";
public static final String OPERATOR_LESS_RELATION = "<";
public static final String OPERATOR_LESS_EQUALS_RELATION = "<=";
public static final String OPERATOR_NOT_EQUALS_RELATION = "!=";
public static final String OPERATOR_AND_STRING_RELATION = "AND";
public static final String OPERATOR_OR_STRING_RELATION = "OR";
/*---------------------------- 数学运算符 ----------------------------*/
public static final String OPERATOR_ADD_MATH = "+";
public static final String OPERATOR_MINUS_MATH = "-";
public static final String OPERATOR_MULITI_MATH = "*";
public static final String OPERATOR_DIVIDE_MATH = "/";
public static final String OPERATOR_MODULU_MATH = "%";
public static final String OPERATOR_ABS_MATH = "abs";
public static final String OPERATOR_ACOS_MATH = "acos";
public static final String OPERATOR_ASIN_MATH = "asin";
public static final String OPERATOR_ATAN_MATH = "atan";
public static final String OPERATOR_ATAN2_MATH = "atan2";
public static final String OPERATOR_AVERAGE_MATH = "avg";
public static final String OPERATOR_CEIL_MATH = "ceil";
public static final String OPERATOR_COS_MATH = "cos";
public static final String OPERATOR_EXP_MATH = "exp";
public static final String OPERATOR_FLOOR_MATH = "floor";
public static final String OPERATOR_IEEE_MATH = "IEEEremainder";
public static final String OPERATOR_LN_MATH = "ln";
public static final String OPERATOR_LOG_MATH = "log";
public static final String OPERATOR_MAX_MATH = "max";
public static final String OPERATOR_MIN_MATH = "min";
public static final String OPERATOR_POW_MATH = "pow";
public static final String OPERATOR_RANDOM_MATH = "random";
public static final String OPERATOR_RINT_MATH = "rint";
public static final String OPERATOR_ROUND_MATH = "round";
public static final String OPERATOR_SIN_MATH = "sin";
public static final String OPERATOR_SQRT_MATH = "sqrt";
public static final String OPERATOR_SUM_MATH = "sum";
public static final String OPERATOR_TAN_MATH = "tan";
public static final String OPERATOR_TODEGREES_MATH = "toDegrees";
public static final String OPERATOR_TORADIANS_MATH = "toRadians";
/*---------------------------- 字符串运算符 ----------------------------*/
public static final String OPERATOR_CHARAT_STRING = "charAt";
public static final String OPERATOR_COMPARE_STRING = "compareTo";
public static final String OPERATOR_CTIC_STRING = "compareToIgnoreCase";
public static final String OPERATOR_CONCAT_STRING = "concat";
public static final String OPERATOR_ENDSWITH_STRING = "endsWith";
public static final String OPERATOR_EIC_STRING = "equalsIgnoreCase";
public static final String OPERATOR_EVAL_STRING = "eval";
public static final String OPERATOR_INDEXOF_STRING = "indexOf";
public static final String OPERATOR_LASTINDEXOF_STRING = "lastIndexOf";
public static final String OPERATOR_LENGTH_STRING = "length";
public static final String OPERATOR_REPLACE_STRING = "replace";
public static final String OPERATOR_STARTSWITH_STRING = "startsWith";
public static final String OPERATOR_SUB_STRING = "substring";
public static final String OPERATOR_TLC_STRING = "toLowerCase";
public static final String OPERATOR_TUC_STRING = "toUpperCase";
public static final String OPERATOR_TRIM_STRING = "trim";
public static final String OPERATOR_CONTAINS_STRING = "contains";
public static final String OPERATOR_UNCONTAINS_STRING = "notContains";
public static final String OPERATOR_EQUALS_STRING = "equals";
public static final String OPERATOR_UNEQUALS_STRING = "notEquals";
/*---------------------------- 符号 ----------------------------*/
public static final String OPERATOR_LEFT_BRACE = "{";
public static final String OPERATOR_RIGHT_BRACE = "}";
public static final String OPERATOR_VARIABLE_LEFT = "#"+OPERATOR_LEFT_BRACE;
public static final String OPERATOR_VARIABLE_RIGHT = "}";
public static final String OPERATOR_LEFT_PARENTHESES = "(";
public static final String OPERATOR_RIGHT_PARENTHESES = ")";
public static final String OPERATOR_LEFT_BRACKET = "[";
public static final String OPERATOR_RIGHT_BRACKET = "]";
}

View File

@@ -0,0 +1,47 @@
package com.baoying.enginex.executor.engine.consts;
public class EnumConst {
public static final String NODE_START = "开始";
public static final String NODE_POLICY = "政策规则";
public static final String NODE_CLASSIFY = "客户分群";
public static final String NODE_SCORECARD = "评分卡";
public static final String NODE_BLACK = "黑名单";
public static final String NODE_WHITE = "白名单";
public static final String NODE_SANDBOX = "沙盒比例";
public static final String NODE_CREDIT_LEVEL = "信用评级";
public static final String NODE_DECISION = "决策选项";
public static final String NODE_QUOTA_CALC = "额度计算";
public static final String NODE_REPORT = "报表分析";
public static final String NODE_CUSTOMIZE = "自定义按钮";
public static final String NODE_COMPLEXRULE = "复杂规则";
public static final String NODE_CHILD_ENGINE = "子引擎";
public static final String NODE_MODEL = "模型";
public static final String DECISION_TABLES = "决策表";
public static final String DECISION_TREE = "决策树";
public static final String NODE_RPC = "远程调用";
public static final String NODE_PARALLEL = "并行";
public static final String NODE_AGGREGATION = "聚合";
public static final String NODE_CHAMPION_CHALLENGE= "冠军挑战";
}

View File

@@ -0,0 +1,119 @@
package com.baoying.enginex.executor.engine.controller;
import com.alibaba.fastjson.JSONObject;
import com.baoying.enginex.executor.engine.model.DecisionReqModel;
import com.baoying.enginex.executor.engine.service.EngineApiService;
import com.baoying.enginex.executor.engine.thread.EngineCallable;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@Controller
@RequestMapping("/QueryString")
public class ApiController {
private static final Logger logger = LoggerFactory.getLogger(ApiController.class);
@Autowired
public EngineApiService engineApiService;
@RequestMapping(value = "/decision", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json;charset=UTF-8")
@ResponseBody
public String decision(String ts, String nonce, String act, String pid, String uid, String sign, String token, String paramJson, String fields) {
logger.info("请求参数--" + "ts:" + ts + ",nonce:" + nonce + ",act:" + act + ",pid:" + pid + ",uid:" + uid + ", sign:" + sign + ",token:" + token + ",paramJson" + paramJson);
Map<String, Object> map = new HashMap<>();
map.put("ts", ts);
map.put("nonce", nonce);
map.put("act", act);
map.put("pid", pid);
map.put("uid", uid);
map.put("token", token);
JSONObject jsonObject = JSONObject.parseObject(paramJson);
if (jsonObject.getInteger("reqType") == 2) {
map.put("version", jsonObject.getInteger("version"));
map.put("subversion", jsonObject.getInteger("subversion"));
}
map.put("reqType", jsonObject.getInteger("reqType"));
map.put("engineId", jsonObject.getLong("engineId"));
map.put("organId", jsonObject.getLong("organId"));
map.put("sign", jsonObject.getString("sign"));
Map<String, Object> requestFields = new HashMap<>();
if(StringUtils.isNotBlank(fields)){
requestFields = JSONObject.parseObject(fields, Map.class);
}
map.put("fields", requestFields);
String result = engineApiService.engineApi(map);
logger.info("uid:" + uid + " 响应参数--" + "result:" + result);
return result;
}
@RequestMapping(value = "/batchDecision", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json;charset=UTF-8")
@ResponseBody
public String batchDecision(HttpServletResponse response, String ts, String nonce, String act, String sign, String token, int reqType, Long engineId, Long organId, String paramJson) {
List<JSONObject> resultList = new ArrayList<>();
Map<String, Object> resultMap = new HashMap<>();
List<Map<String, Object>> list = new ArrayList<>();
List<DecisionReqModel> reqModelList = JSONObject.parseArray(paramJson, DecisionReqModel.class);
for (DecisionReqModel reqModel : reqModelList) {
Map<String, Object> map = new HashMap<>();
map.put("ts", ts);
map.put("nonce", nonce);
map.put("act", act);
map.put("token", token);
map.put("reqType", reqType);
map.put("engineId", engineId);
map.put("organId", organId);
map.put("sign", sign);
map.put("pid", reqModel.getPid());
map.put("uid", reqModel.getUid());
Map<String, Object> requestFields = new HashMap<>();
if(reqModel.getFields() != null){
requestFields = JSONObject.parseObject(JSONObject.toJSONString(reqModel.getFields()), Map.class);
}
map.put("fields", requestFields);
list.add(map);
}
List<Future<String>> futureList = new ArrayList<>();
ExecutorService executorService = Executors.newFixedThreadPool(10);
for(Map<String, Object> paramMap : list){
futureList.add(executorService.submit(new EngineCallable(paramMap)));
}
// 获取线程执行结果
for (final Future<String> future : futureList) {
try {
final String str = future.get(5, TimeUnit.MINUTES);
resultList.add(JSONObject.parseObject(str));
} catch (Exception e) {
boolean cancelResult = future.cancel(true);
logger.error("取消结果(" + cancelResult + ")" + e.getMessage(), e);
}
}
String result = JSONObject.toJSONString(resultList);
resultMap.put("result", resultList);
logger.info(" 响应参数--" + "result:" + result);
return result;
}
}

View File

@@ -0,0 +1,70 @@
package com.baoying.enginex.executor.engine.controller;
import com.baoying.enginex.executor.common.session.SessionData;
import com.baoying.enginex.executor.common.session.SessionManager;
import com.baoying.enginex.executor.engine.model.request.DecisionApiBizData;
import com.baoying.enginex.executor.engine.model.request.DecisionApiRequest;
import com.baoying.enginex.executor.engine.service.EngineApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/runner")
public class DecisionController {
private static final Logger logger = LoggerFactory.getLogger(DecisionController.class);
@Autowired
public EngineApiService engineApiService;
@RequestMapping(value = "/decision", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public String decision(@RequestBody DecisionApiRequest apiRequest) {
long start = System.currentTimeMillis();
DecisionApiBizData bizData = apiRequest.getBiz_data();
Map<String, Object> map = new HashMap<>();
map.put("pid", bizData.getBusinessId());
map.put("uid", "");
map.put("reqType", 1);
map.put("engineId", bizData.getEngineId());
map.put("organId", bizData.getOrganId());
SessionData sessionData = new SessionData();
sessionData.setOrganId(bizData.getOrganId());
sessionData.setEngineId(bizData.getEngineId());
sessionData.setReqType(1);
SessionManager.setSession(sessionData);
if(bizData.getFields() != null){
map.put("fields", bizData.getFields());
} else {
map.put("fields", new HashMap<>());
}
String result = engineApiService.engineApi(map);
long end = System.currentTimeMillis();
logger.info("============ 接口调用耗时:{}ms ============", (end -start));
return result;
}
@RequestMapping(value = "/batchExecute", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public List batchExecute(@RequestBody List<DecisionApiRequest> requestList){
List<String> list = new ArrayList<>();
for (DecisionApiRequest apiRequest : requestList) {
String decision = this.decision(apiRequest);
list.add(decision);
}
return list;
}
}

View File

@@ -0,0 +1,23 @@
package com.baoying.enginex.executor.engine.enums;
public enum CallBackTypeEnum {
SYNC(1,"同步"),
ASYNC(2,"异步");
private int code;
private String message;
CallBackTypeEnum(int code, String message) {
this.code = code;
this.message = message;
}
public int getCode() {
return code;
}
public String getMessage() {
return message;
}
}

View File

@@ -0,0 +1,125 @@
package com.baoying.enginex.executor.engine.enums;
import com.baoying.enginex.executor.engine.consts.EnumConst;
public enum NodeTypeEnum {
/**
* 开始节点
*/
START(1, EnumConst.NODE_START),
/**
* 规则节点
*/
POLICY(2,EnumConst.NODE_POLICY),
/**
* 分组节点
*/
CLASSIFY(3, EnumConst.NODE_CLASSIFY),
/**
* 评分卡节点
*/
SCORECARD(4,EnumConst.NODE_SCORECARD),
/**
* 黑名单节点
*/
BLACKLIST(5,EnumConst.NODE_BLACK),
/**
* 白名单节点
*/
WHITELIST(6,EnumConst.NODE_WHITE),
/**
* 沙盒节点
*/
SANDBOX(7,EnumConst.NODE_SANDBOX),
/**
* 信用评级节点
*/
CREDITLEVEL(8,EnumConst.NODE_CREDIT_LEVEL),
/**
* 决策选项节点
*/
DECISION(9,EnumConst.NODE_DECISION),
/**
* 额度计算节点
*/
QUOTACALC(10,EnumConst.NODE_QUOTA_CALC),
/**
* 报表分析节点
*/
REPORT(11,EnumConst.NODE_REPORT),
/**
* 自定义节点
*/
CUSTOMIZE(12,EnumConst.NODE_CUSTOMIZE),
/**
* 复杂规则
*/
NODE_COMPLEXRULE(13,EnumConst.NODE_COMPLEXRULE),
/**
* 子引擎
*/
CHILD_ENGINE(14,EnumConst.NODE_CHILD_ENGINE),
/**
* 模型
*/
MODEL(15,EnumConst.NODE_MODEL),
/**
* 决策表
*/
DECISION_TABLES(16,EnumConst.DECISION_TABLES),
/**
* 决策树
*/
DECISION_TREE(17,EnumConst.DECISION_TREE),
/**
* 远程调用
*/
RPC(18, EnumConst.NODE_RPC),
/**
* 并行节点
*/
PARALLEL(19, EnumConst.NODE_PARALLEL),
/**
* 聚合节点
*/
AGGREGATION(20, EnumConst.NODE_AGGREGATION),
/**
* 冠军挑战节点
*/
CHAMPION_CHALLENGE(21, EnumConst.NODE_CHAMPION_CHALLENGE);
private int value;
private String type;
private NodeTypeEnum(int value, String type)
{
this.value = value;
this.type = type;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public static NodeTypeEnum adapad(int value) {
for (NodeTypeEnum nodeTypeEnum : NodeTypeEnum.values()) {
if (nodeTypeEnum.getValue() == value) {
return nodeTypeEnum;
}
}
return null;
}
}

View File

@@ -0,0 +1,9 @@
package com.baoying.enginex.executor.engine.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baoying.enginex.executor.engine.model.Engine;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface EngineMapper extends BaseMapper<Engine> {
}

View File

@@ -0,0 +1,18 @@
package com.baoying.enginex.executor.engine.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baoying.enginex.executor.engine.model.EngineNode;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface EngineNodeMapper extends BaseMapper<EngineNode> {
/**
* 根据版本id获取版本下的所有节点
* @param engineVersionId
* @return
*/
List<EngineNode> getEngineNodeListByVersionId(@Param("engineVersionId") Long engineVersionId);
}

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.engine.mapper.EngineNodeMapper">
<cache></cache>
<resultMap id="EngineNodeMap" type="engineNode">
<id column="node_id" jdbcType="INTEGER" property="nodeId" />
<result column="version_id" jdbcType="INTEGER" property="versionId" />
<result column="parent_id" jdbcType="VARCHAR" property="parentId" />
<result column="node_name" jdbcType="VARCHAR" property="nodeName" />
<result column="node_code" jdbcType="VARCHAR" property="nodeCode" />
<result column="node_order" jdbcType="INTEGER" property="nodeOrder" />
<result column="node_type" jdbcType="INTEGER" property="nodeType" />
<result column="node_x" jdbcType="DECIMAL" property="nodeX" />
<result column="node_y" jdbcType="DECIMAL" property="nodeY" />
<result column="node_json" jdbcType="LONGVARCHAR" property="nodeJson" />
<result column="node_script" jdbcType="LONGVARCHAR" property="nodeScript" />
<result column="next_nodes" jdbcType="LONGVARCHAR" property="nextNodes" />
<result column="params" jdbcType="LONGVARCHAR" property="params" />
<result column="snapshot" jdbcType="LONGVARCHAR" property="snapshot" />
</resultMap>
<sql id="Base_Column_List">
node_id, parent_id, version_id, node_name, node_code, node_order, node_type, node_x, node_y,node_json,node_script,next_nodes,params,snapshot
</sql>
<select id="getEngineNodeListByVersionId" parameterType="long" resultMap="EngineNodeMap">
select <include refid="Base_Column_List"/> from t_engine_node where version_id =#{engineVersionId}
ORDER BY node_order ASC
</select>
</mapper>

View File

@@ -0,0 +1,72 @@
package com.baoying.enginex.executor.engine.mapper;
import com.baoying.enginex.executor.engine.model.EngineResultSet;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface EngineResultSetMapper {
/**
*
* 增加结果集
* @param resultSet 结果集对象
* @return 返回结果
* @see
*/
int insertResultSet(EngineResultSet resultSet);
/**
*
* 查询结果集列表
* @param resultSet 查询对象
* @return 返回结果集
* @see
*/
List<EngineResultSet> getResultSetByList(EngineResultSet resultSet);
/**
* 根据引擎编号和时间段获取结果集数据
* @param map
* @return
*/
List<EngineResultSet> getEngineResultSetBySegment(Map map);
/**
*
* 通过主键编号得到
* @param resultSet 对象
* @return 返回对象
* @see
*/
EngineResultSet getResultSetById(EngineResultSet resultSet);
List<EngineResultSet> getResultSetDetailsById(long resultSetId);
/**
* 查找引擎id的批量测试结果
* yuanlinfeng
* @param resultSetId
* @return
*/
List<EngineResultSet> getBatchTestResultSetByEngineId(Map<String, Object> paramMap);
/**
* 查找引擎批量测试批次号的所有测试结果
* yuanlinfeng
* @param resultSetId
* @return
*/
List<EngineResultSet> getBatchTestResultSetByBatchNo(Map<String, Object> paramMap);
/**
* 更新结果出参
* @param resultSet
*/
void updateResultOutput(EngineResultSet resultSet);
void updateResultById(@Param("resultId") Integer resultId, @Param("rowKeyStr") String rowKeyStr);
}

View File

@@ -0,0 +1,223 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.engine.mapper.EngineResultSetMapper">
<resultMap type="engineresultset" id="engineresultsetMap">
<id column="id" property="id"/>
<result column="input" property="input"/>
<result column="create_datetime" property="create_datetime"/>
<result column="result" property="result"/>
<result column="engine_id" property="engine_id"/>
<result column="uuid" property="uuid"/>
<result column="engine_version" property="engine_version"/>
<result column="engine_name" property="engine_name"/>
<result column="engine_code" property="engine_code"/>
<result column="type" property="type"/>
<result column="sub_version" property="subVersion"/>
<result column="scorecardscore" property="scorecardscore"/>
<result column="batch_no" property="batchNo"/>
<result column="datilResult" property="datilResult"/>
<result column="startTime" property="startTime"/>
<result column="costTime" property="costTime"/>
<collection property="resultSetList" column="id" select="selectResultSetList" ofType="resultsetlist" javaType="ArrayList" />
</resultMap>
<resultMap type="resultsetlist" id="resultSetListResult">
<id column="subId" property="id"/>
<result column="subType" property="type"/>
<result column="code" property="code"/>
<result column="name" property="name"/>
<result column="description" property="description"/>
<result column="resultset_id" property="resultsetId"/>
<result column="expression" property="expression"/>
</resultMap>
<select id="selectResultSetList" parameterType="Long" resultType="engineresultset" resultMap="resultSetListResult" >
select
r.id,r.input,r.create_datetime,r.result,r.engine_id,r.uuid,r.engine_version,r.engine_name,r.engine_code,
r.type,r.sub_version,r.scorecardscore,
s.id as subId,s.type as subType,s.code,s.name,s.description,s.resultset_id,s.expression
from t_resultset r join t_resultset_list s on r.id = s.resultset_id where r.id = #{resultSetId} order by r.id asc
</select>
<select id="getResultSetDetailsById" parameterType="Long" resultMap="engineresultsetMap">
select *
from t_resultset
where id = #{resultSetId}
</select>
<!-- 新增引擎并返回ID -->
<insert id="insertResultSet" parameterType="engineresultset" useGeneratedKeys="true" keyProperty="id">
INSERT INTO
t_resultset
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="uid != null">
uid,
</if>
<if test="pid != null">
pid,
</if>
<if test="input != null">
input,
</if>
<if test="output != null">
output,
</if>
<if test="result != null">
result,
</if>
<if test="engine_id != null">
engine_id,
</if>
<if test="uuid != null">
uuid,
</if>
<if test="engine_version != null">
engine_version,
</if>
<if test="engine_name != null">
engine_name,
</if>
<if test="engine_code != null">
engine_code,
</if>
<if test="type != null">
type,
</if>
<if test="subVersion != null">
sub_version,
</if>
<if test="scorecardscore != null">
scorecardscore,
</if>
<if test="batchNo != null">
batch_no,
</if>
<if test="datilResult != null">
datilResult,
</if>
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="uid != null">
#{uid},
</if>
<if test="pid != null">
#{pid},
</if>
<if test="input != null">
#{input},
</if>
<if test="output != null">
#{output},
</if>
<if test="result != null">
#{result},
</if>
<if test="engine_id != null">
#{engine_id},
</if>
<if test="uuid != null">
#{uuid},
</if>
<if test="engine_version != null">
#{engine_version},
</if>
<if test="engine_name != null">
#{engine_name},
</if>
<if test="engine_code != null">
#{engine_code},
</if>
<if test="type != null">
#{type},
</if>
<if test="subVersion != null">
#{subVersion},
</if>
<if test="scorecardscore != null">
#{scorecardscore},
</if>
<if test="batchNo != null">
#{batchNo},
</if>
<if test="datilResult != null">
#{datilResult},
</if>
</trim>
</insert>
<select id="getResultSetByList" parameterType="engineresultset" resultMap="engineresultsetMap" >
SELECT
*
FROM
t_engine
where
status>-1 and
organ_id =#{organId}
<if test="startDate != null and startDate !=''">
<![CDATA[ and create_datetime >= #{startDate} ]]>
</if>
<if test="endDate != null and endDate !=''">
<![CDATA[ and create_datetime <= #{endDate} ]]>
</if>
order by create_datetime desc
</select>
<select id="getEngineResultSetBySegment" parameterType="map" resultMap="engineresultsetMap" >
SELECT
*
FROM
t_resultset
where engine_id = #{engineId}
<if test="startDate != null and startDate !=''">
<![CDATA[ and create_datetime >= #{startDate} ]]>
</if>
<if test="endDate != null and endDate !=''">
<![CDATA[ and create_datetime <= #{endDate} ]]>
</if>
order by create_datetime desc
</select>
<select id="getResultSetById" parameterType="engineresultset" resultMap="engineresultsetMap">
select * from t_resultset where id = #{id}
</select>
<select id="getBatchTestResultSetByEngineId" parameterType="map" resultMap="engineresultsetMap">
select batch_no, engine_id, engine_name, startTime, costTime
from(
select rs.batch_no, e.id as engine_id, e.name as engine_name
, min(rs.create_datetime) as startTime
, TIMESTAMPDIFF(second,min(rs.create_datetime),max(rs.create_datetime)) as costTime
from t_resultset rs, t_engine e
where rs.engine_id = e.id
and ( batch_no is not null and batch_no != '' )
and e.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and rs.engine_id = #{engineId}
group by rs.batch_no, e.id, e.name
)x
order by x.startTime desc
</select>
<select id="getBatchTestResultSetByBatchNo" parameterType="map" resultMap="engineresultsetMap">
select rs.*
from t_resultset rs, t_engine e
where rs.engine_id = e.id
and e.organ_id = ( select organ_id from t_user where user_id = #{userId} )
and rs.batch_no = #{batchNo}
</select>
<update id="updateResultOutput" parameterType="engineresultset">
update t_resultset t set t.`output` = #{output} where t.`id` = #{id}
</update>
<update id="updateResultById">
UPDATE t_resultset
set hbase_row_key = #{rowKeyStr}
where id = #{resultId}
</update>
</mapper>

View File

@@ -0,0 +1,27 @@
package com.baoying.enginex.executor.engine.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baoying.enginex.executor.engine.model.EngineVersion;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
@Mapper
public interface EngineVersionMapper extends BaseMapper<EngineVersion> {
/**
* 获取引擎正在运行中的版本
* @param engineId
* @return
*/
EngineVersion getRunningVersion(@Param("engineId") Long engineId);
/**
* 获取指定版本信息
* @param paramMap
* @return
*/
EngineVersion getTargetEngineVersion(Map<String, Object> paramMap);
}

View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.baoying.enginex.executor.engine.mapper.EngineVersionMapper">
<cache></cache>
<resultMap id="EngineVersionMap" type="EngineVersion">
<id column="version_id" jdbcType="INTEGER" property="versionId" />
<result column="engine_id" jdbcType="INTEGER" property="engineId" />
<result column="version" jdbcType="INTEGER" property="version" />
<result column="sub_version" jdbcType="INTEGER" property="subVersion" />
<result column="boot_state" jdbcType="INTEGER" property="bootState" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="layout" jdbcType="INTEGER" property="layout" />
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="create_time" jdbcType="VARCHAR" property="createTime" />
<result column="latest_user" jdbcType="INTEGER" property="latestUser" />
<result column="latest_time" jdbcType="VARCHAR" property="latestTime" />
<result column="engineName" jdbcType="VARCHAR" property="engineName" />
<result column="description" jdbcType="VARCHAR" property="engineDesc" />
<collection property="engineNodeList" ofType="engineNode" column="version_id" select ="com.baoying.enginex.executor.engine.mapper.EngineNodeMapper.getEngineNodeListByEngineVersionId"></collection>
</resultMap>
<sql id="Base_Column_List">
version_id, engine_id, version, boot_state, status, layout, user_id, create_time,
latest_user, latest_time, sub_version
</sql>
<select id="getTargetEngineVersion" parameterType="java.util.Map" resultType="EngineVersion">
select
<include refid="Base_Column_List" />
from t_engine_version
where engine_id = #{engineId,jdbcType=INTEGER}
and version = #{version,jdbcType=INTEGER}
and sub_version = #{subversion,jdbcType=INTEGER}
order by sub_version desc
limit 1
</select>
<select id="getRunningVersion" parameterType="java.lang.Long" resultType="EngineVersion">
select
<include refid="Base_Column_List" />
from t_engine_version
where engine_id = #{engineId,jdbcType=INTEGER}
and boot_state = 1
</select>
</mapper>

View File

@@ -0,0 +1,42 @@
package com.baoying.enginex.executor.engine.model;
import java.util.Map;
public class ComplexRule {
private Map<String,Object> result;
private String out;
private Map<String, Object> returnResult;
public Map<String, Object> getReturnResult() {
return returnResult;
}
public void setReturnResult(Map<String, Object> returnResult) {
this.returnResult = returnResult;
}
public Map<String, Object> getResult() {
return result;
}
public void setResult(Map<String, Object> result) {
this.result = result;
}
public String getOut() {
return out;
}
public void setOut(String out) {
this.out = out;
}
}

View File

@@ -0,0 +1,62 @@
package com.baoying.enginex.executor.engine.model;
import java.util.Map;
public class DecisionOptions {
private String code;//决策选项code
private String name;//决策选项名称
private Map<String , Object> inFields;//输入字段
private Map<String, Object> outFields;//输出字段
private Integer fType;//输出字段类型
private Long nodId;//节点id
private String fieldScope;
public String getFieldScope() {
return fieldScope;
}
public void setFieldScope(String fieldScope) {
this.fieldScope = fieldScope;
}
public Long getNodId() {
return nodId;
}
public void setNodId(Long nodId) {
this.nodId = nodId;
}
public Integer getfType() {
return fType;
}
public void setfType(Integer fType) {
this.fType = fType;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, Object> getInFields() {
return inFields;
}
public void setInFields(Map<String, Object> inFields) {
this.inFields = inFields;
}
public Map<String, Object> getOutFields() {
return outFields;
}
public void setOutFields(Map<String, Object> outFields) {
this.outFields = outFields;
}
}

View File

@@ -0,0 +1,16 @@
package com.baoying.enginex.executor.engine.model;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import java.io.Serializable;
@Data
public class DecisionReqModel implements Serializable {
private static final long serialVersionUID = 1743177499998353115L;
private String pid;
private String uid;
private JSONObject fields;
}

View File

@@ -0,0 +1,90 @@
package com.baoying.enginex.executor.engine.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
@TableName("t_engine")
public class Engine implements Serializable {
private static final long serialVersionUID = -6611916471057697499L;
/**
* 主键id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 引擎编号
*/
private String code;
/**
* 引擎名称
*/
private String name;
/**
* 引擎描述
*/
private String description;
/**
* 引擎状态
*/
private Integer status;
/**
* 创建时间
*/
private Date createDatetime;
/**
* 修改时间
*/
private Date updateDatetime;
/**
* 创建人
*/
private Long creator;
/**
* 修改人
*/
private Long userId;
/**
* 公司编号
*/
private Long organId;
/**
* 调用方式 1同步2异步
*/
private Integer callbackType;
/**
* 回调地址
*/
private String callbackUrl;
/**
* 异常回调地址
*/
private String exceptionCallbackUrl;
/**
* 引擎版本集合
*/
@TableField(exist = false)
private List<EngineVersion> engineVersionList;
}

View File

@@ -0,0 +1,85 @@
package com.baoying.enginex.executor.engine.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
@Data
@TableName("t_engine_node")
public class EngineNode implements Serializable{
private static final long serialVersionUID = -1867357850853531748L;
/**
* 节点编号
*/
@TableId(type = IdType.AUTO)
private Long nodeId;
/**
* 版本编号
*/
private Long versionId;
/**
* 节点名称
*/
private String nodeName;
/**
* 节点code
*/
private String nodeCode;
/**
* 节点顺序
*/
private Integer nodeOrder;
/**
* 节点类型
*/
private Integer nodeType;
/**
* 节点json
*/
private String nodeJson;
/**
* 节点X轴
*/
private double nodeX;
/**
* 节点Y轴
*/
private double nodeY;
/**
* 节点脚本
*/
private String nodeScript;
/**
* 下一节点
*/
private String nextNodes;
/**
* 节点类型,图标等信息
*/
private String params;
/**
* 父节点编号
*/
private String parentId;
/**
* 节点配置快照
*/
private String snapshot;
}

View File

@@ -0,0 +1,252 @@
package com.baoying.enginex.executor.engine.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors
public class EngineResultSet {
private Integer id;
private String uid;
private String pid;
private String input;
private String output;
private Date create_datetime;
private String result;
private Long engine_id;
private Integer engine_version;
private String uuid;
private String engine_name;
private String engine_code;
private Date startDate;
private Date endDate;
private Integer type;
private Integer subVersion;
private String scorecardscore;
private String datilResult;
/**
*决策表结果
*/
private String decisionTablesResult;
/**
*决策树结果
*/
private String decisionTreeResult;
/**
* 批量测试批次号
*/
private String batchNo;
/**
* 批量测试每批测试开始时间
*/
private Date startTime;
/**
* 批量测试每批次花费时间
*/
private String costTime;
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getScorecardscore() {
return scorecardscore;
}
public void setScorecardscore(String scorecardscore) {
this.scorecardscore = scorecardscore;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getSubVersion() {
return subVersion;
}
public void setSubVersion(Integer subVersion) {
this.subVersion = subVersion;
}
private List<ResultSetList> resultSetList;
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
public String getEngine_name() {
return engine_name;
}
public void setEngine_name(String engine_name) {
this.engine_name = engine_name;
}
public String getEngine_code() {
return engine_code;
}
public void setEngine_code(String engine_code) {
this.engine_code = engine_code;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getInput() {
return input;
}
public void setInput(String input) {
this.input = input;
}
public Date getCreate_datetime() {
return create_datetime;
}
public void setCreate_datetime(Date create_datetime) {
this.create_datetime = create_datetime;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public Long getEngine_id() {
return engine_id;
}
public void setEngine_id(Long engine_id) {
this.engine_id = engine_id;
}
public Integer getEngine_version() {
return engine_version;
}
public void setEngine_version(Integer engine_version) {
this.engine_version = engine_version;
}
public List<ResultSetList> getResultSetList() {
return resultSetList;
}
public void setResultSetList(List<ResultSetList> resultSetList) {
this.resultSetList = resultSetList;
}
public String getBatchNo() {
return batchNo;
}
public void setBatchNo(String batchNo) {
this.batchNo = batchNo;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public String getCostTime() {
return costTime;
}
public void setCostTime(String costTime) {
this.costTime = costTime;
}
public String getDatilResult() {
return datilResult;
}
public void setDatilResult(String datilResult) {
this.datilResult = datilResult;
}
public String getOutput() {
return output;
}
public void setOutput(String output) {
this.output = output;
}
}

View File

@@ -0,0 +1,74 @@
package com.baoying.enginex.executor.engine.model;
import java.util.Map;
public class EngineRule {
private String refused;
private String code ;
private String policyName;
private String desc;
private String Strtus;
private Map<String, String >fields;
public String getStrtus() {
return Strtus;
}
public void setStrtus(String strtus) {
Strtus = strtus;
}
public String getRefused() {
return refused;
}
public void setRefused(String refused) {
this.refused = refused;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getPolicyName() {
return policyName;
}
public void setPolicyName(String policyName) {
this.policyName = policyName;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public Map<String, String> getFields() {
return fields;
}
public void setFields(Map<String, String> fields) {
this.fields = fields;
}
}

View File

@@ -0,0 +1,79 @@
package com.baoying.enginex.executor.engine.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
@TableName("t_engine_version")
public class EngineVersion implements Serializable {
private static final long serialVersionUID = 2923432053414979455L;
/**
* 版本编号
*/
@TableId(type = IdType.AUTO)
private Long versionId;
/**
* 引擎编号
*/
private Long engineId;
/**
* 版本号
*/
private Integer version;
/**
* 子版本
*/
private Integer subVersion;
/**
* 部署状态
*/
private Integer bootState;
/**
* 版本状态
*/
private Integer status;
/**
* 布局方式
*/
private Integer layout;
/**
* 创建者
*/
private Long userId;
/**
* 创建时间
*/
private String createTime;
/**
* 修改人
*/
private Long latestUser;
/**
* 最后修改时间
*/
private String latestTime;
/**
* 节点集合
* */
@TableField(exist = false)
private List<EngineNode> engineNodeList;
}

View File

@@ -0,0 +1,53 @@
package com.baoying.enginex.executor.engine.model;
import java.io.Serializable;
public class IndexEngineReportVo implements Serializable {
private static final long serialVersionUID = -1274492726714567316L;
private String dayTime;
private String monthTime;
private Integer engineId;
private String engineName;
private Integer useNum;
public String getDayTime() {
return dayTime;
}
public void setDayTime(String dayTime) {
this.dayTime = dayTime;
}
public String getMonthTime() {
return monthTime;
}
public void setMonthTime(String monthTime) {
this.monthTime = monthTime;
}
public Integer getEngineId() {
return engineId;
}
public void setEngineId(Integer engineId) {
this.engineId = engineId;
}
public String getEngineName() {
return engineName;
}
public void setEngineName(String engineName) {
this.engineName = engineName;
}
public Integer getUseNum() {
return useNum;
}
public void setUseNum(Integer useNum) {
this.useNum = useNum;
}
}

View File

@@ -0,0 +1,36 @@
package com.baoying.enginex.executor.engine.model;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class InputParam {
private Map<String ,Object> inputParam;
private List<Result> result;
// 数组中 符合条件的对象属性
private Map<String, Set<String>> outputParam;
public Map<String, Object> getInputParam() {
return inputParam;
}
public void setInputParam(Map<String, Object> inputParam) {
this.inputParam = inputParam;
}
public List<Result> getResult() {
return result;
}
public void setResult(List<Result> result) {
this.result = result;
}
public Map<String, Set<String>> getOutputParam() {
return outputParam;
}
public void setOutputParam(Map<String, Set<String>> outputParam) {
this.outputParam = outputParam;
}
}

View File

@@ -0,0 +1,63 @@
package com.baoying.enginex.executor.engine.model;
import java.io.Serializable;
/**
* 节点与知识库映射关系模型
* @author sunyk
*
*/
public class NodeKnowledge implements Serializable {
private static final long serialVersionUID = -55965399064577379L;
/**
* 主键编号
*/
private Long relId;
/**
* 节点编号
*/
private Long nodeId;
/**
* 知识库信息编号
*/
private Long knowledgeId;
/**
* 知识库类型1规则2评分卡
*/
private Integer knowledgeType;
public Long getRelId() {
return relId;
}
public void setRelId(Long relId) {
this.relId = relId;
}
public Long getNodeId() {
return nodeId;
}
public void setNodeId(Long nodeId) {
this.nodeId = nodeId;
}
public Long getKnowledgeId() {
return knowledgeId;
}
public void setKnowledgeId(Long knowledgeId) {
this.knowledgeId = knowledgeId;
}
public Integer getKnowledgeType() {
return knowledgeType;
}
public void setKnowledgeType(Integer knowledgeType) {
this.knowledgeType = knowledgeType;
}
}

View File

@@ -0,0 +1,63 @@
package com.baoying.enginex.executor.engine.model;
import java.util.List;
import java.util.Map;
public class Result {
private String resultType;//规则1代表加减法2拒绝规则
private Integer id;//规则编号
private String code;//规则code
private String name;
private String value;
private Map<String, Object> map;//评分
private List<EngineRule> list;
public Map<String, Object> getMap() {
return map;
}
public void setMap(Map<String, Object> map) {
this.map = map;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getResultType() {
return resultType;
}
public void setResultType(String resultType) {
this.resultType = resultType;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<EngineRule> getList() {
return list;
}
public void setList(List<EngineRule> list) {
this.list = list;
}
}

View File

@@ -0,0 +1,76 @@
package com.baoying.enginex.executor.engine.model;
import java.util.Date;
public class ResultSetList {
private Long id;
private Integer type;//1.黑名单。2.白名单。3.拒绝规则。4.加减分规则
private String code;
private String name;
private String description;
private String resultsetId;
private String expression;
private Date startDate;
private Date endDate;
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getResultsetId() {
return resultsetId;
}
public void setResultsetId(String resultsetId) {
this.resultsetId = resultsetId;
}
public String getExpression() {
return expression;
}
public void setExpression(String expression) {
this.expression = expression;
}
}

View File

@@ -0,0 +1,53 @@
package com.baoying.enginex.executor.engine.model;
public class Sandbox {
private Integer sandbox;//沙盒组编号
private Integer proportion;//沙盒占用比例
private String nextNode;//下个节点序号
private Integer sum;//分母
private Integer startNumber;//起始值
private Integer endNumberl;//终止值
public Integer getSum() {
return sum;
}
public void setSum(Integer sum) {
this.sum = sum;
}
public Integer getStartNumber() {
return startNumber;
}
public void setStartNumber(Integer startNumber) {
this.startNumber = startNumber;
}
public Integer getEndNumberl() {
return endNumberl;
}
public void setEndNumberl(Integer endNumberl) {
this.endNumberl = endNumberl;
}
public Integer getSandbox() {
return sandbox;
}
public void setSandbox(Integer sandbox) {
this.sandbox = sandbox;
}
public Integer getProportion() {
return proportion;
}
public void setProportion(Integer proportion) {
this.proportion = proportion;
}
public String getNextNode() {
return nextNode;
}
public void setNextNode(String nextNode) {
this.nextNode = nextNode;
}
}

View File

@@ -0,0 +1,49 @@
package com.baoying.enginex.executor.engine.model;
import java.util.Map;
public class ScoreCardEngine {
private String code;//评分卡编号
private String name;//评分卡名称
private String scoreCardName;//评分卡名称
private Map<String , Object> inFields;//评分可用到的字段
private Map<String, Object> outFields;//评分卡
public String getScoreCardName() {
return scoreCardName;
}
public void setScoreCardName(String scoreCardName) {
this.scoreCardName = scoreCardName;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, Object> getInFields() {
return inFields;
}
public void setInFields(Map<String, Object> inFields) {
this.inFields = inFields;
}
public Map<String, Object> getOutFields() {
return outFields;
}
public void setOutFields(Map<String, Object> outFields) {
this.outFields = outFields;
}
}

View File

@@ -0,0 +1,37 @@
package com.baoying.enginex.executor.engine.model;
public class TestRule {
private String id;
private String ruleid;
private String param;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getRuleid() {
return ruleid;
}
public void setRuleid(String ruleid) {
this.ruleid = ruleid;
}
public String getParam() {
return param;
}
public void setParam(String param) {
this.param = param;
}
}

View File

@@ -0,0 +1,18 @@
package com.baoying.enginex.executor.engine.model.request;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.Map;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = false)
public class DecisionApiBizData {
private String businessId; // 业务id
private Long organId; // 组织id
private Long engineId; // 引擎id
private Map<String, Object> fields; // 指标字段键值对
}

View File

@@ -0,0 +1,17 @@
package com.baoying.enginex.executor.engine.model.request;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = false)
public class DecisionApiRequest {
private String tp_code; // 调用方编码
private String timestamp; // 精确到毫秒
private String sign; // 签名
private String biz_enc; // biz_data加密方式0不加密1加密
private DecisionApiBizData biz_data; // 请求的业务数据json格式的字符串
}

View File

@@ -0,0 +1,8 @@
package com.baoying.enginex.executor.engine.service;
import java.util.Map;
public interface EngineApiService {
String engineApi(Map<String, Object> paramJson);
}

View File

@@ -0,0 +1,16 @@
package com.baoying.enginex.executor.engine.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baoying.enginex.executor.engine.model.EngineNode;
import java.util.List;
public interface EngineNodeService extends IService<EngineNode> {
/**
* 根据版本id获取版本下的所有节点
* @param versionId
* @return
*/
List<EngineNode> getEngineNodeListByVersionId(Long versionId);
}

View File

@@ -0,0 +1,14 @@
package com.baoying.enginex.executor.engine.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baoying.enginex.executor.engine.model.Engine;
public interface EngineService extends IService<Engine> {
/**
* 根据id查询引擎
* @param id
* @return
*/
Engine getEngineById(Long id);
}

View File

@@ -0,0 +1,17 @@
package com.baoying.enginex.executor.engine.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baoying.enginex.executor.engine.model.EngineVersion;
public interface EngineVersionService extends IService<EngineVersion> {
EngineVersion getEngineVersionById(Long versionId);
/**
* 获取引擎正在运行中的版本
* @param engineId
* @return
*/
EngineVersion getRunningVersion(Long engineId);
}

View File

@@ -0,0 +1,400 @@
package com.baoying.enginex.executor.engine.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baoying.enginex.executor.engine.enums.NodeTypeEnum;
import com.baoying.enginex.executor.engine.mapper.EngineResultSetMapper;
import com.baoying.enginex.executor.engine.model.Engine;
import com.baoying.enginex.executor.engine.model.EngineNode;
import com.baoying.enginex.executor.engine.model.EngineResultSet;
import com.baoying.enginex.executor.engine.model.EngineVersion;
import com.baoying.enginex.executor.engine.service.EngineApiService;
import com.baoying.enginex.executor.engine.service.EngineNodeService;
import com.baoying.enginex.executor.engine.service.EngineService;
import com.baoying.enginex.executor.engine.service.EngineVersionService;
import com.baoying.enginex.executor.node.service.impl.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.ListenableFutureCallback;
import org.springframework.web.client.AsyncRestTemplate;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
@Service
public class EngineApiServiceImpl implements EngineApiService {
private static final Logger logger = LoggerFactory.getLogger(EngineApiServiceImpl.class);
@Autowired
public EngineService engineService;
@Resource
public EngineVersionService engineVersionService;
@Resource
public EngineNodeService engineNodeService;
@Resource
public EngineResultSetMapper resultSetMapper;
@Autowired
private DecisionOptionsNode decisionOptionsNode;
@Autowired
private RuleSetNode ruleSetNode;
@Autowired
private GroupNode groupNode;
@Autowired
private SandboxProportionNode sandboxProportionNode;
@Autowired
private AsyncRestTemplate asyncRestTemplate;
@Override
public String engineApi(Map<String, Object> paramJson) {
logger.info("请求参数paramJson: {}", JSONObject.toJSONString(paramJson));
JSONObject jsonObject = new JSONObject();
JSONArray resultJson = new JSONArray();
Map<String, Map<String,Object>> featureMaps = new ConcurrentHashMap<>();
//时间差小于等于30分钟并且鉴权成功
if (true){
Long organId = Long.valueOf(paramJson.get("organId").toString());
Long engineId = Long.valueOf(paramJson.get("engineId").toString());
//获取引擎信息
Engine engine = engineService.getEngineById(engineId);
if(engine != null && !engine.getOrganId().equals(organId)){
// todo 校验引擎是否为该组织所属
}
//获取引擎正在运行中的版本
EngineVersion engineVersion = engineVersionService.getRunningVersion(engineId);
if (engineVersion != null) {
//返回引擎下的所有节点集合
List<EngineNode> engineNodeList = engineNodeService.getEngineNodeListByVersionId(engineVersion.getVersionId());
Map<String, EngineNode> engineNodeMap = getEngineNodeListByMap(engineNodeList);
try {
//变量池
Map<String, Object> inputParam = new ConcurrentHashMap<>();
inputParam.putAll(JSONObject.parseObject(JSONObject.toJSONString(paramJson.get("fields")), Map.class));
EngineNode engineNode = engineNodeMap.get("ND_START");
if (null != engineNode && null != engineNode.getNextNodes()) {
//返回输出结果
Map<String, Object> outMap = new ConcurrentHashMap<>();
// 记录执行前全量指标
featureMaps.put("before",inputParam);
//节点执行方法
recursionEngineNode(inputParam, engineNodeMap.get(engineNode.getNextNodes()), engineNodeMap, outMap);
jsonObject.put("status", "0x0000");
jsonObject.put("msg", "执行成功");
if (outMap.containsKey("centens") && outMap.get("centens").equals("true")) {
jsonObject.put("status", "0x0006");
jsonObject.put("msg", "获取数据失败");
jsonObject.put("data", "");
return jsonObject.toString();
}
//记录执行后的全量指标
featureMaps.put("after",inputParam);
paramJson.put("versionId",engineNode.getVersionId());
String json = JSONObject.toJSONString(inputParam);
jsonObject.put("input", JSONObject.parseObject(json));
EngineResultSet resultSet = new EngineResultSet();
resultSet.setEngine_code(engine.getCode());
resultSet.setInput(json);
resultSet.setEngine_id(engine.getId());
resultSet.setEngine_name(engine.getName());
resultSet.setType(2);
resultSet.setSubVersion(engineVersion.getSubVersion());
resultSet.setUid(String.valueOf(paramJson.get("uid")));
resultSet.setPid(String.valueOf(paramJson.get("pid")));
//决策表最终结果
if (outMap.containsKey("decisionTables")){
jsonObject.put("decisionTablesResult", outMap.get("decisionTables").toString());
resultSet.setDecisionTablesResult(outMap.get("decisionTables").toString());
}
//决策树最终结果
if (outMap.containsKey("decisionTree")){
jsonObject.put("decisionTreeResult", outMap.get("decisionTree").toString());
resultSet.setDecisionTreeResult(outMap.get("decisionTree").toString());
}
// 节点终止输出
if (outMap.containsKey("result")) {
resultSet.setResult(outMap.get("result").toString());
//决策选项最终结果
jsonObject.put("result", outMap.get("result").toString());
}
if (outMap.containsKey("blackJson")) {
resultJson.add(new JSONObject().parse(outMap.get("blackJson").toString()));
}
if (outMap.containsKey("whiteJson")) {
resultJson.add(new JSONObject().parse(outMap.get("whiteJson").toString()));
}
if (outMap.containsKey("ruleJson")) {
//规则集节点输出
JSONObject ruleJson = new JSONObject();
ruleJson.put("resultType", 2);
ruleJson.put("resultJson", outMap.get("ruleJson"));
resultJson.add(ruleJson);
}
if (outMap.containsKey("scoreJson")) {
//评分卡输出
JSONObject ruleJson = new JSONObject();
ruleJson.put("resultType", 4);
ruleJson.put("resultJson", outMap.get("scoreJson"));
resultJson.add(ruleJson);
}
if (outMap.containsKey("decisionJson")) {
//决策选项输出
JSONObject ruleJson = new JSONObject();
ruleJson.put("resultType", 9);
ruleJson.put("resultJson", outMap.get("decisionJson"));
resultJson.add(ruleJson);
}
if (outMap.containsKey("childEngineJson")) {
//子引擎节点输出
JSONObject ruleJson = new JSONObject();
ruleJson.put("resultType", 14);
ruleJson.put("resultJson", outMap.get("childEngineJson"));
resultJson.add(ruleJson);
}
if (outMap.containsKey("modelJson")) {
//模型节点输出
JSONObject ruleJson = new JSONObject();
ruleJson.put("resultType", 15);
ruleJson.put("resultJson", outMap.get("modelJson"));
resultJson.add(ruleJson);
}
if (outMap.containsKey("decisionTablesJson")) {
//决策表输出
JSONObject ruleJson = new JSONObject();
ruleJson.put("resultType", 16);
ruleJson.put("resultJson", outMap.get("decisionTablesJson"));
resultJson.add(ruleJson);
}
if (outMap.containsKey("decisionTreeJson")) {
//决策树输出
JSONObject ruleJson = new JSONObject();
ruleJson.put("resultType", 17);
ruleJson.put("resultJson", outMap.get("decisionTreeJson"));
resultJson.add(ruleJson);
}
jsonObject.put("data", resultJson);
String result = JSONObject.toJSONString(jsonObject);
JSONObject tmpJsonObject = JSONObject.parseObject(result);
tmpJsonObject.remove("input");
resultSet.setOutput(JSONObject.toJSONString(tmpJsonObject));
resultSetMapper.insertResultSet(resultSet);
Integer resultId = resultSet.getId();
// 正常返回结果回调
decisionCallback(engine.getCallbackUrl(), paramJson, result);
}
} catch (Exception e) {
logger.error("接口请求异常", e);
jsonObject.put("status", "0x0005");
jsonObject.put("msg", "执行失败");
jsonObject.put("data", "");
// 异常回调
decisionCallback(engine.getCallbackUrl(), paramJson, "执行失败");
}
} else {
jsonObject.put("status", "0x0004");
jsonObject.put("msg", "请求引擎不存在或尚未部署运行");
jsonObject.put("data", "");
}
} else {
jsonObject.put("status", "0x0001");
jsonObject.put("msg", "鉴权失败,非法调用");
jsonObject.put("data", "");
}
return jsonObject.toString();
}
/**
* 递归执行节点
* @param inputParam
* @param engineNode
* @param engineNodeMap
* @param outMap
*/
private EngineNode recursionEngineNode(Map<String, Object> inputParam, EngineNode engineNode, Map<String, EngineNode> engineNodeMap, Map<String, Object> outMap) {
logger.info("请求参数--" + "inputParam:" + JSONObject.toJSONString(inputParam));
EngineNode resultNode = null; // 结束时返回节点: 串行流程返回null、并行流程返回聚合节点
if(engineNode == null){
return null;
}
// 获取节点所需的指标
getNodeField(engineNode, inputParam);
// 执行节点逻辑
runNode(engineNode, inputParam, outMap);
//用于存储执行过的节点
List<String> executedNodeList = new ArrayList<>();
if(outMap.containsKey("executedNodes")){
executedNodeList =(List<String>) outMap.get("executedNodes");
}
executedNodeList.add(engineNode.getNodeId()+"");
// 更新执行过节点数组
outMap.put("executedNodes",executedNodeList);
// 递归执行下一个节点
if (StringUtils.isNotBlank(engineNode.getNextNodes())) {
// 串行节点执行
EngineNode nextEngineNode = engineNodeMap.get(engineNode.getNextNodes());
//如果输出的map里面有nextNode则说明有分组需要走分组下面的节点
if (outMap.containsKey("nextNode")) {
nextEngineNode = engineNodeMap.get(outMap.get("nextNode"));
outMap.remove("nextNode");
}
if(nextEngineNode!=null&&nextEngineNode.getNodeType() == NodeTypeEnum.AGGREGATION.getValue()){
// 并行节点后面的分支为多线程执行,执行到聚合节点则结束
resultNode = nextEngineNode;
} else {
resultNode = recursionEngineNode(inputParam, nextEngineNode, engineNodeMap, outMap);
}
}
return resultNode;
}
/**
* 获取节点所需的指标
* @param engineNode
* @param inputParam
*/
private void getNodeField(EngineNode engineNode, Map<String, Object> inputParam) {
switch (engineNode.getNodeType()) {
case 2:
//规则
ruleSetNode.getNodeField(engineNode, inputParam);
break;
case 3:
//分组
groupNode.getNodeField(engineNode, inputParam);
break;
case 9:
//决策选项
decisionOptionsNode.getNodeField(engineNode, inputParam);
break;
default:
break;
}
}
/**
* 执行节点逻辑
* @param engineNode
* @param inputParam
* @param outMap
*/
private void runNode(EngineNode engineNode, Map<String, Object> inputParam, Map<String, Object> outMap) {
switch (engineNode.getNodeType()) {
case 2:
//规则
ruleSetNode.runNode(engineNode, inputParam, outMap);
break;
case 3:
//分组
groupNode.runNode(engineNode, inputParam, outMap);
break;
case 7:
//沙盒比例
sandboxProportionNode.runNode(engineNode, inputParam, outMap);
break;
case 9:
//决策选项
decisionOptionsNode.runNode(engineNode, inputParam, outMap);
break;
default:
break;
}
}
/**
* 把引擎节点以序号为key放入map
*
* @param nodelist 引擎节点
* @return map
* @see
*/
private Map<String, EngineNode> getEngineNodeListByMap(List<EngineNode> nodelist) {
Map<String, EngineNode> map = new HashMap<>();
for (int i = 0; i < nodelist.size(); i++) {
map.put(nodelist.get(i).getNodeCode(), nodelist.get(i));
}
return map;
}
/**
* 决策流执行完回调(包括决策流正常返回结果回调、以及异常回调)
* @param url
* @param paramJson
* @param result
*/
private void decisionCallback(String url, Map<String, Object> paramJson, String result){
if(StringUtils.isBlank(url)){
return;
}
Map<String, String> paramMap = new HashMap<>();
paramMap.put("paramJson", JSONObject.toJSONString(paramJson));
paramMap.put("result", result);
// 设置请求头
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
// 封装请求体
JSONObject body = JSONObject.parseObject(JSONObject.toJSONString(paramMap));
// 封装参数和头信息
HttpEntity<JSONObject> httpEntity = new HttpEntity(body, httpHeaders);
ListenableFuture<ResponseEntity<String>> future = asyncRestTemplate.postForEntity(url, httpEntity, String.class);
if(future != null){
future.addCallback(new ListenableFutureCallback<ResponseEntity<String>>() {
@Override
public void onFailure(Throwable throwable) {
logger.info("引擎回调异步调用失败", throwable);
}
@Override
public void onSuccess(ResponseEntity<String> stringResponseEntity) {
String result = stringResponseEntity.getBody();
logger.info("引擎回调异步调用成功result:{}", result);
}
});
}
}
}

View File

@@ -0,0 +1,45 @@
package com.baoying.enginex.executor.engine.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baoying.enginex.executor.canal.TableEnum;
import com.baoying.enginex.executor.common.constants.Constants;
import com.baoying.enginex.executor.config.ConfigHolder;
import com.baoying.enginex.executor.engine.mapper.EngineNodeMapper;
import com.baoying.enginex.executor.engine.model.EngineNode;
import com.baoying.enginex.executor.engine.service.EngineNodeService;
import com.baoying.enginex.executor.redis.RedisManager;
import com.baoying.enginex.executor.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class EngineNodeServiceImpl extends ServiceImpl<EngineNodeMapper, EngineNode> implements EngineNodeService {
@Autowired
private ConfigHolder configHolder;
@Autowired
private RedisManager redisManager;
@Autowired
private EngineNodeMapper engineNodeMapper;
@Override
public List<EngineNode> getEngineNodeListByVersionId(Long versionId) {
List<EngineNode> engineNodeList = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
String key = RedisUtils.getForeignKey(TableEnum.T_ENGINE_NODE, versionId);
engineNodeList = redisManager.getByForeignKey(key, EngineNode.class);
if(engineNodeList != null){
// 按node_order升序排序
engineNodeList = engineNodeList.stream().sorted(Comparator.comparing(EngineNode::getNodeOrder)).collect(Collectors.toList());
}
} else {
engineNodeList = engineNodeMapper.getEngineNodeListByVersionId(versionId);
}
return engineNodeList;
}
}

View File

@@ -0,0 +1,37 @@
package com.baoying.enginex.executor.engine.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baoying.enginex.executor.canal.TableEnum;
import com.baoying.enginex.executor.common.constants.Constants;
import com.baoying.enginex.executor.config.ConfigHolder;
import com.baoying.enginex.executor.engine.mapper.EngineMapper;
import com.baoying.enginex.executor.engine.model.Engine;
import com.baoying.enginex.executor.engine.service.EngineService;
import com.baoying.enginex.executor.redis.RedisManager;
import com.baoying.enginex.executor.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class EngineServiceImpl extends ServiceImpl<EngineMapper, Engine> implements EngineService {
@Autowired
private ConfigHolder configHolder;
@Autowired
private RedisManager redisManager;
@Autowired
private EngineMapper engineMapper;
@Override
public Engine getEngineById(Long id) {
Engine engine = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
String key = RedisUtils.getPrimaryKey(TableEnum.T_ENGINE, id);
engine = redisManager.getByPrimaryKey(key, Engine.class);
} else {
engine = engineMapper.selectById(id);
}
return engine;
}
}

View File

@@ -0,0 +1,56 @@
package com.baoying.enginex.executor.engine.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baoying.enginex.executor.canal.TableEnum;
import com.baoying.enginex.executor.common.constants.Constants;
import com.baoying.enginex.executor.config.ConfigHolder;
import com.baoying.enginex.executor.engine.mapper.EngineVersionMapper;
import com.baoying.enginex.executor.engine.model.EngineVersion;
import com.baoying.enginex.executor.engine.service.EngineVersionService;
import com.baoying.enginex.executor.redis.RedisManager;
import com.baoying.enginex.executor.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public class EngineVersionServiceImpl extends ServiceImpl<EngineVersionMapper, EngineVersion> implements EngineVersionService {
@Autowired
private ConfigHolder configHolder;
@Autowired
private RedisManager redisManager;
@Autowired
private EngineVersionMapper engineVersionMapper;
@Override
public EngineVersion getEngineVersionById(Long versionId) {
EngineVersion engineVersion = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
String key = RedisUtils.getPrimaryKey(TableEnum.T_ENGINE_VERSION, versionId);
engineVersion = redisManager.getByPrimaryKey(key, EngineVersion.class);
} else {
engineVersion = engineVersionMapper.selectById(versionId);
}
return engineVersion;
}
@Override
public EngineVersion getRunningVersion(Long engineId) {
EngineVersion engineVersion = null;
if(Constants.switchFlag.ON.equals(configHolder.getCacheSwitch())){
String key = RedisUtils.getForeignKey(TableEnum.T_ENGINE_VERSION, engineId);
List<EngineVersion> list = redisManager.getByForeignKey(key, EngineVersion.class);
Optional<EngineVersion> optional = list.stream().filter(item -> item.getBootState() == 1).findFirst();
if(optional.isPresent()){
engineVersion = optional.get();
}
} else {
engineVersion = engineVersionMapper.getRunningVersion(engineId);
}
return engineVersion;
}
}

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