fix: 检测同步任务

This commit is contained in:
taojinlong 2021-05-28 12:19:14 +08:00
parent 8f88821be4
commit 7f48bf4fe4
15 changed files with 869 additions and 24 deletions

View File

@ -21,6 +21,8 @@ public class DatasetTable implements Serializable {
private Long createTime;
private String qrtzInstance;
private String syncStatus;
private String info;

View File

@ -644,6 +644,76 @@ public class DatasetTableExample {
return (Criteria) this;
}
public Criteria andQrtzInstanceIsNull() {
addCriterion("qrtz_instance is null");
return (Criteria) this;
}
public Criteria andQrtzInstanceIsNotNull() {
addCriterion("qrtz_instance is not null");
return (Criteria) this;
}
public Criteria andQrtzInstanceEqualTo(String value) {
addCriterion("qrtz_instance =", value, "qrtzInstance");
return (Criteria) this;
}
public Criteria andQrtzInstanceNotEqualTo(String value) {
addCriterion("qrtz_instance <>", value, "qrtzInstance");
return (Criteria) this;
}
public Criteria andQrtzInstanceGreaterThan(String value) {
addCriterion("qrtz_instance >", value, "qrtzInstance");
return (Criteria) this;
}
public Criteria andQrtzInstanceGreaterThanOrEqualTo(String value) {
addCriterion("qrtz_instance >=", value, "qrtzInstance");
return (Criteria) this;
}
public Criteria andQrtzInstanceLessThan(String value) {
addCriterion("qrtz_instance <", value, "qrtzInstance");
return (Criteria) this;
}
public Criteria andQrtzInstanceLessThanOrEqualTo(String value) {
addCriterion("qrtz_instance <=", value, "qrtzInstance");
return (Criteria) this;
}
public Criteria andQrtzInstanceLike(String value) {
addCriterion("qrtz_instance like", value, "qrtzInstance");
return (Criteria) this;
}
public Criteria andQrtzInstanceNotLike(String value) {
addCriterion("qrtz_instance not like", value, "qrtzInstance");
return (Criteria) this;
}
public Criteria andQrtzInstanceIn(List<String> values) {
addCriterion("qrtz_instance in", values, "qrtzInstance");
return (Criteria) this;
}
public Criteria andQrtzInstanceNotIn(List<String> values) {
addCriterion("qrtz_instance not in", values, "qrtzInstance");
return (Criteria) this;
}
public Criteria andQrtzInstanceBetween(String value1, String value2) {
addCriterion("qrtz_instance between", value1, value2, "qrtzInstance");
return (Criteria) this;
}
public Criteria andQrtzInstanceNotBetween(String value1, String value2) {
addCriterion("qrtz_instance not between", value1, value2, "qrtzInstance");
return (Criteria) this;
}
public Criteria andSyncStatusIsNull() {
addCriterion("sync_status is null");
return (Criteria) this;

View File

@ -0,0 +1,17 @@
package io.dataease.base.domain;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class QrtzSchedulerState extends QrtzSchedulerStateKey implements Serializable {
private Long lastCheckinTime;
private Long checkinInterval;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,460 @@
package io.dataease.base.domain;
import java.util.ArrayList;
import java.util.List;
public class QrtzSchedulerStateExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public QrtzSchedulerStateExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andSchedNameIsNull() {
addCriterion("SCHED_NAME is null");
return (Criteria) this;
}
public Criteria andSchedNameIsNotNull() {
addCriterion("SCHED_NAME is not null");
return (Criteria) this;
}
public Criteria andSchedNameEqualTo(String value) {
addCriterion("SCHED_NAME =", value, "schedName");
return (Criteria) this;
}
public Criteria andSchedNameNotEqualTo(String value) {
addCriterion("SCHED_NAME <>", value, "schedName");
return (Criteria) this;
}
public Criteria andSchedNameGreaterThan(String value) {
addCriterion("SCHED_NAME >", value, "schedName");
return (Criteria) this;
}
public Criteria andSchedNameGreaterThanOrEqualTo(String value) {
addCriterion("SCHED_NAME >=", value, "schedName");
return (Criteria) this;
}
public Criteria andSchedNameLessThan(String value) {
addCriterion("SCHED_NAME <", value, "schedName");
return (Criteria) this;
}
public Criteria andSchedNameLessThanOrEqualTo(String value) {
addCriterion("SCHED_NAME <=", value, "schedName");
return (Criteria) this;
}
public Criteria andSchedNameLike(String value) {
addCriterion("SCHED_NAME like", value, "schedName");
return (Criteria) this;
}
public Criteria andSchedNameNotLike(String value) {
addCriterion("SCHED_NAME not like", value, "schedName");
return (Criteria) this;
}
public Criteria andSchedNameIn(List<String> values) {
addCriterion("SCHED_NAME in", values, "schedName");
return (Criteria) this;
}
public Criteria andSchedNameNotIn(List<String> values) {
addCriterion("SCHED_NAME not in", values, "schedName");
return (Criteria) this;
}
public Criteria andSchedNameBetween(String value1, String value2) {
addCriterion("SCHED_NAME between", value1, value2, "schedName");
return (Criteria) this;
}
public Criteria andSchedNameNotBetween(String value1, String value2) {
addCriterion("SCHED_NAME not between", value1, value2, "schedName");
return (Criteria) this;
}
public Criteria andInstanceNameIsNull() {
addCriterion("INSTANCE_NAME is null");
return (Criteria) this;
}
public Criteria andInstanceNameIsNotNull() {
addCriterion("INSTANCE_NAME is not null");
return (Criteria) this;
}
public Criteria andInstanceNameEqualTo(String value) {
addCriterion("INSTANCE_NAME =", value, "instanceName");
return (Criteria) this;
}
public Criteria andInstanceNameNotEqualTo(String value) {
addCriterion("INSTANCE_NAME <>", value, "instanceName");
return (Criteria) this;
}
public Criteria andInstanceNameGreaterThan(String value) {
addCriterion("INSTANCE_NAME >", value, "instanceName");
return (Criteria) this;
}
public Criteria andInstanceNameGreaterThanOrEqualTo(String value) {
addCriterion("INSTANCE_NAME >=", value, "instanceName");
return (Criteria) this;
}
public Criteria andInstanceNameLessThan(String value) {
addCriterion("INSTANCE_NAME <", value, "instanceName");
return (Criteria) this;
}
public Criteria andInstanceNameLessThanOrEqualTo(String value) {
addCriterion("INSTANCE_NAME <=", value, "instanceName");
return (Criteria) this;
}
public Criteria andInstanceNameLike(String value) {
addCriterion("INSTANCE_NAME like", value, "instanceName");
return (Criteria) this;
}
public Criteria andInstanceNameNotLike(String value) {
addCriterion("INSTANCE_NAME not like", value, "instanceName");
return (Criteria) this;
}
public Criteria andInstanceNameIn(List<String> values) {
addCriterion("INSTANCE_NAME in", values, "instanceName");
return (Criteria) this;
}
public Criteria andInstanceNameNotIn(List<String> values) {
addCriterion("INSTANCE_NAME not in", values, "instanceName");
return (Criteria) this;
}
public Criteria andInstanceNameBetween(String value1, String value2) {
addCriterion("INSTANCE_NAME between", value1, value2, "instanceName");
return (Criteria) this;
}
public Criteria andInstanceNameNotBetween(String value1, String value2) {
addCriterion("INSTANCE_NAME not between", value1, value2, "instanceName");
return (Criteria) this;
}
public Criteria andLastCheckinTimeIsNull() {
addCriterion("LAST_CHECKIN_TIME is null");
return (Criteria) this;
}
public Criteria andLastCheckinTimeIsNotNull() {
addCriterion("LAST_CHECKIN_TIME is not null");
return (Criteria) this;
}
public Criteria andLastCheckinTimeEqualTo(Long value) {
addCriterion("LAST_CHECKIN_TIME =", value, "lastCheckinTime");
return (Criteria) this;
}
public Criteria andLastCheckinTimeNotEqualTo(Long value) {
addCriterion("LAST_CHECKIN_TIME <>", value, "lastCheckinTime");
return (Criteria) this;
}
public Criteria andLastCheckinTimeGreaterThan(Long value) {
addCriterion("LAST_CHECKIN_TIME >", value, "lastCheckinTime");
return (Criteria) this;
}
public Criteria andLastCheckinTimeGreaterThanOrEqualTo(Long value) {
addCriterion("LAST_CHECKIN_TIME >=", value, "lastCheckinTime");
return (Criteria) this;
}
public Criteria andLastCheckinTimeLessThan(Long value) {
addCriterion("LAST_CHECKIN_TIME <", value, "lastCheckinTime");
return (Criteria) this;
}
public Criteria andLastCheckinTimeLessThanOrEqualTo(Long value) {
addCriterion("LAST_CHECKIN_TIME <=", value, "lastCheckinTime");
return (Criteria) this;
}
public Criteria andLastCheckinTimeIn(List<Long> values) {
addCriterion("LAST_CHECKIN_TIME in", values, "lastCheckinTime");
return (Criteria) this;
}
public Criteria andLastCheckinTimeNotIn(List<Long> values) {
addCriterion("LAST_CHECKIN_TIME not in", values, "lastCheckinTime");
return (Criteria) this;
}
public Criteria andLastCheckinTimeBetween(Long value1, Long value2) {
addCriterion("LAST_CHECKIN_TIME between", value1, value2, "lastCheckinTime");
return (Criteria) this;
}
public Criteria andLastCheckinTimeNotBetween(Long value1, Long value2) {
addCriterion("LAST_CHECKIN_TIME not between", value1, value2, "lastCheckinTime");
return (Criteria) this;
}
public Criteria andCheckinIntervalIsNull() {
addCriterion("CHECKIN_INTERVAL is null");
return (Criteria) this;
}
public Criteria andCheckinIntervalIsNotNull() {
addCriterion("CHECKIN_INTERVAL is not null");
return (Criteria) this;
}
public Criteria andCheckinIntervalEqualTo(Long value) {
addCriterion("CHECKIN_INTERVAL =", value, "checkinInterval");
return (Criteria) this;
}
public Criteria andCheckinIntervalNotEqualTo(Long value) {
addCriterion("CHECKIN_INTERVAL <>", value, "checkinInterval");
return (Criteria) this;
}
public Criteria andCheckinIntervalGreaterThan(Long value) {
addCriterion("CHECKIN_INTERVAL >", value, "checkinInterval");
return (Criteria) this;
}
public Criteria andCheckinIntervalGreaterThanOrEqualTo(Long value) {
addCriterion("CHECKIN_INTERVAL >=", value, "checkinInterval");
return (Criteria) this;
}
public Criteria andCheckinIntervalLessThan(Long value) {
addCriterion("CHECKIN_INTERVAL <", value, "checkinInterval");
return (Criteria) this;
}
public Criteria andCheckinIntervalLessThanOrEqualTo(Long value) {
addCriterion("CHECKIN_INTERVAL <=", value, "checkinInterval");
return (Criteria) this;
}
public Criteria andCheckinIntervalIn(List<Long> values) {
addCriterion("CHECKIN_INTERVAL in", values, "checkinInterval");
return (Criteria) this;
}
public Criteria andCheckinIntervalNotIn(List<Long> values) {
addCriterion("CHECKIN_INTERVAL not in", values, "checkinInterval");
return (Criteria) this;
}
public Criteria andCheckinIntervalBetween(Long value1, Long value2) {
addCriterion("CHECKIN_INTERVAL between", value1, value2, "checkinInterval");
return (Criteria) this;
}
public Criteria andCheckinIntervalNotBetween(Long value1, Long value2) {
addCriterion("CHECKIN_INTERVAL not between", value1, value2, "checkinInterval");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@ -0,0 +1,13 @@
package io.dataease.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
public class QrtzSchedulerStateKey implements Serializable {
private String schedName;
private String instanceName;
private static final long serialVersionUID = 1L;
}

View File

@ -10,6 +10,7 @@
<result column="mode" jdbcType="INTEGER" property="mode" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="qrtz_instance" jdbcType="VARCHAR" property="qrtzInstance" />
<result column="sync_status" jdbcType="VARCHAR" property="syncStatus" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.dataease.base.domain.DatasetTable">
@ -74,7 +75,8 @@
</where>
</sql>
<sql id="Base_Column_List">
id, `name`, scene_id, data_source_id, `type`, `mode`, create_by, create_time, sync_status
id, `name`, scene_id, data_source_id, `type`, `mode`, create_by, create_time, qrtz_instance,
sync_status
</sql>
<sql id="Blob_Column_List">
info
@ -130,12 +132,12 @@
<insert id="insert" parameterType="io.dataease.base.domain.DatasetTable">
insert into dataset_table (id, `name`, scene_id,
data_source_id, `type`, `mode`,
create_by, create_time, sync_status,
info)
create_by, create_time, qrtz_instance,
sync_status, info)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{sceneId,jdbcType=VARCHAR},
#{dataSourceId,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{mode,jdbcType=INTEGER},
#{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{syncStatus,jdbcType=VARCHAR},
#{info,jdbcType=LONGVARCHAR})
#{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{qrtzInstance,jdbcType=VARCHAR},
#{syncStatus,jdbcType=VARCHAR}, #{info,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.dataease.base.domain.DatasetTable">
insert into dataset_table
@ -164,6 +166,9 @@
<if test="createTime != null">
create_time,
</if>
<if test="qrtzInstance != null">
qrtz_instance,
</if>
<if test="syncStatus != null">
sync_status,
</if>
@ -196,6 +201,9 @@
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="qrtzInstance != null">
#{qrtzInstance,jdbcType=VARCHAR},
</if>
<if test="syncStatus != null">
#{syncStatus,jdbcType=VARCHAR},
</if>
@ -237,6 +245,9 @@
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.qrtzInstance != null">
qrtz_instance = #{record.qrtzInstance,jdbcType=VARCHAR},
</if>
<if test="record.syncStatus != null">
sync_status = #{record.syncStatus,jdbcType=VARCHAR},
</if>
@ -258,6 +269,7 @@
`mode` = #{record.mode,jdbcType=INTEGER},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
qrtz_instance = #{record.qrtzInstance,jdbcType=VARCHAR},
sync_status = #{record.syncStatus,jdbcType=VARCHAR},
info = #{record.info,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
@ -274,6 +286,7 @@
`mode` = #{record.mode,jdbcType=INTEGER},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
qrtz_instance = #{record.qrtzInstance,jdbcType=VARCHAR},
sync_status = #{record.syncStatus,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -303,6 +316,9 @@
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="qrtzInstance != null">
qrtz_instance = #{qrtzInstance,jdbcType=VARCHAR},
</if>
<if test="syncStatus != null">
sync_status = #{syncStatus,jdbcType=VARCHAR},
</if>
@ -321,6 +337,7 @@
`mode` = #{mode,jdbcType=INTEGER},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
qrtz_instance = #{qrtzInstance,jdbcType=VARCHAR},
sync_status = #{syncStatus,jdbcType=VARCHAR},
info = #{info,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
@ -334,6 +351,7 @@
`mode` = #{mode,jdbcType=INTEGER},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
qrtz_instance = #{qrtzInstance,jdbcType=VARCHAR},
sync_status = #{syncStatus,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>

View File

@ -0,0 +1,31 @@
package io.dataease.base.mapper;
import io.dataease.base.domain.QrtzSchedulerState;
import io.dataease.base.domain.QrtzSchedulerStateExample;
import io.dataease.base.domain.QrtzSchedulerStateKey;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface QrtzSchedulerStateMapper {
long countByExample(QrtzSchedulerStateExample example);
int deleteByExample(QrtzSchedulerStateExample example);
int deleteByPrimaryKey(QrtzSchedulerStateKey key);
int insert(QrtzSchedulerState record);
int insertSelective(QrtzSchedulerState record);
List<QrtzSchedulerState> selectByExample(QrtzSchedulerStateExample example);
QrtzSchedulerState selectByPrimaryKey(QrtzSchedulerStateKey key);
int updateByExampleSelective(@Param("record") QrtzSchedulerState record, @Param("example") QrtzSchedulerStateExample example);
int updateByExample(@Param("record") QrtzSchedulerState record, @Param("example") QrtzSchedulerStateExample example);
int updateByPrimaryKeySelective(QrtzSchedulerState record);
int updateByPrimaryKey(QrtzSchedulerState record);
}

View File

@ -0,0 +1,196 @@
<?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="io.dataease.base.mapper.QrtzSchedulerStateMapper">
<resultMap id="BaseResultMap" type="io.dataease.base.domain.QrtzSchedulerState">
<id column="SCHED_NAME" jdbcType="VARCHAR" property="schedName" />
<id column="INSTANCE_NAME" jdbcType="VARCHAR" property="instanceName" />
<result column="LAST_CHECKIN_TIME" jdbcType="BIGINT" property="lastCheckinTime" />
<result column="CHECKIN_INTERVAL" jdbcType="BIGINT" property="checkinInterval" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
SCHED_NAME, INSTANCE_NAME, LAST_CHECKIN_TIME, CHECKIN_INTERVAL
</sql>
<select id="selectByExample" parameterType="io.dataease.base.domain.QrtzSchedulerStateExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from qrtz_scheduler_state
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="io.dataease.base.domain.QrtzSchedulerStateKey" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from qrtz_scheduler_state
where SCHED_NAME = #{schedName,jdbcType=VARCHAR}
and INSTANCE_NAME = #{instanceName,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="io.dataease.base.domain.QrtzSchedulerStateKey">
delete from qrtz_scheduler_state
where SCHED_NAME = #{schedName,jdbcType=VARCHAR}
and INSTANCE_NAME = #{instanceName,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.dataease.base.domain.QrtzSchedulerStateExample">
delete from qrtz_scheduler_state
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.dataease.base.domain.QrtzSchedulerState">
insert into qrtz_scheduler_state (SCHED_NAME, INSTANCE_NAME, LAST_CHECKIN_TIME,
CHECKIN_INTERVAL)
values (#{schedName,jdbcType=VARCHAR}, #{instanceName,jdbcType=VARCHAR}, #{lastCheckinTime,jdbcType=BIGINT},
#{checkinInterval,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="io.dataease.base.domain.QrtzSchedulerState">
insert into qrtz_scheduler_state
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="schedName != null">
SCHED_NAME,
</if>
<if test="instanceName != null">
INSTANCE_NAME,
</if>
<if test="lastCheckinTime != null">
LAST_CHECKIN_TIME,
</if>
<if test="checkinInterval != null">
CHECKIN_INTERVAL,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="schedName != null">
#{schedName,jdbcType=VARCHAR},
</if>
<if test="instanceName != null">
#{instanceName,jdbcType=VARCHAR},
</if>
<if test="lastCheckinTime != null">
#{lastCheckinTime,jdbcType=BIGINT},
</if>
<if test="checkinInterval != null">
#{checkinInterval,jdbcType=BIGINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.dataease.base.domain.QrtzSchedulerStateExample" resultType="java.lang.Long">
select count(*) from qrtz_scheduler_state
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update qrtz_scheduler_state
<set>
<if test="record.schedName != null">
SCHED_NAME = #{record.schedName,jdbcType=VARCHAR},
</if>
<if test="record.instanceName != null">
INSTANCE_NAME = #{record.instanceName,jdbcType=VARCHAR},
</if>
<if test="record.lastCheckinTime != null">
LAST_CHECKIN_TIME = #{record.lastCheckinTime,jdbcType=BIGINT},
</if>
<if test="record.checkinInterval != null">
CHECKIN_INTERVAL = #{record.checkinInterval,jdbcType=BIGINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update qrtz_scheduler_state
set SCHED_NAME = #{record.schedName,jdbcType=VARCHAR},
INSTANCE_NAME = #{record.instanceName,jdbcType=VARCHAR},
LAST_CHECKIN_TIME = #{record.lastCheckinTime,jdbcType=BIGINT},
CHECKIN_INTERVAL = #{record.checkinInterval,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.dataease.base.domain.QrtzSchedulerState">
update qrtz_scheduler_state
<set>
<if test="lastCheckinTime != null">
LAST_CHECKIN_TIME = #{lastCheckinTime,jdbcType=BIGINT},
</if>
<if test="checkinInterval != null">
CHECKIN_INTERVAL = #{checkinInterval,jdbcType=BIGINT},
</if>
</set>
where SCHED_NAME = #{schedName,jdbcType=VARCHAR}
and INSTANCE_NAME = #{instanceName,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.QrtzSchedulerState">
update qrtz_scheduler_state
set LAST_CHECKIN_TIME = #{lastCheckinTime,jdbcType=BIGINT},
CHECKIN_INTERVAL = #{checkinInterval,jdbcType=BIGINT}
where SCHED_NAME = #{schedName,jdbcType=VARCHAR}
and INSTANCE_NAME = #{instanceName,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -145,7 +145,7 @@ public class DatasourceService {
DatasourceRequest datasourceRequest = new DatasourceRequest();
datasourceRequest.setDatasource(datasource);
datasourceProvider.initDataSource(datasourceRequest);
LogUtil.error("Succsss to init datasource connection pool: " + datasource.getName());
LogUtil.info("Succsss to init datasource connection pool: " + datasource.getName());
}catch (Exception e){
LogUtil.error("Failed to init datasource connection pool: " + datasource.getName(), e);
}

View File

@ -1,5 +1,6 @@
package io.dataease.job.sechedule;
import com.google.gson.Gson;
import io.dataease.commons.utils.LogUtil;
import org.quartz.*;

View File

@ -15,7 +15,7 @@ public class ExtractDataJob extends DeScheduleJob{
@Override
void businessExecute(JobExecutionContext context) {
extractDataService.extractData(datasetTableId, taskId, updateType);
extractDataService.extractData(datasetTableId, taskId, updateType, context);
}
}

View File

@ -1,11 +1,10 @@
package io.dataease.service.dataset;
import com.fit2cloud.quartz.anno.QuartzScheduled;
import com.google.gson.Gson;
import io.dataease.base.domain.*;
import io.dataease.base.mapper.DatasetTableIncrementalConfigMapper;
import io.dataease.base.mapper.DatasetTableMapper;
import io.dataease.base.mapper.DatasourceMapper;
import io.dataease.base.mapper.*;
import io.dataease.base.mapper.ext.ExtDataSetTableMapper;
import io.dataease.commons.constants.JobStatus;
import io.dataease.commons.utils.*;
@ -75,6 +74,10 @@ public class DataSetTableService {
private DataSetTableUnionService dataSetTableUnionService;
@Resource
private DataSetTableTaskLogService dataSetTableTaskLogService;
@Resource
private QrtzSchedulerStateMapper qrtzSchedulerStateMapper;
@Resource
private DatasetTableTaskLogMapper datasetTableTaskLogMapper;
@Value("${upload.file.path}")
private String path;
@ -106,7 +109,7 @@ public class DataSetTableService {
saveTableField(datasetTable);
if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "excel")) {
commonThreadPool.addTask(() -> {
extractDataService.extractData(datasetTable.getId(), null, "all_scope");
extractDataService.extractData(datasetTable.getId(), null, "all_scope", null);
});
}
}
@ -867,22 +870,48 @@ public class DataSetTableService {
}
public Boolean checkDorisTableIsExists(String id) throws Exception {
// Datasource dorisDatasource = (Datasource) CommonBeanFactory.getBean("DorisDatasource");
// JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class);
// DatasourceRequest datasourceRequest = new DatasourceRequest();
// datasourceRequest.setDatasource(dorisDatasource);
// QueryProvider qp = ProviderFactory.getQueryProvider(dorisDatasource.getType());
// datasourceRequest.setQuery(qp.searchTable(DorisTableUtils.dorisName(id)));
// List<String[]> data = jdbcProvider.getData(datasourceRequest);
// return CollectionUtils.isNotEmpty(data);
return true;
Datasource dorisDatasource = (Datasource) CommonBeanFactory.getBean("DorisDatasource");
JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class);
DatasourceRequest datasourceRequest = new DatasourceRequest();
datasourceRequest.setDatasource(dorisDatasource);
QueryProvider qp = ProviderFactory.getQueryProvider(dorisDatasource.getType());
datasourceRequest.setQuery(qp.searchTable(DorisTableUtils.dorisName(id)));
List<String[]> data = jdbcProvider.getData(datasourceRequest);
return CollectionUtils.isNotEmpty(data);
}
@QuartzScheduled(cron = "0 0/3 * * * ?")
public void updateDatasetTableStatus(){
DatasetTable record = new DatasetTable();
record.setSyncStatus(JobStatus.Completed.name());
List<QrtzSchedulerState> qrtzSchedulerStates = qrtzSchedulerStateMapper.selectByExample(null);
List<String> activeQrtzInstances = qrtzSchedulerStates.stream().filter(qrtzSchedulerState -> qrtzSchedulerState.getLastCheckinTime() + qrtzSchedulerState.getCheckinInterval() + 1000 > System.currentTimeMillis()).map(QrtzSchedulerStateKey::getInstanceName).collect(Collectors.toList());
List<DatasetTable> jobStoppeddDatasetTables = new ArrayList<>();
DatasetTableExample example = new DatasetTableExample();
example.createCriteria().andSyncStatusEqualTo(JobStatus.Underway.name());
datasetTableMapper.selectByExample(example).forEach(datasetTable -> {
if(StringUtils.isEmpty(datasetTable.getQrtzInstance()) || !activeQrtzInstances.contains(datasetTable.getQrtzInstance().substring(0, datasetTable.getQrtzInstance().length() - 13))){
jobStoppeddDatasetTables.add(datasetTable);
}
});
if(CollectionUtils.isEmpty(jobStoppeddDatasetTables)){
return;
}
DatasetTable record = new DatasetTable();
record.setSyncStatus(JobStatus.Completed.name());
example.clear();
example.createCriteria().andSyncStatusEqualTo(JobStatus.Underway.name()).andIdIn(jobStoppeddDatasetTables.stream().map(DatasetTable::getId).collect(Collectors.toList()));
datasetTableMapper.updateByExampleSelective(record, example);
DatasetTableTaskLog datasetTableTaskLog = new DatasetTableTaskLog();
datasetTableTaskLog.setStatus(JobStatus.Error.name());
datasetTableTaskLog.setInfo("Job stopped due to system error.");
DatasetTableTaskLogExample datasetTableTaskLogExample = new DatasetTableTaskLogExample();
datasetTableTaskLogExample.createCriteria().andStatusEqualTo(JobStatus.Underway.name()).andTableIdIn(jobStoppeddDatasetTables.stream().map(DatasetTable::getId).collect(Collectors.toList()));
datasetTableTaskLogMapper.updateByExampleSelective(datasetTableTaskLog, datasetTableTaskLogExample);
}
}

