Parcourir la source

Merge remote-tracking branch 'origin/dev_v2.1.0' into dev_v2.1.0

wangliang il y a 4 ans
Parent
commit
4efac48c9c

+ 4 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/SysUserServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.teachcloud.common.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -264,6 +265,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         boolean isSuccess = true;
         try {
             Long schoolId = Objects.nonNull(ServletUtil.getRequestHeaderSchoolIdByNotVaild()) ? Long.valueOf(ServletUtil.getRequestHeaderSchoolIdByNotVaild().toString()) : null;
+            if (schoolId == null){
+                schoolId = userSaveParams.getSchoolId();
+            }
             SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
             Gson gson = new Gson();
             userSaveParams.setSchoolId(schoolId);

+ 19 - 19
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/AnalyzeForReportServiceImpl.java

@@ -527,7 +527,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
             // 考察点数据源
             List<TBDimension> dimensionDatasource = tbDimensionService.list(new QueryWrapper<TBDimension>().lambda()
                     .eq(TBDimension::getExamId, examId)
-                    .eq(TBDimension::getCourseCode, courseCode));
+                    .eq(TBDimension::getCourseCode, effectiveCourseCode));
 
             if (dimensionDatasource.size() < 1) {
                 continue;
@@ -544,11 +544,11 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
 
             taExamCourseRecordModService.remove(new QueryWrapper<TAExamCourseRecordMod>().lambda()
                     .eq(TAExamCourseRecordMod::getExamId, examId)
-                    .eq(TAExamCourseRecordMod::getCourseCode, courseCode));
+                    .eq(TAExamCourseRecordMod::getCourseCode, effectiveCourseCode));
 
             List<TBPaper> tbPaperList = tbPaperService.list(new QueryWrapper<TBPaper>().lambda()
                     .eq(TBPaper::getExamId, examId)
-                    .eq(TBPaper::getCourseCode, courseCode));
+                    .eq(TBPaper::getCourseCode, effectiveCourseCode));
 
             if (tbPaperList.size() == 0) {
                 throw ExceptionResultEnum.ERROR.exception("试卷基础数据查找失败");
@@ -569,10 +569,10 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                 }
 
                 // 5.计算每个考察点所对应的题目集合
-                Map<String, List<TBPaperStruct>> pointToPaper = this.handlePointToPaper(dimensionDatasource, tbPaperStructList, examId, courseCode);
+                Map<String, List<TBPaperStruct>> pointToPaper = this.handlePointToPaper(dimensionDatasource, tbPaperStructList, examId, effectiveCourseCode);
 
                 // 计算每个模块对应的题目集合
-                Map<String, List<TBPaperStruct>> moduleToPaper = this.handleModuleToPaper(dimensionDatasource, tbPaperStructList, examId, courseCode);
+                Map<String, List<TBPaperStruct>> moduleToPaper = this.handleModuleToPaper(dimensionDatasource, tbPaperStructList, examId, effectiveCourseCode);
 
                 // 6.计算每个考察点在此次考试所占分数
                 Map<String, Object> everyPointTotalScore = this.handleEveryPointTotalScore(pointToPaper);
@@ -726,7 +726,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                     taExamCourseDio.setExamId(examId);
                     taExamCourseDio.setSchoolId(tbExamService.getById(examId).getSchoolId());
                     taExamCourseDio.setCourseCode(effectiveCourseCode);
-                    taExamCourseDio.setCourseName(basicCourseService.findByCourseCode(courseCode).getName());
+                    taExamCourseDio.setCourseName(basicCourseService.findByCourseCode(effectiveCourseCode).getName());
                     taExamCourseDio.setPaperId(paperId);
                     taExamCourseDio.setDimensionType(dimensionType);
                     taExamCourseDio.setDimensionCode(dimensionCode);
