Commit 313d2ce8 by huangfusuper

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

parents 40bf03ee aec307f9
package com.byit.api;
import com.byit.dto.plugin.CollectData;
import com.byit.dto.web.ResponseResult;
import com.byit.model.RunRecording;
import com.byit.model.vo.RunRecordingVo;
......@@ -160,4 +161,9 @@ public class ApiFlowController {
return ResponseResult.ok("SUCCESS");
}
public ResponseResult loadStatisticData(String param){
CollectData collectData = apiFlowService.loadStatisticData(param);
return ResponseResult.ok(collectData);
}
}
package com.byit.service;
import com.byit.dto.plugin.CollectData;
import com.byit.dto.plugin.PluginFlow;
import com.byit.model.RunRecording;
import com.byit.model.vo.RunRecordingVo;
......@@ -80,4 +81,11 @@ public interface ApiFlowService {
* @return
*/
RunRecordingVo loadScheduleLog(String param);
/**
* 统计汇总数据
* @param param
* @return
*/
CollectData loadStatisticData(String param);
}
......@@ -81,6 +81,9 @@ public class ApiFlowServiceImpl implements ApiFlowService {
private WaitingTaskMapper waitingTaskMapper;
@Resource
private FlowStatusSnapshootMapper flowStatusSnapshootMapper;
@Resource
private CurrentUserUtils currentUserUtils;
private void parseParam(String param, DeleteDto deletDto){
......@@ -688,6 +691,84 @@ public class ApiFlowServiceImpl implements ApiFlowService {
return runRecordingVo;
}
@Override
public CollectData loadStatisticData(String param){
ValidationUtil.dataNotBank(param, "请求参数不允许为空!");
JSONObject jsonObject = JSON.parseObject(param);
//获取工作空间名称
String workspaceName = jsonObject.getString("workspaceName");
ValidationUtil.dataNotBank(workspaceName, "工作空间名称不允许为空!");
//开始校验
Workspace workspace = workspaceMapper.getByName(workspaceName);
ValidationUtil.dataNotNull(workspace, workspaceName + "工作空间不存在");
//获取时间间隔
Long startTime = jsonObject.getLong("startTime");
ValidationUtil.dataNotNull(startTime, "开始时间不允许为空!");
Long endTime = jsonObject.getLong("endTime");
ValidationUtil.dataNotNull(endTime, "结束时间不允许为空!");
ValidationUtil.isTrueValidation(String.valueOf(startTime).length() < 13 || String.valueOf(endTime).length() < 13 , "时间格式必须是毫秒");
//获取工作流名称
String flowName = jsonObject.getString("flowName");
List<Integer> flowIdList = new ArrayList<>();
if (StringUtils.isNotEmpty(flowName)){
Flow flow = flowMapper.getByWorkSpaceAndName(workspace.getWorkspaceId(), flowName);
ValidationUtil.dataNotNull(flow, "工作流不存在!");
flowIdList.add(flow.getFlowId());
if (FlowPropertyEnum.IS_INNER.getCode().equals(flow.getIsInner())){
List<RunRecording> runRecordingList = runRecordingMapper.findByStartAndEndTime(startTime, endTime, flowIdList, null, null);
flowIdList.clear();
runRecordingList.forEach(runRecording -> flowIdList.add(runRecording.getFlowId()));
}
}else {
List<Flow> flowList = flowMapper.findByWorkspace(workspace.getWorkspaceId());
if (flowList != null && flowList.size() > 0){
flowList.forEach(flow -> flowIdList.add(flow.getFlowId()));
}
}
StatisticData flowStatisticData = runRecordingMapper.findStatusByStartAndEndTime(startTime, endTime, flowIdList);
StatisticData nodeStatisticData = jobTaskRunLogMapper.findStatusByStartAndEndTime(startTime, endTime, flowIdList);
List<FlowStatusSnapshoot> flowStatusSnapshootList = flowStatusSnapshootMapper.findByTime(startTime, endTime);
Map<String, StatisticData> collectMap = new HashMap<>();
flowStatusSnapshootList.forEach(flowStatusSnapshoot -> {
String key = flowStatusSnapshoot.getDay() + " " + flowStatusSnapshoot.getHour();
StatisticData statisticData = collectMap.get(key);
if (null == statisticData){
statisticData = new StatisticData();
statisticData.setUnstart(flowStatusSnapshoot.getUnstartNode());
statisticData.setRunIng(flowStatusSnapshoot.getRuningNode());
statisticData.setSuccess(flowStatusSnapshoot.getSuccessNode());
statisticData.setFail(flowStatusSnapshoot.getFailNode());
statisticData.setKill(flowStatusSnapshoot.getKillNode());
collectMap.put(key, statisticData);
}else {
statisticData.setUnstart(statisticData.getUnstart() + flowStatusSnapshoot.getUnstartNode());
statisticData.setRunIng(statisticData.getRunIng() + flowStatusSnapshoot.getRuningNode());
statisticData.setSuccess(statisticData.getSuccess() + flowStatusSnapshoot.getSuccessNode());
statisticData.setFail(statisticData.getFail() + flowStatusSnapshoot.getFailNode());
statisticData.setKill(statisticData.getKill() + flowStatusSnapshoot.getKillNode());
collectMap.put(key, statisticData);
}
});
CollectData collectData = new CollectData();
collectData.setFlowData(flowStatisticData);
collectData.setNodeData(nodeStatisticData);
collectData.setCollectMap(collectMap);
return collectData;
}
public static void main(String[] args) throws ParseException {
String str = "20200401";
SimpleDateFormat ssss = new SimpleDateFormat("yyyy-MM-dd hh");
Date date = new Date();
System.out.println(ssss.format(date));
System.out.println(sdf.parse(str));
}
/**
* runState 补批机制 1 补批当前节点 2 补批当前节点及以下节点
* @param param
......
......@@ -55,5 +55,5 @@ file:
myth-job:
filestystem: FASTDFS
snapshoot-date: 60 #快照的保存时间 单位天
......@@ -38,10 +38,12 @@ authentication:
expire: 43200 # 外部token有效期为12小时
pub-key: client/pub.key # 解密
file:
system:
ip: 10.0.120.2
port: 88
myth-job:
filestystem: FASTDFS
\ No newline at end of file
filestystem: FASTDFS
snapshoot-date: 60 #快照的保存时间 单位天
\ No newline at end of file
......@@ -44,4 +44,5 @@ file:
port: 88
myth-job:
filestystem: FASTDFS
\ No newline at end of file
filestystem: FASTDFS
snapshoot-date: 60 #快照的保存时间 单位天
\ No newline at end of file
......@@ -45,4 +45,5 @@ file:
port: ${FILW_PORT}
myth-job:
filestystem: FASTDFS
\ No newline at end of file
filestystem: FASTDFS
snapshoot-date: 60 #快照的保存时间 单位天
\ No newline at end of file
package com.byit.enums;
/**
* @Description
* @Description 调度状态
* @Author guo_m
* @Date 2020-03-31
*/
public enum ExecuteStatusEnum {
UN_START(1, "未运行"),
STARTING(2, "运行中"),
FINISH(3, "暂停"),
STOP(4, "完成"),
SUCCESS(1, "成功"),
FAIL(2, "失败"),
REPAIR_SUCCESS(3, "补批成功"),
REPAIR_FAIL(4, "补批失败"),
KILL(5, "杀死")
;
private Integer code;
private String msg;
......@@ -28,5 +27,4 @@ public enum ExecuteStatusEnum {
public String getMsg(){
return this.msg;
}
}
package com.byit.enums;
/**
* @Description 调度状态
* @Description
* @Author guo_m
* @Date 2020-03-31
*/
public enum ScheduleStatusEnum {
SUCCESS(1, "成功"),
FAIL(2, "失败"),
REPAIR_SUCCESS(3, "补批成功"),
REPAIR_FAIL(4, "补批失败"),
KILL(5, "杀死")
UN_START(1, "未运行"),
STARTING(2, "运行中"),
FINISH(3, "暂停"),
STOP(4, "完成"),
;
private Integer code;
private String msg;
......@@ -27,4 +28,5 @@ public enum ScheduleStatusEnum {
public String getMsg(){
return this.msg;
}
}
......@@ -25,15 +25,15 @@ public class DaemonScanThreadRunHelper {
private volatile static boolean THREAD_GROUP_STOP = false;
/**
* 初始睡眠时间
* 初始睡眠时间 单位毫秒
*/
private static final Long INIT_SLEEP_DATE = 10000L;
/**
* 关闭等待时间
* 关闭等待时间 单位毫秒
*/
private static final Long CLOSE_WAIT_TIME = 1000L;
/**
* 循环间隔
* 循环间隔 单位毫秒
*/
private static final Long CYCLE_INTERVAL = 1000L;
......@@ -196,7 +196,7 @@ public class DaemonScanThreadRunHelper {
private static void dateAligned(long waitTime,String threadName){
try {
log.debug("-----------线程{}开始休眠,休眠时间{}---------",threadName,waitTime);
TimeUnit.MILLISECONDS.sleep(waitTime - System.currentTimeMillis()%1000);
TimeUnit.MILLISECONDS.sleep(waitTime - System.currentTimeMillis() % 1000);
} catch (InterruptedException e) {
log.warn("----------------【{}线程被中断】-----------------------",threadName);
}
......
......@@ -42,4 +42,10 @@ public interface FlowMapper {
* @return
*/
List<Flow> findByWorkspace(Integer workspaceId);
/**
* 获取已经启动的工作流
* @return
*/
List<Flow> findONStartUp();
}
\ No newline at end of file
package com.byit.mapper;
import com.byit.model.FlowStatusSnapshoot;
import java.util.List;
public interface FlowStatusSnapshootMapper {
int deleteById(Integer statusId);
int insert(FlowStatusSnapshoot record);
int insertSelective(FlowStatusSnapshoot record);
FlowStatusSnapshoot getById(Integer statusId);
int updateByIdSelective(FlowStatusSnapshoot record);
int updateById(FlowStatusSnapshoot record);
/**
* 判断快照是否存在
* @param date
* @param hour
* @return
*/
Integer exist(String date, String hour);
/**
* 批量保存
* @param flowStatusSnapshootList
* @return
*/
int saveList(List<FlowStatusSnapshoot> flowStatusSnapshootList);
/**
* 删除太长时间的快照
* @param outTime
* @return
*/
int deleteOutSnapShoot(Long outTime);
/**
* 根据时间范围查询
* @param startTime
* @param endTime
* @return
*/
List<FlowStatusSnapshoot> findByTime(Long startTime, Long endTime);
}
\ No newline at end of file
package com.byit.mapper;
import com.byit.dto.plugin.StatisticData;
import com.byit.model.JobTaskRunLog;
import com.byit.model.JobTaskRunLogWithBLOBs;
import org.apache.ibatis.annotations.Param;
......@@ -110,4 +111,17 @@ public interface JobTaskRunLogMapper {
* @return
*/
List<JobTaskRunLog> findByRunId(String runId);
/**
* 查询运行汇总
* @param startTime
* @param endTime
* @param flowIdList
* @return
*/
StatisticData findStatusByStartAndEndTime(@Param("startTime")Long startTime,
@Param("endTime")Long endTime,
@Param("flowIdList")List<Integer> flowIdList);
StatisticData findStatisticDataByRunIdAndFlowId(@Param("runId")String runId, @Param("flowId")Integer flowId);
}
\ No newline at end of file
package com.byit.mapper;
import com.byit.dto.plugin.StatisticData;
import com.byit.model.RunRecording;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
......@@ -157,4 +158,17 @@ public interface RunRecordingMapper {
* @return
*/
List<RunRecording> findUnFinishByFlowId(Integer flowId);
/**
* 查询运行汇总
* @param startTime
* @param endTime
* @param flowIdList
* @return
*/
StatisticData findStatusByStartAndEndTime(@Param("startTime")Long startTime,
@Param("endTime")Long endTime,
@Param("flowIdList")List<Integer> flowIdList);
RunRecording findMaxByFlowId(@Param("flowId")Integer flowId);
}
\ No newline at end of file
package com.byit.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import lombok.Data;
/**
*
*/
@ApiModel
@Data
public class FlowStatusSnapshoot implements Serializable {
/**
* 主键
*/
@ApiModelProperty("主键")
private Integer statusId;
/**
* 工作空间主键
*/
@ApiModelProperty("工作空间主键")
private Integer workspaceId;
/**
* 工作流主键
*/
@ApiModelProperty("工作流主键")
private Integer flowId;
/**
* 工作流名称
*/
@ApiModelProperty("工作流名称")
private String flowName;
/**
* 快照日期
*/
@ApiModelProperty("快照日期")
private String day;
/**
* 快照小时
*/
@ApiModelProperty("快照小时")
private String hour;
/**
* 工作流状态(1 未运行 2 运行中 3 暂停 4 成功 5 失败 6 kill)
*/
@ApiModelProperty("工作流状态(1 未运行 2 运行中 3 暂停 4 成功 5 失败 6 kill)")
private Integer flowStatus;
/**
* 快照的时间戳
*/
@ApiModelProperty("快照的时间戳")
private Long snapshootTime;
/**
* 未开始节点数目
*/
@ApiModelProperty("未开始节点数目")
private int unstartNode;
/**
* 运行中节点数目
*/
@ApiModelProperty("运行中节点数目")
private int runingNode;
/**
* 成功节点数目
*/
@ApiModelProperty("成功节点数目")
private int successNode;
/**
* 失败节点数目
*/
@ApiModelProperty("失败节点数目")
private int failNode;
/**
* 杀死的节点数目
*/
@ApiModelProperty("杀死的节点数目")
private int killNode;
/**
*/
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package com.byit.thread.helper;
import com.byit.dto.plugin.StatisticData;
import com.byit.mapper.FlowMapper;
import com.byit.mapper.FlowStatusSnapshootMapper;
import com.byit.mapper.JobTaskRunLogMapper;
import com.byit.mapper.RunRecordingMapper;
import com.byit.model.Flow;
import com.byit.model.FlowStatusSnapshoot;
import com.byit.model.RunRecording;
import com.byit.thread.BaseThreadRunHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.sql.DataSource;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
/**
* @Description 扫描状态并保存快照的线程类
* @Author guo_m
* @Date 2020-04-02
*/
@Component
@Slf4j
public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
private static final String LOCK_NAME = "flow_status_snapshoot_lock";
@Resource
private FlowMapper flowMapper;
@Resource
private FlowStatusSnapshootMapper flowStatusSnapshootMapper;
@Resource
private RunRecordingMapper runRecordingMapper;
@Resource
private JobTaskRunLogMapper jobTaskRunLogMapper;
@Resource
private DataSource dataSource;
@Value("${myth-job.snapshoot-date}")
private Integer snapshootDate;
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
@Override
public Long start() {
LocalDateTime localDateTime = LocalDateTime.now();
String date = localDateTime.format(DATE_FORMATTER);
String hour = String.valueOf(localDateTime.getHour());
Integer num = flowStatusSnapshootMapper.exist(date, hour);
//判断是否存储过快照
if (num != null && num >= 1){
return (60 - LocalDateTime.now().getMinute()) * 60 * 1000L;
}else {
//获取所有在调度上的工作流
List<Flow> flowList = flowMapper.findONStartUp();
if (flowList != null && flowList.size() > 0){
LocalDateTime hourDateTime = localDateTime
.minusMinutes(localDateTime.getMinute()) //减去分钟
.minusSeconds(localDateTime.getSecond()) //减去秒
.minusNanos(localDateTime.getNano()); //减去纳秒
Long hourTime = hourDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli(); //转换时间戳
List<FlowStatusSnapshoot> flowStatusSnapshootList = new ArrayList<>();
flowList.forEach(flow -> {
RunRecording runRecording = runRecordingMapper.findMaxByFlowId(flow.getFlowId());
if (runRecording != null){
//获取凌晨的时间戳
Long time = LocalDate.now().atStartOfDay(ZoneOffset.ofHours(8)).toInstant().toEpochMilli();
FlowStatusSnapshoot flowStatusSnapshoot = new FlowStatusSnapshoot();
flowStatusSnapshoot.setDay(date);
flowStatusSnapshoot.setFlowId(flow.getFlowId());
flowStatusSnapshoot.setHour(hour);
flowStatusSnapshoot.setFlowName(flow.getFlowName());
flowStatusSnapshoot.setWorkspaceId(flow.getWorkspaceId());
flowStatusSnapshoot.setSnapshootTime(hourTime);
if (time.longValue() > runRecording.getTriggerTime().longValue()){
flowStatusSnapshoot.setFlowStatus(1);
flowStatusSnapshoot.setUnstartNode(flow.getFlowNodeCount());
}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;
}
}
//获取运行实例下各类状态的节点数目
StatisticData nodeStatistic = jobTaskRunLogMapper.findStatisticDataByRunIdAndFlowId(runRecording.getRunId(), flow.getFlowId());
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());
}else {
nodeStatistic.setUnstart(flow.getFlowNodeCount());
}
}
flowStatusSnapshootList.add(flowStatusSnapshoot);
}
});
if (flowList != null && flowList.size() > 0){
flowStatusSnapshootMapper.saveList(flowStatusSnapshootList);
}
//获取过期的时间戳
Long outTime = hourDateTime.minusDays(snapshootDate).toInstant(ZoneOffset.of("+8")).toEpochMilli(); //转换时间戳;
//删除超过期限的快照
flowStatusSnapshootMapper.deleteOutSnapShoot(outTime);
}
}
return (60 - LocalTime.now().getMinute()) * 60 * 1000L;
}
@Override
public DataSource getDataSource() {
return dataSource;
}
@Override
public String getLockName() {
return LOCK_NAME;
}
}
......@@ -55,7 +55,7 @@
type="XMLMAPPER">
<property name="enableSubPackages" value="false"/>
</javaClientGenerator>
<table tableName="waiting_task" domainObjectName="WaitingTask" />
<table tableName="flow_status_snapshoot" domainObjectName="FlowStatusSnapshoot" />
</context>
......
......@@ -61,21 +61,27 @@
where workspace_id = #{workspaceId}
and flow_name = #{flowName}
</select>
<select id="findFlowById" resultType="com.byit.model.Flow">
<select id="findFlowById" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from flow
where flow_id = #{id,jdbcType=INTEGER}
</select>
<select id="findByWorkspace" resultType="com.byit.model.Flow">
<select id="findByWorkspace" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from flow
where false = #{workspaceId,jdbcType=INTEGER}
where workspace_id = #{workspaceId,jdbcType=INTEGER}
</select>
<select id="findONStartUp" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from flow
where start_up = '0'
</select>
<delete id="deleteById" parameterType="java.lang.Integer">
<delete id="deleteById" parameterType="java.lang.Integer">
<!-- generated @mbg.generated date: 2019-12-31 -->
delete from flow
where flow_id = #{flowId,jdbcType=INTEGER}
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.byit.mapper.FlowStatusSnapshootMapper">
<resultMap id="BaseResultMap" type="com.byit.model.FlowStatusSnapshoot">
<!-- generated @mbg.generated date: 2020-04-02 -->
<id column="status_id" jdbcType="INTEGER" property="statusId" />
<result column="workspace_id" jdbcType="INTEGER" property="workspaceId" />
<result column="flow_id" jdbcType="INTEGER" property="flowId" />
<result column="flow_name" jdbcType="VARCHAR" property="flowName" />
<result column="day" jdbcType="VARCHAR" property="day" />
<result column="hour" jdbcType="VARCHAR" property="hour" />
<result column="flow_status" jdbcType="INTEGER" property="flowStatus" />
<result column="snapshoot_time" jdbcType="BIGINT" property="snapshootTime" />
<result column="unstart_node" jdbcType="INTEGER" property="unstartNode" />
<result column="runing_node" jdbcType="INTEGER" property="runingNode" />
<result column="success_node" jdbcType="INTEGER" property="successNode" />
<result column="fail_node" jdbcType="INTEGER" property="failNode" />
<result column="kill_node" jdbcType="INTEGER" property="killNode" />
</resultMap>
<sql id="Base_Column_List">
<!-- generated @mbg.generated date: 2020-04-02 -->
status_id, workspace_id, flow_id, flow_name, `day`, `hour`, flow_status, snapshoot_time,
unstart_node, runing_node, success_node, fail_node, kill_node
</sql>
<select id="getById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!-- generated @mbg.generated date: 2020-04-02 -->
select
<include refid="Base_Column_List" />
from flow_status_snapshoot
where status_id = #{statusId,jdbcType=INTEGER}
</select>
<delete id="deleteById" parameterType="java.lang.Integer">
<!-- generated @mbg.generated date: 2020-04-02 -->
delete from flow_status_snapshoot
where status_id = #{statusId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.byit.model.FlowStatusSnapshoot">
<!-- generated @mbg.generated date: 2020-04-02 -->
insert into flow_status_snapshoot (status_id, workspace_id, flow_id,
flow_name, `day`, `hour`,
flow_status, snapshoot_time, unstart_node,
runing_node, success_node, fail_node,
kill_node)
values (#{statusId,jdbcType=INTEGER}, #{workspaceId,jdbcType=INTEGER}, #{flowId,jdbcType=INTEGER},
#{flowName,jdbcType=VARCHAR}, #{day,jdbcType=VARCHAR}, #{hour,jdbcType=VARCHAR},
#{flowStatus,jdbcType=INTEGER}, #{snapshootTime,jdbcType=BIGINT}, #{unstartNode,jdbcType=INTEGER},
#{runingNode,jdbcType=INTEGER}, #{successNode,jdbcType=INTEGER}, #{failNode,jdbcType=INTEGER},
#{killNode,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.byit.model.FlowStatusSnapshoot">
<!-- generated @mbg.generated date: 2020-04-02 -->
insert into flow_status_snapshoot
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="statusId != null">
status_id,
</if>
<if test="workspaceId != null">
workspace_id,
</if>
<if test="flowId != null">
flow_id,
</if>
<if test="flowName != null">
flow_name,
</if>
<if test="day != null">
`day`,
</if>
<if test="hour != null">
`hour`,
</if>
<if test="flowStatus != null">
flow_status,
</if>
<if test="snapshootTime != null">
snapshoot_time,
</if>
<if test="unstartNode != null">
unstart_node,
</if>
<if test="runingNode != null">
runing_node,
</if>
<if test="successNode != null">
success_node,
</if>
<if test="failNode != null">
fail_node,
</if>
<if test="killNode != null">
kill_node,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="statusId != null">
#{statusId,jdbcType=INTEGER},
</if>
<if test="workspaceId != null">
#{workspaceId,jdbcType=INTEGER},
</if>
<if test="flowId != null">
#{flowId,jdbcType=INTEGER},
</if>
<if test="flowName != null">
#{flowName,jdbcType=VARCHAR},
</if>
<if test="day != null">
#{day,jdbcType=VARCHAR},
</if>
<if test="hour != null">
#{hour,jdbcType=VARCHAR},
</if>
<if test="flowStatus != null">
#{flowStatus,jdbcType=INTEGER},
</if>
<if test="snapshootTime != null">
#{snapshootTime,jdbcType=BIGINT},
</if>
<if test="unstartNode != null">
#{unstartNode,jdbcType=INTEGER},
</if>
<if test="runingNode != null">
#{runingNode,jdbcType=INTEGER},
</if>
<if test="successNode != null">
#{successNode,jdbcType=INTEGER},
</if>
<if test="failNode != null">
#{failNode,jdbcType=INTEGER},
</if>
<if test="killNode != null">
#{killNode,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByIdSelective" parameterType="com.byit.model.FlowStatusSnapshoot">
<!-- generated @mbg.generated date: 2020-04-02 -->
update flow_status_snapshoot
<set>
<if test="workspaceId != null">
workspace_id = #{workspaceId,jdbcType=INTEGER},
</if>
<if test="flowId != null">
flow_id = #{flowId,jdbcType=INTEGER},
</if>
<if test="flowName != null">
flow_name = #{flowName,jdbcType=VARCHAR},
</if>
<if test="day != null">
`day` = #{day,jdbcType=VARCHAR},
</if>
<if test="hour != null">
`hour` = #{hour,jdbcType=VARCHAR},
</if>
<if test="flowStatus != null">
flow_status = #{flowStatus,jdbcType=INTEGER},
</if>
<if test="snapshootTime != null">
snapshoot_time = #{snapshootTime,jdbcType=BIGINT},
</if>
<if test="unstartNode != null">
unstart_node = #{unstartNode,jdbcType=INTEGER},
</if>
<if test="runingNode != null">
runing_node = #{runingNode,jdbcType=INTEGER},
</if>
<if test="successNode != null">
success_node = #{successNode,jdbcType=INTEGER},
</if>
<if test="failNode != null">
fail_node = #{failNode,jdbcType=INTEGER},
</if>
<if test="killNode != null">
kill_node = #{killNode,jdbcType=INTEGER},
</if>
</set>
where status_id = #{statusId,jdbcType=INTEGER}
</update>
<update id="updateById" parameterType="com.byit.model.FlowStatusSnapshoot">
<!-- generated @mbg.generated date: 2020-04-02 -->
update flow_status_snapshoot
set workspace_id = #{workspaceId,jdbcType=INTEGER},
flow_id = #{flowId,jdbcType=INTEGER},
flow_name = #{flowName,jdbcType=VARCHAR},
`day` = #{day,jdbcType=VARCHAR},
`hour` = #{hour,jdbcType=VARCHAR},
flow_status = #{flowStatus,jdbcType=INTEGER},
snapshoot_time = #{snapshootTime,jdbcType=BIGINT},
unstart_node = #{unstartNode,jdbcType=INTEGER},
runing_node = #{runingNode,jdbcType=INTEGER},
success_node = #{successNode,jdbcType=INTEGER},
fail_node = #{failNode,jdbcType=INTEGER},
kill_node = #{killNode,jdbcType=INTEGER}
where status_id = #{statusId,jdbcType=INTEGER}
</update>
<select id="exist" resultType="java.lang.Integer">
select count(1)
from flow_status_snapshoot
where 'day' = #{date} and `hour` = #{hour}
</select>
<select id="findByTime" resultType="com.byit.model.FlowStatusSnapshoot">
select
<include refid="Base_Column_List" />
from flow_status_snapshoot
where snapshoot_time &gt;= ${startDate}
and snapshoot_time &lt;= ${endDate}
</select>
<delete id="deleteOutSnapShoot" parameterType="java.lang.Long">
delete from flow_status_snapshoot
where snapshoot_time = #{outTime,jdbcType=BIGINT}
</delete>
<insert id="saveList" parameterType="com.byit.model.FlowStatusSnapshoot">
INSERT INTO flow_status_snapshoot
(
status_id, workspace_id, flow_id,
flow_name, `day`, `hour`,
flow_status, snapshoot_time, unstart_node,
runing_node, success_node, fail_node,
kill_node
)
VALUES
<foreach collection="flowStatusSnapshootList" item="flowStatusSnapshoot" separator=",">
(
#{flowStatusSnapshoot.statusId,jdbcType=INTEGER},
#{flowStatusSnapshoot.workspaceId,jdbcType=INTEGER},
#{flowStatusSnapshoot.flowId,jdbcType=INTEGER},
#{flowStatusSnapshoot.flowName,jdbcType=VARCHAR},
#{flowStatusSnapshoot.day,jdbcType=VARCHAR},
#{flowStatusSnapshoot.hour,jdbcType=VARCHAR},
#{flowStatusSnapshoot.flowStatus,jdbcType=INTEGER},
#{flowStatusSnapshoot.snapshootTime,jdbcType=BIGINT},
#{flowStatusSnapshoot.unstartNode,jdbcType=INTEGER},
#{flowStatusSnapshoot.runingNode,jdbcType=INTEGER},
#{flowStatusSnapshoot.successNode,jdbcType=INTEGER},
#{flowStatusSnapshoot.failNode,jdbcType=INTEGER},
#{flowStatusSnapshoot.killNode,jdbcType=INTEGER},
)
</foreach>
</insert>
</mapper>
\ No newline at end of file
......@@ -121,8 +121,33 @@
from job_task_run_log
where log_id = #{logId,jdbcType=INTEGER}
</select>
<select id="findStatusByStartAndEndTime" resultType="com.byit.dto.plugin.StatisticData">
select sum(case when run_code = '0' then 1 else 0 end) as runIng,
sum(case when run_code = '1' or run_code = '3' then 1 else 0 end) as success,
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}
<if test="flowIds != null">
and flow_id in (
<foreach collection="flowIds" item="flowId" separator=",">
#{flowId}
</foreach>
)
</if>
</select>
<select id="findStatisticDataByRunIdAndFlowId" resultType="com.byit.dto.plugin.StatisticData">
select sum(case when run_code = '0' then 1 else 0 end) as runIng,
sum(case when run_code = '1' or run_code = '3' then 1 else 0 end) as success,
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 run_id = #{runId}
and flow_id = #{flowId}
</select>
<delete id="deleteById" parameterType="java.lang.Integer">
<delete id="deleteById" parameterType="java.lang.Integer">
delete from job_task_run_log
where log_id = #{logId,jdbcType=INTEGER}
</delete>
......
......@@ -148,6 +148,33 @@
where flow_id = #{flowId}
and flow_status != '4'
</select>
<select id="findStatusByStartAndEndTime" resultType="com.byit.dto.plugin.StatisticData">
select sum(case when flow_status = '1' then 1 else 0 end ) unstart,
sum(case when flow_status='2' then 1 else 0 end ) runing,
sum(case when flow_status='3' then 1 else 0 end ) stop,
sum(case when flow_status='4' and (flow_run_result = '1' or flow_run_result = '3') then 1 else 0 end ) success,
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}
<if test="flowIds != null">
and flow_id in (
<foreach collection="flowIds" item="flowId" separator=",">
#{flowId}
</foreach>
)
</if>
</select>
<select id="findMaxByFlowId" resultType="com.byit.model.RunRecording">
select <include refid="Base_Column_List" />
from run_recording
where flow_id = #{flowId}
and trigger_time = (select max(trigger_time)
from run_recording
where flow_id = #{flowId}
)
</select>
<delete id="deleteById" parameterType="java.lang.Integer">
<!-- generated @mbg.generated date: 2019-12-25 -->
......
package com.byit.dto.plugin;
import lombok.Data;
import java.util.Map;
/**
* @Description 汇总数据
* @Author guo_m
* @Date 2020-04-01
*/
@Data
public class CollectData {
/**
* 工作流的汇总
*/
private StatisticData flowData;
/**
* 节点的汇总
*/
private StatisticData nodeData;
/**
* 按时间段的汇总
*/
private Map<String, StatisticData> collectMap;
}
package com.byit.dto.plugin;
import lombok.Data;
/**
* @Description 统计数据
* @Author guo_m
* @Date 2020-04-01
*/
@Data
public class StatisticData {
/**
* 未开始
*/
private int unstart;
/**
* 运行中
*/
private int runIng;
/**
* 停止的
*/
private int stop;
/**
* 成功
*/
private int success;
/**
* 失败
*/
private int fail;
/**
* 杀死
*/
private int kill;
}
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