浏览代码

加入推送云阅卷更新考生客观题分数

wangliang 2 年之前
父节点
当前提交
125fc02f7a

+ 84 - 0
themis-business/src/main/java/com/qmth/themis/business/bean/cloudmark/StudentObjectiveScoreParams.java

@@ -0,0 +1,84 @@
+package com.qmth.themis.business.bean.cloudmark;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.themis.common.exception.BusinessException;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * @Description: 推送云阅卷更新客观题分数接口参数
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2022/9/28
+ */
+public class StudentObjectiveScoreParams extends BaseParams implements Serializable {
+
+    @ApiModelProperty(value = "云阅卷考试id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long examId;
+
+    @ApiModelProperty(value = "准考证号")
+    private String examNumber;
+
+    @ApiModelProperty(value = "客观题分数")
+    private Double objectiveScore;
+
+    public StudentObjectiveScoreParams() {
+
+    }
+
+    public StudentObjectiveScoreParams(Long orgId, Long examId, String examNumber, Double objectiveScore) {
+        super(orgId, null, null);
+        this.examId = examId;
+        this.examNumber = examNumber;
+        this.objectiveScore = objectiveScore;
+    }
+
+    public StudentObjectiveScoreParams(Long orgId, Long examId, String examNumber, Double objectiveScore
+            , String accessKey, String accessSecret) {
+        super(orgId, accessKey, accessSecret);
+        this.examId = examId;
+        this.examNumber = examNumber;
+        this.objectiveScore = objectiveScore;
+    }
+
+    public void vaildParams() {
+        if (Objects.isNull(this.examId)) {
+            throw new BusinessException("云阅卷考试id不能为空");
+        }
+        if (Objects.isNull(this.examNumber)) {
+            throw new BusinessException("准考证号不能为空");
+        }
+        if (Objects.isNull(this.objectiveScore)) {
+            throw new BusinessException("客观题分数不能为空");
+        }
+    }
+
+    public Long getExamId() {
+        return examId;
+    }
+
+    public void setExamId(Long examId) {
+        this.examId = examId;
+    }
+
+    public String getExamNumber() {
+        return examNumber;
+    }
+
+    public void setExamNumber(String examNumber) {
+        this.examNumber = examNumber;
+    }
+
+    public Double getObjectiveScore() {
+        return objectiveScore;
+    }
+
+    public void setObjectiveScore(Double objectiveScore) {
+        this.objectiveScore = objectiveScore;
+    }
+}

+ 1 - 0
themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java

@@ -66,6 +66,7 @@ public class SystemConstant {
     public static final String CLOUD_MARK_SUBJECT_SAVE_API = "/api/exam/subject/save";
     public static final String CLOUD_MARK_STUDENT_SAVE_API = "/api/exam/student/save";
     public static final String CLOUD_MARK_FILE_TYPE_UPLOAD_API = "/api/file/{type}/upload";
+    public static final String CLOUD_MARK_STUDENT_OBJECTIVE_SAVE_API = "/api/exam/student/objective/save";
 
     /**
      * api前缀

+ 4 - 4
themis-business/src/main/java/com/qmth/themis/business/templete/service/impl/TempleteLogicServiceImpl.java

@@ -7,10 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.common.reflect.TypeToken;
 import com.qmth.themis.business.bean.admin.OpenRecordAnswerTempBean;
 import com.qmth.themis.business.bean.admin.OpenRecordNeedMarkBean;
-import com.qmth.themis.business.bean.cloudmark.FileUploadParams;
-import com.qmth.themis.business.bean.cloudmark.SaveExamParams;
-import com.qmth.themis.business.bean.cloudmark.SaveStudentParams;
-import com.qmth.themis.business.bean.cloudmark.SaveSubjectParams;
+import com.qmth.themis.business.bean.cloudmark.*;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.cache.bean.ExamPaperCacheBean;
 import com.qmth.themis.business.constant.SystemConstant;
@@ -543,6 +540,9 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
                             SystemConstant.VALUE_OF_BLANK_REQUIRED_FIELD,
                             courseCode,
                             t.getCourseName()));
+
+                    cloudMarkUtil.callStudentObjectiveScoreApi(new StudentObjectiveScoreParams(orgId, cloudMarkExamId, String.valueOf(tOeExamRecord.getId()), tOeExamRecord.getObjectiveScore()));
+
                     OpenRecordNeedMarkBean openRecordNeedMarkBean = GsonUtil.fromJson(GsonUtil.toJson(tOeExamRecord), OpenRecordNeedMarkBean.class);
                     List<OpenRecordAnswerTempBean> answersTemp = examAnswerService.findByExamRecordId(tOeExamRecord.getId());
                     openRecordNeedMarkBean = SystemConstant.filterAnswer(openRecordNeedMarkBean, answersTemp, paperStructMap);

+ 29 - 0
themis-business/src/main/java/com/qmth/themis/business/util/CloudMarkUtil.java

@@ -215,4 +215,33 @@ public class CloudMarkUtil {
         Map<String, Object> resultMap = (Map<String, Object>) JSON.parse(result);
         return (Boolean) resultMap.get("success");
     }
+
+    /**
+     * 推送云阅卷更新考生客观题分数
+     *
+     * @param studentObjectiveScoreParams
+     * @return
+     * @throws IOException
+     */
+    public String callStudentObjectiveScoreApi(StudentObjectiveScoreParams studentObjectiveScoreParams) throws IOException {
+        studentObjectiveScoreParams.vaildParams();
+        this.getAccessKeyAndAccessSecret(studentObjectiveScoreParams);
+
+        SysConfig sysConfig = themisCacheService.addSysConfigCache(SystemConstant.CLOUD_MARK_URL);
+        Optional.ofNullable(sysConfig).orElseThrow(() -> new BusinessException("未配置云阅卷地址"));
+
+        String url = sysConfig.getConfigValue() + SystemConstant.CLOUD_MARK_STUDENT_OBJECTIVE_SAVE_API;
+        long timestamp = System.currentTimeMillis();
+        String accessToken = SignatureInfo.build(SignatureType.SECRET, SystemConstant.METHOD, SystemConstant.CLOUD_MARK_STUDENT_OBJECTIVE_SAVE_API, timestamp, studentObjectiveScoreParams.getAccessKey(), studentObjectiveScoreParams.getAccessSecret());
+        studentObjectiveScoreParams.resetDefaultData();
+        Map<String, Object> params = JSON.parseObject(JSON.toJSONString(studentObjectiveScoreParams), Map.class);
+        String result = HttpUtil.post(url, params, accessToken, timestamp);
+        result = StringEscapeUtils.unescapeHtml4(result);
+        if (result.contains("HTTP")) {
+            log.error("callStudentObjectiveScoreApi result:{}", result);
+            throw new BusinessException("云阅卷更新考生客观题分数失败");
+        }
+        Map<String, Object> resultMap = (Map<String, Object>) JSON.parse(result);
+        return String.valueOf(resultMap.get("updateTime"));
+    }
 }