Просмотр исходного кода

修改调用信创的配置项

郭超 4 лет назад
Родитель
Сommit
01ed121ebd

+ 8 - 1
src/main/java/edu/nju/dao/ReviewWorkerDao.java

@@ -4,6 +4,7 @@ import edu.nju.entities.ReviewWorker;
 import edu.nju.model.ReviewWorkerVO;
 import org.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.mongodb.core.MongoOperations;
 import org.springframework.data.mongodb.core.query.Criteria;
 import org.springframework.data.mongodb.core.query.Query;
@@ -18,6 +19,12 @@ public class ReviewWorkerDao {
     @Autowired
     private MongoOperations mongoOperations;
 
+    @Value("${main.site}")
+    private String mainSite;
+
+    @Value("${main.userInfoApi}")
+    private String mainUserInfoApi;
+
     public String save(ReviewWorker worker) {
         mongoOperations.save(worker);
         return worker.getId();
@@ -53,7 +60,7 @@ public class ReviewWorkerDao {
     }
 
     public ReviewWorkerVO getEduInfo(ReviewWorker reviewWorker) {
-        String result = HTTP.sendGet("http://114.55.91.83:8191/api/user/" + reviewWorker.getOriginal_id(), "");
+        String result = HTTP.sendGet(mainSite + mainUserInfoApi + reviewWorker.getOriginal_id(), "");
         String name = "";
         String school = "";
         if (result != null && !result.equals("")) {

+ 4 - 12
src/main/java/edu/nju/service/AnalyzeService.java

@@ -596,7 +596,7 @@ public class AnalyzeService {
 		if(task!=null)res.setTaskName(task.getName());
 		String caseTakeId = caseId+"-"+taskId;
 		// 部分数据从主战接口中取得
-		String result = HTTP.sendGet("http://114.55.91.83:8191/api/user/" + workerId, "");
+		String result = HTTP.sendGet(mainSite + mainUserInfoApi + workerId, "");
 		if (result != null && !result.equals("")) {
 			JSONObject json = new JSONObject(result);
 			if (json.has("name") && !json.isNull("name")) {
@@ -749,7 +749,7 @@ 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, "");
 			String name = "";
 			String school = "";
 			String province="";
@@ -918,17 +918,9 @@ public class AnalyzeService {
 		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);
+				workerDistribution.put(workerId, -1);
 			}
+			gradeDistribution.put(-1, 1);
 		}
 
 		int forkNum=0;

+ 7 - 1
src/main/java/edu/nju/service/ExportService.java

@@ -10,6 +10,7 @@ import edu.nju.model.ExportBugDTO;
 import edu.nju.model.ExportReportDTO;
 import org.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
@@ -30,13 +31,18 @@ public class ExportService {
     @Autowired
     BugScoreDao bugScoreDao;
 
+    @Value("${main.site}")
+    private String mainSite;
+
+    @Value("${main.userInfoApi}")
+    private String mainUserInfoApi;
 
     public List<ExportReportDTO> getExportReport(String case_take_id){
         List<Report> reportList=reportDao.findByCaseTakeId(case_take_id);
         List<ExportReportDTO> exportReportDTOList=new ArrayList<>();
         for(Report report:reportList){
             String workerId=report.getWorker_id();
-            String result = HTTP.sendGet("http://114.55.91.83:8191/api/user/" + workerId, "");
+            String result = HTTP.sendGet(mainSite + mainUserInfoApi + workerId, "");
             String name="";
             if(result != null && !result.equals("")) {
                 JSONObject json = new JSONObject(result);

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

@@ -6,6 +6,7 @@ import edu.nju.model.ReviewWorkerVO;
 import edu.nju.util.HTTP;
 import org.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.converter.StringHttpMessageConverter;
@@ -53,7 +54,11 @@ public class ReviewService {
     @Autowired
     ReviewPaperDao reviewPaperDao;
 
+    @Value("${main.site}")
+    private String mainSite;
 
+    @Value("${main.userInfoApi}")
+    private String mainUserInfoApi;
 
     public ReviewAnswer getAnswerByWorkerJobReportItem(String jobId,String reportId,String workerId,String itemId){
         ReviewAnswer reviewAnswer= answerDao.findAnswerByWorkerJobReportItem(jobId,reportId,workerId, itemId);
@@ -129,7 +134,7 @@ public class ReviewService {
         try {
             for(int i=0;i<reviewWorkers.size();i++){
                 ReviewWorker reviewWorker=reviewWorkers.get(i);
-                String result = HTTP.sendGet("http://114.55.91.83:8191/api/user/" + reviewWorker.getOriginal_id(), "");
+                String result = HTTP.sendGet(mainSite + mainUserInfoApi + reviewWorker.getOriginal_id(), "");
                 String name="";
                 String school="";
                 if(result != null && !result.equals("")) {

+ 8 - 1
src/main/java/edu/nju/service/SaveService.java

@@ -10,6 +10,7 @@ import java.util.Set;
 import edu.nju.util.HTTP;
 import org.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import edu.nju.dao.BugDao;
@@ -59,6 +60,12 @@ public class SaveService {
 	
 	@Autowired
 	AnalyzeService aservice;
+
+	@Value("${main.site}")
+	private String mainSite;
+
+	@Value("${main.userInfoApi}")
+	private String mainUserInfoApi;
 	
 	public String save(String case_take_id, String bug_category, String description, String img_url, String severity, String recurrent, String title, String report_id, String parent, String page, String useCase, String case_id) {
 		try {
@@ -105,7 +112,7 @@ public class SaveService {
 		try {
 			String name = sdao.findById(report_id);
 			if(name.equals("null") || name.equals("")) {
-				String result = HTTP.sendGet("http://114.55.91.83:8191/api/user/" + worker_id, "");
+				String result = HTTP.sendGet(mainSite + mainUserInfoApi + worker_id, "");
 				if(result != null && !result.equals("")) { 
 					JSONObject json = new JSONObject(result);
 					sdao.save(report_id, worker_id, json.getString("name"));