|
@@ -1,5 +1,6 @@
|
|
|
package com.qmth.cqb.paper.service;
|
|
|
|
|
|
+import java.lang.annotation.Annotation;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
@@ -13,6 +14,7 @@ import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
import com.qmth.cqb.utils.exception.PaperException;
|
|
|
+
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.nlpcn.commons.lang.util.StringUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -21,6 +23,9 @@ 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.Order;
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
import org.springframework.data.mongodb.core.query.Query;
|
|
@@ -50,7 +55,6 @@ import com.qmth.cqb.utils.BeanCopierUtil;
|
|
|
import com.qmth.cqb.utils.CommonUtils;
|
|
|
import com.qmth.cqb.utils.enums.PaperStatus;
|
|
|
import com.qmth.cqb.utils.enums.PaperType;
|
|
|
-import com.sun.org.apache.bcel.internal.generic.NEW;
|
|
|
|
|
|
import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
|
|
|
import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
@@ -207,10 +211,17 @@ public class PaperService {
|
|
|
* @return
|
|
|
*/
|
|
|
public Page<Paper> getGenPapers(PaperSearchInfo paperSearchInfo, int curPage, int pageSize) {
|
|
|
- formatPaperSearchInfo(paperSearchInfo);
|
|
|
- Paper importPaper = BeanCopierUtil.copyProperties(paperSearchInfo, Paper.class);
|
|
|
- importPaper.setPaperType(PaperType.GENERATE);
|
|
|
- return paperRepo.findAll(Example.of(importPaper), new PageRequest(curPage - 1, pageSize));
|
|
|
+ Query query = new Query();
|
|
|
+ query.addCriteria(Criteria.where("paperType").is(PaperType.GENERATE));
|
|
|
+ if(StringUtils.isNotBlank(paperSearchInfo.getCourseNo())){
|
|
|
+ query.addCriteria(Criteria.where("courseNo").is(paperSearchInfo.getCourseNo()));
|
|
|
+ }
|
|
|
+ long count = this.mongoTemplate.count(query, Paper.class);
|
|
|
+ query.with(new Sort(new Order(Direction.DESC,"createTime")));
|
|
|
+ query.limit(pageSize);
|
|
|
+ query.skip((curPage - 1) * pageSize);
|
|
|
+ List<Paper> paperList = this.mongoTemplate.find(query, Paper.class);
|
|
|
+ return new PageImpl<Paper>(paperList, new PageRequest(curPage - 1, pageSize), count);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -813,4 +824,24 @@ public class PaperService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 根据试卷名称、试卷类型检查名称是否存在
|
|
|
+ * @param paperName
|
|
|
+ * @param paperType
|
|
|
+ * @param orgId
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public boolean checkPaperName(String paperName, PaperType paperType,String orgId)throws Exception{
|
|
|
+ Paper paperTemp = new Paper();
|
|
|
+ paperTemp.setCreateTime(null);
|
|
|
+ paperTemp.setName(paperName.trim());
|
|
|
+ paperTemp.setOrgId(orgId);
|
|
|
+ paperTemp.setPaperType(paperType);
|
|
|
+ Paper paper = paperRepo.findOne(Example.of(paperTemp));
|
|
|
+ if(paper!=null){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|