forked from github/dataease
fix: excel 数据集记录日志
This commit is contained in:
parent
4ad1344872
commit
40a0e196e4
@ -35,7 +35,7 @@ public class DataSetTableTaskLogController {
|
||||
@ApiOperation("保存")
|
||||
@PostMapping("save")
|
||||
public DatasetTableTaskLog save(@RequestBody DatasetTableTaskLog datasetTableTaskLog) {
|
||||
return dataSetTableTaskLogService.save(datasetTableTaskLog);
|
||||
return dataSetTableTaskLogService.save(datasetTableTaskLog, true);
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询")
|
||||
|
@ -33,8 +33,8 @@ public class DataSetTableTaskLogService {
|
||||
@Resource
|
||||
private DatasetTableTaskMapper datasetTableTaskMapper;
|
||||
|
||||
public DatasetTableTaskLog save(DatasetTableTaskLog datasetTableTaskLog) {
|
||||
if(datasetTableTaskMapper.selectByPrimaryKey(datasetTableTaskLog.getTaskId()) == null){
|
||||
public DatasetTableTaskLog save(DatasetTableTaskLog datasetTableTaskLog, Boolean hasTask) {
|
||||
if(hasTask && datasetTableTaskMapper.selectByPrimaryKey(datasetTableTaskLog.getTaskId()) == null){
|
||||
return datasetTableTaskLog;
|
||||
}
|
||||
if (StringUtils.isEmpty(datasetTableTaskLog.getId())) {
|
||||
|
@ -137,7 +137,7 @@ public class DataSetTableTaskService {
|
||||
datasetTableTaskLog.setStatus(JobStatus.Underway.name());
|
||||
datasetTableTaskLog.setStartTime(startTime);
|
||||
datasetTableTaskLog.setTriggerType(TriggerType.Custom.name());
|
||||
dataSetTableTaskLogService.save(datasetTableTaskLog);
|
||||
dataSetTableTaskLogService.save(datasetTableTaskLog, true);
|
||||
}
|
||||
return existSyncTask;
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ public class ExtractDataService {
|
||||
return o1.getColumnIndex().compareTo(o2.getColumnIndex());
|
||||
});
|
||||
|
||||
DatasetTableTaskLog datasetTableTaskLog = writeDatasetTableTaskLog(datasetTableId, ops);
|
||||
DatasetTableTaskLog datasetTableTaskLog = writeExcelLog(datasetTableId, ops);
|
||||
switch (updateType) {
|
||||
case all_scope: // 全量更新
|
||||
try {
|
||||
@ -193,7 +193,7 @@ public class ExtractDataService {
|
||||
extractExcelDataForSimpleMode(datasetTable, "all_scope");
|
||||
}
|
||||
replaceTable(TableUtils.tableName(datasetTableId));
|
||||
saveSuccessLog(datasetTableTaskLog);
|
||||
saveSuccessLog(datasetTableTaskLog, false);
|
||||
updateTableStatus(datasetTableId, JobStatus.Completed, execTime);
|
||||
if (ops.equalsIgnoreCase("替换")) {
|
||||
List<DatasetTableField> oldFileds = getDatasetTableFields(datasetTable.getId());
|
||||
@ -226,7 +226,7 @@ public class ExtractDataService {
|
||||
toDelete.forEach(datasetTableField -> dataSetTableFieldsService.delete(datasetTableField.getId()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
saveErrorLog(datasetTableTaskLog, e);
|
||||
saveErrorLog(datasetTableTaskLog, e, false);
|
||||
updateTableStatus(datasetTableId, JobStatus.Error, null);
|
||||
dropDorisTable(TableUtils.tmpName(TableUtils.tableName(datasetTableId)));
|
||||
} finally {
|
||||
@ -245,10 +245,10 @@ public class ExtractDataService {
|
||||
} else {
|
||||
extractExcelDataForSimpleMode(datasetTable, "incremental_add");
|
||||
}
|
||||
saveSuccessLog(datasetTableTaskLog);
|
||||
saveSuccessLog(datasetTableTaskLog, false);
|
||||
updateTableStatus(datasetTableId, JobStatus.Completed, execTime);
|
||||
} catch (Exception e) {
|
||||
saveErrorLog(datasetTableTaskLog, e);
|
||||
saveErrorLog(datasetTableTaskLog, e, false);
|
||||
updateTableStatus(datasetTableId, JobStatus.Error, null);
|
||||
} finally {
|
||||
deleteFile("incremental_add", datasetTableId);
|
||||
@ -314,11 +314,11 @@ public class ExtractDataService {
|
||||
execTime = System.currentTimeMillis();
|
||||
extractData(datasetTable, datasource, datasetTableFields, "all_scope", null);
|
||||
replaceTable(TableUtils.tableName(datasetTableId));
|
||||
saveSuccessLog(datasetTableTaskLog);
|
||||
saveSuccessLog(datasetTableTaskLog, true);
|
||||
msg = true;
|
||||
lastExecStatus = JobStatus.Completed;
|
||||
} catch (Exception e) {
|
||||
saveErrorLog(datasetTableTaskLog, e);
|
||||
saveErrorLog(datasetTableTaskLog, e, true);
|
||||
msg = false;
|
||||
lastExecStatus = JobStatus.Error;
|
||||
execTime = null;
|
||||
@ -374,11 +374,11 @@ public class ExtractDataService {
|
||||
extractData(datasetTable, datasource, datasetTableFields, "incremental_delete", sql);
|
||||
}
|
||||
}
|
||||
saveSuccessLog(datasetTableTaskLog);
|
||||
saveSuccessLog(datasetTableTaskLog, true);
|
||||
msg = true;
|
||||
lastExecStatus = JobStatus.Completed;
|
||||
} catch (Exception e) {
|
||||
saveErrorLog(datasetTableTaskLog, e);
|
||||
saveErrorLog(datasetTableTaskLog, e, true);
|
||||
msg = false;
|
||||
lastExecStatus = JobStatus.Error;
|
||||
execTime = null;
|
||||
@ -600,18 +600,18 @@ public class ExtractDataService {
|
||||
dataSetTableService.updateByExampleSelective(datasetTableRecord, example);
|
||||
}
|
||||
|
||||
private void saveSuccessLog(DatasetTableTaskLog datasetTableTaskLog) {
|
||||
private void saveSuccessLog(DatasetTableTaskLog datasetTableTaskLog, Boolean hasTask) {
|
||||
datasetTableTaskLog.setStatus(JobStatus.Completed.name());
|
||||
datasetTableTaskLog.setEndTime(System.currentTimeMillis());
|
||||
dataSetTableTaskLogService.save(datasetTableTaskLog);
|
||||
dataSetTableTaskLogService.save(datasetTableTaskLog, hasTask);
|
||||
}
|
||||
|
||||
private void saveErrorLog(DatasetTableTaskLog datasetTableTaskLog, Exception e) {
|
||||
private void saveErrorLog(DatasetTableTaskLog datasetTableTaskLog, Exception e, Boolean hasTask) {
|
||||
LogUtil.error("Extract data error: " + datasetTableTaskLog.getTaskId(), e);
|
||||
datasetTableTaskLog.setStatus(JobStatus.Error.name());
|
||||
datasetTableTaskLog.setInfo(e.getMessage());
|
||||
datasetTableTaskLog.setEndTime(System.currentTimeMillis());
|
||||
dataSetTableTaskLogService.save(datasetTableTaskLog);
|
||||
dataSetTableTaskLogService.save(datasetTableTaskLog, hasTask);
|
||||
}
|
||||
|
||||
private void createEngineTable(String tableName, List<DatasetTableField> datasetTableFields) throws Exception {
|
||||
@ -667,14 +667,14 @@ public class ExtractDataService {
|
||||
return null;
|
||||
}
|
||||
|
||||
private DatasetTableTaskLog writeDatasetTableTaskLog(String datasetTableId, String taskId) {
|
||||
private DatasetTableTaskLog writeExcelLog(String datasetTableId, String taskId) {
|
||||
DatasetTableTaskLog datasetTableTaskLog = new DatasetTableTaskLog();
|
||||
datasetTableTaskLog.setTableId(datasetTableId);
|
||||
datasetTableTaskLog.setTaskId(taskId);
|
||||
datasetTableTaskLog.setStatus(JobStatus.Underway.name());
|
||||
datasetTableTaskLog.setTriggerType(TriggerType.Cron.name());
|
||||
datasetTableTaskLog.setStartTime(System.currentTimeMillis());
|
||||
dataSetTableTaskLogService.save(datasetTableTaskLog);
|
||||
dataSetTableTaskLogService.save(datasetTableTaskLog, false);
|
||||
return datasetTableTaskLog;
|
||||
}
|
||||
|
||||
@ -696,7 +696,7 @@ public class ExtractDataService {
|
||||
}
|
||||
datasetTableTaskLog.setTriggerType(TriggerType.Cron.name());
|
||||
datasetTableTaskLog.setStartTime(startTime);
|
||||
dataSetTableTaskLogService.save(datasetTableTaskLog);
|
||||
dataSetTableTaskLogService.save(datasetTableTaskLog, true);
|
||||
return datasetTableTaskLog;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user