fix: 预览 excel数据集时,给出提示信息:处理中/处理失败

This commit is contained in:
taojinlong
2021-05-24 18:43:45 +08:00
parent de3ec60cad
commit a48249c8db
6 changed files with 22 additions and 1 deletions

View File

@@ -13,7 +13,6 @@ public class ExtractDataJob extends DeScheduleJob{
extractDataService = (ExtractDataService) CommonBeanFactory.getBean(ExtractDataService.class);
}
@Override
void businessExecute(JobExecutionContext context) {
extractDataService.extractData(datasetTableId, taskId, updateType);

View File

@@ -7,6 +7,7 @@ import io.dataease.base.mapper.DatasetTableIncrementalConfigMapper;
import io.dataease.base.mapper.DatasetTableMapper;
import io.dataease.base.mapper.DatasourceMapper;
import io.dataease.base.mapper.ext.ExtDataSetTableMapper;
import io.dataease.commons.constants.JobStatus;
import io.dataease.commons.utils.*;
import io.dataease.controller.request.dataset.DataSetTableRequest;
import io.dataease.datasource.dto.TableFiled;
@@ -71,6 +72,8 @@ public class DataSetTableService {
private DatasetTableIncrementalConfigMapper datasetTableIncrementalConfigMapper;
@Resource
private DataSetTableUnionService dataSetTableUnionService;
@Resource
private DataSetTableTaskLogService dataSetTableTaskLogService;
@Value("${upload.file.path}")
private String path;
@@ -256,6 +259,16 @@ public class DataSetTableService {
e.printStackTrace();
}
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "excel")) {
List<DatasetTableTaskLog> datasetTableTaskLogs = dataSetTableTaskLogService.getByTableId(datasetTable.getId());
if(CollectionUtils.isEmpty(datasetTableTaskLogs)){
throw new Exception("no records");
}
if(datasetTableTaskLogs.get(0).getStatus().equalsIgnoreCase(JobStatus.Underway.name())){
throw new Exception(Translator.get("i18n_processing_data"));
}
if(datasetTableTaskLogs.get(0).getStatus().equalsIgnoreCase(JobStatus.Error.name())){
throw new Exception("Failed to extract data: " + datasetTableTaskLogs.get(0).getInfo());
}
Datasource ds = (Datasource) CommonBeanFactory.getBean("DorisDatasource");
JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class);
DatasourceRequest datasourceRequest = new DatasourceRequest();

View File

@@ -49,4 +49,10 @@ public class DataSetTableTaskLogService {
datasetTableTaskLogMapper.deleteByExample(datasetTableTaskLogExample);
}
public List<DatasetTableTaskLog> getByTableId(String datasetId){
DatasetTableTaskLogExample datasetTableTaskLogExample = new DatasetTableTaskLogExample();
DatasetTableTaskLogExample.Criteria criteria = datasetTableTaskLogExample.createCriteria();
criteria.andTableIdEqualTo(datasetId);
return datasetTableTaskLogMapper.selectByExampleWithBLOBs(datasetTableTaskLogExample);
}
}