Ver código fonte

后端:修改蓝图结构中的难度值计算不对 bug

weiwenhai 7 anos atrás
pai
commit
9d6eaf0daf

+ 5 - 3
cqb-paper/src/main/java/com/qmth/cqb/paper/service/PaperStructService.java

@@ -246,7 +246,7 @@ public class PaperStructService {
         	}
         	paperStruct.setPaperStrucType(PaperStructType.BLUEPRINT);
         	//计算试卷结构难度
-			Double difficulty = getDifficulty(paperDetailStructs);
+			Double difficulty = getDifficulty(paperDetailStructs,paperStruct.getTotalScore());
 			paperStruct.setDifficulty(difficulty);
 		}
         paperStruct.setOrgId(user.getRootOrgId().toString());
@@ -264,7 +264,8 @@ public class PaperStructService {
     	return unitStruct.getPropertyId() + "-" + String.valueOf(unitStruct.getPublicity()) + "-" + unitStruct.getDifficulty();
 	}
 
-	public Double getDifficulty(List<PaperDetailStruct> paperDetailStructs) {
+	public Double getDifficulty(List<PaperDetailStruct> paperDetailStructs,Double totalScore) {
+		Double sum = 0.0;
 		if(paperDetailStructs != null && paperDetailStructs.size() >0){
 			Integer simpleCount = 0;
 			Integer mediumCount = 0;
@@ -273,8 +274,9 @@ public class PaperStructService {
 				simpleCount = paperDetailStruct.getPublicSimpleCount() + paperDetailStruct.getNoPublicSimpleCount();
 				mediumCount = paperDetailStruct.getPublicMediumCount() + paperDetailStruct.getNoPublicMediumCount();
 				difficultyCount = paperDetailStruct.getPublicDifficultyCount() + paperDetailStruct.getNoPublicDifficultyCount();
+				sum = simpleCount * paperDetailStruct.getScore() * 0.8 + mediumCount * paperDetailStruct.getScore() * 0.5 + difficultyCount * paperDetailStruct.getScore() * 0.2 + sum;
 			}
-			Double dif = ((simpleCount * 0.8) + (mediumCount * 0.5) + (difficultyCount * 0.2))/(simpleCount + mediumCount + difficultyCount);
+			Double dif = sum / totalScore;
 			BigDecimal b = new BigDecimal(dif);
 			Double difficulty = b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
 			return difficulty;