|
@@ -13,8 +13,10 @@ import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
|
|
|
import cn.com.qmth.examcloud.core.questions.base.excel.ExportUtils;
|
|
|
import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
|
|
|
import cn.com.qmth.examcloud.core.questions.dao.ExportServiceManageRepo;
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.PaperDetailUnitRepo;
|
|
|
import cn.com.qmth.examcloud.core.questions.dao.PaperRepo;
|
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.Paper;
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailUnit;
|
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.PaperSearchInfo;
|
|
|
import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.PaperService;
|
|
@@ -37,6 +39,8 @@ import cn.com.qmth.examcloud.web.support.Naked;
|
|
|
import com.google.gson.Gson;
|
|
|
import freemarker.template.TemplateException;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Example;
|
|
@@ -54,6 +58,7 @@ import javax.validation.constraints.NotNull;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.io.StringWriter;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
@@ -91,6 +96,8 @@ public class PaperController extends ControllerSupport {
|
|
|
@Autowired
|
|
|
OrgCloudService orgCloudService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ PaperDetailUnitRepo paperDetailUnitRepo;
|
|
|
|
|
|
* 根据Id获取试卷
|
|
|
*
|
|
@@ -227,16 +234,17 @@ public class PaperController extends ControllerSupport {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@ApiOperation(value = "查询所有导入试卷(not in paperIds)", notes = "查询所有导入试卷(not in paperIds)")
|
|
|
- @GetMapping(value = "/genPaper/{ids}/{curPage}/{pageSize}")
|
|
|
+ @GetMapping(value = "/genPaper/huoge/{curPage}/{pageSize}")
|
|
|
public ResponseEntity<Object> getGenPapersNotInIds(@ModelAttribute PaperSearchInfo paperSearchInfo,
|
|
|
- @PathVariable String[] ids, @PathVariable int curPage, @PathVariable int pageSize) {
|
|
|
- User user = getAccessUser();
|
|
|
+ @RequestParam String ids, @PathVariable int curPage, @PathVariable int pageSize) {
|
|
|
+ User user = getAccessUser();
|
|
|
paperSearchInfo.setOrgId(user.getRootOrgId().toString());
|
|
|
- Page<Paper> ret;
|
|
|
- if (ids != null && ids.length > 0) {
|
|
|
- ret = paperService.getPapersNotInIds(paperSearchInfo, ids, curPage, pageSize, PaperType.GENERATE);
|
|
|
+ Page<Paper> ret=null;
|
|
|
+ if (StringUtils.isNotBlank(ids)) {
|
|
|
+ String[] idArr=ids.split(",");
|
|
|
+ ret = paperService.getPapersNotInIds(paperSearchInfo, idArr, curPage, pageSize, PaperType.GENERATE);
|
|
|
if (ret.getContent().size() == 0 && ret.getTotalElements() > 0 && curPage > 1) {
|
|
|
- ret = paperService.getPapersNotInIds(paperSearchInfo, ids, curPage - 1, pageSize, PaperType.GENERATE);
|
|
|
+ ret = paperService.getPapersNotInIds(paperSearchInfo, idArr, curPage - 1, pageSize, PaperType.GENERATE);
|
|
|
}
|
|
|
} else {
|
|
|
ret = paperService.getGenPapers(paperSearchInfo, curPage, pageSize);
|
|
@@ -244,6 +252,9 @@ public class PaperController extends ControllerSupport {
|
|
|
ret = paperService.getGenPapers(paperSearchInfo, curPage - 1, pageSize);
|
|
|
}
|
|
|
}
|
|
|
+ if(ret!=null&&CollectionUtils.isNotEmpty(ret.getContent())) {
|
|
|
+ setPaperQuesCountAndScore(ret.getContent());
|
|
|
+ }
|
|
|
return new ResponseEntity<>(ret, HttpStatus.OK);
|
|
|
}
|
|
|
|
|
@@ -574,16 +585,17 @@ public class PaperController extends ControllerSupport {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@ApiOperation(value = "查询所有导入试卷(not in paperIds)", notes = "查询所有导入试卷(not in paperIds)")
|
|
|
- @GetMapping(value = "/importPaper/{ids}/{curPage}/{pageSize}")
|
|
|
- public ResponseEntity<Object> getImportPapersNotInIds(@ModelAttribute PaperSearchInfo paperSearchInfo, @PathVariable String[] ids, @PathVariable int curPage,
|
|
|
+ @GetMapping(value = "/importPaper/huoge/{curPage}/{pageSize}")
|
|
|
+ public ResponseEntity<Object> getImportPapersNotInIds(@ModelAttribute PaperSearchInfo paperSearchInfo, @RequestParam String ids, @PathVariable int curPage,
|
|
|
@PathVariable int pageSize) {
|
|
|
- User user = getAccessUser();
|
|
|
+ User user = getAccessUser();
|
|
|
paperSearchInfo.setOrgId(user.getRootOrgId().toString());
|
|
|
- Page<Paper> ret;
|
|
|
- if (ids != null && ids.length > 0) {
|
|
|
- ret = paperService.getPapersNotInIds(paperSearchInfo, ids, curPage, pageSize, PaperType.IMPORT);
|
|
|
+ Page<Paper> ret=null;
|
|
|
+ if (StringUtils.isNotBlank(ids)) {
|
|
|
+ String[] idArr=ids.split(",");
|
|
|
+ ret = paperService.getPapersNotInIds(paperSearchInfo, idArr, curPage, pageSize, PaperType.IMPORT);
|
|
|
if (ret.getContent().size() == 0 && ret.getTotalElements() > 0 && curPage > 1) {
|
|
|
- ret = paperService.getPapersNotInIds(paperSearchInfo, ids, curPage - 1, pageSize, PaperType.IMPORT);
|
|
|
+ ret = paperService.getPapersNotInIds(paperSearchInfo, idArr, curPage - 1, pageSize, PaperType.IMPORT);
|
|
|
}
|
|
|
} else {
|
|
|
ret = paperService.getImportPapers(paperSearchInfo, curPage, pageSize);
|
|
@@ -591,8 +603,71 @@ public class PaperController extends ControllerSupport {
|
|
|
ret = paperService.getImportPapers(paperSearchInfo, curPage - 1, pageSize);
|
|
|
}
|
|
|
}
|
|
|
+ if(ret!=null&&CollectionUtils.isNotEmpty(ret.getContent())) {
|
|
|
+ setPaperQuesCountAndScore(ret.getContent());
|
|
|
+ }
|
|
|
return new ResponseEntity<>(ret, HttpStatus.OK);
|
|
|
}
|
|
|
+
|
|
|
+ private void setPaperQuesCountAndScore(List<Paper> paperList) {
|
|
|
+ if (paperList == null || paperList.size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (Paper paper : paperList) {
|
|
|
+ initQuesCountAndScore(paper);
|
|
|
+ Map<String, Integer> quesCount = paper.getQuesCount();
|
|
|
+ Map<String, Double> quesScore = paper.getQuesScore();
|
|
|
+ List<PaperDetailUnit> units = paperDetailUnitRepo.findByPaperOrderByNumber(paper);
|
|
|
+ if (units != null && units.size() > 0) {
|
|
|
+ for (PaperDetailUnit unit : units) {
|
|
|
+ if (unit.getQuestion().getPublicity() == null) {
|
|
|
+ unit.getQuestion().setPublicity(true);
|
|
|
+ }
|
|
|
+ if (unit.getQuestion().getDifficulty() == null) {
|
|
|
+ unit.getQuestion().setDifficulty("中");
|
|
|
+ }
|
|
|
+ String key = getKey(unit.getQuestion().getPublicity(), unit.getQuestion().getDifficulty());
|
|
|
+ quesCount.put(key, quesCount.get(key) + 1);
|
|
|
+ quesScore.put(key, BigDecimal.valueOf(quesScore.get(key)).add(BigDecimal.valueOf(unit.getScore())).doubleValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getKey(Boolean publicity, String difficultyType) {
|
|
|
+ String difficulty = null;
|
|
|
+ if ("易".equals(difficultyType)) {
|
|
|
+ difficulty = "1";
|
|
|
+ } else if ("中".equals(difficultyType)) {
|
|
|
+ difficulty = "2";
|
|
|
+ } else {
|
|
|
+ difficulty = "3";
|
|
|
+ }
|
|
|
+ if (publicity == null || publicity) {
|
|
|
+ return "1-" + difficulty;
|
|
|
+ } else {
|
|
|
+ return "0-" + difficulty;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initQuesCountAndScore(Paper paper) {
|
|
|
+ Map<String, Integer> quesCount = new HashMap<>();
|
|
|
+ quesCount.put("0-1", 0);
|
|
|
+ quesCount.put("0-2", 0);
|
|
|
+ quesCount.put("0-3", 0);
|
|
|
+ quesCount.put("1-1", 0);
|
|
|
+ quesCount.put("1-2", 0);
|
|
|
+ quesCount.put("1-3", 0);
|
|
|
+ Map<String, Double> quesScore = new HashMap<>();
|
|
|
+ quesScore.put("0-1", 0.0);
|
|
|
+ quesScore.put("0-2", 0.0);
|
|
|
+ quesScore.put("0-3", 0.0);
|
|
|
+ quesScore.put("1-1", 0.0);
|
|
|
+ quesScore.put("1-2", 0.0);
|
|
|
+ quesScore.put("1-3", 0.0);
|
|
|
+ paper.setQuesCount(quesCount);
|
|
|
+ paper.setQuesScore(quesScore);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
* @param paperSearchInfo
|