Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	cqb-gen-paper/src/main/java/com/qmth/cqb/genpaper/web/GenPaperController.java
#	cqb-starter/src/main/resources/application.properties
宋悦 8 gadi atpakaļ
vecāks
revīzija
2e58d7dfc4

+ 42 - 0
cqb-comm-utils/src/main/java/com/qmth/cqb/utils/enums/GenPaperExpression.java

@@ -0,0 +1,42 @@
+package com.qmth.cqb.utils.enums;
+
+public enum GenPaperExpression {
+	EQUAL(1L,"等于"),
+	NOT_EQUAL(2L,"不等于"),
+	LESS(3L,"小于"),
+	LESS_EQUAL(4L,"小于等于"),
+	GREATER(5L,"大于"),
+	GREATER_EQUAL(6L,"大于等于");
+	
+    private Long key;
+    private String name;
+    
+    
+    private GenPaperExpression(Long key, String name) {
+		this.key = key;
+		this.name = name;
+	}
+    
+    private  GenPaperExpression(){
+    	
+    }
+    
+	public Long getKey() {
+		return key;
+	}
+
+
+	public void setKey(Long key) {
+		this.key = key;
+	}
+
+
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+    
+    
+}

+ 29 - 0
cqb-comm-utils/src/main/java/com/qmth/cqb/utils/enums/GenPaperFunction.java

@@ -0,0 +1,29 @@
+package com.qmth.cqb.utils.enums;
+
+public enum GenPaperFunction {
+	SUM(1L,"求和"),
+	RATIO(2L,"比例");
+	
+	private Long key;
+    private String name;
+    
+    
+	private GenPaperFunction(Long key, String name) {
+		this.key = key;
+		this.name = name;
+	}
+	public Long getKey() {
+		return key;
+	}
+	public void setKey(Long key) {
+		this.key = key;
+	}
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+
+    
+}

+ 35 - 0
cqb-comm-utils/src/main/java/com/qmth/cqb/utils/enums/RandomGenPaperPolicy.java

@@ -0,0 +1,35 @@
+package com.qmth.cqb.utils.enums;
+
+public enum RandomGenPaperPolicy {
+	BY_QUESTIONNUM(1L,"按每套试卷需要抽取的试题数量来组卷"),
+	BY_SCORE(2L,"按每套试卷需要抽取的分数来组卷");
+	
+	private Long key;
+	private String value;
+	
+	
+	private RandomGenPaperPolicy(Long key, String value) {
+		this.key = key;
+		this.value = value;
+	}
+	
+	private RandomGenPaperPolicy(){
+		
+	}
+
+	public Long getKey() {
+		return key;
+	}
+
+	public void setKey(Long key) {
+		this.key = key;
+	}
+
+	public String getValue() {
+		return value;
+	}
+	public void setValue(String value) {
+		this.value = value;
+	}
+	
+}

+ 27 - 10
cqb-gen-paper/src/main/java/com/qmth/cqb/genpaper/model/GenPaperDto.java

@@ -3,30 +3,34 @@ package com.qmth.cqb.genpaper.model;
 import java.io.Serializable;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.locks.Condition;
+
+import com.qmth.cqb.genpaper.condition.Condition;
+import com.qmth.cqb.utils.enums.RandomGenPaperPolicy;
 
 /**
  * Created by songyue on 17/3/24.
  */
