浏览代码

新增ai评卷参数表

wangliang 2 月之前
父节点
当前提交
d0160d2a97

+ 8 - 1
distributed-print/install/mysql/upgrade/3.4.5.sql

@@ -61,4 +61,11 @@ ALTER TABLE `mark_question` ADD COLUMN `person_task` TINYINT(1) NULL DEFAULT 1 C
 -- 2025-04-11
 -- 2025-04-11
 RENAME TABLE mark_ai_question_score TO mark_ai_question_point;
 RENAME TABLE mark_ai_question_score TO mark_ai_question_point;
 
 
-ALTER TABLE mark_ai_question_param ADD CONSTRAINT mark_ai_question_param_unique UNIQUE KEY (question_id);
+ALTER TABLE mark_ai_question_param ADD CONSTRAINT mark_ai_question_param_unique UNIQUE KEY (question_id);
+
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(1222, 'AI评卷参数新增/修改', '/api/admin/mark/ai_question_param/save', 'URL', 897, 1, 'AUTH', NULL, 1, 1, 1);
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(1223, 'AI评卷参数查询', '/api/admin/mark/ai_question_param/info', 'URL', 897, 1, 'AUTH', NULL, 1, 1, 1);

+ 68 - 5
distributed-print/src/main/java/com/qmth/distributed/print/api/mark/MarkAiQuestionParamController.java

@@ -5,16 +5,20 @@ import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.bean.result.EditResult;
 import com.qmth.distributed.print.business.bean.result.EditResult;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.enums.FieldUniqueEnum;
 import com.qmth.teachcloud.common.enums.FieldUniqueEnum;
 import com.qmth.teachcloud.common.util.Result;
 import com.qmth.teachcloud.common.util.Result;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.common.util.ResultUtil;
-import com.qmth.teachcloud.mark.bean.ai.MarkAiQuestionParamResult;
+import com.qmth.teachcloud.common.util.ServletUtil;
+import com.qmth.teachcloud.mark.entity.MarkAiQuestionLevel;
 import com.qmth.teachcloud.mark.entity.MarkAiQuestionParam;
 import com.qmth.teachcloud.mark.entity.MarkAiQuestionParam;
+import com.qmth.teachcloud.mark.entity.MarkAiQuestionPoint;
 import com.qmth.teachcloud.mark.service.MarkAiQuestionLevelService;
 import com.qmth.teachcloud.mark.service.MarkAiQuestionLevelService;
 import com.qmth.teachcloud.mark.service.MarkAiQuestionParamService;
 import com.qmth.teachcloud.mark.service.MarkAiQuestionParamService;
 import com.qmth.teachcloud.mark.service.MarkAiQuestionPointService;
 import com.qmth.teachcloud.mark.service.MarkAiQuestionPointService;
 import io.swagger.annotations.*;
 import io.swagger.annotations.*;
