Browse Source

试卷蓝图校验

wangliang 1 year ago
parent
commit
704f8b23fd

+ 18 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TCPaperStruct.java

@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
+import java.util.Objects;
 
 /**
  * <p>
@@ -167,4 +168,21 @@ public class TCPaperStruct implements Serializable {
     public void setUpdateTime(Long updateTime) {
         this.updateTime = updateTime;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        TCPaperStruct that = (TCPaperStruct) o;
+        return examId.equals(that.examId) && courseCode.equals(that.courseCode) && courseName.equals(that.courseName) && paperNumber.equals(that.paperNumber) && paperStruct.equals(that.paperStruct);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(examId, courseCode, courseName, paperNumber, paperStruct);
+    }
 }

+ 14 - 9
distributed-print/src/main/java/com/qmth/distributed/print/api/TCFinalScoreController.java

@@ -23,11 +23,11 @@ import com.qmth.teachcloud.mark.entity.MarkPaper;
 import com.qmth.teachcloud.mark.service.MarkPaperService;
 import com.qmth.teachcloud.mark.service.MarkQuestionService;
 import io.swagger.annotations.*;
+import org.apache.commons.collections4.CollectionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.CollectionUtils;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -242,18 +242,24 @@ public class TCFinalScoreController {
             }
         }
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        TCPaperStruct tcPaperStruct = tcPaperStructService.getOne(new QueryWrapper<TCPaperStruct>().lambda().eq(TCPaperStruct::getExamId, paperStructParams.getExamId()).eq(TCPaperStruct::getCourseCode, paperStructParams.getCourseCode()).eq(TCPaperStruct::getPaperNumber, paperStructParams.getPaperNumber()));
-        if (Objects.isNull(tcPaperStruct)) {
+        TCPaperStruct tcPaperStructDb = tcPaperStructService.getOne(new QueryWrapper<TCPaperStruct>().lambda().eq(TCPaperStruct::getExamId, paperStructParams.getExamId()).eq(TCPaperStruct::getCourseCode, paperStructParams.getCourseCode()).eq(TCPaperStruct::getPaperNumber, paperStructParams.getPaperNumber()));
+        if (Objects.isNull(tcPaperStructDb)) {
             MarkPaper markPaper = markPaperService.getByExamIdAndPaperNumber(paperStructParams.getExamId(), paperStructParams.getPaperNumber());
             Objects.requireNonNull(markPaper, "未找到科目信息");
 
-            tcPaperStruct = new TCPaperStruct(paperStructParams.getExamId(), paperStructParams.getCourseCode(), markPaper.getCourseName(), paperStructParams.getPaperNumber(), JacksonUtil.parseJson(paperStructParams.getPaperStruct()), sysUser.getId());
+            tcPaperStructDb = new TCPaperStruct(paperStructParams.getExamId(), paperStructParams.getCourseCode(), markPaper.getCourseName(), paperStructParams.getPaperNumber(), JacksonUtil.parseJson(paperStructParams.getPaperStruct()), sysUser.getId());
+            tcPaperStructService.save(tcPaperStructDb);
         } else {
-            tcPaperStruct.updateInfo(JacksonUtil.parseJson(paperStructParams.getPaperStruct()), sysUser.getId());
+            TCPaperStruct tcPaperStructSource = new TCPaperStruct();
+            BeanUtils.copyProperties(tcPaperStructDb, tcPaperStructSource);
+            tcPaperStructDb.updateInfo(JacksonUtil.parseJson(paperStructParams.getPaperStruct()), sysUser.getId());
+            if (!tcPaperStructDb.equals(tcPaperStructSource)) {
+                trExamStudentService.remove(paperStructParams.getExamId(), paperStructParams.getCourseCode(), paperStructParams.getPaperNumber());
+                trBasicInfoService.remove(paperStructParams.getExamId(), paperStructParams.getCourseCode(), paperStructParams.getPaperNumber());
+                tcPaperStructService.updateById(tcPaperStructDb);
+            }
         }
-        trExamStudentService.remove(paperStructParams.getExamId(), paperStructParams.getCourseCode(), paperStructParams.getPaperNumber());
-        trBasicInfoService.remove(paperStructParams.getExamId(), paperStructParams.getCourseCode(), paperStructParams.getPaperNumber());
-        return ResultUtil.ok(tcPaperStructService.saveOrUpdate(tcPaperStruct));
+        return ResultUtil.ok(true);
     }
 
     @ApiOperation(value = "期末成绩试卷蓝图查询")
@@ -264,7 +270,6 @@ public class TCFinalScoreController {
                                              @ApiParam(value = "科目编码", required = true) @RequestParam String courseCode,
                                              @ApiParam(value = "试卷编号", required = true) @RequestParam String paperNumber) throws IOException {
         List<PaperStructResult> paperStructResultList = null;
-//        org.apache.commons.collections4.CollectionUtils.isEqualCollection()
         TCPaperStruct tcPaperStruct = tcPaperStructService.getOne(new QueryWrapper<TCPaperStruct>().lambda().eq(TCPaperStruct::getExamId, examId).eq(TCPaperStruct::getCourseCode, courseCode).eq(TCPaperStruct::getPaperNumber, paperNumber));
         if (Objects.isNull(tcPaperStruct)) {
             List<MarkQuestion> markQuestionList = markQuestionService.listQuestionByExamIdAndPaperNumberAndPaperType(examId, paperNumber, null);