package edu.nju.service; import java.nio.charset.StandardCharsets; import java.util.*; import java.util.stream.Collectors; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import edu.nju.dao.*; import edu.nju.entities.*; import edu.nju.model.*; import edu.nju.util.HTTP; import edu.nju.util.TimeUtil; import org.apache.commons.lang3.EnumUtils; import org.json.JSONArray; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.stereotype.Service; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestTemplate; @Service public class AnalyzeService { @Autowired CTBDao ctbdao; @Autowired BugScoreDao bsdao; @Autowired BugHistoryDao hdao; @Autowired BugMirrorDao mdao; @Autowired StuInfoDao studao; @Autowired BugDao bdao; @Autowired HistoryService hservice; @Autowired BugScoreByWorkerDao bugScoreByWorkerDao; @Autowired BugSimilarScoreDao bugSimilarScoreDao; @Autowired ReportDao reportDao; @Autowired TaskDao taskDao; @Autowired TestCaseDao testCaseDao; @Autowired ThumsUpDao thumsUpDao; @Autowired BugHistoryDao bugHistoryDao; @Autowired UserLabelDao userLabelDao; @Autowired ExtraService extraService; Logger logger= LoggerFactory.getLogger(RecommendService.class); //获取所有bug public List getValid(String case_take_id) { List result = new ArrayList(); List mirrors = mdao.findValid(case_take_id); for(BugMirror ctb : mirrors) { result.add(ctb.getId()); } return result; } public List getValidByBugId(String id) { List result = new ArrayList(); BugMirror bugMirror=mdao.findById(id); String case_take_id=bugMirror.getCase_take_id(); List mirrors = mdao.findValid(case_take_id); for(BugMirror ctb : mirrors) { result.add(ctb.getId()); } return result; } //获取所有有测试用例的bug public List getValidTwo(String case_take_id) { List result = new ArrayList(); List lists = ctbdao.findByCase(case_take_id); for(CaseToBug ctb : lists) { for(String str: ctb.getBug_id()) { result.add(str); } } return result; } public ListgetBugDataVO(String case_take_id){ Listresult=new ArrayList<>(); List mirrors = mdao.findValid(case_take_id); Listbugs=bdao.findByCaseid(case_take_id); MapbugMap=new HashMap<>(); for(Bug bug:bugs){ if(bug!=null){ bugMap.put(bug.getId(),bug); } } for(BugMirror bugMirror : mirrors) { if(bugMirror!=null){ Bug bug=bugMap.get(bugMirror.getId()); BugHistory bugHistory=hdao.findByid(bugMirror.getId()); if(bug!=null&&bugHistory!=null){ BugSeverity bugSeveritsy=BugSeverity.getValue(2); String bugSeverity=bugSeveritsy.toString(); BugScore bugScore=bsdao.findById(bug.getId()); int score=bugScore==null?0:bugScore.getGrade(); String reportId=bug.getReport_id(); String workerId=findWorkerId(reportId); BugDataVO bugDataVO=new BugDataVO(bug.getId(),bug.getBug_category(),bugSeverity,bug.getCreate_time_millis(),bug.getBug_page(),score,bugHistory.getParent(),bugHistory.getChildren(),bugHistory.getRoot(),bugMirror.getGood().size(),bugMirror.getBad().size(),reportId,workerId); result.add(bugDataVO); } } } return result; } public List getReports(String case_take_id) { List result = new ArrayList(); List lists = ctbdao.findByCase(case_take_id); for(CaseToBug ctb : lists) { if(!result.contains(ctb.getReport_id())) {result.add(ctb.getReport_id());} } return result; } public List getUsers(String examId) { List result = new ArrayList(); List reports = reportDao.findByExamId(examId); for(Report report : reports) { if(report!=null) { String workerId=report.getWorker_id(); if(!workerId.equals("")&&!result.contains(workerId)) result.add(Long.parseLong(workerId)); } } return result; } public int getGrade(String id) { BugScore bs = bsdao.findById(id); if(bs != null) {return bs.getGrade();} return -1; } public boolean saveGrade(String id, int grade) { try { bsdao.save(new BugScore(id, grade, 0)); return true; } catch(Exception e) { return false; } } public BugSimilarScore getSimilarScore(String id) { BugSimilarScore bss = bugSimilarScoreDao.findById(id); return bss; } public boolean saveGradeByWorker(String id, String workerId, int grade) { try { bsdao.save(new BugScore(id, grade, 0)); return true; } catch(Exception e) { return false; } } public boolean saveSimiliarGrade(String id, int grade,String similiarBug) { try { bugSimilarScoreDao.save(new BugSimilarScore(id, grade, similiarBug)); return true; } catch(Exception e) { return false; } } public int mark(String id, Map grades, BugMirror mirror) { int mark = 0; int grade = grades.get(id); BugHistory history = hdao.findByid(id); int parent = 0; if(!history.getParent().equals("null")) { parent = grades.getOrDefault(history.getParent(), 0); } int count = 0; for(String child : history.getChildren()) { if(grades.getOrDefault(child, 3) <= 2) {count ++;} } switch(grade) { case 1: if(parent == 1) {mark += 40;} else {mark += 100;} mark += count * 2; break; case 2: if(parent == 1) {break;} else if(parent == 2) {mark += 40;} else {mark += 80;} mark += count * 2; break; case 3: mark += count; break; } if(grade <= 2) { mark += 2 * (mirror.getGood().size() - mirror.getBad().size()); } return mark; } //todo 搞清楚究竟是通过哪种方式写回主站分数 public JSONArray getScores(String case_take_id) { // Map reviewScore = new HashMap(); //评审他人bug得分 // Map bugScore = new HashMap(); //系统或专家评审你的bug得分 // Map finalScores = new HashMap(); //计算bug得分 // JSONArray json = new JSONArray(); // // //获取所有bugID // List bugIdList = getValid(case_take_id); // logger.info(String.valueOf(bugIdList.size())); // //获取bug本身得分 // for(String bugId: bugIdList) { // BugScore temp = bsdao.findById(bugId); // if(temp != null) {bugScore.put(bugId, temp.getGrade());} // else {bugScore.put(bugId, 0);} // } // // //计算树状bug得分 // countScore(case_take_id, finalScores, bugScore); // // //计算审查得分 // for(String bug: bugIdList) { // BugMirror mirror = mdao.findById(bug); // if(mirror == null) { continue; } // int grade = bugScore.getOrDefault(bug, 0); // int thumbsScore=0; // if(grade>=0&&grade<3){ // thumbsScore=-2; // }else if(grade<5){ // thumbsScore=-1; // }else if(grade<8){ // thumbsScore=1; // }else{ // thumbsScore=2; // } // //点赞点踩积分减分 // ThumsUp(thumbsScore,reviewScore,mirror); // } // int maxReviewScore=0; // int maxReportScore=0; // for(Map.Entry entry : reviewScore.entrySet()) { // //审查得分低于零分按零分算 // if(entry.getValue() < 0) { reviewScore.put(entry.getKey(), 0); } // if(entry.getValue()>maxReviewScore){ // maxReviewScore=entry.getValue(); // } // } // // //将bug得分汇总为report得分 // Map reportScore = new HashMap(); // for(String bugId: bugIdList) { // BugMirror mirror = mdao.findById(bugId); // if(mirror == null) { continue; } // String reportId=mirror.getReport_id(); // //出现过bug和bugMirror中没有reportId的问题,需要单独检查 // if(reportId!=null) { // reportScore.put(reportId, finalScores.getOrDefault(bugId, 0) + reportScore.getOrDefault(reportId, 0)); // if (reportScore.get(reportId) > maxReportScore) { // maxReportScore = reportScore.get(reportId); // } // } // } // //确保被除数不为0 // if(maxReportScore==0){ // maxReportScore=1; // } // if(maxReviewScore==0){ // maxReviewScore=1; // } // //得分要以最高分为满分 // for(Map.Entry entry : reportScore.entrySet()) { // JSONObject json_temp = new JSONObject(); // json_temp.put("report_id", entry.getKey()); // json_temp.put("worker_id", findWorkerId(entry.getKey())); // json_temp.put("名字", report_trans(entry.getKey())); // json_temp.put("报告得分", (entry.getValue()/maxReportScore)*100); // json_temp.put("审查得分", (reviewScore.getOrDefault(entry.getKey(), 0)/maxReviewScore)*100); // json.put(json_temp); // } List reportList=reportDao.findByCaseTakeId(case_take_id); HashMap hashMap=new HashMap<>(); int maxScore=0; for(Report report:reportList){ String workerId=report.getWorker_id(); hashMap.put(workerId,0); List bugList=bdao.findByReport(report.getId(),case_take_id); // logger.info(String.valueOf(bugList.size())); for(Bug bug:bugList){ if(bug!=null) { logger.info(bug.getId()); BugScore bugScore = bsdao.findById(bug.getId()); int score = hashMap.get(workerId); if (bugScore != null) { score += bugScore.getGrade(); logger.info(String.valueOf(bugScore.getGrade())); } if (score > maxScore) { maxScore = score; } hashMap.put(workerId, score); } } } logger.info(String.valueOf(maxScore)); JSONArray json = new JSONArray(); for(Map.Entry entry : hashMap.entrySet()) { String key=entry.getKey(); int value=entry.getValue(); value=(value*100/maxScore); JSONObject json_temp = new JSONObject(); json_temp.put("worker_id",key); json_temp.put("score",value); json.put(json_temp); } //把分写回主站 // logger.info("计算结束"); logger.info(json.toString()); writeScores(case_take_id, json); return json; } public JSONArray getNewScores(JSONArray array) { if(array == null || array.length() <= 0) { return array; } for(int i = 0; i < array.length(); i ++) { JSONObject object = array.getJSONObject(i); if(object.keySet().size() < 5) { continue; } object.put("name", object.get("名字")); object.remove("名字"); int bugScore=Integer.parseInt(object.get("报告得分").toString()); int reviewScore=Integer.parseInt(object.get("审查得分").toString()); double score = bugScore*0.7+reviewScore*0.3; if(score > 100) { object.put("score", 100); } else { object.put("score", score); } object.remove("报告得分"); object.remove("审查得分"); } return array; } //计算点赞得分 private void ThumsUp(int grade, Map result, BugMirror mirror) { //给好的点赞加分,点踩减分,不好的反之 for(String report : mirror.getGood()) { result.put(report, result.getOrDefault(report, 0) + grade); } for(String report : mirror.getBad()) { result.put(report, result.getOrDefault(report, 0) - grade); } } public Map getThums(String case_take_id) { Map result = new HashMap(); List bugs = getValid(case_take_id); for(String bug: bugs) { BugMirror mirror = mdao.findById(bug); if(mirror.getGood().size() > 0 || mirror.getBad().size() > 0) { result.put(bug, mirror.getGood().size() + "," + mirror.getBad().size()); } } return result; } public Map getBugDetail(String case_take_id) { Map page = new HashMap(); List bugs = getValid(case_take_id); for(String id : bugs) { Bug bug = bdao.findByid(id); page.put(bug.getBug_page(), page.getOrDefault(bug.getBug_page(), 0) + 1); } return page; } public JSONObject getCaseDetail(String case_take_id) { JSONObject result = new JSONObject(); Map kind = new HashMap(); List bugs = getValid(case_take_id); for(String id : bugs) { Bug bug = bdao.findByid(id); kind.put(bug.getBug_category(), kind.getOrDefault(bug.getBug_category(), 0) + 1); } result.put("page", new JSONObject(getBugDetail(case_take_id))); result.put("category", new JSONObject(kind)); return result; } public Map getAllGrades(String case_take_id) { Map result = new HashMap(); List mlist = mdao.findByCase(case_take_id); List idlist = new ArrayList(); for(BugMirror mirror : mlist) { idlist.add(mirror.getId()); } List slist = bsdao.findByIds(idlist); for(BugScore bugscore: slist) { result.put(bugscore.getId(), bugscore.getGrade()); } return result; } public List getDiff(String case_take_id) { List bugs = getValid(case_take_id); bugs.add("split"); for(Map.Entry entry: getAllGrades(case_take_id).entrySet()) { if(bugs.contains(entry.getKey())) {bugs.remove(entry.getKey());} else {bugs.add(entry.getKey());} } return bugs; } //评价页面获取评分 public List> getScores(List ids) { List> result = new ArrayList>(); List list = bsdao.findByIds(ids); for(BugScore bs: list) { List temp = new ArrayList(); temp.add(bs.getId()); temp.add(Integer.toString(bs.getGrade())); result.add(temp); } return result; } //根据树状结构计算分数,会根据fork关系减去父节点的分数 public void countScore(String case_take_id, Map result, Map grades) { List roots = hservice.getRoots(case_take_id); for(String root : roots) { List> lists = hservice.getDepth(root); for(List path : lists) { int max = 0; for(String id : path) { int grade = grades.getOrDefault(id, 0); result.put(id, Math.max(grade - max, 0)); max = Math.max(max, grade); } } } } private void writeScores(String case_take_id, JSONArray array) { // String host = "http://www.mooctest.net"; // String url = "/api/common/uploadCaseScore"; // String[] ids = case_take_id.split("-"); // String param1 = "caseId=" + ids[0] + "&examId=" + ids[1]; // for(int i = 0; i < array.length(); i ++) { // JSONObject json = (JSONObject)array.get(i); // String worker_id = json.get("worker_id").toString(); // //报告得分*0.7+审查得分*0.3 //// int bugScore=Integer.parseInt(json.get("报告得分").toString()); //// int reviewScore=Integer.parseInt(json.get("审查得分").toString()); // double score = json.getDouble("score"); // if(worker_id.equals("")) { continue; } // if(score<0){ // score=0; // } // if(score > 100) { score = 100; } // String param2 = "&userId=" + worker_id + "&score=" + score; // HTTP.sendPut(host, url, param1 + param2); // logger.info("---------------"); // logger.info(worker_id); // } RestTemplate template = new RestTemplate(); String url = "http://www.test.mooctest.net/api/common/uploadCaseScore"; String[] ids = case_take_id.split("-"); for(int i = 0; i < array.length(); i ++) { MultiValueMap paramMap = new LinkedMultiValueMap(); JSONObject json = (JSONObject)array.get(i); String worker_id = json.get("worker_id").toString(); paramMap.add("examId", ids[1]); paramMap.add("caseId", ids[0]); paramMap.add("userId", worker_id); paramMap.add("score", json.getDouble("score")); template.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8)); HttpHeaders headers = new HttpHeaders(); HttpEntity> httpEntity = new HttpEntity>(paramMap, headers); template.put(url, httpEntity); logger.info("workerId:" +worker_id); logger.info("score:" +json.getDouble("score")); } } private String report_trans(String report_id) { String name = studao.findById(report_id); if(name == null || name.equals("null")) { return report_id;} return name; } private String findWorkerId(String report_id) { String workerId = studao.findWorkerId(report_id); if(workerId == null || workerId.equals("null")) { return "";} return workerId; } public List getAfterSimilarBug(String bug_id){ Bug bug =bdao.findByid(bug_id); List bugList=bdao.findByCaseid(bug.getCase_id()); List result=new ArrayList<>(); for(Bug tempBug: bugList){ if(Long.parseLong(tempBug.getCreate_time_millis())>Long.parseLong(bug.getCreate_time_millis())){ if(checkSimilarity(bug,tempBug)){ result.add(tempBug); } } } return result; } //todo check similarity private boolean checkSimilarity(Bug bug1,Bug bug2){ return true; } public AnalysePeopleVO getReviewAnalysePeopleVO(String caseId,String taskId,String workerId) { Task task=taskDao.findById(taskId); AnalysePeopleVO res = new AnalysePeopleVO(); if(task!=null)res.setTaskName(task.getName()); String caseTakeId = caseId+"-"+taskId; // 部分数据从主战接口中取得 String result = HTTP.sendGet("http://114.55.91.83:8191/api/user/" + workerId, ""); if (result != null && !result.equals("")) { JSONObject json = new JSONObject(result); if (json.has("name") && !json.isNull("name")) { res.setName(json.getString("name")); } if (json.has("school") && !json.isNull("school")) { res.setSchool( json.getString("school")); } if (json.has("province") && !json.isNull("province")) { res.setProvince(json.getString("province")); } if (json.has("city") && !json.isNull("city")) { res.setCity(json.getString("city")); } if (json.has("createTime") && !json.isNull("createTime")) { res.setRegisterTime(json.getLong("createTime")); } if (json.has("photoUrl") && !json.isNull("photoUrl")) { res.setPhotoUrl(json.getString("photoUrl")); } } //用户lebels res.setLabels(getUserLabels(workerId)); Report userReport = extraService.findByWorker(caseTakeId,workerId); List bugList = extraService.getBugList(userReport.getId(),caseTakeId); Collections.sort(bugList, Comparator.comparing(Bug::getCreate_time_millis)); JSONArray array=new JSONArray(); Map severityCount = new HashMap<>(); int [] severityValueCount = new int[5]; for(Bug bug : bugList){ severityValueCount[bug.getSeverity()]++; JSONObject object = new JSONObject(); object.put("content",bug.getTitle()); object.put("timestamp", TimeUtil.timestamp2DayHour(bug.getCreate_time_millis())); array.put(object); } int severityMax = Arrays.stream(severityValueCount).max().getAsInt(); for(int i = 0 ;ireports=reportDao.findReportsByWorker(String.valueOf(workerId)); reports = reports.stream().filter(e->{ return Long.parseLong(e.getCreate_time_millis()) > monthAgoStart(5); }).collect(Collectors.toList()); List bugs = new ArrayList<>(); for(Report report : reports){ bugs.addAll(bdao.findByReport(report.getId(),report.getCase_take_id())); } Map data = new HashMap<>(6); for(Bug bug : bugs){ } } private long monthAgoStart(int offset){ Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.MONTH, -offset); calendar.set(Calendar.DAY_OF_MONTH,1); return calendar.getTimeInMillis(); } public AnalyseVO getReviewAnalyseVO(String caseId, String taskId){ Task task=taskDao.findById(taskId); long startTime=0; long endTime=0; String taskName=""; double writeMins=0.0; if(task!=null) { startTime = task.getStart_time(); endTime = task.getEnd_time(); taskName = task.getName(); writeMins = task.getTotal_mins(); } String caseTakeId=caseId+"-"+taskId; Listbugs=bdao.findByCaseid(caseTakeId); int bugNum=bugs.size(); Listreports=reportDao.findByCaseTakeId(caseTakeId); int participateNum=reports.size(); int testCaseNum=0; for(Report report:reports){ ListtestCases=testCaseDao.findByReport(report.getId()); if(testCases!=null){ testCaseNum+=testCases.size(); } } MapgradeDistribution=new HashMap<>(); MapworkerDistribution=new HashMap<>(); for(Bug bug:bugs){ BugScore bugScore=bsdao.findById(bug.getId()); String reportId=bug.getReport_id(); if(reportId!=null) { Report report = reportDao.findById(reportId); if(report !=null) { String workerId=report.getWorker_id(); if (workerId!=null) { int grade=0; if(bugScore!=null) { grade = bugScore.getGrade(); if (gradeDistribution.containsKey(grade)) { gradeDistribution.replace(grade, gradeDistribution.get(grade) + 1); } else { gradeDistribution.put(grade, 1); } } if (workerDistribution.containsKey(workerId)) { workerDistribution.replace(workerId, workerDistribution.get(workerId) + grade); } else { workerDistribution.put(workerId, grade); } } } } } //分数排序 List> list = new ArrayList<>(workerDistribution.entrySet()); Collections.sort(list, new Comparator>() { @Override public int compare(Map.Entry o1, Map.Entry o2) { return o2.getValue().compareTo(o1.getValue()); } }); ListworkerVOS=new ArrayList<>(); MapprovinceDistribute=new HashMap<>(); for(int i=0;i entry : provinceDistribute.entrySet()){ String mapKey = entry.getKey(); int mapValue = entry.getValue(); JSONObject jsonObject=new JSONObject(); jsonObject.put("name",mapKey); jsonObject.put("value",mapValue); jsonArray.put(jsonObject); } AnalyseVO analyseVO=new AnalyseVO(startTime,endTime,taskName,participateNum,bugNum,testCaseNum,gradeDistribution,workerVOS,jsonArray); return analyseVO; } public HistoricalDataVO getHistoricalData(Long workerId, int caseTypeId){ Listreports=reportDao.findReportsByWorker(String.valueOf(workerId)); int reportNum=reports.size(); ListreportScoreList=new ArrayList<>(); double totalScore=0; int participateSimilarNum=0; for(Report report:reports){ String reportId=report.getId(); ListbugIds=bdao.findByReport(reportId); double score=0; for(String bugId:bugIds){ BugScore bugScore=bsdao.findById(bugId); if(bugScore!=null) { score += bugScore.getGrade(); } } totalScore+=score; reportScoreList.add(score); int itemCaseType=1; String brand=report.getDevice_os(); if(EnumUtils.isValidEnum(WebBrand.class, brand)){ itemCaseType=0; } if(itemCaseType==caseTypeId){ participateSimilarNum++; } } HistoricalDataVO historicalDataVO=new HistoricalDataVO(reportNum,reportScoreList,totalScore,participateSimilarNum,reportNum); return historicalDataVO; } /** * 根据用户信息获取用户的labels * @param wordkId * @return */ private List getUserLabels(String wordkId){ List labels = userLabelDao.findLabelsByWorkerId(wordkId); return labels.stream().map(UserLabel::getLabel).collect(Collectors.toList()); } public AnalyseVO2 getReviewAnalyseVO2(String caseId, String taskId){ // Cache cache = CacheBuilder.newBuilder().build(); // cache.put("word","Hello Guava Cache"); // System.out.println(cache.getIfPresent("word")); Task task=taskDao.findById(taskId); long startTime=0; long endTime=0; String taskName=""; double writeMins=0.0; if(task!=null) { startTime = task.getStart_time(); endTime = task.getEnd_time(); taskName = task.getName(); writeMins = task.getTotal_mins(); } String caseTakeId=caseId+"-"+taskId; Listbugs=bdao.findByCaseid(caseTakeId); int bugNum=bugs.size(); Listreports=reportDao.findByCaseTakeId(caseTakeId); ListreportIds=new ArrayList<>(); int reportNum=reports.size(); int testCaseNum=0; MapreportWorkerMap=new HashMap<>(); for(Report report:reports){ reportIds.add(report.getId()); reportWorkerMap.put(report.getId(),report.getWorker_id()); } ListtestCases=testCaseDao.findByReports(reportIds); testCaseNum+=testCases.size(); ListbugMirrors=mdao.findByCase(caseTakeId); int likeNum=0; int dislikeNum=0; for(BugMirror bugMirror:bugMirrors){ if(bugMirror.getGood()!=null){ likeNum+=bugMirror.getGood().size(); } if(bugMirror.getBad()!=null){ dislikeNum+=bugMirror.getBad().size(); } } ListbugIds=new ArrayList<>(); MapbugWorkerMap=new HashMap<>(); for(Bug bug:bugs){ bugIds.add(bug.getId()); String reportId=bug.getReport_id(); if(reportId!=null) { String workerId=reportWorkerMap.get(reportId); if (workerId!=null) { bugWorkerMap.put(bug.getId(),workerId); } } } MapgradeDistribution=new HashMap<>(); MapworkerDistribution=new HashMap<>(); ListbugScores=bsdao.findByIds(bugIds); for(BugScore bugScore:bugScores){ int grade = bugScore.getGrade(); String workerId=bugWorkerMap.get(bugScore.getId()); if(workerId!=null){ if (workerDistribution.containsKey(workerId)) { workerDistribution.replace(workerId, workerDistribution.get(workerId) + grade); } else { workerDistribution.put(workerId, grade); } } if (gradeDistribution.containsKey(grade)) { gradeDistribution.replace(grade, gradeDistribution.get(grade) + 1); } else { gradeDistribution.put(grade, 1); } } int forkNum=0; ListbugHistories=bugHistoryDao.findBugHistoryList(bugIds); for(BugHistory bugHistory:bugHistories){ if(bugHistory.getChildren()!=null&&bugHistory.getChildren().size()!=0){ forkNum+=1; } } //分数排序 List> list = new ArrayList<>(workerDistribution.entrySet()); Collections.sort(list, new Comparator>() { @Override public int compare(Map.Entry o1, Map.Entry o2) { return o2.getValue().compareTo(o1.getValue()); } }); ListworkerRank=new ArrayList<>(); MapprovinceDistribute=new HashMap<>(); for(int i=0;i entry : provinceDistribute.entrySet()){ String mapKey = entry.getKey(); int mapValue = entry.getValue(); JSONObject jsonObject=new JSONObject(); jsonObject.put("name",mapKey); jsonObject.put("value",mapValue); workerDistribute.put(jsonObject); } AnalyseVO2 analyseVO=new AnalyseVO2(likeNum,dislikeNum,forkNum,reportNum,testCaseNum,bugNum,startTime,endTime,reportNum,taskName,workerDistribute,workerRank,gradeDistribution); return analyseVO; } public Map getPageCover(String taskId,String caseId){ String caseTakeId=caseId+"-"+taskId; MapcoverMap=getBugDetail(caseTakeId); ListpageStr=getPageStr(caseId); for(String page:pageStr){ if(!coverMap.containsKey(page)){ coverMap.put(page,0); } } return coverMap; } private List getPageStr(String caseId){ Listresult=new ArrayList<>(); Exam exam=extraService.getExam(String.valueOf(caseId)); JSONArray jsonArray=new JSONArray(exam.getJson()); LinkedList res = new LinkedList<>(); if(jsonArray==null){ return res; } for(int i=0;i res) { if(jsonObject==null||jsonObject.getString("item")==null) return; cur+=jsonObject.getString("item"); if (!jsonObject.has("children")||jsonObject.get("children")==null) { res.add(cur); } else { JSONArray jsonArray=jsonObject.getJSONArray("children"); for(int i=0;i