+import org.apache.commons.collections4.CollectionUtils;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.dao.DuplicateKeyException;
@@ -24,6 +28,9 @@ import org.springframework.web.bind.annotation.*;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import javax.validation.Valid;
 import javax.validation.Valid;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -56,8 +63,59 @@ public class MarkAiQuestionParamController {
         if (bindingResult.hasErrors()) {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
         }
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         try {
         try {
-
+            switch (markAiQuestionParam.getMode()) {
+                case POINT://按得分点
+                    if (CollectionUtils.isEmpty(markAiQuestionParam.getPointList())) {
+                        throw ExceptionResultEnum.ERROR.exception("得分点信息为空");
+                    }
+                    markAiQuestionParam.getPointList().stream().peek(s -> s.setAiQuestionId(markAiQuestionParam.getId())).collect(Collectors.toList());
+                    if (Objects.isNull(markAiQuestionParam.getId())) {//新增
+                        markAiQuestionParam.insertInfo(sysUser.getId());
+                        markAiQuestionPointService.saveBatch(markAiQuestionParam.getPointList());
+                    } else {//修改
+                        List<MarkAiQuestionPoint> markAiQuestionPointDbList = markAiQuestionPointService.listByAiQuestionId(markAiQuestionParam.getId());
+                        List<MarkAiQuestionLevel> markAiQuestionLevelDbList = markAiQuestionLevelService.listByAiQuestionId(markAiQuestionParam.getId());
+                        //删除档次的数据
+                        if (CollectionUtils.isNotEmpty(markAiQuestionLevelDbList)) {
+                            markAiQuestionLevelService.removeByIds(markAiQuestionLevelDbList.stream().map(MarkAiQuestionLevel::getId).collect(Collectors.toList()));
+                        }
+                        //全删point数据全增
+                        if (CollectionUtils.isNotEmpty(markAiQuestionPointDbList)) {
+                            markAiQuestionPointService.removeByIds(markAiQuestionPointDbList.stream().map(MarkAiQuestionPoint::getId).collect(Collectors.toList()));
+                        }
+                        markAiQuestionPointService.saveBatch(markAiQuestionParam.getPointList());
+                        markAiQuestionParam.updateInfo(sysUser.getId());
+                    }
+                    break;
+                case LEVEL://按档次
+                    if (CollectionUtils.isEmpty(markAiQuestionParam.getLevelList())) {
+                        throw ExceptionResultEnum.ERROR.exception("档次信息为空");
+                    }
+                    markAiQuestionParam.getLevelList().stream().peek(s -> s.setAiQuestionId(markAiQuestionParam.getId())).collect(Collectors.toList());
+                    if (Objects.isNull(markAiQuestionParam.getId())) {//新增
+                        markAiQuestionParam.insertInfo(sysUser.getId());
+                        markAiQuestionLevelService.saveBatch(markAiQuestionParam.getLevelList());
+                    } else {
+                        List<MarkAiQuestionPoint> markAiQuestionPointDbList = markAiQuestionPointService.listByAiQuestionId(markAiQuestionParam.getId());
+                        List<MarkAiQuestionLevel> markAiQuestionLevelDbList = markAiQuestionLevelService.listByAiQuestionId(markAiQuestionParam.getId());
+                        //删除得分点的数据
+                        if (CollectionUtils.isNotEmpty(markAiQuestionPointDbList)) {
+                            markAiQuestionPointService.removeByIds(markAiQuestionPointDbList.stream().map(MarkAiQuestionPoint::getId).collect(Collectors.toList()));
+                        }
+                        //全删level数据全增
+                        if (CollectionUtils.isNotEmpty(markAiQuestionLevelDbList)) {
+                            markAiQuestionLevelService.removeByIds(markAiQuestionLevelDbList.stream().map(MarkAiQuestionLevel::getId).collect(Collectors.toList()));
+                        }
+                        markAiQuestionLevelService.saveBatch(markAiQuestionParam.getLevelList());
+                        markAiQuestionParam.updateInfo(sysUser.getId());
+                    }
+                    break;
+                default:
+                    break;
+            }
+            markAiQuestionParamService.saveOrUpdate(markAiQuestionParam);
         } catch (Exception e) {
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             log.error(SystemConstant.LOG_ERROR, e);
             if (e instanceof DuplicateKeyException) {
             if (e instanceof DuplicateKeyException) {
@@ -75,8 +133,13 @@ public class MarkAiQuestionParamController {
 
 
     @ApiOperation(value = "AI评卷参数查询")
     @ApiOperation(value = "AI评卷参数查询")
     @RequestMapping(value = "/info", method = RequestMethod.POST)
     @RequestMapping(value = "/info", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "AI评卷参数查询", response = MarkAiQuestionParamResult.class)})
-    public Result info(@ApiParam(value = "主键", required = true) @RequestParam Long id) {
-        return ResultUtil.ok();
+    @ApiResponses({@ApiResponse(code = 200, message = "AI评卷参数查询", response = MarkAiQuestionParam.class)})
+    public Result info(@ApiParam(value = "题目id", required = true) @RequestParam Long questionId) {
+        MarkAiQuestionParam markAiQuestionParam = markAiQuestionParamService.getByExamIdAndPaperNumberAndQuestionId(null, null, questionId);
+        Objects.requireNonNull(markAiQuestionParam, "AI评卷参数信息为空");
+        List<MarkAiQuestionPoint> markAiQuestionPointDbList = markAiQuestionPointService.listByAiQuestionId(markAiQuestionParam.getId());
+        List<MarkAiQuestionLevel> markAiQuestionLevelDbList = markAiQuestionLevelService.listByAiQuestionId(markAiQuestionParam.getId());
+        markAiQuestionParam.setListInfo(markAiQuestionPointDbList, markAiQuestionLevelDbList);
+        return ResultUtil.ok(markAiQuestionParam);
     }
     }
 }
 }

+ 0 - 41
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/bean/ai/MarkAiQuestionParamResult.java

@@ -1,41 +0,0 @@
-package com.qmth.teachcloud.mark.bean.ai;
-
-import com.qmth.teachcloud.mark.entity.MarkAiQuestionLevel;
-import com.qmth.teachcloud.mark.entity.MarkAiQuestionParam;
-import com.qmth.teachcloud.mark.entity.MarkAiQuestionPoint;
-import io.swagger.annotations.ApiModelProperty;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * @Description: ai评卷参数返回信息
- * @Param:
- * @return:
- * @Author: wangliang
- * @Date: 2025/4/11
- */
-public class MarkAiQuestionParamResult extends MarkAiQuestionParam implements Serializable {
-
-    @ApiModelProperty(value = "得分点列表")
-    List<MarkAiQuestionPoint> pointList;
-
-    @ApiModelProperty(value = "档次列表")
-    List<MarkAiQuestionLevel> levelList;
-
-    public List<MarkAiQuestionPoint> getPointList() {
-        return pointList;
-    }
-
-    public void setPointList(List<MarkAiQuestionPoint> pointList) {
-        this.pointList = pointList;
-    }
-
-    public List<MarkAiQuestionLevel> getLevelList() {
-        return levelList;
-    }
-
-    public void setLevelList(List<MarkAiQuestionLevel> levelList) {
-        this.levelList = levelList;
-    }
-}

+ 4 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/entity/MarkAiQuestionLevel.java

@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 
 
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.io.Serializable;
 
 
 /**
 /**
@@ -29,12 +30,15 @@ public class MarkAiQuestionLevel implements Serializable {
     private Long aiQuestionId;
     private Long aiQuestionId;
 
 
     @ApiModelProperty(value = "最小分值")
     @ApiModelProperty(value = "最小分值")
+    @NotNull(message = "最小分值不能为空")
     private Double minScore;
     private Double minScore;
 
 
     @ApiModelProperty(value = "最大分值")
     @ApiModelProperty(value = "最大分值")
+    @NotNull(message = "最大分值不能为空")
     private Double maxScore;
     private Double maxScore;
 
 
     @ApiModelProperty(value = "标答")
     @ApiModelProperty(value = "标答")
+    @NotNull(message = "标答不能为空")
     private String answer;
     private String answer;
 
 
     public Long getId() {
     public Long getId() {

+ 37 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/entity/MarkAiQuestionParam.java

@@ -1,5 +1,6 @@
 package com.qmth.teachcloud.mark.entity;
 package com.qmth.teachcloud.mark.entity;
 
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.teachcloud.common.base.BaseEntity;
 import com.qmth.teachcloud.common.base.BaseEntity;
@@ -9,6 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
 
 
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.io.Serializable;
+import java.util.List;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -51,6 +53,41 @@ public class MarkAiQuestionParam extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "最小分")
     @ApiModelProperty(value = "最小分")
     private Double minScore;
     private Double minScore;
 
 
+    @ApiModelProperty(value = "得分点列表")
+    @TableField(exist = false)
+    List<MarkAiQuestionPoint> pointList;
+
+    @ApiModelProperty(value = "档次列表")
+    @TableField(exist = false)
+    List<MarkAiQuestionLevel> levelList;
+
+    /**
+     * set列表数据
+     *
+     * @param pointList
+     * @param levelList
+     */
+    public void setListInfo(List<MarkAiQuestionPoint> pointList, List<MarkAiQuestionLevel> levelList) {
+        this.pointList = pointList;
+        this.levelList = levelList;
+    }
+
+    public List<MarkAiQuestionPoint> getPointList() {
+        return pointList;
+    }
+
+    public void setPointList(List<MarkAiQuestionPoint> pointList) {
+        this.pointList = pointList;
+    }
+
+    public List<MarkAiQuestionLevel> getLevelList() {
+        return levelList;
+    }
+
+    public void setLevelList(List<MarkAiQuestionLevel> levelList) {
+        this.levelList = levelList;
+    }
+
     public Long getQuestionId() {
     public Long getQuestionId() {
         return questionId;
         return questionId;
     }
     }

+ 3 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/entity/MarkAiQuestionPoint.java

@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 
 
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.io.Serializable;
 
 
 /**
 /**
@@ -29,9 +30,11 @@ public class MarkAiQuestionPoint implements Serializable {
     private Long aiQuestionId;
     private Long aiQuestionId;
 
 
     @ApiModelProperty(value = "分值")
     @ApiModelProperty(value = "分值")
+    @NotNull(message = "分值不能为空")
     private Double score;
     private Double score;
 
 
     @ApiModelProperty(value = "标答")
     @ApiModelProperty(value = "标答")
+    @NotNull(message = "标答不能为空")
     private String answer;
     private String answer;
 
 
     public Long getId() {
     public Long getId() {

+ 1 - 1
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/MarkAiQuestionParamService.java

@@ -12,7 +12,7 @@ import com.qmth.teachcloud.mark.entity.MarkAiQuestionParam;
  * @since 2025-04-10
  * @since 2025-04-10
  */
  */
 public interface MarkAiQuestionParamService extends IService<MarkAiQuestionParam> {
 public interface MarkAiQuestionParamService extends IService<MarkAiQuestionParam> {
-    boolean existMarkAiQuestionScoreOrLevel(Long examId, String paperNumber, Long questionId);
+    boolean existMarkAiQuestionPointOrLevel(Long examId, String paperNumber, Long questionId);
 
 
     MarkAiQuestionParam getByExamIdAndPaperNumberAndQuestionId(Long examId, String paperNumber, Long questionId);
     MarkAiQuestionParam getByExamIdAndPaperNumberAndQuestionId(Long examId, String paperNumber, Long questionId);
 }
 }

+ 9 - 4
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkAiQuestionParamServiceImpl.java

@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.List;
+import java.util.Objects;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -33,7 +34,7 @@ public class MarkAiQuestionParamServiceImpl extends ServiceImpl<MarkAiQuestionPa
     private MarkAiQuestionLevelService markAiQuestionLevelService;
     private MarkAiQuestionLevelService markAiQuestionLevelService;
 
 
     @Override
     @Override
-    public boolean existMarkAiQuestionScoreOrLevel(Long examId, String paperNumber, Long questionId) {
+    public boolean existMarkAiQuestionPointOrLevel(Long examId, String paperNumber, Long questionId) {
         MarkAiQuestionParam markAiQuestionParam = this.getByExamIdAndPaperNumberAndQuestionId(examId, paperNumber, questionId);
         MarkAiQuestionParam markAiQuestionParam = this.getByExamIdAndPaperNumberAndQuestionId(examId, paperNumber, questionId);
         if (markAiQuestionParam == null) {
         if (markAiQuestionParam == null) {
             return false;
             return false;
@@ -54,9 +55,13 @@ public class MarkAiQuestionParamServiceImpl extends ServiceImpl<MarkAiQuestionPa
     @Override
     @Override
     public MarkAiQuestionParam getByExamIdAndPaperNumberAndQuestionId(Long examId, String paperNumber, Long questionId) {
     public MarkAiQuestionParam getByExamIdAndPaperNumberAndQuestionId(Long examId, String paperNumber, Long questionId) {
         QueryWrapper<MarkAiQuestionParam> queryWrapper = new QueryWrapper<>();
         QueryWrapper<MarkAiQuestionParam> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(MarkAiQuestionParam::getExamId, examId)
-                .eq(MarkAiQuestionParam::getPaperNumber, paperNumber)
-                .eq(MarkAiQuestionParam::getQuestionId, questionId);
+        if (Objects.nonNull(examId)) {
+            queryWrapper.lambda().eq(MarkAiQuestionParam::getExamId, examId);
+        }
+        if (Objects.nonNull(paperNumber)) {
+            queryWrapper.lambda().eq(MarkAiQuestionParam::getPaperNumber, paperNumber);
+        }
+        queryWrapper.lambda().eq(MarkAiQuestionParam::getQuestionId, questionId);
         return this.getOne(queryWrapper);
         return this.getOne(queryWrapper);
     }
     }
 }
 }

+ 1 - 1
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkServiceImpl.java

@@ -474,7 +474,7 @@ public class MarkServiceImpl implements MarkService {
             // 处理正常考生
             // 处理正常考生
             List<MarkQuestion> markQuestionList = markQuestionService.listByExamIdAndPaperNumberAndObjective(markPaper.getExamId(), markPaper.getPaperNumber(), false);
             List<MarkQuestion> markQuestionList = markQuestionService.listByExamIdAndPaperNumberAndObjective(markPaper.getExamId(), markPaper.getPaperNumber(), false);
             for (MarkQuestion markQuestion : markQuestionList) {
             for (MarkQuestion markQuestion : markQuestionList) {
-                if (!MarkPaperAiMark.NONE.equals(markQuestion.getAiMark()) && !markAiQuestionParamService.existMarkAiQuestionScoreOrLevel(markQuestion.getExamId(), markQuestion.getPaperNumber(), markQuestion.getId())) {
+                if (!MarkPaperAiMark.NONE.equals(markQuestion.getAiMark()) && !markAiQuestionParamService.existMarkAiQuestionPointOrLevel(markQuestion.getExamId(), markQuestion.getPaperNumber(), markQuestion.getId())) {
                     continue;
                     continue;
                 }
                 }
                 // 生成正评任务
                 // 生成正评任务