feat(数据集): 同步日志导出
This commit is contained in:
parent
d963c92a7c
commit
6ace949487
@ -13,6 +13,7 @@ import io.dataease.controller.sys.base.BaseGridRequest;
|
|||||||
import io.dataease.dto.dataset.DataSetTaskLogDTO;
|
import io.dataease.dto.dataset.DataSetTaskLogDTO;
|
||||||
import io.dataease.service.dataset.DataSetTableTaskLogService;
|
import io.dataease.service.dataset.DataSetTableTaskLogService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -52,4 +53,11 @@ public class DataSetTableTaskLogController {
|
|||||||
return PageUtils.setPageInfo(page, dataSetTableTaskLogService.listTaskLog(request, type));
|
return PageUtils.setPageInfo(page, dataSetTableTaskLogService.listTaskLog(request, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation("导出同步日志")
|
||||||
|
@PostMapping("export")
|
||||||
|
public void export(@RequestBody BaseGridRequest request) throws Exception{
|
||||||
|
dataSetTableTaskLogService.exportExcel(request);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
package io.dataease.service.dataset;
|
package io.dataease.service.dataset;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import io.dataease.commons.constants.SysLogConstants;
|
||||||
|
import io.dataease.commons.utils.ServletUtils;
|
||||||
|
import io.dataease.exception.DataEaseException;
|
||||||
import io.dataease.ext.ExtDataSetTaskMapper;
|
import io.dataease.ext.ExtDataSetTaskMapper;
|
||||||
import io.dataease.ext.query.GridExample;
|
import io.dataease.ext.query.GridExample;
|
||||||
import io.dataease.commons.utils.AuthUtils;
|
import io.dataease.commons.utils.AuthUtils;
|
||||||
@ -7,18 +11,33 @@ import io.dataease.controller.sys.base.BaseGridRequest;
|
|||||||
import io.dataease.controller.sys.base.ConditionEntity;
|
import io.dataease.controller.sys.base.ConditionEntity;
|
||||||
import io.dataease.dto.dataset.DataSetTaskDTO;
|
import io.dataease.dto.dataset.DataSetTaskDTO;
|
||||||
import io.dataease.dto.dataset.DataSetTaskLogDTO;
|
import io.dataease.dto.dataset.DataSetTaskLogDTO;
|
||||||
|
import io.dataease.i18n.Translator;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableTaskLog;
|
import io.dataease.plugins.common.base.domain.DatasetTableTaskLog;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableTaskLogExample;
|
import io.dataease.plugins.common.base.domain.DatasetTableTaskLogExample;
|
||||||
|
import io.dataease.plugins.common.base.domain.SysLogWithBLOBs;
|
||||||
import io.dataease.plugins.common.base.mapper.DatasetTableTaskLogMapper;
|
import io.dataease.plugins.common.base.mapper.DatasetTableTaskLogMapper;
|
||||||
import io.dataease.plugins.common.base.mapper.DatasetTableTaskMapper;
|
import io.dataease.plugins.common.base.mapper.DatasetTableTaskMapper;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
import org.apache.poi.ss.usermodel.CellStyle;
|
||||||
|
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||||
|
import org.apache.poi.ss.usermodel.Font;
|
||||||
|
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author gin
|
* @Author gin
|
||||||
@ -51,6 +70,73 @@ public class DataSetTableTaskLogService {
|
|||||||
datasetTableTaskLogMapper.deleteByPrimaryKey(id);
|
datasetTableTaskLogMapper.deleteByPrimaryKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void exportExcel(BaseGridRequest request) throws Exception {
|
||||||
|
HttpServletResponse response = ServletUtils.response();
|
||||||
|
OutputStream outputStream = response.getOutputStream();
|
||||||
|
try {
|
||||||
|
List<DataSetTaskLogDTO> taskLogDTOS = listTaskLog(request, "notexcel");
|
||||||
|
List<String[]> details = taskLogDTOS.stream().map(item -> {
|
||||||
|
String[] row = new String[5];
|
||||||
|
row[0] = item.getName();
|
||||||
|
row[1] = item.getDatasetName();
|
||||||
|
row[2] = DateUtil.formatDateTime(new Date(item.getStartTime()));
|
||||||
|
row[3] = DateUtil.formatDateTime(new Date(item.getEndTime()));
|
||||||
|
row[4] = Translator.get("I18N_TASK_LOG_" + item.getStatus().toUpperCase()) ;
|
||||||
|
return row;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
String[] headArr = {Translator.get("I18N_TASK_NAEME"), Translator.get("I18N_DATASET"), Translator.get("I18N_START_TIME"), Translator.get("I18N_END_TIME"), Translator.get("I18N_STATUS")};
|
||||||
|
details.add(0, headArr);
|
||||||
|
|
||||||
|
HSSFWorkbook wb = new HSSFWorkbook();
|
||||||
|
//明细sheet
|
||||||
|
HSSFSheet detailsSheet = wb.createSheet(Translator.get("I18N_DATA"));
|
||||||
|
|
||||||
|
//给单元格设置样式
|
||||||
|
CellStyle cellStyle = wb.createCellStyle();
|
||||||
|
Font font = wb.createFont();
|
||||||
|
//设置字体大小
|
||||||
|
font.setFontHeightInPoints((short) 12);
|
||||||
|
//设置字体加粗
|
||||||
|
font.setBold(true);
|
||||||
|
//给字体设置样式
|
||||||
|
cellStyle.setFont(font);
|
||||||
|
//设置单元格背景颜色
|
||||||
|
cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
|
||||||
|
//设置单元格填充样式(使用纯色背景颜色填充)
|
||||||
|
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(details)) {
|
||||||
|
for (int i = 0; i < details.size(); i++) {
|
||||||
|
HSSFRow row = detailsSheet.createRow(i);
|
||||||
|
String[] rowData = details.get(i);
|
||||||
|
if (rowData != null) {
|
||||||
|
for (int j = 0; j < rowData.length; j++) {
|
||||||
|
HSSFCell cell = row.createCell(j);
|
||||||
|
cell.setCellValue(rowData[j]);
|
||||||
|
if (i == 0) {// 头部
|
||||||
|
cell.setCellStyle(cellStyle);
|
||||||
|
//设置列的宽度
|
||||||
|
detailsSheet.setColumnWidth(j, 255 * 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
response.setContentType("application/vnd.ms-excel");
|
||||||
|
//文件名称
|
||||||
|
String fileName = "DataEase " + Translator.get("I18N_SYNC_LOG");
|
||||||
|
String encodeFileName = URLEncoder.encode(fileName, "UTF-8");
|
||||||
|
response.setHeader("Content-disposition", "attachment;filename="+encodeFileName+".xls");
|
||||||
|
wb.write(outputStream);
|
||||||
|
outputStream.flush();
|
||||||
|
outputStream.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
DataEaseException.throwException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<DataSetTaskLogDTO> listTaskLog(BaseGridRequest request, String type) {
|
public List<DataSetTaskLogDTO> listTaskLog(BaseGridRequest request, String type) {
|
||||||
List<ConditionEntity> conditionEntities = request.getConditions();
|
List<ConditionEntity> conditionEntities = request.getConditions();
|
||||||
if(!type.equalsIgnoreCase("excel")){
|
if(!type.equalsIgnoreCase("excel")){
|
||||||
|
|||||||
@ -222,3 +222,13 @@ I18N_XPACKTASK_STATUS=Status
|
|||||||
I18N_XPACKTASK_SUCCESS=Success
|
I18N_XPACKTASK_SUCCESS=Success
|
||||||
I18N_XPACKTASK_ERROR=Error
|
I18N_XPACKTASK_ERROR=Error
|
||||||
I18N_XPACKTASK_UNDERWAY=Underway
|
I18N_XPACKTASK_UNDERWAY=Underway
|
||||||
|
I18N_TASK_LOG_ERROR=Error
|
||||||
|
I18N_TASK_LOG_COMPLETED=Completed
|
||||||
|
I18N_TASK_LOG_UNDERWAY=Underway
|
||||||
|
I18N_TASK_NAEME=Task name
|
||||||
|
I18N_DATASET=Dataset
|
||||||
|
I18N_START_TIME=Start time
|
||||||
|
I18N_END_TIME=End time
|
||||||
|
I18N_STATUS=Status
|
||||||
|
I18N_DATA=Data
|
||||||
|
I18N_SYNC_LOG=Sync log
|
||||||
|
|||||||
@ -223,3 +223,14 @@ I18N_XPACKTASK_STATUS=\u6267\u884C\u72B6\u6001
|
|||||||
I18N_XPACKTASK_SUCCESS=\u6210\u529F
|
I18N_XPACKTASK_SUCCESS=\u6210\u529F
|
||||||
I18N_XPACKTASK_ERROR=\u5931\u8D25
|
I18N_XPACKTASK_ERROR=\u5931\u8D25
|
||||||
I18N_XPACKTASK_UNDERWAY=\u6267\u884C\u4E2D
|
I18N_XPACKTASK_UNDERWAY=\u6267\u884C\u4E2D
|
||||||
|
|
||||||
|
I18N_TASK_LOG_ERROR=失败
|
||||||
|
I18N_TASK_LOG_COMPLETED=成功
|
||||||
|
I18N_TASK_LOG_UNDERWAY=执行中
|
||||||
|
I18N_TASK_NAEME=任务名称
|
||||||
|
I18N_DATASET=数据集
|
||||||
|
I18N_START_TIME=开始时间
|
||||||
|
I18N_END_TIME=结束时间
|
||||||
|
I18N_STATUS=状态
|
||||||
|
I18N_DATA=数据
|
||||||
|
I18N_SYNC_LOG=同步日志
|
||||||
@ -220,3 +220,13 @@ I18N_XPACKTASK_STATUS=\u57F7\u884C\u72C0\u614B
|
|||||||
I18N_XPACKTASK_SUCCESS=\u6210\u529F
|
I18N_XPACKTASK_SUCCESS=\u6210\u529F
|
||||||
I18N_XPACKTASK_ERROR=\u5931\u6557
|
I18N_XPACKTASK_ERROR=\u5931\u6557
|
||||||
I18N_XPACKTASK_UNDERWAY=\u57F7\u884C\u4E2D
|
I18N_XPACKTASK_UNDERWAY=\u57F7\u884C\u4E2D
|
||||||
|
I18N_TASK_LOG_ERROR=失敗
|
||||||
|
I18N_TASK_LOG_COMPLETED=成功
|
||||||
|
I18N_TASK_LOG_UNDERWAY=執行中
|
||||||
|
I18N_TASK_NAEME=任務名稱
|
||||||
|
I18N_DATASET=數據集
|
||||||
|
I18N_START_TIME=開始時間
|
||||||
|
I18N_END_TIME=結束時間
|
||||||
|
I18N_STATUS=狀態
|
||||||
|
I18N_DATA=數據
|
||||||
|
I18N_SYNC_LOG=同步日誌
|
||||||
|
|||||||
@ -223,4 +223,13 @@ export function checkCustomDs() {
|
|||||||
loading: true
|
loading: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
export function exportExcel(data) {
|
||||||
|
return request({
|
||||||
|
url: '/dataset/taskLog/export',
|
||||||
|
method: 'post',
|
||||||
|
loading: true,
|
||||||
|
responseType: 'blob',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
export default { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree, checkCustomDs }
|
export default { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree, checkCustomDs }
|
||||||
|
|||||||
@ -1521,7 +1521,8 @@ export default {
|
|||||||
preview_result: 'Preview',
|
preview_result: 'Preview',
|
||||||
sql_ds_union_error: 'Direct connect SQL dataset can not be union',
|
sql_ds_union_error: 'Direct connect SQL dataset can not be union',
|
||||||
api_data: 'API dataset',
|
api_data: 'API dataset',
|
||||||
copy: 'Copy'
|
copy: 'Copy',
|
||||||
|
sync_log: 'Sync log'
|
||||||
},
|
},
|
||||||
driver: {
|
driver: {
|
||||||
driver: 'Driver',
|
driver: 'Driver',
|
||||||
|
|||||||
@ -1520,7 +1520,8 @@ export default {
|
|||||||
preview_result: '預覽結果',
|
preview_result: '預覽結果',
|
||||||
sql_ds_union_error: '直連模式下SQL數據集,不支持關聯',
|
sql_ds_union_error: '直連模式下SQL數據集,不支持關聯',
|
||||||
api_data: 'API 數據集',
|
api_data: 'API 數據集',
|
||||||
copy: '復製'
|
copy: '復製',
|
||||||
|
sync_log: '同步日誌'
|
||||||
},
|
},
|
||||||
driver: {
|
driver: {
|
||||||
driver: '驅動',
|
driver: '驅動',
|
||||||
|
|||||||
@ -1522,7 +1522,8 @@ export default {
|
|||||||
preview_result: '预览结果',
|
preview_result: '预览结果',
|
||||||
sql_ds_union_error: '直连模式下SQL数据集,不支持关联',
|
sql_ds_union_error: '直连模式下SQL数据集,不支持关联',
|
||||||
api_data: 'API 数据集',
|
api_data: 'API 数据集',
|
||||||
copy: '复制'
|
copy: '复制',
|
||||||
|
sync_log: '同步日志'
|
||||||
},
|
},
|
||||||
driver: {
|
driver: {
|
||||||
driver: '驱动',
|
driver: '驱动',
|
||||||
|
|||||||
@ -2,10 +2,7 @@
|
|||||||
<div class="dataset-on-time">
|
<div class="dataset-on-time">
|
||||||
<el-row class="top-operate">
|
<el-row class="top-operate">
|
||||||
<el-col :span="10">
|
<el-col :span="10">
|
||||||
<deBtn
|
<deBtn secondary @click="exportConfirm" >{{ $t("zip.export") }}</deBtn>
|
||||||
secondary
|
|
||||||
>{{ $t("zip.export") }}</deBtn
|
|
||||||
>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="14" class="right-user">
|
<el-col :span="14" class="right-user">
|
||||||
<el-input
|
<el-input
|
||||||
@ -114,8 +111,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { formatOrders } from '@/utils/index'
|
import {formatCondition, formatOrders, formatQuickCondition} from '@/utils/index'
|
||||||
import { post } from '@/api/dataset/dataset'
|
import {exportExcel, post} from '@/api/dataset/dataset'
|
||||||
import GridTable from "@/components/gridTable/index.vue";
|
import GridTable from "@/components/gridTable/index.vue";
|
||||||
import filterUser from "./filterUserRecord.vue";
|
import filterUser from "./filterUserRecord.vue";
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
@ -180,6 +177,40 @@ export default {
|
|||||||
this.destroyTimer()
|
this.destroyTimer()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
exportConfirm() {
|
||||||
|
this.$confirm(this.$t('log.confirm'), '', {
|
||||||
|
confirmButtonText: this.$t('commons.confirm'),
|
||||||
|
cancelButtonText: this.$t('commons.cancel'),
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => {
|
||||||
|
this.exportData()
|
||||||
|
}).catch(() => {
|
||||||
|
// this.$info(this.$t('commons.delete_cancel'))
|
||||||
|
})
|
||||||
|
},
|
||||||
|
exportData() {
|
||||||
|
const param = {
|
||||||
|
orders: formatOrders(this.orderConditions),
|
||||||
|
conditions: [...this.cacheCondition],
|
||||||
|
};
|
||||||
|
if (this.nikeName) {
|
||||||
|
param.conditions.push({
|
||||||
|
field: `dataset_table_task.name`,
|
||||||
|
operator: "like",
|
||||||
|
value: this.nikeName,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exportExcel( param).then(res => {
|
||||||
|
const blob = new Blob([res], { type: 'application/vnd.ms-excel' })
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.style.display = 'none'
|
||||||
|
link.href = URL.createObjectURL(blob)
|
||||||
|
link.download = 'DataEase' + this.$t('dataset.sync_log') + '.xls'
|
||||||
|
document.body.appendChild(link)
|
||||||
|
link.click()
|
||||||
|
document.body.removeChild(link)
|
||||||
|
})
|
||||||
|
},
|
||||||
getScrollStatus() {
|
getScrollStatus() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
const dom = document.querySelector(".filter-texts-container");
|
const dom = document.querySelector(".filter-texts-container");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user