|
@@ -40,26 +40,35 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.Assert;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.common.dto.print.CoursePaperDto;
|
|
|
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.mysql.fabric.xmlrpc.base.Array;
|
|
|
import com.qmth.cqb.paper.dao.ExamPaperRepo;
|
|
|
+import com.qmth.cqb.paper.dao.ExportServiceManageRepo;
|
|
|
import com.qmth.cqb.paper.dao.PaperDetailRepo;
|
|
|
import com.qmth.cqb.paper.dao.PaperDetailUnitRepo;
|
|
|
import com.qmth.cqb.paper.dao.PaperRepo;
|
|
|
+import com.qmth.cqb.paper.dto.ObjectiveQuestionStructure;
|
|
|
import com.qmth.cqb.paper.dto.PaperDetailExp;
|
|
|
import com.qmth.cqb.paper.dto.PaperDetailUnitExp;
|
|
|
import com.qmth.cqb.paper.dto.PaperExp;
|
|
|
+import com.qmth.cqb.paper.dto.QuestionAllTypeDto;
|
|
|
+import com.qmth.cqb.paper.dto.SubjectiveQuestionStructure;
|
|
|
import com.qmth.cqb.paper.model.ExamPaper;
|
|
|
+import com.qmth.cqb.paper.model.ExportServiceManage;
|
|
|
import com.qmth.cqb.paper.model.Paper;
|
|
|
import com.qmth.cqb.paper.model.PaperDetail;
|
|
|
import com.qmth.cqb.paper.model.PaperDetailUnit;
|
|
|
import com.qmth.cqb.paper.model.PaperSearchInfo;
|
|
|
+import com.qmth.cqb.paper.rpc.PrintCoursePaperClient;
|
|
|
import com.qmth.cqb.paper.service.ExtractConfigService;
|
|
|
import com.qmth.cqb.paper.service.PaperDetailService;
|
|
|
import com.qmth.cqb.paper.service.PaperDetailUnitService;
|
|
|
import com.qmth.cqb.paper.service.PaperService;
|
|
|
+import com.qmth.cqb.paper.service.export.ExportPaperAbstractService;
|
|
|
import com.qmth.cqb.question.dao.QuesBakRepo;
|
|
|
import com.qmth.cqb.question.dao.QuesRepo;
|
|
|
import com.qmth.cqb.question.dao.QuestionAudioRepo;
|
|
@@ -71,6 +80,7 @@ import com.qmth.cqb.question.service.QuesService;
|
|
|
import com.qmth.cqb.question.service.impl.QuestionAudioServiceImpl;
|
|
|
import com.qmth.cqb.utils.BeanCopierUtil;
|
|
|
import com.qmth.cqb.utils.CommonUtils;
|
|
|
+import com.qmth.cqb.utils.SpringContextUtils;
|
|
|
import com.qmth.cqb.utils.enums.PaperStatus;
|
|
|
import com.qmth.cqb.utils.enums.PaperType;
|
|
|
import com.qmth.cqb.utils.exception.PaperException;
|
|
@@ -128,6 +138,12 @@ public class PaperServiceImpl implements PaperService{
|
|
|
|
|
|
@Autowired
|
|
|
private RedisTemplate redisTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExportServiceManageRepo exportServiceManageRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PrintCoursePaperClient printCoursePaperClient;
|
|
|
|
|
|
@Value("${upyun.radioType}")
|
|
|
private String radioType;
|
|
@@ -668,8 +684,12 @@ public class PaperServiceImpl implements PaperService{
|
|
|
for(int i =0;i<paperDetailUnit.getQuestion().getSubQuestions().size();i++){
|
|
|
Question subQuestion = paperDetailUnit.getQuestion().getSubQuestions().get(i);
|
|
|
//设置公开度
|
|
|
- if(subQuestion.getPublicity()){
|
|
|
+ if(subQuestion.getPublicity()==null){
|
|
|
publicity = true;
|
|
|
+ }else{
|
|
|
+ if(subQuestion.getPublicity()){
|
|
|
+ publicity = true;
|
|
|
+ }
|
|
|
}
|
|
|
if(subQuestion.getDifficultyDegree() == null){
|
|
|
subQuestion.setDifficultyDegree(0.5);
|
|
@@ -1286,6 +1306,126 @@ public class PaperServiceImpl implements PaperService{
|
|
|
map.put("htmlList", htmlList);
|
|
|
return map;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PaperExp findByNameAndOrgId(String paperName, String orgId, AccessUser accessUser) throws Exception {
|
|
|
+ //查询paper对象
|
|
|
+ Paper paper = paperRepo.findByNameAndOrgIdAndPaperType(paperName, orgId, PaperType.PREVIEW);
|
|
|
+ ExportServiceManage esm = exportServiceManageRepo.findByOrgName(accessUser.getRootOrgName());
|
|
|
+ if(esm == null){
|
|
|
+ esm = exportServiceManageRepo.findByOrgName("陕西师范大学");
|
|
|
+ }
|
|
|
+ ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils.getBeanById(esm.getExportServiceName());
|
|
|
+ PaperExp paperExp = exportPaperAbstractService.initPaperExp(paper.getId());
|
|
|
+ return paperExp;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String sendPrint(String paperId, String paperHtmlUrl, String examId, AccessUser user) {
|
|
|
+ //查询原paper对象
|
|
|
+ Paper paper = paperRepo.findOne(paperId);
|
|
|
+ CoursePaperDto coursePaperDto = new CoursePaperDto();
|
|
|
+ coursePaperDto.setOrgId(user.getOrgId());
|
|
|
+ coursePaperDto.setPaperId(paper.getId());
|
|
|
+ coursePaperDto.setPaperName(paper.getName());
|
|
|
+ coursePaperDto.setExamId(Long.parseLong(examId));
|
|
|
+ coursePaperDto.setPaperHtmlUrl(paperHtmlUrl);
|
|
|
+ coursePaperDto.setCourseCode(paper.getCourse().getCode());
|
|
|
+ coursePaperDto.setCourseName(paper.getCourse().getName());
|
|
|
+ //远程调用印刷平台接口,把对象传值过去
|
|
|
+ String message = printCoursePaperClient.saveCoursePaper(user.getToken(), coursePaperDto);
|
|
|
+ return message;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, QuestionAllTypeDto> findQuestionStructure(String paperId,AccessUser user) throws Exception {
|
|
|
+ //根据paperId查询新的对象
|
|
|
+ ExportServiceManage esm = exportServiceManageRepo.findByOrgName(user.getRootOrgName());
|
|
|
+ if(esm == null){
|
|
|
+ esm = exportServiceManageRepo.findByOrgName("陕西师范大学");
|
|
|
+ }
|
|
|
+ ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils.getBeanById(esm.getExportServiceName());
|
|
|
+ PaperExp paperExp = exportPaperAbstractService.initPaperExp(paperId);
|
|
|
+ //得到试卷中的客观大题
|
|
|
+ List<PaperDetailExp> objectiveDetails = exportPaperAbstractService.getAllObjectiveDetails(paperExp);
|
|
|
+ //客观题中如果有套题,要拆开
|
|
|
+ List<PaperDetailExp> newObjectiveDetails = buildPaperDetailExp(objectiveDetails);
|
|
|
+ //生成客观题数集合
|
|
|
+ List<ObjectiveQuestionStructure> objectiveQuestionStructureList = new ArrayList<ObjectiveQuestionStructure>();
|
|
|
+ for(PaperDetailExp paperDetailExp:newObjectiveDetails){
|
|
|
+ for(PaperDetailUnitExp unit:paperDetailExp.getPaperDetailUnits()){
|
|
|
+ objectiveQuestionStructureList.add(new ObjectiveQuestionStructure(paperExp,paperDetailExp,unit,null));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //得到试卷中的主观大题
|
|
|
+ List<PaperDetailExp> subjectiveDetails = exportPaperAbstractService.getAllSubjectiveDetails(paperExp);
|
|
|
+ //生成主观题数集合
|
|
|
+ List<SubjectiveQuestionStructure> subjectiveQuestionStructureList = new ArrayList<SubjectiveQuestionStructure>();
|
|
|
+ for(PaperDetailExp paperDetailExp:subjectiveDetails){
|
|
|
+ for(PaperDetailUnitExp unit:paperDetailExp.getPaperDetailUnits()){
|
|
|
+ subjectiveQuestionStructureList.add(new SubjectiveQuestionStructure(paperExp,paperDetailExp,unit,null));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //生成map集合返回给硬刷平台
|
|
|
+ Map<String, QuestionAllTypeDto> map = new HashMap<String, QuestionAllTypeDto>();
|
|
|
+ QuestionAllTypeDto questionAllTypeDto = new QuestionAllTypeDto(objectiveQuestionStructureList, subjectiveQuestionStructureList);
|
|
|
+ map.put("questionAllTypeDto", questionAllTypeDto);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<PaperDetailExp> buildPaperDetailExp(List<PaperDetailExp> objectiveDetails) {
|
|
|
+ //1.得到所有客观题大题的类型
|
|
|
+ Set<QuesStructType> types = new HashSet<QuesStructType>();
|
|
|
+ for(PaperDetailExp paperDetailExp:objectiveDetails){
|
|
|
+ types.add(QuesStructType.getQuesStructTypeById(paperDetailExp.getSortNumber()));
|
|
|
+ }
|
|
|
+ //2.生成新的大题集合
|
|
|
+ List<PaperDetailExp> newObjs = new ArrayList<PaperDetailExp>();
|
|
|
+ for(QuesStructType type:types){
|
|
|
+ for(PaperDetailExp paperDetailExp:objectiveDetails){
|
|
|
+ if(paperDetailExp.getSortNumber() == type.getId()){
|
|
|
+ //生成新的大题
|
|
|
+ PaperDetailExp newPaperDetailExp = new PaperDetailExp();
|
|
|
+ //生成新的小题
|
|
|
+ List<PaperDetailUnitExp> newPaperDetailUnits = new ArrayList<PaperDetailUnitExp>();
|
|
|
+ //得到旧大题下的所有小题
|
|
|
+ List<PaperDetailUnitExp> paperDetailUnits = paperDetailExp.getPaperDetailUnits();
|
|
|
+ for(PaperDetailUnitExp paperDetailUnitExp:paperDetailUnits){
|
|
|
+ if(paperDetailUnitExp.getQuestionType() != QuesStructType.NESTED_ANSWER_QUESTION){
|
|
|
+ newPaperDetailUnits.add(paperDetailUnitExp);
|
|
|
+ }else{
|
|
|
+ List<Question> subQuestions = paperDetailUnitExp.getQuestion().getSubQuestions();
|
|
|
+ if(subQuestions!=null&&subQuestions.size()>0){
|
|
|
+ for(int i = 0;i<subQuestions.size();i++){
|
|
|
+ newPaperDetailUnits.add(new PaperDetailUnitExp(type,subQuestions.get(i)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //设置小题
|
|
|
+ newPaperDetailExp.setPaperDetailUnits(newPaperDetailUnits);
|
|
|
+ //设置大题题号
|
|
|
+ newPaperDetailExp.setNumber(Integer.parseInt(type.getId()+""));
|
|
|
+ newPaperDetailExp.setSortNumber(paperDetailExp.getSortNumber());
|
|
|
+ newObjs.add(newPaperDetailExp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //刷一遍number
|
|
|
+ int num = 0;
|
|
|
+ for(QuesStructType type:types){
|
|
|
+ for(int i = 0;i<newObjs.size();i++){
|
|
|
+ if(newObjs.get(i).getSortNumber() == type.getId()){
|
|
|
+ List<PaperDetailUnitExp> exps = newObjs.get(i).getPaperDetailUnits();
|
|
|
+ for(int j = 0;j<exps.size();j++){
|
|
|
+ num++;
|
|
|
+ exps.get(j).setNumber(num);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return newObjs;
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|