Explorar el Código

完善树状报告详情页面。

insomniaLee hace 6 años
padre
commit
82fda18820

+ 9 - 1
src/main/java/com/mooctest/controller/HistoryController.java

@@ -5,6 +5,7 @@ import com.mooctest.data.FinalReportDTO;
 import com.mooctest.data.SupplementDTO;
 import com.mooctest.data.TaskDTO;
 import com.mooctest.model.FinalReport;
+import com.mooctest.model.MasterReport;
 import com.mooctest.service.*;
 import com.mooctest.util.ReportUtil;
 import org.json.JSONArray;
@@ -46,6 +47,9 @@ public class HistoryController {
 	@Autowired
 	FinalReportService finalReportService;
 
+	@Autowired
+	MasterReportService masterReportService;
+
 
 	//获取指定节点的历史信息
 //	@RequestMapping(value = "/getHistory")
@@ -144,6 +148,7 @@ public class HistoryController {
 				.map((severityNum) -> ReportUtil.severity2String.get(severityNum))
 				.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
 //		List<FinalReportDTO> finalReports = new ArrayList<>();// 暂时还没有finalreport的数据
+		Map<String,String> report2master = masterReportService.getBugIds2Master(masterReportService.getAllMasterIdByExamIdAndCaseId(examId, caseId));
 
 		List<FinalReportDTO> finalReports = finalReportService.getBySourceId(treeId);
         model.addAttribute("categoryCounts", categoryCounts);
@@ -160,6 +165,7 @@ public class HistoryController {
         model.addAttribute("severity2String", ReportUtil.severity2String);
         model.addAttribute("reviewed",false);
         model.addAttribute("examId", examId);
+        model.addAttribute("report2master",report2master);
         model.addAttribute("caseId", caseId);
 		model.addAttribute("showReference",true);//是否展示其他聚合报告的参考标签
         return "tree_report_new";
@@ -190,7 +196,8 @@ public class HistoryController {
 				.map((severityNum) -> ReportUtil.severity2String.get(severityNum))
 				.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
 		List<FinalReportDTO> finalReports = new ArrayList<>();// 暂时还没有finalreport的数据
-
+		//report to master
+		Map<String,String> report2master = masterReportService.getBugIds2Master(masterReportService.getAllMasterIdByExamIdAndCaseId(examId, caseId));
 
 		model.addAttribute("severityCounts", severityCounts);
 		model.addAttribute("categoryCounts", categoryCounts);
@@ -204,6 +211,7 @@ public class HistoryController {
 		model.addAttribute("category2String", ReportUtil.category2String);
 		model.addAttribute("recurrent2String", ReportUtil.recurrent2String);
 		model.addAttribute("severity2String", ReportUtil.severity2String);
+		model.addAttribute("report2master",report2master); // report 2 master report//
 		model.addAttribute("reviewed",false);
 		model.addAttribute("examId", examId);
 		model.addAttribute("caseId", caseId);

+ 57 - 0
src/main/java/com/mooctest/controller/ReportController.java

@@ -105,6 +105,7 @@ public class ReportController {
         model.addAttribute("caseId", caseId);
 //        model.addAttribute("show")
 
+        model.addAttribute("showReference",true);//是否展示其他聚合报告的参考标签
         boolean bugReviewed = bugReviewService.isBugReviewed(masterId);
         model.addAttribute("reviewed", bugReviewed);
         if (finalReportId != null) {
@@ -115,6 +116,62 @@ public class ReportController {
         return "agg_report_new";
     }
 
+    //part of aggreate report
+    @GetMapping(value = "/report_part")
+    public String showAggrReportPart(@RequestParam("masterId") String masterId,
+                                 @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 masterReport = bugMap.get(masterId);
+        List<SupplementDTO> supplements = supplementService.getSupplementByMasterId(masterId, bugMap);
+        List<BugDTO> bugs = new LinkedList<>();
+        supplements.forEach(supplementDTO -> bugs.addAll(supplementDTO.getBugs()));
+        List<BugDTO> sourceReports = bugs.stream().distinct().collect(Collectors.toList());
+        Map<String, Long> categoryCounts = sourceReports.stream().collect(Collectors.groupingBy(BugDTO::getBugCategory, Collectors.counting()));
+        Map<String, Long> pageCounts =  sourceReports.stream().collect(Collectors.groupingBy(BugDTO::getBug_page,Collectors.counting()));
+        Map<String, Long> recurrentCounts = sourceReports.stream()
+                .map(BugDTO::getRecurrent)
+                .map((recurrentNum) -> ReportUtil.recurrent2String.get(recurrentNum))
+                .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+        Map<String, Long> severityCounts = sourceReports.stream()
+                .map(BugDTO::getSeverity)
+                .map((severityNum) -> ReportUtil.severity2String.get(severityNum))
+                .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+
+        List<FinalReportDTO> finalReports = finalReportService.getBySourceId(masterId);
+        Map<String,String> single2rootMap = historyService.getSingle2Root(caseId, examId);
+        model.addAttribute("single2root",single2rootMap);
+        model.addAttribute("wordList", getWordCloudList(sourceReports));
+        model.addAttribute("categoryCounts", categoryCounts);
+        model.addAttribute("severityCounts", severityCounts);
+        model.addAttribute("pageCounts",pageCounts);
+        model.addAttribute("recurrentCounts",recurrentCounts);
+        model.addAttribute("aggReportId", "ML-AG-" + masterId.substring(10));
+        model.addAttribute("masterReport", masterReport);
+        model.addAttribute("createTime", new Date(Long.parseLong(masterReport.getCreateTimeMillis())));
+        model.addAttribute("supplements", supplements);
+        model.addAttribute("finalReports", finalReports);
+        model.addAttribute("category2String", ReportUtil.category2String);
+        model.addAttribute("recurrent2String", ReportUtil.recurrent2String);
+        model.addAttribute("severity2String", ReportUtil.severity2String);
+        model.addAttribute("examId", examId);
+        model.addAttribute("caseId", caseId);
+
+        model.addAttribute("showReference",false);//是否展示其他聚合报告的参考标签
+
+
+        boolean bugReviewed = bugReviewService.isBugReviewed(masterId);
+        model.addAttribute("reviewed", bugReviewed);
+        if (finalReportId != null) {
+            Optional<FinalReportDTO> finalReportDTO = finalReports.stream().filter(finalReport -> finalReport.getId()==finalReportId).findFirst();
+            model.addAttribute("finalReportId", finalReportId);
+            model.addAttribute("editReport", finalReportDTO.get());
+        }
+        return "agg_report_new::masterBody";
+    }
+
     @GetMapping(value = "/report/{id}")
     public String showAggrReportTest(@PathVariable("id") String   id,
                                  @RequestParam("examId") long examId,

+ 2 - 0
src/main/java/com/mooctest/service/MasterReportService.java

@@ -92,6 +92,7 @@ public class MasterReportService {
                 .collect(Collectors.toList());
     }
 
+
     public Map<String, List<String>> getMaster2BugIdsMap(List<String> masterIds) {
         List<MasterReport> mrs = masterReportDao.findByMasterIdIn(masterIds);
         return mrs.stream().collect(
@@ -102,6 +103,7 @@ public class MasterReportService {
     }
 
     //获得bug对masteride 的map
+    // 获得普通报告dui master报告的对应关系关系
     public Map<String , String > getBugIds2Master(List<String> masterIds){
         List<MasterReport> nrs = masterReportDao.findByMasterIdIn(masterIds);
         return nrs.stream().collect(Collectors.toMap(MasterReport::getBugId,MasterReport::getMasterId));

+ 7 - 5
src/main/resources/static/js/agg_report_new.js

@@ -3,13 +3,15 @@ $(function () {
     if( urlParams.get("masterId") == null){
         return ;
     }
-
-    initMaster();
+    var masterId = urlParams.get("masterId")
+    initMaster(masterId);
 
 });
 
-initMaster=function () {
-
+initMaster=function (masterId) {
+    console.log("zhixing")
+    $('.nodes').html("");
+    $('.links').html(""); // clear content of node, in order to refresh
     function createImg(src) {
         var $img = $('<img />')
         $img.attr("src", src);
@@ -57,7 +59,7 @@ initMaster=function () {
     };
 
     var urlParams = new URLSearchParams(window.location.search);
-    d3.json("/tree?masterId=" + urlParams.get("masterId"), function(error, data) {
+    d3.json("/tree?masterId=" + masterId, function(error, data) {
         var root = d3.hierarchy(data);
 
         var normal_r = 14;

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

@@ -248,7 +248,7 @@
                 </div>
             </div>
 
-            <div id="treePart">
+            <div id="aggPart">
 
             </div>
 
@@ -680,6 +680,11 @@
 
     }
 
+
+
+
+
+
     function reviewConfirm() {
         $.ajax({
             url: '/bug_review?masterId='+masterId,

+ 77 - 5
src/main/resources/templates/tree_report_new.html

@@ -47,6 +47,7 @@
     <section class="content-header">
         <h1>树状报告详情
             <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> -->
@@ -206,13 +207,12 @@
                                                       style="color: #3c8dbc; margin-right: 5px;"></span>
                                                     <a th:href="'/report/'+${supplement.id}+'?examId=' + ${examId} + '&amp;caseId=' + ${caseId}" style="margin-right: 5px;" th:text="${supplement.getId()}"></a>
                                                     <!--查看聚合报告-->
-                                                    <span th:if="${showReference == true}" class="fa fa-sitemap text-warning"
+                                                     <span th:if="${report2master.get(supplement.getId())!=null }"
+                                                          class="fa fa-sitemap text-warning"
+                                                           th:onclick="'changeToAgg('+${report2master.get(supplement.getId())}+')'"
                                                           style="color: #8a6d3b; margin-right: 5px;" >
                                                     </span>
-<!--                                                    <span th:if="${single2root.get(report.id)!=null}"  th:onclick="'changeToTree('+${single2root.get(report.id)}+')'"-->
-<!--                                                          class="glyphicon glyphicon-tree-conifer"-->
-<!--                                                          style="color: #07b309; margin-right: 5px;" >-->
-<!--                                                    </span>-->
+
                                                     <!-- de scription -->
 
                                                     <th:block >
@@ -245,6 +245,10 @@
 
             </div>
 
+            <div id="aggPart">
+
+            </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>-->
 
@@ -419,6 +423,7 @@
 </script>
 <script src="https://d3js.org/d3.v4.min.js"></script>
 <script type="text/javascript" src="/static/js/tree_report_new.js"></script>
+<script type="text/javascript" src="/static/js/agg_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">
@@ -621,4 +626,71 @@
             }
         });
     }
+
+    //展示聚合报告报告 ----  yiho 以后可能还有其他报告
+
+    changeToAgg = function (master_id) {
+        // alert(treeId);
+        // $('#summary').hide();
+        /*<![CDATA[*/
+        $('#summary').hide();
+        $("#aggPart").load("/report_part?masterId="+master_id+"&caseId="+ caseId +"&examId="+ examId);
+        $("#backButton").show();
+        $('#aggPart').show();
+        //initTree(treeId);
+        /*]]>*/
+        initAggReport(master_id);
+
+    }
+
+    initAggReport = function(master_id){
+        console.log("start init master");
+        $('.sup-collapse').click(function () {
+            var dupTitle = $(this).parents('li').find('.sup-title');
+            dupTitle.toggle();
+        });
+        initMaster(master_id);
+        console.log("---end---")
+    }
+
+    //创建Img
+    function createImg(src) {
+        var $img = $('<img />')
+        $img.attr("src", src);
+        $img.attr("class", "my-img-thumbnail pointer to-delete");
+        $img.on("click", function (){
+            showimage(src);
+        });
+        return $img;
+    }
+
+    /*<![CDATA[*/
+    refreshPhotoDrag = function () {
+        $(".to-add").on("dragend", function (e) {
+            var src = $(e.target).attr("src");
+            if (images.indexOf(src) < 0) {
+                images.push(src);
+                var $img = createImg(src);
+                $img.on("dragend", function (e) {
+                    var src = $(e.target).attr("src");
+                    var idx = images.indexOf(src);
+                    if (idx >= 0) {
+                        images.splice(idx, 1);
+                    }
+
+                    $(e.target).remove();
+                });
+                $("#new-report-img").append($img)
+            }
+        });
+    }
+    /*]]>*/
+
+    showMainReport  = function () {
+        $('#summary').show();
+        $('#aggPart').hide();
+        $('#backButton').hide();
+        initTree(treeId);
+    }
+
 </script>