use of com.dtstack.taier.develop.dto.devlop.BatchParamDTO in project Taier by DTStack.
the class BatchJobService method startSqlImmediately.
/**
* 运行SQL任务
* @param userId
* @param tenantId
* @param taskId
* @param uniqueKey
* @param sql
* @param taskVariables
* @param dtToken
* @param isCheckDDL
* @param isRoot
* @param isEnd 是否是当前session最后一条sql
* @return
*/
public ExecuteResultVO startSqlImmediately(Long userId, Long tenantId, Long taskId, String uniqueKey, String sql, List<Map> taskVariables, String dtToken, Integer isCheckDDL, Boolean isRoot, Boolean isEnd) {
final User user = userService.getById(userId);
dtToken = String.format("%s;dt_user_id=%s;dt_username=%s;", dtToken, user.getId(), user.getUserName());
ExecuteResultVO result = new ExecuteResultVO();
try {
final BatchTask task = batchTaskService.getOneWithError(taskId);
result.setTaskType(task.getTaskType());
// 真正运行的SQL是页面传入的SQL
task.setSqlText(sql);
// 将SQL中的 系统参数和自定义参数 转换为DTO对象
List<BatchParamDTO> batchParamDTOS = this.batchTaskParamService.paramResolver(taskVariables);
final List<BatchTaskParam> params = this.batchTaskParamService.convertParam(batchParamDTOS);
List<BatchTaskParamShade> taskParamsToReplace = this.batchTaskParamService.convertShade(params);
ParamTaskAction paramTaskAction = getParamTaskAction(task, userId, taskParamsToReplace);
ParamActionExt paramActionExt = actionService.paramActionExt(paramTaskAction.getBatchTask(), paramTaskAction.getJobId(), paramTaskAction.getFlowJobId());
sql = paramActionExt.getSqlText();
String jobId = paramActionExt.getJobId();
task.setTaskParams(paramActionExt.getTaskParams());
IBatchJobExeService batchJobService = this.multiEngineServiceFactory.getBatchJobExeService(task.getTaskType());
result = batchJobService.startSqlImmediately(userId, tenantId, uniqueKey, taskId, sql, isRoot, task, dtToken, isEnd, jobId);
} catch (Exception e) {
LOGGER.warn("startSqlImmediately-->", e);
result.setMsg(e.getMessage());
result.setStatus(TaskStatus.FAILED.getStatus());
result.setSqlText(sql);
return result;
}
return result;
}
use of com.dtstack.taier.develop.dto.devlop.BatchParamDTO in project Taier by DTStack.
the class BatchTaskParamService method buildBatchTaskParams.
public List<BatchTaskParam> buildBatchTaskParams(final long taskId, final List<BatchParamDTO> batchParamDTOS) {
final List<BatchTaskParam> saves = new ArrayList<>(batchParamDTOS.size());
for (final BatchParamDTO tmp : batchParamDTOS) {
if (StringUtils.isBlank(tmp.getParamCommand())) {
throw new RdosDefineException("自定义参数赋值不能为空");
}
BatchTaskParam batchTaskParam = new BatchTaskParam();
batchTaskParam.setTaskId(taskId);
batchTaskParam.setType(tmp.getType());
batchTaskParam.setParamName(tmp.getParamName());
batchTaskParam.setParamCommand(tmp.getParamCommand());
saves.add(this.addOrUpdate(batchTaskParam));
}
return saves;
}
use of com.dtstack.taier.develop.dto.devlop.BatchParamDTO in project Taier by DTStack.
the class BatchTaskParamService method paramResolver.
/**
* 转换SQL任务中的 自定义参数 和 系统参数 为参数对象
* @param taskVariables
* @return
*/
public List<BatchParamDTO> paramResolver(final List<Map> taskVariables) {
if (CollectionUtils.isEmpty(taskVariables)) {
return Collections.emptyList();
}
final List<BatchParamDTO> parameters = new ArrayList<>(taskVariables.size());
for (Map<String, Object> var : taskVariables) {
final BatchParamDTO batchParamDTO = new BatchParamDTO(MathUtil.getIntegerVal(var.get("type")), MathUtil.getString(var.get("paramName")), MathUtil.getString(var.get("paramCommand")));
parameters.add(batchParamDTO);
}
return parameters;
}
Aggregations