|
@@ -1,23 +1,5 @@
|
|
|
package cn.com.qmth.examcloud.bridge.modules.cloudmarking.controller;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.nio.charset.Charset;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-import org.apache.commons.io.FileUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.MediaType;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
-import com.google.common.collect.Maps;
|
|
|
-
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.util.IOUtil;
|
|
|
import cn.com.qmth.examcloud.commons.util.JsonUtil;
|
|
@@ -27,6 +9,23 @@ import cn.com.qmth.examcloud.core.oe.admin.api.bean.SubjectiveAnswerBean;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.GetSubjectiveAnswerReq;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.GetSubjectiveAnswerResp;
|
|
|
import cn.com.qmth.examcloud.web.config.SystemProperties;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.nio.charset.Charset;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description 云阅卷接口
|
|
@@ -43,6 +42,8 @@ public class CloudMarkingController {
|
|
|
|
|
|
@Autowired
|
|
|
SystemProperties systemConfig;
|
|
|
+ @Resource
|
|
|
+ SystemProperties systemConfig1;
|
|
|
|
|
|
/**
|
|
|
* 生成主观题答案
|
|
@@ -53,10 +54,12 @@ public class CloudMarkingController {
|
|
|
throw new StatusException("101001", "考试批次id不允许为空");
|
|
|
}
|
|
|
|
|
|
+ System.out.println(systemConfig1.getDataDir());
|
|
|
//答案临时存放目录
|
|
|
final String tempAnswerDir = systemConfig.getTempDataDir() + "/tempAnswer" + System.currentTimeMillis();
|
|
|
|
|
|
Long startId = 0L;
|
|
|
+ Boolean hasData = false;
|
|
|
while (true) {
|
|
|
GetSubjectiveAnswerReq req = new GetSubjectiveAnswerReq();
|
|
|
req.setExamId(examId);
|
|
@@ -68,6 +71,10 @@ public class CloudMarkingController {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
+ if (!hasData) {
|
|
|
+ hasData = true;
|
|
|
+ }
|
|
|
+
|
|
|
List<SubjectiveAnswerBean> subjectiveAnswerList = resp.getSubjectiveAnswerList();
|
|
|
|
|
|
List<Long> examStudentIdList = subjectiveAnswerList.stream().
|
|
@@ -120,6 +127,10 @@ public class CloudMarkingController {
|
|
|
startId = resp.getNextExamRecordDataId();
|
|
|
}
|
|
|
|
|
|
+ if (!hasData){
|
|
|
+ return ResponseEntity.ok().body("There's no data to download.");
|
|
|
+ }
|
|
|
+
|
|
|
String zipPath = tempAnswerDir + "/" + examId + "-" + System.currentTimeMillis() + ".zip";
|
|
|
File zipFile = new File(zipPath);
|
|
|
ZipUtil.zip(new File(tempAnswerDir), zipFile);
|