|
@@ -1,88 +1,102 @@
|
|
|
-package com.qmth.cqb.paper.service.impl;
|
|
|
-
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.data.domain.Example;
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
-import org.springframework.data.domain.PageRequest;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
-import cn.com.qmth.examcloud.common.dto.em.enums.ExamType;
|
|
|
-import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
|
-
|
|
|
-import com.qmth.cqb.paper.dao.ExportStructureRepo;
|
|
|
-import com.qmth.cqb.paper.model.ExportStructure;
|
|
|
-import com.qmth.cqb.paper.model.QuestionTypeNum;
|
|
|
-import com.qmth.cqb.paper.service.ExportStructureService;
|
|
|
-import com.qmth.cqb.utils.enums.ExportType;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author chenken
|
|
|
- * @date 2017年7月12日 下午4:26:49
|
|
|
- * @company QMTH
|
|
|
- * @description 导出试卷结构设置
|
|
|
- */
|
|
|
-@Service("exportStructureService")
|
|
|
-public class ExportStructureServiceImpl implements ExportStructureService {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExportStructureRepo exportStructureRepo;
|
|
|
-
|
|
|
- @Override
|
|
|
- public void saveExportStructure(ExportStructure exportStructure,AccessUser user) {
|
|
|
- if(StringUtils.isBlank(exportStructure.getId())){
|
|
|
- exportStructure.setCreateUser(user.getName());
|
|
|
- exportStructure.setCreateTime(new Date());
|
|
|
- }else{
|
|
|
- exportStructure.setUpdateUser(user.getName());
|
|
|
- exportStructure.setUpdateTime(new Date());
|
|
|
- }
|
|
|
- exportStructureRepo.save(exportStructure);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ExportStructure findByExportStructure(ExportStructure exportStructure) {
|
|
|
- List<ExportStructure> exportStructures = exportStructureRepo.findAll(Example.of(exportStructure));
|
|
|
- if(exportStructures.size()>0){
|
|
|
- return exportStructures.get(0);
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Page<ExportStructure> findPageByExportStructure(ExportStructure exportStructure, int curPage, int pageSize) {
|
|
|
- Page<ExportStructure> list = exportStructureRepo.findAll(Example.of(exportStructure), new PageRequest(curPage - 1, pageSize));
|
|
|
- return list;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Map<String, Object> findStructureByExamIdAndExamType(String examId,ExamType examType) {
|
|
|
- Map<String, Object> returnMap = new HashMap<String, Object>();
|
|
|
- ExportStructure exportStructure = findByExportStructure(new ExportStructure(examId,examType));
|
|
|
- if(exportStructure==null){
|
|
|
- returnMap.put("returnMsg", "no_structure");
|
|
|
- return returnMap;
|
|
|
- }
|
|
|
- if(exportStructure.getExportType()==ExportType.NORMAL){
|
|
|
- List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
|
|
|
- for(QuestionTypeNum questionTypeNum:questionTypeNums){
|
|
|
- if(questionTypeNum.getQuantity()==null){
|
|
|
- //结构设置不完整
|
|
|
- returnMap.put("returnMsg", "structure_imperfect");
|
|
|
- return returnMap;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- returnMap.put("exportStructure",exportStructure);
|
|
|
- return returnMap;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
+package com.qmth.cqb.paper.service.impl;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Example;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.common.dto.em.enums.ExamType;
|
|
|
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
|
+
|
|
|
+import com.qmth.cqb.paper.dao.ExportStructureRepo;
|
|
|
+import com.qmth.cqb.paper.model.ExportStructure;
|
|
|
+import com.qmth.cqb.paper.model.QuestionTypeNum;
|
|
|
+import com.qmth.cqb.paper.service.ExportStructureService;
|
|
|
+import com.qmth.cqb.utils.enums.ExportType;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author chenken
|
|
|
+ * @date 2017年7月12日 下午4:26:49
|
|
|
+ * @company QMTH
|
|
|
+ * @description 导出试卷结构设置
|
|
|
+ */
|
|
|
+@Service("exportStructureService")
|
|
|
+public class ExportStructureServiceImpl implements ExportStructureService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExportStructureRepo exportStructureRepo;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void saveExportStructure(ExportStructure exportStructure,AccessUser user) {
|
|
|
+ if(StringUtils.isBlank(exportStructure.getId())){
|
|
|
+ exportStructure.setCreateUser(user.getName());
|
|
|
+ exportStructure.setCreateTime(new Date());
|
|
|
+ }else{
|
|
|
+ exportStructure.setUpdateUser(user.getName());
|
|
|
+ exportStructure.setUpdateTime(new Date());
|
|
|
+ }
|
|
|
+ exportStructureRepo.save(exportStructure);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ExportStructure findByExportStructure(ExportStructure exportStructure) {
|
|
|
+ List<ExportStructure> exportStructures = exportStructureRepo.findAll(Example.of(exportStructure));
|
|
|
+ if(exportStructures.size()>0){
|
|
|
+ return exportStructures.get(0);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<ExportStructure> findPageByExportStructure(ExportStructure exportStructure, int curPage, int pageSize) {
|
|
|
+ Page<ExportStructure> list = exportStructureRepo.findAll(Example.of(exportStructure), new PageRequest(curPage - 1, pageSize));
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> findStructureByExamIdAndExamType(String examId,ExamType examType) {
|
|
|
+ Map<String, Object> returnMap = new HashMap<String, Object>();
|
|
|
+ ExportStructure exportStructure = findByExportStructure(new ExportStructure(examId,examType));
|
|
|
+ if(exportStructure==null){
|
|
|
+ returnMap.put("returnMsg", "no_structure");
|
|
|
+ return returnMap;
|
|
|
+ }
|
|
|
+ if(exportStructure.getExportType()==ExportType.NORMAL){
|
|
|
+ List<QuestionTypeNum> questionTypeNums = exportStructure.getQuestionTypeNums();
|
|
|
+ for(QuestionTypeNum questionTypeNum:questionTypeNums){
|
|
|
+ if(questionTypeNum.getQuantity()==null){
|
|
|
+ //结构设置不完整
|
|
|
+ returnMap.put("returnMsg", "structure_imperfect");
|
|
|
+ return returnMap;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ returnMap.put("exportStructure",exportStructure);
|
|
|
+ return returnMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<String> findExportStructureByExamType(String examType) {
|
|
|
+ List<ExportStructure> exportStructures = exportStructureRepo.findAll(Example.of(new ExportStructure(ExamType.strToEnum(examType))));
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|