|
@@ -32,7 +32,6 @@ import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.math.BigInteger;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.Instant;
|
|
|
import java.time.LocalDate;
|
|
@@ -283,8 +282,12 @@ public class WhuDataSyncServiceImpl implements WhuDataSyncService {
|
|
|
// 选模式
|
|
|
// 解析计算参数
|
|
|
JSONObject object = JSON.parseObject(examAssign.getCoefficient());
|
|
|
+ // 是否统一设置
|
|
|
Boolean all = object.getBoolean("all");
|
|
|
+ // 统一设置系数
|
|
|
Double allValue = object.getDoubleValue("value");
|
|
|
+ // 重修赋分系数
|
|
|
+ Double rebuildValue = object.getDoubleValue("rebuildValue");
|
|
|
|
|
|
List<ExamSyncStudentDto> finalList = new ArrayList<>();
|
|
|
List<ExamSyncStudentDto> examSyncStudentDtoList = cloudMarkingScoreService.listExamSyncStudentDtos(examAssign.getSchoolId(), examAssign.getSemesterId(), examAssign.getExamTypeId(), examAssign.getCourseCode(), examAssign.getOpenCollege());
|
|
@@ -292,7 +295,7 @@ public class WhuDataSyncServiceImpl implements WhuDataSyncService {
|
|
|
Double maxTotalScore = examSyncStudentDtoList.stream().map(m -> Double.parseDouble(m.getTotalScore())).max(Comparator.comparingDouble(x -> x)).get();
|
|
|
if (all) {
|
|
|
// 卷面最高分
|
|
|
- calcProgress(examAssign.getFormula(), allValue, examSyncStudentDtoList, maxTotalScore, finalList);
|
|
|
+ calcProgress(examAssign, allValue, rebuildValue, examSyncStudentDtoList, maxTotalScore, finalList);
|
|
|
} else {
|
|
|
Map<String, List<ExamSyncStudentDto>> collect = examSyncStudentDtoList.stream().collect(Collectors.groupingBy(ExamSyncStudentDto::getJgmc));
|
|
|
for (Map.Entry<String, List<ExamSyncStudentDto>> entry : collect.entrySet()) {
|
|
@@ -303,7 +306,8 @@ public class WhuDataSyncServiceImpl implements WhuDataSyncService {
|
|
|
throw ExceptionResultEnum.ERROR.exception(String.format("开课学院[%s]未设置的参数值", college));
|
|
|
}
|
|
|
double collegeValue = objectOptional.get().getDoubleValue("value");
|
|
|
- calcProgress(examAssign.getFormula(), collegeValue, entry.getValue(), maxTotalScore, finalList);
|
|
|
+ double collegeRebuildValue = objectOptional.get().getDoubleValue("rebuildValue");
|
|
|
+ calcProgress(examAssign, collegeValue, collegeRebuildValue, entry.getValue(), maxTotalScore, finalList);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -333,23 +337,30 @@ public class WhuDataSyncServiceImpl implements WhuDataSyncService {
|
|
|
/**
|
|
|
* 计算公共方法
|
|
|
*
|
|
|
- * @param formula 公式
|
|
|
+ * @param examAssign examAssign
|
|
|
* @param value 系数
|
|
|
+ * @param rebuildValue 重修系数
|
|
|
* @param examSyncStudentDtoList 源数据
|
|
|
* @param finalList 计算后数据
|
|
|
* 备注:AviatorEvaluator.compile(formula).execute(paramMap),paramMap中的参数值不能为String类型
|
|
|
*/
|
|
|
- private void calcProgress(FormulaEnum formula, Double value, List<ExamSyncStudentDto> examSyncStudentDtoList, Double maxTotalScore, List<ExamSyncStudentDto> finalList) {
|
|
|
+ private void calcProgress(ExamAssign examAssign, Double value, Double rebuildValue, List<ExamSyncStudentDto> examSyncStudentDtoList, Double maxTotalScore, List<ExamSyncStudentDto> finalList) {
|
|
|
+ // 开启原始分四舍五入,先将分数四舍五入后再进行赋分计算
|
|
|
+ if (examAssign.getOpenTotalScoreRound()) {
|
|
|
+ value = new BigDecimal(value).setScale(0, RoundingMode.HALF_UP).doubleValue();
|
|
|
+ }
|
|
|
// 公式1(赋值分=卷面成绩+ (100- 卷面成绩)/赋分系数)
|
|
|
- if (FormulaEnum.FORMULA1.equals(formula)) {
|
|
|
+ if (FormulaEnum.FORMULA1.equals(examAssign.getFormula())) {
|
|
|
// a为卷面成绩,y为赋分系数
|
|
|
String formula1 = "a+(100-a)/b";
|
|
|
for (ExamSyncStudentDto studentDto : examSyncStudentDtoList) {
|
|
|
Map<String, Object> paramMap = new HashMap<>();
|
|
|
paramMap.put("a", Double.parseDouble(studentDto.getTotalScore()));
|
|
|
- paramMap.put("b", value);
|
|
|
+ // 判断是否重修
|
|
|
+ Double bValue = StringUtils.isNotBlank(studentDto.getCxbj()) && "1".equals(studentDto.getCxbj()) && rebuildValue != null && rebuildValue.doubleValue() != 0 ? rebuildValue : value;
|
|
|
+ paramMap.put("b", bValue);
|
|
|
String assignScore = AviatorEvaluator.compile(formula1).execute(paramMap).toString();
|
|
|
- studentDto.setAssignScore(stripTrailingZerosFormula1(assignScore));
|
|
|
+ studentDto.setAssignScore(roundOff59(stripTrailingZerosFormula1(assignScore), examAssign.getOpenRound()));
|
|
|
finalList.add(studentDto);
|
|
|
}
|
|
|
}
|
|
@@ -359,31 +370,33 @@ public class WhuDataSyncServiceImpl implements WhuDataSyncService {
|
|
|
说明:1.如果初始卷面最高的大于99时,则x=100,否则x=99;
|
|
|
2.参数根据每次总体初始成绩的不及格率进行调整。
|
|
|
*/
|
|
|
- else if (FormulaEnum.FORMULA2.equals(formula)) {
|
|
|
+ else if (FormulaEnum.FORMULA2.equals(examAssign.getFormula())) {
|
|
|
int x = maxTotalScore.doubleValue() > 99 ? 100 : 99;
|
|
|
// a:初始卷面,b:参数,c:初始卷面最高分,x:说明1中参数
|
|
|
String formula2_1 = "(55+(a-b)/(c-b)*(x-55))*2";
|
|
|
String formula2_2 = "(a*50/b)*2";
|
|
|
|
|
|
for (ExamSyncStudentDto studentDto : examSyncStudentDtoList) {
|
|
|
+ // 判断是否重修
|
|
|
+ Double bValue = StringUtils.isNotBlank(studentDto.getCxbj()) && "1".equals(studentDto.getCxbj()) && rebuildValue != null && rebuildValue.doubleValue() != 0 ? rebuildValue : value;
|
|
|
Map<String, Object> paramMap = new HashMap<>();
|
|
|
Double totalScore = Double.valueOf(studentDto.getTotalScore());
|
|
|
String tempAssignScore;
|
|
|
if (totalScore >= value) {
|
|
|
paramMap.put("a", totalScore.doubleValue());
|
|
|
- paramMap.put("b", value);
|
|
|
+ paramMap.put("b", bValue.doubleValue());
|
|
|
paramMap.put("c", maxTotalScore.doubleValue());
|
|
|
paramMap.put("x", x);
|
|
|
tempAssignScore = AviatorEvaluator.compile(formula2_1).execute(paramMap).toString();
|
|
|
} else {
|
|
|
paramMap.put("a", totalScore.doubleValue());
|
|
|
- paramMap.put("b", value.doubleValue());
|
|
|
+ paramMap.put("b", bValue.doubleValue());
|
|
|
tempAssignScore = AviatorEvaluator.compile(formula2_2).execute(paramMap).toString();
|
|
|
}
|
|
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(tempAssignScore).setScale(0, RoundingMode.HALF_UP);
|
|
|
String assignScore = bigDecimal.divide(new BigDecimal("2")).toString();
|
|
|
- studentDto.setAssignScore(stripTrailingZeros(assignScore));
|
|
|
+ studentDto.setAssignScore(roundOff59(stripTrailingZeros(assignScore), examAssign.getOpenRound()));
|
|
|
finalList.add(studentDto);
|
|
|
}
|
|
|
}
|
|
@@ -422,6 +435,22 @@ public class WhuDataSyncServiceImpl implements WhuDataSyncService {
|
|
|
return new BigDecimal(value).stripTrailingZeros().toPlainString();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 满59进1到60
|
|
|
+ *
|
|
|
+ * @param value
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String roundOff59(String value, Boolean openRound) {
|
|
|
+ // 分数>59,进1为60
|
|
|
+ int intValue = new BigDecimal(value).setScale(0, RoundingMode.FLOOR).intValue();
|
|
|
+ if (openRound && intValue == 59) {
|
|
|
+ return "60";
|
|
|
+ } else {
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional
|
|
|
public void saveScoreData(Long schoolId, Long collegeId, Long semesterId, Long examTypeId, Integer examId, List<CloudMarkingScore> cloudMarkingScoreList) {
|
|
|
// 查询对外数据
|
|
@@ -431,9 +460,9 @@ public class WhuDataSyncServiceImpl implements WhuDataSyncService {
|
|
|
}
|
|
|
List<ExamSyncStudent> examSyncStudents = examSyncStudentService.listByExamSyncTotalId(examSyncTotal);
|
|
|
for (CloudMarkingScore cloudMarkingScore : cloudMarkingScoreList) {
|
|
|
+ // 通过课程号+学号进行云阅卷数据和考务数据匹配
|
|
|
Optional<ExamSyncStudent> optional = examSyncStudents.stream()
|
|
|
- .filter(s -> s.getJxbmc().equals(cloudMarkingScore.getClassName())
|
|
|
- && ((StringUtils.isBlank(s.getCloudMarkingCourseCode()) && s.getKch().equals(cloudMarkingScore.getSubjectCode())) || (StringUtils.isNotBlank(s.getCloudMarkingCourseCode()) && s.getCloudMarkingCourseCode().equals(cloudMarkingScore.getSubjectCode())))
|
|
|
+ .filter(s -> ((StringUtils.isBlank(s.getCloudMarkingCourseCode()) && s.getKch().equals(cloudMarkingScore.getSubjectCode())) || (StringUtils.isNotBlank(s.getCloudMarkingCourseCode()) && s.getCloudMarkingCourseCode().equals(cloudMarkingScore.getSubjectCode())))
|
|
|
&& s.getXh().equals(cloudMarkingScore.getStudentCode())).findFirst();
|
|
|
if (optional.isPresent()) {
|
|
|
ExamSyncStudent examSyncStudent = optional.get();
|