[feat] 初始化数据中台框架

This commit is contained in:
Kris 2024-12-17 17:38:33 +08:00
parent 0899497024
commit 26f48e6522
586 changed files with 38760 additions and 11297 deletions

View File

@ -71,31 +71,47 @@
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.5.15</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<fork>true</fork> <!-- 如果没有该配置devtools不会生效 -->
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/package.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<goals>
<goal>repackage</goal>
<goal>single</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>${project.artifactId}</warName>
</configuration>
</plugin>
<classesDirectory>target/classes/</classesDirectory>
<excludes>
<exclude>/**.yml</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>default-jar</id>
<goals>
<goal>jar</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
<finalName>${project.artifactId}</finalName>
</build>
</project>

View File

@ -0,0 +1,49 @@
<assembly>
<id>dist</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${basedir}/src/main/bin</directory>
<lineEnding>unix</lineEnding>
<outputDirectory>service</outputDirectory>
<includes>
<include>*.service</include>
</includes>
</fileSet>
<fileSet>
<directory>${basedir}/src/main/bin</directory>
<lineEnding>unix</lineEnding>
<outputDirectory/>
<fileMode>755</fileMode>
<includes>
<include>*.sh</include>
</includes>
</fileSet>
<fileSet>
<directory>${basedir}/src/main/bin</directory>
<lineEnding>windows</lineEnding>
<outputDirectory/>
<includes>
<include>*.bat</include>
</includes>
</fileSet>
<fileSet>
<directory>target/classes</directory>
<outputDirectory>config</outputDirectory>
<includes>
<include>**/*.yml</include>
<include>**/*.xml</include>
</includes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<unpack>false</unpack>
</dependencySet>
</dependencySets>
</assembly>

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>dist</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<useProjectArtifact>true</useProjectArtifact>
<outputDirectory>admin/lib</outputDirectory>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<lineEnding>unix</lineEnding>
<directory>./src/main/bin</directory>
<outputDirectory>admin/bin</outputDirectory>
<includes>
<include>**/*</include>
</includes>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<directory>./src/main/logs</directory>
<outputDirectory>admin/logs</outputDirectory>
</fileSet>
<fileSet>
<directory>./src/main/resources</directory>
<includes>
<include>*.properties</include>
<include>logback.xml</include>
<include>application.yml</include>
<include>mapper/**/**</include>
<include>i18n/**</include>
<include>static/**</include>
</includes>
<outputDirectory>admin/conf</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/lib</directory>
<outputDirectory>admin/lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>

View File

@ -0,0 +1,9 @@
@echo off
set home=%~dp0
set conf_dir=%home%..\conf
set lib_dir=%home%..\lib\*
set log_dir=%home%..\logs
java -Dspring.profiles.active=standalone -Dlogging.file=%log_dir%\dbApi.log -classpath %conf_dir%;%lib_dir% com.larkmidtable.admin.AdminApplication
pause

View File

@ -0,0 +1,266 @@
#!/bin/bash
#
FRIEND_NAME=ADMIN
MAIN_CLASS=com.larkmidtable.admin.AdminApplication
if [ ! ${ENV_FILE} ]; then
ENV_FILE="env.properties"
fi
SLEEP_TIMEREVAL_S=2
abs_path(){
SOURCE="${BASH_SOURCE[0]}"
while [ -h "${SOURCE}" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "${SOURCE}")"
[[ ${SOURCE} != /* ]] && SOURCE="${DIR}/${SOURCE}"
done
echo "$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
}
function LOG(){
currentTime=`date "+%Y-%m-%d %H:%M:%S.%3N"`
echo -e "$currentTime [${1}] ($$) $2" | tee -a ${SHELL_LOG}
}
verify_java_env(){
if [ "x${JAVA_HOME}" != "x" ]; then
${JAVA_HOME}/bin/java -version >/dev/null 2>&1
else
java -version >/dev/null 2>&1
fi
if [ $? -ne 0 ]; then
cat 1>&2 <<EOF
+========================================================================+
| Error: Java Environment is not availiable, Please check your JAVA_HOME |
+------------------------------------------------------------------------+
EOF
return 1
fi
return 0
}
load_env(){
LOG INFO "load environment variables"
while read line
do
if [[ ! -z $(echo "${line}" | grep "=") ]]; then
key=${line%%=*}
value=${line#*=}
key1=$(echo ${key} | tr '.' '_')
if [ -z $(echo "${key1}" | grep -P '\s*#+.*') ]; then
eval "${key1}=${value}"
fi
fi
done < "${BIN}/${ENV_FILE}"
}
BIN=`abs_path`
SHELL_LOG="${BIN}/console.out"
load_env
#verify environment
verify_java_env
if [ $? -ne 0 ]; then
exit $?
fi
if [[ ! ${SERVICE_LOG_PATH} ]]; then
SERVICE_LOG_PATH=${BIN}/../logs
fi
if [[ ! ${SERVICE_CONF_PATH} ]]; then
SERVICE_CONF_PATH=${BIN}/../conf
fi
if [[ ! ${DATA_PATH} ]]; then
DATA_PATH=${BIN}/../data
fi
if [[ ! ${MAIL_USERNAME} ]]; then
MAIL_USERNAME="flinkx"
fi
if [[ ! ${MAIL_PASSWORD} ]]; then
MAIL_PASSWORD="123456"
fi
if [[ ! ${JAVA_OPTS} ]]; then
JAVA_OPTS=" -Xms2g -Xmx2g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"
fi
if [[ ! ${REMOTE_DEBUG_SWITCH} ]]; then
REMOTE_DEBUG_SWITCH=false
fi
if [[ ! ${REMOTE_DEBUG_PORT} ]]; then
REMOTE_DEBUG_PORT="8089"
fi
LIB_PATH=${BIN}/../lib
USER_DIR=${BIN}/../
CLASSPATH=${LIB_PATH}"/*:"${SERVICE_CONF_PATH}":."
if [ ${REMOTE_DEBUG_SWITCH} == true ]; then
JAVA_OPTS=${JAVA_OPTS}" -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${REMOTE_DEBUG_PORT}"
fi
JAVA_OPTS=${JAVA_OPTS}" -XX:HeapDumpPath="${SERVICE_LOG_PATH}" -Dlog.path="${SERVICE_LOG_PATH}
JAVA_OPTS=${JAVA_OPTS}" -Duser.dir="${USER_DIR}
JAVA_OPTS=${JAVA_OPTS}" -Ddata.path="${DATA_PATH}" -Dmail.username="${MAIL_USERNAME}" -Dmail.password="${MAIL_PASSWORD}
if [ "x"${PID_FILE_PATH} != "x" ]; then
JAVA_OPTS=${JAVA_OPTS}" -Dpid.file="${PID_FILE_PATH}
fi
JAVA_OPTS=${JAVA_OPTS}" -Dlogging.config="${SERVICE_CONF_PATH}"/logback.xml"
JAVA_OPTS=${JAVA_OPTS}" -classpath "${CLASSPATH}
if [ "x${JAVA_HOME}" != "x" ]; then
EXE_JAVA=${JAVA_HOME}"/bin/java "${JAVA_OPTS}" "${MAIN_CLASS}
JPS=${JAVA_HOME}/bin/jps
else
EXE_JAVA="java "${JAVA_OPTS}" "${MAIN_CLASS}
JPS="jps"
fi
usage(){
echo " usage is [start|stop|shutdown|restart]"
}
# check if the process still in jvm
status_class(){
local p=""
if [ "x"${PID_FILE_PATH} != "x" ]; then
if [ -f ${PID_FILE_PATH} ]; then
local pid_in_file=`cat ${PID_FILE_PATH} 2>/dev/null`
if [ "x"${pid_in_file} != "x" ]; then
p=`${JPS} -q | grep ${pid_in_file} | awk '{print $1}'`
fi
fi
else
p=`${JPS} -l | grep "$2" | awk '{print $1}'`
fi
if [ -n "$p" ]; then
# echo "$1 ($2) is still running with pid $p"
return 0
else
# echo "$1 ($2) does not appear in the java process table"
return 1
fi
}
wait_for_startup(){
local now_s=`date '+%s'`
local stop_s=$((${now_s} + $1))
while [ ${now_s} -le ${stop_s} ];do
status_class ${FRIEND_NAME} ${MAIN_CLASS}
if [ $? -eq 0 ]; then
return 0
fi
sleep ${SLEEP_TIMEREVAL_S}
now_s=`date '+%s'`
done
exit 1
}
wait_for_stop(){
local now_s=`date '+%s'`
local stop_s=$((${now_s} + $1))
while [ ${now_s} -le ${stop_s} ];do
status_class ${FRIEND_NAME} ${MAIN_CLASS}
if [ $? -eq 1 ]; then
return 0
fi
sleep ${SLEEP_TIMEREVAL_S}
now_s=`date '+%s'`
done
return 1
}
start_m(){
status_class ${FRIEND_NAME} ${MAIN_CLASS}
if [ $? -eq 0 ]; then
LOG INFO "${FRIEND_NAME} has been started in process"
exit 0
fi
LOG INFO ${EXE_JAVA}
nohup ${EXE_JAVA} >${SHELL_LOG} 2>&1 &
LOG INFO "Waiting ${FRIEND_NAME} to start complete ..."
wait_for_startup 20
if [ $? -eq 0 ]; then
LOG INFO "${FRIEND_NAME} start success"
return 0
else
LOG ERROR "${FRIEND_NAME} start exceeded over 20s" >&2
return 1
fi
}
stop_m(){
local p=""
if [ "x"${PID_FILE_PATH} != "x" ]; then
if [ -f ${PID_FILE_PATH} ]; then
local pid_in_file=`cat ${PID_FILE_PATH} 2>/dev/null`
if [ "x"${pid_in_file} != "x" ]; then
p=`${JPS} -q | grep ${pid_in_file} | awk '{print $1}'`
fi
fi
else
p=`${JPS} -l | grep "${MAIN_CLASS}" | awk '{print $1}'`
fi
if [ -z "${p}" ]; then
LOG INFO "${FRIEND_NAME} didn't start successfully, not found in the java process table"
return 0
fi
LOG INFO "Killing ${FRIEND_NAME} (pid ${p}) ..."
kill -9 ${p}
LOG INFO "Stop successful..."
}
shutdown_m(){
local p=""
if [ "x"${PID_FILE_PATH} != "x" ]; then
if [ -f ${PID_FILE_PATH} ]; then
local pid_in_file=`cat ${PID_FILE_PATH} 2>/dev/null`
if [ "x"${pid_in_file} != "x" ]; then
p=`${JPS} -q | grep ${pid_in_file} | awk '{print $1}'`
fi
fi
else
p=`${JPS} -l | grep "${MAIN_CLASS}" | awk '{print $1}'`
fi
if [ -z "${p}" ]; then
LOG INFO "${FRIEND_NAME} didn't start successfully, not found in the java process table"
return 0
fi
LOG INFO "Killing ${FRIEND_NAME} (pid ${p}) ..."
case "`uname`" in
CYCGWIN*) taskkill /F /PID "${p}" ;;
*) kill -9 "${p}" ;;
esac
}
restart_m(){
stop_m
if [ $? -eq 0 ]; then
start_m
exit $?
else
LOG ERROR "${FRIEND_NAME} restart fail" >&2
exit 1
fi
}
if [ ! $1 ]; then
usage
exit 1;
fi
case $1 in
start) start_m;;
stop) stop_m;;
shutdown) shutdown_m;;
restart) restart_m;;
*)
usage
exit 1
;;
esac
exit $?

View File

@ -0,0 +1,202 @@
#!/bin/bash
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
SHELL_LOG="${DIR}/console.out"
SERVER_NAME="admin"
USER=`whoami`
SAFE_MODE=true
SUDO_USER=false
ENV_FILE_PATH="${DIR}/env.properties"
usage(){
printf "Configure usage:\n"
printf "\t%-10s %-10s %-2s \n" --server "server-name" "Name of admin server"
printf "\t%-10s %-10s %-2s \n" --unsafe "unsafe mode" "Will clean the directory existed"
printf "\t%-10s %-10s %-2s \n" --safe "safe mode" "Will not modify the directory existed (Default)"
printf "\t%-10s %-10s %-2s \n" "-h|--help" "usage" "List help document"
}
LOG(){
currentTime=`date "+%Y-%m-%d %H:%M:%S.%3N"`
echo -e "$currentTime [${1}] ($$) $2" | tee -a ${SHELL_LOG}
}
interact_echo(){
while [ 1 ]; do
read -p "$1 (Y/N)" yn
if [ "${yn}x" == "Yx" ] || [ "${yn}x" == "yx" ]; then
return 0
elif [ "${yn}x" == "Nx" ] || [ "${yn}x" == "nx" ]; then
return 1
else
echo "Unknown choise: [$yn], please choose again."
fi
done
}
is_sudo_user(){
sudo -v >/dev/null 2>&1
}
abs_path(){
SOURCE="${BASH_SOURCE[0]}"
while [ -h "${SOURCE}" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "${SOURCE}")"
[[ ${SOURCE} != /* ]] && SOURCE="${DIR}/${SOURCE}"
done
echo "$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
}
check_exist(){
if test -e "$1"; then
LOG INFO "Directory or file: [$1] has been exist"
if [ $2 == true ]; then
LOG INFO "Configure program will shutdown..."
exit 0
fi
fi
}
copy_replace(){
file_name=$1
if test -e "${CONF_PATH}/${file_name}";then
if [ ${SAFE_MODE} == true ]; then
check_exist "${CONF_PATH}/${file_name}" true
fi
LOG INFO "Delete file or directory: [${CONF_PATH}/${file_name}]"
rm -rf ${CONF_PATH}/${file_name}
fi
if test -e "${DIR}/../conf/${file_name}";then
LOG INFO "Copy from ${DIR}/../conf/${file_name}"
cp -R ${DIR}/../conf/${file_name} ${CONF_PATH}/
fi
}
mkdir_p(){
if [ ${SAFE_MODE} == true ]; then
check_exist $1 false
fi
if [ ! -d $1 ]; then
LOG INFO "Creating directory: ["$1"]."
#mkdir -p $1
if [ ${SUDO_USER} == true ]; then
sudo mkdir -p $1 && sudo chown -R ${USER} $1
else
mkdir -p $1
fi
fi
}
while [ 1 ]; do
case ${!OPTIND} in
--server)
SERVER_NAME=$2
shift 2
;;
--unsafe)
SAFE_MODE=false
shift 1
;;
--safe)
SAFE_MODE=true
shift 1
;;
--help|-h)
usage
exit 0
;;
*)
break
;;
esac
done
is_sudo_user
if [ $? == 0 ]; then
SUDO_USER=true
fi
BIN=`abs_path`
SERVER_NAME_SIMPLE=${SERVER_NAME/flinkx-/}
LOG_PATH=${BIN}/../logs
if [ "x${BASE_LOG_DIR}" != "x" ]; then
LOG_PATH=${BASE_LOG_DIR}/${SERVER_NAME_SIMPLE}
sed -ri "s![#]?(WEB_LOG_PATH=)\S*!\1${LOG_PATH}!g" ${ENV_FILE_PATH}
fi
CONF_PATH=${BIN}/../conf
if [ "x${BASE_CONF_DIR}" != "x" ]; then
CONF_PATH=${BASE_CONF_DIR}/${SERVER_NAME_SIMPLE}
sed -ri "s![#]?(WEB_CONF_PATH=)\S*!\1${CONF_PATH}!g" ${ENV_FILE_PATH}
fi
DATA_PATH=${BIN}/../data
if [ "x${BASE_DATA_DIR}" != "x" ]; then
DATA_PATH=${BASE_DATA_DIR}/${SERVER_NAME_SIMPLE}
sed -ri "s![#]?(DATA_PATH=)\S*!\1${DATA_PATH}!g" ${ENV_FILE_PATH}
fi
echo "Start to make directory"
# Start to make directory
LOG INFO "\033[1m Start to build directory\033[0m"
mkdir_p ${LOG_PATH}
mkdir_p ${CONF_PATH}
mkdir_p ${DATA_PATH}
if [ "x${BASE_CONF_DIR}" != "x" ]; then
LOG INFO "\033[1m Start to copy configuration file/directory\033[0m"
# Copy the configuration file
copy_replace bootstrap.properties
copy_replace application.yml
copy_replace logback.xml
copy_replace i18n
copy_replace mybatis-mapper
copy_replace static
fi
echo "end to make directory"
BOOTSTRAP_PROP_FILE="${CONF_PATH}/bootstrap.properties"
# Start to initalize database
echo "Start to initalize database"
if [ "x${SQL_SOURCE_PATH}" != "x" ] && [ -f "${SQL_SOURCE_PATH}" ]; then
`mysql --version >/dev/null 2>&1`
if [ $? == 0 ]; then
LOG INFO "\033[1m Scan out mysql command, so begin to initalize the database\033[0m"
interact_echo "Do you want to initalize database with sql: [${SQL_SOURCE_PATH}]?"
if [ $? == 0 ]; then
read -p "Please input the db host(default: 127.0.0.1): " HOST
if [ "x${HOST}" == "x" ]; then
HOST="127.0.0.1"
fi
while [ 1 ]; do
read -p "Please input the db port(default: 3306): " PORT
if [ "x${PORT}" == "x" ]; then
PORT=3306
break
elif [ ${PORT} -gt 0 ] 2>/dev/null; then
break
else
echo "${PORT} is not a number, please input again"
fi
done
read -p "Please input the db username(default: root): " USERNAME
if [ "x${USERNAME}" == "x" ]; then
USERNAME="root"
fi
read -p "Please input the db password(default: ""): " PASSWORD
read -p "Please input the db name(default: flinkxweb)" DATABASE
if [ "x${DATABASE}" == "x" ]; then
DATABASE="flinkxweb"
fi
mysql -h ${HOST} -P ${PORT} -u ${USERNAME} -p${PASSWORD} --default-character-set=utf8 -e \
"CREATE DATABASE IF NOT EXISTS ${DATABASE}; USE ${DATABASE}; source ${SQL_SOURCE_PATH};"
sed -ri "s![#]?(DB_HOST=)\S*!\1${HOST}!g" ${BOOTSTRAP_PROP_FILE}
sed -ri "s![#]?(DB_PORT=)\S*!\1${PORT}!g" ${BOOTSTRAP_PROP_FILE}
sed -ri "s![#]?(DB_USERNAME=)\S*!\1${USERNAME}!g" ${BOOTSTRAP_PROP_FILE}
sed -ri "s![#]?(DB_PASSWORD=)\S*!\1${PASSWORD}!g" ${BOOTSTRAP_PROP_FILE}
sed -ri "s![#]?(DB_DATABASE=)\S*!\1${DATABASE}!g" ${BOOTSTRAP_PROP_FILE}
fi
fi
fi

View File

@ -0,0 +1,36 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import os
import signal
import subprocess
import time
import re
import socket
import json
from optparse import OptionParser
from optparse import OptionGroup
from string import Template
import codecs
import platform
def printCopyright():
print '''
LarkMidTable (%s), From LarkMidTable !
LarkMidTable All Rights Reserved.
'''
sys.stdout.flush()
if __name__ == "__main__":
printCopyright()
abs_file=sys.path[0]
json_file=sys.argv[1]
log_name=sys.argv[2]
startCommand = "java -server -Xms1g -Xmx1g -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=E:\datax/log -Xms1g -Xmx1g -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=E:\datax/log -Dloglevel=info -Dfile.encoding=UTF-8 -Dlogback.statusListenerClass=ch.qos.logback.core.status.NopStatusListener -Djava.security.egd=file:///dev/urandom -Ddatax.home=E:\datax -Dlogback.configurationFile=E:\datax/conf/logback.xml -classpath E:\datax/lib/* -Dlog.file.name=8e8e5f7d4cd0fd5_json com.alibaba.datax.core.Engine -mode standalone -jobid -1 -job %s > %s" %(json_file,log_name)
print startCommand
child_process = subprocess.Popen(startCommand, shell=True)
(stdout, stderr) = child_process.communicate()
sys.exit(child_process.returncode)

View File

@ -0,0 +1,21 @@
# environment variables
#JAVA_HOME=""
WEB_LOG_PATH=${BIN}/../logs
WEB_CONF_PATH=${BIN}/../conf
DATA_PATH=${BIN}/../data
SERVER_PORT=8080
#PID_FILE_PATH=${BIN}/flinkxadmin.pid
# mail account
MAIL_USERNAME=""
MAIL_PASSWORD=""
#debug
#REMOTE_DEBUG_SWITCH=true
#REMOTE_DEBUG_PORT=7003

View File

@ -0,0 +1 @@
sh ./bin/flinkx -mode local -jobType sync -job ./job/stream.json -flinkxDistDir ./flinkx-dist -flinkConfDir ./flinkconf

View File

@ -0,0 +1,36 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import os
import signal
import subprocess
import time
import re
import socket
import json
from optparse import OptionParser
from optparse import OptionGroup
from string import Template
import codecs
import platform
def printCopyright():
print ('''
LarkMidTable (%s), From LarkMidTable !
LarkMidTable All Rights Reserved.
''')
sys.stdout.flush()
if __name__ == "__main__":
printCopyright()
abs_file=sys.path[0]
json_file=sys.argv[1]
log_name=sys.argv[2]
startCommand = "java -cp %s/lib/* com.dtstack.flinkx.client.Launcher -mode local -jobType sync -job %s -flinkxDistDir %s/flinkx-dist -flinkConfDir %s/flinkconf > %s/%s" %(abs_file,json_file,abs_file,abs_file,abs_file,log_name)
print(startCommand)
child_process = subprocess.Popen(startCommand, shell=True)
(stdout, stderr) = child_process.communicate()
sys.exit(child_process.returncode)

View File

@ -0,0 +1,36 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import os
import signal
import subprocess
import time
import re
import socket
import json
from optparse import OptionParser
from optparse import OptionGroup
from string import Template
import codecs
import platform
def printCopyright():
print '''
LarkMidTable (%s), From LarkMidTable !
LarkMidTable All Rights Reserved.
'''
sys.stdout.flush()
if __name__ == "__main__":
printCopyright()
abs_file=sys.path[0]
json_file=sys.argv[1]
log_name=sys.argv[2]
startCommand = "java -cp %s/lib/* com.dtstack.flinkx.client.Launcher -mode local -jobType sync -job %s -flinkxDistDir %s/flinkx-dist -flinkConfDir %s/flinkconf > %s" %(abs_file,json_file,abs_file,abs_file,log_name)
print startCommand
child_process = subprocess.Popen(startCommand, shell=True)
(stdout, stderr) = child_process.communicate()
sys.exit(child_process.returncode)

View File

@ -0,0 +1,148 @@
package com.czsj.web.controller.bigdata;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.czsj.common.constant.HttpStatus;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.core.domain.model.LoginUser;
import com.czsj.common.core.page.PageDomain;
import com.czsj.common.core.page.TableDataInfo;
import com.czsj.common.core.page.TableSupport;
import com.czsj.common.utils.DateUtils;
import com.czsj.common.utils.PageUtils;
import com.czsj.common.utils.SecurityUtils;
import com.czsj.common.utils.StringUtils;
import com.czsj.common.utils.sql.SqlUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import java.beans.PropertyEditorSupport;
import java.util.Date;
import java.util.List;
/**
* web层通用数据处理
*
* @author czsj
*/
public class BaseController extends ApiController
{
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* 将前台传递过来的日期格式的字符串自动转化为Date类型
*/
@InitBinder
public void initBinder(WebDataBinder binder)
{
// Date 类型转换
binder.registerCustomEditor(Date.class, new PropertyEditorSupport()
{
@Override
public void setAsText(String text)
{
setValue(DateUtils.parseDate(text));
}
});
}
/**
* 设置请求分页数据
*/
protected void startPage()
{
PageUtils.startPage();
}
/**
* 设置请求排序数据
*/
protected void startOrderBy()
{
PageDomain pageDomain = TableSupport.buildPageRequest();
if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
{
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
PageHelper.orderBy(orderBy);
}
}
/**
* 清理分页的线程变量
*/
protected void clearPage()
{
PageUtils.clearPage();
}
/**
* 响应请求分页数据
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
protected TableDataInfo getDataTable(List<?> list)
{
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS);
rspData.setMsg("查询成功");
rspData.setRows(list);
rspData.setTotal(new PageInfo(list).getTotal());
return rspData;
}
/**
* 响应返回结果
*
* @param rows 影响行数
* @return 操作结果
*/
protected AjaxResult toAjax(int rows)
{
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
}
/**
* 页面跳转
*/
public String redirect(String url)
{
return StringUtils.format("redirect:{}", url);
}
/**
* 获取用户缓存信息
*/
public LoginUser getLoginUser()
{
return SecurityUtils.getLoginUser();
}
/**
* 获取登录用户id
*/
public Long getUserId()
{
return getLoginUser().getUserId();
}
/**
* 获取登录部门id
*/
public Long getDeptId()
{
return getLoginUser().getDeptId();
}
/**
* 获取登录用户名
*/
public String getUsername()
{
return getLoginUser().getUsername();
}
}

