소스 검색

just format code styles.

deason 6 년 전
부모
커밋
af9db96d15
99개의 변경된 파일11563개의 추가작업 그리고 11237개의 파일을 삭제
  1. 51 46
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/AudioTimeConfigService.java
  2. 80 70
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/CoursePropertyService.java
  3. 39 33
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ExamFileService.java
  4. 5 4
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ExportPaperService.java
  5. 54 45
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ExportStructureService.java
  6. 54 48
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ExtractConfigProviderService.java
  7. 128 106
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ExtractConfigService.java
  8. 476 470
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ImportPaperService.java
  9. 7 7
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PaperDetailService.java
  10. 17 15
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PaperDetailUnitService.java
  11. 36 32
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PaperProviderService.java
  12. 68 46
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PaperService.java
  13. 177 174
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PaperStructService.java
  14. 79 69
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PropertyService.java
  15. 29 15
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/QuesService.java
  16. 21 19
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/QuesTypeNameService.java
  17. 53 43
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/QuestionAudioService.java
  18. 37 33
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/QuestionProviderService.java
  19. 100 100
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/CouresInfo.java
  20. 3 3
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/PaperDetailDtoAssembler.java
  21. 12 12
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/PaperDetailUnitDtoAssembler.java
  22. 3 2
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/PaperDtoAssembler.java
  23. 38 36
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/PropertyAssembler.java
  24. 6 6
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/SubQuestionDtoAssembler.java
  25. 4 3
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/condition/Condition.java
  26. 66 66
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/ExportPaperInfoModel.java
  27. 23 23
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/GenPaperDto.java
  28. 95 95
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/NumberDto.java
  29. 220 219
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/ObjectiveQuestionStructure.java
  30. 60 60
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/PageExamCourse.java
  31. 47 47
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/PaperDetailExp.java
  32. 65 64
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/PaperDetailUnitExp.java
  33. 112 109
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/PaperExp.java
  34. 7 7
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/PaperQuestionStructureInfo.java
  35. 91 91
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/PaperStructBlueprintDto.java
  36. 1 1
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/QuesNameDto.java
  37. 58 58
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/QuestionDistributeDto.java
  38. 2 0
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/SettingDto.java
  39. 151 150
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/SubjectiveQuestionStructure.java
  40. 8 8
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/valve/Valve.java
  41. 1 1
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/converter/PrintExamPaperService.java
  42. 62 62
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/BjhkExportPaperService.java
  43. 55 55
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/BjjtExportPaperService.java
  44. 62 62
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/BjsfExportPaperService.java
  45. 177 175
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/BuildComputerTestJsonService.java
  46. 100 99
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/CqdxExportPaperService.java
  47. 62 62
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/DbsfExportPaperService.java
  48. 288 282
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/DzkdExportPaperService.java
  49. 1285 1247
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/ExportPaperAbstractService.java
  50. 83 83
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/FjsfExportPaperService.java
  51. 55 55
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/HnsfExportPaperService.java
  52. 86 86
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/HzkjExportPaperService.java
  53. 348 338
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/InitPaperExpService.java
  54. 83 83
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/NkdxExportPaperService.java
  55. 54 53
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/RjgcExportPaperService.java
  56. 63 62
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/SddxExportPaperService.java
  57. 67 67
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/SxsfExportPaperService.java
  58. 128 125
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/SydxExportPaperService.java
  59. 12 12
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/TjdxExportPaperService.java
  60. 66 66
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/XnjdExportPaperService.java
  61. 56 56
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/YkdxExportPaperService.java
  62. 63 63
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/ZgddbExportPaperService.java
  63. 62 62
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/ZgddwExportPaperService.java
  64. 58 58
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/xajdExportPaperService.java
  65. 180 179
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/AudioTimeConfigServiceImpl.java
  66. 125 125
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/CoursePropertyServiceImpl.java
  67. 28 28
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/CourseService.java
  68. 77 76
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExamFileServiceImpl.java
  69. 151 150
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExportPaperServiceImpl.java
  70. 137 138
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExportStructureServiceImpl.java
  71. 610 598
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExtractConfigProviderServiceImpl.java
  72. 485 481
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExtractConfigServiceImpl.java
  73. 493 486
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/GenPaperService.java
  74. 15 15
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PaperDetailServiceImpl.java
  75. 101 96
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PaperDetailUnitServiceImpl.java
  76. 189 186
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PaperProviderServiceImpl.java
  77. 655 643
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PaperServiceImpl.java
  78. 176 175
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PropertyServiceImpl.java
  79. 339 336
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/QuesServiceImpl.java
  80. 155 155
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/QuestionAudioServiceImpl.java
  81. 503 499
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/QuestionProviderServiceImpl.java
  82. 11 10
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/initQuesHash/InitQuesHashService.java
  83. 21 21
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/initQuesHash/InitQuesHashServiceImpl.java
  84. 142 81
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/DdCollegeUtilService.java
  85. 12 11
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/ImgDataUtils.java
  86. 110 110
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/QuestionsTemp.java
  87. 45 44
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/UpdatePaperStruct.java
  88. 54 54
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/DdExcelDto.java
  89. 95 95
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/DdPaperDto.java
  90. 82 82
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/DdPaperStructDto.java
  91. 147 146
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/SubQuestionDto.java
  92. 53 53
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestFillAnswer.java
  93. 12 12
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestFillContent.java
  94. 38 38
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestOption.java
  95. 15 15
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestOptionGroup.java
  96. 56 56
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestPaper.java
  97. 109 109
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestQuestion.java
  98. 180 180
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestQuestionInfo.java
  99. 3 5
      examcloud-core-questions-service/src/test/java/org/examcloud/core/questions/service/AppTest.java

+ 51 - 46
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/AudioTimeConfigService.java

@@ -7,54 +7,59 @@ import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.core.questions.dao.entity.AudioTimeConfig;
 
 /**
- * @author  	chenken
- * @date    	2017年8月10日 下午3:16:02
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年8月10日 下午3:16:02
+ * @company QMTH
  * @description 音频次数设置service
  */
 public interface AudioTimeConfigService {
-	
-	/**
-	 * 保存
-	 */
-	public void saveAudioTimeConfig(List<AudioTimeConfig> audioTimeConfigs,User user);
-	/**
-	 * 查询
-	 * @param audioTimeConfig
-	 * @return
-	 */
-	public List<AudioTimeConfig> findByAudioTimeConfig(AudioTimeConfig audioTimeConfig);
-	/**
-	 * 根据examId删除
-	 */
-	public void deleteByExamIdAndCourseCode(String examId,String courseCode);
-	
-	/**
-	 * 根据传入的对象查询音频题
-	 * @return
-	 */
-	public List<AudioTimeConfig> findAudioTimeConfigList(List<AudioTimeConfig> audioTimeConfigModelList);
-	
-	/**
-	 * 
-	 * @param audioTimeConfigModelList
-	 * @return
-	 */
-	public List<AudioTimeConfig> findUpdateAudioTimeConfigList(List<AudioTimeConfig> audioTimeConfigModelList);
-	
-	/**
-	 * 新增音频播放次数
-	 * @param audioTimeConfig
-	 */
-	public void addAudioTimeConfig(AudioTimeConfig audioTimeConfig);
-	
-	/**
-	 * 根据考试id和课程id查询音频试题
-	 * @param examId
-	 * @return
-	 */
-	public List<AudioTimeConfig> findAudioTimeConfigByExamId(String examId,String courseCode);
-	
-	public Map<String, String> findAudioTimeConfig(String examId,String courseCode,String groupCode,String paperDetailUnitId);
+
+    /**
+     * 保存
+     */
+    public void saveAudioTimeConfig(List<AudioTimeConfig> audioTimeConfigs, User user);
+
+    /**
+     * 查询
+     *
+     * @param audioTimeConfig
+     * @return
+     */
+    public List<AudioTimeConfig> findByAudioTimeConfig(AudioTimeConfig audioTimeConfig);
+
+    /**
+     * 根据examId删除
+     */
+    public void deleteByExamIdAndCourseCode(String examId, String courseCode);
+
+    /**
+     * 根据传入的对象查询音频题
+     *
+     * @return
+     */
+    public List<AudioTimeConfig> findAudioTimeConfigList(List<AudioTimeConfig> audioTimeConfigModelList);
+
+    /**
+     * @param audioTimeConfigModelList
+     * @return
+     */
+    public List<AudioTimeConfig> findUpdateAudioTimeConfigList(List<AudioTimeConfig> audioTimeConfigModelList);
+
+    /**
+     * 新增音频播放次数
+     *
+     * @param audioTimeConfig
+     */
+    public void addAudioTimeConfig(AudioTimeConfig audioTimeConfig);
+
+    /**
+     * 根据考试id和课程id查询音频试题
+     *
+     * @param examId
+     * @return
+     */
+    public List<AudioTimeConfig> findAudioTimeConfigByExamId(String examId, String courseCode);
+
+    public Map<String, String> findAudioTimeConfig(String examId, String courseCode, String groupCode, String paperDetailUnitId);
 }
 

+ 80 - 70
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/CoursePropertyService.java

@@ -9,80 +9,90 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.dto.CoursePropertyDto;
 import cn.com.qmth.examcloud.core.questions.dao.entity.CourseProperty;
 
 /**
- * @describle 课程属性 coursePropertyService
  * @author weiwenhai
- * @date   2017.11.2
+ * @describle 课程属性 coursePropertyService
+ * @date 2017.11.2
  */
 public interface CoursePropertyService {
 
-	/**
-	 * 查询所有课程属性
-	 * @param orgId
-	 * @return
-	 */
-	public List<CourseProperty> findAllByOrgId(Long orgId);
-	
-	/**
-	 * 查询所有课程属性带分页
-	 * @param coursePropertyDto
-	 * @param pageable
-	 * @return
-	 */
-	public Page<CourseProperty> findAllByOrg(CoursePropertyDto coursePropertyDto, Pageable pageable);
-	
-	/**
-	 * 保存课程属性
-	 * @param coursePropertyDto
-	 */
-	public void saveCourseProperty(CoursePropertyDto coursePropertyDto) throws Exception;
-	
-	/**
-	 * 启用
-	 * @param id
-	 * @param orgId
-	 */
-	public void openCourseProperty(Long id);
-	
-	/**
-	 * 禁用
-	 * @param id
-	 * @param orgId
-	 */
-	public void closeCourseProperty(Long id);
-	
-	/**
-	 * 根据课程id查询所有课程属性
-	 * @param courseId
-	 * @return
-	 */
-	public List<CourseProperty> findAllByCourseId(Long courseId);
-	
-	/**
-	 * 根据课程code查询所有课程属性
-	 * @param courseId
-	 * @return
-	 */
-	public List<CourseProperty> findAllByCourseCode(String code);
-	
-	/**
-	 * 根据课程code查询所有开启的课程属性
-	 * @param code
-	 * @param enable
-	 * @return
-	 */
-	public List<CourseProperty> findAllEnable(String code, Boolean enable);
+    /**
+     * 查询所有课程属性
+     *
+     * @param orgId
+     * @return
+     */
+    public List<CourseProperty> findAllByOrgId(Long orgId);
+
+    /**
+     * 查询所有课程属性带分页
+     *
+     * @param coursePropertyDto
+     * @param pageable
+     * @return
+     */
+    public Page<CourseProperty> findAllByOrg(CoursePropertyDto coursePropertyDto, Pageable pageable);
+
+    /**
+     * 保存课程属性
+     *
+     * @param coursePropertyDto
+     */
+    public void saveCourseProperty(CoursePropertyDto coursePropertyDto) throws Exception;
+
+    /**
+     * 启用
+     *
+     * @param id
+     * @param orgId
+     */
+    public void openCourseProperty(Long id);
+
+    /**
+     * 禁用
+     *
+     * @param id
+     * @param orgId
+     */
+    public void closeCourseProperty(Long id);
+
+    /**
+     * 根据课程id查询所有课程属性
+     *
+     * @param courseId
+     * @return
+     */
+    public List<CourseProperty> findAllByCourseId(Long courseId);
+
+    /**
+     * 根据课程code查询所有课程属性
+     *
+     * @param courseId
+     * @return
+     */
+    public List<CourseProperty> findAllByCourseCode(String code);
+
+    /**
+     * 根据课程code查询所有开启的课程属性
+     *
+     * @param code
+     * @param enable
+     * @return
+     */
+    public List<CourseProperty> findAllEnable(String code, Boolean enable);
 
-	/**
-	 * 批量启用
-	 * @param idList
-	 * @param orgId
-	 */
-	public void opensCourseProperty(List<String> idList);
+    /**
+     * 批量启用
+     *
+     * @param idList
+     * @param orgId
+     */
+    public void opensCourseProperty(List<String> idList);
 
-	/**
-	 * 批量禁用
-	 * @param idList
-	 * @param orgId
-	 */
-	public void closesCourseProperty(List<String> idList);
+    /**
+     * 批量禁用
+     *
+     * @param idList
+     * @param orgId
+     */
+    public void closesCourseProperty(List<String> idList);
 }

+ 39 - 33
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ExamFileService.java

@@ -7,41 +7,47 @@ import cn.com.qmth.examcloud.core.questions.service.bean.dto.ExportPaperInfoMode
 import cn.com.qmth.examcloud.core.questions.dao.entity.ExamFile;
 
 /**
- * @author  	chenken
- * @date    	2017年7月13日 下午4:47:55
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年7月13日 下午4:47:55
+ * @company QMTH
  * @description ExamFileService.java
  */
 public interface ExamFileService {
-	/**
-	 * 批量保存考试文件
-	 * @param examFile
-	 */
-	public void saveExamFiles(List<ExamFile> examFileList,User accessUser);
-	
-	/**
-	 * 保存考试文件
-	 * @param examFile
-	 */
-	public void saveExamFile(ExamFile examFile,User accessUser);
-	
-	/**
-	 * 删除考试文件
-	 * @param examFile
-	 */
-	public void deleteExamFile(ExamFile examFile);
-	
-	/**
-	 * 根据条件查询ExamFile集合
-	 * @param examFile
-	 * @return
-	 */
-	public List<ExamFile> findExamFileListByExamFile(ExamFile examFile);
-	/**
-	 * 根据导出试卷模型查询ExamFile集合
-	 * @param exportPaperInfoModel
-	 * @return
-	 */
-	public List<ExamFile> findExamFileListByExportPaperInfoModel(ExportPaperInfoModel exportPaperInfoModel);
+    /**
+     * 批量保存考试文件
+     *
+     * @param examFile
+     */
+    public void saveExamFiles(List<ExamFile> examFileList, User accessUser);
+
+    /**
+     * 保存考试文件
+     *
+     * @param examFile
+     */
+    public void saveExamFile(ExamFile examFile, User accessUser);
+
+    /**
+     * 删除考试文件
+     *
+     * @param examFile
+     */
+    public void deleteExamFile(ExamFile examFile);
+
+    /**
+     * 根据条件查询ExamFile集合
+     *
+     * @param examFile
+     * @return
+     */
+    public List<ExamFile> findExamFileListByExamFile(ExamFile examFile);
+
+    /**
+     * 根据导出试卷模型查询ExamFile集合
+     *
+     * @param exportPaperInfoModel
+     * @return
+     */
+    public List<ExamFile> findExamFileListByExportPaperInfoModel(ExportPaperInfoModel exportPaperInfoModel);
 }
 

+ 5 - 4
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ExportPaperService.java

@@ -38,8 +38,8 @@ public interface ExportPaperService {
      * @param response
      */
     public void downQuestionDistribute(String courseNo, HttpServletResponse response) throws IOException;
-    
-    
+
+
     /**
      * 导出课程下的试题分布Excel(按试卷)
      *
@@ -47,13 +47,14 @@ public interface ExportPaperService {
      * @param response
      */
     public void downQuestionDistributeByPapers(String paperIds, HttpServletResponse response) throws IOException;
-    
+
     /**
      * 导出原始的导入试卷
+     *
      * @param paperId
      * @param response
      * @throws Exception
      */
     public void downOriginalPaper(String paperId, String loginName, HttpServletResponse response) throws Exception;
-    
+
 }

+ 54 - 45
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ExportStructureService.java

@@ -8,53 +8,62 @@ import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.core.questions.dao.entity.ExportStructure;
 
 /**
- * @author  	chenken
- * @date    	2017年7月12日 下午4:26:36
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年7月12日 下午4:26:36
+ * @company QMTH
  * @description ExportStructureService.java
  */
 public interface ExportStructureService {
-	
-	/**
-	 * 保存导出结构
-	 * @param exportStructure
-	 */
-	public void saveExportStructure(ExportStructure exportStructure,User user);
-	/**
-	 * 查询导出结构
-	 * @param exportStructure
-	 * @return
-	 */
-	public ExportStructure findByExportStructure(String orgId,String examId);
-	/**
-	 * 分页查询
-	 * @param exportStructure
-	 * @param curPage
-	 * @param pageSize
-	 * @return
-	 */
-	public Page<ExportStructure> findPageByExportStructure(ExportStructure exportStructure,int curPage,int pageSize);
-	/**
-	 * 根据考试ID查询结构
-	 * 如果结构存在、判断结构设置是否完整
-	 * 是否完整是指 客观题题数是否都设置过了
-	 * @param examId
-	 * @param examType
-	 * @return
-	 */
-	public ExportStructure findStructureByExamId(String examId);
-	
-	/**
-	 * 根据考试类型查询考试id
-	 * @param examType
-	 * @return
-	 */
-	public List<String> findExportStructureByExamType(String examType,User user);
-	
-	/**
-	 * 根据导出结构id删除
-	 * @param id
-	 */
-	public void deleteExportStructure(String id);
+
+    /**
+     * 保存导出结构
+     *
+     * @param exportStructure
+     */
+    public void saveExportStructure(ExportStructure exportStructure, User user);
+
+    /**
+     * 查询导出结构
+     *
+     * @param exportStructure
+     * @return
+     */
+    public ExportStructure findByExportStructure(String orgId, String examId);
+
+    /**
+     * 分页查询
+     *
+     * @param exportStructure
+     * @param curPage
+     * @param pageSize
+     * @return
+     */
+    public Page<ExportStructure> findPageByExportStructure(ExportStructure exportStructure, int curPage, int pageSize);
+
+    /**
+     * 根据考试ID查询结构
+     * 如果结构存在、判断结构设置是否完整
+     * 是否完整是指 客观题题数是否都设置过了
+     *
+     * @param examId
+     * @param examType
+     * @return
+     */
+    public ExportStructure findStructureByExamId(String examId);
+
+    /**
+     * 根据考试类型查询考试id
+     *
+     * @param examType
+     * @return
+     */
+    public List<String> findExportStructureByExamType(String examType, User user);
+
+    /**
+     * 根据导出结构id删除
+     *
+     * @param id
+     */
+    public void deleteExportStructure(String id);
 }
 

+ 54 - 48
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ExtractConfigProviderService.java

@@ -8,55 +8,61 @@ import cn.com.qmth.examcloud.question.commons.core.paper.DefaultPaper;
 import cn.com.qmth.examcloud.question.commons.core.question.DefaultQuestion;
 
 /**
- * @author 		weiwenhai
- * @date 		2018.8.15
- * @company		qmth
- * @describle	调卷规则远程接口
+ * @author weiwenhai
+ * @date 2018.8.15
+ * @company qmth
+ * @describle 调卷规则远程接口
  */
 public interface ExtractConfigProviderService {
 
-	/**
-	 * 根据调卷规则抽取试卷
-	 * @param req
-	 * @return
-	 */
-	public Map<String, Object> getDefaultPaper(Long examId,String courseCode,String groupCode);
-	
-	/**
-	 * 根据试题id获取试题
-	 * @param exam_id
-	 * @param course_code
-	 * @param group_code
-	 * @param questionId
-	 * @return
-	 */
-	public DefaultQuestion getDefaultQuestion(Long examId,String courseCode,String groupCode,String questionId);
-	
-	/**
-	 * 根据试卷id获取试卷
-	 * @param paperId
-	 * @return
-	 */
-	public DefaultPaper getBaseDefaultPaper(String paperId);
-	
-	/**
-	 * 根据试题id集合获取试题对象集合
-	 * @param questionIds
-	 * @return
-	 */
-	public Map<String, DefaultQuestion> getDefaultQuestions(Set<String> questionIds);
-
-	/**
-	 * 根据试题id查询试题答案
-	 * @param questionId
-	 * @return
-	 */
-	public List<String> getAnswer(String questionId);
-	
-	/**
-	 * 根据试卷id查询主观题与客观题数量
-	 * @param paperId
-	 * @return
-	 */
-	public String getQuestionStructure(String paperId) throws Exception;
+    /**
+     * 根据调卷规则抽取试卷
+     *
+     * @param req
+     * @return
+     */
+    public Map<String, Object> getDefaultPaper(Long examId, String courseCode, String groupCode);
+
+    /**
+     * 根据试题id获取试题
+     *
+     * @param exam_id
+     * @param course_code
+     * @param group_code
+     * @param questionId
+     * @return
+     */
+    public DefaultQuestion getDefaultQuestion(Long examId, String courseCode, String groupCode, String questionId);
+
+    /**
+     * 根据试卷id获取试卷
+     *
+     * @param paperId
+     * @return
+     */
+    public DefaultPaper getBaseDefaultPaper(String paperId);
+
+    /**
+     * 根据试题id集合获取试题对象集合
+     *
+     * @param questionIds
+     * @return
+     */
+    public Map<String, DefaultQuestion> getDefaultQuestions(Set<String> questionIds);
+
+    /**
+     * 根据试题id查询试题答案
+     *
+     * @param questionId
+     * @return
+     */
+    public List<String> getAnswer(String questionId);
+
+    /**
+     * 根据试卷id查询主观题与客观题数量
+     *
+     * @param paperId
+     * @return
+     */
+    public String getQuestionStructure(String paperId) throws Exception;
 }

+ 128 - 106
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ExtractConfigService.java

@@ -16,113 +16,135 @@ import cn.com.qmth.examcloud.core.questions.service.bean.CouresInfo;
 import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
 
 /**
- * 
- * @author  	chenken
- * @date    	2017年4月14日 下午6:08:15
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年4月14日 下午6:08:15
+ * @company QMTH
  * @description 调卷规则接口
  */
 public interface ExtractConfigService {
-	/**
-	 * 根据考试ID和课程code获取规则
-	 * @param examId
-	 * @param courseCode
-	 * @return
-	 */
-	public ExtractConfig findConfig(ExtractConfig extractConfig);
-	/**
-	 * 根据ID获取调卷规则
-	 * @param id
-	 * @return
-	 */
-	public ExtractConfig findConfigById(String id);
-	/**
-	 * 保存调卷规则
-	 * @param extractConfig
-	 * @param orgName		机构名称
-	 * @throws Exception
-	 */
-	public Map<String, String> saveExtractConfig2(ExtractConfig extractConfig,User user) throws Exception;
-	
-	/**
-	 * 保存调卷规则
-	 * @return
-	 * @throws Exception
-	 */
-	public List<ExamPaper> saveExtractConfig(ExtractConfig extractConfig,User user) throws Exception;
-	/**
-	 * 按照设定调卷规则生成一套试卷
-	 * 1.根据ExamPaper集合得出每个类型下应该抽取的试卷,并返回 试卷类型--->试卷的map
-	 * 2.根据小题乱序和选项乱序规则,重组试卷
-	 * 3.得到试卷类型--->试卷ID的map,设置到finishedPaperIdMap属性中
-	 * 4.如果 是第一次生成试卷,保存finishedPaperIdMap
-	 * @param extractConfigId	规则 ID
-	 * @return 类型--->试卷ID的Map集合
-	 */
-	public Map<String, String> makePaperByConfig(ExtractConfig extractConfig);
-	/**
-	 * 根据给定试卷重组试卷,生成新的试卷
-	 * @param paper					给定的试卷
-	 * @param upSetQuestionOrder	小题乱序		1:乱序  0:不乱序
-	 * @param upSetOptionOrder		选项乱序		1:乱序  0:不乱序
-	 * @return
-	 */
-	public Paper recombinationPaper(Paper paper,PaperType paperType,int upSetQuestionOrder,int upSetOptionOrder);
-	/**
-	 * 根据courseNo和orgId取出所有被引用的试卷 ID
-	 * @return
-	 */
-	public List<String> getExamPaperId(String courseCode,String orgId);
-	/**
-	 * 根据考试ID,课程code,试卷类型生成试卷
-	 * @return PaperDto
-	 */
-	public Map<String, Object> extractExamPaper(Long exam_id,String course_code,String group_code);
-	/**
-	 * 根据paperDetailUnitId抽取单个试题
-	 * @param id
-	 * @return
-	 */
-	public QuestionDto extractExamQuestion(String examId,String courseCode,String groupCode,String paperDetailUnitId);
-	/**
-	 * 判断试卷中的题是否都为客观题(单选、多选、判断),包括套题中的小题
-	 * 全为客观题返回true
-	 * 不全为客观题返回false
-	 * @param newPaper
-	 * @return
-	 */
-	public boolean checkIsAllQbjectiveQuestion(String paperId);
-	/**
-	 * 分页查询调卷规则
-	 * @param currentPage
-	 * @param pageSize
-	 * @param examId
-	 * @param courseNo
-	 * @return
-	 */
-	public Page<ExtractConfig> findPageExtractConfig(int currentPage,int pageSize, Long examId, String courseCode,String orgId);
-	
-	/**
-	 * 根据试卷id获取试卷结构
-	 * @return PaperDto
-	 */
-	public Map<String, Object> extractPaper(String paperId);
-
-
-	public PaperDto getPaperDtoByPaperNew(String basePaperId);
-	
-	/**
-	 * 根据考试id获取答案html
-	 * @param paperId
-	 * @return
-	 */
-	public String getAnswerHtml(String paperId);
-	
-	/**
-	 * 根据考试Id获取已经制定的调卷规则
-	 * @param examId
-	 * @return
-	 */
-	public List<CouresInfo> findCourseByExtractConfig(Long examId,String orgId);
-	
+    /**
+     * 根据考试ID和课程code获取规则
+     *
+     * @param examId
+     * @param courseCode
+     * @return
+     */
+    public ExtractConfig findConfig(ExtractConfig extractConfig);
+
+    /**
+     * 根据ID获取调卷规则
+     *
+     * @param id
+     * @return
+     */
+    public ExtractConfig findConfigById(String id);
+
+    /**
+     * 保存调卷规则
+     *
+     * @param extractConfig
+     * @param orgName       机构名称
+     * @throws Exception
+     */
+    public Map<String, String> saveExtractConfig2(ExtractConfig extractConfig, User user) throws Exception;
+
+    /**
+     * 保存调卷规则
+     *
+     * @return
+     * @throws Exception
+     */
+    public List<ExamPaper> saveExtractConfig(ExtractConfig extractConfig, User user) throws Exception;
+
+    /**
+     * 按照设定调卷规则生成一套试卷
+     * 1.根据ExamPaper集合得出每个类型下应该抽取的试卷,并返回 试卷类型--->试卷的map
+     * 2.根据小题乱序和选项乱序规则,重组试卷
+     * 3.得到试卷类型--->试卷ID的map,设置到finishedPaperIdMap属性中
+     * 4.如果 是第一次生成试卷,保存finishedPaperIdMap
+     *
+     * @param extractConfigId 规则 ID
+     * @return 类型--->试卷ID的Map集合
+     */
+    public Map<String, String> makePaperByConfig(ExtractConfig extractConfig);
+
+    /**
+     * 根据给定试卷重组试卷,生成新的试卷
+     *
+     * @param paper              给定的试卷
+     * @param upSetQuestionOrder 小题乱序		1:乱序  0:不乱序
+     * @param upSetOptionOrder   选项乱序		1:乱序  0:不乱序
+     * @return
+     */
+    public Paper recombinationPaper(Paper paper, PaperType paperType, int upSetQuestionOrder, int upSetOptionOrder);
+
+    /**
+     * 根据courseNo和orgId取出所有被引用的试卷 ID
+     *
+     * @return
+     */
+    public List<String> getExamPaperId(String courseCode, String orgId);
+
+    /**
+     * 根据考试ID,课程code,试卷类型生成试卷
+     *
+     * @return PaperDto
+     */
+    public Map<String, Object> extractExamPaper(Long exam_id, String course_code, String group_code);
+
+    /**
+     * 根据paperDetailUnitId抽取单个试题
+     *
+     * @param id
+     * @return
+     */
+    public QuestionDto extractExamQuestion(String examId, String courseCode, String groupCode, String paperDetailUnitId);
+
+    /**
+     * 判断试卷中的题是否都为客观题(单选、多选、判断),包括套题中的小题
+     * 全为客观题返回true
+     * 不全为客观题返回false
+     *
+     * @param newPaper
+     * @return
+     */
+    public boolean checkIsAllQbjectiveQuestion(String paperId);
+
+    /**
+     * 分页查询调卷规则
+     *
+     * @param currentPage
+     * @param pageSize
+     * @param examId
+     * @param courseNo
+     * @return
+     */
+    public Page<ExtractConfig> findPageExtractConfig(int currentPage, int pageSize, Long examId, String courseCode, String orgId);
+
+    /**
+     * 根据试卷id获取试卷结构
+     *
+     * @return PaperDto
+     */
+    public Map<String, Object> extractPaper(String paperId);
+
+
+    public PaperDto getPaperDtoByPaperNew(String basePaperId);
+
+    /**
+     * 根据考试id获取答案html
+     *
+     * @param paperId
+     * @return
+     */
+    public String getAnswerHtml(String paperId);
+
+    /**
+     * 根据考试Id获取已经制定的调卷规则
+     *
+     * @param examId
+     * @return
+     */
+    public List<CouresInfo> findCourseByExtractConfig(Long examId, String orgId);
+
 }

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 476 - 470
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ImportPaperService.java


+ 7 - 7
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PaperDetailService.java

@@ -10,7 +10,7 @@ import cn.com.qmth.examcloud.api.commons.security.bean.User;
 public interface PaperDetailService {
     /**
      * 根据Id获得对应所有小题
-     * 
+     *
      * @param id
      * @return
      */
@@ -18,7 +18,7 @@ public interface PaperDetailService {
 
     /**
      * 按ID查询大题
-     * 
+     *
      * @param id
      * @return
      */
@@ -26,7 +26,7 @@ public interface PaperDetailService {
 
     /**
      * 保存大题
-     * 
+     *
      * @param pd
      * @return
      */
@@ -34,7 +34,7 @@ public interface PaperDetailService {
 
     /**
      * 删除大题
-     * 
+     *
      * @param id
      * @return
      */
@@ -42,7 +42,7 @@ public interface PaperDetailService {
 
     /**
      * 查询同一个试卷对象对应大题
-     * 
+     *
      * @param paper
      * @return
      */
@@ -50,14 +50,14 @@ public interface PaperDetailService {
 
     /**
      * 删除试卷大题
-     * 
+     *
      * @param paper
      */
     public void deletePaperDetailsByPaper(Paper paper);
 
     /**
      * 批量删除试卷大题
-     * 
+     *
      * @param papers
      */
     public void deletePaperDetailsByPapers(List<Paper> papers);

+ 17 - 15
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PaperDetailUnitService.java

@@ -11,10 +11,9 @@ import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 
 /**
- * 
- * @author  	chenken
- * @date    	2017年9月13日 上午11:32:00
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年9月13日 上午11:32:00
+ * @company QMTH
  * @description PaperDetailUnitService.java
  */
 public interface PaperDetailUnitService {
@@ -65,34 +64,37 @@ public interface PaperDetailUnitService {
      * @param paperDetails
      */
     public void deleteUnitsByPaperDetails(List<PaperDetail> paperDetails);
-    
-    public List<PaperDetailUnit> findByQuestionAndPaperTypes(Question question,List<PaperType> paperTypes);
-    
+
+    public List<PaperDetailUnit> findByQuestionAndPaperTypes(Question question, List<PaperType> paperTypes);
+
     /**
      * 查询大题下的小题
      * 按number升序或降序排列,取第一个
+     *
      * @return
      */
-    public PaperDetailUnit findTopOrderByNumber(PaperDetail paperDetail,String orderType);
-    
+    public PaperDetailUnit findTopOrderByNumber(PaperDetail paperDetail, String orderType);
+
     /**
      * 按试卷 查询 小题,并将小题按number,createTime排序
+     *
      * @param paper
      * @return
      */
     public List<PaperDetailUnit> findByPaperAndSort(Paper paper);
-    
+
     /**
      * 根据试题id集合和试卷类型查询
+     *
      * @param ids
      * @param paperType
      * @return
      */
-    public List<PaperDetailUnit> findByQuestionsAndPaperType(List<String> ids,PaperType paperType);
-    
-    public List<PaperDetailUnit> findByDDQuestionsAndPaperType(List<String> ids,PaperType paperType,List<Question> questionList);
-    
+    public List<PaperDetailUnit> findByQuestionsAndPaperType(List<String> ids, PaperType paperType);
+
+    public List<PaperDetailUnit> findByDDQuestionsAndPaperType(List<String> ids, PaperType paperType, List<Question> questionList);
+
     //public List<PaperDetailUnit> testFind(List<String> ids,PaperType paperType,List<Question> questionList);
-    
+
     public List<PaperDetailUnit> findByPaperIds(List<String> ids);
 }

+ 36 - 32
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PaperProviderService.java

@@ -7,39 +7,43 @@ import cn.com.qmth.examcloud.core.questions.api.bean.PaperK12Bean;
 import cn.com.qmth.examcloud.question.commons.core.paper.DefaultPaper;
 
 /**
- * @author 		weiwenhai
- * @date 		2018.10.8
- * @company		qmth
- * @description	试卷对象服务接口
+ * @author weiwenhai
+ * @date 2018.10.8
+ * @company qmth
+ * @description 试卷对象服务接口
  */
 public interface PaperProviderService {
 
-	/**
-	 * 根据id集合查询试题集合
-	 * @param questionIds
-	 * @return
-	 */
-	public String genPaper(Set<String> questionIds,Map<String, PaperK12Bean> map,String paperName,String orgId,String userName);
-	
-	/**
-	 * 根据试卷id查询试卷
-	 * @param paperId
-	 * @return
-	 */
-	public DefaultPaper findPaper(String paperId);
-	
-	/**
-	 * 制定考试试卷
-	 * @return
-	 */
-	public String examPaper(String orgId, String paperId, Long examId);
-	
-	
-	/**
-	 * 根据考试Id查询试卷对象
-	 * @param examId
-	 * @return
-	 */
-	public DefaultPaper findExamPaper(String orgId, Long examId);
-	
+    /**
+     * 根据id集合查询试题集合
+     *
+     * @param questionIds
+     * @return
+     */
+    public String genPaper(Set<String> questionIds, Map<String, PaperK12Bean> map, String paperName, String orgId, String userName);
+
+    /**
+     * 根据试卷id查询试卷
+     *
+     * @param paperId
+     * @return
+     */
+    public DefaultPaper findPaper(String paperId);
+
+    /**
+     * 制定考试试卷
+     *
+     * @return
+     */
+    public String examPaper(String orgId, String paperId, Long examId);
+
+
+    /**
+     * 根据考试Id查询试卷对象
+     *
+     * @param examId
+     * @return
+     */
+    public DefaultPaper findExamPaper(String orgId, Long examId);
+
 }

+ 68 - 46
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PaperService.java

@@ -21,9 +21,9 @@ import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
 
 
 /**
- * @author  	chenken
- * @date    	2017年9月12日 上午11:21:48
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年9月12日 上午11:21:48
+ * @company QMTH
  * @description PaperService.java
  */
 public interface PaperService {
@@ -39,7 +39,7 @@ public interface PaperService {
 
     /**
      * 查询所有待审核和审核不通过的导入试卷
-     * 
+     *
      * @param paperSearchInfo
      * @param curPage
      * @param pageSize
@@ -49,7 +49,7 @@ public interface PaperService {
 
     /**
      * 根据条件查询
-     * 
+     *
      * @param paperSearchInfo
      * @return
      */
@@ -151,43 +151,52 @@ public interface PaperService {
      * @return
      */
     public PaperExp getPaperDto(String id);
+
     /**
      * 重新对选择题option进行排序(多选、单选、套题下选择题)
      */
     public void reorderChoicequestionOption(List<PaperDetailUnitExp> paperDetailUnitExps);
+
     /**
      * 初始化试卷内容(增加序号)
      *
      * @param paperExp
      */
     public void initPaper(PaperExp paperExp);
+
     /**
      * 格式化查询条件
      *
      * @param paperSearchInfo
      */
     public void formatPaperSearchInfo(PaperSearchInfo paperSearchInfo);
+
     /**
-     *1.重新设置小题number,并返回试卷总分
-     *2.重新计算大题的总分和小题总数
-     *3.重新保存试卷大题数量、小题数量、试卷总分等信息
+     * 1.重新设置小题number,并返回试卷总分
+     * 2.重新计算大题的总分和小题总数
+     * 3.重新保存试卷大题数量、小题数量、试卷总分等信息
+     *
      * @param paper
      */
     public void formatPaper(Paper paper, User user);
-	/**
+
+    /**
      * 先备份准备删掉的试题,然后再删掉
      *
      * @param questionId
      * @return
      */
     public List<String> deleteImportQuestionById(String questionId, User user);
+
     /**
      * 向试卷中插入一个试题
+     *
      * @param paperId
      * @param paperDetailId
      * @return
      */
     public Paper insertQuestionToPaper(String paperId, String paperDetailId, Question question, User user);
+
     /**
      * 获取试题所在的试卷名称
      *
@@ -195,107 +204,120 @@ public interface PaperService {
      * @return
      */
     public List<String> getPaperNamesByQuestionId(String questionId);
-    
-    public Page<Question> listQuestionforSelect(String paperId,int curPage,int pageSize,QuesStructType quesType,User user,String quesBody);
+
+    public Page<Question> listQuestionforSelect(String paperId, int curPage, int pageSize, QuesStructType quesType, User user, String quesBody);
 
     public Paper selectQuestionsToPaper(String paperId, String paperDetailId, List<Question> questions, User user);
 
     public String checkPaperName(String paperName, String orgId);
 
-    public void checkPaperNameNew(String paperName, String orgId)throws Exception;
+    public void checkPaperNameNew(String paperName, String orgId) throws Exception;
+
+    public Page<Paper> getPapersNotInIds(PaperSearchInfo paperSearchInfo, String[] ids, int curPage, int pageSize, PaperType paperType);
 
-    public Page<Paper> getPapersNotInIds(PaperSearchInfo paperSearchInfo, String[] ids, int curPage,int pageSize,PaperType paperType);
     /**
      * 将选中的导入试卷复制为卷库试卷
      */
-    public void useBasePaper(String selectedPaperIds,String userId);
+    public void useBasePaper(String selectedPaperIds, String userId);
+
     /**
      * 根据试卷名称、试卷类型检查名称是否存在
+     *
      * @param paperName
      * @param paperType
      * @param orgId
      * @return
      * @throws Exception
      */
-    public boolean checkPaperName(String paperName, PaperType paperType,String orgId)throws Exception;
-    
+    public boolean checkPaperName(String paperName, PaperType paperType, String orgId) throws Exception;
+
     /**
      * 上传音频文件检查
+     *
      * @param paperId
      * @param filesName
      * @return
      */
-    public Map<String, String> checkRadioFile(String paperId,List<String> filesName);
-    
+    public Map<String, String> checkRadioFile(String paperId, List<String> filesName);
+
     //判断选项
-    public Map<String, String> checkOptions(List<PaperDetailUnit> paperDetailUnits,String fileNames[],String fileName);
-    
+    public Map<String, String> checkOptions(List<PaperDetailUnit> paperDetailUnits, String fileNames[], String fileName);
+
     /**
      * 上传音频文件到又拍云
+     *
      * @param files
      * @param paperId
      * @param accessUser
      * @throws IOException
      */
-    public void uploadRadio(List<MultipartFile> files,String paperId,User user) throws IOException;
-    
+    public void uploadRadio(List<MultipartFile> files, String paperId, User user) throws IOException;
+
     /**
      * 音频文件插入到标签
+     *
      * @param files
      * @param paperId
      */
-    public void appendAudioTag(String fileName,String questionId);
-    
+    public void appendAudioTag(String fileName, String questionId);
+
     /**
      * 计算试卷难度
+     *
      * @param paper
      * @param paperTotalScore
      * @return
      */
-    public Double reSetDifficulty(Paper paper,double paperTotalScore);
-    
+    public Double reSetDifficulty(Paper paper, double paperTotalScore);
+
     /**
      * 获取Html片段
+     *
      * @param paperId
      * @return
      */
-    public Map<String, Object> getPaperPDF(String paperId,String type) throws Exception;
-
-	/**
-	 * pdf路径传至印刷平台
-	 * @param paperId
-	 * @param paperHtmlUrl
-	 */
-	public String sendPrint(String paperId, String orgId, String examId);
-
-	/**
-	 * 根据试卷id查询主观题与客观题的数量
-	 * @param paperId
-	 */
-	public String findQuestionStructure(String paperId) throws Exception;
-	
-	/**
+    public Map<String, Object> getPaperPDF(String paperId, String type) throws Exception;
+
+    /**
+     * pdf路径传至印刷平台
+     *
+     * @param paperId
+     * @param paperHtmlUrl
+     */
+    public String sendPrint(String paperId, String orgId, String examId);
+
+    /**
+     * 根据试卷id查询主观题与客观题的数量
+     *
+     * @param paperId
+     */
+    public String findQuestionStructure(String paperId) throws Exception;
+
+    /**
      * 导出试卷Dto
+     *
      * @param paperId
      * @return
      */
     public PaperExp getDownPaperExp(String paperId) throws Exception;
-    
+
     /**
      * 根据试卷id,公开度,难度查询题目数量
+     *
      * @param paperId
      * @param publicityType
      * @param difficultyType
      * @return
      */
-    public int getQuestionTypeNumbers(String paperId,Integer publicityType,Integer difficultyType);
-    
+    public int getQuestionTypeNumbers(String paperId, Integer publicityType, Integer difficultyType);
+
     /**
      * 根据试卷id,公开度,难度查询题目分数
+     *
      * @param paperId
      * @param publicityType
      * @param difficultyType
      * @return
      */
-    public double getQuestionTypeScore(String paperId,Integer publicityType,Integer difficultyType);
+    public double getQuestionTypeScore(String paperId, Integer publicityType, Integer difficultyType);
 }

+ 177 - 174
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PaperStructService.java

@@ -44,79 +44,80 @@ public class PaperStructService {
 
     @Autowired
     MongoTemplate mongoTemplate;
-    
+
     @Autowired
     CourseCloudService courseCloudService;
 
     /**
      * 获取所有试卷结构(分页)
-     * 
+     *
      * @param searchInfo
      * @param curPage
      * @param pageSize
      * @return
      */
     public Page<PaperStruct> getPaperStructs(PaperStructSearchInfo searchInfo, int curPage, int pageSize) {
-    	Query query = new Query();
+        Query query = new Query();
         query.addCriteria(Criteria.where("orgId").is(searchInfo.getOrgId()));
         query.addCriteria(Criteria.where("type").is(searchInfo.getType()));
-        if(StringUtils.isNotBlank(searchInfo.getName())){
-        	String paperStructName = CommonUtils.escapeExprSpecialWord(searchInfo.getName());
-        	query.addCriteria(Criteria.where("name").regex(".*?" + paperStructName + ".*"));
+        if (StringUtils.isNotBlank(searchInfo.getName())) {
+            String paperStructName = CommonUtils.escapeExprSpecialWord(searchInfo.getName());
+            query.addCriteria(Criteria.where("name").regex(".*?" + paperStructName + ".*"));
         }
-        if(StringUtils.isNotBlank(searchInfo.getCreator())){
-        	String userName = CommonUtils.escapeExprSpecialWord(searchInfo.getCreator());
-        	query.addCriteria(Criteria.where("creator").regex(".*?" + userName + ".*"));
+        if (StringUtils.isNotBlank(searchInfo.getCreator())) {
+            String userName = CommonUtils.escapeExprSpecialWord(searchInfo.getCreator());
+            query.addCriteria(Criteria.where("creator").regex(".*?" + userName + ".*"));
         }
         //判断试卷结构
-        if(searchInfo.getType().equals("EXACT")){
-        	if(StringUtils.isNotBlank(searchInfo.getCourseNo())){
-            	if(!searchInfo.getCourseNo().equals("ALL")){
-            		query.addCriteria(Criteria.where("courseNo").is(searchInfo.getCourseNo()));
-            	}
-            }else{
-            	query.addCriteria(Criteria.where("courseNo").is(""));
+        if (searchInfo.getType().equals("EXACT")) {
+            if (StringUtils.isNotBlank(searchInfo.getCourseNo())) {
+                if (!searchInfo.getCourseNo().equals("ALL")) {
+                    query.addCriteria(Criteria.where("courseNo").is(searchInfo.getCourseNo()));
+                }
+            } else {
+                query.addCriteria(Criteria.where("courseNo").is(""));
             }
-        }else {
-        	if(StringUtils.isNotBlank(searchInfo.getCourseNo())){
-            	query.addCriteria(Criteria.where("courseNo").is(searchInfo.getCourseNo()));
+        } else {
+            if (StringUtils.isNotBlank(searchInfo.getCourseNo())) {
+                query.addCriteria(Criteria.where("courseNo").is(searchInfo.getCourseNo()));
             }
-		}
+        }
         long count = this.mongoTemplate.count(query, PaperStruct.class);
-        query.with(new Sort(new Sort.Order(Sort.Direction.DESC,"createTime")));
+        query.with(new Sort(new Sort.Order(Sort.Direction.DESC, "createTime")));
         query.limit(pageSize);
         query.skip((curPage - 1) * pageSize);
         List<PaperStruct> paperList = this.mongoTemplate.find(query, PaperStruct.class);
         //远程调用rmi,查询课程名称
-        if(paperList != null && paperList.size()>0){
-        	for(PaperStruct paperStruct:paperList){
-        		if(StringUtils.isBlank(paperStruct.getCourseNo())){
-        			paperStruct.setCourseName("公用");
-        		}else {
-        			GetCourseReq req = new GetCourseReq();
-            		req.setRootOrgId(Long.valueOf(paperStruct.getOrgId()));
-            		req.setCode(paperStruct.getCourseNo());
-            		GetCourseResp resp = courseCloudService.getCourse(req);
-            		paperStruct.setCourseName(resp.getCourseBean().getName());
-				}
-        	}
+        if (paperList != null && paperList.size() > 0) {
+            for (PaperStruct paperStruct : paperList) {
+                if (StringUtils.isBlank(paperStruct.getCourseNo())) {
+                    paperStruct.setCourseName("公用");
+                } else {
+                    GetCourseReq req = new GetCourseReq();
+                    req.setRootOrgId(Long.valueOf(paperStruct.getOrgId()));
+                    req.setCode(paperStruct.getCourseNo());
+                    GetCourseResp resp = courseCloudService.getCourse(req);
+                    paperStruct.setCourseName(resp.getCourseBean().getName());
+                }
+            }
         }
         return new PageImpl<PaperStruct>(paperList, new PageRequest(curPage - 1, pageSize), count);
     }
 
     /**
      * 获取所有试卷结构(分页)
+     *
      * @param searchInfo
      * @return
      */
     public List<PaperStruct> getPaperStructs(PaperStructSearchInfo searchInfo) {
         Query query = new Query();
-        if(StringUtils.isNotBlank(searchInfo.getCourseNo())){
+        if (StringUtils.isNotBlank(searchInfo.getCourseNo())) {
             query.addCriteria(Criteria.where("courseNo")
-                    .in("",searchInfo.getCourseNo()));
+                    .in("", searchInfo.getCourseNo()));
         }
         query.addCriteria(Criteria.where("orgId").is(searchInfo.getOrgId()));
-        query.with(new Sort(new Sort.Order(Sort.Direction.DESC,"createTime")));
+        query.with(new Sort(new Sort.Order(Sort.Direction.DESC, "createTime")));
         List<PaperStruct> paperList = this.mongoTemplate.find(query, PaperStruct.class);
         return paperList;
     }
@@ -139,7 +140,7 @@ public class PaperStructService {
 
     /**
      * 保存试卷结构
-     * 
+     *
      * @param paperStruct
      * @return
      */
@@ -148,7 +149,7 @@ public class PaperStructService {
             PaperStruct oldPaperStruct = Model.of(paperStructRepo.findById(paperStruct.getId()));
             PaperStruct rps = null;
             if (oldPaperStruct != null && !paperStruct.getName().equals(oldPaperStruct.getName())) {// 那么就是更新操作
-                rps = this.checkNameUnique(paperStruct.getName(), user.getRootOrgId().toString(),oldPaperStruct.getType());
+                rps = this.checkNameUnique(paperStruct.getName(), user.getRootOrgId().toString(), oldPaperStruct.getType());
             }
             if (rps != null) {
                 return null;
@@ -157,7 +158,7 @@ public class PaperStructService {
         List<PaperDetailStruct> paperDetailStructs = paperStruct.getPaperDetailStructs();
         int number = 0;
         //新增精确试卷结构
-        if(paperStruct.getType().equals("EXACT")){
+        if (paperStruct.getType().equals("EXACT")) {
             for (PaperDetailStruct paperDetailStruct : paperDetailStructs) {
                 List<PaperDetailUnitStruct> oldStructs = paperDetailStruct.getPaperDetailUnitStructs();
                 if (oldStructs != null && oldStructs.size() > 0) {
@@ -165,12 +166,12 @@ public class PaperStructService {
                 }
                 List<PaperDetailUnitStruct> unitStructs = new ArrayList<PaperDetailUnitStruct>();
                 for (PaperDetailUnitStructDto unitStructDto : paperDetailStruct.getUnitStructs()) {
-                	//公开简单总数
-                	for(int i = 0;i<unitStructDto.getPublicSimple();i++){
-                		++number;
-                		PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct();
+                    //公开简单总数
+                    for (int i = 0; i < unitStructDto.getPublicSimple(); i++) {
+                        ++number;
+                        PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct();
                         unitStruct.setDifficulty("易");
-                		unitStruct.setPublicity(true);
+                        unitStruct.setPublicity(true);
                         unitStruct.setId(String.valueOf(number));
                         unitStruct.setNumber(number);
                         unitStruct.setScore(unitStructDto.getScore());
@@ -178,13 +179,13 @@ public class PaperStructService {
                         unitStruct.setQuesNames(unitStructDto.getQuesNames());
                         unitStruct.setPropertyGroup(buildGroup(unitStruct));
                         unitStructs.add(unitStruct);
-                	}
-                	//公开中等总数
-                	for(int i = 0;i<unitStructDto.getPublicMedium();i++){
-                		++number;
-                		PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct();
+                    }
+                    //公开中等总数
+                    for (int i = 0; i < unitStructDto.getPublicMedium(); i++) {
+                        ++number;
+                        PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct();
                         unitStruct.setDifficulty("中");
-                		unitStruct.setPublicity(true);
+                        unitStruct.setPublicity(true);
                         unitStruct.setId(String.valueOf(number));
                         unitStruct.setNumber(number);
                         unitStruct.setScore(unitStructDto.getScore());
@@ -192,13 +193,13 @@ public class PaperStructService {
                         unitStruct.setQuesNames(unitStructDto.getQuesNames());
                         unitStruct.setPropertyGroup(buildGroup(unitStruct));
                         unitStructs.add(unitStruct);
-                	}
-                	//公开困难总数
-                	for(int i = 0;i<unitStructDto.getPublicDifficulty();i++){
-                		++number;
-                		PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct();
+                    }
+                    //公开困难总数
+                    for (int i = 0; i < unitStructDto.getPublicDifficulty(); i++) {
+                        ++number;
+                        PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct();
                         unitStruct.setDifficulty("难");
-                		unitStruct.setPublicity(true);
+                        unitStruct.setPublicity(true);
                         unitStruct.setId(String.valueOf(number));
                         unitStruct.setNumber(number);
                         unitStruct.setScore(unitStructDto.getScore());
@@ -206,13 +207,13 @@ public class PaperStructService {
                         unitStruct.setQuesNames(unitStructDto.getQuesNames());
                         unitStruct.setPropertyGroup(buildGroup(unitStruct));
                         unitStructs.add(unitStruct);
-                	}
-                	//非公开简单总数
-                	for(int i = 0;i<unitStructDto.getNoPublicSimple();i++){
-                		++number;
-                		PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct();
+                    }
+                    //非公开简单总数
+                    for (int i = 0; i < unitStructDto.getNoPublicSimple(); i++) {
+                        ++number;
+                        PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct();
                         unitStruct.setDifficulty("易");
-                		unitStruct.setPublicity(false);
+                        unitStruct.setPublicity(false);
                         unitStruct.setId(String.valueOf(number));
                         unitStruct.setNumber(number);
                         unitStruct.setScore(unitStructDto.getScore());
@@ -220,13 +221,13 @@ public class PaperStructService {
                         unitStruct.setQuesNames(unitStructDto.getQuesNames());
                         unitStruct.setPropertyGroup(buildGroup(unitStruct));
                         unitStructs.add(unitStruct);
-                	}
-                	//非公开中等总数
-                	for(int i = 0;i<unitStructDto.getNoPublicMedium();i++){
-                		++number;
-                		PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct();
+                    }
+                    //非公开中等总数
+                    for (int i = 0; i < unitStructDto.getNoPublicMedium(); i++) {
+                        ++number;
+                        PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct();
                         unitStruct.setDifficulty("中");
-                		unitStruct.setPublicity(false);
+                        unitStruct.setPublicity(false);
                         unitStruct.setId(String.valueOf(number));
                         unitStruct.setNumber(number);
                         unitStruct.setScore(unitStructDto.getScore());
@@ -234,13 +235,13 @@ public class PaperStructService {
                         unitStruct.setQuesNames(unitStructDto.getQuesNames());
                         unitStruct.setPropertyGroup(buildGroup(unitStruct));
                         unitStructs.add(unitStruct);
-                	}
-                	//非公开困难总数
-                	for(int i = 0;i<unitStructDto.getNoPublicDifficulty();i++){
-                		++number;
-                		PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct();
+                    }
+                    //非公开困难总数
+                    for (int i = 0; i < unitStructDto.getNoPublicDifficulty(); i++) {
+                        ++number;
+                        PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct();
                         unitStruct.setDifficulty("难");
-                		unitStruct.setPublicity(false);
+                        unitStruct.setPublicity(false);
                         unitStruct.setId(String.valueOf(number));
                         unitStruct.setNumber(number);
                         unitStruct.setScore(unitStructDto.getScore());
@@ -248,136 +249,138 @@ public class PaperStructService {
                         unitStruct.setQuesNames(unitStructDto.getQuesNames());
                         unitStruct.setPropertyGroup(buildGroup(unitStruct));
                         unitStructs.add(unitStruct);
-                	}
+                    }
                 }
                 paperDetailStruct.setPaperDetailUnitStructs(unitStructs);
             }
             paperStruct.setPaperStrucType(PaperStructType.EXACT);
             paperStruct.setDetailUnitCount(paperDetailStructs.stream().mapToInt(PaperDetailStruct::getDetailCount).sum());
-        }else {
-			//新增蓝图试卷结构
-        	for(PaperDetailStruct paperDetailStruct : paperDetailStructs){
-        		List<PaperDetailUnitStruct> oldStructs = paperDetailStruct.getPaperDetailUnitStructs();
+        } else {
+            //新增蓝图试卷结构
+            for (PaperDetailStruct paperDetailStruct : paperDetailStructs) {
+                List<PaperDetailUnitStruct> oldStructs = paperDetailStruct.getPaperDetailUnitStructs();
                 if (oldStructs != null && oldStructs.size() > 0) {
                     oldStructs.clear();
                 }
                 List<PaperDetailUnitStruct> unitStructs = new ArrayList<PaperDetailUnitStruct>();
-                for(CoursePropertyNumberDto coursePropertyNumberDto:paperDetailStruct.getCoursePropertyNumberDtos()){
-                	//取到子节点上的题目
-                	if(!coursePropertyNumberDto.getDisable()){
-                		//公开简单数量
-                    	for(int i=0;i<coursePropertyNumberDto.getPublicSimple();i++){
-                    		++number;
-                    		PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct(paperDetailStruct,number,coursePropertyNumberDto);
-                    		unitStruct.setDifficulty("易");
-                    		unitStruct.setPublicity(true);
-                    		unitStruct.setPropertyGroup(buildPropertyGroup(unitStruct));
-                    		unitStructs.add(unitStruct);
-                    	}
-                    	//公开中等数量
-                    	for(int i=0;i<coursePropertyNumberDto.getPublicMedium();i++){
-                    		++number;
-                    		PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct(paperDetailStruct,number,coursePropertyNumberDto);
-                    		unitStruct.setDifficulty("中");
-                    		unitStruct.setPublicity(true);
-                    		unitStruct.setPropertyGroup(buildPropertyGroup(unitStruct));
-                    		unitStructs.add(unitStruct);
-                    	}
-                    	//公开困难数量
-                    	for(int i=0;i<coursePropertyNumberDto.getPublicDifficulty();i++){
-                    		++number;
-                    		PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct(paperDetailStruct,number,coursePropertyNumberDto);
-                    		unitStruct.setDifficulty("难");
-                    		unitStruct.setPublicity(true);
-                    		unitStruct.setPropertyGroup(buildPropertyGroup(unitStruct));
-                    		unitStructs.add(unitStruct);
-                    	}
-                    	//非公开简单数量
-                    	for(int i=0;i<coursePropertyNumberDto.getNoPublicSimple();i++){
-                    		++number;
-                    		PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct(paperDetailStruct,number,coursePropertyNumberDto);
-                    		unitStruct.setDifficulty("易");
-                    		unitStruct.setPublicity(false);
-                    		unitStruct.setPropertyGroup(buildPropertyGroup(unitStruct));
-                    		unitStructs.add(unitStruct);
-                    	}
-                    	//非公开中等数量
-                    	for(int i=0;i<coursePropertyNumberDto.getNoPublicMedium();i++){
-                    		++number;
-                    		PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct(paperDetailStruct,number,coursePropertyNumberDto);
-                    		unitStruct.setDifficulty("中");
-                    		unitStruct.setPublicity(false);
-                    		unitStruct.setPropertyGroup(buildPropertyGroup(unitStruct));
-                    		unitStructs.add(unitStruct);
-                    	}
-                    	//非公开困难
-                    	for(int i=0;i<coursePropertyNumberDto.getNoPublicDifficulty();i++){
-                    		++number;
-                    		PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct(paperDetailStruct,number,coursePropertyNumberDto);
-                    		unitStruct.setDifficulty("难");
-                    		unitStruct.setPublicity(false);
-                    		unitStruct.setPropertyGroup(buildPropertyGroup(unitStruct));
-                    		unitStructs.add(unitStruct);
-                    	}
-                	}
+                for (CoursePropertyNumberDto coursePropertyNumberDto : paperDetailStruct.getCoursePropertyNumberDtos()) {
+                    //取到子节点上的题目
+                    if (!coursePropertyNumberDto.getDisable()) {
+                        //公开简单数量
+                        for (int i = 0; i < coursePropertyNumberDto.getPublicSimple(); i++) {
+                            ++number;
+                            PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct(paperDetailStruct, number, coursePropertyNumberDto);
+                            unitStruct.setDifficulty("易");
+                            unitStruct.setPublicity(true);
+                            unitStruct.setPropertyGroup(buildPropertyGroup(unitStruct));
+                            unitStructs.add(unitStruct);
+                        }
+                        //公开中等数量
+                        for (int i = 0; i < coursePropertyNumberDto.getPublicMedium(); i++) {
+                            ++number;
+                            PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct(paperDetailStruct, number, coursePropertyNumberDto);
+                            unitStruct.setDifficulty("中");
+                            unitStruct.setPublicity(true);
+                            unitStruct.setPropertyGroup(buildPropertyGroup(unitStruct));
+                            unitStructs.add(unitStruct);
+                        }
+                        //公开困难数量
+                        for (int i = 0; i < coursePropertyNumberDto.getPublicDifficulty(); i++) {
+                            ++number;
+                            PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct(paperDetailStruct, number, coursePropertyNumberDto);
+                            unitStruct.setDifficulty("难");
+                            unitStruct.setPublicity(true);
+                            unitStruct.setPropertyGroup(buildPropertyGroup(unitStruct));
+                            unitStructs.add(unitStruct);
+                        }
+                        //非公开简单数量
+                        for (int i = 0; i < coursePropertyNumberDto.getNoPublicSimple(); i++) {
+                            ++number;
+                            PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct(paperDetailStruct, number, coursePropertyNumberDto);
+                            unitStruct.setDifficulty("易");
+                            unitStruct.setPublicity(false);
+                            unitStruct.setPropertyGroup(buildPropertyGroup(unitStruct));
+                            unitStructs.add(unitStruct);
+                        }
+                        //非公开中等数量
+                        for (int i = 0; i < coursePropertyNumberDto.getNoPublicMedium(); i++) {
+                            ++number;
+                            PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct(paperDetailStruct, number, coursePropertyNumberDto);
+                            unitStruct.setDifficulty("中");
+                            unitStruct.setPublicity(false);
+                            unitStruct.setPropertyGroup(buildPropertyGroup(unitStruct));
+                            unitStructs.add(unitStruct);
+                        }
+                        //非公开困难
+                        for (int i = 0; i < coursePropertyNumberDto.getNoPublicDifficulty(); i++) {
+                            ++number;
+                            PaperDetailUnitStruct unitStruct = new PaperDetailUnitStruct(paperDetailStruct, number, coursePropertyNumberDto);
+                            unitStruct.setDifficulty("难");
+                            unitStruct.setPublicity(false);
+                            unitStruct.setPropertyGroup(buildPropertyGroup(unitStruct));
+                            unitStructs.add(unitStruct);
+                        }
+                    }
                 }
                 paperDetailStruct.setPaperDetailUnitStructs(unitStructs);
-        	}
-        	paperStruct.setPaperStrucType(PaperStructType.BLUEPRINT);
-        	//计算试卷结构难度
-			Double difficulty = getDifficulty(paperDetailStructs,paperStruct.getTotalScore());
-			paperStruct.setDifficulty(difficulty);
-		}
+            }
+            paperStruct.setPaperStrucType(PaperStructType.BLUEPRINT);
+            //计算试卷结构难度
+            Double difficulty = getDifficulty(paperDetailStructs, paperStruct.getTotalScore());
+            paperStruct.setDifficulty(difficulty);
+        }
         paperStruct.setOrgId(user.getRootOrgId().toString());
         paperStruct.setCreator(user.getDisplayName());
         paperStruct.setCreateTime(CommonUtils.getCurDateTime());
         paperStruct.setDetailCount(paperDetailStructs.size());
         return paperStructRepo.save(paperStruct);
     }
-    
+
     /**
      * 构建精确组建筛选条件
+     *
      * @param unitStruct
      * @return
      */
-    private String buildGroup(PaperDetailUnitStruct unitStruct){
-    	return String.valueOf(unitStruct.getPublicity()) + "-" + unitStruct.getDifficulty();
+    private String buildGroup(PaperDetailUnitStruct unitStruct) {
+        return String.valueOf(unitStruct.getPublicity()) + "-" + unitStruct.getDifficulty();
     }
 
     /**
      * 构建单个属性组(用来筛选题目)
+     *
      * @param unitStruct
      */
     private String buildPropertyGroup(PaperDetailUnitStruct unitStruct) {
-    	return unitStruct.getPropertyId() + "-" + String.valueOf(unitStruct.getPublicity()) + "-" + unitStruct.getDifficulty();
-	}
+        return unitStruct.getPropertyId() + "-" + String.valueOf(unitStruct.getPublicity()) + "-" + unitStruct.getDifficulty();
+    }
 
-	public Double getDifficulty(List<PaperDetailStruct> paperDetailStructs,Double totalScore) {
-		Double sum = 0.0;
-		if(paperDetailStructs != null && paperDetailStructs.size() >0){
-			Integer simpleCount = 0;
-			Integer mediumCount = 0;
-			Integer difficultyCount = 0;
-			for(PaperDetailStruct paperDetailStruct:paperDetailStructs){
-				simpleCount = paperDetailStruct.getPublicSimpleCount() + paperDetailStruct.getNoPublicSimpleCount();
-				mediumCount = paperDetailStruct.getPublicMediumCount() + paperDetailStruct.getNoPublicMediumCount();
-				difficultyCount = paperDetailStruct.getPublicDifficultyCount() + paperDetailStruct.getNoPublicDifficultyCount();
-				sum = simpleCount * paperDetailStruct.getScore() * 0.8 + mediumCount * paperDetailStruct.getScore() * 0.5 + difficultyCount * paperDetailStruct.getScore() * 0.2 + sum;
-			}
-			Double dif = sum / totalScore;
-			BigDecimal b = new BigDecimal(dif);
-			Double difficulty = b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
-			return difficulty;
-		}
-		return (double)0;
-	}
+    public Double getDifficulty(List<PaperDetailStruct> paperDetailStructs, Double totalScore) {
+        Double sum = 0.0;
+        if (paperDetailStructs != null && paperDetailStructs.size() > 0) {
+            Integer simpleCount = 0;
+            Integer mediumCount = 0;
+            Integer difficultyCount = 0;
+            for (PaperDetailStruct paperDetailStruct : paperDetailStructs) {
+                simpleCount = paperDetailStruct.getPublicSimpleCount() + paperDetailStruct.getNoPublicSimpleCount();
+                mediumCount = paperDetailStruct.getPublicMediumCount() + paperDetailStruct.getNoPublicMediumCount();
+                difficultyCount = paperDetailStruct.getPublicDifficultyCount() + paperDetailStruct.getNoPublicDifficultyCount();
+                sum = simpleCount * paperDetailStruct.getScore() * 0.8 + mediumCount * paperDetailStruct.getScore() * 0.5 + difficultyCount * paperDetailStruct.getScore() * 0.2 + sum;
+            }
+            Double dif = sum / totalScore;
+            BigDecimal b = new BigDecimal(dif);
+            Double difficulty = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+            return difficulty;
+        }
+        return (double) 0;
+    }
 
     public PaperStruct checkNameUnique(String name, String orgId, String type) {
-    	Query query = new Query();
-    	query.addCriteria(Criteria.where("orgId").is(orgId));
-    	query.addCriteria(Criteria.where("name").is(name.trim()));
-    	query.addCriteria(Criteria.where("type").is(type));
-    	PaperStruct paperStruct = this.mongoTemplate.findOne(query, PaperStruct.class);
+        Query query = new Query();
+        query.addCriteria(Criteria.where("orgId").is(orgId));
+        query.addCriteria(Criteria.where("name").is(name.trim()));
+        query.addCriteria(Criteria.where("type").is(type));
+        PaperStruct paperStruct = this.mongoTemplate.findOne(query, PaperStruct.class);
         return paperStruct;
     }
 
@@ -400,8 +403,8 @@ public class PaperStructService {
         return quesNameList;
     }
 
-    private QuesNameDto getQuesName(String name){
-        return new QuesNameDto(name,name);
+    private QuesNameDto getQuesName(String name) {
+        return new QuesNameDto(name, name);
     }
 
 }

+ 79 - 69
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PropertyService.java

@@ -7,77 +7,87 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.dto.PropertyDto;
 import cn.com.qmth.examcloud.core.questions.dao.entity.Property;
 
 /**
+ * @author weiwenhai
  * @describle 属性service
- * @author    weiwenhai
- * @date      2017.11.6
+ * @date 2017.11.6
  */
 public interface PropertyService {
 
-	/**
-	 * 保存属性
-	 * @param propertyDtos
-	 */
-	public void saveProperty(List<PropertyDto> propertyDtos, User user);
-	
-	/**
-	 * 查询属性
-	 * @param coursePropertyId
-	 * @param user
-	 * @return
-	 */
-	public List<PropertyDto> propertyDtos(Long coursePropertyId, User user);
-	
-	/**
-	 * 新增属性
-	 * @param property
-	 * @param user
-	 */
-	public void saveProperty(Property property, User user) throws Exception;
-	
-	/**
-	 * 删除属性
-	 * @param propertyId
-	 */
-	public void deleteProperty(Long propertyId, Long coursePropertyId, User user);
-	
-	/**
-	 * 查询所有属性
-	 * @param coursePropertyId
-	 * @param user
-	 * @return
-	 */
-	public List<Property> findAll(Long coursePropertyId, User user);
-	
-	/**
-	 * 查询某个树下的子节点
-	 * @param property
-	 * @return
-	 */
-	public List<Property> findPropertySons(Property property);
-	
-	/**
-	 * 查询某个树下的子节点
-	 * @param property
-	 * @return
-	 */
-	public List<Property> findPropertySons(Long propertyId);
-	
-	/**
-	 * 查询课程属性下面的所有父节点
-	 * @param property
-	 * @return
-	 */
-	public List<Property> findPropertyParents(Long coursePropertyId, Long orgId);
-	
-	/**
-	 * 上移
-	 * @param property
-	 */
-	public void moveUp(Property property) throws Exception;
-	
-	/**
-	 * 下移
-	 * @param property
-	 */
-	public void moveDown(Property property) throws Exception;
+    /**
+     * 保存属性
+     *
+     * @param propertyDtos
+     */
+    public void saveProperty(List<PropertyDto> propertyDtos, User user);
+
+    /**
+     * 查询属性
+     *
+     * @param coursePropertyId
+     * @param user
+     * @return
+     */
+    public List<PropertyDto> propertyDtos(Long coursePropertyId, User user);
+
+    /**
+     * 新增属性
+     *
+     * @param property
+     * @param user
+     */
+    public void saveProperty(Property property, User user) throws Exception;
+
+    /**
+     * 删除属性
+     *
+     * @param propertyId
+     */
+    public void deleteProperty(Long propertyId, Long coursePropertyId, User user);
+
+    /**
+     * 查询所有属性
+     *
+     * @param coursePropertyId
+     * @param user
+     * @return
+     */
+    public List<Property> findAll(Long coursePropertyId, User user);
+
+    /**
+     * 查询某个树下的子节点
+     *
+     * @param property
+     * @return
+     */
+    public List<Property> findPropertySons(Property property);
+
+    /**
+     * 查询某个树下的子节点
+     *
+     * @param property
+     * @return
+     */
+    public List<Property> findPropertySons(Long propertyId);
+
+    /**
+     * 查询课程属性下面的所有父节点
+     *
+     * @param property
+     * @return
+     */
+    public List<Property> findPropertyParents(Long coursePropertyId, Long orgId);
+
+    /**
+     * 上移
+     *
+     * @param property
+     */
+    public void moveUp(Property property) throws Exception;
+
+    /**
+     * 下移
+     *
+     * @param property
+     */
+    public void moveDown(Property property) throws Exception;
 }

+ 29 - 15
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/QuesService.java

@@ -24,13 +24,17 @@ public interface QuesService {
      * @param question
      */
     public Question saveQues(Question question);
+
     /**
      * 批量保存试题
+     *
      * @param list
      */
     public void saveQuesList(List<Question> list);
+
     /**
      * 查询所有试题
+     *
      * @param searchCondition
      * @param curPage
      * @param pageSize
@@ -42,21 +46,25 @@ public interface QuesService {
 
     /**
      * 查询按ID过滤的试题
+     *
      * @param idSet
      * @param curPage
      * @param pageSize
      * @return
      */
-    public Page<Question> findByIdExclude(Set<String> idSet,String courseNo,QuesStructType quesType,int curPage,int pageSize,Long orgId,String quesBody);
+    public Page<Question> findByIdExclude(Set<String> idSet, String courseNo, QuesStructType quesType, int curPage, int pageSize, Long orgId, String quesBody);
 
     /**
      * 按ID获取试题
+     *
      * @param id
      * @return
      */
     public Question findById(String id);
+
     /**
      * 去除试题中的word
+     *
      * @param question
      */
     public void formatQues(Question question);
@@ -65,47 +73,53 @@ public interface QuesService {
 
     /**
      * 保存后更新word
-     * 
+     *
      * @param question
      */
     public void updateQuesWord(Question question);
 
     public void updateQuesWordUnit(WordprocessingMLPackage wordMLPackage, Question question) throws Exception;
+
     /**
      * 获取试题有效文本
-     * 
+     *
      * @param question
      * @return
      */
     public String getExtractText(Question question);
+
     /**
      * 设置选择题答案
+     *
      * @param question
      * @param order
      * @return
      */
-    public void setSelectQuestionAnswer(Question question,String optionOrder);
-    
+    public void setSelectQuestionAnswer(Question question, String optionOrder);
+
     /**
      * 查询题目数量
+     *
      * @param searchCondition
      * @return
      */
     public long findQuesCount(QuestionSearchCondition searchCondition);
-    
+
     /**
      * 根据试卷ids集合更新试题属性
+     *
      * @param paperList
      * @param difficultyDegree
      * @param publicity
      */
-	public void updateProByPapers(List<String> paperList,Double difficultyDegree, Boolean publicity,User user);
-	
-	/**
-	 * 根据课程代码更新试题属性
-	 * @param courseCode
-	 * @param difficultyDegree
-	 * @param publicity
-	 */
-	public void updateProByCourse(String courseCode,Double difficultyDegree,Boolean publicity,String orgId);
+    public void updateProByPapers(List<String> paperList, Double difficultyDegree, Boolean publicity, User user);
+
+    /**
+     * 根据课程代码更新试题属性
+     *
+     * @param courseCode
+     * @param difficultyDegree
+     * @param publicity
+     */
+    public void updateProByCourse(String courseCode, Double difficultyDegree, Boolean publicity, String orgId);
 }

+ 21 - 19
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/QuesTypeNameService.java

@@ -21,32 +21,33 @@ public class QuesTypeNameService {
 
     /**
      * 保存来源大题名称
+     *
      * @param detailUnitList
      */
-    public void saveQuesTypeName(List<PaperDetailUnit> detailUnitList){
+    public void saveQuesTypeName(List<PaperDetailUnit> detailUnitList) {
 
-        for(PaperDetailUnit paperDetailUnit:detailUnitList){
+        for (PaperDetailUnit paperDetailUnit : detailUnitList) {
             String orgId = paperDetailUnit.getPaper().getOrgId();
             String courseNo = paperDetailUnit.getPaper().getCourseNo();
             QuesStructType questionType = paperDetailUnit.getQuestionType();
             String detailName = paperDetailUnit.getPaperDetail().getName();
-            List<QuesTypeName> quesTypeNames = quesTypeRepo.findQuesName(orgId,courseNo,questionType);
-            if(quesTypeNames != null && quesTypeNames.size() > 0){
+            List<QuesTypeName> quesTypeNames = quesTypeRepo.findQuesName(orgId, courseNo, questionType);
+            if (quesTypeNames != null && quesTypeNames.size() > 0) {
                 QuesTypeName quesTypeName = quesTypeNames.get(0);
                 List<String> quesNames = quesTypeName.getQuesNames();
-                if(quesNames != null && quesNames.size() > 0 ){
-                    if(quesNames.contains(detailName)){
+                if (quesNames != null && quesNames.size() > 0) {
+                    if (quesNames.contains(detailName)) {
                         continue;
-                    }else{
+                    } else {
                         quesNames.add(detailName);
                     }
-                }else{
+                } else {
                     quesNames = new ArrayList<>();
                     quesNames.add(detailName);
                 }
                 quesTypeName.setQuesNames(quesNames);
                 quesTypeRepo.save(quesTypeName);
-            }else{
+            } else {
                 QuesTypeName quesTypeName = new QuesTypeName();
                 List<String> quesNames = new ArrayList<>();
                 quesNames.add(detailName);
@@ -58,33 +59,34 @@ public class QuesTypeNameService {
             }
         }
     }
-    
+
     /**
      * 复制试卷时保存来源大题名称
+     *
      * @param detailUnitList
      */
-    public void saveCloneQuesTypeName(List<PaperDetailUnit> detailUnitList,String courseNo){
-        for(PaperDetailUnit paperDetailUnit:detailUnitList){
+    public void saveCloneQuesTypeName(List<PaperDetailUnit> detailUnitList, String courseNo) {
+        for (PaperDetailUnit paperDetailUnit : detailUnitList) {
             String orgId = paperDetailUnit.getPaper().getOrgId();
             QuesStructType questionType = paperDetailUnit.getQuestionType();
             String detailName = paperDetailUnit.getPaperDetail().getName();
-            List<QuesTypeName> quesTypeNames = quesTypeRepo.findQuesName(orgId,courseNo,questionType);
-            if(quesTypeNames != null && quesTypeNames.size() > 0){
+            List<QuesTypeName> quesTypeNames = quesTypeRepo.findQuesName(orgId, courseNo, questionType);
+            if (quesTypeNames != null && quesTypeNames.size() > 0) {
                 QuesTypeName quesTypeName = quesTypeNames.get(0);
                 List<String> quesNames = quesTypeName.getQuesNames();
-                if(quesNames != null && quesNames.size() > 0 ){
-                    if(quesNames.contains(detailName)){
+                if (quesNames != null && quesNames.size() > 0) {
+                    if (quesNames.contains(detailName)) {
                         continue;
-                    }else{
+                    } else {
                         quesNames.add(detailName);
                     }
-                }else{
+                } else {
                     quesNames = new ArrayList<>();
                     quesNames.add(detailName);
                 }
                 quesTypeName.setQuesNames(quesNames);
                 quesTypeRepo.save(quesTypeName);
-            }else{
+            } else {
                 QuesTypeName quesTypeName = new QuesTypeName();
                 List<String> quesNames = new ArrayList<>();
                 quesNames.add(detailName);

+ 53 - 43
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/QuestionAudioService.java

@@ -7,51 +7,61 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
 import cn.com.qmth.examcloud.core.questions.dao.entity.QuestionAudio;
 
 /**
- * @author  	chenken
- * @date    	2017年8月1日 上午11:26:40
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年8月1日 上午11:26:40
+ * @company QMTH
  * @description QuestionRadioService.java
  */
 public interface QuestionAudioService {
-	
-	/**
-	 * 使用ID查询音频
-	 * @param id
-	 * @return
-	 */
-	public QuestionAudio findAudioById(String id);
-	/**
-	 * 保存试题音频文件记录
-	 * @param questionRadio
-	 */
-	public void saveQuestionAudio(QuestionAudio questionAudio,User user);
-	 /**
-	  * 根据试题ID获取音频文件
-	  * @return
-	  */
-	public List<QuestionAudio> findQuestionAudiosByQuestionId(String questionId);
-	/**
-	 * 根据questionId和文件名称查询对象
-	 * @param questionId
-	 * @param fileName
-	 * @return  
-	 */
-	public QuestionAudio findByQuestionIdAndFileName(String questionId,String fileName);
-	/**
-	 * 删除不在试题中的音频
-	 * @param question
-	 */
-	public void deleteAudioNotInQuestion(Question question);
-	
-	/**
-	 * 给音频排序
-	 * @param question
-	 */
-	public void sortAudio(Question question);
-	
-	/**
-	 * 根据试题集合删除音频
-	 */
-	public void deleteAudio(List<Question> questions);
+
+    /**
+     * 使用ID查询音频
+     *
+     * @param id
+     * @return
+     */
+    public QuestionAudio findAudioById(String id);
+
+    /**
+     * 保存试题音频文件记录
+     *
+     * @param questionRadio
+     */
+    public void saveQuestionAudio(QuestionAudio questionAudio, User user);
+
+    /**
+     * 根据试题ID获取音频文件
+     *
+     * @return
+     */
+    public List<QuestionAudio> findQuestionAudiosByQuestionId(String questionId);
+
+    /**
+     * 根据questionId和文件名称查询对象
+     *
+     * @param questionId
+     * @param fileName
+     * @return
+     */
+    public QuestionAudio findByQuestionIdAndFileName(String questionId, String fileName);
+
+    /**
+     * 删除不在试题中的音频
+     *
+     * @param question
+     */
+    public void deleteAudioNotInQuestion(Question question);
+
+    /**
+     * 给音频排序
+     *
+     * @param question
+     */
+    public void sortAudio(Question question);
+
+    /**
+     * 根据试题集合删除音频
+     */
+    public void deleteAudio(List<Question> questions);
 }
 

+ 37 - 33
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/QuestionProviderService.java

@@ -9,40 +9,44 @@ import org.springframework.data.domain.Page;
 import cn.com.qmth.examcloud.question.commons.core.question.DefaultQuestion;
 
 /**
- * @author 		weiwenhai
- * @date 		2018.9.10
- * @company		qmth
- * @description	试题对象服务接口
+ * @author weiwenhai
+ * @date 2018.9.10
+ * @company qmth
+ * @description 试题对象服务接口
  */
 public interface QuestionProviderService {
 
-	/**
-	 * 保存试题对象
-	 * @param defaultQuestion
-	 * @return
-	 */
-	public String save(DefaultQuestion defaultQuestion);
-	
-	/**
-	 * 根据机构和属性查询试题集合
-	 * @param rootOrgId
-	 * @param map
-	 * @return
-	 */
-	public Page<DefaultQuestion> findQustions(Long rootOrgId,Map<String, String> map,int curPage,int pageSize);
-	
-	/**
-	 * 批量保存试题对象
-	 * @param defaultQuestion
-	 * @return
-	 */
-	public String saveList(List<DefaultQuestion> defaultQuestions);
-	
-	/**
-	 * 查询试题对象集合
-	 * @param questionId
-	 * @return
-	 */
-	public List<DefaultQuestion> findQuestions(Set<String> questionIds);
-	
+    /**
+     * 保存试题对象
+     *
+     * @param defaultQuestion
+     * @return
+     */
+    public String save(DefaultQuestion defaultQuestion);
+
+    /**
+     * 根据机构和属性查询试题集合
+     *
+     * @param rootOrgId
+     * @param map
+     * @return
+     */
+    public Page<DefaultQuestion> findQustions(Long rootOrgId, Map<String, String> map, int curPage, int pageSize);
+
+    /**
+     * 批量保存试题对象
+     *
+     * @param defaultQuestion
+     * @return
+     */
+    public String saveList(List<DefaultQuestion> defaultQuestions);
+
+    /**
+     * 查询试题对象集合
+     *
+     * @param questionId
+     * @return
+     */
+    public List<DefaultQuestion> findQuestions(Set<String> questionIds);
+
 }

+ 100 - 100
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/CouresInfo.java

@@ -3,105 +3,105 @@ package cn.com.qmth.examcloud.core.questions.service.bean;
 import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamCourseRelationBean;
 
-public class CouresInfo implements JsonSerializable{
-
-	private static final long serialVersionUID = 1487659956593385878L;
-	
-	private Long examId;
-
-	private Long courseId;
-
-	private String courseName;
-
-	private String courseCode;
-
-	private String courseLevel;
-
-	private Boolean courseEnable;
-	
-	public CouresInfo(){
-	}
-	
-	public CouresInfo(ExamCourseRelationBean bean){
-		this.examId = bean.getExamId();
-		this.courseCode = bean.getCourseCode();
-		this.courseId = bean.getCourseId();
-		this.courseEnable = bean.getCourseEnable();
-		this.courseName = bean.getCourseName();
-	}
-
-	public Long getExamId() {
-		return examId;
-	}
-
-	public void setExamId(Long examId) {
-		this.examId = examId;
-	}
-
-	public Long getCourseId() {
-		return courseId;
-	}
-
-	public void setCourseId(Long courseId) {
-		this.courseId = courseId;
-	}
-
-	public String getCourseName() {
-		return courseName;
-	}
-
-	public void setCourseName(String courseName) {
-		this.courseName = courseName;
-	}
-
-	public String getCourseCode() {
-		return courseCode;
-	}
-
-	public void setCourseCode(String courseCode) {
-		this.courseCode = courseCode;
-	}
-
-	public String getCourseLevel() {
-		return courseLevel;
-	}
-
-	public void setCourseLevel(String courseLevel) {
-		this.courseLevel = courseLevel;
-	}
-
-	public Boolean getCourseEnable() {
-		return courseEnable;
-	}
-
-	public void setCourseEnable(Boolean courseEnable) {
-		this.courseEnable = courseEnable;
-	}
-
-	@Override
-	public int hashCode() {
-		final int prime = 31;
-		int result = 1;
-		result = prime * result
-				+ ((courseCode == null) ? 0 : courseCode.hashCode());
-		return result;
-	}
-
-	@Override
-	public boolean equals(Object obj) {
-		if (this == obj)
-			return true;
-		if (obj == null)
-			return false;
-		if (getClass() != obj.getClass())
-			return false;
-		CouresInfo other = (CouresInfo) obj;
-		if (courseCode == null) {
-			if (other.courseCode != null)
-				return false;
-		} else if (!courseCode.equals(other.courseCode))
-			return false;
-		return true;
-	}
+public class CouresInfo implements JsonSerializable {
+
+    private static final long serialVersionUID = 1487659956593385878L;
+
+    private Long examId;
+
+    private Long courseId;
+
+    private String courseName;
+
+    private String courseCode;
+
+    private String courseLevel;
+
+    private Boolean courseEnable;
+
+    public CouresInfo() {
+    }
+
+    public CouresInfo(ExamCourseRelationBean bean) {
+        this.examId = bean.getExamId();
+        this.courseCode = bean.getCourseCode();
+        this.courseId = bean.getCourseId();
+        this.courseEnable = bean.getCourseEnable();
+        this.courseName = bean.getCourseName();
+    }
+
+    public Long getExamId() {
+        return examId;
+    }
+
+    public void setExamId(Long examId) {
+        this.examId = examId;
+    }
+
+    public Long getCourseId() {
+        return courseId;
+    }
+
+    public void setCourseId(Long courseId) {
+        this.courseId = courseId;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getCourseLevel() {
+        return courseLevel;
+    }
+
+    public void setCourseLevel(String courseLevel) {
+        this.courseLevel = courseLevel;
+    }
+
+    public Boolean getCourseEnable() {
+        return courseEnable;
+    }
+
+    public void setCourseEnable(Boolean courseEnable) {
+        this.courseEnable = courseEnable;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result
+                + ((courseCode == null) ? 0 : courseCode.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        CouresInfo other = (CouresInfo) obj;
+        if (courseCode == null) {
+            if (other.courseCode != null)
+                return false;
+        } else if (!courseCode.equals(other.courseCode))
+            return false;
+        return true;
+    }
 
 }

+ 3 - 3
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/PaperDetailDtoAssembler.java

@@ -13,7 +13,7 @@ import java.util.List;
 @Component
 public class PaperDetailDtoAssembler {
 
-    public PaperDetailDto toDto(PaperDetail paperDetail){
+    public PaperDetailDto toDto(PaperDetail paperDetail) {
         PaperDetailDto paperDetailDto = new PaperDetailDto();
         paperDetailDto.setId(paperDetail.getId());
         paperDetailDto.setName(paperDetail.getName());
@@ -22,9 +22,9 @@ public class PaperDetailDtoAssembler {
         return paperDetailDto;
     }
 
-    public List<PaperDetailDto> toDtoList(List<PaperDetail> paperDetailList){
+    public List<PaperDetailDto> toDtoList(List<PaperDetail> paperDetailList) {
         List<PaperDetailDto> paperDetailDtos = new ArrayList<>();
-        for(PaperDetail paperDetail:paperDetailList){
+        for (PaperDetail paperDetail : paperDetailList) {
             paperDetailDtos.add(toDto(paperDetail));
         }
         return paperDetailDtos;

+ 12 - 12
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/PaperDetailUnitDtoAssembler.java

@@ -17,7 +17,7 @@ import java.util.List;
 @Component
 public class PaperDetailUnitDtoAssembler {
 
-    public PaperDetailUnitDto toDto(PaperDetailUnit paperDetailUnit){
+    public PaperDetailUnitDto toDto(PaperDetailUnit paperDetailUnit) {
         PaperDetailUnitDto paperDetailUnitDto = new PaperDetailUnitDto();
         paperDetailUnitDto.setId(paperDetailUnit.getId());
         paperDetailUnitDto.setNumber(paperDetailUnit.getNumber());
@@ -26,22 +26,22 @@ public class PaperDetailUnitDtoAssembler {
         paperDetailUnitDto.setQuestionType(paperDetailUnit.getQuestionType());
         paperDetailUnitDto.setSubScoreList(paperDetailUnit.getSubScoreList());
         paperDetailUnitDto.setQuesBody(paperDetailUnit.getQuestion().getQuesBody());
-        if(paperDetailUnit.getQuestion().getQuesOptions() != null && paperDetailUnit.getQuestion().getQuesOptions().size()>0){
-        	List<QuesOptionDto> quesOptionDtos = new ArrayList<QuesOptionDto>();
-        	for(QuesOption quesOption:paperDetailUnit.getQuestion().getQuesOptions()){
-        		QuesOptionDto quesOptionDto = new QuesOptionDto();
-        		quesOptionDto.setNumber(quesOption.getNumber());
-        		quesOptionDto.setOptionBody(quesOption.getOptionBody());
-        		quesOptionDtos.add(quesOptionDto);
-        	}
-        	paperDetailUnitDto.setQuesOptions(quesOptionDtos);
+        if (paperDetailUnit.getQuestion().getQuesOptions() != null && paperDetailUnit.getQuestion().getQuesOptions().size() > 0) {
+            List<QuesOptionDto> quesOptionDtos = new ArrayList<QuesOptionDto>();
+            for (QuesOption quesOption : paperDetailUnit.getQuestion().getQuesOptions()) {
+                QuesOptionDto quesOptionDto = new QuesOptionDto();
+                quesOptionDto.setNumber(quesOption.getNumber());
+                quesOptionDto.setOptionBody(quesOption.getOptionBody());
+                quesOptionDtos.add(quesOptionDto);
+            }
+            paperDetailUnitDto.setQuesOptions(quesOptionDtos);
         }
         return paperDetailUnitDto;
     }
 
-    public List<PaperDetailUnitDto> toDtoList(List<PaperDetailUnit> paperDetailUnitList){
+    public List<PaperDetailUnitDto> toDtoList(List<PaperDetailUnit> paperDetailUnitList) {
         List<PaperDetailUnitDto> paperDetailUnitDtos = new ArrayList<>();
-        for(PaperDetailUnit pdu:paperDetailUnitList){
+        for (PaperDetailUnit pdu : paperDetailUnitList) {
             paperDetailUnitDtos.add(toDto(pdu));
         }
         return paperDetailUnitDtos;

+ 3 - 2
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/PaperDtoAssembler.java

@@ -3,6 +3,7 @@ package cn.com.qmth.examcloud.core.questions.service.bean;
 import cn.com.qmth.examcloud.core.questions.base.question.PaperDto;
 import cn.com.qmth.examcloud.core.questions.dao.entity.Paper;
 import org.springframework.stereotype.Component;
+
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -12,7 +13,7 @@ import java.util.stream.Collectors;
 @Component
 public class PaperDtoAssembler {
 
-    public PaperDto toDto(Paper paper){
+    public PaperDto toDto(Paper paper) {
         PaperDto paperDto = new PaperDto();
         paperDto.setId(paper.getId());
         paperDto.setName(paper.getName());
@@ -23,7 +24,7 @@ public class PaperDtoAssembler {
         return paperDto;
     }
 
-    public List<PaperDto> toDtoList(List<Paper> paperList){
+    public List<PaperDto> toDtoList(List<Paper> paperList) {
         return paperList.stream()
                 .map(paper -> toDto(paper))
                 .collect(Collectors.toList());

+ 38 - 36
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/PropertyAssembler.java

@@ -11,40 +11,42 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.Property;
 @Component
 public class PropertyAssembler {
 
-	/**
-	 * 得到父节点对象
-	 * @param propertyDto
-	 * @return
-	 */
-	public Property toProperty(PropertyDto propertyDto){
-		Property property = null;
-		if(propertyDto != null){
-			property = new Property();
-			property.setId(propertyDto.getId());
-			property.setCoursePropertyId(propertyDto.getCoursePropertyId());
-			property.setName(propertyDto.getName());
-			property.setParentId(propertyDto.getCoursePropertyId());
-			property.setRemark(propertyDto.getRemark());
-		}
-		return property;
-	}
-	
-	/**
-	 * 得到子类节点对象
-	 * @param propertyDto
-	 * @return
-	 */
-	public List<Property> toPropertySon(PropertyDto propertyDto){
-		Property property = null;
-		List<PropertyDto> propertyDtos = propertyDto.getPropertyDtos();
-		if(propertyDtos != null && propertyDtos.size()>0){
-			List<Property> properties = new ArrayList<Property>();
-			for(PropertyDto propertyDto2:propertyDtos){
-				property = toProperty(propertyDto2);
-				properties.add(property);
-			}
-			return properties;
-		}
-		return null;
-	}
+    /**
+     * 得到父节点对象
+     *
+     * @param propertyDto
+     * @return
+     */
+    public Property toProperty(PropertyDto propertyDto) {
+        Property property = null;
+        if (propertyDto != null) {
+            property = new Property();
+            property.setId(propertyDto.getId());
+            property.setCoursePropertyId(propertyDto.getCoursePropertyId());
+            property.setName(propertyDto.getName());
+            property.setParentId(propertyDto.getCoursePropertyId());
+            property.setRemark(propertyDto.getRemark());
+        }
+        return property;
+    }
+
+    /**
+     * 得到子类节点对象
+     *
+     * @param propertyDto
+     * @return
+     */
+    public List<Property> toPropertySon(PropertyDto propertyDto) {
+        Property property = null;
+        List<PropertyDto> propertyDtos = propertyDto.getPropertyDtos();
+        if (propertyDtos != null && propertyDtos.size() > 0) {
+            List<Property> properties = new ArrayList<Property>();
+            for (PropertyDto propertyDto2 : propertyDtos) {
+                property = toProperty(propertyDto2);
+                properties.add(property);
+            }
+            return properties;
+        }
+        return null;
+    }
 }

+ 6 - 6
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/SubQuestionDtoAssembler.java

@@ -16,7 +16,7 @@ import java.util.stream.Collectors;
 @Component
 public class SubQuestionDtoAssembler {
 
-    public SubQuestionDto toDto(Question question){
+    public SubQuestionDto toDto(Question question) {
         SubQuestionDto subQuestionDto = new SubQuestionDto();
         subQuestionDto.setQuestionType(question.getQuestionType());
         subQuestionDto.setNumber(question.getNumber());
@@ -28,15 +28,15 @@ public class SubQuestionDtoAssembler {
         return subQuestionDto;
     }
 
-    public QuesOptionDto toOptionDto(QuesOption quesOption){
+    public QuesOptionDto toOptionDto(QuesOption quesOption) {
         QuesOptionDto quesOptionDto = new QuesOptionDto();
         quesOptionDto.setNumber(quesOption.getNumber());
         quesOptionDto.setOptionBody(quesOption.getOptionBody());
         return quesOptionDto;
     }
 
-    public List<SubQuestionDto> toDtoList(List<Question> questionList){
-        if(questionList == null || questionList.size() == 0 ){
+    public List<SubQuestionDto> toDtoList(List<Question> questionList) {
+        if (questionList == null || questionList.size() == 0) {
             return new ArrayList<SubQuestionDto>();
         }
         return questionList.stream()
@@ -44,8 +44,8 @@ public class SubQuestionDtoAssembler {
                 .collect(Collectors.toList());
     }
 
-    public List<QuesOptionDto> toOptionDtoList(List<QuesOption> quesOptionList){
-        if(quesOptionList == null || quesOptionList.size() == 0 ){
+    public List<QuesOptionDto> toOptionDtoList(List<QuesOption> quesOptionList) {
+        if (quesOptionList == null || quesOptionList.size() == 0) {
             return new ArrayList<QuesOptionDto>();
         }
         return quesOptionList.stream()

+ 4 - 3
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/condition/Condition.java

@@ -1,8 +1,9 @@
 package cn.com.qmth.examcloud.core.questions.service.bean.condition;
 
 public interface Condition {
-	
-	public String  getName();
-	public String  getCode();
+
+    public String getName();
+
+    public String getCode();
 
 }

+ 66 - 66
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/ExportPaperInfoModel.java

@@ -6,74 +6,74 @@ import java.util.List;
 import cn.com.qmth.examcloud.core.questions.base.enums.ExportWay;
 
 /**
- * @author  	chenken
- * @date    	2017年7月15日 下午1:52:52
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年7月15日 下午1:52:52
+ * @company QMTH
  * @description ExportPaperInfoModel.java
  */
-public class ExportPaperInfoModel implements Serializable{
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = -8364161638270123652L;
-
-	/**
-	 * 考试ID
-	 */
-	private String examId;
-	/**
-	 * 课程ID
-	 */
-	private String courseId;
-	
-	/**
-	 * BATCH:批量导出
-	 * SINGLE:单个课程导出
-	 */
-	private ExportWay exportWay;
-	
-	/**
-	 * 详见枚举类:ExamFileType
-	 * PAPER
-	 * ANSWER
-	 * PAPER_STRUCTURE_SUBJECTIVE
-	 * PAPER_STRUCTURE_OBJECTIVE
-	 * AUDIO
-	 * ENCRYPT_PACKAGE
-	 */
-	private List<String> exportContentList;
-
-	public String getExamId() {
-		return examId;
-	}
-
-	public void setExamId(String examId) {
-		this.examId = examId;
-	}
-	
-	public List<String> getExportContentList() {
-		return exportContentList;
-	}
-
-	public void setExportContentList(List<String> exportContentList) {
-		this.exportContentList = exportContentList;
-	}
-
-	public String getCourseId() {
-		return courseId;
-	}
-
-	public void setCourseId(String courseId) {
-		this.courseId = courseId;
-	}
-
-	public ExportWay getExportWay() {
-		return exportWay;
-	}
-
-	public void setExportWay(ExportWay exportWay) {
-		this.exportWay = exportWay;
-	}
+public class ExportPaperInfoModel implements Serializable {
+    /**
+     *
+     */
+    private static final long serialVersionUID = -8364161638270123652L;
+
+    /**
+     * 考试ID
+     */
+    private String examId;
+    /**
+     * 课程ID
+     */
+    private String courseId;
+
+    /**
+     * BATCH:批量导出
+     * SINGLE:单个课程导出
+     */
+    private ExportWay exportWay;
+
+    /**
+     * 详见枚举类:ExamFileType
+     * PAPER
+     * ANSWER
+     * PAPER_STRUCTURE_SUBJECTIVE
+     * PAPER_STRUCTURE_OBJECTIVE
+     * AUDIO
+     * ENCRYPT_PACKAGE
+     */
+    private List<String> exportContentList;
+
+    public String getExamId() {
+        return examId;
+    }
+
+    public void setExamId(String examId) {
+        this.examId = examId;
+    }
+
+    public List<String> getExportContentList() {
+        return exportContentList;
+    }
+
+    public void setExportContentList(List<String> exportContentList) {
+        this.exportContentList = exportContentList;
+    }
+
+    public String getCourseId() {
+        return courseId;
+    }
+
+    public void setCourseId(String courseId) {
+        this.courseId = courseId;
+    }
+
+    public ExportWay getExportWay() {
+        return exportWay;
+    }
+
+    public void setExportWay(ExportWay exportWay) {
+        this.exportWay = exportWay;
+    }
 
 }
 

+ 23 - 23
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/GenPaperDto.java

@@ -20,9 +20,9 @@ public class GenPaperDto implements Serializable {
     private String courseNo;// 课程代码
 
     private String courseName;// 课程名称
-    
+
     private Course course;
-    
+
     private CourseLevel level;// 层次
 
     private String paperName;// 试卷名称
@@ -30,7 +30,7 @@ public class GenPaperDto implements Serializable {
     private List<String> paperIds;// 试卷ID集合
 
     //private Map<String, Double> simpleParams;// 简单组卷规则
-    
+
     private Map<String, NumberDto> simpleParams;// 简单组卷规则
 
     private List<Condition> conditions;// 精细组卷规则
@@ -81,15 +81,15 @@ public class GenPaperDto implements Serializable {
         this.paperIds = paperIds;
     }
 
-	public Map<String, NumberDto> getSimpleParams() {
-		return simpleParams;
-	}
+    public Map<String, NumberDto> getSimpleParams() {
+        return simpleParams;
+    }
 
-	public void setSimpleParams(Map<String, NumberDto> simpleParams) {
-		this.simpleParams = simpleParams;
-	}
+    public void setSimpleParams(Map<String, NumberDto> simpleParams) {
+        this.simpleParams = simpleParams;
+    }
 
-	public List<Condition> getConditions() {
+    public List<Condition> getConditions() {
         return conditions;
     }
 
@@ -141,20 +141,20 @@ public class GenPaperDto implements Serializable {
         this.orgId = orgId;
     }
 
-	public CourseLevel getLevel() {
-		return level;
-	}
+    public CourseLevel getLevel() {
+        return level;
+    }
 
-	public void setLevel(CourseLevel level) {
-		this.level = level;
-	}
+    public void setLevel(CourseLevel level) {
+        this.level = level;
+    }
 
-	public Course getCourse() {
-		return course;
-	}
+    public Course getCourse() {
+        return course;
+    }
+
+    public void setCourse(Course course) {
+        this.course = course;
+    }
 
-	public void setCourse(Course course) {
-		this.course = course;
-	}
-    
 }

+ 95 - 95
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/NumberDto.java

@@ -1,102 +1,102 @@
 package cn.com.qmth.examcloud.core.questions.service.bean.dto;
 
 /**
- * @author 		weiwenhai
- * @date 		2018.8.30
- * @company 	qmth
- * @describle	简单组卷Dto
+ * @author weiwenhai
+ * @date 2018.8.30
+ * @company qmth
+ * @describle 简单组卷Dto
  */
 public class NumberDto {
 
-	/**
-	 * 公开简答
-	 */
-	private Double publicSimple;
-
-	/**
-	 * 公开中等
-	 */
-	private Double publicMedium;
-	
-	/**
-	 * 公开困难
-	 */
-	private Double publicDifficulty;
-	
-	/**
-	 * 非公开简单
-	 */
-	private Double noPublicSimple;
-	
-	/**
-	 * 非公开中等
-	 */
-	private Double noPublicMedium;
-	
-	/**
-	 * 非公开困难
-	 */
-	private Double noPublicDifficulty;
-	
-	/**
-	 * 总数
-	 */
-	private Double count;
-
-	public Double getPublicSimple() {
-		return publicSimple;
-	}
-
-	public void setPublicSimple(Double publicSimple) {
-		this.publicSimple = publicSimple;
-	}
-
-	public Double getPublicMedium() {
-		return publicMedium;
-	}
-
-	public void setPublicMedium(Double publicMedium) {
-		this.publicMedium = publicMedium;
-	}
-
-	public Double getPublicDifficulty() {
-		return publicDifficulty;
-	}
-
-	public void setPublicDifficulty(Double publicDifficulty) {
-		this.publicDifficulty = publicDifficulty;
-	}
-
-	public Double getNoPublicSimple() {
-		return noPublicSimple;
-	}
-
-	public void setNoPublicSimple(Double noPublicSimple) {
-		this.noPublicSimple = noPublicSimple;
-	}
-
-	public Double getNoPublicMedium() {
-		return noPublicMedium;
-	}
-
-	public void setNoPublicMedium(Double noPublicMedium) {
-		this.noPublicMedium = noPublicMedium;
-	}
-
-	public Double getNoPublicDifficulty() {
-		return noPublicDifficulty;
-	}
-
-	public void setNoPublicDifficulty(Double noPublicDifficulty) {
-		this.noPublicDifficulty = noPublicDifficulty;
-	}
-
-	public Double getCount() {
-		return count;
-	}
-
-	public void setCount(Double count) {
-		this.count = count;
-	}
-	
+    /**
+     * 公开简答
+     */
+    private Double publicSimple;
+
+    /**
+     * 公开中等
+     */
+    private Double publicMedium;
+
+    /**
+     * 公开困难
+     */
+    private Double publicDifficulty;
+
+    /**
+     * 非公开简单
+     */
+    private Double noPublicSimple;
+
+    /**
+     * 非公开中等
+     */
+    private Double noPublicMedium;
+
+    /**
+     * 非公开困难
+     */
+    private Double noPublicDifficulty;
+
+    /**
+     * 总数
+     */
+    private Double count;
+
+    public Double getPublicSimple() {
+        return publicSimple;
+    }
+
+    public void setPublicSimple(Double publicSimple) {
+        this.publicSimple = publicSimple;
+    }
+
+    public Double getPublicMedium() {
+        return publicMedium;
+    }
+
+    public void setPublicMedium(Double publicMedium) {
+        this.publicMedium = publicMedium;
+    }
+
+    public Double getPublicDifficulty() {
+        return publicDifficulty;
+    }
+
+    public void setPublicDifficulty(Double publicDifficulty) {
+        this.publicDifficulty = publicDifficulty;
+    }
+
+    public Double getNoPublicSimple() {
+        return noPublicSimple;
+    }
+
+    public void setNoPublicSimple(Double noPublicSimple) {
+        this.noPublicSimple = noPublicSimple;
+    }
+
+    public Double getNoPublicMedium() {
+        return noPublicMedium;
+    }
+
+    public void setNoPublicMedium(Double noPublicMedium) {
+        this.noPublicMedium = noPublicMedium;
+    }
+
+    public Double getNoPublicDifficulty() {
+        return noPublicDifficulty;
+    }
+
+    public void setNoPublicDifficulty(Double noPublicDifficulty) {
+        this.noPublicDifficulty = noPublicDifficulty;
+    }
+
+    public Double getCount() {
+        return count;
+    }
+
+    public void setCount(Double count) {
+        this.count = count;
+    }
+
 }

+ 220 - 219
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/ObjectiveQuestionStructure.java

@@ -9,226 +9,227 @@ import cn.com.qmth.examcloud.core.questions.base.excel.ExcelProperty;
 import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
 
 /**
- * @author  	chenken
- * @date    	2017年7月18日 上午10:59:49
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年7月18日 上午10:59:49
+ * @company QMTH
  * @description 客观题数据--用于Excel导出
  */
-public class ObjectiveQuestionStructure implements Serializable{
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = -4064781474344761068L;
-	
-	/**
-	 * 课程ID
-	 */
-	private Long courseId;
-	/**
-	 * 课程代码
-	 */
-	@ExcelProperty(name="课程代码",index = 0)
-	private String courseCode;
-	/**
-	 * 课程名称
-	 */
-	@ExcelProperty(name="课程名称",index = 1)
-	private String courseName;
-	
-	/**
-	 * 试卷名称
-	 */
-	@ExcelProperty(name="试卷名称",index = 2)
-	private String paperName;
-	
-	/**
-	 * 试卷类型
-	 */
-	@ExcelProperty(name="试卷类型",index = 3)
-	private String paperType;
-	/**
-	 * 大题号
-	 */
-	@ExcelProperty(name="大题号",index = 4)
-	private Integer sectionNum;
-	/**
-	 * 小题号
-	 */
-	@ExcelProperty(name="小题号",index = 5)
-	private Integer unitNum;
-	/**
-	 * 题目类型
-	 */
-	@ExcelProperty(name="题目类型",index = 6)
-	private String questionType;
-	/**
-	 * 标准答案
-	 */
-	@ExcelProperty(name="标准答案",index = 7)
-	private String answer;
-	/**
-	 * 小题分数
-	 */
-	@ExcelProperty(name="小题分数",index = 8)
-	private Double unitScore;
-	
-	public ObjectiveQuestionStructure(){}
-	
-	public ObjectiveQuestionStructure(PaperExp paperExp,PaperDetailExp paperDetailExp,PaperDetailUnitExp unit,String paperType){
-		this.courseId = Long.valueOf(paperExp.getCourse().getId());
-		this.paperType = paperType;
-		this.paperName = paperExp.getName();
-		this.courseCode = paperExp.getCourseNo();
-		this.courseName = paperExp.getCourseName();
-		this.sectionNum = paperDetailExp.getNumber();
-		this.questionType = unit.getQuestionType().getName();
-		this.unitNum = unit.getNumber();
-		this.unitScore = unit.getScore();
-		if(StringUtils.isNotBlank(unit.getQuestion().getQuesAnswer())){
-			if(unit.getQuestionType()==QuesStructType.BOOL_ANSWER_QUESTION){
-				if("正确".equals(unit.getQuestion().getQuesAnswer())){
-					this.answer = "A";
-				}else if("错误".equals(unit.getQuestion().getQuesAnswer())){
-					this.answer = "B";
-				}else if("#".equals(unit.getQuestion().getQuesAnswer())){
-					this.answer = "#";
-				}
-			}else if(unit.getQuestionType()==QuesStructType.MULTIPLE_ANSWER_QUESTION){
-				this.answer = unit.getQuestion().getQuesAnswer().replaceAll(",", "");
-			}else{
-				this.answer = unit.getQuestion().getQuesAnswer();
-			}
-		}
-	}
-	
-	
-	public ObjectiveQuestionStructure(PaperExp paperExp,PaperDetailExp paperDetailExp,PaperDetailUnitExp unit){
-		this.courseCode = paperExp.getCourseNo();
-		this.courseName = paperExp.getCourseName();
-		this.sectionNum = paperDetailExp.getNumber();
-		this.questionType = unit.getQuestionType().getName();
-		this.unitNum = unit.getNumber();
-		this.unitScore = unit.getScore();
-		if(StringUtils.isNotBlank(unit.getQuestion().getQuesAnswer())){
-			if(unit.getQuestionType()==QuesStructType.BOOL_ANSWER_QUESTION){
-				if("正确".equals(unit.getQuestion().getQuesAnswer())){
-					this.answer = "A";
-				}else if("错误".equals(unit.getQuestion().getQuesAnswer())){
-					this.answer = "B";
-				}else if("#".equals(unit.getQuestion().getQuesAnswer())){
-					this.answer = "#";
-				}
-			}else if(unit.getQuestionType()==QuesStructType.MULTIPLE_ANSWER_QUESTION){
-				this.answer = unit.getQuestion().getQuesAnswer().replaceAll(",", "");
-			}else{
-				this.answer = unit.getQuestion().getQuesAnswer();
-			}
-		}
-	}
-	
-	public ObjectiveQuestionStructure(PaperExp paperExp,PaperDetailExp paperDetailExp,Question question){
-		this.courseCode = paperExp.getCourseNo();
-		this.courseName = paperExp.getCourseName();
-		this.sectionNum = paperDetailExp.getNumber();
-		this.questionType = question.getQuestionType().getName();
-		this.unitNum = question.getNumber();
-		this.unitScore = question.getScore();
-		if(StringUtils.isNotBlank(question.getQuesAnswer())){
-			if(question.getQuestionType()==QuesStructType.BOOL_ANSWER_QUESTION){
-				if("正确".equals(question.getQuesAnswer())){
-					this.answer = "A";
-				}else if("错误".equals(question.getQuesAnswer())){
-					this.answer = "B";
-				}else if("#".equals(question.getQuesAnswer())){
-					this.answer = "#";
-				}
-			}else if(question.getQuestionType()==QuesStructType.MULTIPLE_ANSWER_QUESTION){
-				this.answer = question.getQuesAnswer().replaceAll(",", "");
-			}else{
-				this.answer = question.getQuesAnswer();
-			}
-		}
-	}
-
-	public Long getCourseId() {
-		return courseId;
-	}
-
-	public void setCourseId(Long courseId) {
-		this.courseId = courseId;
-	}
-
-	public String getCourseCode() {
-		return courseCode;
-	}
-
-	public void setCourseCode(String courseCode) {
-		this.courseCode = courseCode;
-	}
-
-	public String getCourseName() {
-		return courseName;
-	}
-
-	public void setCourseName(String courseName) {
-		this.courseName = courseName;
-	}
-
-	public String getPaperName() {
-		return paperName;
-	}
-
-	public void setPaperName(String paperName) {
-		this.paperName = paperName;
-	}
-
-	public String getPaperType() {
-		return paperType;
-	}
-
-	public void setPaperType(String paperType) {
-		this.paperType = paperType;
-	}
-
-	public Integer getSectionNum() {
-		return sectionNum;
-	}
-
-	public void setSectionNum(Integer sectionNum) {
-		this.sectionNum = sectionNum;
-	}
-
-	public Integer getUnitNum() {
-		return unitNum;
-	}
-
-	public void setUnitNum(Integer unitNum) {
-		this.unitNum = unitNum;
-	}
-
-	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 getUnitScore() {
-		return unitScore;
-	}
-
-	public void setUnitScore(Double unitScore) {
-		this.unitScore = unitScore;
-	}
-	
+public class ObjectiveQuestionStructure implements Serializable {
+    /**
+     *
+     */
+    private static final long serialVersionUID = -4064781474344761068L;
+
+    /**
+     * 课程ID
+     */
+    private Long courseId;
+    /**
+     * 课程代码
+     */
+    @ExcelProperty(name = "课程代码", index = 0)
+    private String courseCode;
+    /**
+     * 课程名称
+     */
+    @ExcelProperty(name = "课程名称", index = 1)
+    private String courseName;
+
+    /**
+     * 试卷名称
+     */
+    @ExcelProperty(name = "试卷名称", index = 2)
+    private String paperName;
+
+    /**
+     * 试卷类型
+     */
+    @ExcelProperty(name = "试卷类型", index = 3)
+    private String paperType;
+    /**
+     * 大题号
+     */
+    @ExcelProperty(name = "大题号", index = 4)
+    private Integer sectionNum;
+    /**
+     * 小题号
+     */
+    @ExcelProperty(name = "小题号", index = 5)
+    private Integer unitNum;
+    /**
+     * 题目类型
+     */
+    @ExcelProperty(name = "题目类型", index = 6)
+    private String questionType;
+    /**
+     * 标准答案
+     */
+    @ExcelProperty(name = "标准答案", index = 7)
+    private String answer;
+    /**
+     * 小题分数
+     */
+    @ExcelProperty(name = "小题分数", index = 8)
+    private Double unitScore;
+
+    public ObjectiveQuestionStructure() {
+    }
+
+    public ObjectiveQuestionStructure(PaperExp paperExp, PaperDetailExp paperDetailExp, PaperDetailUnitExp unit, String paperType) {
+        this.courseId = Long.valueOf(paperExp.getCourse().getId());
+        this.paperType = paperType;
+        this.paperName = paperExp.getName();
+        this.courseCode = paperExp.getCourseNo();
+        this.courseName = paperExp.getCourseName();
+        this.sectionNum = paperDetailExp.getNumber();
+        this.questionType = unit.getQuestionType().getName();
+        this.unitNum = unit.getNumber();
+        this.unitScore = unit.getScore();
+        if (StringUtils.isNotBlank(unit.getQuestion().getQuesAnswer())) {
+            if (unit.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION) {
+                if ("正确".equals(unit.getQuestion().getQuesAnswer())) {
+                    this.answer = "A";
+                } else if ("错误".equals(unit.getQuestion().getQuesAnswer())) {
+                    this.answer = "B";
+                } else if ("#".equals(unit.getQuestion().getQuesAnswer())) {
+                    this.answer = "#";
+                }
+            } else if (unit.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
+                this.answer = unit.getQuestion().getQuesAnswer().replaceAll(",", "");
+            } else {
+                this.answer = unit.getQuestion().getQuesAnswer();
+            }
+        }
+    }
+
+
+    public ObjectiveQuestionStructure(PaperExp paperExp, PaperDetailExp paperDetailExp, PaperDetailUnitExp unit) {
+        this.courseCode = paperExp.getCourseNo();
+        this.courseName = paperExp.getCourseName();
+        this.sectionNum = paperDetailExp.getNumber();
+        this.questionType = unit.getQuestionType().getName();
+        this.unitNum = unit.getNumber();
+        this.unitScore = unit.getScore();
+        if (StringUtils.isNotBlank(unit.getQuestion().getQuesAnswer())) {
+            if (unit.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION) {
+                if ("正确".equals(unit.getQuestion().getQuesAnswer())) {
+                    this.answer = "A";
+                } else if ("错误".equals(unit.getQuestion().getQuesAnswer())) {
+                    this.answer = "B";
+                } else if ("#".equals(unit.getQuestion().getQuesAnswer())) {
+                    this.answer = "#";
+                }
+            } else if (unit.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
+                this.answer = unit.getQuestion().getQuesAnswer().replaceAll(",", "");
+            } else {
+                this.answer = unit.getQuestion().getQuesAnswer();
+            }
+        }
+    }
+
+    public ObjectiveQuestionStructure(PaperExp paperExp, PaperDetailExp paperDetailExp, Question question) {
+        this.courseCode = paperExp.getCourseNo();
+        this.courseName = paperExp.getCourseName();
+        this.sectionNum = paperDetailExp.getNumber();
+        this.questionType = question.getQuestionType().getName();
+        this.unitNum = question.getNumber();
+        this.unitScore = question.getScore();
+        if (StringUtils.isNotBlank(question.getQuesAnswer())) {
+            if (question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION) {
+                if ("正确".equals(question.getQuesAnswer())) {
+                    this.answer = "A";
+                } else if ("错误".equals(question.getQuesAnswer())) {
+                    this.answer = "B";
+                } else if ("#".equals(question.getQuesAnswer())) {
+                    this.answer = "#";
+                }
+            } else if (question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
+                this.answer = question.getQuesAnswer().replaceAll(",", "");
+            } else {
+                this.answer = question.getQuesAnswer();
+            }
+        }
+    }
+
+    public Long getCourseId() {
+        return courseId;
+    }
+
+    public void setCourseId(Long courseId) {
+        this.courseId = courseId;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getPaperName() {
+        return paperName;
+    }
+
+    public void setPaperName(String paperName) {
+        this.paperName = paperName;
+    }
+
+    public String getPaperType() {
+        return paperType;
+    }
+
+    public void setPaperType(String paperType) {
+        this.paperType = paperType;
+    }
+
+    public Integer getSectionNum() {
+        return sectionNum;
+    }
+
+    public void setSectionNum(Integer sectionNum) {
+        this.sectionNum = sectionNum;
+    }
+
+    public Integer getUnitNum() {
+        return unitNum;
+    }
+
+    public void setUnitNum(Integer unitNum) {
+        this.unitNum = unitNum;
+    }
+
+    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 getUnitScore() {
+        return unitScore;
+    }
+
+    public void setUnitScore(Double unitScore) {
+        this.unitScore = unitScore;
+    }
+
 }
 

+ 60 - 60
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/PageExamCourse.java

@@ -6,67 +6,67 @@ import java.util.List;
 import cn.com.qmth.examcloud.core.questions.base.core.ExamCourseDto;
 
 /**
- * @author  	chenken
- * @date    	2017年7月26日 上午11:32:38
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年7月26日 上午11:32:38
+ * @company QMTH
  * @description PageExamCourse.java
  */
-public class PageExamCourse implements Serializable{
-	
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = -4960290977498969319L;
-
-	private List<ExamCourseDto> content;
-	
-	private int totalElements;
-	
-	private int totalPages;
-	
-	private int size;
-	
-	private int number;
-
-	public List<ExamCourseDto> getContent() {
-		return content;
-	}
-
-	public void setContent(List<ExamCourseDto> content) {
-		this.content = content;
-	}
-
-	public int getTotalElements() {
-		return totalElements;
-	}
-
-	public void setTotalElements(int totalElements) {
-		this.totalElements = totalElements;
-	}
-
-	public int getTotalPages() {
-		return totalPages;
-	}
-
-	public void setTotalPages(int totalPages) {
-		this.totalPages = totalPages;
-	}
-
-	public int getSize() {
-		return size;
-	}
-
-	public void setSize(int size) {
-		this.size = size;
-	}
-
-	public int getNumber() {
-		return number;
-	}
-
-	public void setNumber(int number) {
-		this.number = number;
-	}
-	
+public class PageExamCourse implements Serializable {
+
+    /**
+     *
+     */
+    private static final long serialVersionUID = -4960290977498969319L;
+
+    private List<ExamCourseDto> content;
+
+    private int totalElements;
+
+    private int totalPages;
+
+    private int size;
+
+    private int number;
+
+    public List<ExamCourseDto> getContent() {
+        return content;
+    }
+
+    public void setContent(List<ExamCourseDto> content) {
+        this.content = content;
+    }
+
+    public int getTotalElements() {
+        return totalElements;
+    }
+
+    public void setTotalElements(int totalElements) {
+        this.totalElements = totalElements;
+    }
+
+    public int getTotalPages() {
+        return totalPages;
+    }
+
+    public void setTotalPages(int totalPages) {
+        this.totalPages = totalPages;
+    }
+
+    public int getSize() {
+        return size;
+    }
+
+    public void setSize(int size) {
+        this.size = size;
+    }
+
+    public int getNumber() {
+        return number;
+    }
+
+    public void setNumber(int number) {
+        this.number = number;
+    }
+
 }
 

+ 47 - 47
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/PaperDetailExp.java

@@ -8,7 +8,7 @@ import java.util.*;
  * 试卷大题导出dto
  * Created by songyue on 17/3/15.
  */
-public class PaperDetailExp implements Serializable,Comparable<PaperDetailExp>{
+public class PaperDetailExp implements Serializable, Comparable<PaperDetailExp> {
     private static final long serialVersionUID = -3520871668728091404L;
 
     private String id;
@@ -20,52 +20,52 @@ public class PaperDetailExp implements Serializable,Comparable<PaperDetailExp>{
     private String name;//大题名称
 
     private String title;//大题标题
-    
+
     private String titleDetail;//标题详情
 
-	private Double score;//大题分数
+    private Double score;//大题分数
 
     private Integer unitCount;//大题下的小题数量
 
     private List<PaperDetailUnitExp> paperDetailUnits;
-    
+
     /**
      * 大题排序
      */
     private Long sortNumber;
-    
+
     /**
      * 导入模板中,【分数】
      * (默认取第一个子题分数)
      */
     private Double firstScore;
-    
+
     /**
      * 题型
      */
     private String quesType;
-    
+
     public String getTitleDetail() {
-		return titleDetail;
-	}
-
-	public void setTitleDetail(String titleDetail) {
-		this.titleDetail = titleDetail;
-	}
-    
-	public Long getSortNumber() {
-		return sortNumber;
-	}
-
-	public void setSortNumber(Long sortNumber) {
-		this.sortNumber = sortNumber;
-	}
-
-	public static long getSerialversionuid() {
-		return serialVersionUID;
-	}
-
-	public static long getSerialVersionUID() {
+        return titleDetail;
+    }
+
+    public void setTitleDetail(String titleDetail) {
+        this.titleDetail = titleDetail;
+    }
+
+    public Long getSortNumber() {
+        return sortNumber;
+    }
+
+    public void setSortNumber(Long sortNumber) {
+        this.sortNumber = sortNumber;
+    }
+
+    public static long getSerialversionuid() {
+        return serialVersionUID;
+    }
+
+    public static long getSerialVersionUID() {
         return serialVersionUID;
     }
 
@@ -132,33 +132,33 @@ public class PaperDetailExp implements Serializable,Comparable<PaperDetailExp>{
     public void setTitle(String title) {
         this.title = title;
     }
-    
+
     public Double getFirstScore() {
-		return firstScore;
-	}
-
-	public void setFirstScore(Double firstScore) {
-		this.firstScore = firstScore;
-	}
-	
-	public String getQuesType() {
-		return quesType;
-	}
-
-	public void setQuesType(String quesType) {
-		this.quesType = quesType;
-	}
-
-	@Override
+        return firstScore;
+    }
+
+    public void setFirstScore(Double firstScore) {
+        this.firstScore = firstScore;
+    }
+
+    public String getQuesType() {
+        return quesType;
+    }
+
+    public void setQuesType(String quesType) {
+        this.quesType = quesType;
+    }
+
+    @Override
     public int compareTo(PaperDetailExp paperDetailExp) {
         if (paperDetailExp != null) {
-            if(this.getNumber() == null)return -1;
-            if(paperDetailExp.getNumber() == null)return 1;
+            if (this.getNumber() == null) return -1;
+            if (paperDetailExp.getNumber() == null) return 1;
             if (this.getNumber() > paperDetailExp.getNumber()) {
                 return 1;
             } else if (this.getNumber() < paperDetailExp.getNumber()) {
                 return -1;
-            }else{
+            } else {
                 return 0;
             }
         }

+ 65 - 64
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/PaperDetailUnitExp.java

@@ -10,7 +10,7 @@ import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
 /**
  * 试卷小题导出dto Created by songyue on 17/3/15.
  */
-public class PaperDetailUnitExp implements Serializable,Comparable<PaperDetailUnitExp>{
+public class PaperDetailUnitExp implements Serializable, Comparable<PaperDetailUnitExp> {
 
     private static final long serialVersionUID = 6507445685386413261L;
 
@@ -27,46 +27,46 @@ public class PaperDetailUnitExp implements Serializable,Comparable<PaperDetailUn
     private String quesId;// 关联试题Id
 
     private List<Double> subScoreList;// 对应套题的情况下,各子题的分数分布
-    
+
     private String optionOrder;
-    
+
     /**
      * 一级属性名称(默认取question中第一个)
      */
     private String firstName;
-    
+
     /**
      * 二级属性名称(默认取question中第一个)
      */
     private String secondName;
-    
+
     /**
      * 公开,非公开
      */
     private String publicity;
-    
+
     public static long getSerialVersionUID() {
         return serialVersionUID;
     }
-    
-    public PaperDetailUnitExp(){
-    	
+
+    public PaperDetailUnitExp() {
+
     }
-    
-    public PaperDetailUnitExp(QuesStructType type,Integer number){
-    	this.questionType = type;
-    	this.score = (double) 0;
-    	this.number = number;
-    	Question question = new Question();
-		question.setQuesAnswer("#");
-    	this.question = question;
+
+    public PaperDetailUnitExp(QuesStructType type, Integer number) {
+        this.questionType = type;
+        this.score = (double) 0;
+        this.number = number;
+        Question question = new Question();
+        question.setQuesAnswer("#");
+        this.question = question;
     }
-    
-    public PaperDetailUnitExp(QuesStructType type,Question subQuestion){
-    	this.questionType = type;
-    	this.score = subQuestion.getScore();
-    	this.number = subQuestion.getNumber();
-    	this.question = subQuestion;
+
+    public PaperDetailUnitExp(QuesStructType type, Question subQuestion) {
+        this.questionType = type;
+        this.score = subQuestion.getScore();
+        this.number = subQuestion.getNumber();
+        this.question = subQuestion;
     }
 
     public String getId() {
@@ -125,53 +125,54 @@ public class PaperDetailUnitExp implements Serializable,Comparable<PaperDetailUn
         this.subScoreList = subScoreList;
     }
 
-	public String getOptionOrder() {
-		return optionOrder;
-	}
-
-	public void setOptionOrder(String optionOrder) {
-		this.optionOrder = optionOrder;
-	}
-	
-	public String getFirstName() {
-		return firstName;
-	}
-
-	public void setFirstName(String firstName) {
-		this.firstName = firstName;
-	}
-
-	public String getSecondName() {
-		return secondName;
-	}
-
-	public void setSecondName(String secondName) {
-		this.secondName = secondName;
-	}
-
-	public String getPublicity() {
-		return publicity;
-	}
-
-	public void setPublicity(String publicity) {
-		this.publicity = publicity;
-	}
-
-	/**
-	 * 按照number排序
-	 * @param paperDetailUnitExp
-	 * @return
-	 */
-	@Override
+    public String getOptionOrder() {
+        return optionOrder;
+    }
+
+    public void setOptionOrder(String optionOrder) {
+        this.optionOrder = optionOrder;
+    }
+
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    public String getSecondName() {
+        return secondName;
+    }
+
+    public void setSecondName(String secondName) {
+        this.secondName = secondName;
+    }
+
+    public String getPublicity() {
+        return publicity;
+    }
+
+    public void setPublicity(String publicity) {
+        this.publicity = publicity;
+    }
+
+    /**
+     * 按照number排序
+     *
+     * @param paperDetailUnitExp
+     * @return
+     */
+    @Override
     public int compareTo(PaperDetailUnitExp paperDetailUnitExp) {
         if (paperDetailUnitExp != null) {
-            if(this.getNumber() == null)return -1;
-            if(paperDetailUnitExp.getNumber() == null)return 1;
+            if (this.getNumber() == null) return -1;
+            if (paperDetailUnitExp.getNumber() == null) return 1;
             if (this.getNumber() > paperDetailUnitExp.getNumber()) {
                 return 1;
             } else if (this.getNumber() < paperDetailUnitExp.getNumber()) {
                 return -1;
-            }else{
+            } else {
                 return 0;
             }
         }

+ 112 - 109
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/PaperExp.java

@@ -11,7 +11,7 @@ import java.util.*;
  * 试卷导出dto
  * Created by songyue on 17/3/15.
  */
-public class PaperExp implements Serializable{
+public class PaperExp implements Serializable {
     private static final long serialVersionUID = -4673013279766466337L;
 
     private String id;
@@ -31,13 +31,13 @@ public class PaperExp implements Serializable{
     private String courseNo;
 
     private String courseName;
-    
+
     private Course course;
 
     private List<PaperDetailExp> paperDetails;
 
-    private Map<String,String> params;//导入试卷属性
-    
+    private Map<String, String> params;//导入试卷属性
+
     /**
      * 客观题
      */
@@ -46,19 +46,19 @@ public class PaperExp implements Serializable{
      * 主观题
      */
     private List<PaperDetailExp> subjectiveDetails;
-    
+
     /**
      * 客观题标题
      */
     private String objectiveTitle;
-    
+
     /**
      * 主观题标题
      */
     private String subjectiveTitle;
-    
+
     private Double objectiveScore;
-    
+
     private Double subjectiveScore;
 
     private String courseLevel;
@@ -68,13 +68,13 @@ public class PaperExp implements Serializable{
      * 是否包含音频题
      */
     private Boolean hasAudio;
-    
-    private Double difficultyDegree ; //难度系数
-    
+
+    private Double difficultyDegree; //难度系数
+
     private String examRemark;//考试说明
-    
+
     private String examRemarkWord;//考试说明word
-    
+
     public static long getSerialVersionUID() {
         return serialVersionUID;
     }
@@ -169,105 +169,108 @@ public class PaperExp implements Serializable{
 
     /**
      * 得到客观题
+     *
      * @return
      */
-	public List<PaperDetailExp> getObjectiveDetails() {
-		return objectiveDetails;
-	}
-
-	public void setObjectiveDetails(List<PaperDetailExp> objectiveDetails) {
-		this.objectiveDetails = objectiveDetails;
-	}
-	 /**
+    public List<PaperDetailExp> getObjectiveDetails() {
+        return objectiveDetails;
+    }
+
+    public void setObjectiveDetails(List<PaperDetailExp> objectiveDetails) {
+        this.objectiveDetails = objectiveDetails;
+    }
+
+    /**
      * 得到主观题
+     *
      * @return
      */
-	public List<PaperDetailExp> getSubjectiveDetails() {
-		return subjectiveDetails;
-	}
-
-	public void setSubjectiveDetails(List<PaperDetailExp> subjectiveDetails) {
-		this.subjectiveDetails = subjectiveDetails;
-	}
-
-	public Double getObjectiveScore() {
-		return objectiveScore;
-	}
-
-	public void setObjectiveScore(Double objectiveScore) {
-		this.objectiveScore = objectiveScore;
-	}
-
-	public Double getSubjectiveScore() {
-		return subjectiveScore;
-	}
-
-	public void setSubjectiveScore(Double subjectiveScore) {
-		this.subjectiveScore = subjectiveScore;
-	}
-
-	public String getCourseLevel() {
-		return courseLevel;
-	}
-
-	public void setCourseLevel(String courseLevel) {
-		this.courseLevel = courseLevel;
-	}
-
-	public Course getCourse() {
-		return course;
-	}
-
-	public void setCourse(Course course) {
-		this.course = course;
-	}
-
-	public Boolean getHasAudio() {
-		return hasAudio;
-	}
-
-	public void setHasAudio(Boolean hasAudio) {
-		this.hasAudio = hasAudio;
-	}
-
-	public String getObjectiveTitle() {
-		return objectiveTitle;
-	}
-
-	public void setObjectiveTitle(String objectiveTitle) {
-		this.objectiveTitle = objectiveTitle;
-	}
-
-	public String getSubjectiveTitle() {
-		return subjectiveTitle;
-	}
-
-	public void setSubjectiveTitle(String subjectiveTitle) {
-		this.subjectiveTitle = subjectiveTitle;
-	}
-
-	public Double getDifficultyDegree() {
-		return difficultyDegree;
-	}
-
-	public void setDifficultyDegree(Double difficultyDegree) {
-		this.difficultyDegree = difficultyDegree;
-	}
-
-	public String getExamRemark() {
-		return examRemark;
-	}
-
-	public void setExamRemark(String examRemark) {
-		this.examRemark = examRemark;
-	}
-
-	public String getExamRemarkWord() {
-		return examRemarkWord;
-	}
-
-	public void setExamRemarkWord(String examRemarkWord) {
-		this.examRemarkWord = examRemarkWord;
-	}
-    
+    public List<PaperDetailExp> getSubjectiveDetails() {
+        return subjectiveDetails;
+    }
+
+    public void setSubjectiveDetails(List<PaperDetailExp> subjectiveDetails) {
+        this.subjectiveDetails = subjectiveDetails;
+    }
+
+    public Double getObjectiveScore() {
+        return objectiveScore;
+    }
+
+    public void setObjectiveScore(Double objectiveScore) {
+        this.objectiveScore = objectiveScore;
+    }
+
+    public Double getSubjectiveScore() {
+        return subjectiveScore;
+    }
+
+    public void setSubjectiveScore(Double subjectiveScore) {
+        this.subjectiveScore = subjectiveScore;
+    }
+
+    public String getCourseLevel() {
+        return courseLevel;
+    }
+
+    public void setCourseLevel(String courseLevel) {
+        this.courseLevel = courseLevel;
+    }
+
+    public Course getCourse() {
+        return course;
+    }
+
+    public void setCourse(Course course) {
+        this.course = course;
+    }
+
+    public Boolean getHasAudio() {
+        return hasAudio;
+    }
+
+    public void setHasAudio(Boolean hasAudio) {
+        this.hasAudio = hasAudio;
+    }
+
+    public String getObjectiveTitle() {
+        return objectiveTitle;
+    }
+
+    public void setObjectiveTitle(String objectiveTitle) {
+        this.objectiveTitle = objectiveTitle;
+    }
+
+    public String getSubjectiveTitle() {
+        return subjectiveTitle;
+    }
+
+    public void setSubjectiveTitle(String subjectiveTitle) {
+        this.subjectiveTitle = subjectiveTitle;
+    }
+
+    public Double getDifficultyDegree() {
+        return difficultyDegree;
+    }
+
+    public void setDifficultyDegree(Double difficultyDegree) {
+        this.difficultyDegree = difficultyDegree;
+    }
+
+    public String getExamRemark() {
+        return examRemark;
+    }
+
+    public void setExamRemark(String examRemark) {
+        this.examRemark = examRemark;
+    }
+
+    public String getExamRemarkWord() {
+        return examRemarkWord;
+    }
+
+    public void setExamRemarkWord(String examRemarkWord) {
+        this.examRemarkWord = examRemarkWord;
+    }
+
 }

+ 7 - 7
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/PaperQuestionStructureInfo.java

@@ -6,15 +6,15 @@ import java.util.List;
 import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
 
 /**
- * @author 		weiwenhai
- * @date 		2018.4.19
- * @company		qmth
- * @describle   主观题可以客观题集合
+ * @author weiwenhai
+ * @date 2018.4.19
+ * @company qmth
+ * @describle 主观题可以客观题集合
  */
 public class PaperQuestionStructureInfo implements JsonSerializable {
-	
-	private static final long serialVersionUID = -2018523006958760481L;
-	/**
+
+    private static final long serialVersionUID = -2018523006958760481L;
+    /**
      * 客观题列表
      */
     private List<ObjectiveQuestionStructure> objectives;

+ 91 - 91
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/PaperStructBlueprintDto.java

@@ -1,98 +1,98 @@
 package cn.com.qmth.examcloud.core.questions.service.bean.dto;
 
 /**
- * @describle 蓝图试卷结构 Dto
  * @author weiwenhai
- * @date   2017.11.17
+ * @describle 蓝图试卷结构 Dto
+ * @date 2017.11.17
  */
 public class PaperStructBlueprintDto {
-	
-	private Long id;
-	
-	private String name;
-	
-	private Double totalScore;
-	
-	private String type;
-	
-	private String courseNo;
-	
-	private Long coursePropertyId;
-	
-	private String creator;
-	
-	private Long orgId;
-	
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public String getCourseCode() {
-		return courseNo;
-	}
-
-	public void setCourseCode(String courseNo) {
-		this.courseNo = courseNo;
-	}
-
-	public String getCreator() {
-		return creator;
-	}
-
-	public void setCreator(String creator) {
-		this.creator = creator;
-	}
-
-	public Long getOrgId() {
-		return orgId;
-	}
-
-	public void setOrgId(Long orgId) {
-		this.orgId = orgId;
-	}
-
-	public Double getTotalScore() {
-		return totalScore;
-	}
-
-	public void setTotalScore(Double totalScore) {
-		this.totalScore = totalScore;
-	}
-
-	public String getType() {
-		return type;
-	}
-
-	public void setType(String type) {
-		this.type = type;
-	}
-
-	public String getCourseNo() {
-		return courseNo;
-	}
-
-	public void setCourseNo(String courseNo) {
-		this.courseNo = courseNo;
-	}
-
-	public Long getCoursePropertyId() {
-		return coursePropertyId;
-	}
-
-	public void setCoursePropertyId(Long coursePropertyId) {
-		this.coursePropertyId = coursePropertyId;
-	}
-	
+
+    private Long id;
+
+    private String name;
+
+    private Double totalScore;
+
+    private String type;
+
+    private String courseNo;
+
+    private Long coursePropertyId;
+
+    private String creator;
+
+    private Long orgId;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getCourseCode() {
+        return courseNo;
+    }
+
+    public void setCourseCode(String courseNo) {
+        this.courseNo = courseNo;
+    }
+
+    public String getCreator() {
+        return creator;
+    }
+
+    public void setCreator(String creator) {
+        this.creator = creator;
+    }
+
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
+    }
+
+    public Double getTotalScore() {
+        return totalScore;
+    }
+
+    public void setTotalScore(Double totalScore) {
+        this.totalScore = totalScore;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getCourseNo() {
+        return courseNo;
+    }
+
+    public void setCourseNo(String courseNo) {
+        this.courseNo = courseNo;
+    }
+
+    public Long getCoursePropertyId() {
+        return coursePropertyId;
+    }
+
+    public void setCoursePropertyId(Long coursePropertyId) {
+        this.coursePropertyId = coursePropertyId;
+    }
+
 }

+ 1 - 1
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/QuesNameDto.java

@@ -5,7 +5,7 @@ import java.io.Serializable;
 /**
  * Created by songyue on 17/8/22.
  */
-public class QuesNameDto implements Serializable{
+public class QuesNameDto implements Serializable {
 
     private static final long serialVersionUID = -2720739626681442382L;
 

+ 58 - 58
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/QuestionDistributeDto.java

@@ -3,65 +3,65 @@ package cn.com.qmth.examcloud.core.questions.service.bean.dto;
 import java.util.Map;
 
 /**
- * @author 		weiwenhai
- * @date   		2018.5.3
- * @company		qmth
- * @describle	试题分布
+ * @author weiwenhai
+ * @date 2018.5.3
+ * @company qmth
+ * @describle 试题分布
  */
 public class QuestionDistributeDto {
-	
-	private String coursePropertyName;//属性名称
-	
-	private String firstPropertyName;//一级属性
-	
-	private String secondPropertyName;//二级属性
-	
-	/**
-	 * key: 题型-公开度-难度   例:单选题-公开-难(101)
-	 */
-	private Map<Long, Long> map;
-	
-	public QuestionDistributeDto(){
-		
-	}
-	
-	public QuestionDistributeDto(String coursePropertyName,String firstPropertyName,String secondPropertyName,Map<Long, Long> map){
-		this.coursePropertyName = coursePropertyName;
-		this.firstPropertyName = firstPropertyName;
-		this.secondPropertyName = secondPropertyName;
-		this.map = map;
-	}
-
-	public String getCoursePropertyName() {
-		return coursePropertyName;
-	}
-
-	public void setCoursePropertyName(String coursePropertyName) {
-		this.coursePropertyName = coursePropertyName;
-	}
-
-	public String getFirstPropertyName() {
-		return firstPropertyName;
-	}
-
-	public void setFirstPropertyName(String firstPropertyName) {
-		this.firstPropertyName = firstPropertyName;
-	}
-
-	public String getSecondPropertyName() {
-		return secondPropertyName;
-	}
-
-	public void setSecondPropertyName(String secondPropertyName) {
-		this.secondPropertyName = secondPropertyName;
-	}
-
-	public Map<Long, Long> getMap() {
-		return map;
-	}
-
-	public void setMap(Map<Long, Long> map) {
-		this.map = map;
-	}
+
+    private String coursePropertyName;//属性名称
+
+    private String firstPropertyName;//一级属性
+
+    private String secondPropertyName;//二级属性
+
+    /**
+     * key: 题型-公开度-难度   例:单选题-公开-难(101)
+     */
+    private Map<Long, Long> map;
+
+    public QuestionDistributeDto() {
+
+    }
+
+    public QuestionDistributeDto(String coursePropertyName, String firstPropertyName, String secondPropertyName, Map<Long, Long> map) {
+        this.coursePropertyName = coursePropertyName;
+        this.firstPropertyName = firstPropertyName;
+        this.secondPropertyName = secondPropertyName;
+        this.map = map;
+    }
+
+    public String getCoursePropertyName() {
+        return coursePropertyName;
+    }
+
+    public void setCoursePropertyName(String coursePropertyName) {
+        this.coursePropertyName = coursePropertyName;
+    }
+
+    public String getFirstPropertyName() {
+        return firstPropertyName;
+    }
+
+    public void setFirstPropertyName(String firstPropertyName) {
+        this.firstPropertyName = firstPropertyName;
+    }
+
+    public String getSecondPropertyName() {
+        return secondPropertyName;
+    }
+
+    public void setSecondPropertyName(String secondPropertyName) {
+        this.secondPropertyName = secondPropertyName;
+    }
+
+    public Map<Long, Long> getMap() {
+        return map;
+    }
+
+    public void setMap(Map<Long, Long> map) {
+        this.map = map;
+    }
 
 }

+ 2 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/SettingDto.java

@@ -1,7 +1,9 @@
 package cn.com.qmth.examcloud.core.questions.service.bean.dto;
 
 import cn.com.qmth.examcloud.core.questions.dao.entity.Setting;
+
 import java.util.List;
+
 /**
  * Created by songyue on 17/3/27.
  */

+ 151 - 150
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/dto/SubjectiveQuestionStructure.java

@@ -5,157 +5,158 @@ import java.io.Serializable;
 import cn.com.qmth.examcloud.core.questions.base.excel.ExcelProperty;
 
 /**
- * @author  	chenken
- * @date    	2017年7月18日 上午10:51:54
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年7月18日 上午10:51:54
+ * @company QMTH
  * @description 主观题数据--用于Excel导出
  */
-public class SubjectiveQuestionStructure implements Serializable{
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = 1130718763453256519L;
-	
-	/**
-	 * 课程Id
-	 */
-	private Long courseId;
-	/**
-	 * 课程代码
-	 */
-	@ExcelProperty(name="科目代码",index = 0)
-	private String courseCode;
-	/**
-	 * 课程名称
-	 */
-	@ExcelProperty(name="科目名称",index = 1)
-	private String courseName;
-	/**
-	 * 试卷名称
-	 */
-	@ExcelProperty(name="试卷名称",index = 2)
-	private String paperName;
-	
-	/**
-	 * 试卷类型
-	 */
-	@ExcelProperty(name="试卷类型",index = 3)
-	private String paperType;
-	/**
-	 * 大题号
-	 */
-	@ExcelProperty(name="大题号",index = 4)
-	private Integer sectionNum;
-	/**
-	 * 大题名称
-	 */
-	@ExcelProperty(name="大题名称",index = 5)
-	private String sectionName;
-	/**
-	 * 小题号
-	 */
-	@ExcelProperty(name="小题号",index = 6)
-	private Integer unitNum;
-	/**
-	 * 小题分数
-	 */
-	@ExcelProperty(name="满分",index = 7)
-	private Double unitScore;
-	
-	public SubjectiveQuestionStructure(){}
-	
-	public SubjectiveQuestionStructure(PaperExp paperExp,PaperDetailExp paperDetailExp,PaperDetailUnitExp unit){
-		this.courseCode = paperExp.getCourseNo();
-		this.courseName = paperExp.getCourseName();
-		this.sectionNum = paperDetailExp.getNumber();
-		this.sectionName = paperDetailExp.getName();
-		this.unitNum = unit.getNumber();
-		this.unitScore = unit.getScore();
-	}
-	
-	public SubjectiveQuestionStructure(PaperExp paperExp,PaperDetailExp paperDetailExp,PaperDetailUnitExp unit,String paperType){
-		this.courseId = Long.valueOf(paperExp.getCourse().getId());
-		this.paperName = paperExp.getName();
-		this.paperType = paperType;
-		this.courseCode = paperExp.getCourseNo();
-		this.courseName = paperExp.getCourseName();
-		this.sectionNum = paperDetailExp.getNumber();
-		this.sectionName = paperDetailExp.getName();
-		this.unitNum = unit.getNumber();
-		this.unitScore = unit.getScore();
-	}
-
-	public Long getCourseId() {
-		return courseId;
-	}
-
-	public void setCourseId(Long courseId) {
-		this.courseId = courseId;
-	}
-
-	public String getCourseCode() {
-		return courseCode;
-	}
-
-	public void setCourseCode(String courseCode) {
-		this.courseCode = courseCode;
-	}
-
-	public String getCourseName() {
-		return courseName;
-	}
-
-	public void setCourseName(String courseName) {
-		this.courseName = courseName;
-	}
-
-	public String getPaperName() {
-		return paperName;
-	}
-
-	public void setPaperName(String paperName) {
-		this.paperName = paperName;
-	}
-
-	public String getPaperType() {
-		return paperType;
-	}
-
-	public void setPaperType(String paperType) {
-		this.paperType = paperType;
-	}
-
-	public Integer getSectionNum() {
-		return sectionNum;
-	}
-
-	public void setSectionNum(Integer sectionNum) {
-		this.sectionNum = sectionNum;
-	}
-
-	public String getSectionName() {
-		return sectionName;
-	}
-
-	public void setSectionName(String sectionName) {
-		this.sectionName = sectionName;
-	}
-
-	public Integer getUnitNum() {
-		return unitNum;
-	}
-
-	public void setUnitNum(Integer unitNum) {
-		this.unitNum = unitNum;
-	}
-
-	public Double getUnitScore() {
-		return unitScore;
-	}
-
-	public void setUnitScore(Double unitScore) {
-		this.unitScore = unitScore;
-	}
-	
+public class SubjectiveQuestionStructure implements Serializable {
+    /**
+     *
+     */
+    private static final long serialVersionUID = 1130718763453256519L;
+
+    /**
+     * 课程Id
+     */
+    private Long courseId;
+    /**
+     * 课程代码
+     */
+    @ExcelProperty(name = "科目代码", index = 0)
+    private String courseCode;
+    /**
+     * 课程名称
+     */
+    @ExcelProperty(name = "科目名称", index = 1)
+    private String courseName;
+    /**
+     * 试卷名称
+     */
+    @ExcelProperty(name = "试卷名称", index = 2)
+    private String paperName;
+
+    /**
+     * 试卷类型
+     */
+    @ExcelProperty(name = "试卷类型", index = 3)
+    private String paperType;
+    /**
+     * 大题号
+     */
+    @ExcelProperty(name = "大题号", index = 4)
+    private Integer sectionNum;
+    /**
+     * 大题名称
+     */
+    @ExcelProperty(name = "大题名称", index = 5)
+    private String sectionName;
+    /**
+     * 小题号
+     */
+    @ExcelProperty(name = "小题号", index = 6)
+    private Integer unitNum;
+    /**
+     * 小题分数
+     */
+    @ExcelProperty(name = "满分", index = 7)
+    private Double unitScore;
+
+    public SubjectiveQuestionStructure() {
+    }
+
+    public SubjectiveQuestionStructure(PaperExp paperExp, PaperDetailExp paperDetailExp, PaperDetailUnitExp unit) {
+        this.courseCode = paperExp.getCourseNo();
+        this.courseName = paperExp.getCourseName();
+        this.sectionNum = paperDetailExp.getNumber();
+        this.sectionName = paperDetailExp.getName();
+        this.unitNum = unit.getNumber();
+        this.unitScore = unit.getScore();
+    }
+
+    public SubjectiveQuestionStructure(PaperExp paperExp, PaperDetailExp paperDetailExp, PaperDetailUnitExp unit, String paperType) {
+        this.courseId = Long.valueOf(paperExp.getCourse().getId());
+        this.paperName = paperExp.getName();
+        this.paperType = paperType;
+        this.courseCode = paperExp.getCourseNo();
+        this.courseName = paperExp.getCourseName();
+        this.sectionNum = paperDetailExp.getNumber();
+        this.sectionName = paperDetailExp.getName();
+        this.unitNum = unit.getNumber();
+        this.unitScore = unit.getScore();
+    }
+
+    public Long getCourseId() {
+        return courseId;
+    }
+
+    public void setCourseId(Long courseId) {
+        this.courseId = courseId;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getPaperName() {
+        return paperName;
+    }
+
+    public void setPaperName(String paperName) {
+        this.paperName = paperName;
+    }
+
+    public String getPaperType() {
+        return paperType;
+    }
+
+    public void setPaperType(String paperType) {
+        this.paperType = paperType;
+    }
+
+    public Integer getSectionNum() {
+        return sectionNum;
+    }
+
+    public void setSectionNum(Integer sectionNum) {
+        this.sectionNum = sectionNum;
+    }
+
+    public String getSectionName() {
+        return sectionName;
+    }
+
+    public void setSectionName(String sectionName) {
+        this.sectionName = sectionName;
+    }
+
+    public Integer getUnitNum() {
+        return unitNum;
+    }
+
+    public void setUnitNum(Integer unitNum) {
+        this.unitNum = unitNum;
+    }
+
+    public Double getUnitScore() {
+        return unitScore;
+    }
+
+    public void setUnitScore(Double unitScore) {
+        this.unitScore = unitScore;
+    }
+
 }
 

+ 8 - 8
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/bean/valve/Valve.java

@@ -5,13 +5,13 @@ import java.util.Map;
 import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
 
 public interface Valve {
-	
-	public boolean check(Question question);
-	
-	public void select(Question question);
-	
-	public Map<String,String> status();
-	
-	public void reset();
+
+    public boolean check(Question question);
+
+    public void select(Question question);
+
+    public Map<String, String> status();
+
+    public void reset();
 
 }

+ 1 - 1
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/converter/PrintExamPaperService.java

@@ -453,7 +453,7 @@ public class PrintExamPaperService {
      * 解压并提取JSON文件
      */
     @SuppressWarnings("unused")
-	private List<File> parseDataFiles(final String dirPath, File zipFile) throws Exception {
+    private List<File> parseDataFiles(final String dirPath, File zipFile) throws Exception {
         List<File> dataFileList = new ArrayList<>();
         //解压当前文件
         List<File> fileList = FileUtil.unZip(new File(dirPath), zipFile);

+ 62 - 62
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/BjhkExportPaperService.java

@@ -18,81 +18,81 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.QuestionTypeNum;
 import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperExp;
 
 /**
- * @author  	weiwenhai
- * @date    	2018年8月14日 上午11:29:49
- * @company 	QMTH
+ * @author weiwenhai
+ * @date 2018年8月14日 上午11:29:49
+ * @company QMTH
  * @description 北京航空大学导出、上传文件service
  */
 @Service("bjhkExportPaperService")
 public class BjhkExportPaperService extends ExportPaperAbstractService {
 
-	@Override
-    public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
-		PaperExp paperExp = super.initPaperExp(paperId);
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			if(examType.equals("offLine")){
-				WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
-				paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
-				DocxProcessUtil.exportWordNew(paperExp, file,BJHK_TMPLATE_PAPER);
-			}else{
-				DocxProcessUtil.exportWordNew(paperExp, file,BJHK_TMPLATE_PAPER);
-			}
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-			//下载音频
-			super.downloadAudio(paperExp, zipFileName);
-		}
+    @Override
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
+        PaperExp paperExp = super.initPaperExp(paperId);
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            if (examType.equals("offLine")) {
+                WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
+                paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
+                DocxProcessUtil.exportWordNew(paperExp, file, BJHK_TMPLATE_PAPER);
+            } else {
+                DocxProcessUtil.exportWordNew(paperExp, file, BJHK_TMPLATE_PAPER);
+            }
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+            //下载音频
+            super.downloadAudio(paperExp, zipFileName);
+        }
     }
-	
-	@Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			DocxProcessUtil.exportWordNew(paperExp,file,BJHK_TMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-		}
-	}
 
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-		PaperExp paperExp = initPaperExp(paperId);
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//删除原有试卷文件
+    @Override
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, BJHK_TMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
+        }
+    }
+
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //删除原有试卷文件
         	/*ExamFile examFile = new ExamFile();
         	examFile.setExamId(extractConfig.getExamId()+"");
         	examFile.setCourseId(extractConfig.getCourseCode());
         	examFile.setOrgId(extractConfig.getOrgId());
         	examFileService.deleteExamFile(examFile);*/
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJHK_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJHK_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJHK_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJHK_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, BJHK_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, BJHK_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, BJHK_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, BJHK_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

+ 55 - 55
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/BjjtExportPaperService.java

@@ -19,69 +19,69 @@ import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperExp;
 @Service("bjjtExportPaperService")
 public class BjjtExportPaperService extends ExportPaperAbstractService {
 
-	@Override
-    public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
-		PaperExp paperExp = super.initPaperExp(paperId);
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			if(examType.equals("offLine")){
-				DocxProcessUtil.exportWordNew(paperExp, file,BJJT_TMPLATE_PAPER);
-			}else{
-				DocxProcessUtil.exportWordNew(paperExp, file,BJJT_TMPLATE_PAPER);
-			}
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-		}
+    @Override
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
+        PaperExp paperExp = super.initPaperExp(paperId);
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            if (examType.equals("offLine")) {
+                DocxProcessUtil.exportWordNew(paperExp, file, BJJT_TMPLATE_PAPER);
+            } else {
+                DocxProcessUtil.exportWordNew(paperExp, file, BJJT_TMPLATE_PAPER);
+            }
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+        }
     }
-	
-	@Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			DocxProcessUtil.exportWordNew(paperExp,file,BJJT_TMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-		}
-	}
 
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-		PaperExp paperExp = initPaperExp(paperId);
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//删除原有试卷文件
+    @Override
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, BJJT_TMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
+        }
+    }
+
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //删除原有试卷文件
         	/*ExamFile examFile = new ExamFile();
         	examFile.setExamId(extractConfig.getExamId()+"");
         	examFile.setCourseId(extractConfig.getCourseCode());
         	examFile.setOrgId(extractConfig.getOrgId());
         	examFileService.deleteExamFile(examFile);*/
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJJT_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJJT_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJJT_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJJT_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, BJJT_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, BJJT_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, BJJT_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, BJJT_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

+ 62 - 62
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/BjsfExportPaperService.java

@@ -18,81 +18,81 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.QuestionTypeNum;
 import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperExp;
 
 /**
- * @author  	weiwenhai
- * @date    	2018年6月2日 上午11:29:49
- * @company 	QMTH
+ * @author weiwenhai
+ * @date 2018年6月2日 上午11:29:49
+ * @company QMTH
  * @description 北京师范大学导出、上传文件service
  */
 @Service("bjsfExportPaperService")
 public class BjsfExportPaperService extends ExportPaperAbstractService {
 
-	@Override
-    public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
-		PaperExp paperExp = super.initPaperExp(paperId);
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			if(examType.equals("offLine")){
-				WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
-				paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
-				DocxProcessUtil.exportWordNew(paperExp, file,BJSF_TMPLATE_PAPER);
-			}else{
-				DocxProcessUtil.exportWordNew(paperExp, file,BJSF_TMPLATE_PAPER);
-			}
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-			//下载音频
-			super.downloadAudio(paperExp, zipFileName);
-		}
+    @Override
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
+        PaperExp paperExp = super.initPaperExp(paperId);
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            if (examType.equals("offLine")) {
+                WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
+                paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
+                DocxProcessUtil.exportWordNew(paperExp, file, BJSF_TMPLATE_PAPER);
+            } else {
+                DocxProcessUtil.exportWordNew(paperExp, file, BJSF_TMPLATE_PAPER);
+            }
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+            //下载音频
+            super.downloadAudio(paperExp, zipFileName);
+        }
     }
-	
-	@Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			DocxProcessUtil.exportWordNew(paperExp,file,BJSF_TMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-		}
-	}
 
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-		PaperExp paperExp = initPaperExp(paperId);
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//删除原有试卷文件
+    @Override
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, BJSF_TMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
+        }
+    }
+
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //删除原有试卷文件
         	/*ExamFile examFile = new ExamFile();
         	examFile.setExamId(extractConfig.getExamId()+"");
         	examFile.setCourseId(extractConfig.getCourseCode());
         	examFile.setOrgId(extractConfig.getOrgId());
         	examFileService.deleteExamFile(examFile);*/
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJSF_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJSF_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJSF_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,BJSF_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, BJSF_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, BJSF_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, BJSF_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, BJSF_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

+ 177 - 175
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/BuildComputerTestJsonService.java

@@ -31,171 +31,173 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
 import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
 
 /**
- * @author  	chenken
- * @date    	2017年10月24日 下午2:29:09
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年10月24日 下午2:29:09
+ * @company QMTH
  * @description 构建机考数据包服务
  */
 @Service("buildComputerTestJsonService")
 public class BuildComputerTestJsonService {
-	
-	@Autowired
-	private PaperService paperService;
-	
-	@Autowired
-	private PaperDetailService paperDetailService;
-	
-	@Autowired
-	private AudioTimeConfigRepo audioTimeConfigRepo;
+
+    @Autowired
+    private PaperService paperService;
+
+    @Autowired
+    private PaperDetailService paperDetailService;
+
+    @Autowired
+    private AudioTimeConfigRepo audioTimeConfigRepo;
+
     /**
      * 根据调卷规则构建机考数据包实体类
+     *
      * @param extractConfig
      * @return
      */
-    public List<ComputerTestPaper> buildComputerTestPapers(ExtractConfig extractConfig){
-    	List<ExamPaper> examPapers = extractConfig.getExamPaperList();
-    	List<ComputerTestPaper> computerTestPapers = new ArrayList<ComputerTestPaper>();
-    	//循环得到试卷
-    	for(ExamPaper examPaper:examPapers){
-    		Paper paper = examPaper.getPaper();
-    		//得到所有旧对象的大题对象
-    		List<PaperDetail> paperDetails = paperService.findPaperDetailsById(paper.getId());
-    		//通过 paper 对象 ,生成新的  ComputerTestPaper 对象
-    		ComputerTestPaper computerTestPaper = new ComputerTestPaper(paper,examPaper.getGroupCode());
-    		List<ComputerTestPaperDetail> details = new ArrayList<ComputerTestPaperDetail>();
-    		//遍历所有旧大题对象,得到小题对象的集合
-    		for(PaperDetail paperDetail:paperDetails){
-    			List<PaperDetailUnit> paperDetailUnits = paperDetailService.getUnitsByPaperDetailId(paperDetail.getId());
-    			ComputerTestPaperDetail computerTestPaperDetail = new ComputerTestPaperDetail(paperDetail);
-    			List<ComputerTestQuestion> questions = new ArrayList<ComputerTestQuestion>();
-    			//遍历所有的小题对象
-    			for(int i = 0;i<paperDetailUnits.size();i++){
-    				PaperDetailUnit paperDetailUnit = paperDetailUnits.get(i);
-    				//根据旧的小题对象,生成新的小题对象
-    				ComputerTestQuestion  computerTestQuestion = new ComputerTestQuestion(paperDetailUnit);
-    				//设置小题题号
-    				computerTestQuestion.setNumber(i+1);
-    				//得到小题题干
-    				computerTestQuestion.setBody(getBody(paperDetailUnit.getQuestion(),paperDetailUnit));
-    				//得到小题所有选项
-    				computerTestQuestion.setOptions(getOption(paperDetailUnit.getQuestion(),paperDetailUnit));
-    				//查询小题中的 套题
-    				List<Question> subQuestionsList = paperDetailUnit.getQuestion().getSubQuestions();
-    				//判断这个小题中是否有套题
-    				if(subQuestionsList!=null&&subQuestionsList.size()>0){
-    					List<ComputerTestQuestion> subQuestions = new ArrayList<ComputerTestQuestion>();
-    					//遍历每个套题
-    					for(int j = 0;j<subQuestionsList.size();j++){
-    						Question subQuestion = subQuestionsList.get(j);
-        					ComputerTestQuestion subcomputerTestQuestion = new ComputerTestQuestion(subQuestion);
-        					//设置套题中小题题号
-        					subcomputerTestQuestion.setNumber(j+1);
-        					subcomputerTestQuestion.setBody(getBody(subQuestion,null));
-        					subcomputerTestQuestion.setOptions(getOption(subQuestion,null));
-        					subQuestions.add(subcomputerTestQuestion);
-    					}
-        				computerTestQuestion.setSubQuestions(subQuestions);
-    				}
-    				questions.add(computerTestQuestion);
-    			}
-    			computerTestPaperDetail.setQuestions(questions);
-    			//paperDetail中的题数(unitCount)可能不准确,这里以questions的实际size为准
-    			computerTestPaperDetail.setQuestionCount(questions.size());
-    			details.add(computerTestPaperDetail);
-    		}
-    		computerTestPaper.setDetails(details);
-    		computerTestPapers.add(computerTestPaper);
-    	}
-    	return computerTestPapers;
+    public List<ComputerTestPaper> buildComputerTestPapers(ExtractConfig extractConfig) {
+        List<ExamPaper> examPapers = extractConfig.getExamPaperList();
+        List<ComputerTestPaper> computerTestPapers = new ArrayList<ComputerTestPaper>();
+        //循环得到试卷
+        for (ExamPaper examPaper : examPapers) {
+            Paper paper = examPaper.getPaper();
+            //得到所有旧对象的大题对象
+            List<PaperDetail> paperDetails = paperService.findPaperDetailsById(paper.getId());
+            //通过 paper 对象 ,生成新的  ComputerTestPaper 对象
+            ComputerTestPaper computerTestPaper = new ComputerTestPaper(paper, examPaper.getGroupCode());
+            List<ComputerTestPaperDetail> details = new ArrayList<ComputerTestPaperDetail>();
+            //遍历所有旧大题对象,得到小题对象的集合
+            for (PaperDetail paperDetail : paperDetails) {
+                List<PaperDetailUnit> paperDetailUnits = paperDetailService.getUnitsByPaperDetailId(paperDetail.getId());
+                ComputerTestPaperDetail computerTestPaperDetail = new ComputerTestPaperDetail(paperDetail);
+                List<ComputerTestQuestion> questions = new ArrayList<ComputerTestQuestion>();
+                //遍历所有的小题对象
+                for (int i = 0; i < paperDetailUnits.size(); i++) {
+                    PaperDetailUnit paperDetailUnit = paperDetailUnits.get(i);
+                    //根据旧的小题对象,生成新的小题对象
+                    ComputerTestQuestion computerTestQuestion = new ComputerTestQuestion(paperDetailUnit);
+                    //设置小题题号
+                    computerTestQuestion.setNumber(i + 1);
+                    //得到小题题干
+                    computerTestQuestion.setBody(getBody(paperDetailUnit.getQuestion(), paperDetailUnit));
+                    //得到小题所有选项
+                    computerTestQuestion.setOptions(getOption(paperDetailUnit.getQuestion(), paperDetailUnit));
+                    //查询小题中的 套题
+                    List<Question> subQuestionsList = paperDetailUnit.getQuestion().getSubQuestions();
+                    //判断这个小题中是否有套题
+                    if (subQuestionsList != null && subQuestionsList.size() > 0) {
+                        List<ComputerTestQuestion> subQuestions = new ArrayList<ComputerTestQuestion>();
+                        //遍历每个套题
+                        for (int j = 0; j < subQuestionsList.size(); j++) {
+                            Question subQuestion = subQuestionsList.get(j);
+                            ComputerTestQuestion subcomputerTestQuestion = new ComputerTestQuestion(subQuestion);
+                            //设置套题中小题题号
+                            subcomputerTestQuestion.setNumber(j + 1);
+                            subcomputerTestQuestion.setBody(getBody(subQuestion, null));
+                            subcomputerTestQuestion.setOptions(getOption(subQuestion, null));
+                            subQuestions.add(subcomputerTestQuestion);
+                        }
+                        computerTestQuestion.setSubQuestions(subQuestions);
+                    }
+                    questions.add(computerTestQuestion);
+                }
+                computerTestPaperDetail.setQuestions(questions);
+                //paperDetail中的题数(unitCount)可能不准确,这里以questions的实际size为准
+                computerTestPaperDetail.setQuestionCount(questions.size());
+                details.add(computerTestPaperDetail);
+            }
+            computerTestPaper.setDetails(details);
+            computerTestPapers.add(computerTestPaper);
+        }
+        return computerTestPapers;
     }
 
-	private Sections getBody(Question question,PaperDetailUnit paperDetailUnit){
-    	Sections body = new Sections();
-		List<Section> sections = new ArrayList<Section>(); 
-		//得到小题题干
-		String questionBodyString = question.getQuesBody();
-		//得到小题题干行数
-		String[] questionRowStrings = questionBodyString.split("</p>");
-		for(int i = 0;i<questionRowStrings.length;i++){
-			Section section = new Section();
-			//将小题题干拆分为Block集合
-			section.setBlocks(disposeQuestionBodyOrOption(questionRowStrings[i],paperDetailUnit));
-			sections.add(section);
-		}
-		body.setSections(sections);
-		return body;
+    private Sections getBody(Question question, PaperDetailUnit paperDetailUnit) {
+        Sections body = new Sections();
+        List<Section> sections = new ArrayList<Section>();
+        //得到小题题干
+        String questionBodyString = question.getQuesBody();
+        //得到小题题干行数
+        String[] questionRowStrings = questionBodyString.split("</p>");
+        for (int i = 0; i < questionRowStrings.length; i++) {
+            Section section = new Section();
+            //将小题题干拆分为Block集合
+            section.setBlocks(disposeQuestionBodyOrOption(questionRowStrings[i], paperDetailUnit));
+            sections.add(section);
+        }
+        body.setSections(sections);
+        return body;
     }
-    
-    private List<ComputerTestOption> getOption(Question question,PaperDetailUnit paperDetailUnit){
-    	//得到小题选项
-		List<QuesOption> quesOptions = question.getQuesOptions();
-		List<ComputerTestOption> options = new ArrayList<ComputerTestOption>();
-		//遍历小题选项
-		if(quesOptions!=null&&quesOptions.size()>0){
-			for(QuesOption quesOption: quesOptions){
-				ComputerTestOption option = new ComputerTestOption();
-				option.setNumber(new Integer(quesOption.getNumber()));
-				option.setCorrect(quesOption.getIsCorrect()==1?true:false);
-				Sections body = new Sections();
-				
-				List<Section> sections = new ArrayList<Section>();
-				//得到小题选项
-				String optionString = quesOption.getOptionBody();
-				String[] optionStrings = optionString.split("</p>");
-				for(int i = 0;i<optionStrings.length;i++){
-					Section section = new Section();
-					section.setBlocks(disposeQuestionBodyOrOption(optionStrings[i],paperDetailUnit));
-					sections.add(section);
-				}
-				body.setSections(sections);
-				option.setBody(body);
-				options.add(option);
-			}
-		}
-		return options;
+
+    private List<ComputerTestOption> getOption(Question question, PaperDetailUnit paperDetailUnit) {
+        //得到小题选项
+        List<QuesOption> quesOptions = question.getQuesOptions();
+        List<ComputerTestOption> options = new ArrayList<ComputerTestOption>();
+        //遍历小题选项
+        if (quesOptions != null && quesOptions.size() > 0) {
+            for (QuesOption quesOption : quesOptions) {
+                ComputerTestOption option = new ComputerTestOption();
+                option.setNumber(new Integer(quesOption.getNumber()));
+                option.setCorrect(quesOption.getIsCorrect() == 1 ? true : false);
+                Sections body = new Sections();
+
+                List<Section> sections = new ArrayList<Section>();
+                //得到小题选项
+                String optionString = quesOption.getOptionBody();
+                String[] optionStrings = optionString.split("</p>");
+                for (int i = 0; i < optionStrings.length; i++) {
+                    Section section = new Section();
+                    section.setBlocks(disposeQuestionBodyOrOption(optionStrings[i], paperDetailUnit));
+                    sections.add(section);
+                }
+                body.setSections(sections);
+                option.setBody(body);
+                options.add(option);
+            }
+        }
+        return options;
     }
-      
-    private List<Block> disposeQuestionBodyOrOption(String questionRow,PaperDetailUnit paperDetailUnit) {
-    	List<Block> blocks = new ArrayList<Block>();
-    	//去掉每行里面的<p>,<span>,</span>标签
-    	questionRow = questionRow.replaceAll("<p>", "")
-			    				 .replaceAll("</p>", "")
-			    				 .replaceAll("<span>", "")
-			    				 .replaceAll("</span>", "")
-			    				 .replaceAll("</a>", "");
-		String[] questionRowStrings = questionRow.split("<|/>|>");
-    	for(int i = 0;i<questionRowStrings.length;i++){
-    		Block block = new Block();
-			//判断是否有图片
-			if(questionRowStrings[i].startsWith("img")){
-				questionRowStrings[i] = "<"+questionRowStrings[i]+">";
-				Map<String, Object> param  = new HashMap<String, Object>();
-				//需要继续做截取,取到Parma
-				block.setType("image");
-				//获取图片的路径
-				List<String> strSrcList = getImg(questionRowStrings[i], "src");
-				if(strSrcList.size()>0){
-					String strSrc = strSrcList.get(0).replaceAll("src=\"", "").replaceAll("\"", "");
-					block.setValue(strSrc);
-				}
-				//获取图片的高度
-				List<String> strHeightList = getImg(questionRowStrings[i], "height");
-				if(strHeightList.size()>0){
-					String strHeight = strHeightList.get(0).replaceAll("height=\"", "").replaceAll("\"", "");
-					param.put("height", strHeight);
-				}
-				//获取图片的宽度
-				List<String> strWidthList = getImg(questionRowStrings[i], "width");
-				if(strHeightList.size()>0){
-					String strWidth = strWidthList.get(0).replaceAll("width=\"", "").replaceAll("\"", "");
-					param.put("width", strWidth);
-				}
-				block.setParam(param);
-				blocks.add(block);
-			}else if(questionRowStrings[i].startsWith("a")
-					&&questionRowStrings[i].contains("id")
-					&&questionRowStrings[i].contains("name")){	//处理音频
-				questionRowStrings[i] = "<"+questionRowStrings[i]+">";
+
+    private List<Block> disposeQuestionBodyOrOption(String questionRow, PaperDetailUnit paperDetailUnit) {
+        List<Block> blocks = new ArrayList<Block>();
+        //去掉每行里面的<p>,<span>,</span>标签
+        questionRow = questionRow.replaceAll("<p>", "")
+                .replaceAll("</p>", "")
+                .replaceAll("<span>", "")
+                .replaceAll("</span>", "")
+                .replaceAll("</a>", "");
+        String[] questionRowStrings = questionRow.split("<|/>|>");
+        for (int i = 0; i < questionRowStrings.length; i++) {
+            Block block = new Block();
+            //判断是否有图片
+            if (questionRowStrings[i].startsWith("img")) {
+                questionRowStrings[i] = "<" + questionRowStrings[i] + ">";
+                Map<String, Object> param = new HashMap<String, Object>();
+                //需要继续做截取,取到Parma
+                block.setType("image");
+                //获取图片的路径
+                List<String> strSrcList = getImg(questionRowStrings[i], "src");
+                if (strSrcList.size() > 0) {
+                    String strSrc = strSrcList.get(0).replaceAll("src=\"", "").replaceAll("\"", "");
+                    block.setValue(strSrc);
+                }
+                //获取图片的高度
+                List<String> strHeightList = getImg(questionRowStrings[i], "height");
+                if (strHeightList.size() > 0) {
+                    String strHeight = strHeightList.get(0).replaceAll("height=\"", "").replaceAll("\"", "");
+                    param.put("height", strHeight);
+                }
+                //获取图片的宽度
+                List<String> strWidthList = getImg(questionRowStrings[i], "width");
+                if (strHeightList.size() > 0) {
+                    String strWidth = strWidthList.get(0).replaceAll("width=\"", "").replaceAll("\"", "");
+                    param.put("width", strWidth);
+                }
+                block.setParam(param);
+                blocks.add(block);
+            } else if (questionRowStrings[i].startsWith("a")
+                    && questionRowStrings[i].contains("id")
+                    && questionRowStrings[i].contains("name")) {    //处理音频
+                questionRowStrings[i] = "<" + questionRowStrings[i] + ">";
 				/*if(paperDetailUnit == null){
 					block.setPlayTime(-1);
 				}else {
@@ -210,39 +212,39 @@ public class BuildComputerTestJsonService {
 						block.setPlayTime(-1);
 					}
 				}*/
-				block.setType("audio");
-				block.setValue(CommonUtils.getAttrValue(questionRowStrings[i],"id"));
-				blocks.add(block);
-			}else{
-				block.setType("text");
-				questionRowStrings[i] = questionRowStrings[i].replace("&nbsp;","");//消除空格
-				questionRowStrings[i] = questionRowStrings[i].replace("&quot;","\"");//将&quot;转换成\"
-				questionRowStrings[i] = questionRowStrings[i].replace("&lt;","<");//将&lt;转换成<
-				questionRowStrings[i] = questionRowStrings[i].replace("&gt;",">");//将&gt;转换成>
-				questionRowStrings[i] = questionRowStrings[i].replace("&amp;","&");//将&amp;转换成&
-				if(StringUtils.isNotBlank(questionRowStrings[i])){
-					block.setValue(questionRowStrings[i]);
-					blocks.add(block);
-				}
-			}
-    	}
-		return blocks;
-	}
-    
-	/**
+                block.setType("audio");
+                block.setValue(CommonUtils.getAttrValue(questionRowStrings[i], "id"));
+                blocks.add(block);
+            } else {
+                block.setType("text");
+                questionRowStrings[i] = questionRowStrings[i].replace("&nbsp;", "");//消除空格
+                questionRowStrings[i] = questionRowStrings[i].replace("&quot;", "\"");//将&quot;转换成\"
+                questionRowStrings[i] = questionRowStrings[i].replace("&lt;", "<");//将&lt;转换成<
+                questionRowStrings[i] = questionRowStrings[i].replace("&gt;", ">");//将&gt;转换成>
+                questionRowStrings[i] = questionRowStrings[i].replace("&amp;", "&");//将&amp;转换成&
+                if (StringUtils.isNotBlank(questionRowStrings[i])) {
+                    block.setValue(questionRowStrings[i]);
+                    blocks.add(block);
+                }
+            }
+        }
+        return blocks;
+    }
+
+    /**
      * 获取图片里面的路径,长度,宽度
+     *
      * @param s
      * @param str
      * @return
      */
-    private List<String> getImg(String s,String str){
+    private List<String> getImg(String s, String str) {
         String regex;
         List<String> list = new ArrayList<String>();
         regex = str + "=\"(.*?)\"";
         Pattern pa = Pattern.compile(regex, Pattern.DOTALL);
         Matcher ma = pa.matcher(s);
-        while (ma.find())
-        {
+        while (ma.find()) {
             list.add(ma.group());
         }
         return list;

+ 100 - 99
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/CqdxExportPaperService.java

@@ -21,117 +21,118 @@ import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperDetailExp;
 import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperExp;
 
 /**
- * @author  	weiwenhai
- * @date    	2018年6月2日 上午11:29:49
- * @company 	QMTH
+ * @author weiwenhai
+ * @date 2018年6月2日 上午11:29:49
+ * @company QMTH
  * @description 重庆大学导出、上传文件service
  */
 @Service("cqdxExportPaperService")
 public class CqdxExportPaperService extends ExportPaperAbstractService {
-	
-	@Override
-    public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
-		PaperExp paperExp = super.initPaperExp(paperId);
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			if(examType.equals("offLine")){
-				WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
-				paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
-				DocxProcessUtil.exportWordNew(paperExp, file,CQDX_TMPLATE_PAPER);
-			}else{
-				DocxProcessUtil.exportWordNew(paperExp, file,CQDX_TMPLATE_PAPER);
-			}
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-			//下载音频
-			super.downloadAudio(paperExp, zipFileName);
-		}
+
+    @Override
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
+        PaperExp paperExp = super.initPaperExp(paperId);
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            if (examType.equals("offLine")) {
+                WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
+                paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
+                DocxProcessUtil.exportWordNew(paperExp, file, CQDX_TMPLATE_PAPER);
+            } else {
+                DocxProcessUtil.exportWordNew(paperExp, file, CQDX_TMPLATE_PAPER);
+            }
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+            //下载音频
+            super.downloadAudio(paperExp, zipFileName);
+        }
+    }
+
+    @Override
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, CQDX_TMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
+        }
     }
-	
-	@Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			DocxProcessUtil.exportWordNew(paperExp,file,CQDX_TMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-		}
-	}
-	
-	/**
-   	 * 设置大题标题
-   	 * @param paperDetailExps
-   	 */
-	@Override
-   	public void setExpDtoTitle(List<PaperDetailExp> paperDetailExps) {
-   		for(PaperDetailExp paperDetailExp:paperDetailExps){
-   			String title = "";
-   			String titleDetail = null;
-   			String totalScore = BigDecimal.valueOf(paperDetailExp.getScore()).stripTrailingZeros().toPlainString();
-   			QuesStructType type = paperDetailExp.getPaperDetailUnits().get(0).getQuestionType();
-   			String questionScore = checkPaperDetailUnitScore(paperDetailExp);
-   			if(questionScore!=null){
-   				questionScore = deletePoint(questionScore);
-   			}
-   			String scoreString = questionScore==null?"":"每小题"+questionScore+"分,";
-   			if (type == QuesStructType.SINGLE_ANSWER_QUESTION) {
-   				title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
-   						+ scoreString + "共" + totalScore + "分)";
-   				titleDetail = "在每小题列出的备选项中只有一个符合题目要求的,请将其选出并将“答题卡”的相应代码涂黑,错涂、多涂或未涂均无分";
-   			} else if (type == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
-   				title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
-   						+ scoreString + "共" + totalScore+ "分)";
-   				titleDetail = "在每小题列出的备选项中至少有两个符合题目要求,请将符合项选出并将“答题卡”的相应代码涂黑,错涂、多涂、少涂或未涂均无分";
-   			} else if (type == QuesStructType.BOOL_ANSWER_QUESTION) {
-   				title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
-   						+ scoreString + "共" + totalScore+ "分。"
-   						+ "正确的填涂√、错误填涂×。错涂、多涂或未涂均无分)";
-   			} else {
-   				title = "(本大题共"+paperDetailExp.getUnitCount()+"小题,"+scoreString+"共"+totalScore+"分)";
-   			}
-   			paperDetailExp.setTitle(title);
-   			paperDetailExp.setTitleDetail(titleDetail);
-   		}
-   	}
 
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-		PaperExp paperExp = initPaperExp(paperId);
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//删除原有试卷文件
+    /**
+     * 设置大题标题
+     *
+     * @param paperDetailExps
+     */
+    @Override
+    public void setExpDtoTitle(List<PaperDetailExp> paperDetailExps) {
+        for (PaperDetailExp paperDetailExp : paperDetailExps) {
+            String title = "";
+            String titleDetail = null;
+            String totalScore = BigDecimal.valueOf(paperDetailExp.getScore()).stripTrailingZeros().toPlainString();
+            QuesStructType type = paperDetailExp.getPaperDetailUnits().get(0).getQuestionType();
+            String questionScore = checkPaperDetailUnitScore(paperDetailExp);
+            if (questionScore != null) {
+                questionScore = deletePoint(questionScore);
+            }
+            String scoreString = questionScore == null ? "" : "每小题" + questionScore + "分,";
+            if (type == QuesStructType.SINGLE_ANSWER_QUESTION) {
+                title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
+                        + scoreString + "共" + totalScore + "分)";
+                titleDetail = "在每小题列出的备选项中只有一个符合题目要求的,请将其选出并将“答题卡”的相应代码涂黑,错涂、多涂或未涂均无分";
+            } else if (type == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
+                title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
+                        + scoreString + "共" + totalScore + "分)";
+                titleDetail = "在每小题列出的备选项中至少有两个符合题目要求,请将符合项选出并将“答题卡”的相应代码涂黑,错涂、多涂、少涂或未涂均无分";
+            } else if (type == QuesStructType.BOOL_ANSWER_QUESTION) {
+                title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
+                        + scoreString + "共" + totalScore + "分。"
+                        + "正确的填涂√、错误填涂×。错涂、多涂或未涂均无分)";
+            } else {
+                title = "(本大题共" + paperDetailExp.getUnitCount() + "小题," + scoreString + "共" + totalScore + "分)";
+            }
+            paperDetailExp.setTitle(title);
+            paperDetailExp.setTitleDetail(titleDetail);
+        }
+    }
+
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //删除原有试卷文件
         	/*ExamFile examFile = new ExamFile();
         	examFile.setExamId(extractConfig.getExamId()+"");
         	examFile.setCourseId(extractConfig.getCourseCode());
         	examFile.setOrgId(extractConfig.getOrgId());
         	examFileService.deleteExamFile(examFile);*/
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,CQDX_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,CQDX_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,CQDX_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,CQDX_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, CQDX_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, CQDX_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, CQDX_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, CQDX_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

+ 62 - 62
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/DbsfExportPaperService.java

@@ -18,81 +18,81 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.QuestionTypeNum;
 import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperExp;
 
 /**
- * @author  	weiwenhai
- * @date    	2018年7月25日 上午11:29:49
- * @company 	QMTH
+ * @author weiwenhai
+ * @date 2018年7月25日 上午11:29:49
+ * @company QMTH
  * @description 东北师范大学导出、上传文件service
  */
 @Service("dbsfExportPaperService")
 public class DbsfExportPaperService extends ExportPaperAbstractService {
 
-	@Override
-    public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
-		PaperExp paperExp = super.initPaperExp(paperId);
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			if(examType.equals("offLine")){
-				WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
-				paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
-				DocxProcessUtil.exportWordNew(paperExp, file,DBSF_TMPLATE_PAPER);
-			}else{
-				DocxProcessUtil.exportWordNew(paperExp, file,DBSF_TMPLATE_PAPER);
-			}
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-			//下载音频
-			super.downloadAudio(paperExp, zipFileName);
-		}
+    @Override
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
+        PaperExp paperExp = super.initPaperExp(paperId);
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            if (examType.equals("offLine")) {
+                WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
+                paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
+                DocxProcessUtil.exportWordNew(paperExp, file, DBSF_TMPLATE_PAPER);
+            } else {
+                DocxProcessUtil.exportWordNew(paperExp, file, DBSF_TMPLATE_PAPER);
+            }
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+            //下载音频
+            super.downloadAudio(paperExp, zipFileName);
+        }
     }
-	
-	@Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			DocxProcessUtil.exportWordNew(paperExp,file,DBSF_TMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-		}
-	}
 
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-		PaperExp paperExp = initPaperExp(paperId);
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//删除原有试卷文件
+    @Override
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, DBSF_TMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
+        }
+    }
+
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //删除原有试卷文件
         	/*ExamFile examFile = new ExamFile();
         	examFile.setExamId(extractConfig.getExamId()+"");
         	examFile.setCourseId(extractConfig.getCourseCode());
         	examFile.setOrgId(extractConfig.getOrgId());
         	examFileService.deleteExamFile(examFile);*/
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,DBSF_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,DBSF_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,DBSF_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,DBSF_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, DBSF_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, DBSF_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, DBSF_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, DBSF_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

+ 288 - 282
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/DzkdExportPaperService.java

@@ -27,303 +27,309 @@ import cn.com.qmth.examcloud.core.questions.base.enums.ExportType;
 import cn.com.qmth.examcloud.core.questions.base.word.DocxProcessUtil;
 
 /**
- * 
- * @author  	chenken
- * @date    	2017年7月31日 上午9:21:51
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年7月31日 上午9:21:51
+ * @company QMTH
  * @description 电子科技大学导出、上传文件service
  */
 @Service("dzkdExportPaperService")
 public class DzkdExportPaperService extends ExportPaperAbstractService {
-	
-	public void downloadPaper(String paperId,String zipFileName,String examType)throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		//电子科大独有
-		setSplitPaperDetailExp(paperExp,paperExp.getPaperDetails());
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			DocxProcessUtil.exportWordNew(paperExp, file,DZKD_TEMPLATE_PAPER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-		}
-	}
 
-	public void downloadPaperAnswer(String paperId,String zipFileName) throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		//电子科大独有
-		setSplitPaperDetailExp(paperExp,paperExp.getPaperDetails());
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			DocxProcessUtil.exportWordNew(paperExp,file,DZKD_TEMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-		}
-	}
-	
-	/**
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        //电子科大独有
+        setSplitPaperDetailExp(paperExp, paperExp.getPaperDetails());
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, DZKD_TEMPLATE_PAPER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+        }
+    }
+
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        //电子科大独有
+        setSplitPaperDetailExp(paperExp, paperExp.getPaperDetails());
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, DZKD_TEMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
+        }
+    }
+
+    /**
      * 小题排序
+     *
+     * @param paperDetailExps
      * @describle 大题排序完成之后,放在一个集合里面。然后对相同类型的大题分组,生成不同的结合,在对小题进行
+     */
+    @Override
+    public void sortPaperDetailUnitExps(List<PaperDetailExp> paperDetailExps) {
+        Map<Long, List<PaperDetailUnitExp>> map = new HashMap<Long, List<PaperDetailUnitExp>>();
+        //循环所有大题,将同类型的小题放到同一个集合下面
+        int index = 0;
+        for (PaperDetailExp paperDetailExp : paperDetailExps) {
+            List<PaperDetailUnitExp> paperDetailUnitExps = null;
+            //单选,多选,判断放在同一集合下排序
+            if (paperDetailExp.getSortNumber() < 5L) {
+                //通过map的key去取value,如果没有,就添加
+                if (map.get(paperDetailExp.getSortNumber()) == null) {
+                    paperDetailUnitExps = new ArrayList<PaperDetailUnitExp>();
+                } else {
+                    paperDetailUnitExps = map.get(paperDetailExp.getSortNumber());
+                }
+                paperDetailUnitExps.addAll(paperDetailExp.getPaperDetailUnits());
+                map.put(paperDetailExp.getSortNumber(), paperDetailUnitExps);
+            } else {
+                paperDetailUnitExps = new ArrayList<PaperDetailUnitExp>();
+                paperDetailUnitExps.addAll(paperDetailExp.getPaperDetailUnits());
+                map.put(paperDetailExp.getSortNumber() + index, paperDetailUnitExps);
+                index++;
+            }
+        }
+        //循环所有小题,给小题排序
+        for (Long sortNumber : map.keySet()) {
+            List<PaperDetailUnitExp> paperDetailUnitExps = map.get(sortNumber);
+            int number = 1;
+            if (paperDetailUnitExps != null && paperDetailUnitExps.size() > 0) {
+                for (int i = 0; i < paperDetailUnitExps.size(); i++) {
+                    PaperDetailUnitExp paperDetailUnitExp = paperDetailUnitExps.get(i);
+                    if (paperDetailUnitExp.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
+                        List<Question> subQuestions = paperDetailUnitExp.getQuestion().getSubQuestions();
+                        for (int j = 0; j < subQuestions.size(); j++) {
+                            subQuestions.get(j).setNumber(number + j);
+                        }
+                        number += subQuestions.size();
+                    } else {
+                        paperDetailUnitExp.setNumber(number);
+                        number++;
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 设置大题标题,并将大题分类  主观题    客观题
+     *
      * @param paperDetailExps
      */
-	@Override
-	public void sortPaperDetailUnitExps(List<PaperDetailExp> paperDetailExps) {
-    	Map<Long,List<PaperDetailUnitExp>> map = new HashMap<Long, List<PaperDetailUnitExp>>();
-    	//循环所有大题,将同类型的小题放到同一个集合下面
-    	int index = 0;
-    	for(PaperDetailExp paperDetailExp:paperDetailExps){
-    		List<PaperDetailUnitExp> paperDetailUnitExps = null;
-    		//单选,多选,判断放在同一集合下排序
-    		if(paperDetailExp.getSortNumber()<5L){
-    			//通过map的key去取value,如果没有,就添加
-        		if(map.get(paperDetailExp.getSortNumber()) == null){
-        			paperDetailUnitExps = new ArrayList<PaperDetailUnitExp>();
-        		}else {
-    				paperDetailUnitExps = map.get(paperDetailExp.getSortNumber());
-    			}
-        		paperDetailUnitExps.addAll(paperDetailExp.getPaperDetailUnits());
-        		map.put(paperDetailExp.getSortNumber(), paperDetailUnitExps);
-    		}else {
-    			paperDetailUnitExps = new ArrayList<PaperDetailUnitExp>();
-    			paperDetailUnitExps.addAll(paperDetailExp.getPaperDetailUnits());
-    			map.put(paperDetailExp.getSortNumber() + index, paperDetailUnitExps);
-    			index++;
-			}
-    	}
-    	//循环所有小题,给小题排序
-    	for(Long sortNumber:map.keySet()){
-    		List<PaperDetailUnitExp> paperDetailUnitExps = map.get(sortNumber);
-    		int number = 1;
-    		if(paperDetailUnitExps != null && paperDetailUnitExps.size()>0){
-    			for(int i = 0;i<paperDetailUnitExps.size();i++){
-    				PaperDetailUnitExp paperDetailUnitExp = paperDetailUnitExps.get(i);
-    				if(paperDetailUnitExp.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION){
-    					List<Question> subQuestions = paperDetailUnitExp.getQuestion().getSubQuestions();
-    					for(int j = 0;j<subQuestions.size();j++){
-    						subQuestions.get(j).setNumber(number+j);
-    					}
-    					number += subQuestions.size();
-    				}else {
-    					paperDetailUnitExp.setNumber(number);
-    					number++;
-					}
-        		}
-    		}
-    	}
-	}
-	
-	/**
-	 * 设置大题标题,并将大题分类  主观题    客观题
-	 * @param paperDetailExps
-	 */
-	@Override
-	public void setExpDtoTitle(List<PaperDetailExp> paperDetailExps) {
-		int firstBlank = 0;
-		int lastBlank = 0;
-		for(PaperDetailExp paperDetailExp:paperDetailExps){
-			String title = "";
-			String titleDetail = null;
-			String totalScore = BigDecimal.valueOf(paperDetailExp.getScore()).stripTrailingZeros().toPlainString();
-			QuesStructType type = paperDetailExp.getPaperDetailUnits().get(0).getQuestionType();
-			String questionScore = checkPaperDetailUnitScore(paperDetailExp);
-			if(questionScore!=null){
-   				questionScore = deletePoint(questionScore);
-   			}
-			String scoreString = questionScore==null?"":"每小题"+questionScore+"分,";
-			if (type == QuesStructType.SINGLE_ANSWER_QUESTION) {
-				title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
-						+ scoreString + "共" + totalScore + "分)";
-				titleDetail = "在每小题列出的备选项中只有一个符号合题目要求的,请将其选出并将“答题卡”的相应代码涂黑,错涂、多涂或未涂均无分";
-			} else if (type == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
-				title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
-						+ scoreString + "共" + totalScore+ "分)";
-				titleDetail = "在每小题列出的备选项中有一个或多个符号合题目要求的,请将符合项选出并将“答题卡”的相应代码涂黑";
-			} else if (type == QuesStructType.BOOL_ANSWER_QUESTION) {
-				title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
-						+ scoreString + "共" + totalScore+ "分。"
-						+ "正确的填涂A、错误填涂B。错涂、多涂或未涂均无分)";
-			} else if (type == QuesStructType.FILL_BLANK_QUESTION) {
-				//计算填空空格数量
-				int blanksNumbers = blanksNumbers(paperDetailExp);
-				//设置填空题题干中 开始空格  和  结束空格
-				lastBlank = firstBlank +  blanksNumbers;
-				questionScore = checkPaperDetailUnitblanksScore(paperDetailExp);
-				scoreString = questionScore==null?"":"每空"+questionScore+"分,";
-				title = "(本大题共" + blanksNumbers + "个空格,将每空答在答题卡 “" + String.valueOf(firstBlank + 1)
-						+ "—" + String.valueOf(lastBlank) + "”相应的序号上。"+ scoreString + "共" + totalScore+ "分。)";
-				firstBlank = lastBlank;
-			} else {
-				title = "(本大题共"+paperDetailExp.getUnitCount()+"小题,"+scoreString+"共"+totalScore+"分)";
-			}
-			paperDetailExp.setTitle(title);
-			paperDetailExp.setTitleDetail(titleDetail);
-		}
-	}
-	
-	//去掉分数后面的小数点
-  	protected String deletePoint(String str) {
-  		if(str.indexOf(".0")>-1){
-  			return str.replace(".0", "");
-  		}
-  		return str;
-  	}
-	
-	/**
-	 * 计算每个大题所有填空题空格数量
-	 * @param paperDetailExp
-	 * @return
-	 */
-	private int blanksNumbers(PaperDetailExp paperDetailExp) {
-		List<PaperDetailUnitExp> paperDetailUnitExps = paperDetailExp.getPaperDetailUnits();
-		int blanksNumbers = 0;
-		for(PaperDetailUnitExp paperDetailUnitExp:paperDetailUnitExps){
-			String str = paperDetailUnitExp.getQuestion().getQuesAnswer();
-			if(str.indexOf("##")>-1){
-				//将所有( 替换为空
-				String str1 = str.replaceAll("##", "");
-				blanksNumbers += ((str.length() - str1.length())/2+1);
-			}else {
-				blanksNumbers += 1;
-			}
-		}
-		return blanksNumbers;
-	}
-	
-	/**
-	 * 计算每个小题所有填空题空格数量
-	 * @param paperDetailExp
-	 * @return
-	 */
-	private int blanksNumbers(PaperDetailUnitExp unitExp) {
-		int blanksNumbers = 0;
-		String str = unitExp.getQuestion().getQuesAnswer();
-		if(str.indexOf("##")>-1){
-			//将所有( 替换为空
-			String str1 = str.replaceAll("##", "");
-			blanksNumbers += ((str.length() - str1.length())/2+1);
-		}else {
-			blanksNumbers += 1;
-		}
-		return blanksNumbers;
-	}
-	
-	/**
-	 * 校验大题下的每个填空题空格分数是否一样
-	 * @param paperDetailExp
-	 * @return  如果分数一样,返回分数
-	 * 			如果分数不一样,返回 null
-	 */
-	protected String checkPaperDetailUnitblanksScore(PaperDetailExp paperDetailExp) {
-		List<PaperDetailUnitExp> paperDetailUnitExps = paperDetailExp.getPaperDetailUnits();
-		Set<Double> scoreSet = new HashSet<Double>();
-		for (PaperDetailUnitExp unitExp : paperDetailUnitExps) {
-			int blanksNumbers = blanksNumbers(unitExp);
-			double everyBlank = unitExp.getScore() / blanksNumbers;
-			scoreSet.add(everyBlank);
-		}
-		if(scoreSet.size() == 1){
-			return scoreSet.iterator().next()+"";
-		}
-		return null;
-	}
-	
-	 /**
+    @Override
+    public void setExpDtoTitle(List<PaperDetailExp> paperDetailExps) {
+        int firstBlank = 0;
+        int lastBlank = 0;
+        for (PaperDetailExp paperDetailExp : paperDetailExps) {
+            String title = "";
+            String titleDetail = null;
+            String totalScore = BigDecimal.valueOf(paperDetailExp.getScore()).stripTrailingZeros().toPlainString();
+            QuesStructType type = paperDetailExp.getPaperDetailUnits().get(0).getQuestionType();
+            String questionScore = checkPaperDetailUnitScore(paperDetailExp);
+            if (questionScore != null) {
+                questionScore = deletePoint(questionScore);
+            }
+            String scoreString = questionScore == null ? "" : "每小题" + questionScore + "分,";
+            if (type == QuesStructType.SINGLE_ANSWER_QUESTION) {
+                title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
+                        + scoreString + "共" + totalScore + "分)";
+                titleDetail = "在每小题列出的备选项中只有一个符号合题目要求的,请将其选出并将“答题卡”的相应代码涂黑,错涂、多涂或未涂均无分";
+            } else if (type == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
+                title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
+                        + scoreString + "共" + totalScore + "分)";
+                titleDetail = "在每小题列出的备选项中有一个或多个符号合题目要求的,请将符合项选出并将“答题卡”的相应代码涂黑";
+            } else if (type == QuesStructType.BOOL_ANSWER_QUESTION) {
+                title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
+                        + scoreString + "共" + totalScore + "分。"
+                        + "正确的填涂A、错误填涂B。错涂、多涂或未涂均无分)";
+            } else if (type == QuesStructType.FILL_BLANK_QUESTION) {
+                //计算填空空格数量
+                int blanksNumbers = blanksNumbers(paperDetailExp);
+                //设置填空题题干中 开始空格  和  结束空格
+                lastBlank = firstBlank + blanksNumbers;
+                questionScore = checkPaperDetailUnitblanksScore(paperDetailExp);
+                scoreString = questionScore == null ? "" : "每空" + questionScore + "分,";
+                title = "(本大题共" + blanksNumbers + "个空格,将每空答在答题卡 “" + String.valueOf(firstBlank + 1)
+                        + "—" + String.valueOf(lastBlank) + "”相应的序号上。" + scoreString + "共" + totalScore + "分。)";
+                firstBlank = lastBlank;
+            } else {
+                title = "(本大题共" + paperDetailExp.getUnitCount() + "小题," + scoreString + "共" + totalScore + "分)";
+            }
+            paperDetailExp.setTitle(title);
+            paperDetailExp.setTitleDetail(titleDetail);
+        }
+    }
+
+    //去掉分数后面的小数点
+    protected String deletePoint(String str) {
+        if (str.indexOf(".0") > -1) {
+            return str.replace(".0", "");
+        }
+        return str;
+    }
+
+    /**
+     * 计算每个大题所有填空题空格数量
+     *
+     * @param paperDetailExp
+     * @return
+     */
+    private int blanksNumbers(PaperDetailExp paperDetailExp) {
+        List<PaperDetailUnitExp> paperDetailUnitExps = paperDetailExp.getPaperDetailUnits();
+        int blanksNumbers = 0;
+        for (PaperDetailUnitExp paperDetailUnitExp : paperDetailUnitExps) {
+            String str = paperDetailUnitExp.getQuestion().getQuesAnswer();
+            if (str.indexOf("##") > -1) {
+                //将所有( 替换为空
+                String str1 = str.replaceAll("##", "");
+                blanksNumbers += ((str.length() - str1.length()) / 2 + 1);
+            } else {
+                blanksNumbers += 1;
+            }
+        }
+        return blanksNumbers;
+    }
+
+    /**
+     * 计算每个小题所有填空题空格数量
+     *
+     * @param paperDetailExp
+     * @return
+     */
+    private int blanksNumbers(PaperDetailUnitExp unitExp) {
+        int blanksNumbers = 0;
+        String str = unitExp.getQuestion().getQuesAnswer();
+        if (str.indexOf("##") > -1) {
+            //将所有( 替换为空
+            String str1 = str.replaceAll("##", "");
+            blanksNumbers += ((str.length() - str1.length()) / 2 + 1);
+        } else {
+            blanksNumbers += 1;
+        }
+        return blanksNumbers;
+    }
+
+    /**
+     * 校验大题下的每个填空题空格分数是否一样
+     *
+     * @param paperDetailExp
+     * @return 如果分数一样,返回分数
+     * 如果分数不一样,返回 null
+     */
+    protected String checkPaperDetailUnitblanksScore(PaperDetailExp paperDetailExp) {
+        List<PaperDetailUnitExp> paperDetailUnitExps = paperDetailExp.getPaperDetailUnits();
+        Set<Double> scoreSet = new HashSet<Double>();
+        for (PaperDetailUnitExp unitExp : paperDetailUnitExps) {
+            int blanksNumbers = blanksNumbers(unitExp);
+            double everyBlank = unitExp.getScore() / blanksNumbers;
+            scoreSet.add(everyBlank);
+        }
+        if (scoreSet.size() == 1) {
+            return scoreSet.iterator().next() + "";
+        }
+        return null;
+    }
+
+    /**
      * 添加主观题与客观题
+     *
      * @param paperDetailExps
      */
-    public void setSplitPaperDetailExp(PaperExp PaperExp,List<PaperDetailExp> paperDetailExps) {
-		// 客观题
-		List<PaperDetailExp> objectiveDetails = new ArrayList<PaperDetailExp>();
-		// 主观题
-		List<PaperDetailExp> subjectiveDetails = new ArrayList<PaperDetailExp>();
-		for(PaperDetailExp paperDetailExp:paperDetailExps){
-			Long type = paperDetailExp.getSortNumber();
-			if(type < 5L){
-				objectiveDetails.add(paperDetailExp);
-			}else {
-				subjectiveDetails.add(paperDetailExp);
-			}
-		}
-		PaperExp.setObjectiveDetails(objectiveDetails);
-		PaperExp.setSubjectiveDetails(subjectiveDetails);
-		//主观题   客观题的标题显示
-		showTitle(PaperExp);
-	}
-	
-	/**
-	 * 主观题   客观题的标题显示
-	 * @param PaperExp
-	 */
+    public void setSplitPaperDetailExp(PaperExp PaperExp, List<PaperDetailExp> paperDetailExps) {
+        // 客观题
+        List<PaperDetailExp> objectiveDetails = new ArrayList<PaperDetailExp>();
+        // 主观题
+        List<PaperDetailExp> subjectiveDetails = new ArrayList<PaperDetailExp>();
+        for (PaperDetailExp paperDetailExp : paperDetailExps) {
+            Long type = paperDetailExp.getSortNumber();
+            if (type < 5L) {
+                objectiveDetails.add(paperDetailExp);
+            } else {
+                subjectiveDetails.add(paperDetailExp);
+            }
+        }
+        PaperExp.setObjectiveDetails(objectiveDetails);
+        PaperExp.setSubjectiveDetails(subjectiveDetails);
+        //主观题   客观题的标题显示
+        showTitle(PaperExp);
+    }
+
+    /**
+     * 主观题   客观题的标题显示
+     *
+     * @param PaperExp
+     */
 
-	private void showTitle(PaperExp paperExp) {
-		String title = "";
-		List<PaperDetailExp> objectiveDetails = paperExp.getObjectiveDetails();
-		List<PaperDetailExp> subjectiveDetails = paperExp.getSubjectiveDetails();
-		//设置客观题的标题
-		if(objectiveDetails != null && objectiveDetails.size()>0){
-			Double score = 0.0; 
-			for(PaperDetailExp objectiveDetail:objectiveDetails){
-				score += objectiveDetail.getScore();
-			}
-			String scores = BigDecimal.valueOf(score).stripTrailingZeros().toPlainString();
-			//判断是否有主观题
-			if(subjectiveDetails == null || subjectiveDetails.size() < 1){
-				title = "客观题(总分" + scores + "分)";
-				paperExp.setObjectiveTitle(title);
-			}else {
-				title = "第一部分"+ "    " +"客观题(总分" + scores + "分)";
-			}
-			paperExp.setObjectiveTitle(title);
-		}
-		if(subjectiveDetails != null && subjectiveDetails.size()>0){
-			Double score = 0.0; 
-			for(PaperDetailExp objectiveDetail:subjectiveDetails){
-				score += objectiveDetail.getScore();
-			}
-			String scores = BigDecimal.valueOf(score).stripTrailingZeros().toPlainString();
-			//判断是否有客观题
-			if(objectiveDetails == null || objectiveDetails.size() < 1){
-				title = "主观题(总分" + scores + "分)";
-				paperExp.setSubjectiveTitle(title);
-			}else {
-				title = "第二部分"+ "    " +"主观题(总分" + scores + "分)";
-			}
-			paperExp.setSubjectiveTitle(title);
-		}
-	}
-	
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-    	PaperExp paperExp = initPaperExp(paperId);
-    	setSplitPaperDetailExp(paperExp,paperExp.getPaperDetails());
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,DZKD_TEMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,DZKD_TEMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,DZKD_TEMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,DZKD_TEMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+    private void showTitle(PaperExp paperExp) {
+        String title = "";
+        List<PaperDetailExp> objectiveDetails = paperExp.getObjectiveDetails();
+        List<PaperDetailExp> subjectiveDetails = paperExp.getSubjectiveDetails();
+        //设置客观题的标题
+        if (objectiveDetails != null && objectiveDetails.size() > 0) {
+            Double score = 0.0;
+            for (PaperDetailExp objectiveDetail : objectiveDetails) {
+                score += objectiveDetail.getScore();
+            }
+            String scores = BigDecimal.valueOf(score).stripTrailingZeros().toPlainString();
+            //判断是否有主观题
+            if (subjectiveDetails == null || subjectiveDetails.size() < 1) {
+                title = "客观题(总分" + scores + "分)";
+                paperExp.setObjectiveTitle(title);
+            } else {
+                title = "第一部分" + "    " + "客观题(总分" + scores + "分)";
+            }
+            paperExp.setObjectiveTitle(title);
+        }
+        if (subjectiveDetails != null && subjectiveDetails.size() > 0) {
+            Double score = 0.0;
+            for (PaperDetailExp objectiveDetail : subjectiveDetails) {
+                score += objectiveDetail.getScore();
+            }
+            String scores = BigDecimal.valueOf(score).stripTrailingZeros().toPlainString();
+            //判断是否有客观题
+            if (objectiveDetails == null || objectiveDetails.size() < 1) {
+                title = "主观题(总分" + scores + "分)";
+                paperExp.setSubjectiveTitle(title);
+            } else {
+                title = "第二部分" + "    " + "主观题(总分" + scores + "分)";
+            }
+            paperExp.setSubjectiveTitle(title);
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        setSplitPaperDetailExp(paperExp, paperExp.getPaperDetails());
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, DZKD_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, DZKD_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, DZKD_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, DZKD_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
+        }
+    }
+
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 
 }

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1285 - 1247
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/ExportPaperAbstractService.java


+ 83 - 83
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/FjsfExportPaperService.java

@@ -20,102 +20,102 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.QuestionTypeNum;
 import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperExp;
 
 /**
- * @author  	weiwenhai
- * @date    	2018年6月2日 上午11:29:49
- * @company 	QMTH
+ * @author weiwenhai
+ * @date 2018年6月2日 上午11:29:49
+ * @company QMTH
  * @description 福建师范大学导出、上传文件service
  */
 @Service("fjsfExportPaperService")
 public class FjsfExportPaperService extends ExportPaperAbstractService {
 
-	protected ExamCloudLog log = ExamCloudLogFactory.getLog(this.getClass());
-	
-	@Override
-    public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
-		log.debug("题库开始下载试卷...");
-		long startTime = System.currentTimeMillis();
-		PaperExp paperExp = super.initPaperExp(paperId);
-		long paperExpTime = System.currentTimeMillis();
-		log.debug("拼装导出对象耗时:"+ (paperExpTime - startTime)+"ms");
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			if(examType.equals("offLine")){
-				WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
-				paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
-				DocxProcessUtil.exportWordNew(paperExp, file,FJSF_TMPLATE_PAPER);
-			}else{
-				long docxTime = System.currentTimeMillis();
-				DocxProcessUtil.exportWordNew(paperExp, file,FJSF_TMPLATE_PAPER);
-				long docxEndTime = System.currentTimeMillis();
-				log.debug("处理word文字耗时:"+ (docxEndTime - docxTime)+"ms");
-			}
-			long docxImgTime = System.currentTimeMillis();
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-			long docxImgEndTime = System.currentTimeMillis();
-			log.debug("处理word文字+图片耗时:"+ (docxImgEndTime - docxImgTime)+"ms");
-			//下载音频
-			super.downloadAudio(paperExp, zipFileName);
-			long aduioTime = System.currentTimeMillis();
-			log.debug("处理音频耗时:"+ (aduioTime - docxImgEndTime)+"ms");
-		}
+    protected ExamCloudLog log = ExamCloudLogFactory.getLog(this.getClass());
+
+    @Override
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
+        log.debug("题库开始下载试卷...");
+        long startTime = System.currentTimeMillis();
+        PaperExp paperExp = super.initPaperExp(paperId);
+        long paperExpTime = System.currentTimeMillis();
+        log.debug("拼装导出对象耗时:" + (paperExpTime - startTime) + "ms");
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            if (examType.equals("offLine")) {
+                WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
+                paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
+                DocxProcessUtil.exportWordNew(paperExp, file, FJSF_TMPLATE_PAPER);
+            } else {
+                long docxTime = System.currentTimeMillis();
+                DocxProcessUtil.exportWordNew(paperExp, file, FJSF_TMPLATE_PAPER);
+                long docxEndTime = System.currentTimeMillis();
+                log.debug("处理word文字耗时:" + (docxEndTime - docxTime) + "ms");
+            }
+            long docxImgTime = System.currentTimeMillis();
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+            long docxImgEndTime = System.currentTimeMillis();
+            log.debug("处理word文字+图片耗时:" + (docxImgEndTime - docxImgTime) + "ms");
+            //下载音频
+            super.downloadAudio(paperExp, zipFileName);
+            long aduioTime = System.currentTimeMillis();
+            log.debug("处理音频耗时:" + (aduioTime - docxImgEndTime) + "ms");
+        }
+    }
+
+    @Override
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        log.debug("题库开始下载答案...");
+        long startTime = System.currentTimeMillis();
+        PaperExp paperExp = initPaperExp(paperId);
+        long paperExpTime = System.currentTimeMillis();
+        log.debug("拼装导出对象耗时:" + (paperExpTime - startTime) + "ms");
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            long docxTime = System.currentTimeMillis();
+            DocxProcessUtil.exportWordNew(paperExp, file, FJSF_TMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
+            long docxEndTime = System.currentTimeMillis();
+            log.debug("处理word文字+图片耗时:" + (docxEndTime - docxTime) + "ms");
+        }
     }
-	
-	@Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-		log.debug("题库开始下载答案...");
-		long startTime = System.currentTimeMillis();
-		PaperExp paperExp = initPaperExp(paperId);
-		long paperExpTime = System.currentTimeMillis();
-		log.debug("拼装导出对象耗时:"+ (paperExpTime - startTime)+"ms");
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			long docxTime = System.currentTimeMillis();
-			DocxProcessUtil.exportWordNew(paperExp,file,FJSF_TMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-			long docxEndTime = System.currentTimeMillis();
-			log.debug("处理word文字+图片耗时:"+ (docxEndTime - docxTime)+"ms");
-		}
-	}
 
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-		PaperExp paperExp = initPaperExp(paperId);
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//删除原有试卷文件
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //删除原有试卷文件
         	/*ExamFile examFile = new ExamFile();
         	examFile.setExamId(extractConfig.getExamId()+"");
         	examFile.setCourseId(extractConfig.getCourseCode());
         	examFile.setOrgId(extractConfig.getOrgId());
         	examFileService.deleteExamFile(examFile);*/
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,FJSF_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,FJSF_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,FJSF_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,FJSF_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, FJSF_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, FJSF_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, FJSF_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, FJSF_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

+ 55 - 55
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/HnsfExportPaperService.java

@@ -19,69 +19,69 @@ import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperExp;
 @Service("hnsfExportPaperService")
 public class HnsfExportPaperService extends ExportPaperAbstractService {
 
-	@Override
-    public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
-		PaperExp paperExp = super.initPaperExp(paperId);
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			if(examType.equals("offLine")){
-				DocxProcessUtil.exportWordNew(paperExp, file,HNSF_TMPLATE_PAPER);
-			}else{
-				DocxProcessUtil.exportWordNew(paperExp, file,HNSF_TMPLATE_PAPER);
-			}
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-		}
+    @Override
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
+        PaperExp paperExp = super.initPaperExp(paperId);
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            if (examType.equals("offLine")) {
+                DocxProcessUtil.exportWordNew(paperExp, file, HNSF_TMPLATE_PAPER);
+            } else {
+                DocxProcessUtil.exportWordNew(paperExp, file, HNSF_TMPLATE_PAPER);
+            }
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+        }
     }
-	
-	@Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			DocxProcessUtil.exportWordNew(paperExp,file,FJSF_TMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-		}
-	}
 
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-		PaperExp paperExp = initPaperExp(paperId);
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//删除原有试卷文件
+    @Override
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, FJSF_TMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
+        }
+    }
+
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //删除原有试卷文件
         	/*ExamFile examFile = new ExamFile();
         	examFile.setExamId(extractConfig.getExamId()+"");
         	examFile.setCourseId(extractConfig.getCourseCode());
         	examFile.setOrgId(extractConfig.getOrgId());
         	examFileService.deleteExamFile(examFile);*/
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,HNSF_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,HNSF_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,HNSF_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,HNSF_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, HNSF_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, HNSF_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, HNSF_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, HNSF_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

+ 86 - 86
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/HzkjExportPaperService.java

@@ -20,104 +20,104 @@ import cn.com.qmth.examcloud.core.questions.base.enums.ExportType;
 import cn.com.qmth.examcloud.core.questions.base.word.DocxProcessUtil;
 
 /**
- * @author  	chenken
- * @date    	2017年7月7日 上午11:29:49
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年7月7日 上午11:29:49
+ * @company QMTH
  * @description 华中科技大学导出、上传文件service
  */
 @Service("hzkjExportPaperService")
 public class HzkjExportPaperService extends ExportPaperAbstractService {
 
-	@Override
-    public void downloadPaper(String paperId,String zipFileName,String examTpye) throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		setExpDtoTitle(paperExp.getPaperDetails());
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			DocxProcessUtil.exportWordNew(paperExp, file,HZKJ_TEMPLATE_PAPER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-		}
+    @Override
+    public void downloadPaper(String paperId, String zipFileName, String examTpye) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        setExpDtoTitle(paperExp.getPaperDetails());
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, HZKJ_TEMPLATE_PAPER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+        }
     }
-	
-	@Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			DocxProcessUtil.exportWordNew(paperExp,file,HZKJ_TEMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-		}
-	}
 
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-		PaperExp paperExp = initPaperExp(paperId);
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,HZKJ_TEMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,HZKJ_TEMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,HZKJ_TEMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,HZKJ_TEMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+    @Override
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, HZKJ_TEMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
         }
     }
 
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, HZKJ_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, HZKJ_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, HZKJ_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, HZKJ_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
+        }
+    }
 
-	@Override
-	public void setExpDtoTitle(List<PaperDetailExp> paperDetailExps) {
-		for(PaperDetailExp paperDetailExp:paperDetailExps){
-			String title = "";
-			String titleDetail = null;
-			String totalScore = BigDecimal.valueOf(paperDetailExp.getScore()).stripTrailingZeros().toPlainString();
-			QuesStructType type = paperDetailExp.getPaperDetailUnits().get(0).getQuestionType();
-			String questionScore = checkPaperDetailUnitScore(paperDetailExp);
-			String scoreString = questionScore==null?"":"每小题"+questionScore+"分,";
-			if (type == QuesStructType.SINGLE_ANSWER_QUESTION) {
-				paperDetailExp.setName("单项选择题");
-				title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
-						+ scoreString + "共" + totalScore + "分)";
-				titleDetail = "在每小题列出的备选项中只有一个符号合题目要求的,请将其选出并将“答题卡”的相应代码涂黑,错涂、多涂或未涂均无分";
-			} else if (type == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
-				paperDetailExp.setName("多项选择题");
-				title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
-						+ scoreString + "共" + totalScore+ "分)";
-				titleDetail = "在每小题列出的备选项中有一个或多个符号合题目要求的,请将符合项选出并将“答题卡”的相应代码涂黑";
-			} else if (type == QuesStructType.BOOL_ANSWER_QUESTION) {
-				paperDetailExp.setName("判断题");
-				title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
-						+ scoreString + "共" + totalScore+ "分。"
-						+ "正确的填涂√、错误填涂×。错涂、多涂或未涂均无分)";
-			} else {
-				paperDetailExp.setName(type.getName());
-				title = "(本大题共"+paperDetailExp.getUnitCount()+"小题,"+scoreString+"共"+totalScore+"分)";
-			}
-			paperDetailExp.setTitle(title);
-			paperDetailExp.setTitleDetail(titleDetail);
-		}
-	}
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public void setExpDtoTitle(List<PaperDetailExp> paperDetailExps) {
+        for (PaperDetailExp paperDetailExp : paperDetailExps) {
+            String title = "";
+            String titleDetail = null;
+            String totalScore = BigDecimal.valueOf(paperDetailExp.getScore()).stripTrailingZeros().toPlainString();
+            QuesStructType type = paperDetailExp.getPaperDetailUnits().get(0).getQuestionType();
+            String questionScore = checkPaperDetailUnitScore(paperDetailExp);
+            String scoreString = questionScore == null ? "" : "每小题" + questionScore + "分,";
+            if (type == QuesStructType.SINGLE_ANSWER_QUESTION) {
+                paperDetailExp.setName("单项选择题");
+                title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
+                        + scoreString + "共" + totalScore + "分)";
+                titleDetail = "在每小题列出的备选项中只有一个符号合题目要求的,请将其选出并将“答题卡”的相应代码涂黑,错涂、多涂或未涂均无分";
+            } else if (type == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
+                paperDetailExp.setName("多项选择题");
+                title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
+                        + scoreString + "共" + totalScore + "分)";
+                titleDetail = "在每小题列出的备选项中有一个或多个符号合题目要求的,请将符合项选出并将“答题卡”的相应代码涂黑";
+            } else if (type == QuesStructType.BOOL_ANSWER_QUESTION) {
+                paperDetailExp.setName("判断题");
+                title = "(本大题共" + paperDetailExp.getUnitCount() + "小题,"
+                        + scoreString + "共" + totalScore + "分。"
+                        + "正确的填涂√、错误填涂×。错涂、多涂或未涂均无分)";
+            } else {
+                paperDetailExp.setName(type.getName());
+                title = "(本大题共" + paperDetailExp.getUnitCount() + "小题," + scoreString + "共" + totalScore + "分)";
+            }
+            paperDetailExp.setTitle(title);
+            paperDetailExp.setTitleDetail(titleDetail);
+        }
+    }
+
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 
 }
 

+ 348 - 338
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/InitPaperExpService.java

@@ -52,467 +52,477 @@ import cn.com.qmth.examcloud.core.questions.base.word.DocxProcessUtil;
 
 
 /**
+ * @author weiwenhai
  * @describle 初始化导出对象service
- * @author weiwenhai 
  * @date 2017.10.17
  * @code 090
  */
 @Service("initPaperExpService")
-public  class InitPaperExpService {
-	
-	@Autowired
-	PaperRepo paperRepo;
-
-	@Autowired
-	PaperService paperService;
-
-	@Autowired
-	PaperDetailRepo paperDetailRepo;
-
-	@Autowired
-	PaperDetailUnitRepo paperDetailUnitRepo;
-	
-	@Autowired
-	ExamFileService examFileService;
-
-	@Autowired
-	private PaperDetailService paperDetailService;
-	
-	@Autowired
-	private QuestionAudioService questionAudioService;
-	
-	@Autowired
-	QuesRepo quesRepo;
-	
-	@Autowired
-	AudioTimeConfigRepo audioTimeConfigRepo;
-	
-	@Autowired
+public class InitPaperExpService {
+
+    @Autowired
+    PaperRepo paperRepo;
+
+    @Autowired
+    PaperService paperService;
+
+    @Autowired
+    PaperDetailRepo paperDetailRepo;
+
+    @Autowired
+    PaperDetailUnitRepo paperDetailUnitRepo;
+
+    @Autowired
+    ExamFileService examFileService;
+
+    @Autowired
+    private PaperDetailService paperDetailService;
+
+    @Autowired
+    private QuestionAudioService questionAudioService;
+
+    @Autowired
+    QuesRepo quesRepo;
+
+    @Autowired
+    AudioTimeConfigRepo audioTimeConfigRepo;
+
+    @Autowired
     CourseService courseService;
 
-	public static final String FILL_BLANK_QUESTION_FLAG = "###";
-	
-	public static final String TEMP_FILE_EXP = "docxExport/";
-	
-	/**
-	 * Word文件后缀
-	 */
-	public static final String DOCX_SUFFIX = ".docx";
-	/**
-	 * Excel文件后缀
-	 */
-	public static final String EXCEL_SUFFIX = ".xlsx";
-	/**
-	 * ZIP文件后缀
-	 */
-	public static final String ZIP_SUFFIX = ".zip";
-	
-	public static final String ENCODING = "UTF-8";
-	
-	@Value("${$upyun.site.2.bucketName}")
-	public String bucketName;
-	
-	@Value("${$upyun.site.2.userName}")
-	public String userName;
-	
-	@Value("${$upyun.site.2.password}")
-	public String password;
-	
-	@Value("${upyun.uploadUrl}")
-	public String uploadUrl;
-	
-	@Value("${upyun.downloadUrl}")
-	public String downloadUrl;
-	
-	/**
-	 * 根据paper得到导出试卷对象PaperExp
+    public static final String FILL_BLANK_QUESTION_FLAG = "###";
+
+    public static final String TEMP_FILE_EXP = "docxExport/";
+
+    /**
+     * Word文件后缀
+     */
+    public static final String DOCX_SUFFIX = ".docx";
+    /**
+     * Excel文件后缀
+     */
+    public static final String EXCEL_SUFFIX = ".xlsx";
+    /**
+     * ZIP文件后缀
+     */
+    public static final String ZIP_SUFFIX = ".zip";
+
+    public static final String ENCODING = "UTF-8";
+
+    @Value("${$upyun.site.2.bucketName}")
+    public String bucketName;
+
+    @Value("${$upyun.site.2.userName}")
+    public String userName;
+
+    @Value("${$upyun.site.2.password}")
+    public String password;
+
+    @Value("${upyun.uploadUrl}")
+    public String uploadUrl;
+
+    @Value("${upyun.downloadUrl}")
+    public String downloadUrl;
+
+    /**
+     * 根据paper得到导出试卷对象PaperExp
+     *
      * @param paperId
      * @return
      * @throws Exception
      */
-    public PaperExp initPaperExp(String paperId){
-    	//根据paperId取到paper对象
-    	Paper paper = Model.of(paperRepo.findById(paperId));
-    	//paperService.formatPaper(paper, null);
-    	if (paper == null) {
-			throw new StatusException("Q-090133","该试卷不存在");
-		}
-    	Course course = courseService.getCourse(Long.valueOf(paper.getOrgId()), paper.getCourse().getCode());
-    	//创建试卷导出的dto
-    	PaperExp paperExpDto = BeanCopierUtil.copyProperties(paper, PaperExp.class);
-    	if(paper.getCourse() == null){
-    		paperExpDto.setCourseLevel(CourseLevel.ALL.getName());
-    	}else {
-    		paperExpDto.setCourseLevel(CourseLevel.getCourseLevel(paper.getCourse().getLevel()).getName());
-    	}
-    	//获取原试卷所有大题
-    	List<PaperDetail> paperDetails = paperDetailRepo.findByPaperOrderByNumber(paper);
-    	//生成新的大题对象集合,加添对应的小题
-    	List<PaperDetailExp> paperDetailExps = separatePaperDetailUntils(paperDetails,paperExpDto);
-    	//给新的大题集合排序,计算小题数量
-    	sortPaperDetailExps(paperDetailExps);
-    	//给新的大题添加分数
-    	scorePaperDetailExps(paperDetailExps);
-    	paperExpDto.setPaperDetails(paperDetailExps);
-    	paperExpDto.getCourse().setId(course.getId());
-    	return paperExpDto;
+    public PaperExp initPaperExp(String paperId) {
+        //根据paperId取到paper对象
+        Paper paper = Model.of(paperRepo.findById(paperId));
+        //paperService.formatPaper(paper, null);
+        if (paper == null) {
+            throw new StatusException("Q-090133", "该试卷不存在");
+        }
+        Course course = courseService.getCourse(Long.valueOf(paper.getOrgId()), paper.getCourse().getCode());
+        //创建试卷导出的dto
+        PaperExp paperExpDto = BeanCopierUtil.copyProperties(paper, PaperExp.class);
+        if (paper.getCourse() == null) {
+            paperExpDto.setCourseLevel(CourseLevel.ALL.getName());
+        } else {
+            paperExpDto.setCourseLevel(CourseLevel.getCourseLevel(paper.getCourse().getLevel()).getName());
+        }
+        //获取原试卷所有大题
+        List<PaperDetail> paperDetails = paperDetailRepo.findByPaperOrderByNumber(paper);
+        //生成新的大题对象集合,加添对应的小题
+        List<PaperDetailExp> paperDetailExps = separatePaperDetailUntils(paperDetails, paperExpDto);
+        //给新的大题集合排序,计算小题数量
+        sortPaperDetailExps(paperDetailExps);
+        //给新的大题添加分数
+        scorePaperDetailExps(paperDetailExps);
+        paperExpDto.setPaperDetails(paperDetailExps);
+        paperExpDto.getCourse().setId(course.getId());
+        return paperExpDto;
     }
 
-	/**
+    /**
      * 将所有小题分类,添加到对应的大题下
+     *
      * @param paperDetails
      * @return
      */
-    private List<PaperDetailExp> separatePaperDetailUntils(List<PaperDetail> paperDetails,PaperExp paperExpDto){
-    	List<PaperDetailExp> paperDetailExps = new ArrayList<PaperDetailExp>();
-    	//循环大题
-    	for(PaperDetail paperDetail:paperDetails){
-    		//获取小题
-    		List<PaperDetailUnit> paperDetailUnits = paperDetailUnitRepo.findByPaperDetailOrderByNumber(paperDetail);
-    		//set集合用来将小题分类
-    		Set<Long> questionTypes = new HashSet<Long>();
-    		//大题的临时集合,用来区分原卷每个大题
-    		List<PaperDetailExp> subPaperDetailExps = new ArrayList<PaperDetailExp>();
-    		//第一次循环小题,分成大题类型
-    		for(PaperDetailUnit paperDetailUnit:paperDetailUnits){
-    			//判断该试卷是否为音频试卷
-    			if(paperDetailUnit.getQuestion().getHasAudio() !=null && paperDetailUnit.getQuestion().getHasAudio()){
-    				paperExpDto.setHasAudio(true);	//设置试卷含有音频
-            	}
-    			//如果是套题
-    			if(paperDetailUnit.getQuestionType().getName().equals("套题")){
-    				isSubQuestion(paperDetailUnit,questionTypes);
-    			}else {
-    				Long questionTypeId = paperDetailUnit.getQuestionType().getId();
-    				questionTypes.add(questionTypeId);
-				}
-    		}
-    		//遍历Set,生成大题集合
-    		for(Long questionType:questionTypes){
-    			//生成大题对象
-    			PaperDetailExp paperDetailExp = new PaperDetailExp();
-    			paperDetailExp.setSortNumber(questionType);
-    			if(StringUtils.isBlank(paperDetail.getName())){
-    				paperDetailExp.setName("默认大题");
-    			}else {
-    				paperDetailExp.setName(paperDetail.getName());
-				}
-    			subPaperDetailExps.add(paperDetailExp);
-    		}
-    		//第二次循环小题,添加到对应的大题下
-    		for(PaperDetailUnit paperDetailUnit:paperDetailUnits){
-    			//判断是否为套题
-    			if(paperDetailUnit.getQuestionType().getName().equals("套题")){
-    				addSubQuestion(paperDetailUnit,subPaperDetailExps);
-    			}else {
-    				PaperDetailUnitExp paperDetailUnitExp = BeanCopierUtil.copyProperties(paperDetailUnit, PaperDetailUnitExp.class);
-        			//循环大题
-        			for(PaperDetailExp paperDetailExp:subPaperDetailExps){
-        				if(paperDetailExp.getSortNumber().longValue() == paperDetailUnitExp.getQuestionType().getId().longValue()){
-        					List<PaperDetailUnitExp> paperDetailUnitExps = paperDetailExp.getPaperDetailUnits();
-        					//如果大题下面没有小题,就生成新对象
-        					if(paperDetailUnitExps == null){
-        						paperDetailUnitExps = new ArrayList<PaperDetailUnitExp>();
-        					}
-        					paperDetailUnitExps.add(paperDetailUnitExp);
-        					//将小题添加到对应大题下面
-        					paperDetailExp.setPaperDetailUnits(paperDetailUnitExps);
-        				}
-        			}
-				}
-    		}
-    		paperDetailExps.addAll(subPaperDetailExps);
-    	}
-    	return paperDetailExps;
+    private List<PaperDetailExp> separatePaperDetailUntils(List<PaperDetail> paperDetails, PaperExp paperExpDto) {
+        List<PaperDetailExp> paperDetailExps = new ArrayList<PaperDetailExp>();
+        //循环大题
+        for (PaperDetail paperDetail : paperDetails) {
+            //获取小题
+            List<PaperDetailUnit> paperDetailUnits = paperDetailUnitRepo.findByPaperDetailOrderByNumber(paperDetail);
+            //set集合用来将小题分类
+            Set<Long> questionTypes = new HashSet<Long>();
+            //大题的临时集合,用来区分原卷每个大题
+            List<PaperDetailExp> subPaperDetailExps = new ArrayList<PaperDetailExp>();
+            //第一次循环小题,分成大题类型
+            for (PaperDetailUnit paperDetailUnit : paperDetailUnits) {
+                //判断该试卷是否为音频试卷
+                if (paperDetailUnit.getQuestion().getHasAudio() != null && paperDetailUnit.getQuestion().getHasAudio()) {
+                    paperExpDto.setHasAudio(true);    //设置试卷含有音频
+                }
+                //如果是套题
+                if (paperDetailUnit.getQuestionType().getName().equals("套题")) {
+                    isSubQuestion(paperDetailUnit, questionTypes);
+                } else {
+                    Long questionTypeId = paperDetailUnit.getQuestionType().getId();
+                    questionTypes.add(questionTypeId);
+                }
+            }
+            //遍历Set,生成大题集合
+            for (Long questionType : questionTypes) {
+                //生成大题对象
+                PaperDetailExp paperDetailExp = new PaperDetailExp();
+                paperDetailExp.setSortNumber(questionType);
+                if (StringUtils.isBlank(paperDetail.getName())) {
+                    paperDetailExp.setName("默认大题");
+                } else {
+                    paperDetailExp.setName(paperDetail.getName());
+                }
+                subPaperDetailExps.add(paperDetailExp);
+            }
+            //第二次循环小题,添加到对应的大题下
+            for (PaperDetailUnit paperDetailUnit : paperDetailUnits) {
+                //判断是否为套题
+                if (paperDetailUnit.getQuestionType().getName().equals("套题")) {
+                    addSubQuestion(paperDetailUnit, subPaperDetailExps);
+                } else {
+                    PaperDetailUnitExp paperDetailUnitExp = BeanCopierUtil.copyProperties(paperDetailUnit, PaperDetailUnitExp.class);
+                    //循环大题
+                    for (PaperDetailExp paperDetailExp : subPaperDetailExps) {
+                        if (paperDetailExp.getSortNumber().longValue() == paperDetailUnitExp.getQuestionType().getId().longValue()) {
+                            List<PaperDetailUnitExp> paperDetailUnitExps = paperDetailExp.getPaperDetailUnits();
+                            //如果大题下面没有小题,就生成新对象
+                            if (paperDetailUnitExps == null) {
+                                paperDetailUnitExps = new ArrayList<PaperDetailUnitExp>();
+                            }
+                            paperDetailUnitExps.add(paperDetailUnitExp);
+                            //将小题添加到对应大题下面
+                            paperDetailExp.setPaperDetailUnits(paperDetailUnitExps);
+                        }
+                    }
+                }
+            }
+            paperDetailExps.addAll(subPaperDetailExps);
+        }
+        return paperDetailExps;
     }
-  
+
     /**
      * 大题序号重排,计算小题数量
+     *
      * @param paperDetailExps
      */
-	private void sortPaperDetailExps(List<PaperDetailExp> paperDetailExps) {
-		Collections.sort(paperDetailExps, new Comparator<PaperDetailExp>() {
-			@Override
-			public int compare(PaperDetailExp o1, PaperDetailExp o2) {
-				if(o1.getSortNumber()>o2.getSortNumber()){
-					return 1;
-				}
-				if(o1.getSortNumber()==o2.getSortNumber()){
-					return 0;
-				}
-				return -1;
-			}
-		});
-		if(paperDetailExps!=null && paperDetailExps.size()>0){
-			//循环所有大题,给大题排序
-			for(int i=0;i<paperDetailExps.size();i++){
-				Integer number = i+1;
-				paperDetailExps.get(i).setNumber(number);
-				paperDetailExps.get(i).setCnNum(CommonUtils.toCHNum(number));
-				int subNum =0;
-				//循环小题,判断是否存在套题
-				for(PaperDetailUnitExp paperDetailUnitExp:paperDetailExps.get(i).getPaperDetailUnits()){
-					//如果有套题
-					if(paperDetailUnitExp.getQuestionType().getName().equals("套题")){
-						subNum = subNum + paperDetailUnitExp.getQuestion().getSubQuestions().size();
-					}else {
-						subNum = subNum + 1;
-					}
-				}
-				paperDetailExps.get(i).setUnitCount(subNum);
-			}
-		}
-	}
-
-	/**
+    private void sortPaperDetailExps(List<PaperDetailExp> paperDetailExps) {
+        Collections.sort(paperDetailExps, new Comparator<PaperDetailExp>() {
+            @Override
+            public int compare(PaperDetailExp o1, PaperDetailExp o2) {
+                if (o1.getSortNumber() > o2.getSortNumber()) {
+                    return 1;
+                }
+                if (o1.getSortNumber() == o2.getSortNumber()) {
+                    return 0;
+                }
+                return -1;
+            }
+        });
+        if (paperDetailExps != null && paperDetailExps.size() > 0) {
+            //循环所有大题,给大题排序
+            for (int i = 0; i < paperDetailExps.size(); i++) {
+                Integer number = i + 1;
+                paperDetailExps.get(i).setNumber(number);
+                paperDetailExps.get(i).setCnNum(CommonUtils.toCHNum(number));
+                int subNum = 0;
+                //循环小题,判断是否存在套题
+                for (PaperDetailUnitExp paperDetailUnitExp : paperDetailExps.get(i).getPaperDetailUnits()) {
+                    //如果有套题
+                    if (paperDetailUnitExp.getQuestionType().getName().equals("套题")) {
+                        subNum = subNum + paperDetailUnitExp.getQuestion().getSubQuestions().size();
+                    } else {
+                        subNum = subNum + 1;
+                    }
+                }
+                paperDetailExps.get(i).setUnitCount(subNum);
+            }
+        }
+    }
+
+    /**
      * 每个大题添加分数
      */
     private void scorePaperDetailExps(List<PaperDetailExp> paperDetailExps) {
-		for(PaperDetailExp paperDetailExp:paperDetailExps){
-			List<PaperDetailUnitExp> paperDetailUnitExps = paperDetailExp.getPaperDetailUnits();
-			Double totalScore = 0.0;
-			//所有小题分数相加,得到大题分数
-			for(PaperDetailUnitExp paperDetailUnitExp:paperDetailUnitExps){
-				totalScore += paperDetailUnitExp.getScore();
-			}
-			paperDetailExp.setScore(totalScore);
-		}
-	}
-    
- 	/**
-	 * 校验大题下的小题分数是不是一样
-	 * @param paperDetailExp
-	 * @return  如果分数一样,返回分数
-	 * 			如果分数不一样,返回 null
-	 */
-	public String checkPaperDetailUnitScore(PaperDetailExp paperDetailExp) {
-		List<PaperDetailUnitExp> paperDetailUnitExps = paperDetailExp.getPaperDetailUnits();
-		Set<Double> scoreSet = new HashSet<Double>();
-		for (PaperDetailUnitExp unitExp : paperDetailUnitExps) {
-			//判断套路
-			if(unitExp.getQuestionType()==QuesStructType.NESTED_ANSWER_QUESTION){
-				List<Question> subQuestions = unitExp.getQuestion().getSubQuestions();
-				for(Question subQuestion:subQuestions){
-					scoreSet.add(subQuestion.getScore());
-				}
+        for (PaperDetailExp paperDetailExp : paperDetailExps) {
+            List<PaperDetailUnitExp> paperDetailUnitExps = paperDetailExp.getPaperDetailUnits();
+            Double totalScore = 0.0;
+            //所有小题分数相加,得到大题分数
+            for (PaperDetailUnitExp paperDetailUnitExp : paperDetailUnitExps) {
+                totalScore += paperDetailUnitExp.getScore();
+            }
+            paperDetailExp.setScore(totalScore);
+        }
+    }
+
+    /**
+     * 校验大题下的小题分数是不是一样
+     *
+     * @param paperDetailExp
+     * @return 如果分数一样,返回分数
+     * 如果分数不一样,返回 null
+     */
+    public String checkPaperDetailUnitScore(PaperDetailExp paperDetailExp) {
+        List<PaperDetailUnitExp> paperDetailUnitExps = paperDetailExp.getPaperDetailUnits();
+        Set<Double> scoreSet = new HashSet<Double>();
+        for (PaperDetailUnitExp unitExp : paperDetailUnitExps) {
+            //判断套路
+            if (unitExp.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
+                List<Question> subQuestions = unitExp.getQuestion().getSubQuestions();
+                for (Question subQuestion : subQuestions) {
+                    scoreSet.add(subQuestion.getScore());
+                }
 				/*List<Double> subScoreList =  unitExp.getSubScoreList();
 				for(Double score:subScoreList){
 					scoreSet.add(score);
 				}*/
-			}else{
-				scoreSet.add(unitExp.getScore());
-			}
-		}
-		if(scoreSet.size() == 1){
-			return scoreSet.iterator().next()+"";
-		}
-		return null;
-	}
+            } else {
+                scoreSet.add(unitExp.getScore());
+            }
+        }
+        if (scoreSet.size() == 1) {
+            return scoreSet.iterator().next() + "";
+        }
+        return null;
+    }
 
     /**
      * 套题添加到对应的大题
+     *
      * @param paperDetailUnit
      * @param subPaperDetailExps
      */
     private void addSubQuestion(PaperDetailUnit paperDetailUnit, List<PaperDetailExp> subPaperDetailExps) {
-    	PaperDetailUnitExp paperDetailUnitExp = BeanCopierUtil.copyProperties(paperDetailUnit, PaperDetailUnitExp.class);
-    	//得到套题下面所有小题
-    	List<Question> questions = paperDetailUnit.getQuestion().getSubQuestions();
-    	Set<Long> subQuestionType = new HashSet<Long>();
-    	for(Question subQuestion:questions){
-			subQuestionType.add(subQuestion.getQuestionType().getId());
-		}
-    	//如果全是同样的类型
-    	if(subQuestionType.size()>0 && subQuestionType.size()<2){
-			//获取所有题目,添加到对应大题下面
-    		for (Long l:subQuestionType) {
-				//循环已有的大题,进行添加套题
-    			for(PaperDetailExp paperDetailExp:subPaperDetailExps){
-    				if(paperDetailExp.getSortNumber().longValue() == l){
-    					List<PaperDetailUnitExp> paperDetailUnitExps = paperDetailExp.getPaperDetailUnits();
-    					//如果大题下面没有小题,就生成新对象
-    					if(paperDetailUnitExps == null){
-    						paperDetailUnitExps = new ArrayList<PaperDetailUnitExp>();
-    					}
-    					paperDetailUnitExps.add(paperDetailUnitExp);
-    					//将小题添加到对应大题下面
-    					paperDetailExp.setPaperDetailUnits(paperDetailUnitExps);
-    				}
-    			}
-			}
-		}else {
-			//循环大题
-			for(PaperDetailExp paperDetailExp:subPaperDetailExps){
-				if(paperDetailExp.getSortNumber().longValue() == paperDetailUnitExp.getQuestionType().getId().longValue()){
-					List<PaperDetailUnitExp> paperDetailUnitExps = paperDetailExp.getPaperDetailUnits();
-					//如果大题下面没有小题,就生成新对象
-					if(paperDetailUnitExps == null){
-						paperDetailUnitExps = new ArrayList<PaperDetailUnitExp>();
-					}
-					paperDetailUnitExps.add(paperDetailUnitExp);
-					//将小题添加到对应大题下面
-					paperDetailExp.setPaperDetailUnits(paperDetailUnitExps);
-				}
-			}
-		}
-	}
-
-	/**
+        PaperDetailUnitExp paperDetailUnitExp = BeanCopierUtil.copyProperties(paperDetailUnit, PaperDetailUnitExp.class);
+        //得到套题下面所有小题
+        List<Question> questions = paperDetailUnit.getQuestion().getSubQuestions();
+        Set<Long> subQuestionType = new HashSet<Long>();
+        for (Question subQuestion : questions) {
+            subQuestionType.add(subQuestion.getQuestionType().getId());
+        }
+        //如果全是同样的类型
+        if (subQuestionType.size() > 0 && subQuestionType.size() < 2) {
+            //获取所有题目,添加到对应大题下面
+            for (Long l : subQuestionType) {
+                //循环已有的大题,进行添加套题
+                for (PaperDetailExp paperDetailExp : subPaperDetailExps) {
+                    if (paperDetailExp.getSortNumber().longValue() == l) {
+                        List<PaperDetailUnitExp> paperDetailUnitExps = paperDetailExp.getPaperDetailUnits();
+                        //如果大题下面没有小题,就生成新对象
+                        if (paperDetailUnitExps == null) {
+                            paperDetailUnitExps = new ArrayList<PaperDetailUnitExp>();
+                        }
+                        paperDetailUnitExps.add(paperDetailUnitExp);
+                        //将小题添加到对应大题下面
+                        paperDetailExp.setPaperDetailUnits(paperDetailUnitExps);
+                    }
+                }
+            }
+        } else {
+            //循环大题
+            for (PaperDetailExp paperDetailExp : subPaperDetailExps) {
+                if (paperDetailExp.getSortNumber().longValue() == paperDetailUnitExp.getQuestionType().getId().longValue()) {
+                    List<PaperDetailUnitExp> paperDetailUnitExps = paperDetailExp.getPaperDetailUnits();
+                    //如果大题下面没有小题,就生成新对象
+                    if (paperDetailUnitExps == null) {
+                        paperDetailUnitExps = new ArrayList<PaperDetailUnitExp>();
+                    }
+                    paperDetailUnitExps.add(paperDetailUnitExp);
+                    //将小题添加到对应大题下面
+                    paperDetailExp.setPaperDetailUnits(paperDetailUnitExps);
+                }
+            }
+        }
+    }
+
+    /**
      * 处理套题类型
+     *
      * @param paperDetailUnit
      */
-    private void isSubQuestion(PaperDetailUnit paperDetailUnit,Set<Long> questionType){
-    	//得到套题下面所有小题
-		List<Question> questions = paperDetailUnit.getQuestion().getSubQuestions();
-		Set<Long> subQuestionType = new HashSet<Long>();
-		for(Question subQuestion:questions){
-			subQuestionType.add(subQuestion.getQuestionType().getId());
-		}
-		//如果全是同样的类型
-		if(subQuestionType.size()>0 && subQuestionType.size()<2){
-			for(Long l:subQuestionType){
-				questionType.add(l);
-			}
-		}else {
-			Long questionTypeId = paperDetailUnit.getQuestionType().getId();
-			questionType.add(questionTypeId);
-		}
+    private void isSubQuestion(PaperDetailUnit paperDetailUnit, Set<Long> questionType) {
+        //得到套题下面所有小题
+        List<Question> questions = paperDetailUnit.getQuestion().getSubQuestions();
+        Set<Long> subQuestionType = new HashSet<Long>();
+        for (Question subQuestion : questions) {
+            subQuestionType.add(subQuestion.getQuestionType().getId());
+        }
+        //如果全是同样的类型
+        if (subQuestionType.size() > 0 && subQuestionType.size() < 2) {
+            for (Long l : subQuestionType) {
+                questionType.add(l);
+            }
+        } else {
+            Long questionTypeId = paperDetailUnit.getQuestionType().getId();
+            questionType.add(questionTypeId);
+        }
     }
-	
-	/**
+
+    /**
      * 设置选项号
+     *
      * @param optionWordMl
      * @param num
      * @return
      * @throws Exception
      */
-    public String setOptionNum(String optionWordMl,String num) throws Exception {
+    public String setOptionNum(String optionWordMl, String num) throws Exception {
         String tmpStr = DocxProcessUtil.BODY_HEADER + optionWordMl + DocxProcessUtil.BODY_TAIL;
-        Body body = (Body)XmlUtils.unmarshalString(tmpStr,Context.jc,Body.class);
+        Body body = (Body) XmlUtils.unmarshalString(tmpStr, Context.jc, Body.class);
         List<Object> pList = body.getContent();
         int index = 0;
-        for(Object pObj:pList){
-            if(index > 0){
+        for (Object pObj : pList) {
+            if (index > 0) {
                 break;
             }
             P p = (P) pObj;
             List<Object> pContent = p.getContent();
             R run = new R();
             Text text = new Text();
-            text.setValue(num+". ");
+            text.setValue(num + ". ");
             run.getContent().add(text);
-            pContent.add(0,run);
+            pContent.add(0, run);
             index++;
         }
         StringBuffer pWordMl = new StringBuffer();
-        for(Object pObj:pList){
-            if(pObj instanceof P){
+        for (Object pObj : pList) {
+            if (pObj instanceof P) {
                 pWordMl.append(DocxProcessUtil.formatPWordMl(XmlUtils.marshaltoString(pObj)));
             }
         }
         return pWordMl.toString();
     }
-	
+
     /**
-	 * 将数字1,2,3,4转化成A,B,C,D
-	 * @param number
-	 * @return
-	 */
-    public String getOptionNum(int number){
-        char optionNum = (char)(65 + number);
+     * 将数字1,2,3,4转化成A,B,C,D
+     *
+     * @param number
+     * @return
+     */
+    public String getOptionNum(int number) {
+        char optionNum = (char) (65 + number);
         return String.valueOf(optionNum);
     }
 
     /**
      * 设置题号
+     *
      * @param quesBodyWordMl
      * @param num
      * @return
      * @throws Exception
      */
-    public String setSubQuesNum(String quesBodyWordMl,int num) throws Exception {
+    public String setSubQuesNum(String quesBodyWordMl, int num) throws Exception {
         String tmpStr = DocxProcessUtil.BODY_HEADER + quesBodyWordMl + DocxProcessUtil.BODY_TAIL;
-        Body body = (Body)XmlUtils.unmarshalString(tmpStr,Context.jc,Body.class);
+        Body body = (Body) XmlUtils.unmarshalString(tmpStr, Context.jc, Body.class);
         List<Object> pList = body.getContent();
         int index = 0;
-        for(Object pObj:pList){
-            if(index > 0){
+        for (Object pObj : pList) {
+            if (index > 0) {
                 break;
             }
             P p = (P) pObj;
             List<Object> pContent = p.getContent();
             R run = new R();
             Text text = new Text();
-            text.setValue(num+". ");
+            text.setValue(num + ". ");
             run.getContent().add(text);
-            pContent.add(0,run);
+            pContent.add(0, run);
             index++;
         }
         StringBuffer pWordMl = new StringBuffer();
-        for(Object pObj:pList){
-            if(pObj instanceof P){
+        for (Object pObj : pList) {
+            if (pObj instanceof P) {
                 pWordMl.append(DocxProcessUtil.formatPWordMl(XmlUtils.marshaltoString(pObj)));
             }
         }
         return pWordMl.toString();
     }
-	
+
     /**
      * 替换填空
      * 将###替换为下划线_______
+     *
      * @param wordMl
      * @param num
      * @return
      * @throws Exception
      */
-	public String replaceQuesBlank(String wordMl,int num) throws Exception {
+    public String replaceQuesBlank(String wordMl, int num) throws Exception {
         String tmpStr = DocxProcessUtil.BODY_HEADER + wordMl + DocxProcessUtil.BODY_TAIL;
-        Body body = (Body)XmlUtils.unmarshalString(tmpStr,Context.jc,Body.class);
+        Body body = (Body) XmlUtils.unmarshalString(tmpStr, Context.jc, Body.class);
         List<Object> pList = body.getContent();
         int index = 0;
         int cur = 0;
-        Map<Integer,String> curMap = new HashMap<Integer,String>();
-        for(Object pObj:pList){
-            if(pObj.getClass().equals(P.class)){
-                List<Object> pContent = ((P)pObj).getContent();
-                for(Object rObj:pContent){
-                    if(rObj.getClass().equals(R.class)){
-                        List<Object> rContent = ((R)rObj).getContent();
-                        for(Object tObj:rContent){
+        Map<Integer, String> curMap = new HashMap<Integer, String>();
+        for (Object pObj : pList) {
+            if (pObj.getClass().equals(P.class)) {
+                List<Object> pContent = ((P) pObj).getContent();
+                for (Object rObj : pContent) {
+                    if (rObj.getClass().equals(R.class)) {
+                        List<Object> rContent = ((R) rObj).getContent();
+                        for (Object tObj : rContent) {
                             if (tObj instanceof JAXBElement)
                                 tObj = ((JAXBElement<?>) tObj).getValue();
-                            if(tObj.getClass().equals(Text.class)){
-                                Text text = (Text)tObj;
+                            if (tObj.getClass().equals(Text.class)) {
+                                Text text = (Text) tObj;
                                 String str = text.getValue();
                                 //1
-                                if("##".equals(str.trim())){
-                                	str = "___";
+                                if ("##".equals(str.trim())) {
+                                    str = "___";
                                     text.setValue(str);
                                 }
                                 //2
-                                str = str.replaceAll("###","______");
+                                str = str.replaceAll("###", "______");
                                 text.setValue(str);
                                 //3
                                 Pattern pattern = Pattern.compile("##\\d{1,}##");
-                        		Matcher m = pattern.matcher(str);
-                            	while(m.find()){
-                            		int curNum = num + index;
+                                Matcher m = pattern.matcher(str);
+                                while (m.find()) {
+                                    int curNum = num + index;
                                     String a = m.group();
-                                    str = str.replaceAll(a, "___"+(curNum)+"___");
+                                    str = str.replaceAll(a, "___" + (curNum) + "___");
                                     text.setValue(str);
                                     index++;
-                            	}
-                            	//4
+                                }
+                                //4
                                 /*if(str.startsWith("#") || str.equals("___")){
                                     curMap.put(cur,str);
                                     text.setValue("");
                                 }*/
                                 //5
-                                if(str.matches("^\\d{1,}$")){
+                                if (str.matches("^\\d{1,}$")) {
                                     String preStr = curMap.get(cur - 1);
                                     int curNum = num + index;
-                                    if(!StringUtils.isEmpty(preStr) && preStr.startsWith("#")){
-                                        text.setValue("___"+(curNum)+"___");
+                                    if (!StringUtils.isEmpty(preStr) && preStr.startsWith("#")) {
+                                        text.setValue("___" + (curNum) + "___");
                                     }
                                     index++;
                                 }
@@ -524,8 +534,8 @@ public  class InitPaperExpService {
             }
         }
         StringBuffer pWordMl = new StringBuffer();
-        for(Object pObj:pList){
-            if(pObj instanceof P){
+        for (Object pObj : pList) {
+            if (pObj instanceof P) {
                 pWordMl.append(DocxProcessUtil.formatPWordMl(XmlUtils.marshaltoString(pObj)));
             }
         }

+ 83 - 83
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/NkdxExportPaperService.java

@@ -20,103 +20,103 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.QuestionTypeNum;
 import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperExp;
 
 /**
- * @author  	weiwenhai
- * @date    	2018年7月26日 上午11:29:49
- * @company 	QMTH
+ * @author weiwenhai
+ * @date 2018年7月26日 上午11:29:49
+ * @company QMTH
  * @description 南开大学导出、上传文件service
  */
 @Service("nkdxExportPaperService")
 public class NkdxExportPaperService extends ExportPaperAbstractService {
 
-	protected ExamCloudLog log = ExamCloudLogFactory.getLog(this.getClass());
-	
-	@Override
-    public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
-		log.debug("题库开始下载试卷...");
-		long startTime = System.currentTimeMillis();
-		PaperExp paperExp = super.initPaperExp(paperId);
-		long paperExpTime = System.currentTimeMillis();
-		log.debug("拼装导出对象耗时:"+ (paperExpTime - startTime)+"ms");
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			if(examType.equals("offLine")){
-				WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
-				paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
-				DocxProcessUtil.exportWordNew(paperExp, file,NKDX_TMPLATE_PAPER);
-			}else{
-				long docxTime = System.currentTimeMillis();
-				DocxProcessUtil.exportWordNew(paperExp, file,NKDX_TMPLATE_PAPER);
-				long docxEndTime = System.currentTimeMillis();
-				log.debug("处理word文字耗时:"+ (docxEndTime - docxTime)+"ms");
-			}
-			long docxImgTime = System.currentTimeMillis();
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-			long docxImgEndTime = System.currentTimeMillis();
-			log.debug("处理word文字+图片耗时:"+ (docxImgEndTime - docxImgTime)+"ms");
-			//下载音频
-			super.downloadAudio(paperExp, zipFileName);
-			long aduioTime = System.currentTimeMillis();
-			log.debug("处理音频耗时:"+ (aduioTime - docxImgEndTime)+"ms");
-		}
+    protected ExamCloudLog log = ExamCloudLogFactory.getLog(this.getClass());
+
+    @Override
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
+        log.debug("题库开始下载试卷...");
+        long startTime = System.currentTimeMillis();
+        PaperExp paperExp = super.initPaperExp(paperId);
+        long paperExpTime = System.currentTimeMillis();
+        log.debug("拼装导出对象耗时:" + (paperExpTime - startTime) + "ms");
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            if (examType.equals("offLine")) {
+                WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
+                paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
+                DocxProcessUtil.exportWordNew(paperExp, file, NKDX_TMPLATE_PAPER);
+            } else {
+                long docxTime = System.currentTimeMillis();
+                DocxProcessUtil.exportWordNew(paperExp, file, NKDX_TMPLATE_PAPER);
+                long docxEndTime = System.currentTimeMillis();
+                log.debug("处理word文字耗时:" + (docxEndTime - docxTime) + "ms");
+            }
+            long docxImgTime = System.currentTimeMillis();
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+            long docxImgEndTime = System.currentTimeMillis();
+            log.debug("处理word文字+图片耗时:" + (docxImgEndTime - docxImgTime) + "ms");
+            //下载音频
+            super.downloadAudio(paperExp, zipFileName);
+            long aduioTime = System.currentTimeMillis();
+            log.debug("处理音频耗时:" + (aduioTime - docxImgEndTime) + "ms");
+        }
+    }
+
+    @Override
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        log.debug("题库开始下载答案...");
+        long startTime = System.currentTimeMillis();
+        PaperExp paperExp = initPaperExp(paperId);
+        long paperExpTime = System.currentTimeMillis();
+        log.debug("拼装导出对象耗时:" + (paperExpTime - startTime) + "ms");
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            long docxTime = System.currentTimeMillis();
+            DocxProcessUtil.exportWordNew(paperExp, file, NKDX_TMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
+            long docxEndTime = System.currentTimeMillis();
+            log.debug("处理word文字+图片耗时:" + (docxEndTime - docxTime) + "ms");
+        }
     }
-	
-	@Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-		log.debug("题库开始下载答案...");
-		long startTime = System.currentTimeMillis();
-		PaperExp paperExp = initPaperExp(paperId);
-		long paperExpTime = System.currentTimeMillis();
-		log.debug("拼装导出对象耗时:"+ (paperExpTime - startTime)+"ms");
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			long docxTime = System.currentTimeMillis();
-			DocxProcessUtil.exportWordNew(paperExp,file,NKDX_TMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-			long docxEndTime = System.currentTimeMillis();
-			log.debug("处理word文字+图片耗时:"+ (docxEndTime - docxTime)+"ms");
-		}
-	}
 
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-		PaperExp paperExp = initPaperExp(paperId);
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//删除原有试卷文件
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //删除原有试卷文件
         	/*ExamFile examFile = new ExamFile();
         	examFile.setExamId(extractConfig.getExamId()+"");
         	examFile.setCourseId(extractConfig.getCourseCode());
         	examFile.setOrgId(extractConfig.getOrgId());
         	examFileService.deleteExamFile(examFile);*/
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,NKDX_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,NKDX_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,NKDX_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,NKDX_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, NKDX_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, NKDX_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, NKDX_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, NKDX_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 
 }

+ 54 - 53
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/RjgcExportPaperService.java

@@ -15,74 +15,75 @@ import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
 import cn.com.qmth.examcloud.core.questions.base.enums.ExamFileType;
 import cn.com.qmth.examcloud.core.questions.base.enums.ExportType;
 import cn.com.qmth.examcloud.core.questions.base.word.DocxProcessUtil;
+
 /**
  * @author weiwenhai
- * @date  2018.3.6
- * @description  武汉软件工程职业学院
+ * @date 2018.3.6
+ * @description 武汉软件工程职业学院
  * @company qmth
  */
 @Service("rjgcExportPaperService")
 public class RjgcExportPaperService extends ExportPaperAbstractService {
 
-	@Override
-    public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			DocxProcessUtil.exportWordNew(paperExp, file,RJGC_TMPLATE_PAPER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-		}
+    @Override
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, RJGC_TMPLATE_PAPER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+        }
+    }
+
+    @Override
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, RJGC_TMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
+        }
     }
-	
-	@Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			DocxProcessUtil.exportWordNew(paperExp,file,RJGC_TMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-		}
-	}
 
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-		PaperExp paperExp = initPaperExp(paperId);
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//删除原有试卷文件
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //删除原有试卷文件
         	/*ExamFile examFile = new ExamFile();
         	examFile.setExamId(extractConfig.getExamId()+"");
         	examFile.setCourseId(extractConfig.getCourseCode());
         	examFile.setOrgId(extractConfig.getOrgId());
         	examFileService.deleteExamFile(examFile);*/
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,SXSF_TEMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,SXSF_TEMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,SXSF_TEMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,SXSF_TEMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, SXSF_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, SXSF_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, SXSF_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, SXSF_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

+ 63 - 62
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/SddxExportPaperService.java

@@ -2,6 +2,7 @@ package cn.com.qmth.examcloud.core.questions.service.export;
 
 import java.io.File;
 import java.util.List;
+
 import org.springframework.stereotype.Service;
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperExp;
@@ -15,74 +16,74 @@ import cn.com.qmth.examcloud.core.questions.base.enums.ExportType;
 import cn.com.qmth.examcloud.core.questions.base.word.DocxProcessUtil;
 
 /**
- * @author  	chenken
- * @date    	2017年7月7日 上午11:29:49
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年7月7日 上午11:29:49
+ * @company QMTH
  * @description 山东大学导出、上传文件service
  */
 @Service("sddxExportPaperService")
-public class SddxExportPaperService extends ExportPaperAbstractService{
-	
-	
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		PaperExp paperExp = previewPDF2(paperId);
-		return paperExp;
-	}
-	
-	@Override
-    public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File firectory = new File(TEMP_FILE_EXP+File.separator+zipFileName);
-			if(!firectory.exists()){
-				firectory.mkdirs();
-			}
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			DocxProcessUtil.exportWordNew(paperExp, file,SDDX_TEMPLATE_PAPER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-		}
+public class SddxExportPaperService extends ExportPaperAbstractService {
+
+
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        PaperExp paperExp = previewPDF2(paperId);
+        return paperExp;
+    }
+
+    @Override
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File firectory = new File(TEMP_FILE_EXP + File.separator + zipFileName);
+            if (!firectory.exists()) {
+                firectory.mkdirs();
+            }
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, SDDX_TEMPLATE_PAPER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+        }
     }
-	
-	@Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			DocxProcessUtil.exportWordNew(paperExp,file,SDDX_TEMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-		}
-	}
 
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-		PaperExp paperExp = initPaperExp(paperId);
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,SDDX_TEMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,SDDX_TEMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,SDDX_TEMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,SDDX_TEMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+    @Override
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, SDDX_TEMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
         }
     }
 
-	
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, SDDX_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, SDDX_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, SDDX_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, SDDX_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
+        }
+    }
+
+
 }

+ 67 - 67
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/SxsfExportPaperService.java

@@ -20,89 +20,89 @@ import cn.com.qmth.examcloud.core.questions.base.enums.ExportType;
 import cn.com.qmth.examcloud.core.questions.base.word.DocxProcessUtil;
 
 /**
- * @author  	chenken
- * @date    	2017年7月7日 上午11:29:49
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年7月7日 上午11:29:49
+ * @company QMTH
  * @description 陕西师范大学导出、上传文件service
  */
 @Service("sxsfExportPaperService")
 public class SxsfExportPaperService extends ExportPaperAbstractService {
-	
-	@Override
-    public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
-		PaperExp paperExp = super.initPaperExp(paperId);
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			List<WordprocessingMLPackage> wordPackages = getPkgList(paperId);
-			if(examType.equals("offLine")){
-				WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
-				if (StringUtils.isBlank(paperExp.getExamRemark())) {
+
+    @Override
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
+        PaperExp paperExp = super.initPaperExp(paperId);
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            List<WordprocessingMLPackage> wordPackages = getPkgList(paperId);
+            if (examType.equals("offLine")) {
+                WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
+                if (StringUtils.isBlank(paperExp.getExamRemark())) {
                     paperExp.setExamRemark("<p></p>");
                 }
-				String examRemark = ImageUtils.reSizeImg(paperExp.getExamRemark());
-				paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(examRemark)));
-				DocxProcessUtil.exportWordNew(paperExp, file,SXSF_OUTLINE_TEMPLATE_PAPER);
-				if (DocxProcessUtil.hasImage(examRemark)) {
+                String examRemark = ImageUtils.reSizeImg(paperExp.getExamRemark());
+                paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(examRemark)));
+                DocxProcessUtil.exportWordNew(paperExp, file, SXSF_OUTLINE_TEMPLATE_PAPER);
+                if (DocxProcessUtil.hasImage(examRemark)) {
                     wordPackages.add(wordMLPackage);
                 }
-			}else{
-				DocxProcessUtil.exportWordNew(paperExp, file,SXSF_TEMPLATE_PAPER);
-			}
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,wordPackages);
-			//下载音频
-			super.downloadAudio(paperExp, zipFileName);
-		}
+            } else {
+                DocxProcessUtil.exportWordNew(paperExp, file, SXSF_TEMPLATE_PAPER);
+            }
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, wordPackages);
+            //下载音频
+            super.downloadAudio(paperExp, zipFileName);
+        }
+    }
+
+    @Override
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, SXSF_TEMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
+        }
     }
-	
-	@Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			DocxProcessUtil.exportWordNew(paperExp,file,SXSF_TEMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-		}
-	}
 
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-		PaperExp paperExp = initPaperExp(paperId);
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//删除原有试卷文件
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //删除原有试卷文件
         	/*ExamFile examFile = new ExamFile();
         	examFile.setExamId(extractConfig.getExamId()+"");
         	examFile.setCourseId(extractConfig.getCourseCode());
         	examFile.setOrgId(extractConfig.getOrgId());
         	examFileService.deleteExamFile(examFile);*/
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,SXSF_TEMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,SXSF_TEMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,SXSF_TEMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,SXSF_TEMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, SXSF_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, SXSF_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, SXSF_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, SXSF_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

+ 128 - 125
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/SydxExportPaperService.java

@@ -49,14 +49,13 @@ import cn.com.qmth.examcloud.core.questions.base.exception.PaperException;
 import cn.com.qmth.examcloud.core.questions.base.word.DocxProcessUtil;
 
 /**
- * 
- * @author  	chenken
- * @date    	2017年7月31日 上午9:04:53
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年7月31日 上午9:04:53
+ * @company QMTH
  * @description 石油大学导出、上传文件service
  */
 @Service("sydxExportPaperService")
-public class SydxExportPaperService extends ExportPaperAbstractService{
+public class SydxExportPaperService extends ExportPaperAbstractService {
     @Autowired
     PaperRepo paperRepo;
 
@@ -78,99 +77,100 @@ public class SydxExportPaperService extends ExportPaperAbstractService{
     @Autowired
     PaperService paperService;
 
-	@Autowired
-	private PaperDetailService paperDetailService;
-	
+    @Autowired
+    private PaperDetailService paperDetailService;
+
     @Override
-    public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
         PaperExp paperExp = initExportSydxPaper(paperId);
-		if(paperExp!=null){
-			String paperfileName = paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			DocxProcessUtil.exportWordNew(paperExp, file,SYDX_TEMPLATE_PAPER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-		}
-        
+        if (paperExp != null) {
+            String paperfileName = paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, SYDX_TEMPLATE_PAPER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+        }
+
     }
-    
+
     @Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-    	PaperExp paperExp = initExportSydxPaper(paperId);
-		if(paperExp!=null){
-			String paperfileName = paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			DocxProcessUtil.exportWordNew(paperExp, file,SYDX_TEMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-		}
-		
-	}
-    
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        PaperExp paperExp = initExportSydxPaper(paperId);
+        if (paperExp != null) {
+            String paperfileName = paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, SYDX_TEMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+        }
+
+    }
+
     @Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-    	PaperExp exportPaperExp = initExportSydxPaper(paperId);
-    	PaperExp exportPaperStructureExp = initExportSydxPaper(paperId);
-        if (exportPaperExp!=null&&exportPaperStructureExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(exportPaperExp,extractConfig,accessUser,currNum,SYDX_TEMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(exportPaperExp,extractConfig,accessUser,currNum,SYDX_TEMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(exportPaperStructureExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(exportPaperExp,extractConfig,accessUser,currNum,SYDX_TEMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(exportPaperExp,extractConfig,accessUser,currNum,SYDX_TEMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(exportPaperStructureExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp exportPaperExp = initExportSydxPaper(paperId);
+        PaperExp exportPaperStructureExp = initExportSydxPaper(paperId);
+        if (exportPaperExp != null && exportPaperStructureExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(exportPaperExp, extractConfig, accessUser, currNum, SYDX_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(exportPaperExp, extractConfig, accessUser, currNum, SYDX_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(exportPaperStructureExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(exportPaperExp, extractConfig, accessUser, currNum, SYDX_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(exportPaperExp, extractConfig, accessUser, currNum, SYDX_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(exportPaperStructureExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
         }
     }
-	
+
     /**
      * 初始化导出石油大学试卷DTO
+     *
      * @param id
      * @return
      */
-    private PaperExp initExportSydxPaper(String id) throws Exception{
+    private PaperExp initExportSydxPaper(String id) throws Exception {
         //获取paper
         Paper paper = Model.of(paperRepo.findById(id));
-        paperService.formatPaper(paper,null);
-        if(paper == null){
+        paperService.formatPaper(paper, null);
+        if (paper == null) {
             throw new PaperException("该试卷不存在");
         }
         //创建paperDto
-        PaperExp paperExp = BeanCopierUtil.copyProperties(paper,PaperExp.class);
+        PaperExp paperExp = BeanCopierUtil.copyProperties(paper, PaperExp.class);
 
         paperExp.setTitle(CommonUtils.PAPER_TITLE);
         paperExp.setSubTitle(CommonUtils.PAPER_SUB_TITLE);
         //获取大题
         List<PaperDetail> paperDetails = paperDetailRepo.findByPaperOrderByNumber(paper);
         List<PaperDetailExp> paperDetailExps = new ArrayList<PaperDetailExp>();
-        for(PaperDetail paperDetail:paperDetails){
-        	PaperDetailExp paperDetailExp = new PaperDetailExp();
-        	BeanUtils.copyProperties(paperDetail, paperDetailExp);
-        	paperDetailExps.add(paperDetailExp);
+        for (PaperDetail paperDetail : paperDetails) {
+            PaperDetailExp paperDetailExp = new PaperDetailExp();
+            BeanUtils.copyProperties(paperDetail, paperDetailExp);
+            paperDetailExps.add(paperDetailExp);
         }
         paperExp.setPaperDetails(paperDetailExps);
         //封装小题
-        for(int i = 0; i < paperDetailExps.size(); i++){
+        for (int i = 0; i < paperDetailExps.size(); i++) {
             PaperDetailExp paperDetailExp = paperDetailExps.get(i);
             paperDetailExp.setTitle(getDetailTitle(paperDetailExp));
             List<PaperDetailUnit> paperDetailUnits = paperDetailUnitRepo.findByPaperDetailOrderByNumber(paperDetails.get(i));
             setAnswerWord(paperDetailUnits);
             List<PaperDetailUnitExp> paperDetailUnitExps = new ArrayList<PaperDetailUnitExp>();
-            for(PaperDetailUnit paperDetailUnit:paperDetailUnits){
-            	PaperDetailUnitExp paperDetailUnitExp = new PaperDetailUnitExp();
-            	BeanUtils.copyProperties(paperDetailUnit, paperDetailUnitExp);
-            	paperDetailUnitExps.add(paperDetailUnitExp);
+            for (PaperDetailUnit paperDetailUnit : paperDetailUnits) {
+                PaperDetailUnitExp paperDetailUnitExp = new PaperDetailUnitExp();
+                BeanUtils.copyProperties(paperDetailUnit, paperDetailUnitExp);
+                paperDetailUnitExps.add(paperDetailUnitExp);
             }
             //选择题,套题下选择题  选项顺序重新排列
             paperService.reorderChoicequestionOption(paperDetailUnitExps);
@@ -183,17 +183,18 @@ public class SydxExportPaperService extends ExportPaperAbstractService{
 
     /**
      * 设置客观题答案
+     *
      * @param answer
      * @return
      * @throws Exception
      */
-    private String getObjectAnswer(String answerWordMl,String answer) throws Exception {
+    private String getObjectAnswer(String answerWordMl, String answer) throws Exception {
         String tmpStr = DocxProcessUtil.BODY_HEADER + answerWordMl + DocxProcessUtil.BODY_TAIL;
-        Body body = (Body)XmlUtils.unmarshalString(tmpStr,Context.jc,Body.class);
+        Body body = (Body) XmlUtils.unmarshalString(tmpStr, Context.jc, Body.class);
         List<Object> pList = body.getContent();
         int index = 0;
-        for(Object pObj:pList){
-            if(index > 0){
+        for (Object pObj : pList) {
+            if (index > 0) {
                 break;
             }
             P p = (P) pObj;
@@ -201,14 +202,14 @@ public class SydxExportPaperService extends ExportPaperAbstractService{
             pContent.removeAll(pContent);
             R run = new R();
             Text text = new Text();
-            text.setValue("[答案]:"+answer);
+            text.setValue("[答案]:" + answer);
             run.getContent().add(text);
-            pContent.add(0,run);
+            pContent.add(0, run);
             index++;
         }
         StringBuffer pWordMl = new StringBuffer();
-        for(Object pObj:pList){
-            if(pObj instanceof P){
+        for (Object pObj : pList) {
+            if (pObj instanceof P) {
                 pWordMl.append(DocxProcessUtil.formatPWordMl(XmlUtils.marshaltoString(pObj)));
             }
         }
@@ -217,17 +218,18 @@ public class SydxExportPaperService extends ExportPaperAbstractService{
 
     /**
      * 设置主观题答案
+     *
      * @param answerWordMl
      * @return
      * @throws Exception
      */
     private String getSubjectAnswer(String answerWordMl) throws Exception {
         String tmpStr = DocxProcessUtil.BODY_HEADER + answerWordMl + DocxProcessUtil.BODY_TAIL;
-        Body body = (Body)XmlUtils.unmarshalString(tmpStr,Context.jc,Body.class);
+        Body body = (Body) XmlUtils.unmarshalString(tmpStr, Context.jc, Body.class);
         List<Object> pList = body.getContent();
         int index = 0;
-        for(Object pObj:pList){
-            if(index > 0){
+        for (Object pObj : pList) {
+            if (index > 0) {
                 break;
             }
             P p = (P) pObj;
@@ -236,21 +238,21 @@ public class SydxExportPaperService extends ExportPaperAbstractService{
             Text text = new Text();
             text.setValue("[答案]:");
             run.getContent().add(text);
-            pContent.add(0,run);
+            pContent.add(0, run);
             index++;
         }
         StringBuffer pWordMl = new StringBuffer();
-        for(Object pObj:pList){
-            if(pObj instanceof P){
+        for (Object pObj : pList) {
+            if (pObj instanceof P) {
                 pWordMl.append(DocxProcessUtil.formatPWordMl(XmlUtils.marshaltoString(pObj)));
             }
         }
         return pWordMl.toString();
     }
 
-    private void setAnswerWord(List<PaperDetailUnit> paperDetailUnits) throws Exception{
+    private void setAnswerWord(List<PaperDetailUnit> paperDetailUnits) throws Exception {
         for (PaperDetailUnit paperDetailUnit : paperDetailUnits) {
-            if(paperDetailUnit==null||paperDetailUnit.getQuestion()==null){
+            if (paperDetailUnit == null || paperDetailUnit.getQuestion() == null) {
                 break;
             }
             String optionOrder = paperDetailUnit.getOptionOrder();
@@ -265,113 +267,114 @@ public class SydxExportPaperService extends ExportPaperAbstractService{
                     Question subQuestion = subQuestions.get(k);
                     if (subQuestion.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
                             || subQuestion.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
-                        if(StringUtils.isNotEmpty(optionOrder) && optionOrder.contains(";")){
+                        if (StringUtils.isNotEmpty(optionOrder) && optionOrder.contains(";")) {
                             setAnswerWordUnit(subQuestion, optionOrder.split(";")[index]);
-                        }else{
+                        } else {
                             setAnswerWordUnit(subQuestion, "");
                         }
                         index++;
                     }
                 }
-            }else{
+            } else {
                 question.setQuesAnswerWord(getSubjectAnswer(question.getQuesAnswerWord()));
             }
         }
     }
 
-    private void setAnswerWordUnit(Question question, String optionOrder) throws Exception{
+    private void setAnswerWordUnit(Question question, String optionOrder) throws Exception {
         List<QuesOption> quesOptions = question.getQuesOptions();
-        if(quesOptions == null || quesOptions.size() == 0){
+        if (quesOptions == null || quesOptions.size() == 0) {
             return;
         }
-        if(StringUtils.isEmpty(optionOrder)){
+        if (StringUtils.isEmpty(optionOrder)) {
             int j = 0;
             String answer = "";
-            for(QuesOption quesOption : quesOptions){
-                if(quesOption.getIsCorrect() == 1){
+            for (QuesOption quesOption : quesOptions) {
+                if (quesOption.getIsCorrect() == 1) {
                     answer += CommonUtils.getOptionNum(j);
                 }
                 j++;
             }
-            question.setQuesAnswerWord(getObjectAnswer(question.getQuesAnswerWord(),answer));
-        }else{
-            String [] order = optionOrder.split(",");
-            for(int i = 0;i < order.length;i++){
-                for(QuesOption quesOption : quesOptions){
-                    if(order[i].equals(quesOption.getNumber()) && quesOption.getIsCorrect() == 1){
-                        question.setQuesAnswerWord(getObjectAnswer(question.getQuesAnswerWord(),CommonUtils.getOptionNum(i)));
+            question.setQuesAnswerWord(getObjectAnswer(question.getQuesAnswerWord(), answer));
+        } else {
+            String[] order = optionOrder.split(",");
+            for (int i = 0; i < order.length; i++) {
+                for (QuesOption quesOption : quesOptions) {
+                    if (order[i].equals(quesOption.getNumber()) && quesOption.getIsCorrect() == 1) {
+                        question.setQuesAnswerWord(getObjectAnswer(question.getQuesAnswerWord(), CommonUtils.getOptionNum(i)));
                     }
                 }
             }
         }
     }
 
-    public String getDetailTitle(PaperDetailExp paperDetailExp){
+    public String getDetailTitle(PaperDetailExp paperDetailExp) {
         int totalScore = paperDetailExp.getScore().intValue();
         int count = paperDetailExp.getUnitCount();
-        return "本大题共"+count+"小题,共"+totalScore+"分";
+        return "本大题共" + count + "小题,共" + totalScore + "分";
     }
 
     /**
      * 初始化序号
+     *
      * @param paperExp
      */
-    public void initPaperNum(PaperExp paperExp)throws Exception{
-        if(paperExp.getPaperDetails() == null || paperExp.getPaperDetails().size() == 0){
+    public void initPaperNum(PaperExp paperExp) throws Exception {
+        if (paperExp.getPaperDetails() == null || paperExp.getPaperDetails().size() == 0) {
             return;
         }
         int mainNum = 0;
         int subNum = 0;
         Collections.sort(paperExp.getPaperDetails());
-        for(PaperDetailExp paperDetail: paperExp.getPaperDetails()){
+        for (PaperDetailExp paperDetail : paperExp.getPaperDetails()) {
             //大题序号
             paperDetail.setNumber(++mainNum);
             paperDetail.setCnNum(CommonUtils.toCHNum(paperDetail.getNumber()));
-            if(paperDetail.getPaperDetailUnits() == null ||
-                    paperDetail.getPaperDetailUnits().size() == 0){
+            if (paperDetail.getPaperDetailUnits() == null ||
+                    paperDetail.getPaperDetailUnits().size() == 0) {
                 continue;
             }
             //小题序号
-            for(PaperDetailUnitExp paperDetailUnit:paperDetail.getPaperDetailUnits()){
+            for (PaperDetailUnitExp paperDetailUnit : paperDetail.getPaperDetailUnits()) {
                 List<QuesOption> optionList = paperDetailUnit.getQuestion().getQuesOptions();
-                if(optionList != null && optionList.size() > 0){
+                if (optionList != null && optionList.size() > 0) {
                     int index = 0;
-                    for(QuesOption quesOption:optionList){
-                        quesOption.setOptionBodyWord(initPaperExpService.setOptionNum(quesOption.getOptionBodyWord(),initPaperExpService.getOptionNum(index)));
+                    for (QuesOption quesOption : optionList) {
+                        quesOption.setOptionBodyWord(initPaperExpService.setOptionNum(quesOption.getOptionBodyWord(), initPaperExpService.getOptionNum(index)));
                         index++;
                     }
                 }
                 List<Question> subQuesList = paperDetailUnit.getQuestion().getSubQuestions();
                 Question question = paperDetailUnit.getQuestion();
                 //套题序号
-                if(subQuesList != null && subQuesList.size() > 0){
-                    question.setQuesBodyWord(initPaperExpService.replaceQuesBlank(question.getQuesBodyWord(),subNum + 1));
-                    for(Question subQues:subQuesList){
+                if (subQuesList != null && subQuesList.size() > 0) {
+                    question.setQuesBodyWord(initPaperExpService.replaceQuesBlank(question.getQuesBodyWord(), subNum + 1));
+                    for (Question subQues : subQuesList) {
                         int curSubNum = ++subNum;
-                        subQues.setQuesBodyWord(initPaperExpService.setSubQuesNum(subQues.getQuesBodyWord(),curSubNum));
-                        subQues.setQuesBodyWord(initPaperExpService.replaceQuesBlank(subQues.getQuesBodyWord(),curSubNum));
+                        subQues.setQuesBodyWord(initPaperExpService.setSubQuesNum(subQues.getQuesBodyWord(), curSubNum));
+                        subQues.setQuesBodyWord(initPaperExpService.replaceQuesBlank(subQues.getQuesBodyWord(), curSubNum));
                         List<QuesOption> subOptionList = subQues.getQuesOptions();
-                        if(subOptionList != null && subOptionList.size() > 0){
+                        if (subOptionList != null && subOptionList.size() > 0) {
                             int sub_index = 0;
-                            for(QuesOption quesOption:subOptionList){
-                                quesOption.setOptionBodyWord(initPaperExpService.setOptionNum(quesOption.getOptionBodyWord(),initPaperExpService.getOptionNum(sub_index)));
+                            for (QuesOption quesOption : subOptionList) {
+                                quesOption.setOptionBodyWord(initPaperExpService.setOptionNum(quesOption.getOptionBodyWord(), initPaperExpService.getOptionNum(sub_index)));
                                 sub_index++;
                             }
                         }
                     }
-                }else{
+                } else {
                     int curSubNum = ++subNum;
-                    question.setQuesBodyWord(initPaperExpService.setSubQuesNum(question.getQuesBodyWord(),curSubNum));
-                    question.setQuesBodyWord(initPaperExpService.replaceQuesBlank(question.getQuesBodyWord(),curSubNum));
+                    question.setQuesBodyWord(initPaperExpService.setSubQuesNum(question.getQuesBodyWord(), curSubNum));
+                    question.setQuesBodyWord(initPaperExpService.replaceQuesBlank(question.getQuesBodyWord(), curSubNum));
                 }
             }
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 
 }

+ 12 - 12
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/TjdxExportPaperService.java

@@ -68,37 +68,37 @@ public class TjdxExportPaperService extends ExportPaperAbstractService {
     }
 
     @Override
-    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser,ExamPaper examPaper) throws Exception {
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
         PaperExp paperExp = initPaperExp(paperId);
         if (paperExp != null) {
             String currNum = CommonUtils.getCurNum();
             //没有试卷结构导出设置
             if (exportStructure == null) {
                 //上传试卷
-                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, TJDX_TEMPLATE_PAPER, ExamFileType.PAPER,examPaper);
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, TJDX_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
                 //上传答案
-                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, TJDX_TEMPLATE_ANSWER, ExamFileType.ANSWER,examPaper);
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, TJDX_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
             } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
                 List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
                 //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
                 checkObjectiveDetailsNum(paperExp, questionTypeNums);
                 //上传试卷
-                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, TJDX_TEMPLATE_PAPER, ExamFileType.PAPER,examPaper);
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, TJDX_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
                 //上传答案
-                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, TJDX_TEMPLATE_ANSWER, ExamFileType.ANSWER,examPaper);
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, TJDX_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
                 //上传试卷结构   不能在上传试卷和答案之前
-                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums,examPaper);
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
             } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
                 //上传机考JSON文件
-                uploadComputerTestFile(extractConfig, accessUser,examPaper);
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
             }
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 
 }

+ 66 - 66
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/XnjdExportPaperService.java

@@ -20,89 +20,89 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.QuestionTypeNum;
 import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperExp;
 
 /**
- * @author  	WEIWENHAI
- * @date    	2018年11月6日 上午11:29:49
- * @company 	QMTH
+ * @author WEIWENHAI
+ * @date 2018年11月6日 上午11:29:49
+ * @company QMTH
  * @description 西南交通大学大学导出、上传文件service
  */
 @Service("xnjdExportPaperService")
 public class XnjdExportPaperService extends ExportPaperAbstractService {
 
-	@Override
-    public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
-		PaperExp paperExp = super.initPaperExp(paperId);
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			List<WordprocessingMLPackage> wordPackages = getPkgList(paperId);
-			if(examType.equals("offLine")){
-				WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
-				if (StringUtils.isBlank(paperExp.getExamRemark())) {
+    @Override
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
+        PaperExp paperExp = super.initPaperExp(paperId);
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            List<WordprocessingMLPackage> wordPackages = getPkgList(paperId);
+            if (examType.equals("offLine")) {
+                WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
+                if (StringUtils.isBlank(paperExp.getExamRemark())) {
                     paperExp.setExamRemark("<p></p>");
                 }
-				String examRemark = ImageUtils.reSizeImg(paperExp.getExamRemark());
-				paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(examRemark)));
-				DocxProcessUtil.exportWordNew(paperExp, file,XNJD_OUTLINE_TEMPLATE_PAPER);
-				if (DocxProcessUtil.hasImage(examRemark)) {
+                String examRemark = ImageUtils.reSizeImg(paperExp.getExamRemark());
+                paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(examRemark)));
+                DocxProcessUtil.exportWordNew(paperExp, file, XNJD_OUTLINE_TEMPLATE_PAPER);
+                if (DocxProcessUtil.hasImage(examRemark)) {
                     wordPackages.add(wordMLPackage);
                 }
-			}else{
-				DocxProcessUtil.exportWordNew(paperExp, file,XNJD_TEMPLATE_PAPER);
-			}
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,wordPackages);
-			//下载音频
-			super.downloadAudio(paperExp, zipFileName);
-		}
+            } else {
+                DocxProcessUtil.exportWordNew(paperExp, file, XNJD_TEMPLATE_PAPER);
+            }
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, wordPackages);
+            //下载音频
+            super.downloadAudio(paperExp, zipFileName);
+        }
     }
-	
-	@Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			DocxProcessUtil.exportWordNew(paperExp,file,XNJD_TEMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-		}
-	}
 
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-		PaperExp paperExp = initPaperExp(paperId);
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//删除原有试卷文件
+    @Override
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, XNJD_TEMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
+        }
+    }
+
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //删除原有试卷文件
         	/*ExamFile examFile = new ExamFile();
         	examFile.setExamId(extractConfig.getExamId()+"");
         	examFile.setCourseId(extractConfig.getCourseCode());
         	examFile.setOrgId(extractConfig.getOrgId());
         	examFileService.deleteExamFile(examFile);*/
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,XNJD_TEMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,XNJD_TEMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,XNJD_TEMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,XNJD_TEMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, XNJD_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, XNJD_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, XNJD_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, XNJD_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

+ 56 - 56
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/YkdxExportPaperService.java

@@ -19,70 +19,70 @@ import cn.com.qmth.examcloud.core.questions.base.word.DocxProcessUtil;
 @Service("ykdxExportPaperService")
 public class YkdxExportPaperService extends ExportPaperAbstractService {
 
-	@Override
-    public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
-		PaperExp paperExp = super.initPaperExp(paperId);
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			if(examType.equals("offLine")){
-				DocxProcessUtil.exportWordNew(paperExp, file,YKDX_TMPLATE_PAPER);
-			}else{
-				DocxProcessUtil.exportWordNew(paperExp, file,YKDX_TMPLATE_PAPER);
-			}
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-		}
+    @Override
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
+        PaperExp paperExp = super.initPaperExp(paperId);
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            if (examType.equals("offLine")) {
+                DocxProcessUtil.exportWordNew(paperExp, file, YKDX_TMPLATE_PAPER);
+            } else {
+                DocxProcessUtil.exportWordNew(paperExp, file, YKDX_TMPLATE_PAPER);
+            }
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+        }
+    }
+
+    @Override
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, YKDX_TMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
+        }
     }
-	
-	@Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			DocxProcessUtil.exportWordNew(paperExp,file,YKDX_TMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-		}
-	}
 
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-		PaperExp paperExp = initPaperExp(paperId);
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//删除原有试卷文件
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //删除原有试卷文件
         	/*ExamFile examFile = new ExamFile();
         	examFile.setExamId(extractConfig.getExamId()+"");
         	examFile.setCourseId(extractConfig.getCourseCode());
         	examFile.setOrgId(extractConfig.getOrgId());
         	examFileService.deleteExamFile(examFile);*/
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,YKDX_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,YKDX_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,YKDX_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,YKDX_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, YKDX_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, YKDX_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, YKDX_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, YKDX_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-	
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 }

+ 63 - 63
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/ZgddbExportPaperService.java

@@ -18,81 +18,81 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.QuestionTypeNum;
 import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperExp;
 
 /**
- * @author  	weiwenhai
- * @date    	2018年7月25日 上午11:29:49
- * @company 	QMTH
- * @description 中国地质(北京)大学导出、上传文件service 
+ * @author weiwenhai
+ * @date 2018年7月25日 上午11:29:49
+ * @company QMTH
+ * @description 中国地质(北京)大学导出、上传文件service
  */
 @Service("zgddbExportPaperService")
 public class ZgddbExportPaperService extends ExportPaperAbstractService {
 
-	@Override
-    public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
-		PaperExp paperExp = super.initPaperExp(paperId);
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			if(examType.equals("offLine")){
-				WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
-				paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
-				DocxProcessUtil.exportWordNew(paperExp, file,ZGDDB_TMPLATE_PAPER);
-			}else{
-				DocxProcessUtil.exportWordNew(paperExp, file,ZGDDB_TMPLATE_PAPER);
-			}
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-			//下载音频
-			super.downloadAudio(paperExp, zipFileName);
-		}
+    @Override
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
+        PaperExp paperExp = super.initPaperExp(paperId);
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            if (examType.equals("offLine")) {
+                WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
+                paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
+                DocxProcessUtil.exportWordNew(paperExp, file, ZGDDB_TMPLATE_PAPER);
+            } else {
+                DocxProcessUtil.exportWordNew(paperExp, file, ZGDDB_TMPLATE_PAPER);
+            }
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+            //下载音频
+            super.downloadAudio(paperExp, zipFileName);
+        }
     }
-	
-	@Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			DocxProcessUtil.exportWordNew(paperExp,file,ZGDDB_TMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-		}
-	}
 
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-		PaperExp paperExp = initPaperExp(paperId);
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//删除原有试卷文件
+    @Override
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, ZGDDB_TMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
+        }
+    }
+
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //删除原有试卷文件
         	/*ExamFile examFile = new ExamFile();
         	examFile.setExamId(extractConfig.getExamId()+"");
         	examFile.setCourseId(extractConfig.getCourseCode());
         	examFile.setOrgId(extractConfig.getOrgId());
         	examFileService.deleteExamFile(examFile);*/
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,ZGDDB_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,ZGDDB_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,ZGDDB_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,ZGDDB_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, ZGDDB_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, ZGDDB_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, ZGDDB_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, ZGDDB_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

+ 62 - 62
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/ZgddwExportPaperService.java

@@ -19,81 +19,81 @@ import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperExp;
 
 
 /**
- * @author  	weiwenhai
- * @date    	2018年7月25日 上午11:29:49
- * @company 	QMTH
+ * @author weiwenhai
+ * @date 2018年7月25日 上午11:29:49
+ * @company QMTH
  * @description 中国地质(武汉)大学导出、上传文件service ZGDDW_TMPLATE_PAPER,ZGDDW_TMPLATE_ANSWER
  */
 @Service("zgddwExportPaperService")
 public class ZgddwExportPaperService extends ExportPaperAbstractService {
 
-	@Override
-    public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
-		PaperExp paperExp = super.initPaperExp(paperId);
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			if(examType.equals("offLine")){
-				WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
-				paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
-				DocxProcessUtil.exportWordNew(paperExp, file,ZGDDW_TMPLATE_PAPER);
-			}else{
-				DocxProcessUtil.exportWordNew(paperExp, file,ZGDDW_TMPLATE_PAPER);
-			}
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-			//下载音频
-			super.downloadAudio(paperExp, zipFileName);
-		}
+    @Override
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
+        PaperExp paperExp = super.initPaperExp(paperId);
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            if (examType.equals("offLine")) {
+                WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
+                paperExp.setExamRemarkWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(paperExp.getExamRemark())));
+                DocxProcessUtil.exportWordNew(paperExp, file, ZGDDW_TMPLATE_PAPER);
+            } else {
+                DocxProcessUtil.exportWordNew(paperExp, file, ZGDDW_TMPLATE_PAPER);
+            }
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+            //下载音频
+            super.downloadAudio(paperExp, zipFileName);
+        }
     }
-	
-	@Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			DocxProcessUtil.exportWordNew(paperExp,file,ZGDDW_TMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-		}
-	}
 
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-		PaperExp paperExp = initPaperExp(paperId);
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//删除原有试卷文件
+    @Override
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, ZGDDW_TMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
+        }
+    }
+
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //删除原有试卷文件
         	/*ExamFile examFile = new ExamFile();
         	examFile.setExamId(extractConfig.getExamId()+"");
         	examFile.setCourseId(extractConfig.getCourseCode());
         	examFile.setOrgId(extractConfig.getOrgId());
         	examFileService.deleteExamFile(examFile);*/
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,ZGDDW_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,ZGDDW_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,ZGDDW_TMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,ZGDDW_TMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, ZGDDW_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, ZGDDW_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, ZGDDW_TMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, ZGDDW_TMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

+ 58 - 58
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/export/xajdExportPaperService.java

@@ -17,69 +17,69 @@ import cn.com.qmth.examcloud.core.questions.base.enums.ExportType;
 import cn.com.qmth.examcloud.core.questions.base.word.DocxProcessUtil;
 
 /**
-* @author  	weiwenhai
-* @date    	2017.10.23
-* @company 	QMTH
-* @description 西安交大导出、上传文件service
-*/
+ * @author weiwenhai
+ * @date 2017.10.23
+ * @company QMTH
+ * @description 西安交大导出、上传文件service
+ */
 @Service("xajdExportPaperService")
-public class xajdExportPaperService extends ExportPaperAbstractService{
-    
-	@Override
-    public void downloadPaper(String paperId,String zipFileName,String examType) throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-			DocxProcessUtil.exportWordNew(paperExp, file,XAJD_TEMPLATE_PAPER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,getPkgList(paperId));
-		}
+public class xajdExportPaperService extends ExportPaperAbstractService {
+
+    @Override
+    public void downloadPaper(String paperId, String zipFileName, String examType) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, XAJD_TEMPLATE_PAPER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, getPkgList(paperId));
+        }
     }
-	
-	@Override
-	public void downloadPaperAnswer(String paperId, String zipFileName)throws Exception {
-		PaperExp paperExp = initPaperExp(paperId);
-		if(paperExp!=null){
-			String answerFileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.ANSWER.getName()+DOCX_SUFFIX;
-			File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+answerFileName);
-			DocxProcessUtil.exportWordNew(paperExp,file,XAJD_TEMPLATE_ANSWER);
-			DocxProcessUtil.processImage(zipFileName+File.separator+answerFileName,getPkgList(paperId));
-		}
-	}
 
-	@Override
-    public void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,User accessUser,ExamPaper examPaper) throws Exception{
-		PaperExp paperExp = initPaperExp(paperId);
-        if (paperExp!=null) {
-        	String currNum = CommonUtils.getCurNum();
-        	//没有试卷结构导出设置
-        	if(exportStructure==null){
-        		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,XAJD_TEMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,XAJD_TEMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.NORMAL){
-        		List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-        		//检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
-        		checkObjectiveDetailsNum(paperExp,questionTypeNums);
-	    		//上传试卷
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,XAJD_TEMPLATE_PAPER,ExamFileType.PAPER,examPaper);
-	        	//上传答案
-        		uploadPaperOrAnswerFile(paperExp,extractConfig,accessUser,currNum,XAJD_TEMPLATE_ANSWER,ExamFileType.ANSWER,examPaper);
-				//上传试卷结构   不能在上传试卷和答案之前
-        		uploadPaperStructure(paperExp,extractConfig,accessUser,currNum,questionTypeNums,examPaper);
-        	}else if(exportStructure!=null&&exportStructure.getExportType()==ExportType.ONLINE){
-        		//上传机考JSON文件
-        		uploadComputerTestFile(extractConfig,accessUser,examPaper);
-        	}
+    @Override
+    public void downloadPaperAnswer(String paperId, String zipFileName) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String answerFileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.ANSWER.getName() + DOCX_SUFFIX;
+            File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + answerFileName);
+            DocxProcessUtil.exportWordNew(paperExp, file, XAJD_TEMPLATE_ANSWER);
+            DocxProcessUtil.processImage(zipFileName + File.separator + answerFileName, getPkgList(paperId));
         }
     }
 
-	@Override
-	public PaperExp previewPDF(String paperId) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-	
+    @Override
+    public void uploadFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User accessUser, ExamPaper examPaper) throws Exception {
+        PaperExp paperExp = initPaperExp(paperId);
+        if (paperExp != null) {
+            String currNum = CommonUtils.getCurNum();
+            //没有试卷结构导出设置
+            if (exportStructure == null) {
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, XAJD_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, XAJD_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.NORMAL) {
+                List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+                //检查试卷中客观题的数量是否大于试卷导出设置中的设置的数量
+                checkObjectiveDetailsNum(paperExp, questionTypeNums);
+                //上传试卷
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, XAJD_TEMPLATE_PAPER, ExamFileType.PAPER, examPaper);
+                //上传答案
+                uploadPaperOrAnswerFile(paperExp, extractConfig, accessUser, currNum, XAJD_TEMPLATE_ANSWER, ExamFileType.ANSWER, examPaper);
+                //上传试卷结构   不能在上传试卷和答案之前
+                uploadPaperStructure(paperExp, extractConfig, accessUser, currNum, questionTypeNums, examPaper);
+            } else if (exportStructure != null && exportStructure.getExportType() == ExportType.ONLINE) {
+                //上传机考JSON文件
+                uploadComputerTestFile(extractConfig, accessUser, examPaper);
+            }
+        }
+    }
+
+    @Override
+    public PaperExp previewPDF(String paperId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 }
 

+ 180 - 179
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/AudioTimeConfigServiceImpl.java

@@ -29,187 +29,188 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
 import cn.com.qmth.examcloud.core.questions.service.QuesService;
 
 /**
- * @author  	chenken
- * @date    	2017年8月10日 下午3:16:12
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年8月10日 下午3:16:12
+ * @company QMTH
  * @description 音频次数设置service
  */
 @Service("audioTimeConfigService")
-public class AudioTimeConfigServiceImpl implements AudioTimeConfigService{
-
-	@Autowired
-	private AudioTimeConfigRepo audioTimeConfigRepo;
-	
-	@Autowired
-	private PaperRepo paperRepo;
-	
-	@Autowired
-	private PaperDetailUnitRepo paperDetailUnitRepo;
-	
-	@Autowired
-	private QuesService quesService;
-	
-	@Autowired
-	private ExtractConfigService extractConfigService;
-	
-	@Override
-	public void saveAudioTimeConfig(List<AudioTimeConfig> audioTimeConfigs,User user) {
-		if(audioTimeConfigs!=null&&audioTimeConfigs.size()>0){
-			this.deleteByExamIdAndCourseCode(audioTimeConfigs.get(0).getExamId(),audioTimeConfigs.get(0).getCourseCode());
-			for(AudioTimeConfig audioTimeConfig:audioTimeConfigs){
-				audioTimeConfig.setCreateDate(new Date());
-				//audioTimeConfig.setCreateUser(user.getName());
-				audioTimeConfig.setCreateUser(user.getDisplayName());
-			}
-			audioTimeConfigRepo.saveAll(audioTimeConfigs);
-		}
-	}
-
-	@Override
-	public List<AudioTimeConfig> findByAudioTimeConfig(AudioTimeConfig audioTimeConfig) {
-		return audioTimeConfigRepo.findAll(Example.of(audioTimeConfig));
-	}
-
-	@Override
-	public void deleteByExamIdAndCourseCode(String examId,String courseCode) {
-		audioTimeConfigRepo.deleteByExamIdAndCourseCode(examId,courseCode);
-	}
-
-	@Override
-	public List<AudioTimeConfig> findAudioTimeConfigList(List<AudioTimeConfig> audioTimeConfigModelList) {
-		List<AudioTimeConfig> audioTimeConfigList = new ArrayList<AudioTimeConfig>();
-		for(AudioTimeConfig audioTimeConfig:audioTimeConfigModelList){
-			Paper paper = Model.of(paperRepo.findById(audioTimeConfig.getPaper().getId()));
-	    	//根据试卷查询所有小题
-	    	List<PaperDetailUnit> list = paperDetailUnitRepo.findByPaperOrderByNumber(paper);
-	    	for(PaperDetailUnit paperDetailUnit:list){
-	    		if(paperDetailUnit.getQuestion().getHasAudio() != null 
-	    				&& paperDetailUnit.getQuestion().getHasAudio()){
-	    			quesService.formatQues(paperDetailUnit.getQuestion());
-	    			audioTimeConfigList.add(new AudioTimeConfig(audioTimeConfig.getExamId(),
-	    														audioTimeConfig.getExamName(),
-	    														audioTimeConfig.getGroupCode(),
-	    														audioTimeConfig.getCourseCode(),
-	    														paperDetailUnit));
-	    		}
-	    	}
-		}
-		return audioTimeConfigList;
-	}
-
-	@Override
-	public void addAudioTimeConfig(AudioTimeConfig audioTimeConfig) {
-		audioTimeConfig.setCreateDate(new Date());
-		audioTimeConfigRepo.save(audioTimeConfig);
-	}
-
-	@Override
-	public List<AudioTimeConfig> findAudioTimeConfigByExamId(String examId,String courseCode) {
-		List<AudioTimeConfig> audioTimeConfigList = audioTimeConfigRepo.findByExamIdAndCourseCodeOrderByGroupCode(examId,courseCode);
-		//添加后面成为音频题的设置
-		addAudioTimeConfig(examId,courseCode,audioTimeConfigList);
-		//删除已经不是音频题的设置
-		deleteAudioTimeConfig(audioTimeConfigList);
-		return audioTimeConfigList;
-	}
-	
-	private void addAudioTimeConfig(String examId,String courseCode,List<AudioTimeConfig> audioTimeConfigList){
-		List<String> questionIds = new ArrayList<String>();
-		for(AudioTimeConfig audioTimeConfig:audioTimeConfigList){
-			questionIds.add(audioTimeConfig.getQuestionId());
-		}
-		//添加后面成为音频题的设置
-		ExtractConfig extractConfig = extractConfigService.findConfig(new ExtractConfig(Long.valueOf(examId),courseCode));
-		Map<String,String> paperIdMap = extractConfig.getFinishedPaperIdMap();
-		if(paperIdMap!=null&&paperIdMap.size()>0){
-			Set<Entry<String,String>> entrySet = paperIdMap.entrySet();
-			Iterator<Entry<String,String>> iterator = entrySet.iterator();
-			while(iterator.hasNext()){
-				Entry<String,String> entry = iterator.next();
-				Paper paper =  Model.of(paperRepo.findById(entry.getValue()));
-		    	//根据试卷查询所有小题
-		    	List<PaperDetailUnit> list = paperDetailUnitRepo.findByPaperOrderByNumber(paper);
-		    	for(PaperDetailUnit paperDetailUnit:list){
-		    		if(paperDetailUnit.getQuestion().getHasAudio() != null 
-		    				&& paperDetailUnit.getQuestion().getHasAudio()){
-		    			if(questionIds.contains(paperDetailUnit.getQuestion().getId())){
-		    				continue;
-		    			}
-		    			audioTimeConfigList.add(new AudioTimeConfig(examId,extractConfig.getExamName(),entry.getKey(),courseCode,paperDetailUnit));
-		    		}
-		    	}
-			}
-		}
-	}
-	
-	/**
-	 * 将题目已经不是音频题的对象从集合中删除,并将对象从数据库删除
-	 * @param audioTimeConfigList
-	 */
-	private void deleteAudioTimeConfig(List<AudioTimeConfig> audioTimeConfigList){
-		List<AudioTimeConfig> configs = new ArrayList<AudioTimeConfig>();
-		for(AudioTimeConfig audioTimeConfig : audioTimeConfigList){
-			Question question = audioTimeConfig.getPaperDetailUnit().getQuestion();
-			if(question.getHasAudio()==null||!question.getHasAudio()){
-				configs.add(audioTimeConfig);
-			}
-			quesService.formatQues(audioTimeConfig.getPaperDetailUnit().getQuestion());
-		}
-		audioTimeConfigList.removeAll(configs);
-		audioTimeConfigRepo.deleteAll(configs);
-	}
-
-	@Override
-	public Map<String, String> findAudioTimeConfig(String examId, String courseCode, String groupCode,String paperDetailUnitId) {
-		Map<String, String> map = new HashMap<String, String>();
-		if(StringUtils.isNotBlank(examId)){
-			map.put("errMessage", "examId为空");
-			return map;
-		}
-		if(StringUtils.isNotBlank(courseCode)){
-			map.put("errMessage", "courseCode为空");
-			return map;
-		}
-		if(StringUtils.isNotBlank(groupCode)){
-			map.put("errMessage", "groupCode为空");
-			return map;
-		}
-		if(StringUtils.isNotBlank(paperDetailUnitId)){
-			map.put("errMessage", "paperDetailUnitId为空");
-			return map;
-		}
-		PaperDetailUnit paperDetailUnit =  Model.of(paperDetailUnitRepo.findById(paperDetailUnitId));
-		AudioTimeConfig audioTime = new AudioTimeConfig();
-		audioTime.setCourseCode(courseCode);
-		audioTime.setExamId(examId);
-		audioTime.setGroupCode(groupCode);
-		audioTime.setPaperDetailUnit(paperDetailUnit);
-		AudioTimeConfig audioTimeConfig =  Model.of(audioTimeConfigRepo.findOne(Example.of(audioTime)));
-	    if(audioTimeConfig == null){
-	    	map.put("errMessage", "音频次数未设置");
-	    	return map;
-	    }
-		Integer playTime = audioTimeConfig.getPlayTime();
-	    map.put("playTime", playTime.toString());
-	    return map;
-	}
-
-	@Override
-	public List<AudioTimeConfig> findUpdateAudioTimeConfigList(List<AudioTimeConfig> audioTimeConfigModelList) {
-		List<AudioTimeConfig> list = findAudioTimeConfigList(audioTimeConfigModelList);
-		List<AudioTimeConfig> newList = new ArrayList<AudioTimeConfig>();
-		if(list != null && list.size()>0){
-			for(AudioTimeConfig audioTimeConfig:list){
-				AudioTimeConfig oldAudioTimeConfig =  Model.of(audioTimeConfigRepo.findOne(Example.of(audioTimeConfig)));
-				if(oldAudioTimeConfig != null){
-					newList.add(oldAudioTimeConfig);
-				}else {
-					newList.add(audioTimeConfig);
-				}
-			}
-			return newList;
-		}
-		return newList;
-	}
+public class AudioTimeConfigServiceImpl implements AudioTimeConfigService {
+
+    @Autowired
+    private AudioTimeConfigRepo audioTimeConfigRepo;
+
+    @Autowired
+    private PaperRepo paperRepo;
+
+    @Autowired
+    private PaperDetailUnitRepo paperDetailUnitRepo;
+
+    @Autowired
+    private QuesService quesService;
+
+    @Autowired
+    private ExtractConfigService extractConfigService;
+
+    @Override
+    public void saveAudioTimeConfig(List<AudioTimeConfig> audioTimeConfigs, User user) {
+        if (audioTimeConfigs != null && audioTimeConfigs.size() > 0) {
+            this.deleteByExamIdAndCourseCode(audioTimeConfigs.get(0).getExamId(), audioTimeConfigs.get(0).getCourseCode());
+            for (AudioTimeConfig audioTimeConfig : audioTimeConfigs) {
+                audioTimeConfig.setCreateDate(new Date());
+                //audioTimeConfig.setCreateUser(user.getName());
+                audioTimeConfig.setCreateUser(user.getDisplayName());
+            }
+            audioTimeConfigRepo.saveAll(audioTimeConfigs);
+        }
+    }
+
+    @Override
+    public List<AudioTimeConfig> findByAudioTimeConfig(AudioTimeConfig audioTimeConfig) {
+        return audioTimeConfigRepo.findAll(Example.of(audioTimeConfig));
+    }
+
+    @Override
+    public void deleteByExamIdAndCourseCode(String examId, String courseCode) {
+        audioTimeConfigRepo.deleteByExamIdAndCourseCode(examId, courseCode);
+    }
+
+    @Override
+    public List<AudioTimeConfig> findAudioTimeConfigList(List<AudioTimeConfig> audioTimeConfigModelList) {
+        List<AudioTimeConfig> audioTimeConfigList = new ArrayList<AudioTimeConfig>();
+        for (AudioTimeConfig audioTimeConfig : audioTimeConfigModelList) {
+            Paper paper = Model.of(paperRepo.findById(audioTimeConfig.getPaper().getId()));
+            //根据试卷查询所有小题
+            List<PaperDetailUnit> list = paperDetailUnitRepo.findByPaperOrderByNumber(paper);
+            for (PaperDetailUnit paperDetailUnit : list) {
+                if (paperDetailUnit.getQuestion().getHasAudio() != null
+                        && paperDetailUnit.getQuestion().getHasAudio()) {
+                    quesService.formatQues(paperDetailUnit.getQuestion());
+                    audioTimeConfigList.add(new AudioTimeConfig(audioTimeConfig.getExamId(),
+                            audioTimeConfig.getExamName(),
+                            audioTimeConfig.getGroupCode(),
+                            audioTimeConfig.getCourseCode(),
+                            paperDetailUnit));
+                }
+            }
+        }
+        return audioTimeConfigList;
+    }
+
+    @Override
+    public void addAudioTimeConfig(AudioTimeConfig audioTimeConfig) {
+        audioTimeConfig.setCreateDate(new Date());
+        audioTimeConfigRepo.save(audioTimeConfig);
+    }
+
+    @Override
+    public List<AudioTimeConfig> findAudioTimeConfigByExamId(String examId, String courseCode) {
+        List<AudioTimeConfig> audioTimeConfigList = audioTimeConfigRepo.findByExamIdAndCourseCodeOrderByGroupCode(examId, courseCode);
+        //添加后面成为音频题的设置
+        addAudioTimeConfig(examId, courseCode, audioTimeConfigList);
+        //删除已经不是音频题的设置
+        deleteAudioTimeConfig(audioTimeConfigList);
+        return audioTimeConfigList;
+    }
+
+    private void addAudioTimeConfig(String examId, String courseCode, List<AudioTimeConfig> audioTimeConfigList) {
+        List<String> questionIds = new ArrayList<String>();
+        for (AudioTimeConfig audioTimeConfig : audioTimeConfigList) {
+            questionIds.add(audioTimeConfig.getQuestionId());
+        }
+        //添加后面成为音频题的设置
+        ExtractConfig extractConfig = extractConfigService.findConfig(new ExtractConfig(Long.valueOf(examId), courseCode));
+        Map<String, String> paperIdMap = extractConfig.getFinishedPaperIdMap();
+        if (paperIdMap != null && paperIdMap.size() > 0) {
+            Set<Entry<String, String>> entrySet = paperIdMap.entrySet();
+            Iterator<Entry<String, String>> iterator = entrySet.iterator();
+            while (iterator.hasNext()) {
+                Entry<String, String> entry = iterator.next();
+                Paper paper = Model.of(paperRepo.findById(entry.getValue()));
+                //根据试卷查询所有小题
+                List<PaperDetailUnit> list = paperDetailUnitRepo.findByPaperOrderByNumber(paper);
+                for (PaperDetailUnit paperDetailUnit : list) {
+                    if (paperDetailUnit.getQuestion().getHasAudio() != null
+                            && paperDetailUnit.getQuestion().getHasAudio()) {
+                        if (questionIds.contains(paperDetailUnit.getQuestion().getId())) {
+                            continue;
+                        }
+                        audioTimeConfigList.add(new AudioTimeConfig(examId, extractConfig.getExamName(), entry.getKey(), courseCode, paperDetailUnit));
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 将题目已经不是音频题的对象从集合中删除,并将对象从数据库删除
+     *
+     * @param audioTimeConfigList
+     */
+    private void deleteAudioTimeConfig(List<AudioTimeConfig> audioTimeConfigList) {
+        List<AudioTimeConfig> configs = new ArrayList<AudioTimeConfig>();
+        for (AudioTimeConfig audioTimeConfig : audioTimeConfigList) {
+            Question question = audioTimeConfig.getPaperDetailUnit().getQuestion();
+            if (question.getHasAudio() == null || !question.getHasAudio()) {
+                configs.add(audioTimeConfig);
+            }
+            quesService.formatQues(audioTimeConfig.getPaperDetailUnit().getQuestion());
+        }
+        audioTimeConfigList.removeAll(configs);
+        audioTimeConfigRepo.deleteAll(configs);
+    }
+
+    @Override
+    public Map<String, String> findAudioTimeConfig(String examId, String courseCode, String groupCode, String paperDetailUnitId) {
+        Map<String, String> map = new HashMap<String, String>();
+        if (StringUtils.isNotBlank(examId)) {
+            map.put("errMessage", "examId为空");
+            return map;
+        }
+        if (StringUtils.isNotBlank(courseCode)) {
+            map.put("errMessage", "courseCode为空");
+            return map;
+        }
+        if (StringUtils.isNotBlank(groupCode)) {
+            map.put("errMessage", "groupCode为空");
+            return map;
+        }
+        if (StringUtils.isNotBlank(paperDetailUnitId)) {
+            map.put("errMessage", "paperDetailUnitId为空");
+            return map;
+        }
+        PaperDetailUnit paperDetailUnit = Model.of(paperDetailUnitRepo.findById(paperDetailUnitId));
+        AudioTimeConfig audioTime = new AudioTimeConfig();
+        audioTime.setCourseCode(courseCode);
+        audioTime.setExamId(examId);
+        audioTime.setGroupCode(groupCode);
+        audioTime.setPaperDetailUnit(paperDetailUnit);
+        AudioTimeConfig audioTimeConfig = Model.of(audioTimeConfigRepo.findOne(Example.of(audioTime)));
+        if (audioTimeConfig == null) {
+            map.put("errMessage", "音频次数未设置");
+            return map;
+        }
+        Integer playTime = audioTimeConfig.getPlayTime();
+        map.put("playTime", playTime.toString());
+        return map;
+    }
+
+    @Override
+    public List<AudioTimeConfig> findUpdateAudioTimeConfigList(List<AudioTimeConfig> audioTimeConfigModelList) {
+        List<AudioTimeConfig> list = findAudioTimeConfigList(audioTimeConfigModelList);
+        List<AudioTimeConfig> newList = new ArrayList<AudioTimeConfig>();
+        if (list != null && list.size() > 0) {
+            for (AudioTimeConfig audioTimeConfig : list) {
+                AudioTimeConfig oldAudioTimeConfig = Model.of(audioTimeConfigRepo.findOne(Example.of(audioTimeConfig)));
+                if (oldAudioTimeConfig != null) {
+                    newList.add(oldAudioTimeConfig);
+                } else {
+                    newList.add(audioTimeConfig);
+                }
+            }
+            return newList;
+        }
+        return newList;
+    }
 
 }

+ 125 - 125
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/CoursePropertyServiceImpl.java

@@ -22,134 +22,134 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.CourseProperty;
 import cn.com.qmth.examcloud.core.questions.service.CoursePropertyService;
 
 /**
- * @describle 课程属性 coursePropertyServiceImpl
  * @author weiwenhai
- * @date   2017.11.2
+ * @describle 课程属性 coursePropertyServiceImpl
+ * @date 2017.11.2
  */
 @Service("coursePropertyService")
-public class CoursePropertyServiceImpl implements CoursePropertyService{
-	
-	@Autowired
-	private CoursePropertyRepo coursePropertyRepo;
-	
-	@Autowired
+public class CoursePropertyServiceImpl implements CoursePropertyService {
+
+    @Autowired
+    private CoursePropertyRepo coursePropertyRepo;
+
+    @Autowired
     CourseCloudService courseCloudService;
 
-	@Override
-	public List<CourseProperty> findAllByOrgId(Long orgId) {
-		List<CourseProperty> courseProperties = coursePropertyRepo.findByOrgId(orgId);
-		return courseProperties;
-	}
-
-	@Override
-	public void saveCourseProperty(CoursePropertyDto coursePropertyDto) throws Exception {
-		coursePropertyDto.setEnable("1");
-		CourseProperty courseProperty = coursePropertyRepo.findByNameAndOrgId(coursePropertyDto.getName(), coursePropertyDto.getOrgId());
-		if(courseProperty != null){
-			throw new Exception("课程属性名已经存在");
-		}
-		courseProperty = new CourseProperty(coursePropertyDto);
-		coursePropertyRepo.save(courseProperty);
-	}
-
-	@Override
-	public Page<CourseProperty> findAllByOrg(CoursePropertyDto coursePropertyDto, Pageable pageable) {
-		Specification<CourseProperty> specification = getSpecification(coursePropertyDto);
-		Page<CourseProperty> coursePropertyies = coursePropertyRepo.findAll(specification, pageable);
-		List<CourseProperty> list = coursePropertyies.getContent();
-		if(list != null && list.size()>0){
-			for(CourseProperty courseProperty:list){
-				GetCourseReq req = new GetCourseReq();
-				req.setId(courseProperty.getCourseId());
-				req.setRootOrgId(Long.valueOf(courseProperty.getOrgId()));
-				GetCourseResp resp = courseCloudService.getCourse(req);
-				courseProperty.setCourseName(resp.getCourseBean().getName());
-			}
-		}
-		return coursePropertyies;
-	}
-
-	private Specification<CourseProperty> getSpecification(CoursePropertyDto coursePropertyDto) {
-		CourseProperty courseProperty = new CourseProperty(coursePropertyDto);
-		Specification<CourseProperty> specification = (root, query, cb) -> {
-		    List<Predicate> predicates = new ArrayList<>();
-		    if(!StringUtils.isEmpty(courseProperty.getOrgId())){
-		    	predicates.add(cb.equal(root.get("orgId"),courseProperty.getOrgId()));
-		    }
-		    if(!StringUtils.isEmpty(courseProperty.getName())){
-		    	predicates.add(cb.like(root.get("name"),"%"+courseProperty.getName()+"%"));
-		    }
-		    if(!StringUtils.isEmpty(courseProperty.getCourseId())){
-		    	predicates.add(cb.equal(root.get("courseId"),courseProperty.getCourseId()));
-		    }
-		    if(!StringUtils.isEmpty(courseProperty.getEnable())){
-		    	predicates.add(cb.equal(root.get("enable"),courseProperty.getEnable()));
-		    }
-		    return cb.and(predicates.toArray(new Predicate[predicates.size()]));
-		};
-		return specification;
-	}
-	
-	@Override
-	public void openCourseProperty(Long id) {
-		CourseProperty courseProperty =  Model.of(coursePropertyRepo.findById(id));
-		courseProperty.setEnable(true);
-		coursePropertyRepo.save(courseProperty);
-	}
-
-	@Override
-	public void closeCourseProperty(Long id) {
-		CourseProperty courseProperty =  Model.of(coursePropertyRepo.findById(id));
-		courseProperty.setEnable(false);
-		coursePropertyRepo.save(courseProperty);
-	}
-
-	@Override
-	public List<CourseProperty> findAllByCourseId(Long courseId) {
-		List<CourseProperty> courseProperties = coursePropertyRepo.findByCourseId(courseId);
-		return courseProperties;
-	}
-
-	@Override
-	public List<CourseProperty> findAllByCourseCode(String code) {
-		List<CourseProperty> courseProperties = coursePropertyRepo.findByCourseCode(code);
-		return courseProperties;
-	}
-
-	@Override
-	public List<CourseProperty> findAllEnable(String code, Boolean enable) {
-		List<CourseProperty> courseProperties = coursePropertyRepo.findByCourseCodeAndEnable(code, true);
-		return courseProperties;
-	}
-
-	@Override
-	public void opensCourseProperty(List<String> idList) {
-		List<Long> ids = new ArrayList<Long>();
-		if(idList != null && idList.size()>0){
-			for(String id:idList){
-				ids.add(Long.parseLong(id));
-			}
-		}
-		List<CourseProperty> courseProperties = coursePropertyRepo.findByIdIn(ids);
-		for(CourseProperty courseProperty:courseProperties){
-			courseProperty.setEnable(true);
-		}
-		coursePropertyRepo.saveAll(courseProperties);
-	}
-
-	@Override
-	public void closesCourseProperty(List<String> idList) {
-		List<Long> ids = new ArrayList<Long>();
-		if(idList != null && idList.size()>0){
-			for(String id:idList){
-				ids.add(Long.parseLong(id));
-			}
-		}
-		List<CourseProperty> courseProperties = coursePropertyRepo.findByIdIn(ids);
-		for(CourseProperty courseProperty:courseProperties){
-			courseProperty.setEnable(false);
-		}
-		coursePropertyRepo.saveAll(courseProperties);
-	}
-	
+    @Override
+    public List<CourseProperty> findAllByOrgId(Long orgId) {
+        List<CourseProperty> courseProperties = coursePropertyRepo.findByOrgId(orgId);
+        return courseProperties;
+    }
+
+    @Override
+    public void saveCourseProperty(CoursePropertyDto coursePropertyDto) throws Exception {
+        coursePropertyDto.setEnable("1");
+        CourseProperty courseProperty = coursePropertyRepo.findByNameAndOrgId(coursePropertyDto.getName(), coursePropertyDto.getOrgId());
+        if (courseProperty != null) {
+            throw new Exception("课程属性名已经存在");
+        }
+        courseProperty = new CourseProperty(coursePropertyDto);
+        coursePropertyRepo.save(courseProperty);
+    }
+
+    @Override
+    public Page<CourseProperty> findAllByOrg(CoursePropertyDto coursePropertyDto, Pageable pageable) {
+        Specification<CourseProperty> specification = getSpecification(coursePropertyDto);
+        Page<CourseProperty> coursePropertyies = coursePropertyRepo.findAll(specification, pageable);
+        List<CourseProperty> list = coursePropertyies.getContent();
+        if (list != null && list.size() > 0) {
+            for (CourseProperty courseProperty : list) {
+                GetCourseReq req = new GetCourseReq();
+                req.setId(courseProperty.getCourseId());
+                req.setRootOrgId(Long.valueOf(courseProperty.getOrgId()));
+                GetCourseResp resp = courseCloudService.getCourse(req);
+                courseProperty.setCourseName(resp.getCourseBean().getName());
+            }
+        }
+        return coursePropertyies;
+    }
+
+    private Specification<CourseProperty> getSpecification(CoursePropertyDto coursePropertyDto) {
+        CourseProperty courseProperty = new CourseProperty(coursePropertyDto);
+        Specification<CourseProperty> specification = (root, query, cb) -> {
+            List<Predicate> predicates = new ArrayList<>();
+            if (!StringUtils.isEmpty(courseProperty.getOrgId())) {
+                predicates.add(cb.equal(root.get("orgId"), courseProperty.getOrgId()));
+            }
+            if (!StringUtils.isEmpty(courseProperty.getName())) {
+                predicates.add(cb.like(root.get("name"), "%" + courseProperty.getName() + "%"));
+            }
+            if (!StringUtils.isEmpty(courseProperty.getCourseId())) {
+                predicates.add(cb.equal(root.get("courseId"), courseProperty.getCourseId()));
+            }
+            if (!StringUtils.isEmpty(courseProperty.getEnable())) {
+                predicates.add(cb.equal(root.get("enable"), courseProperty.getEnable()));
+            }
+            return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+        };
+        return specification;
+    }
+
+    @Override
+    public void openCourseProperty(Long id) {
+        CourseProperty courseProperty = Model.of(coursePropertyRepo.findById(id));
+        courseProperty.setEnable(true);
+        coursePropertyRepo.save(courseProperty);
+    }
+
+    @Override
+    public void closeCourseProperty(Long id) {
+        CourseProperty courseProperty = Model.of(coursePropertyRepo.findById(id));
+        courseProperty.setEnable(false);
+        coursePropertyRepo.save(courseProperty);
+    }
+
+    @Override
+    public List<CourseProperty> findAllByCourseId(Long courseId) {
+        List<CourseProperty> courseProperties = coursePropertyRepo.findByCourseId(courseId);
+        return courseProperties;
+    }
+
+    @Override
+    public List<CourseProperty> findAllByCourseCode(String code) {
+        List<CourseProperty> courseProperties = coursePropertyRepo.findByCourseCode(code);
+        return courseProperties;
+    }
+
+    @Override
+    public List<CourseProperty> findAllEnable(String code, Boolean enable) {
+        List<CourseProperty> courseProperties = coursePropertyRepo.findByCourseCodeAndEnable(code, true);
+        return courseProperties;
+    }
+
+    @Override
+    public void opensCourseProperty(List<String> idList) {
+        List<Long> ids = new ArrayList<Long>();
+        if (idList != null && idList.size() > 0) {
+            for (String id : idList) {
+                ids.add(Long.parseLong(id));
+            }
+        }
+        List<CourseProperty> courseProperties = coursePropertyRepo.findByIdIn(ids);
+        for (CourseProperty courseProperty : courseProperties) {
+            courseProperty.setEnable(true);
+        }
+        coursePropertyRepo.saveAll(courseProperties);
+    }
+
+    @Override
+    public void closesCourseProperty(List<String> idList) {
+        List<Long> ids = new ArrayList<Long>();
+        if (idList != null && idList.size() > 0) {
+            for (String id : idList) {
+                ids.add(Long.parseLong(id));
+            }
+        }
+        List<CourseProperty> courseProperties = coursePropertyRepo.findByIdIn(ids);
+        for (CourseProperty courseProperty : courseProperties) {
+            courseProperty.setEnable(false);
+        }
+        coursePropertyRepo.saveAll(courseProperties);
+    }
+
 }

+ 28 - 28
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/CourseService.java

@@ -12,35 +12,35 @@ import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
 import cn.com.qmth.examcloud.core.questions.dao.entity.Course;
 
 /**
- * @author 		weiwenhai
- * @date 		2018.9.28
- * @company		qmth
- * @description	课程对象转换
+ * @author weiwenhai
+ * @date 2018.9.28
+ * @company qmth
+ * @description 课程对象转换
  */
 @Service
 public class CourseService {
-	
-	
-	@Autowired
-	CourseCloudService courseCloudService;
-	
-	public Course getCourse(Long orgId,String courseCode){
-		GetCourseReq req = new GetCourseReq();
-		req.setRootOrgId(orgId);
-		req.setCode(courseCode);
-		GetCourseResp resp = courseCloudService.getCourse(req);
-		CourseBean courseBean = resp.getCourseBean();
-		Course course = new Course();
-		BeanUtils.copyProperties(courseBean, course);
-		if(courseBean.getEnable()){
-			course.setEnable("true");
-		}else {
-			course.setEnable("false");
-		}
-		course.setId(courseBean.getId()+"");
-		course.setOrgId(courseBean.getRootOrgId()+"");
-		course.setCreateTime(CommonUtils.getCurDateTime());
-		return course;
-	}
-	
+
+
+    @Autowired
+    CourseCloudService courseCloudService;
+
+    public Course getCourse(Long orgId, String courseCode) {
+        GetCourseReq req = new GetCourseReq();
+        req.setRootOrgId(orgId);
+        req.setCode(courseCode);
+        GetCourseResp resp = courseCloudService.getCourse(req);
+        CourseBean courseBean = resp.getCourseBean();
+        Course course = new Course();
+        BeanUtils.copyProperties(courseBean, course);
+        if (courseBean.getEnable()) {
+            course.setEnable("true");
+        } else {
+            course.setEnable("false");
+        }
+        course.setId(courseBean.getId() + "");
+        course.setOrgId(courseBean.getRootOrgId() + "");
+        course.setCreateTime(CommonUtils.getCurDateTime());
+        return course;
+    }
+
 }

+ 77 - 76
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExamFileServiceImpl.java

@@ -3,6 +3,7 @@ package cn.com.qmth.examcloud.core.questions.service.impl;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+
 import main.java.com.UpYun;
 
 import org.apache.commons.lang3.StringUtils;
@@ -21,91 +22,91 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.ExamFile;
 import cn.com.qmth.examcloud.core.questions.service.ExamFileService;
 
 /**
- * @author  	chenken
- * @date    	2017年7月13日 下午4:48:02
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年7月13日 下午4:48:02
+ * @company QMTH
  * @description ExamFileServiceImpl.java
  */
 @Service("examFileService")
-public class ExamFileServiceImpl implements ExamFileService{
-
-	@Autowired
-	private ExamFileRepo examFileRepo;
-	@Autowired
-	private MongoTemplate MongoTemplate;
-	
-	@Value("${$upyun.site.2.bucketName}")
-	protected String bucketName;
-	
-	@Value("${$upyun.site.2.userName}")
-	protected String userName;
-	
-	@Value("${$upyun.site.2.password}")
-	protected String password;
-	
-	@Override
-	public void saveExamFiles(List<ExamFile> examFileList,User accessUser){
-		for(ExamFile examFile:examFileList){
-			saveExamFile(examFile,accessUser);
-		}
-	}
-
-	@Override
-	public List<ExamFile> findExamFileListByExamFile(ExamFile examFile) {
-		return examFileRepo.findAll(Example.of(examFile));
-	}
-
-	@Override
-	public void saveExamFile(ExamFile examFile, User accessUser) {
-		examFile.setCreateTime(new Date());
-		examFile.setCreateUser(accessUser.getDisplayName());
-		examFileRepo.save(examFile);
-	}
-
-	@Override
-	public List<ExamFile> findExamFileListByExportPaperInfoModel(ExportPaperInfoModel exportPaperInfoModel) {
-		Query query = new Query();
-		if(StringUtils.isBlank(exportPaperInfoModel.getExamId())){
-			throw new RuntimeException("考试ID不能为空");
-		}
-		query.addCriteria(Criteria.where("examId").is(exportPaperInfoModel.getExamId()));
-		if(StringUtils.isNotBlank(exportPaperInfoModel.getCourseId())){
-			query.addCriteria(Criteria.where("courseId").is(exportPaperInfoModel.getCourseId()));
-		}
-		List<String> exportContentList = exportPaperInfoModel.getExportContentList();
-		//批量导出时,不直接导出试卷结构
+public class ExamFileServiceImpl implements ExamFileService {
+
+    @Autowired
+    private ExamFileRepo examFileRepo;
+    @Autowired
+    private MongoTemplate MongoTemplate;
+
+    @Value("${$upyun.site.2.bucketName}")
+    protected String bucketName;
+
+    @Value("${$upyun.site.2.userName}")
+    protected String userName;
+
+    @Value("${$upyun.site.2.password}")
+    protected String password;
+
+    @Override
+    public void saveExamFiles(List<ExamFile> examFileList, User accessUser) {
+        for (ExamFile examFile : examFileList) {
+            saveExamFile(examFile, accessUser);
+        }
+    }
+
+    @Override
+    public List<ExamFile> findExamFileListByExamFile(ExamFile examFile) {
+        return examFileRepo.findAll(Example.of(examFile));
+    }
+
+    @Override
+    public void saveExamFile(ExamFile examFile, User accessUser) {
+        examFile.setCreateTime(new Date());
+        examFile.setCreateUser(accessUser.getDisplayName());
+        examFileRepo.save(examFile);
+    }
+
+    @Override
+    public List<ExamFile> findExamFileListByExportPaperInfoModel(ExportPaperInfoModel exportPaperInfoModel) {
+        Query query = new Query();
+        if (StringUtils.isBlank(exportPaperInfoModel.getExamId())) {
+            throw new RuntimeException("考试ID不能为空");
+        }
+        query.addCriteria(Criteria.where("examId").is(exportPaperInfoModel.getExamId()));
+        if (StringUtils.isNotBlank(exportPaperInfoModel.getCourseId())) {
+            query.addCriteria(Criteria.where("courseId").is(exportPaperInfoModel.getCourseId()));
+        }
+        List<String> exportContentList = exportPaperInfoModel.getExportContentList();
+        //批量导出时,不直接导出试卷结构
 		/*if(exportPaperInfoModel.getExportWay()==ExportWay.BATCH){
 			exportContentList.remove(ExamFileType.PAPER_STRUCTURE_OBJECTIVE.name());
 			exportContentList.remove(ExamFileType.PAPER_STRUCTURE_SUBJECTIVE.name());
 		}*/
-		if(exportContentList.size()>0){
-			List<String> examFileTypes = new ArrayList<String>();
-			for(int i = 0;i<exportContentList.size();i++){
-				examFileTypes.add(exportContentList.get(i));
-			}
-			query.addCriteria(Criteria.where("examFileType").in(examFileTypes));
-		}else{
-			return null;
-		}
-		return this.MongoTemplate.find(query, ExamFile.class);
-	}
-
-	@Override
-	public void deleteExamFile(ExamFile examFile) {
+        if (exportContentList.size() > 0) {
+            List<String> examFileTypes = new ArrayList<String>();
+            for (int i = 0; i < exportContentList.size(); i++) {
+                examFileTypes.add(exportContentList.get(i));
+            }
+            query.addCriteria(Criteria.where("examFileType").in(examFileTypes));
+        } else {
+            return null;
+        }
+        return this.MongoTemplate.find(query, ExamFile.class);
+    }
+
+    @Override
+    public void deleteExamFile(ExamFile examFile) {
 //		Example example=Example.of(examFile);
 //		List<ExamFile> examFiles = examFileRepo.findAll(example);
-		Query query=new Query();
-		query.addCriteria(Criteria.where("orgId").is(examFile.getOrgId()));
-		query.addCriteria(Criteria.where("examId").is(examFile.getExamId()));
-		query.addCriteria(Criteria.where("courseId").is(examFile.getCourseId()));
-		List<ExamFile> examFiles = MongoTemplate.find(query,ExamFile.class);
-		UpYun upyun = new UpYun(bucketName,userName,password);
-		for(ExamFile examFile2:examFiles){
-			//删除又拍云上的文件
-			upyun.deleteFile(examFile2.getFilePath());
-		}
-		examFileRepo.deleteAll(examFiles);
-	}
+        Query query = new Query();
+        query.addCriteria(Criteria.where("orgId").is(examFile.getOrgId()));
+        query.addCriteria(Criteria.where("examId").is(examFile.getExamId()));
+        query.addCriteria(Criteria.where("courseId").is(examFile.getCourseId()));
+        List<ExamFile> examFiles = MongoTemplate.find(query, ExamFile.class);
+        UpYun upyun = new UpYun(bucketName, userName, password);
+        for (ExamFile examFile2 : examFiles) {
+            //删除又拍云上的文件
+            upyun.deleteFile(examFile2.getFilePath());
+        }
+        examFileRepo.deleteAll(examFiles);
+    }
 
 }
 

+ 151 - 150
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExportPaperServiceImpl.java

@@ -57,14 +57,14 @@ import java.util.stream.Collectors;
 
 @Service("exportPaperService")
 public class ExportPaperServiceImpl implements ExportPaperService {
-	
-	protected ExamCloudLog log = ExamCloudLogFactory.getLog(this.getClass());
+
+    protected ExamCloudLog log = ExamCloudLogFactory.getLog(this.getClass());
 
     public static final String TEMP_FILE_EXP = "docxExport/";
 
     public static final String TEMP_FILE_NAME = "_考试说明.docx";
-    
-	public static final String DOCX_SUFFIX = ".docx";
+
+    public static final String DOCX_SUFFIX = ".docx";
 
     @Autowired
     private PaperRepo paperRepo;
@@ -89,12 +89,12 @@ public class ExportPaperServiceImpl implements ExportPaperService {
 
     @Autowired
     private PrintExamPaperService printExamPaperService;
-    
+
     @Autowired
     private PaperDetailUnitRepo paperDetailUnitRepo;
-    
+
     @Autowired
-	protected QuesPkgPathRepo quesPkgPathRepo;
+    protected QuesPkgPathRepo quesPkgPathRepo;
 
     @Value("${$upyun.site.2.bucketName}")
     protected String bucketName;
@@ -142,10 +142,10 @@ public class ExportPaperServiceImpl implements ExportPaperService {
         FileDisposeUtil.fileToZip(TEMP_FILE_EXP + File.separator + zipFileName, TEMP_FILE_EXP, zipFileName);
         FileDisposeUtil.downloadFile(paper.getName() + "_" + paper.getCourse().getCode() + ".zip", TEMP_FILE_EXP + File.separator + zipFileName + ".zip", response);
         long endTime = System.currentTimeMillis();
-        log.debug("下载zip耗时:"+ (endTime - startTime)+"ms");
+        log.debug("下载zip耗时:" + (endTime - startTime) + "ms");
         deteleFolder(TEMP_FILE_EXP, zipFileName);
         long deleteTime = System.currentTimeMillis();
-        log.debug("删除文件耗时:"+ (deleteTime - endTime)+"ms");
+        log.debug("删除文件耗时:" + (deleteTime - endTime) + "ms");
     }
 
     /**
@@ -155,7 +155,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
      * @throws Exception
      */
     @SuppressWarnings("unused")
-	private void downExamRemark(Paper paper, String zipFileName) throws Exception {
+    private void downExamRemark(Paper paper, String zipFileName) throws Exception {
         //1.考试说明html转成word
         String title = "<p style=\"text-align:center\"><span style=\"font-size:26px\"><span style=\"font-family:宋体\">考&nbsp;试&nbsp;说&nbsp;明</span></span></p>";
         WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
@@ -213,7 +213,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
                                 for (Block block : blocks) {
                                     if (block.getType().equals("audio")) {
                                         String id = block.getValue();
-                                        QuestionAudio questionAudio =  Model.of(questionAudioRepo.findById(id));
+                                        QuestionAudio questionAudio = Model.of(questionAudioRepo.findById(id));
                                         String audioFileName = questionAudio.getId() + "_" +
                                                 detail.getNumber() + "_" + question.getNumber() +
                                                 "_1_" + bodyNum + "." + questionAudio.getFileSuffixes();
@@ -240,7 +240,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
                                             for (Block block : blocks) {
                                                 if (block.getType().equals("audio")) {
                                                     String id = block.getValue();
-                                                    QuestionAudio questionAudio =  Model.of(questionAudioRepo.findById(id));
+                                                    QuestionAudio questionAudio = Model.of(questionAudioRepo.findById(id));
                                                     String audioFileName = questionAudio.getId() + "_" +
                                                             detail.getNumber() + "_" + question.getNumber() +
                                                             "_2_" + computerTestOption.getNumber() + "_" + optionNum + "." + questionAudio.getFileSuffixes();
@@ -285,11 +285,11 @@ public class ExportPaperServiceImpl implements ExportPaperService {
                 //设置小题题号
                 computerTestQuestion.setNumber(i + 1);
                 //得到小题题干
-                computerTestQuestion.setBody(getBodyOrAnswer(paperDetailUnit.getQuestion().getQuesBody(),computerTestPaper));
+                computerTestQuestion.setBody(getBodyOrAnswer(paperDetailUnit.getQuestion().getQuesBody(), computerTestPaper));
                 //得到小题所有选项
-                computerTestQuestion.setOptions(getOption(paperDetailUnit.getQuestion(),computerTestPaper));
+                computerTestQuestion.setOptions(getOption(paperDetailUnit.getQuestion(), computerTestPaper));
                 //得到小题的答案
-                computerTestQuestion.setAnswer(getBodyOrAnswer(paperDetailUnit.getQuestion().getQuesAnswer(),computerTestPaper));
+                computerTestQuestion.setAnswer(getBodyOrAnswer(paperDetailUnit.getQuestion().getQuesAnswer(), computerTestPaper));
                 //查询小题中的 套题
                 List<Question> subQuestionsList = paperDetailUnit.getQuestion().getSubQuestions();
                 //判断这个小题中是否有套题
@@ -301,9 +301,9 @@ public class ExportPaperServiceImpl implements ExportPaperService {
                         ComputerTestQuestion subcomputerTestQuestion = new ComputerTestQuestion(subQuestion);
                         //设置套题中小题题号
                         subcomputerTestQuestion.setNumber(j + 1);
-                        subcomputerTestQuestion.setBody(getBodyOrAnswer(subQuestion.getQuesBody(),computerTestPaper));
-                        subcomputerTestQuestion.setOptions(getOption(subQuestion,computerTestPaper));
-                        subcomputerTestQuestion.setAnswer(getBodyOrAnswer(subQuestion.getQuesAnswer(),computerTestPaper));
+                        subcomputerTestQuestion.setBody(getBodyOrAnswer(subQuestion.getQuesBody(), computerTestPaper));
+                        subcomputerTestQuestion.setOptions(getOption(subQuestion, computerTestPaper));
+                        subcomputerTestQuestion.setAnswer(getBodyOrAnswer(subQuestion.getQuesAnswer(), computerTestPaper));
                         subQuestions.add(subcomputerTestQuestion);
                     }
                     computerTestQuestion.setSubQuestions(subQuestions);
@@ -319,7 +319,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
         return computerTestPaper;
     }
 
-    private Sections getBodyOrAnswer(String str,ComputerTestPaper computerTestPaper) {
+    private Sections getBodyOrAnswer(String str, ComputerTestPaper computerTestPaper) {
         Sections body = new Sections();
         List<Section> sections = new ArrayList<Section>();
         //得到小题题干或者答案行数
@@ -328,7 +328,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
         }
         String[] questionRowStrings = str.split("</p>");
         for (int i = 0; i < questionRowStrings.length; i++) {
-            List<Block> blocks = disposeQuestionBodyOrOption(questionRowStrings[i],computerTestPaper);
+            List<Block> blocks = disposeQuestionBodyOrOption(questionRowStrings[i], computerTestPaper);
             if (blocks != null && blocks.size() > 0) {
                 Section section = new Section();
                 //将小题题干拆分为Block集合
@@ -340,7 +340,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
         return body;
     }
 
-    private List<ComputerTestOption> getOption(Question question,ComputerTestPaper computerTestPaper) {
+    private List<ComputerTestOption> getOption(Question question, ComputerTestPaper computerTestPaper) {
         //得到小题选项
         List<QuesOption> quesOptions = question.getQuesOptions();
         List<ComputerTestOption> options = new ArrayList<ComputerTestOption>();
@@ -357,7 +357,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
                 String optionString = quesOption.getOptionBody();
                 String[] optionStrings = optionString.split("</p>");
                 for (int i = 0; i < optionStrings.length; i++) {
-                    List<Block> blocks = disposeQuestionBodyOrOption(optionStrings[i],computerTestPaper);
+                    List<Block> blocks = disposeQuestionBodyOrOption(optionStrings[i], computerTestPaper);
                     if (blocks != null && blocks.size() > 0) {
                         Section section = new Section();
                         section.setBlocks(blocks);
@@ -372,7 +372,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
         return options;
     }
 
-    private List<Block> disposeQuestionBodyOrOption(String questionRow,ComputerTestPaper computerTestPaper) {
+    private List<Block> disposeQuestionBodyOrOption(String questionRow, ComputerTestPaper computerTestPaper) {
         List<Block> blocks = new ArrayList<Block>();
         //去掉每行里面的<p>,<span>,</span>标签
         questionRow = questionRow.replaceAll("<p>", "")
@@ -433,8 +433,8 @@ public class ExportPaperServiceImpl implements ExportPaperService {
                 }
             }
         }
-        if(hasAudio){
-        	computerTestPaper.setHasVideo(1);
+        if (hasAudio) {
+            computerTestPaper.setHasVideo(1);
         }
         return blocks;
     }
@@ -489,7 +489,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
     }
 
     @SuppressWarnings("unused")
-	@Override
+    @Override
     public void exportPaperFiles(List<String> paperIds, String serviceName, String exportContentList, HttpServletResponse response, String loginName, String examType) throws Exception {
         ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils.getBeanById(serviceName);
         //根据试卷id查询所有试卷
@@ -600,7 +600,7 @@ public class ExportPaperServiceImpl implements ExportPaperService {
      * @throws IOException
      */
     @SuppressWarnings("resource")
-	private void writeExcel(List<QuestionDistributeDto> questionDistributeDtos, int cloumnCount, String courseNo, HttpServletResponse response) throws IOException {
+    private void writeExcel(List<QuestionDistributeDto> questionDistributeDtos, int cloumnCount, String courseNo, HttpServletResponse response) throws IOException {
         //读取Excel模板
         InputStream in = this.getClass().getResourceAsStream("/quesDistinct.xlsx");
         Workbook workBook = new XSSFWorkbook(in);
@@ -719,148 +719,149 @@ public class ExportPaperServiceImpl implements ExportPaperService {
         List<Question> questionList = this.mongoTemplate.find(query, Question.class);
         return questionList;
     }
-    
-    public List<Question> questionList2(String courseNo, CourseProperty courseProperty, QuesStructType quesStructType, Property parentProperty, Property sonProperty,List<Question> questions) {
-    	List<Question> questionList = new ArrayList<Question>();
-    	String id = courseNo + quesStructType.name() + courseProperty.getName();
-    	//二级属性不为空,那么一级属性也不为空
+
+    public List<Question> questionList2(String courseNo, CourseProperty courseProperty, QuesStructType quesStructType, Property parentProperty, Property sonProperty, List<Question> questions) {
+        List<Question> questionList = new ArrayList<Question>();
+        String id = courseNo + quesStructType.name() + courseProperty.getName();
+        //二级属性不为空,那么一级属性也不为空
         if (sonProperty != null && sonProperty.getId() != null) {
             id = id + parentProperty.getId() + sonProperty.getId();
         } else {
             if (parentProperty != null && parentProperty.getId() != null) {
-            	id = id + parentProperty.getId();
+                id = id + parentProperty.getId();
             }
         }
-        for(Question question:questions){
-        	List<String> idStrings = new ArrayList<String>();
-        	String id_Q = question.getCourseNo() + question.getQuestionType();
-        	List<QuesProperty> quesProperties = question.getQuesProperties();
-        	if(quesProperties != null && quesProperties.size()>0){
-        		for(QuesProperty property:quesProperties){
-            		String idP = id_Q + property.getCoursePropertyName() + property.getFirstProperty().getId();
-            		if(property.getSecondProperty() != null){
-            			idP = id_Q + property.getCoursePropertyName() + property.getFirstProperty().getId() + property.getSecondProperty().getId();
-            		}
-            		idStrings.add(idP);
-            	}
-        		if(idStrings.contains(id)){
-        			questionList.add(question);
-        		}
-        	}
+        for (Question question : questions) {
+            List<String> idStrings = new ArrayList<String>();
+            String id_Q = question.getCourseNo() + question.getQuestionType();
+            List<QuesProperty> quesProperties = question.getQuesProperties();
+            if (quesProperties != null && quesProperties.size() > 0) {
+                for (QuesProperty property : quesProperties) {
+                    String idP = id_Q + property.getCoursePropertyName() + property.getFirstProperty().getId();
+                    if (property.getSecondProperty() != null) {
+                        idP = id_Q + property.getCoursePropertyName() + property.getFirstProperty().getId() + property.getSecondProperty().getId();
+                    }
+                    idStrings.add(idP);
+                }
+                if (idStrings.contains(id)) {
+                    questionList.add(question);
+                }
+            }
         }
         return questionList;
     }
 
-	@Override
-	public void downOriginalPaper(String paperId, String loginName, HttpServletResponse response) throws Exception {
-		//生成导出的试卷对象
-		PaperExp paperExp = paperService.getDownPaperExp(paperId);
-		String zipFileName = loginName + System.currentTimeMillis() + "";
-	    File directory = new File(TEMP_FILE_EXP + File.separator + zipFileName);
-	    if (!directory.exists()) {
-	    	directory.mkdirs();
-	    }
-		String paperfileName = paperExp.getName()+"_"+paperExp.getCourseNo()+"_"+ExamFileType.PAPER.getName()+DOCX_SUFFIX;
-		File file = new File(TEMP_FILE_EXP+File.separator+zipFileName+File.separator+paperfileName);
-		List<WordprocessingMLPackage> wordPackages = getPkgList(paperId);
-		DocxProcessUtil.exportWordNew(paperExp, file,ExportPaperAbstractService.ORIGINAL_PAPER);
-		DocxProcessUtil.processImage(zipFileName+File.separator+paperfileName,wordPackages);
-		FileDisposeUtil.fileToZip(TEMP_FILE_EXP + File.separator + zipFileName, TEMP_FILE_EXP, zipFileName);
+    @Override
+    public void downOriginalPaper(String paperId, String loginName, HttpServletResponse response) throws Exception {
+        //生成导出的试卷对象
+        PaperExp paperExp = paperService.getDownPaperExp(paperId);
+        String zipFileName = loginName + System.currentTimeMillis() + "";
+        File directory = new File(TEMP_FILE_EXP + File.separator + zipFileName);
+        if (!directory.exists()) {
+            directory.mkdirs();
+        }
+        String paperfileName = paperExp.getName() + "_" + paperExp.getCourseNo() + "_" + ExamFileType.PAPER.getName() + DOCX_SUFFIX;
+        File file = new File(TEMP_FILE_EXP + File.separator + zipFileName + File.separator + paperfileName);
+        List<WordprocessingMLPackage> wordPackages = getPkgList(paperId);
+        DocxProcessUtil.exportWordNew(paperExp, file, ExportPaperAbstractService.ORIGINAL_PAPER);
+        DocxProcessUtil.processImage(zipFileName + File.separator + paperfileName, wordPackages);
+        FileDisposeUtil.fileToZip(TEMP_FILE_EXP + File.separator + zipFileName, TEMP_FILE_EXP, zipFileName);
         FileDisposeUtil.downloadFile(paperExp.getName() + "_" + paperExp.getCourse().getCode() + ".zip", TEMP_FILE_EXP + File.separator + zipFileName + ".zip", response);
         deteleFolder(TEMP_FILE_EXP, zipFileName);
-	}
-	
-	/**
+    }
+
+    /**
      * 获取当前试卷下所有试题WordPkg
+     *
      * @param id
      * @return
      */
-    protected List<WordprocessingMLPackage> getPkgList(String id){
-        Paper paper =  Model.of(paperRepo.findById(id));
+    protected List<WordprocessingMLPackage> getPkgList(String id) {
+        Paper paper = Model.of(paperRepo.findById(id));
         List<WordprocessingMLPackage> wordMLPackages = paperDetailUnitRepo.findByPaperOrderByNumber(paper)
                 .stream().map(PaperDetailUnit::getQuestion).collect(Collectors.toList())
                 .stream().map(question -> getPkgObj(question)).collect(Collectors.toList());
         return wordMLPackages;
     }
-    
-    private WordprocessingMLPackage getPkgObj(Question question){
-		String pkgPathId = question.getQuesPkgPathId();
-		QuestionPkgPath quesPkg = quesPkgPathRepo.findFirstById(pkgPathId);
-		if(quesPkg == null){
-			 byte[] bytes=new byte[0];
-			return DocxProcessUtil.getPkg(bytes);
-		}
-		byte[] pkgByte = quesPkg.getQuesPkg();
-		return DocxProcessUtil.getPkg(pkgByte);
-	}
-
-	@Override
-	public void downQuestionDistributeByPapers(String paperIds, HttpServletResponse response) throws IOException {
-		List<QuestionDistributeDto> questionDistributeDtos = new ArrayList<QuestionDistributeDto>();
-		//定义课程集合
-		List<String> courseNos = new ArrayList<String>();
-		//定义试题集合
-		List<Question> questions = new ArrayList<Question>();
-		// 查询试卷集合
-		String[] paperIdArray = paperIds.split(",");
-		for (int i = 0; i < paperIdArray.length; i++) {
-			Paper basePaper = Model.of( paperRepo.findById(paperIdArray[i]));
-			courseNos.add(basePaper.getCourse().getCode());
-			//将小题全部取出来,只取一次,减少对数据库的查询
-			List<PaperDetailUnit> allPaperDetailUnits = paperDetailUnitRepo.findByPaper(basePaper);
-			for(PaperDetailUnit unit:allPaperDetailUnits){
-				if(unit.getQuestionType().equals(QuesStructType.SINGLE_ANSWER_QUESTION)||unit.getQuestionType().equals(QuesStructType.MULTIPLE_ANSWER_QUESTION)||unit.getQuestionType().equals(QuesStructType.BOOL_ANSWER_QUESTION)){
-					questions.add(unit.getQuestion());
-				}
-			}
-		}
-		 //根据课程code查询课程属性集合
-		for(String courseNo:courseNos){
-			List<CourseProperty> courseProperties = coursePropertyRepo.findByCourseCodeAndEnable(courseNo, true);
-			//遍历课程属性集合,根据课程属性查询一级
-	        if (courseProperties != null && courseProperties.size() > 0) {
-	            for (CourseProperty courseProperty : courseProperties) {
-	                List<Property> parentProperties = propertyService.findPropertyParents(courseProperty.getId(), courseProperty.getOrgId());
-	                if (parentProperties != null && parentProperties.size() > 0) {
-	                    for (Property parentProperty : parentProperties) {
-	                        List<Property> sonProperties = propertyService.findPropertySons(parentProperty.getId());
-	                        if (sonProperties != null && sonProperties.size() > 0) {
-	                            for (Property sonProperty : sonProperties) {
-	                                //单选题集合
-	                                List<Question> sinList = questionList2(courseNo, courseProperty, QuesStructType.SINGLE_ANSWER_QUESTION, parentProperty, sonProperty,questions);
-	                                //多选题集合
-	                                List<Question> mulList = questionList2(courseNo, courseProperty, QuesStructType.MULTIPLE_ANSWER_QUESTION, parentProperty, sonProperty,questions);
-	                                //判断题集合
-	                                List<Question> bolList = questionList2(courseNo, courseProperty, QuesStructType.BOOL_ANSWER_QUESTION, parentProperty, sonProperty,questions);
-	                                //计算所有题型数量
-	                                Map<Long, Long> map = countQuesType(sinList, mulList, bolList);
-	                                QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(courseProperty.getName(), parentProperty.getName(), sonProperty.getName(), map);
-	                                questionDistributeDtos.add(questionDistributeDto);
-	                            }
-	                        } else {
-	                            //一级属性不为空,二级属性为空
-	                            //单选题集合
-	                            List<Question> sinList = questionList2(courseNo, courseProperty, QuesStructType.SINGLE_ANSWER_QUESTION, parentProperty, null,questions);
-	                            //多选题集合
-	                            List<Question> mulList = questionList2(courseNo, courseProperty, QuesStructType.MULTIPLE_ANSWER_QUESTION, parentProperty, null,questions);
-	                            //判断题集合
-	                            List<Question> bolList = questionList2(courseNo, courseProperty, QuesStructType.BOOL_ANSWER_QUESTION, parentProperty, null,questions);
-	                            //计算所有题型数量
-	                            Map<Long, Long> map = countQuesType(sinList, mulList, bolList);
-	                            QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(courseProperty.getName(), parentProperty.getName(), null, map);
-	                            questionDistributeDtos.add(questionDistributeDto);
-	                        }
-	                    }
-	                } else {
-	                    //一级属性为空
-	                    QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(courseProperty.getName(), null, null, null);
-	                    questionDistributeDtos.add(questionDistributeDto);
-	                }
-	            }
-	        }
-	        //生成Excel导出
-	        writeExcel(questionDistributeDtos, 21, new Date().toString(), response);
-		}
-	}
-	
+
+    private WordprocessingMLPackage getPkgObj(Question question) {
+        String pkgPathId = question.getQuesPkgPathId();
+        QuestionPkgPath quesPkg = quesPkgPathRepo.findFirstById(pkgPathId);
+        if (quesPkg == null) {
+            byte[] bytes = new byte[0];
+            return DocxProcessUtil.getPkg(bytes);
+        }
+        byte[] pkgByte = quesPkg.getQuesPkg();
+        return DocxProcessUtil.getPkg(pkgByte);
+    }
+
+    @Override
+    public void downQuestionDistributeByPapers(String paperIds, HttpServletResponse response) throws IOException {
+        List<QuestionDistributeDto> questionDistributeDtos = new ArrayList<QuestionDistributeDto>();
+        //定义课程集合
+        List<String> courseNos = new ArrayList<String>();
+        //定义试题集合
+        List<Question> questions = new ArrayList<Question>();
+        // 查询试卷集合
+        String[] paperIdArray = paperIds.split(",");
+        for (int i = 0; i < paperIdArray.length; i++) {
+            Paper basePaper = Model.of(paperRepo.findById(paperIdArray[i]));
+            courseNos.add(basePaper.getCourse().getCode());
+            //将小题全部取出来,只取一次,减少对数据库的查询
+            List<PaperDetailUnit> allPaperDetailUnits = paperDetailUnitRepo.findByPaper(basePaper);
+            for (PaperDetailUnit unit : allPaperDetailUnits) {
+                if (unit.getQuestionType().equals(QuesStructType.SINGLE_ANSWER_QUESTION) || unit.getQuestionType().equals(QuesStructType.MULTIPLE_ANSWER_QUESTION) || unit.getQuestionType().equals(QuesStructType.BOOL_ANSWER_QUESTION)) {
+                    questions.add(unit.getQuestion());
+                }
+            }
+        }
+        //根据课程code查询课程属性集合
+        for (String courseNo : courseNos) {
+            List<CourseProperty> courseProperties = coursePropertyRepo.findByCourseCodeAndEnable(courseNo, true);
+            //遍历课程属性集合,根据课程属性查询一级
+            if (courseProperties != null && courseProperties.size() > 0) {
+                for (CourseProperty courseProperty : courseProperties) {
+                    List<Property> parentProperties = propertyService.findPropertyParents(courseProperty.getId(), courseProperty.getOrgId());
+                    if (parentProperties != null && parentProperties.size() > 0) {
+                        for (Property parentProperty : parentProperties) {
+                            List<Property> sonProperties = propertyService.findPropertySons(parentProperty.getId());
+                            if (sonProperties != null && sonProperties.size() > 0) {
+                                for (Property sonProperty : sonProperties) {
+                                    //单选题集合
+                                    List<Question> sinList = questionList2(courseNo, courseProperty, QuesStructType.SINGLE_ANSWER_QUESTION, parentProperty, sonProperty, questions);
+                                    //多选题集合
+                                    List<Question> mulList = questionList2(courseNo, courseProperty, QuesStructType.MULTIPLE_ANSWER_QUESTION, parentProperty, sonProperty, questions);
+                                    //判断题集合
+                                    List<Question> bolList = questionList2(courseNo, courseProperty, QuesStructType.BOOL_ANSWER_QUESTION, parentProperty, sonProperty, questions);
+                                    //计算所有题型数量
+                                    Map<Long, Long> map = countQuesType(sinList, mulList, bolList);
+                                    QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(courseProperty.getName(), parentProperty.getName(), sonProperty.getName(), map);
+                                    questionDistributeDtos.add(questionDistributeDto);
+                                }
+                            } else {
+                                //一级属性不为空,二级属性为空
+                                //单选题集合
+                                List<Question> sinList = questionList2(courseNo, courseProperty, QuesStructType.SINGLE_ANSWER_QUESTION, parentProperty, null, questions);
+                                //多选题集合
+                                List<Question> mulList = questionList2(courseNo, courseProperty, QuesStructType.MULTIPLE_ANSWER_QUESTION, parentProperty, null, questions);
+                                //判断题集合
+                                List<Question> bolList = questionList2(courseNo, courseProperty, QuesStructType.BOOL_ANSWER_QUESTION, parentProperty, null, questions);
+                                //计算所有题型数量
+                                Map<Long, Long> map = countQuesType(sinList, mulList, bolList);
+                                QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(courseProperty.getName(), parentProperty.getName(), null, map);
+                                questionDistributeDtos.add(questionDistributeDto);
+                            }
+                        }
+                    } else {
+                        //一级属性为空
+                        QuestionDistributeDto questionDistributeDto = new QuestionDistributeDto(courseProperty.getName(), null, null, null);
+                        questionDistributeDtos.add(questionDistributeDto);
+                    }
+                }
+            }
+            //生成Excel导出
+            writeExcel(questionDistributeDtos, 21, new Date().toString(), response);
+        }
+    }
+
 }

+ 137 - 138
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExportStructureServiceImpl.java

@@ -30,148 +30,147 @@ import cn.com.qmth.examcloud.core.questions.service.ExportStructureService;
 import cn.com.qmth.examcloud.core.questions.base.enums.ExportType;
 
 /**
- * @author  	chenken
- * @date    	2017年7月12日 下午4:26:49
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年7月12日 下午4:26:49
+ * @company QMTH
  * @description 导出试卷结构设置
  */
 @Service("exportStructureService")
 public class ExportStructureServiceImpl implements ExportStructureService {
 
-	@Autowired
-	private ExportStructureRepo exportStructureRepo;
-	
-	@Autowired
-	private ExamFileRepo examFileRepo;
-	
-	@Autowired
-	private ExamFileService examFileService;
-	
-	@Autowired
-	private ExtractConfigRepo extractConfigRepo;
-	
-	@Autowired
-	private MongoTemplate mongoTemplate;
-	
-	@Value("${$upyun.site.2.bucketName}")
-	protected String bucketName;
-	
-	@Value("${$upyun.site.2.userName}")
-	protected String userName;
-	
-	@Value("${$upyun.site.2.password}")
-	protected String password;
-	
-	@Override
-	public void saveExportStructure(ExportStructure exportStructure,User user) {
-		if(StringUtils.isBlank(exportStructure.getId())){
-			exportStructure.setCreateUser(user.getDisplayName());
-			exportStructure.setCreateTime(new Date());
-		}else{
-			exportStructure.setUpdateUser(user.getDisplayName());
-			exportStructure.setUpdateTime(new Date());
-		}
-		exportStructure.setOrgId(user.getRootOrgId()+"");
-		exportStructure.setOrgName(user.getRootOrgName());
-		exportStructureRepo.save(exportStructure);
-	}
-
-	@Override
-	public ExportStructure findByExportStructure(String orgId,String examId) {
-		Query query = new Query();
-		query.addCriteria(Criteria.where("orgId").is(orgId));
-		query.addCriteria(Criteria.where("examId").is(examId));
-		List<ExportStructure> list = this.mongoTemplate.find(query, ExportStructure.class);
-		if(list!=null&&list.size()>0){
-			return list.get(0);
-		}
-		return null;
-	}
-
-	@Override
-	public Page<ExportStructure> findPageByExportStructure(ExportStructure exportStructure, int curPage, int pageSize) {
-		Query query = new Query();
-		query.addCriteria(Criteria.where("orgId").is(exportStructure.getOrgId()));
-		if(exportStructure.getExamType() != null){
-			query.addCriteria(Criteria.where("examType").is(exportStructure.getExamType()));
-		}
-		if(StringUtils.isNotBlank(exportStructure.getExamId())){
-			query.addCriteria(Criteria.where("examId").is(exportStructure.getExamId()));
-		}
-		if(exportStructure.getExportType() != null){
-			query.addCriteria(Criteria.where("exportType").is(exportStructure.getExportType()));
-		}
-		long count = this.mongoTemplate.count(query, ExportStructure.class);
-		query.limit(pageSize);
-		query.skip((curPage - 1) * pageSize);
-		List<ExportStructure> list = this.mongoTemplate.find(query, ExportStructure.class);
-		return new PageImpl<ExportStructure>(list, new PageRequest(curPage - 1, pageSize), count);
-	}
-
-	@Override
-	public ExportStructure findStructureByExamId(String examId) {
-		Query query = new Query();
-		query.addCriteria(Criteria.where("examId").is(examId));
-		ExportStructure exportStructure = this.mongoTemplate.findOne(query, ExportStructure.class);
-		if(exportStructure==null){
-			return null;
-		}
-		if(exportStructure.getExportType()==ExportType.NORMAL){
-			List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
-			for(QuestionTypeNum questionTypeNum:questionTypeNums){
-				if(questionTypeNum.getQuantity()==null){
-					//结构设置不完整
-					throw new RuntimeException("试卷结构导出设置不完整,请核实后重新设置导出规则!");
-				}
-			}
-		}
-		return exportStructure;
-	}
-
-	@Override
-	public List<String> findExportStructureByExamType(String examType,User user) {
-		Query query = new Query();
-		query.addCriteria(Criteria.where("orgId").is(user.getRootOrgId()+""));
-		query.addCriteria(Criteria.where("examType").is(examType));
-		List<ExportStructure> exportStructures = this.mongoTemplate.find(query, ExportStructure.class);
-		if(exportStructures.size()>0){
-			List<String> list = new ArrayList<String>();
-			for(int i=0;i<exportStructures.size();i++){
-				list.add(exportStructures.get(i).getExamId());
-			}
-			return list;
-		}
-		return null;
-	}
-
-	@Override
-	public void deleteExportStructure(String id) {
-		//首先根据id,查询到  exportStructure 对象
-		ExportStructure exportStructure = Model.of(exportStructureRepo.findById(id));
-		if(exportStructure != null){
-			//1.首先删除ExamFile表       根据  examId 和    orgId  查询   ExamFile对象
-			List<ExamFile> list = examFileService.findExamFileListByExamFile(new ExamFile(exportStructure.getExamId(),exportStructure.getOrgId()));
-			if(list.size()>0){
-				//根据 ExamFile 对象查询  filePath ,并删除又拍云上的文件 , 然后在删除表里面的数据
-				UpYun upyun = new UpYun(bucketName,userName,password);
-				for(int i=0;i<list.size();i++){
-					upyun.deleteFile(list.get(i).getFilePath());
-				}
-				examFileRepo.deleteAll(list);
-			}
-			//2.然后修改ExtractConfig表      根据 examId 和    orgId
-			Query query = new Query();
-			query.addCriteria(Criteria.where("orgId").is(exportStructure.getOrgId()));
-			query.addCriteria(Criteria.where("examId").is(Long.valueOf(exportStructure.getExamId())));
-			Update update = new Update();
-			update.set("ifFinish", 0);
-			update.unset("finishedPaperIdMap");
-			mongoTemplate.updateMulti(query, update, ExtractConfig.class);
-			exportStructureRepo.delete(exportStructure);
-		}
-	}
-	
-	
-	
+    @Autowired
+    private ExportStructureRepo exportStructureRepo;
+
+    @Autowired
+    private ExamFileRepo examFileRepo;
+
+    @Autowired
+    private ExamFileService examFileService;
+
+    @Autowired
+    private ExtractConfigRepo extractConfigRepo;
+
+    @Autowired
+    private MongoTemplate mongoTemplate;
+
+    @Value("${$upyun.site.2.bucketName}")
+    protected String bucketName;
+
+    @Value("${$upyun.site.2.userName}")
+    protected String userName;
+
+    @Value("${$upyun.site.2.password}")
+    protected String password;
+
+    @Override
+    public void saveExportStructure(ExportStructure exportStructure, User user) {
+        if (StringUtils.isBlank(exportStructure.getId())) {
+            exportStructure.setCreateUser(user.getDisplayName());
+            exportStructure.setCreateTime(new Date());
+        } else {
+            exportStructure.setUpdateUser(user.getDisplayName());
+            exportStructure.setUpdateTime(new Date());
+        }
+        exportStructure.setOrgId(user.getRootOrgId() + "");
+        exportStructure.setOrgName(user.getRootOrgName());
+        exportStructureRepo.save(exportStructure);
+    }
+
+    @Override
+    public ExportStructure findByExportStructure(String orgId, String examId) {
+        Query query = new Query();
+        query.addCriteria(Criteria.where("orgId").is(orgId));
+        query.addCriteria(Criteria.where("examId").is(examId));
+        List<ExportStructure> list = this.mongoTemplate.find(query, ExportStructure.class);
+        if (list != null && list.size() > 0) {
+            return list.get(0);
+        }
+        return null;
+    }
+
+    @Override
+    public Page<ExportStructure> findPageByExportStructure(ExportStructure exportStructure, int curPage, int pageSize) {
+        Query query = new Query();
+        query.addCriteria(Criteria.where("orgId").is(exportStructure.getOrgId()));
+        if (exportStructure.getExamType() != null) {
+            query.addCriteria(Criteria.where("examType").is(exportStructure.getExamType()));
+        }
+        if (StringUtils.isNotBlank(exportStructure.getExamId())) {
+            query.addCriteria(Criteria.where("examId").is(exportStructure.getExamId()));
+        }
+        if (exportStructure.getExportType() != null) {
+            query.addCriteria(Criteria.where("exportType").is(exportStructure.getExportType()));
+        }
+        long count = this.mongoTemplate.count(query, ExportStructure.class);
+        query.limit(pageSize);
+        query.skip((curPage - 1) * pageSize);
+        List<ExportStructure> list = this.mongoTemplate.find(query, ExportStructure.class);
+        return new PageImpl<ExportStructure>(list, new PageRequest(curPage - 1, pageSize), count);
+    }
+
+    @Override
+    public ExportStructure findStructureByExamId(String examId) {
+        Query query = new Query();
+        query.addCriteria(Criteria.where("examId").is(examId));
+        ExportStructure exportStructure = this.mongoTemplate.findOne(query, ExportStructure.class);
+        if (exportStructure == null) {
+            return null;
+        }
+        if (exportStructure.getExportType() == ExportType.NORMAL) {
+            List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
+            for (QuestionTypeNum questionTypeNum : questionTypeNums) {
+                if (questionTypeNum.getQuantity() == null) {
+                    //结构设置不完整
+                    throw new RuntimeException("试卷结构导出设置不完整,请核实后重新设置导出规则!");
+                }
+            }
+        }
+        return exportStructure;
+    }
+
+    @Override
+    public List<String> findExportStructureByExamType(String examType, User user) {
+        Query query = new Query();
+        query.addCriteria(Criteria.where("orgId").is(user.getRootOrgId() + ""));
+        query.addCriteria(Criteria.where("examType").is(examType));
+        List<ExportStructure> exportStructures = this.mongoTemplate.find(query, ExportStructure.class);
+        if (exportStructures.size() > 0) {
+            List<String> list = new ArrayList<String>();
+            for (int i = 0; i < exportStructures.size(); i++) {
+                list.add(exportStructures.get(i).getExamId());
+            }
+            return list;
+        }
+        return null;
+    }
+
+    @Override
+    public void deleteExportStructure(String id) {
+        //首先根据id,查询到  exportStructure 对象
+        ExportStructure exportStructure = Model.of(exportStructureRepo.findById(id));
+        if (exportStructure != null) {
+            //1.首先删除ExamFile表       根据  examId 和    orgId  查询   ExamFile对象
+            List<ExamFile> list = examFileService.findExamFileListByExamFile(new ExamFile(exportStructure.getExamId(), exportStructure.getOrgId()));
+            if (list.size() > 0) {
+                //根据 ExamFile 对象查询  filePath ,并删除又拍云上的文件 , 然后在删除表里面的数据
+                UpYun upyun = new UpYun(bucketName, userName, password);
+                for (int i = 0; i < list.size(); i++) {
+                    upyun.deleteFile(list.get(i).getFilePath());
+                }
+                examFileRepo.deleteAll(list);
+            }
+            //2.然后修改ExtractConfig表      根据 examId 和    orgId
+            Query query = new Query();
+            query.addCriteria(Criteria.where("orgId").is(exportStructure.getOrgId()));
+            query.addCriteria(Criteria.where("examId").is(Long.valueOf(exportStructure.getExamId())));
+            Update update = new Update();
+            update.set("ifFinish", 0);
+            update.unset("finishedPaperIdMap");
+            mongoTemplate.updateMulti(query, update, ExtractConfig.class);
+            exportStructureRepo.delete(exportStructure);
+        }
+    }
+
+
 }
 

+ 610 - 598
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExtractConfigProviderServiceImpl.java

@@ -55,630 +55,642 @@ import cn.com.qmth.examcloud.question.commons.core.question.DefaultQuestionUnit;
 import cn.com.qmth.examcloud.question.commons.core.question.QuestionType;
 
 /**
- * @author 		weiwenhai
- * @date 		2018.8.15
- * @company		qmth
- * @describle	provider中的service方法
- * @code 		020
+ * @author weiwenhai
+ * @date 2018.8.15
+ * @company qmth
+ * @describle provider中的service方法
+ * @code 020
  */
 @Service("extractConfigCloudService")
-public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderService{
-
-	protected ExamCloudLog log = ExamCloudLogFactory.getLog(this.getClass());
-	
-	@Autowired
-	private ExtractConfigService extractConfigService;
-	
-	@Autowired
+public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderService {
+
+    protected ExamCloudLog log = ExamCloudLogFactory.getLog(this.getClass());
+
+    @Autowired
+    private ExtractConfigService extractConfigService;
+
+    @Autowired
     private PaperRepo paperRepo;
-	
-	@Autowired
-	private PaperDetailRepo paperDetailRepo;
-	
-	@Autowired
+
+    @Autowired
+    private PaperDetailRepo paperDetailRepo;
+
+    @Autowired
     private PaperDetailUnitRepo paperDetailUnitRepo;
-	
-	@Autowired
+
+    @Autowired
     private QuesRepo quesRepo;
-	
-	@Autowired
+
+    @Autowired
     private AudioTimeConfigRepo audioTimeConfigRepo;
-	
+
     @Autowired
     private QuestionAudioService questionAudioService;
-    
+
     @Autowired
     private QuesService quesService;
-    
+
     @Autowired
     private PaperService paperService;
-	
-	@Value("${upyun.downloadUrl}")
-	private String downloadUrl;
-	
-	@Override
-	public Map<String, Object> getDefaultPaper(Long examId,String courseCode,String groupCode) {
-		Map<String,Object> map = new HashMap<String, Object>();
-		log.debug("调卷开始...");
-		long startTime = System.currentTimeMillis();
-		log.debug("开始根据examId:"+ examId +"和courseCode:"+ courseCode +"获取调卷规则");
-		ExtractConfig extractConfig = extractConfigService.findConfig(new ExtractConfig(examId,courseCode));
-		if(extractConfig == null){
-			log.error("该课程调卷规则未制定,请联系学校");
-			throw new StatusException("Q-020101","该课程调卷规则未制定,请联系学校");
-		}
-		long configFinishTime = System.currentTimeMillis();
-		log.debug("获取调卷规则共耗时:"+ (configFinishTime - startTime)+"ms");
-		log.debug("根据调卷规则中设置的概率获取类型为"+ groupCode +"的试卷");
-		Map<String,Paper> paperMap = this.getExamPaperByProbability(extractConfig.getExamPaperList());
-		if(paperMap.isEmpty()){
-			log.error("该考试和课程下调卷规则中试卷不存在,请检查调卷规则,调卷程序退出");
-			throw new StatusException("Q-020109","该考试和课程下调卷规则中试卷不存在,请重新制定调卷规则");
-		}
-		long paperMapFinishTime = System.currentTimeMillis();
-		log.debug("获取类型为"+ groupCode +"的试卷共耗时:"+ (paperMapFinishTime - configFinishTime)+"ms");
-		Paper basePaper = paperMap.get(groupCode);
-		if(basePaper==null){
-			log.error("该考试和课程下调卷规则中该类型试卷不存在,请检查调卷规则,调卷程序退出");
-			throw new StatusException("Q-020116","该考试和课程下调卷规则中试卷不存在,请重新制定调卷规则");
-		}
-		log.debug("将原始试卷:"+ basePaper.getId() +"根据规则重新组卷");
-		Short upSetQuestionOrder = extractConfig.getScrambling_the_question_order();
-		Short upSetOptionOrder = extractConfig.getScrambling_the_option_order();
-		map.put("upSetQuestionOrder", upSetQuestionOrder);
-		map.put("upSetOptionOrder", upSetOptionOrder);
-		map.put("paperId", basePaper.getId());
-		//构建试卷结构
-		DefaultPaper defaultPaper = buildDefaultByBasePaper(basePaper,String.valueOf(examId),courseCode,groupCode);
-		map.put("defaultPaper", defaultPaper);
-		return map;
-	}
-	
-	/**
-	 * 每个试卷类型取出一套试卷
-	 * {
-	 * 	 A:Paper,
-	 *   B:Paper
-	 * }
-	 * A是试卷类型   Paper是A类型下选定的试卷
-	 * @param examPaperList		
-	 * @return
-	 */
-	private Map<String,Paper> getExamPaperByProbability(List<ExamPaper> examPaperList){
-		Map<String,Paper> paperByTypeMap = new HashMap<String,Paper>();
-		if(examPaperList == null || examPaperList.size() == 0) {
-			throw new StatusException("Q-020114","可供抽取的试卷集合为空,无法抽取试卷"); 
+
+    @Value("${upyun.downloadUrl}")
+    private String downloadUrl;
+
+    @Override
+    public Map<String, Object> getDefaultPaper(Long examId, String courseCode, String groupCode) {
+        Map<String, Object> map = new HashMap<String, Object>();
+        log.debug("调卷开始...");
+        long startTime = System.currentTimeMillis();
+        log.debug("开始根据examId:" + examId + "和courseCode:" + courseCode + "获取调卷规则");
+        ExtractConfig extractConfig = extractConfigService.findConfig(new ExtractConfig(examId, courseCode));
+        if (extractConfig == null) {
+            log.error("该课程调卷规则未制定,请联系学校");
+            throw new StatusException("Q-020101", "该课程调卷规则未制定,请联系学校");
+        }
+        long configFinishTime = System.currentTimeMillis();
+        log.debug("获取调卷规则共耗时:" + (configFinishTime - startTime) + "ms");
+        log.debug("根据调卷规则中设置的概率获取类型为" + groupCode + "的试卷");
+        Map<String, Paper> paperMap = this.getExamPaperByProbability(extractConfig.getExamPaperList());
+        if (paperMap.isEmpty()) {
+            log.error("该考试和课程下调卷规则中试卷不存在,请检查调卷规则,调卷程序退出");
+            throw new StatusException("Q-020109", "该考试和课程下调卷规则中试卷不存在,请重新制定调卷规则");
+        }
+        long paperMapFinishTime = System.currentTimeMillis();
+        log.debug("获取类型为" + groupCode + "的试卷共耗时:" + (paperMapFinishTime - configFinishTime) + "ms");
+        Paper basePaper = paperMap.get(groupCode);
+        if (basePaper == null) {
+            log.error("该考试和课程下调卷规则中该类型试卷不存在,请检查调卷规则,调卷程序退出");
+            throw new StatusException("Q-020116", "该考试和课程下调卷规则中试卷不存在,请重新制定调卷规则");
+        }
+        log.debug("将原始试卷:" + basePaper.getId() + "根据规则重新组卷");
+        Short upSetQuestionOrder = extractConfig.getScrambling_the_question_order();
+        Short upSetOptionOrder = extractConfig.getScrambling_the_option_order();
+        map.put("upSetQuestionOrder", upSetQuestionOrder);
+        map.put("upSetOptionOrder", upSetOptionOrder);
+        map.put("paperId", basePaper.getId());
+        //构建试卷结构
+        DefaultPaper defaultPaper = buildDefaultByBasePaper(basePaper, String.valueOf(examId), courseCode, groupCode);
+        map.put("defaultPaper", defaultPaper);
+        return map;
+    }
+
+    /**
+     * 每个试卷类型取出一套试卷
+     * {
+     * A:Paper,
+     * B:Paper
+     * }
+     * A是试卷类型   Paper是A类型下选定的试卷
+     *
+     * @param examPaperList
+     * @return
+     */
+    private Map<String, Paper> getExamPaperByProbability(List<ExamPaper> examPaperList) {
+        Map<String, Paper> paperByTypeMap = new HashMap<String, Paper>();
+        if (examPaperList == null || examPaperList.size() == 0) {
+            throw new StatusException("Q-020114", "可供抽取的试卷集合为空,无法抽取试卷");
+        }
+        Map<String, List<ExamPaper>> examPaperMap = new HashMap<String, List<ExamPaper>>();
+        for (int i = 0; i < examPaperList.size(); i++) {
+            ExamPaper examPaper = examPaperList.get(i);
+            if (!examPaperMap.containsKey(examPaper.getGroupCode())) {
+                if (examPaper.getPaper() != null) {
+                    List<ExamPaper> epList = new ArrayList<ExamPaper>();
+                    epList.add(examPaper);
+                    examPaperMap.put(examPaper.getGroupCode(), epList);
+                }
+            } else {
+                if (examPaper.getPaper() != null) {
+                    List<ExamPaper> epList = examPaperMap.get(examPaper.getGroupCode());
+                    epList.add(examPaper);
+                }
+            }
+        }
+        if (examPaperMap != null) {
+            Set<String> keys = examPaperMap.keySet();
+            Iterator<String> it = keys.iterator();
+            while (it.hasNext()) {
+                String key = it.next();
+                Paper paper = this.getPaperByProbability(examPaperMap.get(key));
+                //不能用原来的paper对象,否则examPaperList中的paper对象会被覆盖
+                Paper newPaper = Model.of(paperRepo.findById(paper.getId()));
+                paperByTypeMap.put(key, newPaper);
+            }
         }
-		Map<String,List<ExamPaper>> examPaperMap = new HashMap<String,List<ExamPaper>>();
-		for(int i = 0;i<examPaperList.size();i++){
-			ExamPaper examPaper = examPaperList.get(i);
-			if(!examPaperMap.containsKey(examPaper.getGroupCode())){
-				if(examPaper.getPaper()!=null){
-					List<ExamPaper> epList = new ArrayList<ExamPaper>();
-					epList.add(examPaper);
-					examPaperMap.put(examPaper.getGroupCode(), epList);
-				}
-			}else{
-				if(examPaper.getPaper()!=null){
-					List<ExamPaper> epList = examPaperMap.get(examPaper.getGroupCode());
-					epList.add(examPaper);
-				}
-			}
-		}
-		if(examPaperMap!=null){
-			Set<String> keys = examPaperMap.keySet();
-			Iterator<String> it = keys.iterator();
-			while (it.hasNext()) {
-				String key = it.next();
-				Paper paper = this.getPaperByProbability(examPaperMap.get(key));
-				//不能用原来的paper对象,否则examPaperList中的paper对象会被覆盖
-				Paper newPaper = Model.of(paperRepo.findById(paper.getId()));
-				paperByTypeMap.put(key,newPaper);
-			}
-		}
         return paperByTypeMap;
-	}
-	
-	/**
-	 * 根据设定几率取出一套试卷
-	 * @param examPaperList
-	 * @return
-	 */
-	private Paper getPaperByProbability(List<ExamPaper> examPaperList){
-		int sum = 0;  
-        for (int i = 0;i<examPaperList.size();i++) {  
-             sum += examPaperList.get(i).getWeight();  
+    }
+
+    /**
+     * 根据设定几率取出一套试卷
+     *
+     * @param examPaperList
+     * @return
+     */
+    private Paper getPaperByProbability(List<ExamPaper> examPaperList) {
+        int sum = 0;
+        for (int i = 0; i < examPaperList.size(); i++) {
+            sum += examPaperList.get(i).getWeight();
         }
         // 从1开始  
-        Integer rand = new Random().nextInt(sum) + 1;  
-        for (int i = 0;i<examPaperList.size();i++) {
+        Integer rand = new Random().nextInt(sum) + 1;
+        for (int i = 0; i < examPaperList.size(); i++) {
             rand -= examPaperList.get(i).getWeight();
             // 选中
             if (rand <= 0) {
                 return examPaperList.get(i).getPaper();
             }
-        } 
+        }
         return null;
-	}
-
-	/**
-	 * 根据paper对象构建DefaultPaper对象
-	 * @param basePaper
-	 * @return
-	 */
-	public DefaultPaper buildDefaultByBasePaper(Paper basePaper,String examId,String courseCode,String groupCode){
-		log.debug("开始包装网考需要的试卷结构...");
-		long beginTime = System.currentTimeMillis();
-		//获取大题
-		List<PaperDetail> paperDetails = paperDetailRepo.findByPaper(basePaper);
-		long pdTime = System.currentTimeMillis();
-		log.debug("数据库取大题耗时:"+(pdTime - beginTime)+"ms");
-		Collections.sort(paperDetails);
-		long pdSortEndTime = System.currentTimeMillis();
-		log.debug("排序大题耗时:"+(pdSortEndTime - pdTime)+"ms");
-		//将小题全部取出来,只取一次,减少对数据库的查询
-		List<PaperDetailUnit> allPaperDetailUnits = paperDetailUnitRepo.findByPaper(basePaper);
-		boolean fullyObjective = checkIsAllQbjectiveQuestion(allPaperDetailUnits);
-		long pduEndTime = System.currentTimeMillis();
-		log.debug("数据库取所有小题耗时:"+(pduEndTime - pdSortEndTime)+"ms");
-		//根据大题id将小题归类
-		Map<String,List<PaperDetailUnit>> pduMap = allPaperDetailUnits.stream().collect(Collectors.groupingBy(PaperDetailUnit::getDetailId));
-		long pduMapEndTime = System.currentTimeMillis();
-		log.debug("获取大题与小题对应关系耗时:"+(pduMapEndTime - pduEndTime)+"ms");
-		log.debug("循环大题,开始组装对象...");
-		//生成新的分组集合
-		List<DefaultQuestionGroup> questionGroupList = new ArrayList<DefaultQuestionGroup>();
-		for(int i = 0; i < paperDetails.size(); i++){
-			PaperDetail paperDetail = paperDetails.get(i);
-			DefaultQuestionGroup defaultQuestionGroup = new DefaultQuestionGroup();
-			defaultQuestionGroup.setGroupName(paperDetail.getName());
-			defaultQuestionGroup.setGroupScore(paperDetail.getScore());
-			//生成新的题包装器集合
-			List<DefaultQuestionStructureWrapper> questionWrapperList = new ArrayList<DefaultQuestionStructureWrapper>();
-			//获取原小题的集合
-			List<PaperDetailUnit> paperDetailUnits = pduMap.get(paperDetail.getId());
-			if(paperDetailUnits==null || paperDetailUnits.size()<1){
-				log.error("试卷大题下面,没有小题");
-				throw new StatusException("Q-020241","考试试卷有误,请联系老师");
-			}
-			for(int j =0; j<paperDetailUnits.size(); j++){
-				PaperDetailUnit paperDetailUnit = paperDetailUnits.get(j);
-				DefaultQuestionStructureWrapper defaultQuestionStructureWrapper = new DefaultQuestionStructureWrapper();
-				defaultQuestionStructureWrapper.setQuestionId(paperDetailUnit.getQuestion().getId());
-				defaultQuestionStructureWrapper.setVersion(CommonUtils.QUESTION_VERSION);
-				defaultQuestionStructureWrapper.setQuestionScore(paperDetailUnit.getScore());
-				defaultQuestionStructureWrapper.setTimeLimit(paperDetailUnit.getTimeLimit());
-				if(examId != null){
-					//设置音频播放次数
-					if(paperDetailUnit.getQuestion().getHasAudio() != null && paperDetailUnit.getQuestion().getHasAudio() == true){
-						AudioTimeConfig audioTimeConfig = Model.of( audioTimeConfigRepo.findOne(Example.of(new AudioTimeConfig(examId,courseCode,groupCode,paperDetailUnit.getQuestion().getId()))));
-						if(audioTimeConfig != null){
-							defaultQuestionStructureWrapper.setLimitedPlayTimes(audioTimeConfig.getPlayTime());
-						}
-					}
-				}
-				//生成新的题单元包装器
-				List<DefaultQuestionUnitWrapper> defaultQuestionUnitWrappers = new ArrayList<DefaultQuestionUnitWrapper>();
-				if(paperDetailUnit.getQuestion().getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION){
-					List<Question> subQuesList = paperDetailUnit.getQuestion().getSubQuestions();
-					List<Double> scoreList = paperDetailUnit.getSubScoreList();
-					if(subQuesList != null && subQuesList.size()>0){
-						for(int k =0;k<subQuesList.size();k++){
-							DefaultQuestionUnitWrapper defaultQuestionUnitWrapper = buildQuesUnitWrapper(subQuesList.get(k),scoreList.get(k));
-							defaultQuestionUnitWrappers.add(defaultQuestionUnitWrapper);
-						}
-					}
-				}else {
-					DefaultQuestionUnitWrapper defaultQuestionUnitWrapper = buildQuesUnitWrapper(paperDetailUnit.getQuestion(),paperDetailUnit.getScore());
-					defaultQuestionUnitWrappers.add(defaultQuestionUnitWrapper);
-				}
-				defaultQuestionStructureWrapper.setQuestionUnitWrapperList(defaultQuestionUnitWrappers);
-				questionWrapperList.add(defaultQuestionStructureWrapper);
-			}
-			defaultQuestionGroup.setQuestionWrapperList(questionWrapperList);
-			questionGroupList.add(defaultQuestionGroup);
-		}
-		DefaultPaper defaultPaper = new DefaultPaper();
-		defaultPaper.setName(basePaper.getName());
-		defaultPaper.setQuestionGroupList(questionGroupList);
-		defaultPaper.setFullyObjective(fullyObjective);
-		return defaultPaper;
-	}
-	
-	/**
-	 * 根据question生成题单元包装器
-	 * @param question
-	 * @param score
-	 * @return
-	 */
-	private DefaultQuestionUnitWrapper buildQuesUnitWrapper(Question question,Double score){
-		DefaultQuestionUnitWrapper defaultQuestionUnitWrapper = new DefaultQuestionUnitWrapper();
-		Integer[] optionPermutation = null;
-		if(question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION ||
-				question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION){
-			int length = question.getQuesOptions().size();
-			optionPermutation = new Integer[length];
-			for(int i=0;i<length;i++){
-				optionPermutation[i] = i;
-			}
-		}
-		defaultQuestionUnitWrapper.setOptionPermutation(optionPermutation);
-		defaultQuestionUnitWrapper.setQuestionScore(score);
-		defaultQuestionUnitWrapper.setQuestionType(getByOldType(question.getQuestionType()));
-		return defaultQuestionUnitWrapper;
-	}
-	
-	/**
-	 * 题型转换方法
-	 * @param quesStructType
-	 * @return
-	 */
-	private QuestionType getByOldType(QuesStructType quesStructType){
-		if(quesStructType == QuesStructType.BOOL_ANSWER_QUESTION){
-			return QuestionType.TRUE_OR_FALSE;
-		}
-		if(quesStructType == QuesStructType.FILL_BLANK_QUESTION){
-			return QuestionType.FILL_UP;
-		}
-		if(quesStructType == QuesStructType.MULTIPLE_ANSWER_QUESTION){
-			return QuestionType.MULTIPLE_CHOICE;
-		}
-		if(quesStructType == QuesStructType.SINGLE_ANSWER_QUESTION){
-			return QuestionType.SINGLE_CHOICE;
-		}
-		if(quesStructType == QuesStructType.TEXT_ANSWER_QUESTION){
-			return QuestionType.ESSAY;
-		}
-		return null;
-	}
-	
-
-	@Override
-	public DefaultQuestion getDefaultQuestion(Long examId, String courseCode, String groupCode, String questionId) {
-		log.debug("网考根据调卷规则中试题id:"+ questionId +"获取单个试题...");
-		long beginTime = System.currentTimeMillis();
-		Question question = Model.of( quesRepo.findById(questionId));
-		if(question == null){
-			throw new StatusException("Q-020330", "question is null");
-		}
-		quesService.formatQues(question);
-		long oldQuesTime = System.currentTimeMillis();
-		log.debug("查询单个试题耗时:"+(oldQuesTime - beginTime)+"ms");
-		DefaultQuestionStructure defaultQuestionStructure = new DefaultQuestionStructure();
-		if(question.getHasAudio() == null || false == question.getHasAudio()){
-			defaultQuestionStructure.setHasAudios(false);
-		}else {
-			defaultQuestionStructure.setHasAudios(true);
-		}
-		defaultQuestionStructure.setVersion(CommonUtils.QUESTION_VERSION);
-		//生成新的题单元集合
-		List<DefaultQuestionUnit> questionUnitList = new ArrayList<DefaultQuestionUnit>();
-		if(question.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION){
-			defaultQuestionStructure.setBody(question.getQuesBody());
-			//获取套题下面所有子题
-			List<Question> subQuesList = question.getSubQuestions();
-			if(subQuesList!=null && subQuesList.size()>0){
-				for(int i=0;i<subQuesList.size();i++){
-					Question subQuestion = subQuesList.get(i);
-					DefaultQuestionUnit defaultQuestionUnit = buildQuestionUnit(subQuestion);
-					questionUnitList.add(defaultQuestionUnit);
-				}
-			}
-		}else {
-			DefaultQuestionUnit defaultQuestionUnit = buildQuestionUnit(question);
-			questionUnitList.add(defaultQuestionUnit);
-		}
-		defaultQuestionStructure.setQuestionUnitList(questionUnitList);
-		DefaultQuestion defaultQuestion = new DefaultQuestion();
-		defaultQuestion.setId(questionId);
-		defaultQuestion.setMasterVersion(defaultQuestionStructure);
-		long newQuesTime = System.currentTimeMillis();
-		log.debug("构建一个新的试题单元耗时:"+(newQuesTime - oldQuesTime)+"ms");
-		//替换试题单元中的音频路径
-		log.debug("给新的试题替换音频标签...");
-		if(examId != null){
-			appendAudioFlag(defaultQuestion,String.valueOf(examId),courseCode,groupCode,question);
-		}
-		long finishTime = System.currentTimeMillis();
-		log.debug("给新的试题替换音频标签耗时:"+(finishTime- newQuesTime)+"ms");
-		return defaultQuestion;
-	}
-	
-	/**
-	 * 构建试题单元
-	 * @param question
-	 * @return
-	 */
-	private DefaultQuestionUnit buildQuestionUnit(Question question){
-		DefaultQuestionUnit defaultQuestionUnit = new DefaultQuestionUnit();
-		defaultQuestionUnit.setBody(question.getQuesBody());
-		defaultQuestionUnit.setQuestionType(getByOldType(question.getQuestionType()));
-		//如果是单选或者多选,添加选项和答案转换
-		if(question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION || question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION){
-			List<DefaultQuestionOption> defaultQuestionOptions = new ArrayList<DefaultQuestionOption>();
-			List<QuesOption> quesOptions = question.getQuesOptions();
-			if(quesOptions != null && quesOptions.size()>0){
-				for(int i=0;i<quesOptions.size();i++){
-					QuesOption quesOption = quesOptions.get(i);
-					DefaultQuestionOption defaultQuestionOption = new DefaultQuestionOption();
-					defaultQuestionOption.setBody(quesOption.getOptionBody());
-					defaultQuestionOptions.add(defaultQuestionOption);
-				}
-			}
-			defaultQuestionUnit.setQuestionOptionList(defaultQuestionOptions);
-			defaultQuestionUnit.setRightAnswer(getSelectQuestionAnswer(quesOptions));
-		}else {
-			defaultQuestionUnit.setRightAnswer(getAnswer(question));
-		}
-		return defaultQuestionUnit;
-	}
-	
-	/**
-	 * 设置单选题和多选题  答案
-	 * @param quesOptions
-	 * @return
-	 */
-	private String[] getSelectQuestionAnswer(List<QuesOption> quesOptions){
-		String[] rightAnswer = null;
-		List<String> list = new ArrayList<String>();
-		if(quesOptions != null && quesOptions.size()>0){
-			for(int i=0;i<quesOptions.size();i++){
-				QuesOption quesOption = quesOptions.get(i);
-				if(quesOption.getIsCorrect() == 1){
-					list.add(String.valueOf(i));
-				}
-			}
-			rightAnswer = list.toArray(new String[list.size()]);
-			return rightAnswer;
-		}
-		return rightAnswer;
-	}
-
-	/**
-	 * 设置试题答案
-	 * @param question
-	 * @return
-	 */
-	private String[] getAnswer(Question question){
-		String[] rightAnswer = null;
-		//判断题答案
-		if(question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION){
-			if(question.getQuesAnswer().equals("正确")){
-				rightAnswer = new String[1];
-				rightAnswer[0] = "true";
-				return rightAnswer;
-			}
-			if(question.getQuesAnswer().equals("错误")){
-				rightAnswer = new String[1];
-				rightAnswer[0] = "false";
-				return rightAnswer;
-			}
-		}
-		//填空题答案
+    }
+
+    /**
+     * 根据paper对象构建DefaultPaper对象
+     *
+     * @param basePaper
+     * @return
+     */
+    public DefaultPaper buildDefaultByBasePaper(Paper basePaper, String examId, String courseCode, String groupCode) {
+        log.debug("开始包装网考需要的试卷结构...");
+        long beginTime = System.currentTimeMillis();
+        //获取大题
+        List<PaperDetail> paperDetails = paperDetailRepo.findByPaper(basePaper);
+        long pdTime = System.currentTimeMillis();
+        log.debug("数据库取大题耗时:" + (pdTime - beginTime) + "ms");
+        Collections.sort(paperDetails);
+        long pdSortEndTime = System.currentTimeMillis();
+        log.debug("排序大题耗时:" + (pdSortEndTime - pdTime) + "ms");
+        //将小题全部取出来,只取一次,减少对数据库的查询
+        List<PaperDetailUnit> allPaperDetailUnits = paperDetailUnitRepo.findByPaper(basePaper);
+        boolean fullyObjective = checkIsAllQbjectiveQuestion(allPaperDetailUnits);
+        long pduEndTime = System.currentTimeMillis();
+        log.debug("数据库取所有小题耗时:" + (pduEndTime - pdSortEndTime) + "ms");
+        //根据大题id将小题归类
+        Map<String, List<PaperDetailUnit>> pduMap = allPaperDetailUnits.stream().collect(Collectors.groupingBy(PaperDetailUnit::getDetailId));
+        long pduMapEndTime = System.currentTimeMillis();
+        log.debug("获取大题与小题对应关系耗时:" + (pduMapEndTime - pduEndTime) + "ms");
+        log.debug("循环大题,开始组装对象...");
+        //生成新的分组集合
+        List<DefaultQuestionGroup> questionGroupList = new ArrayList<DefaultQuestionGroup>();
+        for (int i = 0; i < paperDetails.size(); i++) {
+            PaperDetail paperDetail = paperDetails.get(i);
+            DefaultQuestionGroup defaultQuestionGroup = new DefaultQuestionGroup();
+            defaultQuestionGroup.setGroupName(paperDetail.getName());
+            defaultQuestionGroup.setGroupScore(paperDetail.getScore());
+            //生成新的题包装器集合
+            List<DefaultQuestionStructureWrapper> questionWrapperList = new ArrayList<DefaultQuestionStructureWrapper>();
+            //获取原小题的集合
+            List<PaperDetailUnit> paperDetailUnits = pduMap.get(paperDetail.getId());
+            if (paperDetailUnits == null || paperDetailUnits.size() < 1) {
+                log.error("试卷大题下面,没有小题");
+                throw new StatusException("Q-020241", "考试试卷有误,请联系老师");
+            }
+            for (int j = 0; j < paperDetailUnits.size(); j++) {
+                PaperDetailUnit paperDetailUnit = paperDetailUnits.get(j);
+                DefaultQuestionStructureWrapper defaultQuestionStructureWrapper = new DefaultQuestionStructureWrapper();
+                defaultQuestionStructureWrapper.setQuestionId(paperDetailUnit.getQuestion().getId());
+                defaultQuestionStructureWrapper.setVersion(CommonUtils.QUESTION_VERSION);
+                defaultQuestionStructureWrapper.setQuestionScore(paperDetailUnit.getScore());
+                defaultQuestionStructureWrapper.setTimeLimit(paperDetailUnit.getTimeLimit());
+                if (examId != null) {
+                    //设置音频播放次数
+                    if (paperDetailUnit.getQuestion().getHasAudio() != null && paperDetailUnit.getQuestion().getHasAudio() == true) {
+                        AudioTimeConfig audioTimeConfig = Model.of(audioTimeConfigRepo.findOne(Example.of(new AudioTimeConfig(examId, courseCode, groupCode, paperDetailUnit.getQuestion().getId()))));
+                        if (audioTimeConfig != null) {
+                            defaultQuestionStructureWrapper.setLimitedPlayTimes(audioTimeConfig.getPlayTime());
+                        }
+                    }
+                }
+                //生成新的题单元包装器
+                List<DefaultQuestionUnitWrapper> defaultQuestionUnitWrappers = new ArrayList<DefaultQuestionUnitWrapper>();
+                if (paperDetailUnit.getQuestion().getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
+                    List<Question> subQuesList = paperDetailUnit.getQuestion().getSubQuestions();
+                    List<Double> scoreList = paperDetailUnit.getSubScoreList();
+                    if (subQuesList != null && subQuesList.size() > 0) {
+                        for (int k = 0; k < subQuesList.size(); k++) {
+                            DefaultQuestionUnitWrapper defaultQuestionUnitWrapper = buildQuesUnitWrapper(subQuesList.get(k), scoreList.get(k));
+                            defaultQuestionUnitWrappers.add(defaultQuestionUnitWrapper);
+                        }
+                    }
+                } else {
+                    DefaultQuestionUnitWrapper defaultQuestionUnitWrapper = buildQuesUnitWrapper(paperDetailUnit.getQuestion(), paperDetailUnit.getScore());
+                    defaultQuestionUnitWrappers.add(defaultQuestionUnitWrapper);
+                }
+                defaultQuestionStructureWrapper.setQuestionUnitWrapperList(defaultQuestionUnitWrappers);
+                questionWrapperList.add(defaultQuestionStructureWrapper);
+            }
+            defaultQuestionGroup.setQuestionWrapperList(questionWrapperList);
+            questionGroupList.add(defaultQuestionGroup);
+        }
+        DefaultPaper defaultPaper = new DefaultPaper();
+        defaultPaper.setName(basePaper.getName());
+        defaultPaper.setQuestionGroupList(questionGroupList);
+        defaultPaper.setFullyObjective(fullyObjective);
+        return defaultPaper;
+    }
+
+    /**
+     * 根据question生成题单元包装器
+     *
+     * @param question
+     * @param score
+     * @return
+     */
+    private DefaultQuestionUnitWrapper buildQuesUnitWrapper(Question question, Double score) {
+        DefaultQuestionUnitWrapper defaultQuestionUnitWrapper = new DefaultQuestionUnitWrapper();
+        Integer[] optionPermutation = null;
+        if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION ||
+                question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
+            int length = question.getQuesOptions().size();
+            optionPermutation = new Integer[length];
+            for (int i = 0; i < length; i++) {
+                optionPermutation[i] = i;
+            }
+        }
+        defaultQuestionUnitWrapper.setOptionPermutation(optionPermutation);
+        defaultQuestionUnitWrapper.setQuestionScore(score);
+        defaultQuestionUnitWrapper.setQuestionType(getByOldType(question.getQuestionType()));
+        return defaultQuestionUnitWrapper;
+    }
+
+    /**
+     * 题型转换方法
+     *
+     * @param quesStructType
+     * @return
+     */
+    private QuestionType getByOldType(QuesStructType quesStructType) {
+        if (quesStructType == QuesStructType.BOOL_ANSWER_QUESTION) {
+            return QuestionType.TRUE_OR_FALSE;
+        }
+        if (quesStructType == QuesStructType.FILL_BLANK_QUESTION) {
+            return QuestionType.FILL_UP;
+        }
+        if (quesStructType == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
+            return QuestionType.MULTIPLE_CHOICE;
+        }
+        if (quesStructType == QuesStructType.SINGLE_ANSWER_QUESTION) {
+            return QuestionType.SINGLE_CHOICE;
+        }
+        if (quesStructType == QuesStructType.TEXT_ANSWER_QUESTION) {
+            return QuestionType.ESSAY;
+        }
+        return null;
+    }
+
+
+    @Override
+    public DefaultQuestion getDefaultQuestion(Long examId, String courseCode, String groupCode, String questionId) {
+        log.debug("网考根据调卷规则中试题id:" + questionId + "获取单个试题...");
+        long beginTime = System.currentTimeMillis();
+        Question question = Model.of(quesRepo.findById(questionId));
+        if (question == null) {
+            throw new StatusException("Q-020330", "question is null");
+        }
+        quesService.formatQues(question);
+        long oldQuesTime = System.currentTimeMillis();
+        log.debug("查询单个试题耗时:" + (oldQuesTime - beginTime) + "ms");
+        DefaultQuestionStructure defaultQuestionStructure = new DefaultQuestionStructure();
+        if (question.getHasAudio() == null || false == question.getHasAudio()) {
+            defaultQuestionStructure.setHasAudios(false);
+        } else {
+            defaultQuestionStructure.setHasAudios(true);
+        }
+        defaultQuestionStructure.setVersion(CommonUtils.QUESTION_VERSION);
+        //生成新的题单元集合
+        List<DefaultQuestionUnit> questionUnitList = new ArrayList<DefaultQuestionUnit>();
+        if (question.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
+            defaultQuestionStructure.setBody(question.getQuesBody());
+            //获取套题下面所有子题
+            List<Question> subQuesList = question.getSubQuestions();
+            if (subQuesList != null && subQuesList.size() > 0) {
+                for (int i = 0; i < subQuesList.size(); i++) {
+                    Question subQuestion = subQuesList.get(i);
+                    DefaultQuestionUnit defaultQuestionUnit = buildQuestionUnit(subQuestion);
+                    questionUnitList.add(defaultQuestionUnit);
+                }
+            }
+        } else {
+            DefaultQuestionUnit defaultQuestionUnit = buildQuestionUnit(question);
+            questionUnitList.add(defaultQuestionUnit);
+        }
+        defaultQuestionStructure.setQuestionUnitList(questionUnitList);
+        DefaultQuestion defaultQuestion = new DefaultQuestion();
+        defaultQuestion.setId(questionId);
+        defaultQuestion.setMasterVersion(defaultQuestionStructure);
+        long newQuesTime = System.currentTimeMillis();
+        log.debug("构建一个新的试题单元耗时:" + (newQuesTime - oldQuesTime) + "ms");
+        //替换试题单元中的音频路径
+        log.debug("给新的试题替换音频标签...");
+        if (examId != null) {
+            appendAudioFlag(defaultQuestion, String.valueOf(examId), courseCode, groupCode, question);
+        }
+        long finishTime = System.currentTimeMillis();
+        log.debug("给新的试题替换音频标签耗时:" + (finishTime - newQuesTime) + "ms");
+        return defaultQuestion;
+    }
+
+    /**
+     * 构建试题单元
+     *
+     * @param question
+     * @return
+     */
+    private DefaultQuestionUnit buildQuestionUnit(Question question) {
+        DefaultQuestionUnit defaultQuestionUnit = new DefaultQuestionUnit();
+        defaultQuestionUnit.setBody(question.getQuesBody());
+        defaultQuestionUnit.setQuestionType(getByOldType(question.getQuestionType()));
+        //如果是单选或者多选,添加选项和答案转换
+        if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION || question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
+            List<DefaultQuestionOption> defaultQuestionOptions = new ArrayList<DefaultQuestionOption>();
+            List<QuesOption> quesOptions = question.getQuesOptions();
+            if (quesOptions != null && quesOptions.size() > 0) {
+                for (int i = 0; i < quesOptions.size(); i++) {
+                    QuesOption quesOption = quesOptions.get(i);
+                    DefaultQuestionOption defaultQuestionOption = new DefaultQuestionOption();
+                    defaultQuestionOption.setBody(quesOption.getOptionBody());
+                    defaultQuestionOptions.add(defaultQuestionOption);
+                }
+            }
+            defaultQuestionUnit.setQuestionOptionList(defaultQuestionOptions);
+            defaultQuestionUnit.setRightAnswer(getSelectQuestionAnswer(quesOptions));
+        } else {
+            defaultQuestionUnit.setRightAnswer(getAnswer(question));
+        }
+        return defaultQuestionUnit;
+    }
+
+    /**
+     * 设置单选题和多选题  答案
+     *
+     * @param quesOptions
+     * @return
+     */
+    private String[] getSelectQuestionAnswer(List<QuesOption> quesOptions) {
+        String[] rightAnswer = null;
+        List<String> list = new ArrayList<String>();
+        if (quesOptions != null && quesOptions.size() > 0) {
+            for (int i = 0; i < quesOptions.size(); i++) {
+                QuesOption quesOption = quesOptions.get(i);
+                if (quesOption.getIsCorrect() == 1) {
+                    list.add(String.valueOf(i));
+                }
+            }
+            rightAnswer = list.toArray(new String[list.size()]);
+            return rightAnswer;
+        }
+        return rightAnswer;
+    }
+
+    /**
+     * 设置试题答案
+     *
+     * @param question
+     * @return
+     */
+    private String[] getAnswer(Question question) {
+        String[] rightAnswer = null;
+        //判断题答案
+        if (question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION) {
+            if (question.getQuesAnswer().equals("正确")) {
+                rightAnswer = new String[1];
+                rightAnswer[0] = "true";
+                return rightAnswer;
+            }
+            if (question.getQuesAnswer().equals("错误")) {
+                rightAnswer = new String[1];
+                rightAnswer[0] = "false";
+                return rightAnswer;
+            }
+        }
+        //填空题答案
 		/*if(question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION){
 			rightAnswer = question.getQuesAnswer().split("##");
 			return rightAnswer;
 		}*/
-		rightAnswer = new String[1];
-		rightAnswer[0] = question.getQuesAnswer();
-		return rightAnswer;
-	}
-	
-	/**
-	 * html中添加音频标签
-	 * @param defaultQuestion
-	 * @param examId
-	 * @param courseCode
-	 * @param groupCode
-	 * @param question
-	 */
-	private void appendAudioFlag(DefaultQuestion defaultQuestion,String examId,String courseCode,String groupCode,Question question){
-		if(question.getHasAudio() != null && question.getHasAudio() == true){
-			//1.判断questionDto是否含有音频,如果有添加音频播放次数
-			AudioTimeConfig audioTimeConfig =  Model.of(audioTimeConfigRepo.findOne(Example.of(new AudioTimeConfig(examId,courseCode,groupCode,question.getId()))));
-			if(audioTimeConfig != null){
-				//2.1 取到题干,给a标签添加url
-				String quesBody = null;
-				if(StringUtils.isNotBlank(defaultQuestion.getMasterVersion().getBody())){
-					//套题
-					quesBody = defaultQuestion.getMasterVersion().getBody();
-					defaultQuestion.getMasterVersion().setBody(buildBody(quesBody, audioTimeConfig.getPlayTime()));
-				}else {
-					DefaultQuestionUnit defaultQuestionUnit = (DefaultQuestionUnit) defaultQuestion.getMasterVersion().getQuestionUnitList().get(0);
-					quesBody = defaultQuestionUnit.getBody();
-					defaultQuestionUnit.setBody(buildBody(quesBody, audioTimeConfig.getPlayTime()));
-					if(defaultQuestionUnit.getQuestionType() == QuestionType.SINGLE_CHOICE || defaultQuestionUnit.getQuestionType() == QuestionType.MULTIPLE_CHOICE){
-						List<DefaultQuestionOption> questionOptionList = defaultQuestionUnit.getQuestionOptionList();
-						if(questionOptionList != null && questionOptionList.size()>0){
-							for(int i = 0;i<questionOptionList.size();i++){
-								DefaultQuestionOption defaultQuestionOption = questionOptionList.get(i);
-								defaultQuestionOption.setBody(buildBody(defaultQuestionOption.getBody(), audioTimeConfig.getPlayTime()));
-							}
-						}
-					}
-				}
-			}else {
-				String quesBody = null;
-				if(StringUtils.isNotBlank(defaultQuestion.getMasterVersion().getBody())){
-					//套题
-					quesBody = defaultQuestion.getMasterVersion().getBody();
-					defaultQuestion.getMasterVersion().setBody(buildBody(quesBody, null));
-				}else {
-					DefaultQuestionUnit defaultQuestionUnit = (DefaultQuestionUnit) defaultQuestion.getMasterVersion().getQuestionUnitList().get(0);
-					quesBody = defaultQuestionUnit.getBody();
-					defaultQuestionUnit.setBody(buildBody(quesBody, null));
-					if(defaultQuestionUnit.getQuestionType() == QuestionType.SINGLE_CHOICE || defaultQuestionUnit.getQuestionType() == QuestionType.MULTIPLE_CHOICE){
-						List<DefaultQuestionOption> questionOptionList = defaultQuestionUnit.getQuestionOptionList();
-						if(questionOptionList != null && questionOptionList.size()>0){
-							for(int i = 0;i<questionOptionList.size();i++){
-								DefaultQuestionOption defaultQuestionOption = questionOptionList.get(i);
-								defaultQuestionOption.setBody(buildBody(defaultQuestionOption.getBody(), null));
-							}
-						}
-					}
-				}
-			}
-		}
-	}
-	
-	/**
-	 * 给题目和选项添加url
-	 * @param body
-	 * @param playTime
-	 * @return
-	 */
-	public String buildBody(String body,Integer playTime){
-		String[] bodyStrings = body.split("></a>");
-		if(bodyStrings.length>1){
-			String resultBody = "";
-			for(int i = 0;i<bodyStrings.length;i++){
-				String containAStr = bodyStrings[i];
-				if(containAStr.indexOf("<a")>-1){
-					String questionAudioId = matchAudioName(containAStr, "a", "id");
-					QuestionAudio questionAudio = questionAudioService.findAudioById(questionAudioId);
-					if(questionAudio!=null){
-						String url = downloadUrl + questionAudio.getFileUrl();
-						if(playTime!=null){
-							containAStr += " question-audio url=\""+url+"\" playTime=\""+playTime+"\""+"></a>";
-						}else{
-							containAStr += " question-audio url=\""+url+"\""+"></a>";
-						}
-					}
-				}
-				resultBody+=containAStr;
-			}
-			return resultBody;
-		}else{
-			return body;
-		}
-	}
-	
-	/**
-	 * 获取一段html中某个标签的值
-	 * @param source
-	 * @param element
-	 * @param attr
-	 * @return
-	 */
-	private String matchAudioName(String source, String element, String attr) {  
-        String reg = "<" + element + "[^<>]*?\\s" + attr + "=['\"]?(.*?)['\"]?(\\s.*?)";  
-        Matcher m = Pattern.compile(reg).matcher(source);  
-        while (m.find()) {  
+        rightAnswer = new String[1];
+        rightAnswer[0] = question.getQuesAnswer();
+        return rightAnswer;
+    }
+
+    /**
+     * html中添加音频标签
+     *
+     * @param defaultQuestion
+     * @param examId
+     * @param courseCode
+     * @param groupCode
+     * @param question
+     */
+    private void appendAudioFlag(DefaultQuestion defaultQuestion, String examId, String courseCode, String groupCode, Question question) {
+        if (question.getHasAudio() != null && question.getHasAudio() == true) {
+            //1.判断questionDto是否含有音频,如果有添加音频播放次数
+            AudioTimeConfig audioTimeConfig = Model.of(audioTimeConfigRepo.findOne(Example.of(new AudioTimeConfig(examId, courseCode, groupCode, question.getId()))));
+            if (audioTimeConfig != null) {
+                //2.1 取到题干,给a标签添加url
+                String quesBody = null;
+                if (StringUtils.isNotBlank(defaultQuestion.getMasterVersion().getBody())) {
+                    //套题
+                    quesBody = defaultQuestion.getMasterVersion().getBody();
+                    defaultQuestion.getMasterVersion().setBody(buildBody(quesBody, audioTimeConfig.getPlayTime()));
+                } else {
+                    DefaultQuestionUnit defaultQuestionUnit = (DefaultQuestionUnit) defaultQuestion.getMasterVersion().getQuestionUnitList().get(0);
+                    quesBody = defaultQuestionUnit.getBody();
+                    defaultQuestionUnit.setBody(buildBody(quesBody, audioTimeConfig.getPlayTime()));
+                    if (defaultQuestionUnit.getQuestionType() == QuestionType.SINGLE_CHOICE || defaultQuestionUnit.getQuestionType() == QuestionType.MULTIPLE_CHOICE) {
+                        List<DefaultQuestionOption> questionOptionList = defaultQuestionUnit.getQuestionOptionList();
+                        if (questionOptionList != null && questionOptionList.size() > 0) {
+                            for (int i = 0; i < questionOptionList.size(); i++) {
+                                DefaultQuestionOption defaultQuestionOption = questionOptionList.get(i);
+                                defaultQuestionOption.setBody(buildBody(defaultQuestionOption.getBody(), audioTimeConfig.getPlayTime()));
+                            }
+                        }
+                    }
+                }
+            } else {
+                String quesBody = null;
+                if (StringUtils.isNotBlank(defaultQuestion.getMasterVersion().getBody())) {
+                    //套题
+                    quesBody = defaultQuestion.getMasterVersion().getBody();
+                    defaultQuestion.getMasterVersion().setBody(buildBody(quesBody, null));
+                } else {
+                    DefaultQuestionUnit defaultQuestionUnit = (DefaultQuestionUnit) defaultQuestion.getMasterVersion().getQuestionUnitList().get(0);
+                    quesBody = defaultQuestionUnit.getBody();
+                    defaultQuestionUnit.setBody(buildBody(quesBody, null));
+                    if (defaultQuestionUnit.getQuestionType() == QuestionType.SINGLE_CHOICE || defaultQuestionUnit.getQuestionType() == QuestionType.MULTIPLE_CHOICE) {
+                        List<DefaultQuestionOption> questionOptionList = defaultQuestionUnit.getQuestionOptionList();
+                        if (questionOptionList != null && questionOptionList.size() > 0) {
+                            for (int i = 0; i < questionOptionList.size(); i++) {
+                                DefaultQuestionOption defaultQuestionOption = questionOptionList.get(i);
+                                defaultQuestionOption.setBody(buildBody(defaultQuestionOption.getBody(), null));
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 给题目和选项添加url
+     *
+     * @param body
+     * @param playTime
+     * @return
+     */
+    public String buildBody(String body, Integer playTime) {
+        String[] bodyStrings = body.split("></a>");
+        if (bodyStrings.length > 1) {
+            String resultBody = "";
+            for (int i = 0; i < bodyStrings.length; i++) {
+                String containAStr = bodyStrings[i];
+                if (containAStr.indexOf("<a") > -1) {
+                    String questionAudioId = matchAudioName(containAStr, "a", "id");
+                    QuestionAudio questionAudio = questionAudioService.findAudioById(questionAudioId);
+                    if (questionAudio != null) {
+                        String url = downloadUrl + questionAudio.getFileUrl();
+                        if (playTime != null) {
+                            containAStr += " question-audio url=\"" + url + "\" playTime=\"" + playTime + "\"" + "></a>";
+                        } else {
+                            containAStr += " question-audio url=\"" + url + "\"" + "></a>";
+                        }
+                    }
+                }
+                resultBody += containAStr;
+            }
+            return resultBody;
+        } else {
+            return body;
+        }
+    }
+
+    /**
+     * 获取一段html中某个标签的值
+     *
+     * @param source
+     * @param element
+     * @param attr
+     * @return
+     */
+    private String matchAudioName(String source, String element, String attr) {
+        String reg = "<" + element + "[^<>]*?\\s" + attr + "=['\"]?(.*?)['\"]?(\\s.*?)";
+        Matcher m = Pattern.compile(reg).matcher(source);
+        while (m.find()) {
             return m.group(1);
-        }  
-        return "";  
+        }
+        return "";
+    }
+
+    /**
+     * 检查所有题目是否为客观题
+     *
+     * @param paperDetailUnits
+     * @return
+     */
+    private boolean checkIsAllQbjectiveQuestion(List<PaperDetailUnit> paperDetailUnits) {
+        for (PaperDetailUnit paperDetailUnit : paperDetailUnits) {
+            Question question = paperDetailUnit.getQuestion();
+            //填空或问答
+            if (question.getQuestionType() == QuesStructType.FILL_BLANK_QUESTION
+                    || question.getQuestionType() == QuesStructType.TEXT_ANSWER_QUESTION) {
+                return false;
+            }
+            if (question.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
+                List<Question> subQuestions = question.getSubQuestions();
+                for (Question subQuestion : subQuestions) {
+                    if (subQuestion.getQuestionType() == QuesStructType.FILL_BLANK_QUESTION
+                            || subQuestion.getQuestionType() == QuesStructType.TEXT_ANSWER_QUESTION) {
+                        return false;
+                    }
+                }
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public DefaultPaper getBaseDefaultPaper(String paperId) {
+        Paper basePaper = Model.of(paperRepo.findById(paperId));
+        if (basePaper == null) {
+            log.error("该考试和课程下调卷规则中该类型试卷不存在,请检查调卷规则,调卷程序退出");
+            throw new StatusException("Q-020560", "该考试和课程下调卷规则中试卷不存在,请重新制定调卷规则");
+        }
+        //构建试卷结构
+        DefaultPaper defaultPaper = buildDefaultByBasePaper(basePaper, null, null, null);
+        return defaultPaper;
     }
-	
-	/**
-	 * 检查所有题目是否为客观题
-	 * @param paperDetailUnits
-	 * @return
-	 */
-	private boolean checkIsAllQbjectiveQuestion(List<PaperDetailUnit> paperDetailUnits) {
-		for(PaperDetailUnit paperDetailUnit:paperDetailUnits){
-			Question question = paperDetailUnit.getQuestion();
-			//填空或问答
-			if(question.getQuestionType()==QuesStructType.FILL_BLANK_QUESTION
-					||question.getQuestionType()==QuesStructType.TEXT_ANSWER_QUESTION){
-				return false;
-			}
-			if(question.getQuestionType()==QuesStructType.NESTED_ANSWER_QUESTION){
-				List<Question> subQuestions = question.getSubQuestions();
-				for(Question subQuestion:subQuestions){
-					if(subQuestion.getQuestionType()==QuesStructType.FILL_BLANK_QUESTION
-							||subQuestion.getQuestionType()==QuesStructType.TEXT_ANSWER_QUESTION){
-						return false;
-					}
-				}
-			}
-		}
-		return true;
-	}
-
-	@Override
-	public DefaultPaper getBaseDefaultPaper(String paperId) {
-		Paper basePaper = Model.of( paperRepo.findById(paperId));
-		if(basePaper==null){
-			log.error("该考试和课程下调卷规则中该类型试卷不存在,请检查调卷规则,调卷程序退出");
-			throw new StatusException("Q-020560","该考试和课程下调卷规则中试卷不存在,请重新制定调卷规则");
-		}
-		//构建试卷结构
-		DefaultPaper defaultPaper = buildDefaultByBasePaper(basePaper,null,null,null);
-		return defaultPaper;
-	}
-
-	@Override
-	public Map<String, DefaultQuestion> getDefaultQuestions(Set<String> questionIds) {
-		Map<String, DefaultQuestion> map = new HashMap<String, DefaultQuestion>();
-		List<Question> questions = quesRepo.findByIdIn(questionIds);
-		if(CollectionUtils.isEmpty(questions)){
-			log.error("根据试题id的集合没有查询到试题结合");
-			throw new StatusException("Q-020572","根据试题id的集合没有查询到试题结合");
-		}
-		for(Question question:questions){
-			DefaultQuestion defaultQuestion = getDefaultQuestion(null, null, null, question.getId());
-			map.put(question.getId(), defaultQuestion);
-		}
-		return map;
-	}
-
-	@Override
-	public List<String> getAnswer(String questionId) {
-		List<String> list = new ArrayList<String>();
-		Question question = Model.of( quesRepo.findById(questionId));
-		if(question.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION){
-			List<Question> subList = question.getSubQuestions();
-			if(subList!=null && subList.size()>0){
-				String answer = "";
-				for(Question subQuestion:subList){
-					if(subQuestion.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION || subQuestion.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION){
-						String[] answers = getSelectQuestionAnswer(subQuestion.getQuesOptions());
-						for(int i =0;i<answers.length;i++){
-							if(i==0){
-								answer = answers[i];
-							}
-							answer = answer + "," + answers[i];
-						}
-					}else if(subQuestion.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION){
-						if(subQuestion.getQuesAnswer().endsWith("正确")){
-							answer = "true";
-						}else {
-							answer = "false";
-						}
-					}else {
-						answer = subQuestion.getQuesAnswer();
-					}
-					list.add(answer);
-				}
-			}
-		}else {
-			String answer = "";
-			if(question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION || question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION){
-				String[] answers = getSelectQuestionAnswer(question.getQuesOptions());
-				for(int i =0;i<answers.length;i++){
-					if(i==0){
-						answer = answers[i];
-					}
-					answer = answer + "," + answers[i];
-				}
-			}else if(question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION){
-				if(question.getQuesAnswer().endsWith("正确")){
-					answer = "true";
-				}else {
-					answer = "false";
-				}
-			}else {
-				answer = question.getQuesAnswer();
-			}
-			list.add(answer);
-		}
-		return list;
-	}
-
-	@Override
-	public String getQuestionStructure(String paperId) throws Exception {
-		String json = paperService.findQuestionStructure(paperId);
-		return json;
-	}
-	
+
+    @Override
+    public Map<String, DefaultQuestion> getDefaultQuestions(Set<String> questionIds) {
+        Map<String, DefaultQuestion> map = new HashMap<String, DefaultQuestion>();
+        List<Question> questions = quesRepo.findByIdIn(questionIds);
+        if (CollectionUtils.isEmpty(questions)) {
+            log.error("根据试题id的集合没有查询到试题结合");
+            throw new StatusException("Q-020572", "根据试题id的集合没有查询到试题结合");
+        }
+        for (Question question : questions) {
+            DefaultQuestion defaultQuestion = getDefaultQuestion(null, null, null, question.getId());
+            map.put(question.getId(), defaultQuestion);
+        }
+        return map;
+    }
+
+    @Override
+    public List<String> getAnswer(String questionId) {
+        List<String> list = new ArrayList<String>();
+        Question question = Model.of(quesRepo.findById(questionId));
+        if (question.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
+            List<Question> subList = question.getSubQuestions();
+            if (subList != null && subList.size() > 0) {
+                String answer = "";
+                for (Question subQuestion : subList) {
+                    if (subQuestion.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION || subQuestion.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
+                        String[] answers = getSelectQuestionAnswer(subQuestion.getQuesOptions());
+                        for (int i = 0; i < answers.length; i++) {
+                            if (i == 0) {
+                                answer = answers[i];
+                            }
+                            answer = answer + "," + answers[i];
+                        }
+                    } else if (subQuestion.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION) {
+                        if (subQuestion.getQuesAnswer().endsWith("正确")) {
+                            answer = "true";
+                        } else {
+                            answer = "false";
+                        }
+                    } else {
+                        answer = subQuestion.getQuesAnswer();
+                    }
+                    list.add(answer);
+                }
+            }
+        } else {
+            String answer = "";
+            if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION || question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
+                String[] answers = getSelectQuestionAnswer(question.getQuesOptions());
+                for (int i = 0; i < answers.length; i++) {
+                    if (i == 0) {
+                        answer = answers[i];
+                    }
+                    answer = answer + "," + answers[i];
+                }
+            } else if (question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION) {
+                if (question.getQuesAnswer().endsWith("正确")) {
+                    answer = "true";
+                } else {
+                    answer = "false";
+                }
+            } else {
+                answer = question.getQuesAnswer();
+            }
+            list.add(answer);
+        }
+        return list;
+    }
+
+    @Override
+    public String getQuestionStructure(String paperId) throws Exception {
+        String json = paperService.findQuestionStructure(paperId);
+        return json;
+    }
+
 }

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 485 - 481
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExtractConfigServiceImpl.java


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 493 - 486
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/GenPaperService.java


+ 15 - 15
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PaperDetailServiceImpl.java

@@ -19,13 +19,13 @@ import cn.com.qmth.examcloud.core.questions.service.PaperDetailUnitService;
 import cn.com.qmth.examcloud.core.questions.service.QuesTypeNameService;
 
 /**
- * @author  	chenken
- * @date    	2017年9月13日 上午11:32:33
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年9月13日 上午11:32:33
+ * @company QMTH
  * @description PaperDetailServiceImpl.java
  */
 @Service("paperDetailService")
-public class PaperDetailServiceImpl implements PaperDetailService{
+public class PaperDetailServiceImpl implements PaperDetailService {
 
     @Autowired
     PaperDetailRepo paperDetailRepo;
@@ -35,7 +35,7 @@ public class PaperDetailServiceImpl implements PaperDetailService{
 
     @Autowired
     PaperRepo paperRepo;
-    
+
     @Autowired
     QuesTypeNameService quesTypeNameService;
 
@@ -44,12 +44,12 @@ public class PaperDetailServiceImpl implements PaperDetailService{
     PaperDetailUnitRepo paperDetailUnitRepo;
 
     @SuppressWarnings("rawtypes")
-	@Autowired
+    @Autowired
     RedisTemplate redisTemplate;
 
     /**
      * 根据Id获得对应所有小题
-     * 
+     *
      * @param id
      * @return
      */
@@ -59,22 +59,22 @@ public class PaperDetailServiceImpl implements PaperDetailService{
 
     /**
      * 按ID查询大题
-     * 
+     *
      * @param id
      * @return
      */
     public PaperDetail findById(String id) {
-        return  Model.of(paperDetailRepo.findById(id));
+        return Model.of(paperDetailRepo.findById(id));
     }
 
     /**
      * 保存大题
-     * 
+     *
      * @param pd
      * @return
      */
     public PaperDetail savePaperDetail(PaperDetail pd, String paperId, User user) {
-        Paper paper =  Model.of(paperRepo.findById(paperId));
+        Paper paper = Model.of(paperRepo.findById(paperId));
         paper.setLastModifyName(user.getDisplayName());
         paper = paperRepo.save(paper);
         pd.setPaper(paper);
@@ -86,7 +86,7 @@ public class PaperDetailServiceImpl implements PaperDetailService{
 
     /**
      * 删除大题
-     * 
+     *
      * @param id
      * @return
      */
@@ -96,7 +96,7 @@ public class PaperDetailServiceImpl implements PaperDetailService{
 
     /**
      * 查询同一个试卷对象对应大题
-     * 
+     *
      * @param paper
      * @return
      */
@@ -106,7 +106,7 @@ public class PaperDetailServiceImpl implements PaperDetailService{
 
     /**
      * 删除试卷大题
-     * 
+     *
      * @param paper
      */
     public void deletePaperDetailsByPaper(Paper paper) {
@@ -117,7 +117,7 @@ public class PaperDetailServiceImpl implements PaperDetailService{
 
     /**
      * 批量删除试卷大题
-     * 
+     *
      * @param papers
      */
     public void deletePaperDetailsByPapers(List<Paper> papers) {

+ 101 - 96
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PaperDetailUnitServiceImpl.java

@@ -37,13 +37,13 @@ import cn.com.qmth.examcloud.core.questions.service.QuesService;
 import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
 
 /**
- * @author  	chenken
- * @date    	2017年9月13日 上午11:29:56
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年9月13日 上午11:29:56
+ * @company QMTH
  * @description PaperDetailUnitServiceImpl.java
  */
 @Service("paperDetailUnitService")
-public class PaperDetailUnitServiceImpl implements PaperDetailUnitService{
+public class PaperDetailUnitServiceImpl implements PaperDetailUnitService {
 
     @Autowired
     PaperDetailUnitRepo paperDetailUnitRepo;
@@ -53,41 +53,44 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService{
 
     @Autowired
     PaperService paperService;
-    
+
     @Autowired
     MongoTemplate mongoTemplate;
-    
+
     @Autowired
-	RedisClient redisClient;
-    
+    RedisClient redisClient;
+
     @Value("${$redis.paper.prefix}")
     private String redisPaperPrefix;
 
     /**
      * 根据Id获得对应的试题对象
+     *
      * @param id
      * @return
      */
     public Question getQuestionByPaperDetailUnitId(String id) {
-        return  Model.of(paperDetailUnitRepo.findById(id)).getQuestion();
+        return Model.of(paperDetailUnitRepo.findById(id)).getQuestion();
     }
 
     /**
      * 按ID查询小题
+     *
      * @param id
      * @return
      */
     public PaperDetailUnit findById(String id) {
-        return  Model.of(paperDetailUnitRepo.findById(id));
+        return Model.of(paperDetailUnitRepo.findById(id));
     }
 
     /**
      * 保存小题
+     *
      * @param pduExp
      * @return
      */
     public PaperDetailUnit savePaperDetailUnit(PaperDetailUnitExp pduExp, User user) {
-        PaperDetailUnit oldPdu =  Model.of(paperDetailUnitRepo.findById(pduExp.getId()));
+        PaperDetailUnit oldPdu = Model.of(paperDetailUnitRepo.findById(pduExp.getId()));
         if (oldPdu.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
             if (pduExp.getQuestion().getId().equals(oldPdu.getQuestion().getId())) {
                 // 更新对象为套题本身
@@ -107,26 +110,26 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService{
                         // 匹配到子题
                         subScoreList.set(index - 1, pduExp.getScore());
                         oldPdu.getQuestion().getSubQuestions().set(index - 1, pduExp.getQuestion());
-                       //重新计算套题的难度,公开度
+                        //重新计算套题的难度,公开度
                         boolean publicity = false;
                         double totalSum = 0d;
                         double totalDou = 0d;
-                        for(int i =0;i<oldPdu.getQuestion().getSubQuestions().size();i++){
-                        	Question subQuestion = oldPdu.getQuestion().getSubQuestions().get(i);
-                			//设置公开度
-                			if(subQuestion.getPublicity()){
-                				publicity = true;
-                			}
-                			if(subQuestion.getDifficultyDegree() == null){
-                				subQuestion.setDifficultyDegree(0.5);
-                			}
-                			totalSum = subQuestion.getDifficultyDegree()*subScoreList.get(i) + totalSum;
-                			totalDou = subScoreList.get(i) + totalDou;
-                		}
-                		BigDecimal b = new BigDecimal(totalSum / totalDou);
-            			Double difficulty = b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
-            			oldPdu.getQuestion().setDifficultyDegree(difficulty);
-            			oldPdu.getQuestion().setPublicity(publicity);
+                        for (int i = 0; i < oldPdu.getQuestion().getSubQuestions().size(); i++) {
+                            Question subQuestion = oldPdu.getQuestion().getSubQuestions().get(i);
+                            //设置公开度
+                            if (subQuestion.getPublicity()) {
+                                publicity = true;
+                            }
+                            if (subQuestion.getDifficultyDegree() == null) {
+                                subQuestion.setDifficultyDegree(0.5);
+                            }
+                            totalSum = subQuestion.getDifficultyDegree() * subScoreList.get(i) + totalSum;
+                            totalDou = subScoreList.get(i) + totalDou;
+                        }
+                        BigDecimal b = new BigDecimal(totalSum / totalDou);
+                        Double difficulty = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+                        oldPdu.getQuestion().setDifficultyDegree(difficulty);
+                        oldPdu.getQuestion().setPublicity(publicity);
                         match = true;
                     }
                 }
@@ -153,10 +156,10 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService{
      * @return
      */
     public void deletePaperDetailUnit(String id, User user) {
-        Paper paper =  Model.of(paperDetailUnitRepo.findById(id)).getPaper();
+        Paper paper = Model.of(paperDetailUnitRepo.findById(id)).getPaper();
         paperDetailUnitRepo.deleteById(id);
-        if(paper.getPaperType() == PaperType.GENERATE){
-        	redisClient.delete(redisPaperPrefix+":"+paper.getId());
+        if (paper.getPaperType() == PaperType.GENERATE) {
+            redisClient.delete(redisPaperPrefix + ":" + paper.getId());
         }
         paperService.formatPaper(paper, user);
     }
@@ -183,75 +186,77 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService{
         }
         paperDetailUnitRepo.deleteAll(units);
     }
-    
-    public List<PaperDetailUnit> findByQuestionAndPaperTypes(Question question,List<PaperType> paperTypes){
-    	Query query = new Query();
-    	query.addCriteria(Criteria.where("paperType").in(paperTypes));
-    	query.addCriteria(Criteria.where("question").is(question));
-    	return this.mongoTemplate.find(query, PaperDetailUnit.class);
+
+    public List<PaperDetailUnit> findByQuestionAndPaperTypes(Question question, List<PaperType> paperTypes) {
+        Query query = new Query();
+        query.addCriteria(Criteria.where("paperType").in(paperTypes));
+        query.addCriteria(Criteria.where("question").is(question));
+        return this.mongoTemplate.find(query, PaperDetailUnit.class);
     }
-    
+
     /**
      * 查询大题下的小题
      * 按number升序或降序排列,取第一个
+     *
      * @return
      */
-    public PaperDetailUnit findTopOrderByNumber(PaperDetail paperDetail,String orderType){
-    	if("ASC".equals(orderType)){
-    		return paperDetailUnitRepo.findTopByPaperDetailOrderByNumberAsc(paperDetail);
-    	}else if("DESC".equals(orderType)){
-    		return paperDetailUnitRepo.findTopByPaperDetailOrderByNumberDesc(paperDetail);
-    	}
-		return null;
+    public PaperDetailUnit findTopOrderByNumber(PaperDetail paperDetail, String orderType) {
+        if ("ASC".equals(orderType)) {
+            return paperDetailUnitRepo.findTopByPaperDetailOrderByNumberAsc(paperDetail);
+        } else if ("DESC".equals(orderType)) {
+            return paperDetailUnitRepo.findTopByPaperDetailOrderByNumberDesc(paperDetail);
+        }
+        return null;
     }
-    
+
     /**
      * 按试卷 查询 小题,并将小题按number,createTime排序
+     *
      * @param paper
      * @return
      */
-    public List<PaperDetailUnit> findByPaperAndSort(Paper paper){
-    	Query query = new Query();
-    	query.addCriteria(Criteria.where("paper").is(paper));
-    	query.with(new Sort(new Order(Direction.ASC,"number")));
-    	query.with(new Sort(new Order(Direction.ASC,"createTime")));
-    	return this.mongoTemplate.find(query, PaperDetailUnit.class);
+    public List<PaperDetailUnit> findByPaperAndSort(Paper paper) {
+        Query query = new Query();
+        query.addCriteria(Criteria.where("paper").is(paper));
+        query.with(new Sort(new Order(Direction.ASC, "number")));
+        query.with(new Sort(new Order(Direction.ASC, "createTime")));
+        return this.mongoTemplate.find(query, PaperDetailUnit.class);
     }
 
-	
-	public List<PaperDetailUnit> findByQuestionsAndPaperTypeOnline(List<String> ids,PaperType paperType) {
-		Query query=new Query();
-		query.addCriteria(Criteria.where("question.id").in(ids));
-		query.addCriteria(Criteria.where("paperType").is(paperType));
-		List<PaperDetailUnit> paperDetailUnits = this.mongoTemplate.find(query, PaperDetailUnit.class);
-		return paperDetailUnits;
-	}
-	
-	@Override
-	public List<PaperDetailUnit> findByQuestionsAndPaperType(List<String> ids,PaperType paperType) {
-		List<ObjectId> objectIds = new ArrayList<ObjectId>();
-		for(String id:ids){
-			objectIds.add(new ObjectId(id));
-		}
-		Query query=new Query();
-		query.addCriteria(Criteria.where("question.$id").in(objectIds));
-		query.addCriteria(Criteria.where("paperType").is(paperType));
-		List<PaperDetailUnit> paperDetailUnits = this.mongoTemplate.find(query, PaperDetailUnit.class);
-		return paperDetailUnits;
-	}
 
-	@Override
-	public List<PaperDetailUnit> findByDDQuestionsAndPaperType(List<String> ids, PaperType paperType,List<Question> questionList) {
-		List<ObjectId> objectIds = new ArrayList<ObjectId>();
-		for(String id:ids){
-			objectIds.add(new ObjectId(id));
-		}
-		Query query=new Query();
-		query.addCriteria(Criteria.where("question.$id").in(objectIds));
-		query.addCriteria(Criteria.where("paperType").is("IMPORT"));
-		List<PaperDetailUnit> paperDetailUnits = mongoTemplate.find(query, PaperDetailUnit.class);
-		return paperDetailUnits;
-	}
+    public List<PaperDetailUnit> findByQuestionsAndPaperTypeOnline(List<String> ids, PaperType paperType) {
+        Query query = new Query();
+        query.addCriteria(Criteria.where("question.id").in(ids));
+        query.addCriteria(Criteria.where("paperType").is(paperType));
+        List<PaperDetailUnit> paperDetailUnits = this.mongoTemplate.find(query, PaperDetailUnit.class);
+        return paperDetailUnits;
+    }
+
+    @Override
+    public List<PaperDetailUnit> findByQuestionsAndPaperType(List<String> ids, PaperType paperType) {
+        List<ObjectId> objectIds = new ArrayList<ObjectId>();
+        for (String id : ids) {
+            objectIds.add(new ObjectId(id));
+        }
+        Query query = new Query();
+        query.addCriteria(Criteria.where("question.$id").in(objectIds));
+        query.addCriteria(Criteria.where("paperType").is(paperType));
+        List<PaperDetailUnit> paperDetailUnits = this.mongoTemplate.find(query, PaperDetailUnit.class);
+        return paperDetailUnits;
+    }
+
+    @Override
+    public List<PaperDetailUnit> findByDDQuestionsAndPaperType(List<String> ids, PaperType paperType, List<Question> questionList) {
+        List<ObjectId> objectIds = new ArrayList<ObjectId>();
+        for (String id : ids) {
+            objectIds.add(new ObjectId(id));
+        }
+        Query query = new Query();
+        query.addCriteria(Criteria.where("question.$id").in(objectIds));
+        query.addCriteria(Criteria.where("paperType").is("IMPORT"));
+        List<PaperDetailUnit> paperDetailUnits = mongoTemplate.find(query, PaperDetailUnit.class);
+        return paperDetailUnits;
+    }
 
 	/*@Override
 	public List<PaperDetailUnit> testFind(List<String> ids,PaperType paperType, List<Question> questionList) {
@@ -296,16 +301,16 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService{
 		return null;
 	}*/
 
-	@Override
-	public List<PaperDetailUnit> findByPaperIds(List<String> ids) {
-		List<ObjectId> objectIds = new ArrayList<ObjectId>();
-		for(String id:ids){
-			objectIds.add(new ObjectId(id));
-		}
-		Query query=new Query();
-		query.addCriteria(Criteria.where("paper.$id").in(objectIds));
-		List<PaperDetailUnit> paperDetailUnits = mongoTemplate.find(query, PaperDetailUnit.class);
-		return paperDetailUnits;
-	}
+    @Override
+    public List<PaperDetailUnit> findByPaperIds(List<String> ids) {
+        List<ObjectId> objectIds = new ArrayList<ObjectId>();
+        for (String id : ids) {
+            objectIds.add(new ObjectId(id));
+        }
+        Query query = new Query();
+        query.addCriteria(Criteria.where("paper.$id").in(objectIds));
+        List<PaperDetailUnit> paperDetailUnits = mongoTemplate.find(query, PaperDetailUnit.class);
+        return paperDetailUnits;
+    }
 }
 

+ 189 - 186
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PaperProviderServiceImpl.java

@@ -35,215 +35,218 @@ import cn.com.qmth.examcloud.core.questions.service.PaperProviderService;
 import cn.com.qmth.examcloud.question.commons.core.paper.DefaultPaper;
 
 /**
- * @author 		weiwenhai
- * @date		2018.10.8
- * @company		qmth
- * @description	paperProviderServiceImpl
- * @code		014
+ * @author weiwenhai
+ * @date 2018.10.8
+ * @company qmth
+ * @description paperProviderServiceImpl
+ * @code 014
  */
 @Service("paperProviderServiceImpl")
-public class PaperProviderServiceImpl implements PaperProviderService{
+public class PaperProviderServiceImpl implements PaperProviderService {
 
-	protected ExamCloudLog log = ExamCloudLogFactory.getLog(this.getClass());
-	
-	@Autowired
+    protected ExamCloudLog log = ExamCloudLogFactory.getLog(this.getClass());
+
+    @Autowired
     private QuesRepo quesRepo;
-	
-	@Autowired
+
+    @Autowired
     PaperRepo paperRepo;
 
     @Autowired
     PaperDetailRepo paperDetailRepo;
-    
+
     @Autowired
     PaperDetailUnitRepo paperDetailUnitRepo;
-    
+
     @Autowired
     ExtractConfigProviderServiceImpl extractConfigProviderServiceImpl;
-    
+
     @Autowired
     ExtractConfigService extractConfigService;
-    
+
     @Autowired
     ExtractConfigRepo extractConfigRepo;
-	
-	@Override
-	public String genPaper(Set<String> questionIds,Map<String, PaperK12Bean> map,String paperName,String orgId,String userName){
-		if(questionIds == null || questionIds.size()<1){
-			throw new StatusException("Q-014038", "questionIds is null");
-		}
-		if(map == null || map.size()<1){
-			throw new StatusException("Q-014041", "map is null");
-		}
-		//查询所有试题集合
-		List<Question> questions = quesRepo.findByIdIn(questionIds);
-		if(CollectionUtils.isEmpty(questions)){
-			log.error("根据试题id的集合没有查询到试题结合");
-			throw new StatusException("Q-014041", "根据试题id的集合没有查询到试题结合");
-		}
-		//构建试卷对象
-		Paper paper = initPaper(paperName,orgId,userName);
-		//构建大题对象,未设置	
-		PaperDetail paperDetail = initPaperDetail(paper);
-		//构建包装试题对象
-		List<PaperDetailUnit> paperDetailUnits = buildUnits(paper,paperDetail,questions,map);
-		paper = paperRepo.save(paper);
-		paperDetailRepo.save(paperDetail);
-		quesRepo.saveAll(questions);
-		paperDetailUnitRepo.saveAll(paperDetailUnits);
-		return paper.getId();
-	}
-	
-	/**
-	 * 构建大题对象
-	 * @param paper
-	 * @return
-	 */
-	private PaperDetail initPaperDetail(Paper paper) {
-		PaperDetail paperDetail = new PaperDetail();
-		paperDetail.setPaper(paper);
+
+    @Override
+    public String genPaper(Set<String> questionIds, Map<String, PaperK12Bean> map, String paperName, String orgId, String userName) {
+        if (questionIds == null || questionIds.size() < 1) {
+            throw new StatusException("Q-014038", "questionIds is null");
+        }
+        if (map == null || map.size() < 1) {
+            throw new StatusException("Q-014041", "map is null");
+        }
+        //查询所有试题集合
+        List<Question> questions = quesRepo.findByIdIn(questionIds);
+        if (CollectionUtils.isEmpty(questions)) {
+            log.error("根据试题id的集合没有查询到试题结合");
+            throw new StatusException("Q-014041", "根据试题id的集合没有查询到试题结合");
+        }
+        //构建试卷对象
+        Paper paper = initPaper(paperName, orgId, userName);
+        //构建大题对象,未设置
+        PaperDetail paperDetail = initPaperDetail(paper);
+        //构建包装试题对象
+        List<PaperDetailUnit> paperDetailUnits = buildUnits(paper, paperDetail, questions, map);
+        paper = paperRepo.save(paper);
+        paperDetailRepo.save(paperDetail);
+        quesRepo.saveAll(questions);
+        paperDetailUnitRepo.saveAll(paperDetailUnits);
+        return paper.getId();
+    }
+
+    /**
+     * 构建大题对象
+     *
+     * @param paper
+     * @return
+     */
+    private PaperDetail initPaperDetail(Paper paper) {
+        PaperDetail paperDetail = new PaperDetail();
+        paperDetail.setPaper(paper);
         paperDetail.setName("默认大题");
         paperDetail.setNumber(1);
         paperDetail.setCreator(paper.getCreator());
-		return paperDetail;
-	}
-
-	/**
-	 * 构建试卷对象
-	 * @param paperName
-	 * @return
-	 */
-	private Paper initPaper(String paperName ,String orgId,String userName) {
-		Paper paper = new Paper();
-		//初始化默认课程
-		Course course = new Course();
-		course.setId("k12");
-		course.setId("k12");
-		course.setName("k12");
-		course.setOrgId(orgId);
-		course.setCreateTime(CommonUtils.getCurDateTime());
-		course.setEnable("true");
-		paper.setCourse(course);
-		paper.setName(paperName);
+        return paperDetail;
+    }
+
+    /**
+     * 构建试卷对象
+     *
+     * @param paperName
+     * @return
+     */
+    private Paper initPaper(String paperName, String orgId, String userName) {
+        Paper paper = new Paper();
+        //初始化默认课程
+        Course course = new Course();
+        course.setId("k12");
+        course.setId("k12");
+        course.setName("k12");
+        course.setOrgId(orgId);
+        course.setCreateTime(CommonUtils.getCurDateTime());
+        course.setEnable("true");
+        paper.setCourse(course);
+        paper.setName(paperName);
         paper.setTitle(paperName);
         paper.setPaperType(PaperType.GENERATE);
         paper.setOrgId(orgId);
         paper.setCreator(userName);
         paper.setCreateTime(CommonUtils.getCurDateTime());
-		return paper;
-	}
-
-	/**
-	 * 构建题包装器
-	 * @param questions
-	 * @param map
-	 * @return
-	 */
-	private List<PaperDetailUnit> buildUnits(Paper paper, PaperDetail paperDetail,List<Question> questions, Map<String, PaperK12Bean> map) {
-		List<PaperDetailUnit> paperDetailUnits = new ArrayList<PaperDetailUnit>();
-		int j = 0;
-		double score = 0;
-		double sum = 0;
-		for(int i=0;i<questions.size();i++){
-			PaperDetailUnit paperDetailUnit = new PaperDetailUnit();
-			paperDetailUnit.setNumber(i+1);
-			paperDetailUnit.setQuestion(questions.get(i));
-			paperDetailUnit.setPaperDetail(paperDetail);
-			paperDetailUnit.setQuestionType(questions.get(i).getQuestionType());
-			paperDetailUnit.setCreator(paper.getCreator());
-			paperDetailUnit.setPaper(paper);
-			paperDetailUnit.setPaperType(PaperType.GENERATE);
-			if(StringUtils.isBlank(map.get(questions.get(i).getId()).getScore()+"")){
-				throw new StatusException("Q-014157", questions.get(i).getId() + "分数未设置");
-			}
-			paperDetailUnit.setScore(map.get(questions.get(i).getId()).getScore());
-			if(!StringUtils.isBlank(map.get(questions.get(i).getId()).getTimeLimit()+"")){
-				paperDetailUnit.setTimeLimit(map.get(questions.get(i).getId()).getTimeLimit());
-			}
-			j++;
-			score = map.get(questions.get(i).getId()).getScore() + score;
-			sum = paperDetailUnit.getScore() * paperDetailUnit.getQuestion().getDifficultyDegree()/10 + sum;
-			paperDetailUnits.add(paperDetailUnit);
-		}
-		paperDetail.setUnitCount(j);
-		paperDetail.setScore(score);
-		BigDecimal b = new BigDecimal(sum / score);
-		Double difficulty = b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
-		paper.setTotalScore(score);
-		paper.setDifficultyDegree(difficulty);
-		return paperDetailUnits;
-	}
-
-	@Override
-	public DefaultPaper findPaper(String paperId) {
-		Paper basePaper = Model.of(paperRepo.findById(paperId));
-		if(basePaper == null){
-			throw new StatusException("Q-014180", "basePaper is null");
-		}
-		DefaultPaper defaultPaper = extractConfigProviderServiceImpl.buildDefaultByBasePaper(basePaper, null, null, null);
-		return defaultPaper;
-	}
-
-	@Override
-	public String examPaper(String orgId, String paperId, Long examId) {
-		ExtractConfig extractConfig = new ExtractConfig();
-		extractConfig.setExamId(examId);
-		extractConfig.setCourseCode("K12");
-		extractConfig.setOrgId(orgId);
-		ExtractConfig tempConfig = extractConfigService.findConfig(extractConfig);
-		if(tempConfig != null){
-			extractConfigRepo.delete(tempConfig);
-    	}
-		//查询试卷对象
-		Paper paper = Model.of(paperRepo.findById(paperId));
-		if(paper == null){
-			throw new StatusException("Q-014200", "paper is null");
-		}
-		//初始化默认课程
-		Course course = new Course();
-		course.setId("k12");
-		course.setCode("k12");
-		course.setName("k12");
-		course.setLevel("ALL");
-		course.setOrgId(orgId);
-		course.setCreateTime(CommonUtils.getCurDateTime());
-		course.setEnable("true");
-		extractConfig.setCourse(course);
-		extractConfig.setIfFinish((short)0);
-		ExamPaper examPaper = new ExamPaper();
-		examPaper.setId(null);
-		examPaper.setGroupCode("K");
-		examPaper.setWeight(100);
-		examPaper.setPaper(paper);
-		List<ExamPaper> examPaperList = new ArrayList<ExamPaper>();
-		examPaperList.add(examPaper);
-		extractConfig.setExamPaperList(examPaperList);
-		extractConfig.setScrambling_the_option_order((short)0);
-		extractConfig.setScrambling_the_question_order((short)0);
-		extractConfig = extractConfigRepo.save(extractConfig);
-		return extractConfig.getId();
-	}
-
-	@Override
-	public DefaultPaper findExamPaper(String orgId, Long examId) {
-		ExtractConfig extractConfig = new ExtractConfig();
-		extractConfig.setExamId(examId);
-		extractConfig.setCourseCode("K12");
-		extractConfig.setOrgId(orgId);
-		ExtractConfig tempConfig = extractConfigService.findConfig(extractConfig);
-		if(tempConfig == null){
-    		return null;
-    	}
-		List<ExamPaper> list = tempConfig.getExamPaperList();
-		if(list == null || list.size()<1){
-			throw new StatusException("Q-014252", "该场考试关联试卷集合为空");
-		}
-		String paperId = list.get(0).getPaper().getId();
-		if(StringUtils.isBlank(paperId)){
-			throw new StatusException("Q-014256", "该场考试关联的试卷id为空");
-		}
-		DefaultPaper defaultPaper = findPaper(paperId);
-		return defaultPaper;
-	}
+        return paper;
+    }
+
+    /**
+     * 构建题包装器
+     *
+     * @param questions
+     * @param map
+     * @return
+     */
+    private List<PaperDetailUnit> buildUnits(Paper paper, PaperDetail paperDetail, List<Question> questions, Map<String, PaperK12Bean> map) {
+        List<PaperDetailUnit> paperDetailUnits = new ArrayList<PaperDetailUnit>();
+        int j = 0;
+        double score = 0;
+        double sum = 0;
+        for (int i = 0; i < questions.size(); i++) {
+            PaperDetailUnit paperDetailUnit = new PaperDetailUnit();
+            paperDetailUnit.setNumber(i + 1);
+            paperDetailUnit.setQuestion(questions.get(i));
+            paperDetailUnit.setPaperDetail(paperDetail);
+            paperDetailUnit.setQuestionType(questions.get(i).getQuestionType());
+            paperDetailUnit.setCreator(paper.getCreator());
+            paperDetailUnit.setPaper(paper);
+            paperDetailUnit.setPaperType(PaperType.GENERATE);
+            if (StringUtils.isBlank(map.get(questions.get(i).getId()).getScore() + "")) {
+                throw new StatusException("Q-014157", questions.get(i).getId() + "分数未设置");
+            }
+            paperDetailUnit.setScore(map.get(questions.get(i).getId()).getScore());
+            if (!StringUtils.isBlank(map.get(questions.get(i).getId()).getTimeLimit() + "")) {
+                paperDetailUnit.setTimeLimit(map.get(questions.get(i).getId()).getTimeLimit());
+            }
+            j++;
+            score = map.get(questions.get(i).getId()).getScore() + score;
+            sum = paperDetailUnit.getScore() * paperDetailUnit.getQuestion().getDifficultyDegree() / 10 + sum;
+            paperDetailUnits.add(paperDetailUnit);
+        }
+        paperDetail.setUnitCount(j);
+        paperDetail.setScore(score);
+        BigDecimal b = new BigDecimal(sum / score);
+        Double difficulty = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+        paper.setTotalScore(score);
+        paper.setDifficultyDegree(difficulty);
+        return paperDetailUnits;
+    }
+
+    @Override
+    public DefaultPaper findPaper(String paperId) {
+        Paper basePaper = Model.of(paperRepo.findById(paperId));
+        if (basePaper == null) {
+            throw new StatusException("Q-014180", "basePaper is null");
+        }
+        DefaultPaper defaultPaper = extractConfigProviderServiceImpl.buildDefaultByBasePaper(basePaper, null, null, null);
+        return defaultPaper;
+    }
+
+    @Override
+    public String examPaper(String orgId, String paperId, Long examId) {
+        ExtractConfig extractConfig = new ExtractConfig();
+        extractConfig.setExamId(examId);
+        extractConfig.setCourseCode("K12");
+        extractConfig.setOrgId(orgId);
+        ExtractConfig tempConfig = extractConfigService.findConfig(extractConfig);
+        if (tempConfig != null) {
+            extractConfigRepo.delete(tempConfig);
+        }
+        //查询试卷对象
+        Paper paper = Model.of(paperRepo.findById(paperId));
+        if (paper == null) {
+            throw new StatusException("Q-014200", "paper is null");
+        }
+        //初始化默认课程
+        Course course = new Course();
+        course.setId("k12");
+        course.setCode("k12");
+        course.setName("k12");
+        course.setLevel("ALL");
+        course.setOrgId(orgId);
+        course.setCreateTime(CommonUtils.getCurDateTime());
+        course.setEnable("true");
+        extractConfig.setCourse(course);
+        extractConfig.setIfFinish((short) 0);
+        ExamPaper examPaper = new ExamPaper();
+        examPaper.setId(null);
+        examPaper.setGroupCode("K");
+        examPaper.setWeight(100);
+        examPaper.setPaper(paper);
+        List<ExamPaper> examPaperList = new ArrayList<ExamPaper>();
+        examPaperList.add(examPaper);
+        extractConfig.setExamPaperList(examPaperList);
+        extractConfig.setScrambling_the_option_order((short) 0);
+        extractConfig.setScrambling_the_question_order((short) 0);
+        extractConfig = extractConfigRepo.save(extractConfig);
+        return extractConfig.getId();
+    }
+
+    @Override
+    public DefaultPaper findExamPaper(String orgId, Long examId) {
+        ExtractConfig extractConfig = new ExtractConfig();
+        extractConfig.setExamId(examId);
+        extractConfig.setCourseCode("K12");
+        extractConfig.setOrgId(orgId);
+        ExtractConfig tempConfig = extractConfigService.findConfig(extractConfig);
+        if (tempConfig == null) {
+            return null;
+        }
+        List<ExamPaper> list = tempConfig.getExamPaperList();
+        if (list == null || list.size() < 1) {
+            throw new StatusException("Q-014252", "该场考试关联试卷集合为空");
+        }
+        String paperId = list.get(0).getPaper().getId();
+        if (StringUtils.isBlank(paperId)) {
+            throw new StatusException("Q-014256", "该场考试关联的试卷id为空");
+        }
+        DefaultPaper defaultPaper = findPaper(paperId);
+        return defaultPaper;
+    }
 
 }

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 655 - 643
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PaperServiceImpl.java


+ 176 - 175
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PropertyServiceImpl.java

@@ -13,184 +13,185 @@ import cn.com.qmth.examcloud.core.questions.dao.PropertyRepo;
 import cn.com.qmth.examcloud.core.questions.dao.entity.dto.PropertyDto;
 import cn.com.qmth.examcloud.core.questions.dao.entity.Property;
 import cn.com.qmth.examcloud.core.questions.service.PropertyService;
+
 /**
- * @describle 课程属性 coursePropertyServiceImpl
  * @author weiwenhai
- * @date   2017.11.8
+ * @describle 课程属性 coursePropertyServiceImpl
+ * @date 2017.11.8
  */
 @Service("propertyService")
-public class PropertyServiceImpl implements PropertyService{
-	
-	@Autowired
-	private PropertyRepo propertyRepo;
-
-	@Override
-	public void saveProperty(List<PropertyDto> propertyDtos, User user) {
-		PropertyAssembler propertyAssembler = new PropertyAssembler();
-		for(int i=0;i<propertyDtos.size();i++){
-			//取到父类节点对象
-			Property property = propertyAssembler.toProperty(propertyDtos.get(i));
-			property.setNumber(i+1);
-			property.setOrgId(user.getRootOrgId());
-			property = propertyRepo.save(property);
-			List<Property> properties = propertyAssembler.toPropertySon(propertyDtos.get(i));
-			if(properties != null && properties.size()>0){
-				for(int j=0;j<properties.size();j++){
-					properties.get(j).setParentId(property.getId());
-					properties.get(j).setNumber(j+1);
-				}
-				propertyRepo.saveAll(properties);
-			}
-		}
-	}
-
-	@Override
-	public List<PropertyDto> propertyDtos(Long coursePropertyId, User user) {
-		List<PropertyDto> propertyDtos = new ArrayList<PropertyDto>();
-		//查询所有父节点对象
-		List<Property> propertieParents = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(user.getRootOrgId(), coursePropertyId, 0l);
-		if(propertieParents != null && propertieParents.size()>0){
-			for(Property property:propertieParents){
-				PropertyDto propertyDtoParent = new PropertyDto(property);
-				//查询所有子节点对象
-				List<Property> propertiesSons = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(user.getRootOrgId(), coursePropertyId, property.getId());
-				if(propertiesSons != null && propertiesSons.size()>0){
-					List<PropertyDto> propertyDtosSons = new ArrayList<PropertyDto>();
-					for(Property property2:propertiesSons){
-						PropertyDto propertyDto2 = new PropertyDto(property2);
-						propertyDtosSons.add(propertyDto2);
-					}
-					propertyDtoParent.setPropertyDtos(propertyDtosSons);
-				}
-				propertyDtos.add(propertyDtoParent);
-			}
-		}
-		return propertyDtos;
-	}
-
-	@Override
-	public void saveProperty(Property property, User user) throws Exception {
-		//新增
-		if(property.getId() == null){
-			//检查是否重名
-			Property sameName = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdAndName(user.getRootOrgId(), property.getCoursePropertyId(), property.getParentId(), property.getName());
-			if(sameName != null){
-				throw new Exception("属性名已经存在");
-			}
-			Integer number = 0;
-			List<Property> propertieParents = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(user.getRootOrgId(), property.getCoursePropertyId(), property.getParentId());
-			if(propertieParents != null && propertieParents.size()>0){
-				number = propertieParents.get(propertieParents.size()-1).getNumber();
-			}
-			property.setNumber(number+1);
-		}else{
-			//得到原来的对象
-			Property propertyOld =  Model.of(propertyRepo.findById(property.getId()));
-			if(!propertyOld.getName().equals(property.getName())){
-				//检查是否重名
-				Property sameName = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdAndName(user.getRootOrgId(), property.getCoursePropertyId(), property.getParentId(), property.getName());
-				if(sameName != null){
-					throw new Exception("属性名已经存在");
-				}
-			}
-		}
-		property.setOrgId(user.getRootOrgId());
-		propertyRepo.save(property);
-	}
-
-	@Override
-	public void deleteProperty(Long propertyId, Long coursePropertyId, User user) {
-		//查询子节点对象
-		List<Property> properties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(user.getRootOrgId(), coursePropertyId, propertyId);
-		if(properties != null && properties.size()>0){
-			for(Property property:properties){
-				propertyRepo.delete(property);
-			}
-		}
-		propertyRepo.deleteById(propertyId);
-	}
-
-	@Override
-	public List<Property> findAll(Long coursePropertyId, User user) {
-		List<PropertyDto> propertyDtos = propertyDtos(coursePropertyId, user);
-		List<Property> properties = new ArrayList<Property>();
-		if(propertyDtos != null && propertyDtos.size() >0){
-			for(PropertyDto propertyDto:propertyDtos){
-				Property property = new Property(propertyDto);
-				properties.add(property);
-				if(propertyDto.getPropertyDtos() != null && propertyDto.getPropertyDtos().size() > 0){
-					for(PropertyDto propertyDtoSon:propertyDto.getPropertyDtos()){
-						Property propertySon = new Property(propertyDtoSon);
-						properties.add(propertySon);
-					}
-				}
-			}
-		}
-		return properties;
-	}
-
-	@Override
-	public List<Property> findPropertySons(Property property) {
-		List<Property> properySonsList = propertyRepo.findByParentIdOrderByNumber(property.getId());
-		return properySonsList;
-	}
-
-	@Override
-	public List<Property> findPropertySons(Long propertyId) {
-		List<Property> properySonsList = propertyRepo.findByParentIdOrderByNumber(propertyId);
-		return properySonsList;
-	}
-
-	@Override
-	public List<Property> findPropertyParents(Long coursePropertyId, Long orgId) {
-		List<Property> properties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(orgId, coursePropertyId, 0l);
-		return properties;
-	}
-
-	@Override
-	public void moveUp(Property property) throws Exception{
-		//查询所有一级属性
-		List<Property> properties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(property.getOrgId(), property.getCoursePropertyId(), 0L);
-		if(properties.size()<2){
-			throw new Exception("无法上移");
-		}else{
-			for(int i=0;i<properties.size();i++){
-				if(property.getId().equals(properties.get(i).getId())){
-					if(i==0){
-						throw new Exception("无法上移");
-					}else{
-						Integer number = property.getNumber();
-						property.setNumber(properties.get(i-1).getNumber());
-						properties.get(i-1).setNumber(number);
-						propertyRepo.save(property);
-						propertyRepo.save(properties.get(i-1));
-					}
-				}
-			}
-		}
-	}
-
-	@Override
-	public void moveDown(Property property) throws Exception{
-		//查询所有一级属性
-		List<Property> properties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(property.getOrgId(), property.getCoursePropertyId(), 0l);
-		if(properties.size()<2){
-			throw new Exception("无法下移");
-		}else{
-			for(int i=0;i<properties.size();i++){
-				if(property.getId().equals(properties.get(i).getId())){
-					if(i==(properties.size()-1)){
-						throw new Exception("无法下移");
-					}else{
-						Integer number = property.getNumber();
-						property.setNumber(properties.get(i+1).getNumber());
-						properties.get(i+1).setNumber(number);
-						propertyRepo.save(property);
-						propertyRepo.save(properties.get(i+1));
-					}
-				}
-			}
-		}
-	}
+public class PropertyServiceImpl implements PropertyService {
+
+    @Autowired
+    private PropertyRepo propertyRepo;
+
+    @Override
+    public void saveProperty(List<PropertyDto> propertyDtos, User user) {
+        PropertyAssembler propertyAssembler = new PropertyAssembler();
+        for (int i = 0; i < propertyDtos.size(); i++) {
+            //取到父类节点对象
+            Property property = propertyAssembler.toProperty(propertyDtos.get(i));
+            property.setNumber(i + 1);
+            property.setOrgId(user.getRootOrgId());
+            property = propertyRepo.save(property);
+            List<Property> properties = propertyAssembler.toPropertySon(propertyDtos.get(i));
+            if (properties != null && properties.size() > 0) {
+                for (int j = 0; j < properties.size(); j++) {
+                    properties.get(j).setParentId(property.getId());
+                    properties.get(j).setNumber(j + 1);
+                }
+                propertyRepo.saveAll(properties);
+            }
+        }
+    }
+
+    @Override
+    public List<PropertyDto> propertyDtos(Long coursePropertyId, User user) {
+        List<PropertyDto> propertyDtos = new ArrayList<PropertyDto>();
+        //查询所有父节点对象
+        List<Property> propertieParents = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(user.getRootOrgId(), coursePropertyId, 0l);
+        if (propertieParents != null && propertieParents.size() > 0) {
+            for (Property property : propertieParents) {
+                PropertyDto propertyDtoParent = new PropertyDto(property);
+                //查询所有子节点对象
+                List<Property> propertiesSons = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(user.getRootOrgId(), coursePropertyId, property.getId());
+                if (propertiesSons != null && propertiesSons.size() > 0) {
+                    List<PropertyDto> propertyDtosSons = new ArrayList<PropertyDto>();
+                    for (Property property2 : propertiesSons) {
+                        PropertyDto propertyDto2 = new PropertyDto(property2);
+                        propertyDtosSons.add(propertyDto2);
+                    }
+                    propertyDtoParent.setPropertyDtos(propertyDtosSons);
+                }
+                propertyDtos.add(propertyDtoParent);
+            }
+        }
+        return propertyDtos;
+    }
+
+    @Override
+    public void saveProperty(Property property, User user) throws Exception {
+        //新增
+        if (property.getId() == null) {
+            //检查是否重名
+            Property sameName = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdAndName(user.getRootOrgId(), property.getCoursePropertyId(), property.getParentId(), property.getName());
+            if (sameName != null) {
+                throw new Exception("属性名已经存在");
+            }
+            Integer number = 0;
+            List<Property> propertieParents = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(user.getRootOrgId(), property.getCoursePropertyId(), property.getParentId());
+            if (propertieParents != null && propertieParents.size() > 0) {
+                number = propertieParents.get(propertieParents.size() - 1).getNumber();
+            }
+            property.setNumber(number + 1);
+        } else {
+            //得到原来的对象
+            Property propertyOld = Model.of(propertyRepo.findById(property.getId()));
+            if (!propertyOld.getName().equals(property.getName())) {
+                //检查是否重名
+                Property sameName = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdAndName(user.getRootOrgId(), property.getCoursePropertyId(), property.getParentId(), property.getName());
+                if (sameName != null) {
+                    throw new Exception("属性名已经存在");
+                }
+            }
+        }
+        property.setOrgId(user.getRootOrgId());
+        propertyRepo.save(property);
+    }
+
+    @Override
+    public void deleteProperty(Long propertyId, Long coursePropertyId, User user) {
+        //查询子节点对象
+        List<Property> properties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(user.getRootOrgId(), coursePropertyId, propertyId);
+        if (properties != null && properties.size() > 0) {
+            for (Property property : properties) {
+                propertyRepo.delete(property);
+            }
+        }
+        propertyRepo.deleteById(propertyId);
+    }
+
+    @Override
+    public List<Property> findAll(Long coursePropertyId, User user) {
+        List<PropertyDto> propertyDtos = propertyDtos(coursePropertyId, user);
+        List<Property> properties = new ArrayList<Property>();
+        if (propertyDtos != null && propertyDtos.size() > 0) {
+            for (PropertyDto propertyDto : propertyDtos) {
+                Property property = new Property(propertyDto);
+                properties.add(property);
+                if (propertyDto.getPropertyDtos() != null && propertyDto.getPropertyDtos().size() > 0) {
+                    for (PropertyDto propertyDtoSon : propertyDto.getPropertyDtos()) {
+                        Property propertySon = new Property(propertyDtoSon);
+                        properties.add(propertySon);
+                    }
+                }
+            }
+        }
+        return properties;
+    }
+
+    @Override
+    public List<Property> findPropertySons(Property property) {
+        List<Property> properySonsList = propertyRepo.findByParentIdOrderByNumber(property.getId());
+        return properySonsList;
+    }
+
+    @Override
+    public List<Property> findPropertySons(Long propertyId) {
+        List<Property> properySonsList = propertyRepo.findByParentIdOrderByNumber(propertyId);
+        return properySonsList;
+    }
+
+    @Override
+    public List<Property> findPropertyParents(Long coursePropertyId, Long orgId) {
+        List<Property> properties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(orgId, coursePropertyId, 0l);
+        return properties;
+    }
+
+    @Override
+    public void moveUp(Property property) throws Exception {
+        //查询所有一级属性
+        List<Property> properties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(property.getOrgId(), property.getCoursePropertyId(), 0L);
+        if (properties.size() < 2) {
+            throw new Exception("无法上移");
+        } else {
+            for (int i = 0; i < properties.size(); i++) {
+                if (property.getId().equals(properties.get(i).getId())) {
+                    if (i == 0) {
+                        throw new Exception("无法上移");
+                    } else {
+                        Integer number = property.getNumber();
+                        property.setNumber(properties.get(i - 1).getNumber());
+                        properties.get(i - 1).setNumber(number);
+                        propertyRepo.save(property);
+                        propertyRepo.save(properties.get(i - 1));
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    public void moveDown(Property property) throws Exception {
+        //查询所有一级属性
+        List<Property> properties = propertyRepo.findByOrgIdAndCoursePropertyIdAndParentIdOrderByNumber(property.getOrgId(), property.getCoursePropertyId(), 0l);
+        if (properties.size() < 2) {
+            throw new Exception("无法下移");
+        } else {
+            for (int i = 0; i < properties.size(); i++) {
+                if (property.getId().equals(properties.get(i).getId())) {
+                    if (i == (properties.size() - 1)) {
+                        throw new Exception("无法下移");
+                    } else {
+                        Integer number = property.getNumber();
+                        property.setNumber(properties.get(i + 1).getNumber());
+                        properties.get(i + 1).setNumber(number);
+                        propertyRepo.save(property);
+                        propertyRepo.save(properties.get(i + 1));
+                    }
+                }
+            }
+        }
+    }
 
 }

+ 339 - 336
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/QuesServiceImpl.java

@@ -51,49 +51,50 @@ import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
 import cn.com.qmth.examcloud.core.questions.base.word.DocxProcessUtil;
 
 /**
- * @author  	chenken
- * @date    	2017年9月12日 上午11:04:23
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年9月12日 上午11:04:23
+ * @company QMTH
  * @description QuesServiceImpl.java
  */
 @Service("quesService")
-public class QuesServiceImpl implements QuesService{
-	@Autowired
-	private QuesRepo quesRepo;
-    
+public class QuesServiceImpl implements QuesService {
+    @Autowired
+    private QuesRepo quesRepo;
+
     @Autowired
     private QuestionAudioService questionAudioService;
 
     @Autowired
     private MongoTemplate mongoTemplate;
-    
+
     @Autowired
     private QuestionAudioRepo questionAudioRepo;
-    
+
     @Autowired
     private QuesPkgPathRepo quesPkgPathRepo;
-    
+
     @Autowired
     private PaperDetailUnitRepo unitRepo;
-    
+
     @Autowired
     private PaperRepo paperRepo;
-    
+
     @Autowired
     private PaperService paperService;
-    
+
     private static WordprocessingMLPackage wordMLPackage = null;
-    
-    static{
-    	try {
-			wordMLPackage = WordprocessingMLPackage.createPackage();
-		} catch (InvalidFormatException e) {
-			e.printStackTrace();
-		}
+
+    static {
+        try {
+            wordMLPackage = WordprocessingMLPackage.createPackage();
+        } catch (InvalidFormatException e) {
+            e.printStackTrace();
+        }
     }
-    
+
     /**
      * 套题子题按序号自动生成ID
+     *
      * @param question
      */
     private void updateSubId(Question question) {
@@ -161,39 +162,40 @@ public class QuesServiceImpl implements QuesService{
         previous.setUpdateTime(now);
         updateSubId(previous);
     }*/
-    
-	/**
+
+    /**
      * 保存试题,用于页面新增和更新
      * 导入时不能调用该方法,里面有更新Word的代码
+     *
      * @param question
      */
     public Question saveQues(Question question) {
-    	if(question.getDifficultyDegree() > 0 && question.getDifficultyDegree()<0.4){
-        	question.setDifficulty("难");
-        }else if(question.getDifficultyDegree() > 0.3 && question.getDifficultyDegree()<0.8){
-        	question.setDifficulty("中");
-        }else {
-        	question.setDifficulty("易");
-		}
-    	String now = CommonUtils.getCurDateTime();
+        if (question.getDifficultyDegree() > 0 && question.getDifficultyDegree() < 0.4) {
+            question.setDifficulty("难");
+        } else if (question.getDifficultyDegree() > 0.3 && question.getDifficultyDegree() < 0.8) {
+            question.setDifficulty("中");
+        } else {
+            question.setDifficulty("易");
+        }
+        String now = CommonUtils.getCurDateTime();
         if (StringUtils.isNotEmpty(question.getId())) {
             question.setCreateTime(now);
             question.setUpdateTime(now);
         } else {
-        	question.setUpdateTime(now);
+            question.setUpdateTime(now);
         }
         //跟新音频文件,以及音频文件排序
-        if(question.getHasAudio()!=null&&question.getHasAudio()){
-        	questionAudioService.deleteAudioNotInQuestion(question);
-        	//给音频重新排序
-        	questionAudioService.sortAudio(question);
-        	//如果根据questionId查询不出音频了,将hasAudio设置为false
-			List<QuestionAudio> questionAudios = questionAudioRepo.findByQuestionId(question.getId());
-			if(questionAudios.size()==0){
-				question.setHasAudio(false);
-			}
-        }
-        setSelectQuestionAnswer(question,"");
+        if (question.getHasAudio() != null && question.getHasAudio()) {
+            questionAudioService.deleteAudioNotInQuestion(question);
+            //给音频重新排序
+            questionAudioService.sortAudio(question);
+            //如果根据questionId查询不出音频了,将hasAudio设置为false
+            List<QuestionAudio> questionAudios = questionAudioRepo.findByQuestionId(question.getId());
+            if (questionAudios.size() == 0) {
+                question.setHasAudio(false);
+            }
+        }
+        setSelectQuestionAnswer(question, "");
         updateSubId(question);
         updateQuesWord(question);
         //更新QuesBody,把  下划线  转成  ##
@@ -201,12 +203,12 @@ public class QuesServiceImpl implements QuesService{
         return quesRepo.save(question);
     }
 
-	private void updateQuesBody(Question question) {
-    	String newQuesBody = question.getQuesBody().replaceAll("______", "###");
+    private void updateQuesBody(Question question) {
+        String newQuesBody = question.getQuesBody().replaceAll("______", "###");
         question.setQuesBody(newQuesBody);
-	}
+    }
 
-	/**
+    /**
      * 批量保存试题
      *
      * @param list
@@ -232,27 +234,27 @@ public class QuesServiceImpl implements QuesService{
         Query query = new Query();
         query.addCriteria(Criteria.where("orgId").is(searchCondition.getOrgId()));
         query.addCriteria(Criteria.where("course.enable").is("true"));
-        if(StringUtils.isNotBlank(searchCondition.getCourseNo())){
+        if (StringUtils.isNotBlank(searchCondition.getCourseNo())) {
             query.addCriteria(Criteria.where("course.code").is(searchCondition.getCourseNo()));
         }
-        if(StringUtils.isNotBlank(searchCondition.getCourseLevel())){
+        if (StringUtils.isNotBlank(searchCondition.getCourseLevel())) {
             query.addCriteria(Criteria.where("course.level").is(searchCondition.getCourseLevel()));
         }
-        if(searchCondition.getQuestionType() != null){
+        if (searchCondition.getQuestionType() != null) {
             query.addCriteria(Criteria.where("questionType").is(searchCondition.getQuestionType()));
         }
-        if(searchCondition.getPublicity() != null){
-        	query.addCriteria(Criteria.where("publicity").is(searchCondition.getPublicity()));
+        if (searchCondition.getPublicity() != null) {
+            query.addCriteria(Criteria.where("publicity").is(searchCondition.getPublicity()));
         }
-        if(searchCondition.getCoursePropertyName() != null){
-        	query.addCriteria(Criteria.where("quesProperties.coursePropertyName").is(searchCondition.getCoursePropertyName()));
+        if (searchCondition.getCoursePropertyName() != null) {
+            query.addCriteria(Criteria.where("quesProperties.coursePropertyName").is(searchCondition.getCoursePropertyName()));
         }
         //二级属性不为空,那么一级属性也不为空
-        if(searchCondition.getSecondPropertyId() !=null){
-        	query.addCriteria(Criteria.where("quesProperties").elemMatch(Criteria.where("firstProperty.id").is(Long.valueOf(searchCondition.getFirstPropertyId())).and("secondProperty.id").is(Long.valueOf(searchCondition.getSecondPropertyId()))));
-        }else {
-        	if(searchCondition.getFirstPropertyId() !=null){
-            	query.addCriteria(Criteria.where("quesProperties").elemMatch(Criteria.where("firstProperty.id").is(Long.valueOf(searchCondition.getFirstPropertyId()))));
+        if (searchCondition.getSecondPropertyId() != null) {
+            query.addCriteria(Criteria.where("quesProperties").elemMatch(Criteria.where("firstProperty.id").is(Long.valueOf(searchCondition.getFirstPropertyId())).and("secondProperty.id").is(Long.valueOf(searchCondition.getSecondPropertyId()))));
+        } else {
+            if (searchCondition.getFirstPropertyId() != null) {
+                query.addCriteria(Criteria.where("quesProperties").elemMatch(Criteria.where("firstProperty.id").is(Long.valueOf(searchCondition.getFirstPropertyId()))));
             }
         }
         long count = this.mongoTemplate.count(query, Question.class);
@@ -266,30 +268,30 @@ public class QuesServiceImpl implements QuesService{
         return new PageImpl<Question>(questionList, new PageRequest(curPage - 1, pageSize), count);
     }
 
-    public void formatQuesCondition(QuestionSearchCondition searchCondition){
-        if(StringUtils.isEmpty(searchCondition.getCourseNo())){
+    public void formatQuesCondition(QuestionSearchCondition searchCondition) {
+        if (StringUtils.isEmpty(searchCondition.getCourseNo())) {
             searchCondition.setCourseNo(null);
         }
-        if(StringUtils.isEmpty(searchCondition.getCourseLevel())){
+        if (StringUtils.isEmpty(searchCondition.getCourseLevel())) {
             searchCondition.setCourseLevel(null);
         }
-        if(StringUtils.isEmpty(searchCondition.getCourseMajor())){
+        if (StringUtils.isEmpty(searchCondition.getCourseMajor())) {
             searchCondition.setCourseMajor(null);
         }
-        if(StringUtils.isEmpty(String.valueOf(searchCondition.getPublicity()))){
-        	searchCondition.setPublicity(null);
+        if (StringUtils.isEmpty(String.valueOf(searchCondition.getPublicity()))) {
+            searchCondition.setPublicity(null);
         }
-        if(StringUtils.isEmpty(searchCondition.getCoursePropertyName())){
-        	searchCondition.setCoursePropertyName(null);
+        if (StringUtils.isEmpty(searchCondition.getCoursePropertyName())) {
+            searchCondition.setCoursePropertyName(null);
         }
-        if(StringUtils.isEmpty(searchCondition.getFirstPropertyId())){
-        	searchCondition.setFirstPropertyId(null);
+        if (StringUtils.isEmpty(searchCondition.getFirstPropertyId())) {
+            searchCondition.setFirstPropertyId(null);
         }
-        if(StringUtils.isEmpty(searchCondition.getSecondPropertyId())){
-        	searchCondition.setSecondPropertyId(null);
+        if (StringUtils.isEmpty(searchCondition.getSecondPropertyId())) {
+            searchCondition.setSecondPropertyId(null);
         }
-        if(StringUtils.isEmpty(searchCondition.getDifficulty())){
-        	searchCondition.setDifficulty(null);
+        if (StringUtils.isEmpty(searchCondition.getDifficulty())) {
+            searchCondition.setDifficulty(null);
         }
     }
 
@@ -301,26 +303,26 @@ public class QuesServiceImpl implements QuesService{
      * @param pageSize
      * @return
      */
-    public Page<Question> findByIdExclude(Set<String> idSet,String courseNo,QuesStructType quesType,int curPage,int pageSize,Long orgId,String quesBody) {
+    public Page<Question> findByIdExclude(Set<String> idSet, String courseNo, QuesStructType quesType, int curPage, int pageSize, Long orgId, String quesBody) {
         Query query = new Query();
-        query.addCriteria(Criteria.where("orgId").is(orgId+""));
+        query.addCriteria(Criteria.where("orgId").is(orgId + ""));
         query.addCriteria(Criteria.where("course.enable").is("true"));
-        if(quesType!=null){
-        	query.addCriteria(Criteria.where("questionType").is(quesType));
+        if (quesType != null) {
+            query.addCriteria(Criteria.where("questionType").is(quesType));
         }
         query.addCriteria(Criteria.where("course.code").is(courseNo));
         query.addCriteria(Criteria.where("id").nin(idSet));
         //模糊匹配
-        if(StringUtils.isNotBlank(quesBody)){
-        	Pattern pattern = Pattern.compile("^.*"+quesBody+".*$", Pattern.CASE_INSENSITIVE);
+        if (StringUtils.isNotBlank(quesBody)) {
+            Pattern pattern = Pattern.compile("^.*" + quesBody + ".*$", Pattern.CASE_INSENSITIVE);
             query.addCriteria(Criteria.where("quesBody").regex(pattern));
         }
         long total = this.mongoTemplate.count(query, Question.class);
-        query.with(new Sort(new Order(Direction.DESC,"id")));
-		query.limit(pageSize);
+        query.with(new Sort(new Order(Direction.DESC, "id")));
+        query.limit(pageSize);
         query.skip((curPage - 1) * pageSize);
-        List<Question> questionList = this.mongoTemplate.find(query,Question.class);
-        Page<Question> questionPageList = new PageImpl<Question>(questionList,new PageRequest(curPage - 1, pageSize), total);
+        List<Question> questionList = this.mongoTemplate.find(query, Question.class);
+        Page<Question> questionPageList = new PageImpl<Question>(questionList, new PageRequest(curPage - 1, pageSize), total);
         for (Question question : questionPageList) {
             formatQues(question);
         }
@@ -334,7 +336,7 @@ public class QuesServiceImpl implements QuesService{
      * @return
      */
     public Question findById(String id) {
-        Question question = Model.of( quesRepo.findById(id));
+        Question question = Model.of(quesRepo.findById(id));
         formatQues(question);
         return question;
     }
@@ -371,15 +373,16 @@ public class QuesServiceImpl implements QuesService{
 
     /**
      * 保存后更新word
+     *
      * @param question
      */
     public void updateQuesWord(Question question) {
         try {
-        	if(wordMLPackage == null){
-        		wordMLPackage = WordprocessingMLPackage.createPackage();
-        	}else{
+            if (wordMLPackage == null) {
+                wordMLPackage = WordprocessingMLPackage.createPackage();
+            } else {
                 DocxProcessUtil.initTmpPackage(wordMLPackage);
-        	    wordMLPackage.getRelationshipsPart().remove();
+                wordMLPackage.getRelationshipsPart().remove();
             }
             updateQuesWordUnit(wordMLPackage, question);
             List<Question> subQuesList = question.getSubQuestions();
@@ -388,13 +391,13 @@ public class QuesServiceImpl implements QuesService{
                     updateQuesWordUnit(wordMLPackage, subQues);
                 }
             }
-            byte [] pkgByte = DocxProcessUtil.getPkgByte(wordMLPackage);
-            if(question.getQuesPkgPathId() == null){
+            byte[] pkgByte = DocxProcessUtil.getPkgByte(wordMLPackage);
+            if (question.getQuesPkgPathId() == null) {
                 QuestionPkgPath quesPkgPath = new QuestionPkgPath(pkgByte);
                 QuestionPkgPath returnQuesPkgPath = quesPkgPathRepo.save(quesPkgPath);
                 question.setQuesPkgPathId(returnQuesPkgPath.getId());
                 quesRepo.save(question);
-            }else{
+            } else {
                 QuestionPkgPath quesPkgPath = quesPkgPathRepo.findFirstById(question.getQuesPkgPathId());
                 quesPkgPath.setQuesPkg(pkgByte);
                 quesPkgPathRepo.save(quesPkgPath);
@@ -408,109 +411,109 @@ public class QuesServiceImpl implements QuesService{
     public void updateQuesWordUnit(WordprocessingMLPackage wordMLPackage, Question question) throws Exception {
         String quesBody = question.getQuesBody();
         String quesAnswer = question.getQuesAnswer();
-        if(!StringUtils.isEmpty(quesBody)){
-        	StringBuffer pWordMl = new StringBuffer();
-            question.setQuesBodyWord(reduceImage(quesBody,pWordMl,wordMLPackage));
+        if (!StringUtils.isEmpty(quesBody)) {
+            StringBuffer pWordMl = new StringBuffer();
+            question.setQuesBodyWord(reduceImage(quesBody, pWordMl, wordMLPackage));
         }
-        if(!StringUtils.isEmpty(quesAnswer)
+        if (!StringUtils.isEmpty(quesAnswer)
                 && (question.getQuestionType() == QuesStructType.FILL_BLANK_QUESTION
-                || question.getQuestionType() == QuesStructType.TEXT_ANSWER_QUESTION)){
+                || question.getQuestionType() == QuesStructType.TEXT_ANSWER_QUESTION)) {
             //question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(quesAnswer)));
-        	StringBuffer pWordMl = new StringBuffer();
-        	question.setQuesAnswerWord(reduceImage(quesAnswer,pWordMl,wordMLPackage));
+            StringBuffer pWordMl = new StringBuffer();
+            question.setQuesAnswerWord(reduceImage(quesAnswer, pWordMl, wordMLPackage));
         }
-        if(!StringUtils.isEmpty(quesAnswer) && question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION){
-        	quesAnswer = "<p>" + quesAnswer + "</p>";
-        	question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(quesAnswer)));
+        if (!StringUtils.isEmpty(quesAnswer) && question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION) {
+            quesAnswer = "<p>" + quesAnswer + "</p>";
+            question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(quesAnswer)));
         }
-        if(!StringUtils.isEmpty(quesAnswer)&& 
-        		(question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
-                ||question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION)){
-        	question.setQuesAnswerWord(makeQuesAnswerWord(quesAnswer));
+        if (!StringUtils.isEmpty(quesAnswer) &&
+                (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
+                        || question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION)) {
+            question.setQuesAnswerWord(makeQuesAnswerWord(quesAnswer));
         }
         List<QuesOption> quesOptions = question.getQuesOptions();
         if (quesOptions != null && quesOptions.size() > 0) {
             for (QuesOption quesOption : quesOptions) {
-            	if(StringUtils.isBlank(quesOption.getOptionBody())){
-            		quesOption.setOptionBody("<p></p>");
-            	}
-            	StringBuffer pWordMl = new StringBuffer();
+                if (StringUtils.isBlank(quesOption.getOptionBody())) {
+                    quesOption.setOptionBody("<p></p>");
+                }
+                StringBuffer pWordMl = new StringBuffer();
                 //quesOption.setOptionBodyWord(DocxProcessUtil.html2Docx(wordMLPackage,CommonUtils.formatHtml(quesOption.getOptionBody())));
-                quesOption.setOptionBodyWord(reduceImage(quesOption.getOptionBody(),pWordMl,wordMLPackage));
+                quesOption.setOptionBodyWord(reduceImage(quesOption.getOptionBody(), pWordMl, wordMLPackage));
             }
         }
     }
-    
+
     //如果图片过大,改变图片大小
-    private String reduceImage(String html,StringBuffer pWordMl,WordprocessingMLPackage wordMLPackage) throws Exception{
-    	String bodyString = DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(html));
-    	if(bodyString.indexOf("cx")>-1 || bodyString.indexOf("cy")>-1){
-    		String tmpStr = DocxProcessUtil.BODY_HEADER + bodyString + DocxProcessUtil.BODY_TAIL;
-    		Body body = (Body)XmlUtils.unmarshalString(tmpStr,Context.jc,Body.class);
+    private String reduceImage(String html, StringBuffer pWordMl, WordprocessingMLPackage wordMLPackage) throws Exception {
+        String bodyString = DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(html));
+        if (bodyString.indexOf("cx") > -1 || bodyString.indexOf("cy") > -1) {
+            String tmpStr = DocxProcessUtil.BODY_HEADER + bodyString + DocxProcessUtil.BODY_TAIL;
+            Body body = (Body) XmlUtils.unmarshalString(tmpStr, Context.jc, Body.class);
             List<Object> pList = body.getContent();
-            for(Object op:pList){
-            	P p = (P) op;
-            	List<Object> rList = p.getContent();
-            	for(Object or:rList){
-            		if(or instanceof R){
-            			R r = (R)or;
-                		List<Object> draList = r.getContent();
-            			for(Object odra:draList){
-            				if(odra instanceof JAXBElement){
-            					JAXBElement<?> jaxbElement = (JAXBElement<?>)odra;
-            					if(jaxbElement.getValue() instanceof Drawing){
-            						Drawing drawing = (Drawing)jaxbElement.getValue();
-                        			List<Object> inList = drawing.getAnchorOrInline();
-                        			for(Object oin:inList){
-                        				Inline inline = (Inline)oin;
-                        				CTPositiveSize2D extent = inline.getExtent();
-                        				if(extent.getCx()>6000000){
-                        					long cx = extent.getCx();
-                        					long cy = extent.getCy();
-                        					Double ncy = (double) ((cy * 6000000) / cx);
-                        					extent.setCx(6000000);
-                        					extent.setCy(ncy.longValue());
-                        				}
-                        				if(extent.getCy()>6000000){
-                        					long cx = extent.getCx();
-                        					long cy = extent.getCy();
-                        					Double ncx = (double) ((cx * 6000000) / cy);
-                        					extent.setCy(6000000);
-                        					extent.setCx(ncx.longValue());
-                        				}
-                        			}
-            					}
-            				}
-                		}
-            		}
-            	}
+            for (Object op : pList) {
+                P p = (P) op;
+                List<Object> rList = p.getContent();
+                for (Object or : rList) {
+                    if (or instanceof R) {
+                        R r = (R) or;
+                        List<Object> draList = r.getContent();
+                        for (Object odra : draList) {
+                            if (odra instanceof JAXBElement) {
+                                JAXBElement<?> jaxbElement = (JAXBElement<?>) odra;
+                                if (jaxbElement.getValue() instanceof Drawing) {
+                                    Drawing drawing = (Drawing) jaxbElement.getValue();
+                                    List<Object> inList = drawing.getAnchorOrInline();
+                                    for (Object oin : inList) {
+                                        Inline inline = (Inline) oin;
+                                        CTPositiveSize2D extent = inline.getExtent();
+                                        if (extent.getCx() > 6000000) {
+                                            long cx = extent.getCx();
+                                            long cy = extent.getCy();
+                                            Double ncy = (double) ((cy * 6000000) / cx);
+                                            extent.setCx(6000000);
+                                            extent.setCy(ncy.longValue());
+                                        }
+                                        if (extent.getCy() > 6000000) {
+                                            long cx = extent.getCx();
+                                            long cy = extent.getCy();
+                                            Double ncx = (double) ((cx * 6000000) / cy);
+                                            extent.setCy(6000000);
+                                            extent.setCx(ncx.longValue());
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
             }
-			for(Object pObj:pList){
-                if(pObj instanceof P){
+            for (Object pObj : pList) {
+                if (pObj instanceof P) {
                     pWordMl.append(DocxProcessUtil.formatPWordMl(XmlUtils.marshaltoString(pObj)));
                 }
             }
-			return pWordMl.toString();
-    	}
-    	return bodyString;
+            return pWordMl.toString();
+        }
+        return bodyString;
     }
-    
-    private String makeQuesAnswerWord(String quesAnswer){
-    	String template = "<w:p xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" w:rsidR=\"00F65544\" w:rsidP=\"00F65544\" w:rsidRDefault=\"001738E2\">"+
-							    "<w:r w:rsidR=\"00F65544\">"+
-							        "<w:rPr>"+
-							            "<w:rFonts w:hint=\"eastAsia\"/>"+
-							            "<w:szCs w:val=\"21\"/>"+
-							        "</w:rPr>"+
-							        "<w:t>quesAnswer</w:t>"+
-							    "</w:r>"+
-							"</w:p>";
-    	return template.replace("quesAnswer", quesAnswer);
+
+    private String makeQuesAnswerWord(String quesAnswer) {
+        String template = "<w:p xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" w:rsidR=\"00F65544\" w:rsidP=\"00F65544\" w:rsidRDefault=\"001738E2\">" +
+                "<w:r w:rsidR=\"00F65544\">" +
+                "<w:rPr>" +
+                "<w:rFonts w:hint=\"eastAsia\"/>" +
+                "<w:szCs w:val=\"21\"/>" +
+                "</w:rPr>" +
+                "<w:t>quesAnswer</w:t>" +
+                "</w:r>" +
+                "</w:p>";
+        return template.replace("quesAnswer", quesAnswer);
     }
 
     /**
      * 获取试题有效文本
-     * 
+     *
      * @param question
      * @return
      */
@@ -530,191 +533,191 @@ public class QuesServiceImpl implements QuesService{
         return quesText.toString();
     }
 
-	@Override
-	public void setSelectQuestionAnswer(Question question, String optionOrder) {
-		if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
-				|| question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
-			question.setQuesAnswer(getSelectQuestionAnswer(question, optionOrder));
-		} else if (question.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
-			List<Question> subQuestions = question.getSubQuestions();
-			int index = 0;
-			for (int k = 0; k < subQuestions.size(); k++) {
-				Question subQuestion = subQuestions.get(k);
-				if (subQuestion.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
-						|| subQuestion.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
-					if(StringUtils.isNotEmpty(optionOrder) && optionOrder.contains(";")){
-						subQuestion.setQuesAnswer(getSelectQuestionAnswer(subQuestion, optionOrder.split(";")[index]));
-					}else{
-						subQuestion.setQuesAnswer(getSelectQuestionAnswer(subQuestion, ""));								
-					}
-					index++;
-				}
-			}
-		}
-	}
-	
-
-	private String getSelectQuestionAnswer(Question question,String optionOrder){
-		String answer = "";
-		List<QuesOption> quesOptions = question.getQuesOptions();
-		if(quesOptions == null || quesOptions.size() == 0){
-			return "";
-		}
-		if(StringUtils.isEmpty(optionOrder)){
-			int j = 0;
-			for(QuesOption quesOption : quesOptions){
-				if(quesOption.getIsCorrect() == 1){
-					answer += CommonUtils.getOptionNum(j);
-				}
-				j++;
-			}
-		}else{
-			String [] order = optionOrder.split(",");
-			for(int i = 0;i < order.length;i++){
-				for(QuesOption quesOption : quesOptions){
-					if(order[i].equals(quesOption.getNumber()) && quesOption.getIsCorrect() == 1){
-						answer += CommonUtils.getOptionNum(i);
-						break;
-					}
-				}
-			}
-		}
-		return answer;
-	}
-
-	@Override
-	public long findQuesCount(QuestionSearchCondition searchCondition) {
-		formatQuesCondition(searchCondition);
-		Query query = new Query();
+    @Override
+    public void setSelectQuestionAnswer(Question question, String optionOrder) {
+        if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
+                || question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
+            question.setQuesAnswer(getSelectQuestionAnswer(question, optionOrder));
+        } else if (question.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
+            List<Question> subQuestions = question.getSubQuestions();
+            int index = 0;
+            for (int k = 0; k < subQuestions.size(); k++) {
+                Question subQuestion = subQuestions.get(k);
+                if (subQuestion.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
+                        || subQuestion.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
+                    if (StringUtils.isNotEmpty(optionOrder) && optionOrder.contains(";")) {
+                        subQuestion.setQuesAnswer(getSelectQuestionAnswer(subQuestion, optionOrder.split(";")[index]));
+                    } else {
+                        subQuestion.setQuesAnswer(getSelectQuestionAnswer(subQuestion, ""));
+                    }
+                    index++;
+                }
+            }
+        }
+    }
+
+
+    private String getSelectQuestionAnswer(Question question, String optionOrder) {
+        String answer = "";
+        List<QuesOption> quesOptions = question.getQuesOptions();
+        if (quesOptions == null || quesOptions.size() == 0) {
+            return "";
+        }
+        if (StringUtils.isEmpty(optionOrder)) {
+            int j = 0;
+            for (QuesOption quesOption : quesOptions) {
+                if (quesOption.getIsCorrect() == 1) {
+                    answer += CommonUtils.getOptionNum(j);
+                }
+                j++;
+            }
+        } else {
+            String[] order = optionOrder.split(",");
+            for (int i = 0; i < order.length; i++) {
+                for (QuesOption quesOption : quesOptions) {
+                    if (order[i].equals(quesOption.getNumber()) && quesOption.getIsCorrect() == 1) {
+                        answer += CommonUtils.getOptionNum(i);
+                        break;
+                    }
+                }
+            }
+        }
+        return answer;
+    }
+
+    @Override
+    public long findQuesCount(QuestionSearchCondition searchCondition) {
+        formatQuesCondition(searchCondition);
+        Query query = new Query();
         query.addCriteria(Criteria.where("orgId").is(searchCondition.getOrgId()));
         query.addCriteria(Criteria.where("course.enable").is("true"));
-        if(StringUtils.isNotBlank(searchCondition.getCourseNo())){
+        if (StringUtils.isNotBlank(searchCondition.getCourseNo())) {
             query.addCriteria(Criteria.where("course.code").is(searchCondition.getCourseNo()));
         }
-        if(searchCondition.getQuestionType() != null){
+        if (searchCondition.getQuestionType() != null) {
             query.addCriteria(Criteria.where("questionType").is(searchCondition.getQuestionType()));
         }
-        if(searchCondition.getPublicity() != null){
-        	query.addCriteria(Criteria.where("publicity").is(searchCondition.getPublicity()));
+        if (searchCondition.getPublicity() != null) {
+            query.addCriteria(Criteria.where("publicity").is(searchCondition.getPublicity()));
         }
-        if(searchCondition.getCoursePropertyName() != null){
-        	query.addCriteria(Criteria.where("quesProperties.coursePropertyName").is(searchCondition.getCoursePropertyName()));
+        if (searchCondition.getCoursePropertyName() != null) {
+            query.addCriteria(Criteria.where("quesProperties.coursePropertyName").is(searchCondition.getCoursePropertyName()));
         }
-        if(searchCondition.getDifficulty() != null){
-        	query.addCriteria(Criteria.where("difficulty").is(searchCondition.getDifficulty()));
+        if (searchCondition.getDifficulty() != null) {
+            query.addCriteria(Criteria.where("difficulty").is(searchCondition.getDifficulty()));
         }
         //二级属性不为空,那么一级属性也不为空
-        if(searchCondition.getSecondPropertyId() !=null){
-        	query.addCriteria(Criteria.where("quesProperties").elemMatch(Criteria.where("firstProperty.id").is(Long.valueOf(searchCondition.getFirstPropertyId())).and("secondProperty.id").is(Long.valueOf(searchCondition.getSecondPropertyId()))));
-        }else {
-        	if(searchCondition.getFirstPropertyId() !=null){
-            	query.addCriteria(Criteria.where("quesProperties").elemMatch(Criteria.where("firstProperty.id").is(Long.valueOf(searchCondition.getFirstPropertyId()))));
+        if (searchCondition.getSecondPropertyId() != null) {
+            query.addCriteria(Criteria.where("quesProperties").elemMatch(Criteria.where("firstProperty.id").is(Long.valueOf(searchCondition.getFirstPropertyId())).and("secondProperty.id").is(Long.valueOf(searchCondition.getSecondPropertyId()))));
+        } else {
+            if (searchCondition.getFirstPropertyId() != null) {
+                query.addCriteria(Criteria.where("quesProperties").elemMatch(Criteria.where("firstProperty.id").is(Long.valueOf(searchCondition.getFirstPropertyId()))));
             }
         }
         long count = 0;
-        List<Question> questionList = this.mongoTemplate.find(query,Question.class);
-        if(questionList == null || questionList.size()<1){
-        	return count;
+        List<Question> questionList = this.mongoTemplate.find(query, Question.class);
+        if (questionList == null || questionList.size() < 1) {
+            return count;
         }
         List<String> oIds = new ArrayList<String>();
-    	for (Question unit : questionList) {
-    		oIds.add(unit.getId());
-    	}
-    	List<ObjectId> objectIds = new ArrayList<ObjectId>();
-		for(String id:oIds){
-			objectIds.add(new ObjectId(id));
-		}
-		Query query2=new Query();
-		query2.addCriteria(Criteria.where("question.$id").in(objectIds));
-		query2.addCriteria(Criteria.where("paperType").is(PaperType.IMPORT));
-		List<PaperDetailUnit> paperDetailUnits = this.mongoTemplate.find(query2, PaperDetailUnit.class);
-		String quesNames = searchCondition.getQuesNames();
-		List<String> list = Arrays.asList(quesNames.split(","));//[单选题]  单选
-		for(PaperDetailUnit unit:paperDetailUnits){
-			if(list.contains(unit.getPaperDetail().getName())){
-				count++;
-			}
-		}
-		return count;
-	}
-
-	@Override
-	public void updateProByPapers(List<String> paperList,Double difficultyDegree, Boolean publicity,User user) {
-		List<Paper> papers = new ArrayList<Paper>();
-		String difficulty = "";
-		if(difficultyDegree>0 && difficultyDegree<0.4){
-			difficulty = "难";
-		}else if (difficultyDegree>0.3 && difficultyDegree<0.8) {
-			difficulty = "中";
-		}else {
-			difficulty = "易";
-		}
-		List<String> quesIds = new ArrayList<String>();
-		List<Question> subQues = new ArrayList<Question>();
-		for(String id:paperList){
-			Paper paper =  Model.of(paperRepo.findById(id));
-			List<PaperDetailUnit> paperDetailUnits = unitRepo.findByPaper(paper);
-			for(PaperDetailUnit unit:paperDetailUnits){
-				Question question = unit.getQuestion();
-				if(question.getSubQuestions()!=null && question.getSubQuestions().size()>0){
-					List<Question> subQuestions = question.getSubQuestions();
-					for(Question subQuestion:subQuestions){
-						subQuestion.setDifficultyDegree(difficultyDegree);
-						subQuestion.setDifficulty(difficulty);
-						subQuestion.setPublicity(publicity);
-						question.setSubQuestions(subQuestions);
-					}
-					subQues.add(question);
-				}
-				quesIds.add(question.getId());
-			}
-			papers.add(paper);
-		}
-		quesRepo.saveAll(subQues);
-		if(quesIds != null && quesIds.size()>0){
-			Query query = new Query();
-			query.addCriteria(Criteria.where("id").in(quesIds));
-			//query.addCriteria(Criteria.where("subQuestions.id").in(subQuesIds));
-			Update update = Update.update("difficultyDegree", difficultyDegree).set("publicity", publicity).set("difficulty", difficulty);
-			//Update update = Update.update("subQuestions.$.difficultyDegree", difficultyDegree).set("subQuestions.$.publicity", publicity);
-			this.mongoTemplate.updateMulti(query, update, Question.class);
-		}
-		for(Paper paper:papers){
-			paperService.formatPaper(paper, user);
-		}
-		paperRepo.saveAll(papers);
-	}
-
-	@Override
-	public void updateProByCourse(String courseCode, Double difficultyDegree, Boolean publicity,String orgId) {
-		String difficulty = "";
-		if(difficultyDegree>0 && difficultyDegree<0.4){
-			difficulty = "难";
-		}else if (difficultyDegree>0.3 && difficultyDegree<0.8) {
-			difficulty = "中";
-		}else {
-			difficulty = "易";
-		}
-		Query query = new Query();
-        query.addCriteria(Criteria.where("orgId").is(orgId+""));
+        for (Question unit : questionList) {
+            oIds.add(unit.getId());
+        }
+        List<ObjectId> objectIds = new ArrayList<ObjectId>();
+        for (String id : oIds) {
+            objectIds.add(new ObjectId(id));
+        }
+        Query query2 = new Query();
+        query2.addCriteria(Criteria.where("question.$id").in(objectIds));
+        query2.addCriteria(Criteria.where("paperType").is(PaperType.IMPORT));
+        List<PaperDetailUnit> paperDetailUnits = this.mongoTemplate.find(query2, PaperDetailUnit.class);
+        String quesNames = searchCondition.getQuesNames();
+        List<String> list = Arrays.asList(quesNames.split(","));//[单选题]  单选
+        for (PaperDetailUnit unit : paperDetailUnits) {
+            if (list.contains(unit.getPaperDetail().getName())) {
+                count++;
+            }
+        }
+        return count;
+    }
+
+    @Override
+    public void updateProByPapers(List<String> paperList, Double difficultyDegree, Boolean publicity, User user) {
+        List<Paper> papers = new ArrayList<Paper>();
+        String difficulty = "";
+        if (difficultyDegree > 0 && difficultyDegree < 0.4) {
+            difficulty = "难";
+        } else if (difficultyDegree > 0.3 && difficultyDegree < 0.8) {
+            difficulty = "中";
+        } else {
+            difficulty = "易";
+        }
+        List<String> quesIds = new ArrayList<String>();
+        List<Question> subQues = new ArrayList<Question>();
+        for (String id : paperList) {
+            Paper paper = Model.of(paperRepo.findById(id));
+            List<PaperDetailUnit> paperDetailUnits = unitRepo.findByPaper(paper);
+            for (PaperDetailUnit unit : paperDetailUnits) {
+                Question question = unit.getQuestion();
+                if (question.getSubQuestions() != null && question.getSubQuestions().size() > 0) {
+                    List<Question> subQuestions = question.getSubQuestions();
+                    for (Question subQuestion : subQuestions) {
+                        subQuestion.setDifficultyDegree(difficultyDegree);
+                        subQuestion.setDifficulty(difficulty);
+                        subQuestion.setPublicity(publicity);
+                        question.setSubQuestions(subQuestions);
+                    }
+                    subQues.add(question);
+                }
+                quesIds.add(question.getId());
+            }
+            papers.add(paper);
+        }
+        quesRepo.saveAll(subQues);
+        if (quesIds != null && quesIds.size() > 0) {
+            Query query = new Query();
+            query.addCriteria(Criteria.where("id").in(quesIds));
+            //query.addCriteria(Criteria.where("subQuestions.id").in(subQuesIds));
+            Update update = Update.update("difficultyDegree", difficultyDegree).set("publicity", publicity).set("difficulty", difficulty);
+            //Update update = Update.update("subQuestions.$.difficultyDegree", difficultyDegree).set("subQuestions.$.publicity", publicity);
+            this.mongoTemplate.updateMulti(query, update, Question.class);
+        }
+        for (Paper paper : papers) {
+            paperService.formatPaper(paper, user);
+        }
+        paperRepo.saveAll(papers);
+    }
+
+    @Override
+    public void updateProByCourse(String courseCode, Double difficultyDegree, Boolean publicity, String orgId) {
+        String difficulty = "";
+        if (difficultyDegree > 0 && difficultyDegree < 0.4) {
+            difficulty = "难";
+        } else if (difficultyDegree > 0.3 && difficultyDegree < 0.8) {
+            difficulty = "中";
+        } else {
+            difficulty = "易";
+        }
+        Query query = new Query();
+        query.addCriteria(Criteria.where("orgId").is(orgId + ""));
         query.addCriteria(Criteria.where("course.enable").is("true"));
         query.addCriteria(Criteria.where("course.code").is(courseCode));
-        List<Question> questionList = this.mongoTemplate.find(query,Question.class);
-        if(questionList != null && questionList.size() >0){
-        	for(Question question:questionList){
-        		question.setDifficultyDegree(difficultyDegree);
-        		question.setDifficulty(difficulty);
-        		question.setPublicity(publicity);
-        		if(question.getSubQuestions() != null && question.getSubQuestions().size() >0){
-        			for(Question subQues:question.getSubQuestions()){
-        				subQues.setDifficultyDegree(difficultyDegree);
-        				subQues.setDifficulty(difficulty);
-						subQues.setPublicity(publicity);
-        			}
-        		}
+        List<Question> questionList = this.mongoTemplate.find(query, Question.class);
+        if (questionList != null && questionList.size() > 0) {
+            for (Question question : questionList) {
+                question.setDifficultyDegree(difficultyDegree);
+                question.setDifficulty(difficulty);
+                question.setPublicity(publicity);
+                if (question.getSubQuestions() != null && question.getSubQuestions().size() > 0) {
+                    for (Question subQues : question.getSubQuestions()) {
+                        subQues.setDifficultyDegree(difficultyDegree);
+                        subQues.setDifficulty(difficulty);
+                        subQues.setPublicity(publicity);
+                    }
+                }
             }
         }
         quesRepo.saveAll(questionList);
-	}
+    }
 }
 

+ 155 - 155
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/QuestionAudioServiceImpl.java

@@ -27,164 +27,164 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.QuestionAudio;
 import cn.com.qmth.examcloud.core.questions.service.QuestionAudioService;
 
 /**
- * @author  	chenken
- * @date    	2017年8月1日 上午11:27:33
- * @company 	QMTH
+ * @author chenken
+ * @date 2017年8月1日 上午11:27:33
+ * @company QMTH
  * @description QuestionRadioServiceImpl.java
  */
 @Service("questionAudioService")
-public class QuestionAudioServiceImpl implements QuestionAudioService{
-
-	@Autowired
-	private QuestionAudioRepo questionAudioRepo;
-	
-	@Autowired
-	private QuesRepo quesRepo;
-	
-	@Value("${$upyun.site.2.bucketName}")
-	protected String bucketName;
-	
-	@Value("${$upyun.site.2.userName}")
-	protected String userName;
-	
-	@Value("${$upyun.site.2.password}")
-	protected String password;
-	
-	@Override
-	public void saveQuestionAudio(QuestionAudio questionAudio,User user) {
-		QuestionAudio questionAudio2 = findByQuestionIdAndFileName(questionAudio.getQuestionId(),questionAudio.getFileName());
-		if(questionAudio2 != null){
-			questionAudio.setId(questionAudio2.getId());
-    		UpYun upYun = new UpYun(bucketName, userName, password);
-    		upYun.deleteFile(questionAudio2.getFileUrl());
-    		questionAudioRepo.delete(questionAudio2);
-    	}
-		questionAudio.setCreateTime(new Date());
-		questionAudio.setCreateUser(user.getDisplayName());
-		questionAudioRepo.save(questionAudio);
-	}
-
-	@Override
-	public List<QuestionAudio> findQuestionAudiosByQuestionId(String questionId) {
-		Assert.hasLength(questionId, "questionId不能为空");
-		return questionAudioRepo.findByQuestionId(questionId);
-	}
-
-	@Override
-	public QuestionAudio findByQuestionIdAndFileName(String questionId,String fileName) {
-		if(StringUtils.isBlank(questionId)||StringUtils.isBlank(fileName)){
-			return null;
-		}
-		return questionAudioRepo.findByQuestionIdAndFileName(questionId,fileName);
-	}
-
-	@Override
-	public void deleteAudioNotInQuestion(Question question) {
-		if(question.getHasAudio()!=null&&question.getHasAudio()){
-			List<QuestionAudio> questionAudios = questionAudioRepo.findByQuestionId(question.getId());
-			StringBuffer buffer = new StringBuffer();
-			buffer.append(question.getQuesBody());
-			if(question.getQuesOptions()!=null&&question.getQuesOptions().size()>0){
-				for(QuesOption option:question.getQuesOptions()){
-					buffer.append(option.getOptionBody());
-				}
-			}
-			String questionBodyAndOptionStr = buffer.toString();
-			Iterator<QuestionAudio> audioIterator = questionAudios.iterator();
-			while(audioIterator.hasNext()){
-				QuestionAudio audio = audioIterator.next();
-				if(!questionBodyAndOptionStr.contains(audio.getFileName())){
-					UpYun upYun = new UpYun(bucketName, userName, password);
-					upYun.deleteFile(audio.getFileUrl());
-					questionAudioRepo.delete(audio);
-				}
-			}
-		}
-	}
-
-	@Override
-	public QuestionAudio findAudioById(String id) {
-		if(StringUtils.isNotBlank(id)){
-			return  Model.of(questionAudioRepo.findById(id));
-		}
-		return null;
-	}
-
-	@Override
-	public void sortAudio(Question question) {
-		if(question.getHasAudio()!=null&&question.getHasAudio()){
-			//音频顺序改变后,更新bodyHtml
-			String newQusBody = getFileNames(question.getQuesBody(),question);
-			question.setQuesBody(newQusBody);
-			//跟新选项中的optionsHtml
-			if(question.getQuesOptions()!=null&&question.getQuesOptions().size()>0){
-				for(QuesOption option:question.getQuesOptions()){
-					String newOptionBody = getFileNames(option.getOptionBody(),question);
-					option.setOptionBody(newOptionBody);
-				}
-			}
-		}
-	}
-	
-	private String getFileNames(String str, Question question){
-		Map<String, String> map = new LinkedHashMap<String, String>();
-		Pattern p = Pattern.compile("<a\\s+[^<>]*\\s+name=\"([^<>\"]*)\"[^<>]*>"); 
-	    Matcher m = p.matcher(str);
-	    int i = 1;
-	    int y = 1;
-	    while(m.find()) {
-		  String name = m.group(1);
-		  StringBuffer buffer = new StringBuffer();
-		  if(name.substring(0, name.indexOf("_")+1).contains("2")){
-			  buffer.append(name.substring(0,name.lastIndexOf("_")+1));
-			  buffer.append(i);
-			  buffer.append("@temp");
-			  buffer.append(name.substring(name.lastIndexOf(".")));
-		      map.put(name, buffer.toString());
-		      i++;
-		  }else {
-			  buffer.append(name.substring(0,name.lastIndexOf("_")+1));
-			  buffer.append(y);
-			  buffer.append("@temp");
-			  buffer.append(name.substring(name.lastIndexOf(".")));
-		      map.put(name, buffer.toString());
-		      y++;
-		  }
-	    }
-	    //循环替换
-	    for(String key:map.keySet()){
-	    	str = str.replace(key, map.get(key));
-		}
-	    //替换并更新数据
-		for(String key:map.keySet()){
-			String fileName = key;
-			String value = map.get(key).replace("@temp", "");
-			str = str.replace(map.get(key), value);
-			QuestionAudio questionAudio = questionAudioRepo.findByQuestionIdAndFileName(question.getId(),fileName);
-			questionAudio.setFileName(value);
-			questionAudioRepo.save(questionAudio);
-		}
-	    return str;
-	}
-
-	@Override
-	public void deleteAudio(List<Question> questions) {
-		//筛选有音频的试题
-		List<String> ids = new ArrayList<String>();
-		for(Question question:questions){
-			if(question.getHasAudio()!=null&&question.getHasAudio()){
-				ids.add(question.getId());
-			}
-		}
-		List<QuestionAudio> questionAudios = questionAudioRepo.findByQuestionIdIn(ids);
-		Iterator<QuestionAudio> audioIterator = questionAudios.iterator();
-		while(audioIterator.hasNext()){
-			QuestionAudio audio = audioIterator.next();
-			UpYun upYun = new UpYun(bucketName, userName, password);
-			upYun.deleteFile(audio.getFileUrl());
-		}
-		questionAudioRepo.deleteAll(questionAudios);
-	}
+public class QuestionAudioServiceImpl implements QuestionAudioService {
+
+    @Autowired
+    private QuestionAudioRepo questionAudioRepo;
+
+    @Autowired
+    private QuesRepo quesRepo;
+
+    @Value("${$upyun.site.2.bucketName}")
+    protected String bucketName;
+
+    @Value("${$upyun.site.2.userName}")
+    protected String userName;
+
+    @Value("${$upyun.site.2.password}")
+    protected String password;
+
+    @Override
+    public void saveQuestionAudio(QuestionAudio questionAudio, User user) {
+        QuestionAudio questionAudio2 = findByQuestionIdAndFileName(questionAudio.getQuestionId(), questionAudio.getFileName());
+        if (questionAudio2 != null) {
+            questionAudio.setId(questionAudio2.getId());
+            UpYun upYun = new UpYun(bucketName, userName, password);
+            upYun.deleteFile(questionAudio2.getFileUrl());
+            questionAudioRepo.delete(questionAudio2);
+        }
+        questionAudio.setCreateTime(new Date());
+        questionAudio.setCreateUser(user.getDisplayName());
+        questionAudioRepo.save(questionAudio);
+    }
+
+    @Override
+    public List<QuestionAudio> findQuestionAudiosByQuestionId(String questionId) {
+        Assert.hasLength(questionId, "questionId不能为空");
+        return questionAudioRepo.findByQuestionId(questionId);
+    }
+
+    @Override
+    public QuestionAudio findByQuestionIdAndFileName(String questionId, String fileName) {
+        if (StringUtils.isBlank(questionId) || StringUtils.isBlank(fileName)) {
+            return null;
+        }
+        return questionAudioRepo.findByQuestionIdAndFileName(questionId, fileName);
+    }
+
+    @Override
+    public void deleteAudioNotInQuestion(Question question) {
+        if (question.getHasAudio() != null && question.getHasAudio()) {
+            List<QuestionAudio> questionAudios = questionAudioRepo.findByQuestionId(question.getId());
+            StringBuffer buffer = new StringBuffer();
+            buffer.append(question.getQuesBody());
+            if (question.getQuesOptions() != null && question.getQuesOptions().size() > 0) {
+                for (QuesOption option : question.getQuesOptions()) {
+                    buffer.append(option.getOptionBody());
+                }
+            }
+            String questionBodyAndOptionStr = buffer.toString();
+            Iterator<QuestionAudio> audioIterator = questionAudios.iterator();
+            while (audioIterator.hasNext()) {
+                QuestionAudio audio = audioIterator.next();
+                if (!questionBodyAndOptionStr.contains(audio.getFileName())) {
+                    UpYun upYun = new UpYun(bucketName, userName, password);
+                    upYun.deleteFile(audio.getFileUrl());
+                    questionAudioRepo.delete(audio);
+                }
+            }
+        }
+    }
+
+    @Override
+    public QuestionAudio findAudioById(String id) {
+        if (StringUtils.isNotBlank(id)) {
+            return Model.of(questionAudioRepo.findById(id));
+        }
+        return null;
+    }
+
+    @Override
+    public void sortAudio(Question question) {
+        if (question.getHasAudio() != null && question.getHasAudio()) {
+            //音频顺序改变后,更新bodyHtml
+            String newQusBody = getFileNames(question.getQuesBody(), question);
+            question.setQuesBody(newQusBody);
+            //跟新选项中的optionsHtml
+            if (question.getQuesOptions() != null && question.getQuesOptions().size() > 0) {
+                for (QuesOption option : question.getQuesOptions()) {
+                    String newOptionBody = getFileNames(option.getOptionBody(), question);
+                    option.setOptionBody(newOptionBody);
+                }
+            }
+        }
+    }
+
+    private String getFileNames(String str, Question question) {
+        Map<String, String> map = new LinkedHashMap<String, String>();
+        Pattern p = Pattern.compile("<a\\s+[^<>]*\\s+name=\"([^<>\"]*)\"[^<>]*>");
+        Matcher m = p.matcher(str);
+        int i = 1;
+        int y = 1;
+        while (m.find()) {
+            String name = m.group(1);
+            StringBuffer buffer = new StringBuffer();
+            if (name.substring(0, name.indexOf("_") + 1).contains("2")) {
+                buffer.append(name.substring(0, name.lastIndexOf("_") + 1));
+                buffer.append(i);
+                buffer.append("@temp");
+                buffer.append(name.substring(name.lastIndexOf(".")));
+                map.put(name, buffer.toString());
+                i++;
+            } else {
+                buffer.append(name.substring(0, name.lastIndexOf("_") + 1));
+                buffer.append(y);
+                buffer.append("@temp");
+                buffer.append(name.substring(name.lastIndexOf(".")));
+                map.put(name, buffer.toString());
+                y++;
+            }
+        }
+        //循环替换
+        for (String key : map.keySet()) {
+            str = str.replace(key, map.get(key));
+        }
+        //替换并更新数据
+        for (String key : map.keySet()) {
+            String fileName = key;
+            String value = map.get(key).replace("@temp", "");
+            str = str.replace(map.get(key), value);
+            QuestionAudio questionAudio = questionAudioRepo.findByQuestionIdAndFileName(question.getId(), fileName);
+            questionAudio.setFileName(value);
+            questionAudioRepo.save(questionAudio);
+        }
+        return str;
+    }
+
+    @Override
+    public void deleteAudio(List<Question> questions) {
+        //筛选有音频的试题
+        List<String> ids = new ArrayList<String>();
+        for (Question question : questions) {
+            if (question.getHasAudio() != null && question.getHasAudio()) {
+                ids.add(question.getId());
+            }
+        }
+        List<QuestionAudio> questionAudios = questionAudioRepo.findByQuestionIdIn(ids);
+        Iterator<QuestionAudio> audioIterator = questionAudios.iterator();
+        while (audioIterator.hasNext()) {
+            QuestionAudio audio = audioIterator.next();
+            UpYun upYun = new UpYun(bucketName, userName, password);
+            upYun.deleteFile(audio.getFileUrl());
+        }
+        questionAudioRepo.deleteAll(questionAudios);
+    }
 
 }
 

+ 503 - 499
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/QuestionProviderServiceImpl.java

@@ -33,512 +33,516 @@ import cn.com.qmth.examcloud.question.commons.core.question.DefaultQuestionUnit;
 import cn.com.qmth.examcloud.question.commons.core.question.QuestionType;
 
 /**
- * @author 		weiwenhai
- * @date 		2018.9.10
- * @company		qmth
- * @describle	试题对象服务实现类
- * @code 		012
+ * @author weiwenhai
+ * @date 2018.9.10
+ * @company qmth
+ * @describle 试题对象服务实现类
+ * @code 012
  */
 @Service("questionProviderService")
-public class QuestionProviderServiceImpl implements QuestionProviderService{
+public class QuestionProviderServiceImpl implements QuestionProviderService {
 
-	@Autowired
-	QuesRepo quesRepo;
-	
-	@Autowired
-	MongoTemplate mongoTemplate;
-	
-	@Override
-	public String save(DefaultQuestion defaultQuestion) {
-		Question question = new Question();
-		if(!StringUtils.isBlank(defaultQuestion.getId())){
-			question.setId(defaultQuestion.getId());
-		}
-		//初始化默认课程
-		Course course = new Course();
-		course.setId("k12");
-		course.setCode("k12");
-		course.setName("k12");
-		course.setLevel("ALL");
-		course.setOrgId(defaultQuestion.getRootOrgId().toString());
-		course.setCreateTime(CommonUtils.getCurDateTime());
-		course.setEnable("true");
-		question.setCourse(course);
-		question.setOrgId(defaultQuestion.getRootOrgId().toString());
-		question.setCreateTime(CommonUtils.getCurDateTime());
-		question.setDifficulty("中");
-		question.setDifficultyDegree(0.5);
-		question.setIsolated(true);
-		question.setPublicity(true);
-		question.setProperties(defaultQuestion.getProperties());
-		DefaultQuestionStructure defaultQuestionStructure = (DefaultQuestionStructure) defaultQuestion.getMasterVersion();
-		//判断试题单元对象
-		List<DefaultQuestionUnit> questionUnitList  = defaultQuestionStructure.getQuestionUnitList();
-		if(questionUnitList == null || questionUnitList.size()<1){
-			throw new StatusException("Q-012033", "试题单元对象为空");
-		}
-		if(questionUnitList.size()==1){
-			DefaultQuestionUnit defaultQuestionUnit = questionUnitList.get(0);
-			//判断试题题型
-			if(defaultQuestionUnit.getQuestionType() == null){
-				throw new StatusException("Q-012039", "试题单元中题型为空");
-			}
-			//设置题干
-			question.setQuesBody(defaultQuestionUnit.getBody());
-			QuesStructType type = buildQuesType(defaultQuestionUnit.getQuestionType());
-			if(type == null){
-				throw new StatusException("Q-012043", "试题单元中题型值不对");
-			}
-			//设置题型
-			question.setQuestionType(type);
-			//如果是选择题,判断选项
-			if(defaultQuestionUnit.getQuestionType() == QuestionType.SINGLE_CHOICE || defaultQuestionUnit.getQuestionType() == QuestionType.MULTIPLE_CHOICE){
-				List<DefaultQuestionOption> questionOptionList = defaultQuestionUnit.getQuestionOptionList();
-				if(questionOptionList == null || questionOptionList.size()<1){
-					throw new StatusException("Q-012049", "试题单元中选项为空");
-				}
-				//设置选项
-				List<QuesOption> quesOptions = buildOptions(questionOptionList, defaultQuestionUnit.getRightAnswer());
-				question.setQuesOptions(quesOptions);
-			}
-			//设置答案
-			question.setQuesAnswer(buildAnswer(defaultQuestionUnit));
-		}else {
-			//套题
-			//设置题干
-			question.setQuesBody(defaultQuestionStructure.getBody());
-			question.setQuestionType(QuesStructType.NESTED_ANSWER_QUESTION);
-			//生成子题
-			List<Question> subList = new ArrayList<Question>();
-			for(DefaultQuestionUnit defaultQuestionUnit:questionUnitList){
-				Question subQues = new Question();
-				subQues.setId(UUID.randomUUID().toString());
-				subQues.setDifficulty("中");
-				subQues.setDifficultyDegree(0.5);
-				subQues.setPublicity(true);
-				//判断试题题型
-				if(defaultQuestionUnit.getQuestionType() == null){
-					throw new StatusException("Q-012039", "试题单元中题型为空");
-				}
-				//设置题干
-				subQues.setQuesBody(defaultQuestionUnit.getBody());
-				QuesStructType type = buildQuesType(defaultQuestionUnit.getQuestionType());
-				if(type == null){
-					throw new StatusException("Q-012043", "试题单元中题型值不对");
-				}
-				//设置题型
-				subQues.setQuestionType(type);
-				//如果是选择题,判断选项
-				if(defaultQuestionUnit.getQuestionType() == QuestionType.SINGLE_CHOICE || defaultQuestionUnit.getQuestionType() == QuestionType.MULTIPLE_CHOICE){
-					List<DefaultQuestionOption> questionOptionList = defaultQuestionUnit.getQuestionOptionList();
-					if(questionOptionList == null || questionOptionList.size()<1){
-						throw new StatusException("Q-012049", "试题单元中选项为空");
-					}
-					//设置选项
-					List<QuesOption> quesOptions = buildOptions(questionOptionList, defaultQuestionUnit.getRightAnswer());
-					subQues.setQuesOptions(quesOptions);
-				}
-				//设置答案
-				subQues.setQuesAnswer(buildAnswer(defaultQuestionUnit));
-				subList.add(subQues);
-			}
-			question.setSubQuestions(subList);
-		}
-		question = quesRepo.save(question);
-		return question.getId();
-	}
-	
-	//构建题型
-	private QuesStructType buildQuesType(QuestionType type){
-		if(type == QuestionType.SINGLE_CHOICE){
-			return QuesStructType.SINGLE_ANSWER_QUESTION;
-		}else if (type == QuestionType.MULTIPLE_CHOICE) {
-			return QuesStructType.MULTIPLE_ANSWER_QUESTION;
-		}else if (type == QuestionType.FILL_UP) {
-			return QuesStructType.FILL_BLANK_QUESTION;
-		}else if (type == QuestionType.ESSAY) {
-			return QuesStructType.TEXT_ANSWER_QUESTION;
-		}else if (type == QuestionType.TRUE_OR_FALSE) {
-			return QuesStructType.BOOL_ANSWER_QUESTION;
-		}else {
-			return null;
-		}
-	}
-	
-	//构建选择题选项							  
-	private List<QuesOption> buildOptions(List<DefaultQuestionOption> questionOptionList,String[] rightAnswer){
-		List<QuesOption> quesOptions = new ArrayList<QuesOption>();
-		for(int i=0;i<questionOptionList.size();i++){
-			DefaultQuestionOption defaultQuestionOption = questionOptionList.get(i);
-			QuesOption option = new QuesOption();
-			option.setNumber(String.valueOf(i+1));
-			option.setOptionBody(defaultQuestionOption.getBody());
-			if(Arrays.asList(rightAnswer).contains(String.valueOf(i))){
-				option.setIsCorrect((short)1);
-			}else {
-				option.setIsCorrect((short)0);
-			}
-			quesOptions.add(option);
-		}
-		return quesOptions;
-	}
-	
-	//构建答案
-	private String buildAnswer(DefaultQuestionUnit defaultQuestionUnit){
-		QuestionType questionType = defaultQuestionUnit.getQuestionType();
-		String answer = "";
-		String[] answers = defaultQuestionUnit.getRightAnswer();
-		if(answers == null || answers.length<1){
-			return answer;
-		}
-		if(questionType == QuestionType.SINGLE_CHOICE || questionType == QuestionType.MULTIPLE_CHOICE){
-			for(int i=0;i<answers.length;i++){
-				int number = Integer.valueOf(answers[i]);
-				if(i == 0){
-					answer = CommonUtils.getOptionNum(number);
-				}else {
-					answer = answer + "," + CommonUtils.getOptionNum(number);
-				}
-			}
-			return answer;
-		}else if (questionType == QuestionType.FILL_UP) {
-			for(int i=0;i<answers.length;i++){
-				if(i == 0){
-					answer = answers[i];
-				}else {
-					answer = answer + "##" + answers[i];
-				}
-			}
-			return answer;
-		}else if (questionType == QuestionType.ESSAY) {
-			if(answers[0].equals("true")){
-				answer = "正确";
-			}else {
-				answer = "错误";
-			}
-			return answer;
-		}else {
-			for(int i=0;i<answers.length;i++){
-				answer = answer + answers[i];
-			}
-			return answer;
-		}
-	}
+    @Autowired
+    QuesRepo quesRepo;
 
-	@Override
-	public Page<DefaultQuestion> findQustions(Long rootOrgId,Map<String, String> map,int curPage,int pageSize) {
-		Query query = new Query();
-		query.addCriteria(Criteria.where("orgId").is(rootOrgId.toString()));
-		query.addCriteria(Criteria.where("isolated").is(true));
-		if(map != null && map.size()>0){
-			for(Map.Entry<String, String> entry:map.entrySet()){
-				if(entry.getKey().equals("questionType")){
-					if(!StringUtils.isBlank(entry.getValue())){
-						if(entry.getValue().equals(QuestionType.SINGLE_CHOICE.toString())){
-							query.addCriteria(Criteria.where("questionType").is(QuesStructType.SINGLE_ANSWER_QUESTION));
-						}else if (entry.getValue().equals(QuestionType.MULTIPLE_CHOICE.toString())) {
-							query.addCriteria(Criteria.where("questionType").is(QuesStructType.MULTIPLE_ANSWER_QUESTION));
-						}else if (entry.getValue().equals(QuestionType.ESSAY.toString())) {
-							query.addCriteria(Criteria.where("questionType").is(QuesStructType.TEXT_ANSWER_QUESTION));
-						}else if (entry.getValue().equals(QuestionType.FILL_UP.toString())) {
-							query.addCriteria(Criteria.where("questionType").is(QuesStructType.FILL_BLANK_QUESTION));
-						}else if (entry.getValue().equals(QuestionType.TRUE_OR_FALSE.toString())) {
-							query.addCriteria(Criteria.where("questionType").is(QuesStructType.BOOL_ANSWER_QUESTION));
-						}else {
-							throw new StatusException("Q-", "题型格式不对!");
-						}
-					}
-				}else if(entry.getKey().equals("difficulty")){
-					Pattern p = Pattern.compile(entry.getValue());
-					String key = "properties." + entry.getKey();
-					query.addCriteria(Criteria.where(key).regex(p));
-				}else {
-					String la = entry.getValue();
-					if(!StringUtils.isBlank(la)){
-						la = la.replaceAll(",", "*");
-						Pattern pattern=Pattern.compile(la, Pattern.CASE_INSENSITIVE);
-						String key = "properties." + entry.getKey();
-						query.addCriteria(Criteria.where(key).regex(pattern));
-					}
-				}
-			 }
-		}
-		long count = this.mongoTemplate.count(query, Question.class);
-		query.limit(pageSize);
-	    query.skip((curPage - 1) * pageSize);
-	    List<Question> questionList = this.mongoTemplate.find(query, Question.class);
-	    List<DefaultQuestion> defaultQuestions = buildDefaultQuestions(questionList);
-	    Page<DefaultQuestion> questions = new PageImpl<DefaultQuestion>(defaultQuestions, new PageRequest(curPage - 1, pageSize), count);
-		return questions;
-	}
-	
-	private List<DefaultQuestion> buildDefaultQuestions(List<Question> questionList){
-		List<DefaultQuestion> defaultQuestions = new ArrayList<DefaultQuestion>();
-		if(questionList != null && questionList.size()>0){
-			for(Question question:questionList){
-				DefaultQuestion defaultQuestion = getDefaultQuestion(question);
-				defaultQuestions.add(defaultQuestion);
-			}
-			return defaultQuestions;
-		}
-		return defaultQuestions;
-	}
+    @Autowired
+    MongoTemplate mongoTemplate;
 
-	private DefaultQuestion getDefaultQuestion(Question question){
-		if(question != null){
-			DefaultQuestionStructure defaultQuestionStructure = new DefaultQuestionStructure();
-			//生成新的题单元集合
-			List<DefaultQuestionUnit> questionUnitList = new ArrayList<DefaultQuestionUnit>();
-			if(question.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION){
-				defaultQuestionStructure.setBody(question.getQuesBody());
-				//获取套题下面所有子题
-				List<Question> subQuesList = question.getSubQuestions();
-				if(subQuesList!=null && subQuesList.size()>0){
-					for(int i=0;i<subQuesList.size();i++){
-						Question subQuestion = subQuesList.get(i);
-						DefaultQuestionUnit defaultQuestionUnit = buildQuestionUnit(subQuestion);
-						questionUnitList.add(defaultQuestionUnit);
-					}
-				}
-			}else {
-				DefaultQuestionUnit defaultQuestionUnit = buildQuestionUnit(question);
-				questionUnitList.add(defaultQuestionUnit);
-			}
-			defaultQuestionStructure.setQuestionUnitList(questionUnitList);
-			DefaultQuestion defaultQuestion = new DefaultQuestion();
-			defaultQuestion.setId(question.getId());
-			defaultQuestion.setIsolated(true);
-			defaultQuestion.setRootOrgId(Long.valueOf(question.getOrgId()));
-			defaultQuestion.setProperties(question.getProperties());
-			defaultQuestion.setMasterVersion(defaultQuestionStructure);
-			return defaultQuestion;
-		}
-		return null;
-	}
-	
-	/**
-	 * 构建试题单元
-	 * @param question
-	 * @return
-	 */
-	private DefaultQuestionUnit buildQuestionUnit(Question question){
-		DefaultQuestionUnit defaultQuestionUnit = new DefaultQuestionUnit();
-		defaultQuestionUnit.setBody(question.getQuesBody());
-		defaultQuestionUnit.setQuestionType(getByOldType(question.getQuestionType()));
-		//如果是单选或者多选,添加选项和答案转换
-		if(question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION || question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION){
-			List<DefaultQuestionOption> defaultQuestionOptions = new ArrayList<DefaultQuestionOption>();
-			List<QuesOption> quesOptions = question.getQuesOptions();
-			if(quesOptions != null && quesOptions.size()>0){
-				for(int i=0;i<quesOptions.size();i++){
-					QuesOption quesOption = quesOptions.get(i);
-					DefaultQuestionOption defaultQuestionOption = new DefaultQuestionOption();
-					defaultQuestionOption.setBody(quesOption.getOptionBody());
-					defaultQuestionOptions.add(defaultQuestionOption);
-				}
-			}
-			defaultQuestionUnit.setQuestionOptionList(defaultQuestionOptions);
-			defaultQuestionUnit.setRightAnswer(getSelectQuestionAnswer(quesOptions));
-		}else {
-			defaultQuestionUnit.setRightAnswer(getAnswer(question));
-		}
-		return defaultQuestionUnit;
-	}
-	
-	/**
-	 * 题型转换方法
-	 * @param quesStructType
-	 * @return
-	 */
-	private QuestionType getByOldType(QuesStructType quesStructType){
-		if(quesStructType == QuesStructType.BOOL_ANSWER_QUESTION){
-			return QuestionType.TRUE_OR_FALSE;
-		}
-		if(quesStructType == QuesStructType.FILL_BLANK_QUESTION){
-			return QuestionType.FILL_UP;
-		}
-		if(quesStructType == QuesStructType.MULTIPLE_ANSWER_QUESTION){
-			return QuestionType.MULTIPLE_CHOICE;
-		}
-		if(quesStructType == QuesStructType.SINGLE_ANSWER_QUESTION){
-			return QuestionType.SINGLE_CHOICE;
-		}
-		if(quesStructType == QuesStructType.TEXT_ANSWER_QUESTION){
-			return QuestionType.ESSAY;
-		}
-		return null;
-	}
-	
+    @Override
+    public String save(DefaultQuestion defaultQuestion) {
+        Question question = new Question();
+        if (!StringUtils.isBlank(defaultQuestion.getId())) {
+            question.setId(defaultQuestion.getId());
+        }
+        //初始化默认课程
+        Course course = new Course();
+        course.setId("k12");
+        course.setCode("k12");
+        course.setName("k12");
+        course.setLevel("ALL");
+        course.setOrgId(defaultQuestion.getRootOrgId().toString());
+        course.setCreateTime(CommonUtils.getCurDateTime());
+        course.setEnable("true");
+        question.setCourse(course);
+        question.setOrgId(defaultQuestion.getRootOrgId().toString());
+        question.setCreateTime(CommonUtils.getCurDateTime());
+        question.setDifficulty("中");
+        question.setDifficultyDegree(0.5);
+        question.setIsolated(true);
+        question.setPublicity(true);
+        question.setProperties(defaultQuestion.getProperties());
+        DefaultQuestionStructure defaultQuestionStructure = (DefaultQuestionStructure) defaultQuestion.getMasterVersion();
+        //判断试题单元对象
+        List<DefaultQuestionUnit> questionUnitList = defaultQuestionStructure.getQuestionUnitList();
+        if (questionUnitList == null || questionUnitList.size() < 1) {
+            throw new StatusException("Q-012033", "试题单元对象为空");
+        }
+        if (questionUnitList.size() == 1) {
+            DefaultQuestionUnit defaultQuestionUnit = questionUnitList.get(0);
+            //判断试题题型
+            if (defaultQuestionUnit.getQuestionType() == null) {
+                throw new StatusException("Q-012039", "试题单元中题型为空");
+            }
+            //设置题干
+            question.setQuesBody(defaultQuestionUnit.getBody());
+            QuesStructType type = buildQuesType(defaultQuestionUnit.getQuestionType());
+            if (type == null) {
+                throw new StatusException("Q-012043", "试题单元中题型值不对");
+            }
+            //设置题型
+            question.setQuestionType(type);
+            //如果是选择题,判断选项
+            if (defaultQuestionUnit.getQuestionType() == QuestionType.SINGLE_CHOICE || defaultQuestionUnit.getQuestionType() == QuestionType.MULTIPLE_CHOICE) {
+                List<DefaultQuestionOption> questionOptionList = defaultQuestionUnit.getQuestionOptionList();
+                if (questionOptionList == null || questionOptionList.size() < 1) {
+                    throw new StatusException("Q-012049", "试题单元中选项为空");
+                }
+                //设置选项
+                List<QuesOption> quesOptions = buildOptions(questionOptionList, defaultQuestionUnit.getRightAnswer());
+                question.setQuesOptions(quesOptions);
+            }
+            //设置答案
+            question.setQuesAnswer(buildAnswer(defaultQuestionUnit));
+        } else {
+            //套题
+            //设置题干
+            question.setQuesBody(defaultQuestionStructure.getBody());
+            question.setQuestionType(QuesStructType.NESTED_ANSWER_QUESTION);
+            //生成子题
+            List<Question> subList = new ArrayList<Question>();
+            for (DefaultQuestionUnit defaultQuestionUnit : questionUnitList) {
+                Question subQues = new Question();
+                subQues.setId(UUID.randomUUID().toString());
+                subQues.setDifficulty("中");
+                subQues.setDifficultyDegree(0.5);
+                subQues.setPublicity(true);
+                //判断试题题型
+                if (defaultQuestionUnit.getQuestionType() == null) {
+                    throw new StatusException("Q-012039", "试题单元中题型为空");
+                }
+                //设置题干
+                subQues.setQuesBody(defaultQuestionUnit.getBody());
+                QuesStructType type = buildQuesType(defaultQuestionUnit.getQuestionType());
+                if (type == null) {
+                    throw new StatusException("Q-012043", "试题单元中题型值不对");
+                }
+                //设置题型
+                subQues.setQuestionType(type);
+                //如果是选择题,判断选项
+                if (defaultQuestionUnit.getQuestionType() == QuestionType.SINGLE_CHOICE || defaultQuestionUnit.getQuestionType() == QuestionType.MULTIPLE_CHOICE) {
+                    List<DefaultQuestionOption> questionOptionList = defaultQuestionUnit.getQuestionOptionList();
+                    if (questionOptionList == null || questionOptionList.size() < 1) {
+                        throw new StatusException("Q-012049", "试题单元中选项为空");
+                    }
+                    //设置选项
+                    List<QuesOption> quesOptions = buildOptions(questionOptionList, defaultQuestionUnit.getRightAnswer());
+                    subQues.setQuesOptions(quesOptions);
+                }
+                //设置答案
+                subQues.setQuesAnswer(buildAnswer(defaultQuestionUnit));
+                subList.add(subQues);
+            }
+            question.setSubQuestions(subList);
+        }
+        question = quesRepo.save(question);
+        return question.getId();
+    }
 
-	/**
-	 * 设置单选题和多选题  答案
-	 * @param quesOptions
-	 * @return
-	 */
-	private String[] getSelectQuestionAnswer(List<QuesOption> quesOptions){
-		String[] rightAnswer = null;
-		List<String> list = new ArrayList<String>();
-		if(quesOptions != null && quesOptions.size()>0){
-			for(int i=0;i<quesOptions.size();i++){
-				QuesOption quesOption = quesOptions.get(i);
-				if(quesOption.getIsCorrect() == 1){
-					list.add(String.valueOf(i));
-				}
-			}
-			rightAnswer = list.toArray(new String[list.size()]);
-			return rightAnswer;
-		}
-		return rightAnswer;
-	}
+    //构建题型
+    private QuesStructType buildQuesType(QuestionType type) {
+        if (type == QuestionType.SINGLE_CHOICE) {
+            return QuesStructType.SINGLE_ANSWER_QUESTION;
+        } else if (type == QuestionType.MULTIPLE_CHOICE) {
+            return QuesStructType.MULTIPLE_ANSWER_QUESTION;
+        } else if (type == QuestionType.FILL_UP) {
+            return QuesStructType.FILL_BLANK_QUESTION;
+        } else if (type == QuestionType.ESSAY) {
+            return QuesStructType.TEXT_ANSWER_QUESTION;
+        } else if (type == QuestionType.TRUE_OR_FALSE) {
+            return QuesStructType.BOOL_ANSWER_QUESTION;
+        } else {
+            return null;
+        }
+    }
 
-	/**
-	 * 设置试题答案
-	 * @param question
-	 * @return
-	 */
-	private String[] getAnswer(Question question){
-		String[] rightAnswer = null;
-		//判断题答案
-		if(question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION){
-			if(question.getQuesAnswer().equals("正确")){
-				rightAnswer = new String[1];
-				rightAnswer[0] = "true";
-				return rightAnswer;
-			}
-			if(question.getQuesAnswer().equals("错误")){
-				rightAnswer = new String[1];
-				rightAnswer[0] = "false";
-				return rightAnswer;
-			}
-		}
-		//填空题答案
-		if(question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION){
-			rightAnswer = question.getQuesAnswer().split("##");
-			return rightAnswer;
-		}
-		rightAnswer = new String[1];
-		rightAnswer[0] = question.getQuesAnswer();
-		return rightAnswer;
-	}
+    //构建选择题选项
+    private List<QuesOption> buildOptions(List<DefaultQuestionOption> questionOptionList, String[] rightAnswer) {
+        List<QuesOption> quesOptions = new ArrayList<QuesOption>();
+        for (int i = 0; i < questionOptionList.size(); i++) {
+            DefaultQuestionOption defaultQuestionOption = questionOptionList.get(i);
+            QuesOption option = new QuesOption();
+            option.setNumber(String.valueOf(i + 1));
+            option.setOptionBody(defaultQuestionOption.getBody());
+            if (Arrays.asList(rightAnswer).contains(String.valueOf(i))) {
+                option.setIsCorrect((short) 1);
+            } else {
+                option.setIsCorrect((short) 0);
+            }
+            quesOptions.add(option);
+        }
+        return quesOptions;
+    }
 
-	@Override
-	public String saveList(List<DefaultQuestion> defaultQuestions) {
-		if(defaultQuestions != null && defaultQuestions.size()>0){
-			List<Question> questions = new ArrayList<Question>();
-			for(DefaultQuestion defaultQuestion:defaultQuestions){
-				Question question = new Question();
-				if(!StringUtils.isBlank(defaultQuestion.getId())){
-					question.setId(defaultQuestion.getId());
-				}
-				//初始化默认课程
-				Course course = new Course();
-				course.setId("k12");
-				course.setCode("k12");
-				course.setName("k12");
-				course.setLevel("ALL");
-				course.setOrgId(defaultQuestion.getRootOrgId().toString());
-				course.setCreateTime(CommonUtils.getCurDateTime());
-				course.setEnable("true");
-				question.setCourse(course);
-				question.setOrgId(defaultQuestion.getRootOrgId().toString());
-				question.setCreateTime(CommonUtils.getCurDateTime());
-				question.setDifficulty("中");
-				question.setDifficultyDegree(0.5);
-				question.setIsolated(true);
-				question.setPublicity(true);
-				question.setProperties(defaultQuestion.getProperties());
-				DefaultQuestionStructure defaultQuestionStructure = (DefaultQuestionStructure) defaultQuestion.getMasterVersion();
-				//判断试题单元对象
-				List<DefaultQuestionUnit> questionUnitList  = defaultQuestionStructure.getQuestionUnitList();
-				if(questionUnitList == null || questionUnitList.size()<1){
-					throw new StatusException("Q-012033", "试题单元对象为空");
-				}
-				if(questionUnitList.size()==1){
-					DefaultQuestionUnit defaultQuestionUnit = questionUnitList.get(0);
-					//判断试题题型
-					if(defaultQuestionUnit.getQuestionType() == null){
-						throw new StatusException("Q-012039", "试题单元中题型为空");
-					}
-					//设置题干
-					question.setQuesBody(defaultQuestionUnit.getBody());
-					QuesStructType type = buildQuesType(defaultQuestionUnit.getQuestionType());
-					if(type == null){
-						throw new StatusException("Q-012043", "试题单元中题型值不对");
-					}
-					//设置题型
-					question.setQuestionType(type);
-					//如果是选择题,判断选项
-					if(defaultQuestionUnit.getQuestionType() == QuestionType.SINGLE_CHOICE || defaultQuestionUnit.getQuestionType() == QuestionType.MULTIPLE_CHOICE){
-						List<DefaultQuestionOption> questionOptionList = defaultQuestionUnit.getQuestionOptionList();
-						if(questionOptionList == null || questionOptionList.size()<1){
-							throw new StatusException("Q-012049", "试题单元中选项为空");
-						}
-						//设置选项
-						List<QuesOption> quesOptions = buildOptions(questionOptionList, defaultQuestionUnit.getRightAnswer());
-						question.setQuesOptions(quesOptions);
-					}
-					//设置答案
-					question.setQuesAnswer(buildAnswer(defaultQuestionUnit));
-				}else {
-					//套题
-					//设置题干
-					question.setQuesBody(defaultQuestionStructure.getBody());
-					question.setQuestionType(QuesStructType.NESTED_ANSWER_QUESTION);
-					//生成子题
-					List<Question> subList = new ArrayList<Question>();
-					for(DefaultQuestionUnit defaultQuestionUnit:questionUnitList){
-						Question subQues = new Question();
-						subQues.setId(UUID.randomUUID().toString());
-						subQues.setDifficulty("中");
-						subQues.setDifficultyDegree(0.5);
-						subQues.setPublicity(true);
-						//判断试题题型
-						if(defaultQuestionUnit.getQuestionType() == null){
-							throw new StatusException("Q-012039", "试题单元中题型为空");
-						}
-						//设置题干
-						subQues.setQuesBody(defaultQuestionUnit.getBody());
-						QuesStructType type = buildQuesType(defaultQuestionUnit.getQuestionType());
-						if(type == null){
-							throw new StatusException("Q-012043", "试题单元中题型值不对");
-						}
-						//设置题型
-						subQues.setQuestionType(type);
-						//如果是选择题,判断选项
-						if(defaultQuestionUnit.getQuestionType() == QuestionType.SINGLE_CHOICE || defaultQuestionUnit.getQuestionType() == QuestionType.MULTIPLE_CHOICE){
-							List<DefaultQuestionOption> questionOptionList = defaultQuestionUnit.getQuestionOptionList();
-							if(questionOptionList == null || questionOptionList.size()<1){
-								throw new StatusException("Q-012049", "试题单元中选项为空");
-							}
-							//设置选项
-							List<QuesOption> quesOptions = buildOptions(questionOptionList, defaultQuestionUnit.getRightAnswer());
-							subQues.setQuesOptions(quesOptions);
-						}
-						//设置答案
-						subQues.setQuesAnswer(buildAnswer(defaultQuestionUnit));
-						subList.add(subQues);
-					}
-					question.setSubQuestions(subList);
-				}
-				questions.add(question);
-			}
-			quesRepo.saveAll(questions);
-			return "success";
-		}
-		return "failure";
-	}
+    //构建答案
+    private String buildAnswer(DefaultQuestionUnit defaultQuestionUnit) {
+        QuestionType questionType = defaultQuestionUnit.getQuestionType();
+        String answer = "";
+        String[] answers = defaultQuestionUnit.getRightAnswer();
+        if (answers == null || answers.length < 1) {
+            return answer;
+        }
+        if (questionType == QuestionType.SINGLE_CHOICE || questionType == QuestionType.MULTIPLE_CHOICE) {
+            for (int i = 0; i < answers.length; i++) {
+                int number = Integer.valueOf(answers[i]);
+                if (i == 0) {
+                    answer = CommonUtils.getOptionNum(number);
+                } else {
+                    answer = answer + "," + CommonUtils.getOptionNum(number);
+                }
+            }
+            return answer;
+        } else if (questionType == QuestionType.FILL_UP) {
+            for (int i = 0; i < answers.length; i++) {
+                if (i == 0) {
+                    answer = answers[i];
+                } else {
+                    answer = answer + "##" + answers[i];
+                }
+            }
+            return answer;
+        } else if (questionType == QuestionType.ESSAY) {
+            if (answers[0].equals("true")) {
+                answer = "正确";
+            } else {
+                answer = "错误";
+            }
+            return answer;
+        } else {
+            for (int i = 0; i < answers.length; i++) {
+                answer = answer + answers[i];
+            }
+            return answer;
+        }
+    }
 
-	@Override
-	public List<DefaultQuestion> findQuestions(Set<String> questionIds) {
-		List<Question> questions = quesRepo.findByIdIn(questionIds);
-		if(questions == null || questions.size()<1){
-			throw new StatusException("Q-012515", "questions is null");
-		}
-		List<DefaultQuestion> defaultQuestions = new ArrayList<DefaultQuestion>();
-		for(Question question:questions){
-			DefaultQuestion defaultQuestion = getDefaultQuestion(question);
-			defaultQuestions.add(defaultQuestion);
-		}
-		return defaultQuestions;
-	}
+    @Override
+    public Page<DefaultQuestion> findQustions(Long rootOrgId, Map<String, String> map, int curPage, int pageSize) {
+        Query query = new Query();
+        query.addCriteria(Criteria.where("orgId").is(rootOrgId.toString()));
+        query.addCriteria(Criteria.where("isolated").is(true));
+        if (map != null && map.size() > 0) {
+            for (Map.Entry<String, String> entry : map.entrySet()) {
+                if (entry.getKey().equals("questionType")) {
+                    if (!StringUtils.isBlank(entry.getValue())) {
+                        if (entry.getValue().equals(QuestionType.SINGLE_CHOICE.toString())) {
+                            query.addCriteria(Criteria.where("questionType").is(QuesStructType.SINGLE_ANSWER_QUESTION));
+                        } else if (entry.getValue().equals(QuestionType.MULTIPLE_CHOICE.toString())) {
+                            query.addCriteria(Criteria.where("questionType").is(QuesStructType.MULTIPLE_ANSWER_QUESTION));
+                        } else if (entry.getValue().equals(QuestionType.ESSAY.toString())) {
+                            query.addCriteria(Criteria.where("questionType").is(QuesStructType.TEXT_ANSWER_QUESTION));
+                        } else if (entry.getValue().equals(QuestionType.FILL_UP.toString())) {
+                            query.addCriteria(Criteria.where("questionType").is(QuesStructType.FILL_BLANK_QUESTION));
+                        } else if (entry.getValue().equals(QuestionType.TRUE_OR_FALSE.toString())) {
+                            query.addCriteria(Criteria.where("questionType").is(QuesStructType.BOOL_ANSWER_QUESTION));
+                        } else {
+                            throw new StatusException("Q-", "题型格式不对!");
+                        }
+                    }
+                } else if (entry.getKey().equals("difficulty")) {
+                    Pattern p = Pattern.compile(entry.getValue());
+                    String key = "properties." + entry.getKey();
+                    query.addCriteria(Criteria.where(key).regex(p));
+                } else {
+                    String la = entry.getValue();
+                    if (!StringUtils.isBlank(la)) {
+                        la = la.replaceAll(",", "*");
+                        Pattern pattern = Pattern.compile(la, Pattern.CASE_INSENSITIVE);
+                        String key = "properties." + entry.getKey();
+                        query.addCriteria(Criteria.where(key).regex(pattern));
+                    }
+                }
+            }
+        }
+        long count = this.mongoTemplate.count(query, Question.class);
+        query.limit(pageSize);
+        query.skip((curPage - 1) * pageSize);
+        List<Question> questionList = this.mongoTemplate.find(query, Question.class);
+        List<DefaultQuestion> defaultQuestions = buildDefaultQuestions(questionList);
+        Page<DefaultQuestion> questions = new PageImpl<DefaultQuestion>(defaultQuestions, new PageRequest(curPage - 1, pageSize), count);
+        return questions;
+    }
+
+    private List<DefaultQuestion> buildDefaultQuestions(List<Question> questionList) {
+        List<DefaultQuestion> defaultQuestions = new ArrayList<DefaultQuestion>();
+        if (questionList != null && questionList.size() > 0) {
+            for (Question question : questionList) {
+                DefaultQuestion defaultQuestion = getDefaultQuestion(question);
+                defaultQuestions.add(defaultQuestion);
+            }
+            return defaultQuestions;
+        }
+        return defaultQuestions;
+    }
+
+    private DefaultQuestion getDefaultQuestion(Question question) {
+        if (question != null) {
+            DefaultQuestionStructure defaultQuestionStructure = new DefaultQuestionStructure();
+            //生成新的题单元集合
+            List<DefaultQuestionUnit> questionUnitList = new ArrayList<DefaultQuestionUnit>();
+            if (question.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
+                defaultQuestionStructure.setBody(question.getQuesBody());
+                //获取套题下面所有子题
+                List<Question> subQuesList = question.getSubQuestions();
+                if (subQuesList != null && subQuesList.size() > 0) {
+                    for (int i = 0; i < subQuesList.size(); i++) {
+                        Question subQuestion = subQuesList.get(i);
+                        DefaultQuestionUnit defaultQuestionUnit = buildQuestionUnit(subQuestion);
+                        questionUnitList.add(defaultQuestionUnit);
+                    }
+                }
+            } else {
+                DefaultQuestionUnit defaultQuestionUnit = buildQuestionUnit(question);
+                questionUnitList.add(defaultQuestionUnit);
+            }
+            defaultQuestionStructure.setQuestionUnitList(questionUnitList);
+            DefaultQuestion defaultQuestion = new DefaultQuestion();
+            defaultQuestion.setId(question.getId());
+            defaultQuestion.setIsolated(true);
+            defaultQuestion.setRootOrgId(Long.valueOf(question.getOrgId()));
+            defaultQuestion.setProperties(question.getProperties());
+            defaultQuestion.setMasterVersion(defaultQuestionStructure);
+            return defaultQuestion;
+        }
+        return null;
+    }
+
+    /**
+     * 构建试题单元
+     *
+     * @param question
+     * @return
+     */
+    private DefaultQuestionUnit buildQuestionUnit(Question question) {
+        DefaultQuestionUnit defaultQuestionUnit = new DefaultQuestionUnit();
+        defaultQuestionUnit.setBody(question.getQuesBody());
+        defaultQuestionUnit.setQuestionType(getByOldType(question.getQuestionType()));
+        //如果是单选或者多选,添加选项和答案转换
+        if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION || question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
+            List<DefaultQuestionOption> defaultQuestionOptions = new ArrayList<DefaultQuestionOption>();
+            List<QuesOption> quesOptions = question.getQuesOptions();
+            if (quesOptions != null && quesOptions.size() > 0) {
+                for (int i = 0; i < quesOptions.size(); i++) {
+                    QuesOption quesOption = quesOptions.get(i);
+                    DefaultQuestionOption defaultQuestionOption = new DefaultQuestionOption();
+                    defaultQuestionOption.setBody(quesOption.getOptionBody());
+                    defaultQuestionOptions.add(defaultQuestionOption);
+                }
+            }
+            defaultQuestionUnit.setQuestionOptionList(defaultQuestionOptions);
+            defaultQuestionUnit.setRightAnswer(getSelectQuestionAnswer(quesOptions));
+        } else {
+            defaultQuestionUnit.setRightAnswer(getAnswer(question));
+        }
+        return defaultQuestionUnit;
+    }
+
+    /**
+     * 题型转换方法
+     *
+     * @param quesStructType
+     * @return
+     */
+    private QuestionType getByOldType(QuesStructType quesStructType) {
+        if (quesStructType == QuesStructType.BOOL_ANSWER_QUESTION) {
+            return QuestionType.TRUE_OR_FALSE;
+        }
+        if (quesStructType == QuesStructType.FILL_BLANK_QUESTION) {
+            return QuestionType.FILL_UP;
+        }
+        if (quesStructType == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
+            return QuestionType.MULTIPLE_CHOICE;
+        }
+        if (quesStructType == QuesStructType.SINGLE_ANSWER_QUESTION) {
+            return QuestionType.SINGLE_CHOICE;
+        }
+        if (quesStructType == QuesStructType.TEXT_ANSWER_QUESTION) {
+            return QuestionType.ESSAY;
+        }
+        return null;
+    }
+
+
+    /**
+     * 设置单选题和多选题  答案
+     *
+     * @param quesOptions
+     * @return
+     */
+    private String[] getSelectQuestionAnswer(List<QuesOption> quesOptions) {
+        String[] rightAnswer = null;
+        List<String> list = new ArrayList<String>();
+        if (quesOptions != null && quesOptions.size() > 0) {
+            for (int i = 0; i < quesOptions.size(); i++) {
+                QuesOption quesOption = quesOptions.get(i);
+                if (quesOption.getIsCorrect() == 1) {
+                    list.add(String.valueOf(i));
+                }
+            }
+            rightAnswer = list.toArray(new String[list.size()]);
+            return rightAnswer;
+        }
+        return rightAnswer;
+    }
+
+    /**
+     * 设置试题答案
+     *
+     * @param question
+     * @return
+     */
+    private String[] getAnswer(Question question) {
+        String[] rightAnswer = null;
+        //判断题答案
+        if (question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION) {
+            if (question.getQuesAnswer().equals("正确")) {
+                rightAnswer = new String[1];
+                rightAnswer[0] = "true";
+                return rightAnswer;
+            }
+            if (question.getQuesAnswer().equals("错误")) {
+                rightAnswer = new String[1];
+                rightAnswer[0] = "false";
+                return rightAnswer;
+            }
+        }
+        //填空题答案
+        if (question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION) {
+            rightAnswer = question.getQuesAnswer().split("##");
+            return rightAnswer;
+        }
+        rightAnswer = new String[1];
+        rightAnswer[0] = question.getQuesAnswer();
+        return rightAnswer;
+    }
+
+    @Override
+    public String saveList(List<DefaultQuestion> defaultQuestions) {
+        if (defaultQuestions != null && defaultQuestions.size() > 0) {
+            List<Question> questions = new ArrayList<Question>();
+            for (DefaultQuestion defaultQuestion : defaultQuestions) {
+                Question question = new Question();
+                if (!StringUtils.isBlank(defaultQuestion.getId())) {
+                    question.setId(defaultQuestion.getId());
+                }
+                //初始化默认课程
+                Course course = new Course();
+                course.setId("k12");
+                course.setCode("k12");
+                course.setName("k12");
+                course.setLevel("ALL");
+                course.setOrgId(defaultQuestion.getRootOrgId().toString());
+                course.setCreateTime(CommonUtils.getCurDateTime());
+                course.setEnable("true");
+                question.setCourse(course);
+                question.setOrgId(defaultQuestion.getRootOrgId().toString());
+                question.setCreateTime(CommonUtils.getCurDateTime());
+                question.setDifficulty("中");
+                question.setDifficultyDegree(0.5);
+                question.setIsolated(true);
+                question.setPublicity(true);
+                question.setProperties(defaultQuestion.getProperties());
+                DefaultQuestionStructure defaultQuestionStructure = (DefaultQuestionStructure) defaultQuestion.getMasterVersion();
+                //判断试题单元对象
+                List<DefaultQuestionUnit> questionUnitList = defaultQuestionStructure.getQuestionUnitList();
+                if (questionUnitList == null || questionUnitList.size() < 1) {
+                    throw new StatusException("Q-012033", "试题单元对象为空");
+                }
+                if (questionUnitList.size() == 1) {
+                    DefaultQuestionUnit defaultQuestionUnit = questionUnitList.get(0);
+                    //判断试题题型
+                    if (defaultQuestionUnit.getQuestionType() == null) {
+                        throw new StatusException("Q-012039", "试题单元中题型为空");
+                    }
+                    //设置题干
+                    question.setQuesBody(defaultQuestionUnit.getBody());
+                    QuesStructType type = buildQuesType(defaultQuestionUnit.getQuestionType());
+                    if (type == null) {
+                        throw new StatusException("Q-012043", "试题单元中题型值不对");
+                    }
+                    //设置题型
+                    question.setQuestionType(type);
+                    //如果是选择题,判断选项
+                    if (defaultQuestionUnit.getQuestionType() == QuestionType.SINGLE_CHOICE || defaultQuestionUnit.getQuestionType() == QuestionType.MULTIPLE_CHOICE) {
+                        List<DefaultQuestionOption> questionOptionList = defaultQuestionUnit.getQuestionOptionList();
+                        if (questionOptionList == null || questionOptionList.size() < 1) {
+                            throw new StatusException("Q-012049", "试题单元中选项为空");
+                        }
+                        //设置选项
+                        List<QuesOption> quesOptions = buildOptions(questionOptionList, defaultQuestionUnit.getRightAnswer());
+                        question.setQuesOptions(quesOptions);
+                    }
+                    //设置答案
+                    question.setQuesAnswer(buildAnswer(defaultQuestionUnit));
+                } else {
+                    //套题
+                    //设置题干
+                    question.setQuesBody(defaultQuestionStructure.getBody());
+                    question.setQuestionType(QuesStructType.NESTED_ANSWER_QUESTION);
+                    //生成子题
+                    List<Question> subList = new ArrayList<Question>();
+                    for (DefaultQuestionUnit defaultQuestionUnit : questionUnitList) {
+                        Question subQues = new Question();
+                        subQues.setId(UUID.randomUUID().toString());
+                        subQues.setDifficulty("中");
+                        subQues.setDifficultyDegree(0.5);
+                        subQues.setPublicity(true);
+                        //判断试题题型
+                        if (defaultQuestionUnit.getQuestionType() == null) {
+                            throw new StatusException("Q-012039", "试题单元中题型为空");
+                        }
+                        //设置题干
+                        subQues.setQuesBody(defaultQuestionUnit.getBody());
+                        QuesStructType type = buildQuesType(defaultQuestionUnit.getQuestionType());
+                        if (type == null) {
+                            throw new StatusException("Q-012043", "试题单元中题型值不对");
+                        }
+                        //设置题型
+                        subQues.setQuestionType(type);
+                        //如果是选择题,判断选项
+                        if (defaultQuestionUnit.getQuestionType() == QuestionType.SINGLE_CHOICE || defaultQuestionUnit.getQuestionType() == QuestionType.MULTIPLE_CHOICE) {
+                            List<DefaultQuestionOption> questionOptionList = defaultQuestionUnit.getQuestionOptionList();
+                            if (questionOptionList == null || questionOptionList.size() < 1) {
+                                throw new StatusException("Q-012049", "试题单元中选项为空");
+                            }
+                            //设置选项
+                            List<QuesOption> quesOptions = buildOptions(questionOptionList, defaultQuestionUnit.getRightAnswer());
+                            subQues.setQuesOptions(quesOptions);
+                        }
+                        //设置答案
+                        subQues.setQuesAnswer(buildAnswer(defaultQuestionUnit));
+                        subList.add(subQues);
+                    }
+                    question.setSubQuestions(subList);
+                }
+                questions.add(question);
+            }
+            quesRepo.saveAll(questions);
+            return "success";
+        }
+        return "failure";
+    }
+
+    @Override
+    public List<DefaultQuestion> findQuestions(Set<String> questionIds) {
+        List<Question> questions = quesRepo.findByIdIn(questionIds);
+        if (questions == null || questions.size() < 1) {
+            throw new StatusException("Q-012515", "questions is null");
+        }
+        List<DefaultQuestion> defaultQuestions = new ArrayList<DefaultQuestion>();
+        for (Question question : questions) {
+            DefaultQuestion defaultQuestion = getDefaultQuestion(question);
+            defaultQuestions.add(defaultQuestion);
+        }
+        return defaultQuestions;
+    }
 }

+ 11 - 10
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/initQuesHash/InitQuesHashService.java

@@ -1,18 +1,19 @@
 package cn.com.qmth.examcloud.core.questions.service.initQuesHash;
 
 /**
- * @author 		weiwenhai
- * @date 		2018.7.17
- * @company		qmth
- * @describle	InitQuesHashService
+ * @author weiwenhai
+ * @date 2018.7.17
+ * @company qmth
+ * @describle InitQuesHashService
  */
 
 public interface InitQuesHashService {
 
-	/**
-	 * 根据orgId初始化所有小题的题干hash
-	 * @param orgId
-	 */
-	public void initHash(String orgId);
-	
+    /**
+     * 根据orgId初始化所有小题的题干hash
+     *
+     * @param orgId
+     */
+    public void initHash(String orgId);
+
 }

+ 21 - 21
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/initQuesHash/InitQuesHashServiceImpl.java

@@ -12,30 +12,30 @@ import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
 import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
 
 /**
- * @author 		weiwenhai
- * @date 		2018.7.17
- * @company		qmth
- * @describle	InitQuesHashServiceImpl
+ * @author weiwenhai
+ * @date 2018.7.17
+ * @company qmth
+ * @describle InitQuesHashServiceImpl
  */
 @Service("initQuesHashService")
-public class InitQuesHashServiceImpl implements InitQuesHashService{
+public class InitQuesHashServiceImpl implements InitQuesHashService {
 
-	@Autowired
+    @Autowired
     private MongoTemplate mongoTemplate;
-	
-	@SuppressWarnings("unused")
-	@Override
-	public void initHash(String orgId) {
-		Query query = new Query();
-		query.addCriteria(Criteria.where("orgId").is(orgId));
-		List<Question> questions = this.mongoTemplate.find(query, Question.class);
-		if(questions != null && questions.size()>0){
-			for(Question question:questions){
-				String bodyHtml = question.getQuesBody();
-				String newBody = CommonUtils.parseHtml(bodyHtml);
-				//newBody转化成bodyHash。
-			}
-		}
-	}
+
+    @SuppressWarnings("unused")
+    @Override
+    public void initHash(String orgId) {
+        Query query = new Query();
+        query.addCriteria(Criteria.where("orgId").is(orgId));
+        List<Question> questions = this.mongoTemplate.find(query, Question.class);
+        if (questions != null && questions.size() > 0) {
+            for (Question question : questions) {
+                String bodyHtml = question.getQuesBody();
+                String newBody = CommonUtils.parseHtml(bodyHtml);
+                //newBody转化成bodyHash。
+            }
+        }
+    }
 
 }

+ 142 - 81
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/DdCollegeUtilService.java

@@ -56,10 +56,71 @@ import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestQuestion;
 import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestQuestionInfo;
 
 *//**
- * @author 		weiwenhai
- * @date		2018.7.19
- * @company		qmth
- * @describle	地大题库数据导入
+ * @author weiwenhai
+ * @date 2018.7.19
+ * @company qmth
+ * @describle 地大题库数据导入 根据课程代码查询所有试卷
+ * @param codeName
+ * @return
+ * @throws UnsupportedEncodingException
+ * <p>
+ * 根据考试id查询所有试题
+ * @param testPaperContentId
+ * @return 根据父ID查询子题
+ * @param parentId
+ * @return 初始化试卷对象
+ * @param paper
+ * @param paperName
+ * @param user
+ * <p>
+ * 初始化大题对象
+ * @param testQuestion
+ * @return 初始化试题对象
+ * @param testQuestionInfo
+ * @param testQuestion
+ * @param course
+ * @param map
+ * @return
+ * @throws Exception
+ * <p>
+ * 初始化题干,答案,选项,资源
+ * @param question
+ * @param testQuestionInfo
+ * @param map
+ * @throws Exception
+ * <p>
+ * 初始化选项
+ * @param testOption
+ * @param number
+ * @param isCorrect
+ * @param wordMLPackage
+ * @return
+ * @throws Exception
+ * <p>
+ * 完形填空初始化所有子题
+ * @param blanks
+ * @param wordMLPackage
+ * @return
+ * @throws Exception
+ * <p>
+ * 初始化小题对象
+ * @param question
+ * @return 将大题和小题分类
+ * @param questions
+ * @return 去除图片中有下划线的图片,并补全图片下载地址
+ * @param str
+ * @return
+ * @throws Exception
+ * <p>
+ * 去除<span>标签中lang=EN-US
+ * @param str
+ * @return 替换img标签,补全图片
+ * @param imgList
+ * @param str
+ * @return 將url路徑中的中文转码
+ * @param str
+ * @return
+ * @throws UnsupportedEncodingException
  *//*
 @Service("ddCollegeUtilService")
 public class DdCollegeUtilService {
@@ -187,11 +248,11 @@ public class DdCollegeUtilService {
 	}
 	
 	*//**
-	 * 根据课程代码查询所有试卷
-	 * @param codeName
-	 * @return
-	 * @throws UnsupportedEncodingException 
-	 *//*
+ * 根据课程代码查询所有试卷
+ * @param codeName
+ * @return
+ * @throws UnsupportedEncodingException
+ *//*
 	@SuppressWarnings({"unchecked","rawtypes"})
 	public List<TestPaper> queryByCourse(String courseCode) throws UnsupportedEncodingException{
 		String sql = "SELECT * from TEST_PAPER_INFO p WHERE p.COURSE_ID in "
@@ -202,10 +263,10 @@ public class DdCollegeUtilService {
 	}
     
     *//**
-     * 根据考试id查询所有试题
-     * @param testPaperContentId
-     * @return
-     *//*
+ * 根据考试id查询所有试题
+ * @param testPaperContentId
+ * @return
+ *//*
     @SuppressWarnings({"unchecked","rawtypes"})
     public List<TestQuestion> queryByTestPaper(String testPaperContentId){
     	List<TestQuestion> dquestions = new ArrayList<TestQuestion>();
@@ -246,10 +307,10 @@ public class DdCollegeUtilService {
     }
     
     *//**
-     * 根据父ID查询子题
-     * @param parentId
-     * @return
-     *//*
+ * 根据父ID查询子题
+ * @param parentId
+ * @return
+ *//*
     @SuppressWarnings({"unchecked","rawtypes"})
     public List<TestQuestion> querySubQuestions(String parentId){
     	String sql = "SELECT q.question_type_enum type, q.json json from QUESTION_CONTENT q WHERE q.parent_id = '" + parentId +"' order by q.sequence";
@@ -258,11 +319,11 @@ public class DdCollegeUtilService {
     }
     
     *//**
-	 * 初始化试卷对象
-	 * @param paper
-	 * @param paperName
-	 * @param user
-	 *//*
+ * 初始化试卷对象
+ * @param paper
+ * @param paperName
+ * @param user
+ *//*
     public Paper initPaper(TestPaper testPaper, String orgId, Course course,Map<Integer, List<TestQuestion>> map) {
     	int unitCount = 0;
     	Set<Integer> paperDetails = map.keySet();
@@ -287,10 +348,10 @@ public class DdCollegeUtilService {
     }
     
     *//**
-     * 初始化大题对象
-     * @param testQuestion
-     * @return
-     *//*
+ * 初始化大题对象
+ * @param testQuestion
+ * @return
+ *//*
     public PaperDetail initPaperDetail(List<TestQuestion> dQuestions,Paper paper){
     	//定义大题分数
     	double dTotal = 0;
@@ -311,14 +372,14 @@ public class DdCollegeUtilService {
     }
     
    *//**
-    * 初始化试题对象
-    * @param testQuestionInfo
-    * @param testQuestion
-    * @param course
-    * @param map
-    * @return
-    * @throws Exception
-    *//*
+ * 初始化试题对象
+ * @param testQuestionInfo
+ * @param testQuestion
+ * @param course
+ * @param map
+ * @return
+ * @throws Exception
+ *//*
     public Question initQuestion(TestQuestionInfo testQuestionInfo,TestQuestion testQuestion,Course course,Map<Question, QuestionPkgPath> map,double difficulty) throws Exception{
     	Question question = new Question();
     	question.setCreateTime(CommonUtils.getCurDateTime());
@@ -336,12 +397,12 @@ public class DdCollegeUtilService {
     }
     
     *//**
-     * 初始化题干,答案,选项,资源
-     * @param question
-     * @param testQuestionInfo
-     * @param map
-     * @throws Exception
-     *//*
+ * 初始化题干,答案,选项,资源
+ * @param question
+ * @param testQuestionInfo
+ * @param map
+ * @throws Exception
+ *//*
     public void initQuestionInfo(Question question,TestQuestionInfo testQuestionInfo,Map<Question, QuestionPkgPath> map,TestQuestion testQuestion) throws Exception{
     	WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
     	//选词填空
@@ -598,14 +659,14 @@ public class DdCollegeUtilService {
     }
     
     *//**
-     * 初始化选项
-     * @param testOption
-     * @param number
-     * @param isCorrect
-     * @param wordMLPackage
-     * @return
-     * @throws Exception
-     *//*
+ * 初始化选项
+ * @param testOption
+ * @param number
+ * @param isCorrect
+ * @param wordMLPackage
+ * @return
+ * @throws Exception
+ *//*
     public QuesOption initQuesOption(TestOption testOption,int number,short isCorrect,WordprocessingMLPackage wordMLPackage) throws Exception{
     	QuesOption quesOption = new QuesOption();
     	quesOption.setNumber(String.valueOf(number));
@@ -622,12 +683,12 @@ public class DdCollegeUtilService {
     	return quesOption;
     }
     *//**
-     * 完形填空初始化所有子题
-     * @param blanks
-     * @param wordMLPackage
-     * @return
-     * @throws Exception
-     *//*
+ * 完形填空初始化所有子题
+ * @param blanks
+ * @param wordMLPackage
+ * @return
+ * @throws Exception
+ *//*
     public List<Question> initSubQuestions(List<TestFillAnswer> blanks,WordprocessingMLPackage wordMLPackage) throws Exception{
     	List<Question> subQuestions = new ArrayList<Question>();
     	if(blanks!=null && blanks.size()>0){
@@ -718,10 +779,10 @@ public class DdCollegeUtilService {
     }
     
     *//**
-     * 初始化小题对象
-     * @param question
-     * @return
-     *//*
+ * 初始化小题对象
+ * @param question
+ * @return
+ *//*
     public PaperDetailUnit initPaperDetailUnit(Paper paper,PaperDetail paperDetail,Question question,TestQuestion testQuestion){
     	PaperDetailUnit paperDetailUnit = new PaperDetailUnit();
     	paperDetailUnit.setPaper(paper);
@@ -736,10 +797,10 @@ public class DdCollegeUtilService {
     }
     
     *//**
-     * 将大题和小题分类
-     * @param questions
-     * @return
-     *//*
+ * 将大题和小题分类
+ * @param questions
+ * @return
+ *//*
     public Map<Integer, List<TestQuestion>> sortPaperDetail(List<TestQuestion> questions){
     	if(questions != null && questions.size()>0){
     		Map<Integer, List<TestQuestion>> map = new HashMap<Integer, List<TestQuestion>>();
@@ -760,11 +821,11 @@ public class DdCollegeUtilService {
     }
     
     *//**
-     * 去除图片中有下划线的图片,并补全图片下载地址
-     * @param str
-     * @return
-     * @throws Exception 
-     *//*
+ * 去除图片中有下划线的图片,并补全图片下载地址
+ * @param str
+ * @return
+ * @throws Exception
+ *//*
     public LinkedHashMap<String, String> imgList(String str) throws Exception{
     	LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
     	//获取img标签
@@ -798,10 +859,10 @@ public class DdCollegeUtilService {
     }
     
     *//**
-     * 去除<span>标签中lang=EN-US
-     * @param str
-     * @return
-     *//*
+ * 去除<span>标签中lang=EN-US
+ * @param str
+ * @return
+ *//*
     public String replaceLang(String str){
     	if(str.contains("lang=EN-US")){
     		str = str.replace("lang=EN-US", "");
@@ -834,11 +895,11 @@ public class DdCollegeUtilService {
     }
     
     *//**
-     * 替换img标签,补全图片
-     * @param imgList
-     * @param str
-     * @return
-     *//*
+ * 替换img标签,补全图片
+ * @param imgList
+ * @param str
+ * @return
+ *//*
     public String replaceImg(LinkedHashMap<String, String> imgList,String str){
 		if(imgList != null && imgList.size()>0){
 			for(Map.Entry<String, String> entry:imgList.entrySet()){
@@ -853,11 +914,11 @@ public class DdCollegeUtilService {
     }
     
     *//**
-     * 將url路徑中的中文转码
-     * @param str
-     * @return
-     * @throws UnsupportedEncodingException 
-     *//*
+ * 將url路徑中的中文转码
+ * @param str
+ * @return
+ * @throws UnsupportedEncodingException
+ *//*
     public String regexCH(String str) throws UnsupportedEncodingException{
     	StringBuffer s = new StringBuffer();
     	Pattern pat = Pattern.compile("[\u4E00-\u9FA5]");

+ 12 - 11
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/ImgDataUtils.java

@@ -4,6 +4,7 @@
  * *************************************************
  */
 package cn.com.qmth.examcloud.core.questions.service.temp;
+
 import org.apache.commons.codec.binary.Base64;
 
 import java.io.*;
@@ -17,14 +18,14 @@ import java.util.regex.Pattern;
 public class ImgDataUtils {
 
     @SuppressWarnings("unused")
-	public static void main(String[] args) throws UnsupportedEncodingException {
+    public static void main(String[] args) throws UnsupportedEncodingException {
         /*String html = "ss<img src=\"http://fanyi.bdstatic.com/static/translation/img/header/logo_cbfea26.png\"/>aa"
                 + "sss<img src=\"http://fanyi.bdstatic.com/static/translation/pkg/index_z_15cc24c.png\"/>ss";*/
-    	String html = "in its&nbsp;<img class=\"UnderLine15\" src=\"/Shared/UnderLine?index=1\" alt=\"\" />area."
-    			+"in its&nbsp;<img class=\"UnderLine15\" src=\"/Shared/UnderLine?index=1\" alt=\"\" />area. People could"
-    			+"nbsp;<img class=\"UnderLine15\" src=\"/Shared/UnderLine?index=2\" alt=\"\" />&nbsp;than they cou"
-    			+"that led to downtown.<br /><img class=\"UnderLine15\" src=\"/Shared/UnderLine?index=3\" alt=\"\" />&nb,"
-    			+"people&nbsp;<img class=\"UnderLine15\" src=\"/Shared/UnderLine?index=4\" alt=\"\" />&nbsp;";
+        String html = "in its&nbsp;<img class=\"UnderLine15\" src=\"/Shared/UnderLine?index=1\" alt=\"\" />area."
+                + "in its&nbsp;<img class=\"UnderLine15\" src=\"/Shared/UnderLine?index=1\" alt=\"\" />area. People could"
+                + "nbsp;<img class=\"UnderLine15\" src=\"/Shared/UnderLine?index=2\" alt=\"\" />&nbsp;than they cou"
+                + "that led to downtown.<br /><img class=\"UnderLine15\" src=\"/Shared/UnderLine?index=3\" alt=\"\" />&nb,"
+                + "people&nbsp;<img class=\"UnderLine15\" src=\"/Shared/UnderLine?index=4\" alt=\"\" />&nbsp;";
         List<String> srcList = parseImages(html);
         /*for (String src : srcList) {
             System.out.println(src);
@@ -40,14 +41,14 @@ public class ImgDataUtils {
         String ssString = "/UploadFiles/刘昌辉/Images/OnlineExam20140923161629.jpg";
         //String ssString =  java.net.URLEncoder.encode("刘昌辉/Images/OnlineExam20140923161629.jpg", "GBK");
         System.out.println(ssString);
-       
+
         String testTxt = "8个文件";
         Pattern pat = Pattern.compile("[\u4E00-\u9FA5]");
         Matcher mat = pat.matcher(ssString);
-        while(mat.find()) {
-        	System.out.println(mat.group());
+        while (mat.find()) {
+            System.out.println(mat.group());
         }
-        String ss =  java.net.URLEncoder.encode("刘昌辉", "utf-8");
+        String ss = java.net.URLEncoder.encode("刘昌辉", "utf-8");
         System.out.println(ss);
     }
 
@@ -89,7 +90,7 @@ public class ImgDataUtils {
         }
         return images;
     }
-    
+
     /**
      * 获取网络图片的流数据,并base64编码
      */

+ 110 - 110
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/QuestionsTemp.java

@@ -6,114 +6,114 @@ import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
 
 public class QuestionsTemp {
 
-	private String number;
-	
-	private String name;
-	
-	private String totalScore;
-	
-	private String count;
-	
-	private String score;
-	
-	private String body;
-	
-	private QuesStructType type;
-	
-	private String answer;
-	
-	private Map<Object, Object> options;
-	
-	private Map<Object, Object> subQues;
-	
-	private Map<Object, Object> ques;
-
-	public String getNumber() {
-		return number;
-	}
-
-	public void setNumber(String number) {
-		this.number = number;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public String getTotalScore() {
-		return totalScore;
-	}
-
-	public void setTotalScore(String totalScore) {
-		this.totalScore = totalScore;
-	}
-
-	public String getCount() {
-		return count;
-	}
-
-	public void setCount(String count) {
-		this.count = count;
-	}
-
-	public String getScore() {
-		return score;
-	}
-
-	public void setScore(String score) {
-		this.score = score;
-	}
-
-	public String getBody() {
-		return body;
-	}
-
-	public void setBody(String body) {
-		this.body = body;
-	}
-
-	public QuesStructType getType() {
-		return type;
-	}
-
-	public void setType(QuesStructType type) {
-		this.type = type;
-	}
-
-	public String getAnswer() {
-		return answer;
-	}
-
-	public void setAnswer(String answer) {
-		this.answer = answer;
-	}
-
-	public Map<Object, Object> getOptions() {
-		return options;
-	}
-
-	public void setOptions(Map<Object, Object> options) {
-		this.options = options;
-	}
-
-	public Map<Object, Object> getSubQues() {
-		return subQues;
-	}
-
-	public void setSubQues(Map<Object, Object> subQues) {
-		this.subQues = subQues;
-	}
-
-	public Map<Object, Object> getQues() {
-		return ques;
-	}
-
-	public void setQues(Map<Object, Object> ques) {
-		this.ques = ques;
-	}
-	
+    private String number;
+
+    private String name;
+
+    private String totalScore;
+
+    private String count;
+
+    private String score;
+
+    private String body;
+
+    private QuesStructType type;
+
+    private String answer;
+
+    private Map<Object, Object> options;
+
+    private Map<Object, Object> subQues;
+
+    private Map<Object, Object> ques;
+
+    public String getNumber() {
+        return number;
+    }
+
+    public void setNumber(String number) {
+        this.number = number;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getTotalScore() {
+        return totalScore;
+    }
+
+    public void setTotalScore(String totalScore) {
+        this.totalScore = totalScore;
+    }
+
+    public String getCount() {
+        return count;
+    }
+
+    public void setCount(String count) {
+        this.count = count;
+    }
+
+    public String getScore() {
+        return score;
+    }
+
+    public void setScore(String score) {
+        this.score = score;
+    }
+
+    public String getBody() {
+        return body;
+    }
+
+    public void setBody(String body) {
+        this.body = body;
+    }
+
+    public QuesStructType getType() {
+        return type;
+    }
+
+    public void setType(QuesStructType type) {
+        this.type = type;
+    }
+
+    public String getAnswer() {
+        return answer;
+    }
+
+    public void setAnswer(String answer) {
+        this.answer = answer;
+    }
+
+    public Map<Object, Object> getOptions() {
+        return options;
+    }
+
+    public void setOptions(Map<Object, Object> options) {
+        this.options = options;
+    }
+
+    public Map<Object, Object> getSubQues() {
+        return subQues;
+    }
+
+    public void setSubQues(Map<Object, Object> subQues) {
+        this.subQues = subQues;
+    }
+
+    public Map<Object, Object> getQues() {
+        return ques;
+    }
+
+    public void setQues(Map<Object, Object> ques) {
+        this.ques = ques;
+    }
+
 }

+ 45 - 44
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/UpdatePaperStruct.java

@@ -17,67 +17,68 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.PaperStruct;
 import cn.com.qmth.examcloud.core.questions.dao.entity.dto.PaperDetailUnitStructDto;
 
 /**
- * @author 		weiwenhai
- * @date		2017.9.7
- * @company		qmth
- * @describle	批量跟新线上精确试卷结构工具类
+ * @author weiwenhai
+ * @date 2017.9.7
+ * @company qmth
+ * @describle 批量跟新线上精确试卷结构工具类
  */
 
 @Service("updatePaperStructService")
 public class UpdatePaperStruct {
-	
-	@Autowired
+
+    @Autowired
     PaperStructRepo paperStructRepo;
-	
-	@Autowired
+
+    @Autowired
     MongoTemplate mongoTemplate;
 
-	public void updatePaperStruct(String orgId){
-		//根据orgId查询所有精确试卷结构
-		//Query query = new Query();
+    public void updatePaperStruct(String orgId) {
+        //根据orgId查询所有精确试卷结构
+        //Query query = new Query();
         /*query.addCriteria(Criteria.where("orgId").is(orgId));
         query.addCriteria(Criteria.where("type").is("EXACT"));
         List<PaperStruct> paperStructList = this.mongoTemplate.find(query, PaperStruct.class);*/
-		PaperStruct paSruct = Model.of(paperStructRepo.findById("5a03ca4e57853f6b94c8e526"));
-		List<PaperStruct> paperStructList = new ArrayList<PaperStruct>();
-		paperStructList.add(paSruct);
+        PaperStruct paSruct = Model.of(paperStructRepo.findById("5a03ca4e57853f6b94c8e526"));
+        List<PaperStruct> paperStructList = new ArrayList<PaperStruct>();
+        paperStructList.add(paSruct);
         int i = 0;
-        if(paperStructList!=null && paperStructList.size()>0){
-        	for(PaperStruct paperStruct:paperStructList){
-        		//获取大题集合
-        		List<PaperDetailStruct> paperDetailStructs = paperStruct.getPaperDetailStructs();
-    			for(PaperDetailStruct paperDetailStruct:paperDetailStructs){
-    				//获取小题类型统计
-    				List<PaperDetailUnitStructDto> unitStructs = paperDetailStruct.getUnitStructs();
-    				for(PaperDetailUnitStructDto dto:unitStructs){
-    					dto.setPublicDifficulty(0);
-    					dto.setPublicMedium(dto.getCount());
-    					dto.setPublicSimple(0);
-    					dto.setNoPublicDifficulty(0);
-    					dto.setNoPublicMedium(0);
-    					dto.setNoPublicSimple(0);
-    				}
-        			List<PaperDetailUnitStruct> units = paperDetailStruct.getPaperDetailUnitStructs();
-        			for(PaperDetailUnitStruct unitStruct:units){
-        				unitStruct.setDifficulty("中");
-                		unitStruct.setPublicity(true);
-                		unitStruct.setPropertyGroup(buildGroup(unitStruct));
-        			}
-        		}
-    			i++;
-        	}
+        if (paperStructList != null && paperStructList.size() > 0) {
+            for (PaperStruct paperStruct : paperStructList) {
+                //获取大题集合
+                List<PaperDetailStruct> paperDetailStructs = paperStruct.getPaperDetailStructs();
+                for (PaperDetailStruct paperDetailStruct : paperDetailStructs) {
+                    //获取小题类型统计
+                    List<PaperDetailUnitStructDto> unitStructs = paperDetailStruct.getUnitStructs();
+                    for (PaperDetailUnitStructDto dto : unitStructs) {
+                        dto.setPublicDifficulty(0);
+                        dto.setPublicMedium(dto.getCount());
+                        dto.setPublicSimple(0);
+                        dto.setNoPublicDifficulty(0);
+                        dto.setNoPublicMedium(0);
+                        dto.setNoPublicSimple(0);
+                    }
+                    List<PaperDetailUnitStruct> units = paperDetailStruct.getPaperDetailUnitStructs();
+                    for (PaperDetailUnitStruct unitStruct : units) {
+                        unitStruct.setDifficulty("中");
+                        unitStruct.setPublicity(true);
+                        unitStruct.setPropertyGroup(buildGroup(unitStruct));
+                    }
+                }
+                i++;
+            }
         }
-        System.out.println("更新精确试卷结构的数量为:"+ i + "------个");
+        System.out.println("更新精确试卷结构的数量为:" + i + "------个");
         paperStructRepo.saveAll(paperStructList);
         System.out.println("更新成功!----");
-	}
-	
-	/**
+    }
+
+    /**
      * 构建精确组建筛选条件
+     *
      * @param unitStruct
      * @return
      */
-    private String buildGroup(PaperDetailUnitStruct unitStruct){
-    	return String.valueOf(unitStruct.getPublicity()) + "-" + unitStruct.getDifficulty();
+    private String buildGroup(PaperDetailUnitStruct unitStruct) {
+        return String.valueOf(unitStruct.getPublicity()) + "-" + unitStruct.getDifficulty();
     }
 }

+ 54 - 54
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/DdExcelDto.java

@@ -3,61 +3,61 @@ package cn.com.qmth.examcloud.core.questions.service.temp.vo;
 import java.util.Map;
 
 /**
- * @author 		weiwenhai
- * @date 		2018.8.19
- * @company		qmth
- * @describle	地大各个课程下各题型统计Excel
+ * @author weiwenhai
+ * @date 2018.8.19
+ * @company qmth
+ * @describle 地大各个课程下各题型统计Excel
  */
 public class DdExcelDto {
 
-	/**
-	 * 课程名称
-	 */
-	private String courseName;
-	
-	/**
-	 * 课程代码
-	 */
-	private String courseCode;
-	
-	/**
-	 * key:大题名称
-	 * value:数量
-	 */
-	private Map<String, Long> map;
-	
-	public DdExcelDto(){
-		
-	}
-	
-	public DdExcelDto(String courseName,String courseCode,Map<String, Long> map){
-		this.courseName = courseName;
-		this.courseCode = courseCode;
-		this.map = map;
-	}
-
-	public String getCourseName() {
-		return courseName;
-	}
-
-	public void setCourseName(String courseName) {
-		this.courseName = courseName;
-	}
-
-	public String getCourseCode() {
-		return courseCode;
-	}
-
-	public void setCourseCode(String courseCode) {
-		this.courseCode = courseCode;
-	}
-
-	public Map<String, Long> getMap() {
-		return map;
-	}
-
-	public void setMap(Map<String, Long> map) {
-		this.map = map;
-	}
-	
+    /**
+     * 课程名称
+     */
+    private String courseName;
+
+    /**
+     * 课程代码
+     */
+    private String courseCode;
+
+    /**
+     * key:大题名称
+     * value:数量
+     */
+    private Map<String, Long> map;
+
+    public DdExcelDto() {
+
+    }
+
+    public DdExcelDto(String courseName, String courseCode, Map<String, Long> map) {
+        this.courseName = courseName;
+        this.courseCode = courseCode;
+        this.map = map;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public Map<String, Long> getMap() {
+        return map;
+    }
+
+    public void setMap(Map<String, Long> map) {
+        this.map = map;
+    }
+
 }

+ 95 - 95
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/DdPaperDto.java

@@ -1,103 +1,103 @@
 package cn.com.qmth.examcloud.core.questions.service.temp.vo;
 
 /**
- * @author 		weiwenhai
- * @date		2018.9.15
- * @company		qmth
- * @description	地大试卷详情导出类
+ * @author weiwenhai
+ * @date 2018.9.15
+ * @company qmth
+ * @description 地大试卷详情导出类
  */
 
 public class DdPaperDto {
-	
-	/**
-	 * 课程代码
-	 */
-	private String code;
-	
-	/**
-	 * 课程名称
-	 */
-	private String name;
-	
-	/**
-	 * 试卷名称
-	 */
-	private String paperName;
-	
-	/**
-	 * 大题名称
-	 */
-	private String detailName;
-	
-	/**
-	 * 大题来源
-	 */
-	private String quesNames;
-	
-	/**
-	 * 题目数量
-	 */
-	private int number;
-	
-	/**
-	 * 题型
-	 */
-	private String quesType;
-
-	public String getCode() {
-		return code;
-	}
-
-	public void setCode(String code) {
-		this.code = code;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public String getPaperName() {
-		return paperName;
-	}
-
-	public void setPaperName(String paperName) {
-		this.paperName = paperName;
-	}
-
-	public String getDetailName() {
-		return detailName;
-	}
-
-	public void setDetailName(String detailName) {
-		this.detailName = detailName;
-	}
-
-	public String getQuesNames() {
-		return quesNames;
-	}
-
-	public void setQuesNames(String quesNames) {
-		this.quesNames = quesNames;
-	}
-
-	public int getNumber() {
-		return number;
-	}
-
-	public void setNumber(int number) {
-		this.number = number;
-	}
-
-	public String getQuesType() {
-		return quesType;
-	}
-
-	public void setQuesType(String quesType) {
-		this.quesType = quesType;
-	}
+
+    /**
+     * 课程代码
+     */
+    private String code;
+
+    /**
+     * 课程名称
+     */
+    private String name;
+
+    /**
+     * 试卷名称
+     */
+    private String paperName;
+
+    /**
+     * 大题名称
+     */
+    private String detailName;
+
+    /**
+     * 大题来源
+     */
+    private String quesNames;
+
+    /**
+     * 题目数量
+     */
+    private int number;
+
+    /**
+     * 题型
+     */
+    private String quesType;
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getPaperName() {
+        return paperName;
+    }
+
+    public void setPaperName(String paperName) {
+        this.paperName = paperName;
+    }
+
+    public String getDetailName() {
+        return detailName;
+    }
+
+    public void setDetailName(String detailName) {
+        this.detailName = detailName;
+    }
+
+    public String getQuesNames() {
+        return quesNames;
+    }
+
+    public void setQuesNames(String quesNames) {
+        this.quesNames = quesNames;
+    }
+
+    public int getNumber() {
+        return number;
+    }
+
+    public void setNumber(int number) {
+        this.number = number;
+    }
+
+    public String getQuesType() {
+        return quesType;
+    }
+
+    public void setQuesType(String quesType) {
+        this.quesType = quesType;
+    }
 
 }

+ 82 - 82
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/DdPaperStructDto.java

@@ -1,89 +1,89 @@
 package cn.com.qmth.examcloud.core.questions.service.temp.vo;
 
 /**
- * @author 		weiwenhai
- * @date		2018.9.15
- * @company		qmth
- * @description	地大试卷结构导出类
+ * @author weiwenhai
+ * @date 2018.9.15
+ * @company qmth
+ * @description 地大试卷结构导出类
  */
 public class DdPaperStructDto {
 
-	/**
-	 * 课程代码
-	 */
-	private String code;
-	
-	/**
-	 * 课程名称
-	 */
-	private String name;
-	
-	/**
-	 * 大题名称
-	 */
-	private String detailName;
-	
-	/**
-	 * 大题来源
-	 */
-	private String quesNames;
-	
-	/**
-	 * 题目数量
-	 */
-	private int number;
-	
-	/**
-	 * 题型
-	 */
-	private String quesType;
-
-	public String getCode() {
-		return code;
-	}
-
-	public void setCode(String code) {
-		this.code = code;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public String getDetailName() {
-		return detailName;
-	}
-
-	public void setDetailName(String detailName) {
-		this.detailName = detailName;
-	}
-
-	public String getQuesNames() {
-		return quesNames;
-	}
-
-	public void setQuesNames(String quesNames) {
-		this.quesNames = quesNames;
-	}
-
-	public int getNumber() {
-		return number;
-	}
-
-	public void setNumber(int number) {
-		this.number = number;
-	}
-
-	public String getQuesType() {
-		return quesType;
-	}
-
-	public void setQuesType(String quesType) {
-		this.quesType = quesType;
-	}
-	
+    /**
+     * 课程代码
+     */
+    private String code;
+
+    /**
+     * 课程名称
+     */
+    private String name;
+
+    /**
+     * 大题名称
+     */
+    private String detailName;
+
+    /**
+     * 大题来源
+     */
+    private String quesNames;
+
+    /**
+     * 题目数量
+     */
+    private int number;
+
+    /**
+     * 题型
+     */
+    private String quesType;
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDetailName() {
+        return detailName;
+    }
+
+    public void setDetailName(String detailName) {
+        this.detailName = detailName;
+    }
+
+    public String getQuesNames() {
+        return quesNames;
+    }
+
+    public void setQuesNames(String quesNames) {
+        this.quesNames = quesNames;
+    }
+
+    public int getNumber() {
+        return number;
+    }
+
+    public void setNumber(int number) {
+        this.number = number;
+    }
+
+    public String getQuesType() {
+        return quesType;
+    }
+
+    public void setQuesType(String quesType) {
+        this.quesType = quesType;
+    }
+
 }

+ 147 - 146
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/SubQuestionDto.java

@@ -1,152 +1,153 @@
 package cn.com.qmth.examcloud.core.questions.service.temp.vo;
+
 /**
- * @author 		weiwenhai
- * @date		2018.11.23
- * @description	主观题导出
+ * @author weiwenhai
+ * @date 2018.11.23
+ * @description 主观题导出
  */
 public class SubQuestionDto {
 
-	/**
-	 * 试卷id
-	 */
-	private String paperId;
-	
-	/**
-	 * 试卷名称
-	 */
-	private String paperName;
-	
-	/**
-	 * 课程代码
-	 */
-	private String courseCode;
-	
-	/**
-	 * 课程名称
-	 */
-	private String courseName;
-	
-	/**
-	 * 大题序号
-	 */
-	private Integer dNumber;
-	
-	/**
-	 * 题目序号
-	 */
-	private Integer number;
-	
-	/**
-	 * 原题干
-	 */
-	private String body;
-	
-	/**
-	 * 去除标签后题干
-	 */
-	private String clearBody;
-	
-	/**
-	 * 原答案
-	 */
-	private String answer;
-	
-	/**
-	 * 去除标签答案
-	 */
-	private String clearAnswer;
-	
-	/**
-	 * 分数
-	 */
-	private Double score;
-
-	public String getPaperId() {
-		return paperId;
-	}
-
-	public void setPaperId(String paperId) {
-		this.paperId = paperId;
-	}
-
-	public String getPaperName() {
-		return paperName;
-	}
-
-	public void setPaperName(String paperName) {
-		this.paperName = paperName;
-	}
-
-	public String getCourseCode() {
-		return courseCode;
-	}
-
-	public void setCourseCode(String courseCode) {
-		this.courseCode = courseCode;
-	}
-
-	public String getCourseName() {
-		return courseName;
-	}
-
-	public void setCourseName(String courseName) {
-		this.courseName = courseName;
-	}
-
-	public Integer getNumber() {
-		return number;
-	}
-
-	public void setNumber(Integer number) {
-		this.number = number;
-	}
-
-	public String getBody() {
-		return body;
-	}
-
-	public void setBody(String body) {
-		this.body = body;
-	}
-
-	public String getClearBody() {
-		return clearBody;
-	}
-
-	public void setClearBody(String clearBody) {
-		this.clearBody = clearBody;
-	}
-
-	public String getAnswer() {
-		return answer;
-	}
-
-	public void setAnswer(String answer) {
-		this.answer = answer;
-	}
-
-	public String getClearAnswer() {
-		return clearAnswer;
-	}
-
-	public void setClearAnswer(String clearAnswer) {
-		this.clearAnswer = clearAnswer;
-	}
-
-	public Double getScore() {
-		return score;
-	}
-
-	public void setScore(Double score) {
-		this.score = score;
-	}
-
-	public Integer getdNumber() {
-		return dNumber;
-	}
-
-	public void setdNumber(Integer dNumber) {
-		this.dNumber = dNumber;
-	}
-	
+    /**
+     * 试卷id
+     */
+    private String paperId;
+
+    /**
+     * 试卷名称
+     */
+    private String paperName;
+
+    /**
+     * 课程代码
+     */
+    private String courseCode;
+
+    /**
+     * 课程名称
+     */
+    private String courseName;
+
+    /**
+     * 大题序号
+     */
+    private Integer dNumber;
+
+    /**
+     * 题目序号
+     */
+    private Integer number;
+
+    /**
+     * 原题干
+     */
+    private String body;
+
+    /**
+     * 去除标签后题干
+     */
+    private String clearBody;
+
+    /**
+     * 原答案
+     */
+    private String answer;
+
+    /**
+     * 去除标签答案
+     */
+    private String clearAnswer;
+
+    /**
+     * 分数
+     */
+    private Double score;
+
+    public String getPaperId() {
+        return paperId;
+    }
+
+    public void setPaperId(String paperId) {
+        this.paperId = paperId;
+    }
+
+    public String getPaperName() {
+        return paperName;
+    }
+
+    public void setPaperName(String paperName) {
+        this.paperName = paperName;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public Integer getNumber() {
+        return number;
+    }
+
+    public void setNumber(Integer number) {
+        this.number = number;
+    }
+
+    public String getBody() {
+        return body;
+    }
+
+    public void setBody(String body) {
+        this.body = body;
+    }
+
+    public String getClearBody() {
+        return clearBody;
+    }
+
+    public void setClearBody(String clearBody) {
+        this.clearBody = clearBody;
+    }
+
+    public String getAnswer() {
+        return answer;
+    }
+
+    public void setAnswer(String answer) {
+        this.answer = answer;
+    }
+
+    public String getClearAnswer() {
+        return clearAnswer;
+    }
+
+    public void setClearAnswer(String clearAnswer) {
+        this.clearAnswer = clearAnswer;
+    }
+
+    public Double getScore() {
+        return score;
+    }
+
+    public void setScore(Double score) {
+        this.score = score;
+    }
+
+    public Integer getdNumber() {
+        return dNumber;
+    }
+
+    public void setdNumber(Integer dNumber) {
+        this.dNumber = dNumber;
+    }
+
 }

+ 53 - 53
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestFillAnswer.java

@@ -3,60 +3,60 @@ package cn.com.qmth.examcloud.core.questions.service.temp.vo;
 import java.util.List;
 
 /**
- * @author 		weiwenhai
- * @date		2018.7.22
- * @company	 	qmth
- * @describle	填空题答案对象
+ * @author weiwenhai
+ * @date 2018.7.22
+ * @company qmth
+ * @describle 填空题答案对象
  */
 public class TestFillAnswer {
 
-	private String ID;
-	
-	/**
-	 * 填空题答案
-	 */
-	private List<TestFillContent> Answers;
-	
-	/**
-	 * 选词填空题答案
-	 */
-	private String AnswerId;
-	
-	/**
-	 * 完形填空选项
-	 */
-	private TestOptionGroup OptionGroup;
-
-	public String getID() {
-		return ID;
-	}
-
-	public void setID(String iD) {
-		ID = iD;
-	}
-
-	public List<TestFillContent> getAnswers() {
-		return Answers;
-	}
-
-	public void setAnswers(List<TestFillContent> answers) {
-		Answers = answers;
-	}
-
-	public String getAnswerId() {
-		return AnswerId;
-	}
-
-	public void setAnswerId(String answerId) {
-		AnswerId = answerId;
-	}
-
-	public TestOptionGroup getOptionGroup() {
-		return OptionGroup;
-	}
-
-	public void setOptionGroup(TestOptionGroup optionGroup) {
-		OptionGroup = optionGroup;
-	}
-	
+    private String ID;
+
+    /**
+     * 填空题答案
+     */
+    private List<TestFillContent> Answers;
+
+    /**
+     * 选词填空题答案
+     */
+    private String AnswerId;
+
+    /**
+     * 完形填空选项
+     */
+    private TestOptionGroup OptionGroup;
+
+    public String getID() {
+        return ID;
+    }
+
+    public void setID(String iD) {
+        ID = iD;
+    }
+
+    public List<TestFillContent> getAnswers() {
+        return Answers;
+    }
+
+    public void setAnswers(List<TestFillContent> answers) {
+        Answers = answers;
+    }
+
+    public String getAnswerId() {
+        return AnswerId;
+    }
+
+    public void setAnswerId(String answerId) {
+        AnswerId = answerId;
+    }
+
+    public TestOptionGroup getOptionGroup() {
+        return OptionGroup;
+    }
+
+    public void setOptionGroup(TestOptionGroup optionGroup) {
+        OptionGroup = optionGroup;
+    }
+
 }

+ 12 - 12
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestFillContent.java

@@ -1,21 +1,21 @@
 package cn.com.qmth.examcloud.core.questions.service.temp.vo;
 
 /**
- * @author 		weiwenhai
- * @date		2018.7.22
- * @company		qmth
- * @describle	填空题文本对象
+ * @author weiwenhai
+ * @date 2018.7.22
+ * @company qmth
+ * @describle 填空题文本对象
  */
 public class TestFillContent {
 
-	private String Content;
+    private String Content;
 
-	public String getContent() {
-		return Content;
-	}
+    public String getContent() {
+        return Content;
+    }
+
+    public void setContent(String content) {
+        Content = content;
+    }
 
-	public void setContent(String content) {
-		Content = content;
-	}
-	
 }

+ 38 - 38
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestOption.java

@@ -2,43 +2,43 @@ package cn.com.qmth.examcloud.core.questions.service.temp.vo;
 
 public class TestOption {
 
-	/**
-	 * ID
-	 */
-	private String ID;
-	
-	/**
-	 * 选项Html
-	 */
-	private String OptionHTML;
-	
-	/**
-	 * 选项文本
-	 */
-	private String OptionTXT;
-
-	public String getID() {
-		return ID;
-	}
-
-	public void setID(String iD) {
-		ID = iD;
-	}
-
-	public String getOptionHTML() {
-		return OptionHTML;
-	}
-
-	public void setOptionHTML(String optionHTML) {
-		OptionHTML = optionHTML;
-	}
-
-	public String getOptionTXT() {
-		return OptionTXT;
-	}
-
-	public void setOptionTXT(String optionTXT) {
-		OptionTXT = optionTXT;
-	}
+    /**
+     * ID
+     */
+    private String ID;
+
+    /**
+     * 选项Html
+     */
+    private String OptionHTML;
+
+    /**
+     * 选项文本
+     */
+    private String OptionTXT;
+
+    public String getID() {
+        return ID;
+    }
+
+    public void setID(String iD) {
+        ID = iD;
+    }
+
+    public String getOptionHTML() {
+        return OptionHTML;
+    }
+
+    public void setOptionHTML(String optionHTML) {
+        OptionHTML = optionHTML;
+    }
+
+    public String getOptionTXT() {
+        return OptionTXT;
+    }
+
+    public void setOptionTXT(String optionTXT) {
+        OptionTXT = optionTXT;
+    }
 
 }

+ 15 - 15
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestOptionGroup.java

@@ -3,24 +3,24 @@ package cn.com.qmth.examcloud.core.questions.service.temp.vo;
 import java.util.List;
 
 /**
- * @author 		weiwenhai
- * @date 		2018.7.23
- * @company		qmth
- * @describle	选词填空选项组
+ * @author weiwenhai
+ * @date 2018.7.23
+ * @company qmth
+ * @describle 选词填空选项组
  */
 public class TestOptionGroup {
 
-	/**
-	 * 选词填空选项集合
-	 */
-	private List<TestOption> Options;
+    /**
+     * 选词填空选项集合
+     */
+    private List<TestOption> Options;
 
-	public List<TestOption> getOptions() {
-		return Options;
-	}
+    public List<TestOption> getOptions() {
+        return Options;
+    }
+
+    public void setOptions(List<TestOption> options) {
+        Options = options;
+    }
 
-	public void setOptions(List<TestOption> options) {
-		Options = options;
-	}
-	
 }

+ 56 - 56
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestPaper.java

@@ -1,63 +1,63 @@
 package cn.com.qmth.examcloud.core.questions.service.temp.vo;
 
 /**
- * @author 		weiwenhai
- * @date		2018.7.19
- * @company 	qmth
- * @describle	地大试卷对象
+ * @author weiwenhai
+ * @date 2018.7.19
+ * @company qmth
+ * @describle 地大试卷对象
  */
 public class TestPaper {
 
-	/**
-	 * id
-	 */
-	private String id;
-	
-	/**
-	 * 试卷名称
-	 */
-	private String name;
-	
-	/**
-	 * 试卷详情
-	 */
-	private String testPaperContentId;
-	
-	/**
-	 * 试卷总分
-	 */
-	private Double score;
-	
-	public String getId() {
-		return id;
-	}
-
-	public void setId(String id) {
-		this.id = id;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public String getTestPaperContentId() {
-		return testPaperContentId;
-	}
-
-	public void setTestPaperContentId(String testPaperContentId) {
-		this.testPaperContentId = testPaperContentId;
-	}
-
-	public Double getScore() {
-		return score;
-	}
-
-	public void setScore(Double score) {
-		this.score = score;
-	}
-	
+    /**
+     * id
+     */
+    private String id;
+
+    /**
+     * 试卷名称
+     */
+    private String name;
+
+    /**
+     * 试卷详情
+     */
+    private String testPaperContentId;
+
+    /**
+     * 试卷总分
+     */
+    private Double score;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getTestPaperContentId() {
+        return testPaperContentId;
+    }
+
+    public void setTestPaperContentId(String testPaperContentId) {
+        this.testPaperContentId = testPaperContentId;
+    }
+
+    public Double getScore() {
+        return score;
+    }
+
+    public void setScore(Double score) {
+        this.score = score;
+    }
+
 }

+ 109 - 109
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestQuestion.java

@@ -1,116 +1,116 @@
 package cn.com.qmth.examcloud.core.questions.service.temp.vo;
 
 /**
- * @author 		weiwenhai
- * @date		2018.7.19
- * @company		qmth
- * @describle	地大试题对象
+ * @author weiwenhai
+ * @date 2018.7.19
+ * @company qmth
+ * @describle 地大试题对象
  */
 public class TestQuestion {
 
-	/**
-	 * 试题id
-	 */
-	private String id;
-	
-	/**
-	 * 大题序号
-	 */
-	private Integer dNumber;
-	
-	/**
-	 * 大题名称
-	 */
-	private String dName;
-	
-	/**
-	 * 小题序号
-	 */
-	private Integer number1;
-	
-	/**
-	 * 小题分数
-	 */
-	private Double score;
-	
-	/**
-	 * 小题父id,用于套题
-	 */
-	private String parentId;
-	
-	/**
-	 * 小题类型
-	 * 11-单选题;12-多选题;13-填空题;14-选词填空;15-完形填空;20-判断题;42-复合题;60-问答题;69-名词解释
-	 */
-	private Integer type;
-	
-	/**
-	 * 试题内容
-	 */
-	private String json;
-
-	public String getId() {
-		return id;
-	}
-
-	public void setId(String id) {
-		this.id = id;
-	}
-
-	public Integer getdNumber() {
-		return dNumber;
-	}
-
-	public void setdNumber(Integer dNumber) {
-		this.dNumber = dNumber;
-	}
-
-	public String getdName() {
-		return dName;
-	}
-
-	public void setdName(String dName) {
-		this.dName = dName;
-	}
-
-	public Integer getNumber() {
-		return number1;
-	}
-
-	public void setNumber(Integer number1) {
-		this.number1 = number1;
-	}
-
-	public Double getScore() {
-		return score;
-	}
-
-	public void setScore(Double score) {
-		this.score = score;
-	}
-
-	public String getParentId() {
-		return parentId;
-	}
-
-	public void setParentId(String parentId) {
-		this.parentId = parentId;
-	}
-
-	public Integer getType() {
-		return type;
-	}
-
-	public void setType(Integer type) {
-		this.type = type;
-	}
-
-	public String getJson() {
-		return json;
-	}
-
-	public void setJson(String json) {
-		this.json = json;
-	}
-	
+    /**
+     * 试题id
+     */
+    private String id;
+
+    /**
+     * 大题序号
+     */
+    private Integer dNumber;
+
+    /**
+     * 大题名称
+     */
+    private String dName;
+
+    /**
+     * 小题序号
+     */
+    private Integer number1;
+
+    /**
+     * 小题分数
+     */
+    private Double score;
+
+    /**
+     * 小题父id,用于套题
+     */
+    private String parentId;
+
+    /**
+     * 小题类型
+     * 11-单选题;12-多选题;13-填空题;14-选词填空;15-完形填空;20-判断题;42-复合题;60-问答题;69-名词解释
+     */
+    private Integer type;
+
+    /**
+     * 试题内容
+     */
+    private String json;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public Integer getdNumber() {
+        return dNumber;
+    }
+
+    public void setdNumber(Integer dNumber) {
+        this.dNumber = dNumber;
+    }
+
+    public String getdName() {
+        return dName;
+    }
+
+    public void setdName(String dName) {
+        this.dName = dName;
+    }
+
+    public Integer getNumber() {
+        return number1;
+    }
+
+    public void setNumber(Integer number1) {
+        this.number1 = number1;
+    }
+
+    public Double getScore() {
+        return score;
+    }
+
+    public void setScore(Double score) {
+        this.score = score;
+    }
+
+    public String getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(String parentId) {
+        this.parentId = parentId;
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public String getJson() {
+        return json;
+    }
+
+    public void setJson(String json) {
+        this.json = json;
+    }
+
 }

+ 180 - 180
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/vo/TestQuestionInfo.java

@@ -4,188 +4,188 @@ import java.util.List;
 
 public class TestQuestionInfo {
 
-	/**
-	 * ID
-	 */
-	private String ID;
-	
-	/**
-	 * 试题类型
-	 * 11-单选题;12-多选题;13-填空题;14-选词填空;15-完形填空;
-	 * 20-判断题;42-复合题;60-问答题;69-名词解释
-	 */
-	private int QuestionType;
-	
-	/**
-	 * 答案 (问答题)
-	 */
-	private String Answer;
-
-	/**
-	 * 创建时间
-	 */
-	private String CreateTime;
-	
-	/**
-	 * 父id(用于套题-42)
-	 */
-	private String ParentId;
-	
-	/**
-	 * QuestionInfoId
-	 */
-	private String QuestionInfoId;
-	
-	/**
-	 * 题干HTML
-	 */
-	private String QuestionHTML;
-	
-	/**
-	 * 题干文本
-	 */
-	private String QuestionTXT;
-	
-	/**
-	 * 答案提示
-	 */
-	private String AnswerTips;
-	
-	/**
-	 * 选项
-	 */
-	private List<TestOption> Options;
-	
-	/**
-	 * 答案ID对应  选择题选项的答案
-	 */
-	private String AnswerId;
-	
-	/**
-	 * 多选题答案集合
-	 */
-	private List<String> Answers;
-	
-	/**
-	 * 填空题答案
-	 */
-	private List<TestFillAnswer> Blanks;
-	
-	/**
-	 * 选词填空选项组
-	 */
-	private TestOptionGroup OptionGroup;
-
-	public String getID() {
-		return ID;
-	}
-
-	public void setID(String iD) {
-		ID = iD;
-	}
-
-	public int getQuestionType() {
-		return QuestionType;
-	}
-
-	public void setQuestionType(int questionType) {
-		QuestionType = questionType;
-	}
-
-	public String getAnswer() {
-		return Answer;
-	}
-
-	public void setAnswer(String answer) {
-		Answer = answer;
-	}
-
-	public String getCreateTime() {
-		return CreateTime;
-	}
-
-	public void setCreateTime(String createTime) {
-		CreateTime = createTime;
-	}
-
-	public String getParentId() {
-		return ParentId;
-	}
-
-	public void setParentId(String parentId) {
-		ParentId = parentId;
-	}
-
-	public String getQuestionInfoId() {
-		return QuestionInfoId;
-	}
-
-	public void setQuestionInfoId(String questionInfoId) {
-		QuestionInfoId = questionInfoId;
-	}
-
-	public String getQuestionHTML() {
-		return QuestionHTML;
-	}
-
-	public void setQuestionHTML(String questionHTML) {
-		QuestionHTML = questionHTML;
-	}
-
-	public String getQuestionTXT() {
-		return QuestionTXT;
-	}
-
-	public void setQuestionTXT(String questionTXT) {
-		QuestionTXT = questionTXT;
-	}
-
-	public String getAnswerTips() {
-		return AnswerTips;
-	}
-
-	public void setAnswerTips(String answerTips) {
-		AnswerTips = answerTips;
-	}
-
-	public List<TestOption> getOptions() {
-		return Options;
-	}
-
-	public void setOptions(List<TestOption> options) {
-		Options = options;
-	}
-
-	public String getAnswerId() {
-		return AnswerId;
-	}
-
-	public void setAnswerId(String answerId) {
-		AnswerId = answerId;
-	}
-
-	public List<String> getAnswers() {
-		return Answers;
-	}
-
-	public void setAnswers(List<String> answers) {
-		Answers = answers;
-	}
-
-	public List<TestFillAnswer> getBlanks() {
-		return Blanks;
-	}
+    /**
+     * ID
+     */
+    private String ID;
+
+    /**
+     * 试题类型
+     * 11-单选题;12-多选题;13-填空题;14-选词填空;15-完形填空;
+     * 20-判断题;42-复合题;60-问答题;69-名词解释
+     */
+    private int QuestionType;
+
+    /**
+     * 答案 (问答题)
+     */
+    private String Answer;
+
+    /**
+     * 创建时间
+     */
+    private String CreateTime;
+
+    /**
+     * 父id(用于套题-42)
+     */
+    private String ParentId;
+
+    /**
+     * QuestionInfoId
+     */
+    private String QuestionInfoId;
+
+    /**
+     * 题干HTML
+     */
+    private String QuestionHTML;
+
+    /**
+     * 题干文本
+     */
+    private String QuestionTXT;
+
+    /**
+     * 答案提示
+     */
+    private String AnswerTips;
+
+    /**
+     * 选项
+     */
+    private List<TestOption> Options;
+
+    /**
+     * 答案ID对应  选择题选项的答案
+     */
+    private String AnswerId;
+
+    /**
+     * 多选题答案集合
+     */
+    private List<String> Answers;
+
+    /**
+     * 填空题答案
+     */
+    private List<TestFillAnswer> Blanks;
+
+    /**
+     * 选词填空选项组
+     */
+    private TestOptionGroup OptionGroup;
+
+    public String getID() {
+        return ID;
+    }
+
+    public void setID(String iD) {
+        ID = iD;
+    }
+
+    public int getQuestionType() {
+        return QuestionType;
+    }
+
+    public void setQuestionType(int questionType) {
+        QuestionType = questionType;
+    }
+
+    public String getAnswer() {
+        return Answer;
+    }
+
+    public void setAnswer(String answer) {
+        Answer = answer;
+    }
+
+    public String getCreateTime() {
+        return CreateTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        CreateTime = createTime;
+    }
+
+    public String getParentId() {
+        return ParentId;
+    }
+
+    public void setParentId(String parentId) {
+        ParentId = parentId;
+    }
+
+    public String getQuestionInfoId() {
+        return QuestionInfoId;
+    }
+
+    public void setQuestionInfoId(String questionInfoId) {
+        QuestionInfoId = questionInfoId;
+    }
+
+    public String getQuestionHTML() {
+        return QuestionHTML;
+    }
+
+    public void setQuestionHTML(String questionHTML) {
+        QuestionHTML = questionHTML;
+    }
+
+    public String getQuestionTXT() {
+        return QuestionTXT;
+    }
+
+    public void setQuestionTXT(String questionTXT) {
+        QuestionTXT = questionTXT;
+    }
+
+    public String getAnswerTips() {
+        return AnswerTips;
+    }
+
+    public void setAnswerTips(String answerTips) {
+        AnswerTips = answerTips;
+    }
+
+    public List<TestOption> getOptions() {
+        return Options;
+    }
+
+    public void setOptions(List<TestOption> options) {
+        Options = options;
+    }
+
+    public String getAnswerId() {
+        return AnswerId;
+    }
+
+    public void setAnswerId(String answerId) {
+        AnswerId = answerId;
+    }
+
+    public List<String> getAnswers() {
+        return Answers;
+    }
+
+    public void setAnswers(List<String> answers) {
+        Answers = answers;
+    }
+
+    public List<TestFillAnswer> getBlanks() {
+        return Blanks;
+    }
 
-	public void setBlanks(List<TestFillAnswer> blanks) {
-		Blanks = blanks;
-	}
+    public void setBlanks(List<TestFillAnswer> blanks) {
+        Blanks = blanks;
+    }
 
-	public TestOptionGroup getOptionGroup() {
-		return OptionGroup;
-	}
+    public TestOptionGroup getOptionGroup() {
+        return OptionGroup;
+    }
 
-	public void setOptionGroup(TestOptionGroup optionGroup) {
-		OptionGroup = optionGroup;
-	}
+    public void setOptionGroup(TestOptionGroup optionGroup) {
+        OptionGroup = optionGroup;
+    }
 
 }

+ 3 - 5
examcloud-core-questions-service/src/test/java/org/examcloud/core/questions/service/AppTest.java

@@ -7,14 +7,12 @@ import org.junit.Test;
 /**
  * Unit test for simple App.
  */
-public class AppTest 
-{
+public class AppTest {
     /**
      * Rigorous Test :-)
      */
     @Test
-    public void shouldAnswerWithTrue()
-    {
-        assertTrue( true );
+    public void shouldAnswerWithTrue() {
+        assertTrue(true);
     }
 }

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.