fix(项目报告): 修复项目报告分享链接时报告内容解析失败的问题

修复项目报告分享链接时报告内容解析失败的问题
This commit is contained in:
song-tianyang 2022-10-26 18:36:11 +08:00 committed by 刘瑞斌
parent 9d544a4f3e
commit 5866dc2ac2
8 changed files with 37 additions and 23 deletions

View File

@ -59,7 +59,7 @@ public class ShiroUtils {
//分享相关接口
filterChainDefinitionMap.put("/share/info/generateShareInfoWithExpired", "anon");
filterChainDefinitionMap.put("/share/list", "anon");
filterChainDefinitionMap.put("/share/info/selectHistoryReportById", "anon");
filterChainDefinitionMap.put("/report/stat/share/**", "anon");
filterChainDefinitionMap.put("/share/get/**", "anon");
filterChainDefinitionMap.put("/share/info", "apikey, csrf, authc"); // 需要认证
filterChainDefinitionMap.put("/document/**", "anon");

View File

@ -0,0 +1,12 @@
package io.metersphere.reportstatistics.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class PageRedirectController {
@GetMapping(value = "/chart-pic")
public String getChart() {
return "share-enterprise-report.html";
}
}

View File

@ -3,30 +3,21 @@ package io.metersphere.reportstatistics.controller;
import io.metersphere.base.domain.ReportStatisticsWithBLOBs;
import io.metersphere.reportstatistics.dto.ReportStatisticsSaveRequest;
import io.metersphere.reportstatistics.service.ReportStatisticsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@Controller
@RestController
@RequestMapping(value = "/report/stat/share")
public class ReportStatShareController {
@GetMapping(value = "/chart-pic")
public String getChart() {
return "share-enterprise-report.html";
}
}
@RequestMapping(value = "/share/info")
class ShareInfoController {
@Resource
private ReportStatisticsService reportStatisticsService;
@PostMapping("/selectHistoryReportById")
@PostMapping("/select/report/by/id")
public ReportStatisticsWithBLOBs selectById(@RequestBody ReportStatisticsSaveRequest request) {
return reportStatisticsService.selectById(request.getId());
}
}
}

View File

@ -84,7 +84,7 @@ public class ReportStatisticsService {
boolean isReportNeedUpdate = this.isReportNeedUpdate(blob);
if (isReportNeedUpdate) {
TestCaseCountRequest countRequest = JSON.parseObject(blob.getSelectOption(), TestCaseCountRequest.class);
Map<String, Object> returnDataOption = this.reloadData(countRequest, JSON.toJSONString(dataOption.get("chartType")));
Map<String, Object> returnDataOption = this.reloadData(countRequest, dataOption.get("chartType").toString());
if (returnDataOption != null) {
dataOption = returnDataOption;
}
@ -94,8 +94,13 @@ public class ReportStatisticsService {
if (dataOption.get("tableData") != null) {
String tableDataJsonStr = JSON.toJSONString(dataOption.get("tableData"));
List<TestCaseCountTableDTO> dtos = JSON.parseArray(tableDataJsonStr, TestCaseCountTableDTO.class);
String yaxisStr = JSON.toJSONString(selectOption.get("yaxis"));
List<String> yaxis = JSON.parseArray(yaxisStr, String.class);
List<String> yaxis = new ArrayList<>();
try {
yaxis = (List<String>) selectOption.get("yaxis");
} catch (Exception e) {
String yaxisStr = JSON.toJSONString(selectOption.get("yaxis"));
yaxis = JSON.parseArray(yaxisStr, String.class);
}
TestCaseCountTableDataDTO showTable = this.countShowTable(String.valueOf(selectOption.get("xaxis")), yaxis, dtos);
dataOption.put("showTable", showTable);
blob.setDataOption(JSON.toJSONString(dataOption));

View File

@ -70,7 +70,7 @@ public class ChromeUtil {
driver.get(url);
driver.manage().window().fullscreen();
//预留echart动画的加载时间
Thread.sleep(3 * 1000);
Thread.sleep(10 * 1000);
String js = "var chartsCanvas = document.getElementById('picChart').getElementsByTagName('canvas')[0];" +
"var imageUrl = null;" +
"if (chartsCanvas!= null) {" +

View File

@ -1,9 +1,9 @@
import {post} from "metersphere-frontend/src/plugins/request"
let basePath = '/share/info';
let basePath = '/report/stat/share';
export function selectShareReportById(param) {
return post(basePath + '/selectHistoryReportById', param)
return post(basePath + '/select/report/by/id', param)
}
export function getShareId() {

View File

@ -203,6 +203,12 @@ export default {
if (typeof (formatData.xaxis) === 'string') {
formatData.xaxis = JSON.parse(formatData.xaxis);
}
if (typeof (formatData.xAxis) === 'string') {
formatData.xAxis = JSON.parse(formatData.xAxis);
}
if (typeof (formatData.yAxis) === 'string') {
formatData.yAxis = JSON.parse(formatData.yAxis);
}
if (typeof (formatData.series) === 'string') {
formatData.series = JSON.parse(formatData.series);
}

View File

@ -1,10 +1,10 @@
<template>
<report-chart v-if="!needReloading" :read-only="true" :need-full-screen="false" :chart-type="dataOption.chartType"
<report-chart v-if="!needReloading" :read-only="true" :need-full-screen="false"
:chart-type="dataOption.chartType"
ref="analysisChart" :load-option="dataOption.loadOption" :pie-option="dataOption.pieOption"/>
</template>
<script>
// import ReportChart from "@/template/enterprise/share/ReportChart";
import ReportChart from "@/business/enterprisereport/components/chart/ReportChart";
import {getShareId, selectShareReportById} from "@/api/share";