|
@@ -15,6 +15,8 @@ import com.qmth.teachcloud.common.util.HttpKit;
|
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
@@ -23,6 +25,7 @@ import java.io.FileInputStream;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* 同步云阅卷接口工具类
|
|
@@ -31,12 +34,15 @@ import java.util.Map;
|
|
|
*/
|
|
|
@Component
|
|
|
public class StmmsUtils {
|
|
|
+ private final static Logger log = LoggerFactory.getLogger(StmmsUtils.class);
|
|
|
|
|
|
// 考试类型(逸教云默认是纸笔"SCAN_IMAGE")
|
|
|
private static final String SAVE_EXAM_TYPE = "SCAN_IMAGE";
|
|
|
// 所有请求方法默认为"POST"
|
|
|
private static final String POST_METHOD = "POST";
|
|
|
|
|
|
+ private final int defaultPageSize = 100;
|
|
|
+
|
|
|
@Autowired
|
|
|
private CommonCacheService commonCacheService;
|
|
|
|
|
@@ -206,7 +212,7 @@ public class StmmsUtils {
|
|
|
|
|
|
String jsonData = JSONObject.toJSONString(map);
|
|
|
|
|
|
- String result = HttpKit.sendPost(postUrl, jsonData, getHeaders(postUrl));
|
|
|
+ String result = HttpKit.sendPost(postUrl, jsonData, getHeaders(structureUrl));
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
if (jsonObject.containsKey("updateTime")) {
|
|
|
return true;
|
|
@@ -361,4 +367,100 @@ public class StmmsUtils {
|
|
|
throw ExceptionResultEnum.ERROR.exception("云阅卷同步接口未正确配置");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 考试成绩考生数量查询接口
|
|
|
+ *
|
|
|
+ * @param examId
|
|
|
+ * @param examCode
|
|
|
+ * @param examNumber
|
|
|
+ * @param studentCode
|
|
|
+ * @param subjectCode
|
|
|
+ * @param college
|
|
|
+ * @param className
|
|
|
+ * @param teacher
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public int getStudentCount(Integer examId, String examCode, String examNumber, String studentCode, String subjectCode, String college, String className, String teacher) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("examId", validParam(String.valueOf(examId), null, true, "考试ID"));
|
|
|
+ map.put("examCode", validParam(examCode, null, false, "考试编码"));
|
|
|
+ map.put("examNumber", validParam(examNumber, null, false, "准考证号"));
|
|
|
+ map.put("studentCode", validParam(studentCode, null, false, "学号"));
|
|
|
+ map.put("subjectCode", validParam(subjectCode, null, false, "课程编码"));
|
|
|
+ map.put("college", validParam(college, null, false, "学院"));
|
|
|
+ map.put("className", validParam(className, null, false, "班级"));
|
|
|
+ map.put("teacher", validParam(teacher, null, false, "教师"));
|
|
|
+
|
|
|
+ String hostUrl = dictionaryConfig.syncDataDomain().getHostUrl();
|
|
|
+ String studentCountUrl = dictionaryConfig.syncDataDomain().getStudentCountUrl();
|
|
|
+ validUrl(hostUrl, studentCountUrl);
|
|
|
+ String postUrl = hostUrl.concat(studentCountUrl);
|
|
|
+
|
|
|
+ //请求
|
|
|
+ String res;
|
|
|
+ try {
|
|
|
+ res = HttpKit.sendPost(postUrl, getHeaders(studentCountUrl), map, null, null, null);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("云阅卷:调用考试成绩考生数量查询接口请求异常,{}", e.getMessage());
|
|
|
+ throw new RuntimeException("云阅卷:调用考试成绩考生数量查询接口请求异常," + e.getMessage());
|
|
|
+ }
|
|
|
+ if (Objects.isNull(res)) {
|
|
|
+ log.info("云阅卷:调用考试成绩考生数量查询接口返回值为null");
|
|
|
+ throw new RuntimeException("云阅卷:调用考试成绩考生数量查询接口返回值为null");
|
|
|
+ }
|
|
|
+ JSONObject object = JSONObject.parseObject(res);
|
|
|
+ return Integer.parseInt(object.get("totalCount").toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 考试成绩考生查询接口
|
|
|
+ *
|
|
|
+ * @param examId
|
|
|
+ * @param examCode
|
|
|
+ * @param examNumber
|
|
|
+ * @param studentCode
|
|
|
+ * @param subjectCode
|
|
|
+ * @param college
|
|
|
+ * @param className
|
|
|
+ * @param teacher
|
|
|
+ * @param pageNo
|
|
|
+ * @param pageSize
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<Map> getStudentScore(Integer examId, String examCode, String examNumber, String studentCode, String subjectCode, String college, String className, String teacher, int pageNo, int pageSize) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("examId", validParam(String.valueOf(examId), null, true, "考试ID"));
|
|
|
+ map.put("examCode", validParam(examCode, null, false, "考试编码"));
|
|
|
+ map.put("examNumber", validParam(examNumber, null, false, "准考证号"));
|
|
|
+ map.put("studentCode", validParam(studentCode, null, false, "学号"));
|
|
|
+ map.put("subjectCode", validParam(subjectCode, null, false, "课程编码"));
|
|
|
+ map.put("college", validParam(college, null, false, "学院"));
|
|
|
+ map.put("className", validParam(className, null, false, "班级"));
|
|
|
+ map.put("teacher", validParam(teacher, null, false, "教师"));
|
|
|
+ map.put("pageNumber", validParam(teacher, null, true, "页码"));
|
|
|
+ map.put("pageSize", validParam(teacher, null, true, "数量"));
|
|
|
+
|
|
|
+ String hostUrl = dictionaryConfig.syncDataDomain().getHostUrl();
|
|
|
+ String studentScoreUrl = dictionaryConfig.syncDataDomain().getStudentScoreUrl();
|
|
|
+ validUrl(hostUrl, studentScoreUrl);
|
|
|
+ String postUrl = hostUrl.concat(studentScoreUrl);
|
|
|
+ //请求
|
|
|
+ String res;
|
|
|
+ try {
|
|
|
+ res = HttpKit.sendPost(postUrl, getHeaders(studentScoreUrl), map, null, null, null);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("云阅卷:调用考试成绩考生查询接口请求异常,{}", e.getMessage());
|
|
|
+ throw new RuntimeException("云阅卷:调用考试成绩考生查询接口请求异常," + e.getMessage());
|
|
|
+ }
|
|
|
+ if (Objects.isNull(res)) {
|
|
|
+ log.info("云阅卷:调用考试成绩考生查询接口返回值为null");
|
|
|
+ throw new RuntimeException("云阅卷:调用考试成绩考生查询接口返回值为null");
|
|
|
+ }
|
|
|
+ return JSONObject.parseArray(JSONObject.toJSON(res).toString(), Map.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getDefaultPageSize() {
|
|
|
+ return defaultPageSize;
|
|
|
+ }
|
|
|
}
|