feat: 导出中心导出失败时,给出失败原因信息,方便问题排查

This commit is contained in:
taojinlong 2024-06-13 17:22:13 +08:00
parent 2d18c00e4b
commit c4e24bcff5
5 changed files with 41 additions and 7 deletions

View File

@ -9,7 +9,7 @@ import java.io.Serializable;
* </p>
*
* @author fit2cloud
* @since 2024-05-23
* @since 2024-06-12
*/
@TableName("core_export_task")
public class CoreExportTask implements Serializable {
@ -43,6 +43,11 @@ public class CoreExportTask implements Serializable {
*/
private String params;
/**
* 错误信息
*/
private String msg;
public String getId() {
return id;
}
@ -139,6 +144,14 @@ public class CoreExportTask implements Serializable {
this.params = params;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
@Override
public String toString() {
return "CoreExportTask{" +
@ -154,6 +167,7 @@ public class CoreExportTask implements Serializable {
", exportProgress = " + exportProgress +
", exportMachineName = " + exportMachineName +
", params = " + params +
", msg = " + msg +
"}";
}
}

View File

@ -10,7 +10,7 @@ import org.apache.ibatis.annotations.Mapper;
* </p>
*
* @author fit2cloud
* @since 2024-05-23
* @since 2024-06-12
*/
@Mapper
public interface CoreExportTaskMapper extends BaseMapper<CoreExportTask> {

View File

@ -293,19 +293,16 @@ public class ExportCenterManage {
ChartDataServer.setExcelData(detailsSheet, cellStyle, header, details, detailFields, excelTypes);
}
}
try (FileOutputStream outputStream = new FileOutputStream(dataPath + "/" + request.getViewName() + ".xlsx")) {
wb.write(outputStream);
outputStream.flush();
}
wb.close();
exportTask.setExportProgress("100");
exportTask.setExportStatus("SUCCESS");
setFileSize(dataPath + "/" + request.getViewName() + ".xlsx", exportTask);
} catch (Exception e) {
e.printStackTrace();
exportTask.setMsg(e.getMessage());
LogUtil.error("Failed to export data", e);
exportTask.setExportStatus("FAILED");
} finally {

View File

@ -19,6 +19,8 @@ const { t } = useI18n()
const tableData = ref([])
const drawerLoading = ref(false)
const drawer = ref(false)
const msgDialogVisible = ref(false)
const msg = ref('')
const exportDatasetLoading = ref(false)
const activeName = ref('ALL')
const multipleSelection = ref([])
@ -224,6 +226,11 @@ const downLoadAll = () => {
})
})
}
const showMsg = item => {
msg.value = ''
msg.value = item.msg
msgDialogVisible.value = true
}
const timestampFormatDate = value => {
if (!value) {
return '-'
@ -383,7 +390,11 @@ defineExpose({
</el-icon>
<div class="name-content">
<div class="fileName">{{ scope.row.fileName }}</div>
<div v-if="scope.row.exportStatus === 'FAILED'" class="failed">
<div
v-if="scope.row.exportStatus === 'FAILED'"
class="failed"
@click="showMsg(scope.row)"
>
{{ $t('data_export.export_failed') }}
</div>
<div v-if="scope.row.exportStatus === 'SUCCESS'" class="success">
@ -444,6 +455,15 @@ defineExpose({
</el-table>
</div>
</el-drawer>
<el-dialog title="失败原因" v-model="msgDialogVisible" width="30%">
<span>{{ msg }}</span>
<template v-slot:footer>
<span class="dialog-footer">
<el-button type="primary" @click="msgDialogVisible = false">关闭</el-button>
</span>
</template>
</el-dialog>
</template>
<style lang="less">
@ -497,6 +517,7 @@ defineExpose({
font-weight: 400;
line-height: 20px;
color: #f54a45;
cursor: pointer;
}
.success {

View File

@ -21,6 +21,8 @@ public class ExportTaskDTO {
private String exportStatus;
private String msg;
private String exportFromType;
private Long exportTime;