|
@@ -1,5 +1,6 @@
|
|
|
package com.qmth.cqb.paper.service.impl;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
@@ -20,6 +21,9 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.domain.Example;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageImpl;
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
import org.springframework.data.mongodb.core.query.Query;
|
|
@@ -27,7 +31,6 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
import cn.com.qmth.examcloud.common.dto.core.ExamCourseDto;
|
|
|
-import cn.com.qmth.examcloud.common.dto.em.enums.ExamType;
|
|
|
import cn.com.qmth.examcloud.common.dto.question.PaperDetailDto;
|
|
|
import cn.com.qmth.examcloud.common.dto.question.PaperDetailUnitDto;
|
|
|
import cn.com.qmth.examcloud.common.dto.question.PaperDto;
|
|
@@ -36,6 +39,7 @@ import cn.com.qmth.examcloud.common.dto.question.QuestionDto;
|
|
|
import cn.com.qmth.examcloud.common.dto.question.SubQuestionDto;
|
|
|
import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
|
|
|
import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
|
+import cn.com.qmth.examcloud.common.util.GsonUtil;
|
|
|
import cn.com.qmth.examcloud.common.util.excel.ExcelWriter;
|
|
|
|
|
|
import com.qmth.cqb.paper.dao.ExportServiceManageRepo;
|
|
@@ -45,6 +49,7 @@ import com.qmth.cqb.paper.dao.PaperDetailUnitRepo;
|
|
|
import com.qmth.cqb.paper.dao.PaperRepo;
|
|
|
import com.qmth.cqb.paper.dto.ExportPaperInfoModel;
|
|
|
import com.qmth.cqb.paper.dto.ObjectiveQuestionStructure;
|
|
|
+import com.qmth.cqb.paper.dto.PageExamCourse;
|
|
|
import com.qmth.cqb.paper.dto.PaperDetailExp;
|
|
|
import com.qmth.cqb.paper.dto.PaperDetailUnitExp;
|
|
|
import com.qmth.cqb.paper.dto.PaperExp;
|
|
@@ -158,18 +163,9 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, Object> saveExtractConfig(ExtractConfig extractConfig,String orgName,AccessUser accessUser) throws Exception {
|
|
|
- Map<String, Object> returnMap = exportStructureService.findStructureByExamIdAndExamType(extractConfig.getExamId()+"",ExamType.strToEnum(extractConfig.getExamType()));
|
|
|
- //试卷导出结构设置不完整
|
|
|
- if("structure_imperfect".equals(returnMap.get("returnMsg"))){
|
|
|
- return returnMap;
|
|
|
- }
|
|
|
- if(extractConfig.getScrambling_the_question_order()==null){
|
|
|
- extractConfig.setScrambling_the_question_order((short) 0);
|
|
|
- }
|
|
|
- if(extractConfig.getScrambling_the_option_order()==null){
|
|
|
- extractConfig.setScrambling_the_option_order((short) 0);
|
|
|
- }
|
|
|
+ public void saveExtractConfig(ExtractConfig extractConfig,String orgName,AccessUser accessUser) throws Exception {
|
|
|
+ //查询试卷导出设置
|
|
|
+ ExportStructure exportStructure = exportStructureService.findStructureByExamId(extractConfig.getExamId()+"");
|
|
|
List<ExamPaper> examPapers = extractConfig.getExamPaperList();
|
|
|
for(int i=0;i<examPapers.size();i++){
|
|
|
ExamPaper examPaper = examPapers.get(i);
|
|
@@ -186,16 +182,14 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
|
Iterator<Entry<String,String>> iterator = entry.iterator();
|
|
|
while(iterator.hasNext()){
|
|
|
String paperId = iterator.next().getValue();
|
|
|
- uploadPaperFile(extractConfig,paperId,accessUser,returnMap);
|
|
|
+ uploadPaperFile(extractConfig,paperId,exportStructure,accessUser);
|
|
|
}
|
|
|
- returnMap.put("returnMsg", "success");
|
|
|
- return returnMap;
|
|
|
}
|
|
|
|
|
|
- private void uploadPaperFile(ExtractConfig extractConfig,String paperId,AccessUser accessUser,Map<String,Object> exportStructureMap) throws Exception {
|
|
|
+ private void uploadPaperFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,AccessUser accessUser) throws Exception {
|
|
|
ExportServiceManage esm = exportServiceManageRepo.findByOrgName("陕西师范大学");
|
|
|
ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils.getBeanById(esm.getExportServiceName());
|
|
|
- exportPaperAbstractService.uploadFile(extractConfig,paperId,accessUser,exportStructureMap);
|
|
|
+ exportPaperAbstractService.uploadFile(extractConfig,paperId,exportStructure,accessUser);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -676,8 +670,7 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
|
|
|
|
@Override
|
|
|
public void exportExamPaperInfoCheck(ExportPaperInfoModel exportModel,HttpServletResponse response) throws Exception {
|
|
|
- Map<String, Object> exportStructureMap = exportStructureService.findStructureByExamIdAndExamType(exportModel.getExamId()+"",exportModel.getExamType());
|
|
|
- ExportStructure exportStructure = (ExportStructure) exportStructureMap.get("exportStructure");
|
|
|
+ ExportStructure exportStructure = exportStructureService.findStructureByExamId(exportModel.getExamId()+"");
|
|
|
//如果是批量导出
|
|
|
if(exportModel.getExportWay()==ExportWay.BATCH){
|
|
|
if(exportStructure==null){
|
|
@@ -696,8 +689,7 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
|
FileDisposeUtil.createDirectory(zipDirectory);
|
|
|
//如果是批量导出,首先检查该考试下的所有课程是否都制定了调卷规则
|
|
|
List<String> paperIds = new ArrayList<String>();
|
|
|
- Map<String, Object> exportStructureMap = exportStructureService.findStructureByExamIdAndExamType(exportModel.getExamId()+"",exportModel.getExamType());
|
|
|
- ExportStructure exportStructure = (ExportStructure) exportStructureMap.get("exportStructure");
|
|
|
+ ExportStructure exportStructure = exportStructureService.findStructureByExamId(exportModel.getExamId()+"");
|
|
|
//如果是批量导出
|
|
|
if(exportModel.getExportWay()==ExportWay.BATCH){
|
|
|
if(exportStructure==null){
|
|
@@ -714,15 +706,15 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
|
List<ExamFile> examFiles = examFileService.findExamFileListByExportPaperInfoModel(exportModel);
|
|
|
if(examFiles!=null&&examFiles.size()>0){
|
|
|
for(ExamFile examFile:examFiles){
|
|
|
- FileDisposeUtil.saveUrlAs(downloadUrl+examFile.getFilePath(),downloadDirectory+"\\"+examFile.getFileName());
|
|
|
+ FileDisposeUtil.saveUrlAs(downloadUrl+examFile.getFilePath(),downloadDirectory+File.separator+examFile.getFileName());
|
|
|
}
|
|
|
}
|
|
|
//创建压缩文件名称
|
|
|
- String zipFileName = exportStructure.getExamName()+"_"+exportStructure.getExamType().name()+"_"+CommonUtils.getCurNum();
|
|
|
+ String zipFileName = CommonUtils.getCurNum();
|
|
|
//将downloadDirectory文件夹压缩成zip文件,存放到zipDirectory文件夹中
|
|
|
FileDisposeUtil.fileToZip(downloadDirectory,zipDirectory,zipFileName);
|
|
|
//下载zip文件到客户端
|
|
|
- FileDisposeUtil.downloadFile(zipFileName+".zip",zipDirectory+"\\"+zipFileName+".zip",response);
|
|
|
+ FileDisposeUtil.downloadFile(zipFileName+".zip",zipDirectory+File.separator+zipFileName+".zip",response);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -740,7 +732,7 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
|
extractConfig = findConfig(extractConfig);
|
|
|
Map<String,String> finishedPaperIdMap = extractConfig.getFinishedPaperIdMap();
|
|
|
if(extractConfig==null||finishedPaperIdMap==null){
|
|
|
- throw new RuntimeException("该考试下的课程没有全部制定调卷规则或考试文件没有生成,不能批量导出");
|
|
|
+ throw new RuntimeException("该考试下的课程“"+extractConfig.getCourseName()+"”没有制定调卷规则或考试文件没有生成,不能批量导出");
|
|
|
}
|
|
|
Set<Entry<String,String>> entry = finishedPaperIdMap.entrySet();
|
|
|
Iterator<Entry<String,String>> iterator = entry.iterator();
|
|
@@ -752,14 +744,6 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
|
return paperIdList;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<ExamFile> findPaperStructure(String examId, String courseId) {
|
|
|
- ExamFile examFile = new ExamFile();
|
|
|
- examFile.setExamId(examId);
|
|
|
- examFile.setCourseId(courseId);
|
|
|
- return examFileService.findExamFileListByExamFile(examFile);
|
|
|
- }
|
|
|
-
|
|
|
private void makePaperStructure(String examName,List<String> paperIds,ExportStructure exportStructure) throws Exception{
|
|
|
List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
|
|
|
|
|
@@ -768,8 +752,7 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
|
List<SubjectiveQuestionStructure> subjectiveQuestionStructureList = new ArrayList<SubjectiveQuestionStructure>();
|
|
|
|
|
|
for(String paperId:paperIds){
|
|
|
- Map<String,Object> dataMap = sxsfExportPaperService.initExportPaper(paperId);
|
|
|
- PaperExp paperExp = (PaperExp) dataMap.get("paper");
|
|
|
+ PaperExp paperExp = sxsfExportPaperService.initExportPaper(paperId);
|
|
|
List<PaperDetailExp> objectiveDetails = paperExp.getObjectiveDetails();
|
|
|
//根据设置补齐客观题
|
|
|
sxsfExportPaperService.fillObjectiveQuestions(objectiveDetails, questionTypeNums);
|
|
@@ -800,4 +783,28 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
|
subjectiveExcelExporter.write(examName+"_主观题.xlsx",subjectiveQuestionStructureList,out2);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Page<ExtractConfig> findPageExtractConfig(int currentPage,int pageSize, Long examId, String courseNo) {
|
|
|
+ String examCourseJson = examCourseClient.findPageExamCourse(examId,courseNo,currentPage,pageSize);
|
|
|
+
|
|
|
+ PageExamCourse pageExamCourse = GsonUtil.getInstanceByJson(examCourseJson,PageExamCourse.class);
|
|
|
+
|
|
|
+ List<ExamCourseDto> examCourseList = pageExamCourse.getContent();
|
|
|
+ if(examCourseList.size()==0){
|
|
|
+ throw new RuntimeException("考务系统无数据返回");
|
|
|
+ }
|
|
|
+ List<ExtractConfig> extractConfigs = new ArrayList<ExtractConfig>();
|
|
|
+ for(ExamCourseDto examCourseDto:examCourseList){
|
|
|
+ ExtractConfig condition = new ExtractConfig();
|
|
|
+ condition.setExamId(examCourseDto.getExamId());
|
|
|
+ condition.setCourseCode(examCourseDto.getCourseCode());
|
|
|
+ ExtractConfig extractConfig = this.findConfig(condition);
|
|
|
+ if(extractConfig==null){
|
|
|
+ extractConfig = new ExtractConfig(examCourseDto);
|
|
|
+ }
|
|
|
+ extractConfigs.add(extractConfig);
|
|
|
+ }
|
|
|
+ return new PageImpl<ExtractConfig>(extractConfigs,new PageRequest(currentPage,pageSize),pageExamCourse.getTotalElements());
|
|
|
+ }
|
|
|
+
|
|
|
}
|