mirror of
https://github.com/dataease/dataease.git
synced 2026-05-15 05:22:13 +08:00
fix: 【数据导出中心】修复切换tab页导致cpu暴增
This commit is contained in:
@@ -127,8 +127,12 @@ public class ChartDataServer implements ChartDataApi {
|
||||
} else {
|
||||
viewDTO.setResultCount(viewLimit);
|
||||
}
|
||||
chartDataManage.encodeData(viewDTO);
|
||||
chartViewInfo = getData(viewDTO);
|
||||
if (CommonConstants.VIEW_DATA_FROM.TEMPLATE.equalsIgnoreCase(viewDTO.getDataFrom())) {
|
||||
chartViewInfo = extendDataManage.getChartDataInfo(viewDTO.getId(), viewDTO);
|
||||
} else {
|
||||
chartViewInfo = chartDataManage.calcData(chartViewInfo);
|
||||
}
|
||||
List<Object[]> tableRow = (List) chartViewInfo.getData().get("sourceData");
|
||||
if ("dataset".equals(request.getDownloadType())) {
|
||||
request.setHeader(dsHeader);
|
||||
|
||||
@@ -2,6 +2,8 @@ package io.dataease.exportCenter.manage;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.dataease.api.chart.dto.ViewDetailField;
|
||||
import io.dataease.api.chart.request.ChartExcelRequest;
|
||||
@@ -31,6 +33,7 @@ import io.dataease.engine.utils.Utils;
|
||||
import io.dataease.exception.DEException;
|
||||
import io.dataease.exportCenter.dao.auto.entity.CoreExportTask;
|
||||
import io.dataease.exportCenter.dao.auto.mapper.CoreExportTaskMapper;
|
||||
import io.dataease.exportCenter.dao.ext.mapper.ExportTaskExtMapper;
|
||||
import io.dataease.exportCenter.util.ExportCenterUtils;
|
||||
import io.dataease.extensions.datasource.api.PluginManageApi;
|
||||
import io.dataease.extensions.datasource.dto.DatasetTableFieldDTO;
|
||||
@@ -86,6 +89,8 @@ public class ExportCenterManage implements BaseExportApi {
|
||||
@Resource
|
||||
private CoreExportTaskMapper exportTaskMapper;
|
||||
@Resource
|
||||
private ExportTaskExtMapper exportTaskExtMapper;
|
||||
@Resource
|
||||
private DatasetGroupManage datasetGroupManage;
|
||||
@Resource
|
||||
DataVisualizationServer dataVisualizationServer;
|
||||
@@ -263,27 +268,58 @@ public class ExportCenterManage implements BaseExportApi {
|
||||
}
|
||||
}
|
||||
|
||||
public List<ExportTaskDTO> exportTasks(String status) {
|
||||
public IPage<ExportTaskDTO> pager(Page<ExportTaskDTO> page, String status) {
|
||||
if (!STATUS.contains(status)) {
|
||||
DEException.throwException("Invalid status: " + status);
|
||||
}
|
||||
|
||||
QueryWrapper<CoreExportTask> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", AuthUtils.getUser().getUserId());
|
||||
if (!status.equalsIgnoreCase("ALL")) {
|
||||
queryWrapper.eq("export_status", status);
|
||||
}
|
||||
queryWrapper.orderByDesc("export_time");
|
||||
List<CoreExportTask> exportTasks = exportTaskMapper.selectList(queryWrapper);
|
||||
List<ExportTaskDTO> result = new ArrayList<>();
|
||||
exportTasks.forEach(exportTask -> {
|
||||
ExportTaskDTO exportTaskDTO = new ExportTaskDTO();
|
||||
BeanUtils.copyBean(exportTaskDTO, exportTask);
|
||||
if (status.equalsIgnoreCase("ALL") || status.equalsIgnoreCase(exportTaskDTO.getExportStatus())) {
|
||||
setExportFromAbsName(exportTaskDTO);
|
||||
IPage<ExportTaskDTO> pager = exportTaskExtMapper.pager(page, queryWrapper);
|
||||
|
||||
List<ExportTaskDTO> records = pager.getRecords();
|
||||
records.forEach(exportTask -> {
|
||||
if (status.equalsIgnoreCase("ALL") || status.equalsIgnoreCase(exportTask.getExportStatus())) {
|
||||
setExportFromAbsName(exportTask);
|
||||
}
|
||||
if (status.equalsIgnoreCase("ALL") || status.equalsIgnoreCase(exportTaskDTO.getExportStatus())) {
|
||||
proxy().setOrg(exportTaskDTO);
|
||||
if (status.equalsIgnoreCase("ALL") || status.equalsIgnoreCase(exportTask.getExportStatus())) {
|
||||
proxy().setOrg(exportTask);
|
||||
}
|
||||
result.add(exportTaskDTO);
|
||||
});
|
||||
|
||||
return pager;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Long> exportTasks() {
|
||||
Map<String, Long> result = new HashMap<>();
|
||||
QueryWrapper<CoreExportTask> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", AuthUtils.getUser().getUserId());
|
||||
queryWrapper.eq("export_status", "IN_PROGRESS");
|
||||
result.put("IN_PROGRESS", exportTaskMapper.selectCount(queryWrapper));
|
||||
|
||||
queryWrapper.clear();
|
||||
queryWrapper.eq("user_id", AuthUtils.getUser().getUserId());
|
||||
queryWrapper.eq("export_status", "SUCCESS");
|
||||
result.put("SUCCESS", exportTaskMapper.selectCount(queryWrapper));
|
||||
|
||||
queryWrapper.clear();
|
||||
queryWrapper.eq("user_id", AuthUtils.getUser().getUserId());
|
||||
queryWrapper.eq("export_status", "FAILED");
|
||||
result.put("FAILED", exportTaskMapper.selectCount(queryWrapper));
|
||||
|
||||
queryWrapper.clear();
|
||||
queryWrapper.eq("user_id", AuthUtils.getUser().getUserId());
|
||||
queryWrapper.eq("export_status", "PENDING");
|
||||
result.put("PENDING", exportTaskMapper.selectCount(queryWrapper));
|
||||
|
||||
queryWrapper.clear();
|
||||
queryWrapper.eq("user_id", AuthUtils.getUser().getUserId());
|
||||
result.put("ALL", exportTaskMapper.selectCount(queryWrapper));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.dataease.exportCenter.server;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.dataease.api.exportCenter.ExportCenterApi;
|
||||
import io.dataease.exportCenter.manage.ExportCenterManage;
|
||||
import io.dataease.exportCenter.util.ExportCenterUtils;
|
||||
@@ -11,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/exportCenter")
|
||||
@@ -20,8 +23,14 @@ public class ExportCenterServer implements ExportCenterApi {
|
||||
private ExportCenterManage exportCenterManage;
|
||||
|
||||
@Override
|
||||
public List<ExportTaskDTO> exportTasks(String status) {
|
||||
return exportCenterManage.exportTasks(status);
|
||||
public Map<String, Long> exportTasks() {
|
||||
return exportCenterManage.exportTasks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<ExportTaskDTO> pager(int goPage, int pageSize, String status) {
|
||||
Page<ExportTaskDTO> page = new Page<>(goPage, pageSize);
|
||||
return exportCenterManage.pager(page, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -336,11 +336,11 @@ export const getFunction = async (): Promise<DatasetDetail[]> => {
|
||||
})
|
||||
}
|
||||
|
||||
export const exportTasks = async (type): Promise<IResponse> => {
|
||||
return request.post({ url: '/exportCenter/exportTasks/' + type, data: {} }).then(res => {
|
||||
return res
|
||||
})
|
||||
}
|
||||
export const exportTasksRecords = () =>
|
||||
request.post({ url: `/exportCenter/exportTasks/records`, data: {} })
|
||||
|
||||
export const exportTasks = (page: number, limit: number, status: string) =>
|
||||
request.post({ url: `/exportCenter/exportTasks/${status}/${page}/${limit}`, data: {} })
|
||||
|
||||
export const exportRetry = async (id): Promise<IResponse> => {
|
||||
return request.post({ url: '/exportCenter/retry/' + id, data: {} }).then(res => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import dvPreviewDownload from '@/assets/svg/icon_download_outlined.svg'
|
||||
import deDelete from '@/assets/svg/de-delete.svg'
|
||||
import icon_fileExcel_colorful from '@/assets/svg/icon_file-excel_colorful.svg'
|
||||
import icon_refresh_outlined from '@/assets/svg/icon_refresh_outlined.svg'
|
||||
import { ref, h, onUnmounted, computed } from 'vue'
|
||||
import { ref, h, onUnmounted, computed, reactive } from 'vue'
|
||||
import { EmptyBackground } from '@/components/empty-background'
|
||||
import { ElButton, ElMessage, ElMessageBox, ElTabPane, ElTabs } from 'element-plus-secondary'
|
||||
import { RefreshLeft } from '@element-plus/icons-vue'
|
||||
@@ -12,7 +12,8 @@ import {
|
||||
exportRetry,
|
||||
exportDelete,
|
||||
exportDeleteAll,
|
||||
exportDeletePost
|
||||
exportDeletePost,
|
||||
exportTasksRecords
|
||||
} from '@/api/dataset'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { useEmitt } from '@/hooks/web/useEmitt'
|
||||
@@ -22,6 +23,13 @@ import { useLinkStoreWithOut } from '@/store/modules/link'
|
||||
import { useAppStoreWithOut } from '@/store/modules/app'
|
||||
|
||||
const { t } = useI18n()
|
||||
const state = reactive({
|
||||
paginationConfig: {
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0
|
||||
}
|
||||
})
|
||||
const tableData = ref([])
|
||||
const drawerLoading = ref(false)
|
||||
const drawer = ref(false)
|
||||
@@ -77,46 +85,29 @@ const handleClick = tab => {
|
||||
description.value = t('data_export.no_task')
|
||||
}
|
||||
drawerLoading.value = true
|
||||
exportTasks(activeName.value)
|
||||
.then(res => {
|
||||
tabList.value.forEach(item => {
|
||||
if (item.name === 'ALL') {
|
||||
item.label = t('data_set.all') + '(' + res.data.length + ')'
|
||||
}
|
||||
if (item.name === 'IN_PROGRESS') {
|
||||
item.label =
|
||||
t('data_set.exporting') +
|
||||
'(' +
|
||||
res.data.filter(task => task.exportStatus === 'IN_PROGRESS').length +
|
||||
')'
|
||||
}
|
||||
if (item.name === 'SUCCESS') {
|
||||
item.label =
|
||||
t('data_set.success') +
|
||||
'(' +
|
||||
res.data.filter(task => task.exportStatus === 'SUCCESS').length +
|
||||
')'
|
||||
}
|
||||
if (item.name === 'FAILED') {
|
||||
item.label =
|
||||
t('data_set.fail') +
|
||||
'(' +
|
||||
res.data.filter(task => task.exportStatus === 'FAILED').length +
|
||||
')'
|
||||
}
|
||||
if (item.name === 'PENDING') {
|
||||
item.label =
|
||||
t('data_set.waiting') +
|
||||
'(' +
|
||||
res.data.filter(task => task.exportStatus === 'PENDING').length +
|
||||
')'
|
||||
}
|
||||
})
|
||||
if (activeName.value === 'ALL') {
|
||||
tableData.value = res.data
|
||||
} else {
|
||||
tableData.value = res.data.filter(task => task.exportStatus === activeName.value)
|
||||
exportTasksRecords().then(res => {
|
||||
tabList.value.forEach(item => {
|
||||
if (item.name === 'ALL') {
|
||||
item.label = t('data_set.all') + '(' + res.data.ALL + ')'
|
||||
}
|
||||
if (item.name === 'IN_PROGRESS') {
|
||||
item.label = t('data_set.exporting') + '(' + res.data.IN_PROGRESS + ')'
|
||||
}
|
||||
if (item.name === 'SUCCESS') {
|
||||
item.label = t('data_set.success') + '(' + res.data.SUCCESS + ')'
|
||||
}
|
||||
if (item.name === 'FAILED') {
|
||||
item.label = t('data_set.fail') + '(' + res.data.FAILED + ')'
|
||||
}
|
||||
if (item.name === 'PENDING') {
|
||||
item.label = t('data_set.waiting') + '(' + res.data.PENDING + ')'
|
||||
}
|
||||
})
|
||||
})
|
||||
exportTasks(state.paginationConfig.currentPage, state.paginationConfig.pageSize, activeName.value)
|
||||
.then(res => {
|
||||
state.paginationConfig.total = res.data.total
|
||||
tableData.value = res.data.records
|
||||
})
|
||||
.finally(() => {
|
||||
drawerLoading.value = false
|
||||
@@ -131,45 +122,32 @@ const init = params => {
|
||||
handleClick()
|
||||
timer = setInterval(() => {
|
||||
if (activeName.value === 'IN_PROGRESS') {
|
||||
exportTasks(activeName.value).then(res => {
|
||||
exportTasksRecords().then(res => {
|
||||
tabList.value.forEach(item => {
|
||||
if (item.name === 'ALL') {
|
||||
item.label = t('data_set.all') + '(' + res.data.length + ')'
|
||||
item.label = t('data_set.all') + '(' + res.data.ALL + ')'
|
||||
}
|
||||
if (item.name === 'IN_PROGRESS') {
|
||||
item.label =
|
||||
t('data_set.exporting') +
|
||||
'(' +
|
||||
res.data.filter(task => task.exportStatus === 'IN_PROGRESS').length +
|
||||
')'
|
||||
item.label = t('data_set.exporting') + '(' + res.data.IN_PROGRESS + ')'
|
||||
}
|
||||
if (item.name === 'SUCCESS') {
|
||||
item.label =
|
||||
t('data_set.success') +
|
||||
'(' +
|
||||
res.data.filter(task => task.exportStatus === 'SUCCESS').length +
|
||||
')'
|
||||
item.label = t('data_set.success') + '(' + res.data.SUCCESS + ')'
|
||||
}
|
||||
if (item.name === 'FAILED') {
|
||||
item.label =
|
||||
t('data_set.fail') +
|
||||
'(' +
|
||||
res.data.filter(task => task.exportStatus === 'FAILED').length +
|
||||
')'
|
||||
item.label = t('data_set.fail') + '(' + res.data.FAILED + ')'
|
||||
}
|
||||
if (item.name === 'PENDING') {
|
||||
item.label =
|
||||
t('data_set.waiting') +
|
||||
'(' +
|
||||
res.data.filter(task => task.exportStatus === 'PENDING').length +
|
||||
')'
|
||||
item.label = t('data_set.waiting') + '(' + res.data.PENDING + ')'
|
||||
}
|
||||
})
|
||||
if (activeName.value === 'ALL') {
|
||||
tableData.value = res.data
|
||||
} else {
|
||||
tableData.value = res.data.filter(task => task.exportStatus === activeName.value)
|
||||
}
|
||||
})
|
||||
exportTasks(
|
||||
state.paginationConfig.currentPage,
|
||||
state.paginationConfig.pageSize,
|
||||
activeName.value
|
||||
).then(res => {
|
||||
state.paginationConfig.total = res.data.total
|
||||
tableData.value = res.data.records
|
||||
})
|
||||
}
|
||||
}, 5000)
|
||||
@@ -262,6 +240,7 @@ const timestampFormatDate = value => {
|
||||
return new Date(value).toLocaleString()
|
||||
}
|
||||
import { PATH_URL } from '@/config/axios/service'
|
||||
import GridTable from '../../../../components/grid-table/src/GridTable.vue'
|
||||
const downloadClick = item => {
|
||||
window.open(PATH_URL + '/exportCenter/download/' + item.id, openType)
|
||||
}
|
||||
@@ -294,6 +273,19 @@ const handleSelectionChange = val => {
|
||||
multipleSelection.value = val
|
||||
}
|
||||
|
||||
const pageChange = index => {
|
||||
if (typeof index !== 'number') {
|
||||
return
|
||||
}
|
||||
state.paginationConfig.currentPage = index
|
||||
handleClick()
|
||||
}
|
||||
const sizeChange = size => {
|
||||
state.paginationConfig.currentPage = 1
|
||||
state.paginationConfig.pageSize = size
|
||||
handleClick()
|
||||
}
|
||||
|
||||
const delAll = () => {
|
||||
if (multipleSelection.value.length === 0) {
|
||||
ElMessageBox.confirm(t('data_export.sure_del_all'), {
|
||||
@@ -386,11 +378,13 @@ defineExpose({
|
||||
>{{ $t('commons.delete') }}
|
||||
</el-button>
|
||||
<div class="table-container" :class="!tableData.length && 'hidden-bottom'">
|
||||
<el-table
|
||||
<GridTable
|
||||
ref="multipleTable"
|
||||
:data="tableData"
|
||||
height="100%"
|
||||
style="width: 100%"
|
||||
:pagination="state.paginationConfig"
|
||||
:table-data="tableData"
|
||||
class="popper-max-width"
|
||||
@current-change="pageChange"
|
||||
@size-change="sizeChange"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="50" />
|
||||
@@ -482,7 +476,7 @@ defineExpose({
|
||||
<template #empty>
|
||||
<empty-background :description="description" img-type="noneWhite" />
|
||||
</template>
|
||||
</el-table>
|
||||
</GridTable>
|
||||
</div>
|
||||
</el-drawer>
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package io.dataease.api.exportCenter;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.dataease.auth.DePermit;
|
||||
import io.dataease.model.ExportTaskDTO;
|
||||
import io.dataease.auth.DeApiPath;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -11,6 +14,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static io.dataease.constant.AuthResourceEnum.DATASOURCE;
|
||||
|
||||
@@ -20,25 +24,34 @@ import static io.dataease.constant.AuthResourceEnum.DATASOURCE;
|
||||
public interface ExportCenterApi {
|
||||
|
||||
|
||||
@PostMapping("/exportTasks/{status}")
|
||||
public List<ExportTaskDTO> exportTasks(@PathVariable String status) ;
|
||||
@PostMapping("/exportTasks/records")
|
||||
public Map<String, Long> exportTasks();
|
||||
|
||||
@DePermit("m:read")
|
||||
@PostMapping("/exportTasks/{status}/{goPage}/{pageSize}")
|
||||
IPage<ExportTaskDTO> pager(@PathVariable("goPage") int goPage, @PathVariable("pageSize") int pageSize, @PathVariable String status);
|
||||
|
||||
@Operation(summary = "删除单条记录")
|
||||
@GetMapping("/delete/{id}")
|
||||
public void delete(@PathVariable String id);
|
||||
public void delete(@PathVariable String id);
|
||||
|
||||
@Operation(summary = "批量删除")
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestBody List<String> ids);
|
||||
public void delete(@RequestBody List<String> ids);
|
||||
|
||||
@Operation(summary = "删除")
|
||||
@PostMapping("/deleteAll/{type}")
|
||||
public void deleteAll(@PathVariable String type);
|
||||
public void deleteAll(@PathVariable String type);
|
||||
|
||||
@Operation(summary = "下载")
|
||||
@GetMapping("/download/{id}")
|
||||
public void download(@PathVariable String id, HttpServletResponse response) throws Exception ;
|
||||
public void download(@PathVariable String id, HttpServletResponse response) throws Exception;
|
||||
|
||||
@Operation(summary = "重试")
|
||||
@PostMapping("/retry/{id}")
|
||||
public void retry(@PathVariable String id);
|
||||
public void retry(@PathVariable String id);
|
||||
|
||||
@PostMapping("/exportLimit")
|
||||
public String exportLimit();
|
||||
public String exportLimit();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user