فهرست منبع

新增期末考试试卷结构导入

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

+ 13 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/report/PaperStructDimensionResult.java

@@ -30,8 +30,13 @@ public class PaperStructDimensionResult implements Serializable {
     private Integer subNumber;
 
     @ApiModelProperty(value = "分数")
+    @NotNull(message = "分数不能为空")
     private Double score;
 
+    @ApiModelProperty(value = "课程目标名称")
+    @NotNull(message = "课程目标名称不能为空")
+    private String courseTargetName;
+
     @ApiModelProperty(value = "课程目标集合")
     @NotEmpty(message = "课程目标集合不能为空")
     private List<CourseTargetWebDto> targetList = new ArrayList<>();
@@ -46,6 +51,14 @@ public class PaperStructDimensionResult implements Serializable {
         this.score = score;
     }
 
+    public String getCourseTargetName() {
+        return courseTargetName;
+    }
+
+    public void setCourseTargetName(String courseTargetName) {
+        this.courseTargetName = courseTargetName;
+    }
+
     public Integer getMainNumber() {
         return mainNumber;
     }

+ 7 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TCPaperStruct.java

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.business.entity;
 
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
@@ -37,9 +38,11 @@ public class TCPaperStruct extends BaseEntity implements Serializable {
     private String paperNumber;
 
     @ApiModelProperty(value = "试卷结构")
+    @TableField(value = "paper_struct", updateStrategy = FieldStrategy.IGNORED)
     private String paperStruct;
 
     @ApiModelProperty(value = "试卷知识点结构")
+    @TableField(value = "paper_struct_dimension", updateStrategy = FieldStrategy.IGNORED)
     private String paperStructDimension;
 
     @ApiModelProperty(value = "全卷满分")
@@ -82,8 +85,8 @@ public class TCPaperStruct extends BaseEntity implements Serializable {
         this.enable = true;
     }
 
-    public void updateInfo(String paperStruct, Long userId) {
-        this.paperStruct = paperStruct;
+    public void updateInfo(String paperStructDimension, Long userId) {
+        this.paperStructDimension = paperStructDimension;
         updateInfo(userId);
     }
 
@@ -176,11 +179,11 @@ public class TCPaperStruct extends BaseEntity implements Serializable {
             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) && paperStructDimension.equals(that.paperStructDimension) && getCreateId().equals(that.getCreateId());
+        return examId.equals(that.examId) && courseCode.equals(that.courseCode) && Objects.equals(courseName, that.courseName) && paperNumber.equals(that.paperNumber) && Objects.equals(paperStruct, that.paperStruct) && Objects.equals(paperStructDimension, that.paperStructDimension);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(examId, courseCode, courseName, paperNumber, paperStruct, paperStructDimension, getCreateId());
+        return Objects.hash(examId, courseCode, courseName, paperNumber, paperStruct, paperStructDimension);
     }
 }

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

@@ -365,7 +365,7 @@ public class TRBasicInfoServiceImpl extends ServiceImpl<TRBasicInfoMapper, TRBas
         TCPaperStruct tcPaperStruct = tcPaperStructService.queryByExamIdAndCourseCodeAndPaperNumber(markPaper.getExamId(), markPaper.getCourseCode(), markPaper.getPaperNumber());
         Objects.requireNonNull(tcPaperStruct, "未找到试卷蓝图信息");
 
-        List<PaperStructDimensionResult> paperStructDimensionResultList = GsonUtil.fromJson(tcPaperStruct.getPaperStruct(), new TypeToken<List<PaperStructDimensionResult>>() {
+        List<PaperStructDimensionResult> paperStructDimensionResultList = GsonUtil.fromJson(tcPaperStruct.getPaperStructDimension(), new TypeToken<List<PaperStructDimensionResult>>() {
         }.getType());
 
         //课程目标考核分布
@@ -835,7 +835,9 @@ public class TRBasicInfoServiceImpl extends ServiceImpl<TRBasicInfoMapper, TRBas
         trExamStudentService.remove(examId, courseCode, paperNumber);
         trBasicInfoService.remove(examId, courseCode, paperNumber);
         if (clearDimension) {
-            tcPaperStructService.remove(examId, courseCode, paperNumber);
+            TCPaperStruct tcPaperStruct = tcPaperStructService.queryByExamIdAndCourseCodeAndPaperNumber(examId, courseCode, paperNumber);
+            tcPaperStruct.setPaperStructDimension(null);
+            tcPaperStructService.updateById(tcPaperStruct);
         }
     }
 

+ 9 - 1
distributed-print/install/mysql/upgrade/3.3.1.sql

@@ -647,4 +647,12 @@ SET name='管理成绩', url='Score', `type`='LINK', parent_id=2001, `sequence`=
 WHERE id=2006;
 INSERT INTO sys_privilege
 (id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
-VALUES(2032, '试卷结构-导入模版', '/api/admin/course/degree/final_score/paper_struct/import', 'URL', 2006, 1, 'AUTH', NULL, 1, 1, 1);
+VALUES(2032, '试卷结构-导入模版', '/api/admin/course/degree/final_score/paper_struct/import', 'URL', 2006, 1, 'AUTH', NULL, 1, 1, 1);
+
+ALTER TABLE t_c_final_score DROP KEY t_c_score_end_exam_unique;
+ALTER TABLE t_c_final_score ADD CONSTRAINT t_c_final_score_unique UNIQUE KEY (exam_id,course_code,paper_number,name,student_code);
+ALTER TABLE t_c_final_score MODIFY COLUMN course_name varchar(100) NULL COMMENT '课程名称';
+
+ALTER TABLE t_c_usual_score DROP KEY t_c_score_normal_unique;
+ALTER TABLE t_c_usual_score ADD CONSTRAINT t_c_usual_score_unique UNIQUE KEY (exam_id,course_code,paper_number,name,student_code);
+ALTER TABLE t_c_usual_score MODIFY COLUMN course_name varchar(100) NULL COMMENT '课程名称';

+ 39 - 11
distributed-print/src/main/java/com/qmth/distributed/print/api/TCPaperStructController.java

@@ -1,8 +1,9 @@
 package com.qmth.distributed.print.api;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.gson.reflect.TypeToken;
 import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.distributed.print.business.bean.dto.CourseWeightDto;
+import com.qmth.distributed.print.business.bean.excel.PaperStructDto;
 import com.qmth.distributed.print.business.bean.params.report.PaperStructParams;
 import com.qmth.distributed.print.business.bean.result.CourseWeightResult;
 import com.qmth.distributed.print.business.bean.result.EditResult;
@@ -34,6 +35,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.annotation.Resource;
 import javax.validation.Valid;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
@@ -90,16 +92,22 @@ public class TCPaperStructController {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
-        for (PaperStructDimensionResult paperStructDimensionResult : paperStructParams.getPaperStruct()) {
-            Objects.requireNonNull(paperStructDimensionResult.getMainNumber(), "大题号为空");
-            Objects.requireNonNull(paperStructDimensionResult.getSubNumber(), "小题号为空");
-            if (!CollectionUtils.isEmpty(paperStructDimensionResult.getTargetList()) && paperStructDimensionResult.getTargetList().size() > 1) {
-                throw ExceptionResultEnum.ERROR.exception("一个题只能属于一个目标");
+        CourseWeightResult courseWeightResult = trBasicInfoService.findCourseWeightResultRmi(paperStructParams.getExamId(), paperStructParams.getCourseCode());
+        for (CourseWeightDto c : courseWeightResult.getSubmitForm()) {
+            for (PaperStructDimensionResult paperStructDimensionResult : paperStructParams.getPaperStruct()) {
+                Objects.requireNonNull(paperStructDimensionResult.getMainNumber(), "大题号为空");
+                Objects.requireNonNull(paperStructDimensionResult.getSubNumber(), "小题号为空");
+                if (!CollectionUtils.isEmpty(paperStructDimensionResult.getTargetList()) && paperStructDimensionResult.getTargetList().size() > 1) {
+                    throw ExceptionResultEnum.ERROR.exception("一个题只能属于一个目标");
+                }
+            }
+            Double score = paperStructParams.getPaperStruct().stream().filter(s -> Objects.equals(s.getCourseTargetName(), c.getCourseTargetName())).mapToDouble(PaperStructDimensionResult::getScore).sum();
+            if (new BigDecimal(score).compareTo(c.getTotalWeight()) == 1) {
+                throw ExceptionResultEnum.ERROR.exception("[" + c.getCourseTargetName() + "]知识点小题总分大于该课程目标分,请重新设置");
             }
         }
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         TCPaperStruct tcPaperStructDb = tcPaperStructService.queryByExamIdAndCourseCodeAndPaperNumber(paperStructParams.getExamId(), paperStructParams.getCourseCode(), paperStructParams.getPaperNumber());
-        CourseWeightResult courseWeightResult = trBasicInfoService.findCourseWeightResultRmi(paperStructParams.getExamId(), paperStructParams.getCourseCode());
         if (Objects.isNull(tcPaperStructDb)) {
             MarkPaper markPaper = markPaperService.getByExamIdAndPaperNumber(paperStructParams.getExamId(), paperStructParams.getPaperNumber());
             Objects.requireNonNull(markPaper, "未找到科目信息");
@@ -112,7 +120,7 @@ public class TCPaperStructController {
             tcPaperStructDb.updateInfo(JacksonUtil.parseJson(paperStructParams.getPaperStruct()), sysUser.getId());
             if (!tcPaperStructDb.equals(tcPaperStructSource)) {
                 if (Objects.nonNull(tcPaperStructDb.getDimensionSign()) && tcPaperStructDb.getDimensionSign().longValue() != courseWeightResult.getDimensionSign().longValue()) {
-                    trBasicInfoService.clearReportData(tcPaperStructDb.getExamId(), tcPaperStructDb.getCourseCode(), tcPaperStructDb.getPaperNumber(), true);
+                    trBasicInfoService.clearReportData(tcPaperStructDb.getExamId(), tcPaperStructDb.getCourseCode(), tcPaperStructDb.getPaperNumber(), false);
                 }
                 tcPaperStructDb.setDimensionSign(courseWeightResult.getDimensionSign());
                 tcPaperStructService.updateById(tcPaperStructDb);
@@ -143,11 +151,31 @@ public class TCPaperStructController {
             CourseWeightResult courseWeightResult = trBasicInfoService.findCourseWeightResultRmi(examId, courseCode);
             if (Objects.nonNull(tcPaperStruct.getDimensionSign()) && tcPaperStruct.getDimensionSign().longValue() != courseWeightResult.getDimensionSign().longValue()) {
                 trBasicInfoService.clearReportData(examId, courseCode, paperNumber, true);
-                return this.finalScorePaperStructQuery(examId, courseCode, paperNumber);
-            } else {
+                paperStructDimensionResultList = new ArrayList<>();
+
                 if (Objects.nonNull(tcPaperStruct.getPaperStruct())) {
-                    paperStructDimensionResultList = GsonUtil.fromJson(tcPaperStruct.getPaperStruct(), new TypeToken<List<PaperStructDimensionResult>>() {
+                    List<PaperStructDto> paperStructDtoList = GsonUtil.fromJson(tcPaperStruct.getPaperStruct(), new TypeToken<List<PaperStructDto>>() {
+                    }.getType());
+                    paperStructDimensionResultList = new ArrayList<>(paperStructDtoList.size());
+                    for (PaperStructDto paperStructDto : paperStructDtoList) {
+                        paperStructDimensionResultList.add(new PaperStructDimensionResult(paperStructDto.getMainNumber(), paperStructDto.getSubNumber(), paperStructDto.getScore()));
+                    }
+                } else {
+                    return this.finalScorePaperStructQuery(examId, courseCode, paperNumber);
+                }
+            } else {
+                if (Objects.nonNull(tcPaperStruct.getPaperStructDimension())) {
+                    paperStructDimensionResultList = GsonUtil.fromJson(tcPaperStruct.getPaperStructDimension(), new TypeToken<List<PaperStructDimensionResult>>() {
+                    }.getType());
+                } else if (Objects.nonNull(tcPaperStruct.getPaperStruct())) {
+                    List<PaperStructDto> paperStructDtoList = GsonUtil.fromJson(tcPaperStruct.getPaperStruct(), new TypeToken<List<PaperStructDto>>() {
                     }.getType());
+                    paperStructDimensionResultList = new ArrayList<>(paperStructDtoList.size());
+                    for (PaperStructDto paperStructDto : paperStructDtoList) {
+                        paperStructDimensionResultList.add(new PaperStructDimensionResult(paperStructDto.getMainNumber(), paperStructDto.getSubNumber(), paperStructDto.getScore()));
+                    }
+                } else {
+                    return this.finalScorePaperStructQuery(examId, courseCode, paperNumber);
                 }
             }
         }