Commit fb235064 by guo_minglei@163.com

修改快照

parent 4367a109
...@@ -866,7 +866,7 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -866,7 +866,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
Map<String, StatisticData> nodeCollectMap = new HashMap<>(); Map<String, StatisticData> nodeCollectMap = new HashMap<>();
flowStatusSnapshootList.forEach(flowStatusSnapshoot -> { flowStatusSnapshootList.forEach(flowStatusSnapshoot -> {
String key = flowStatusSnapshoot.getDay() + " " + flowStatusSnapshoot.getHour(); String key = flowStatusSnapshoot.getDay() + "/" + flowStatusSnapshoot.getHour();
StatisticData nodeHourStatisticData = nodeCollectMap.get(key); StatisticData nodeHourStatisticData = nodeCollectMap.get(key);
if (null == nodeHourStatisticData){ if (null == nodeHourStatisticData){
nodeHourStatisticData = new StatisticData(); nodeHourStatisticData = new StatisticData();
......
...@@ -172,4 +172,12 @@ public interface RunRecordingMapper { ...@@ -172,4 +172,12 @@ public interface RunRecordingMapper {
@Param("flowIdList")List<Integer> flowIdList); @Param("flowIdList")List<Integer> flowIdList);
RunRecording findMaxByFlowId(@Param("flowId")Integer flowId); 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.*; ...@@ -5,6 +5,7 @@ import com.byit.mapper.*;
import com.byit.model.*; import com.byit.model.*;
import com.byit.thread.BaseThreadRunHelper; import com.byit.thread.BaseThreadRunHelper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -13,6 +14,7 @@ import javax.sql.DataSource; ...@@ -13,6 +14,7 @@ import javax.sql.DataSource;
import java.time.*; import java.time.*;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -64,7 +66,7 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper { ...@@ -64,7 +66,7 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
List<FlowStatusSnapshoot> flowStatusSnapshootList = new ArrayList<>(); List<FlowStatusSnapshoot> flowStatusSnapshootList = new ArrayList<>();
flowList.forEach(flow -> { flowList.forEach(flow -> {
RunRecording runRecording = runRecordingMapper.findMaxByFlowId(flow.getFlowId()); RunRecording maxRunRecording = runRecordingMapper.findMaxByFlowId(flow.getFlowId());
FlowStatusSnapshoot flowStatusSnapshoot = new FlowStatusSnapshoot(); FlowStatusSnapshoot flowStatusSnapshoot = new FlowStatusSnapshoot();
flowStatusSnapshoot.setDay(date); flowStatusSnapshoot.setDay(date);
flowStatusSnapshoot.setFlowId(flow.getFlowId()); flowStatusSnapshoot.setFlowId(flow.getFlowId());
...@@ -75,25 +77,31 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper { ...@@ -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(); 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.setFlowStatus(1);
flowStatusSnapshoot.setUnstartNode(flow.getFlowNodeCount()); flowStatusSnapshoot.setUnstartNode(flow.getFlowNodeCount());
flowStatusSnapshootList.add(flowStatusSnapshoot);
} else { //存在工作流的运行实例 } else { //存在工作流的运行实例
//判断运行状态 List<RunRecording> runRecordingList = runRecordingMapper.findByPreTime(new Date(preHourTime), flow.getFlowId());
if (runRecording.getFlowStatus().equals("1") || runRecording.getFlowStatus().equals("2") || runRecording.getFlowStatus().equals("3")){ runRecordingList.forEach(runRecording -> {
flowStatusSnapshoot.setFlowStatus(Integer.valueOf(runRecording.getFlowStatus())); FlowStatusSnapshoot hourFlowStatusSnapshoot = new FlowStatusSnapshoot();
}else { BeanUtils.copyProperties(flowStatusSnapshoot, hourFlowStatusSnapshoot);
switch (runRecording.getFlowRunResult()){ //判断运行状态
case "1" : if (runRecording.getFlowStatus().equals("1") || runRecording.getFlowStatus().equals("2") || runRecording.getFlowStatus().equals("3")){
case "3" : flowStatusSnapshoot.setFlowStatus(4); break; hourFlowStatusSnapshoot.setFlowStatus(Integer.valueOf(runRecording.getFlowStatus()));
case "2" : }else {
case "4" : flowStatusSnapshoot.setFlowStatus(5); break; switch (runRecording.getFlowRunResult()){
case "5" : flowStatusSnapshoot.setFlowStatus(6); break; case "1" :
default : flowStatusSnapshoot.setFlowStatus(5); break; 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()); StatisticData nodeStatistic = jobTaskRunLogMapper.findStatisticDataByRunIdAndFlowId(runRecording.getRunId(), flow.getFlowId());
...@@ -101,18 +109,17 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper { ...@@ -101,18 +109,17 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
//存在节点运行日志 //存在节点运行日志
if (nodeStatistic != null){ if (nodeStatistic != null){
int sum = nodeStatistic.getFail() + nodeStatistic.getSuccess() + nodeStatistic.getRunIng() + nodeStatistic.getKill(); int sum = nodeStatistic.getFail() + nodeStatistic.getSuccess() + nodeStatistic.getRunIng() + nodeStatistic.getKill();
flowStatusSnapshoot.setUnstartNode(flow.getFlowNodeCount() - sum); hourFlowStatusSnapshoot.setUnstartNode(flow.getFlowNodeCount() - sum);
flowStatusSnapshoot.setRuningNode(nodeStatistic.getRunIng()); hourFlowStatusSnapshoot.setRuningNode(nodeStatistic.getRunIng());
flowStatusSnapshoot.setSuccessNode(nodeStatistic.getSuccess()); hourFlowStatusSnapshoot.setSuccessNode(nodeStatistic.getSuccess());
flowStatusSnapshoot.setFailNode(nodeStatistic.getFail()); hourFlowStatusSnapshoot.setFailNode(nodeStatistic.getFail());
flowStatusSnapshoot.setKillNode(nodeStatistic.getKill()); hourFlowStatusSnapshoot.setKillNode(nodeStatistic.getKill());
}else { }else {
//不存在节点的运行日志 //不存在节点的运行日志
flowStatusSnapshoot.setUnstartNode(flow.getFlowNodeCount()); hourFlowStatusSnapshoot.setUnstartNode(flow.getFlowNodeCount());
} }
flowStatusSnapshootList.add(flowStatusSnapshoot); flowStatusSnapshootList.add(hourFlowStatusSnapshoot);
} });
} }
}else { }else {
//如果不存在运行实例 //如果不存在运行实例
......
...@@ -176,6 +176,13 @@ ...@@ -176,6 +176,13 @@
where flow_id = #{flowId} where flow_id = #{flowId}
) )
</select> </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"> <delete id="deleteById" parameterType="java.lang.Integer">
<!-- generated @mbg.generated date: 2019-12-25 --> <!-- 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