|
@@ -3,17 +3,21 @@ package com.qmth.eds.api;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
|
+import com.qmth.eds.bean.result.AssignContrastResult;
|
|
|
import com.qmth.eds.bean.result.AssignResultPreviewResult;
|
|
|
import com.qmth.eds.bean.result.EditResult;
|
|
|
+import com.qmth.eds.bean.result.StudentMarkResult;
|
|
|
import com.qmth.eds.common.contant.SystemConstant;
|
|
|
import com.qmth.eds.common.entity.ExamAssign;
|
|
|
+import com.qmth.eds.common.entity.SysUser;
|
|
|
import com.qmth.eds.common.util.Result;
|
|
|
import com.qmth.eds.common.util.ResultUtil;
|
|
|
+import com.qmth.eds.common.util.ServletUtil;
|
|
|
+import com.qmth.eds.service.CloudMarkingScoreService;
|
|
|
+import com.qmth.eds.service.CommonService;
|
|
|
import com.qmth.eds.service.ExamAssignService;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import io.swagger.annotations.ApiResponse;
|
|
|
-import io.swagger.annotations.ApiResponses;
|
|
|
+import io.swagger.annotations.*;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -23,6 +27,11 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.validation.constraints.Max;
|
|
|
import javax.validation.constraints.Min;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -38,6 +47,12 @@ public class ExamAssignController {
|
|
|
@Resource
|
|
|
private ExamAssignService examAssignService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ CommonService commonService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ CloudMarkingScoreService cloudMarkingScoreService;
|
|
|
+
|
|
|
@ApiOperation(value = "分页查询")
|
|
|
@PostMapping("/page")
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = Result.class)})
|
|
@@ -71,20 +86,60 @@ public class ExamAssignController {
|
|
|
@ApiOperation(value = "计算结果查询")
|
|
|
@PostMapping("/result")
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = AssignResultPreviewResult.class)})
|
|
|
- public Result assignResultPreview(@RequestParam(value = "开课学院", required = false) String collegeName,
|
|
|
- @RequestParam(value = "班级id", required = false) String clazzId,
|
|
|
- @RequestParam(value = "任课老师工号", required = false) String teacherCode,
|
|
|
- @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
|
|
|
- @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
|
|
|
+ public Result assignResultPreview(@ApiParam(value = "开课学院", required = true) @RequestParam String collegeName,
|
|
|
+ @ApiParam(value = "班级id", required = true) @RequestParam String clazzId,
|
|
|
+ @ApiParam(value = "任课老师工号", required = true) @RequestParam String teacherCode,
|
|
|
+ @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
|
|
|
+ @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
|
|
|
return ResultUtil.ok(examAssignService.assignResultPreview(new Page<>(pageNumber, pageSize), collegeName, clazzId, teacherCode));
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "计算结果对比")
|
|
|
@PostMapping("/contrast")
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "保存/更新成功", response = EditResult.class)})
|
|
|
- public Result contrast(@RequestParam(value = "semesterId", required = false) Long semesterId,
|
|
|
- @RequestParam(value = "examTypeId", required = false) Long examTypeId,
|
|
|
- @RequestParam(value = "courseCode", required = false) String courseCode) {
|
|
|
- return ResultUtil.ok(examAssignService.contrast(semesterId, examTypeId, courseCode));
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "保存/更新成功", response = AssignContrastResult.class)})
|
|
|
+ public Result contrast(@ApiParam(value = "学期id", required = true) @RequestParam Long semesterId,
|
|
|
+ @ApiParam(value = "考试id", required = true) @RequestParam Long examId,
|
|
|
+ @ApiParam(value = "科目代码", required = true) @RequestParam String subjectCode,
|
|
|
+ @ApiParam(value = "开课学院", required = true) @RequestParam String collegeName,
|
|
|
+// @ApiParam(value = "卷面总分", required = true) @RequestParam BigDecimal surfaceScore,
|
|
|
+ @ApiParam(value = "及格分", required = true) @RequestParam BigDecimal passScore) {
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
+ Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
+ Set<String> subjectCodeSet = commonService.findCloudMarkSubjectCode(semesterId, examId, subjectCode);
|
|
|
+ List<StudentMarkResult> studentMarkResultList = cloudMarkingScoreService.queryStudentMark(schoolId, sysUser.getOrgId(), semesterId, examId, subjectCode, collegeName, subjectCodeSet);
|
|
|
+ AssignContrastResult assignContrastResult = null;
|
|
|
+ if (!CollectionUtils.isEmpty(studentMarkResultList)) {
|
|
|
+ BigDecimal assignBeforeSumScore = new BigDecimal(0), assignAfterSumScore = new BigDecimal(0), sumCount = new BigDecimal(studentMarkResultList.size());
|
|
|
+ Integer assignBeforeFailCount = 0, assignAfterFailCount = 0;
|
|
|
+ for (StudentMarkResult s : studentMarkResultList) {
|
|
|
+ //赋分前分数和不及格人数
|
|
|
+ if (Objects.nonNull(s.getTotalScore()) && !Objects.equals(s.getTotalScore().trim(), "")) {
|
|
|
+ BigDecimal totalScore = new BigDecimal(s.getTotalScore());
|
|
|
+ assignBeforeSumScore = assignBeforeSumScore.add(totalScore);
|
|
|
+ if (totalScore.compareTo(passScore) < 0) {
|
|
|
+ assignBeforeFailCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //赋分后分数和不及格人数
|
|
|
+ if (Objects.nonNull(s.getAssignScore()) && !Objects.equals(s.getAssignScore().trim(), "")) {
|
|
|
+ BigDecimal assignScore = new BigDecimal(s.getAssignScore());
|
|
|
+ assignAfterSumScore = assignAfterSumScore.add(assignScore);
|
|
|
+ if (assignScore.compareTo(passScore) < 0) {
|
|
|
+ assignAfterFailCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //赋分前平均分
|
|
|
+ BigDecimal assignBeforeAverageScore = assignBeforeSumScore.divide(sumCount, 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ //赋分前不及格率
|
|
|
+ BigDecimal assignBeforeFailRate = new BigDecimal(assignBeforeFailCount).divide(sumCount, 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ //赋分后平均分
|
|
|
+ BigDecimal assignAfterAverageScore = assignAfterSumScore.divide(sumCount, 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ //赋分后不及格率
|
|
|
+ BigDecimal assignAfterFailRate = new BigDecimal(assignAfterFailCount).divide(sumCount, 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ assignContrastResult = new AssignContrastResult(sumCount.intValue(), assignBeforeAverageScore, assignBeforeFailRate,
|
|
|
+ assignBeforeFailCount, assignAfterAverageScore, assignAfterAverageScore, assignAfterFailCount);
|
|
|
+ }
|
|
|
+ return ResultUtil.ok(Objects.isNull(assignContrastResult) ? new AssignContrastResult() : assignContrastResult);
|
|
|
}
|
|
|
}
|