wangliang 7 ماه پیش
والد
کامیت
0098ebff28
1فایلهای تغییر یافته به همراه12 افزوده شده و 18 حذف شده
  1. 12 18
      teachcloud-obe/src/main/java/com/qmth/teachcloud/obe/service/impl/TCPaperStructServiceImpl.java

+ 12 - 18
teachcloud-obe/src/main/java/com/qmth/teachcloud/obe/service/impl/TCPaperStructServiceImpl.java

@@ -85,15 +85,13 @@ public class TCPaperStructServiceImpl extends ServiceImpl<TCPaperStructMapper, T
     @Override
     @Transactional
     public Boolean remove(Long cultureProgramId, Long courseId, String paperNumber, Long examId) {
-        QueryWrapper<TCPaperStruct> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(TCPaperStruct::getCultureProgramId, cultureProgramId).eq(TCPaperStruct::getCourseId, courseId);
-        if (Objects.nonNull(paperNumber)) {
-            queryWrapper.lambda().and(w -> w.eq(TCPaperStruct::getPaperNumber, paperNumber).or().isNull(TCPaperStruct::getPaperNumber));
-        }
-        if (Objects.nonNull(examId)) {
-            queryWrapper.lambda().eq(TCPaperStruct::getExamId, examId);
+        TCPaperStruct tcPaperStruct = this.queryPaperStruct(cultureProgramId, courseId, paperNumber, examId);
+        if (Objects.nonNull(tcPaperStruct)) {
+            tcPaperStructService.removeById(tcPaperStruct.getId());
+        } else {
+            return false;
         }
-        return tcPaperStructService.remove(queryWrapper);
+        return true;
     }
 
     /**
@@ -168,9 +166,6 @@ 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("导入的试卷结构不一致,请检查");
@@ -179,12 +174,7 @@ public class TCPaperStructServiceImpl extends ServiceImpl<TCPaperStructMapper, T
                     if (Objects.nonNull(tcPaperStructDb) && Objects.nonNull(tcPaperStructDb.getPaperStructDimension())) {
                         tcPaperStruct.updateInfo(tcPaperStructDb.getPaperStructDimension(), sysUser.getId());
                     }
-                    if (Objects.nonNull(tcPaperStructDb)) {
-                        tcPaperStructService.removeById(tcPaperStructDb.getId());
-                    } else {
-                        tcPaperStructService.remove(cultureProgramId, courseId, paperNumber, examId);
-                        tcPaperStructService.remove(cultureProgramId, courseId, null, null);
-                    }
+                    tcPaperStructService.remove(cultureProgramId, courseId, paperNumber, examId);
                     tcPaperStructService.save(tcPaperStruct);
                 }
             }
@@ -317,7 +307,11 @@ public class TCPaperStructServiceImpl extends ServiceImpl<TCPaperStructMapper, T
         if (Objects.nonNull(examId)) {
             queryWrapper.lambda().eq(TCPaperStruct::getExamId, examId);
         }
-        return tcPaperStructService.getOne(queryWrapper);
+        TCPaperStruct tcPaperStruct = tcPaperStructService.getOne(queryWrapper);
+        if (Objects.isNull(tcPaperStruct)) {
+            tcPaperStruct = tcPaperStructService.getOne(new QueryWrapper<TCPaperStruct>().lambda().eq(TCPaperStruct::getCultureProgramId, cultureProgramId).eq(TCPaperStruct::getCourseId, courseId));
+        }
+        return tcPaperStruct;
     }
 
     /**