@@ -748,7 +748,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
             for (TAExamCourseRecordMod taExamCourseRecordMod : examCourseRecordModList) {
                 String moduleType = taExamCourseRecordMod.getModuleType();
                 Long myCollegeId = taExamCourseRecordMod.getInspectCollegeId();
-                List<TAExamCourseRecordMod> sameColModuleList = examCourseRecordModList.stream().filter(e -> e.getInspectCollegeId().equals(myCollegeId)).collect(Collectors.toList()); // 同学院下学生该模块数据
+                List<TAExamCourseRecordMod> sameColModuleList = examCourseRecordModList.stream().filter(e -> e.getInspectCollegeId().equals(myCollegeId) && moduleType.equals(e.getModuleType())).collect(Collectors.toList()); // 同学院下学生该模块数据
 
                 // 计算模块得分率在学院的排名和排名等级
                 double size = sameColModuleList.size();
@@ -782,7 +782,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                         if (!formula.equals(LevelRuleEnum.COLLEGE_RANK.getValue())) {  // 当计算规则不为学院排名时,为了方便计算,将minNumber设置为1 使其无效
                             size = -1;
                         }
-                        taExamCourseRecordMod.setLevel(this.handleModuleRankLevel(examId, courseCode, moduleType, value, size));
+                        taExamCourseRecordMod.setLevel(this.handleModuleRankLevel(examId, effectiveCourseCode, moduleType, value, size));
                     }
                 }
             }
@@ -803,7 +803,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                     .eq(TAExamCourseCollegeInspectDio::getExamId, examId)
                     .eq(TAExamCourseCollegeInspectDio::getCourseCode, effectiveCourseCode));
 
-            taExamCourseCollegeInspectDioService.insertByTAExamCourseRecordDio(examId, courseCode);
+            taExamCourseCollegeInspectDioService.insertByTAExamCourseRecordDio(examId, effectiveCourseCode);
         }
         return "'t_a_exam_course_college_inspect_dio'表构建完成 ";
     }
@@ -825,7 +825,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                     .eq(TAPaperStruct::getCourseCode, effectiveCourseCode));
             List<TAPaperStruct> taPaperStructList = new ArrayList<>();
             // 该课程有效试卷结构数据
