Prechádzať zdrojové kódy

实现部分聚合报告到树状报告功能

insomniaLee 6 rokov pred
rodič
commit
9dcf2e31bb

+ 46 - 0
src/main/java/com/mooctest/controller/HistoryController.java

@@ -157,6 +157,52 @@ public class HistoryController {
         return "tree_report_new";
     }
 
+	@GetMapping(value = "/report_part")
+	public String showTreerReportPart(@RequestParam("treeId") String treeId,
+								 @RequestParam("examId") long examId,
+								 @RequestParam("caseId") long caseId,
+								 @RequestParam(value = "finalReportId", required = false) Long finalReportId,
+								 Model model) {
+		Map<String, BugDTO> bugMap = bugReportService.getAllBugsMap(examId, caseId);
+		BugDTO treeReport = bugMap.get(treeId);  // 从bugmap中取得主报告的信息
+		List<String> treeRootids = hisservice.getTreeRoots(caseId+"-"+examId); // 获得所有的根结点的id
+		List<String> childReportIds = hisservice.getSingleRootReports(treeId); // 获得所有自报告的信息
+		List<BugDTO> childReports = new ArrayList<>();
+		childReportIds.forEach(s->{
+			childReports.add(bugMap.get(s));
+		});
+		Map<String, Long> categoryCounts = childReports.stream().collect(Collectors.groupingBy(BugDTO::getBugCategory, Collectors.counting()));
+		Map<String, Long> pageCounts =  childReports.stream().collect(Collectors.groupingBy(BugDTO::getBug_page,Collectors.counting()));
+		Map<String, Long> recurrentCounts = childReports.stream()
+				.map(BugDTO::getRecurrent)
+				.map((recurrentNum) -> ReportUtil.recurrent2String.get(recurrentNum))
+				.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+		Map<String, Long> severityCounts = childReports.stream()
+				.map(BugDTO::getSeverity)
+				.map((severityNum) -> ReportUtil.severity2String.get(severityNum))
+				.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+		List<FinalReportDTO> finalReports = new ArrayList<>();// 暂时还没有finalreport的数据
+
+
+		model.addAttribute("categoryCounts", categoryCounts);
+		model.addAttribute("severityCounts", severityCounts);
+		model.addAttribute("pageCounts",pageCounts);
+		model.addAttribute("recurrentCounts",recurrentCounts);
+		model.addAttribute("aggReportId", "ML-TR-" + treeId.substring(10)); // 树报告的信息
+		model.addAttribute("masterReport", treeReport);
+		model.addAttribute("createTime", new Date(Long.parseLong(treeReport.getCreateTimeMillis())));
+		model.addAttribute("supplements", childReports);
+		model.addAttribute("finalReports", finalReports);
+		model.addAttribute("category2String", ReportUtil.category2String);
+		model.addAttribute("recurrent2String", ReportUtil.recurrent2String);
+		model.addAttribute("severity2String", ReportUtil.severity2String);
+		model.addAttribute("reviewed",false);
+		model.addAttribute("examId", examId);
+		model.addAttribute("caseId", caseId);
+		return "tree_report_new::treeBody";
+	}
+
+
 
 	//获取所有形成树状结构的bug根节点
 //	case_take_id=1281-2724&start=0&count=10&page=null&identity=0&report_id=5cbc1a9f825a8960cdc7bd4f&worker_id=22383

+ 2 - 1
src/main/java/com/mooctest/controller/ReportController.java

