caozixuan 4 lat temu
rodzic
commit
263459c887

+ 82 - 0
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/bean/dto/CombineDto.java

@@ -0,0 +1,82 @@
+package com.qmth.teachcloud.report.business.bean.dto;
+
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+
+public class CombineDto {
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long examId;
+    private String courseCode;
+    private String orgMain1;
+    private String orgSub1;
+    private String orgMain2;
+    private String orgSub2;
+    private String comMain;
+    private String comSub;
+
+    public Long getExamId() {
+        return examId;
+    }
+
+    public void setExamId(Long examId) {
+        this.examId = examId;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getOrgMain1() {
+        return orgMain1;
+    }
+
+    public void setOrgMain1(String orgMain1) {
+        this.orgMain1 = orgMain1;
+    }
+
+    public String getOrgSub1() {
+        return orgSub1;
+    }
+
+    public void setOrgSub1(String orgSub1) {
+        this.orgSub1 = orgSub1;
+    }
+
+    public String getOrgMain2() {
+        return orgMain2;
+    }
+
+    public void setOrgMain2(String orgMain2) {
+        this.orgMain2 = orgMain2;
+    }
+
+    public String getOrgSub2() {
+        return orgSub2;
+    }
+
+    public void setOrgSub2(String orgSub2) {
+        this.orgSub2 = orgSub2;
+    }
+
+    public String getComMain() {
+        return comMain;
+    }
+
+    public void setComMain(String comMain) {
+        this.comMain = comMain;
+    }
+
+    public String getComSub() {
+        return comSub;
+    }
+
+    public void setComSub(String comSub) {
+        this.comSub = comSub;
+    }
+}

+ 0 - 1
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/templete/execute/AsyncDataCalculateTempleteService.java

@@ -70,7 +70,6 @@ public class AsyncDataCalculateTempleteService extends AsyncCalculateTaskTemplet
             tbTask.setRemark(exception);
             tbExamCourse.setPublishStatus(oldStatus);
         }finally {
-
             tbExamCourseService.updateById(tbExamCourse);
             if (Objects.isNull(exception)){
                 cacheService.removeExamStudentReportCache();

+ 68 - 4
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/BasicDatasourceController.java

@@ -21,6 +21,7 @@ import com.qmth.teachcloud.common.util.ExcelUtil;
 import com.qmth.teachcloud.common.util.JacksonUtil;
 import com.qmth.teachcloud.common.util.Result;
 import com.qmth.teachcloud.common.util.ResultUtil;
+import com.qmth.teachcloud.report.business.bean.dto.CombineDto;
 import com.qmth.teachcloud.report.business.bean.dto.excel.*;
 import com.qmth.teachcloud.report.business.bean.dto.query.*;
 import com.qmth.teachcloud.report.business.entity.*;
@@ -31,10 +32,7 @@ import com.qmth.teachcloud.report.business.service.*;
 import io.swagger.annotations.*;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.LinkedMultiValueMap;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
@@ -1022,6 +1020,72 @@ public class BasicDatasourceController {
         return ResultUtil.ok("有【" + count + "】条缺考学生数据被更新");
     }
 
+    @ApiOperation(value = "特殊科目合并题目处理")
+    @RequestMapping(value = "/special/combine", method = RequestMethod.POST)
+    @Transactional(rollbackFor = Exception.class)
+    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    public Result specialCombine(@RequestBody CombineDto combineDto) {
+
+        Long examId = combineDto.getExamId();
+        String courseCode = combineDto.getCourseCode();
+        String orgMain1 = combineDto.getOrgMain1();
+        String orgSub1 = combineDto.getOrgSub1();
+        String orgMain2 = combineDto.getOrgMain2();
+        String orgSub2 = combineDto.getOrgSub2();
+        String comMain = combineDto.getComMain();
+        String comSub = combineDto.getComSub();
+        // TODO: 2021/6/25 合题的检验
+        TBPaper tbPaper = tbPaperService.getOne(new QueryWrapper<TBPaper>().lambda().eq(TBPaper::getExamId,examId).eq(TBPaper::getCourseCode,courseCode));
+        Long paperId = tbPaper.getId();
+        List<TBExamRecord> tbExamRecordList = tbExamRecordService.list(new QueryWrapper<TBExamRecord>().lambda().eq(TBExamRecord::getExamId,examId).eq(TBExamRecord::getPaperId,paperId));
+        List<Long> examRecordIdList = tbExamRecordList.stream().map(TBExamRecord::getId).distinct().collect(Collectors.toList());
+
+        List<TBAnswer> tbAnswerList = tbAnswerService.list(new QueryWrapper<TBAnswer>().lambda().in(TBAnswer::getExamRecordId,examRecordIdList));
+
+        List<Long> willDeleteList = new ArrayList<>();
+        List<TBAnswer> willInsertList = new ArrayList<>();
+        for (Long examRecordId : examRecordIdList) {
+            List<TBAnswer> oneStudentAnswerList = tbAnswerList.stream().filter(e -> e.getExamRecordId().equals(examRecordId)).collect(Collectors.toList());
+            if (oneStudentAnswerList.size() == 0){
+                continue;
+            }
+            // 原始1题
+            TBAnswer org1 = oneStudentAnswerList.stream()
+                    .filter(e -> e.getMainNumber().equals(orgMain1) && e.getSubNumber().equals(orgSub1))
+                    .collect(Collectors.toList()).get(0);
+            Long org1Id = org1.getId();
+            BigDecimal org1Score = org1.getScore();
+
+            // 原始2题
+            TBAnswer org2 = oneStudentAnswerList.stream()
+                    .filter(e -> e.getMainNumber().equals(orgMain2) && e.getSubNumber().equals(orgSub2))
+                    .collect(Collectors.toList()).get(0);
+
+            Long org2Id = org2.getId();
+            BigDecimal org2Score = org2.getScore();
+            if (!org1.getNumberType().equals(org2.getNumberType())){
+                throw ExceptionResultEnum.ERROR.exception("题目类型不一致 合题失败");
+            }
+
+            BigDecimal comboScore = org1Score.add(org2Score);
+            TBAnswer combo = new TBAnswer();
+            combo.setId(SystemConstant.getDbUuid());
+            combo.setExamRecordId(examRecordId);
+            combo.setNumberType(org1.getNumberType());
+            combo.setMainNumber(comMain);
+            combo.setSubNumber(comSub);
+            combo.setScore(comboScore);
+
+            willInsertList.add(combo);
+
+            willDeleteList.add(org1Id);
+            willDeleteList.add(org2Id);
+        }
+        tbAnswerService.removeByIds(willDeleteList);
+        tbAnswerService.saveBatch(willInsertList);
+        return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
+    }
+
 
 
     /**

+ 12 - 15
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/CourseController.java

@@ -168,10 +168,10 @@ public class CourseController {
             throw ExceptionResultEnum.NOT_LOGIN.exception();
         }
         Long collegeId = sysUser.getOrgId();
-        if (Objects.isNull(collegeId)){
+        if (Objects.isNull(collegeId)) {
             throw ExceptionResultEnum.ERROR.exception("学院id不存在");
         }
-        return ResultUtil.ok(courseReportService.findInfoInspectCourseExamTotal(Objects.isNull(schoolId) ? tmp : SystemConstant.convertIdToLong(schoolId), semester, SystemConstant.convertIdToLong(examId),collegeId));
+        return ResultUtil.ok(courseReportService.findInfoInspectCourseExamTotal(Objects.isNull(schoolId) ? tmp : SystemConstant.convertIdToLong(schoolId), semester, SystemConstant.convertIdToLong(examId), collegeId));
     }
 
     @ApiOperation(value = "考查课程考试分析接口")
@@ -228,20 +228,17 @@ public class CourseController {
             @ApiParam(value = "考试id", required = true) @RequestParam String examId,
             @ApiParam(value = "科目编码", required = true) @RequestParam String courseCode,
             @ApiParam(value = "赋分系数", required = true) @RequestParam BigDecimal coefficient) {
-        if (coefficient.compareTo(BigDecimal.ZERO) != 0) {
-            List<TBPaper> tbPaperList = tbPaperService.list(new QueryWrapper<TBPaper>().lambda()
-                    .eq(TBPaper::getExamId, examId).eq(TBPaper::getCourseCode, courseCode));
-
-            for (TBPaper tbPaper : tbPaperList) {
-                tbPaper.setCoefficient(coefficient);
-            }
-            tbPaperService.updateBatchById(tbPaperList);
-
-            Map<String, Object> map = tbTaskService.saveTask(TaskTypeEnum.DATA_CALCULATE);
-            map.put("examId", examId);
-            map.put("courseCode", courseCode);
-            asyncDataCalculateTempleteService.calculateTask(map);
+
+        List<TBPaper> tbPaperList = tbPaperService.list(new QueryWrapper<TBPaper>().lambda()
+                .eq(TBPaper::getExamId, examId).eq(TBPaper::getCourseCode, courseCode));
+        for (TBPaper tbPaper : tbPaperList) {
+            tbPaper.setCoefficient(coefficient);
         }
+        tbPaperService.updateBatchById(tbPaperList);
+        Map<String, Object> map = tbTaskService.saveTask(TaskTypeEnum.DATA_CALCULATE);
+        map.put("examId", examId);
+        map.put("courseCode", courseCode);
+        asyncDataCalculateTempleteService.calculateTask(map);
         return ResultUtil.ok();
     }