Unverified 提交 de9a4e04 authored 作者: taojinlong's avatar taojinlong 提交者: GitHub

Merge pull request #321 from dataease/pr@v1.1@task

fix: 更新任务状态
......@@ -33,10 +33,10 @@ public class DataSetTableTaskLogController {
dataSetTableTaskLogService.delete(id);
}
@PostMapping("list/{goPage}/{pageSize}")
public Pager<List<DataSetTaskLogDTO>> list(@RequestBody BaseGridRequest request, @PathVariable int goPage, @PathVariable int pageSize) {
@PostMapping("list/{type}/{goPage}/{pageSize}")
public Pager<List<DataSetTaskLogDTO>> list(@RequestBody BaseGridRequest request, @PathVariable String type, @PathVariable int goPage, @PathVariable int pageSize) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, dataSetTableTaskLogService.list(request));
return PageUtils.setPageInfo(page, dataSetTableTaskLogService.list(request, type));
}
}
......@@ -14,6 +14,7 @@ import java.util.List;
public class DataTableInfoDTO {
private String table;
private String sql;
private List<String> sheets;
private String data;// file path
private List<DataTableInfoCustomUnion> list;
}
......@@ -101,7 +101,7 @@ public class DataSetTableService {
private void extractData(DataSetTableRequest datasetTable) throws Exception {
if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "excel")) {
commonThreadPool.addTask(() -> {
extractDataService.extractExcelData(datasetTable.getId(), "all_scope");
extractDataService.extractExcelData(datasetTable.getId(), "all_scope", "初始导入");
});
return;
}
......@@ -131,7 +131,6 @@ public class DataSetTableService {
datasetTable.setId(UUID.randomUUID().toString());
datasetTable.setCreateBy(AuthUtils.getUser().getUsername());
datasetTable.setCreateTime(System.currentTimeMillis());
DataTableInfoDTO dataTableInfoDTO = new DataTableInfoDTO();
int insert = datasetTableMapper.insert(datasetTable);
// 添加表成功后,获取当前表字段和类型,抽象到dataease数据库
if (insert == 1) {
......@@ -151,11 +150,11 @@ public class DataSetTableService {
if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "excel")) {
if (datasetTable.getEditType() == 0) {
commonThreadPool.addTask(() -> {
extractDataService.extractExcelData(datasetTable.getId(), "all_scope");
extractDataService.extractExcelData(datasetTable.getId(), "all_scope", "替换");
});
} else if (datasetTable.getEditType() == 1) {
commonThreadPool.addTask(() -> {
extractDataService.extractExcelData(datasetTable.getId(), "add_scope");
extractDataService.extractExcelData(datasetTable.getId(), "add_scope", "追加");
});
}
}
......@@ -416,20 +415,10 @@ public class DataSetTableService {
}
}
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "excel")) {
if (StringUtils.isEmpty(datasetTable.getSyncStatus()) || datasetTable.getSyncStatus().equalsIgnoreCase(JobStatus.Underway.name())) {
map.put("status", "warnning");
map.put("msg", Translator.get("i18n_processing_data"));
dataSetPreviewPage.setTotal(0);
} else if (datasetTable.getSyncStatus().equalsIgnoreCase(JobStatus.Error.name())) {
List<DatasetTableTaskLog> datasetTableTaskLogs = dataSetTableTaskLogService.getByTableId(datasetTable.getId());
map.put("status", "error");
if (CollectionUtils.isNotEmpty(datasetTableTaskLogs)) {
map.put("msg", "Failed to extract data: " + datasetTableTaskLogs.get(0).getInfo());
} else {
map.put("msg", "Failed to extract data.");
if (!checkDorisTableIsExists(dataSetTableRequest.getId())) {
throw new RuntimeException(Translator.get("i18n_data_not_sync"));
}
dataSetPreviewPage.setTotal(0);
} else {
Datasource ds = (Datasource) CommonBeanFactory.getBean("DorisDatasource");
JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class);
DatasourceRequest datasourceRequest = new DatasourceRequest();
......@@ -448,7 +437,6 @@ public class DataSetTableService {
} catch (Exception e) {
e.printStackTrace();
}
}
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "custom")) {
if (datasetTable.getMode() == 0) {
Datasource ds = datasourceMapper.selectByPrimaryKey(dataSetTableRequest.getDataSourceId());
......
......@@ -47,7 +47,8 @@ public class DataSetTableTaskLogService {
datasetTableTaskLogMapper.deleteByPrimaryKey(id);
}
public List<DataSetTaskLogDTO> list(BaseGridRequest request) {
public List<DataSetTaskLogDTO> list(BaseGridRequest request, String type) {
if(!type.equalsIgnoreCase("excel")){
ConditionEntity entity = new ConditionEntity();
entity.setField("task_id");
entity.setOperator("not null");
......@@ -57,8 +58,16 @@ public class DataSetTableTaskLogService {
}
conditionEntities.add(entity);
request.setConditions(conditionEntities);
}
GridExample gridExample = request.convertExample();
return extDataSetTaskMapper.list(gridExample);
List<DataSetTaskLogDTO> dataSetTaskLogDTOS = extDataSetTaskMapper.list(gridExample);
dataSetTaskLogDTOS.forEach(dataSetTaskLogDTO -> {
if(StringUtils.isEmpty(dataSetTaskLogDTO.getName())){
dataSetTaskLogDTO.setName(dataSetTaskLogDTO.getTaskId());
}
});
return dataSetTaskLogDTOS;
}
public void deleteByTaskId(String taskId){
......
......@@ -13,6 +13,7 @@ import io.dataease.commons.constants.TaskStatus;
import io.dataease.commons.constants.TriggerType;
import io.dataease.controller.request.dataset.DataSetTaskRequest;
import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.controller.sys.base.ConditionEntity;
import io.dataease.controller.sys.response.SysUserGridResponse;
import io.dataease.controller.sys.response.SysUserRole;
import io.dataease.dto.dataset.DataSetTaskDTO;
......@@ -28,6 +29,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
......@@ -177,8 +179,20 @@ public class DataSetTableTaskService {
datasetTableTask.setStatus(TaskStatus.Stopped.name());
}else {
if(StringUtils.isNotEmpty(datasetTableTask.getEnd()) && datasetTableTask.getEnd().equalsIgnoreCase("1")){
if(utilMapper.currentTimestamp() > datasetTableTask.getEndTime()){
BaseGridRequest request = new BaseGridRequest();
ConditionEntity conditionEntity = new ConditionEntity();
conditionEntity.setField("dataset_table_task.id");
conditionEntity.setOperator("eq");
conditionEntity.setValue(datasetTableTask.getId());
request.setConditions(Arrays.asList(conditionEntity));
List<DataSetTaskDTO> dataSetTaskDTOS = taskList(request);
if(CollectionUtils.isEmpty(dataSetTaskDTOS)){
return;
}
if(dataSetTaskDTOS.get(0).getNextExecTime() == null || dataSetTaskDTOS.get(0).getNextExecTime() <= 0){
datasetTableTask.setStatus(TaskStatus.Stopped.name());
}else {
datasetTableTask.setStatus(TaskStatus.Underway.name());
}
}else {
datasetTableTask.setStatus(TaskStatus.Underway.name());
......
......@@ -23,4 +23,4 @@ ALTER TABLE `dataset_table_task` ADD COLUMN `extra_data` LONGTEXT NULL AFTER `la
update dataset_table_task_log set trigger_type='Cron';
update dataset_table_task_log set dataset_table_task_log.task_id='初始导入' where dataset_table_task_log.task_id is null;
......@@ -258,7 +258,7 @@ export default {
type: 'excel',
mode: parseInt(this.mode),
// info: '{"data":"' + this.path + '"}',
info: JSON.stringify({ data: this.path }),
info: JSON.stringify({ data: this.path, sheets: [this.sheets[0]]}),
fields: this.fields
}
} else {
......
<template>
<el-col>
<el-row>
<el-button v-if="hasDataPermission('manage',param.privileges)" icon="el-icon-setting" size="mini" @click="showConfig">
<el-button v-if="hasDataPermission('manage',param.privileges) || table.type !== 'excel'" icon="el-icon-setting" size="mini" @click="showConfig">
{{ $t('dataset.update_setting') }}
</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="refreshLog">
......@@ -615,8 +615,8 @@ export default {
}
},
listTaskLog(loading = true) {
const params = {"conditions":[{"field":"dataset_table_task.table_id","operator":"eq","value": this.table.id}],"orders":[]}
post('/dataset/taskLog/list/' + this.page.currentPage + '/' + this.page.pageSize, params, loading).then(response => {
const params = {"conditions":[{"field":"dataset_table_task_log.table_id","operator":"eq","value": this.table.id}],"orders":[]}
post('/dataset/taskLog/list/' + this.table.type + '/' + this.page.currentPage + '/' + this.page.pageSize, params, loading).then(response => {
this.taskLogData = response.data.listObject
this.page.total = response.data.itemCount
})
......
......@@ -51,7 +51,7 @@
<el-tab-pane v-if="table.type !== 'custom'" :label="$t('dataset.join_view')" name="joinView">
<union-view :param="param" :table="table" />
</el-tab-pane>
<el-tab-pane v-if="table.mode === 1 && (table.type === 'db' || table.type === 'sql')" :label="$t('dataset.update_info')" name="updateInfo">
<el-tab-pane v-if="table.mode === 1 && (table.type === 'excel' || table.type === 'db' || table.type === 'sql')" :label="$t('dataset.update_info')" name="updateInfo">
<update-info :param="param" :table="table" />
</el-tab-pane>
</el-tabs>
......
......@@ -47,7 +47,7 @@
<el-table-column prop="nextExecTime" :label="$t('dataset.task.next_exec_time')">
<template slot-scope="scope" >
<span v-if="scope.row.nextExecTime && scope.row.rate !== 'SIMPLE'">
<span v-if="scope.row.nextExecTime && scope.row.nextExecTime !== -1 && scope.row.rate !== 'SIMPLE'">
{{ scope.row.nextExecTime | timestampFormatDate }}
</span>
<span v-if="!scope.row.nextExecTime || scope.row.rate === 'SIMPLE'"></span>
......
......@@ -198,7 +198,7 @@ export default {
const temp = formatCondition(condition)
const param = temp || {}
param['orders'] = formatOrders(this.orderConditions)
post('/dataset/taskLog/list/' + this.paginationConfig.currentPage + '/' + this.paginationConfig.pageSize, param, showLoading).then(response => {
post('/dataset/taskLog/list/notexcel/' + this.paginationConfig.currentPage + '/' + this.paginationConfig.pageSize, param, showLoading).then(response => {
this.data = response.data.listObject
this.paginationConfig.total = response.data.itemCount
})
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论