@@ -61,6 +61,7 @@ public class ReportController {
 
 
 
+    //聚合报告
     @GetMapping(value = "/report")
     public String showAggrReport(@RequestParam("masterId") String masterId,
                                  @RequestParam("examId") long examId,
@@ -102,6 +103,7 @@ public class ReportController {
         model.addAttribute("severity2String", ReportUtil.severity2String);
         model.addAttribute("examId", examId);
         model.addAttribute("caseId", caseId);
+//        model.addAttribute("show")
 
         boolean bugReviewed = bugReviewService.isBugReviewed(masterId);
         model.addAttribute("reviewed", bugReviewed);
@@ -109,7 +111,6 @@ public class ReportController {
             Optional<FinalReportDTO> finalReportDTO = finalReports.stream().filter(finalReport -> finalReport.getId()==finalReportId).findFirst();
             model.addAttribute("finalReportId", finalReportId);
             model.addAttribute("editReport", finalReportDTO.get());
-
         }
         return "agg_report_new";
     }

+ 24 - 13
src/main/resources/static/js/agg_report_new.js

@@ -1,5 +1,15 @@
 $(function () {
 
+    if( urlParams.get("masterId") == null){
+        return ;
+    }
+
+    initMaster();
+
+});
+
+initMaster=function () {
+
     function createImg(src) {
         var $img = $('<img />')
         $img.attr("src", src);
@@ -64,10 +74,10 @@ $(function () {
             })
                 .on('mouseover', function (d) {
 
-                var g = d3.select(this); // The node
-                var n = g.select('.the-node');
-                var info = n.transition().duration(400).attr('r', 47 / d.data.group)
-            })
+                    var g = d3.select(this); // The node
+                    var n = g.select('.the-node');
+                    var info = n.transition().duration(400).attr('r', 47 / d.data.group)
+                })
                 .on('mouseout', function (d) {
                     var g = d3.select(this); // The node
                     var n = g.select('.the-node');
@@ -96,11 +106,11 @@ $(function () {
         treeNodes.append('circle')
             .classed('the-node solid', true)
             .attr('cx', d => d.x)
-            .attr('cy', d => d.y + 20)
-            .attr('r', d => 40 / d.data.group)
-            .style("fill", function (d) {
-                return color[d.data.group]
-            });
+    .attr('cy', d => d.y + 20)
+    .attr('r', d => 40 / d.data.group)
+    .style("fill", function (d) {
+            return color[d.data.group]
+        });
 
         treeNodes.append('text')
             .attr('class', 'label')
@@ -131,14 +141,15 @@ $(function () {
             .append('path')
             .classed('link', true)
             .attr("d", (d) => {
-                return `
+            return `
       M ${d.x} ${d.y}
       C 
       ${d.x} ${(d.y + d.parent.y) / 2}
       ${d.parent.x} ${(d.y + d.parent.y) / 2}
       ${d.parent.x} ${d.parent.y}
       `;
-            })
-            .style("stroke", "#5f5f5f");
+    })
+    .style("stroke", "#5f5f5f");
     });
-});
+
+}

+ 12 - 1
src/main/resources/static/js/tree_report_new.js

@@ -1,5 +1,16 @@
 $(function () {
 
+    if( urlParams.get("treeId") == null){
+        return ;
+    }
+
+    initTree();
+
+
+});
+
+
+initTree = function () {
     function createImg(src) {
         var $img = $('<img />')
         $img.attr("src", src);
@@ -141,4 +152,4 @@ $(function () {
     })
     .style("stroke", "#5f5f5f");
     });
-});
+}

+ 41 - 6
src/main/resources/templates/agg_report_new.html

@@ -45,9 +45,13 @@
 <th:block layout:fragment="maincontent">
 
     <section class="content-header">
-        <h1>融合报告详情
+<!--        <button id="backButton" onclick="showMainReport()"  style="display: none; " >返回</button>-->
+        <h1 id="mainTitle">融合报告详情
             <small th:text="${aggReportId}"></small>
+
+            <button id="backButton" type="button" class="btn btn-default" onclick="showMainReport()"  style="display: none; " >返回</button>
         </h1>
+
         <!-- <h1>Summary for report 0-5</h1> -->
         <!-- <small style="font-style: italic;">at 50% report-level and 25% supplementary level</small> -->
 
@@ -69,9 +73,10 @@
             </li>
         </ol>
     </section>
-    <section class="content container-fluid">
+
+    <section  class="content container-fluid">
         <div style="overflow: auto;" class="row">
-            <div class="col-md-8" id="summary">
+            <div class="col-md-8" id="summary" th:fragment="masterBody">
                 <div class="box box-info detail-table">
                     <div class="box-header with-border" style="padding: 4px;">
                         <i class="fa fa-object-group" style="color: #00c0ef;"></i>
@@ -206,7 +211,7 @@
                                                       style="color: #3c8dbc; margin-right: 5px;"></span>
                                                     <a th:href="'/report/'+${report.id}+'?examId=' + ${examId} + '&amp;caseId=' + ${caseId}" style="margin-right: 5px;" th:text="${report.id}"></a>
                                                     <!--查看树状报告-->
-                                                    <span th:if="${single2root.get(report.id)!=null}"
+                                                    <span th:if="${single2root.get(report.id)!=null}"  th:onclick="'changeToTree('+${single2root.get(report.id)}+')'"
                                                           th:href="'/history/report?treeId='+${single2root.get(report.id)}+'&amp;examId='+ ${examId} + '&amp;caseId=' + ${caseId}"
                                                           class="glyphicon glyphicon-tree-conifer"
                                                            style="color: #07b309; margin-right: 5px;" >
@@ -236,17 +241,20 @@
                                             </ul>
                                         </div>
                                     </li>
-
-
                                 </ul>
                             </td>
                         </tr>
                         </tbody>
                     </table>
                 </div>
+            </div>
+
+            <div id="treePart">
 
             </div>
 
+
+
             <div class="col-md-4 pull-right" >
                 <!--<div id="my_favorite_latin_words" class="box box-info" style="margin-bottom: 5px; min-height: 182px;"></div>-->
 
@@ -388,6 +396,9 @@
         </div>
 
 
+
+
+
     </section>
 </th:block>
 
@@ -429,6 +440,7 @@
 </script>
 <script src="https://d3js.org/d3.v4.min.js"></script>
 <script type="text/javascript" src="/static/js/agg_report_new.js"></script>
+<script type="text/javascript" src="/static/js/tree_report_new.js"></script>
 <script type="text/javascript" src="/static/js/jqcloud-1.0.4.min.js"></script>
 <!--<script type="text/javascript" src="/static/js/partload.js"></script>-->
 <script type="text/javascript" xmlns:th="http://www.thymeleaf.org" th:inline="javascript">
@@ -510,6 +522,29 @@
         }
     }
 
+    changeToTree = function (treeId) { //
+        // alert(treeId);
+        // $('#summary').hide();
+        /*<![CDATA[*/
+        $('#summary').hide();
+        $("#treePart").load("/history/report_part?treeId="+treeId+"&caseId="+ caseId +"&examId="+ examId);
+        //$('#new-report-create-block').load("/created_reports_form");
+        $("#backButton").show();
+        $('.sup-collapse').click(function () {
+            var dupTitle = $(this).parents('li').find('.sup-title');
+            dupTitle.toggle();
+        });
+        $('#treePart').show();
+        initTree();
+    }
+
+    showMainReport  = function () {
+        $('#summary').show();
+        $('#treePart').hide();
+        $('#backButton').hide();
+        initMaster();
+    }
+
     function showCreateButton() {
         $("#create_bug").show()
 

+ 4 - 4
src/main/resources/templates/tree_report_new.html

@@ -71,7 +71,7 @@
     </section>
     <section class="content container-fluid">
         <div style="overflow: auto;" class="row">
-            <div class="col-md-8" id="summary">
+            <div class="col-md-8" id="summary" th:fragment="treeBody">
                 <div class="box box-info detail-table">
                     <div class="box-header with-border" style="padding: 4px;">
                         <i class="fa fa-object-group" style="color: #00c0ef;"></i>
@@ -174,7 +174,7 @@
                         <tr>
                             <td class="attr-title">补充点</td>
                             <td class="dup-supplementary" colspan="3">
-                                <ul id="sup-list" class="list-group"
+                                <ul id="tree-sup-list" class="list-group"
                                     style="max-height: 450px; margin-bottom: 0px; overflow: scroll;">
 
                                     <li class="list-group-item" style="padding: 3px 3px;"
@@ -182,7 +182,7 @@
 
                                         <p style="border-bottom: 1px solid #ddd; margin: 0 0 1px;">
                                             <b><a href="#" th:text="'补充点 ' + ${iterStat.count}"> </a></b>
-                                            <a th:href="'#sup-' + ${iterStat.count}"
+                                            <a th:href="'#tree-sup-' + ${iterStat.count}"
                                                class="glyphicon glyphicon-menu-hamburger pull-right sup-collapse"
                                                data-toggle="collapse" style="color: #000;"></a>
                                         </p>
@@ -198,7 +198,7 @@
 
 
                                         </div>
-                                        <div th:id="'sup-' + ${iterStat.count}" class="collapse">
+                                        <div th:id="'tree-sup-' + ${iterStat.count}" class="collapse">
                                             <ul class="list-group" style="margin-bottom: 0px;">
                                                 <li class="list-group-item" style="padding: 3px 3px;"
                                                     >