Commit 984611e0 by huangfusuper

Merge remote-tracking branch 'origin/developer' into developer

parents 818a7e1e 2abfbe8b
......@@ -7,7 +7,7 @@ import com.byit.dto.plugin.*;
import com.byit.enums.DagCheckEnum;
import com.byit.enums.FlowPropertyEnum;
import com.byit.enums.NodePropertyEnum;
import com.byit.enums.ScheduleEnum;
import com.byit.enums.ScheduleTypeEnum;
import com.byit.enums.plugin.PluginNodeTypeEnum;
import com.byit.job.utils.CronExpression;
import com.byit.job.utils.CurrentUserUtils;
......@@ -44,7 +44,6 @@ import static com.alibaba.fastjson.serializer.SerializerFeature.WriteClassName;
@Transactional(rollbackFor = Exception.class)
public class ApiFlowServiceImpl implements ApiFlowService {
private final static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
private final static SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Resource
private FlowMapper flowMapper;
......@@ -479,15 +478,14 @@ public class ApiFlowServiceImpl implements ApiFlowService {
//获取当前时间
String reRunId = UUID.randomUUID().toString().replace("-","");
Long triggerTime = System.currentTimeMillis();
List<JobTask> jobTaskList = new ArrayList<>();
JobTask jobTask = new JobTask();
BeanUtils.copyProperties(node, jobTask);
BeanUtils.copyProperties(jobTaskRunLog, jobTask);
jobTask.setTriggerTime(triggerTime);
jobTask.setTriggerStatus("1");
jobTask.setRunId(reRunId);
jobTask.setReRunId(jobTaskRunLog.getRunId());
//设置为重跑
jobTask.setScheduleType(ScheduleEnum.REPEAT.getCode());
jobTask.setScheduleType(ScheduleTypeEnum.REPEAT.getCode());
jobTask.setOperator(userName);
//查询当前节点的依赖节点
......@@ -496,6 +494,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
jobTask.setNodeDepend(Joiner.on(",").join(dependNodeIdList));
}
List<JobTask> jobTaskList = new ArrayList<>();
jobTaskList.add(jobTask);
//校验通过,开始设置重跑
......@@ -509,7 +508,6 @@ public class ApiFlowServiceImpl implements ApiFlowService {
}
jobTaskMapper.saveJobTasks(jobTaskList);
}
......@@ -536,28 +534,30 @@ public class ApiFlowServiceImpl implements ApiFlowService {
if (FlowPropertyEnum.IS_INNER.getCode().equals(flow.getIsInner())){//是内嵌工作流
Node node = nodeMapper.getByMapFlowId(flow.getFlowId());
RunInfo nodeRun = RunInfo.builder().workspaceName(runInfo.getWorkspaceName()).flowName(runInfo.getFlowName())
.nodeName(runInfo.getNodeName()).runId(runInfo.getRunId()).runState("1").build();
.nodeName(node.getNodeName()).runId(runInfo.getRunId()).runState("1").build();
reRunJob(JSON.toJSONString(nodeRun, WriteClassName));
}else {
//不是内嵌工作流
Long triggerTime = System.currentTimeMillis();
String reRunId = UUID.randomUUID().toString().replace("-","");
List<JobTask> jobTaskList = new ArrayList<>();
List<Node> nodeList = nodeMapper.findOnforkByFlowId(flow.getFlowId());
ValidationUtil.dataNotNull(nodeList, "该工作流没有在调度上的任务");
List<JobTaskRunLogWithBLOBs> jobTaskRunLogList = jobTaskRunLogMapper.findJobTaskRunLogWithBLOBsByFlowIdAndRunId(flow.getFlowId(), runInfo.getRunId());
ValidationUtil.dataNotNull(jobTaskRunLogList, "该工作流没有在调度上的任务");
String userName = currentUserUtils.account();
nodeList.forEach(node -> {
jobTaskRunLogList.forEach(jobTaskRunLog -> {
JobTask jobTask = new JobTask();
BeanUtils.copyProperties(node, jobTask);
BeanUtils.copyProperties(jobTaskRunLog, jobTask);
jobTask.setTriggerTime(triggerTime);
jobTask.setTriggerStatus("1");
jobTask.setRunId(reRunId);
jobTask.setReRunId(runInfo.getRunId());
//设置为重跑
jobTask.setScheduleType(ScheduleEnum.REPEAT.getCode());
jobTask.setScheduleType(ScheduleTypeEnum.REPEAT.getCode());
jobTask.setOperator(userName);
//查询当前节点的依赖节点
List<Integer> dependNodeIdList = nodeDependencyMapper.findDependIdByNodeId(node.getNodeId());
List<Integer> dependNodeIdList = nodeDependencyMapper.findDependIdByNodeId(jobTaskRunLog.getNodeId());
if (dependNodeIdList != null && dependNodeIdList.size() > 0){
jobTask.setNodeDepend(Joiner.on(",").join(dependNodeIdList));
}
......@@ -569,19 +569,19 @@ public class ApiFlowServiceImpl implements ApiFlowService {
private void addDependNode(String reRunId, String runId, Long triggerTime, List<JobTask> jobTaskList, List<Integer> subNodeIdList, String userName) {
subNodeIdList.forEach(childNodeId -> {
Node subNode = nodeMapper.getById(childNodeId);
JobTaskRunLog jobTaskRunLog = jobTaskRunLogMapper.findByRunIdAndNodeId(runId, childNodeId);
JobTask jobTask = new JobTask();
BeanUtils.copyProperties(subNode, jobTask);
BeanUtils.copyProperties(jobTaskRunLog, jobTask);
jobTask.setTriggerTime(triggerTime);
jobTask.setTriggerStatus("1");
jobTask.setRunId(reRunId);
jobTask.setReRunId(runId);
//设置为重跑
jobTask.setScheduleType(ScheduleEnum.REPEAT.getCode());
jobTask.setScheduleType(ScheduleTypeEnum.REPEAT.getCode());
jobTask.setOperator(userName);
//查询当前节点的依赖节点
List<Integer> dependNodeIdList = nodeDependencyMapper.findDependIdByNodeId(subNode.getNodeId());
List<Integer> dependNodeIdList = nodeDependencyMapper.findDependIdByNodeId(jobTaskRunLog.getNodeId());
if (dependNodeIdList != null && dependNodeIdList.size() > 0){
jobTask.setNodeDepend(Joiner.on(",").join(dependNodeIdList));
}
......@@ -668,9 +668,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
if(StringUtils.isNotEmpty(executeStatus)){
executeStatusList = Arrays.asList(executeStatus.split(","));
}
String startDate = dateTimeFormat.format(new Date(startTime));
String endDate = dateTimeFormat.format(new Date(endTime));
List<RunRecording> runRecordList = runRecordingMapper.findByStartAndEndTime(startDate, endDate, flowIds, scheduleStatusList, executeStatusList);
List<RunRecording> runRecordList = runRecordingMapper.findByStartAndEndTime(new Date(startTime), new Date(endTime), flowIds, scheduleStatusList, executeStatusList);
return runRecordList;
}
......@@ -725,7 +723,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
if (null != unstartflowStatisticData){
flowStatisticData.setUnstart(flowStatisticData.getUnstart() + unstartflowStatisticData.getUnstart());
}
StatisticData nodeStatisticData = jobTaskRunLogMapper.findStatusByStartAndEndTime(startTime, endTime, flowIdList);
StatisticData nodeStatisticData = jobTaskRunLogMapper.findStatusByStartAndEndTime(new Date(startTime), new Date(endTime), flowIdList);
StatisticData unstartNodeStatisticData = waitingTaskMapper.findStatusByStartAndEndTime(flowIdList);
if (null != unstartNodeStatisticData){
nodeStatisticData.setUnstart(nodeStatisticData.getUnstart() + unstartNodeStatisticData.getUnstart());
......@@ -823,7 +821,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
}
}
StatisticData nodeStatisticData = jobTaskRunLogMapper.findStatusByStartAndEndTime(startTime, endTime, flowIdList);
StatisticData nodeStatisticData = jobTaskRunLogMapper.findStatusByStartAndEndTime(new Date(startTime), new Date(endTime), flowIdList);
StatisticData unstartNodeStatisticData = waitingTaskMapper.findStatusByStartAndEndTime(flowIdList);
if (null != unstartNodeStatisticData){
nodeStatisticData.setUnstart(nodeStatisticData.getUnstart() + unstartNodeStatisticData.getUnstart());
......@@ -938,7 +936,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
waitingRecord.setRunId(runId);
waitingRecord.setFlowNodeCount(nodeList.size());
waitingRecord.setOperator(userName);
waitingRecord.setScheduleType(ScheduleEnum.REPAIR.getCode());
waitingRecord.setScheduleType(ScheduleTypeEnum.REPAIR.getCode());
waitingRecord.setWaitOrder(++order);
//设置实例
BeanUtils.copyProperties(waitingRecord, runRecording);
......@@ -976,7 +974,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
waitingTask.setNodeDepend(Joiner.on(",").join(dependNodeNameList));
}
waitingTask.setOperator(usernName);
waitingTask.setScheduleType(ScheduleEnum.REPAIR.getCode());
waitingTask.setScheduleType(ScheduleTypeEnum.REPAIR.getCode());
waitingTaskList.add(waitingTask);
});
......
......@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.byit.dto.plugin.RunLog;
import com.byit.dto.plugin.RunNode;
import com.byit.enums.NodePropertyEnum;
import com.byit.enums.ScheduleEnum;
import com.byit.enums.ScheduleTypeEnum;
import com.byit.job.WorkRoulette;
import com.byit.job.utils.PlaceholderUtils;
import com.byit.mapper.JobTaskRunLogMapper;
......@@ -63,7 +63,7 @@ public class ApiNodeServiceImpl implements ApiNodeService {
schedule.setScriptUrls(runNode.getScriptUrl());
schedule.setJobType(runNode.getJobType());
schedule.setTriggerTime(triggerTime);
schedule.setScheduleType(ScheduleEnum.REAL.getCode());
schedule.setScheduleType(ScheduleTypeEnum.REAL.getCode());
schedule.setRunParam(PlaceholderUtils.formatParam(schedule.getRunParam()));
......
......@@ -5,7 +5,7 @@ package com.byit.enums;
* @author: gml
* @create: 2020/3/9
*/
public enum ScheduleEnum {
public enum ScheduleTypeEnum {
NORMAL(1, "正常跑批"),
REPEAT(2, "重跑"),
......@@ -16,7 +16,7 @@ public enum ScheduleEnum {
private Integer code;
private String msg;
private ScheduleEnum(Integer code, String msg){
private ScheduleTypeEnum(Integer code, String msg){
this.code = code;
this.msg = msg;
}
......
......@@ -6,6 +6,7 @@ import com.byit.model.JobTaskRunLogWithBLOBs;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
/**
......@@ -119,8 +120,8 @@ public interface JobTaskRunLogMapper {
* @param flowIdList
* @return
*/
StatisticData findStatusByStartAndEndTime(@Param("startTime")Long startTime,
@Param("endTime")Long endTime,
StatisticData findStatusByStartAndEndTime(@Param("startTime")Date startTime,
@Param("endTime")Date endTime,
@Param("flowIdList")List<Integer> flowIdList);
StatisticData findStatisticDataByRunIdAndFlowId(@Param("runId")String runId, @Param("flowId")Integer flowId);
......
......@@ -139,8 +139,8 @@ public interface RunRecordingMapper {
*/
List<RunRecording> findUnFinishByRunId(String runId);
List<RunRecording> findByStartAndEndTime(@Param("startDate")String startDate,
@Param("endDate")String endDate,
List<RunRecording> findByStartAndEndTime(@Param("startDate")Date startDate,
@Param("endDate")Date endDate,
@Param("flowIds")List<Integer> flowIds,
@Param("scheduleStatusList")List<String> scheduleStatusList,
@Param("executeStatusList")List<String> executeStatusList);
......
......@@ -150,6 +150,11 @@ public class RunRecording implements Serializable {
@ApiModelProperty("重跑和补批的操作人")
private String operator;
/**
* 重跑的运行标识
*/
@ApiModelProperty("重跑的运行标识")
private String reRunId;
/**
*/
......
......@@ -202,8 +202,8 @@
select
<include refid="Base_Column_List" />
from flow_status_snapshoot
where snapshoot_time &gt;= ${startDate}
and snapshoot_time &lt;= ${endDate}
where snapshoot_time &gt;= #{startDate}
and snapshoot_time &lt;= #{endDate}
</select>
<delete id="deleteOutSnapShoot" parameterType="java.lang.Long">
delete from flow_status_snapshoot
......
......@@ -179,6 +179,9 @@
<if test="operator != null">
operator,
</if>
<if test="scheduleType != null">
schedule_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
......@@ -283,6 +286,9 @@
<if test="operator != null">
#{operator,jdbcType=VARCHAR},
</if>
<if test="scheduleType != null">
#{scheduleType,jdbcType=INTEGER},
</if>
</trim>
</insert>
......@@ -292,7 +298,7 @@
job_type, handler_name, node_desc, node_name, map_flow_id, node_timeout, is_virtual,
plugin_urls, priority, failed_retry_interval, routing_strategy, run_id, run_param,
run_source_desc, script_urls, source_principal, trigger_time, trigger_status, version_name,
run_command,run_source,flow_name,super_success_run, re_run_id ,log_id, node_depend, operator
run_command,run_source,flow_name,super_success_run, re_run_id ,log_id, node_depend, operator, schedule_type
) values
<foreach collection="jobTasks" item="jobTask" separator =",">
(
......@@ -305,7 +311,7 @@
#{jobTask.sourcePrincipal,jdbcType=VARCHAR},#{jobTask.triggerTime,jdbcType=BIGINT},#{jobTask.triggerStatus,jdbcType=CHAR},
#{jobTask.versionName,jdbcType=VARCHAR},#{jobTask.runCommand,jdbcType=VARCHAR},#{jobTask.runSource,jdbcType=LONGVARCHAR},
#{jobTask.flowName,jdbcType=VARCHAR},#{jobTask.superSuccessRun,jdbcType=CHAR},#{jobTask.reRunId,jdbcType=VARCHAR},
#{jobTask.logId,jdbcType=INTEGER},#{jobTask.nodeDepend,jdbcType=VARCHAR},#{jobTask.operator,jdbcType=VARCHAR}
#{jobTask.logId,jdbcType=INTEGER},#{jobTask.nodeDepend,jdbcType=VARCHAR},#{jobTask.operator,jdbcType=VARCHAR}, #{scheduleType,jdbcType=INTEGER},
)
</foreach>
......@@ -414,6 +420,9 @@
<if test="operator != null">
operator = #{operator,jdbcType=VARCHAR},
</if>
<if test="scheduleType != null">
schedule_type = #{scheduleType,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
......
......@@ -32,6 +32,7 @@
<result column="log_remotely_path" jdbcType="VARCHAR" property="logRemotelyPath"/>
<result column="node_depend" jdbcType="VARCHAR" property="nodeDepend"/>
<result column="operator" jdbcType="VARCHAR" property="operator"/>
<result column="schedule_type" jdbcType="INTEGER" property="scheduleType"/>
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.byit.model.JobTaskRunLogWithBLOBs">
<result column="run_msg" jdbcType="LONGVARCHAR" property="runMsg" />
......@@ -41,7 +42,7 @@
log_id, failed_remaining_count, version_name, flow_id, flow_name, job_group_id, handler_name,
node_name, is_virtual, run_code, run_params, start_time, run_type, trigger_code,
trigger_time, job_group_ip, map_flow_id, run_command, end_time, node_id,job_type,alert_end,run_id,re_run_id
,log_file_name, super_success_run, run_count, log_remotely_path, node_depend, operator
,log_file_name, super_success_run, run_count, log_remotely_path, node_depend, operator, schedule_type
</sql>
<sql id="Blob_Column_List">
run_msg, trigger_msg
......@@ -127,8 +128,8 @@
sum(case when run_code = '2' or run_code = '4' or run_code = '6' then 1 else 0 end) as fail,
sum(case when run_code = '5' then 1 else 0 end) as 'kill'
from job_task_run_log
where start_time &gt;= ${startDate}
and end_time &lt;= ${endDate}
where start_time &gt;= #{startDate}
and end_time &lt;= #{endDate}
<if test="flowIdList != null">
and flow_id in (
<foreach collection="flowIdList" item="flowId" separator=",">
......@@ -251,6 +252,9 @@
<if test="operator != null">
operator,
</if>
<if test="scheduleType != null">
schedule_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="logId != null">
......@@ -349,6 +353,9 @@
<if test="operator != null">
#{operator,jdbcType=VARCHAR},
</if>
<if test="scheduleType != null">
#{scheduleType,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateJobTaskRunLogWithBLOBs" parameterType="com.byit.model.JobTaskRunLogWithBLOBs">
......@@ -447,6 +454,9 @@
<if test="operator != null">
operator = #{operator,jdbcType=VARCHAR},
</if>
<if test="scheduleType != null">
schedule_type = #{scheduleType,jdbcType=INTEGER},
</if>
</set>
where log_id = #{logId,jdbcType=INTEGER}
</update>
......@@ -540,6 +550,9 @@
<if test="operator != null">
operator = #{operator,jdbcType=VARCHAR},
</if>
<if test="scheduleType != null">
schedule_type = #{scheduleType,jdbcType=INTEGER},
</if>
</set>
where log_id = #{logId,jdbcType=INTEGER}
</update>
......
......@@ -36,6 +36,7 @@
<result column="re_run_id" jdbcType="VARCHAR" property="reRunId"/>
<result column="node_depend" jdbcType="VARCHAR" property="nodeDepend"/>
<result column="operator" jdbcType="VARCHAR" property="operator"/>
<result column="schedule_type" jdbcType="INTEGER" property="scheduleType"/>
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.byit.model.JobTaskSchedule">
......@@ -47,7 +48,7 @@
job_type, handler_name, node_desc, node_name, map_flow_id, node_timeout, is_virtual,
plugin_urls, priority, failed_retry_interval, routing_strategy, run_id, run_param,
run_source_desc, script_urls, source_principal, trigger_time, trigger_status, version_name,
log_id, run_command,flow_name, super_success_run, re_run_id, node_depend, operator
log_id, run_command,flow_name, super_success_run, re_run_id, node_depend, operator, schedule_type
</sql>
<sql id="Blob_Column_List">
run_source
......@@ -182,6 +183,9 @@
<if test="operator != null">
operator,
</if>
<if test="scheduleType != null">
schedule_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
......@@ -286,6 +290,9 @@
<if test="operator != null">
#{operator,jdbcType=VARCHAR},
</if>
<if test="scheduleType != null">
#{scheduleType,jdbcType=INTEGER},
</if>
</trim>
</insert>
......@@ -300,7 +307,7 @@
script_urls, source_principal, trigger_time,
trigger_status, version_name, log_id,
run_command, run_source,flow_name, super_success_run, re_run_id,
node_depend, operator
node_depend, operator, schedule_type
)
values
<foreach collection="jobTaskSchedules" item="jobTaskSchedule" separator=",">
......@@ -326,7 +333,7 @@
#{jobTaskSchedule.runCommand,jdbcType=VARCHAR}, #{jobTaskSchedule.runSource,jdbcType=LONGVARCHAR},
#{jobTaskSchedule.flowName,jdbcType=VARCHAR}, #{jobTaskSchedule.superSuccessRun,jdbcType=CHAR},
#{jobTaskSchedule.reRunId,jdbcType=VARCHAR}, #{jobTaskSchedule.nodeDepend,jdbcType=VARCHAR},
#{jobTaskSchedule.operator,jdbcType=VARCHAR}
#{jobTaskSchedule.operator,jdbcType=VARCHAR}, #{scheduleType,jdbcType=INTEGER},
)
</foreach>
</insert>
......@@ -434,6 +441,9 @@
<if test="operator != null">
operator = #{operator,jdbcType=VARCHAR},
</if>
<if test="scheduleType != null">
schedule_type = #{scheduleType,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
......
......@@ -108,8 +108,8 @@
select
<include refid="Base_Column_List" />
from run_recording
where start_time &gt;= ${startDate}
and end_time &lt;= ${endDate}
where start_time &gt;= #{startDate}
and end_time &lt;= #{endDate}
<if test="flowIds != null">
and flow_id in (
<foreach collection="flowIds" item="flowId" separator=",">
......@@ -120,14 +120,14 @@
<if test="scheduleStatusList != null">
and flow_status in (
<foreach collection="scheduleStatusList" item="scheduleStatus" separator=",">
${scheduleStatus}
#{scheduleStatus}
</foreach>
)
</if>
<if test="executeStatusList != null">
and flow_run_result in (
<foreach collection="executeStatusList" item="executeStatus" separator=",">
${executeStatus}
#{executeStatus}
</foreach>
)
</if>
......@@ -156,8 +156,8 @@
sum(case when flow_status='4' and (flow_run_result = '2' or flow_run_result = '4') then 1 else 0 end ) fail,
sum(case when flow_run_result='5' then 1 else 0 end ) 'kill'
from run_recording
where start_time &gt;= ${startDate}
and end_time &lt;= ${endDate}
where start_time &gt;= #{startDate}
and end_time &lt;= #{endDate}
<if test="flowIdList != null">
and flow_id in (
<foreach collection="flowIdList" item="flowId" separator=",">
......@@ -488,7 +488,7 @@
<update id="killInnerFlow" >
update run_recording set flow_status = '4',flow_run_result = '5'
where run_id = #{runId,jdbcType=VARCHAR}
and flow_name = ${flowName,jdbcType=VARCHAR}
and flow_name = #{flowName,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
......@@ -12,7 +12,7 @@ import javax.servlet.http.HttpServletRequest;
@Component
public class CurrentUserUtils {
@Value("{authentication.user.pub-key}")
@Value("${authentication.user.pub-key}")
private String pubKey;
public JwtUserInfo getCurrentUser() {
......
package com.byit.dto.plugin;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Description 重跑信息
......@@ -10,6 +12,8 @@ import lombok.Data;
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class RunInfo {
/**
* 运行实例id 必填
......
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