-public class GenPaperDto implements Serializable{
+public class GenPaperDto implements Serializable {
 
     private static final long serialVersionUID = -7738591929656796661L;
 
-    private String courseNo;//课程代码
+    private String courseNo;// 课程代码
+
+    private String courseName;// 课程名称
 
-    private String courseName;//课程名称
+    private String paperName;// 试卷名称
 
-    private String paperName;//试卷名称
+    private List<String> paperIds;// 试卷ID集合
 
-    private List<String> paperIds;//试卷ID集合
+    private Map<String, Double> simpleParams;// 简单组卷规则
 
-    private Map<String,Double> simpleParams;//简单组卷规则
+    private List<Condition> conditions;// 精细组卷规则
 
-    private List<Condition> conditions;//精细组卷规则
+    private String creator;// 创建人
 
-    private String creator;//创建人
+    private String paperStructId;// 试卷模板Id
 
-    private String paperStructId;//试卷模板Id
+    private RandomGenPaperPolicy simpleGenPaperPolicy;
 
     public static long getSerialVersionUID() {
         return serialVersionUID;
@@ -95,4 +99,17 @@ public class GenPaperDto implements Serializable{
     public void setPaperStructId(String paperStructId) {
         this.paperStructId = paperStructId;
     }
+
+    public RandomGenPaperPolicy getSimpleGenPaperPolicy() {
+        return simpleGenPaperPolicy;
+    }
+
+    public void setSimpleGenPaperPolicy(RandomGenPaperPolicy simpleGenPaperPolicy) {
+        this.simpleGenPaperPolicy = simpleGenPaperPolicy;
+    }
+
+    public static long getSerialversionuid() {
+        return serialVersionUID;
+    }
+
 }

+ 161 - 115
cqb-gen-paper/src/main/java/com/qmth/cqb/genpaper/service/GenPaperService.java

@@ -2,6 +2,7 @@ package com.qmth.cqb.genpaper.service;
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -10,10 +11,10 @@ import java.util.Set;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import com.qmth.cqb.genpaper.condition.Condition;
 import com.qmth.cqb.genpaper.context.DetailContext;
 import com.qmth.cqb.genpaper.context.PaperContext;
 import com.qmth.cqb.genpaper.context.UnitContext;
+import com.qmth.cqb.genpaper.model.GenPaperDto;
 import com.qmth.cqb.paper.dao.PaperDetailRepo;
 import com.qmth.cqb.paper.dao.PaperDetailUnitRepo;
 import com.qmth.cqb.paper.dao.PaperRepo;
@@ -42,13 +43,103 @@ public class GenPaperService {
     PaperStructRepo paperStructRepo;
 
     /**
-     * 按分数在选定的试卷中随机抽取题,组成一套新的试
+     * 精确组卷,根据设定试卷结构组
      * 
-     * @param paperMap
-     *            key:指定的试卷Id,value:需要抽取的分数
-     * @return 试卷
+     * @param paperIds
+     *            取题范围
+     * @param paperStruct
+     *            设定的试卷结构
+     * @param conditions
+     *            筛选条件
+     * @return
      */
-    public Paper genPaperByScore(Map<String, Double> paperMap, String paperName) {
+    public Map<String, Object> genPaper(GenPaperDto genPaperDto) {
+        String msg = "";
+        Map<String, Object> paperMsgMap = new HashMap<String, Object>();
+        LinkedList<Question> questions = new LinkedList<Question>();// 所有试题集合
+        PaperStruct paperStruct = paperStructRepo.findOne(genPaperDto.getPaperStructId());
+        PaperContext paperContext = new PaperContext(paperStruct, genPaperDto.getConditions());
+        List<UnitContext> unitContexts = new LinkedList<UnitContext>();
+        List<DetailContext> detailContexts = paperContext.getDetails();
+        for (DetailContext dc : detailContexts) {
+            unitContexts.addAll(dc.getUnits());
+        }
+        List<Paper> papers = (List<Paper>) paperRepo.findAll(genPaperDto.getPaperIds());
+        for (Paper oldPaper : papers) {
+            List<PaperDetailUnit> unitList = unitRepo.findByPaper(oldPaper);
+            for (PaperDetailUnit unit : unitList) {
+                questions.add(unit.getQuestion());
+            }
+
+        }
+        Collections.shuffle(questions);
+        int maxLoopCount = questions.size() * 2;
+        int selectCount = 0;
+        int maxCount = unitContexts.size();
+        int loopCount = 0;
+        while (questions.size() > 0 && (selectCount < maxCount) && loopCount < maxLoopCount) {
+            Question question = questions.removeFirst();
+            boolean structTypeMatch = false;
+            boolean selected = false;
+            for (UnitContext uc : unitContexts) {
+                if (uc.getUnitStruct().getQuestionType() == question.getQuestionType() && !uc.finish()) {
+                    structTypeMatch = true;
+                    if (uc.check(question)) {
+                        uc.select(question);
+                        selected = true;
+                        selectCount++;
+                        break;
+                    }
+                }
+            }
+            if (structTypeMatch && !selected) {
+                questions.addLast(question);
+            }
+            loopCount++;
+        }
+        Set<Question> quesSet = paperContext.getSelectQues();
+        if (quesSet.size() < unitContexts.size()) {
+            msg = "匹配的题源不足,请核查";
+            return paperMsgMap;
+        }
+        List<PaperDetail> paperDetails = new ArrayList<PaperDetail>();
+        List<PaperDetailUnit> paperDetailunits = new ArrayList<PaperDetailUnit>();
+        for (DetailContext dc : detailContexts) {
+            List<PaperDetailUnit> unitsTemp = new ArrayList<PaperDetailUnit>();
+            List<UnitContext> units = dc.getUnits();
+            for (UnitContext uc : units) {
+                for (Question ques : quesSet) {
+                    if (uc.getUnitStruct().getQuestionType() == ques.getQuestionType()) {
+                        PaperDetailUnit pdu = new PaperDetailUnit();
+                        pdu.setCreateTime(CommonUtils.getCurDateTime());
+                        pdu.setQuestion(ques);
+                        pdu.setQuestionType(ques.getQuestionType());
+                        pdu.setScore(uc.getUnitStruct().getScore());
+                        unitsTemp.add(pdu);
+                    }
+
+                }
+
+            }
+            paperDetails.add(this.constuctPaperDeatil(unitsTemp, dc.getDetailStruct().getNumber(),
+                    dc.getDetailStruct().getName()));
+            paperDetailunits.addAll(unitsTemp);
+        }
+        Paper paper = this.constuctPaperByPaperDetails(paperDetails, genPaperDto);
+        this.persistentPaper(paperDetails, paperDetailunits, paper);
+        msg = "success";
+        paperMsgMap.put("paper", paper);
+        paperMsgMap.put("msg", msg);
+        return paperMsgMap;
+    }
+
+    /**
+     * 按分数在选定的试卷中随机抽取题,组成一套新的试卷
+     */
+    public Map<String, Object> genPaperByScore(GenPaperDto genPaperDto) {
+        String msg = "";
+        Map<String, Object> paperMsgMap = new HashMap<String, Object>();
+        Map<String, Double> paperMap = genPaperDto.getSimpleParams();
         List<PaperDetailUnit> selectedUnits = new ArrayList<PaperDetailUnit>();// 选中的小题
         if (paperMap != null && paperMap.size() > 0) {
             for (String paperId : paperMap.keySet()) {
@@ -68,24 +159,27 @@ public class GenPaperService {
             }
         }
 
-        return this.constuctPaper(selectedUnits, paperName);
+        Paper paper = this.constuctPaper(selectedUnits, genPaperDto);
+        msg = "success";
+        paperMsgMap.put("paper", paper);
+        paperMsgMap.put("msg", msg);
+        return paperMsgMap;
 
     }
 
     /**
      * 按每套试卷需要抽取的题目数量随机抽取题,组成一套新的试卷
      * 
-     * @param paperMap
-     *            key:指定的试卷Id,value:需要抽取试题数量
-     * @param paperName
-     *            试卷名称
      * @return
      */
-    public Paper genPaperByQuestionNum(Map<String, Integer> paperMap, String paperName) {
+    public Map<String, Object> genPaperByQuestionNum(GenPaperDto genPaperDto) {
+        String msg = "";
+        Map<String, Object> paperMsgMap = new HashMap<String, Object>();
+        Map<String, Double> paperMap = genPaperDto.getSimpleParams();
         List<PaperDetailUnit> selectedUnits = new ArrayList<PaperDetailUnit>();// 选中的小题
         if (paperMap != null && paperMap.size() > 0) {
             for (String paperId : paperMap.keySet()) {
-                int unitNum = paperMap.get(paperId);
+                int unitNum = paperMap.get(paperId).intValue();
                 Paper oldPaper = paperRepo.findOne(paperId);
                 List<PaperDetailUnit> unitList = unitRepo.findByPaper(oldPaper);
                 Collections.shuffle(unitList);// 随机乱序之后再取题
@@ -94,6 +188,10 @@ public class GenPaperService {
                         selectedUnits.add(unitList.get(i));
                         unitList.remove(i);
                     }
+                } else {
+                    msg = "题源不足:需要抽取的题目数量要多于试卷中题目数量,请检查";
+                    paperMsgMap.put("msg", msg);
+                    return paperMsgMap;
                 }
                 for (PaperDetailUnit pdu : selectedUnits) {
                     if (pdu.getQuestionType().getId() == 6L && pdu.getQuestion().getSubQuestions().size() > 1) {// 假如是套题,要计算下面小题数量
@@ -106,10 +204,14 @@ public class GenPaperService {
                         }
                     }
                 }
+
             }
         }
-
-        return this.constuctPaper(selectedUnits, paperName);
+        Paper paper = this.constuctPaper(selectedUnits, genPaperDto);
+        msg = "success";
+        paperMsgMap.put("paper", paper);
+        paperMsgMap.put("msg", msg);
+        return paperMsgMap;
 
     }
 
@@ -149,7 +251,7 @@ public class GenPaperService {
      * @param details
      * @return
      */
-    public Paper constuctPaperByPaperDetails(List<PaperDetail> details, String paperName) {
+    public Paper constuctPaperByPaperDetails(List<PaperDetail> details, GenPaperDto genPaperDto) {
         Paper paper = new Paper();
         if (details != null && details.size() > 0) {
             Double score = 0d;
@@ -157,10 +259,13 @@ public class GenPaperService {
                 score += pd.getScore();
 
             }
-            paper.setName(paperName);
+            paper.setName(genPaperDto.getPaperName());
+            paper.setCourseNo(genPaperDto.getCourseNo());
+            paper.setCourseName(genPaperDto.getCourseName());
+            paper.setCreator(genPaperDto.getCreator());
+            paper.setCreateTime(CommonUtils.getCurDateTime());
             paper.setPaperDetailCount(details.size());
             paper.setTotalScore(score);
-            paper.setCreateTime(CommonUtils.getCurDateTime());
             for (PaperDetail pdu : details) {
                 pdu.setPaper(paper);
             }
@@ -177,7 +282,7 @@ public class GenPaperService {
      * @param quesName
      * @return
      */
-    public Paper constuctPaper(List<PaperDetailUnit> selectedUnits, String paperName) {
+    public Paper constuctPaper(List<PaperDetailUnit> selectedUnits, GenPaperDto genPaperDto) {
         Paper paper = new Paper();
         List<PaperDetailUnit> singUnits = new ArrayList<PaperDetailUnit>();
         List<PaperDetailUnit> multipleUnits = new ArrayList<PaperDetailUnit>();
@@ -208,50 +313,72 @@ public class GenPaperService {
 
             }
         }
-        PaperDetail singPd = this.constuctPaperDeatil(singUnits, 1, QuesStructType.SINGLE_ANSWER_QUESTION.getName());
-        PaperDetail multipePd = this.constuctPaperDeatil(multipleUnits, 2,
-                QuesStructType.MULTIPLE_ANSWER_QUESTION.getName());
-        PaperDetail boolPd = this.constuctPaperDeatil(boolUnits, 3, QuesStructType.BOOL_ANSWER_QUESTION.getName());
-        PaperDetail blankPd = this.constuctPaperDeatil(blankUnits, 4, QuesStructType.FILL_BLANK_QUESTION.getName());
-        PaperDetail textPd = this.constuctPaperDeatil(textUnits, 5, QuesStructType.TEXT_ANSWER_QUESTION.getName());
-        PaperDetail nestPd = this.constuctPaperDeatil(nestUnits, 6, QuesStructType.NESTED_ANSWER_QUESTION.getName());
+        int detailNumber = 1;
+        PaperDetail singPd = null;
+        PaperDetail multipePd = null;
+        PaperDetail boolPd = null;
+        PaperDetail blankPd = null;
+        PaperDetail textPd = null;
+        PaperDetail nestPd = null;
+        if (singUnits != null && singUnits.size() > 0) {
+            singPd = this.constuctPaperDeatil(singUnits, detailNumber, QuesStructType.SINGLE_ANSWER_QUESTION.getName());
+            detailNumber++;
+        } else if (multipleUnits != null && multipleUnits.size() > 0) {
+            multipePd = this.constuctPaperDeatil(multipleUnits, detailNumber,
+                    QuesStructType.MULTIPLE_ANSWER_QUESTION.getName());
+            detailNumber++;
+        } else if (boolUnits != null && boolUnits.size() > 0) {
+            boolPd = this.constuctPaperDeatil(boolUnits, detailNumber, QuesStructType.BOOL_ANSWER_QUESTION.getName());
+            detailNumber++;
+        } else if (blankUnits != null && blankUnits.size() > 0) {
+            blankPd = this.constuctPaperDeatil(blankUnits, detailNumber, QuesStructType.FILL_BLANK_QUESTION.getName());
+            detailNumber++;
+        } else if (textUnits != null && textUnits.size() > 0) {
+            textPd = this.constuctPaperDeatil(textUnits, detailNumber, QuesStructType.TEXT_ANSWER_QUESTION.getName());
+            detailNumber++;
+        } else if (nestUnits != null && nestUnits.size() > 0) {
+            nestPd = this.constuctPaperDeatil(nestUnits, detailNumber, QuesStructType.NESTED_ANSWER_QUESTION.getName());
+        }
         selectedUnits.clear();
         List<PaperDetail> pds = new ArrayList<PaperDetail>();
         int paperDetailCount = 0;// 大题数量
         Double totalScore = 0d;
-        if (singPd.getUnitCount() > 0) {
+        if (singPd != null && singPd.getUnitCount() > 0) {
             paperDetailCount = paperDetailCount + 1;
             totalScore += singPd.getScore();
             pds.add(singPd);
             selectedUnits.addAll(singUnits);
-        } else if (multipePd.getUnitCount() > 0) {
+        } else if (multipePd != null && multipePd.getUnitCount() > 0) {
             paperDetailCount = paperDetailCount + 1;
             totalScore += singPd.getScore();
             pds.add(multipePd);
             selectedUnits.addAll(multipleUnits);
-        } else if (boolPd.getUnitCount() > 0) {
+        } else if (boolPd != null && boolPd.getUnitCount() > 0) {
             paperDetailCount = paperDetailCount + 1;
             totalScore += singPd.getScore();
             pds.add(boolPd);
             selectedUnits.addAll(boolUnits);
-        } else if (blankPd.getUnitCount() > 0) {
+        } else if (blankPd != null && blankPd.getUnitCount() > 0) {
             paperDetailCount = paperDetailCount + 1;
             totalScore += singPd.getScore();
             pds.add(blankPd);
             selectedUnits.addAll(blankUnits);
-        } else if (textPd.getUnitCount() > 0) {
+        } else if (textPd != null && textPd.getUnitCount() > 0) {
             paperDetailCount = paperDetailCount + 1;
             totalScore += singPd.getScore();
             pds.add(textPd);
             selectedUnits.addAll(textUnits);
-        } else if (nestPd.getUnitCount() > 0) {
+        } else if (nestPd != null && nestPd.getUnitCount() > 0) {
             paperDetailCount = nestPd.getUnitCount() + paperDetailCount;
             totalScore += singPd.getScore();
             pds.add(nestPd);
             selectedUnits.addAll(nestUnits);
         }
-
-        paper.setName(paperName);
+        paper.setName(genPaperDto.getPaperName());
+        paper.setCourseName(genPaperDto.getCourseName());
+        paper.setCourseNo(genPaperDto.getCourseNo());
+        paper.setCreator(genPaperDto.getCreator());
+        paper.setCreateTime(CommonUtils.getCurDateTime());
         paper.setTotalScore(totalScore);
         paper.setPaperDetailCount(paperDetailCount);
         // 数据入库
@@ -282,85 +409,4 @@ public class GenPaperService {
 
     }
 
-    /**
-     * 精确组卷,根据设定试卷结构组卷
-     * 
-     * @param paperIds
-     *            取题范围
-     * @param paperStruct
-     *            设定的试卷结构
-     * @param conditions
-     *            筛选条件
-     * @return
-     */
-    public Paper genPaper(List<String> paperIds, PaperStruct paperStruct, List<Condition> conditions) {
-        LinkedList<Question> questions = new LinkedList<Question>();// 所有试题集合
-        PaperContext paperContext = new PaperContext(paperStruct, conditions);
-        List<UnitContext> unitContexts = new LinkedList<UnitContext>();
-        List<DetailContext> detailContexts = paperContext.getDetails();
-        for (DetailContext dc : detailContexts) {
-            unitContexts.addAll(dc.getUnits());
-        }
-        List<Paper> papers = (List<Paper>) paperRepo.findAll(paperIds);
-        for (Paper oldPaper : papers) {
-            List<PaperDetailUnit> unitList = unitRepo.findByPaper(oldPaper);
-            for (PaperDetailUnit unit : unitList) {
-                questions.add(unit.getQuestion());
-            }
-
-        }
-        Collections.shuffle(questions);
-        int maxLoopCount = questions.size() * 2;
-        int selectCount = 0;
-        int maxCount = unitContexts.size();
-        int loopCount = 0;
-        while (questions.size() > 0 && (selectCount < maxCount) && loopCount < maxLoopCount) {
-            Question question = questions.removeFirst();
-            boolean structTypeMatch = false;
-            boolean selected = false;
-            for (UnitContext uc : unitContexts) {
-                if (uc.getUnitStruct().getQuestionType() == question.getQuestionType() && !uc.finish()) {
-                    structTypeMatch = true;
-                    if (uc.check(question)) {
-                        uc.select(question);
-                        selected = true;
-                        selectCount++;
-                        break;
-                    }
-                }
-            }
-            if (structTypeMatch && !selected) {
-                questions.addLast(question);
-            }
-            loopCount++;
-        }
-
-        Set<Question> quesSet = paperContext.getSelectQues();
-        List<PaperDetail> paperDetails = new ArrayList<PaperDetail>();
-        List<PaperDetailUnit> paperDetailunits = new ArrayList<PaperDetailUnit>();
-        for (DetailContext dc : detailContexts) {
-            List<PaperDetailUnit> unitsTemp = new ArrayList<PaperDetailUnit>();
-            List<UnitContext> units = dc.getUnits();
-            for (UnitContext uc : units) {
-                for (Question ques : quesSet) {
-                    if (uc.getUnitStruct().getQuestionType() == ques.getQuestionType()) {
-                        PaperDetailUnit pdu = new PaperDetailUnit();
-                        pdu.setCreateTime(CommonUtils.getCurDateTime());
-                        pdu.setQuestion(ques);
-                        pdu.setQuestionType(ques.getQuestionType());
-                        pdu.setScore(uc.getUnitStruct().getScore());
-                        unitsTemp.add(pdu);
-                    }
-
-                }
-
-            }
-            paperDetails.add(this.constuctPaperDeatil(unitsTemp, dc.getDetailStruct().getNumber(),
-                    dc.getDetailStruct().getName()));
-            paperDetailunits.addAll(unitsTemp);
-        }
-        Paper paper = this.constuctPaperByPaperDetails(paperDetails, paperStruct.getName());
-        this.persistentPaper(paperDetails, paperDetailunits, paper);
-        return paper;
-    }
 }

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

@@ -1,18 +1,21 @@
 package com.qmth.cqb.genpaper.web;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import com.qmth.cqb.genpaper.model.GenPaperDto;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Controller;
-
-import com.qmth.cqb.genpaper.service.GenPaperService;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.qmth.cqb.genpaper.model.GenPaperDto;
+import com.qmth.cqb.genpaper.service.GenPaperService;
+
 /**
  * Created by songyue on 16/12/28.
  */
@@ -25,15 +28,30 @@ public class GenPaperController {
 
     @ApiOperation(value="简易随机组卷",notes="简易随机组卷")
     @PostMapping("/genPaper/simple")
-    public ResponseEntity genPaperSimple(@RequestBody GenPaperDto genPaperDto){
-        return new ResponseEntity("", HttpStatus.OK);
+    public ResponseEntity genPaperSimple(@RequestBody GenPaperDto genPaperDto) {
+        Map<String, Object> paperMap = new HashMap<String, Object>();
+        if (genPaperDto.getSimpleGenPaperPolicy().getKey() == 1L) {
+            paperMap = genPaperService.genPaperByQuestionNum(genPaperDto);
+        } else if (genPaperDto.getSimpleGenPaperPolicy().getKey() == 2L) {
+            paperMap = genPaperService.genPaperByScore(genPaperDto);
+        }
+        if (paperMap.get("msg").equals("success")) {
+            return new ResponseEntity(paperMap.get("paper"), HttpStatus.OK);
+        } else {
+            return new ResponseEntity(paperMap.get("msg"), HttpStatus.INTERNAL_SERVER_ERROR);
+        }
+
     }
 
     @ApiOperation(value="精细组卷",notes="精细组卷")
     @PostMapping("/genPaper/normal")
-    public ResponseEntity genPaperNormal(@RequestBody GenPaperDto genPaperDto){
-        return new ResponseEntity("", HttpStatus.OK);
+    public ResponseEntity genPaperNormal(@RequestBody GenPaperDto genPaperDto) {
+        Map<String, Object> paperMap = genPaperService.genPaper(genPaperDto);
+        if (paperMap.get("msg").equals("success")) {
+            return new ResponseEntity(paperMap.get("paper"), HttpStatus.OK);
+        } else {
+            return new ResponseEntity(paperMap.get("msg"), HttpStatus.INTERNAL_SERVER_ERROR);
+        }
     }
 
-
 }