Prechádzať zdrojové kódy

提交导出试卷代码

chenken 8 rokov pred
rodič
commit
e9d2cc069a
24 zmenil súbory, kde vykonal 645 pridanie a 158 odobranie
  1. 10 0
      cqb-comm-utils/pom.xml
  2. 8 2
      cqb-comm-utils/src/main/java/com/qmth/cqb/utils/enums/ExamFileType.java
  3. 34 0
      cqb-comm-utils/src/main/java/com/qmth/cqb/utils/enums/ExportType.java
  4. 17 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/dto/ExportPaperInfoModel.java
  5. 111 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/dto/ObjectiveQuestionStructure.java
  6. 16 4
      cqb-paper/src/main/java/com/qmth/cqb/paper/dto/PaperExp.java
  7. 99 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/dto/SubjectiveQuestionStructure.java
  8. 2 2
      cqb-paper/src/main/java/com/qmth/cqb/paper/model/ExamFile.java
  9. 18 3
      cqb-paper/src/main/java/com/qmth/cqb/paper/model/ExportStructure.java
  10. 10 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/model/ExtractConfig.java
  11. 21 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/rpc/ExamCourseClient.java
  12. 6 1
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/ExamFileService.java
  13. 12 0
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/ExportStructureService.java
  14. 7 1
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/ExtractConfigService.java
  15. 1 1
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/export/DzkdExportPaperService.java
  16. 1 7
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/export/ExportPaperAbstractService.java
  17. 2 29
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/export/HzkjExportPaperService.java
  18. 2 29
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/export/SddxExportPaperService.java
  19. 137 23
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/export/SxsfExportPaperService.java
  20. 2 29
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/export/TjdxExportPaperService.java
  21. 21 16
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/impl/ExamFileServiceImpl.java
  22. 30 1
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/impl/ExportStructureServiceImpl.java
  23. 68 9
      cqb-paper/src/main/java/com/qmth/cqb/paper/service/impl/ExtractConfigServiceImpl.java
  24. 10 1
      cqb-paper/src/main/java/com/qmth/cqb/paper/web/ExtractConfigController.java

+ 10 - 0
cqb-comm-utils/pom.xml

@@ -38,6 +38,16 @@
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>
 
+		<dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-feign</artifactId>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-eureka</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-mongodb</artifactId>

+ 8 - 2
cqb-comm-utils/src/main/java/com/qmth/cqb/utils/enums/ExamFileType.java