View File

@ -63,6 +63,7 @@ import org.pentaho.di.trans.steps.textfileoutput.TextFileOutputMeta;
import org.pentaho.di.trans.steps.userdefinedjavaclass.UserDefinedJavaClassDef;
import org.pentaho.di.trans.steps.userdefinedjavaclass.UserDefinedJavaClassMeta;
import org.pentaho.di.www.SlaveServerJobStatus;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -183,7 +184,7 @@ public class ExtractDataService {
return datasetTableMapper.updateByExampleSelective(datasetTable, example) == 0;
}
public void extractData(String datasetTableId, String taskId, String type) {
public void extractData(String datasetTableId, String taskId, String type, JobExecutionContext context) {
DatasetTable datasetTable = dataSetTableService.get(datasetTableId);
if(updateSyncStatus(datasetTable)){
LogUtil.info("Skip synchronization task for table : " + datasetTableId);
@ -193,6 +194,10 @@ public class ExtractDataService {
UpdateType updateType = UpdateType.valueOf(type);
Datasource datasource = new Datasource();
try {
if(context != null){
datasetTable.setQrtzInstance(context.getFireInstanceId());
datasetTableMapper.updateByPrimaryKeySelective(datasetTable);
}
if (StringUtils.isNotEmpty(datasetTable.getDataSourceId())) {
datasource = datasourceMapper.selectByPrimaryKey(datasetTable.getDataSourceId());
} else {

View File

@ -1 +1,2 @@
ALTER TABLE `dataease`.`dataset_table` ADD COLUMN `sync_status` VARCHAR(45) NULL AFTER `create_time`;
ALTER TABLE `dataset_table` ADD COLUMN `sync_status` VARCHAR(45) NULL AFTER `create_time`;
ALTER TABLE `dataset_table` ADD COLUMN `qrtz_instance` VARCHAR(1024) NULL AFTER `create_time`;

View File

@ -498,6 +498,7 @@ export default {
this.update_task = false
this.resetTaskForm()
this.listTask()
this.listTaskLog()
})
},
deleteTask(task) {
@ -514,6 +515,7 @@ export default {
})
this.resetTaskForm()
this.listTask()
this.listTaskLog()
})
}).catch(() => {
})