gaoxing 8 anni fa
parent
commit
c4a0a1e0fa

+ 4 - 4
cqb-gen-paper/src/main/java/com/qmth/cqb/genpaper/web/GenPaperController.java

@@ -30,6 +30,7 @@ public class GenPaperController {
     @PostMapping("/genPaper/simple")
     public ResponseEntity genPaperSimple(@RequestBody GenPaperDto genPaperDto) {
         Map<String, Object> paperMap = new HashMap<String, Object>();
+        String paperName = genPaperDto.getPaperName();
         if (genPaperDto.getGenNumber() == 1) {
             if (genPaperDto.getSimpleGenPaperPolicy().getKey() == 1L) {
                 paperMap = genPaperService.genPaperByQuestionNum(genPaperDto);
@@ -39,9 +40,8 @@ public class GenPaperController {
         } else if (genPaperDto.getGenNumber() > 1) {
             if (genPaperDto.getSimpleGenPaperPolicy().getKey() == 1L) {
                 for (int i = 1; i <= genPaperDto.getGenNumber(); i++) {
-                    genPaperDto.setPaperName(genPaperDto.getPaperName() + "_" + i);
+                    genPaperDto.setPaperName(paperName + "_" + i);
                     paperMap.putAll(genPaperService.genPaperByQuestionNum(genPaperDto));
-                    genPaperDto.setPaperName("");
                 }
 
             } else if (genPaperDto.getSimpleGenPaperPolicy().getKey() == 2L) {
@@ -66,11 +66,11 @@ public class GenPaperController {
     @PostMapping("/genPaper/normal")
     public ResponseEntity genPaperNormal(@RequestBody GenPaperDto genPaperDto) {
         Map<String, Object> paperMap = new HashMap<String, Object>();
+        String paperName = genPaperDto.getPaperName();
         if (genPaperDto.getGenNumber() > 1) {
             for (int i = 1; i <= genPaperDto.getGenNumber(); i++) {
-                genPaperDto.setPaperName(genPaperDto.getPaperName() + "_" + i);
+                genPaperDto.setPaperName(paperName + "_" + i);
                 paperMap.putAll(genPaperService.genPaper(genPaperDto));
-                genPaperDto.setPaperName("");
             }
         } else if (genPaperDto.getGenNumber() == 1) {
             paperMap = genPaperService.genPaper(genPaperDto);

+ 91 - 118
cqb-paper/src/main/java/com/qmth/cqb/paper/dto/PaperDetailUnitExp.java

@@ -1,118 +1,91 @@
-package com.qmth.cqb.paper.dto;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.lang3.StringUtils;
-
-import com.qmth.cqb.question.model.Question;
-
-import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
-
-/**
- * 试卷小题导出dto Created by songyue on 17/3/15.
- */
-public class PaperDetailUnitExp implements Serializable {
-
-    private static final long serialVersionUID = 6507445685386413261L;
-
-    private String id;
-
-    private Integer number;// 小题序号
-
-    private Double score;// 小题分数
-
-    private QuesStructType questionType;// 小题类型
-
-    private Question question;// 关联试题
-
-    private String quesId;// 关联试题Id
-
-    private String subScores;// 对应套题的情况下,各子题的分数分布
-
-    private List<Double> subScoreList;
-
-    public static long getSerialVersionUID() {
-        return serialVersionUID;
-    }
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public Integer getNumber() {
-        return number;
-    }
-
-    public void setNumber(Integer number) {
-        this.number = number;
-    }
-
-    public Double getScore() {
-        return score;
-    }
-
-    public void setScore(Double score) {
-        this.score = score;
-    }
-
-    public QuesStructType getQuestionType() {
-        return questionType;
-    }
-
-    public void setQuestionType(QuesStructType questionType) {
-        this.questionType = questionType;
-    }
-
-    public Question getQuestion() {
-        return question;
-    }
-
-    public void setQuestion(Question question) {
-        this.question = question;
-    }
-
-    public String getQuesId() {
-        return quesId;
-    }
-
-    public void setQuesId(String quesId) {
-        this.quesId = quesId;
-    }
-
-    public String getSubScores() {
-        return subScores;
-    }
-
-    public void setSubScores(String subScores) {
-        this.subScores = subScores;
-    }
-
-    public void setSubScoreList(List<Double> subScoreList) {
-        if (getSubScoreList() != null && getSubScoreList().size() > 0) {
-            this.subScoreList = getSubScoreList();
-        } else {
-            this.subScoreList = null;
-        }
-
-    }
-
-    public List<Double> getSubScoreList() {
-        List<Double> list = new ArrayList<>();
-        String[] values = StringUtils.split(StringUtils.trimToEmpty(this.subScores), ",");
-        for (String value : values) {
-            try {
-                list.add(Double.valueOf(value));
-            } catch (Exception e) {
-
-            }
-        }
-        return list;
-    }
-
-}
+package com.qmth.cqb.paper.dto;
+
+import java.io.Serializable;
+import java.util.List;
+
+import com.qmth.cqb.question.model.Question;
+
+import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
+
+/**
+ * 试卷小题导出dto Created by songyue on 17/3/15.
+ */
+public class PaperDetailUnitExp implements Serializable {
+
+    private static final long serialVersionUID = 6507445685386413261L;
+
+    private String id;
+
+    private Integer number;// 小题序号
+
+    private Double score;// 小题分数
+
+    private QuesStructType questionType;// 小题类型
+
+    private Question question;// 关联试题
+
+    private String quesId;// 关联试题Id
+
+    private List<Double> subScoreList;// 对应套题的情况下,各子题的分数分布
+
+    public static long getSerialVersionUID() {
+        return serialVersionUID;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public Integer getNumber() {
+        return number;
+    }
+
+    public void setNumber(Integer number) {
+        this.number = number;
+    }
+
+    public Double getScore() {
+        return score;
+    }
+
+    public void setScore(Double score) {
+        this.score = score;
+    }
+
+    public QuesStructType getQuestionType() {
+        return questionType;
+    }
+
+    public void setQuestionType(QuesStructType questionType) {
+        this.questionType = questionType;
+    }
+
+    public Question getQuestion() {
+        return question;
+    }
+
+    public void setQuestion(Question question) {
+        this.question = question;
+    }
+
+    public String getQuesId() {
+        return quesId;
+    }
+
+    public void setQuesId(String quesId) {
+        this.quesId = quesId;
+    }
+
+    public List<Double> getSubScoreList() {
+        return subScoreList;
+    }
+
+    public void setSubScoreList(List<Double> subScoreList) {
+        this.subScoreList = subScoreList;
+    }
+
+}

+ 13 - 11
cqb-paper/src/main/java/com/qmth/cqb/paper/service/PaperDetailUnitService.java

@@ -1,6 +1,11 @@
 package com.qmth.cqb.paper.service;
 
-import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
 import com.qmth.cqb.paper.dao.PaperDetailUnitRepo;
 import com.qmth.cqb.paper.dto.PaperDetailUnitExp;
 import com.qmth.cqb.paper.model.Paper;
@@ -8,11 +13,8 @@ import com.qmth.cqb.paper.model.PaperDetail;
 import com.qmth.cqb.paper.model.PaperDetailUnit;
 import com.qmth.cqb.question.model.Question;
 import com.qmth.cqb.question.service.QuesService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.List;
+import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
 
 @Service
 public class PaperDetailUnitService {
@@ -56,28 +58,28 @@ public class PaperDetailUnitService {
         PaperDetailUnit oldPdu = paperDetailUnitRepo.findOne(pduExp.getId());
         if (oldPdu.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
             if (pduExp.getQuestion().getId().equals(oldPdu.getQuestion().getId())) {
-                //更新对象为套题本身
+                // 更新对象为套题本身
                 oldPdu.setQuestion(quesService.saveQues(pduExp.getQuestion()));
             } else {
                 List<Double> subScoreList = oldPdu.getSubScoreList();
                 int size = oldPdu.getQuestion().getSubQuestions().size();
                 boolean match = false;
-                //判断更新的对象是哪个子题
+                // 判断更新的对象是哪个子题
                 for (int index = 1; index <= size; index++) {
-                    //检查子题分数,确保没有错误数据
+                    // 检查子题分数,确保没有错误数据
                     if (subScoreList.size() < index) {
                         subScoreList.add(0d);
                     }
                     Question sub = oldPdu.getQuestion().getSubQuestions().get(index - 1);
                     if (pduExp.getQuestion().getId().equals(sub.getId())) {
-                        //匹配到子题
+                        // 匹配到子题
                         subScoreList.set(index - 1, pduExp.getScore());
                         oldPdu.getQuestion().getSubQuestions().set(index - 1, pduExp.getQuestion());
                         match = true;
                     }
                 }
-                //更新套题unit当前总分
-                oldPdu.updateSubScore(subScoreList);
+                // 更新套题unit当前总分
+                oldPdu.setSubScoreList(subScoreList);
                 if (match) {
                     oldPdu.setQuestion(quesService.saveQues(oldPdu.getQuestion()));
                 }