@@ -17,9 +17,15 @@ public enum ExamFileType {
 	/**
 	 * ZIP文件
 	 * 试卷结构
-	 * 主观题Excel、客观题Excel
+	 * 主观题
 	 */
-	PAPER_STRUCTURE("试卷结构"),
+	PAPER_STRUCTURE_SUBJECTIVE("试卷结构-主观题"),
+	/**
+	 * ZIP文件
+	 * 试卷结构
+	 * 客观题
+	 */
+	PAPER_STRUCTURE_OBJECTIVE("试卷结构-客观题"),
 	/**
 	 * 音频文件
 	 */

+ 34 - 0
cqb-comm-utils/src/main/java/com/qmth/cqb/utils/enums/ExportType.java

@@ -0,0 +1,34 @@
+package com.qmth.cqb.utils.enums;
+/**
+ * @author  	chenken
+ * @date    	2017年7月18日 上午10:21:48
+ * @company 	QMTH
+ * @description 试卷导出类型
+ */
+public enum ExportType {
+	
+	/**
+	 * 机考
+	 */
+	ONLINE("机考"),
+	
+	/**
+	 * 普通
+	 */
+	NORMAL("普通");
+	
+	private String name;
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	private ExportType(String name){
+		this.name = name;
+	}
+}
+

+ 17 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/dto/ExportPaperInfoModel.java

@@ -3,6 +3,8 @@ package com.qmth.cqb.paper.dto;
 import java.io.Serializable;
 import java.util.List;
 
+import cn.com.qmth.examcloud.common.dto.em.enums.ExamType;
+
 /**
  * @author  	chenken
  * @date    	2017年7月15日 下午1:52:52
@@ -16,7 +18,14 @@ public class ExportPaperInfoModel implements Serializable{
 	 */
 	private static final long serialVersionUID = -8364161638270123652L;
 
+	/**
+	 * 考试ID
+	 */
 	private String examId;
+	/**
+	 * 考试类型
+	 */
+	private ExamType examType;
 	
 	private List<String> exportContentList;
 
@@ -27,6 +36,14 @@ public class ExportPaperInfoModel implements Serializable{
 	public void setExamId(String examId) {
 		this.examId = examId;
 	}
+	
+	public ExamType getExamType() {
+		return examType;
+	}
+
+	public void setExamType(ExamType examType) {
+		this.examType = examType;
+	}
 
 	public List<String> getExportContentList() {
 		return exportContentList;

+ 111 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/dto/ObjectiveQuestionStructure.java

@@ -0,0 +1,111 @@
+package com.qmth.cqb.paper.dto;
+
+import java.io.Serializable;
+
+import cn.com.qmth.examcloud.common.util.excel.ExcelProperty;
+
+/**
+ * @author  	chenken
+ * @date    	2017年7月18日 上午10:59:49
+ * @company 	QMTH
+ * @description 客观题数据--用于Excel导出
+ */
+public class ObjectiveQuestionStructure implements Serializable{
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -4064781474344761068L;
+	/**
+	 * 课程代码
+	 */
+	@ExcelProperty(name="课程代码",index = 0)
+	private String courseNo;
+	/**
+	 * 课程名称
+	 */
+	@ExcelProperty(name="课程名称",index = 1)
+	private String courseName;
+	/**
+	 * 大题号
+	 */
+	@ExcelProperty(name="大题号",index = 2)
+	private Integer bigQuestionNo;
+	/**
+	 * 小题号
+	 */
+	@ExcelProperty(name="小题号",index = 3)
+	private Integer smallQuestionNo;
+	/**
+	 * 题目类型
+	 */
+	@ExcelProperty(name="题目类型",index = 4)
+	private String questionType;
+	/**
+	 * 标准答案
+	 */
+	@ExcelProperty(name="标准答案",index = 5)
+	private String answer;
+	/**
+	 * 小题分数
+	 */
+	@ExcelProperty(name="小题分数",index = 6)
+	private Double smallQuestionScore;
+	
+	public ObjectiveQuestionStructure(){}
+	
+	public ObjectiveQuestionStructure(PaperExp paperExp,PaperDetailExp paperDetailExp,PaperDetailUnitExp unit){
+		this.courseNo = paperExp.getCourseNo();
+		this.courseName = paperExp.getCourseName();
+		this.bigQuestionNo = paperDetailExp.getNumber();
+		this.questionType = unit.getQuestionType().getName();
+		this.smallQuestionNo = unit.getNumber();
+		this.smallQuestionScore = unit.getScore();
+		this.answer = unit.getQuestion().getQuesAnswer();
+	}
+	
+	
+	public String getCourseNo() {
+		return courseNo;
+	}
+	public void setCourseNo(String courseNo) {
+		this.courseNo = courseNo;
+	}
+	public String getCourseName() {
+		return courseName;
+	}
+	public void setCourseName(String courseName) {
+		this.courseName = courseName;
+	}
+	public Integer getBigQuestionNo() {
+		return bigQuestionNo;
+	}
+	public void setBigQuestionNo(Integer bigQuestionNo) {
+		this.bigQuestionNo = bigQuestionNo;
+	}
+	public Integer getSmallQuestionNo() {
+		return smallQuestionNo;
+	}
+	public void setSmallQuestionNo(Integer smallQuestionNo) {
+		this.smallQuestionNo = smallQuestionNo;
+	}
+	public String getQuestionType() {
+		return questionType;
+	}
+	public void setQuestionType(String questionType) {
+		this.questionType = questionType;
+	}
+	public String getAnswer() {
+		return answer;
+	}
+	public void setAnswer(String answer) {
+		this.answer = answer;
+	}
+	public Double getSmallQuestionScore() {
+		return smallQuestionScore;
+	}
+	public void setSmallQuestionScore(Double smallQuestionScore) {
+		this.smallQuestionScore = smallQuestionScore;
+	}
+	
+}
+

+ 16 - 4
cqb-paper/src/main/java/com/qmth/cqb/paper/dto/PaperExp.java

@@ -38,9 +38,14 @@ public class PaperExp implements Serializable{
 
     private Map<String,String> params;//导入试卷属性
     
-    private List<PaperDetailExp> objectiveDetails;//客观题
-    
-    private List<PaperDetailExp> subjectiveDetails;//主观题
+    /**
+     * 客观题
+     */
+    private List<PaperDetailExp> objectiveDetails;
+    /**
+     * 主观题
+     */
+    private List<PaperDetailExp> subjectiveDetails;
     
     private Double objectiveScore;
     
@@ -141,6 +146,10 @@ public class PaperExp implements Serializable{
         this.subTitle = subTitle;
     }
 
+    /**
+     * 得到客观题
+     * @return
+     */
 	public List<PaperDetailExp> getObjectiveDetails() {
 		return objectiveDetails;
 	}
@@ -148,7 +157,10 @@ public class PaperExp implements Serializable{
 	public void setObjectiveDetails(List<PaperDetailExp> objectiveDetails) {
 		this.objectiveDetails = objectiveDetails;
 	}
-
+	 /**
+     * 得到主观题
+     * @return
+     */
 	public List<PaperDetailExp> getSubjectiveDetails() {
 		return subjectiveDetails;
 	}

+ 99 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/dto/SubjectiveQuestionStructure.java

@@ -0,0 +1,99 @@
+package com.qmth.cqb.paper.dto;
+
+import java.io.Serializable;
+
+import cn.com.qmth.examcloud.common.util.excel.ExcelProperty;
+
+/**
+ * @author  	chenken
+ * @date    	2017年7月18日 上午10:51:54
+ * @company 	QMTH
+ * @description 主观题数据--用于Excel导出
+ */
+public class SubjectiveQuestionStructure implements Serializable{
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1130718763453256519L;
+	/**
+	 * 课程代码
+	 */
+	@ExcelProperty(name="科目代码",index = 0)
+	private String courseNo;
+	/**
+	 * 课程名称
+	 */
+	@ExcelProperty(name="科目名称",index = 1)
+	private String courseName;
+	/**
+	 * 大题号
+	 */
+	@ExcelProperty(name="大题号",index = 2)
+	private Integer bigQuestionNo;
+	/**
+	 * 大题名称
+	 */
+	@ExcelProperty(name="大题名称",index = 3)
+	private String bigQuestionName;
+	/**
+	 * 小题号
+	 */
+	@ExcelProperty(name="小题号",index = 4)
+	private Integer smallQuestionNo;
+	/**
+	 * 大题总分
+	 */
+	@ExcelProperty(name="大题总分",index = 5)
+	private Double bigQuestionScore;
+	
+	public SubjectiveQuestionStructure(){}
+	
+	public SubjectiveQuestionStructure(PaperExp paperExp,PaperDetailExp paperDetailExp,PaperDetailUnitExp unit){
+		this.courseNo = paperExp.getCourseNo();
+		this.courseName = paperExp.getCourseName();
+		this.bigQuestionNo = paperDetailExp.getNumber();
+		this.bigQuestionName = paperDetailExp.getName();
+		this.smallQuestionNo = unit.getNumber();
+		this.bigQuestionScore = paperDetailExp.getScore();
+	}
+	
+	
+	public String getCourseNo() {
+		return courseNo;
+	}
+	public void setCourseNo(String courseNo) {
+		this.courseNo = courseNo;
+	}
+	public String getCourseName() {
+		return courseName;
+	}
+	public void setCourseName(String courseName) {
+		this.courseName = courseName;
+	}
+	public Integer getBigQuestionNo() {
+		return bigQuestionNo;
+	}
+	public void setBigQuestionNo(Integer bigQuestionNo) {
+		this.bigQuestionNo = bigQuestionNo;
+	}
+	public String getBigQuestionName() {
+		return bigQuestionName;
+	}
+	public void setBigQuestionName(String bigQuestionName) {
+		this.bigQuestionName = bigQuestionName;
+	}
+	public Integer getSmallQuestionNo() {
+		return smallQuestionNo;
+	}
+	public void setSmallQuestionNo(Integer smallQuestionNo) {
+		this.smallQuestionNo = smallQuestionNo;
+	}
+	public Double getBigQuestionScore() {
+		return bigQuestionScore;
+	}
+	public void setBigQuestionScore(Double bigQuestionScore) {
+		this.bigQuestionScore = bigQuestionScore;
+	}
+	
+}
+

+ 2 - 2
cqb-paper/src/main/java/com/qmth/cqb/paper/model/ExamFile.java

@@ -80,9 +80,9 @@ public class ExamFile implements Serializable{
     
     public ExamFile(){}
     
-    public ExamFile(ExtractConfig extractConfig,String orgName,String fileName,String filePath,ExamFileType examFileType){
+    public ExamFile(ExtractConfig extractConfig,String fileName,String filePath,ExamFileType examFileType){
     	this.orgId = extractConfig.getOrgId();
-    	this.orgName = orgName;
+    	this.orgName = extractConfig.getOrgName();
     	this.examId = extractConfig.getExamId()+"";
     	this.examName = extractConfig.getExamName();
     	this.examType = ExamType.strToEnum(extractConfig.getExamType());

+ 18 - 3
cqb-paper/src/main/java/com/qmth/cqb/paper/model/ExportStructure.java

@@ -6,6 +6,9 @@ import java.util.List;
 
 import org.springframework.data.annotation.Id;
 
+import com.qmth.cqb.paper.dto.ExportPaperInfoModel;
+import com.qmth.cqb.utils.enums.ExportType;
+
 import cn.com.qmth.examcloud.common.dto.em.enums.ExamType;
 
 /**
@@ -38,7 +41,7 @@ public class ExportStructure implements Serializable{
 	/**
 	 * 导出 类型
 	 */
-	private String exportType;
+	private ExportType exportType;
 	
 	private List<QuestionTypeNum> questionTypeNums;
 	/**
@@ -54,6 +57,18 @@ public class ExportStructure implements Serializable{
 
     private Date updateTime;
 
+    public ExportStructure(){}
+    
+    public ExportStructure(String examId,ExamType examType){
+    	this.examId = examId;
+    	this.examType = examType;
+    }
+    
+    public ExportStructure(ExportPaperInfoModel exportModel){
+    	this.examId = exportModel.getExamId();
+    	this.examType = exportModel.getExamType();
+    }
+    
 	public String getId() {
 		return id;
 	}
@@ -78,11 +93,11 @@ public class ExportStructure implements Serializable{
 		this.examName = examName;
 	}
 
-	public String getExportType() {
+	public ExportType getExportType() {
 		return exportType;
 	}
 
-	public void setExportType(String exportType) {
+	public void setExportType(ExportType exportType) {
 		this.exportType = exportType;
 	}
 

+ 10 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/model/ExtractConfig.java

@@ -94,6 +94,8 @@ public class ExtractConfig implements Serializable {
      */
     private String orgId;
     
+    private String orgName;
+    
     public ExtractConfig(){}
     
     public ExtractConfig(String id){
@@ -236,5 +238,13 @@ public class ExtractConfig implements Serializable {
 	public void setFinishedPaperIdMap(Map<String, String> finishedPaperIdMap) {
 		this.finishedPaperIdMap = finishedPaperIdMap;
 	}
+
+	public String getOrgName() {
+		return orgName;
+	}
+
+	public void setOrgName(String orgName) {
+		this.orgName = orgName;
+	}
     
 }

+ 21 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/rpc/ExamCourseClient.java

@@ -0,0 +1,21 @@
+package com.qmth.cqb.paper.rpc;
+
+import java.util.List;
+
+import org.springframework.cloud.netflix.feign.FeignClient;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * @author  	chenken
+ * @date    	2017年7月18日 上午9:39:46
+ * @company 	QMTH
+ * @description ExamCourseClient.java
+ */
+@FeignClient(value = "ExamCloud-service-core")
+public interface ExamCourseClient {
+	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/user/disposeCreaterName")
+	List findExamCourseByExamId(@RequestParam("examId") String examId);
+}
+

+ 6 - 1
cqb-paper/src/main/java/com/qmth/cqb/paper/service/ExamFileService.java

@@ -14,11 +14,16 @@ import com.qmth.cqb.paper.model.ExamFile;
  */
 public interface ExamFileService {
 	/**
-	 * 保存考试文件
+	 * 批量保存考试文件
 	 * @param examFile
 	 */
 	public void saveExamFiles(List<ExamFile> examFileList,AccessUser accessUser);
 	
+	/**
+	 * 保存考试文件
+	 * @param examFile
+	 */
+	public void saveExamFile(ExamFile examFile,AccessUser accessUser);
 	
 	/**
 	 * 根据条件查询ExamFile集合

+ 12 - 0
cqb-paper/src/main/java/com/qmth/cqb/paper/service/ExportStructureService.java

@@ -1,7 +1,10 @@
 package com.qmth.cqb.paper.service;
 
+import java.util.Map;
+
 import org.springframework.data.domain.Page;
 
+import cn.com.qmth.examcloud.common.dto.em.enums.ExamType;
 import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
 
 import com.qmth.cqb.paper.model.ExportStructure;
@@ -33,5 +36,14 @@ public interface ExportStructureService {
 	 * @return
 	 */
 	public Page<ExportStructure> findPageByExportStructure(ExportStructure exportStructure,int curPage,int pageSize);
+	/**
+	 * 根据考试类型和考试ID查询结构
+	 * 如果结构存在、判断结构设置是否完整
+	 * 是否完整是指 客观题题数是否都设置过了
+	 * @param examId
+	 * @param examType
+	 * @return
+	 */
+	public Map<String,Object> findStructureByExamIdAndExamType(String examId,ExamType examType);
 }
 

+ 7 - 1
cqb-paper/src/main/java/com/qmth/cqb/paper/service/ExtractConfigService.java

@@ -38,7 +38,7 @@ public interface ExtractConfigService {
 	 * @param orgName		机构名称
 	 * @throws Exception
 	 */
-	public void saveExtractConfig(ExtractConfig extractConfig,String orgName,AccessUser accessUser) throws Exception;
+	public Map<String, Object> saveExtractConfig(ExtractConfig extractConfig,String orgName,AccessUser accessUser) throws Exception;
 	/**
 	 * 按照设定调卷规则生成一套试卷
 	 * 1.根据extractConfigId取出调卷规则
@@ -87,4 +87,10 @@ public interface ExtractConfigService {
 	 * @param exportModel
 	 */
 	public void exportExamPaperInfo(ExportPaperInfoModel exportModel,HttpServletResponse response);
+	/**
+	 * 检查是否所有课程都制定了调卷规则
+	 * @param examId
+	 * @return
+	 */
+	public boolean checkAllCourseByExamId(String examId);
 }

+ 1 - 1
cqb-paper/src/main/java/com/qmth/cqb/paper/service/export/DzkdExportPaperService.java

@@ -134,7 +134,7 @@ public class DzkdExportPaperService extends ExportPaperAbstractService{
 	}
 
 	@Override
-	public void uploadFile(String orgName,ExtractConfig extractConfig,String paperId,AccessUser accessUser) throws Exception {
+	public void uploadFile(ExtractConfig extractConfig,String paperId,AccessUser accessUser) throws Exception {
 		// TODO Auto-generated method stub
 		
 	}

+ 1 - 7
cqb-paper/src/main/java/com/qmth/cqb/paper/service/export/ExportPaperAbstractService.java

@@ -1,6 +1,5 @@
 package com.qmth.cqb.paper.service.export;
 
-import java.io.File;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -13,11 +12,6 @@ import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 import javax.xml.bind.JAXBElement;
 
-
-
-
-import main.java.com.UpYun;
-
 import org.apache.commons.lang3.StringUtils;
 import org.docx4j.XmlUtils;
 import org.docx4j.jaxb.Context;
@@ -177,7 +171,7 @@ public abstract class ExportPaperAbstractService {
 	 * @param paperId
 	 * @throws Exception
 	 */
-    public abstract void uploadFile(String orgName,ExtractConfig extractConfig,String paperId,AccessUser accessUser) throws Exception;
+    public abstract void uploadFile(ExtractConfig extractConfig,String paperId,AccessUser accessUser) throws Exception;
 	
 	/**
 	 * 初始化导出试卷DTO

+ 2 - 29
cqb-paper/src/main/java/com/qmth/cqb/paper/service/export/HzkjExportPaperService.java

@@ -49,35 +49,8 @@ public class HzkjExportPaperService extends ExportPaperAbstractService {
     }
 
     @Override
-    public void uploadFile(String orgName,ExtractConfig extractConfig,String paperId,AccessUser accessUser) throws Exception{
-    	Map<String,Object> dataMap = initExportPaper(paperId);
-        if (dataMap.get("fileName") != null) {
-        	String paperfileName = (String) dataMap.get("fileName")+CommonUtils.getCurNum();
-            String answerFileName = paperfileName+"__答案"+CommonUtils.getCurNum();
-            DocxProcessUtil.exportPaper(dataMap, paperfileName,HZKJ_TEMPLATE_PAPER);
-            DocxProcessUtil.exportAnswer(dataMap,answerFileName,HZKJ_TEMPLATE_ANSWER);
-            DocxProcessUtil.processImage(paperfileName,getPkgList(paperId));
-            DocxProcessUtil.processImage(answerFileName,getPkgList(paperId));
-            //得到本地文件和文件路径
-            File paperFile  = new File(TEMP_FILE_EXP+paperfileName+DOCX_SUFFIX);
-            File answerFile  = new File(TEMP_FILE_EXP+answerFileName+DOCX_SUFFIX);
-            String paperFilePath = uploadUrl+paperfileName+DOCX_SUFFIX;
-            String answerFilePath = uploadUrl+answerFileName+DOCX_SUFFIX;
-        	//上传至又拍云
-            UpYun upyun = new UpYun(bucketName,userName,password);
-			upyun.writeFile(paperFilePath, paperFile,true);
-			upyun.writeFile(answerFilePath, answerFile,true);
-			//保存上传文件记录
-			List<ExamFile> examFileList = new ArrayList<ExamFile>();
-			//试卷
-			examFileList.add(new ExamFile(extractConfig,orgName,paperfileName+DOCX_SUFFIX,downloadUrl+paperFilePath,ExamFileType.PAPER));
-			//答案
-			examFileList.add(new ExamFile(extractConfig,orgName,answerFileName+DOCX_SUFFIX,downloadUrl+answerFilePath,ExamFileType.ANSWER));
-			examFileService.saveExamFiles(examFileList,accessUser);
-			//删除本地文件
-			paperFile.delete();
-			answerFile.delete();
-        }
+    public void uploadFile(ExtractConfig extractConfig,String paperId,AccessUser accessUser) throws Exception{
+    	
     }
     
 }

+ 2 - 29
cqb-paper/src/main/java/com/qmth/cqb/paper/service/export/SddxExportPaperService.java

@@ -49,35 +49,8 @@ public class SddxExportPaperService extends ExportPaperAbstractService {
     }
 
     @Override
-    public void uploadFile(String orgName,ExtractConfig extractConfig,String paperId,AccessUser accessUser) throws Exception{
-    	Map<String,Object> dataMap = initExportPaper(paperId);
-        if (dataMap.get("fileName") != null) {
-        	String paperfileName = (String) dataMap.get("fileName")+CommonUtils.getCurNum();
-            String answerFileName = paperfileName+"__答案"+CommonUtils.getCurNum();
-            DocxProcessUtil.exportPaper(dataMap, paperfileName,SDDX_TEMPLATE_PAPER);
-            DocxProcessUtil.exportAnswer(dataMap,answerFileName,SDDX_TEMPLATE_ANSWER);
-            DocxProcessUtil.processImage(paperfileName,getPkgList(paperId));
-            DocxProcessUtil.processImage(answerFileName,getPkgList(paperId));
-            //得到本地文件和文件路径
-            File paperFile  = new File(TEMP_FILE_EXP+paperfileName+DOCX_SUFFIX);
-            File answerFile  = new File(TEMP_FILE_EXP+answerFileName+DOCX_SUFFIX);
-            String paperFilePath = uploadUrl+paperfileName+DOCX_SUFFIX;
-            String answerFilePath = uploadUrl+answerFileName+DOCX_SUFFIX;
-        	//上传至又拍云
-            UpYun upyun = new UpYun(bucketName,userName,password);
-			upyun.writeFile(paperFilePath, paperFile,true);
-			upyun.writeFile(answerFilePath, answerFile,true);
-			//保存上传文件记录
-			List<ExamFile> examFileList = new ArrayList<ExamFile>();
-			//试卷
-			examFileList.add(new ExamFile(extractConfig,orgName,paperfileName+DOCX_SUFFIX,downloadUrl+paperFilePath,ExamFileType.PAPER));
-			//答案
-			examFileList.add(new ExamFile(extractConfig,orgName,answerFileName+DOCX_SUFFIX,downloadUrl+answerFilePath,ExamFileType.ANSWER));
-			examFileService.saveExamFiles(examFileList,accessUser);
-			//删除本地文件
-			paperFile.delete();
-			answerFile.delete();
-        }
+    public void uploadFile(ExtractConfig extractConfig,String paperId,AccessUser accessUser) throws Exception{
+    	
     }
     
 }

+ 137 - 23
cqb-paper/src/main/java/com/qmth/cqb/paper/service/export/SxsfExportPaperService.java

@@ -1,6 +1,9 @@
 package com.qmth.cqb.paper.service.export;
 
 import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -12,9 +15,16 @@ import main.java.com.UpYun;
 import org.springframework.stereotype.Service;
 
 import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
+import cn.com.qmth.examcloud.common.util.excel.ExcelWriter;
 
+import com.qmth.cqb.paper.dto.ObjectiveQuestionStructure;
+import com.qmth.cqb.paper.dto.PaperDetailExp;
+import com.qmth.cqb.paper.dto.PaperDetailUnitExp;
+import com.qmth.cqb.paper.dto.PaperExp;
+import com.qmth.cqb.paper.dto.SubjectiveQuestionStructure;
 import com.qmth.cqb.paper.model.ExamFile;
 import com.qmth.cqb.paper.model.ExtractConfig;
+import com.qmth.cqb.paper.model.PaperDetailUnit;
 import com.qmth.cqb.utils.CommonUtils;
 import com.qmth.cqb.utils.enums.ExamFileType;
 import com.qmth.cqb.utils.word.DocxProcessUtil;
@@ -46,36 +56,140 @@ public class SxsfExportPaperService extends ExportPaperAbstractService {
     }
 
     @Override
-    public void uploadFile(String orgName,ExtractConfig extractConfig,String paperId,AccessUser accessUser) throws Exception{
+    public void uploadFile(ExtractConfig extractConfig,String paperId,AccessUser accessUser) throws Exception{
     	Map<String,Object> dataMap = initExportPaper(paperId);
         if (dataMap.get("fileName") != null) {
-            String paperfileName = (String) dataMap.get("fileName")+"_"+CommonUtils.getCurNum();
-            String answerFileName = paperfileName+"_答案";
-            DocxProcessUtil.exportPaper(dataMap, paperfileName,SXSF_TEMPLATE_PAPER);
-            DocxProcessUtil.exportAnswer(dataMap,answerFileName,SXSF_TEMPLATE_ANSWER);
-            DocxProcessUtil.processImage(paperfileName,getPkgList(paperId));
-            DocxProcessUtil.processImage(answerFileName,getPkgList(paperId));
-            //得到本地文件和文件路径
-            File paperFile  = new File(TEMP_FILE_EXP+paperfileName+DOCX_SUFFIX);
-            File answerFile  = new File(TEMP_FILE_EXP+answerFileName+DOCX_SUFFIX);
-            String paperFilePath = uploadUrl+paperfileName+DOCX_SUFFIX;
-            String answerFilePath = uploadUrl+answerFileName+DOCX_SUFFIX;
-        	//上传至又拍云
+        	String currNum = CommonUtils.getCurNum();
+        	uploadPaperWord(dataMap,extractConfig,paperId,accessUser,currNum);
+        	uploadAnswerWord(dataMap,extractConfig,paperId,accessUser,currNum);
+        	uploadPaperStructure(dataMap,extractConfig,paperId,accessUser,currNum);
+        }
+    }
+    
+	/**
+     * 生成试卷Word,上传至又拍云
+     * @param orgName
+     * @param dataMap
+     * @param extractConfig
+     * @param paperId
+     * @param accessUser
+     */
+    private void uploadPaperWord(Map<String,Object> dataMap,ExtractConfig extractConfig,String paperId,AccessUser accessUser,String currNum){
+    	String paperfileName = extractConfig.getCourseName()+"_"+extractConfig.getCourseCode()+"_"+currNum+"_试卷";
+    	try {
+			DocxProcessUtil.exportPaper(dataMap, paperfileName,SXSF_TEMPLATE_PAPER);
+			DocxProcessUtil.processImage(paperfileName,getPkgList(paperId));
+			File paperFile  = new File(TEMP_FILE_EXP+paperfileName+DOCX_SUFFIX);
+			String paperFilePath = uploadUrl+paperfileName+DOCX_SUFFIX;
+			//上传至又拍云
             UpYun upyun = new UpYun(bucketName,userName,password);
 			upyun.writeFile(paperFilePath, paperFile,true);
-			upyun.writeFile(answerFilePath, answerFile,true);
-			//保存上传文件记录
-			List<ExamFile> examFileList = new ArrayList<ExamFile>();
-			//试卷
-			examFileList.add(new ExamFile(extractConfig,orgName,paperfileName+DOCX_SUFFIX,paperFilePath,ExamFileType.PAPER));
-			//答案
-			examFileList.add(new ExamFile(extractConfig,orgName,answerFileName+DOCX_SUFFIX,answerFilePath,ExamFileType.ANSWER));
-			examFileService.saveExamFiles(examFileList,accessUser);
-			//删除本地文件
+			examFileService.saveExamFile(new ExamFile(extractConfig,paperfileName+DOCX_SUFFIX,paperFilePath,ExamFileType.PAPER),accessUser);
 			paperFile.delete();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+    }
+    
+    /**
+     * 生成答案Word,上传至又拍云
+     * @param orgName
+     * @param dataMap
+     * @param extractConfig
+     * @param paperId
+     * @param accessUser
+     */
+    private void uploadAnswerWord(Map<String,Object> dataMap,ExtractConfig extractConfig,String paperId,AccessUser accessUser,String currNum){
+    	String answerFileName = extractConfig.getCourseName()+"_"+extractConfig.getCourseCode()+"_"+currNum+"_答案";
+    	try {
+    		DocxProcessUtil.exportAnswer(dataMap,answerFileName,SXSF_TEMPLATE_ANSWER);
+    		DocxProcessUtil.processImage(answerFileName,getPkgList(paperId));
+    		File answerFile  = new File(TEMP_FILE_EXP+answerFileName+DOCX_SUFFIX);
+    		String answerFilePath = uploadUrl+answerFileName+DOCX_SUFFIX;
+			//上传至又拍云
+            UpYun upyun = new UpYun(bucketName,userName,password);
+			upyun.writeFile(answerFilePath, answerFile,true);
+			examFileService.saveExamFile(new ExamFile(extractConfig,answerFileName+DOCX_SUFFIX,answerFilePath,ExamFileType.ANSWER),accessUser);
 			answerFile.delete();
-        }
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
     }
     
+    /**
+     * 生成试卷结构,上传至又拍云
+     */
+    private void uploadPaperStructure(Map<String,Object> dataMap,ExtractConfig extractConfig,String paperId,AccessUser accessUser,String currNum) {
+    	exportObjectiveQuestionStructures(dataMap,extractConfig,accessUser,currNum);
+    	exportSubjectiveQuestionStructures(dataMap,extractConfig,accessUser,currNum);
+	}
+    
+    /**
+     * 获得客观题导出结构,并上传至又拍云
+     * @param paperExp
+     * @return
+     */
+    private void exportObjectiveQuestionStructures(Map<String,Object> dataMap,ExtractConfig extractConfig,AccessUser accessUser,String currNum){
+    	PaperExp paperExp = (PaperExp) dataMap.get("paper");
+    	List<PaperDetailExp> objectiveDetails = paperExp.getObjectiveDetails();
+    	List<ObjectiveQuestionStructure> objectiveQuestionStructureList = new ArrayList<ObjectiveQuestionStructure>();
+    	for(PaperDetailExp paperDetailExp:objectiveDetails){
+    		for(PaperDetailUnitExp unit:paperDetailExp.getPaperDetailUnits()){
+    			objectiveQuestionStructureList.add(new ObjectiveQuestionStructure(paperExp,paperDetailExp,unit));
+    		}
+    	}
+    	
+    	ExcelWriter objectiveExcelExporter = new ExcelWriter(ObjectiveQuestionStructure.class); 
+    	String objectiveFilename = extractConfig.getCourseName()+"_"+extractConfig.getCourseCode()+"_"+currNum+"_客观题";
+		try {
+			File file = new File(TEMP_FILE_EXP+objectiveFilename+".xlsx");
+			FileOutputStream out = new FileOutputStream(file);
+			objectiveExcelExporter.write(objectiveFilename,objectiveQuestionStructureList,out);
+			//上传至又拍云
+			String objectiveFilePath = uploadUrl+objectiveFilename+".xlsx";
+            UpYun upyun = new UpYun(bucketName,userName,password);
+			upyun.writeFile(objectiveFilePath,file,true);
+			//保存记录
+			examFileService.saveExamFile(new ExamFile(extractConfig,objectiveFilename+".xlsx",uploadUrl+objectiveFilename+".xlsx",ExamFileType.PAPER_STRUCTURE_OBJECTIVE),accessUser);
+			file.delete();
+		} catch (FileNotFoundException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+    }
+    /**
+     * 获得主观题导出结构,并上传至又拍云
+     * @param paperExp
+     * @return
+     */
+    private void exportSubjectiveQuestionStructures(Map<String,Object> dataMap,ExtractConfig extractConfig,AccessUser accessUser,String currNum){
+    	PaperExp paperExp = (PaperExp) dataMap.get("paper");
+    	List<PaperDetailExp> subjectiveDetails = paperExp.getSubjectiveDetails();
+    	List<SubjectiveQuestionStructure> subjectiveQuestionStructureList = new ArrayList<SubjectiveQuestionStructure>();
+    	for(PaperDetailExp paperDetailExp:subjectiveDetails){
+    		for(PaperDetailUnitExp unit:paperDetailExp.getPaperDetailUnits()){
+    			subjectiveQuestionStructureList.add(new SubjectiveQuestionStructure(paperExp,paperDetailExp,unit));
+    		}
+    	}
+    	ExcelWriter subjectiveExcelExporter = new ExcelWriter(SubjectiveQuestionStructure.class); 
+    	String subjectiveFileName = extractConfig.getCourseName()+"_"+extractConfig.getCourseCode()+"_"+currNum+"_主观题";
+		try {
+			File file = new File(TEMP_FILE_EXP+subjectiveFileName+".xlsx");
+			FileOutputStream out = new FileOutputStream(file);
+			subjectiveExcelExporter.write(subjectiveFileName,subjectiveQuestionStructureList,out);
+			//上传至又拍云
+			String subjectiveFilePath = uploadUrl+subjectiveFileName+".xlsx";
+            UpYun upyun = new UpYun(bucketName,userName,password);
+			upyun.writeFile(subjectiveFilePath,file,true);
+			//保存记录
+			examFileService.saveExamFile(new ExamFile(extractConfig,subjectiveFileName+".xlsx",uploadUrl+subjectiveFileName+".xlsx",ExamFileType.PAPER_STRUCTURE_SUBJECTIVE),accessUser);
+			file.delete();
+		} catch (FileNotFoundException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+    }
 }
 

+ 2 - 29
cqb-paper/src/main/java/com/qmth/cqb/paper/service/export/TjdxExportPaperService.java

@@ -49,35 +49,8 @@ public class TjdxExportPaperService extends ExportPaperAbstractService {
     }
 
     @Override
-    public void uploadFile(String orgName,ExtractConfig extractConfig,String paperId,AccessUser accessUser) throws Exception{
-    	Map<String,Object> dataMap = initExportPaper(paperId);
-        if (dataMap.get("fileName") != null) {
-        	String paperfileName = (String) dataMap.get("fileName")+CommonUtils.getCurNum();
-            String answerFileName = paperfileName+"__答案"+CommonUtils.getCurNum();
-            DocxProcessUtil.exportPaper(dataMap, paperfileName,TJDX_TEMPLATE_PAPER);
-            DocxProcessUtil.exportAnswer(dataMap,answerFileName,TJDX_TEMPLATE_ANSWER);
-            DocxProcessUtil.processImage(paperfileName,getPkgList(paperId));
-            DocxProcessUtil.processImage(answerFileName,getPkgList(paperId));
-            //得到本地文件和文件路径
-            File paperFile  = new File(TEMP_FILE_EXP+paperfileName+DOCX_SUFFIX);
-            File answerFile  = new File(TEMP_FILE_EXP+answerFileName+DOCX_SUFFIX);
-            String paperFilePath = uploadUrl+paperfileName+DOCX_SUFFIX;
-            String answerFilePath = uploadUrl+answerFileName+DOCX_SUFFIX;
-        	//上传至又拍云
-            UpYun upyun = new UpYun(bucketName,userName,password);
-			upyun.writeFile(paperFilePath, paperFile,true);
-			upyun.writeFile(answerFilePath, answerFile,true);
-			//保存上传文件记录
-			List<ExamFile> examFileList = new ArrayList<ExamFile>();
-			//试卷
-			examFileList.add(new ExamFile(extractConfig,orgName,paperfileName+DOCX_SUFFIX,downloadUrl+paperFilePath,ExamFileType.PAPER));
-			//答案
-			examFileList.add(new ExamFile(extractConfig,orgName,answerFileName+DOCX_SUFFIX,downloadUrl+answerFilePath,ExamFileType.ANSWER));
-			examFileService.saveExamFiles(examFileList,accessUser);
-			//删除本地文件
-			paperFile.delete();
-			answerFile.delete();
-        }
+    public void uploadFile(ExtractConfig extractConfig,String paperId,AccessUser accessUser) throws Exception{
+    	
     }
     
 }

+ 21 - 16
cqb-paper/src/main/java/com/qmth/cqb/paper/service/impl/ExamFileServiceImpl.java

@@ -40,22 +40,7 @@ public class ExamFileServiceImpl implements ExamFileService{
 	@Override
 	public void saveExamFiles(List<ExamFile> examFileList,AccessUser accessUser){
 		for(ExamFile examFile:examFileList){
-			ExamFile oldExamFile = new ExamFile();
-			oldExamFile.setExamId(examFile.getExamId());
-			oldExamFile.setExamType(examFile.getExamType());
-			oldExamFile.setCourseId(examFile.getCourseId());
-			oldExamFile.setExamFileType(examFile.getExamFileType());
-			oldExamFile = examFileRepo.findOne(Example.of(oldExamFile));
-			if(oldExamFile!=null){
-				//删除又拍云上的文件
-				UpYun upyun = new UpYun(bucketName,userName,password);
-				upyun.deleteFile(oldExamFile.getFilePath());
-				//删除数据库记录
-				examFileRepo.delete(oldExamFile);
-			}
-			examFile.setCreateTime(new Date());
-			examFile.setCreateUser(accessUser.getName());
-			examFileRepo.save(examFile);
+			saveExamFile(examFile,accessUser);
 		}
 	}
 
@@ -64,5 +49,25 @@ public class ExamFileServiceImpl implements ExamFileService{
 		return examFileRepo.findAll(Example.of(examFile));
 	}
 
+	@Override
+	public void saveExamFile(ExamFile examFile, AccessUser accessUser) {
+		ExamFile oldExamFile = new ExamFile();
+		oldExamFile.setExamId(examFile.getExamId());
+		oldExamFile.setExamType(examFile.getExamType());
+		oldExamFile.setCourseId(examFile.getCourseId());
+		oldExamFile.setExamFileType(examFile.getExamFileType());
+		oldExamFile = examFileRepo.findOne(Example.of(oldExamFile));
+		if(oldExamFile!=null){
+			//删除又拍云上的文件
+			UpYun upyun = new UpYun(bucketName,userName,password);
+			upyun.deleteFile(oldExamFile.getFilePath());
+			//删除数据库记录
+			examFileRepo.delete(oldExamFile);
+		}
+		examFile.setCreateTime(new Date());
+		examFile.setCreateUser(accessUser.getName());
+		examFileRepo.save(examFile);
+	}
+
 }
 

+ 30 - 1
cqb-paper/src/main/java/com/qmth/cqb/paper/service/impl/ExportStructureServiceImpl.java

@@ -1,7 +1,9 @@
 package com.qmth.cqb.paper.service.impl;
 
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -10,17 +12,20 @@ import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
 
+import cn.com.qmth.examcloud.common.dto.em.enums.ExamType;
 import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
 
 import com.qmth.cqb.paper.dao.ExportStructureRepo;
 import com.qmth.cqb.paper.model.ExportStructure;
+import com.qmth.cqb.paper.model.QuestionTypeNum;
 import com.qmth.cqb.paper.service.ExportStructureService;
+import com.qmth.cqb.utils.enums.ExportType;
 
 /**
  * @author  	chenken
  * @date    	2017年7月12日 下午4:26:49
  * @company 	QMTH
- * @description ExportStructureServiceImpl.java
+ * @description 导出试卷结构设置
  */
 @Service("exportStructureService")
 public class ExportStructureServiceImpl implements ExportStructureService {
@@ -54,6 +59,30 @@ public class ExportStructureServiceImpl implements ExportStructureService {
 		Page<ExportStructure> list = exportStructureRepo.findAll(Example.of(exportStructure), new PageRequest(curPage - 1, pageSize));
 		return list;
 	}
+
+	@Override
+	public Map<String, Object> findStructureByExamIdAndExamType(String examId,ExamType examType) {
+		Map<String, Object> returnMap = new HashMap<String, Object>();
+		ExportStructure exportStructure = findByExportStructure(new ExportStructure(examId,examType));
+		if(exportStructure==null){
+			returnMap.put("returnMsg", "no_structure");
+			return returnMap;
+		}
+		if(exportStructure.getExportType()==ExportType.NORMAL){
+			List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+			for(QuestionTypeNum questionTypeNum:questionTypeNums){
+				if(questionTypeNum.getQuantity()==null){
+					//结构设置不完整
+					returnMap.put("returnMsg", "structure_imperfect");
+					return returnMap;
+				}
+			}
+		}
+		returnMap.put("exportStructure",exportStructure);
+		return returnMap;
+	}
+	
+	
 	
 }
 

+ 68 - 9
cqb-paper/src/main/java/com/qmth/cqb/paper/service/impl/ExtractConfigServiceImpl.java

@@ -26,6 +26,7 @@ import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.stereotype.Service;
 import org.springframework.util.Assert;
 
+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;
@@ -44,11 +45,14 @@ import com.qmth.cqb.paper.dto.ExportPaperInfoModel;
 import com.qmth.cqb.paper.model.ExamFile;
 import com.qmth.cqb.paper.model.ExamPaper;
 import com.qmth.cqb.paper.model.ExportServiceManage;
+import com.qmth.cqb.paper.model.ExportStructure;
 import com.qmth.cqb.paper.model.ExtractConfig;
 import com.qmth.cqb.paper.model.Paper;
 import com.qmth.cqb.paper.model.PaperDetail;
 import com.qmth.cqb.paper.model.PaperDetailUnit;
+import com.qmth.cqb.paper.model.QuestionTypeNum;
 import com.qmth.cqb.paper.service.ExamFileService;
+import com.qmth.cqb.paper.service.ExportStructureService;
 import com.qmth.cqb.paper.service.ExtractConfigService;
 import com.qmth.cqb.paper.service.PaperDetailUnitService;
 import com.qmth.cqb.paper.service.PaperService;
@@ -104,6 +108,9 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
     @Autowired
     private ExamFileService examFileService;
     
+    @Autowired
+    private ExportStructureService exportStructureService;
+    
     @Value("${upyun.bucketName}")
 	private String bucketName;
 	
@@ -135,7 +142,7 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
 	}
 
 	@Override
-	public void saveExtractConfig(ExtractConfig extractConfig,String orgName,AccessUser accessUser) throws Exception {
+	public Map<String, Object> saveExtractConfig(ExtractConfig extractConfig,String orgName,AccessUser accessUser) throws Exception {
 		if(extractConfig.getScrambling_the_question_order()==null){
 			extractConfig.setScrambling_the_question_order((short) 0);
 		}
@@ -149,16 +156,24 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
 			paper = paperRepo.findOne(paper.getId());
 			examPaper.setPaper(paper);
 		}
+		extractConfig.setOrgName(orgName);
 		extractConfigRepo.save(extractConfig);
 		//将试卷生成Word后上传至又拍云
 		String paperId = examPapers.get(0).getPaper().getId();
-		uploadPaperFile(extractConfig,paperId,orgName,accessUser);
+		Map<String, Object> returnMap = uploadPaperFile(extractConfig,paperId,accessUser);
+		return returnMap;
 	}
 
-	private void uploadPaperFile(ExtractConfig extractConfig,String paperId,String orgName,AccessUser accessUser) throws Exception {
+	private Map<String, Object> uploadPaperFile(ExtractConfig extractConfig,String paperId,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;
+		}
 		ExportServiceManage esm = exportServiceManageRepo.findByOrgName("陕西师范大学");
     	ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils.getBeanById(esm.getExportServiceName());
-    	exportPaperAbstractService.uploadFile(orgName,extractConfig,paperId,accessUser);
+    	exportPaperAbstractService.uploadFile(extractConfig,paperId,accessUser);
+    	return null;
 	}
 
 	@Override
@@ -639,17 +654,32 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
 
 	@Override
 	public void exportExamPaperInfo(ExportPaperInfoModel exportModel,HttpServletResponse response) {
-		String examId = exportModel.getExamId();
-		List<ExamFile> examFiles = examFileService.findExamFileListByExamFile(new ExamFile(examId));
+		ExportStructure exportStructure =  exportStructureService.findByExportStructure(new ExportStructure(exportModel));
+		/*if(exportStructure.getExportType()==ExportType.ONLINE){
+			exportEncryptPackage(response);
+		}
+		if(exportStructure.getExportType()==ExportType.NORMAL){
+			exportOrdinaryFile(exportModel,exportStructure,response);
+		}*/
+		exportOrdinaryFile(exportModel,exportStructure,response);
+	}
+	
+	/**
+	 * 普通类型,可以导出试卷、答案、试卷结构
+	 * @param exportModel
+	 */
+	private void exportOrdinaryFile(ExportPaperInfoModel exportModel,ExportStructure exportStructure,HttpServletResponse response) {
+		List<ExamFile> examFiles = examFileService.findExamFileListByExamFile(new ExamFile(exportModel.getExamId()));
 		if(examFiles.size()>0){
 			//创建试卷和压缩文件 文件夹
 			createDirectory(downloadDirectory);
 			createDirectory(zipDirectory);
 			//下载文件到服务器
 			for(ExamFile examFile:examFiles){
-				String fileName = examFile.getExamFileType().getName()+"_"+examFile.getFileName();
-				FileDisposeUtil.saveUrlAs(downloadUrl+examFile.getFilePath(),downloadDirectory+"\\"+fileName);
+				FileDisposeUtil.saveUrlAs(downloadUrl+examFile.getFilePath(),downloadDirectory+"\\"+examFile.getFileName());
 			}
+			//导出试卷结构
+			exportPaperStructure(exportStructure);
 			
 			//创建压缩文件名称
 			String zipFileName = examFiles.get(0).getExamName()+"_"+
@@ -661,7 +691,36 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
 			FileDisposeUtil.downloadFile(zipFileName+".zip",zipDirectory+"\\"+zipFileName+".zip",response);
 		}
 	}
-	
+
+	/**
+	 * 导出试卷结构
+	 * @param exportStructure
+	 */
+	private void exportPaperStructure(ExportStructure exportStructure) {
+		List<QuestionTypeNum> questionTypeNumList = exportStructure.getQuestionTypeNums();
+		
+		
+		
+		
+		
+	}
+
+	/**
+	 * 导出加密数据包
+	 */
+	private void exportEncryptPackage(HttpServletResponse response) {
+		
+	}
+
+	/**
+	 * 查询该考试下是否所有课程都制定了调卷规则
+	 * @param examId
+	 */
+	@Override
+	public boolean checkAllCourseByExamId(String examId) {
+		return true;
+	}
+
 	/**
 	 * 创建文件夹
 	 * 如果已经存在,删除再新建

+ 10 - 1
cqb-paper/src/main/java/com/qmth/cqb/paper/web/ExtractConfigController.java

@@ -18,7 +18,6 @@ import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -149,4 +148,14 @@ public class ExtractConfigController {
 		extractConfigService.exportExamPaperInfo(exportModel,response);
 		return new ResponseEntity(HttpStatus.OK);
 	}
+	
+	@ApiOperation(value = "检查该考试下是否所有课程都制定了调卷规则", notes = "检查该考试下是否所有课程都制定了调卷规则")
+	@GetMapping(value = "/checkAllCourseByExamId/{examId}")
+	public ResponseEntity<Map<String, Object>> checkAllCourseByExamId(@PathVariable String examId){
+		Map<String, Object> returnMap = new HashMap<String, Object>();
+		boolean result = extractConfigService.checkAllCourseByExamId(examId);
+		returnMap.put("result", result);
+		returnMap.put("resultMsg", result?"是":"否");
+		return new ResponseEntity(returnMap,HttpStatus.OK);
+	}
 }