提交 7fc6296b authored 作者: taojinlong's avatar taojinlong

feat: 检测同步状态

上级 dccfd6ec
package io.dataease.base.mapper.ext;
public interface UtilMapper {
Long currentTimestamp();
}
<?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.ext.UtilMapper">
<select id="currentTimestamp" resultType="java.lang.Long">
select unix_timestamp(current_timestamp()) * 1000 as c_timestamp
</select>
</mapper>
...@@ -6,6 +6,7 @@ import com.google.gson.Gson; ...@@ -6,6 +6,7 @@ import com.google.gson.Gson;
import io.dataease.base.domain.*; import io.dataease.base.domain.*;
import io.dataease.base.mapper.*; import io.dataease.base.mapper.*;
import io.dataease.base.mapper.ext.ExtDataSetTableMapper; import io.dataease.base.mapper.ext.ExtDataSetTableMapper;
import io.dataease.base.mapper.ext.UtilMapper;
import io.dataease.commons.constants.JobStatus; import io.dataease.commons.constants.JobStatus;
import io.dataease.commons.utils.*; import io.dataease.commons.utils.*;
import io.dataease.controller.request.dataset.DataSetTableRequest; import io.dataease.controller.request.dataset.DataSetTableRequest;
...@@ -880,12 +881,14 @@ public class DataSetTableService { ...@@ -880,12 +881,14 @@ public class DataSetTableService {
return CollectionUtils.isNotEmpty(data); return CollectionUtils.isNotEmpty(data);
} }
@Resource
private UtilMapper utilMapper;
@QuartzScheduled(cron = "0 0/3 * * * ?") @QuartzScheduled(cron = "0 0/3 * * * ?")
public void updateDatasetTableStatus(){ public void updateDatasetTableStatus(){
List<QrtzSchedulerState> qrtzSchedulerStates = qrtzSchedulerStateMapper.selectByExample(null); 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<String> activeQrtzInstances = qrtzSchedulerStates.stream().filter(qrtzSchedulerState -> qrtzSchedulerState.getLastCheckinTime() + qrtzSchedulerState.getCheckinInterval() + 1000 > utilMapper.currentTimestamp()).map(QrtzSchedulerStateKey::getInstanceName).collect(Collectors.toList());
List<DatasetTable> jobStoppeddDatasetTables = new ArrayList<>(); List<DatasetTable> jobStoppeddDatasetTables = new ArrayList<>();
DatasetTableExample example = new DatasetTableExample(); DatasetTableExample example = new DatasetTableExample();
example.createCriteria().andSyncStatusEqualTo(JobStatus.Underway.name()); example.createCriteria().andSyncStatusEqualTo(JobStatus.Underway.name());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论