wangliang 7 月之前
父節點
當前提交
3d86390d6d

+ 9 - 1
teachcloud-obe/src/main/java/com/qmth/teachcloud/obe/service/impl/TCPaperStructServiceImpl.java

@@ -168,6 +168,9 @@ public class TCPaperStructServiceImpl extends ServiceImpl<TCPaperStructMapper, T
                     paperStructDtoNewList = SDFrame.read(paperStructDtoNewList).sortDesc(Sorter.sortDescBy(PaperStructDto::getMainNumber).sortDesc(PaperStructDto::getMainNumber)).toLists();
                     TCPaperStruct tcPaperStruct = new TCPaperStruct(examId, cultureProgramId, courseId, markPaper.getCourseCode(), markPaper.getCourseName(), paperNumber, JacksonUtil.parseJson(paperStructDtoNewList), totalScore, 60d, sysUser.getId());
                     TCPaperStruct tcPaperStructDb = tcPaperStructService.queryPaperStruct(cultureProgramId, courseId, paperNumber, examId);
+                    if (Objects.isNull(tcPaperStructDb)) {
+                        tcPaperStructDb = tcPaperStructService.queryPaperStruct(cultureProgramId, courseId, null, null);
+                    }
                     if (Objects.nonNull(tcPaperStructDb) && !tcPaperStructDb.equals(tcPaperStruct)) {
                         if (Objects.nonNull(tcPaperStructDb.getPaperStruct()) && !Objects.equals(tcPaperStructDb.getPaperStruct(), tcPaperStruct.getPaperStruct())) {
                             throw ExceptionResultEnum.ERROR.exception("导入的试卷结构不一致,请检查");
@@ -176,7 +179,12 @@ public class TCPaperStructServiceImpl extends ServiceImpl<TCPaperStructMapper, T
                     if (Objects.nonNull(tcPaperStructDb) && Objects.nonNull(tcPaperStructDb.getPaperStructDimension())) {
                         tcPaperStruct.updateInfo(tcPaperStructDb.getPaperStructDimension(), sysUser.getId());
                     }
-                    tcPaperStructService.remove(cultureProgramId, courseId, paperNumber, examId);
+                    if (Objects.nonNull(tcPaperStructDb)) {
+                        tcPaperStructService.removeById(tcPaperStructDb.getId());
+                    } else {
+                        tcPaperStructService.remove(cultureProgramId, courseId, paperNumber, examId);
+                        tcPaperStructService.remove(cultureProgramId, courseId, null, null);
+                    }
                     tcPaperStructService.save(tcPaperStruct);
                 }
             }