-            List<ValidAnswerDetailDto> answerDetailDtoList = tbAnswerService.findValid(examId, courseCode);
+            List<ValidAnswerDetailDto> answerDetailDtoList = tbAnswerService.findValid(examId, effectiveCourseCode);
             for (TBPaper tbPaper : tbPaperList) {
                 Long paperId = tbPaper.getId();
                 String paperType = tbPaper.getPaperType();
@@ -851,7 +851,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                     double scoreAvg = descriptiveStatistics.getAverage();
                     BigDecimal scoreRate = BigDecimal.valueOf(scoreAvg).divide(fullScore, 4, BigDecimal.ROUND_HALF_DOWN);
                     scoreRate = scoreRate.setScale(1, BigDecimal.ROUND_HALF_DOWN);
-                    String difficult = this.analyzeDifficult(examId, courseCode, scoreRate.doubleValue());
+                    String difficult = this.analyzeDifficult(examId, effectiveCourseCode, scoreRate.doubleValue());
 
                     double validity = this.calculateValidity(oneQuestionAnswerDetailList, fullScore.doubleValue());
 
@@ -860,8 +860,8 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                     taPaperStruct.setPaperStructId(paperStruct.getId());
                     taPaperStruct.setExamId(examId);
                     taPaperStruct.setSchoolId(tbExamService.getById(examId).getSchoolId());
-                    taPaperStruct.setCourseCode(courseCode);
-                    taPaperStruct.setCourseName(basicCourseService.findByCourseCode(courseCode).getName());
+                    taPaperStruct.setCourseCode(effectiveCourseCode);
+                    taPaperStruct.setCourseName(basicCourseService.findByCourseCode(effectiveCourseCode).getName());
                     taPaperStruct.setPaperId(paperId);
                     taPaperStruct.setQuestionName(paperStruct.getQuestionName());
                     taPaperStruct.setNumberType(paperStruct.getNumberType());
@@ -896,7 +896,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
         for (String effectiveCourseCode : effectiveCourseCodeList) {
             taExamCourseDifficultService.remove(new QueryWrapper<TAExamCourseDifficult>().lambda()
                     .eq(TAExamCourseDifficult::getExamId, examId)
-                    .eq(TAExamCourseDifficult::getCourseCode, courseCode));
+                    .eq(TAExamCourseDifficult::getCourseCode, effectiveCourseCode));
 
             List<TAExamCourseDifficult> taExamCourseDifficultList = new ArrayList<>();
 
@@ -906,7 +906,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
             List<TAPaperStruct> questionDatasource = taPaperStructService.list(new QueryWrapper<TAPaperStruct>().lambda()
                     .eq(TAPaperStruct::getExamId, examId).eq(TAPaperStruct::getCourseCode, effectiveCourseCode));// 该科目试题情况数据源
 
-            LinkedList<AnswerDetailBean> answerDetailDatasource = tbAnswerService.findValidAnswerDetailWithPap(examId, courseCode);
+            LinkedList<AnswerDetailBean> answerDetailDatasource = tbAnswerService.findValidAnswerDetailWithPap(examId, effectiveCourseCode);
             Set<Long> paperTypeList = questionDatasource.stream().map(TAPaperStruct::getPaperId).collect(Collectors.toSet());
 
             for (Long paperId : paperTypeList) {
@@ -929,7 +929,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
                     // 学院id集合
                     List<Long> collegeIdList = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
                             .eq(TAExamCourseRecord::getExamId, examId)
-                            .eq(TAExamCourseRecord::getCourseCode, courseCode)
+                            .eq(TAExamCourseRecord::getCourseCode, effectiveCourseCode)
                             .eq(TAExamCourseRecord::getPaperId, paperId)
                             .eq(TAExamCourseRecord::getAbsent, false)
                             .eq(TAExamCourseRecord::getStudentCurrent, true))
@@ -1055,13 +1055,13 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
             // 删除该课程原有分析
             taExamCourseCollegeTeacherService.remove(new QueryWrapper<TAExamCourseCollegeTeacher>().lambda()
                     .eq(TAExamCourseCollegeTeacher::getExamId, examId)
-                    .eq(TAExamCourseCollegeTeacher::getCourseCode, courseCode));
+                    .eq(TAExamCourseCollegeTeacher::getCourseCode, effectiveCourseCode));
 
             List<TAExamCourseCollegeTeacher> taExamCourseCollegeTeacherList = new ArrayList<>();
             // 整体该课程下数据源
             List<TAExamCourseRecord> dataSource = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()
                     .eq(TAExamCourseRecord::getExamId, examId)
-                    .eq(TAExamCourseRecord::getCourseCode, courseCode));
+                    .eq(TAExamCourseRecord::getCourseCode, effectiveCourseCode));
 
             // 考察学院
             Set<Long> inspectCollegeIdSet = dataSource.stream().map(TAExamCourseRecord::getInspectCollegeId).collect(Collectors.toSet());
@@ -1186,7 +1186,7 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
         for (String effectiveCourseCode : effectiveCourseCodeList) {
             taExamCourseTeacherService.remove(new QueryWrapper<TAExamCourseTeacher>().lambda()
                     .eq(TAExamCourseTeacher::getExamId, examId)
-                    .eq(TAExamCourseTeacher::getCourseCode, courseCode));
+                    .eq(TAExamCourseTeacher::getCourseCode, effectiveCourseCode));
 
             List<TAExamCourseTeacher> taExamCourseTeacherList = new ArrayList<>();
             List<TAExamCourseRecord> dataSource = taExamCourseRecordService.list(new QueryWrapper<TAExamCourseRecord>().lambda()

+ 11 - 8
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/TBExamCourseServiceImpl.java

@@ -63,23 +63,26 @@ public class TBExamCourseServiceImpl extends ServiceImpl<TBExamCourseMapper, TBE
     }
 
     @Override