View File

@ -0,0 +1,253 @@
package com.czsj.web.controller.bigdata;
import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.czsj.bigdata.util.PageUtils;
import com.czsj.bigdata.util.ServletUtils;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.http.HttpServletRequest;
import java.net.URLDecoder;
import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 基础参数辅助类
*
* @author zhouhongfa@gz-yibo.com
* @version 1.0
* @since 2019/5/15
*/
@Slf4j
public class BaseForm {
/**
* 查询参数对象
*/
protected Map<String, Object> values = new LinkedHashMap<>();
/**
* 当前页码
*/
private Long current = 1L;
/**
* 页大小
*/
private Long size = 10L;
/**
* 构造方法
*/
public BaseForm() {
try {
HttpServletRequest request = ServletUtils.getRequest();
Enumeration<String> params = request.getParameterNames();
while (params.hasMoreElements()) {
String name = params.nextElement();
String value = StrUtil.trim(request.getParameter(name));
this.set(name, URLDecoder.decode(value, "UTF-8"));
}
this.parsePagingQueryParams();
} catch (Exception e) {
e.printStackTrace();
log.error("BaseControlForm initialize parameters setting error" + e);
}
}
/**
* 获取页码
*
* @return
*/
public Long getPageNo() {
String pageNum = StrUtil.toString(this.get("current"));
if (!StrUtil.isEmpty(pageNum) && NumberUtil.isNumber(pageNum)) {
this.current = Long.parseLong(pageNum);
}
return this.current;
}
/**
* 获取页大小
*
* @return
*/
public Long getPageSize() {
String pageSize = StrUtil.toString(this.get("size"));
if (StrUtil.isNotEmpty(pageSize) && NumberUtil.isNumber(pageSize) && !"null".equalsIgnoreCase(pageSize)) {
this.size = Long.parseLong(pageSize);
}
return this.size;
}
/**
* 获得参数信息对象
*
* @return
*/
public Map<String, Object> getParameters() {
return values;
}
/**
* 根据key获取values中的值
*
* @param name
* @return
*/
public Object get(String name) {
if (values == null) {
values = new LinkedHashMap<>();
return null;
}
return this.values.get(name);
}
/**
* 根据key获取values中String类型值
*
* @param key
* @return String
*/
public String getString(String key) {
return StrUtil.toString(get(key));
}
/**
* 获取排序字段
*
* @return
*/
public String getSort() {
return StrUtil.toString(this.values.get("sort"));
}
/**
* 获取排序
*
* @return
*/
public String getOrder() {
return StrUtil.toString(this.values.get("order"));
}
/**
* 获取排序
*
* @return
*/
public String getOrderby() {
return StrUtil.toString(this.values.get("orderby"));
}
/**
* 解析出mybatis plus分页查询参数
*/
public Page getPlusPagingQueryEntity() {
Page page = new Page();
//如果无current默认返回1000条数据
page.setCurrent(this.getPageNo());
page.setSize(this.getPageSize());
if (ObjectUtil.isNotNull(this.get("ifCount"))) {
page.setSearchCount(BooleanUtil.toBoolean(this.getString("ifCount")));
} else {
//默认给true
page.setSearchCount(true);
}
return page;
}
/**
* 解析分页排序参数pageHelper
*/
public void parsePagingQueryParams() {
// 排序字段解析
String orderBy = StrUtil.toString(this.get("orderby")).trim();
String sortName = StrUtil.toString(this.get("sort")).trim();
String sortOrder = StrUtil.toString(this.get("order")).trim().toLowerCase();
if (StrUtil.isEmpty(orderBy) && !StrUtil.isEmpty(sortName)) {
if (!sortOrder.equals("asc") && !sortOrder.equals("desc")) {
sortOrder = "asc";
}
this.set("orderby", sortName + " " + sortOrder);
}
}
/**
* 设置参数
*
* @param name 参数名称
* @param value 参数值
*/
public void set(String name, Object value) {
if (ObjectUtil.isNotNull(value)) {
this.values.put(name, value);
}
}
/**
* 移除参数
*
* @param name
*/
public void remove(String name) {
this.values.remove(name);
}
/**
* 清除所有参数
*/
public void clear() {
if (values != null) {
values.clear();
}
}
/**
* 自定义查询组装
*
* @param map
* @return
*/
protected QueryWrapper<?> pageQueryWrapperCustom(Map<String, Object> map, QueryWrapper<?> queryWrapper) {
// mybatis plus 分页相关的参数
Map<String, Object> pageParams = PageUtils.filterPageParams(map);
//过滤空值分页查询相关的参数
Map<String, Object> colQueryMap = PageUtils.filterColumnQueryParams(map);
//排序 操作
pageParams.forEach((k, v) -> {
switch (k) {
case "ascs":
queryWrapper.orderByAsc(StrUtil.toUnderlineCase(StrUtil.toString(v)));
break;
case "descs":
queryWrapper.orderByDesc(StrUtil.toUnderlineCase(StrUtil.toString(v)));
break;
}
});
//遍历进行字段查询条件组装
colQueryMap.forEach((k, v) -> {
switch (k) {
case "pluginName":
case "datasourceName":
queryWrapper.like(StrUtil.toUnderlineCase(k), v);
break;
default:
queryWrapper.eq(StrUtil.toUnderlineCase(k), v);
}
});
return queryWrapper;
}
}

View File

@ -0,0 +1,94 @@
package com.czsj.web.controller.bigdata;
import com.czsj.bigdata.entity.BaseResource;
import com.czsj.bigdata.mapper.BaseResourceMapper;
import com.czsj.bigdata.util.AESUtil;
import com.czsj.core.biz.model.ReturnT;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/api/base/resource")
@Api(tags = "基础建设-资源管理")
public class BaseResourceController {
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Autowired
private BaseResourceMapper baseResourceMapper;
@ApiOperation("获取所有数据")
@GetMapping("/list")
@PreAuthorize("@ss.hasPermi('datax:resource:list')")
public ReturnT<Map<String, Object>> selectList(
@RequestParam(value = "current", required = false, defaultValue = "1") int current,
@RequestParam(value = "size", required = false, defaultValue = "10") int size,
@RequestParam(value = "name", required = false) String name) {
// page list
List<BaseResource> list = baseResourceMapper.findList((current - 1) * size,size,name);
Map<String, Object> maps = new HashMap<>();
maps.put("recordsTotal", list.size()); // 过滤后的总记录数
maps.put("data", list); // 分页列表
return new ReturnT<>(maps);
}
@ApiOperation("新增数据")
@PostMapping("/add")
@PreAuthorize("@ss.hasPermi('datax:resource:add')")
public ReturnT<String> insert(HttpServletRequest request, @RequestBody BaseResource entity) {
entity.setUpdate_time(sdf.format(new Date()));
entity.setServerPassword(AESUtil.encrypt(entity.getServerPassword()));
this.baseResourceMapper.save(entity);
return ReturnT.SUCCESS;
}
@ApiOperation("修改数据")
@PostMapping(value = "/update")
@PreAuthorize("@ss.hasPermi('datax:resource:edit')")
public ReturnT<String> update(@RequestBody BaseResource entity) {
entity.setUpdate_time(sdf.format(new Date()));
//查询元数据
BaseResource byId = baseResourceMapper.getById(entity.getId());
if(entity.getServerPassword().equals(byId.getServerPassword())){
entity.setServerPassword(AESUtil.encrypt(AESUtil.decrypt(entity.getServerPassword())));
}else{
entity.setServerPassword(AESUtil.encrypt(entity.getServerPassword()));
}
baseResourceMapper.update(entity);
return ReturnT.SUCCESS;
}
@RequestMapping(value = "/remove", method = RequestMethod.POST)
@ApiOperation("删除数据")
@PreAuthorize("@ss.hasPermi('datax:resource:remove')")
public ReturnT<String> delete(int id) {
int result = baseResourceMapper.delete(id);
return result != 1 ? ReturnT.FAIL : ReturnT.SUCCESS;
}
@RequestMapping(value = "/getResource", method = RequestMethod.POST)
@ApiOperation("查询资源列表")
@PreAuthorize("@ss.hasPermi('datax:resource:query')")
public ReturnT<String> getResource() {
List<BaseResource> result = baseResourceMapper.getResource();
return new ReturnT(result);
}
@RequestMapping(value = "/getFileResource", method = RequestMethod.POST)
@ApiOperation("查询资源列表")
@PreAuthorize("@ss.hasPermi('datax:resource:query')")
public ReturnT<String> getFileResource() {
List<BaseResource> result = baseResourceMapper.getFileResource();
return new ReturnT(result);
}
}

View File

@ -0,0 +1,48 @@
package com.czsj.web.controller.bigdata;
import com.baomidou.mybatisplus.extension.api.R;
import com.czsj.bigdata.core.util.I18nUtil;
import com.czsj.bigdata.dto.DataXJsonBuildDto;
import com.czsj.bigdata.service.DataxJsonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Created by jingwk on 2022/05/05
*/
@RestController
@RequestMapping("api/dataxJson")
@Api(tags = "组装datax json的控制器")
public class DataxJsonController extends BaseController {
@Autowired
private DataxJsonService dataxJsonService;
@PostMapping("/buildJson")
@ApiOperation("JSON构建")
public R<String> buildJobJson(@RequestBody DataXJsonBuildDto dto) {
String key = "system_please_choose";
if (dto.getReaderDatasourceId() == null) {
return failed(I18nUtil.getString(key) + I18nUtil.getString("jobinfo_field_readerDataSource"));
}
if (dto.getWriterDatasourceId() == null) {
return failed(I18nUtil.getString(key) + I18nUtil.getString("jobinfo_field_writerDataSource"));
}
if (CollectionUtils.isEmpty(dto.getReaderColumns())) {
return failed(I18nUtil.getString(key) + I18nUtil.getString("jobinfo_field_readerColumns"));
}
if (CollectionUtils.isEmpty(dto.getWriterColumns())) {
return failed(I18nUtil.getString(key) + I18nUtil.getString("jobinfo_field_writerColumns"));
}
return success(dataxJsonService.buildJobJson(dto));
}
}

View File

@ -0,0 +1,145 @@
package com.czsj.web.controller.bigdata;
import com.czsj.bigdata.core.conf.JobAdminConfig;
import com.czsj.bigdata.core.util.JacksonUtil;
import com.czsj.core.biz.AdminBiz;
import com.czsj.core.biz.model.HandleCallbackParam;
import com.czsj.core.biz.model.HandleProcessCallbackParam;
import com.czsj.core.biz.model.RegistryParam;
import com.czsj.core.biz.model.ReturnT;
import com.czsj.core.util.JobRemotingUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* Created by xuxueli on 17/5/10.
*/
@RestController
@RequestMapping("/api")
public class JobApiController {
@Autowired
private AdminBiz adminBiz;
/**
* callback
*
* @param data
* @return
*/
@RequestMapping("/callback")
public ReturnT<String> callback(HttpServletRequest request, @RequestBody(required = false) String data) {
// valid
if (JobAdminConfig.getAdminConfig().getAccessToken()!=null
&& JobAdminConfig.getAdminConfig().getAccessToken().trim().length()>0
&& !JobAdminConfig.getAdminConfig().getAccessToken().equals(request.getHeader(JobRemotingUtil.XXL_RPC_ACCESS_TOKEN))) {
return new ReturnT<>(ReturnT.FAIL_CODE, "The access token is wrong.");
}
// param
List<HandleCallbackParam> callbackParamList = null;
try {
callbackParamList = JacksonUtil.readValue(data, List.class, HandleCallbackParam.class);
} catch (Exception e) { }
if (callbackParamList==null || callbackParamList.size()==0) {
return new ReturnT<>(ReturnT.FAIL_CODE, "The request data invalid.");
}
// invoke
return adminBiz.callback(callbackParamList);
}
/**
* callback
*
* @param data
* @return
*/
@RequestMapping("/processCallback")
public ReturnT<String> processCallback(HttpServletRequest request, @RequestBody(required = false) String data) {
// valid
if (JobAdminConfig.getAdminConfig().getAccessToken()!=null
&& JobAdminConfig.getAdminConfig().getAccessToken().trim().length()>0
&& !JobAdminConfig.getAdminConfig().getAccessToken().equals(request.getHeader(JobRemotingUtil.XXL_RPC_ACCESS_TOKEN))) {
return new ReturnT<>(ReturnT.FAIL_CODE, "The access token is wrong.");
}
// param
List<HandleProcessCallbackParam> callbackParamList = null;
try {
callbackParamList = JacksonUtil.readValue(data, List.class, HandleProcessCallbackParam.class);
} catch (Exception e) { }
if (callbackParamList==null || callbackParamList.size()==0) {
return new ReturnT<>(ReturnT.FAIL_CODE, "The request data invalid.");
}
// invoke
return adminBiz.processCallback(callbackParamList);
}
/**
* registry
*
* @param data
* @return
*/
@RequestMapping("/registry")
public ReturnT<String> registry(HttpServletRequest request, @RequestBody(required = false) String data) {
// valid
if (JobAdminConfig.getAdminConfig().getAccessToken()!=null
&& JobAdminConfig.getAdminConfig().getAccessToken().trim().length()>0
&& !JobAdminConfig.getAdminConfig().getAccessToken().equals(request.getHeader(JobRemotingUtil.XXL_RPC_ACCESS_TOKEN))) {
return new ReturnT<String>(ReturnT.FAIL_CODE, "The access token is wrong.");
}
// param
RegistryParam registryParam = null;
try {
registryParam = JacksonUtil.readValue(data, RegistryParam.class);
} catch (Exception e) {}
if (registryParam == null) {
return new ReturnT<String>(ReturnT.FAIL_CODE, "The request data invalid.");
}
// invoke
return adminBiz.registry(registryParam);
}
/**
* registry remove
*
* @param data
* @return
*/
@RequestMapping("/registryRemove")
public ReturnT<String> registryRemove(HttpServletRequest request, @RequestBody(required = false) String data) {
// valid
if (JobAdminConfig.getAdminConfig().getAccessToken()!=null
&& JobAdminConfig.getAdminConfig().getAccessToken().trim().length()>0
&& !JobAdminConfig.getAdminConfig().getAccessToken().equals(request.getHeader(JobRemotingUtil.XXL_RPC_ACCESS_TOKEN))) {
return new ReturnT<>(ReturnT.FAIL_CODE, "The access token is wrong.");
}
// param
RegistryParam registryParam = null;
try {
registryParam = JacksonUtil.readValue(data, RegistryParam.class);
} catch (Exception e) {}
if (registryParam == null) {
return new ReturnT<>(ReturnT.FAIL_CODE, "The request data invalid.");
}
// invoke
return adminBiz.registryRemove(registryParam);
}
}

View File

