Commit 591c3b52 by huangfusuper

脚本类数据

parent 82ecd236
...@@ -29,7 +29,7 @@ public enum NodeTypeEnum { ...@@ -29,7 +29,7 @@ public enum NodeTypeEnum {
return this.code; return this.code;
} }
public NodeTypeEnum getTypeByCode(String code){ public static NodeTypeEnum getTypeByCode(String code){
for (NodeTypeEnum typeEnum : NodeTypeEnum.values()) { for (NodeTypeEnum typeEnum : NodeTypeEnum.values()) {
if (typeEnum.getCode().equals(code)){ if (typeEnum.getCode().equals(code)){
return typeEnum; return typeEnum;
......
...@@ -79,7 +79,7 @@ public interface RunRecordingMapper { ...@@ -79,7 +79,7 @@ public interface RunRecordingMapper {
* @param runId * @param runId
* @return * @return
*/ */
RunRecording findAllByRunID(String runId); RunRecording findAllByRunIDAndFlowName(@Param("runId") String runId, @Param("flowName") String flowName);
/** /**
*根据运行标识查询对应的运行实例 *根据运行标识查询对应的运行实例
......
...@@ -75,7 +75,7 @@ public interface RunRecordingService { ...@@ -75,7 +75,7 @@ public interface RunRecordingService {
* @param runId * @param runId
* @return * @return
*/ */
RunRecording findAllByRunID(String runId); RunRecording findAllByRunIDAndFlowName(String runId,String flowName);
/** /**
* 根据工作流ID查询 是否有正在运行中的实例 * 根据工作流ID查询 是否有正在运行中的实例
......
...@@ -124,8 +124,8 @@ public class RunRecordingServiceImpl implements RunRecordingService { ...@@ -124,8 +124,8 @@ public class RunRecordingServiceImpl implements RunRecordingService {
} }
@Override @Override
public RunRecording findAllByRunID(String runId) { public RunRecording findAllByRunIDAndFlowName(String runId,String flowName) {
return runRecordingMapper.findAllByRunID(runId); return runRecordingMapper.findAllByRunIDAndFlowName(runId,flowName);
} }
/** /**
......
...@@ -238,7 +238,7 @@ public class RunRecordingAndJobTaskServiceImpl implements RunRecordingAndJobTask ...@@ -238,7 +238,7 @@ public class RunRecordingAndJobTaskServiceImpl implements RunRecordingAndJobTask
@Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED) @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
public void updateRunRecordingAndTask(WaitingRecord waitingRecord) { public void updateRunRecordingAndTask(WaitingRecord waitingRecord) {
log.debug("---------开始查询等待工作流{}对应的数据-------------",waitingRecord); log.debug("---------开始查询等待工作流{}对应的数据-------------",waitingRecord);
RunRecording runRecording = runRecordingService.findAllByRunID(waitingRecord.getRunId()); RunRecording runRecording = runRecordingService.findAllByRunIDAndFlowName(waitingRecord.getRunId(),waitingRecord.getFlowName());
log.info("-------修改运行实例表成功,查询对应等待实例{},的等待节点-------",waitingRecord); log.info("-------修改运行实例表成功,查询对应等待实例{},的等待节点-------",waitingRecord);
List<WaitingTask> allByWaitId = taskService.findAllByWaitId(waitingRecord.getWaitId()); List<WaitingTask> allByWaitId = taskService.findAllByWaitId(waitingRecord.getWaitId());
if(waitingRecord.getFlowNodeCount() != allByWaitId.size()){ if(waitingRecord.getFlowNodeCount() != allByWaitId.size()){
......
package com.byit.strategy;
import com.byit.model.JobTaskSchedule;
/**
* 任务执行生命周期
*
* @author huangfu
* @date 2020年12月14日18:24:11
*/
public interface TaskRunTheLifeCycleCallback {
/**
* 实例执行前
*
* @param jobTaskSchedule 任务对象
*/
default void postProcessAfterInitialization(JobTaskSchedule jobTaskSchedule) {
}
/**
* 后置处理器
*
* @param jobTaskSchedule 任务对象
*/
default void postProcessBeforeInitialization(JobTaskSchedule jobTaskSchedule) {
}
/**
* 判断是否匹配类型
*
* @param jobTaskSchedule 任务对象
* @return 是否匹配本次的执行对象
*/
boolean matchType(JobTaskSchedule jobTaskSchedule);
}
package com.byit.strategy.impl; package com.byit.strategy.instances;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.byit.annotations.MythRankOrder; import com.byit.annotations.MythRankOrder;
......
package com.byit.strategy.impl; package com.byit.strategy.instances;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.byit.annotations.MythRankOrder; import com.byit.annotations.MythRankOrder;
......
package com.byit.strategy.impl; package com.byit.strategy.instances;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
......
package com.byit.strategy.task;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.byit.annotations.MythRankOrder;
import com.byit.dto.executor.RunParamWrapped;
import com.byit.dto.executor.ScriptParamAndPlaceholderDto;
import com.byit.enums.NodeTypeEnum;
import com.byit.enums.PlaceholderEnum;
import com.byit.enums.ScheduleTypeEnum;
import com.byit.job.utils.PlaceholderUtils;
import com.byit.model.JobTaskSchedule;
import com.byit.strategy.TaskRunTheLifeCycleCallback;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* 脚本命令参数替换
*
* @author huangfu
* @date 2020年12月14日20:39:53
*/
@Component
@Slf4j
@MythRankOrder(10)
public class ScriptCommandTaskRunTheLifeCycleCallback implements TaskRunTheLifeCycleCallback {
public static final String JAVA_TYPE = "java";
/**
* 脚本类型的数据
*/
public static final String SCRIPT = "SCRIPT";
/**
* 任务执行前
*
* @param jobTaskSchedule 任务对象
*/
@Override
public void postProcessAfterInitialization(JobTaskSchedule jobTaskSchedule) {
String runParam = jobTaskSchedule.getRunParam();
RunParamWrapped runParamWrapped = JSON.parseObject(runParam, RunParamWrapped.class);
String privateParam = runParamWrapped.getPrivateParam();
ScriptParamAndPlaceholderDto scriptParamAndPlaceholderDto = JSON.parseObject(privateParam, ScriptParamAndPlaceholderDto.class);
String command = jobTaskSchedule.getRunCommand();
//脚本参数不为空的时候
if (scriptParamAndPlaceholderDto != null) {
Map<String, String> param = scriptParamAndPlaceholderDto.getParam();
if (CollectionUtil.isNotEmpty(param)) {
//将参数追加到命令上
command = PlaceholderUtils.commandReplace(command, param);
}
//补批的
if (ScheduleTypeEnum.REPAIR.getCode().equals(jobTaskSchedule.getScheduleType())) {
if (command.startsWith(JAVA_TYPE)) {
//去替换时间
command = PlaceholderUtils.commandDateReplace(param, command, param.get(PlaceholderEnum.DATE_PLACEHOLDER.getName()),
param.get(PlaceholderEnum.NOW_DATE_PLACEHOLDER.getName()));
}
}
jobTaskSchedule.setRunCommand(command);
}
}
/**
* 判断是否匹配类型
*
* @param jobTaskSchedule 任务对象
* @return 是否匹配本次的执行对象
*/
@Override
public boolean matchType(JobTaskSchedule jobTaskSchedule) {
String jobType = jobTaskSchedule.getJobType();
NodeTypeEnum typeByCode = NodeTypeEnum.getTypeByCode(jobType);
if (typeByCode == null) {
throw new RuntimeException(String.format("调度暂不支持此种类型的任务:%s", jobType));
}
return typeByCode.getType().equals(SCRIPT);
}
}
package com.byit.strategy.task;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.byit.annotations.MythRankOrder;
import com.byit.dto.executor.RunParamWrapped;
import com.byit.dto.executor.ScriptParamAndPlaceholderDto;
import com.byit.dto.plugin.FlowExtendedConfiguration;
import com.byit.enums.NodeTypeEnum;
import com.byit.model.JobTaskSchedule;
import com.byit.model.RunRecording;
import com.byit.service.RunRecordingService;
import com.byit.strategy.TaskRunTheLifeCycleCallback;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* 脚本参数合并 私有参数与共有参数合并
*
* @author huangfu
* @date 2020年12月14日19:43:30
*/
@Component
@Slf4j
@MythRankOrder(5)
public class ScriptParamMergeTaskRunTheLifeCycleCallback implements TaskRunTheLifeCycleCallback {
private final StringRedisTemplate stringRedisTemplate;
private final RunRecordingService runRecordingService;
/**
* 脚本类型的数据
*/
public static final String SCRIPT = "SCRIPT";
public ScriptParamMergeTaskRunTheLifeCycleCallback(StringRedisTemplate stringRedisTemplate, RunRecordingService runRecordingService) {
this.stringRedisTemplate = stringRedisTemplate;
this.runRecordingService = runRecordingService;
}
/**
* 实例执行前
*
* @param jobTaskSchedule 任务对象
*/
@Override
public void postProcessAfterInitialization(JobTaskSchedule jobTaskSchedule) {
String runId = jobTaskSchedule.getRunId();
String flowName = jobTaskSchedule.getFlowName();
RunRecording runRecording = runRecordingService.findAllByRunIDAndFlowName(runId, flowName);
String extendedConfiguration = runRecording.getExtendedConfiguration();
FlowExtendedConfiguration flowExtendedConfiguration = JSON.parseObject(extendedConfiguration, FlowExtendedConfiguration.class);
String publicParam = flowExtendedConfiguration.getPublicParam();
Map<String,String> publicMap = JSON.parseObject(publicParam, Map.class);
String runParam = jobTaskSchedule.getRunParam();
RunParamWrapped runParamWrapped = JSON.parseObject(runParam, RunParamWrapped.class);
if(runParamWrapped == null) {
runParamWrapped = new RunParamWrapped();
}
String privateParam = runParamWrapped.getPrivateParam();
Map<String, String> publicParamMap = runParamWrapped.getPublicParamMap();
publicParamMap.putAll(publicMap);
ScriptParamAndPlaceholderDto scriptParamAndPlaceholderDto = JSON.parseObject(privateParam, ScriptParamAndPlaceholderDto.class);
if(scriptParamAndPlaceholderDto == null) {
scriptParamAndPlaceholderDto = new ScriptParamAndPlaceholderDto();
}
//处理命令参数
Map<String, String> commandParam = scriptParamAndPlaceholderDto.getParam();
Map<String, String> placeholder = scriptParamAndPlaceholderDto.getPlaceholder();
if(CollectionUtil.isEmpty(commandParam)){
commandParam.putAll(publicMap);
}else{
publicMap.forEach((key,value) ->{
if (!commandParam.containsKey(key)) {
commandParam.put(key,value);
}
});
}
//处理替换参数
if(CollectionUtil.isEmpty(placeholder)){
placeholder.putAll(publicMap);
}else{
publicMap.forEach((key,value) ->{
if (!placeholder.containsKey(key)) {
placeholder.put(key,value);
}
});
}
//重新设置值
String privateParamNew = JSON.toJSONString(scriptParamAndPlaceholderDto);
runParamWrapped.setPrivateParam(privateParamNew);
runParamWrapped.setPublicParamMap(publicParamMap);
//设置运行参数
jobTaskSchedule.setRunParam(JSON.toJSONString(runParamWrapped));
}
/**
* 判断是否匹配类型
*
* @param jobTaskSchedule 任务对象
* @return 是否匹配本次的执行对象
*/
@Override
public boolean matchType(JobTaskSchedule jobTaskSchedule) {
String jobType = jobTaskSchedule.getJobType();
NodeTypeEnum typeByCode = NodeTypeEnum.getTypeByCode(jobType);
if (typeByCode == null) {
throw new RuntimeException(String.format("调度暂不支持此种类型的任务:%s", jobType));
}
return typeByCode.getType().equals(SCRIPT);
}
}
package com.byit.strategy.task;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.byit.annotations.MythRankOrder;
import com.byit.dto.executor.RunParamWrapped;
import com.byit.dto.executor.ScriptParamAndPlaceholderDto;
import com.byit.enums.NodeTypeEnum;
import com.byit.enums.PlaceholderEnum;
import com.byit.enums.ScheduleTypeEnum;
import com.byit.model.JobTaskSchedule;
import com.byit.strategy.TaskRunTheLifeCycleCallback;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 脚本执行的生命周期
* 脚本类型的任务特殊参数的替换
*
* @author huangfu
* @date 2020年12月14日18:28:08
*/
@Component
@Slf4j
@MythRankOrder(1)
public class ScriptSpecialParametersTaskRunTheLifeCycleCallback implements TaskRunTheLifeCycleCallback {
/**
* 脚本类型的数据
*/
public static final String SCRIPT = "SCRIPT";
public static final String DEFAULT_DATE_FORMAT = "yyyyMMdd";
/**
* 正常流程的情况下 进行特殊参数的替换
*
* @param jobTaskSchedule 任务对象
* @return 是否匹配
*/
@Override
public boolean matchType(JobTaskSchedule jobTaskSchedule) {
String jobType = jobTaskSchedule.getJobType();
NodeTypeEnum typeByCode = NodeTypeEnum.getTypeByCode(jobType);
if (typeByCode == null) {
throw new RuntimeException(String.format("调度暂不支持此种类型的任务:%s", jobType));
}
//是否是脚本类型的
boolean isScript = typeByCode.getType().equals(SCRIPT);
//是否是正常
boolean isNormal = ScheduleTypeEnum.NORMAL.getCode().equals(jobTaskSchedule.getScheduleType()) || ScheduleTypeEnum.REAL.getCode().equals(jobTaskSchedule.getScheduleType());
return isScript && isNormal;
}
/**
* 实例执行前 特殊参数的替换
*
* @param jobTaskSchedule 任务对象
* @return 两者的包装对象
*/
@Override
public void postProcessAfterInitialization(JobTaskSchedule jobTaskSchedule) {
String runParam = jobTaskSchedule.getRunParam();
//转换参数对象为参数包装体
RunParamWrapped runParamWrapped = JSON.parseObject(runParam, RunParamWrapped.class);
if (runParamWrapped == null) {
runParamWrapped = new RunParamWrapped();
}
String privateParam = runParamWrapped.getPrivateParam();
//处理私有参数
ScriptParamAndPlaceholderDto scriptParamAndPlaceholderDto = JSON.parseObject(privateParam, ScriptParamAndPlaceholderDto.class);
if (scriptParamAndPlaceholderDto == null) {
scriptParamAndPlaceholderDto = new ScriptParamAndPlaceholderDto();
}
//获取替换参数
Map<String, String> placeholder = scriptParamAndPlaceholderDto.getPlaceholder();
//获取命令参数
Map<String, String> commandParam = scriptParamAndPlaceholderDto.getParam();
//向前偏移一天
DateTime dateTime = DateUtil.offset(new Date(), DateField.HOUR_OF_DAY, -1);
//替换参数
if (CollectionUtil.isEmpty(placeholder)) {
placeholder = new HashMap<>(2);
//替换 biz_date
placeholder.put(PlaceholderEnum.DATE_PLACEHOLDER.getName(), DateUtil.format(dateTime, DEFAULT_DATE_FORMAT));
//替换 now_date
placeholder.put(PlaceholderEnum.NOW_DATE_PLACEHOLDER.getName(), DateUtil.format(new Date(), DEFAULT_DATE_FORMAT));
} else {
//替换 biz_date
String bizDateFormat = placeholder.get(PlaceholderEnum.DATE_PLACEHOLDER.getName());
if (StringUtils.isBlank(bizDateFormat)) {
bizDateFormat = DEFAULT_DATE_FORMAT;
}
placeholder.put(PlaceholderEnum.DATE_PLACEHOLDER.getName(), DateUtil.format(dateTime, bizDateFormat));
//替换 now_date
String nowDateFormat = placeholder.get(PlaceholderEnum.NOW_DATE_PLACEHOLDER.getName());
if (StringUtils.isBlank(nowDateFormat)) {
nowDateFormat = DEFAULT_DATE_FORMAT;
}
placeholder.put(PlaceholderEnum.NOW_DATE_PLACEHOLDER.getName(), DateUtil.format(new Date(), nowDateFormat));
}
//命令参数
if (CollectionUtil.isEmpty(commandParam)) {
commandParam = new HashMap<>(4);
//替换 biz_date
commandParam.put(PlaceholderEnum.DATE_PLACEHOLDER.getName(), DateUtil.format(dateTime, DEFAULT_DATE_FORMAT));
//替换 now_date
commandParam.put(PlaceholderEnum.NOW_DATE_PLACEHOLDER.getName(), DateUtil.format(new Date(), DEFAULT_DATE_FORMAT));
} else {
//替换 biz_date
String bizDateFormat = placeholder.get(PlaceholderEnum.DATE_PLACEHOLDER.getName());
if (StringUtils.isBlank(bizDateFormat)) {
bizDateFormat = DEFAULT_DATE_FORMAT;
}
commandParam.put(PlaceholderEnum.DATE_PLACEHOLDER.getName(), DateUtil.format(dateTime, bizDateFormat));
//替换 now_date
String nowDateFormat = placeholder.get(PlaceholderEnum.NOW_DATE_PLACEHOLDER.getName());
if (StringUtils.isBlank(nowDateFormat)) {
nowDateFormat = DEFAULT_DATE_FORMAT;
}
commandParam.put(PlaceholderEnum.NOW_DATE_PLACEHOLDER.getName(), DateUtil.format(new Date(), nowDateFormat));
}
scriptParamAndPlaceholderDto.setPlaceholder(placeholder);
scriptParamAndPlaceholderDto.setParam(commandParam);
//重新设置参数
runParamWrapped.setPrivateParam(JSON.toJSONString(scriptParamAndPlaceholderDto));
jobTaskSchedule.setRunParam(JSON.toJSONString(runParamWrapped));
}
}
...@@ -3,6 +3,7 @@ package com.byit.task; ...@@ -3,6 +3,7 @@ package com.byit.task;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.byit.conf.MythJobAutoConfigure; import com.byit.conf.MythJobAutoConfigure;
import com.byit.dto.BeanStrategyPackage;
import com.byit.dto.executor.DispatchResponseDto; import com.byit.dto.executor.DispatchResponseDto;
import com.byit.dto.executor.RunParamWrapped; import com.byit.dto.executor.RunParamWrapped;
import com.byit.dto.executor.ScriptDto; import com.byit.dto.executor.ScriptDto;
...@@ -22,6 +23,8 @@ import com.byit.service.FastRunLogService; ...@@ -22,6 +23,8 @@ import com.byit.service.FastRunLogService;
import com.byit.service.FlowStatusService; import com.byit.service.FlowStatusService;
import com.byit.service.RunScriptService; import com.byit.service.RunScriptService;
import com.byit.service.impl.JobTaskRunLogServiceImpl; import com.byit.service.impl.JobTaskRunLogServiceImpl;
import com.byit.strategy.TaskRunTheLifeCycleCallback;
import com.byit.util.ClassSortUtil;
import com.byit.util.GetRegConfig; import com.byit.util.GetRegConfig;
import com.byit.util.SpringUtil; import com.byit.util.SpringUtil;
import io.netty.util.Timeout; import io.netty.util.Timeout;
...@@ -50,7 +53,7 @@ public class ScriptExecutorJobTask implements TimerTask { ...@@ -50,7 +53,7 @@ public class ScriptExecutorJobTask implements TimerTask {
private static final Integer INIT_SLEEP_TIME = 100; private static final Integer INIT_SLEEP_TIME = 100;
public static final String JAVA_TYPE = "java"; public static final String JAVA_TYPE = "java";
private JobTaskSchedule mythJobTaskSchedule; private final JobTaskSchedule mythJobTaskSchedule;
public ScriptExecutorJobTask(JobTaskSchedule mythJobTaskSchedule) { public ScriptExecutorJobTask(JobTaskSchedule mythJobTaskSchedule) {
this.mythJobTaskSchedule = mythJobTaskSchedule; this.mythJobTaskSchedule = mythJobTaskSchedule;
...@@ -91,75 +94,6 @@ public class ScriptExecutorJobTask implements TimerTask { ...@@ -91,75 +94,6 @@ public class ScriptExecutorJobTask implements TimerTask {
return bean.checkFlowStatusIsKill(flowId, runId); return bean.checkFlowStatusIsKill(flowId, runId);
} }
private void paramBuild(JobTaskSchedule mythJobTaskSchedule) {
//获取参数
String runParam = mythJobTaskSchedule.getRunParam();
//获取命令
String command = mythJobTaskSchedule.getRunCommand();
command = PlaceholderUtils.formatJavaJarCommand(command);
if (!command.startsWith(JAVA_TYPE)) {
command = command.replaceAll(" ","&&");
}
//转换参数对象为参数包装体
RunParamWrapped runParamWrapped = JSON.parseObject(runParam, RunParamWrapped.class);
//当参数包装体不为空时 证明存在参数 或私有或公有
if (runParamWrapped != null) {
//获取到私有参数
String privateParam = runParamWrapped.getPrivateParam();
//替换运行参数中的时间参数 当为正常运行或者立即执行的时候
if (ScheduleTypeEnum.NORMAL.getCode().equals(mythJobTaskSchedule.getScheduleType())
|| ScheduleTypeEnum.REAL.getCode().equals(mythJobTaskSchedule.getScheduleType())) {
privateParam = PlaceholderUtils.formatBizDateParam(privateParam, PlaceholderEnum.DATE_PLACEHOLDER.getName(), 1);
if (StringUtils.isNoneBlank(privateParam)) {
ScriptParamAndPlaceholderDto scriptParamAndPlaceholderDto = JSON.parseObject(privateParam, ScriptParamAndPlaceholderDto.class);
Map<String, String> placeholder = scriptParamAndPlaceholderDto.getPlaceholder();
if (CollectionUtil.isNotEmpty(placeholder)) {
if (placeholder.containsKey(PlaceholderEnum.NOW_DATE_PLACEHOLDER.getName())) {
String nowDateFormatName = placeholder.get(PlaceholderEnum.NOW_DATE_PLACEHOLDER.getName());
String dateFormat = DateUtil.dateFormat(new Date(), nowDateFormatName);
privateParam = PlaceholderUtils.formatBizDateParam(privateParam, PlaceholderEnum.NOW_DATE_PLACEHOLDER.getName(), dateFormat, 0);
}
}
runParamWrapped.setPrivateParam(privateParam);
mythJobTaskSchedule.setRunParam(JSON.toJSONString(runParamWrapped));
}
}
//获取到公有参数
Map<String, String> publicParam = runParamWrapped.getPublicParamMap();
//将私有参数转换为对应的参数DTO
ScriptParamAndPlaceholderDto scriptParamAndPlaceholderDto = null;
if (StringUtils.isNoneBlank(privateParam)) {
scriptParamAndPlaceholderDto = JSON.parseObject(privateParam, ScriptParamAndPlaceholderDto.class);
}
//脚本参数不为空的时候
if (scriptParamAndPlaceholderDto != null) {
Map<String, String> param = scriptParamAndPlaceholderDto.getParam();
if (CollectionUtil.isNotEmpty(param)) {
command = PlaceholderUtils.commandReplace(command, param);
}
if (ScheduleTypeEnum.REPAIR.getCode().equals(mythJobTaskSchedule.getScheduleType())) {
if (command.startsWith(JAVA_TYPE)) {
if (ScheduleTypeEnum.REPAIR.getCode().equals(mythJobTaskSchedule.getScheduleType())) {
command = PlaceholderUtils.commandDateReplace(param, command, param.get(PlaceholderEnum.DATE_PLACEHOLDER.getName()),
param.get(PlaceholderEnum.NOW_DATE_PLACEHOLDER.getName()));
} else {
command = PlaceholderUtils.commandDateReplace(param, command);
}
}
}
}
//公共参数不为空的时候
if (CollectionUtil.isNotEmpty(publicParam)) {
command = PlaceholderUtils.commandReplace(command, publicParam);
}
mythJobTaskSchedule.setRunCommand(command);
}
}
/** /**
* 运行任务 * 运行任务
* *
...@@ -169,7 +103,17 @@ public class ScriptExecutorJobTask implements TimerTask { ...@@ -169,7 +103,17 @@ public class ScriptExecutorJobTask implements TimerTask {
DispatchResponseDto dispatchResponseDto = new DispatchResponseDto(); DispatchResponseDto dispatchResponseDto = new DispatchResponseDto();
String uploadFilePath = null; String uploadFilePath = null;
try { try {
paramBuild(mythJobTaskSchedule); //获取该节点的全部声明周期函数
Map<String, TaskRunTheLifeCycleCallback> stringTaskRunTheLifeCycleCallbackMap = SpringUtil.getBeansOfType(TaskRunTheLifeCycleCallback.class);
//数据排序
List<BeanStrategyPackage<TaskRunTheLifeCycleCallback>> beanStrategyPackages = ClassSortUtil.objectSort(stringTaskRunTheLifeCycleCallbackMap);
beanStrategyPackages.forEach(beanStrategyPackage ->{
log.info("--------------脚本节点生命周期开始回调{}--------------",beanStrategyPackage.getBeanName());
TaskRunTheLifeCycleCallback beanStrategyPackageBean = beanStrategyPackage.getBean();
if (beanStrategyPackageBean.matchType(this.mythJobTaskSchedule)) {
beanStrategyPackageBean.postProcessAfterInitialization(this.mythJobTaskSchedule);
}
});
mythJobTaskSchedule.setRunCommand(mythJobTaskSchedule.getRunCommand()); mythJobTaskSchedule.setRunCommand(mythJobTaskSchedule.getRunCommand());
RunScriptService runScriptService = SpringUtil.getBean(RunScriptService.class); RunScriptService runScriptService = SpringUtil.getBean(RunScriptService.class);
JobTaskRunLogServiceImpl jobTaskRunLogService = SpringUtil.getBean(JobTaskRunLogServiceImpl.class); JobTaskRunLogServiceImpl jobTaskRunLogService = SpringUtil.getBean(JobTaskRunLogServiceImpl.class);
......
...@@ -131,11 +131,11 @@ ...@@ -131,11 +131,11 @@
where flow_status ='4' and is_alarm = '1' and schedule_type != 4 where flow_status ='4' and is_alarm = '1' and schedule_type != 4
</select> </select>
<!--and is_inner = '1'--> <!--and is_inner = '1'-->
<select id="findAllByRunID" resultMap="BaseResultMap"> <select id="findAllByRunIDAndFlowName" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from run_recording from run_recording
where run_id=#{runId,jdbcType=VARCHAR} and schedule_type != 4 where run_id=#{runId,jdbcType=VARCHAR} and schedule_type != 4 and flow_name=#{flowName}
</select> </select>
<select id="findByRunID" resultMap="BaseResultMap"> <select id="findByRunID" resultMap="BaseResultMap">
......
...@@ -20,11 +20,11 @@ public class ScriptParamAndPlaceholderDto implements Serializable { ...@@ -20,11 +20,11 @@ public class ScriptParamAndPlaceholderDto implements Serializable {
/** /**
* 参数的处理 命令参数 * 参数的处理 命令参数
*/ */
private Map<String,String> param; private Map<String,String> param = new HashMap<>(8);
/** /**
* 占位符的处理 * 占位符的处理
*/ */
private Map<String,String> Placeholder; private Map<String,String> Placeholder = new HashMap<>(8);
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment