Переглянути джерело

抽取调用主站的用户信息配置项

郭超 4 роки тому
батько
коміт
ecc9ea1568

+ 17 - 11
src/main/java/edu/nju/controller/AnalyzeController.java

@@ -392,9 +392,15 @@ public class AnalyzeController {
 		return AESUtil.encrypt("taskId="+taskId+"&caseId="+caseId);
 	}
 
+	/**
+	 *
+	 * @param token
+	 * @param response
+	 */
 	@RequestMapping(value = "/analyse/task")
 	public void analyseTask(String token, HttpServletResponse response ){
 		String realUrl = AESUtil.decrypt(token);
+		System.out.println("realUrl " + realUrl);
 		String [] decoder = url2decode(realUrl);
 		analyseExam2(decoder[1],decoder[0],response);
 //		return "redirect:/analyze/analyseExam2?"+realUrl;
@@ -710,17 +716,17 @@ public class AnalyzeController {
 	@RequestMapping(value = "/progress", method = RequestMethod.GET)
 	@ResponseBody
 	public Double crowdTestProgress(String token){
-		return 50.0;
-//		String realUrl = AESUtil.decrypt(token);
-//		String [] decoder = url2decode(realUrl);
-//		String taskId=decoder[0];
-//		String caseId=decoder[1];
-//		Task task=taskDao.findById(taskId);
-//		if(task.getEnd_time()>System.currentTimeMillis()){
-//			return aservice.crowdTestProgressFromDB(caseId,taskId);
-//		}else{
-//			return aservice.crowdTestProgress(caseId,taskId);
-//		}
+//		return 50.0;
+		String realUrl = AESUtil.decrypt(token);
+		String [] decoder = url2decode(realUrl);
+		String taskId=decoder[0];
+		String caseId=decoder[1];
+		Task task=taskDao.findById(taskId);
+		if(task.getEnd_time()>System.currentTimeMillis()){
+			return aservice.crowdTestProgressFromDB(caseId,taskId);
+		}else{
+			return aservice.crowdTestProgress(caseId,taskId);
+		}
 	}
 
 

+ 32 - 10
src/main/java/edu/nju/service/AnalyzeService.java

@@ -95,6 +95,12 @@ public class AnalyzeService {
 
 	private String serverPort="8090";
 
+	@Value("${main.site}")
+	private String mainSite;
+
+	@Value("${main.userInfoApi}")
+	private String mainUserInfoApi;
+
 	private static String[] radarInfo = {"发现bug能力","描述bug能力","经验值","bug有效率","众测平均得分"};
 	private static int[] radarValueStart = {70,80,60,50,70};
 	private static List<String> mockLabels = Arrays.asList("移动应用","Android","ios","鸿蒙os","华为","MacOS","Windows10",
@@ -828,16 +834,8 @@ 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"));
-
 		Exam exam = examDao.findById(caseId);
 		Task task=taskDao.findById(taskId);
-
-
-
 		long startTime=0;
 		long endTime=0;
 		String taskName="";
@@ -889,11 +887,14 @@ public class AnalyzeService {
 				}
 			}
 		}
-
+		System.out.println("bugWorkerMap.toString() " + bugWorkerMap.toString());
 		Map<Integer,Integer>gradeDistribution=new HashMap<>();
 		Map<String,Integer>workerDistribution=new HashMap<>();
 		List<BugScore>bugScores=bsdao.findByIds(bugIds);
+		// 有分数的
 		for(BugScore bugScore:bugScores){
+			// 从bugIds中移除
+			bugIds.remove(bugScore.getId());
 			int grade = bugScore.getGrade();
 			String workerId=bugWorkerMap.get(bugScore.getId());
 			if(workerId!=null){
@@ -910,6 +911,23 @@ public class AnalyzeService {
 			}
 		}
 
+		System.out.println("去重后: " + bugIds.toString());
+		for(String bugId:bugIds){
+			String workerId=bugWorkerMap.get(bugId);
+			if(workerId!=null){
+				if (workerDistribution.containsKey(workerId)) {
+					workerDistribution.replace(workerId, workerDistribution.get(workerId) + -1);
+				} else {
+					workerDistribution.put(workerId, -1);
+				}
+			}
+			if (gradeDistribution.containsKey(-1)) {
+				gradeDistribution.replace(-1, gradeDistribution.get(-1) + 1);
+			} else {
+				gradeDistribution.put(-1, 1);
+			}
+		}
+
 		int forkNum=0;
 		List<BugHistory>bugHistories=bugHistoryDao.findBugHistoryList(bugIds);
 		for(BugHistory bugHistory:bugHistories){
@@ -933,7 +951,8 @@ public class AnalyzeService {
 		for(int i=0;i<list.size();i++) {
 			String workerId = list.get(i).getKey();
 			int grade=list.get(i).getValue();
-			String result = HTTP.sendGet("http://114.55.91.83:8191/api/user/" + workerId, "");
+			String result = HTTP.sendGet(mainSite + mainUserInfoApi + workerId, "");
+			System.out.println("主站人员信息: " + result);
 			String name = "";
 			String school = "";
 			String province="";
@@ -1061,6 +1080,9 @@ public class AnalyzeService {
 			endTime = task.getEnd_time();
 		}
 		long pieceTime=(endTime-startTime)/piece;
+		if(pieceTime == 0){
+			pieceTime = 10;
+		}
 		String caseTakeId=caseId+"-"+taskId;
 		List<Bug>bugs=bdao.findByCaseid(caseTakeId);
 		map.put(0,0);

+ 6 - 1
src/main/java/edu/nju/service/GuideService.java

@@ -12,6 +12,7 @@ import java.util.Set;
 
 import javax.servlet.http.HttpSession;
 
+import edu.nju.configuration.OSSConfiguration;
 import edu.nju.util.HTTP;
 import org.json.JSONArray;
 import org.json.JSONObject;
@@ -33,6 +34,9 @@ public class GuideService {
 	@Autowired
 	ReportService rservice;
 
+	@Autowired
+	OSSConfiguration ossConfiguration;
+
 	@Value("${useOss}")
 	boolean useOss;
 
@@ -69,7 +73,8 @@ public class GuideService {
 		String structure = "";
 		if(session.getAttribute(QS) == null) {
 			if(useOss){
-				structure = HTTP.sendGet("http://mooctest-site.oss-cn-shanghai.aliyuncs.com/json/" + QS + ".json" , "");
+				String baseUrl = ossConfiguration.getBaseUrl();
+				structure = HTTP.sendGet(baseUrl + "/json/" + QS + ".json" , "");
 			}else{
 				// 私有云使用本地的json文件
 				String jsonFilePath = savePath + folderName + jsonName + "/" + QS + ".json";

+ 2 - 0
src/main/resources/application.yml

@@ -98,6 +98,8 @@ save:
   image: /image
 main:
   site: http://127.0.0.1:8080
+  userInfoApi: /api/user/info/
+
 #  site: http://121.196.124.158:8200
 
 ---