fix(项目报告): 修复项目报告发送邮件失败的问题

--bug=1018499 --user=宋天阳 【报表管理】发送报告提示异常
https://www.tapd.cn/55049933/s/1269178
This commit is contained in:
song-tianyang 2022-10-20 11:15:19 +08:00 committed by 建国
parent 53aa0fe219
commit 271b375b43
11 changed files with 175 additions and 175 deletions

View File

@ -11,10 +11,8 @@ public class EnterpriseReportContentStep implements Serializable {
private String type; private String type;
//type为report //type为report
private String reportRecordId; private String reportRecordId;
// @JsonProperty("reportRecordData") private Map<String, Object> reportRecordData;
private Map<String, String> reportRecordData;
private String recordImageContent; private String recordImageContent;
// @JsonProperty("tableData")
private Map<String, String> tableData; private Map<String, String> tableData;
//type为txt //type为txt
private String previewContext; private String previewContext;

View File

@ -3,8 +3,8 @@ package io.metersphere.reportstatistics.service;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.EnterpriseTestReportMapper; import io.metersphere.base.mapper.EnterpriseTestReportMapper;
import io.metersphere.base.mapper.EnterpriseTestReportSendRecordMapper; import io.metersphere.base.mapper.EnterpriseTestReportSendRecordMapper;
import io.metersphere.base.mapper.ext.ExtEnterpriseTestReportMapper;
import io.metersphere.base.mapper.ext.BaseUserGroupMapper; import io.metersphere.base.mapper.ext.BaseUserGroupMapper;
import io.metersphere.base.mapper.ext.ExtEnterpriseTestReportMapper;
import io.metersphere.commons.constants.ScheduleGroup; import io.metersphere.commons.constants.ScheduleGroup;
import io.metersphere.commons.constants.ScheduleStatus; import io.metersphere.commons.constants.ScheduleStatus;
import io.metersphere.commons.constants.ScheduleType; import io.metersphere.commons.constants.ScheduleType;
@ -408,7 +408,8 @@ public class EnterpriseTestReportService {
StringBuffer tableBuffer = new StringBuffer(); StringBuffer tableBuffer = new StringBuffer();
tableBuffer.append("<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 100%;border: 1px\">"); tableBuffer.append("<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 100%;border: 1px\">");
try { try {
TestCaseCountTableDataDTO showTable = JSON.parseObject(step.getReportRecordData().get("showTable"), TestCaseCountTableDataDTO.class); String showTableJsonStr = JSON.toJSONString(step.getReportRecordData().get("showTable"));
TestCaseCountTableDataDTO showTable = JSON.parseObject(showTableJsonStr, TestCaseCountTableDataDTO.class);
tableBuffer.append("<tr style=\"font-size: 14px;font-weight: 700;color: #909399;text-align: left;\">"); tableBuffer.append("<tr style=\"font-size: 14px;font-weight: 700;color: #909399;text-align: left;\">");
for (TestCaseCountTableItemDataDTO itemData : showTable.getHeads()) { for (TestCaseCountTableItemDataDTO itemData : showTable.getHeads()) {
String tableHeadValue = itemData.getValue(); String tableHeadValue = itemData.getValue();
@ -454,6 +455,7 @@ public class EnterpriseTestReportService {
} }
} catch (Exception e) { } catch (Exception e) {
LogUtil.error("解析表格数据出错!", e);
} }
tableBuffer.append("</table>"); tableBuffer.append("</table>");
returnReportContentBuffer.append(tableBuffer); returnReportContentBuffer.append(tableBuffer);

View File

@ -36,7 +36,7 @@ export default {
placeholder: { placeholder: {
type: String, type: String,
}, },
errorInfor: String, errorInfo: String,
addTagOnKeys: { addTagOnKeys: {
type: Array, type: Array,
default: () => [13, 188, 9] default: () => [13, 188, 9]
@ -119,8 +119,8 @@ export default {
this.innerTags.push(tag) this.innerTags.push(tag)
return true return true
} else { } else {
if (tag !== "" && this.errorInfor) { if (tag !== "" && this.errorInfo) {
this.$error(this.errorInfor); this.$error(this.errorInfo);
} }
} }
return false return false

View File

@ -245,16 +245,16 @@ export default {
if (command === 'jpg') { if (command === 'jpg') {
imageType = 'image/jpg'; imageType = 'image/jpg';
} }
let returnImageDatas = ""; let returnImageData = "";
if (document.getElementById(this.reportId)) { if (document.getElementById(this.reportId)) {
let chartsCanvas = document.getElementById(this.reportId).querySelectorAll('canvas')[0]; let chartsCanvas = document.getElementById(this.reportId).querySelectorAll('canvas')[0];
if (chartsCanvas) { if (chartsCanvas) {
// toDataURL()canvascanvasbase64 // toDataURL()canvascanvasbase64
returnImageDatas = chartsCanvas && chartsCanvas.toDataURL(imageType); returnImageData = chartsCanvas && chartsCanvas.toDataURL(imageType);
} }
} }
this.$emit("getImage", returnImageDatas); this.$emit("getImage", returnImageData);
return returnImageDatas; return returnImageData;
}, },
exportCommand(command) { exportCommand(command) {
let fileName = 'report_pic.' + command; let fileName = 'report_pic.' + command;

View File

@ -2,7 +2,7 @@
<div v-loading="loading" class="ms-div"> <div v-loading="loading" class="ms-div">
<el-card> <el-card>
<el-row style="padding-top: 10px"> <el-row style="padding-top: 10px">
<p class="tip"><span style="margin-left: 5px"></span>{{$t('commons.report_statistics.excel')}} </p> <p class="tip"><span style="margin-left: 5px"></span>{{ $t('commons.report_statistics.excel') }} </p>
</el-row> </el-row>
<el-row> <el-row>
<el-table <el-table
@ -51,72 +51,72 @@
</template> </template>
<script> <script>
export default { export default {
name: "ReportTable", name: "ReportTable",
components: {}, components: {},
props: { props: {
tableData: Array, tableData: Array,
groupName: String, groupName: String,
showColoums: Array, showColumns: Array,
fullScreen: { fullScreen: {
type: Boolean, type: Boolean,
default(){ default() {
return false; return false;
} }
} }
}, },
data() { data() {
return { return {
tableHeight : "100px", tableHeight: "100px",
w: document.documentElement.clientWidth - 760, w: document.documentElement.clientWidth - 760,
loading: false, loading: false,
} }
}, },
created() { created() {
this.getTableHeight(); this.getTableHeight();
if(this.fullScreen){ if (this.fullScreen) {
this.w = document.documentElement.clientWidth; this.w = document.documentElement.clientWidth;
} }
}, },
methods: { methods: {
isShowColumn(type){ isShowColumn(type) {
if(this.showColoums){ if (this.showColumns) {
return this.showColoums.findIndex(item => item=== type) >= 0; return this.showColumns.findIndex(item => item === type) >= 0;
}else { } else {
return false; return false;
} }
}, },
getTableHeight(){ getTableHeight() {
let countNumber = document.documentElement.clientHeight * 0.4 /1 - 140; let countNumber = document.documentElement.clientHeight * 0.4 / 1 - 140;
countNumber = Math.ceil(countNumber); countNumber = Math.ceil(countNumber);
this.tableHeight = countNumber + 'px'; this.tableHeight = countNumber + 'px';
} }
}, },
} }
</script> </script>
<style scoped> <style scoped>
.tip { .tip {
float: left; float: left;
font-size: 14px; font-size: 14px;
border-radius: 2px; border-radius: 2px;
border-left: 2px solid #783887; border-left: 2px solid #783887;
margin: 0px 20px 0px; margin: 0px 20px 0px;
} }
.ms-div { .ms-div {
margin-bottom: 20px; margin-bottom: 20px;
} }
.ms-table { .ms-table {
width: 95%; width: 95%;
margin: 20px; margin: 20px;
} }
:deep(.el-card__body) { :deep(.el-card__body) {
padding: 0px; padding: 0px;
} }
</style> </style>

View File

@ -32,7 +32,7 @@ export default {
} }
}, },
methods: { methods: {
initDatas() { initData() {
if (this.$refs.reportItemPic && this.$refs.reportItemPic.length > 0) { if (this.$refs.reportItemPic && this.$refs.reportItemPic.length > 0) {
this.$refs.reportItemPic.forEach(item => { this.$refs.reportItemPic.forEach(item => {
item.initData(); item.initData();

View File

@ -14,7 +14,7 @@
ref="analysisChart" :load-option="loadOption" :pie-option="pieOption"/> ref="analysisChart" :load-option="loadOption" :pie-option="pieOption"/>
</div> </div>
<div class="ms-row"> <div class="ms-row">
<report-table :full-screen="false" :group-name="options.xaxis" :show-coloums="options.yaxis" <report-table :full-screen="false" :group-name="options.xaxis" :show-columns="options.yaxis"
:tableData="tableData"/> :tableData="tableData"/>
</div> </div>
</div> </div>
@ -71,7 +71,7 @@ export default {
deleteDetail() { deleteDetail() {
this.$emit("deleteDetail", this.reportDetail); this.$emit("deleteDetail", this.reportDetail);
}, },
editAttachDataName(comman) { editAttachDataName(common) {
this.reportDetail.nameIsEdit = !this.reportDetail.nameIsEdit; this.reportDetail.nameIsEdit = !this.reportDetail.nameIsEdit;
}, },
initPic() { initPic() {

View File

@ -29,7 +29,7 @@
:label-width="formLabelWidth" :label-width="formLabelWidth"
prop="addressee"> prop="addressee">
<ms-input-tag :currentScenario="form" prop="addressee" <ms-input-tag :currentScenario="form" prop="addressee"
:error-infor="$t('commons.report_statistics.alert.mail_is_exist')" :error-info="$t('commons.report_statistics.alert.mail_is_exist')"
:placeholder="$t('mail.enter_mail_addressee')" :placeholder="$t('mail.enter_mail_addressee')"
@onblur="validateForm"> @onblur="validateForm">
</ms-input-tag> </ms-input-tag>
@ -72,7 +72,7 @@
:label-width="formLabelWidth" :label-width="formLabelWidth"
prop="duplicated"> prop="duplicated">
<ms-input-tag :currentScenario="form" prop="duplicated" <ms-input-tag :currentScenario="form" prop="duplicated"
:error-infor="$t('commons.report_statistics.alert.mail_is_exist')" :error-info="$t('commons.report_statistics.alert.mail_is_exist')"
:placeholder="$t('mail.enter_mail_duplicate')" :placeholder="$t('mail.enter_mail_duplicate')"
@onblur="validateForm"/> @onblur="validateForm"/>
</el-form-item> </el-form-item>
@ -126,7 +126,7 @@
</el-popover> </el-popover>
</ms-form-divider> </ms-form-divider>
<email-compnent :read-only="false" :data.sync="form.reportContent" ref="emailCompnent"/> <email-component :read-only="false" :data.sync="form.reportContent" ref="emailComponent"/>
</el-form> </el-form>
<template v-slot:footer> <template v-slot:footer>
@ -168,7 +168,7 @@ import {getUUID, listenGoBack, removeGoBackListener} from "metersphere-frontend/
import {getCurrentProjectID, getCurrentUserId} from "metersphere-frontend/src/utils/token"; import {getCurrentProjectID, getCurrentUserId} from "metersphere-frontend/src/utils/token";
import MsInputTag from "@/business/compnent/form/MsInputTag"; import MsInputTag from "@/business/compnent/form/MsInputTag";
import MsFormDivider from "metersphere-frontend/src/components/MsFormDivider"; import MsFormDivider from "metersphere-frontend/src/components/MsFormDivider";
import EmailCompnent from "@/business/enterprisereport/components/container/EmailComponent"; import EmailComponent from "@/business/enterprisereport/components/container/EmailComponent";
import ReportStatisticsDialog from "@/business/enterprisereport/components/dialog/SelectReportStatisticsDialog"; import ReportStatisticsDialog from "@/business/enterprisereport/components/dialog/SelectReportStatisticsDialog";
import EmailPreviewDialog from "@/business/enterprisereport/components/dialog/EmailPreviewDialog"; import EmailPreviewDialog from "@/business/enterprisereport/components/dialog/EmailPreviewDialog";
import {getUesrGroup} from "@/api/user"; import {getUesrGroup} from "@/api/user";
@ -177,7 +177,7 @@ import {createEnterpriseReport, updateEnterpriseReport} from "@/api/enterprise-r
export default { export default {
name: "ProjectReportEditDialog", name: "ProjectReportEditDialog",
components: {MsFormDivider, MsInputTag, EmailCompnent, ReportStatisticsDialog, EmailPreviewDialog}, components: {MsFormDivider, MsInputTag, EmailComponent, ReportStatisticsDialog, EmailPreviewDialog},
data() { data() {
var checkEmail = (rule, value, callback) => { var checkEmail = (rule, value, callback) => {
if (value.length === 0) { if (value.length === 0) {
@ -371,8 +371,8 @@ export default {
// //
this.$refs['planFrom'].validate((valid) => { this.$refs['planFrom'].validate((valid) => {
if (valid) { if (valid) {
if (this.$refs.emailCompnent) { if (this.$refs.emailComponent) {
this.$refs.emailCompnent.initDatas(); this.$refs.emailComponent.initData();
} }
let param = JSON.parse(JSON.stringify(this.form)); let param = JSON.parse(JSON.stringify(this.form));
@ -440,8 +440,8 @@ export default {
this.form = JSON.parse(JSON.stringify(this.baseForm)); this.form = JSON.parse(JSON.stringify(this.baseForm));
}, },
previewReport() { previewReport() {
if (this.$refs.emailCompnent) { if (this.$refs.emailComponent) {
this.$refs.emailCompnent.initDatas(); this.$refs.emailComponent.initData();
} }
this.$refs.emailPreviewDialog.open(this.form) this.$refs.emailPreviewDialog.open(this.form)
}, },

View File

@ -14,7 +14,7 @@
:chart-width="chartWidth" :load-option="loadOption" :pie-option="pieOption"/> :chart-width="chartWidth" :load-option="loadOption" :pie-option="pieOption"/>
</div> </div>
<div class="ms-row" v-if="!isHide"> <div class="ms-row" v-if="!isHide">
<test-case-count-table :group-name="getGroupNameStr(options.xaxis)" :show-coloums="options.yaxis" <test-case-count-table :group-name="getGroupNameStr(options.xaxis)" :show-columns="options.yaxis"
:tableData="tableData"/> :tableData="tableData"/>
</div> </div>
</el-main> </el-main>

View File

@ -163,16 +163,16 @@ export default {
if (command === 'jpg') { if (command === 'jpg') {
imageType = 'image/jpg'; imageType = 'image/jpg';
} }
let returnImageDatas = ""; let returnImageData = "";
if (document.getElementById('picChart')) { if (document.getElementById('picChart')) {
let chartsCanvas = document.getElementById('picChart').querySelectorAll('canvas')[0]; let chartsCanvas = document.getElementById('picChart').querySelectorAll('canvas')[0];
if (chartsCanvas) { if (chartsCanvas) {
// toDataURL()canvascanvasbase64 // toDataURL()canvascanvasbase64
returnImageDatas = chartsCanvas && chartsCanvas.toDataURL(imageType); returnImageData = chartsCanvas && chartsCanvas.toDataURL(imageType);
} }
} }
this.$emit("getImage", returnImageDatas); this.$emit("getImage", returnImageData);
return returnImageDatas; return returnImageData;
}, },
exportCommand(command) { exportCommand(command) {
let fileName = 'report_pic.' + command; let fileName = 'report_pic.' + command;

View File

@ -2,7 +2,7 @@
<div v-loading="loading" class="ms-div"> <div v-loading="loading" class="ms-div">
<el-card :style="{ width: w+'px'}"> <el-card :style="{ width: w+'px'}">
<el-row style="padding-top: 10px"> <el-row style="padding-top: 10px">
<p class="tip"><span style="margin-left: 5px"></span>{{$t('commons.report_statistics.excel')}} </p> <p class="tip"><span style="margin-left: 5px"></span>{{ $t('commons.report_statistics.excel') }} </p>
</el-row> </el-row>
<el-row> <el-row>
<el-table <el-table
@ -51,72 +51,72 @@
</template> </template>
<script> <script>
export default { export default {
name: "TestAnalysisTable", name: "TestAnalysisTable",
components: {}, components: {},
props: { props: {
tableData: Array, tableData: Array,
groupName: String, groupName: String,
showColoums: Array, showColumns: Array,
fullScreen: { fullScreen: {
type: Boolean, type: Boolean,
default(){ default() {
return false; return false;
} }
} }
}, },
data() { data() {
return { return {
tableHeight : "100px", tableHeight: "100px",
w: document.documentElement.clientWidth - 760, w: document.documentElement.clientWidth - 760,
loading: false, loading: false,
} }
}, },
created() { created() {
this.getTableHeight(); this.getTableHeight();
if(this.fullScreen){ if (this.fullScreen) {
this.w = document.documentElement.clientWidth; this.w = document.documentElement.clientWidth;
} }
}, },
methods: { methods: {
isShowColumn(type){ isShowColumn(type) {
if(this.showColoums){ if (this.showColumns) {
return this.showColoums.findIndex(item => item=== type) >= 0; return this.showColumns.findIndex(item => item === type) >= 0;
}else { } else {
return false; return false;
} }
}, },
getTableHeight(){ getTableHeight() {
let countNumber = document.documentElement.clientHeight * 0.4 /1 - 140; let countNumber = document.documentElement.clientHeight * 0.4 / 1 - 140;
countNumber = Math.ceil(countNumber); countNumber = Math.ceil(countNumber);
this.tableHeight = countNumber + 'px'; this.tableHeight = countNumber + 'px';
} }
}, },
} }
</script> </script>
<style scoped> <style scoped>
.tip { .tip {
float: left; float: left;
font-size: 14px; font-size: 14px;
border-radius: 2px; border-radius: 2px;
border-left: 2px solid #783887; border-left: 2px solid #783887;
margin: 0px 20px 0px; margin: 0px 20px 0px;
} }
.ms-div { .ms-div {
margin-bottom: 20px; margin-bottom: 20px;
} }
.ms-table { .ms-table {
width: 95%; width: 95%;
margin: 20px; margin: 20px;
} }
:deep( .el-card__body ) { :deep( .el-card__body ) {
padding: 0px; padding: 0px;
} }
</style> </style>