ソースを参照

fix:期末成绩同步更改

caozixuan 1 年間 前
コミット
3e6cb393de

+ 23 - 18
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TCFinalScoreServiceImpl.java

@@ -20,6 +20,7 @@ import com.qmth.distributed.print.business.service.PrintCommonService;
 import com.qmth.distributed.print.business.service.TCFinalScoreService;
 import com.qmth.distributed.print.business.service.TCPaperStructService;
 import com.qmth.distributed.print.business.service.TRBasicInfoService;
+import com.qmth.teachcloud.common.base.BaseEntity;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicCourse;
 import com.qmth.teachcloud.common.entity.SysUser;
@@ -310,34 +311,38 @@ public class TCFinalScoreServiceImpl extends ServiceImpl<TCFinalScoreMapper, TCF
                             String name = scoreItem.getMainNumber() + "-" + scoreItem.getSubNumber();
                             tcFinalScoreDtoList.add(new TCFinalScoreDto(scoreItem.getScore().toString(), name));
                             if (i == 0) {
-                                paperStructDimensionResultList.add(new PaperStructDimensionResult(scoreItem.getMainNumber(), scoreItem.getSubNumber(), examId, paperNumber, new BigDecimal(scoreItem.getTotalScore())));
+                                paperStructDimensionResultList.add(
+                                        new PaperStructDimensionResult(scoreItem.getMainNumber(), scoreItem.getSubNumber(), examId, paperNumber,
+                                                new BigDecimal(scoreItem.getTotalScore())));
                             }
                         }
-                        tcFinalScoreList.add(new TCFinalScore(markStudentScoreVo, JacksonUtil.parseJson(tcFinalScoreDtoList), SourceEnum.SYNC, sysUser.getId(), cultureProgramId, courseId));
+                        tcFinalScoreList.add(
+                                new TCFinalScore(markStudentScoreVo, JacksonUtil.parseJson(tcFinalScoreDtoList),
+                                        SourceEnum.SYNC, sysUser.getId(), cultureProgramId, courseId));
                     }
                 }
-                if (!CollectionUtils.isEmpty(tcFinalScoreList) && !CollectionUtils.isEmpty(paperStructDimensionResultList)) {
+                if (!CollectionUtils.isEmpty(tcFinalScoreList) && !CollectionUtils.isEmpty(
+                        paperStructDimensionResultList)) {
                     successData.add("共同步").add(tcFinalScoreList.size() + "").add("条数据");
-                    List<TCFinalScore> tcFinalScoreDbSourceList = tcFinalScoreService.queryFinalScore(cultureProgramId, courseId, paperNumber);
-                    if (CollectionUtils.isEmpty(tcFinalScoreDbSourceList) || !CollectionUtils.isEqualCollection(tcFinalScoreDbSourceList, tcFinalScoreList)) {
-                        tcFinalScoreService.removeByIds(tcFinalScoreDbSourceList.stream().map(s -> s.getId()).collect(Collectors.toList()));
+                    List<TCFinalScore> tcFinalScoreDbSourceList = tcFinalScoreService.queryFinalScore(cultureProgramId,
+                            courseId, null);
+                    if (CollectionUtils.isEmpty(tcFinalScoreDbSourceList) || !CollectionUtils.isEqualCollection(
+                            tcFinalScoreDbSourceList, tcFinalScoreList)) {
+                        tcFinalScoreService.removeByIds(
+                                tcFinalScoreDbSourceList.stream().map(BaseEntity::getId).collect(Collectors.toList()));
                         tcFinalScoreService.saveBatch(tcFinalScoreList);
                         trBasicInfoService.clearReportData(cultureProgramId, courseId, paperNumber, true);
                     }
-                    TCPaperStruct tcPaperStruct = tcPaperStructService.queryPaperStruct(cultureProgramId, courseId, paperNumber);
+                    TCPaperStruct tcPaperStruct = tcPaperStructService.queryPaperStruct(cultureProgramId, courseId, null);
                     if (Objects.nonNull(tcPaperStruct)) {
-                        tcPaperStruct.setPaperNumber(paperNumber);
-                        tcPaperStruct.setPaperStruct(JacksonUtil.parseJson(paperStructDimensionResultList));
-                        tcPaperStruct.updateInfo(sysUser.getId());
-                        tcPaperStructService.updateById(tcPaperStruct);
-                    } else {
-                        BasicCourse basicCourse = basicCourseService.getById(courseId);
-                        Objects.requireNonNull(basicCourse, "未找到基础课程信息");
-                        tcPaperStruct = new TCPaperStruct(cultureProgramId, courseId, basicCourse.getCode(), basicCourse.getName(), paperNumber, JacksonUtil.parseJson(paperStructDimensionResultList), sysUser.getId());
-                    }
-                    if (SystemConstant.longNotNull(examId)) {
-                        tcPaperStruct.setExamId(examId);
+                        tcPaperStructService.removeById(tcPaperStruct.getId());
                     }
+                    BasicCourse basicCourse = basicCourseService.getById(courseId);
+                    Objects.requireNonNull(basicCourse, "未找到基础课程信息");
+                    tcPaperStruct = new TCPaperStruct(cultureProgramId, courseId, basicCourse.getCode(), basicCourse.getName(), paperNumber, JacksonUtil.parseJson(paperStructDimensionResultList),
+                            sysUser.getId());
+                    tcPaperStruct.setExamId(examId);
+
                     tcPaperStructService.saveOrUpdate(tcPaperStruct);
                 }
             }

+ 2 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TCPaperStructServiceImpl.java

@@ -239,7 +239,7 @@ public class TCPaperStructServiceImpl extends ServiceImpl<TCPaperStructMapper, T
                     Collections.sort(paperStructDbList);
                     Collections.sort(paperStructList);
 
-                    tcFinalScoreService.remove(cultureProgramId, courseId, paperNumber);
+//                    tcFinalScoreService.remove(cultureProgramId, courseId, paperNumber);
                     trBasicInfoService.clearReportData(cultureProgramId, courseId, paperNumber, false);
                     tcPaperStruct.setPaperStruct(null);
                 }
@@ -258,7 +258,7 @@ public class TCPaperStructServiceImpl extends ServiceImpl<TCPaperStructMapper, T
                     Collections.sort(paperStructDbList);
                     Collections.sort(paperStructList);
 
-                    tcFinalScoreService.remove(cultureProgramId, courseId, paperNumber);
+//                    tcFinalScoreService.remove(cultureProgramId, courseId, paperNumber);
                     trBasicInfoService.clearReportData(cultureProgramId, courseId, paperNumber, false);
                 }
             }