Commit fb4752af by guominglei

修改统计方式

parent d896cd3d
......@@ -66,7 +66,10 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
List<FlowStatusSnapshoot> flowStatusSnapshootList = new ArrayList<>();
flowList.forEach(flow -> {
List<RunRecording> maxRunRecordingList = runRecordingMapper.findMaxByFlowId(flow.getFlowId());
//获取今天凌晨的时间戳
Long time = LocalDate.now().atStartOfDay(ZoneOffset.ofHours(8)).toInstant().toEpochMilli();
//获取今天的运行实例
List<RunRecording> runRecordingList = runRecordingMapper.findByPreTime(new Date(time), flow.getFlowId());
FlowStatusSnapshoot flowStatusSnapshoot = new FlowStatusSnapshoot();
flowStatusSnapshoot.setDay(date);
flowStatusSnapshoot.setFlowId(flow.getFlowId());
......@@ -77,46 +80,9 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
//统计运行实例的数据
//如果存在实例
if (null != maxRunRecordingList && maxRunRecordingList.size() > 0){
//获取今天凌晨的时间戳
Long time = LocalDate.now().atStartOfDay(ZoneOffset.ofHours(8)).toInstant().toEpochMilli();
RunRecording maxRunRecording = maxRunRecordingList.get(0);
//从凌晨到现在是否有运行实例
if (time.longValue() > maxRunRecording.getStartTime().getTime()){
flowStatusSnapshoot.setFlowStatus(1);
flowStatusSnapshoot.setUnstartNode(flow.getFlowNodeCount());
flowStatusSnapshootList.add(flowStatusSnapshoot);
} else { //从凌晨到现在存在工作流的运行实例
//获取上一个小时的时间戳
Long preHourTime = hourDateTime.minusHours(1).toInstant(ZoneOffset.of("+8")).toEpochMilli();
//查询过去一个小时的和未完成的工作流实例
List<RunRecording> runRecordingList = runRecordingMapper.findByPreTime(new Date(preHourTime), flow.getFlowId());
//判断是否存在过去一个小时的和未完成的工作流实例
if(null != runRecordingList && runRecordingList.size() > 0){
//处理未完成和过去一个小时的工作流实例
if (null != runRecordingList && runRecordingList.size() > 0){
buildUnFinish(runRecordingList, flowStatusSnapshootList, flowStatusSnapshoot, flow);
}else {
//如果不存在实例,获取上一个小时的运行快照保存
LocalDateTime preHourLocalDateTime = localDateTime.minusHours(1);
String preHourDate = preHourLocalDateTime.format(DATE_FORMATTER);
String preHourHour = String.valueOf(preHourLocalDateTime.getHour());
List<FlowStatusSnapshoot> preHourFlowStatusSnapshootList = flowStatusSnapshootMapper.findByDateAndHourAndFlowId(preHourDate, preHourHour, flow.getFlowId());
if (null != preHourFlowStatusSnapshootList && preHourFlowStatusSnapshootList.size() > 0){
preHourFlowStatusSnapshootList.forEach(preHourFlowStatusSnapshoot->{
preHourFlowStatusSnapshoot.setDay(date);
preHourFlowStatusSnapshoot.setHour(hour);
preHourFlowStatusSnapshoot.setSnapshootTime(hourTime);
flowStatusSnapshootList.add(preHourFlowStatusSnapshoot);
});
}else {
//如果上个小时也没有,就设置为未运行
flowStatusSnapshoot.setFlowStatus(1);
flowStatusSnapshoot.setUnstartNode(flow.getFlowNodeCount());
flowStatusSnapshootList.add(flowStatusSnapshoot);
}
}
}
}else {
//如果不存在运行实例
flowStatusSnapshoot.setFlowStatus(1);
flowStatusSnapshoot.setUnstartNode(flow.getFlowNodeCount());
......@@ -137,7 +103,7 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
}
/**
* 功能描述 处理过去一小时和未完成的工作流的快照
* 功能描述 当天的和未完成的工作流的快照
* @author gml
* @date 2020-05-08 10:20
* @param runRecordingList
......
......@@ -234,6 +234,7 @@
where flow_id = #{flowId}
and (
start_time &gt;= #{preHourDate}
or end_time &gt;= #{preHourDate}
or flow_status != '4'
)
</select>
......
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