|
@@ -3,14 +3,11 @@ package edu.nju.service;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.*;
|
|
|
|
|
|
-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 org.apache.commons.lang3.EnumUtils;
|
|
|
-import org.apache.poi.hpsf.Thumbnail;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
import org.slf4j.Logger;
|
|
@@ -26,25 +23,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;
|
|
|
|
|
@@ -69,9 +66,15 @@ public class AnalyzeService {
|
|
|
@Autowired
|
|
|
BugHistoryDao bugHistoryDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ UserLabelDao userLabelDao;
|
|
|
|
|
|
- Logger logger= LoggerFactory.getLogger(RecommendService.class);
|
|
|
+ @Autowired
|
|
|
+ ExtraService extraService;
|
|
|
|
|
|
+
|
|
|
+ Logger logger= LoggerFactory.getLogger(RecommendService.class);
|
|
|
+
|
|
|
//获取所有bug
|
|
|
public List<String> getValid(String case_take_id) {
|
|
|
List<String> result = new ArrayList<String>();
|
|
@@ -92,7 +95,7 @@ public class AnalyzeService {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//获取所有有测试用例的bug
|
|
|
public List<String> getValidTwo(String case_take_id) {
|
|
|
List<String> result = new ArrayList<String>();
|
|
@@ -133,7 +136,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 +158,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 +196,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 +210,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 +227,11 @@ public class AnalyzeService {
|
|
|
mark += count;
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if(grade <= 2) {
|
|
|
mark += 2 * (mirror.getGood().size() - mirror.getBad().size());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return mark;
|
|
|
}
|
|
|
|
|
@@ -383,7 +386,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 +398,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 +408,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 +421,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 +435,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 +445,7 @@ public class AnalyzeService {
|
|
|
}
|
|
|
return bugs;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//评价页面获取评分
|
|
|
public List<List<String>> getScores(List<String> ids) {
|
|
|
List<List<String>> result = new ArrayList<List<String>>();
|
|
@@ -455,7 +458,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);
|
|
@@ -550,6 +553,53 @@ public class AnalyzeService {
|
|
|
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<Bug> bugList = extraService.getBugList(userReport.getId(),caseTakeId);
|
|
|
+ long firstActivate = Long.MAX_VALUE ;
|
|
|
+ long lastActivate = 0 ;
|
|
|
+ long cur ;
|
|
|
+ for(Bug bug : bugList){
|
|
|
+ cur = Long.parseLong(bug.getCreate_time_millis());
|
|
|
+ if(firstActivate>cur)firstActivate = cur;
|
|
|
+ if(lastActivate<cur)lastActivate=cur;
|
|
|
+ }
|
|
|
+ if(firstActivate == Long.MAX_VALUE)firstActivate = 0 ;
|
|
|
+ res.setFirstActivate(firstActivate);
|
|
|
+ res.setLastActivate(lastActivate);
|
|
|
+ res.setBugList(bugList);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
public AnalyseVO getReviewAnalyseVO(String caseId, String taskId){
|
|
|
Task task=taskDao.findById(taskId);
|
|
|
long startTime=0;
|
|
@@ -689,6 +739,16 @@ public class AnalyzeService {
|
|
|
return historicalDataVO;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据用户信息获取用户的labels
|
|
|
+ * @param wordkId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<String> getUserLabels(String wordkId){
|
|
|
+ List<UserLabel> labels = userLabelDao.findLabelsByWorkerId(wordkId);
|
|
|
+ return labels.stream().map(UserLabel::getLabel).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public AnalyseVO2 getReviewAnalyseVO2(String caseId, String taskId){
|
|
|
|