|
@@ -17,8 +17,6 @@ import java.util.Set;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
-import com.qmth.cqb.utils.exception.PaperException;
|
|
|
|
-
|
|
|
|
import main.java.com.UpYun;
|
|
import main.java.com.UpYun;
|
|
|
|
|
|
import org.apache.commons.io.FileUtils;
|
|
import org.apache.commons.io.FileUtils;
|
|
@@ -26,7 +24,12 @@ import org.apache.commons.lang3.StringUtils;
|
|
import org.nlpcn.commons.lang.util.StringUtil;
|
|
import org.nlpcn.commons.lang.util.StringUtil;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
-import org.springframework.data.domain.*;
|
|
|
|
|
|
+import org.springframework.data.domain.Example;
|
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
|
+import org.springframework.data.domain.PageImpl;
|
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
|
+import org.springframework.data.domain.Sort;
|
|
import org.springframework.data.domain.Sort.Direction;
|
|
import org.springframework.data.domain.Sort.Direction;
|
|
import org.springframework.data.domain.Sort.Order;
|
|
import org.springframework.data.domain.Sort.Order;
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
@@ -36,6 +39,9 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.util.Assert;
|
|
import org.springframework.util.Assert;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
|
|
|
|
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
|
|
+
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
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;
|
|
@@ -62,9 +68,7 @@ import com.qmth.cqb.utils.BeanCopierUtil;
|
|
import com.qmth.cqb.utils.CommonUtils;
|
|
import com.qmth.cqb.utils.CommonUtils;
|
|
import com.qmth.cqb.utils.enums.PaperStatus;
|
|
import com.qmth.cqb.utils.enums.PaperStatus;
|
|
import com.qmth.cqb.utils.enums.PaperType;
|
|
import com.qmth.cqb.utils.enums.PaperType;
|
|
-
|
|
|
|
-import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
|
|
|
|
-import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
|
|
|
|
+import com.qmth.cqb.utils.exception.PaperException;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Created by songyue on 16/12/28.
|
|
* Created by songyue on 16/12/28.
|
|
@@ -447,14 +451,6 @@ public class PaperService {
|
|
*/
|
|
*/
|
|
public PaperExp getPaperDto(String id) {
|
|
public PaperExp getPaperDto(String id) {
|
|
Paper paper = paperRepo.findOne(id);
|
|
Paper paper = paperRepo.findOne(id);
|
|
- /*
|
|
|
|
- List<PaperDetailUnit> paperDetailUnitsByPaper = paperDetailUnitRepo.findByPaperOrderByNumber(paper);
|
|
|
|
- for(int i = 0;i<paperDetailUnitsByPaper.size();i++){
|
|
|
|
- PaperDetailUnit unit = paperDetailUnitsByPaper.get(i);
|
|
|
|
- unit.setNumber(i+1);
|
|
|
|
- }
|
|
|
|
- paperDetailUnitRepo.save(paperDetailUnitsByPaper);
|
|
|
|
- */
|
|
|
|
// 创建paperDto
|
|
// 创建paperDto
|
|
PaperExp paperExp = BeanCopierUtil.copyProperties(paper,PaperExp.class);
|
|
PaperExp paperExp = BeanCopierUtil.copyProperties(paper,PaperExp.class);
|
|
paperExp.setCourse(paper.getCourse());
|
|
paperExp.setCourse(paper.getCourse());
|
|
@@ -540,12 +536,15 @@ public class PaperService {
|
|
// 大题序号
|
|
// 大题序号
|
|
paperDetail.setNumber(++mainNum);
|
|
paperDetail.setNumber(++mainNum);
|
|
paperDetail.setCnNum(CommonUtils.toCHNum(paperDetail.getNumber()));
|
|
paperDetail.setCnNum(CommonUtils.toCHNum(paperDetail.getNumber()));
|
|
- if (paperDetail != null && paperDetail.getPaperDetailUnits() != null
|
|
|
|
- && paperDetail.getPaperDetailUnits().size() > 0) {
|
|
|
|
|
|
+ if (paperDetail != null && paperDetail.getPaperDetailUnits() != null&& paperDetail.getPaperDetailUnits().size() > 0) {
|
|
for (PaperDetailUnitExp paperDetailUnit : paperDetail.getPaperDetailUnits()) {
|
|
for (PaperDetailUnitExp paperDetailUnit : paperDetail.getPaperDetailUnits()) {
|
|
- if (paperDetailUnit.getQuestion() != null) {
|
|
|
|
- quesService.formatQuesUnit(paperDetailUnit.getQuestion());
|
|
|
|
- List<Question> subQuesList = paperDetailUnit.getQuestion().getSubQuestions();
|
|
|
|
|
|
+ Question question = paperDetailUnit.getQuestion();
|
|
|
|
+ if (question != null) {
|
|
|
|
+ if(question.getHasAudio()!=null&&question.getHasAudio()){
|
|
|
|
+ paperExp.setHasAudio(true); //设置试卷含有音频
|
|
|
|
+ }
|
|
|
|
+ quesService.formatQuesUnit(question);
|
|
|
|
+ List<Question> subQuesList = question.getSubQuestions();
|
|
// 套题序号
|
|
// 套题序号
|
|
if (subQuesList != null && subQuesList.size() > 0) {
|
|
if (subQuesList != null && subQuesList.size() > 0) {
|
|
int index = 0;
|
|
int index = 0;
|
|
@@ -555,8 +554,8 @@ public class PaperService {
|
|
subQues.setQuesParams(params);
|
|
subQues.setQuesParams(params);
|
|
quesService.formatQuesUnit(subQues);
|
|
quesService.formatQuesUnit(subQues);
|
|
}
|
|
}
|
|
- String quesBodyHtml = relaceQuestionIdx(paperDetailUnit.getQuestion().getQuesBody(), index);
|
|
|
|
- paperDetailUnit.getQuestion().setQuesBody(quesBodyHtml);
|
|
|
|
|
|
+ String quesBodyHtml = relaceQuestionIdx(question.getQuesBody(), index);
|
|
|
|
+ question.setQuesBody(quesBodyHtml);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1003,17 +1002,6 @@ public class PaperService {
|
|
}
|
|
}
|
|
uploadAudioFile(paperId,question.getId(),file,accessUser);
|
|
uploadAudioFile(paperId,question.getId(),file,accessUser);
|
|
appendAudioTag(file.getOriginalFilename(),question.getId());
|
|
appendAudioTag(file.getOriginalFilename(),question.getId());
|
|
- //将所有关联了此试题的试卷(类型为IMPORT或者GENERATE)都设置为hasAudio=true
|
|
|
|
- List<PaperType> paperTypes = new ArrayList<PaperType>();
|
|
|
|
- paperTypes.add(PaperType.GENERATE);
|
|
|
|
- paperTypes.add(PaperType.IMPORT);
|
|
|
|
- List<PaperDetailUnit> paperDetailUnitsByQuestion = paperDetailUnitService.findByQuestionAndPaperTypes(question,paperTypes);
|
|
|
|
- for(PaperDetailUnit unit:paperDetailUnitsByQuestion){
|
|
|
|
- Paper paper2 = unit.getPaper();
|
|
|
|
- paper2.setHasAudio(true);
|
|
|
|
- paper2.setLastModifyName(accessUser.getName());
|
|
|
|
- paperRepo.save(paper2);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
//删除服务器文件夹
|
|
//删除服务器文件夹
|
|
String mp3DirectoryPath = TEMP_FILE_EXP + File.separator + paperId;
|
|
String mp3DirectoryPath = TEMP_FILE_EXP + File.separator + paperId;
|
|
@@ -1100,4 +1088,7 @@ public class PaperService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void checkPaperAudio(String paperId){
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|