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

View File

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

View File

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

View File

@ -19,6 +19,8 @@ const { t } = useI18n()
const tableData = ref([]) const tableData = ref([])
const drawerLoading = ref(false) const drawerLoading = ref(false)
const drawer = ref(false) const drawer = ref(false)
const msgDialogVisible = ref(false)
const msg = ref('')
const exportDatasetLoading = ref(false) const exportDatasetLoading = ref(false)
const activeName = ref('ALL') const activeName = ref('ALL')
const multipleSelection = ref([]) const multipleSelection = ref([])
@ -224,6 +226,11 @@ const downLoadAll = () => {
}) })
}) })
} }
const showMsg = item => {
msg.value = ''
msg.value = item.msg
msgDialogVisible.value = true
}
const timestampFormatDate = value => { const timestampFormatDate = value => {
if (!value) { if (!value) {
return '-' return '-'
@ -383,7 +390,11 @@ defineExpose({
</el-icon> </el-icon>
<div class="name-content"> <div class="name-content">
<div class="fileName">{{ scope.row.fileName }}</div> <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') }} {{ $t('data_export.export_failed') }}
</div> </div>
<div v-if="scope.row.exportStatus === 'SUCCESS'" class="success"> <div v-if="scope.row.exportStatus === 'SUCCESS'" class="success">
@ -444,6 +455,15 @@ defineExpose({
</el-table> </el-table>
</div> </div>
</el-drawer> </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> </template>
<style lang="less"> <style lang="less">
@ -497,6 +517,7 @@ defineExpose({
font-weight: 400; font-weight: 400;
line-height: 20px; line-height: 20px;
color: #f54a45; color: #f54a45;
cursor: pointer;
} }
.success { .success {

View File

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