فهرست منبع

新增试卷蓝图保存

wangliang 1 سال پیش
والد
کامیت
c6d9c9f741

+ 70 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/params/report/PaperStructParams.java

@@ -0,0 +1,70 @@
+package com.qmth.distributed.print.business.bean.params.report;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.distributed.print.business.bean.result.report.PaperStructResult;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @Description: 试卷蓝图params
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2024/2/19
+ */
+public class PaperStructParams implements Serializable {
+
+    @ApiModelProperty(value = "考试id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    @NotNull(message = "考试id不能为空")
+    private Long examId;
+
+    @ApiModelProperty(value = "课程编码")
+    @NotNull(message = "课程编码不能为空")
+    private String courseCode;
+
+    @ApiModelProperty(value = "试卷编码")
+    @NotNull(message = "试卷编码不能为空")
+    private String paperNumber;
+
+    @ApiModelProperty(value = "试卷蓝图结构")
+    @NotEmpty(message = "试卷蓝图结构不能为空")
+    private List<PaperStructResult> paperStruct;
+
+    public Long getExamId() {
+        return examId;
+    }
+
+    public void setExamId(Long examId) {
+        this.examId = examId;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getPaperNumber() {
+        return paperNumber;
+    }
+
+    public void setPaperNumber(String paperNumber) {
+        this.paperNumber = paperNumber;
+    }
+
+    public List<PaperStructResult> getPaperStruct() {
+        return paperStruct;
+    }
+
+    public void setPaperStruct(List<PaperStructResult> paperStruct) {
+        this.paperStruct = paperStruct;
+    }
+}

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

@@ -2,6 +2,7 @@ package com.qmth.distributed.print.business.entity;
 
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.teachcloud.common.contant.SystemConstant;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -57,6 +58,28 @@ public class TCPaperStruct implements Serializable {
     @ApiModelProperty(value = "更新时间")
     private Long updateTime;
 
+    public TCPaperStruct() {
+
+    }
+
+    public TCPaperStruct(Long examId, String courseCode, String courseName, String paperNumber, String paperStruct, Long userId) {
+        this.id = SystemConstant.getDbUuid();
+        this.examId = examId;
+        this.courseCode = courseCode;
+        this.courseName = courseName;
+        this.paperNumber = paperNumber;
+        this.paperStruct = paperStruct;
+        this.enable = true;
+        this.createId = userId;
+        this.createTime = System.currentTimeMillis();
+    }
+
+    public void updateInfo(String paperStruct, Long userId) {
+        this.paperStruct = paperStruct;
+        this.updateId = userId;
+        this.updateTime = System.currentTimeMillis();
+    }
+
     public Long getId() {
         return id;
     }

+ 30 - 2
distributed-print/src/main/java/com/qmth/distributed/print/api/TCFinalScoreController.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.gson.reflect.TypeToken;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.distributed.print.business.bean.excel.ExcelField;
+import com.qmth.distributed.print.business.bean.params.report.PaperStructParams;
 import com.qmth.distributed.print.business.bean.result.EditResult;
 import com.qmth.distributed.print.business.bean.result.report.PaperStructResult;
 import com.qmth.distributed.print.business.entity.TCFinalScore;
@@ -19,8 +20,11 @@ import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.log.CustomizedOperationTypeEnum;
 import com.qmth.teachcloud.common.util.GsonUtil;
+import com.qmth.teachcloud.common.util.JacksonUtil;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
+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.slf4j.Logger;
@@ -66,6 +70,9 @@ public class TCFinalScoreController {
     @Resource
     TCPaperStructService tcPaperStructService;
 
+    @Resource
+    MarkPaperService markPaperService;
+
     @ApiOperation(value = "导入期末成绩-模板下载")
     @RequestMapping(value = "/final_score/template_download", method = RequestMethod.POST)
     @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.EXPORT)
@@ -173,11 +180,32 @@ public class TCFinalScoreController {
     @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.UPDATE)
     @ApiResponses({@ApiResponse(code = 200, message = "试卷蓝图保存", response = Object.class)})
     @Transactional
-    public Object finalScorePaperStructSave(@ApiParam(value = "试卷蓝图结构", required = true) @Valid @RequestBody List<PaperStructResult> paperStructResultList, BindingResult bindingResult) throws IOException {
+    public Object finalScorePaperStructSave(@ApiParam(value = "试卷蓝图结构", required = true) @Valid @RequestBody PaperStructParams paperStructParams, BindingResult bindingResult) throws IOException {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
-        return ResultUtil.ok(true);
+        for (PaperStructResult paperStructResult : paperStructParams.getPaperStruct()) {
+            if (Objects.isNull(paperStructResult.getMainNumber())) {
+                throw ExceptionResultEnum.ERROR.exception("大题号为空");
+            }
+            if (Objects.isNull(paperStructResult.getSubNumber())) {
+                throw ExceptionResultEnum.ERROR.exception("小题号为空");
+            }
+            if (!CollectionUtils.isEmpty(paperStructResult.getTargetList()) && paperStructResult.getTargetList().size() > 1) {
+                throw ExceptionResultEnum.ERROR.exception("一个题只能属于一个目标");
+            }
+        }
+        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)) {
+            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());
+        } else {
+            tcPaperStruct.updateInfo(JacksonUtil.parseJson(paperStructParams.getPaperStruct()), sysUser.getId());
+        }
+        return ResultUtil.ok(tcPaperStructService.saveOrUpdate(tcPaperStruct));
     }
 
     @ApiOperation(value = "期末成绩试卷蓝图查询")