Commit fb235064 by guo_minglei@163.com

修改快照

parent 4367a109
......@@ -866,7 +866,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
Map<String, StatisticData> nodeCollectMap = new HashMap<>();
flowStatusSnapshootList.forEach(flowStatusSnapshoot -> {
String key = flowStatusSnapshoot.getDay() + " " + flowStatusSnapshoot.getHour();
String key = flowStatusSnapshoot.getDay() + "/" + flowStatusSnapshoot.getHour();
StatisticData nodeHourStatisticData = nodeCollectMap.get(key);
if (null == nodeHourStatisticData){
nodeHourStatisticData = new StatisticData();
......
......@@ -172,4 +172,12 @@ public interface RunRecordingMapper {
@Param("flowIdList")List<Integer> flowIdList);
RunRecording findMaxByFlowId(@Param("flowId")Integer flowId);
/**
* 查询过去一小时的运行实例
* @param preHourDate
* @param flowId
* @return
*/
List<RunRecording> findByPreTime(@Param("preHourDate")Date preHourDate, @Param("flowId")Integer flowId);
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import com.byit.mapper.*;
import com.byit.model.*;
import com.byit.thread.BaseThreadRunHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
......@@ -13,6 +14,7 @@ import javax.sql.DataSource;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
......@@ -64,7 +66,7 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
List<FlowStatusSnapshoot> flowStatusSnapshootList = new ArrayList<>();
flowList.forEach(flow -> {
RunRecording runRecording = runRecordingMapper.findMaxByFlowId(flow.getFlowId());
RunRecording maxRunRecording = runRecordingMapper.findMaxByFlowId(flow.getFlowId());
FlowStatusSnapshoot flowStatusSnapshoot = new FlowStatusSnapshoot();
flowStatusSnapshoot.setDay(date);
flowStatusSnapshoot.setFlowId(flow.getFlowId());
......@@ -75,25 +77,31 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
//统计运行实例的数据
//如果存在实例
if (runRecording != null){
if (maxRunRecording != null){
//获取上一个时间
Long preHourTime = hourDateTime.minusHours(1).toInstant(ZoneOffset.of("+8")).toEpochMilli();
//从凌晨到现在是否有运行实例
if (preHourTime.longValue() > runRecording.getTriggerTime().longValue()){
if (preHourTime.longValue() > maxRunRecording.getTriggerTime().longValue()){
flowStatusSnapshoot.setFlowStatus(1);
flowStatusSnapshoot.setUnstartNode(flow.getFlowNodeCount());
flowStatusSnapshootList.add(flowStatusSnapshoot);
} else { //存在工作流的运行实例
//判断运行状态
if (runRecording.getFlowStatus().equals("1") || runRecording.getFlowStatus().equals("2") || runRecording.getFlowStatus().equals("3")){
flowStatusSnapshoot.setFlowStatus(Integer.valueOf(runRecording.getFlowStatus()));
}else {
switch (runRecording.getFlowRunResult()){
case "1" :
case "3" : flowStatusSnapshoot.setFlowStatus(4); break;
case "2" :
case "4" : flowStatusSnapshoot.setFlowStatus(5); break;
case "5" : flowStatusSnapshoot.setFlowStatus(6); break;
default : flowStatusSnapshoot.setFlowStatus(5); break;
List<RunRecording> runRecordingList = runRecordingMapper.findByPreTime(new Date(preHourTime), flow.getFlowId());
runRecordingList.forEach(runRecording -> {
FlowStatusSnapshoot hourFlowStatusSnapshoot = new FlowStatusSnapshoot();
BeanUtils.copyProperties(flowStatusSnapshoot, hourFlowStatusSnapshoot);
//判断运行状态
if (runRecording.getFlowStatus().equals("1") || runRecording.getFlowStatus().equals("2") || runRecording.getFlowStatus().equals("3")){
hourFlowStatusSnapshoot.setFlowStatus(Integer.valueOf(runRecording.getFlowStatus()));
}else {
switch (runRecording.getFlowRunResult()){
case "1" :
case "3" : hourFlowStatusSnapshoot.setFlowStatus(4); break;
case "2" :
case "4" : hourFlowStatusSnapshoot.setFlowStatus(5); break;
case "5" : hourFlowStatusSnapshoot.setFlowStatus(6); break;
default : hourFlowStatusSnapshoot.setFlowStatus(5); break;
}
}
//获取运行实例下各类状态的节点数目
StatisticData nodeStatistic = jobTaskRunLogMapper.findStatisticDataByRunIdAndFlowId(runRecording.getRunId(), flow.getFlowId());
......@@ -101,18 +109,17 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
//存在节点运行日志
if (nodeStatistic != null){
int sum = nodeStatistic.getFail() + nodeStatistic.getSuccess() + nodeStatistic.getRunIng() + nodeStatistic.getKill();
flowStatusSnapshoot.setUnstartNode(flow.getFlowNodeCount() - sum);
flowStatusSnapshoot.setRuningNode(nodeStatistic.getRunIng());
flowStatusSnapshoot.setSuccessNode(nodeStatistic.getSuccess());
flowStatusSnapshoot.setFailNode(nodeStatistic.getFail());
flowStatusSnapshoot.setKillNode(nodeStatistic.getKill());
hourFlowStatusSnapshoot.setUnstartNode(flow.getFlowNodeCount() - sum);
hourFlowStatusSnapshoot.setRuningNode(nodeStatistic.getRunIng());
hourFlowStatusSnapshoot.setSuccessNode(nodeStatistic.getSuccess());
hourFlowStatusSnapshoot.setFailNode(nodeStatistic.getFail());
hourFlowStatusSnapshoot.setKillNode(nodeStatistic.getKill());
}else {
//不存在节点的运行日志
flowStatusSnapshoot.setUnstartNode(flow.getFlowNodeCount());
hourFlowStatusSnapshoot.setUnstartNode(flow.getFlowNodeCount());
}
flowStatusSnapshootList.add(flowStatusSnapshoot);
}
flowStatusSnapshootList.add(hourFlowStatusSnapshoot);
});
}
}else {
//如果不存在运行实例
......
......@@ -176,6 +176,13 @@
where flow_id = #{flowId}
)
</select>
<select id="findByPreTime" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from run_recording
where flow_id = #{flowId}
and start_time &gt;= #{preHourDate}
</select>
<delete id="deleteById" parameterType="java.lang.Integer">
<!-- generated @mbg.generated date: 2019-12-25 -->
......
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