|
@@ -157,60 +157,91 @@ public class AnalyzeService {
|
|
|
|
|
|
return mark;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ //todo 搞清楚究竟是通过哪种方式写回主站分数
|
|
|
public JSONArray getScores(String case_take_id) {
|
|
|
- Map<String, Integer> result = new HashMap<String, Integer>(); //用户得分
|
|
|
- Map<String, Integer> grades = new HashMap<String, Integer>(); //专家评价分
|
|
|
- Map<String, Integer> scores = new HashMap<String, Integer>(); //计算bug得分
|
|
|
+ Map<String, Integer> reviewScore = new HashMap<String, Integer>(); //评审他人bug得分
|
|
|
+ Map<String, Integer> bugScore = new HashMap<String, Integer>(); //系统或专家评审你的bug得分
|
|
|
+ Map<String, Integer> finalScores = new HashMap<String, Integer>(); //计算bug得分
|
|
|
JSONArray json = new JSONArray();
|
|
|
-
|
|
|
- List<String> bugs = getValid(case_take_id);
|
|
|
- for(String bug: bugs) {
|
|
|
- BugScore temp = bsdao.findById(bug);
|
|
|
- if(temp != null) {grades.put(bug, temp.getGrade());}
|
|
|
- else {grades.put(bug, 0);}
|
|
|
+
|
|
|
+ //获取所有bugID
|
|
|
+ List<String> bugIdList = getValid(case_take_id);
|
|
|
+ //获取bug本身得分
|
|
|
+ for(String bugId: bugIdList) {
|
|
|
+ BugScore temp = bsdao.findById(bugId);
|
|
|
+ if(temp != null) {bugScore.put(bugId, temp.getGrade());}
|
|
|
+ else {bugScore.put(bugId, 0);}
|
|
|
}
|
|
|
-// for(String bug: bugs) {
|
|
|
-// BugMirror mirror = mdao.findById(bug);
|
|
|
-// int grade = grades.get(bug);
|
|
|
-// if(grade == 0) {continue;}
|
|
|
-// if(grade == 1) {ThumsUp(5, result, mirror);}
|
|
|
-// else if(grade == 2) {ThumsUp(3, result, mirror);}
|
|
|
-// else {ThumsUp(-3, result, mirror);}
|
|
|
-// result.put(mirror.getReport_id(), result.getOrDefault(mirror.getReport_id(), 0) + mark(bug, grades, mirror));
|
|
|
-// }
|
|
|
- countScore(case_take_id, scores, grades);
|
|
|
- for(String bug: bugs) {
|
|
|
+
|
|
|
+ //计算树状bug得分
|
|
|
+ countScore(case_take_id, finalScores, bugScore);
|
|
|
+
|
|
|
+ //计算审查得分
|
|
|
+ for(String bug: bugIdList) {
|
|
|
BugMirror mirror = mdao.findById(bug);
|
|
|
if(mirror == null) { continue; }
|
|
|
- int grade = grades.getOrDefault(bug, 0);
|
|
|
- if(grade > 0) { ThumsUp(1, result, mirror); }
|
|
|
- if(grade == 0) { ThumsUp(-1, result, mirror); }
|
|
|
+ int grade = bugScore.getOrDefault(bug, 0);
|
|
|
+ int thumbsScore=0;
|
|
|
+ if(grade>=0&&grade<3){
|
|
|
+ thumbsScore=-2;
|
|
|
+ }else if(grade<5){
|
|
|
+ thumbsScore=-1;
|
|
|
+ }else if(grade<8){
|
|
|
+ thumbsScore=1;
|
|
|
+ }else{
|
|
|
+ thumbsScore=2;
|
|
|
+ }
|
|
|
+ //点赞点踩积分减分
|
|
|
+ ThumsUp(thumbsScore,reviewScore,mirror);
|
|
|
}
|
|
|
- for(Map.Entry<String, Integer> entry : result.entrySet()) {
|
|
|
- if(entry.getValue() > 20) { result.put(entry.getKey(), 20); }
|
|
|
- if(entry.getValue() < 0) { result.put(entry.getKey(), 0); }
|
|
|
+ int maxReviewScore=0;
|
|
|
+ int maxReportScore=0;
|
|
|
+ for(Map.Entry<String, Integer> entry : reviewScore.entrySet()) {
|
|
|
+ //审查得分低于零分按零分算
|
|
|
+ if(entry.getValue() < 0) { reviewScore.put(entry.getKey(), 0); }
|
|
|
+ if(entry.getValue()>maxReviewScore){
|
|
|
+ maxReviewScore=entry.getValue();
|
|
|
+ }
|
|
|
}
|
|
|
- Map<String, Integer> temp = new HashMap<String, Integer>();
|
|
|
- for(String bug: bugs) {
|
|
|
- BugMirror mirror = mdao.findById(bug);
|
|
|
+
|
|
|
+ //将bug得分汇总为report得分
|
|
|
+ Map<String, Integer> reportScore = new HashMap<String, Integer>();
|
|
|
+ for(String bugId: bugIdList) {
|
|
|
+ BugMirror mirror = mdao.findById(bugId);
|
|
|
if(mirror == null) { continue; }
|
|
|
- temp.put(mirror.getReport_id(), scores.getOrDefault(bug, 0) + temp.getOrDefault(mirror.getReport_id(), 0));
|
|
|
+ String reportId=mirror.getReport_id();
|
|
|
+ //出现过bug和bugMirror中没有reportId的问题,需要单独检查
|
|
|
+ if(reportId!=null) {
|
|
|
+ reportScore.put(reportId, finalScores.getOrDefault(bugId, 0) + reportScore.getOrDefault(reportId, 0));
|
|
|
+ if (reportScore.get(reportId) > maxReportScore) {
|
|
|
+ maxReportScore = reportScore.get(reportId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //确保被除数不为0
|
|
|
+ if(maxReportScore==0){
|
|
|
+ maxReportScore=1;
|
|
|
}
|
|
|
- for(Map.Entry<String, Integer> entry : temp.entrySet()) {
|
|
|
+ if(maxReviewScore==0){
|
|
|
+ maxReviewScore=1;
|
|
|
+ }
|
|
|
+ //得分要以最高分为满分
|
|
|
+ for(Map.Entry<String, Integer> entry : reportScore.entrySet()) {
|
|
|
JSONObject json_temp = new JSONObject();
|
|
|
json_temp.put("report_id", entry.getKey());
|
|
|
json_temp.put("worker_id", findWorkerId(entry.getKey()));
|
|
|
json_temp.put("名字", report_trans(entry.getKey()));
|
|
|
- json_temp.put("报告得分", entry.getValue());
|
|
|
- json_temp.put("审查得分", result.getOrDefault(entry.getKey(), 0));
|
|
|
+ json_temp.put("报告得分", (entry.getValue()/maxReportScore)*100);
|
|
|
+ json_temp.put("审查得分", (reviewScore.getOrDefault(entry.getKey(), 0)/maxReviewScore)*100);
|
|
|
json.put(json_temp);
|
|
|
}
|
|
|
+ //把分写回主站
|
|
|
writeScores(case_take_id, json);
|
|
|
return json;
|
|
|
}
|
|
|
|
|
|
- //todo 修改算分逻辑
|
|
|
+
|
|
|
public JSONArray getNewScores(JSONArray array) {
|
|
|
if(array == null || array.length() <= 0) { return array; }
|
|
|
for(int i = 0; i < array.length(); i ++) {
|
|
@@ -218,7 +249,9 @@ public class AnalyzeService {
|
|
|
if(object.keySet().size() < 5) { continue; }
|
|
|
object.put("name", object.get("名字"));
|
|
|
object.remove("名字");
|
|
|
- int score = Integer.parseInt(object.get("报告得分").toString()) + Integer.parseInt(object.get("审查得分").toString());
|
|
|
+ int bugScore=Integer.parseInt(object.get("报告得分").toString());
|
|
|
+ int reviewScore=Integer.parseInt(object.get("审查得分").toString());
|
|
|
+ double score = bugScore*0.7+reviewScore*0.3;
|
|
|
if(score > 100) { object.put("score", 100); }
|
|
|
else { object.put("score", score); }
|
|
|
object.remove("报告得分");
|
|
@@ -229,6 +262,7 @@ public class AnalyzeService {
|
|
|
|
|
|
//计算点赞得分
|
|
|
private void ThumsUp(int grade, Map<String, Integer> result, BugMirror mirror) {
|
|
|
+ //给好的点赞加分,点踩减分,不好的反之
|
|
|
for(String report : mirror.getGood()) {
|
|
|
result.put(report, result.getOrDefault(report, 0) + grade);
|
|
|
}
|
|
@@ -309,7 +343,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);
|
|
|
for(String root : roots) {
|
|
@@ -333,7 +367,10 @@ public class AnalyzeService {
|
|
|
for(int i = 0; i < array.length(); i ++) {
|
|
|
JSONObject json = (JSONObject)array.get(i);
|
|
|
String worker_id = json.get("worker_id").toString();
|
|
|
- int score = Integer.parseInt(json.get("报告得分").toString()) + Integer.parseInt(json.get("审查得分").toString());
|
|
|
+ //报告得分*0.7+审查得分*0.3
|
|
|
+ int bugScore=Integer.parseInt(json.get("报告得分").toString());
|
|
|
+ int reviewScore=Integer.parseInt(json.get("审查得分").toString());
|
|
|
+ double score = bugScore*0.7+reviewScore*0.3;
|
|
|
if(score <= 0 || worker_id.equals("")) { continue; }
|
|
|
if(score > 100) { score = 100; }
|
|
|
String param2 = "&userId=" + worker_id + "&score=" + score;
|