|
@@ -2,11 +2,13 @@ package edu.nju.service;
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import edu.nju.dao.*;
|
|
|
import edu.nju.entities.*;
|
|
|
import edu.nju.model.*;
|
|
|
import edu.nju.util.HTTP;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang3.EnumUtils;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
@@ -60,6 +62,12 @@ public class AnalyzeService {
|
|
|
@Autowired
|
|
|
TestCaseDao testCaseDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ UserLabelDao userLabelDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExtraService extraService;
|
|
|
+
|
|
|
|
|
|
Logger logger= LoggerFactory.getLogger(RecommendService.class);
|
|
|
|
|
@@ -541,6 +549,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;
|
|
@@ -680,5 +735,15 @@ 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());
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|