Commit 84f12afb by guo_minglei@163.com

修改存储方式

parent 1ead9b24
package com.byit.mapper;
import com.byit.model.FlowStatusSnapshoot;
import org.apache.ibatis.annotations.Param;
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(@Param("date") String date, @Param("hour")String hour);
Integer exist(String date, String hour);
/**
* 批量保存
* @param flowStatusSnapshootList
* @return
*/
int saveList(List<FlowStatusSnapshoot> flowStatusSnapshootList);
/**
* 删除过期时间的快照
* 删除太长时间的快照
* @param outTime
* @return
*/
......
......@@ -3,7 +3,6 @@ package com.byit.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
......@@ -55,18 +54,42 @@ public class FlowStatusSnapshoot implements Serializable {
private Integer flowStatus;
/**
* 工作流内节点状态 (统计 未运行、运行中、成功、失败、kill的节点数目)
*/
@ApiModelProperty("工作流内节点状态 (统计 未运行、运行中、成功、失败、kill的节点数目)")
private String nodeStatus;
/**
* 快照的时间戳
*/
@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
......@@ -77,12 +77,11 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
flowStatusSnapshoot.setFlowName(flow.getFlowName());
flowStatusSnapshoot.setWorkspaceId(flow.getWorkspaceId());
flowStatusSnapshoot.setSnapshootTime(hourTime);
StatisticData nodeStatistic = new StatisticData();
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")){
nodeStatistic.setUnstart(flow.getFlowNodeCount());
flowStatusSnapshoot.setFlowStatus(Integer.valueOf(runRecording.getFlowStatus()));
}else {
switch (runRecording.getFlowRunResult()){
......@@ -93,17 +92,21 @@ public class StatusSnapshootThreadRunHelper extends BaseThreadRunHelper {
case "5" : flowStatusSnapshoot.setFlowStatus(6); break;
default : flowStatusSnapshoot.setFlowStatus(5); break;
}
//获取运行实例下各类状态的节点数目
nodeStatistic = jobTaskRunLogMapper.findStatisticDataByRunIdAndFlowId(runRecording.getRunId(), flow.getFlowId());
if (nodeStatistic != null){
int sum = nodeStatistic.getFail() + nodeStatistic.getSuccess() + nodeStatistic.getRunIng() + nodeStatistic.getKill();
nodeStatistic.setUnstart(flow.getFlowNodeCount() - sum);
}else {
nodeStatistic.setUnstart(flow.getFlowNodeCount());
}
}
//获取运行实例下各类状态的节点数目
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());
}
}
flowStatusSnapshoot.setNodeStatus(JSON.toJSONString(nodeStatistic));
flowStatusSnapshootList.add(flowStatusSnapshoot);
}
});
......
......@@ -10,13 +10,17 @@
<result column="day" jdbcType="VARCHAR" property="day" />
<result column="hour" jdbcType="VARCHAR" property="hour" />
<result column="flow_status" jdbcType="INTEGER" property="flowStatus" />
<result column="node_status" jdbcType="VARCHAR" property="nodeStatus" />
<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, node_status,
snapshoot_time
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 -->
......@@ -25,20 +29,24 @@
from flow_status_snapshoot
where status_id = #{statusId,jdbcType=INTEGER}
</select>
<select id="exist" resultType="java.lang.Integer">
select count(1)
from flow_status_snapshoot
where 'day' = #{date} and `hour` = #{hour}
</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>
<delete id="deleteOutSnapShoot" parameterType="java.lang.Long">
delete from flow_status_snapshoot
where snapshoot_time = #{outTime,jdbcType=BIGINT}
</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
......@@ -64,12 +72,24 @@
<if test="flowStatus != null">
flow_status,
</if>
<if test="nodeStatus != null">
node_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">
......@@ -93,31 +113,26 @@
<if test="flowStatus != null">
#{flowStatus,jdbcType=INTEGER},
</if>
<if test="nodeStatus != null">
#{nodeStatus,jdbcType=VARCHAR},
</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>
<insert id="saveList" parameterType="com.byit.model.FlowStatusSnapshoot">
INSERT INTO flow_status_snapshoot
(workspace_id, flow_id, flow_name, `day`, `hour`, flow_status, node_status, snapshoot_time)
VALUES
<foreach collection="flowStatusSnapshootList" item="flowStatusSnapshoot" separator =",">
(
#{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.nodeStatus,jdbcType=VARCHAR},
#{flowStatusSnapshoot.snapshootTime,jdbcType=BIGINT},
)
</foreach>
</insert>
<update id="updateByIdSelective" parameterType="com.byit.model.FlowStatusSnapshoot">
<!-- generated @mbg.generated date: 2020-04-02 -->
update flow_status_snapshoot
......@@ -140,14 +155,80 @@
<if test="flowStatus != null">
flow_status = #{flowStatus,jdbcType=INTEGER},
</if>
<if test="nodeStatus != null">
node_status = #{nodeStatus,jdbcType=VARCHAR},
</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>
<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
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