|
@@ -7,7 +7,6 @@ import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
@@ -57,13 +56,13 @@ public class SxsfExportPaperService extends ExportPaperAbstractService {
|
|
|
|
|
|
@Override
|
|
|
public void downloadPaper(String paperId, HttpServletResponse response) throws Exception {
|
|
|
- Map<String,Object> dataMap = initExportPaper(paperId);
|
|
|
+ PaperExp paperExp = initExportPaper(paperId);
|
|
|
List<String> fileList = new ArrayList<String>();
|
|
|
- if (dataMap.get("fileName") != null) {
|
|
|
- String paperfileName = (String) dataMap.get("fileName")+DOCX_SUFFIX;
|
|
|
- String answerFileName = (String) dataMap.get("fileName")+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
|
|
|
- DocxProcessUtil.exportWord(dataMap, paperfileName,SXSF_TEMPLATE_PAPER);
|
|
|
- DocxProcessUtil.exportWord(dataMap,answerFileName,SXSF_TEMPLATE_ANSWER);
|
|
|
+ if (paperExp!= null) {
|
|
|
+ String paperfileName = paperExp.getName()+DOCX_SUFFIX;
|
|
|
+ String answerFileName = paperExp.getName()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
|
|
|
+ DocxProcessUtil.exportWord(paperExp, paperfileName,SXSF_TEMPLATE_PAPER);
|
|
|
+ DocxProcessUtil.exportWord(paperExp,answerFileName,SXSF_TEMPLATE_ANSWER);
|
|
|
DocxProcessUtil.processImage(paperfileName,getPkgList(paperId));
|
|
|
DocxProcessUtil.processImage(answerFileName,getPkgList(paperId));
|
|
|
fileList.add(paperfileName);
|
|
@@ -73,34 +72,32 @@ public class SxsfExportPaperService extends ExportPaperAbstractService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void uploadFile(ExtractConfig extractConfig,String paperId,AccessUser accessUser,Map<String,Object> exportStructureMap) throws Exception{
|
|
|
- Map<String,Object> dataMap = initExportPaper(paperId);
|
|
|
- if (dataMap.get("fileName") != null) {
|
|
|
+ public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,AccessUser accessUser) throws Exception{
|
|
|
+ PaperExp paperExp = initExportPaper(paperId);
|
|
|
+ if (paperExp!=null) {
|
|
|
String currNum = CommonUtils.getCurNum();
|
|
|
- ExportStructure exportStructure = (ExportStructure) exportStructureMap.get("exportStructure");
|
|
|
- List<QuestionTypeNum> questionTypeNums = new ArrayList<QuestionTypeNum>();
|
|
|
- if(exportStructure!=null){
|
|
|
- questionTypeNums = exportStructure.getQuestionTypeNums();
|
|
|
- }
|
|
|
- PaperExp paperExp = (PaperExp) dataMap.get("paper");
|
|
|
List<PaperDetailExp> objectiveDetails = paperExp.getObjectiveDetails();
|
|
|
- //检查客观题的数量是否大于试卷导出设置中的客观题数量
|
|
|
- if(questionTypeNums.size()>0){
|
|
|
- checkObjectiveDetailsNum(paperExp,objectiveDetails,questionTypeNums);
|
|
|
- }
|
|
|
if(exportStructure==null||exportStructure.getExportType()==ExportType.NORMAL){
|
|
|
+ List<QuestionTypeNum> questionTypeNums = new ArrayList<QuestionTypeNum>();
|
|
|
+ if(exportStructure!=null){
|
|
|
+ questionTypeNums = exportStructure.getQuestionTypeNums();
|
|
|
+ }
|
|
|
+ //检查客观题的数量是否大于试卷导出设置中的客观题数量
|
|
|
+ if(questionTypeNums.size()>0){
|
|
|
+ checkObjectiveDetailsNum(paperExp,objectiveDetails,questionTypeNums);
|
|
|
+ }
|
|
|
//上传试卷
|
|
|
- uploadPaperWord(dataMap,extractConfig,paperId,accessUser,currNum);
|
|
|
+ uploadPaperWord(paperExp,extractConfig,paperId,accessUser,currNum);
|
|
|
//上传答案
|
|
|
- uploadAnswerWord(dataMap,extractConfig,paperId,accessUser,currNum);
|
|
|
+ uploadAnswerWord(paperExp,extractConfig,paperId,accessUser,currNum);
|
|
|
+ //上传试卷结构
|
|
|
+ if(questionTypeNums.size()>0){
|
|
|
+ uploadPaperStructure(paperExp,extractConfig,paperId,accessUser,currNum,questionTypeNums);
|
|
|
+ }
|
|
|
}else if(exportStructure.getExportType()==ExportType.ONLINE){
|
|
|
//上传机考JSON文件
|
|
|
uploadComputerTestFile(extractConfig,currNum);
|
|
|
}
|
|
|
- //上传试卷结构
|
|
|
- if(questionTypeNums.size()>0){
|
|
|
- uploadPaperStructure(dataMap,extractConfig,paperId,accessUser,currNum,questionTypeNums);
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -112,10 +109,10 @@ public class SxsfExportPaperService extends ExportPaperAbstractService {
|
|
|
* @param paperId
|
|
|
* @param accessUser
|
|
|
*/
|
|
|
- private void uploadPaperWord(Map<String,Object> dataMap,ExtractConfig extractConfig,String paperId,AccessUser accessUser,String currNum){
|
|
|
+ private void uploadPaperWord(PaperExp paperExp,ExtractConfig extractConfig,String paperId,AccessUser accessUser,String currNum){
|
|
|
String paperfileName = currNum+ExamFileType.PAPER.name()+DOCX_SUFFIX;
|
|
|
try {
|
|
|
- DocxProcessUtil.exportWord(dataMap,paperfileName,SXSF_TEMPLATE_PAPER);
|
|
|
+ DocxProcessUtil.exportWord(paperExp,paperfileName,SXSF_TEMPLATE_PAPER);
|
|
|
DocxProcessUtil.processImage(paperfileName,getPkgList(paperId));
|
|
|
File paperFile = new File(TEMP_FILE_EXP+paperfileName);
|
|
|
String paperFilePath = uploadUrl+paperfileName;
|
|
@@ -136,10 +133,10 @@ public class SxsfExportPaperService extends ExportPaperAbstractService {
|
|
|
* @param paperId
|
|
|
* @param accessUser
|
|
|
*/
|
|
|
- private void uploadAnswerWord(Map<String,Object> dataMap,ExtractConfig extractConfig,String paperId,AccessUser accessUser,String currNum){
|
|
|
+ private void uploadAnswerWord(PaperExp paperExp,ExtractConfig extractConfig,String paperId,AccessUser accessUser,String currNum){
|
|
|
String answerFileName = currNum+ExamFileType.ANSWER.name()+DOCX_SUFFIX;
|
|
|
try {
|
|
|
- DocxProcessUtil.exportWord(dataMap,answerFileName,SXSF_TEMPLATE_ANSWER);
|
|
|
+ DocxProcessUtil.exportWord(paperExp,answerFileName,SXSF_TEMPLATE_ANSWER);
|
|
|
DocxProcessUtil.processImage(answerFileName,getPkgList(paperId));
|
|
|
File answerFile = new File(TEMP_FILE_EXP+answerFileName);
|
|
|
String answerFilePath = uploadUrl+answerFileName;
|
|
@@ -155,9 +152,9 @@ public class SxsfExportPaperService extends ExportPaperAbstractService {
|
|
|
/**
|
|
|
* 生成试卷结构,上传至又拍云
|
|
|
*/
|
|
|
- private void uploadPaperStructure(Map<String,Object> dataMap,ExtractConfig extractConfig,String paperId,AccessUser accessUser,String currNum,List<QuestionTypeNum> questionTypeNums) {
|
|
|
- exportObjectiveQuestionStructures(dataMap,extractConfig,accessUser,currNum,questionTypeNums);
|
|
|
- exportSubjectiveQuestionStructures(dataMap,extractConfig,accessUser,currNum);
|
|
|
+ private void uploadPaperStructure(PaperExp paperExp,ExtractConfig extractConfig,String paperId,AccessUser accessUser,String currNum,List<QuestionTypeNum> questionTypeNums) {
|
|
|
+ exportObjectiveQuestionStructures(paperExp,extractConfig,accessUser,currNum,questionTypeNums);
|
|
|
+ exportSubjectiveQuestionStructures(paperExp,extractConfig,accessUser,currNum);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -165,9 +162,8 @@ public class SxsfExportPaperService extends ExportPaperAbstractService {
|
|
|
* @param paperExp
|
|
|
* @return
|
|
|
*/
|
|
|
- private void exportObjectiveQuestionStructures(Map<String,Object> dataMap,ExtractConfig extractConfig,AccessUser accessUser,String currNum,List<QuestionTypeNum> questionTypeNums){
|
|
|
+ private void exportObjectiveQuestionStructures(PaperExp paperExp,ExtractConfig extractConfig,AccessUser accessUser,String currNum,List<QuestionTypeNum> questionTypeNums){
|
|
|
String objectiveFilename = currNum+ExamFileType.PAPER_STRUCTURE_OBJECTIVE.name()+EXCEL_SUFFIX;
|
|
|
- PaperExp paperExp = (PaperExp) dataMap.get("paper");
|
|
|
List<PaperDetailExp> objectiveDetails = paperExp.getObjectiveDetails();
|
|
|
//根据试卷结构导出设置中的数量补齐客观题
|
|
|
fillObjectiveQuestions(objectiveDetails,questionTypeNums);
|
|
@@ -257,9 +253,8 @@ public class SxsfExportPaperService extends ExportPaperAbstractService {
|
|
|
* @param paperExp
|
|
|
* @return
|
|
|
*/
|
|
|
- private void exportSubjectiveQuestionStructures(Map<String,Object> dataMap,ExtractConfig extractConfig,AccessUser accessUser,String currNum){
|
|
|
+ private void exportSubjectiveQuestionStructures(PaperExp paperExp,ExtractConfig extractConfig,AccessUser accessUser,String currNum){
|
|
|
String subjectiveFileName = currNum+ExamFileType.PAPER_STRUCTURE_SUBJECTIVE.name()+EXCEL_SUFFIX;
|
|
|
- PaperExp paperExp = (PaperExp) dataMap.get("paper");
|
|
|
List<PaperDetailExp> subjectiveDetails = paperExp.getSubjectiveDetails();
|
|
|
List<SubjectiveQuestionStructure> subjectiveQuestionStructureList = new ArrayList<SubjectiveQuestionStructure>();
|
|
|
for(PaperDetailExp paperDetailExp:subjectiveDetails){
|