-    public List<String> findEffectiveByExamId(Long examId, String courseCode) {
+    public List<String> findEffectiveByExamId(Long examId,String courseCode) {
+        List<PublishStatusEnum> publishStatusEnumList = new ArrayList<>();
+        publishStatusEnumList.add(PublishStatusEnum.UN_COMPUTE);
+        publishStatusEnumList.add(PublishStatusEnum.UN_PUBLISH);
 
         List<TBExamCourse> effectiveCourseList = this.list(new QueryWrapper<TBExamCourse>().lambda()
-                .eq(TBExamCourse::getExamId, examId)
-                .eq(TBExamCourse::getTestStatus, TestStatusEnum.UN_TEST)
-                .eq(TBExamCourse::getPublishStatus, PublishStatusEnum.UN_COMPUTE));
+                .eq(TBExamCourse::getExamId,examId)
+                .eq(TBExamCourse::getTestStatus,TestStatusEnum.UN_TEST)
+                .in(TBExamCourse::getPublishStatus,publishStatusEnumList));
 
-        if (effectiveCourseList.size() == 0) {
+        if (effectiveCourseList.size() == 0){
             throw ExceptionResultEnum.ERROR.exception("该考试目前没有任何课程可以分析");
         }
         List<String> effectCourseCodeList = new ArrayList<>();
-        if (courseCode != null && courseCode.length() > 0) {
-            if (!effectiveCourseList.stream().map(TBExamCourse::getCourseCode).collect(Collectors.toList()).contains(courseCode)) {
+        if (courseCode != null && courseCode.length() > 0){
+            if (!effectiveCourseList.stream().map(TBExamCourse::getCourseCode).collect(Collectors.toList()).contains(courseCode)){
                 throw ExceptionResultEnum.ERROR.exception("课程【" + courseCode + "】无法进行分析");
             }
             effectCourseCodeList.add(courseCode);
-        } else {
+        }else {
             effectCourseCodeList = effectiveCourseList.stream().map(TBExamCourse::getCourseCode).collect(Collectors.toList());
         }
         return effectCourseCodeList;

+ 95 - 18
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/BasicDatasourceController.java

@@ -27,7 +27,9 @@ import com.qmth.teachcloud.report.business.enums.ExamCloudDataEnum;
 import com.qmth.teachcloud.report.business.enums.NumberTypeEnum;
 import com.qmth.teachcloud.report.business.service.*;
 import com.qmth.teachcloud.common.util.Result;
+import io.netty.handler.codec.http.HttpRequest;
 import io.swagger.annotations.*;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -35,8 +37,11 @@ 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.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.util.WebUtils;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.*;
@@ -132,8 +137,8 @@ public class BasicDatasourceController {
                             continue;
                         }
                         BigDecimal coefficient = BigDecimal.ZERO;
-                        if (Objects.nonNull(paperConfigDto.getCoefficient()) && paperConfigDto.getCoefficient() instanceof Double) {
-                            coefficient = BigDecimal.valueOf((Double) paperConfigDto.getCoefficient());
+                        if (Objects.nonNull(paperConfigDto.getCoefficient())) {
+                            coefficient = BigDecimal.valueOf(Long.parseLong(String.valueOf(paperConfigDto.getCoefficient())));
                         }
                         String paperType = paperConfigDto.getPaperType();
                         List<TBPaper> oldList = tbPaperService.list(new QueryWrapper<TBPaper>().lambda()
@@ -344,12 +349,10 @@ public class BasicDatasourceController {
         }
         Set<String> moduleProficiencyRemove = tbModuleProficiencyList.stream().map(e -> e.getExamId() + SystemConstant.HYPHEN
                 + e.getCourseCode() + SystemConstant.HYPHEN
-                + e.getCourseName() + SystemConstant.HYPHEN
                 + e.getModuleType()).collect(Collectors.toSet());
 
         Set<String> moduleConfigRemove = tbModuleConfigList.stream().map(e -> e.getExamId() + SystemConstant.HYPHEN
                 + e.getCourseCode() + SystemConstant.HYPHEN
-                + e.getCourseName() + SystemConstant.HYPHEN
                 + e.getModuleType()).collect(Collectors.toSet());
 
         for (String s : moduleProficiencyRemove) {
@@ -357,16 +360,14 @@ public class BasicDatasourceController {
             tbModuleProficiencyService.remove(new QueryWrapper<TBModuleProficiency>().lambda()
                     .eq(TBModuleProficiency::getExamId, arr[0])
                     .eq(TBModuleProficiency::getCourseCode, arr[1])
-                    .eq(TBModuleProficiency::getCourseName, arr[2])
-                    .eq(TBModuleProficiency::getModuleType, arr[3]));
+                    .eq(TBModuleProficiency::getModuleType, arr[2]));
         }
         for (String s : moduleConfigRemove) {
             String[] arr = s.split(SystemConstant.HYPHEN);
             tbModuleConfigService.remove(new QueryWrapper<TBModuleConfig>().lambda()
                     .eq(TBModuleConfig::getExamId, arr[0])
                     .eq(TBModuleConfig::getCourseCode, arr[1])
-                    .eq(TBModuleConfig::getCourseName, arr[2])
-                    .eq(TBModuleConfig::getModuleType, arr[3]));
+                    .eq(TBModuleConfig::getModuleType, arr[2]));
         }
         tbModuleProficiencyService.saveBatch(tbModuleProficiencyList);
         tbModuleConfigService.saveBatch(tbModuleConfigList);
@@ -443,12 +444,13 @@ public class BasicDatasourceController {
     public Result examAnswerImport(@ApiParam(value = "云阅卷考试id", required = true) @RequestParam Long id, @ApiParam(value = "云阅卷考试编号", required = false)
     @RequestParam(required = false) String cloudExamCode,
                                    @ApiParam(value = "教研分析将AB卷分开分析时自定义科目和卷形的连接符(连接符必须和’t_e_course‘表中的科目名称中连接符对应)")
-                                   @RequestParam(required = false) String linkSign, @RequestParam Long schoolId) throws IOException {
-        if (schoolId == null || schoolId == 0) {
-            throw ExceptionResultEnum.ERROR.exception("参数缺失");
-        }
+                                   @RequestParam(required = false) String linkSign, @RequestParam Long pSchoolId) throws IOException {
         TBExam tbExam = tbExamService.findByCloudExamId(id);
         Long examId = tbExam.getId();
+        Long schoolId = tbExamService.getById(examId).getSchoolId();
+        if (schoolId != pSchoolId){
+            throw ExceptionResultEnum.ERROR.exception("学校id不匹配");
+        }
 
         // 该考试要考察的所有课程
         List<TBExamCourse> tbExamCourseList = tbExamCourseService.list(new QueryWrapper<TBExamCourse>().lambda().eq(TBExamCourse::getExamId, examId));
@@ -595,7 +597,11 @@ public class BasicDatasourceController {
                 tbExamStudent.setInspectCollegeId(tbSchoolCollege.getId());
                 tbExamStudent.setClazzId(tbSchoolClazz.getId());
                 tbExamStudent.setMajorId(0L);
-                tbExamStudent.setTeacherId(tbSchoolTeacher.getId());
+                if (Objects.nonNull(tbSchoolTeacher)){
+                    tbExamStudent.setTeacherId(tbSchoolTeacher.getId());
+                }else {
+                    tbExamStudent.setTeacherId(0L);
+                }
                 tbExamStudent.setTicketNumber(examNumber);
                 tbExamStudent.setAbsent(status == 2);
                 // 全部设置为本届
@@ -655,13 +661,11 @@ public class BasicDatasourceController {
         tbStudentService.saveOrUpdateBatch(tbStudentList);
 
         // 删除原t_b_answer、t_b_exam_record、t_b_exam_student表数据
-        List<String> courseInfoList = tbExamStudentList.stream().map(e -> e.getCourseCode() + SystemConstant.HYPHEN + e.getCourseName()).collect(Collectors.toList());
+        List<String> courseInfoList = tbExamStudentList.stream().map(TBExamStudent::getCourseCode).collect(Collectors.toList());
         Set<Long> examStudentRemoveIdSet = new HashSet<>();
         for (String s : courseInfoList) {
-            String[] arr = s.split(SystemConstant.HYPHEN);
             Set<Long> ids = tbExamStudentService.list(new QueryWrapper<TBExamStudent>().lambda()
-                    .eq(TBExamStudent::getCourseCode, arr[0])
-                    .eq(TBExamStudent::getCourseName, arr[1]))
+                    .eq(TBExamStudent::getCourseCode, s))
                     .stream().map(TBExamStudent::getId).collect(Collectors.toSet());
             examStudentRemoveIdSet.addAll(ids);
         }
@@ -687,6 +691,76 @@ public class BasicDatasourceController {
         return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
     }
 
+    @ApiOperation(value = "公式赋分操作")
+    @RequestMapping(value = "/normal/assignScore", method = RequestMethod.POST)
+    @Transactional(rollbackFor = Exception.class)
+    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    public Result normalAssignScore(@RequestParam Long examId, @RequestParam Long schoolId, @RequestParam String courseCode) throws IOException, NoSuchFieldException {
+        List<String> courseCodeList = new ArrayList<>();
+        courseCodeList.add(courseCode);
+
+        // 数据同步操作
+        // 获取当前课程下所有学生考试成绩记录
+        List<BasicExamRecordDto> basicExamRecordDtoDatasource = tbExamRecordService.findByExamIdAndCourseCodeS(examId, courseCodeList);
+        for (String s : courseCodeList) {
+            if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, s, basicCourseService.findByCourseCode(s).getName())) {
+                throw ExceptionResultEnum.ERROR.exception("课程编号[" + s + "]的课程分析数据已测试或发布,不能变更基础数据");
+            }
+            List<BasicExamRecordDto> basicExamRecordDtoList = basicExamRecordDtoDatasource.stream()
+                    .filter(e -> s.equals(e.getCourseCode())).collect(Collectors.toList());
+            if (basicExamRecordDtoList.size() > 0) {
+                // 删除源数据
+                taExamCourseRecordService.remove(new QueryWrapper<TAExamCourseRecord>()
+                        .lambda().eq(TAExamCourseRecord::getExamId, examId).eq(TAExamCourseRecord::getCourseCode, s));
+                // 迁移数据至't_a_exam_course_record'
+                List<TAExamCourseRecord> taExamCourseRecordList = new ArrayList<>();
+                for (BasicExamRecordDto basicExamRecordDto : basicExamRecordDtoList) {
+                    boolean absent = basicExamRecordDto.getAbsent();
+                    // 正常公式赋分操作
+                    Long paperId = basicExamRecordDto.getPaperId();
+                    TBPaper tbPaper = tbPaperService.getById(paperId);
+                    if (Objects.isNull(tbPaper)) {
+                        throw ExceptionResultEnum.ERROR.exception("试卷信息数据异常");
+                    }
+                    BigDecimal fullScore = tbPaper.getTotalScore();
+                    BigDecimal myScore = basicExamRecordDto.getTotalScore();
+                    BigDecimal coefficient = tbPaper.getCoefficient();
+                    BigDecimal assignScore;
+                    // 当该试卷的赋分系数不为0时赋分
+                    if (coefficient != null && coefficient.compareTo(BigDecimal.ZERO) > 0 && !absent) {
+                        assignScore = myScore.add(fullScore.subtract(myScore).divide(coefficient, 0, BigDecimal.ROUND_HALF_DOWN));
+                    } else {
+                        assignScore = myScore;
+                    }
+
+                    TAExamCourseRecord taExamCourseRecord = new TAExamCourseRecord();
+                    taExamCourseRecord.setId(SystemConstant.getDbUuid());
+                    taExamCourseRecord.setExamRecordId(basicExamRecordDto.getTbExamRecordId());
+                    // 数据同步默认赋分成绩为卷面成绩
+                    taExamCourseRecord.setSchoolId(tbExamService.getById(examId).getSchoolId());
+                    taExamCourseRecord.setAssignedScore(assignScore);
+                    taExamCourseRecord.setExamId(examId);
+                    taExamCourseRecord.setCourseCode(basicExamRecordDto.getCourseCode());
+                    taExamCourseRecord.setPaperId(basicExamRecordDto.getPaperId());
+                    taExamCourseRecord.setPaperType(basicExamRecordDto.getPaperType());
+                    taExamCourseRecord.setStudentId(basicExamRecordDto.getStudentId());
+                    taExamCourseRecord.setStudentCode(basicExamRecordDto.getStudentCode());
+                    taExamCourseRecord.setTeacherId(basicExamRecordDto.getTeacherId());
+                    taExamCourseRecord.setClazzId(basicExamRecordDto.getClazzId());
+                    taExamCourseRecord.setTeachCollegeId(basicExamRecordDto.getTeachCollegeId());
+                    taExamCourseRecord.setInspectCollegeId(basicExamRecordDto.getInspectCollegeId());
+                    taExamCourseRecord.setMajorId(basicExamRecordDto.getMajorId());
+                    taExamCourseRecord.setTotalScore(myScore);
+                    taExamCourseRecord.setAbsent(absent);
+                    taExamCourseRecord.setStudentCurrent(basicExamRecordDto.getStudentCurrent());
+                    taExamCourseRecordList.add(taExamCourseRecord);
+                }
+                taExamCourseRecordService.saveBatch(taExamCourseRecordList);
+            }
+        }
+        return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
+    }
+
     @ApiOperation(value = "特殊科目赋分操作")
     @RequestMapping(value = "/special/assignScore", method = RequestMethod.POST)
     @Transactional(rollbackFor = Exception.class)
@@ -722,7 +796,7 @@ public class BasicDatasourceController {
                     BigDecimal myScore = basicExamRecordDto.getTotalScore();
                     BigDecimal coefficient = tbPaper.getCoefficient();
                     BigDecimal assignScore;
-                    if (coefficient != null && coefficient.compareTo(BigDecimal.ZERO) > 0) {
+                    if (coefficient != null && coefficient.compareTo(BigDecimal.ZERO) > 0 && !basicExamRecordDto.getAbsent()) {
                         assignScore = myScore.add(fullScore.subtract(myScore).divide(coefficient, 0, BigDecimal.ROUND_HALF_DOWN));
                     } else {
                         assignScore = myScore;
@@ -784,6 +858,9 @@ public class BasicDatasourceController {
                                     .filter(e -> assExamId.equals(e.getExamId()) && s.equals(e.getCourseCode()) && assStudentCode.equals(e.getStudentCode()))
                                     .collect(Collectors.toList());
                             if (taExamCourseRecordList.size() != 1) {
+                                if (taExamCourseRecordList.size() < 1){
+                                    continue;
+                                }
                                 System.out.println("-----------------------");
                                 System.out.println(JSON.toJSONString(taExamCourseRecordList));
                                 throw ExceptionResultEnum.ERROR.exception("赋分异常,考生记录分析表数据异常");

+ 3 - 3
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/DataAnalyzeController.java

@@ -19,9 +19,9 @@ import javax.annotation.Resource;
 import java.util.Collections;
 
 /**
- * @Description:
+ * @Description: 数据计算控制类
  * @Author: CaoZixuan
- * @Date:
+ * @Date: 2021-06-15
  */
 @Api(tags = "数据源分析计算controller")
 @RestController
@@ -34,7 +34,7 @@ public class DataAnalyzeController {
     @RequestMapping(value = "/calculate", method = RequestMethod.POST)
     @Transactional(rollbackFor = Exception.class)
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
-    public Result dataCalculate(@RequestParam Long schoolId, @RequestParam Long examId, @RequestParam String courseCode) throws Exception {
+    public Result dataCalculate(@RequestParam Long schoolId, @RequestParam Long examId, @RequestParam(required = false) String courseCode) throws Exception {
         analyzeForReportService.buildAnalyzeExamCourse(examId,courseCode);
         analyzeForReportService.buildAnalyzeExamCourseRecord(examId, courseCode);
         analyzeForReportService.buildAnalyzeExamCourseCollegeInspect(examId, courseCode);