Browse Source

添加树状报告列表的页面。

insomniaLee 6 years ago
parent
commit
66d7948bbf

+ 28 - 34
src/main/java/com/mooctest/controller/HistoryController.java

@@ -1,10 +1,8 @@
 package com.mooctest.controller;
 
+import com.mooctest.data.BugDTO;
 import com.mooctest.data.TaskDTO;
-import com.mooctest.service.AnalyzeService;
-import com.mooctest.service.HistoryService;
-import com.mooctest.service.RecommendService;
-import com.mooctest.service.TaskService;
+import com.mooctest.service.*;
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -19,6 +17,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -39,6 +38,10 @@ public class HistoryController {
 	@Autowired
 	RecommendService recservice;
 
+	@Autowired
+    BugReportService bugReportService;
+
+
 	//获取指定节点的历史信息
 //	@RequestMapping(value = "/getHistory")
 //	@ResponseBody
@@ -81,47 +84,38 @@ public class HistoryController {
 						Model model){
 		String case_take_id = caseId+"-"+examId;
 		JSONObject result = new JSONObject(); // 用来存放树状结构信息的reuslt;
-		List<String> all = hisservice.getTreeRoots(caseId+"-"+examId); // 获得所有的根结点的id
-		TaskDTO task = taskService.getByExamIdAndCaseId(examId, caseId);
+		List<String> treeRootids = hisservice.getTreeRoots(caseId+"-"+examId); // 获得所有的根结点的id
+		TaskDTO task = taskService.getByExamIdAndCaseId(examId, caseId); //  infomation of task
 		List<List<String>> list = new ArrayList<List<String>>();
-		for(String id: all) {
+		for(String id: treeRootids) {
 			list.add(hisservice.getDetail(id));
 		} // 获得树的信息。
 		//获得每份报告的具体信息
 
-
-		List<String> list_bugs = aservice.getValid(case_take_id); // 得到所有的bug报告
-		System.out.println("all :"+all.size());
-		System.out.println("list:"+list.size());
-		System.out.println(list_bugs);
-		List<String> res = list_bugs.stream().filter(s->all.contains(s)).collect(Collectors.toList());
-		System.out.println(res.size());
-		if(all.size()>=0){
-			return "error";
-		}
-
-
-
-
-		List<List<String>> lists = hisservice.getDepth(all.get(0));
-		Set<String> filter = hisservice.filter(lists);
-		result.put("path", new JSONArray(lists));
-		result.put("invalid", new JSONArray(hisservice.getInvalid(filter)));
-		List<String> ids = new ArrayList<String>(filter);
-		result.put("score", new JSONArray(aservice.getScores(ids)));
-		System.out.println("/getPath path = " + result);
-		System.out.println("result.toString() = " + result.toString());
-
-
-		model.addAttribute("master2BugIdsMap", all); //
-		model.addAttribute("bugMap", all); //
+        //history 报告对应的report列表列
+        Map<String , List<String >> tree2BugIdsMap = hisservice.getTree2BugIdsMap(treeRootids);
+        Map<String, BugDTO> bugsMap = bugReportService.getAllBugsMap(examId, caseId); //得到所有bug的对应map
+
+//		List<List<String>> lists = hisservice.getDepth(treeRootids.get(0));
+//		Set<String> filter = hisservice.filter(lists);
+//		result.put("path", new JSONArray(lists));
+//		result.put("invalid", new JSONArray(hisservice.getInvalid(filter)));
+//		List<String> ids = new ArrayList<String>(filter);
+//		result.put("score", new JSONArray(aservice.getScores(ids)));
+//		System.out.println("/getPath path = " + result);
+//		System.out.println("result.toString() = " + result.toString());
+
+		model.addAttribute("master2BugIdsMap", tree2BugIdsMap); //
+		model.addAttribute("bugMap", bugsMap); //
 		model.addAttribute("examId", examId);
 		model.addAttribute("caseId", caseId);
 		model.addAttribute("task", task);
-		model.addAttribute("aggNum", all.size());
+		model.addAttribute("aggNum", treeRootids.size()); //
 		return  "tree_report_list";
 	}
 
+
+
     @RequestMapping(value = "/getTrees2")
     public String getTrees2(@RequestParam("case_take_id") String case_take_id) {
 	    return "managerCheck";

+ 6 - 12
src/main/java/com/mooctest/controller/ReportController.java

@@ -225,27 +225,21 @@ public class ReportController {
                                     @RequestParam("caseId") long caseId,
                                     @RequestParam(value = "status", required = false, defaultValue = "-1") int status,
                                     Model model) {
-        List<String> masterIds = masterReportService.getAllMasterIdByExamIdAndCaseId(examId, caseId);
-        List<MasterReport> mrs = masterReportService.getByBugIds(masterIds);
-        Map<String, MasterReport> mrMap = mrs.stream().collect(toMap(MasterReport::getBugId, Function.identity()));
+        List<String> masterIds = masterReportService.getAllMasterIdByExamIdAndCaseId(examId, caseId);//get all masterreport id String
+        List<MasterReport> mrs = masterReportService.getByBugIds(masterIds); // masterReport的报告内容
+        Map<String, MasterReport> mrMap = mrs.stream().collect(toMap(MasterReport::getBugId, Function.identity()));//单个的master报告的对应map
         if (status >= 0) {
             masterIds = masterIds.stream().filter(masterId -> mrMap.get(masterId).getStatus() == status).collect(Collectors.toList());
         }
 
 //        Map<String, List<String>> master2BugIdsMap = supplementService.getMaster2BugIdsMap(masterIds);
-        Map<String, List<String>> master2BugIdsMap = masterReportService.getMaster2BugIdsMap(masterIds);
-        Map<String, BugDTO> bugsMap = bugReportService.getAllBugsMap(examId, caseId);
-
+        Map<String, List<String>> master2BugIdsMap = masterReportService.getMaster2BugIdsMap(masterIds); // master报告对应的report的列表
+        Map<String, BugDTO> bugsMap = bugReportService.getAllBugsMap(examId, caseId); //得到所有bug的对应map
 //        Map<String, List<BugDTO>> masterBugMap = bugReportService.getMasterBugMap(master2BugIdsMap, bugsMap);
-        TaskDTO task = taskService.getByExamIdAndCaseId(examId, caseId);
-
-
+        TaskDTO task = taskService.getByExamIdAndCaseId(examId, caseId); // 任务情况
         masterIds.forEach(masterId -> {
-
             bugsMap.get(masterId).setStatus(mrMap.get(masterId).getStatus());
         });
-
-
         model.addAttribute("master2BugIdsMap", master2BugIdsMap);
         model.addAttribute("bugMap", bugsMap);
         model.addAttribute("examId", examId);

+ 7 - 0
src/main/java/com/mooctest/dao3/BugHistoryDao.java

@@ -33,6 +33,13 @@ public class BugHistoryDao {
 		if(history != null && history.size() != 0) { return history.get(0); }
 		else { return null; }
 	}
+
+	public List<BugHistory> findBugRoot(List<String> roots){
+		Query query = new Query();
+		query.addCriteria(Criteria.where("root").in(roots));
+		List<BugHistory> res = mongoOps.find(query,BugHistory.class);
+		return res;
+	}
 	
 	//查找所有指定的根
 	public List<String> findRoots(List<String> lists) {

+ 12 - 0
src/main/java/com/mooctest/service/HistoryService.java

@@ -10,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
+import java.util.stream.Collector;
+import java.util.stream.Collectors;
 
 @Service
 public class HistoryService {
@@ -32,6 +34,16 @@ public class HistoryService {
 	public BugHistory getHistory(String id) {
 		return historydao.findByid(id);
 	}
+
+	public Map<String ,List<String>> getTree2BugIdsMap(List<String> masterIds){
+		List<BugHistory> histories = historydao.findBugRoot(masterIds);
+		return histories.stream().collect(
+				Collectors.groupingBy(
+						BugHistory::getRoot,
+						Collectors.mapping(BugHistory::getId,Collectors.toList())
+				)
+		);
+	}
 	
 	public List<String> parents(String id) {
 		Stack<String> stack = new Stack<String>();

+ 1 - 1
src/main/resources/templates/test.html

@@ -219,7 +219,7 @@
         </div>
 
     </div>
-    
+
 
 </th:block>
 </body>