|
@@ -23,10 +23,6 @@ import org.springframework.data.mongodb.core.query.Query;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
-import com.qmth.cqb.flow.enums.PassEnum;
|
|
|
|
-import com.qmth.cqb.flow.model.DataMapModel;
|
|
|
|
-import com.qmth.cqb.flow.service.ComTaskService;
|
|
|
|
-import com.qmth.cqb.flow.service.DataMapModelService;
|
|
|
|
import com.qmth.cqb.paper.dao.ExamPaperRepo;
|
|
import com.qmth.cqb.paper.dao.ExamPaperRepo;
|
|
import com.qmth.cqb.paper.dao.PaperDetailRepo;
|
|
import com.qmth.cqb.paper.dao.PaperDetailRepo;
|
|
import com.qmth.cqb.paper.dao.PaperDetailUnitRepo;
|
|
import com.qmth.cqb.paper.dao.PaperDetailUnitRepo;
|
|
@@ -109,6 +105,7 @@ public class PaperService {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询所有待审核和审核不通过的导入试卷
|
|
* 查询所有待审核和审核不通过的导入试卷
|
|
|
|
+ *
|
|
* @param paperSearchInfo
|
|
* @param paperSearchInfo
|
|
* @param curPage
|
|
* @param curPage
|
|
* @param pageSize
|
|
* @param pageSize
|
|
@@ -116,26 +113,27 @@ public class PaperService {
|
|
*/
|
|
*/
|
|
public Page<Paper> getImportPapersNotSuccess(PaperSearchInfo paperSearchInfo, int curPage, int pageSize) {
|
|
public Page<Paper> getImportPapersNotSuccess(PaperSearchInfo paperSearchInfo, int curPage, int pageSize) {
|
|
Query query = new Query();
|
|
Query query = new Query();
|
|
- if(paperSearchInfo.getPaperStatus()!=null){
|
|
|
|
- query.addCriteria(Criteria.where("paperStatus").is(paperSearchInfo.getPaperStatus()));
|
|
|
|
- }else{
|
|
|
|
- query.addCriteria(Criteria.where("paperStatus").ne(PaperStatus.PASS));
|
|
|
|
|
|
+ if (paperSearchInfo.getPaperStatus() != null) {
|
|
|
|
+ query.addCriteria(Criteria.where("paperStatus").is(paperSearchInfo.getPaperStatus()));
|
|
|
|
+ } else {
|
|
|
|
+ query.addCriteria(Criteria.where("paperStatus").ne(PaperStatus.PASS));
|
|
}
|
|
}
|
|
query.addCriteria(Criteria.where("paperType").is(PaperType.IMPORT));
|
|
query.addCriteria(Criteria.where("paperType").is(PaperType.IMPORT));
|
|
query.addCriteria(Criteria.where("orgId").is(paperSearchInfo.getOrgId()));
|
|
query.addCriteria(Criteria.where("orgId").is(paperSearchInfo.getOrgId()));
|
|
- if(StringUtil.isNotBlank(paperSearchInfo.getCourseNo())){
|
|
|
|
- query.addCriteria(Criteria.where("courseNo").is(paperSearchInfo.getCourseNo()));
|
|
|
|
|
|
+ if (StringUtil.isNotBlank(paperSearchInfo.getCourseNo())) {
|
|
|
|
+ query.addCriteria(Criteria.where("courseNo").is(paperSearchInfo.getCourseNo()));
|
|
}
|
|
}
|
|
|
|
|
|
long totalNumber = this.mongoTemplate.count(query, Paper.class);
|
|
long totalNumber = this.mongoTemplate.count(query, Paper.class);
|
|
query.limit(pageSize);
|
|
query.limit(pageSize);
|
|
- query.skip((curPage-1)*pageSize);
|
|
|
|
|
|
+ query.skip((curPage - 1) * pageSize);
|
|
List<Paper> paperList = this.mongoTemplate.find(query, Paper.class);
|
|
List<Paper> paperList = this.mongoTemplate.find(query, Paper.class);
|
|
- return new PageImpl<Paper>(paperList,new PageRequest(curPage - 1, pageSize),totalNumber);
|
|
|
|
|
|
+ return new PageImpl<Paper>(paperList, new PageRequest(curPage - 1, pageSize), totalNumber);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 根据条件查询
|
|
* 根据条件查询
|
|
|
|
+ *
|
|
* @param paperSearchInfo
|
|
* @param paperSearchInfo
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -342,7 +340,7 @@ public class PaperService {
|
|
if (paperDetailUnits != null && paperDetailUnits.size() > 0) {
|
|
if (paperDetailUnits != null && paperDetailUnits.size() > 0) {
|
|
List<PaperDetailUnitExp> paperDetailUnitExps = BeanCopierUtil.copyPropertiesOfList(paperDetailUnits,
|
|
List<PaperDetailUnitExp> paperDetailUnitExps = BeanCopierUtil.copyPropertiesOfList(paperDetailUnits,
|
|
PaperDetailUnitExp.class);
|
|
PaperDetailUnitExp.class);
|
|
- //选择题,套题下选择题 选项顺序重新排列
|
|
|
|
|
|
+ // 选择题,套题下选择题 选项顺序重新排列
|
|
reorderChoicequestionOption(paperDetailUnitExps);
|
|
reorderChoicequestionOption(paperDetailUnitExps);
|
|
paperDetailExps.get(i).setPaperDetailUnits(paperDetailUnitExps);
|
|
paperDetailExps.get(i).setPaperDetailUnits(paperDetailUnitExps);
|
|
} else {
|
|
} else {
|
|
@@ -359,46 +357,47 @@ public class PaperService {
|
|
/**
|
|
/**
|
|
* 重新对选择题option进行排序(多选、单选、套题下选择题)
|
|
* 重新对选择题option进行排序(多选、单选、套题下选择题)
|
|
*/
|
|
*/
|
|
- public void reorderChoicequestionOption(List<PaperDetailUnitExp> paperDetailUnitExps){
|
|
|
|
- for(PaperDetailUnitExp paperDetailUnitExp:paperDetailUnitExps){
|
|
|
|
- String optionOrder = paperDetailUnitExp.getOptionOrder();
|
|
|
|
- if(StringUtil.isNotBlank(optionOrder)){
|
|
|
|
- Question question = paperDetailUnitExp.getQuestion();
|
|
|
|
- if(question.getQuestionType()==QuesStructType.SINGLE_ANSWER_QUESTION||
|
|
|
|
- question.getQuestionType()==QuesStructType.MULTIPLE_ANSWER_QUESTION){
|
|
|
|
- question.setQuesOptions(reorderOptionCore(question.getQuesOptions(),optionOrder));
|
|
|
|
- }
|
|
|
|
- if(question.getQuestionType()==QuesStructType.NESTED_ANSWER_QUESTION){
|
|
|
|
- List<Question> subQuestions = question.getSubQuestions();
|
|
|
|
- int index = 0;
|
|
|
|
- for(int k=0;k<subQuestions.size();k++){
|
|
|
|
- Question subQuestion = subQuestions.get(k);
|
|
|
|
- if(subQuestion.getQuestionType()==QuesStructType.SINGLE_ANSWER_QUESTION||
|
|
|
|
- subQuestion.getQuestionType()==QuesStructType.MULTIPLE_ANSWER_QUESTION){
|
|
|
|
- subQuestion.setQuesOptions(reorderOptionCore(subQuestion.getQuesOptions(),optionOrder.split(";")[index]));
|
|
|
|
- index++;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ public void reorderChoicequestionOption(List<PaperDetailUnitExp> paperDetailUnitExps) {
|
|
|
|
+ for (PaperDetailUnitExp paperDetailUnitExp : paperDetailUnitExps) {
|
|
|
|
+ String optionOrder = paperDetailUnitExp.getOptionOrder();
|
|
|
|
+ if (StringUtil.isNotBlank(optionOrder)) {
|
|
|
|
+ Question question = paperDetailUnitExp.getQuestion();
|
|
|
|
+ if (question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
|
|
|
|
+ || question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
|
|
|
|
+ question.setQuesOptions(reorderOptionCore(question.getQuesOptions(), optionOrder));
|
|
|
|
+ }
|
|
|
|
+ if (question.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
|
|
|
|
+ List<Question> subQuestions = question.getSubQuestions();
|
|
|
|
+ int index = 0;
|
|
|
|
+ for (int k = 0; k < subQuestions.size(); k++) {
|
|
|
|
+ Question subQuestion = subQuestions.get(k);
|
|
|
|
+ if (subQuestion.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
|
|
|
|
+ || subQuestion.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION) {
|
|
|
|
+ subQuestion.setQuesOptions(
|
|
|
|
+ reorderOptionCore(subQuestion.getQuesOptions(), optionOrder.split(";")[index]));
|
|
|
|
+ index++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public List<QuesOption> reorderOptionCore(List<QuesOption> quesOptions,String optionOrder){
|
|
|
|
- List<QuesOption> newQuesOptions = new ArrayList<QuesOption>();
|
|
|
|
- if(StringUtil.isBlank(optionOrder)||quesOptions.isEmpty()){
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- String[] optionOrderArr = optionOrder.split(",");
|
|
|
|
- for(int j = 0;j<optionOrderArr.length;j++){
|
|
|
|
- for(int k = 0;k<quesOptions.size();k++){
|
|
|
|
- if(optionOrderArr[j].equals(quesOptions.get(k).getNumber())){
|
|
|
|
- newQuesOptions.add(quesOptions.get(k));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- quesOptions = null;
|
|
|
|
- return newQuesOptions;
|
|
|
|
|
|
+ public List<QuesOption> reorderOptionCore(List<QuesOption> quesOptions, String optionOrder) {
|
|
|
|
+ List<QuesOption> newQuesOptions = new ArrayList<QuesOption>();
|
|
|
|
+ if (StringUtil.isBlank(optionOrder) || quesOptions.isEmpty()) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ String[] optionOrderArr = optionOrder.split(",");
|
|
|
|
+ for (int j = 0; j < optionOrderArr.length; j++) {
|
|
|
|
+ for (int k = 0; k < quesOptions.size(); k++) {
|
|
|
|
+ if (optionOrderArr[j].equals(quesOptions.get(k).getNumber())) {
|
|
|
|
+ newQuesOptions.add(quesOptions.get(k));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ quesOptions = null;
|
|
|
|
+ return newQuesOptions;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -414,7 +413,7 @@ public class PaperService {
|
|
int subNum = 0;
|
|
int subNum = 0;
|
|
Collections.sort(paperExp.getPaperDetails());
|
|
Collections.sort(paperExp.getPaperDetails());
|
|
List<PaperDetailExp> paperDetailExpList = paperExp.getPaperDetails();
|
|
List<PaperDetailExp> paperDetailExpList = paperExp.getPaperDetails();
|
|
- for (PaperDetailExp paperDetail:paperDetailExpList) {
|
|
|
|
|
|
+ for (PaperDetailExp paperDetail : paperDetailExpList) {
|
|
// 大题序号
|
|
// 大题序号
|
|
paperDetail.setCnNum(CommonUtils.toCHNum(paperDetail.getNumber()));
|
|
paperDetail.setCnNum(CommonUtils.toCHNum(paperDetail.getNumber()));
|
|
paperDetail.setNumber(++mainNum);
|
|
paperDetail.setNumber(++mainNum);
|
|
@@ -422,21 +421,24 @@ public class PaperService {
|
|
if (paperDetail != null && paperDetail.getPaperDetailUnits() != null
|
|
if (paperDetail != null && paperDetail.getPaperDetailUnits() != null
|
|
&& paperDetail.getPaperDetailUnits().size() > 0) {
|
|
&& paperDetail.getPaperDetailUnits().size() > 0) {
|
|
for (PaperDetailUnitExp paperDetailUnit : paperDetail.getPaperDetailUnits()) {
|
|
for (PaperDetailUnitExp paperDetailUnit : paperDetail.getPaperDetailUnits()) {
|
|
- quesService.formatQuesUnit(paperDetailUnit.getQuestion());
|
|
|
|
- List<Question> subQuesList = paperDetailUnit.getQuestion().getSubQuestions();
|
|
|
|
- // 套题序号
|
|
|
|
- if (subQuesList != null && subQuesList.size() > 0) {
|
|
|
|
- int index = subNum;
|
|
|
|
- for (Question subQues : subQuesList) {
|
|
|
|
- Map<String, String> params = new HashMap<String, String>();
|
|
|
|
- params.put("number", String.valueOf(++subNum));
|
|
|
|
- subQues.setQuesParams(params);
|
|
|
|
- quesService.formatQuesUnit(subQues);
|
|
|
|
|
|
+ if (paperDetailUnit.getQuestion() != null) {
|
|
|
|
+ quesService.formatQuesUnit(paperDetailUnit.getQuestion());
|
|
|
|
+ List<Question> subQuesList = paperDetailUnit.getQuestion().getSubQuestions();
|
|
|
|
+ // 套题序号
|
|
|
|
+ if (subQuesList != null && subQuesList.size() > 0) {
|
|
|
|
+ int index = subNum;
|
|
|
|
+ for (Question subQues : subQuesList) {
|
|
|
|
+ Map<String, String> params = new HashMap<String, String>();
|
|
|
|
+ params.put("number", String.valueOf(++subNum));
|
|
|
|
+ subQues.setQuesParams(params);
|
|
|
|
+ quesService.formatQuesUnit(subQues);
|
|
|
|
+ }
|
|
|
|
+ String quesBodyHtml = relaceRuestionIdx(paperDetailUnit.getQuestion().getQuesBody(), index);
|
|
|
|
+ paperDetailUnit.getQuestion().setQuesBody(quesBodyHtml);
|
|
|
|
+ } else {
|
|
|
|
+ paperDetailUnit.setNumber(++subNum);
|
|
}
|
|
}
|
|
- String quesBodyHtml = relaceRuestionIdx(paperDetailUnit.getQuestion().getQuesBody(), index);
|
|
|
|
- paperDetailUnit.getQuestion().setQuesBody(quesBodyHtml);
|
|
|
|
- } else {
|
|
|
|
- paperDetailUnit.setNumber(++subNum);
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -531,18 +533,18 @@ public class PaperService {
|
|
List<Paper> papers = new ArrayList<Paper>();
|
|
List<Paper> papers = new ArrayList<Paper>();
|
|
for (PaperDetailUnit pdu : pdus) {
|
|
for (PaperDetailUnit pdu : pdus) {
|
|
if (pdu.getPaper() != null) {
|
|
if (pdu.getPaper() != null) {
|
|
|
|
+ if (!papers.contains(pdu.getPaper())) {
|
|
|
|
+ papers.add(pdu.getPaper());
|
|
|
|
+ }
|
|
if (PaperType.GENERATE == pdu.getPaper().getPaperType()) {
|
|
if (PaperType.GENERATE == pdu.getPaper().getPaperType()) {
|
|
paperNames.add(pdu.getPaper().getName());
|
|
paperNames.add(pdu.getPaper().getName());
|
|
- needPdus.add(pdu);
|
|
|
|
- if (!papers.contains(pdu.getPaper())) {
|
|
|
|
- papers.add(pdu.getPaper());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
- if (paperNames.size() == 0) {// 此试题没有被组卷调用,则可以删除此试题
|
|
|
|
|
|
+ if (paperNames.size() == 0) {
|
|
|
|
+ needPdus.addAll(pdus);// 此试题没有被组卷调用,则可以删除此试题
|
|
paperDetailUnitRepo.delete(needPdus);
|
|
paperDetailUnitRepo.delete(needPdus);
|
|
quesBakRepo.save(BeanCopierUtil.copyProperties(ques, QuestionBak.class));
|
|
quesBakRepo.save(BeanCopierUtil.copyProperties(ques, QuestionBak.class));
|
|
quesRepo.delete(ques);
|
|
quesRepo.delete(ques);
|