|
@@ -2,7 +2,6 @@ package com.qmth.cqb.paper.web;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -12,7 +11,6 @@ import java.util.stream.Stream;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
-import com.qmth.cqb.question.service.QuesService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -39,6 +37,7 @@ import com.qmth.cqb.paper.model.Paper;
|
|
|
import com.qmth.cqb.paper.model.PaperSearchInfo;
|
|
|
import com.qmth.cqb.paper.service.PaperService;
|
|
|
import com.qmth.cqb.question.model.Question;
|
|
|
+import com.qmth.cqb.question.service.QuesService;
|
|
|
import com.qmth.cqb.utils.BeanCopierUtil;
|
|
|
import com.qmth.cqb.utils.StringSimilarityUtils;
|
|
|
import com.qmth.cqb.utils.enums.PaperType;
|
|
@@ -89,16 +88,15 @@ public class PaperController {
|
|
|
*/
|
|
|
@ApiOperation(value = "保存试卷", notes = "保存试卷")
|
|
|
@PutMapping(value = "/paper")
|
|
|
- public ResponseEntity savePaperById(HttpServletRequest request,
|
|
|
- @RequestBody PaperExp paper) {
|
|
|
+ public ResponseEntity savePaperById(HttpServletRequest request, @RequestBody PaperExp paper) {
|
|
|
AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
- Map<String,Object> msgMap = paperService.savePaper(paper,user);
|
|
|
- if("success".equals(msgMap.get("msg"))){
|
|
|
+ Map<String, Object> msgMap = paperService.savePaper(paper, user);
|
|
|
+ if ("success".equals(msgMap.get("msg"))) {
|
|
|
return new ResponseEntity(msgMap, HttpStatus.OK);
|
|
|
} else {
|
|
|
return new ResponseEntity(msgMap, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -111,10 +109,8 @@ public class PaperController {
|
|
|
*/
|
|
|
@ApiOperation(value = "查询所有导入试卷", notes = "查询所有导入试卷")
|
|
|
@GetMapping(value = "/importPaper/{curPage}/{pageSize}")
|
|
|
- public ResponseEntity getImportPapers( HttpServletRequest request,
|
|
|
- @ModelAttribute PaperSearchInfo paperSearchInfo,
|
|
|
- @PathVariable int curPage,
|
|
|
- @PathVariable int pageSize) {
|
|
|
+ public ResponseEntity getImportPapers(HttpServletRequest request, @ModelAttribute PaperSearchInfo paperSearchInfo,
|
|
|
+ @PathVariable int curPage, @PathVariable int pageSize) {
|
|
|
AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
paperSearchInfo.setOrgId(user.getOrgId().toString());
|
|
|
return new ResponseEntity(paperService.getImportPapers(paperSearchInfo, curPage, pageSize), HttpStatus.OK);
|
|
@@ -122,22 +118,20 @@ public class PaperController {
|
|
|
|
|
|
@ApiOperation(value = "查询所有待审核和审核不通过的导入试卷", notes = "查询所有待审核和审核不通过的导入试卷")
|
|
|
@GetMapping(value = "/importPaperNotSuccess/{curPage}/{pageSize}")
|
|
|
- public ResponseEntity getImportPapersNotSuccess( HttpServletRequest request,
|
|
|
- @ModelAttribute PaperSearchInfo paperSearchInfo,
|
|
|
- @PathVariable int curPage,
|
|
|
- @PathVariable int pageSize) {
|
|
|
+ public ResponseEntity getImportPapersNotSuccess(HttpServletRequest request,
|
|
|
+ @ModelAttribute PaperSearchInfo paperSearchInfo, @PathVariable int curPage, @PathVariable int pageSize) {
|
|
|
AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
paperSearchInfo.setOrgId(user.getOrgId().toString());
|
|
|
- return new ResponseEntity(paperService.getImportPapersNotSuccess(paperSearchInfo, curPage, pageSize), HttpStatus.OK);
|
|
|
+ return new ResponseEntity(paperService.getImportPapersNotSuccess(paperSearchInfo, curPage, pageSize),
|
|
|
+ HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "根据条件查询导入试卷", notes = "根据条件查询导入试卷")
|
|
|
@GetMapping(value = "/getImportPaper")
|
|
|
- public ResponseEntity<List<Paper>> getImportPapersBySearch(@ModelAttribute PaperSearchInfo paperSearchInfo){
|
|
|
- return new ResponseEntity<List<Paper>>(paperService.getImportPapersBySearch(paperSearchInfo), HttpStatus.OK);
|
|
|
+ public ResponseEntity<List<Paper>> getImportPapersBySearch(@ModelAttribute PaperSearchInfo paperSearchInfo) {
|
|
|
+ return new ResponseEntity<List<Paper>>(paperService.getImportPapersBySearch(paperSearchInfo), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 查询所有已组试卷
|
|
|
*
|
|
@@ -148,10 +142,8 @@ public class PaperController {
|
|
|
*/
|
|
|
@ApiOperation(value = "查询所有已组试卷", notes = "查询所有已组试卷")
|
|
|
@GetMapping(value = "/genPaper/{curPage}/{pageSize}")
|
|
|
- public ResponseEntity getGenPapers( HttpServletRequest request,
|
|
|
- @ModelAttribute PaperSearchInfo paperSearchInfo,
|
|
|
- @PathVariable int curPage,
|
|
|
- @PathVariable int pageSize) {
|
|
|
+ public ResponseEntity getGenPapers(HttpServletRequest request, @ModelAttribute PaperSearchInfo paperSearchInfo,
|
|
|
+ @PathVariable int curPage, @PathVariable int pageSize) {
|
|
|
AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
paperSearchInfo.setOrgId(user.getOrgId().toString());
|
|
|
return new ResponseEntity(paperService.getGenPapers(paperSearchInfo, curPage, pageSize), HttpStatus.OK);
|
|
@@ -167,13 +159,11 @@ public class PaperController {
|
|
|
@DeleteMapping(value = "/paper/{paperIds}")
|
|
|
public ResponseEntity delPaper(@PathVariable String paperIds) {
|
|
|
List<String> paperList = Stream.of(paperIds.split(",")).collect(Collectors.toList());
|
|
|
- String msg = paperService.deletePapers(paperList);
|
|
|
- if (msg.equals("success")) {
|
|
|
- return new ResponseEntity(msg, HttpStatus.OK);
|
|
|
+ Map<String, Object> msgMap = paperService.deletePapers(paperList);
|
|
|
+ if (msgMap.get("msg").equals("success")) {
|
|
|
+ return new ResponseEntity(msgMap, HttpStatus.OK);
|
|
|
} else {
|
|
|
- Map map = new HashMap();
|
|
|
- map.put("errorMsg", msg);
|
|
|
- return new ResponseEntity(map, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ return new ResponseEntity(msgMap, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -304,10 +294,9 @@ public class PaperController {
|
|
|
*/
|
|
|
@ApiOperation(value = "删除导入试卷中的试题", notes = "删除导入试卷中的试题")
|
|
|
@DeleteMapping(value = "/paper/deleteQuestion/{questionId}")
|
|
|
- public ResponseEntity deleteImportPaperQuestion(HttpServletRequest request,
|
|
|
- @PathVariable String questionId) {
|
|
|
+ public ResponseEntity deleteImportPaperQuestion(HttpServletRequest request, @PathVariable String questionId) {
|
|
|
AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
- List<String> paperNames = paperService.deleteImportQuestionById(questionId,user);
|
|
|
+ List<String> paperNames = paperService.deleteImportQuestionById(questionId, user);
|
|
|
return new ResponseEntity(paperNames, HttpStatus.OK);
|
|
|
}
|
|
|
|
|
@@ -321,12 +310,11 @@ public class PaperController {
|
|
|
*/
|
|
|
@ApiOperation(value = "向导入试卷中的新增试题", notes = "向导入试卷中的新增试题")
|
|
|
@PostMapping(value = "/paper/addQuestion/{paperId}/{paperDetailId}")
|
|
|
- public ResponseEntity insertQuestionToPaper(HttpServletRequest request,
|
|
|
- @PathVariable String paperId,
|
|
|
- @PathVariable String paperDetailId,
|
|
|
- @RequestBody Question question) {
|
|
|
+ public ResponseEntity insertQuestionToPaper(HttpServletRequest request, @PathVariable String paperId,
|
|
|
+ @PathVariable String paperDetailId, @RequestBody Question question) {
|
|
|
AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
- return new ResponseEntity(paperService.insertQuestionToPaper(paperId, paperDetailId, question,user), HttpStatus.OK);
|
|
|
+ return new ResponseEntity(paperService.insertQuestionToPaper(paperId, paperDetailId, question, user),
|
|
|
+ HttpStatus.OK);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -353,16 +341,16 @@ public class PaperController {
|
|
|
for (int i = 0; i < length - 1; i++) {
|
|
|
PaperDetailUnitExp paperDetailUnitExp1 = allPaperDetailUnitList.get(i);
|
|
|
String quesText1 = quesService.getExtractText(paperDetailUnitExp1.getQuestion());
|
|
|
- if(StringUtils.isEmpty(quesText1)){
|
|
|
+ if (StringUtils.isEmpty(quesText1)) {
|
|
|
continue;
|
|
|
}
|
|
|
for (int j = i + 1; j < length; j++) {
|
|
|
PaperDetailUnitExp paperDetailUnitExp2 = allPaperDetailUnitList.get(j);
|
|
|
String quesText2 = quesService.getExtractText(paperDetailUnitExp2.getQuestion());
|
|
|
- if(StringUtils.isEmpty(quesText2)){
|
|
|
+ if (StringUtils.isEmpty(quesText2)) {
|
|
|
continue;
|
|
|
}
|
|
|
- double similarity = StringSimilarityUtils.getSimilarityWithCosinesBySeg(quesText1,quesText2);
|
|
|
+ double similarity = StringSimilarityUtils.getSimilarityWithCosinesBySeg(quesText1, quesText2);
|
|
|
if (similarity > reduplicateSimilarity) {
|
|
|
boolean found = false;
|
|
|
for (int k = 0; k < reduplicateId.size(); k++) {
|
|
@@ -443,15 +431,14 @@ public class PaperController {
|
|
|
*/
|
|
|
@ApiOperation(value = "向导入试卷中的新增试题", notes = "向导入试卷中的新增试题")
|
|
|
@PostMapping(value = "/paper/selectQuestions/{paperId}/{paperDetailId}")
|
|
|
- public ResponseEntity selectQuestionsToPaper(HttpServletRequest request,
|
|
|
- @PathVariable String paperId,
|
|
|
- @PathVariable String paperDetailId,
|
|
|
- @RequestBody List<Question> questions) {
|
|
|
+ public ResponseEntity selectQuestionsToPaper(HttpServletRequest request, @PathVariable String paperId,
|
|
|
+ @PathVariable String paperDetailId, @RequestBody List<Question> questions) {
|
|
|
AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
- return new ResponseEntity(paperService.selectQuestionsToPaper(paperId, paperDetailId, questions,user),HttpStatus.OK);
|
|
|
+ return new ResponseEntity(paperService.selectQuestionsToPaper(paperId, paperDetailId, questions, user),
|
|
|
+ HttpStatus.OK);
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* @param request
|
|
@@ -463,22 +450,20 @@ public class PaperController {
|
|
|
*/
|
|
|
@ApiOperation(value = "查询所有导入试卷(not in paperIds)", notes = "查询所有导入试卷(not in paperIds)")
|
|
|
@GetMapping(value = "/importPaper/{ids}/{curPage}/{pageSize}")
|
|
|
- public ResponseEntity getImportPapersNotInIds( HttpServletRequest request,
|
|
|
- @ModelAttribute PaperSearchInfo paperSearchInfo,
|
|
|
- @PathVariable String[] ids,
|
|
|
- @PathVariable int curPage,
|
|
|
- @PathVariable int pageSize) {
|
|
|
+ public ResponseEntity getImportPapersNotInIds(HttpServletRequest request,
|
|
|
+ @ModelAttribute PaperSearchInfo paperSearchInfo, @PathVariable String[] ids, @PathVariable int curPage,
|
|
|
+ @PathVariable int pageSize) {
|
|
|
AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
paperSearchInfo.setOrgId(user.getOrgId().toString());
|
|
|
- if(ids !=null && ids.length > 0){
|
|
|
- return new ResponseEntity(paperService.getImportPapersNotInIds(paperSearchInfo,ids,curPage, pageSize), HttpStatus.OK);
|
|
|
+ if (ids != null && ids.length > 0) {
|
|
|
+ return new ResponseEntity(paperService.getImportPapersNotInIds(paperSearchInfo, ids, curPage, pageSize),
|
|
|
+ HttpStatus.OK);
|
|
|
} else {
|
|
|
return new ResponseEntity(paperService.getImportPapers(paperSearchInfo, curPage, pageSize), HttpStatus.OK);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
*
|
|
|
* @param request
|
|
@@ -487,14 +472,14 @@ public class PaperController {
|
|
|
*/
|
|
|
@ApiOperation(value = "查询该课程的所有导入试卷", notes = "查询该课程的所有导入试卷")
|
|
|
@GetMapping(value = "/importPaper/course")
|
|
|
- public ResponseEntity getImportPapersByCourseNo( HttpServletRequest request,
|
|
|
- @ModelAttribute PaperSearchInfo paperSearchInfo) {
|
|
|
+ public ResponseEntity getImportPapersByCourseNo(HttpServletRequest request,
|
|
|
+ @ModelAttribute PaperSearchInfo paperSearchInfo) {
|
|
|
AccessUser user = (AccessUser) request.getAttribute("accessUser");
|
|
|
paperSearchInfo.setOrgId(user.getOrgId().toString());
|
|
|
paperService.formatPaperSearchInfo(paperSearchInfo);
|
|
|
Paper importPaper = BeanCopierUtil.copyProperties(paperSearchInfo, Paper.class);
|
|
|
importPaper.setPaperType(PaperType.IMPORT);
|
|
|
return new ResponseEntity(paperRepo.findAll(Example.of(importPaper)), HttpStatus.OK);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|