@ -0,0 +1,77 @@
package com.czsj.web.controller.bigdata;
import com.czsj.core.biz.model.ReturnT;
import com.czsj.bigdata.core.util.I18nUtil;
import com.czsj.bigdata.entity.JobInfo;
import com.czsj.bigdata.entity.JobLogGlue;
import com.czsj.bigdata.mapper.JobInfoMapper;
import com.czsj.bigdata.mapper.JobLogGlueMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import static com.czsj.core.biz.model.ReturnT.FAIL_CODE;
/**
* Created by jingwk on 2019/11/17
*/
@RestController
@RequestMapping("/jobcode")
@Api(tags = "任务状态接口")
public class JobCodeController {
@Autowired
private JobInfoMapper jobInfoMapper;
@Autowired
private JobLogGlueMapper jobLogGlueMapper;
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation("保存任务状态")
public ReturnT<String> save(Model model, int id, String glueSource, String glueRemark) {
// valid
if (glueRemark == null) {
return new ReturnT<>(FAIL_CODE, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobinfo_glue_remark")));
}
if (glueRemark.length() < 4 || glueRemark.length() > 100) {
return new ReturnT<>(FAIL_CODE, I18nUtil.getString("jobinfo_glue_remark_limit"));
}
JobInfo existsJobInfo = jobInfoMapper.loadById(id);
if (existsJobInfo == null) {
return new ReturnT<>(FAIL_CODE, I18nUtil.getString("jobinfo_glue_jobid_invalid"));
}
// update new code
existsJobInfo.setGlueSource(glueSource);
existsJobInfo.setGlueRemark(glueRemark);
existsJobInfo.setGlueUpdatetime(new Date());
existsJobInfo.setUpdateTime(new Date());
jobInfoMapper.update(existsJobInfo);
// log old code
JobLogGlue jobLogGlue = new JobLogGlue();
jobLogGlue.setJobId(existsJobInfo.getId());
jobLogGlue.setGlueType(existsJobInfo.getGlueType());
jobLogGlue.setGlueSource(glueSource);
jobLogGlue.setGlueRemark(glueRemark);
jobLogGlue.setAddTime(new Date());
jobLogGlue.setUpdateTime(new Date());
jobLogGlueMapper.save(jobLogGlue);
// remove code backup more than 30
jobLogGlueMapper.removeOld(existsJobInfo.getId(), 30);
return ReturnT.SUCCESS;
}
}

View File

@ -0,0 +1,140 @@
package com.czsj.web.controller.bigdata;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.R;
import com.czsj.bigdata.core.util.LocalCacheUtil;
import com.czsj.bigdata.entity.JobDatasource;
import com.czsj.bigdata.service.JobDatasourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.io.Serializable;
import java.util.List;
/**
* jdbc数据源配置控制器层
*
* @author zhouhongfa@gz-yibo.com
* @version v1.0
* @since 2019-07-30
*/
@RestController
@RequestMapping("/api/jobJdbcDatasource")
@Api(tags = "jdbc数据源配置接口")
public class JobDatasourceController extends BaseController {
/**
* 服务对象
*/
@Autowired
private JobDatasourceService jobJdbcDatasourceService;
/**
* 分页查询所有数据
*
* @return 所有数据
*/
@GetMapping
@ApiOperation("分页查询所有数据")
@ApiImplicitParams(
{@ApiImplicitParam(paramType = "query", dataType = "String", name = "current", value = "当前页", defaultValue = "1", required = true),
@ApiImplicitParam(paramType = "query", dataType = "String", name = "size", value = "一页大小", defaultValue = "10", required = true),
@ApiImplicitParam(paramType = "query", dataType = "Boolean", name = "ifCount", value = "是否查询总数", defaultValue = "true"),
@ApiImplicitParam(paramType = "query", dataType = "String", name = "ascs", value = "升序字段,多个用逗号分隔"),
@ApiImplicitParam(paramType = "query", dataType = "String", name = "descs", value = "降序字段,多个用逗号分隔")
})
@PreAuthorize("@ss.hasPermi('datax:Datasource:list')")
public R<IPage<JobDatasource>> selectAll() {
BaseForm form = new BaseForm();
QueryWrapper<JobDatasource> query = (QueryWrapper<JobDatasource>) form.pageQueryWrapperCustom(form.getParameters(), new QueryWrapper<JobDatasource>());
return success(jobJdbcDatasourceService.page(form.getPlusPagingQueryEntity(), query));
}
/**
* 获取所有数据源
* @return
*/
@ApiOperation("获取所有数据源")
@GetMapping("/all")
@PreAuthorize("@ss.hasPermi('datax:Datasource:query')")
public R<List<JobDatasource>> selectAllDatasource() {
return success(this.jobJdbcDatasourceService.selectAllDatasource());
}
/**
* 通过主键查询单条数据
*
* @param id 主键
* @return 单条数据
*/
@ApiOperation("通过主键查询单条数据")
@GetMapping("{id}")
@PreAuthorize("@ss.hasPermi('datax:Datasource:query')")
public R<JobDatasource> selectOne(@PathVariable Serializable id) {
return success(this.jobJdbcDatasourceService.getById(id));
}
/**
* 新增数据
*
* @param entity 实体对象
* @return 新增结果
*/
@ApiOperation("新增数据")
@PostMapping
@PreAuthorize("@ss.hasPermi('datax:Datasource:add')")
public R<Boolean> insert(@RequestBody JobDatasource entity) {
return success(this.jobJdbcDatasourceService.save(entity));
}
/**
* 修改数据
*
* @param entity 实体对象
* @return 修改结果
*/
@PutMapping
@ApiOperation("修改数据")
@PreAuthorize("@ss.hasPermi('datax:Datasource:edit')")
public R<Boolean> update(@RequestBody JobDatasource entity) {
LocalCacheUtil.remove(entity.getDatasourceName());
JobDatasource d = jobJdbcDatasourceService.getById(entity.getId());
if (null != d.getJdbcUsername() && entity.getJdbcUsername().equals(d.getJdbcUsername())) {
entity.setJdbcUsername(null);
}
if (null != entity.getJdbcPassword() && entity.getJdbcPassword().equals(d.getJdbcPassword())) {
entity.setJdbcPassword(null);
}
return success(this.jobJdbcDatasourceService.updateById(entity));
}
/**
* 删除数据
*
* @param idList 主键结合
* @return 删除结果
*/
@DeleteMapping
@ApiOperation("删除数据")
@PreAuthorize("@ss.hasPermi('datax:Datasource:remove')")
public R<Boolean> delete(@RequestParam("idList") List<Long> idList) {
return success(this.jobJdbcDatasourceService.removeByIds(idList));
}
/**
* 测试数据源
* @param jobJdbcDatasource
* @return
*/
@PostMapping("/test")
@ApiOperation("测试数据")
public R<Boolean> dataSourceTest (@RequestBody JobDatasource jobJdbcDatasource) throws IOException {
return success(jobJdbcDatasourceService.dataSourceTest(jobJdbcDatasource));
}
}

View File

@ -0,0 +1,179 @@
package com.czsj.web.controller.bigdata;
import com.czsj.bigdata.core.util.I18nUtil;
import com.czsj.bigdata.entity.JobGroup;
import com.czsj.bigdata.entity.JobRegistry;
import com.czsj.bigdata.mapper.JobGroupMapper;
import com.czsj.bigdata.mapper.JobInfoMapper;
import com.czsj.bigdata.mapper.JobRegistryMapper;
import com.czsj.core.biz.model.ReturnT;
import com.czsj.core.enums.RegistryConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* Created by jingwk on 2019/11/17
*/
@RestController
@RequestMapping("/api/jobGroup")
@Api(tags = "执行器管理接口")
public class JobGroupController {
@Autowired
public JobInfoMapper jobInfoMapper;
@Autowired
public JobGroupMapper jobGroupMapper;
@Autowired
private JobRegistryMapper jobRegistryMapper;
@GetMapping("/list")
@ApiOperation("执行器列表")
@PreAuthorize("@ss.hasPermi('datax:executor:list')")
public ReturnT<List<JobGroup>> getExecutorList() {
return new ReturnT<>(jobGroupMapper.findAll());
}
@PostMapping("/save")
@ApiOperation("新建执行器")
@PreAuthorize("@ss.hasPermi('datax:executor:add')")
public ReturnT<String> save(@RequestBody JobGroup jobGroup) {
// valid
if (jobGroup.getAppName() == null || jobGroup.getAppName().trim().length() == 0) {
return new ReturnT<String>(500, (I18nUtil.getString("system_please_input") + "AppName"));
}
if (jobGroup.getAppName().length() < 4 || jobGroup.getAppName().length() > 64) {
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_appName_length"));
}
if (jobGroup.getTitle() == null || jobGroup.getTitle().trim().length() == 0) {
return new ReturnT<String>(500, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobgroup_field_title")));
}
if (jobGroup.getAddressType() != 0) {
if (jobGroup.getAddressList() == null || jobGroup.getAddressList().trim().length() == 0) {
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_addressType_limit"));
}
String[] addresses = jobGroup.getAddressList().split(",");
for (String item : addresses) {
if (item == null || item.trim().length() == 0) {
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_registryList_invalid"));
}
}
}
int ret = jobGroupMapper.save(jobGroup);
return (ret > 0) ? ReturnT.SUCCESS : ReturnT.FAIL;
}
@PostMapping("/update")
@ApiOperation("更新执行器")
@PreAuthorize("@ss.hasPermi('datax:executor:edit')")
public ReturnT<String> update(@RequestBody JobGroup jobGroup) {
// valid
if (jobGroup.getAppName() == null || jobGroup.getAppName().trim().length() == 0) {
return new ReturnT<String>(500, (I18nUtil.getString("system_please_input") + "AppName"));
}
if (jobGroup.getAppName().length() < 4 || jobGroup.getAppName().length() > 64) {
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_appName_length"));
}
if (jobGroup.getTitle() == null || jobGroup.getTitle().trim().length() == 0) {
return new ReturnT<String>(500, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobgroup_field_title")));
}
if (jobGroup.getAddressType() == 0) {
// 0=自动注册
List<String> registryList = findRegistryByAppName(jobGroup.getAppName());
String addressListStr = null;
if (registryList != null && !registryList.isEmpty()) {
Collections.sort(registryList);
addressListStr = "";
for (String item : registryList) {
addressListStr += item + ",";
}
addressListStr = addressListStr.substring(0, addressListStr.length() - 1);
}
jobGroup.setAddressList(addressListStr);
} else {
// 1=手动录入
if (jobGroup.getAddressList() == null || jobGroup.getAddressList().trim().length() == 0) {
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_addressType_limit"));
}
String[] addresses = jobGroup.getAddressList().split(",");
for (String item : addresses) {
if (item == null || item.trim().length() == 0) {
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_registryList_invalid"));
}
}
}
int ret = jobGroupMapper.update(jobGroup);
return (ret > 0) ? ReturnT.SUCCESS : ReturnT.FAIL;
}
private List<String> findRegistryByAppName(String appNameParam) {
HashMap<String, List<String>> appAddressMap = new HashMap<>();
List<JobRegistry> list = jobRegistryMapper.findAll(RegistryConfig.DEAD_TIMEOUT, new Date());
if (list != null) {
for (JobRegistry item : list) {
if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
String appName = item.getRegistryKey();
List<String> registryList = appAddressMap.get(appName);
if (registryList == null) {
registryList = new ArrayList<>();
}
if (!registryList.contains(item.getRegistryValue())) {
registryList.add(item.getRegistryValue());
}
appAddressMap.put(appName, registryList);
}
}
}
return appAddressMap.get(appNameParam);
}
@PostMapping("/remove")
@ApiOperation("移除执行器")
@PreAuthorize("@ss.hasPermi('datax:executor:remove')")
public ReturnT<String> remove(int id) {
// valid
int count = jobInfoMapper.pageListCount(0, 10, id, -1, null, null, 0,null);
if (count > 0) {
return new ReturnT<>(500, I18nUtil.getString("jobgroup_del_limit_0"));
}
List<JobGroup> allList = jobGroupMapper.findAll();
if (allList.size() == 1) {
return new ReturnT<>(500, I18nUtil.getString("jobgroup_del_limit_1"));
}
int ret = jobGroupMapper.remove(id);
return (ret > 0) ? ReturnT.SUCCESS : ReturnT.FAIL;
}
@RequestMapping(value = "/loadById", method = RequestMethod.POST)
@ApiOperation("根据id获取执行器")
@PreAuthorize("@ss.hasPermi('datax:executor:query')")
public ReturnT<JobGroup> loadById(int id) {
JobGroup jobGroup = jobGroupMapper.load(id);
return jobGroup != null ? new ReturnT<>(jobGroup) : new ReturnT<>(ReturnT.FAIL_CODE, null);
}
@GetMapping("/query")
@ApiOperation("查询执行器")
@PreAuthorize("@ss.hasPermi('datax:executor:query')")
public ReturnT<List<JobGroup>> get(@ApiParam(value = "执行器AppName")
@RequestParam(value = "appName", required = false) String appName,
@ApiParam(value = "执行器名称")
@RequestParam(value = "title", required = false) String title,
@ApiParam(value = "执行器地址列表")
@RequestParam(value = "addressList", required = false) String addressList) {
return new ReturnT<>(jobGroupMapper.find(appName, title, addressList));
}
}

View File

@ -0,0 +1,138 @@
package com.czsj.web.controller.bigdata;
import com.czsj.bigdata.core.cron.CronExpression;
import com.czsj.bigdata.core.thread.JobTriggerPoolHelper;
import com.czsj.bigdata.core.trigger.TriggerTypeEnum;
import com.czsj.bigdata.core.util.I18nUtil;
import com.czsj.bigdata.dto.DataXBatchJsonBuildDto;
import com.czsj.bigdata.dto.TriggerJobDto;
import com.czsj.bigdata.entity.JobInfo;
import com.czsj.bigdata.service.JobService;
import com.czsj.core.biz.model.ReturnT;
import com.czsj.core.util.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* index controller
*
* @author xuxueli 2015-12-19 16:13:16
*/
@Api(tags = "任务配置接口")
@RestController
@RequestMapping("/api/job")
public class JobInfoController extends BaseController{
@Autowired
private JobService jobService;
@GetMapping("/pageList")
@ApiOperation("任务列表")
@PreAuthorize("@ss.hasPermi('datax:job:list')")
public ReturnT<Map<String, Object>> pageList(@RequestParam(required = false, defaultValue = "0") int current,
@RequestParam(required = false, defaultValue = "10") int size,
int jobGroup, int triggerStatus, String jobDesc, String glueType, Integer[] projectIds) {
return new ReturnT<>(jobService.pageList((current-1)*size, size, jobGroup, triggerStatus, jobDesc, glueType, 0, projectIds));
}
@GetMapping("/list")
@ApiOperation("全部任务列表")
@PreAuthorize("@ss.hasPermi('datax:job:query')")
public ReturnT<List<JobInfo>> list(){
return new ReturnT<>(jobService.list());
}
@PostMapping("/add")
@ApiOperation("添加任务")
@PreAuthorize("@ss.hasPermi('datax:job:add')")
public ReturnT<String> add(HttpServletRequest request, @RequestBody JobInfo jobInfo) {
jobInfo.setUserId(getUserId());
return jobService.add(jobInfo);
}
@PostMapping("/update")
@ApiOperation("更新任务")
@PreAuthorize("@ss.hasPermi('datax:job:edit')")
public ReturnT<String> update(HttpServletRequest request,@RequestBody JobInfo jobInfo) {
jobInfo.setUserId(getUserId());
return jobService.update(jobInfo);
}
@PostMapping(value = "/remove/{id}")
@ApiOperation("移除任务")
@PreAuthorize("@ss.hasPermi('datax:job:remove')")
public ReturnT<String> remove(@PathVariable(value = "id") int id) {
return jobService.remove(id);
}
@RequestMapping(value = "/stop",method = RequestMethod.POST)
@ApiOperation("停止任务")
@PreAuthorize("@ss.hasPermi('datax:job:startorstop')")
public ReturnT<String> pause(int id) {
return jobService.stop(id);
}
@RequestMapping(value = "/start",method = RequestMethod.POST)
@ApiOperation("开启任务")
@PreAuthorize("@ss.hasPermi('datax:job:startorstop')")
public ReturnT<String> start(int id) {
return jobService.start(id);
}
@PostMapping(value = "/trigger")
@ApiOperation("触发任务")
@PreAuthorize("@ss.hasPermi('datax:job:trigger')")
public ReturnT<String> triggerJob(@RequestBody TriggerJobDto dto) {
// force cover job param
String executorParam=dto.getExecutorParam();
if (executorParam == null) {
executorParam = "";
}
JobTriggerPoolHelper.trigger(dto.getJobId(), TriggerTypeEnum.MANUAL, -1, null, executorParam);
return ReturnT.SUCCESS;
}
@GetMapping("/nextTriggerTime")
@ApiOperation("获取近5次触发时间")
public ReturnT<List<String>> nextTriggerTime(String cron) {
List<String> result = new ArrayList<>();
try {
CronExpression cronExpression = new CronExpression(cron);
Date lastTime = new Date();
for (int i = 0; i < 5; i++) {
lastTime = cronExpression.getNextValidTimeAfter(lastTime);
if (lastTime != null) {
result.add(DateUtil.formatDateTime(lastTime));
} else {
break;
}
}
} catch (ParseException e) {
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_invalid"));
}
return new ReturnT<>(result);
}
@PostMapping("/batchAdd")
@ApiOperation("批量创建任务")
public ReturnT<String> batchAdd(@RequestBody DataXBatchJsonBuildDto dto) throws IOException {
if (dto.getTemplateId() ==0) {
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_choose") + I18nUtil.getString("jobinfo_field_temp")));
}
return jobService.batchAdd(dto);
}
}

View File

@ -0,0 +1,177 @@
package com.czsj.web.controller.bigdata;
import com.czsj.bigdata.core.kill.KillJob;
import com.czsj.bigdata.core.scheduler.JobScheduler;
import com.czsj.bigdata.core.util.I18nUtil;
import com.czsj.bigdata.entity.JobInfo;
import com.czsj.bigdata.entity.JobLog;
import com.czsj.bigdata.mapper.JobInfoMapper;
import com.czsj.bigdata.mapper.JobLogMapper;
import com.czsj.core.biz.ExecutorBiz;
import com.czsj.core.biz.model.LogResult;
import com.czsj.core.biz.model.ReturnT;
import com.czsj.core.util.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by jingwk on 2019/11/17
*/
@RestController
@RequestMapping("/api/log")
@Api(tags = "任务运行日志接口")
public class JobLogController {
private static Logger logger = LoggerFactory.getLogger(JobLogController.class);
@Autowired
public JobInfoMapper jobInfoMapper;
@Autowired
public JobLogMapper jobLogMapper;
@GetMapping("/pageList")
@ApiOperation("运行日志列表")
@PreAuthorize("@ss.hasPermi('datax:joblog:list')")
public ReturnT<Map<String, Object>> pageList(
@RequestParam(required = false, defaultValue = "0") int current,
@RequestParam(required = false, defaultValue = "10") int size,
int jobGroup, int jobId, int logStatus, String filterTime) {
// parse param
Date triggerTimeStart = null;
Date triggerTimeEnd = null;
if (filterTime != null && filterTime.trim().length() > 0) {
String[] temp = filterTime.split(" - ");
if (temp.length == 2) {
triggerTimeStart = DateUtil.parseDateTime(temp[0]);
triggerTimeEnd = DateUtil.parseDateTime(temp[1]);
}
}
// page query
List<JobLog> data = jobLogMapper.pageList((current - 1) * size, size, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
int cnt = jobLogMapper.pageListCount((current - 1) * size, size, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
// package result
Map<String, Object> maps = new HashMap<>();
maps.put("recordsTotal", cnt); // 总记录数
maps.put("recordsFiltered", cnt); // 过滤后的总记录数
maps.put("data", data); // 分页列表
return new ReturnT<>(maps);
}
@RequestMapping(value = "/logDetailCat", method = RequestMethod.GET)
@ApiOperation("运行日志详情")
@PreAuthorize("@ss.hasPermi('datax:joblog:logDetailCat')")
public ReturnT<LogResult> logDetailCat(String executorAddress, long triggerTime, long logId, int fromLineNum) {
try {
ExecutorBiz executorBiz = JobScheduler.getExecutorBiz(executorAddress);
ReturnT<LogResult> logResult = executorBiz.log(triggerTime, logId, fromLineNum);
// is end
if (logResult.getContent() != null && fromLineNum > logResult.getContent().getToLineNum()) {
JobLog jobLog = jobLogMapper.load(logId);
if (jobLog.getHandleCode() > 0) {
logResult.getContent().setEnd(true);
}
}
return logResult;
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new ReturnT<>(ReturnT.FAIL_CODE, e.getMessage());
}
}
@RequestMapping(value = "/logKill", method = RequestMethod.POST)
@ApiOperation("kill任务")
@PreAuthorize("@ss.hasPermi('datax:joblog:killJob')")
public ReturnT<String> logKill(int id) {
// base check
JobLog log = jobLogMapper.load(id);
JobInfo jobInfo = jobInfoMapper.loadById(log.getJobId());
if (jobInfo == null) {
return new ReturnT<>(500, I18nUtil.getString("jobinfo_glue_jobid_invalid"));
}
if (ReturnT.SUCCESS_CODE != log.getTriggerCode()) {
return new ReturnT<>(500, I18nUtil.getString("joblog_kill_log_limit"));
}
// request of kill
ReturnT<String> runResult;
try {
ExecutorBiz executorBiz = JobScheduler.getExecutorBiz(log.getExecutorAddress());
runResult = executorBiz.kill(jobInfo.getId());
} catch (Exception e) {
logger.error(e.getMessage(), e);
runResult = new ReturnT<>(500, e.getMessage());
}
if (ReturnT.SUCCESS_CODE == runResult.getCode()) {
log.setHandleCode(ReturnT.FAIL_CODE);
log.setHandleMsg(I18nUtil.getString("joblog_kill_log_byman") + ":" + (runResult.getMsg() != null ? runResult.getMsg() : ""));
log.setHandleTime(new Date());
jobLogMapper.updateHandleInfo(log);
return new ReturnT<>(runResult.getMsg());
} else {
return new ReturnT<>(500, runResult.getMsg());
}
}
@PostMapping("/clearLog")
@ApiOperation("清理日志")
@PreAuthorize("@ss.hasPermi('datax:joblog:clearLog')")
public ReturnT<String> clearLog(int jobGroup, int jobId, int type) {
Date clearBeforeTime = null;
int clearBeforeNum = 0;
if (type == 1) {
clearBeforeTime = DateUtil.addMonths(new Date(), -1); // 清理一个月之前日志数据
} else if (type == 2) {
clearBeforeTime = DateUtil.addMonths(new Date(), -3); // 清理三个月之前日志数据
} else if (type == 3) {
clearBeforeTime = DateUtil.addMonths(new Date(), -6); // 清理六个月之前日志数据
} else if (type == 4) {
clearBeforeTime = DateUtil.addYears(new Date(), -1); // 清理一年之前日志数据
} else if (type == 5) {
clearBeforeNum = 1000; // 清理一千条以前日志数据
} else if (type == 6) {
clearBeforeNum = 10000; // 清理一万条以前日志数据
} else if (type == 7) {
clearBeforeNum = 30000; // 清理三万条以前日志数据
} else if (type == 8) {
clearBeforeNum = 100000; // 清理十万条以前日志数据
} else if (type == 9) {
clearBeforeNum = 0; // 清理所有日志数据
} else {
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("joblog_clean_type_invalid"));
}
List<Long> logIds;
do {
logIds = jobLogMapper.findClearLogIds(jobGroup, jobId, clearBeforeTime, clearBeforeNum, 1000);
if (logIds != null && logIds.size() > 0) {
jobLogMapper.clearLog(logIds);
}
} while (logIds != null && logIds.size() > 0);
return ReturnT.SUCCESS;
}
@ApiOperation("停止该job作业")
@PostMapping("/killJob")
@PreAuthorize("@ss.hasPermi('datax:joblog:killJob')")
public ReturnT<String> killJob(@RequestBody JobLog log) {
return KillJob.trigger(log.getId(), log.getTriggerTime(), log.getExecutorAddress(), log.getProcessId());
}
}

View File

@ -0,0 +1,117 @@
package com.czsj.web.controller.bigdata;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.R;
import com.czsj.bigdata.entity.JobProject;
import com.czsj.bigdata.service.JobProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.List;
/**
* project manage controller
*
* @author jingwk 2022-05-24 16:13:16
*/
@RestController
@RequestMapping("/api/jobProject")
@Api(tags = "项目管理模块")
public class JobProjectController extends BaseController {
@Autowired
private JobProjectService jobProjectService;
/**
* 分页查询所有数据
*
* @return 所有数据
*/
@GetMapping
@ApiOperation("分页查询所有数据")
@PreAuthorize("@ss.hasPermi('datax:jobProject:list')")
public R<IPage<JobProject>> selectAll(@RequestParam(value = "searchVal", required = false) String searchVal,
@RequestParam("pageSize") Integer pageSize,
@RequestParam("pageNo") Integer pageNo) {
return success(jobProjectService.getProjectListPaging(pageSize, pageNo, searchVal));
}
/**
* Get all project
*
* @return
*/
@ApiOperation("获取所有数据")
@GetMapping("/list")
@PreAuthorize("@ss.hasPermi('datax:jobProject:query')")
public R<List<JobProject>> selectList() {
QueryWrapper<JobProject> query = new QueryWrapper();
query.eq("flag", true);
return success(jobProjectService.list(query));
}
/**
* 通过主键查询单条数据
*
* @param id 主键
* @return 单条数据
*/
@ApiOperation("通过主键查询单条数据")
@GetMapping("{id}")
@PreAuthorize("@ss.hasPermi('datax:jobProject:query')")
public R<JobProject> selectOne(@PathVariable Serializable id) {
return success(this.jobProjectService.getById(id));
}
/**
* 新增数据
*
* @param entity 实体对象
* @return 新增结果
*/
@ApiOperation("新增数据")
@PostMapping
@PreAuthorize("@ss.hasPermi('datax:jobProject:add')")
public R<Boolean> insert(HttpServletRequest request, @RequestBody JobProject entity) {
entity.setUserId(getUserId());
return success(this.jobProjectService.save(entity));
}
/**
* 修改数据
*
* @param entity 实体对象
* @return 修改结果
*/
@PutMapping
@ApiOperation("修改数据")
@PreAuthorize("@ss.hasPermi('datax:jobProject:edit')")
public R<Boolean> update(@RequestBody JobProject entity) {
JobProject project = jobProjectService.getById(entity.getId());
project.setName(entity.getName());
project.setDescription(entity.getDescription());
return success(this.jobProjectService.updateById(entity));
}
/**
* 删除数据
*
* @param idList 主键结合
* @return 删除结果
*/
@DeleteMapping
@ApiOperation("删除数据")
@PreAuthorize("@ss.hasPermi('datax:jobProject:remove')")
public R<Boolean> delete(@RequestParam("idList") List<Long> idList) {
return success(this.jobProjectService.removeByIds(idList));
}
}

View File

@ -0,0 +1,90 @@
package com.czsj.web.controller.bigdata;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.R;
import com.czsj.bigdata.entity.JobRegistry;
import com.czsj.bigdata.service.JobRegistryService;
import com.czsj.bigdata.util.PageUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* Created by jingwk on 2019/11/17
*/
@RestController
@RequestMapping("/api/jobRegistry")
@Api(tags = "执行器资源监控")
public class JobRegistryController extends BaseController {
@Autowired
private JobRegistryService jobRegistryService;
/**
* 分页查询所有数据
*
* @return 所有数据
*/
@GetMapping
@ApiOperation("分页查询所有数据")
@ApiImplicitParams(
{@ApiImplicitParam(paramType = "query", dataType = "String", name = "current", value = "当前页", defaultValue = "1", required = true),
@ApiImplicitParam(paramType = "query", dataType = "String", name = "size", value = "一页大小", defaultValue = "10", required = true),
@ApiImplicitParam(paramType = "query", dataType = "Boolean", name = "ifCount", value = "是否查询总数", defaultValue = "true"),
@ApiImplicitParam(paramType = "query", dataType = "String", name = "ascs", value = "升序字段,多个用逗号分隔"),
@ApiImplicitParam(paramType = "query", dataType = "String", name = "descs", value = "降序字段,多个用逗号分隔")
})
public R<IPage<JobRegistry>> selectAll() {
BaseForm baseForm = new BaseForm();
return success(this.jobRegistryService.page(baseForm.getPlusPagingQueryEntity(), pageQueryWrapperCustom(baseForm.getParameters())));
}
/**
* 自定义查询组装
*
* @param map
* @return
*/
protected QueryWrapper<JobRegistry> pageQueryWrapperCustom(Map<String, Object> map) {
// mybatis plus 分页相关的参数
Map<String, Object> pageHelperParams = PageUtils.filterPageParams(map);
//过滤空值分页查询相关的参数
Map<String, Object> columnQueryMap = PageUtils.filterColumnQueryParams(map);
QueryWrapper<JobRegistry> queryWrapper = new QueryWrapper<>();
//排序 操作
pageHelperParams.forEach((k, v) -> {
switch (k) {
case "ascs":
queryWrapper.orderByAsc(StrUtil.toUnderlineCase(StrUtil.toString(v)));
break;
case "descs":
queryWrapper.orderByDesc(StrUtil.toUnderlineCase(StrUtil.toString(v)));
break;
}
});
//遍历进行字段查询条件组装
columnQueryMap.forEach((k, v) -> {
switch (k) {
case "datasourceName":
queryWrapper.like(StrUtil.toUnderlineCase(k), v);
break;
default:
queryWrapper.eq(StrUtil.toUnderlineCase(k), v);
}
});
return queryWrapper;
}
}

View File

@ -0,0 +1,89 @@
package com.czsj.web.controller.bigdata;
import com.czsj.bigdata.core.cron.CronExpression;
import com.czsj.bigdata.core.util.I18nUtil;
import com.czsj.bigdata.entity.JobTemplate;
import com.czsj.bigdata.service.JobTemplateService;
import com.czsj.core.biz.model.ReturnT;
import com.czsj.core.util.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* template controller
*
* @author jingwk 2019-12-22 16:13:16
*/
@Api(tags = "任务配置接口")
@RestController
@RequestMapping("/api/jobTemplate")
public class JobTemplateController extends BaseController{
@Autowired
private JobTemplateService jobTemplateService;
@GetMapping("/pageList")
@ApiOperation("任务模板列表")
@PreAuthorize("@ss.hasPermi('datax:jobTemplate:list')")
public ReturnT<Map<String, Object>> pageList(@RequestParam(required = false, defaultValue = "0") int current,
@RequestParam(required = false, defaultValue = "10") int size,
int jobGroup, String jobDesc, String executorHandler, int userId, Integer[] projectIds) {
return new ReturnT<>(jobTemplateService.pageList((current-1)*size, size, jobGroup, jobDesc, executorHandler, userId, projectIds));
}
@PostMapping("/add")
@ApiOperation("添加任务模板")
@PreAuthorize("@ss.hasPermi('datax:jobTemplate:add')")
public ReturnT<String> add(HttpServletRequest request, @RequestBody JobTemplate jobTemplate) {
jobTemplate.setUserId(getUserId());
return jobTemplateService.add(jobTemplate);
}
@PostMapping("/update")
@ApiOperation("更新任务")
@PreAuthorize("@ss.hasPermi('datax:jobTemplate:edit')")
public ReturnT<String> update(HttpServletRequest request,@RequestBody JobTemplate jobTemplate) {
jobTemplate.setUserId(getUserId());
return jobTemplateService.update(jobTemplate);
}
@PostMapping(value = "/remove/{id}")
@ApiOperation("移除任务模板")
@PreAuthorize("@ss.hasPermi('datax:jobTemplate:remove')")
public ReturnT<String> remove(@PathVariable(value = "id") int id) {
return jobTemplateService.remove(id);
}
@GetMapping("/nextTriggerTime")
@ApiOperation("获取近5次触发时间")
public ReturnT<List<String>> nextTriggerTime(String cron) {
List<String> result = new ArrayList<>();
try {
CronExpression cronExpression = new CronExpression(cron);
Date lastTime = new Date();
for (int i = 0; i < 5; i++) {
lastTime = cronExpression.getNextValidTimeAfter(lastTime);
if (lastTime != null) {
result.add(DateUtil.formatDateTime(lastTime));
} else {
break;
}
}
} catch (ParseException e) {
return new ReturnT<>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_invalid"));
}
return new ReturnT<>(result);
}
}

View File

@ -0,0 +1,106 @@
package com.czsj.web.controller.bigdata;
import com.baomidou.mybatisplus.extension.api.R;
import com.czsj.bigdata.service.DatasourceQueryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
/**
* 查询数据库表名字段的控制器
*
* @author jingwk
* @ClassName MetadataController
* @Version 2.1.2
* @since 2022/05/31 20:48
*/
@RestController
@RequestMapping("api/metadata")
@Api(tags = "jdbc数据库查询控制器")
public class MetadataController extends BaseController {
@Autowired
private DatasourceQueryService datasourceQueryService;
/**
* 根据数据源id获取mongo库名
*
* @param datasourceId
* @return
*/
@GetMapping("/getDBs")
@ApiOperation("根据数据源id获取mongo库名")
public R<List<String>> getDBs(Long datasourceId) throws IOException {
return success(datasourceQueryService.getDBs(datasourceId));
}
/**
* 根据数据源id,dbname获取CollectionNames
*
* @param datasourceId
* @return
*/
@GetMapping("/collectionNames")
@ApiOperation("根据数据源id,dbname获取CollectionNames")
public R<List<String>> getCollectionNames(Long datasourceId,String dbName) throws IOException {
return success(datasourceQueryService.getCollectionNames(datasourceId,dbName));
}
/**
* 获取PG table schema
*
* @param datasourceId
* @return
*/
@GetMapping("/getDBSchema")
@ApiOperation("根据数据源id获取 db schema")
public R<List<String>> getTableSchema(Long datasourceId) {
return success(datasourceQueryService.getTableSchema(datasourceId));
}
/**
* 根据数据源id获取可用表名
*
* @param datasourceId
* @return
*/
@GetMapping("/getTables")
@ApiOperation("根据数据源id获取可用表名")
public R<List<String>> getTableNames(Long datasourceId,String tableSchema) throws IOException {
return success(datasourceQueryService.getTables(datasourceId,tableSchema));
}
/**
* 根据数据源id和表名获取所有字段
*
* @param datasourceId 数据源id
* @param tableName 表名
* @return
*/
@GetMapping("/getColumns")
@ApiOperation("根据数据源id和表名获取所有字段")
public R<List<String>> getColumns(Long datasourceId, String tableName) throws IOException {
return success(datasourceQueryService.getColumns(datasourceId, tableName));
}
/**
* 根据数据源id和sql语句获取所有字段
*
* @param datasourceId 数据源id
* @param querySql 表名
* @return
*/
@GetMapping("/getColumnsByQuerySql")
@ApiOperation("根据数据源id和sql语句获取所有字段")
public R<List<String>> getColumnsByQuerySql(Long datasourceId, String querySql) throws SQLException {
return success(datasourceQueryService.getColumnsByQuerySql(datasourceId, querySql));
}
}

View File

@ -1,104 +0,0 @@
package com.czsj.web.controller.dataCenter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czsj.common.annotation.Log;
import com.czsj.common.core.controller.BaseController;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.enums.BusinessType;
import com.czsj.dataCenter.domain.DataArrangeEntity;
import com.czsj.dataCenter.service.IDataArrangeEntityService;
import com.czsj.common.utils.poi.ExcelUtil;
import com.czsj.common.core.page.TableDataInfo;
/**
* 任务编排信息Controller
*
* @author czsj
* @date 2024-12-08
*/
@RestController
@RequestMapping("/dataCenter/arrange")
public class DataArrangeEntityController extends BaseController
{
@Autowired
private IDataArrangeEntityService dataArrangeEntityService;
/**
* 查询任务编排信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:arrange:list')")
@GetMapping("/list")
public TableDataInfo list(DataArrangeEntity dataArrangeEntity)
{
startPage();
List<DataArrangeEntity> list = dataArrangeEntityService.selectDataArrangeEntityList(dataArrangeEntity);
return getDataTable(list);
}
/**
* 导出任务编排信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:arrange:export')")
@Log(title = "任务编排信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataArrangeEntity dataArrangeEntity)
{
List<DataArrangeEntity> list = dataArrangeEntityService.selectDataArrangeEntityList(dataArrangeEntity);
ExcelUtil<DataArrangeEntity> util = new ExcelUtil<DataArrangeEntity>(DataArrangeEntity.class);
util.exportExcel(response, list, "任务编排信息数据");
}
/**
* 获取任务编排信息详细信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:arrange:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(dataArrangeEntityService.selectDataArrangeEntityById(id));
}
/**
* 新增任务编排信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:arrange:add')")
@Log(title = "任务编排信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DataArrangeEntity dataArrangeEntity)
{
return toAjax(dataArrangeEntityService.insertDataArrangeEntity(dataArrangeEntity));
}
/**
* 修改任务编排信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:arrange:edit')")
@Log(title = "任务编排信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DataArrangeEntity dataArrangeEntity)
{
return toAjax(dataArrangeEntityService.updateDataArrangeEntity(dataArrangeEntity));
}
/**
* 删除任务编排信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:arrange:remove')")
@Log(title = "任务编排信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(dataArrangeEntityService.deleteDataArrangeEntityByIds(ids));
}
}

View File

@ -1,104 +0,0 @@
package com.czsj.web.controller.dataCenter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czsj.common.annotation.Log;
import com.czsj.common.core.controller.BaseController;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.enums.BusinessType;
import com.czsj.dataCenter.domain.DataArrangeLogEntity;
import com.czsj.dataCenter.service.IDataArrangeLogEntityService;
import com.czsj.common.utils.poi.ExcelUtil;
import com.czsj.common.core.page.TableDataInfo;
/**
* 编排日志信息Controller
*
* @author czsj
* @date 2024-12-08
*/
@RestController
@RequestMapping("/dataCenter/arrangeLog")
public class DataArrangeLogEntityController extends BaseController
{
@Autowired
private IDataArrangeLogEntityService dataArrangeLogEntityService;
/**
* 查询编排日志信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:arrangeLog:list')")
@GetMapping("/list")
public TableDataInfo list(DataArrangeLogEntity dataArrangeLogEntity)
{
startPage();
List<DataArrangeLogEntity> list = dataArrangeLogEntityService.selectDataArrangeLogEntityList(dataArrangeLogEntity);
return getDataTable(list);
}
/**
* 导出编排日志信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:arrangeLog:export')")
@Log(title = "编排日志信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataArrangeLogEntity dataArrangeLogEntity)
{
List<DataArrangeLogEntity> list = dataArrangeLogEntityService.selectDataArrangeLogEntityList(dataArrangeLogEntity);
ExcelUtil<DataArrangeLogEntity> util = new ExcelUtil<DataArrangeLogEntity>(DataArrangeLogEntity.class);
util.exportExcel(response, list, "编排日志信息数据");
}
/**
* 获取编排日志信息详细信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:arrangeLog:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(dataArrangeLogEntityService.selectDataArrangeLogEntityById(id));
}
/**
* 新增编排日志信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:arrangeLog:add')")
@Log(title = "编排日志信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DataArrangeLogEntity dataArrangeLogEntity)
{
return toAjax(dataArrangeLogEntityService.insertDataArrangeLogEntity(dataArrangeLogEntity));
}
/**
* 修改编排日志信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:arrangeLog:edit')")
@Log(title = "编排日志信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DataArrangeLogEntity dataArrangeLogEntity)
{
return toAjax(dataArrangeLogEntityService.updateDataArrangeLogEntity(dataArrangeLogEntity));
}
/**
* 删除编排日志信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:arrangeLog:remove')")
@Log(title = "编排日志信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(dataArrangeLogEntityService.deleteDataArrangeLogEntityByIds(ids));
}
}

View File

@ -1,104 +0,0 @@
package com.czsj.web.controller.dataCenter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czsj.common.annotation.Log;
import com.czsj.common.core.controller.BaseController;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.enums.BusinessType;
import com.czsj.dataCenter.domain.DataBusinessEntity;
import com.czsj.dataCenter.service.IDataBusinessEntityService;
import com.czsj.common.utils.poi.ExcelUtil;
import com.czsj.common.core.page.TableDataInfo;
/**
* 业务分类信息Controller
*
* @author czsj
* @date 2024-12-08
*/
@RestController
@RequestMapping("/dataCenter/business")
public class DataBusinessEntityController extends BaseController
{
@Autowired
private IDataBusinessEntityService dataBusinessEntityService;
/**
* 查询业务分类信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:business:list')")
@GetMapping("/list")
public TableDataInfo list(DataBusinessEntity dataBusinessEntity)
{
startPage();
List<DataBusinessEntity> list = dataBusinessEntityService.selectDataBusinessEntityList(dataBusinessEntity);
return getDataTable(list);
}
/**
* 导出业务分类信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:business:export')")
@Log(title = "业务分类信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataBusinessEntity dataBusinessEntity)
{
List<DataBusinessEntity> list = dataBusinessEntityService.selectDataBusinessEntityList(dataBusinessEntity);
ExcelUtil<DataBusinessEntity> util = new ExcelUtil<DataBusinessEntity>(DataBusinessEntity.class);
util.exportExcel(response, list, "业务分类信息数据");
}
/**
* 获取业务分类信息详细信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:business:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(dataBusinessEntityService.selectDataBusinessEntityById(id));
}
/**
* 新增业务分类信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:business:add')")
@Log(title = "业务分类信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DataBusinessEntity dataBusinessEntity)
{
return toAjax(dataBusinessEntityService.insertDataBusinessEntity(dataBusinessEntity));
}
/**
* 修改业务分类信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:business:edit')")
@Log(title = "业务分类信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DataBusinessEntity dataBusinessEntity)
{
return toAjax(dataBusinessEntityService.updateDataBusinessEntity(dataBusinessEntity));
}
/**
* 删除业务分类信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:business:remove')")
@Log(title = "业务分类信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(dataBusinessEntityService.deleteDataBusinessEntityByIds(ids));
}
}

View File

@ -1,104 +0,0 @@
package com.czsj.web.controller.dataCenter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czsj.common.annotation.Log;
import com.czsj.common.core.controller.BaseController;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.enums.BusinessType;
import com.czsj.dataCenter.domain.DataInterfaceEntity;
import com.czsj.dataCenter.service.IDataInterfaceEntityService;
import com.czsj.common.utils.poi.ExcelUtil;
import com.czsj.common.core.page.TableDataInfo;
/**
* 接口信息Controller
*
* @author czsj
* @date 2024-12-08
*/
@RestController
@RequestMapping("/dataCenter/interface")
public class DataInterfaceEntityController extends BaseController
{
@Autowired
private IDataInterfaceEntityService dataInterfaceEntityService;
/**
* 查询接口信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:interface:list')")
@GetMapping("/list")
public TableDataInfo list(DataInterfaceEntity dataInterfaceEntity)
{
startPage();
List<DataInterfaceEntity> list = dataInterfaceEntityService.selectDataInterfaceEntityList(dataInterfaceEntity);
return getDataTable(list);
}
/**
* 导出接口信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:interface:export')")
@Log(title = "接口信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataInterfaceEntity dataInterfaceEntity)
{
List<DataInterfaceEntity> list = dataInterfaceEntityService.selectDataInterfaceEntityList(dataInterfaceEntity);
ExcelUtil<DataInterfaceEntity> util = new ExcelUtil<DataInterfaceEntity>(DataInterfaceEntity.class);
util.exportExcel(response, list, "接口信息数据");
}
/**
* 获取接口信息详细信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:interface:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(dataInterfaceEntityService.selectDataInterfaceEntityById(id));
}
/**
* 新增接口信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:interface:add')")
@Log(title = "接口信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DataInterfaceEntity dataInterfaceEntity)
{
return toAjax(dataInterfaceEntityService.insertDataInterfaceEntity(dataInterfaceEntity));
}
/**
* 修改接口信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:interface:edit')")
@Log(title = "接口信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DataInterfaceEntity dataInterfaceEntity)
{
return toAjax(dataInterfaceEntityService.updateDataInterfaceEntity(dataInterfaceEntity));
}
/**
* 删除接口信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:interface:remove')")
@Log(title = "接口信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(dataInterfaceEntityService.deleteDataInterfaceEntityByIds(ids));
}
}

View File

@ -1,104 +0,0 @@
package com.czsj.web.controller.dataCenter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czsj.common.annotation.Log;
import com.czsj.common.core.controller.BaseController;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.enums.BusinessType;
import com.czsj.dataCenter.domain.DataInterfaceParamsEntity;
import com.czsj.dataCenter.service.IDataInterfaceParamsEntityService;
import com.czsj.common.utils.poi.ExcelUtil;
import com.czsj.common.core.page.TableDataInfo;
/**
* 接口参数信息Controller
*
* @author czsj
* @date 2024-12-08
*/
@RestController
@RequestMapping("/dataCenter/interfaceParams")
public class DataInterfaceParamsEntityController extends BaseController
{
@Autowired
private IDataInterfaceParamsEntityService dataInterfaceParamsEntityService;
/**
* 查询接口参数信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:interfaceParams:list')")
@GetMapping("/list")
public TableDataInfo list(DataInterfaceParamsEntity dataInterfaceParamsEntity)
{
startPage();
List<DataInterfaceParamsEntity> list = dataInterfaceParamsEntityService.selectDataInterfaceParamsEntityList(dataInterfaceParamsEntity);
return getDataTable(list);
}
/**
* 导出接口参数信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:interfaceParams:export')")
@Log(title = "接口参数信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataInterfaceParamsEntity dataInterfaceParamsEntity)
{
List<DataInterfaceParamsEntity> list = dataInterfaceParamsEntityService.selectDataInterfaceParamsEntityList(dataInterfaceParamsEntity);
ExcelUtil<DataInterfaceParamsEntity> util = new ExcelUtil<DataInterfaceParamsEntity>(DataInterfaceParamsEntity.class);
util.exportExcel(response, list, "接口参数信息数据");
}
/**
* 获取接口参数信息详细信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:interfaceParams:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(dataInterfaceParamsEntityService.selectDataInterfaceParamsEntityById(id));
}
/**
* 新增接口参数信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:interfaceParams:add')")
@Log(title = "接口参数信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DataInterfaceParamsEntity dataInterfaceParamsEntity)
{
return toAjax(dataInterfaceParamsEntityService.insertDataInterfaceParamsEntity(dataInterfaceParamsEntity));
}
/**
* 修改接口参数信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:interfaceParams:edit')")
@Log(title = "接口参数信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DataInterfaceParamsEntity dataInterfaceParamsEntity)
{
return toAjax(dataInterfaceParamsEntityService.updateDataInterfaceParamsEntity(dataInterfaceParamsEntity));
}
/**
* 删除接口参数信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:interfaceParams:remove')")
@Log(title = "接口参数信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(dataInterfaceParamsEntityService.deleteDataInterfaceParamsEntityByIds(ids));
}
}

View File

@ -1,104 +0,0 @@
package com.czsj.web.controller.dataCenter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czsj.common.annotation.Log;
import com.czsj.common.core.controller.BaseController;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.enums.BusinessType;
import com.czsj.dataCenter.domain.DataMappingArgsEntity;
import com.czsj.dataCenter.service.IDataMappingArgsEntityService;
import com.czsj.common.utils.poi.ExcelUtil;
import com.czsj.common.core.page.TableDataInfo;
/**
* 配置执行类参数信息Controller
*
* @author czsj
* @date 2024-12-08
*/
@RestController
@RequestMapping("/dataCenter/mappingArgs")
public class DataMappingArgsEntityController extends BaseController
{
@Autowired
private IDataMappingArgsEntityService dataMappingArgsEntityService;
/**
* 查询配置执行类参数信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:mappingArgs:list')")
@GetMapping("/list")
public TableDataInfo list(DataMappingArgsEntity dataMappingArgsEntity)
{
startPage();
List<DataMappingArgsEntity> list = dataMappingArgsEntityService.selectDataMappingArgsEntityList(dataMappingArgsEntity);
return getDataTable(list);
}
/**
* 导出配置执行类参数信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:mappingArgs:export')")
@Log(title = "配置执行类参数信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataMappingArgsEntity dataMappingArgsEntity)
{
List<DataMappingArgsEntity> list = dataMappingArgsEntityService.selectDataMappingArgsEntityList(dataMappingArgsEntity);
ExcelUtil<DataMappingArgsEntity> util = new ExcelUtil<DataMappingArgsEntity>(DataMappingArgsEntity.class);
util.exportExcel(response, list, "配置执行类参数信息数据");
}
/**
* 获取配置执行类参数信息详细信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:mappingArgs:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(dataMappingArgsEntityService.selectDataMappingArgsEntityById(id));
}
/**
* 新增配置执行类参数信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:mappingArgs:add')")
@Log(title = "配置执行类参数信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DataMappingArgsEntity dataMappingArgsEntity)
{
return toAjax(dataMappingArgsEntityService.insertDataMappingArgsEntity(dataMappingArgsEntity));
}
/**
* 修改配置执行类参数信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:mappingArgs:edit')")
@Log(title = "配置执行类参数信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DataMappingArgsEntity dataMappingArgsEntity)
{
return toAjax(dataMappingArgsEntityService.updateDataMappingArgsEntity(dataMappingArgsEntity));
}
/**
* 删除配置执行类参数信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:mappingArgs:remove')")
@Log(title = "配置执行类参数信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(dataMappingArgsEntityService.deleteDataMappingArgsEntityByIds(ids));
}
}

View File

@ -1,104 +0,0 @@
package com.czsj.web.controller.dataCenter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czsj.common.annotation.Log;
import com.czsj.common.core.controller.BaseController;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.enums.BusinessType;
import com.czsj.dataCenter.domain.DataMappingEntity;
import com.czsj.dataCenter.service.IDataMappingEntityService;
import com.czsj.common.utils.poi.ExcelUtil;
import com.czsj.common.core.page.TableDataInfo;
/**
* 配置执行类映射信息Controller
*
* @author czsj
* @date 2024-12-08
*/
@RestController
@RequestMapping("/dataCenter/mapping")
public class DataMappingEntityController extends BaseController
{
@Autowired
private IDataMappingEntityService dataMappingEntityService;
/**
* 查询配置执行类映射信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:mapping:list')")
@GetMapping("/list")
public TableDataInfo list(DataMappingEntity dataMappingEntity)
{
startPage();
List<DataMappingEntity> list = dataMappingEntityService.selectDataMappingEntityList(dataMappingEntity);
return getDataTable(list);
}
/**
* 导出配置执行类映射信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:mapping:export')")
@Log(title = "配置执行类映射信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataMappingEntity dataMappingEntity)
{
List<DataMappingEntity> list = dataMappingEntityService.selectDataMappingEntityList(dataMappingEntity);
ExcelUtil<DataMappingEntity> util = new ExcelUtil<DataMappingEntity>(DataMappingEntity.class);
util.exportExcel(response, list, "配置执行类映射信息数据");
}
/**
* 获取配置执行类映射信息详细信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:mapping:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(dataMappingEntityService.selectDataMappingEntityById(id));
}
/**
* 新增配置执行类映射信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:mapping:add')")
@Log(title = "配置执行类映射信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DataMappingEntity dataMappingEntity)
{
return toAjax(dataMappingEntityService.insertDataMappingEntity(dataMappingEntity));
}
/**
* 修改配置执行类映射信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:mapping:edit')")
@Log(title = "配置执行类映射信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DataMappingEntity dataMappingEntity)
{
return toAjax(dataMappingEntityService.updateDataMappingEntity(dataMappingEntity));
}
/**
* 删除配置执行类映射信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:mapping:remove')")
@Log(title = "配置执行类映射信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(dataMappingEntityService.deleteDataMappingEntityByIds(ids));
}
}

View File

@ -1,104 +0,0 @@
package com.czsj.web.controller.dataCenter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czsj.common.annotation.Log;
import com.czsj.common.core.controller.BaseController;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.enums.BusinessType;
import com.czsj.dataCenter.domain.DataProcessEntity;
import com.czsj.dataCenter.service.IDataProcessEntityService;
import com.czsj.common.utils.poi.ExcelUtil;
import com.czsj.common.core.page.TableDataInfo;
/**
* 节点流程信息Controller
*
* @author czsj
* @date 2024-12-08
*/
@RestController
@RequestMapping("/dataCenter/process")
public class DataProcessEntityController extends BaseController
{
@Autowired
private IDataProcessEntityService dataProcessEntityService;
/**
* 查询节点流程信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:process:list')")
@GetMapping("/list")
public TableDataInfo list(DataProcessEntity dataProcessEntity)
{
startPage();
List<DataProcessEntity> list = dataProcessEntityService.selectDataProcessEntityList(dataProcessEntity);
return getDataTable(list);
}
/**
* 导出节点流程信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:process:export')")
@Log(title = "节点流程信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataProcessEntity dataProcessEntity)
{
List<DataProcessEntity> list = dataProcessEntityService.selectDataProcessEntityList(dataProcessEntity);
ExcelUtil<DataProcessEntity> util = new ExcelUtil<DataProcessEntity>(DataProcessEntity.class);
util.exportExcel(response, list, "节点流程信息数据");
}
/**
* 获取节点流程信息详细信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:process:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(dataProcessEntityService.selectDataProcessEntityById(id));
}
/**
* 新增节点流程信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:process:add')")
@Log(title = "节点流程信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DataProcessEntity dataProcessEntity)
{
return toAjax(dataProcessEntityService.insertDataProcessEntity(dataProcessEntity));
}
/**
* 修改节点流程信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:process:edit')")
@Log(title = "节点流程信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DataProcessEntity dataProcessEntity)
{
return toAjax(dataProcessEntityService.updateDataProcessEntity(dataProcessEntity));
}
/**
* 删除节点流程信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:process:remove')")
@Log(title = "节点流程信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(dataProcessEntityService.deleteDataProcessEntityByIds(ids));
}
}

View File

@ -1,104 +0,0 @@
package com.czsj.web.controller.dataCenter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czsj.common.annotation.Log;
import com.czsj.common.core.controller.BaseController;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.enums.BusinessType;
import com.czsj.dataCenter.domain.DataSingleTaskConfigEntity;
import com.czsj.dataCenter.service.IDataSingleTaskConfigEntityService;
import com.czsj.common.utils.poi.ExcelUtil;
import com.czsj.common.core.page.TableDataInfo;
/**
* 单任务配置信息Controller
*
* @author czsj
* @date 2024-12-08
*/
@RestController
@RequestMapping("/dataCenter/singleTaskConfig")
public class DataSingleTaskConfigEntityController extends BaseController
{
@Autowired
private IDataSingleTaskConfigEntityService dataSingleTaskConfigEntityService;
/**
* 查询单任务配置信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:singleTaskConfig:list')")
@GetMapping("/list")
public TableDataInfo list(DataSingleTaskConfigEntity dataSingleTaskConfigEntity)
{
startPage();
List<DataSingleTaskConfigEntity> list = dataSingleTaskConfigEntityService.selectDataSingleTaskConfigEntityList(dataSingleTaskConfigEntity);
return getDataTable(list);
}
/**
* 导出单任务配置信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:singleTaskConfig:export')")
@Log(title = "单任务配置信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataSingleTaskConfigEntity dataSingleTaskConfigEntity)
{
List<DataSingleTaskConfigEntity> list = dataSingleTaskConfigEntityService.selectDataSingleTaskConfigEntityList(dataSingleTaskConfigEntity);
ExcelUtil<DataSingleTaskConfigEntity> util = new ExcelUtil<DataSingleTaskConfigEntity>(DataSingleTaskConfigEntity.class);
util.exportExcel(response, list, "单任务配置信息数据");
}
/**
* 获取单任务配置信息详细信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:singleTaskConfig:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(dataSingleTaskConfigEntityService.selectDataSingleTaskConfigEntityById(id));
}
/**
* 新增单任务配置信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:singleTaskConfig:add')")
@Log(title = "单任务配置信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DataSingleTaskConfigEntity dataSingleTaskConfigEntity)
{
return toAjax(dataSingleTaskConfigEntityService.insertDataSingleTaskConfigEntity(dataSingleTaskConfigEntity));
}
/**
* 修改单任务配置信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:singleTaskConfig:edit')")
@Log(title = "单任务配置信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DataSingleTaskConfigEntity dataSingleTaskConfigEntity)
{
return toAjax(dataSingleTaskConfigEntityService.updateDataSingleTaskConfigEntity(dataSingleTaskConfigEntity));
}
/**
* 删除单任务配置信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:singleTaskConfig:remove')")
@Log(title = "单任务配置信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(dataSingleTaskConfigEntityService.deleteDataSingleTaskConfigEntityByIds(ids));
}
}

View File

@ -1,104 +0,0 @@
package com.czsj.web.controller.dataCenter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czsj.common.annotation.Log;
import com.czsj.common.core.controller.BaseController;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.enums.BusinessType;
import com.czsj.dataCenter.domain.DataSourceEntity;
import com.czsj.dataCenter.service.IDataSourceEntityService;
import com.czsj.common.utils.poi.ExcelUtil;
import com.czsj.common.core.page.TableDataInfo;
/**
* 数据源信息Controller
*
* @author czsj
* @date 2024-12-08
*/
@RestController
@RequestMapping("/dataCenter/source")
public class DataSourceEntityController extends BaseController
{
@Autowired
private IDataSourceEntityService dataSourceEntityService;
/**
* 查询数据源信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:source:list')")
@GetMapping("/list")
public TableDataInfo list(DataSourceEntity dataSourceEntity)
{
startPage();
List<DataSourceEntity> list = dataSourceEntityService.selectDataSourceEntityList(dataSourceEntity);
return getDataTable(list);
}
/**
* 导出数据源信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:source:export')")
@Log(title = "数据源信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataSourceEntity dataSourceEntity)
{
List<DataSourceEntity> list = dataSourceEntityService.selectDataSourceEntityList(dataSourceEntity);
ExcelUtil<DataSourceEntity> util = new ExcelUtil<DataSourceEntity>(DataSourceEntity.class);
util.exportExcel(response, list, "数据源信息数据");
}
/**
* 获取数据源信息详细信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:source:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(dataSourceEntityService.selectDataSourceEntityById(id));
}
/**
* 新增数据源信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:source:add')")
@Log(title = "数据源信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DataSourceEntity dataSourceEntity)
{
return toAjax(dataSourceEntityService.insertDataSourceEntity(dataSourceEntity));
}
/**
* 修改数据源信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:source:edit')")
@Log(title = "数据源信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DataSourceEntity dataSourceEntity)
{
return toAjax(dataSourceEntityService.updateDataSourceEntity(dataSourceEntity));
}
/**
* 删除数据源信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:source:remove')")
@Log(title = "数据源信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(dataSourceEntityService.deleteDataSourceEntityByIds(ids));
}
}

View File

@ -1,104 +0,0 @@
package com.czsj.web.controller.dataCenter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czsj.common.annotation.Log;
import com.czsj.common.core.controller.BaseController;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.enums.BusinessType;
import com.czsj.dataCenter.domain.DataSourceTypeEntity;
import com.czsj.dataCenter.service.IDataSourceTypeEntityService;
import com.czsj.common.utils.poi.ExcelUtil;
import com.czsj.common.core.page.TableDataInfo;
/**
* 数据源分类信息Controller
*
* @author czsj
* @date 2024-12-08
*/
@RestController
@RequestMapping("/dataCenter/sourceType")
public class DataSourceTypeEntityController extends BaseController
{
@Autowired
private IDataSourceTypeEntityService dataSourceTypeEntityService;
/**
* 查询数据源分类信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:sourceType:list')")
@GetMapping("/list")
public TableDataInfo list(DataSourceTypeEntity dataSourceTypeEntity)
{
startPage();
List<DataSourceTypeEntity> list = dataSourceTypeEntityService.selectDataSourceTypeEntityList(dataSourceTypeEntity);
return getDataTable(list);
}
/**
* 导出数据源分类信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:sourceType:export')")
@Log(title = "数据源分类信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataSourceTypeEntity dataSourceTypeEntity)
{
List<DataSourceTypeEntity> list = dataSourceTypeEntityService.selectDataSourceTypeEntityList(dataSourceTypeEntity);
ExcelUtil<DataSourceTypeEntity> util = new ExcelUtil<DataSourceTypeEntity>(DataSourceTypeEntity.class);
util.exportExcel(response, list, "数据源分类信息数据");
}
/**
* 获取数据源分类信息详细信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:sourceType:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(dataSourceTypeEntityService.selectDataSourceTypeEntityById(id));
}
/**
* 新增数据源分类信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:sourceType:add')")
@Log(title = "数据源分类信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DataSourceTypeEntity dataSourceTypeEntity)
{
return toAjax(dataSourceTypeEntityService.insertDataSourceTypeEntity(dataSourceTypeEntity));
}
/**
* 修改数据源分类信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:sourceType:edit')")
@Log(title = "数据源分类信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DataSourceTypeEntity dataSourceTypeEntity)
{
return toAjax(dataSourceTypeEntityService.updateDataSourceTypeEntity(dataSourceTypeEntity));
}
/**
* 删除数据源分类信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:sourceType:remove')")
@Log(title = "数据源分类信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(dataSourceTypeEntityService.deleteDataSourceTypeEntityByIds(ids));
}
}

View File

@ -1,104 +0,0 @@
package com.czsj.web.controller.dataCenter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czsj.common.annotation.Log;
import com.czsj.common.core.controller.BaseController;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.enums.BusinessType;
import com.czsj.dataCenter.domain.DataTable;
import com.czsj.dataCenter.service.IDataTableService;
import com.czsj.common.utils.poi.ExcelUtil;
import com.czsj.common.core.page.TableDataInfo;
/**
* 数据库信息Controller
*
* @author czsj
* @date 2024-12-08
*/
@RestController
@RequestMapping("/dataCenter/table")
public class DataTableController extends BaseController
{
@Autowired
private IDataTableService dataTableService;
/**
* 查询数据库信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:table:list')")
@GetMapping("/list")
public TableDataInfo list(DataTable dataTable)
{
startPage();
List<DataTable> list = dataTableService.selectDataTableList(dataTable);
return getDataTable(list);
}
/**
* 导出数据库信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:table:export')")
@Log(title = "数据库信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataTable dataTable)
{
List<DataTable> list = dataTableService.selectDataTableList(dataTable);
ExcelUtil<DataTable> util = new ExcelUtil<DataTable>(DataTable.class);
util.exportExcel(response, list, "数据库信息数据");
}
/**
* 获取数据库信息详细信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:table:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(dataTableService.selectDataTableById(id));
}
/**
* 新增数据库信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:table:add')")
@Log(title = "数据库信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DataTable dataTable)
{
return toAjax(dataTableService.insertDataTable(dataTable));
}
/**
* 修改数据库信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:table:edit')")
@Log(title = "数据库信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DataTable dataTable)
{
return toAjax(dataTableService.updateDataTable(dataTable));
}
/**
* 删除数据库信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:table:remove')")
@Log(title = "数据库信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(dataTableService.deleteDataTableByIds(ids));
}
}

View File

@ -1,104 +0,0 @@
package com.czsj.web.controller.dataCenter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czsj.common.annotation.Log;
import com.czsj.common.core.controller.BaseController;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.enums.BusinessType;
import com.czsj.dataCenter.domain.DataTableField;
import com.czsj.dataCenter.service.IDataTableFieldService;
import com.czsj.common.utils.poi.ExcelUtil;
import com.czsj.common.core.page.TableDataInfo;
/**
* 数据库字段信息Controller
*
* @author czsj
* @date 2024-12-08
*/
@RestController
@RequestMapping("/dataCenter/tableField")
public class DataTableFieldController extends BaseController
{
@Autowired
private IDataTableFieldService dataTableFieldService;
/**
* 查询数据库字段信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:tableField:list')")
@GetMapping("/list")
public TableDataInfo list(DataTableField dataTableField)
{
startPage();
List<DataTableField> list = dataTableFieldService.selectDataTableFieldList(dataTableField);
return getDataTable(list);
}
/**
* 导出数据库字段信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:tableField:export')")
@Log(title = "数据库字段信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataTableField dataTableField)
{
List<DataTableField> list = dataTableFieldService.selectDataTableFieldList(dataTableField);
ExcelUtil<DataTableField> util = new ExcelUtil<DataTableField>(DataTableField.class);
util.exportExcel(response, list, "数据库字段信息数据");
}
/**
* 获取数据库字段信息详细信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:tableField:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(dataTableFieldService.selectDataTableFieldById(id));
}
/**
* 新增数据库字段信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:tableField:add')")
@Log(title = "数据库字段信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DataTableField dataTableField)
{
return toAjax(dataTableFieldService.insertDataTableField(dataTableField));
}
/**
* 修改数据库字段信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:tableField:edit')")
@Log(title = "数据库字段信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DataTableField dataTableField)
{
return toAjax(dataTableFieldService.updateDataTableField(dataTableField));
}
/**
* 删除数据库字段信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:tableField:remove')")
@Log(title = "数据库字段信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(dataTableFieldService.deleteDataTableFieldByIds(ids));
}
}

View File

@ -1,104 +0,0 @@
package com.czsj.web.controller.dataCenter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czsj.common.annotation.Log;
import com.czsj.common.core.controller.BaseController;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.enums.BusinessType;
import com.czsj.dataCenter.domain.DataTaskConfigEntity;
import com.czsj.dataCenter.service.IDataTaskConfigEntityService;
import com.czsj.common.utils.poi.ExcelUtil;
import com.czsj.common.core.page.TableDataInfo;
/**
* 任务JOB块配置信息Controller
*
* @author czsj
* @date 2024-12-08
*/
@RestController
@RequestMapping("/dataCenter/taskConfig")
public class DataTaskConfigEntityController extends BaseController
{
@Autowired
private IDataTaskConfigEntityService dataTaskConfigEntityService;
/**
* 查询任务JOB块配置信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskConfig:list')")
@GetMapping("/list")
public TableDataInfo list(DataTaskConfigEntity dataTaskConfigEntity)
{
startPage();
List<DataTaskConfigEntity> list = dataTaskConfigEntityService.selectDataTaskConfigEntityList(dataTaskConfigEntity);
return getDataTable(list);
}
/**
* 导出任务JOB块配置信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskConfig:export')")
@Log(title = "任务JOB块配置信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataTaskConfigEntity dataTaskConfigEntity)
{
List<DataTaskConfigEntity> list = dataTaskConfigEntityService.selectDataTaskConfigEntityList(dataTaskConfigEntity);
ExcelUtil<DataTaskConfigEntity> util = new ExcelUtil<DataTaskConfigEntity>(DataTaskConfigEntity.class);
util.exportExcel(response, list, "任务JOB块配置信息数据");
}
/**
* 获取任务JOB块配置信息详细信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskConfig:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(dataTaskConfigEntityService.selectDataTaskConfigEntityById(id));
}
/**
* 新增任务JOB块配置信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskConfig:add')")
@Log(title = "任务JOB块配置信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DataTaskConfigEntity dataTaskConfigEntity)
{
return toAjax(dataTaskConfigEntityService.insertDataTaskConfigEntity(dataTaskConfigEntity));
}
/**
* 修改任务JOB块配置信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskConfig:edit')")
@Log(title = "任务JOB块配置信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DataTaskConfigEntity dataTaskConfigEntity)
{
return toAjax(dataTaskConfigEntityService.updateDataTaskConfigEntity(dataTaskConfigEntity));
}
/**
* 删除任务JOB块配置信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskConfig:remove')")
@Log(title = "任务JOB块配置信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(dataTaskConfigEntityService.deleteDataTaskConfigEntityByIds(ids));
}
}

View File

@ -1,104 +0,0 @@
package com.czsj.web.controller.dataCenter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czsj.common.annotation.Log;
import com.czsj.common.core.controller.BaseController;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.enums.BusinessType;
import com.czsj.dataCenter.domain.DataTaskCoreEntity;
import com.czsj.dataCenter.service.IDataTaskCoreEntityService;
import com.czsj.common.utils.poi.ExcelUtil;
import com.czsj.common.core.page.TableDataInfo;
/**
* 任务CORE块配置信息Controller
*
* @author czsj
* @date 2024-12-08
*/
@RestController
@RequestMapping("/dataCenter/taskCore")
public class DataTaskCoreEntityController extends BaseController
{
@Autowired
private IDataTaskCoreEntityService dataTaskCoreEntityService;
/**
* 查询任务CORE块配置信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskCore:list')")
@GetMapping("/list")
public TableDataInfo list(DataTaskCoreEntity dataTaskCoreEntity)
{
startPage();
List<DataTaskCoreEntity> list = dataTaskCoreEntityService.selectDataTaskCoreEntityList(dataTaskCoreEntity);
return getDataTable(list);
}
/**
* 导出任务CORE块配置信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskCore:export')")
@Log(title = "任务CORE块配置信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataTaskCoreEntity dataTaskCoreEntity)
{
List<DataTaskCoreEntity> list = dataTaskCoreEntityService.selectDataTaskCoreEntityList(dataTaskCoreEntity);
ExcelUtil<DataTaskCoreEntity> util = new ExcelUtil<DataTaskCoreEntity>(DataTaskCoreEntity.class);
util.exportExcel(response, list, "任务CORE块配置信息数据");
}
/**
* 获取任务CORE块配置信息详细信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskCore:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(dataTaskCoreEntityService.selectDataTaskCoreEntityById(id));
}
/**
* 新增任务CORE块配置信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskCore:add')")
@Log(title = "任务CORE块配置信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DataTaskCoreEntity dataTaskCoreEntity)
{
return toAjax(dataTaskCoreEntityService.insertDataTaskCoreEntity(dataTaskCoreEntity));
}
/**
* 修改任务CORE块配置信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskCore:edit')")
@Log(title = "任务CORE块配置信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DataTaskCoreEntity dataTaskCoreEntity)
{
return toAjax(dataTaskCoreEntityService.updateDataTaskCoreEntity(dataTaskCoreEntity));
}
/**
* 删除任务CORE块配置信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskCore:remove')")
@Log(title = "任务CORE块配置信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(dataTaskCoreEntityService.deleteDataTaskCoreEntityByIds(ids));
}
}

View File

@ -1,104 +0,0 @@
package com.czsj.web.controller.dataCenter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czsj.common.annotation.Log;
import com.czsj.common.core.controller.BaseController;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.enums.BusinessType;
import com.czsj.dataCenter.domain.DataTaskEntity;
import com.czsj.dataCenter.service.IDataTaskEntityService;
import com.czsj.common.utils.poi.ExcelUtil;
import com.czsj.common.core.page.TableDataInfo;
/**
* 任务主体信息Controller
*
* @author czsj
* @date 2024-12-08
*/
@RestController
@RequestMapping("/dataCenter/task")
public class DataTaskEntityController extends BaseController
{
@Autowired
private IDataTaskEntityService dataTaskEntityService;
/**
* 查询任务主体信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:task:list')")
@GetMapping("/list")
public TableDataInfo list(DataTaskEntity dataTaskEntity)
{
startPage();
List<DataTaskEntity> list = dataTaskEntityService.selectDataTaskEntityList(dataTaskEntity);
return getDataTable(list);
}
/**
* 导出任务主体信息列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:task:export')")
@Log(title = "任务主体信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataTaskEntity dataTaskEntity)
{
List<DataTaskEntity> list = dataTaskEntityService.selectDataTaskEntityList(dataTaskEntity);
ExcelUtil<DataTaskEntity> util = new ExcelUtil<DataTaskEntity>(DataTaskEntity.class);
util.exportExcel(response, list, "任务主体信息数据");
}
/**
* 获取任务主体信息详细信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:task:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(dataTaskEntityService.selectDataTaskEntityById(id));
}
/**
* 新增任务主体信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:task:add')")
@Log(title = "任务主体信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DataTaskEntity dataTaskEntity)
{
return toAjax(dataTaskEntityService.insertDataTaskEntity(dataTaskEntity));
}
/**
* 修改任务主体信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:task:edit')")
@Log(title = "任务主体信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DataTaskEntity dataTaskEntity)
{
return toAjax(dataTaskEntityService.updateDataTaskEntity(dataTaskEntity));
}
/**
* 删除任务主体信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:task:remove')")
@Log(title = "任务主体信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(dataTaskEntityService.deleteDataTaskEntityByIds(ids));
}
}

View File

@ -1,104 +0,0 @@
package com.czsj.web.controller.dataCenter;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.czsj.common.annotation.Log;
import com.czsj.common.core.controller.BaseController;
import com.czsj.common.core.domain.AjaxResult;
import com.czsj.common.enums.BusinessType;
import com.czsj.dataCenter.domain.DataTaskMakeUpEntity;
import com.czsj.dataCenter.service.IDataTaskMakeUpEntityService;
import com.czsj.common.utils.poi.ExcelUtil;
import com.czsj.common.core.page.TableDataInfo;
/**
* 任务配置组成数据Controller
*
* @author czsj
* @date 2024-12-08
*/
@RestController
@RequestMapping("/dataCenter/taskMakeUp")
public class DataTaskMakeUpEntityController extends BaseController
{
@Autowired
private IDataTaskMakeUpEntityService dataTaskMakeUpEntityService;
/**
* 查询任务配置组成数据列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskMakeUp:list')")
@GetMapping("/list")
public TableDataInfo list(DataTaskMakeUpEntity dataTaskMakeUpEntity)
{
startPage();
List<DataTaskMakeUpEntity> list = dataTaskMakeUpEntityService.selectDataTaskMakeUpEntityList(dataTaskMakeUpEntity);
return getDataTable(list);
}
/**
* 导出任务配置组成数据列表
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskMakeUp:export')")
@Log(title = "任务配置组成数据", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DataTaskMakeUpEntity dataTaskMakeUpEntity)
{
List<DataTaskMakeUpEntity> list = dataTaskMakeUpEntityService.selectDataTaskMakeUpEntityList(dataTaskMakeUpEntity);
ExcelUtil<DataTaskMakeUpEntity> util = new ExcelUtil<DataTaskMakeUpEntity>(DataTaskMakeUpEntity.class);
util.exportExcel(response, list, "任务配置组成数据数据");
}
/**
* 获取任务配置组成数据详细信息
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskMakeUp:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return success(dataTaskMakeUpEntityService.selectDataTaskMakeUpEntityById(id));
}
/**
* 新增任务配置组成数据
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskMakeUp:add')")
@Log(title = "任务配置组成数据", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DataTaskMakeUpEntity dataTaskMakeUpEntity)
{
return toAjax(dataTaskMakeUpEntityService.insertDataTaskMakeUpEntity(dataTaskMakeUpEntity));
}
/**
* 修改任务配置组成数据
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskMakeUp:edit')")
@Log(title = "任务配置组成数据", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DataTaskMakeUpEntity dataTaskMakeUpEntity)
{
return toAjax(dataTaskMakeUpEntityService.updateDataTaskMakeUpEntity(dataTaskMakeUpEntity));
}
/**
* 删除任务配置组成数据
*/
@PreAuthorize("@ss.hasPermi('dataCenter:taskMakeUp:remove')")
@Log(title = "任务配置组成数据", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(dataTaskMakeUpEntityService.deleteDataTaskMakeUpEntityByIds(ids));
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

36
czsj-assembly/pom.xml Normal file
View File

@ -0,0 +1,36 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.czsj</groupId>
<artifactId>czsj</artifactId>
<version>3.8.8</version>
</parent>
<artifactId>czsj-assembly</artifactId>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<finalName>${project.parent.artifactId}-release-${project.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/package.xml</descriptor>
</descriptors>
<outputDirectory>${project.parent.basedir}/build/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,75 @@
<assembly>
<id>${project.version}</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.parent.basedir}/bin</directory>
<outputDirectory>bin</outputDirectory>
<lineEnding>unix</lineEnding>
<fileMode>0755</fileMode>
<includes>
<include>adminStart.sh</include>
<include>executorStart.sh</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.parent.basedir}/bin</directory>
<outputDirectory>bin</outputDirectory>
<includes>
<include>adminStart.bat</include>
<include>executorStart.bat</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.parent.basedir}/czsj-admin/target/classes</directory>
<outputDirectory>config</outputDirectory>
<includes>
<include>**/*.yml</include>
<include>**/logback.xml</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.parent.basedir}/czsj-admin/target/czsj-admin/lib</directory>
<outputDirectory>lib</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.parent.basedir}/sql</directory>
<outputDirectory>sql</outputDirectory>
<includes>
<include>*.sql</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.parent.basedir}/czsj-datax-executor/target
</directory>
<outputDirectory>executor</outputDirectory>
<includes>
<include>czsj-datax-executor.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.parent.basedir}/czsj-datax-executor/target/classes</directory>
<outputDirectory>executor/config</outputDirectory>
<includes>
<include>**/*.yml</include>
<include>**/logback.xml</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.parent.basedir}/czsj-flink-core/target
</directory>
<outputDirectory>flinkexecutor</outputDirectory>
<includes>
<include>flink-streaming-core.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>

View File

@ -0,0 +1,18 @@
package com.czsj.common.config;
import org.springframework.context.annotation.Bean;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Component;
@Component
public class MailConfig {
@Bean
public JavaMailSenderImpl mailSender() {
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
javaMailSender.setProtocol("SMTP");
javaMailSender.setHost("smtp.qq.com");
javaMailSender.setPort(465);
return javaMailSender;
}
}

View File

@ -0,0 +1,48 @@
package com.czsj.common.config;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.InetSocketAddress;
import java.net.Socket;
public class RPCClient<T> {
@SuppressWarnings("unchecked")
public static <T> T getRemoteProxyObj(final Class<?> serviceInterface, final InetSocketAddress addr) {
// 1.将本地的接口调用转换成JDK的动态代理在动态代理中实现接口的远程调用
return (T) Proxy.newProxyInstance(serviceInterface.getClassLoader(), new Class<?>[]{serviceInterface},
new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Socket socket = null;
ObjectOutputStream output = null;
ObjectInputStream input = null;
try {
// 2.创建Socket客户端根据指定地址连接远程服务提供者
socket = new Socket();
socket.connect(addr);
// 3.将远程服务调用所需的接口类方法名参数列表等编码后发送给服务提供者
output = new ObjectOutputStream(socket.getOutputStream());
output.writeUTF(serviceInterface.getName());
output.writeUTF(method.getName());
output.writeObject(method.getParameterTypes());
output.writeObject(args);
// 4.同步阻塞等待服务器返回应答获取应答后返回
input = new ObjectInputStream(socket.getInputStream());
return input.readObject();
} finally {
if (socket != null){
socket.close();}
if (output != null){
output.close();}
if (input != null){
input.close();}
}
}
});
}
}

144
czsj-core/pom.xml Normal file
View File

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>czsj</artifactId>
<groupId>com.czsj</groupId>
<version>3.8.8</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>czsj-core</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.czsj</groupId>
<artifactId>czsj-rpc</artifactId>
<version>3.8.8</version>
<scope>compile</scope>
</dependency>
<!-- groovy-all -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>${groovy.version}</version>
</dependency>
<!-- spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<scope>provided</scope>
</dependency>
<!-- junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>${jna.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool.version}</version>
</dependency>
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-annotation</artifactId>
<version>3.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-core</artifactId>
<version>3.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
<version>3.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.3.20</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,52 @@
package com.czsj.core.biz;
import com.czsj.core.biz.model.HandleCallbackParam;
import com.czsj.core.biz.model.HandleProcessCallbackParam;
import com.czsj.core.biz.model.RegistryParam;
import com.czsj.core.biz.model.ReturnT;
import java.util.List;
/**
* @author xuxueli 2017-07-27 21:52:49
*/
public interface AdminBiz {
// ---------------------- callback ----------------------
/**
* callback
*
* @param callbackParamList
* @return
*/
ReturnT<String> callback(List<HandleCallbackParam> callbackParamList);
/**
* processCallback
*
* @param processCallbackParamList
* @return
*/
ReturnT<String> processCallback(List<HandleProcessCallbackParam> processCallbackParamList);
// ---------------------- registry ----------------------
/**
* registry
*
* @param registryParam
* @return
*/
ReturnT<String> registry(RegistryParam registryParam);
/**
* registry remove
*
* @param registryParam
* @return
*/
ReturnT<String> registryRemove(RegistryParam registryParam);
}

View File

@ -0,0 +1,52 @@
package com.czsj.core.biz;
import com.czsj.core.biz.model.LogResult;
import com.czsj.core.biz.model.ReturnT;
import com.czsj.core.biz.model.TriggerParam;
/**
* Created by xuxueli on 17/3/1.
*/
public interface ExecutorBiz {
/**
* beat
*
* @return
*/
ReturnT<String> beat();
/**
* idle beat
*
* @param jobId
* @return
*/
ReturnT<String> idleBeat(int jobId);
/**
* kill
*
* @param jobId
* @return
*/
ReturnT<String> kill(int jobId);
/**
* log
*
* @param logDateTim
* @param logId
* @param fromLineNum
* @return
*/
ReturnT<LogResult> log(long logDateTim, long logId, int fromLineNum);
/**
* run
*
* @param triggerParam
* @return
*/
ReturnT<String> run(TriggerParam triggerParam);
}

View File

@ -0,0 +1,54 @@
package com.czsj.core.biz.client;
import com.czsj.core.biz.AdminBiz;
import com.czsj.core.biz.model.HandleCallbackParam;
import com.czsj.core.biz.model.HandleProcessCallbackParam;
import com.czsj.core.biz.model.RegistryParam;
import com.czsj.core.biz.model.ReturnT;
import com.czsj.core.util.JobRemotingUtil;
import java.util.List;
/**
* admin api test
*
* @author xuxueli 2017-07-28 22:14:52
*/
public class AdminBizClient implements AdminBiz {
public AdminBizClient() {
}
public AdminBizClient(String addressUrl, String accessToken) {
this.addressUrl = addressUrl;
this.accessToken = accessToken;
// valid
if (!this.addressUrl.endsWith("/")) {
this.addressUrl = this.addressUrl + "/";
}
}
private String addressUrl ;
private String accessToken;
@Override
public ReturnT<String> callback(List<HandleCallbackParam> callbackParamList) {
return JobRemotingUtil.postBody(addressUrl+"api/callback", accessToken, callbackParamList, 3);
}
@Override
public ReturnT<String> processCallback(List<HandleProcessCallbackParam> callbackParamList) {
return JobRemotingUtil.postBody(addressUrl + "api/processCallback", accessToken, callbackParamList, 3);
}
@Override
public ReturnT<String> registry(RegistryParam registryParam) {
return JobRemotingUtil.postBody(addressUrl + "api/registry", accessToken, registryParam, 3);
}
@Override
public ReturnT<String> registryRemove(RegistryParam registryParam) {
return JobRemotingUtil.postBody(addressUrl + "api/registryRemove", accessToken, registryParam, 3);
}
}

View File

@ -0,0 +1,171 @@
package com.czsj.core.biz.impl;
import com.czsj.core.biz.ExecutorBiz;
import com.czsj.core.biz.model.LogResult;
import com.czsj.core.biz.model.ReturnT;
import com.czsj.core.biz.model.TriggerParam;
import com.czsj.core.enums.ExecutorBlockStrategyEnum;
import com.czsj.core.executor.JobExecutor;
import com.czsj.core.glue.GlueFactory;
import com.czsj.core.glue.GlueTypeEnum;
import com.czsj.core.handler.IJobHandler;
import com.czsj.core.handler.impl.GlueJobHandler;
import com.czsj.core.handler.impl.ScriptJobHandler;
import com.czsj.core.log.JobFileAppender;
import com.czsj.core.thread.JobThread;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
/**
* Created by xuxueli on 17/3/1.
*/
public class ExecutorBizImpl implements ExecutorBiz {
private static Logger logger = LoggerFactory.getLogger(ExecutorBizImpl.class);
@Override
public ReturnT<String> beat() {
return ReturnT.SUCCESS;
}
@Override
public ReturnT<String> idleBeat(int jobId) {
// isRunningOrHasQueue
JobThread jobThread = JobExecutor.loadJobThread(jobId);
if (jobThread != null && jobThread.isRunningOrHasQueue()) {
return new ReturnT<>(ReturnT.FAIL_CODE, "job thread is running or has trigger queue.");
}
return ReturnT.SUCCESS;
}
@Override
public ReturnT<String> kill(int jobId) {
// kill handlerThread, and create new one
JobThread jobThread = JobExecutor.loadJobThread(jobId);
if (jobThread != null) {
JobExecutor.removeJobThread(jobId, "scheduling center kill job.");
return ReturnT.SUCCESS;
}
return new ReturnT<>(ReturnT.SUCCESS_CODE, "job thread already killed.");
}
@Override
public ReturnT<LogResult> log(long logDateTim, long logId, int fromLineNum) {
// log filename: logPath/yyyy-MM-dd/9999.log
String logFileName = JobFileAppender.makeLogFileName(new Date(logDateTim), logId);
LogResult logResult = JobFileAppender.readLog(logFileName, fromLineNum);
return new ReturnT<>(logResult);
}
@Override
public ReturnT<String> run(TriggerParam triggerParam) {
// load oldjobHandler + jobThread
JobThread jobThread = JobExecutor.loadJobThread(triggerParam.getJobId());
IJobHandler jobHandler = jobThread != null ? jobThread.getHandler() : null;
String removeOldReason = null;
// validjobHandler + jobThread
GlueTypeEnum glueTypeEnum = GlueTypeEnum.match(triggerParam.getGlueType());
if (GlueTypeEnum.BEAN == glueTypeEnum) {
// new jobhandler
IJobHandler newJobHandler = JobExecutor.loadJobHandler(triggerParam.getExecutorHandler());
// valid old jobThread
if (jobThread != null && jobHandler != newJobHandler) {
// change handler, need kill old thread
removeOldReason = "change jobhandler or glue type, and terminate the old job thread.";
jobThread = null;
jobHandler = null;
}
// valid handler
if (jobHandler == null) {
jobHandler = newJobHandler;
if (jobHandler == null) {
return new ReturnT<>(ReturnT.FAIL_CODE, "job handler [" + triggerParam.getExecutorHandler() + "] not found.");
}
}
} else if (GlueTypeEnum.GLUE_GROOVY == glueTypeEnum) {
// valid old jobThread
if (jobThread != null &&
!(jobThread.getHandler() instanceof GlueJobHandler
&& ((GlueJobHandler) jobThread.getHandler()).getGlueUpdatetime() == triggerParam.getGlueUpdatetime())) {
// change handler or gluesource updated, need kill old thread
removeOldReason = "change job source or glue type, and terminate the old job thread.";
jobThread = null;
jobHandler = null;
}
// valid handler
if (jobHandler == null) {
try {
IJobHandler originJobHandler = GlueFactory.getInstance().loadNewInstance(triggerParam.getGlueSource());
jobHandler = new GlueJobHandler(originJobHandler, triggerParam.getGlueUpdatetime());
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new ReturnT<String>(ReturnT.FAIL_CODE, e.getMessage());
}
}
} else if (glueTypeEnum != null && glueTypeEnum.isScript()) {
// valid old jobThread
if (jobThread != null &&
!(jobThread.getHandler() instanceof ScriptJobHandler
&& ((ScriptJobHandler) jobThread.getHandler()).getGlueUpdatetime() == triggerParam.getGlueUpdatetime())) {
// change script or gluesource updated, need kill old thread
removeOldReason = "change job source or glue type, and terminate the old job thread.";
jobThread = null;
jobHandler = null;
}
// valid handler
if (jobHandler == null) {
jobHandler = new ScriptJobHandler(triggerParam.getJobId(), triggerParam.getGlueUpdatetime(), triggerParam.getGlueSource(), GlueTypeEnum.match(triggerParam.getGlueType()));
}
} else {
return new ReturnT<>(ReturnT.FAIL_CODE, "glueType[" + triggerParam.getGlueType() + "] is not valid.");
}
// executor block strategy
if (jobThread != null) {
ExecutorBlockStrategyEnum blockStrategy = ExecutorBlockStrategyEnum.match(triggerParam.getExecutorBlockStrategy(), null);
if (ExecutorBlockStrategyEnum.DISCARD_LATER == blockStrategy) {
// discard when running
if (jobThread.isRunningOrHasQueue()) {
return new ReturnT<>(ReturnT.FAIL_CODE, "block strategy effect" + ExecutorBlockStrategyEnum.DISCARD_LATER.getTitle());
}
} else if (ExecutorBlockStrategyEnum.COVER_EARLY == blockStrategy) {
// kill running jobThread
if (jobThread.isRunningOrHasQueue()) {
removeOldReason = "block strategy effect" + ExecutorBlockStrategyEnum.COVER_EARLY.getTitle();
jobThread = null;
}
} else {
// just queue trigger
}
}
// replace thread (new or exists invalid)
if (jobThread == null) {
jobThread = JobExecutor.registJobThread(triggerParam.getJobId(), jobHandler, removeOldReason);
}
// push data to queue
ReturnT<String> pushResult = jobThread.pushTriggerQueue(triggerParam);
return pushResult;
}
}

View File

@ -0,0 +1,56 @@
package com.czsj.core.biz.model;
import java.io.Serializable;
/**
* Created by xuxueli on 17/3/2.
*/
public class HandleCallbackParam implements Serializable {
private static final long serialVersionUID = 42L;
private long logId;
private long logDateTim;
private ReturnT<String> executeResult;
public HandleCallbackParam(){}
public HandleCallbackParam(long logId, long logDateTim, ReturnT<String> executeResult) {
this.logId = logId;
this.logDateTim = logDateTim;
this.executeResult = executeResult;
}
public long getLogId() {
return logId;
}
public void setLogId(long logId) {
this.logId = logId;
}
public long getLogDateTim() {
return logDateTim;
}
public void setLogDateTim(long logDateTim) {
this.logDateTim = logDateTim;
}
public ReturnT<String> getExecuteResult() {
return executeResult;
}
public void setExecuteResult(ReturnT<String> executeResult) {
this.executeResult = executeResult;
}
@Override
public String toString() {
return "HandleCallbackParam{" +
"logId=" + logId +
", logDateTim=" + logDateTim +
", executeResult=" + executeResult +
'}';
}
}

View File

@ -0,0 +1,57 @@
package com.czsj.core.biz.model;
import java.io.Serializable;
/**
* Created by jingwk on 2019/12/14.
*/
public class HandleProcessCallbackParam implements Serializable {
private static final long serialVersionUID = 42L;
private long logId;
private String processId;
private long logDateTime;
public HandleProcessCallbackParam(){}
public HandleProcessCallbackParam(long logId,long logDateTime, String processId) {
this.logId = logId;
this.processId = processId;
this.logDateTime=logDateTime;
}
public long getLogId() {
return logId;
}
public void setLogId(long logId) {
this.logId = logId;
}
public String getProcessId() {
return processId;
}
public void setProcessId(String processId) {
this.processId = processId;
}
public long getLogDateTime() {
return logDateTime;
}
public void setLogDateTime(long logDateTime) {
this.logDateTime = logDateTime;
}
@Override
public String toString() {
return "HandleCallbackParam{" +
"logId=" + logId +
", processId=" + processId +
", logDateTime=" + logDateTime +
'}';
}
}

View File

@ -0,0 +1,125 @@
package com.czsj.core.biz.model;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.sql.Date;
/**
* 执行器管理对象 job_registry
*
* @author czsj
* @date 2022-04-27
*/
public class JobRegistry
{
/** id */
private Long id;
/** 执行器名称 */
private String registryName;
/** 执行器标识 */
private String registryKey;
/** 在线机器ip */
private String registryValue;
/** cpu使用率 */
private Long cpuUsage;
/** 内存使用 */
private Long memoryUsage;
/** 平均负荷 */
private Long loadAverage;
private Date updateTime;
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setRegistryName(String registryName)
{
this.registryName = registryName;
}
public String getRegistryName()
{
return registryName;
}
public void setRegistryKey(String registryKey)
{
this.registryKey = registryKey;
}
public String getRegistryKey()
{
return registryKey;
}
public void setRegistryValue(String registryValue)
{
this.registryValue = registryValue;
}
public String getRegistryValue()
{
return registryValue;
}
public void setCpuUsage(Long cpuUsage)
{
this.cpuUsage = cpuUsage;
}
public Long getCpuUsage()
{
return cpuUsage;
}
public void setMemoryUsage(Long memoryUsage)
{
this.memoryUsage = memoryUsage;
}
public Long getMemoryUsage()
{
return memoryUsage;
}
public void setLoadAverage(Long loadAverage)
{
this.loadAverage = loadAverage;
}
public Long getLoadAverage()
{
return loadAverage;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("registryName", getRegistryName())
.append("registryKey", getRegistryKey())
.append("registryValue", getRegistryValue())
.append("cpuUsage", getCpuUsage())
.append("memoryUsage", getMemoryUsage())
.append("loadAverage", getLoadAverage())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,54 @@
package com.czsj.core.biz.model;
import java.io.Serializable;
/**
* Created by xuxueli on 17/3/23.
*/
public class LogResult implements Serializable {
private static final long serialVersionUID = 42L;
public LogResult(int fromLineNum, int toLineNum, String logContent, boolean isEnd) {
this.fromLineNum = fromLineNum;
this.toLineNum = toLineNum;
this.logContent = logContent;
this.isEnd = isEnd;
}
private int fromLineNum;
private int toLineNum;
private String logContent;
private boolean isEnd;
public int getFromLineNum() {
return fromLineNum;
}
public void setFromLineNum(int fromLineNum) {
this.fromLineNum = fromLineNum;
}
public int getToLineNum() {
return toLineNum;
}
public void setToLineNum(int toLineNum) {
this.toLineNum = toLineNum;
}
public String getLogContent() {
return logContent;
}
public void setLogContent(String logContent) {
this.logContent = logContent;
}
public boolean isEnd() {
return isEnd;
}
public void setEnd(boolean end) {
isEnd = end;
}
}

View File

@ -0,0 +1,95 @@
package com.czsj.core.biz.model;
import java.io.Serializable;
/**
* Created by xuxueli on 2017-05-10 20:22:42
*/
public class RegistryParam implements Serializable {
private static final long serialVersionUID = 42L;
private String registryGroup;
private String registryKey;
private String registryValue;
private double cpuUsage;
private double memoryUsage;
private double loadAverage;
public RegistryParam() {
}
public RegistryParam(String registryGroup, String registryKey, String registryValue) {
this.registryGroup = registryGroup;
this.registryKey = registryKey;
this.registryValue = registryValue;
}
public RegistryParam(String registryGroup, String registryKey, String registryValue, double cpuUsage, double memoryUsage, double loadAverage) {
this.registryGroup = registryGroup;
this.registryKey = registryKey;
this.registryValue = registryValue;
this.cpuUsage = cpuUsage;
this.memoryUsage = memoryUsage;
this.loadAverage = loadAverage;
}
public String getRegistryGroup() {
return registryGroup;
}
public void setRegistryGroup(String registryGroup) {
this.registryGroup = registryGroup;
}
public String getRegistryKey() {
return registryKey;
}
public void setRegistryKey(String registryKey) {
this.registryKey = registryKey;
}
public String getRegistryValue() {
return registryValue;
}
public void setRegistryValue(String registryValue) {
this.registryValue = registryValue;
}
public double getCpuUsage() {
return cpuUsage;
}
public void setCpuUsage(double cpuUsage) {
this.cpuUsage = cpuUsage;
}
public double getMemoryUsage() {
return memoryUsage;
}
public void setMemoryUsage(double memoryUsage) {
this.memoryUsage = memoryUsage;
}
public double getLoadAverage() {
return loadAverage;
}
public void setLoadAverage(double loadAverage) {
this.loadAverage = loadAverage;
}
@Override
public String toString() {
return "RegistryParam{" +
"registryGroup='" + registryGroup + '\'' +
", registryKey='" + registryKey + '\'' +
", registryValue='" + registryValue + '\'' +
", cpuUsage='" + cpuUsage + '\'' +
", memoryUsage='" + memoryUsage + '\'' +
", loadAverage='" + loadAverage + '\'' +
'}';
}
}

View File

@ -0,0 +1,58 @@
package com.czsj.core.biz.model;
import java.io.Serializable;
/**
* common return
* @author xuxueli 2015-12-4 16:32:31
* @param <T>
*/
public class ReturnT<T> implements Serializable {
public static final long serialVersionUID = 42L;
public static final int SUCCESS_CODE = 200;
public static final int FAIL_CODE = 500;
public static final int ING_CODE = 300;
public static final ReturnT<String> SUCCESS = new ReturnT<>(null);
public static final ReturnT<String> FAIL = new ReturnT<>(FAIL_CODE, null);
private int code;
private String msg;
private T content;
public ReturnT(){}
public ReturnT(int code, String msg) {
this.code = code;
this.msg = msg;
}
public ReturnT(T content) {
this.code = SUCCESS_CODE;
this.content = content;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getContent() {
return content;
}
public void setContent(T content) {
this.content = content;
}
@Override
public String toString() {
return "ReturnT [code=" + code + ", msg=" + msg + ", content=" + content + "]";
}
}

View File

@ -0,0 +1,260 @@
package com.czsj.core.biz.model;
import java.io.Serializable;
import java.util.Date;
/**
* Created by xuxueli on 16/7/22.
*/
public class TriggerParam implements Serializable{
private static final long serialVersionUID = 42L;
private int jobId;
private String executorHandler;
private String executorParams;
private String executorBlockStrategy;
private int executorTimeout;
private long logId;
private long logDateTime;
private String glueType;
private String glueSource;
private long glueUpdatetime;
private int broadcastIndex;
private int broadcastTotal;
private String jobJson;
private String processId;
private String replaceParam;
private String jvmParam;
private Date startTime;
private Date triggerTime;
private String partitionInfo;
private long startId;
private long endId;
private Integer incrementType;
private String replaceParamType;
public int getJobId() {
return jobId;
}
public void setJobId(int jobId) {
this.jobId = jobId;
}
public String getExecutorHandler() {
return executorHandler;
}
public void setExecutorHandler(String executorHandler) {
this.executorHandler = executorHandler;
}
public String getExecutorParams() {
return executorParams;
}
public void setExecutorParams(String executorParams) {
this.executorParams = executorParams;
}
public String getExecutorBlockStrategy() {
return executorBlockStrategy;
}
public void setExecutorBlockStrategy(String executorBlockStrategy) {
this.executorBlockStrategy = executorBlockStrategy;
}
public int getExecutorTimeout() {
return executorTimeout;
}
public void setExecutorTimeout(int executorTimeout) {
this.executorTimeout = executorTimeout;
}
public long getLogId() {
return logId;
}
public void setLogId(long logId) {
this.logId = logId;
}
public long getLogDateTime() {
return logDateTime;
}
public void setLogDateTime(long logDateTime) {
this.logDateTime = logDateTime;
}
public String getGlueType() {
return glueType;
}
public void setGlueType(String glueType) {
this.glueType = glueType;
}
public String getGlueSource() {
return glueSource;
}
public void setGlueSource(String glueSource) {
this.glueSource = glueSource;
}
public long getGlueUpdatetime() {
return glueUpdatetime;
}
public void setGlueUpdatetime(long glueUpdatetime) {
this.glueUpdatetime = glueUpdatetime;
}
public int getBroadcastIndex() {
return broadcastIndex;
}
public void setBroadcastIndex(int broadcastIndex) {
this.broadcastIndex = broadcastIndex;
}
public int getBroadcastTotal() {
return broadcastTotal;
}
public void setBroadcastTotal(int broadcastTotal) {
this.broadcastTotal = broadcastTotal;
}
public String getJobJson() {
return jobJson;
}
public void setJobJson(String jobJson) {
this.jobJson = jobJson;
}
public String getProcessId() {
return processId;
}
public void setProcessId(String processId) {
this.processId = processId;
}
public String getReplaceParam() {
return replaceParam;
}
public void setReplaceParam(String replaceParam) {
this.replaceParam = replaceParam;
}
public String getJvmParam() {
return jvmParam;
}
public void setJvmParam(String jvmParam) {
this.jvmParam = jvmParam;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getTriggerTime() {
return triggerTime;
}
public void setTriggerTime(Date triggerTime) {
this.triggerTime = triggerTime;
}
public String getPartitionInfo() {
return partitionInfo;
}
public void setPartitionInfo(String partitionInfo) {
this.partitionInfo = partitionInfo;
}
public long getStartId() {
return startId;
}
public void setStartId(long startId) {
this.startId = startId;
}
public long getEndId() {
return endId;
}
public void setEndId(long endId) {
this.endId = endId;
}
public Integer getIncrementType() {
return incrementType;
}
public void setIncrementType(Integer incrementType) {
this.incrementType = incrementType;
}
public String getReplaceParamType() {
return replaceParamType;
}
public void setReplaceParamType(String replaceParamType) {
this.replaceParamType = replaceParamType;
}
@Override
public String toString() {
return "TriggerParam{" +
"jobId=" + jobId +
", executorHandler='" + executorHandler + '\'' +
", executorParams='" + executorParams + '\'' +
", executorBlockStrategy='" + executorBlockStrategy + '\'' +
", executorTimeout=" + executorTimeout +
", logId=" + logId +
", logDateTime=" + logDateTime +
", glueType='" + glueType + '\'' +
", glueSource='" + glueSource + '\'' +
", glueUpdatetime=" + glueUpdatetime +
", broadcastIndex=" + broadcastIndex +
", broadcastTotal=" + broadcastTotal +
", jobJson=" + jobJson +
", processId=" + processId +
", replaceParam=" + replaceParam +
", jvmParam=" + jvmParam +
", startTime=" + startTime +
", triggerTime=" + triggerTime +
", partitionInfo=" + partitionInfo +
", replaceParamType=" + replaceParamType +
", startId=" + startId +
", endId=" + endId +
", incrementType=" + incrementType +
'}';
}
}

View File

@ -0,0 +1,18 @@
package com.czsj.core.database.base;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.czsj.core.database.core.DataConstant;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface BaseDao<T> extends BaseMapper<T> {
List<T> selectListDataScope(@Param("ew") Wrapper<T> queryWrapper, @Param("dataScope") DataConstant.DataScope dataScope);
IPage<T> selectPageDataScope(IPage<T> page, @Param("ew") Wrapper<T> queryWrapper, @Param("dataScope") DataConstant.DataScope dataScope);
}

View File

@ -0,0 +1,62 @@
package com.czsj.core.database.base;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Date;
@Data
public abstract class BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(value = "id", type = IdType.ASSIGN_ID)
private String id;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
/**
* 创建人
*/
@TableField(value = "create_by", fill = FieldFill.INSERT)
private String createBy;
/**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
/**
* 更新人
*/
@TableField(value = "update_by",fill = FieldFill.INSERT_UPDATE)
private String updateBy;
/**
* 状态0不启用1启用
*/
@TableField(value = "status", fill = FieldFill.INSERT)
private String status;
/**
* 备注
*/
@TableField(value = "remark")
private String remark;
}

View File

@ -0,0 +1,29 @@
package com.czsj.core.database.base;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class BaseQueryParams implements Serializable {
private static final long serialVersionUID = 1L;
// 关键字
private String keyword;
// 当前页码
private Integer pageNum = 1;
// 分页条数
private Integer pageSize = 20;
// 排序
private List<OrderItem> orderList;
// 数据权限
private String dataScope;
@Data
public class OrderItem{
private String column;
private boolean asc;
}
}

View File

@ -0,0 +1,8 @@
package com.czsj.core.database.base;
import com.baomidou.mybatisplus.extension.service.IService;
public interface BaseService<T> extends IService<T> {
}

View File

@ -0,0 +1,10 @@
package com.czsj.core.database.base;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
public abstract class BaseServiceImpl<M extends BaseDao<T>, T> extends ServiceImpl<M, T> implements BaseService<T> {
@Autowired
protected M baseDao;
}

View File

@ -0,0 +1,19 @@
package com.czsj.core.database.base;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public abstract class DataScopeBaseEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 创建人所属部门
*/
@TableField(value = "create_dept", fill = FieldFill.INSERT)
private String createDept;
}

View File

@ -0,0 +1,211 @@
package com.czsj.core.database.core;
public class DataConstant {
/**
* Oauth2安全相关常量
*/
public enum Security {
//请求头TOKEN名称
TOKENHEADER("gatewayToken"),
//请求头TOKEN值
TOKENVALUE("datax:gateway:123456"),
//OAUTH2请求头
AUTHORIZATION("Authorization"),
//OAUTH2令牌类型
TOKENTYPE("bearer "),
//security授权角色前缀
ROLEPREFIX("ROLE_");
Security(String val){
this.val = val;
}
private final String val;
public String getVal() {
return val;
}
}
/**
* 通用的是否
*/
public enum TrueOrFalse {
FALSE("0",false),
TRUE("1",true);
TrueOrFalse(String key, boolean val){
this.key = key;
this.val = val;
}
private final String key;
private final boolean val;
public String getKey() {
return key;
}
public boolean getVal() {
return val;
}
}
/**
* 用户认证返回额外信息
*/
public enum UserAdditionalInfo {
LICENSE("license", "datax"),
USER("user", "用户"),
USERID("user_id", "用户ID"),
USERNAME("username", "用户名"),
NICKNAME("nickname", "用户昵称"),
DEPT("user_dept", "用户部门"),
ROLE("user_role", "用户角色"),
POST("user_post", "用户岗位");
UserAdditionalInfo(String key, String val){
this.key = key;
this.val = val;
}
private final String key;
private final String val;
public String getKey() {
return key;
}
public String getVal() {
return val;
}
}
/**
* 通用的启用禁用状态
*/
public enum EnableState {
DISABLE("0","禁用"),
ENABLE("1","启用");
EnableState(String key, String val){
this.key = key;
this.val = val;
}
private final String key;
private final String val;
public String getKey() {
return key;
}
public String getVal() {
return val;
}
}
/**
* 流程审核状态
*/
public enum AuditState{
WAIT("1","待提交"),
BACK("2", "已退回"),
AUDIT("3","审核中"),
AGREE("4","通过"),
REJECT("5","不通过"),
CANCEL("6", "已撤销");
AuditState(String key, String val){
this.key = key;
this.val = val;
}
private final String key;
private final String val;
public String getKey() {
return key;
}
public String getVal() {
return val;
}
}
/**
* 菜单类型
*/
public enum MenuType{
MODULE("0","模块"),
MENU("1","菜单"),
BUTTON("2","按钮");
MenuType(String key, String val){
this.key = key;
this.val = val;
}
private final String key;
private final String val;
public String getKey() {
return key;
}
public String getVal() {
return val;
}
}
/**
* 数据范围
*/
public enum DataScope{
ALL("1","全部数据权限"),
CUSTOM("2","自定义数据权限"),
DEPT("3","本部门数据权限"),
DEPTANDCHILD("4","本部门及以下数据权限"),
SELF("5","仅本人数据权限");
DataScope(String key, String val){
this.key = key;
this.val = val;
}
private final String key;
private final String val;
public String getKey() {
return key;
}
public String getVal() {
return val;
}
}
/**
* Api状态
*/
public enum ApiState{
WAIT("1","待发布"),
RELEASE("2","已发布"),
CANCEL("3","已下线");
ApiState(String key, String val){
this.key = key;
this.val = val;
}
private final String key;
private final String val;
public String getKey() {
return key;
}
public String getVal() {
return val;
}
}
}

View File

@ -0,0 +1,14 @@
package com.czsj.core.database.core;
import lombok.Data;
import java.io.Serializable;
@Data
public class DataRole implements Serializable {
private static final long serialVersionUID=1L;
private String id;
private String dataScope;
}

View File

@ -0,0 +1,35 @@
package com.czsj.core.database.core;
import cn.hutool.core.util.ObjectUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
import java.util.Collection;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = true)
public class DataUser extends User {
private String id;
private String nickname;
private String dept;
private List<DataRole> roles;
private List<String> posts;
public DataUser(String id, String nickname, String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) {
super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
this.id = id;
this.nickname = nickname;
}
public boolean isAdmin() {
return isAdmin(this.getUsername());
}
public static boolean isAdmin(String username) {
return ObjectUtil.equal(username, "admin");
}
}

View File

@ -0,0 +1,57 @@
package com.czsj.core.database.core;
import lombok.Data;
@Data
public class DbColumn {
/**
* 列名
*/
private String colName;
/**
* 数据类型
*/
private String dataType;
/**
* 数据长度
*/
private String dataLength;
/**
* 数据精度
*/
private String dataPrecision;
/**
* 数据小数位
*/
private String dataScale;
/**
* 是否主键
*/
private Boolean colKey;
/**
* 是否允许为空
*/
private Boolean nullable;
/**
* 列的序号
*/
private Integer colPosition;
/**
* 列默认值
*/
private String dataDefault;
/**
* 列注释
*/
private String colComment;
}

View File

@ -0,0 +1,17 @@
package com.czsj.core.database.core;
import lombok.Data;
@Data
public class DbTable {
/**
* 表名
*/
private String tableName;
/**
* 表注释
*/
private String tableComment;
}

View File

@ -0,0 +1,26 @@
package com.czsj.core.database.core;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
@Data
@Accessors(chain = true)
public class JsonPage<T> implements Serializable {
private static final long serialVersionUID = 1L;
private Integer pageNum;
private Integer pageSize;
private Integer total;
private List<T> data;
public JsonPage(Long pageNum, Long pageSize, Long total, List<T> data) {
this.pageNum = pageNum.intValue();
this.pageSize = pageSize.intValue();
this.total = total.intValue();
this.data = data;
}
}

View File

@ -0,0 +1,24 @@
package com.czsj.core.database.core;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
@Data
@Accessors(chain = true)
public class PageResult<T> implements Serializable {
private static final long serialVersionUID = 1L;
private Integer pageNum;
private Integer pageSize;
private Integer total;
private List<T> data;
public PageResult(Integer total, List<T> data) {
this.total = total;
this.data = data;
}
}

View File

@ -0,0 +1,26 @@
package com.czsj.core.database.core;
public interface RedisConstant {
String MARKET_API_KEY = "data:market:apis";
String MARKET_API_MASK_KEY = "data:market:api:masks";
String SYSTEM_DICT_KEY = "data:system:dicts";
String SYSTEM_CONFIG_KEY = "data:system:configs";
String METADATA_SOURCE_KEY = "data:metadata:sources";
String METADATA_TABLE_KEY = "data:metadata:tables";
String METADATA_COLUMN_KEY = "data:metadata:columns";
String METADATA_AUTHORIZE_KEY = "data:metadata:authorizes";
String STANDARD_DICT_KEY = "data:standard:dicts";
String WORKFLOW_BUSINESS_KEY = "data:workflow:business";
String VISUAL_SET_KEY = "data:visual:sets";
}

View File

@ -0,0 +1,35 @@
package com.czsj.core.enums;
/**
* Created by xuxueli on 17/5/9.
*/
public enum ExecutorBlockStrategyEnum {
SERIAL_EXECUTION("Serial execution"),
/*CONCURRENT_EXECUTION("并行"),*/
DISCARD_LATER("Discard Later"),
COVER_EARLY("Cover Early");
private String title;
ExecutorBlockStrategyEnum(String title) {
this.title = title;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
public static ExecutorBlockStrategyEnum match(String name, ExecutorBlockStrategyEnum defaultItem) {
if (name != null) {
for (ExecutorBlockStrategyEnum item:ExecutorBlockStrategyEnum.values()) {
if (item.name().equals(name)) {
return item;
}
}
}
return defaultItem;
}
}

View File

@ -0,0 +1,32 @@
package com.czsj.core.enums;
/**
* increment type
*/
public enum IncrementTypeEnum {
/**
* 2 TIME
* 1 ID
* 3 PARTITION
*/
TIME(2, "时间"),
ID(1, "自增主键"),
PARTITION(3, "HIVE分区");
IncrementTypeEnum(int code, String descp){
this.code = code;
this.descp = descp;
}
private final int code;
private final String descp;
public int getCode() {
return code;
}
public String getDescp() {
return descp;
}
}

View File

@ -0,0 +1,13 @@
package com.czsj.core.enums;
/**
* Created by xuxueli on 17/5/10.
*/
public class RegistryConfig {
public static final int BEAT_TIMEOUT = 30;
public static final int DEAD_TIMEOUT = BEAT_TIMEOUT * 3;
public enum RegistType{ EXECUTOR, ADMIN }
}

View File

@ -0,0 +1,52 @@
package com.czsj.core.enums.biz;
import com.czsj.core.enums.biz.model.HandleCallbackParam;
import com.czsj.core.enums.biz.model.HandleProcessCallbackParam;
import com.czsj.core.enums.biz.model.RegistryParam;
import com.czsj.core.enums.biz.model.ReturnT;
import java.util.List;
/**
* @author xuxueli 2017-07-27 21:52:49
*/
public interface AdminBiz {
// ---------------------- callback ----------------------
/**
* callback
*
* @param callbackParamList
* @return
*/
ReturnT<String> callback(List<HandleCallbackParam> callbackParamList);
/**
* processCallback
*
* @param processCallbackParamList
* @return
*/
ReturnT<String> processCallback(List<HandleProcessCallbackParam> processCallbackParamList);
// ---------------------- registry ----------------------
/**
* registry
*
* @param registryParam
* @return
*/
ReturnT<String> registry(RegistryParam registryParam);
/**
* registry remove
*
* @param registryParam
* @return
*/
ReturnT<String> registryRemove(RegistryParam registryParam);
}

View File

@ -0,0 +1,52 @@
package com.czsj.core.enums.biz;
import com.czsj.core.enums.biz.model.LogResult;
import com.czsj.core.enums.biz.model.ReturnT;
import com.czsj.core.enums.biz.model.TriggerParam;
/**
* Created by xuxueli on 17/3/1.
*/
public interface ExecutorBiz {
/**
* beat
*
* @return
*/
ReturnT<String> beat();
/**
* idle beat
*
* @param jobId
* @return
*/
ReturnT<String> idleBeat(int jobId);
/**
* kill
*
* @param jobId
* @return
*/
ReturnT<String> kill(int jobId);
/**
* log
*
* @param logDateTim
* @param logId
* @param fromLineNum
* @return
*/
ReturnT<LogResult> log(long logDateTim, long logId, int fromLineNum);
/**
* run
*
* @param triggerParam
* @return
*/
ReturnT<String> run(TriggerParam triggerParam);
}

View File

@ -0,0 +1,54 @@
package com.czsj.core.enums.biz.client;
import com.czsj.core.enums.biz.AdminBiz;
import com.czsj.core.enums.biz.model.HandleCallbackParam;
import com.czsj.core.enums.biz.model.HandleProcessCallbackParam;
import com.czsj.core.enums.biz.model.RegistryParam;
import com.czsj.core.enums.biz.model.ReturnT;
import com.czsj.core.enums.util.JobRemotingUtil;
import java.util.List;
/**
* admin api test
*
* @author xuxueli 2017-07-28 22:14:52
*/
public class AdminBizClient implements AdminBiz {
public AdminBizClient() {
}
public AdminBizClient(String addressUrl, String accessToken) {
this.addressUrl = addressUrl;
this.accessToken = accessToken;
// valid
if (!this.addressUrl.endsWith("/")) {
this.addressUrl = this.addressUrl + "/";
}
}
private String addressUrl ;
private String accessToken;
@Override
public ReturnT<String> callback(List<HandleCallbackParam> callbackParamList) {
return JobRemotingUtil.postBody(addressUrl+"api/callback", accessToken, callbackParamList, 3);
}
@Override
public ReturnT<String> processCallback(List<HandleProcessCallbackParam> callbackParamList) {
return JobRemotingUtil.postBody(addressUrl + "api/processCallback", accessToken, callbackParamList, 3);
}
@Override
public ReturnT<String> registry(RegistryParam registryParam) {
return JobRemotingUtil.postBody(addressUrl + "api/registry", accessToken, registryParam, 3);
}
@Override
public ReturnT<String> registryRemove(RegistryParam registryParam) {
return JobRemotingUtil.postBody(addressUrl + "api/registryRemove", accessToken, registryParam, 3);
}
}

View File

@ -0,0 +1,171 @@
package com.czsj.core.enums.biz.impl;
import com.czsj.core.enums.biz.ExecutorBiz;
import com.czsj.core.enums.biz.model.LogResult;
import com.czsj.core.enums.biz.model.ReturnT;
import com.czsj.core.enums.biz.model.TriggerParam;
import com.czsj.core.enums.enums.ExecutorBlockStrategyEnum;
import com.czsj.core.enums.executor.JobExecutor;
import com.czsj.core.enums.glue.GlueFactory;
import com.czsj.core.enums.glue.GlueTypeEnum;
import com.czsj.core.enums.handler.IJobHandler;
import com.czsj.core.enums.handler.impl.GlueJobHandler;
import com.czsj.core.enums.handler.impl.ScriptJobHandler;
import com.czsj.core.enums.log.JobFileAppender;
import com.czsj.core.enums.thread.JobThread;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
/**
* Created by xuxueli on 17/3/1.
*/
public class ExecutorBizImpl implements ExecutorBiz {
private static Logger logger = LoggerFactory.getLogger(ExecutorBizImpl.class);
@Override
public ReturnT<String> beat() {
return ReturnT.SUCCESS;
}
@Override
public ReturnT<String> idleBeat(int jobId) {
// isRunningOrHasQueue
JobThread jobThread = JobExecutor.loadJobThread(jobId);
if (jobThread != null && jobThread.isRunningOrHasQueue()) {
return new ReturnT<>(ReturnT.FAIL_CODE, "job thread is running or has trigger queue.");
}
return ReturnT.SUCCESS;
}
@Override
public ReturnT<String> kill(int jobId) {
// kill handlerThread, and create new one
JobThread jobThread = JobExecutor.loadJobThread(jobId);
if (jobThread != null) {
JobExecutor.removeJobThread(jobId, "scheduling center kill job.");
return ReturnT.SUCCESS;
}
return new ReturnT<>(ReturnT.SUCCESS_CODE, "job thread already killed.");
}
@Override
public ReturnT<LogResult> log(long logDateTim, long logId, int fromLineNum) {
// log filename: logPath/yyyy-MM-dd/9999.log
String logFileName = JobFileAppender.makeLogFileName(new Date(logDateTim), logId);
LogResult logResult = JobFileAppender.readLog(logFileName, fromLineNum);
return new ReturnT<>(logResult);
}
@Override
public ReturnT<String> run(TriggerParam triggerParam) {
// load oldjobHandler + jobThread
JobThread jobThread = JobExecutor.loadJobThread(triggerParam.getJobId());
IJobHandler jobHandler = jobThread != null ? jobThread.getHandler() : null;
String removeOldReason = null;
// validjobHandler + jobThread
GlueTypeEnum glueTypeEnum = GlueTypeEnum.match(triggerParam.getGlueType());
if (GlueTypeEnum.BEAN == glueTypeEnum) {
// new jobhandler
IJobHandler newJobHandler = JobExecutor.loadJobHandler(triggerParam.getExecutorHandler());
// valid old jobThread
if (jobThread != null && jobHandler != newJobHandler) {
// change handler, need kill old thread
removeOldReason = "change jobhandler or glue type, and terminate the old job thread.";
jobThread = null;
jobHandler = null;
}
// valid handler
if (jobHandler == null) {
jobHandler = newJobHandler;
if (jobHandler == null) {
return new ReturnT<>(ReturnT.FAIL_CODE, "job handler [" + triggerParam.getExecutorHandler() + "] not found.");
}
}
} else if (GlueTypeEnum.GLUE_GROOVY == glueTypeEnum) {
// valid old jobThread
if (jobThread != null &&
!(jobThread.getHandler() instanceof GlueJobHandler
&& ((GlueJobHandler) jobThread.getHandler()).getGlueUpdatetime() == triggerParam.getGlueUpdatetime())) {
// change handler or gluesource updated, need kill old thread
removeOldReason = "change job source or glue type, and terminate the old job thread.";
jobThread = null;
jobHandler = null;
}
// valid handler
if (jobHandler == null) {
try {
IJobHandler originJobHandler = GlueFactory.getInstance().loadNewInstance(triggerParam.getGlueSource());
jobHandler = new GlueJobHandler(originJobHandler, triggerParam.getGlueUpdatetime());
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new ReturnT<String>(ReturnT.FAIL_CODE, e.getMessage());
}
}
} else if (glueTypeEnum != null && glueTypeEnum.isScript()) {
// valid old jobThread
if (jobThread != null &&
!(jobThread.getHandler() instanceof ScriptJobHandler
&& ((ScriptJobHandler) jobThread.getHandler()).getGlueUpdatetime() == triggerParam.getGlueUpdatetime())) {
// change script or gluesource updated, need kill old thread
removeOldReason = "change job source or glue type, and terminate the old job thread.";
jobThread = null;
jobHandler = null;
}
// valid handler
if (jobHandler == null) {
jobHandler = new ScriptJobHandler(triggerParam.getJobId(), triggerParam.getGlueUpdatetime(), triggerParam.getGlueSource(), GlueTypeEnum.match(triggerParam.getGlueType()));
}
} else {
return new ReturnT<>(ReturnT.FAIL_CODE, "glueType[" + triggerParam.getGlueType() + "] is not valid.");
}
// executor block strategy
if (jobThread != null) {
ExecutorBlockStrategyEnum blockStrategy = ExecutorBlockStrategyEnum.match(triggerParam.getExecutorBlockStrategy(), null);
if (ExecutorBlockStrategyEnum.DISCARD_LATER == blockStrategy) {
// discard when running
if (jobThread.isRunningOrHasQueue()) {
return new ReturnT<>(ReturnT.FAIL_CODE, "block strategy effect" + ExecutorBlockStrategyEnum.DISCARD_LATER.getTitle());
}
} else if (ExecutorBlockStrategyEnum.COVER_EARLY == blockStrategy) {
// kill running jobThread
if (jobThread.isRunningOrHasQueue()) {
removeOldReason = "block strategy effect" + ExecutorBlockStrategyEnum.COVER_EARLY.getTitle();
jobThread = null;
}
} else {
// just queue trigger
}
}
// replace thread (new or exists invalid)
if (jobThread == null) {
jobThread = JobExecutor.registJobThread(triggerParam.getJobId(), jobHandler, removeOldReason);
}
// push data to queue
ReturnT<String> pushResult = jobThread.pushTriggerQueue(triggerParam);
return pushResult;
}
}

View File

@ -0,0 +1,56 @@
package com.czsj.core.enums.biz.model;
import java.io.Serializable;
/**
* Created by xuxueli on 17/3/2.
*/
public class HandleCallbackParam implements Serializable {
private static final long serialVersionUID = 42L;
private long logId;
private long logDateTim;
private ReturnT<String> executeResult;
public HandleCallbackParam(){}
public HandleCallbackParam(long logId, long logDateTim, ReturnT<String> executeResult) {
this.logId = logId;
this.logDateTim = logDateTim;
this.executeResult = executeResult;
}
public long getLogId() {
return logId;
}
public void setLogId(long logId) {
this.logId = logId;
}
public long getLogDateTim() {
return logDateTim;
}
public void setLogDateTim(long logDateTim) {
this.logDateTim = logDateTim;
}
public ReturnT<String> getExecuteResult() {
return executeResult;
}
public void setExecuteResult(ReturnT<String> executeResult) {
this.executeResult = executeResult;
}
@Override
public String toString() {
return "HandleCallbackParam{" +
"logId=" + logId +
", logDateTim=" + logDateTim +
", executeResult=" + executeResult +
'}';
}
}

View File

@ -0,0 +1,57 @@
package com.czsj.core.enums.biz.model;
import java.io.Serializable;
/**
* Created by jingwk on 2019/12/14.
*/
public class HandleProcessCallbackParam implements Serializable {
private static final long serialVersionUID = 42L;
private long logId;
private String processId;
private long logDateTime;
public HandleProcessCallbackParam(){}
public HandleProcessCallbackParam(long logId,long logDateTime, String processId) {
this.logId = logId;
this.processId = processId;
this.logDateTime=logDateTime;
}
public long getLogId() {
return logId;
}
public void setLogId(long logId) {
this.logId = logId;
}
public String getProcessId() {
return processId;
}
public void setProcessId(String processId) {
this.processId = processId;
}
public long getLogDateTime() {
return logDateTime;
}
public void setLogDateTime(long logDateTime) {
this.logDateTime = logDateTime;
}
@Override
public String toString() {
return "HandleCallbackParam{" +
"logId=" + logId +
", processId=" + processId +
", logDateTime=" + logDateTime +
'}';
}
}

View File

@ -0,0 +1,54 @@
package com.czsj.core.enums.biz.model;
import java.io.Serializable;
/**
* Created by xuxueli on 17/3/23.
*/
public class LogResult implements Serializable {
private static final long serialVersionUID = 42L;
public LogResult(int fromLineNum, int toLineNum, String logContent, boolean isEnd) {
this.fromLineNum = fromLineNum;
this.toLineNum = toLineNum;
this.logContent = logContent;
this.isEnd = isEnd;
}
private int fromLineNum;
private int toLineNum;
private String logContent;
private boolean isEnd;
public int getFromLineNum() {
return fromLineNum;
}
public void setFromLineNum(int fromLineNum) {
this.fromLineNum = fromLineNum;
}
public int getToLineNum() {
return toLineNum;
}
public void setToLineNum(int toLineNum) {
this.toLineNum = toLineNum;
}
public String getLogContent() {
return logContent;
}
public void setLogContent(String logContent) {
this.logContent = logContent;
}
public boolean isEnd() {
return isEnd;
}
public void setEnd(boolean end) {
isEnd = end;
}
}

View File

@ -0,0 +1,95 @@
package com.czsj.core.enums.biz.model;
import java.io.Serializable;
/**
* Created by xuxueli on 2017-05-10 20:22:42
*/
public class RegistryParam implements Serializable {
private static final long serialVersionUID = 42L;
private String registryGroup;
private String registryKey;
private String registryValue;
private double cpuUsage;
private double memoryUsage;
private double loadAverage;
public RegistryParam() {
}
public RegistryParam(String registryGroup, String registryKey, String registryValue) {
this.registryGroup = registryGroup;
this.registryKey = registryKey;
this.registryValue = registryValue;
}
public RegistryParam(String registryGroup, String registryKey, String registryValue, double cpuUsage, double memoryUsage, double loadAverage) {
this.registryGroup = registryGroup;
this.registryKey = registryKey;
this.registryValue = registryValue;
this.cpuUsage = cpuUsage;
this.memoryUsage = memoryUsage;
this.loadAverage = loadAverage;
}
public String getRegistryGroup() {
return registryGroup;
}
public void setRegistryGroup(String registryGroup) {
this.registryGroup = registryGroup;
}
public String getRegistryKey() {
return registryKey;
}
public void setRegistryKey(String registryKey) {
this.registryKey = registryKey;
}
public String getRegistryValue() {
return registryValue;
}
public void setRegistryValue(String registryValue) {
this.registryValue = registryValue;
}
public double getCpuUsage() {
return cpuUsage;
}
public void setCpuUsage(double cpuUsage) {
this.cpuUsage = cpuUsage;
}
public double getMemoryUsage() {
return memoryUsage;
}
public void setMemoryUsage(double memoryUsage) {
this.memoryUsage = memoryUsage;
}
public double getLoadAverage() {
return loadAverage;
}
public void setLoadAverage(double loadAverage) {
this.loadAverage = loadAverage;
}
@Override
public String toString() {
return "RegistryParam{" +
"registryGroup='" + registryGroup + '\'' +
", registryKey='" + registryKey + '\'' +
", registryValue='" + registryValue + '\'' +
", cpuUsage='" + cpuUsage + '\'' +
", memoryUsage='" + memoryUsage + '\'' +
", loadAverage='" + loadAverage + '\'' +
'}';
}
}

View File

@ -0,0 +1,57 @@
package com.czsj.core.enums.biz.model;
import java.io.Serializable;
/**
* common return
* @author xuxueli 2015-12-4 16:32:31
* @param <T>
*/
public class ReturnT<T> implements Serializable {
public static final long serialVersionUID = 42L;
public static final int SUCCESS_CODE = 200;
public static final int FAIL_CODE = 500;
public static final ReturnT<String> SUCCESS = new ReturnT<>(null);
public static final ReturnT<String> FAIL = new ReturnT<>(FAIL_CODE, null);
private int code;
private String msg;
private T content;
public ReturnT(){}
public ReturnT(int code, String msg) {
this.code = code;
this.msg = msg;
}
public ReturnT(T content) {
this.code = SUCCESS_CODE;
this.content = content;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getContent() {
return content;
}
public void setContent(T content) {
this.content = content;
}
@Override
public String toString() {
return "ReturnT [code=" + code + ", msg=" + msg + ", content=" + content + "]";
}
}

View File

@ -0,0 +1,260 @@
package com.czsj.core.enums.biz.model;
import java.io.Serializable;
import java.util.Date;
/**
* Created by xuxueli on 16/7/22.
*/
public class TriggerParam implements Serializable{
private static final long serialVersionUID = 42L;
private int jobId;
private String executorHandler;
private String executorParams;
private String executorBlockStrategy;
private int executorTimeout;
private long logId;
private long logDateTime;
private String glueType;
private String glueSource;
private long glueUpdatetime;
private int broadcastIndex;
private int broadcastTotal;
private String jobJson;
private String processId;
private String replaceParam;
private String jvmParam;
private Date startTime;
private Date triggerTime;
private String partitionInfo;
private long startId;
private long endId;
private Integer incrementType;
private String replaceParamType;
public int getJobId() {
return jobId;
}
public void setJobId(int jobId) {
this.jobId = jobId;
}
public String getExecutorHandler() {
return executorHandler;
}
public void setExecutorHandler(String executorHandler) {
this.executorHandler = executorHandler;
}
public String getExecutorParams() {
return executorParams;
}
public void setExecutorParams(String executorParams) {
this.executorParams = executorParams;
}
public String getExecutorBlockStrategy() {
return executorBlockStrategy;
}
public void setExecutorBlockStrategy(String executorBlockStrategy) {
this.executorBlockStrategy = executorBlockStrategy;
}
public int getExecutorTimeout() {
return executorTimeout;
}
public void setExecutorTimeout(int executorTimeout) {
this.executorTimeout = executorTimeout;
}
public long getLogId() {
return logId;
}
public void setLogId(long logId) {
this.logId = logId;
}
public long getLogDateTime() {
return logDateTime;
}
public void setLogDateTime(long logDateTime) {
this.logDateTime = logDateTime;
}
public String getGlueType() {
return glueType;
}
public void setGlueType(String glueType) {
this.glueType = glueType;
}
public String getGlueSource() {
return glueSource;
}
public void setGlueSource(String glueSource) {
this.glueSource = glueSource;
}
public long getGlueUpdatetime() {
return glueUpdatetime;
}
public void setGlueUpdatetime(long glueUpdatetime) {
this.glueUpdatetime = glueUpdatetime;
}
public int getBroadcastIndex() {
return broadcastIndex;
}
public void setBroadcastIndex(int broadcastIndex) {
this.broadcastIndex = broadcastIndex;
}
public int getBroadcastTotal() {
return broadcastTotal;
}
public void setBroadcastTotal(int broadcastTotal) {
this.broadcastTotal = broadcastTotal;
}
public String getJobJson() {
return jobJson;
}
public void setJobJson(String jobJson) {
this.jobJson = jobJson;
}
public String getProcessId() {
return processId;
}
public void setProcessId(String processId) {
this.processId = processId;
}
public String getReplaceParam() {
return replaceParam;
}
public void setReplaceParam(String replaceParam) {
this.replaceParam = replaceParam;
}
public String getJvmParam() {
return jvmParam;
}
public void setJvmParam(String jvmParam) {
this.jvmParam = jvmParam;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getTriggerTime() {
return triggerTime;
}
public void setTriggerTime(Date triggerTime) {
this.triggerTime = triggerTime;
}
public String getPartitionInfo() {
return partitionInfo;
}
public void setPartitionInfo(String partitionInfo) {
this.partitionInfo = partitionInfo;
}
public long getStartId() {
return startId;
}
public void setStartId(long startId) {
this.startId = startId;
}
public long getEndId() {
return endId;
}
public void setEndId(long endId) {
this.endId = endId;
}
public Integer getIncrementType() {
return incrementType;
}
public void setIncrementType(Integer incrementType) {
this.incrementType = incrementType;
}
public String getReplaceParamType() {
return replaceParamType;
}
public void setReplaceParamType(String replaceParamType) {
this.replaceParamType = replaceParamType;
}
@Override
public String toString() {
return "TriggerParam{" +
"jobId=" + jobId +
", executorHandler='" + executorHandler + '\'' +
", executorParams='" + executorParams + '\'' +
", executorBlockStrategy='" + executorBlockStrategy + '\'' +
", executorTimeout=" + executorTimeout +
", logId=" + logId +
", logDateTime=" + logDateTime +
", glueType='" + glueType + '\'' +
", glueSource='" + glueSource + '\'' +
", glueUpdatetime=" + glueUpdatetime +
", broadcastIndex=" + broadcastIndex +
", broadcastTotal=" + broadcastTotal +
", jobJson=" + jobJson +
", processId=" + processId +
", replaceParam=" + replaceParam +
", jvmParam=" + jvmParam +
", startTime=" + startTime +
", triggerTime=" + triggerTime +
", partitionInfo=" + partitionInfo +
", replaceParamType=" + replaceParamType +
", startId=" + startId +
", endId=" + endId +
", incrementType=" + incrementType +
'}';
}
}

View File

@ -0,0 +1,35 @@
package com.czsj.core.enums.enums;
/**
* Created by xuxueli on 17/5/9.
*/
public enum ExecutorBlockStrategyEnum {
SERIAL_EXECUTION("Serial execution"),
/*CONCURRENT_EXECUTION("并行"),*/
DISCARD_LATER("Discard Later"),
COVER_EARLY("Cover Early");
private String title;
ExecutorBlockStrategyEnum(String title) {
this.title = title;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
public static ExecutorBlockStrategyEnum match(String name, ExecutorBlockStrategyEnum defaultItem) {
if (name != null) {
for (ExecutorBlockStrategyEnum item:ExecutorBlockStrategyEnum.values()) {
if (item.name().equals(name)) {
return item;
}
}
}
return defaultItem;
}
}

View File

@ -0,0 +1,32 @@
package com.czsj.core.enums.enums;
/**
* increment type
*/
public enum IncrementTypeEnum {
/**
* 2 TIME
* 1 ID
* 3 PARTITION
*/
TIME(2, "时间"),
ID(1, "自增主键"),
PARTITION(3, "HIVE分区");
IncrementTypeEnum(int code, String descp){
this.code = code;
this.descp = descp;
}
private final int code;
private final String descp;
public int getCode() {
return code;
}
public String getDescp() {
return descp;
}
}

View File

@ -0,0 +1,13 @@
package com.czsj.core.enums.enums;
/**
* Created by xuxueli on 17/5/10.
*/
public class RegistryConfig {
public static final int BEAT_TIMEOUT = 30;
public static final int DEAD_TIMEOUT = BEAT_TIMEOUT * 3;
public enum RegistType{ EXECUTOR, ADMIN }
}

View File

@ -0,0 +1,279 @@
package com.czsj.core.enums.executor;
import com.czsj.core.enums.biz.AdminBiz;
import com.czsj.core.enums.biz.ExecutorBiz;
import com.czsj.core.enums.biz.client.AdminBizClient;
import com.czsj.core.enums.biz.impl.ExecutorBizImpl;
import com.czsj.core.enums.handler.IJobHandler;
import com.czsj.core.enums.log.JobFileAppender;
import com.czsj.core.enums.thread.*;
import com.czsj.rpc.registry.ServiceRegistry;
import com.czsj.rpc.remoting.net.impl.netty_http.server.NettyHttpServer;
import com.czsj.rpc.remoting.provider.XxlRpcProviderFactory;
import com.czsj.rpc.serialize.Serializer;
import com.czsj.rpc.serialize.impl.HessianSerializer;
import com.czsj.rpc.util.IpUtil;
import com.czsj.rpc.util.NetUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* Created by xuxueli on 2016/3/2 21:14.
*/
public class JobExecutor {
private static final Logger logger = LoggerFactory.getLogger(JobExecutor.class);
// ---------------------- param ----------------------
private String adminAddresses;
private String appName;
private String ip;
private int port;
private String accessToken;
private String logPath;
private int logRetentionDays;
public void setAdminAddresses(String adminAddresses) {
this.adminAddresses = adminAddresses;
}
public void setAppName(String appName) {
this.appName = appName;
}
public void setIp(String ip) {
this.ip = ip;
}
public void setPort(int port) {
this.port = port;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
public void setLogPath(String logPath) {
this.logPath = logPath;
}
public void setLogRetentionDays(int logRetentionDays) {
this.logRetentionDays = logRetentionDays;
}
// ---------------------- start + stop ----------------------
public void start() throws Exception {
// init logpath
JobFileAppender.initLogPath(logPath);
// init invoker, admin-client
initAdminBizList(adminAddresses, accessToken);
// init JobLogFileCleanThread
JobLogFileCleanThread.getInstance().start(logRetentionDays);
// init TriggerCallbackThread
TriggerCallbackThread.getInstance().start();
// init ProcessCallbackThread
ProcessCallbackThread.getInstance().start();
// init executor-server
port = port > 0 ? port : NetUtil.findAvailablePort(9998);
ip = (ip != null && ip.trim().length() > 0) ? ip : IpUtil.getIp();
initRpcProvider(ip, port, appName, accessToken);
}
public void destroy() {
// destory executor-server
stopRpcProvider();
// destory jobThreadRepository
if (jobThreadRepository.size() > 0) {
for (Map.Entry<Integer, JobThread> item : jobThreadRepository.entrySet()) {
removeJobThread(item.getKey(), "web container destroy and kill the job.");
JobThread oldJobThread = removeJobThread(item.getKey(), "web container destroy and kill the job.");
// wait for job thread push result to callback queue
if (oldJobThread != null) {
try {
oldJobThread.join();
} catch (InterruptedException e) {
logger.error(">>>>>>>>>>> web, JobThread destroy(join) error, jobId:{}", item.getKey(), e);
}
}
}
jobThreadRepository.clear();
}
jobHandlerRepository.clear();
// destory JobLogFileCleanThread
JobLogFileCleanThread.getInstance().toStop();
// destory TriggerCallbackThread
TriggerCallbackThread.getInstance().toStop();
// destory ProcessCallbackThread
ProcessCallbackThread.getInstance().toStop();
}
// ---------------------- admin-client (rpc invoker) ----------------------
private static List<AdminBiz> adminBizList;
private static Serializer serializer = new HessianSerializer();
private void initAdminBizList(String adminAddresses, String accessToken) throws Exception {
if (adminAddresses != null && adminAddresses.trim().length() > 0) {
for (String address : adminAddresses.trim().split(",")) {
if (address != null && address.trim().length() > 0) {
//实例化AdminBizClient
AdminBiz adminBiz = new AdminBizClient(address.trim(), accessToken);
if (adminBizList == null) {
adminBizList = new ArrayList<>();
}
adminBizList.add(adminBiz);
}
}
}
}
public static List<AdminBiz> getAdminBizList() {
return adminBizList;
}
public static Serializer getSerializer() {
return serializer;
}
// ---------------------- executor-server (rpc provider) ----------------------
private XxlRpcProviderFactory xxlRpcProviderFactory = null;
private void initRpcProvider(String ip, int port, String appName, String accessToken) throws Exception {
// init, provider factory
String address = IpUtil.getIpPort(ip, port);
Map<String, String> serviceRegistryParam = new HashMap<>();
serviceRegistryParam.put("appName", appName);
serviceRegistryParam.put("address", address);
xxlRpcProviderFactory = new XxlRpcProviderFactory();
xxlRpcProviderFactory.setServer(NettyHttpServer.class);
xxlRpcProviderFactory.setSerializer(HessianSerializer.class);
xxlRpcProviderFactory.setCorePoolSize(20);
xxlRpcProviderFactory.setMaxPoolSize(200);
xxlRpcProviderFactory.setIp(ip);
xxlRpcProviderFactory.setPort(port);
xxlRpcProviderFactory.setAccessToken(accessToken);
xxlRpcProviderFactory.setServiceRegistry(ExecutorServiceRegistry.class);
xxlRpcProviderFactory.setServiceRegistryParam(serviceRegistryParam);
// add services
xxlRpcProviderFactory.addService(ExecutorBiz.class.getName(), null, new ExecutorBizImpl());
// start
xxlRpcProviderFactory.start();
}
public static class ExecutorServiceRegistry extends ServiceRegistry {
@Override
public void start(Map<String, String> param) {
// start registry
ExecutorRegistryThread.getInstance().start(param.get("appName"), param.get("address"));
}
@Override
public void stop() {
// stop registry
ExecutorRegistryThread.getInstance().toStop();
}
@Override
public boolean registry(Set<String> keys, String value) {
return false;
}
@Override
public boolean remove(Set<String> keys, String value) {
return false;
}
@Override
public Map<String, TreeSet<String>> discovery(Set<String> keys) {
return null;
}
@Override
public TreeSet<String> discovery(String key) {
return null;
}
}
private void stopRpcProvider() {
// stop provider factory
try {
xxlRpcProviderFactory.stop();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
// ---------------------- job handler repository ----------------------
private static ConcurrentMap<String, IJobHandler> jobHandlerRepository = new ConcurrentHashMap<String, IJobHandler>();
public static IJobHandler registJobHandler(String name, IJobHandler jobHandler) {
logger.info(">>>>>>>>>>> web register jobhandler success, name:{}, jobHandler:{}", name, jobHandler);
return jobHandlerRepository.put(name, jobHandler);
}
public static IJobHandler loadJobHandler(String name) {
return jobHandlerRepository.get(name);
}
// ---------------------- job thread repository ----------------------
private static ConcurrentMap<Integer, JobThread> jobThreadRepository = new ConcurrentHashMap<Integer, JobThread>();
public static JobThread registJobThread(int jobId, IJobHandler handler, String removeOldReason) {
JobThread newJobThread = new JobThread(jobId, handler);
newJobThread.start();
logger.info(">>>>>>>>>>> web regist JobThread success, jobId:{}, handler:{}", new Object[]{jobId, handler});
JobThread oldJobThread = jobThreadRepository.put(jobId, newJobThread); // putIfAbsent | oh my god, map's put method return the old value!!!
if (oldJobThread != null) {
oldJobThread.toStop(removeOldReason);
oldJobThread.interrupt();
}
return newJobThread;
}
public static JobThread removeJobThread(int jobId, String removeOldReason) {
JobThread oldJobThread = jobThreadRepository.remove(jobId);
if (oldJobThread != null) {
oldJobThread.toStop(removeOldReason);
oldJobThread.interrupt();
return oldJobThread;
}
return null;
}
public static JobThread loadJobThread(int jobId) {
JobThread jobThread = jobThreadRepository.get(jobId);
return jobThread;
}
}

View File

@ -0,0 +1,85 @@
package com.czsj.core.enums.executor.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.czsj.core.enums.executor.JobExecutor;
import com.czsj.core.enums.glue.GlueFactory;
import com.czsj.core.enums.handler.IJobHandler;
import com.czsj.core.enums.handler.annotation.JobHandler;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import java.util.Map;
/**
* xxl-job executor (for spring)
*
* @author xuxueli 2018-11-01 09:24:52
*/
public class JobSpringExecutor extends JobExecutor
implements ApplicationContextAware, SmartInitializingSingleton, DisposableBean {
// start
@Override
public void afterSingletonsInstantiated() {
// init JobHandler Repository
initJobHandlerRepository(applicationContext);
// refresh GlueFactory
GlueFactory.refreshInstance(1);
// super start
try {
super.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
// destroy
@Override
public void destroy() {
super.destroy();
}
private void initJobHandlerRepository(ApplicationContext applicationContext) {
if (applicationContext == null) {
return;
}
// init job handler action
Map<String, Object> serviceBeanMap = applicationContext.getBeansWithAnnotation(JobHandler.class);
if (CollectionUtil.isNotEmpty(serviceBeanMap)) {
for (Object serviceBean : serviceBeanMap.values()) {
if (serviceBean instanceof IJobHandler) {
String name = serviceBean.getClass().getAnnotation(JobHandler.class).value();
IJobHandler handler = (IJobHandler) serviceBean;
if (loadJobHandler(name) != null) {
throw new RuntimeException("web jobhandler[" + name + "] naming conflicts.");
}
registJobHandler(name, handler);
}
}
}
}
// ---------------------- applicationContext ----------------------
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
}

View File

@ -0,0 +1,93 @@
package com.czsj.core.enums.glue;
import com.czsj.core.enums.glue.impl.SpringGlueFactory;
import com.czsj.core.enums.handler.IJobHandler;
import groovy.lang.GroovyClassLoader;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* glue factory, product class/object by name
*
* @author xuxueli 2016-1-2 20:02:27
*/
public class GlueFactory {
private static GlueFactory glueFactory = new GlueFactory();
public static GlueFactory getInstance() {
return glueFactory;
}
public static void refreshInstance(int type) {
if (type == 0) {
glueFactory = new GlueFactory();
} else if (type == 1) {
glueFactory = new SpringGlueFactory();
}
}
/**
* groovy class loader
*/
private GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
private ConcurrentMap<String, Class<?>> CLASS_CACHE = new ConcurrentHashMap<>();
/**
* load new instance, prototype
*
* @param codeSource
* @return
* @throws Exception
*/
public IJobHandler loadNewInstance(String codeSource) throws Exception {
if (codeSource != null && codeSource.trim().length() > 0) {
Class<?> clazz = getCodeSourceClass(codeSource);
if (clazz != null) {
Object instance = clazz.newInstance();
if (instance != null) {
if (instance instanceof IJobHandler) {
this.injectService(instance);
return (IJobHandler) instance;
} else {
throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, "
+ "cannot convert from instance[" + instance.getClass() + "] to IJobHandler");
}
}
}
}
throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, instance is null");
}
private Class<?> getCodeSourceClass(String codeSource) {
try {
// md5
byte[] md5 = MessageDigest.getInstance("MD5").digest(codeSource.getBytes());
String md5Str = new BigInteger(1, md5).toString(16);
Class<?> clazz = CLASS_CACHE.get(md5Str);
if (clazz == null) {
clazz = groovyClassLoader.parseClass(codeSource);
CLASS_CACHE.putIfAbsent(md5Str, clazz);
}
return clazz;
} catch (Exception e) {
return groovyClassLoader.parseClass(codeSource);
}
}
/**
* inject service of bean field
*
* @param instance
*/
public void injectService(Object instance) {
// do something
}
}

View File

@ -0,0 +1,55 @@
package com.czsj.core.enums.glue;
/**
* Created by xuxueli on 17/4/26.
*/
public enum GlueTypeEnum {
seatunnel("seatunnel", false, null, null),
datax("data", false, null, null),
flinkx("flinkx", false, null, null),
BEAN("BEAN", false, null, null),
GLUE_GROOVY("GLUE(Java)", false, null, null),
GLUE_SHELL("GLUE(Shell)", true, "bash", ".sh"),
GLUE_PYTHON("GLUE(Python)", true, "python", ".py"),
GLUE_PHP("GLUE(PHP)", true, "php", ".php"),
GLUE_NODEJS("GLUE(Nodejs)", true, "node", ".js"),
GLUE_POWERSHELL("GLUE(PowerShell)", true, "powershell", ".ps1");
private String desc;
private boolean isScript;
private String cmd;
private String suffix;
private GlueTypeEnum(String desc, boolean isScript, String cmd, String suffix) {
this.desc = desc;
this.isScript = isScript;
this.cmd = cmd;
this.suffix = suffix;
}
public String getDesc() {
return desc;
}
public boolean isScript() {
return isScript;
}
public String getCmd() {
return cmd;
}
public String getSuffix() {
return suffix;
}
public static GlueTypeEnum match(String name){
for (GlueTypeEnum item: GlueTypeEnum.values()) {
if (item.name().equals(name)) {
return item;
}
}
return null;
}
}

View File

@ -0,0 +1,84 @@
package com.czsj.core.enums.glue.impl;
import com.czsj.core.enums.executor.impl.JobSpringExecutor;
import com.czsj.core.enums.glue.GlueFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
/**
* @author xuxueli 2018-11-01
*/
public class SpringGlueFactory extends GlueFactory {
private static Logger logger = LoggerFactory.getLogger(SpringGlueFactory.class);
/**
* inject action of spring
* @param instance
*/
@Override
public void injectService(Object instance){
if (instance==null) {
return;
}
if (JobSpringExecutor.getApplicationContext() == null) {
return;
}
Field[] fields = instance.getClass().getDeclaredFields();
for (Field field : fields) {
if (Modifier.isStatic(field.getModifiers())) {
continue;
}
Object fieldBean = null;
// with bean-id, bean could be found by both @Autowired and @Autowired, or bean could only be found by @Autowired
if (AnnotationUtils.getAnnotation(field, Resource.class) != null) {
try {
Resource resource = AnnotationUtils.getAnnotation(field, Resource.class);
if (resource.name()!=null && resource.name().length()>0){
fieldBean = JobSpringExecutor.getApplicationContext().getBean(resource.name());
} else {
fieldBean = JobSpringExecutor.getApplicationContext().getBean(field.getName());
}
} catch (Exception e) {
}
if (fieldBean==null ) {
fieldBean = JobSpringExecutor.getApplicationContext().getBean(field.getType());
}
} else if (AnnotationUtils.getAnnotation(field, Autowired.class) != null) {
Qualifier qualifier = AnnotationUtils.getAnnotation(field, Qualifier.class);
if (qualifier!=null && qualifier.value()!=null && qualifier.value().length()>0) {
fieldBean = JobSpringExecutor.getApplicationContext().getBean(qualifier.value());
} else {
fieldBean = JobSpringExecutor.getApplicationContext().getBean(field.getType());
}
}
if (fieldBean!=null) {
field.setAccessible(true);
try {
field.set(instance, fieldBean);
} catch (IllegalArgumentException e) {
logger.error(e.getMessage(), e);
} catch (IllegalAccessException e) {
logger.error(e.getMessage(), e);
}
}
}
}
}

View File

@ -0,0 +1,50 @@
package com.czsj.core.enums.handler;
import com.czsj.core.enums.biz.model.ReturnT;
import com.czsj.core.enums.biz.model.TriggerParam;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* job handler
*
* @author xuxueli 2015-12-19 19:06:38
*/
public abstract class IJobHandler {
/** success */
public static final ReturnT<String> SUCCESS = new ReturnT<>(200, null);
/** fail */
public static final ReturnT<String> FAIL = new ReturnT<>(500, null);
/** fail timeout */
public static final ReturnT<String> FAIL_TIMEOUT = new ReturnT<>(502, null);
public static final ConcurrentMap<String, String> jobTmpFiles = new ConcurrentHashMap<>();
/**
* execute handler, invoked when executor receives a scheduling request
*
* @param tgParam
* @return
* @throws Exception
*/
public abstract ReturnT<String> execute(TriggerParam tgParam) throws Exception;
/**
* init handler, invoked when JobThread init
*/
public void init() {
// do something
}
/**
* destroy handler, invoked when JobThread destroy
*/
public void destroy() {
// do something
}
}

View File

@ -0,0 +1,16 @@
package com.czsj.core.enums.handler.annotation;
import java.lang.annotation.*;
/**
* annotation for job handler
* @author 2016-5-17 21:06:49
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface JobHandler {
String value() default "";
}

View File

@ -0,0 +1,29 @@
package com.czsj.core.enums.handler.impl;
import com.czsj.core.enums.biz.model.ReturnT;
import com.czsj.core.enums.biz.model.TriggerParam;
import com.czsj.core.enums.handler.IJobHandler;
import com.czsj.core.enums.log.JobLogger;
/**
* glue job handler
* @author xuxueli 2016-5-19 21:05:45
*/
public class GlueJobHandler extends IJobHandler {
private long glueUpdatetime;
private IJobHandler jobHandler;
public GlueJobHandler(IJobHandler jobHandler, long glueUpdatetime) {
this.jobHandler = jobHandler;
this.glueUpdatetime = glueUpdatetime;
}
public long getGlueUpdatetime() {
return glueUpdatetime;
}
@Override
public ReturnT<String> execute(TriggerParam tgParam) throws Exception {
JobLogger.log("----------- glue.version:"+ glueUpdatetime +" -----------");
return jobHandler.execute(tgParam);
}
}

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