Commit 1a0e6539 authored by sml's avatar sml

代码提交

parents
Pipeline #361 canceled with stages
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
/target/
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jz-dmp-cmdexectool</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
This diff is collapsed.
package com.jz.dmp.cmdexectool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import com.jz.dmp.cmdexectool.common.utils.ApplicationContextUtil;
import com.jz.dmp.cmdexectool.scheduler.service.process.ProcessService;
@EnableTransactionManagement
@SpringBootApplication
@EnableCaching
public class ApiApplication implements HealthIndicator {
private static Logger logger = LoggerFactory.getLogger(ApiApplication.class);
public static void main(String[] args) {
long start = System.currentTimeMillis();
SpringApplication springApplication = new SpringApplication(ApiApplication.class);
springApplication.run(args);
Integer taskId = Integer.parseInt(args[0]);
if (taskId==null) {
logger.info("taskId 不能为空");
return ;
}
String jobId = args[1];
boolean isSingle = Boolean.parseBoolean(args[2]);
logger.info("启动参数,taskId【{}】,jobId【{}】,isSingle【{}】",taskId,jobId,isSingle);
ProcessService processService = ApplicationContextUtil.getBean(ProcessService.class);
processService.taskStart(taskId, jobId, isSingle);
long cost = System.currentTimeMillis() - start;
logger.info(" started status: {}, cost: {}", "SUCCESS!", cost);
}
@Override
public Health health() {
return Health.up().withDetail("label center 系统", "启动成功!").build();
}
}
package com.jz.dmp.cmdexectool.common.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @ClassName: ResubmitCheck
* @Description: TODO(校验重复提交)
* @author ybz
* @date 2021年1月21日
*
*/
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface ResubmitCheck {
}
package com.jz.dmp.cmdexectool.common.bean;
import java.util.List;
/**
* @author ybz
*
*/
public class BaseBeanResponse<T> extends BaseResponse {
private T data;
private List<T> datas;
public BaseBeanResponse(){
super();
}
public BaseBeanResponse(String code, T data) {
super(code);
this.data = data;
}
public BaseBeanResponse(String code, List<T> datas) {
super(code);
this.datas = datas;
}
public BaseBeanResponse(String code, String message, T data) {
super(code, message);
this.data = data;
}
public BaseBeanResponse(String code, String message, List<T> datas) {
super(code, message);
this.datas = datas;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public List<T> getDatas() {
return datas;
}
public void setDatas(List<T> datas) {
this.datas = datas;
}
}
package com.jz.dmp.cmdexectool.common.bean;
/**分页信息封装
* @author ybz
*
*/
public class BasePageBean {
private int pageNum = 1;
private int pageSize = 10;
public int getPageNum() {
return pageNum;
}
public void setPageNum(int pageNum) {
this.pageNum = pageNum;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
}
package com.jz.dmp.cmdexectool.common.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @author ybz
*
*/
@ApiModel(value = "响应码封装实体", description = "响应码封装实体")
public class BaseResponse {
//错误码
@ApiModelProperty(value = "错误码")
private String code;
//错误消息
@ApiModelProperty(value = "错误消息")
private String message;
public BaseResponse() {}
public BaseResponse(String code) {
this.code = code;
}
public BaseResponse(String code, String message) {
this.code = code;
this.message = message;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
package com.jz.dmp.cmdexectool.common.bean;
import com.github.pagehelper.PageInfo;
/**
* @author ybz
*
*/
public class PageInfoResponse<T> extends BaseResponse {
private PageInfo<T> data;
public PageInfo<T> getData() {
return data;
}
public void setData(PageInfo<T> data) {
this.data = data;
}
}
package com.jz.dmp.cmdexectool.common.constant;
/**
* @ClassName: CommConstant
* @Description: TODO(通用常亮)
* @author ybz
* @date 2021年1月18日
*
*/
public class CommConstant {
/***************************************************/
//重复提交校验token
public static final String RE_SUBMIT_TOKEN = "resubmitToken";
/***************************************************/
//MDC
public static final String TRACE_ID="traceId";
/***************************************************/
//子任务类型
public static final String WORK_TYPE_START = "start";//开始任务
public static final String WORK_TYPE_SHELL = "shell";//shell任务
public static final String WORK_TYPE_SQL = "sql";//sql任务
public static final String WORK_TYPE_SYNC = "sync";//离线任务
public static final String WORK_TYPE_SUBPROCESS = "subprocess";//子流程任务
public static final String WORK_TYPE_FTP = "ftp";//ftp下载任务
public static final String WORK_TYPE_UNZIPFILE = "unzipFile";//解压文件任务
public static final String WORK_TYPE_DOCTRANS = "docTrans";//文件转码任务
public static final String WORK_TYPE_HDFS = "hdfs";//hdfs上传任务
public static final String WORK_TYPE_STOP = "stop";//停止任务
/***************************************************/
// task_type任务类型
public static final String TASK_TYPE_DEVELOP = "1";// 开发任务
public static final String TASK_TYPE_OFFLINE = "2";// 离线任务
public static final String TASK_TYPE_DEVSHELL = "3";// SHELL任务
public static final String TASK_TYPE_DEVSQL = "4";// SQL任务
}
package com.jz.dmp.cmdexectool.common.constant;
/**常量
* @author ybz
*
*/
public class StatuConstant {
/***************************************************************************/
/*操作码**/
public final static String SUCCESS_CODE = "000";
public final static String SUCCESS_CODE_MSG = "操作成功";
public final static String FAILURE_CODE = "001";
public final static String FAILURE_CODE_MSG = "操作失败";
/*****************************************************************************/
public static String CODE_ERROR_REQUESTMETHOD = "100";
public static String MSG_ERROR_REQUESTMETHOD = "请求方式错误(只支持POST方式请求)";
public static String CODE_ERROR_PARAMETER = "101";
public static String MSG_ERROR_PARAMETER = "参数不正确(格式不正确或必填参数为空)";
public static String CODE_ERROR_CITYCODE = "102";
public static String MSG_ERROR_CITYCODE = "城市区域代码错误";
public static String CODE_NOT_SIGNED = "103";
public static String MSG_NOT_SIGNED = "尚未登录或者登录已过期";
public static String CODE_DATA_EXISTED = "106";
public static String MSG_DATA_EXISTED = "企业已备案,请勿重复备案";
public static String CODE_ERROR_USERNAMEORPASSWD = "107";
public static String MSG_ERROR_USERNAMEORPASSWD = "用户名或密码错误";
public static String CODE_USER_LOGGEDOFF = "108";
public static String MSG_USER_LOGGEDOFF = "用户已注销";
public static String CODE_PERMISSION_NO = "109";
public static String MSG_PERMISSION_NO = "权限不足,请联系管理员";
public static String CODE_DATA_NOTMEET = "201";
public static String MSG_DATA_NOTMEET = "数据不符合业务处理要求";
public static String CODE_SYS_EXCEPTION = "500";
public static String MSG_SYS_EXCEPTION = "系统异常,请联系接口提供方";
/*****************************************************************************/
}
package com.jz.dmp.cmdexectool.common.interceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.MDC;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import com.jz.dmp.cmdexectool.common.constant.CommConstant;
import com.jz.dmp.cmdexectool.common.utils.CommonUtils;
/**
* @ClassName: LogInterceptor
* @Description: TODO(日志MDC)
* @author ybz
* @date 2021年1月25日
*
*/
public class LogInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//如果有上层调用就用上层的ID
String traceId = request.getHeader(CommConstant.TRACE_ID);
if (traceId == null) {
traceId = CommonUtils.generateTraceId();
}
MDC.put(CommConstant.TRACE_ID, traceId);
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
throws Exception {
//调用结束后删除
MDC.remove(CommConstant.TRACE_ID);
}
}
package com.jz.dmp.cmdexectool.common.interceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
import com.alibaba.fastjson.JSONObject;
import com.jz.dmp.cmdexectool.common.annotation.ResubmitCheck;
import com.jz.dmp.cmdexectool.common.bean.BaseResponse;
import com.jz.dmp.cmdexectool.common.constant.CommConstant;
import com.jz.dmp.cmdexectool.common.constant.StatuConstant;
/**
* @ClassName: LogInterceptor
* @Description: TODO(重复提交校验)
* @author ybz
* @date 2021年1月25日
*
*/
public class ResubmitCheckInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (handler instanceof ResourceHttpRequestHandler) {
return true;
}
HandlerMethod handlerMethod = (HandlerMethod)handler;
ResubmitCheck resubmitCheck = handlerMethod.getMethod().getAnnotation(ResubmitCheck.class);
if (resubmitCheck!=null) {//判断是否需要进行重复提交校验
String resubmitToken = request.getHeader(CommConstant.RE_SUBMIT_TOKEN);
if (resubmitToken==null) {
resubmitToken = request.getParameter(CommConstant.RE_SUBMIT_TOKEN);
}
if (StringUtils.isEmpty(resubmitToken)) {//没有上传校验token
BaseResponse baseResponse = new BaseResponse();
baseResponse.setCode(StatuConstant.CODE_ERROR_PARAMETER);
baseResponse.setMessage("重复提交校验token不能为空!");
response.getWriter().write(JSONObject.toJSONString(baseResponse));
return false;
}
HttpSession session = request.getSession();
String resubmitTokenSession = (String) session.getAttribute(CommConstant.RE_SUBMIT_TOKEN);
if (!resubmitToken.equals(resubmitTokenSession)) {//判断是否重复提交
BaseResponse baseResponse = new BaseResponse();
baseResponse.setCode(StatuConstant.FAILURE_CODE);
baseResponse.setMessage("重复提交!");
response.getWriter().write(JSONObject.toJSONString(baseResponse));
return false;
}
//校验通过,置空token
session.setAttribute(CommConstant.RE_SUBMIT_TOKEN, null);
}
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
throws Exception {
}
}
package com.jz.dmp.cmdexectool.common.persistence;
import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
public class CBTHandler extends BaseTypeHandler<String> {
private static final String DEFAULT_CHARSET = "utf-8";
@Override
public void setNonNullParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType)
throws SQLException {
ByteArrayInputStream bis;
try {
bis = new ByteArrayInputStream(parameter.getBytes(DEFAULT_CHARSET));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Blob Encoding Error!");
}
ps.setBinaryStream(i, bis, parameter.length());
}
@Override
public String getNullableResult(ResultSet rs, String columnName) throws SQLException {
Blob blob = rs.getBlob(columnName);
byte[] returnValue = null;
if (null != blob) {
returnValue = blob.getBytes(1, (int) blob.length());
}
try {
if(returnValue == null) return "";
return new String(returnValue, DEFAULT_CHARSET);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Blob Encoding Error!");
}
}
@Override
public String getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
Blob blob = cs.getBlob(columnIndex);
byte[] returnValue = null;
if (null != blob) {
returnValue = blob.getBytes(1, (int) blob.length());
}
try {
return new String(returnValue, DEFAULT_CHARSET);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Blob Encoding Error!");
}
}
@Override
public String getNullableResult(ResultSet arg0, int arg1) throws SQLException {
return null;
}
}
\ No newline at end of file
package com.jz.dmp.cmdexectool.common.service;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class BaseService {
private Logger logger=LoggerFactory.getLogger(BaseService.class);
/**获取当前用户的主键
* @param httpRequest
* @return
* @throws Exception
*/
public String getHttpRequestUserId(HttpServletRequest httpRequest)throws Exception{
return null;
}
}
package com.jz.dmp.cmdexectool.common.utils;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class ApplicationContextUtil implements ApplicationContextAware {
private static ApplicationContext applicationContext = null;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
if(this.applicationContext == null) {
this.applicationContext = applicationContext;
}
}
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
public static <T> T getBean(Class<T> clazz) {
return getApplicationContext().getBean(clazz);
}
}
package com.jz.dmp.cmdexectool.common.utils;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;
public class CommonUtils {
private static final Logger logger = LoggerFactory.getLogger(CommonUtils.class);
/**
* UUID随机数
* @return
*/
public static String generatePrimaryKeyId() {
String id = UUID.randomUUID().toString().toUpperCase().replaceAll("-", "");
return id;
}
/**
* @Title: generateTraceId
* @Description: TODO(生成traceId)
* @param @return 参数
* @return String 返回类型
* @throws
*/
public static String generateTraceId() {
String traceId = UUID.randomUUID().toString().toUpperCase().replaceAll("-", "");
return traceId;
}
/**
* @Title: generateUuid
* @Description: TODO(生成uuid)
* @param @return 参数
* @return String 返回类型
* @throws
*/
public static String generateUuid() {
String uuid = UUID.randomUUID().toString().toUpperCase().replaceAll("-", "");
return uuid;
}
/**
* @param <T>
* @Title: objArrangeTree
* @Description: TODO(将所有的资源整理成树形结构)
* @param @param dmpPermissions
* @param @return
* @param @throws Exception 参数
* @return List<DmpPermission> 返回类型
* @throws
*/
public static <T> List<T> objArrangeTree(Object parentCode, List<T> objs, String parentCodeFiledName, String codeFieldName, String childrenFieldName) throws Exception {
Map<Object, List<T>> dictMap = objs.stream().collect(Collectors.groupingBy(x->{
try {
return ReflectAssistUtils.getFieldValueByFieldName(parentCodeFiledName, x);
} catch (Exception e) {
e.printStackTrace();
logger.error("树形结构封装异常【{}】", e);
}
return "";
}));
List<T> tList = dictMap.get(parentCode);// 获取顶层资源
if (!CollectionUtils.isEmpty(tList)) {
for (T t : tList) {
t = arrangeChildren(t, dictMap, codeFieldName, childrenFieldName);
}
}
return tList;
}
/**
* @Title: arrangeChildren
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param permission
* @param @param dictMap
* @param @return
* @param @throws Exception 参数
* @return DmpPermission 返回类型
* @throws
*/
private static <T> T arrangeChildren(T t, Map<Object, List<T>> dictMap, String codeFieldName, String childrenFieldName)throws Exception{
Object code = ReflectAssistUtils.getFieldValueByFieldName(codeFieldName, t);
List<T> children = dictMap.get(code);
if (!CollectionUtils.isEmpty(children)) {
for (T child : children) {
child = arrangeChildren(child, dictMap, codeFieldName, childrenFieldName);
}
ReflectAssistUtils.setFieldValueByFieldName(childrenFieldName, t, children);
}
return t;
}
}
package com.jz.dmp.cmdexectool.common.utils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import com.jz.dmp.cmdexectool.common.constant.CommConstant;
/**
*
* @author hack2003
* @date 2016-8-11
* @version v1.0
*
*/
public class HttpRequestUtil {
/**
* 获取有nginx代理的真实地址IP
*
* @param request
* @return
* @throws Exception
*/
public static String getNginxRealIp(HttpServletRequest request) throws Exception {
String ip = request.getHeader("X-Forwarded-For");
if (!org.springframework.util.StringUtils.isEmpty(ip) && !"unKnown".equalsIgnoreCase(ip)) {
// 多次反向代理后会有多个ip值,第一个ip才是真实ip
int index = ip.indexOf(",");
if (index != -1) {
return ip.substring(0, index);
} else {
return ip;
}
}
ip = request.getHeader("X-Real-IP");// 需要在代理服务器上配置该属性
if (!org.springframework.util.StringUtils.isEmpty(ip) && !"unKnown".equalsIgnoreCase(ip)) {
return ip;
}
return request.getRemoteAddr();
}
/**
* 根据httpRequest获取url地址
*
* @param httpRequest
* @return
*/
public static String getRequestUrl(HttpServletRequest httpRequest) {
StringBuffer url = httpRequest.getRequestURL();
return url.toString();
}
/**
* @Title: getResubmitToken
* @Description: TODO(获取并设置重复提交判断token)
* @param @param request
* @param @return 参数
* @return String 返回类型
* @throws
*/
public static String getResubmitToken(HttpServletRequest request) {
HttpSession sesson = request.getSession();
String uuid = CommonUtils.generateUuid();
sesson.setAttribute(CommConstant.RE_SUBMIT_TOKEN, uuid);
return uuid;
}
}
package com.jz.dmp.cmdexectool.common.utils;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName: ReflectAssistUtils
* @Description: TODO(反射辅助工具类)
* @author ybz
* @date 2021年1月26日
*
*/
public class ReflectAssistUtils {
/**
* @Title: getFieldValueByFieldName
* @Description: TODO(根据属性名称获取属性值)
* @param @param fieldName
* @param @param cls
* @param @return
* @param @throws Exception 参数
* @return Field 返回类型
* @throws
*/
public static Object getFieldValueByFieldName(String fieldName, Object obj)throws Exception{
Class<?> cls = obj.getClass();
String getMethodName = "get"+fieldName.substring(0, 1).toUpperCase()+fieldName.substring(1);
Method getMethod = cls.getMethod(getMethodName);
return getMethod.invoke(obj);
}
/**
* @param <T>
* @Title: setFieldValueByFieldName
* @Description: TODO(设置属性值)
* @param @param fieldName
* @param @param cls
* @param @param fieldVaule
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
public static <T> void setFieldValueByFieldName(String fieldName, Object obj, T fieldVaule)throws Exception{
Class<?> cls = obj.getClass();
String setMethodName = "set"+fieldName.substring(0, 1).toUpperCase()+fieldName.substring(1);
Class<?> fieldValueClass = fieldVaule.getClass();
if (fieldVaule instanceof ArrayList) {
fieldValueClass = List.class;
}
Method setMethod = cls.getMethod(setMethodName, fieldValueClass);
setMethod.invoke(obj, fieldVaule);
}
}
package com.jz.dmp.cmdexectool.config;
import javax.sql.DataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
@Configuration
@MapperScan(basePackages = DataSourceConfig1.PACKAGE, sqlSessionFactoryRef = "sqlSessionFactory1")
public class DataSourceConfig1 {
static final String PACKAGE = "com.jz.dmp.cmdexectool.mapper";
@Value("${spring.datasource1.driver-class-name}")
private String driverClassName;
@Value("${spring.datasource1.url}")
private String url;
@Value("${spring.datasource1.username}")
private String userName;
@Value("${spring.datasource1.password}")
private String password;
@Value("${spring.datasource1.hikari.connectionTimeout}")
private long connectionTimeout;
@Value("${spring.datasource1.hikari.idleTimeout}")
private long idleTimeout;
@Value("${spring.datasource1.hikari.maxLifetime}")
private long maxLifetime;
@Value("${spring.datasource1.hikari.maximumPoolSize}")
private int maximumPoolSize;
@Bean(name = "dataSource1")
@Primary
public DataSource dataSource1() {
HikariConfig config = new HikariConfig();
config.setDriverClassName(driverClassName);
config.setJdbcUrl(url);
config.setUsername(userName);
config.setPassword(password);
config.setConnectionTimeout(connectionTimeout);
config.setIdleTimeout(idleTimeout);
config.setMaxLifetime(maxLifetime);
config.setMaximumPoolSize(maximumPoolSize);
HikariDataSource dataSource = new HikariDataSource(config);
return dataSource;
}
@Bean(name = "sqlSessionFactory1")
@Primary
public SqlSessionFactory sqlSessionFactory1(@Qualifier("dataSource1") DataSource dataSource) throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
try {
sessionFactory.setConfigLocation(new ClassPathResource("mybatis-config.xml"));
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources("classpath:mapperconf/*.xml"));
return sessionFactory.getObject();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Bean(name = "transactionManager1")
@Primary
public DataSourceTransactionManager transactionManager1() {
return new DataSourceTransactionManager(dataSource1());
}
}
package com.jz.dmp.cmdexectool.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.jz.dmp.cmdexectool.common.interceptor.LogInterceptor;
import com.jz.dmp.cmdexectool.common.interceptor.ResubmitCheckInterceptor;
/**
* @ClassName: WebAppConfig
* @Description: TODO(web mvc相关配置)
* @author ybz
* @date 2021年1月25日
*
*/
@Configuration
public class WebAppConfig implements WebMvcConfigurer {
/**
*拦截器注册
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new LogInterceptor());
registry.addInterceptor(new ResubmitCheckInterceptor());
}
}
package com.jz.dmp.cmdexectool.controller.bean;
import java.util.List;
import com.jz.dmp.cmdexectool.entity.DmpDevelopTask;
/**
* @author ybz
*
*/
public class DmpDevelopTaskBatch {
private List<DmpDevelopTask> dmpDevelopTasks;
public List<DmpDevelopTask> getDmpDevelopTasks() {
return dmpDevelopTasks;
}
public void setDmpDevelopTasks(List<DmpDevelopTask> dmpDevelopTasks) {
this.dmpDevelopTasks = dmpDevelopTasks;
}
}
package com.jz.dmp.cmdexectool.controller.bean;
import com.jz.dmp.cmdexectool.entity.DmpDevelopTask;
import io.swagger.annotations.ApiModel;
/**任务开发Dto
* @author ybz
*
*/
@ApiModel(value = "任务开发Dto", description = "任务开发Dto")
public class DmpDevelopTaskDto extends DmpDevelopTask {
}
package com.jz.dmp.cmdexectool.controller.bean;
import java.util.List;
import com.jz.dmp.cmdexectool.entity.DmpDevelopTaskHistory;
/**
* @author ybz
*
*/
public class DmpDevelopTaskHistoryBatch {
private List<DmpDevelopTaskHistory> dmpDevelopTaskHistorys;
public List<DmpDevelopTaskHistory> getDmpDevelopTaskHistorys() {
return dmpDevelopTaskHistorys;
}
public void setDmpDevelopTaskHistorys(List<DmpDevelopTaskHistory> dmpDevelopTaskHistorys) {
this.dmpDevelopTaskHistorys = dmpDevelopTaskHistorys;
}
}
package com.jz.dmp.cmdexectool.controller.bean;
import com.jz.dmp.cmdexectool.entity.DmpDevelopTaskHistory;
import io.swagger.annotations.ApiModel;
/**任务历史版本Dto
* @author ybz
*
*/
@ApiModel(value = "任务历史版本Dto", description = "任务历史版本Dto")
public class DmpDevelopTaskHistoryDto extends DmpDevelopTaskHistory {
}
package com.jz.dmp.cmdexectool.controller.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
import com.jz.dmp.cmdexectool.common.bean.BasePageBean;
/**任务历史版本参数请求封装
* @author ybz
*
*/
@ApiModel(value = "任务历史版本参数请求封装", description = "任务历史版本参数请求封装")
public class DmpDevelopTaskHistoryRequest extends BasePageBean {
/**
* 主键
*/
@ApiModelProperty(value = "主键")
private Integer id;
/**
* 所属任务(关联任务主键)
*/
@ApiModelProperty(value = "所属任务(关联任务主键)")
private Integer taskId;
/**
* tree ID
*/
@ApiModelProperty(value = "tree ID")
private Integer treeId;
/**
* 数据源ID
*/
@ApiModelProperty(value = "数据源ID")
private Integer datasourceId;
/**
* 任务类型
*/
@ApiModelProperty(value = "任务类型")
private String taskType;
/**
* 类型
*/
@ApiModelProperty(value = "类型")
private String type;
/**
* 调度类型
*/
@ApiModelProperty(value = "调度类型")
private String scheduleType;
/**
* 是否已提交
*/
@ApiModelProperty(value = "是否已提交")
private String isSubmit;
/**
* 描述
*/
@ApiModelProperty(value = "描述")
private String taskDesc;
/**
* 脚本
*/
@ApiModelProperty(value = "脚本")
private String script;
/**
* flow_header
*/
@ApiModelProperty(value = "flow_header")
private String flowHeader;
/**
* flow_json
*/
@ApiModelProperty(value = "flow_json")
private String flowJson;
/**
* 版本
*/
@ApiModelProperty(value = "版本")
private String version;
/**
* is_gziped
*/
@ApiModelProperty(value = "is_gziped")
private String isGziped;
/**
* 任务数据状态
*/
@ApiModelProperty(value = "任务数据状态")
private String taskDataStatus;
/**
* 任务创建用户ID
*/
@ApiModelProperty(value = "任务创建用户ID")
private String taskCreateUserId;
/**
* 任务创建时间起
*/
@ApiModelProperty(value = "任务创建时间起")
private Date taskCreateTimeStart;
/**
* 任务创建时间止
*/
@ApiModelProperty(value = "任务创建时间止")
private Date taskCreateTimeEnd;
/**
* 任务修改用户ID
*/
@ApiModelProperty(value = "任务修改用户ID")
private String taskUpdateUserId;
/**
* 任务修改时间起
*/
@ApiModelProperty(value = "任务修改时间起")
private Date taskUpdateTimeStart;
/**
* 任务修改时间止
*/
@ApiModelProperty(value = "任务修改时间止")
private Date taskUpdateTimeEnd;
/**
* 备注
*/
@ApiModelProperty(value = "备注")
private String remark;
/**
* 数据状态(0:删除,1,未删除)
*/
@ApiModelProperty(value = "数据状态(0:删除,1,未删除)")
private String dataStatus;
/**
* 创建用户ID
*/
@ApiModelProperty(value = "创建用户ID")
private Integer createUserId;
/**
* 创建时间起
*/
@ApiModelProperty(value = "创建时间起")
private Date createTimeStart;
/**
* 创建时间止
*/
@ApiModelProperty(value = "创建时间止")
private Date createTimeEnd;
/**
* 修改用户ID
*/
@ApiModelProperty(value = "修改用户ID")
private Integer updateUserId;
/**
* 修改时间起
*/
@ApiModelProperty(value = "修改时间起")
private Date updateTimeStart;
/**
* 修改时间止
*/
@ApiModelProperty(value = "修改时间止")
private Date updateTimeEnd;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getTaskId() {
return taskId;
}
public void setTaskId(Integer taskId) {
this.taskId = taskId;
}
public Integer getTreeId() {
return treeId;
}
public void setTreeId(Integer treeId) {
this.treeId = treeId;
}
public Integer getDatasourceId() {
return datasourceId;
}
public void setDatasourceId(Integer datasourceId) {
this.datasourceId = datasourceId;
}
public String getTaskType() {
return taskType;
}
public void setTaskType(String taskType) {
this.taskType = taskType;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getScheduleType() {
return scheduleType;
}
public void setScheduleType(String scheduleType) {
this.scheduleType = scheduleType;
}
public String getIsSubmit() {
return isSubmit;
}
public void setIsSubmit(String isSubmit) {
this.isSubmit = isSubmit;
}
public String getTaskDesc() {
return taskDesc;
}
public void setTaskDesc(String taskDesc) {
this.taskDesc = taskDesc;
}
public String getScript() {
return script;
}
public void setScript(String script) {
this.script = script;
}
public String getFlowHeader() {
return flowHeader;
}
public void setFlowHeader(String flowHeader) {
this.flowHeader = flowHeader;
}
public String getFlowJson() {
return flowJson;
}
public void setFlowJson(String flowJson) {
this.flowJson = flowJson;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getIsGziped() {
return isGziped;
}
public void setIsGziped(String isGziped) {
this.isGziped = isGziped;
}
public String getTaskDataStatus() {
return taskDataStatus;
}
public void setTaskDataStatus(String taskDataStatus) {
this.taskDataStatus = taskDataStatus;
}
public String getTaskCreateUserId() {
return taskCreateUserId;
}
public void setTaskCreateUserId(String taskCreateUserId) {
this.taskCreateUserId = taskCreateUserId;
}
public Date getTaskCreateTimeStart() {
return taskCreateTimeStart;
}
public void setTaskCreateTimeStart(Date taskCreateTimeStart) {
this.taskCreateTimeStart = taskCreateTimeStart;
}
public Date getTaskCreateTimeEnd() {
return taskCreateTimeEnd;
}
public void setTaskCreateTimeEnd(Date taskCreateTimeEnd) {
this.taskCreateTimeEnd = taskCreateTimeEnd;
}
public String getTaskUpdateUserId() {
return taskUpdateUserId;
}
public void setTaskUpdateUserId(String taskUpdateUserId) {
this.taskUpdateUserId = taskUpdateUserId;
}
public Date getTaskUpdateTimeStart() {
return taskUpdateTimeStart;
}
public void setTaskUpdateTimeStart(Date taskUpdateTimeStart) {
this.taskUpdateTimeStart = taskUpdateTimeStart;
}
public Date getTaskUpdateTimeEnd() {
return taskUpdateTimeEnd;
}
public void setTaskUpdateTimeEnd(Date taskUpdateTimeEnd) {
this.taskUpdateTimeEnd = taskUpdateTimeEnd;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getDataStatus() {
return dataStatus;
}
public void setDataStatus(String dataStatus) {
this.dataStatus = dataStatus;
}
public Integer getCreateUserId() {
return createUserId;
}
public void setCreateUserId(Integer createUserId) {
this.createUserId = createUserId;
}
public Date getCreateTimeStart() {
return createTimeStart;
}
public void setCreateTimeStart(Date createTimeStart) {
this.createTimeStart = createTimeStart;
}
public Date getCreateTimeEnd() {
return createTimeEnd;
}
public void setCreateTimeEnd(Date createTimeEnd) {
this.createTimeEnd = createTimeEnd;
}
public Integer getUpdateUserId() {
return updateUserId;
}
public void setUpdateUserId(Integer updateUserId) {
this.updateUserId = updateUserId;
}
public Date getUpdateTimeStart() {
return updateTimeStart;
}
public void setUpdateTimeStart(Date updateTimeStart) {
this.updateTimeStart = updateTimeStart;
}
public Date getUpdateTimeEnd() {
return updateTimeEnd;
}
public void setUpdateTimeEnd(Date updateTimeEnd) {
this.updateTimeEnd = updateTimeEnd;
}
}
package com.jz.dmp.cmdexectool.controller.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
import com.jz.dmp.cmdexectool.common.bean.BasePageBean;
/**任务开发参数请求封装
* @author ybz
*
*/
@ApiModel(value = "任务开发参数请求封装", description = "任务开发参数请求封装")
public class DmpDevelopTaskRequest extends BasePageBean {
/**
* ID
*/
@ApiModelProperty(value = "ID")
private Integer id;
/**
* tree ID
*/
@ApiModelProperty(value = "tree ID")
private Integer treeId;
/**
* 数据源ID
*/
@ApiModelProperty(value = "数据源ID")
private Integer datasourceId;
/**
* 任务类型(1,开发任务;2,离线任务;3,SHELL任务;4,SQL任务)
*/
@ApiModelProperty(value = "任务类型(1,开发任务;2,离线任务;3,SHELL任务;4,SQL任务)")
private String taskType;
/**
* 类型
*/
@ApiModelProperty(value = "类型")
private String type;
/**
* 调度类型
*/
@ApiModelProperty(value = "调度类型")
private String scheduleType;
/**
* 是否已提交
*/
@ApiModelProperty(value = "是否已提交")
private String isSubmit;
/**
* 描述
*/
@ApiModelProperty(value = "描述")
private String taskDesc;
/**
* 脚本
*/
@ApiModelProperty(value = "脚本")
private String script;
/**
* 校验状态:SUCCEED 成功, FAIL 失败
*/
@ApiModelProperty(value = "校验状态:SUCCEED 成功, FAIL 失败")
private String chkResult;
/**
* 同步状态:SUCCEED 成功,FAIL 失败
*/
@ApiModelProperty(value = "同步状态:SUCCEED 成功,FAIL 失败")
private String syncResult;
/**
* 最终校验时间起
*/
@ApiModelProperty(value = "最终校验时间起")
private Date chkTimeStart;
/**
* 最终校验时间止
*/
@ApiModelProperty(value = "最终校验时间止")
private Date chkTimeEnd;
/**
* 最终同步时间起
*/
@ApiModelProperty(value = "最终同步时间起")
private Date syncTimeStart;
/**
* 最终同步时间止
*/
@ApiModelProperty(value = "最终同步时间止")
private Date syncTimeEnd;
/**
*
*/
@ApiModelProperty(value = "")
private String flowHeader;
/**
*
*/
@ApiModelProperty(value = "")
private String flowJson;
/**
* 保存版本
*/
@ApiModelProperty(value = "保存版本")
private String version;
/**
* 发布版本
*/
@ApiModelProperty(value = "发布版本")
private String publishVersion;
/**
*
*/
@ApiModelProperty(value = "")
private Integer isGziped;
/**
* 源数据库ID
*/
@ApiModelProperty(value = "源数据库ID")
private String sourceDbId;
/**
* 源数据库名称
*/
@ApiModelProperty(value = "源数据库名称")
private String sourceDbName;
/**
* 源数据表名称
*/
@ApiModelProperty(value = "源数据表名称")
private String sourceTableName;
/**
* 目标数据库名称
*/
@ApiModelProperty(value = "目标数据库名称")
private String targetDbName;
/**
* 目标数据表名称
*/
@ApiModelProperty(value = "目标数据表名称")
private String targetTableName;
/**
* 创建用户ID
*/
@ApiModelProperty(value = "创建用户ID")
private String createUserId;
/**
* 数据创建时间起
*/
@ApiModelProperty(value = "数据创建时间起")
private Date createTimeStart;
/**
* 数据创建时间止
*/
@ApiModelProperty(value = "数据创建时间止")
private Date createTimeEnd;
/**
* 创建用户ID
*/
@ApiModelProperty(value = "创建用户ID")
private String updateUserId;
/**
* 数据更新时间起
*/
@ApiModelProperty(value = "数据更新时间起")
private Date updateTimeStart;
/**
* 数据更新时间止
*/
@ApiModelProperty(value = "数据更新时间止")
private Date updateTimeEnd;
/**
* 数据状态:0删除,1未删除
*/
@ApiModelProperty(value = "数据状态:0删除,1未删除")
private String dataStatus;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getTreeId() {
return treeId;
}
public void setTreeId(Integer treeId) {
this.treeId = treeId;
}
public Integer getDatasourceId() {
return datasourceId;
}
public void setDatasourceId(Integer datasourceId) {
this.datasourceId = datasourceId;
}
public String getTaskType() {
return taskType;
}
public void setTaskType(String taskType) {
this.taskType = taskType;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getScheduleType() {
return scheduleType;
}
public void setScheduleType(String scheduleType) {
this.scheduleType = scheduleType;
}
public String getIsSubmit() {
return isSubmit;
}
public void setIsSubmit(String isSubmit) {
this.isSubmit = isSubmit;
}
public String getTaskDesc() {
return taskDesc;
}
public void setTaskDesc(String taskDesc) {
this.taskDesc = taskDesc;
}
public String getScript() {
return script;
}
public void setScript(String script) {
this.script = script;
}
public String getChkResult() {
return chkResult;
}
public void setChkResult(String chkResult) {
this.chkResult = chkResult;
}
public String getSyncResult() {
return syncResult;
}
public void setSyncResult(String syncResult) {
this.syncResult = syncResult;
}
public Date getChkTimeStart() {
return chkTimeStart;
}
public void setChkTimeStart(Date chkTimeStart) {
this.chkTimeStart = chkTimeStart;
}
public Date getChkTimeEnd() {
return chkTimeEnd;
}
public void setChkTimeEnd(Date chkTimeEnd) {
this.chkTimeEnd = chkTimeEnd;
}
public Date getSyncTimeStart() {
return syncTimeStart;
}
public void setSyncTimeStart(Date syncTimeStart) {
this.syncTimeStart = syncTimeStart;
}
public Date getSyncTimeEnd() {
return syncTimeEnd;
}
public void setSyncTimeEnd(Date syncTimeEnd) {
this.syncTimeEnd = syncTimeEnd;
}
public String getFlowHeader() {
return flowHeader;
}
public void setFlowHeader(String flowHeader) {
this.flowHeader = flowHeader;
}
public String getFlowJson() {
return flowJson;
}
public void setFlowJson(String flowJson) {
this.flowJson = flowJson;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getPublishVersion() {
return publishVersion;
}
public void setPublishVersion(String publishVersion) {
this.publishVersion = publishVersion;
}
public Integer getIsGziped() {
return isGziped;
}
public void setIsGziped(Integer isGziped) {
this.isGziped = isGziped;
}
public String getSourceDbId() {
return sourceDbId;
}
public void setSourceDbId(String sourceDbId) {
this.sourceDbId = sourceDbId;
}
public String getSourceDbName() {
return sourceDbName;
}
public void setSourceDbName(String sourceDbName) {
this.sourceDbName = sourceDbName;
}
public String getSourceTableName() {
return sourceTableName;
}
public void setSourceTableName(String sourceTableName) {
this.sourceTableName = sourceTableName;
}
public String getTargetDbName() {
return targetDbName;
}
public void setTargetDbName(String targetDbName) {
this.targetDbName = targetDbName;
}
public String getTargetTableName() {
return targetTableName;
}
public void setTargetTableName(String targetTableName) {
this.targetTableName = targetTableName;
}
public String getCreateUserId() {
return createUserId;
}
public void setCreateUserId(String createUserId) {
this.createUserId = createUserId;
}
public Date getCreateTimeStart() {
return createTimeStart;
}
public void setCreateTimeStart(Date createTimeStart) {
this.createTimeStart = createTimeStart;
}
public Date getCreateTimeEnd() {
return createTimeEnd;
}
public void setCreateTimeEnd(Date createTimeEnd) {
this.createTimeEnd = createTimeEnd;
}
public String getUpdateUserId() {
return updateUserId;
}
public void setUpdateUserId(String updateUserId) {
this.updateUserId = updateUserId;
}
public Date getUpdateTimeStart() {
return updateTimeStart;
}
public void setUpdateTimeStart(Date updateTimeStart) {
this.updateTimeStart = updateTimeStart;
}
public Date getUpdateTimeEnd() {
return updateTimeEnd;
}
public void setUpdateTimeEnd(Date updateTimeEnd) {
this.updateTimeEnd = updateTimeEnd;
}
public String getDataStatus() {
return dataStatus;
}
public void setDataStatus(String dataStatus) {
this.dataStatus = dataStatus;
}
}
package com.jz.dmp.cmdexectool.controller.bean;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import com.jz.dmp.cmdexectool.common.constant.CommConstant;
import com.jz.dmp.cmdexectool.entity.DmpDevelopTask;
import com.jz.dmp.cmdexectool.scheduler.common.enums.JobType;
import com.jz.dmp.cmdexectool.scheduler.common.task.shell.ShellParameters;
import com.jz.dmp.cmdexectool.scheduler.dao.entity.TaskInstance;
import com.jz.dmp.cmdexectool.scheduler.server.entity.TaskExecutionContext;
public class MyDmpDevelopTaskConverter {
private static MyDmpDevelopTaskConverter instance;
private MyDmpDevelopTaskConverter() {};
public synchronized static MyDmpDevelopTaskConverter INSTANCE() {
if (instance==null) {
instance = new MyDmpDevelopTaskConverter();
}
return instance;
}
public DmpDevelopTaskDto domain2dto(DmpDevelopTask dmpDevelopTask) {
DmpDevelopTaskDto dmpDevelopTaskDto = new DmpDevelopTaskDto();
BeanUtils.copyProperties(dmpDevelopTask, dmpDevelopTaskDto);
return dmpDevelopTaskDto;
}
public List<DmpDevelopTaskDto> domain2dto(List<DmpDevelopTask> dmpDevelopTasks) {
List<DmpDevelopTaskDto> dmpDevelopTaskDtos = new ArrayList<DmpDevelopTaskDto>();
dmpDevelopTasks.stream().forEach(x -> {
dmpDevelopTaskDtos.add(domain2dto(x));
});
return dmpDevelopTaskDtos;
}
public DmpDevelopTask dto2domain(DmpDevelopTaskDto dmpDevelopTaskDto) {
DmpDevelopTask dmpDevelopTask = new DmpDevelopTask();
BeanUtils.copyProperties(dmpDevelopTaskDto, dmpDevelopTask);
return dmpDevelopTask;
}
public List<DmpDevelopTask> dto2domain(List<DmpDevelopTaskDto> dmpDevelopTaskDtos) {
List<DmpDevelopTask> dmpDevelopTasks = new ArrayList<DmpDevelopTask>();
dmpDevelopTaskDtos.stream().forEach(x -> {
dmpDevelopTasks.add(domain2dto(x));
});
return dmpDevelopTasks;
}
/**
* @Title: dto2instance
* @Description: TODO(将task的job转换成taskInstance)
* @param @param dmpDevelopTaskDto
* @param @param jobId
* @param @return 参数
* @return TaskInstance 返回类型
* @throws
*/
public TaskInstance dto2instance(DmpDevelopTaskDto dmpDevelopTaskDto, String jobId) {
TaskInstance taskInstance = new TaskInstance();
return taskInstance;
}
/**
* @Title: dto2execcontext
* @Description: TODO(将task的job转换成taskExecutionContext)
* @param @param dmpDevelopTaskDto
* @param @param jobId
* @param @return 参数
* @return TaskExecutionContext 返回类型
* @throws
*/
public TaskExecutionContext dto2execcontext(DmpDevelopTaskDto dmpDevelopTaskDto, String jobId) {
TaskExecutionContext taskExecutionContext = new TaskExecutionContext();
JobType jobType = null;
if (StringUtils.isEmpty(jobId)) {
jobType = JobType.valueOf(jobId);
}
String taskType = dmpDevelopTaskDto.getTaskType();
if (taskType.equals(CommConstant.TASK_TYPE_DEVSHELL)) {
jobType = JobType.SHELL;
}else if (taskType.equals(CommConstant.TASK_TYPE_DEVSQL)) {
jobType = JobType.SQL;
}else if (taskType.equals(CommConstant.TASK_TYPE_OFFLINE)) {
jobType = JobType.SYNC;
}
switch (jobType) {
case SHELL:
taskExecutionContext = ShellParameters.getTaskExecutionContext(dmpDevelopTaskDto);
break;
case SQL:
break;
case SYNC:
break;
case SUBPROCESS:
break;
case FTP:
break;
case UNZIPFILE:
break;
case DOCTRANS:
break;
case HDFS:
break;
default:
break;
}
return taskExecutionContext;
}
}
package com.jz.dmp.cmdexectool.controller.bean;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.BeanUtils;
import com.jz.dmp.cmdexectool.entity.DmpDevelopTaskHistory;
import com.jz.dmp.cmdexectool.scheduler.server.entity.TaskExecutionContext;
public class MyDmpDevelopTaskHistoryConverter {
private static MyDmpDevelopTaskHistoryConverter instance;
private MyDmpDevelopTaskHistoryConverter() {};
public synchronized static MyDmpDevelopTaskHistoryConverter INSTANCE() {
if (instance==null) {
instance = new MyDmpDevelopTaskHistoryConverter();
}
return instance;
}
public DmpDevelopTaskHistoryDto domain2dto(DmpDevelopTaskHistory dmpDevelopTaskHistory) {
DmpDevelopTaskHistoryDto dmpDevelopTaskHistoryDto = new DmpDevelopTaskHistoryDto();
BeanUtils.copyProperties(dmpDevelopTaskHistory, dmpDevelopTaskHistoryDto);
return dmpDevelopTaskHistoryDto;
}
public List<DmpDevelopTaskHistoryDto> domain2dto(List<DmpDevelopTaskHistory> dmpDevelopTaskHistorys) {
List<DmpDevelopTaskHistoryDto> dmpDevelopTaskHistoryDtos = new ArrayList<DmpDevelopTaskHistoryDto>();
dmpDevelopTaskHistorys.stream().forEach(x -> {
dmpDevelopTaskHistoryDtos.add(domain2dto(x));
});
return dmpDevelopTaskHistoryDtos;
}
public DmpDevelopTaskHistory dto2domain(DmpDevelopTaskHistoryDto dmpDevelopTaskHistoryDto) {
DmpDevelopTaskHistory dmpDevelopTaskHistory = new DmpDevelopTaskHistory();
BeanUtils.copyProperties(dmpDevelopTaskHistoryDto, dmpDevelopTaskHistory);
return dmpDevelopTaskHistory;
}
public List<DmpDevelopTaskHistory> dto2domain(List<DmpDevelopTaskHistoryDto> dmpDevelopTaskHistoryDtos) {
List<DmpDevelopTaskHistory> dmpDevelopTaskHistorys = new ArrayList<DmpDevelopTaskHistory>();
dmpDevelopTaskHistoryDtos.stream().forEach(x -> {
dmpDevelopTaskHistorys.add(domain2dto(x));
});
return dmpDevelopTaskHistorys;
}
/**
* @Title: historyDto2taskDto
* @Description: TODO(history转Task)
* @param @param dmpDevelopTaskHistoryDto
* @param @return 参数
* @return DmpDevelopTaskDto 返回类型
* @throws
*/
public DmpDevelopTaskDto historyDto2taskDto(DmpDevelopTaskHistoryDto dmpDevelopTaskHistoryDto) {
DmpDevelopTaskDto dmpDevelopTaskDto = new DmpDevelopTaskDto();
BeanUtils.copyProperties(dmpDevelopTaskHistoryDto, dmpDevelopTaskDto);
return dmpDevelopTaskDto;
}
}
package com.jz.dmp.cmdexectool.controller.sys;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.jz.dmp.cmdexectool.common.bean.BaseBeanResponse;
import com.jz.dmp.cmdexectool.common.constant.StatuConstant;
import com.jz.dmp.cmdexectool.service.sys.SystemCommonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* 系统公共服务
* @author ybz
*
*/
@RestController
@RequestMapping("/sys/common")
@Api(tags = "系统公共服务Controller")
public class SystemCommonController {
@Autowired
private SystemCommonService systemCommonService;
/**获取防止重复提交token
* @param dmpMemberRequest
* @return
*/
@RequestMapping(method = RequestMethod.GET, value = "/getResubmitToken")
@ApiOperation(value = "获取防止重复提交token", notes = "获取防止重复提交token")
public BaseBeanResponse<String> getResubmitToken(HttpServletRequest httpRequest){
BaseBeanResponse<String> baseBeanResponse = new BaseBeanResponse<String>();
try {
baseBeanResponse = systemCommonService.getResubmitToken(httpRequest);
} catch (Exception e) {
baseBeanResponse.setMessage("获取失败");
baseBeanResponse.setCode(StatuConstant.FAILURE_CODE);
e.printStackTrace();
}
return baseBeanResponse;
}
}
package com.jz.dmp.cmdexectool.entity;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**任务开发
* @author ybz
*
*/
@ApiModel(value = "任务开发", description = "任务开发")
public class DmpDevelopTask implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* ID
*/
@ApiModelProperty(value = "ID")
private Integer id;
/**
* tree ID
*/
@ApiModelProperty(value = "tree ID")
private Integer treeId;
/**
* 数据源ID
*/
@ApiModelProperty(value = "数据源ID")
private Integer datasourceId;
/**
* 任务类型(1,开发任务;2,离线任务;3,SHELL任务;4,SQL任务)
*/
@ApiModelProperty(value = "任务类型(1,开发任务;2,离线任务;3,SHELL任务;4,SQL任务)")
private String taskType;
/**
* 类型
*/
@ApiModelProperty(value = "类型")
private String type;
/**
* 调度类型
*/
@ApiModelProperty(value = "调度类型")
private String scheduleType;
/**
* 是否已提交
*/
@ApiModelProperty(value = "是否已提交")
private String isSubmit;
/**
* 描述
*/
@ApiModelProperty(value = "描述")
private String taskDesc;
/**
* 脚本
*/
@ApiModelProperty(value = "脚本")
private String script;
/**
* 校验状态:SUCCEED 成功, FAIL 失败
*/
@ApiModelProperty(value = "校验状态:SUCCEED 成功, FAIL 失败")
private String chkResult;
/**
* 同步状态:SUCCEED 成功,FAIL 失败
*/
@ApiModelProperty(value = "同步状态:SUCCEED 成功,FAIL 失败")
private String syncResult;
/**
* 最终校验时间
*/
@ApiModelProperty(value = "最终校验时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date chkTime;
/**
* 最终同步时间
*/
@ApiModelProperty(value = "最终同步时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date syncTime;
/**
*
*/
@ApiModelProperty(value = "")
private String flowHeader;
/**
*
*/
@ApiModelProperty(value = "")
private String flowJson;
/**
* 保存版本
*/
@ApiModelProperty(value = "保存版本")
private String version;
/**
* 发布版本
*/
@ApiModelProperty(value = "发布版本")
private String publishVersion;
/**
*
*/
@ApiModelProperty(value = "")
private Integer isGziped;
/**
* 源数据库ID
*/
@ApiModelProperty(value = "源数据库ID")
private String sourceDbId;
/**
* 源数据库名称
*/
@ApiModelProperty(value = "源数据库名称")
private String sourceDbName;
/**
* 源数据表名称
*/
@ApiModelProperty(value = "源数据表名称")
private String sourceTableName;
/**
* 目标数据库名称
*/
@ApiModelProperty(value = "目标数据库名称")
private String targetDbName;
/**
* 目标数据表名称
*/
@ApiModelProperty(value = "目标数据表名称")
private String targetTableName;
/**
* 创建用户ID
*/
@ApiModelProperty(value = "创建用户ID")
private String createUserId;
/**
* 数据创建时间
*/
@ApiModelProperty(value = "数据创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**
* 创建用户ID
*/
@ApiModelProperty(value = "创建用户ID")
private String updateUserId;
/**
* 数据更新时间
*/
@ApiModelProperty(value = "数据更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/**
* 数据状态:0删除,1未删除
*/
@ApiModelProperty(value = "数据状态:0删除,1未删除")
private String dataStatus;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getTreeId() {
return treeId;
}
public void setTreeId(Integer treeId) {
this.treeId = treeId;
}
public Integer getDatasourceId() {
return datasourceId;
}
public void setDatasourceId(Integer datasourceId) {
this.datasourceId = datasourceId;
}
public String getTaskType() {
return taskType;
}
public void setTaskType(String taskType) {
this.taskType = taskType;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getScheduleType() {
return scheduleType;
}
public void setScheduleType(String scheduleType) {
this.scheduleType = scheduleType;
}
public String getIsSubmit() {
return isSubmit;
}
public void setIsSubmit(String isSubmit) {
this.isSubmit = isSubmit;
}
public String getTaskDesc() {
return taskDesc;
}
public void setTaskDesc(String taskDesc) {
this.taskDesc = taskDesc;
}
public String getScript() {
return script;
}
public void setScript(String script) {
this.script = script;
}
public String getChkResult() {
return chkResult;
}
public void setChkResult(String chkResult) {
this.chkResult = chkResult;
}
public String getSyncResult() {
return syncResult;
}
public void setSyncResult(String syncResult) {
this.syncResult = syncResult;
}
public Date getChkTime() {
return chkTime;
}
public void setChkTime(Date chkTime) {
this.chkTime = chkTime;
}
public Date getSyncTime() {
return syncTime;
}
public void setSyncTime(Date syncTime) {
this.syncTime = syncTime;
}
public String getFlowHeader() {
return flowHeader;
}
public void setFlowHeader(String flowHeader) {
this.flowHeader = flowHeader;
}
public String getFlowJson() {
return flowJson;
}
public void setFlowJson(String flowJson) {
this.flowJson = flowJson;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getPublishVersion() {
return publishVersion;
}
public void setPublishVersion(String publishVersion) {
this.publishVersion = publishVersion;
}
public Integer getIsGziped() {
return isGziped;
}
public void setIsGziped(Integer isGziped) {
this.isGziped = isGziped;
}
public String getSourceDbId() {
return sourceDbId;
}
public void setSourceDbId(String sourceDbId) {
this.sourceDbId = sourceDbId;
}
public String getSourceDbName() {
return sourceDbName;
}
public void setSourceDbName(String sourceDbName) {
this.sourceDbName = sourceDbName;
}
public String getSourceTableName() {
return sourceTableName;
}
public void setSourceTableName(String sourceTableName) {
this.sourceTableName = sourceTableName;
}
public String getTargetDbName() {
return targetDbName;
}
public void setTargetDbName(String targetDbName) {
this.targetDbName = targetDbName;
}
public String getTargetTableName() {
return targetTableName;
}
public void setTargetTableName(String targetTableName) {
this.targetTableName = targetTableName;
}
public String getCreateUserId() {
return createUserId;
}
public void setCreateUserId(String createUserId) {
this.createUserId = createUserId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getUpdateUserId() {
return updateUserId;
}
public void setUpdateUserId(String updateUserId) {
this.updateUserId = updateUserId;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getDataStatus() {
return dataStatus;
}
public void setDataStatus(String dataStatus) {
this.dataStatus = dataStatus;
}
}
package com.jz.dmp.cmdexectool.entity;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**任务历史版本
* @author ybz
*
*/
@ApiModel(value = "任务历史版本", description = "任务历史版本")
public class DmpDevelopTaskHistory implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@ApiModelProperty(value = "主键")
private Integer id;
/**
* 所属任务(关联任务主键)
*/
@ApiModelProperty(value = "所属任务(关联任务主键)")
private Integer taskId;
/**
* tree ID
*/
@ApiModelProperty(value = "tree ID")
private Integer treeId;
/**
* 数据源ID
*/
@ApiModelProperty(value = "数据源ID")
private Integer datasourceId;
/**
* 任务类型
*/
@ApiModelProperty(value = "任务类型")
private String taskType;
/**
* 类型
*/
@ApiModelProperty(value = "类型")
private String type;
/**
* 调度类型
*/
@ApiModelProperty(value = "调度类型")
private String scheduleType;
/**
* 是否已提交
*/
@ApiModelProperty(value = "是否已提交")
private String isSubmit;
/**
* 描述
*/
@ApiModelProperty(value = "描述")
private String taskDesc;
/**
* 脚本
*/
@ApiModelProperty(value = "脚本")
private String script;
/**
* flow_header
*/
@ApiModelProperty(value = "flow_header")
private String flowHeader;
/**
* flow_json
*/
@ApiModelProperty(value = "flow_json")
private String flowJson;
/**
* 版本
*/
@ApiModelProperty(value = "版本")
private String version;
/**
* is_gziped
*/
@ApiModelProperty(value = "is_gziped")
private String isGziped;
/**
* 任务数据状态
*/
@ApiModelProperty(value = "任务数据状态")
private String taskDataStatus;
/**
* 任务创建用户ID
*/
@ApiModelProperty(value = "任务创建用户ID")
private String taskCreateUserId;
/**
* 任务创建时间
*/
@ApiModelProperty(value = "任务创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date taskCreateTime;
/**
* 任务修改用户ID
*/
@ApiModelProperty(value = "任务修改用户ID")
private String taskUpdateUserId;
/**
* 任务修改时间
*/
@ApiModelProperty(value = "任务修改时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date taskUpdateTime;
/**
* 备注
*/
@ApiModelProperty(value = "备注")
private String remark;
/**
* 数据状态(0:删除,1,未删除)
*/
@ApiModelProperty(value = "数据状态(0:删除,1,未删除)")
private String dataStatus;
/**
* 创建用户ID
*/
@ApiModelProperty(value = "创建用户ID")
private Integer createUserId;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**
* 修改用户ID
*/
@ApiModelProperty(value = "修改用户ID")
private Integer updateUserId;
/**
* 修改时间
*/
@ApiModelProperty(value = "修改时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getTaskId() {
return taskId;
}
public void setTaskId(Integer taskId) {
this.taskId = taskId;
}
public Integer getTreeId() {
return treeId;
}
public void setTreeId(Integer treeId) {
this.treeId = treeId;
}
public Integer getDatasourceId() {
return datasourceId;
}
public void setDatasourceId(Integer datasourceId) {
this.datasourceId = datasourceId;
}
public String getTaskType() {
return taskType;
}
public void setTaskType(String taskType) {
this.taskType = taskType;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getScheduleType() {
return scheduleType;
}
public void setScheduleType(String scheduleType) {
this.scheduleType = scheduleType;
}
public String getIsSubmit() {
return isSubmit;
}
public void setIsSubmit(String isSubmit) {
this.isSubmit = isSubmit;
}
public String getTaskDesc() {
return taskDesc;
}
public void setTaskDesc(String taskDesc) {
this.taskDesc = taskDesc;
}
public String getScript() {
return script;
}
public void setScript(String script) {
this.script = script;
}
public String getFlowHeader() {
return flowHeader;
}
public void setFlowHeader(String flowHeader) {
this.flowHeader = flowHeader;
}
public String getFlowJson() {
return flowJson;
}
public void setFlowJson(String flowJson) {
this.flowJson = flowJson;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getIsGziped() {
return isGziped;
}
public void setIsGziped(String isGziped) {
this.isGziped = isGziped;
}
public String getTaskDataStatus() {
return taskDataStatus;
}
public void setTaskDataStatus(String taskDataStatus) {
this.taskDataStatus = taskDataStatus;
}
public String getTaskCreateUserId() {
return taskCreateUserId;
}
public void setTaskCreateUserId(String taskCreateUserId) {
this.taskCreateUserId = taskCreateUserId;
}
public Date getTaskCreateTime() {
return taskCreateTime;
}
public void setTaskCreateTime(Date taskCreateTime) {
this.taskCreateTime = taskCreateTime;
}
public String getTaskUpdateUserId() {
return taskUpdateUserId;
}
public void setTaskUpdateUserId(String taskUpdateUserId) {
this.taskUpdateUserId = taskUpdateUserId;
}
public Date getTaskUpdateTime() {
return taskUpdateTime;
}
public void setTaskUpdateTime(Date taskUpdateTime) {
this.taskUpdateTime = taskUpdateTime;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getDataStatus() {
return dataStatus;
}
public void setDataStatus(String dataStatus) {
this.dataStatus = dataStatus;
}
public Integer getCreateUserId() {
return createUserId;
}
public void setCreateUserId(Integer createUserId) {
this.createUserId = createUserId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Integer getUpdateUserId() {
return updateUserId;
}
public void setUpdateUserId(Integer updateUserId) {
this.updateUserId = updateUserId;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
package com.jz.dmp.cmdexectool.mapper;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import com.jz.dmp.cmdexectool.controller.bean.DmpDevelopTaskHistoryDto;
import com.jz.dmp.cmdexectool.entity.DmpDevelopTaskHistory;
/**任务历史版本 mapper
* @author ybz
*
*/
public interface DmpDevelopTaskHistoryMapper {
/**新增任务历史版本
* @param dmpDevelopTaskHistory
* @return
* @throws Exception
*/
public int insert(DmpDevelopTaskHistory dmpDevelopTaskHistory)throws Exception;
/**选择性增加任务历史版本
* @param dmpDevelopTaskHistory
* @return
* @throws Exception
*/
public int insertSelective(DmpDevelopTaskHistory dmpDevelopTaskHistory)throws Exception;
/**主键修改任务历史版本
* @param dmpDevelopTaskHistory
* @return
* @throws Exception
*/
public int updateByPrimaryKey(DmpDevelopTaskHistory dmpDevelopTaskHistory)throws Exception;
/**选择性修改任务历史版本
* @param dmpDevelopTaskHistory
* @return
* @throws Exception
*/
public int updateByPrimaryKeySelective(DmpDevelopTaskHistory dmpDevelopTaskHistory)throws Exception;
/**主键查询任务历史版本
* @param id
* @return
* @throws Exception
*/
public DmpDevelopTaskHistory selectByPrimaryKey(Integer id)throws Exception;
/**主键删除任务历史版本
* @param id
* @return
* @throws Exception
*/
public int deleteByPrimaryKey(Integer id)throws Exception;
/**主键软删除任务历史版本
* @param id
* @return
* @throws Exception
*/
public int softDeleteByPrimaryKey(Integer id)throws Exception;
/**主键删除任务历史版本
* @param id
* @return
* @throws Exception
*/
public int delete(Map<String, Object> param)throws Exception;
/**主键软删除任务历史版本
* @param id
* @return
* @throws Exception
*/
public int softDelete(Map<String, Object> param)throws Exception;
/**条件查询任务历史版本
* @param param
* @return
* @throws Exception
*/
public List<DmpDevelopTaskHistoryDto> findList(Map<String, Object> param)throws Exception;
/**主键查询任务历史版本
* @param id
* @return
* @throws Exception
*/
public DmpDevelopTaskHistoryDto findById(Integer id)throws Exception;
/**批量新增任务历史版本
* @param dmpDevelopTaskHistorys
* @throws Exception
*/
public void insertBatch(List<DmpDevelopTaskHistory> dmpDevelopTaskHistorys)throws Exception;
/**
* @Title: deleteByIds
* @Description: TODO(批量删除)
* @param @param idList
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
public void deleteByIds(@Param("idList")List<Integer> idList)throws Exception;
/**
* @Title: softDeleteByIds
* @Description: TODO(批量软删除)
* @param @param idList
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
public void softDeleteByIds(@Param("idList")List<Integer> idList)throws Exception;
}
package com.jz.dmp.cmdexectool.mapper;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import com.jz.dmp.cmdexectool.controller.bean.DmpDevelopTaskDto;
import com.jz.dmp.cmdexectool.entity.DmpDevelopTask;
/**任务开发 mapper
* @author ybz
*
*/
public interface DmpDevelopTaskMapper {
/**新增任务开发
* @param dmpDevelopTask
* @return
* @throws Exception
*/
public int insert(DmpDevelopTask dmpDevelopTask)throws Exception;
/**选择性增加任务开发
* @param dmpDevelopTask
* @return
* @throws Exception
*/
public int insertSelective(DmpDevelopTask dmpDevelopTask)throws Exception;
/**主键修改任务开发
* @param dmpDevelopTask
* @return
* @throws Exception
*/
public int updateByPrimaryKey(DmpDevelopTask dmpDevelopTask)throws Exception;
/**选择性修改任务开发
* @param dmpDevelopTask
* @return
* @throws Exception
*/
public int updateByPrimaryKeySelective(DmpDevelopTask dmpDevelopTask)throws Exception;
/**主键查询任务开发
* @param id
* @return
* @throws Exception
*/
public DmpDevelopTask selectByPrimaryKey(Integer id)throws Exception;
/**主键删除任务开发
* @param id
* @return
* @throws Exception
*/
public int deleteByPrimaryKey(Integer id)throws Exception;
/**主键软删除任务开发
* @param id
* @return
* @throws Exception
*/
public int softDeleteByPrimaryKey(Integer id)throws Exception;
/**主键删除任务开发
* @param id
* @return
* @throws Exception
*/
public int delete(Map<String, Object> param)throws Exception;
/**主键软删除任务开发
* @param id
* @return
* @throws Exception
*/
public int softDelete(Map<String, Object> param)throws Exception;
/**条件查询任务开发
* @param param
* @return
* @throws Exception
*/
public List<DmpDevelopTaskDto> findList(Map<String, Object> param)throws Exception;
/**主键查询任务开发
* @param id
* @return
* @throws Exception
*/
public DmpDevelopTaskDto findById(Integer id)throws Exception;
/**批量新增任务开发
* @param dmpDevelopTasks
* @throws Exception
*/
public void insertBatch(List<DmpDevelopTask> dmpDevelopTasks)throws Exception;
/**
* @Title: deleteByIds
* @Description: TODO(批量删除)
* @param @param idList
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
public void deleteByIds(@Param("idList")List<Integer> idList)throws Exception;
/**
* @Title: softDeleteByIds
* @Description: TODO(批量软删除)
* @param @param idList
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
public void softDeleteByIds(@Param("idList")List<Integer> idList)throws Exception;
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jz.dmp.cmdexectool.scheduler.common.enums;
import java.util.HashMap;
import java.util.Map;
/**
* command types
*/
public enum CommandType {
/**
* command types
* 0 start a new process
* 1 start a new process from current nodes
* 2 recover tolerance fault process
* 3 recover suspended process
* 4 start process from failure task nodes
* 5 complement data
* 6 start a new process from scheduler
* 7 repeat running a process
* 8 pause a process
* 9 stop a process
* 10 recover waiting thread
*/
START_PROCESS(0, "start a new process"),
START_CURRENT_TASK_PROCESS(1, "start a new process from current nodes"),
RECOVER_TOLERANCE_FAULT_PROCESS(2, "recover tolerance fault process"),
RECOVER_SUSPENDED_PROCESS(3, "recover suspended process"),
START_FAILURE_TASK_PROCESS(4, "start process from failure task nodes"),
COMPLEMENT_DATA(5, "complement data"),
SCHEDULER(6, "start a new process from scheduler"),
REPEAT_RUNNING(7, "repeat running a process"),
PAUSE(8, "pause a process"),
STOP(9, "stop a process"),
RECOVER_WAITTING_THREAD(10, "recover waiting thread");
CommandType(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;
}
private static final Map<Integer, CommandType> COMMAND_TYPE_MAP = new HashMap<>();
static {
for (CommandType commandType : CommandType.values()) {
COMMAND_TYPE_MAP.put(commandType.code,commandType);
}
}
public static CommandType of(Integer status) {
if (COMMAND_TYPE_MAP.containsKey(status)) {
return COMMAND_TYPE_MAP.get(status);
}
throw new IllegalArgumentException("invalid status : " + status);
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jz.dmp.cmdexectool.scheduler.common.enums;
/**
* data types in user define parameter
*/
public enum DataType {
/**
* 0 string
* 1 integer
* 2 long
* 3 float
* 4 double
* 5 date, "YYYY-MM-DD"
* 6 time, "HH:MM:SS"
* 7 time stamp
* 8 Boolean
*/
VARCHAR,INTEGER,LONG,FLOAT,DOUBLE,DATE,TIME,TIMESTAMP,BOOLEAN
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jz.dmp.cmdexectool.scheduler.common.enums;
/**
* depend result
*/
public enum DependResult {
/**
* 0 success
* 1 waiting
* 2 failed
*/
SUCCESS, WAITING, FAILED
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jz.dmp.cmdexectool.scheduler.common.enums;
/**
* dependent relation: and or
*/
public enum DependentRelation {
AND,OR;
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jz.dmp.cmdexectool.scheduler.common.enums;
/**
* parameter of stored procedure
*/
public enum Direct {
/**
* 0 in; 1 out;
*/
IN,OUT
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jz.dmp.cmdexectool.scheduler.common.enums;
import java.util.HashMap;
/**
* running status for workflow and task nodes
*/
public enum ExecutionStatus {
/**
* status:
* 0 submit success
* 1 running
* 2 ready pause
* 3 pause
* 4 ready stop
* 5 stop
* 6 failure
* 7 success
* 8 need fault tolerance
* 9 kill
* 10 waiting thread
* 11 waiting depend node complete
* 12 delay execution
*/
SUBMITTED_SUCCESS(0, "submit success"),
RUNNING_EXECUTION(1, "running"),
READY_PAUSE(2, "ready pause"),
PAUSE(3, "pause"),
READY_STOP(4, "ready stop"),
STOP(5, "stop"),
FAILURE(6, "failure"),
SUCCESS(7, "success"),
NEED_FAULT_TOLERANCE(8, "need fault tolerance"),
KILL(9, "kill"),
WAITTING_THREAD(10, "waiting thread"),
WAITTING_DEPEND(11, "waiting depend node complete"),
DELAY_EXECUTION(12, "delay execution");
ExecutionStatus(int code, String descp) {
this.code = code;
this.descp = descp;
}
private final int code;
private final String descp;
private static HashMap<Integer, ExecutionStatus> EXECUTION_STATUS_MAP = new HashMap<>();
static {
for (ExecutionStatus executionStatus : ExecutionStatus.values()) {
EXECUTION_STATUS_MAP.put(executionStatus.code, executionStatus);
}
}
/**
* status is success
*
* @return status
*/
public boolean typeIsSuccess() {
return this == SUCCESS;
}
/**
* status is failure
*
* @return status
*/
public boolean typeIsFailure() {
return this == FAILURE || this == NEED_FAULT_TOLERANCE || this == KILL;
}
/**
* status is finished
*
* @return status
*/
public boolean typeIsFinished() {
return typeIsSuccess() || typeIsFailure() || typeIsCancel() || typeIsPause()
|| typeIsStop();
}
/**
* status is waiting thread
*
* @return status
*/
public boolean typeIsWaitingThread() {
return this == WAITTING_THREAD;
}
/**
* status is pause
*
* @return status
*/
public boolean typeIsPause() {
return this == PAUSE;
}
/**
* status is pause
*
* @return status
*/
public boolean typeIsStop() {
return this == STOP;
}
/**
* status is running
*
* @return status
*/
public boolean typeIsRunning() {
return this == RUNNING_EXECUTION || this == WAITTING_DEPEND || this == DELAY_EXECUTION;
}
/**
* status is cancel
*
* @return status
*/
public boolean typeIsCancel() {
return this == KILL || this == STOP;
}
public int getCode() {
return code;
}
public String getDescp() {
return descp;
}
public static ExecutionStatus of(int status) {
if (EXECUTION_STATUS_MAP.containsKey(status)) {
return EXECUTION_STATUS_MAP.get(status);
}
throw new IllegalArgumentException("invalid status : " + status);
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jz.dmp.cmdexectool.scheduler.common.enums;
/**
* failure policy when some task node failed.
*/
public enum FailureStrategy {
/**
* 0 ending process when some tasks failed.
* 1 continue running when some tasks failed.
**/
END(0, "end"),
CONTINUE(1, "continue");
FailureStrategy(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;
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jz.dmp.cmdexectool.scheduler.common.enums;
/**
* have_script
* have_file
* can_retry
* have_arr_variables
* have_map_variables
* have_alert
*/
public enum Flag {
/**
* 0 no
* 1 yes
*/
NO(0, "no"),
YES(1, "yes");
Flag(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;
}
}
package com.jz.dmp.cmdexectool.scheduler.common.enums;
public enum JobType {
START("start","开始任务"),
SHELL("shell","shell任务"),
SQL("sql","sql任务"),
SYNC("sync","离线任务"),
SUBPROCESS("subprocess","子流程任务"),
FTP("ftp","ftp下载任务"),
UNZIPFILE("unzipFile","解压文件任务"),
DOCTRANS("docTrans","文件转码任务"),
HDFS("hdfs","hdfs上传任务"),
STOP("stop","停止任务");
//job类型
private String jobTypeStr;
//释义
private String chinese;
private JobType(String jobTypeStr, String chinese) {
// TODO Auto-generated constructor stub
this.jobTypeStr = jobTypeStr;
this.chinese = chinese;
}
public String getJobTypeStr() {
return jobTypeStr;
}
public String getChinese() {
return chinese;
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jz.dmp.cmdexectool.scheduler.common.enums;
/**
* define process and task priority
*/
public enum Priority {
/**
* 0 highest priority
* 1 higher priority
* 2 medium priority
* 3 lower priority
* 4 lowest priority
*/
HIGHEST(0, "highest"),
HIGH(1, "high"),
MEDIUM(2, "medium"),
LOW(3, "low"),
LOWEST(4, "lowest");
Priority(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;
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jz.dmp.cmdexectool.scheduler.common.enums;
/**
* support program types
*/
public enum ProgramType {
/**
* 0 JAVA,1 SCALA,2 PYTHON
*/
JAVA,
SCALA,
PYTHON
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jz.dmp.cmdexectool.scheduler.common.enums;
/**
* process define release state
*/
public enum ReleaseState {
/**
* 0 offline
* 1 on line
*/
OFFLINE(0, "offline"),
ONLINE(1, "online");
ReleaseState(int code, String descp){
this.code = code;
this.descp = descp;
}
private final int code;
private final String descp;
public static ReleaseState getEnum(int value){
for (ReleaseState e:ReleaseState.values()) {
if(e.ordinal() == value) {
return e;
}
}
//For values out of enum scope
return null;