diff --git a/source/xzs/src/main/java/com/mindskip/xzs/domain/Question.java b/source/xzs/src/main/java/com/mindskip/xzs/domain/Question.java index 30e7783..844e516 100644 --- a/source/xzs/src/main/java/com/mindskip/xzs/domain/Question.java +++ b/source/xzs/src/main/java/com/mindskip/xzs/domain/Question.java @@ -43,6 +43,8 @@ public class Question implements Serializable { private Boolean deleted; + private String content; + public Integer getId() { return id; } @@ -51,6 +53,14 @@ public class Question implements Serializable { this.id = id; } + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + public Integer getQuestionType() { return questionType; } diff --git a/source/xzs/src/main/java/com/mindskip/xzs/repository/QuestionMapper.java b/source/xzs/src/main/java/com/mindskip/xzs/repository/QuestionMapper.java index 7114072..bbf9799 100644 --- a/source/xzs/src/main/java/com/mindskip/xzs/repository/QuestionMapper.java +++ b/source/xzs/src/main/java/com/mindskip/xzs/repository/QuestionMapper.java @@ -3,7 +3,7 @@ package com.mindskip.xzs.repository; import com.mindskip.xzs.domain.Question; import com.mindskip.xzs.domain.other.KeyValue; import com.mindskip.xzs.viewmodel.admin.question.QuestionPageRequestVM; -import com.mindskip.xzs.viewmodel.student.exam.ExaminationProductionVM; +import com.mindskip.xzs.viewmodel.student.exam.EachPaperProductionVM; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -32,5 +32,5 @@ public interface QuestionMapper extends BaseMapper { List selectCountByDate(@Param("startTime") Date startTime, @Param("endTime") Date endTime); - List selectQuestionsByQuestionsNumber(ExaminationProductionVM examinationProductionVM); + List selectQuestionsByQuestionsNumber(@Param("eachList") List eachList); } diff --git a/source/xzs/src/main/java/com/mindskip/xzs/service/impl/ExaminationPaperProductionServiceImpl.java b/source/xzs/src/main/java/com/mindskip/xzs/service/impl/ExaminationPaperProductionServiceImpl.java index 1a3a295..33c3500 100644 --- a/source/xzs/src/main/java/com/mindskip/xzs/service/impl/ExaminationPaperProductionServiceImpl.java +++ b/source/xzs/src/main/java/com/mindskip/xzs/service/impl/ExaminationPaperProductionServiceImpl.java @@ -4,10 +4,13 @@ import com.mindskip.xzs.domain.Question; import com.mindskip.xzs.repository.BaseMapper; import com.mindskip.xzs.repository.QuestionMapper; import com.mindskip.xzs.service.ExaminationPaperProductionService; +import com.mindskip.xzs.viewmodel.student.exam.EachPaperProductionVM; import com.mindskip.xzs.viewmodel.student.exam.ExaminationProductionVM; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; import java.util.List; @Service @@ -26,6 +29,42 @@ public class ExaminationPaperProductionServiceImpl extends BaseServiceImpl generation(ExaminationProductionVM examinationProductionVM) { - return questionMapper.selectQuestionsByQuestionsNumber(examinationProductionVM); + Integer difficult = examinationProductionVM.getDifficult(); + Integer industryId = examinationProductionVM.getIndustryId(); + + List skillIds = examinationProductionVM.getSkillIds(); + @NotNull int questionNumber = examinationProductionVM.getQuestionNumber(); + + List integerList = new ArrayList<>(); + int size = skillIds.size(); + + + if (size < 1) { + size = 1; + } + + int remainder = questionNumber % size; + int each = questionNumber / size; + + for (int i = 0; i < size; i++) { + integerList.add(each); + } + + if (remainder > 0) { + Integer first = integerList.get(0); + int i = first + remainder; + integerList.set(0, i); + } + examinationProductionVM.setEachNumber(integerList); + List eachList = new ArrayList<>(); + if (size > 0) { + for (int i = 0; i < size; i++) { + EachPaperProductionVM eachPaperProductionVM = new EachPaperProductionVM(difficult, industryId, skillIds.get(i), integerList.get(i)); + eachList.add(eachPaperProductionVM); + } + } + + examinationProductionVM.setEachList(eachList); + return questionMapper.selectQuestionsByQuestionsNumber(examinationProductionVM.getEachList()); } } diff --git a/source/xzs/src/main/java/com/mindskip/xzs/viewmodel/student/exam/EachPaperProductionVM.java b/source/xzs/src/main/java/com/mindskip/xzs/viewmodel/student/exam/EachPaperProductionVM.java new file mode 100644 index 0000000..1f934b1 --- /dev/null +++ b/source/xzs/src/main/java/com/mindskip/xzs/viewmodel/student/exam/EachPaperProductionVM.java @@ -0,0 +1,17 @@ +package com.mindskip.xzs.viewmodel.student.exam; + +import lombok.AllArgsConstructor; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +@AllArgsConstructor +public class EachPaperProductionVM { + private Integer difficult; + private Integer industryId; + private Integer skillId; + + @NotNull + private Integer eachNumber; +} diff --git a/source/xzs/src/main/java/com/mindskip/xzs/viewmodel/student/exam/ExaminationProductionVM.java b/source/xzs/src/main/java/com/mindskip/xzs/viewmodel/student/exam/ExaminationProductionVM.java index 9ffba5b..f157b4f 100644 --- a/source/xzs/src/main/java/com/mindskip/xzs/viewmodel/student/exam/ExaminationProductionVM.java +++ b/source/xzs/src/main/java/com/mindskip/xzs/viewmodel/student/exam/ExaminationProductionVM.java @@ -12,7 +12,11 @@ public class ExaminationProductionVM extends BasePage { private int questionNumber; private Integer difficult; - private List skillIds; private Integer industryId; + private List skillIds; + private List eachNumber; + + + private List eachList; } diff --git a/source/xzs/src/main/resources/mapper/QuestionMapper.xml b/source/xzs/src/main/resources/mapper/QuestionMapper.xml index 7f69689..798113a 100644 --- a/source/xzs/src/main/resources/mapper/QuestionMapper.xml +++ b/source/xzs/src/main/resources/mapper/QuestionMapper.xml @@ -232,30 +232,26 @@