|
@@ -10,9 +10,12 @@ import com.qmth.distributed.print.business.bean.dto.CourseWeightFormDto;
|
|
import com.qmth.distributed.print.business.bean.params.CourseWeightParam;
|
|
import com.qmth.distributed.print.business.bean.params.CourseWeightParam;
|
|
import com.qmth.distributed.print.business.bean.result.CourseEvaluationResult;
|
|
import com.qmth.distributed.print.business.bean.result.CourseEvaluationResult;
|
|
import com.qmth.distributed.print.business.bean.result.CourseTargetResult;
|
|
import com.qmth.distributed.print.business.bean.result.CourseTargetResult;
|
|
|
|
+import com.qmth.distributed.print.business.bean.result.CourseWeightResult;
|
|
|
|
+import com.qmth.distributed.print.business.entity.CourseEvaluation;
|
|
import com.qmth.distributed.print.business.entity.CourseTarget;
|
|
import com.qmth.distributed.print.business.entity.CourseTarget;
|
|
import com.qmth.distributed.print.business.entity.CourseWeight;
|
|
import com.qmth.distributed.print.business.entity.CourseWeight;
|
|
import com.qmth.distributed.print.business.entity.TeachCourse;
|
|
import com.qmth.distributed.print.business.entity.TeachCourse;
|
|
|
|
+import com.qmth.distributed.print.business.enums.CourseEvaluationTypeEnum;
|
|
import com.qmth.distributed.print.business.enums.CourseSettingTypeEnum;
|
|
import com.qmth.distributed.print.business.enums.CourseSettingTypeEnum;
|
|
import com.qmth.distributed.print.business.mapper.CourseWeightMapper;
|
|
import com.qmth.distributed.print.business.mapper.CourseWeightMapper;
|
|
import com.qmth.distributed.print.business.service.CourseEvaluationService;
|
|
import com.qmth.distributed.print.business.service.CourseEvaluationService;
|
|
@@ -28,10 +31,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
+import java.math.RoundingMode;
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -55,8 +56,11 @@ public class CourseWeightServiceImpl extends ServiceImpl<CourseWeightMapper, Cou
|
|
private CourseEvaluationService courseEvaluationService;
|
|
private CourseEvaluationService courseEvaluationService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<CourseWeightDto> findCourseWeight(Long examId, String courseCode, Long userId) {
|
|
|
|
|
|
+ public CourseWeightResult findCourseWeight(Long examId, String courseCode, Long userId) {
|
|
TeachCourse teachCourse = teachCourseService.findByExamIdCourseCodeAndUserId(examId, courseCode, userId);
|
|
TeachCourse teachCourse = teachCourseService.findByExamIdCourseCodeAndUserId(examId, courseCode, userId);
|
|
|
|
+ BigDecimal defaultRate = teachCourse.getDefaultRate();
|
|
|
|
+ BigDecimal customRate = teachCourse.getCustomRate();
|
|
|
|
+
|
|
Long teachCourseId = teachCourse.getId();
|
|
Long teachCourseId = teachCourse.getId();
|
|
|
|
|
|
// 现有目标
|
|
// 现有目标
|
|
@@ -71,7 +75,7 @@ public class CourseWeightServiceImpl extends ServiceImpl<CourseWeightMapper, Cou
|
|
Map<String, CourseWeight> courseWeightMap = courseWeightList.stream()
|
|
Map<String, CourseWeight> courseWeightMap = courseWeightList.stream()
|
|
.collect(Collectors.toMap(k -> k.getTargetId() + SystemConstant.HYPHEN + k.getEvaluationId(), v -> v));
|
|
.collect(Collectors.toMap(k -> k.getTargetId() + SystemConstant.HYPHEN + k.getEvaluationId(), v -> v));
|
|
|
|
|
|
- List<CourseWeightDto> result = new ArrayList<>();
|
|
|
|
|
|
+ List<CourseWeightDto> submitForm = new ArrayList<>();
|
|
if (CollectionUtils.isNotEmpty(courseTargetList)) {
|
|
if (CollectionUtils.isNotEmpty(courseTargetList)) {
|
|
for (CourseTargetResult courseTarget : courseTargetList) {
|
|
for (CourseTargetResult courseTarget : courseTargetList) {
|
|
Long targetId = courseTarget.getId();
|
|
Long targetId = courseTarget.getId();
|
|
@@ -96,10 +100,14 @@ public class CourseWeightServiceImpl extends ServiceImpl<CourseWeightMapper, Cou
|
|
enable = courseWeight.getEnable();
|
|
enable = courseWeight.getEnable();
|
|
weight = courseWeight.getWeight();
|
|
weight = courseWeight.getWeight();
|
|
targetScore = courseWeight.getTargetScore();
|
|
targetScore = courseWeight.getTargetScore();
|
|
|
|
+ } else if (CourseEvaluationTypeEnum.DEFAULT.equals(courseEvaluationResult.getType())) {
|
|
|
|
+ enable = true;
|
|
|
|
+ weight = new BigDecimal(100);
|
|
}
|
|
}
|
|
CourseWeightDetailDto detail = new CourseWeightDetailDto();
|
|
CourseWeightDetailDto detail = new CourseWeightDetailDto();
|
|
detail.setEvaluationId(evaluationId);
|
|
detail.setEvaluationId(evaluationId);
|
|
detail.setEvaluationName(evaluationName);
|
|
detail.setEvaluationName(evaluationName);
|
|
|
|
+ detail.setEvaluationDesc(courseEvaluationResult.getEvaluationDesc());
|
|
detail.setEnable(enable);
|
|
detail.setEnable(enable);
|
|
detail.setWeight(weight);
|
|
detail.setWeight(weight);
|
|
detail.setTargetScore(targetScore);
|
|
detail.setTargetScore(targetScore);
|
|
@@ -113,23 +121,32 @@ public class CourseWeightServiceImpl extends ServiceImpl<CourseWeightMapper, Cou
|
|
courseWeightDto.setCourseTargetId(targetId);
|
|
courseWeightDto.setCourseTargetId(targetId);
|
|
courseWeightDto.setCourseTargetName(targetName);
|
|
courseWeightDto.setCourseTargetName(targetName);
|
|
courseWeightDto.setDimensionList(dimensionList);
|
|
courseWeightDto.setDimensionList(dimensionList);
|
|
|
|
+ courseWeightDto.analyzeDimensionStr();
|
|
courseWeightDto.setDegreeRequirement(degreeRequirement);
|
|
courseWeightDto.setDegreeRequirement(degreeRequirement);
|
|
courseWeightDto.setTotalWeight(totalWeight);
|
|
courseWeightDto.setTotalWeight(totalWeight);
|
|
courseWeightDto.setTotalScore(totalScore);
|
|
courseWeightDto.setTotalScore(totalScore);
|
|
courseWeightDto.setEvaluationList(courseWeightDetailDtoList);
|
|
courseWeightDto.setEvaluationList(courseWeightDetailDtoList);
|
|
- result.add(courseWeightDto);
|
|
|
|
|
|
+ courseWeightDto.analyzeDimensionStr();
|
|
|
|
+ submitForm.add(courseWeightDto);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ CourseWeightResult result = new CourseWeightResult();
|
|
|
|
+ result.setDefaultRate(defaultRate);
|
|
|
|
+ result.setCustomRate(customRate);
|
|
|
|
+ result.setSubmitForm(submitForm);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
public void saveCourseWeight(CourseWeightParam courseWeightParam, SysUser requestUser) {
|
|
public void saveCourseWeight(CourseWeightParam courseWeightParam, SysUser requestUser) {
|
|
|
|
+ List<String> errorMsgList = new ArrayList<>();
|
|
Long requestUserId = requestUser.getId();
|
|
Long requestUserId = requestUser.getId();
|
|
Long examId = courseWeightParam.getExamId();
|
|
Long examId = courseWeightParam.getExamId();
|
|
String courseCode = courseWeightParam.getCourseCode();
|
|
String courseCode = courseWeightParam.getCourseCode();
|
|
|
|
+ BigDecimal defaultRate = courseWeightParam.getDefaultRate();
|
|
|
|
+ BigDecimal customRate = courseWeightParam.getCustomRate();
|
|
|
|
+
|
|
List<CourseWeightDto> submitForm = courseWeightParam.getSubmitForm();
|
|
List<CourseWeightDto> submitForm = courseWeightParam.getSubmitForm();
|
|
|
|
|
|
TeachCourse teachCourse = teachCourseService.findByExamIdCourseCodeAndUserId(examId, courseCode, requestUserId);
|
|
TeachCourse teachCourse = teachCourseService.findByExamIdCourseCodeAndUserId(examId, courseCode, requestUserId);
|
|
@@ -140,15 +157,12 @@ public class CourseWeightServiceImpl extends ServiceImpl<CourseWeightMapper, Cou
|
|
List<CourseTarget> courseTargetList = new ArrayList<>();
|
|
List<CourseTarget> courseTargetList = new ArrayList<>();
|
|
List<CourseWeight> courseWeightList = new ArrayList<>();
|
|
List<CourseWeight> courseWeightList = new ArrayList<>();
|
|
|
|
|
|
- // 目标分值检测
|
|
|
|
- BigDecimal checkTotalScore = BigDecimal.ZERO;
|
|
|
|
-
|
|
|
|
- // 评价方式整体权重检测
|
|
|
|
- BigDecimal checkEvaluationTotalWeight = BigDecimal.ZERO;
|
|
|
|
-
|
|
|
|
// 课程目标整体权重检测
|
|
// 课程目标整体权重检测
|
|
BigDecimal checkTargetTotalWeight = BigDecimal.ZERO;
|
|
BigDecimal checkTargetTotalWeight = BigDecimal.ZERO;
|
|
|
|
|
|
|
|
+ // 一个评价方式必须在一个目标下
|
|
|
|
+ Map<Long, CourseEvaluationTypeEnum> evaluationMap = new HashMap<>();
|
|
|
|
+
|
|
for (CourseWeightDto courseWeightDto : submitForm) {
|
|
for (CourseWeightDto courseWeightDto : submitForm) {
|
|
Long courseTargetId = courseWeightDto.getCourseTargetId();
|
|
Long courseTargetId = courseWeightDto.getCourseTargetId();
|
|
CourseTarget courseTarget = courseTargetService.getById(courseTargetId);
|
|
CourseTarget courseTarget = courseTargetService.getById(courseTargetId);
|
|
@@ -162,12 +176,40 @@ public class CourseWeightServiceImpl extends ServiceImpl<CourseWeightMapper, Cou
|
|
courseTargetList.add(courseTarget);
|
|
courseTargetList.add(courseTarget);
|
|
checkTargetTotalWeight = checkTargetTotalWeight.add(totalWeight);
|
|
checkTargetTotalWeight = checkTargetTotalWeight.add(totalWeight);
|
|
|
|
|
|
|
|
+ // 评价方式整体权重检测(自定义)
|
|
|
|
+ BigDecimal checkEvaluationCustomTotalWeight = BigDecimal.ZERO;
|
|
List<CourseWeightDetailDto> detailDtoList = courseWeightDto.getEvaluationList();
|
|
List<CourseWeightDetailDto> detailDtoList = courseWeightDto.getEvaluationList();
|
|
for (CourseWeightDetailDto detail : detailDtoList) {
|
|
for (CourseWeightDetailDto detail : detailDtoList) {
|
|
Long evaluationId = detail.getEvaluationId();
|
|
Long evaluationId = detail.getEvaluationId();
|
|
|
|
+ CourseEvaluation courseEvaluation = courseEvaluationService.getById(evaluationId);
|
|
|
|
+ BigDecimal rate = new BigDecimal(0);
|
|
|
|
+ CourseEvaluationTypeEnum evaluationType = courseEvaluation.getType();
|
|
|
|
+ if (CourseEvaluationTypeEnum.DEFAULT.equals(evaluationType)) {
|
|
|
|
+ rate = defaultRate;
|
|
|
|
+ } else if (CourseEvaluationTypeEnum.CUSTOM.equals(evaluationType)) {
|
|
|
|
+ rate = customRate;
|
|
|
|
+ }
|
|
|
|
+
|
|
Boolean enable = detail.getEnable();
|
|
Boolean enable = detail.getEnable();
|
|
BigDecimal weight = detail.getWeight();
|
|
BigDecimal weight = detail.getWeight();
|
|
- BigDecimal targetScore = detail.getTargetScore();
|
|
|
|
|
|
+ if (enable && CourseEvaluationTypeEnum.CUSTOM.equals(evaluationType)) {
|
|
|
|
+ if (evaluationMap.containsKey(evaluationId)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("评价方式只能被一个课程目标使用");
|
|
|
|
+ } else {
|
|
|
|
+ evaluationMap.put(evaluationId, evaluationType);
|
|
|
|
+ }
|
|
|
|
+ checkEvaluationCustomTotalWeight = checkEvaluationCustomTotalWeight.add(weight);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ BigDecimal denominator = new BigDecimal(100);
|
|
|
|
+ // 目标分值计算: 100 * 类型占比 * 目标占比 * 评价方式占比
|
|
|
|
+ BigDecimal targetScore = new BigDecimal(0);
|
|
|
|
+ if (enable) {
|
|
|
|
+ targetScore = new BigDecimal(100).multiply(rate).divide(denominator, 2, RoundingMode.HALF_UP)
|
|
|
|
+ .multiply(totalWeight).divide(denominator, 2, RoundingMode.HALF_UP).multiply(weight)
|
|
|
|
+ .divide(denominator, 2, RoundingMode.HALF_UP);
|
|
|
|
+ }
|
|
|
|
|
|
CourseWeight courseWeight = new CourseWeight();
|
|
CourseWeight courseWeight = new CourseWeight();
|
|
courseWeight.setTeachCourseId(teachCourseId);
|
|
courseWeight.setTeachCourseId(teachCourseId);
|
|
@@ -182,32 +224,21 @@ public class CourseWeightServiceImpl extends ServiceImpl<CourseWeightMapper, Cou
|
|
courseWeight.setTargetScore(targetScore);
|
|
courseWeight.setTargetScore(targetScore);
|
|
courseWeight.insertInfo(requestUserId);
|
|
courseWeight.insertInfo(requestUserId);
|
|
courseWeightList.add(courseWeight);
|
|
courseWeightList.add(courseWeight);
|
|
-
|
|
|
|
- if (enable) {
|
|
|
|
- checkTotalScore = checkTotalScore.add(targetScore);
|
|
|
|
- checkEvaluationTotalWeight = checkEvaluationTotalWeight.add(weight);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
- List<String> errorMsgList = new ArrayList<>();
|
|
|
|
- // 数据校验1:所有课程目标的总目标分值等于100分;
|
|
|
|
- int checkTotalScoreCompareResult = checkTotalScore.compareTo(new BigDecimal(100));
|
|
|
|
- if (checkTotalScoreCompareResult > 0) {
|
|
|
|
- errorMsgList.add(String.format("所有课程目标的总目标分值为[%s],超过100分", checkTotalScore));
|
|
|
|
- } else if (checkTotalScoreCompareResult < 0) {
|
|
|
|
- errorMsgList.add(String.format("所有课程目标的总目标分值为[%s],低于100分", checkTotalScore));
|
|
|
|
|
|
+ // 数据校验2:各课程目标下自定义评价方式的总权重应等于100%;
|
|
|
|
+ int checkEvaluationTotalWeightCompareResult = checkEvaluationCustomTotalWeight.compareTo(new BigDecimal(100));
|
|
|
|
+ if (checkEvaluationTotalWeightCompareResult > 0) {
|
|
|
|
+ errorMsgList.add(String.format("课程目标[%s]下评价方式的总权重为[%s],超过[%s]", courseTarget.getTargetName(),
|
|
|
|
+ String.valueOf(checkEvaluationCustomTotalWeight) + '%', "100%"));
|
|
|
|
+ } else if (checkEvaluationTotalWeightCompareResult < 0) {
|
|
|
|
+ errorMsgList.add(String.format("课程目标[%s]下评价方式的总权重为[%s],低于[%s]", courseTarget.getTargetName(),
|
|
|
|
+ String.valueOf(checkEvaluationCustomTotalWeight) + '%', "100%"));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- // 数据校验2:各课程目标下评价方式的总权重应等于100%;
|
|
|
|
- int checkEvaluationTotalWeightCompareResult = checkEvaluationTotalWeight.compareTo(new BigDecimal(100));
|
|
|
|
- if (checkEvaluationTotalWeightCompareResult > 0) {
|
|
|
|
- errorMsgList.add(
|
|
|
|
- String.format("所有课程目标下评价方式的总权重为[%s],超过[%s]", String.valueOf(checkEvaluationTotalWeight) + '%',
|
|
|
|
- "100%"));
|
|
|
|
- } else if (checkEvaluationTotalWeightCompareResult < 0) {
|
|
|
|
- errorMsgList.add(
|
|
|
|
- String.format("所有课程目标下评价方式的总权重为[%s],低于[%s]", String.valueOf(checkEvaluationTotalWeight) + '%',
|
|
|
|
- "100%"));
|
|
|
|
|
|
+ // 数据校验1:默认和自定义的权重合为100;
|
|
|
|
+ if (defaultRate.add(customRate).compareTo(new BigDecimal(100)) != 0) {
|
|
|
|
+ errorMsgList.add("平时成绩权重和期末成绩权重之和不为100%");
|
|
}
|
|
}
|
|
|
|
|
|
// 数据校验3:目标整体权重应等于100%,用于计算课程整体达成度。
|
|
// 数据校验3:目标整体权重应等于100%,用于计算课程整体达成度。
|
|
@@ -229,6 +260,8 @@ public class CourseWeightServiceImpl extends ServiceImpl<CourseWeightMapper, Cou
|
|
this.saveBatch(courseWeightList);
|
|
this.saveBatch(courseWeightList);
|
|
// 更新课程权重设置状态
|
|
// 更新课程权重设置状态
|
|
teachCourse.setWeightSetting(true);
|
|
teachCourse.setWeightSetting(true);
|
|
|
|
+ teachCourse.setDefaultRate(defaultRate);
|
|
|
|
+ teachCourse.setCustomRate(customRate);
|
|
teachCourseService.updateById(teachCourse);
|
|
teachCourseService.updateById(teachCourse);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -240,6 +273,10 @@ public class CourseWeightServiceImpl extends ServiceImpl<CourseWeightMapper, Cou
|
|
courseTargetUpdateWrapper.lambda().eq(CourseTarget::getTeachCourseId, teachCourseId)
|
|
courseTargetUpdateWrapper.lambda().eq(CourseTarget::getTeachCourseId, teachCourseId)
|
|
.set(CourseTarget::getTotalWeight, null);
|
|
.set(CourseTarget::getTotalWeight, null);
|
|
courseTargetService.update(courseTargetUpdateWrapper);
|
|
courseTargetService.update(courseTargetUpdateWrapper);
|
|
|
|
+
|
|
|
|
+ UpdateWrapper<TeachCourse> teachCourseUpdateWrapper = new UpdateWrapper<>();
|
|
|
|
+ teachCourseUpdateWrapper.lambda().eq(TeachCourse::getId, teachCourseId).set(TeachCourse::getDefaultRate, null).set(TeachCourse::getCustomRate, null);
|
|
|
|
+ teachCourseService.update(teachCourseUpdateWrapper);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|