|
@@ -26,25 +26,25 @@ 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;
|
|
|
|
|
@@ -71,7 +71,7 @@ public class AnalyzeService {
|
|
|
|
|
|
|
|
|
Logger logger= LoggerFactory.getLogger(RecommendService.class);
|
|
|
-
|
|
|
+
|
|
|
//获取所有bug
|
|
|
public List<String> getValid(String case_take_id) {
|
|
|
List<String> result = new ArrayList<String>();
|
|
@@ -92,7 +92,7 @@ public class AnalyzeService {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//获取所有有测试用例的bug
|
|
|
public List<String> getValidTwo(String case_take_id) {
|
|
|
List<String> result = new ArrayList<String>();
|
|
@@ -133,7 +133,7 @@ public class AnalyzeService {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public List<String> getReports(String case_take_id) {
|
|
|
List<String> result = new ArrayList<String>();
|
|
|
List<CaseToBug> lists = ctbdao.findByCase(case_take_id);
|
|
@@ -155,13 +155,13 @@ public class AnalyzeService {
|
|
|
}
|
|
|
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));
|
|
@@ -193,12 +193,12 @@ public class AnalyzeService {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public int mark(String id, Map<String, Integer> 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);
|
|
@@ -207,7 +207,7 @@ public class AnalyzeService {
|
|
|
for(String child : history.getChildren()) {
|
|
|
if(grades.getOrDefault(child, 3) <= 2) {count ++;}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
switch(grade) {
|
|
|
case 1:
|
|
|
if(parent == 1) {mark += 40;}
|
|
@@ -224,11 +224,11 @@ public class AnalyzeService {
|
|
|
mark += count;
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if(grade <= 2) {
|
|
|
mark += 2 * (mirror.getGood().size() - mirror.getBad().size());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return mark;
|
|
|
}
|
|
|
|
|
@@ -383,7 +383,7 @@ public class AnalyzeService {
|
|
|
result.put(report, result.getOrDefault(report, 0) - grade);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public Map<String, String> getThums(String case_take_id) {
|
|
|
Map<String, String> result = new HashMap<String, String>();
|
|
|
List<String> bugs = getValid(case_take_id);
|
|
@@ -395,7 +395,7 @@ public class AnalyzeService {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public Map<String, Integer> getBugDetail(String case_take_id) {
|
|
|
Map<String, Integer> page = new HashMap<String, Integer>();
|
|
|
List<String> bugs = getValid(case_take_id);
|
|
@@ -405,7 +405,7 @@ public class AnalyzeService {
|
|
|
}
|
|
|
return page;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public JSONObject getCaseDetail(String case_take_id) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
Map<String, Integer> kind = new HashMap<String, Integer>();
|
|
@@ -418,7 +418,7 @@ public class AnalyzeService {
|
|
|
result.put("category", new JSONObject(kind));
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public Map<String, Integer> getAllGrades(String case_take_id) {
|
|
|
Map<String, Integer> result = new HashMap<String, Integer>();
|
|
|
List<BugMirror> mlist = mdao.findByCase(case_take_id);
|
|
@@ -432,7 +432,7 @@ public class AnalyzeService {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public List<String> getDiff(String case_take_id) {
|
|
|
List<String> bugs = getValid(case_take_id);
|
|
|
bugs.add("split");
|
|
@@ -442,7 +442,7 @@ public class AnalyzeService {
|
|
|
}
|
|
|
return bugs;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//评价页面获取评分
|
|
|
public List<List<String>> getScores(List<String> ids) {
|
|
|
List<List<String>> result = new ArrayList<List<String>>();
|
|
@@ -455,7 +455,7 @@ public class AnalyzeService {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//根据树状结构计算分数,会根据fork关系减去父节点的分数
|
|
|
public void countScore(String case_take_id, Map<String, Integer> result, Map<String, Integer> grades) {
|
|
|
List<String> roots = hservice.getRoots(case_take_id);
|
|
@@ -692,9 +692,11 @@ public class AnalyzeService {
|
|
|
|
|
|
public AnalyseVO2 getReviewAnalyseVO2(String caseId, String taskId){
|
|
|
|
|
|
-// Cache<String,String> cache = CacheBuilder.newBuilder().build();
|
|
|
-// cache.put("word","Hello Guava Cache");
|
|
|
-// System.out.println(cache.getIfPresent("word"));
|
|
|
+ Cache<String,String> 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;
|