|
@@ -1,13 +1,25 @@
|
|
|
package com.qmth.teachcloud.report;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.qmth.boot.tools.signature.SignatureEntity;
|
|
|
+import com.qmth.boot.tools.signature.SignatureType;
|
|
|
+import com.qmth.teachcloud.common.config.DictionaryConfig;
|
|
|
+import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
+import com.qmth.teachcloud.common.util.HttpUtil;
|
|
|
+import com.qmth.teachcloud.report.business.entity.TBCloudExam;
|
|
|
import com.qmth.teachcloud.report.business.enums.PublishStatusEnum;
|
|
|
import com.qmth.teachcloud.report.business.service.AnalyzeForReportService;
|
|
|
+import org.apache.commons.lang3.StringEscapeUtils;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @Description:
|
|
@@ -19,6 +31,10 @@ import javax.annotation.Resource;
|
|
|
public class AnalyzeForStudentServiceTest {
|
|
|
@Resource
|
|
|
private AnalyzeForReportService analyzeForReportService;
|
|
|
+ @Resource
|
|
|
+ DictionaryConfig dictionaryConfig;
|
|
|
+
|
|
|
+
|
|
|
@Test
|
|
|
public void buildAnalyzeExamCourse() {
|
|
|
Long examId = 2L;
|
|
@@ -52,7 +68,7 @@ public class AnalyzeForStudentServiceTest {
|
|
|
public void analyzePointScoreRate() throws Exception {
|
|
|
Long examId = 1L;
|
|
|
String courseCode = "1013";
|
|
|
- analyzeForReportService.AnalyzePointScoreRate(examId,courseCode);
|
|
|
+ analyzeForReportService.buildAnalyzePointScoreRate(examId,courseCode);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -160,4 +176,47 @@ public class AnalyzeForStudentServiceTest {
|
|
|
String courseCode = null;
|
|
|
System.out.println(analyzeForReportService.buildAnalyzeTeacherCollegePaperStruct(examId,courseCode));
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void syncCloudExam() throws IOException {
|
|
|
+ // 三个参数
|
|
|
+ Long examId = 263L;
|
|
|
+ String accessKey = "a8599fce46fd4e0192d2d13c7b258931";
|
|
|
+ String accessSecret = "Sl9xiXAphY04eE8ojuTqRgcv";
|
|
|
+
|
|
|
+ String url = dictionaryConfig.yunMarkDomain().getUrl() + dictionaryConfig.yunMarkDomain().getStudentScoreApi();
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("examId", examId);
|
|
|
+
|
|
|
+
|
|
|
+ int pageNumber = 1;
|
|
|
+ int pageSize = 100;
|
|
|
+ List<Map> students = null;
|
|
|
+ for (; ; ) {
|
|
|
+ params.put("pageNumber", pageNumber);
|
|
|
+ params.put("pageSize", pageSize);
|
|
|
+ Long timestamp = System.currentTimeMillis();
|
|
|
+ String accessToken = SignatureEntity.build(SignatureType.SECRET, SystemConstant.METHOD, dictionaryConfig.yunMarkDomain().getStudentScoreApi(), timestamp, accessKey, accessSecret);
|
|
|
+ String result = HttpUtil.post(url, params, accessToken, timestamp);
|
|
|
+ result = StringEscapeUtils.unescapeHtml4(result);
|
|
|
+ if (Objects.nonNull(result)) {
|
|
|
+ if (result.contains("HTTP")) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("云阅卷鉴权失败");
|
|
|
+ }
|
|
|
+ List<Map> tempList = JSONObject.parseArray(JSONObject.toJSON(result).toString(), Map.class);
|
|
|
+ if (Objects.nonNull(tempList) && tempList.size() > 0) {
|
|
|
+ if (Objects.isNull(students)) {
|
|
|
+ students = new ArrayList<>();
|
|
|
+ }
|
|
|
+ students.addAll(tempList);
|
|
|
+ pageNumber++;
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println(JSON.toJSONString(students));
|
|
|
+ }
|
|
|
}
|