fix: 任务列表上次执行时间与执行记录执行时间不一致

This commit is contained in:
taojinlong 2021-07-29 12:15:40 +08:00
parent 9536f730ed
commit 86f0791a4f
3 changed files with 14 additions and 10 deletions

View File

@ -117,7 +117,8 @@ public class DataSetTableTaskService {
example.or(example.createCriteria().andIdEqualTo(datasetTable.getId()).andSyncStatusIsNull()); example.or(example.createCriteria().andIdEqualTo(datasetTable.getId()).andSyncStatusIsNull());
Boolean existSyncTask = datasetTableMapper.updateByExampleSelective(datasetTable, example) == 0; Boolean existSyncTask = datasetTableMapper.updateByExampleSelective(datasetTable, example) == 0;
if(!existSyncTask){ if(!existSyncTask){
datasetTableTask.setLastExecTime(System.currentTimeMillis()); Long startTime = System.currentTimeMillis();
datasetTableTask.setLastExecTime(startTime);
datasetTableTask.setLastExecStatus(JobStatus.Underway.name()); datasetTableTask.setLastExecStatus(JobStatus.Underway.name());
datasetTableTask.setStatus(TaskStatus.Exec.name()); datasetTableTask.setStatus(TaskStatus.Exec.name());
update(datasetTableTask); update(datasetTableTask);
@ -125,7 +126,7 @@ public class DataSetTableTaskService {
datasetTableTaskLog.setTableId(datasetTableTask.getTableId()); datasetTableTaskLog.setTableId(datasetTableTask.getTableId());
datasetTableTaskLog.setTaskId(datasetTableTask.getId()); datasetTableTaskLog.setTaskId(datasetTableTask.getId());
datasetTableTaskLog.setStatus(JobStatus.Underway.name()); datasetTableTaskLog.setStatus(JobStatus.Underway.name());
datasetTableTaskLog.setStartTime(System.currentTimeMillis()); datasetTableTaskLog.setStartTime(startTime);
datasetTableTaskLog.setTriggerType(TriggerType.Custom.name()); datasetTableTaskLog.setTriggerType(TriggerType.Custom.name());
dataSetTableTaskLogService.save(datasetTableTaskLog); dataSetTableTaskLogService.save(datasetTableTaskLog);
} }

View File

@ -124,7 +124,7 @@ public class ExtractDataService {
"fi\n" + "fi\n" +
"rm -rf %s\n"; "rm -rf %s\n";
public synchronized boolean existSyncTask(DatasetTable datasetTable, DatasetTableTask datasetTableTask) { public synchronized boolean existSyncTask(DatasetTable datasetTable, DatasetTableTask datasetTableTask, Long startTime) {
datasetTable.setSyncStatus(JobStatus.Underway.name()); datasetTable.setSyncStatus(JobStatus.Underway.name());
DatasetTableExample example = new DatasetTableExample(); DatasetTableExample example = new DatasetTableExample();
example.createCriteria().andIdEqualTo(datasetTable.getId()).andSyncStatusNotEqualTo(JobStatus.Underway.name()); example.createCriteria().andIdEqualTo(datasetTable.getId()).andSyncStatusNotEqualTo(JobStatus.Underway.name());
@ -141,7 +141,7 @@ public class ExtractDataService {
} }
return true; return true;
} else { } else {
datasetTableTask.setLastExecTime(System.currentTimeMillis()); datasetTableTask.setLastExecTime(startTime);
datasetTableTask.setLastExecStatus(JobStatus.Underway.name()); datasetTableTask.setLastExecStatus(JobStatus.Underway.name());
datasetTableTask.setStatus(TaskStatus.Exec.name()); datasetTableTask.setStatus(TaskStatus.Exec.name());
dataSetTableTaskService.update(datasetTableTask); dataSetTableTaskService.update(datasetTableTask);
@ -238,12 +238,13 @@ public class ExtractDataService {
LogUtil.info("Skip synchronization task, task ID : " + datasetTableTask.getId()); LogUtil.info("Skip synchronization task, task ID : " + datasetTableTask.getId());
return; return;
} }
if (existSyncTask(datasetTable, datasetTableTask)) {
Long startTime = System.currentTimeMillis();
if (existSyncTask(datasetTable, datasetTableTask, startTime)) {
LogUtil.info("Skip synchronization task for dataset, dataset ID : " + datasetTableId); LogUtil.info("Skip synchronization task for dataset, dataset ID : " + datasetTableId);
return; return;
} }
DatasetTableTaskLog datasetTableTaskLog = getDatasetTableTaskLog(datasetTableId, taskId, startTime);
DatasetTableTaskLog datasetTableTaskLog = getDatasetTableTaskLog(datasetTableId, taskId);
UpdateType updateType = UpdateType.valueOf(type); UpdateType updateType = UpdateType.valueOf(type);
if (context != null) { if (context != null) {
datasetTable.setQrtzInstance(context.getFireInstanceId()); datasetTable.setQrtzInstance(context.getFireInstanceId());
@ -520,11 +521,12 @@ public class ExtractDataService {
} }
} }
private DatasetTableTaskLog getDatasetTableTaskLog(String datasetTableId, String taskId) { private DatasetTableTaskLog getDatasetTableTaskLog(String datasetTableId, String taskId, Long startTime) {
DatasetTableTaskLog datasetTableTaskLog = new DatasetTableTaskLog(); DatasetTableTaskLog datasetTableTaskLog = new DatasetTableTaskLog();
datasetTableTaskLog.setTableId(datasetTableId); datasetTableTaskLog.setTableId(datasetTableId);
datasetTableTaskLog.setTaskId(taskId); datasetTableTaskLog.setTaskId(taskId);
datasetTableTaskLog.setStatus(JobStatus.Underway.name()); datasetTableTaskLog.setStatus(JobStatus.Underway.name());
datasetTableTaskLog.setTriggerType(TriggerType.Custom.name());
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
List<DatasetTableTaskLog> datasetTableTaskLogs = dataSetTableTaskLogService.select(datasetTableTaskLog); List<DatasetTableTaskLog> datasetTableTaskLogs = dataSetTableTaskLogService.select(datasetTableTaskLog);
if (CollectionUtils.isNotEmpty(datasetTableTaskLogs)) { if (CollectionUtils.isNotEmpty(datasetTableTaskLogs)) {
@ -535,7 +537,8 @@ public class ExtractDataService {
} catch (Exception ignore) { } catch (Exception ignore) {
} }
} }
datasetTableTaskLog.setStartTime(System.currentTimeMillis()); datasetTableTaskLog.setTriggerType(TriggerType.Cron.name());
datasetTableTaskLog.setStartTime(startTime);
dataSetTableTaskLogService.save(datasetTableTaskLog); dataSetTableTaskLogService.save(datasetTableTaskLog);
return datasetTableTaskLog; return datasetTableTaskLog;
} }

View File

@ -47,7 +47,7 @@
<el-table-column prop="nextExecTime" :label="$t('dataset.task.next_exec_time')"> <el-table-column prop="nextExecTime" :label="$t('dataset.task.next_exec_time')">
<template slot-scope="scope"> <template slot-scope="scope">
<span v-if="scope.row.nextExecTime && scope.row.nextExecTime !== -1 && scope.row.rate !== 'SIMPLE'"> <span v-if="scope.row.nextExecTime && scope.row.nextExecTime !== -1 && scope.row.rate !== 'SIMPLE'&& scope.row.status !== 'Pending'">
{{ scope.row.nextExecTime | timestampFormatDate }} {{ scope.row.nextExecTime | timestampFormatDate }}
</span> </span>
<span v-if="!scope.row.nextExecTime || scope.row.rate === 'SIMPLE'" /> <span v-if="!scope.row.nextExecTime || scope.row.rate === 'SIMPLE'" />