Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
307523b3be
@ -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;
|
||||
}
|
||||
|
@ -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<Question> {
|
||||
|
||||
List<KeyValue> selectCountByDate(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
|
||||
List<Question> selectQuestionsByQuestionsNumber(ExaminationProductionVM examinationProductionVM);
|
||||
List<Question> selectQuestionsByQuestionsNumber(@Param("eachList") List<EachPaperProductionVM> eachList);
|
||||
}
|
||||
|
@ -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<Quest
|
||||
@Override
|
||||
public List<Question> generation(ExaminationProductionVM examinationProductionVM) {
|
||||
|
||||
return questionMapper.selectQuestionsByQuestionsNumber(examinationProductionVM);
|
||||
Integer difficult = examinationProductionVM.getDifficult();
|
||||
Integer industryId = examinationProductionVM.getIndustryId();
|
||||
|
||||
List<Integer> skillIds = examinationProductionVM.getSkillIds();
|
||||
@NotNull int questionNumber = examinationProductionVM.getQuestionNumber();
|
||||
|
||||
List<Integer> 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<EachPaperProductionVM> 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());
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
@ -12,7 +12,11 @@ public class ExaminationProductionVM extends BasePage {
|
||||
private int questionNumber;
|
||||
|
||||
private Integer difficult;
|
||||
private List<Integer> skillIds;
|
||||
private Integer industryId;
|
||||
|
||||
private List<Integer> skillIds;
|
||||
private List<Integer> eachNumber;
|
||||
|
||||
|
||||
private List<EachPaperProductionVM> eachList;
|
||||
}
|
||||
|
@ -232,30 +232,26 @@
|
||||
</select>
|
||||
|
||||
<select id="selectQuestionsByQuestionsNumber"
|
||||
parameterType="com.mindskip.xzs.viewmodel.student.exam.ExaminationProductionVM"
|
||||
resultMap="BaseResultMap"
|
||||
>
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from t_question
|
||||
<where>
|
||||
deleted=0
|
||||
<if test="difficult != null">
|
||||
and difficult = #{difficult}
|
||||
</if>
|
||||
<if test="industryId != null">
|
||||
and industry_id= #{industryId}
|
||||
</if>
|
||||
<if test="skillIds != null">
|
||||
and skill_id in
|
||||
<foreach collection="skillIds" item="skillId" open="(" separator=","
|
||||
close=")">
|
||||
#{skillId}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
|
||||
limit #{questionNumber}
|
||||
resultMap="BaseResultMap">
|
||||
<foreach collection="eachList" item="each" separator="union">
|
||||
(select q.skill_id, q.industry_id, i.name as industry_name, s.name as skill_name
|
||||
, t.content ,q.difficult ,q.question_type from t_industry i
|
||||
join t_question q on i.id = q.industry_id
|
||||
join t_skill s on s.id = q.skill_id
|
||||
join t_text_content t on t.id = q.info_text_content_id
|
||||
<where>
|
||||
<if test="each.difficult != null">
|
||||
and q.difficult = #{each.difficult}
|
||||
</if>
|
||||
<if test="each.industryId != null">
|
||||
and i.id = #{each.industryId}
|
||||
</if>
|
||||
<if test="each.skillId != null">
|
||||
and s.id = #{each.skillId}
|
||||
</if>
|
||||
</where>
|
||||
limit #{each.eachNumber} )
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user