|
@@ -1,6 +1,7 @@
|
|
|
package cn.com.qmth.examcloud.core.questions.service.impl;
|
|
|
|
|
|
import cn.com.qmth.examcloud.core.questions.base.core.ExamCourseDto;
|
|
|
+import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
|
import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
|
|
|
import cn.com.qmth.examcloud.core.questions.base.FileDisposeUtil;
|
|
@@ -22,6 +23,10 @@ import cn.com.qmth.examcloud.core.questions.service.converter.PrintExamPaperServ
|
|
|
import cn.com.qmth.examcloud.core.questions.service.export.ExportPaperAbstractService;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.export.InitPaperExpService;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.rpc.ExamCourseClient;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.bean.ExamCourseRelationBean;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.request.GetExamCourseListReq;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.response.GetExamCourseListResp;
|
|
|
import main.java.com.UpYun;
|
|
|
|
|
|
import org.apache.commons.io.FileUtils;
|
|
@@ -92,6 +97,9 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
|
|
|
|
|
|
@Autowired
|
|
|
private ExportPaperService exportPaperService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamCloudService examCloudService;
|
|
|
|
|
|
@Value("${upyun.downloadUrl}")
|
|
|
protected String downloadUrl;
|
|
@@ -389,8 +397,27 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
|
|
|
*/
|
|
|
private Map<String, String> checkAllCourseByExamId(String examId, ExportType exportType) {
|
|
|
Map<String, String> paperIdMap = new HashMap<String, String>();
|
|
|
- List<ExamCourseDto> examCourseDtoList = examCourseClient.findExamCourseByExamId(examId);
|
|
|
- for (ExamCourseDto examCourseDto : examCourseDtoList) {
|
|
|
+ List<ExamCourseRelationBean> examCourseDtoList = new ArrayList<ExamCourseRelationBean>();
|
|
|
+ GetExamCourseListReq req = new GetExamCourseListReq();
|
|
|
+ req.setExamId(Long.valueOf(examId));
|
|
|
+ Long start = 1l;
|
|
|
+ int count = 0;
|
|
|
+ while (true) {
|
|
|
+ req.setStart(start);
|
|
|
+ GetExamCourseListResp resp = examCloudService.getExamCourseList(req);
|
|
|
+ examCourseDtoList.addAll(resp.getRelationList());
|
|
|
+ if(start.equals(resp.getNext())){
|
|
|
+ break;
|
|
|
+ }else {
|
|
|
+ start = resp.getNext();
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ if(count>1000){
|
|
|
+ throw new StatusException("Q-", "考试下课程的数据量过大");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (ExamCourseRelationBean examCourseDto : examCourseDtoList) {
|
|
|
ExtractConfig condition = new ExtractConfig();
|
|
|
condition.setExamId(examCourseDto.getExamId());
|
|
|
condition.setCourseCode(examCourseDto.getCourseCode());
|
|
@@ -401,15 +428,24 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
|
|
|
if (extractConfig.getIfFinish() == null || extractConfig.getIfFinish() == 0) {
|
|
|
throw new RuntimeException("该考试下的课程“" + examCourseDto.getCourseName() + "”考试文件没有生成,不能批量导出,请保存调卷规则生成文件");
|
|
|
}
|
|
|
- checkExamFileExists(examId, examCourseDto, exportType);
|
|
|
- Map<String, String> finishedPaperIdMap = extractConfig.getFinishedPaperIdMap();
|
|
|
+ checkExamFileExists(examId, examCourseDto.getCourseCode(), exportType, examCourseDto.getCourseName());
|
|
|
+ List<ExamPaper> examPapers = extractConfig.getExamPaperList();
|
|
|
+ if(examPapers == null || examPapers.size()<1){
|
|
|
+ throw new RuntimeException("该考试下的课程“" + examCourseDto.getCourseName() + "”没有绑定试卷。");
|
|
|
+ }
|
|
|
+ for(ExamPaper examPaper:examPapers){
|
|
|
+ String paperId = examPaper.getPaper().getId();
|
|
|
+ paperIdMap.put(paperId,examPaper.getGroupCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ /*Map<String, String> finishedPaperIdMap = extractConfig.getFinishedPaperIdMap();
|
|
|
Set<Entry<String, String>> entry = finishedPaperIdMap.entrySet();
|
|
|
Iterator<Entry<String, String>> iterator = entry.iterator();
|
|
|
while (iterator.hasNext()) {
|
|
|
Entry<String, String> next = iterator.next();
|
|
|
//paperId为key,paperType为value
|
|
|
paperIdMap.put(next.getValue(), next.getKey());
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
return paperIdMap;
|
|
|
}
|
|
@@ -420,10 +456,10 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
|
|
|
* @param examId
|
|
|
* @param examCourseDto
|
|
|
*/
|
|
|
- private void checkExamFileExists(String examId, ExamCourseDto examCourseDto, ExportType exportType) {
|
|
|
+ private void checkExamFileExists(String examId, String code, ExportType exportType, String name) {
|
|
|
ExamFile examFileCondition = new ExamFile();
|
|
|
examFileCondition.setExamId(examId);
|
|
|
- examFileCondition.setCourseId(examCourseDto.getCourseCode());
|
|
|
+ examFileCondition.setCourseId(code);
|
|
|
|
|
|
List<ExamFile> examfiles = examFileService.findExamFileListByExamFile(examFileCondition);
|
|
|
|
|
@@ -445,7 +481,7 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
|
|
|
|
|
|
if (!paperFlag) {
|
|
|
String message = exportType == ExportType.NORMAL ? "考试文件" : "机考数据包";
|
|
|
- throw new RuntimeException("该考试下的课程“" + examCourseDto.getCourseName() + "”" + message + "没有生成,不能批量导出,请重新保存调卷规则生成");
|
|
|
+ throw new RuntimeException("该考试下的课程“" + name + "”" + message + "没有生成,不能批量导出,请重新保存调卷规则生成");
|
|
|
}
|
|
|
}
|
|
|
|