|
@@ -0,0 +1,218 @@
|
|
|
+package cn.com.qmth.stmms.api.controller.admin;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+
|
|
|
+import com.qmth.boot.core.collection.PageResult;
|
|
|
+
|
|
|
+import cn.com.qmth.stmms.admin.vo.TrialMarkerVO;
|
|
|
+import cn.com.qmth.stmms.admin.vo.TrialQuestionVO;
|
|
|
+import cn.com.qmth.stmms.api.controller.BaseApiController;
|
|
|
+import cn.com.qmth.stmms.biz.config.service.impl.SystemCache;
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.ExamSubject;
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.MarkGroup;
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.Marker;
|
|
|
+import cn.com.qmth.stmms.biz.exam.query.MarkerSearchQuery;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.*;
|
|
|
+import cn.com.qmth.stmms.biz.exception.StatusException;
|
|
|
+import cn.com.qmth.stmms.biz.file.service.FileService;
|
|
|
+import cn.com.qmth.stmms.biz.lock.LockService;
|
|
|
+import cn.com.qmth.stmms.biz.mark.model.TrialLibrary;
|
|
|
+import cn.com.qmth.stmms.biz.mark.query.TrialLibrarySearchQuery;
|
|
|
+import cn.com.qmth.stmms.biz.mark.service.MarkService;
|
|
|
+import cn.com.qmth.stmms.biz.mark.service.TrialService;
|
|
|
+import cn.com.qmth.stmms.biz.user.model.User;
|
|
|
+import cn.com.qmth.stmms.biz.user.service.UserService;
|
|
|
+import cn.com.qmth.stmms.biz.utils.PageUtil;
|
|
|
+import cn.com.qmth.stmms.biz.utils.ScoreItem;
|
|
|
+import cn.com.qmth.stmms.common.annotation.Logging;
|
|
|
+import cn.com.qmth.stmms.common.domain.ApiUser;
|
|
|
+import cn.com.qmth.stmms.common.enums.LogType;
|
|
|
+import cn.com.qmth.stmms.common.enums.MarkStatus;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+@Api(tags = "试评管理")
|
|
|
+@Controller("adminTrialController")
|
|
|
+@RequestMapping("/api/admin/trial")
|
|
|
+public class TrialController extends BaseApiController {
|
|
|
+
|
|
|
+ protected static Logger log = LoggerFactory.getLogger(TrialController.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamStudentService studentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MarkGroupService groupService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TrialService trialService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MarkService markService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MarkerService markerService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LockService lockService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamQuestionService questionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamService examService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FileService fileService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SystemCache systemCache;
|
|
|
+
|
|
|
+ public static final String UN_SELECTIVE_SCORE = "-1";
|
|
|
+
|
|
|
+ @ApiOperation(value = "试评任务查询")
|
|
|
+ @Logging(menu = "试评任务查询", type = LogType.QUERY)
|
|
|
+ @RequestMapping(value = "query", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public PageResult<TrialLibrary> query(TrialLibrarySearchQuery query) {
|
|
|
+ ApiUser user = getApiUser();
|
|
|
+ int examId = getSessionExamId();
|
|
|
+ List<ExamSubject> subjectList = getExamSubject(examId, user);
|
|
|
+ if (subjectList.isEmpty()) {
|
|
|
+ throw new StatusException("没有科目");
|
|
|
+ }
|
|
|
+ query.setExamId(examId);
|
|
|
+ if (StringUtils.isBlank(query.getSubjectCode()) && !subjectList.isEmpty()) {
|
|
|
+ query.setSubjectCode(subjectList.get(0).getCode());
|
|
|
+ }
|
|
|
+ List<MarkGroup> groupList = groupService.findByExamAndSubjectAndStatus(examId, query.getSubjectCode(),
|
|
|
+ MarkStatus.TRIAL);
|
|
|
+ if (!groupList.isEmpty()) {
|
|
|
+ query = trialService.findLibrary(query);
|
|
|
+ for (TrialLibrary library : query.getResult()) {
|
|
|
+ if (library.getMarkerId() != null) {
|
|
|
+ Marker marker = markerService.findById(library.getMarkerId());
|
|
|
+ library.setMarkerLoginName(userService.findById(marker.getUserId()).getLoginName());
|
|
|
+ }
|
|
|
+ if (library.getMarkerScoreList() != null) {
|
|
|
+ library.setMarkerScoreList(library.getMarkerScoreList().replace(UN_SELECTIVE_SCORE, "/"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return PageUtil.of(query);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "试评分析查询")
|
|
|
+ @RequestMapping(value = "marker", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public PageResult<TrialMarkerVO> marker(MarkerSearchQuery query) {
|
|
|
+ ApiUser wu = getApiUser();
|
|
|
+ int examId = getSessionExamId();
|
|
|
+ List<ExamSubject> subjectList = getExamSubject(examId, wu);
|
|
|
+ if (subjectList.isEmpty()) {
|
|
|
+ throw new StatusException("没有科目");
|
|
|
+ }
|
|
|
+ query.setExamId(examId);
|
|
|
+ if (StringUtils.isBlank(query.getSubjectCode()) && !subjectList.isEmpty()) {
|
|
|
+ query.setSubjectCode(subjectList.get(0).getCode());
|
|
|
+ }
|
|
|
+ List<MarkGroup> groupList = groupService.findByExamAndSubjectAndStatus(examId, query.getSubjectCode(),
|
|
|
+ MarkStatus.TRIAL);
|
|
|
+ String groupTile = null;
|
|
|
+ List<ExamQuestion> questionList = new ArrayList<>();
|
|
|
+ if (!groupList.isEmpty()) {
|
|
|
+ for (MarkGroup group : groupList) {
|
|
|
+ List<ExamQuestion> questions = questionService.findByExamAndSubjectAndObjectiveAndGroupNumber(examId,
|
|
|
+ group.getSubjectCode(), false, group.getNumber());
|
|
|
+ group.setQuestionList(questions);
|
|
|
+ if (query.getGroupNumber() == group.getNumber()) {
|
|
|
+ groupTile = group.getTitle();
|
|
|
+ questionList = questions;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<TrialMarkerVO> result = new ArrayList<TrialMarkerVO>();
|
|
|
+ List<Marker> markerList = new ArrayList<Marker>();
|
|
|
+ if (query.getGroupNumber() != null) {
|
|
|
+ MarkerSearchQuery mQuery = new MarkerSearchQuery();
|
|
|
+ mQuery.setExamId(examId);
|
|
|
+ mQuery.setSubjectCode(query.getSubjectCode());
|
|
|
+ mQuery.setGroupNumber(query.getGroupNumber());
|
|
|
+ mQuery.setPageSize(Integer.MAX_VALUE);
|
|
|
+ mQuery = markerService.findByQuery(mQuery);
|
|
|
+ for (Marker marker : mQuery.getResult()) {
|
|
|
+ User user = userService.findById(marker.getUserId());
|
|
|
+ marker.setLoginName(user.getLoginName());
|
|
|
+ marker.setUser(user);
|
|
|
+ markerList.add(marker);
|
|
|
+ }
|
|
|
+
|
|
|
+ query.setPageSize(Integer.MAX_VALUE);
|
|
|
+ query = markerService.findByQuery(query);
|
|
|
+ for (Marker marker : query.getResult()) {
|
|
|
+ TrialMarkerVO vo = new TrialMarkerVO();
|
|
|
+ vo.setId(marker.getId());
|
|
|
+ vo.setLoginName(userService.findById(marker.getUserId()).getLoginName());
|
|
|
+ vo.setGroupNumber(marker.getGroupNumber());
|
|
|
+ vo.setGroupTitle(groupTile);
|
|
|
+ List<TrialLibrary> libraryList = trialService.findLibraryByMarkerId(marker.getId());
|
|
|
+ Double avgScore = 0d;
|
|
|
+ List<TrialLibrary> markedList = libraryList.stream().filter(s -> s.getMarkerScore() != null)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ vo.setTrialCount(markedList.size());
|
|
|
+ if (!markedList.isEmpty()) {
|
|
|
+ avgScore = markedList.stream().mapToDouble(TrialLibrary::getMarkerScore).average().orElse(0);
|
|
|
+ }
|
|
|
+ vo.setAvgScore(avgScore);
|
|
|
+ Map<Integer, List<ScoreItem>> map = new HashMap<>();
|
|
|
+ for (TrialLibrary library : markedList) {
|
|
|
+ List<ScoreItem> sList = library.getScoreList();
|
|
|
+ for (int i = 0; i < questionList.size(); i++) {
|
|
|
+ ExamQuestion question = questionList.get(i);
|
|
|
+ List<ScoreItem> qsList = map.get(question.getId());
|
|
|
+ if (qsList == null) {
|
|
|
+ qsList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ qsList.add(sList.get(i));
|
|
|
+ map.put(question.getId(), qsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<TrialQuestionVO> list = new ArrayList<>();
|
|
|
+ for (ExamQuestion question : questionList) {
|
|
|
+ List<ScoreItem> qsList = map.get(question.getId());
|
|
|
+ TrialQuestionVO trialQuestionVO = new TrialQuestionVO();
|
|
|
+ if (qsList != null && !qsList.isEmpty()) {
|
|
|
+ trialQuestionVO.setAvgScore(qsList.stream().filter(s -> s.getScore() >= 0)
|
|
|
+ .mapToDouble(ScoreItem::getScore).average().orElse(0));
|
|
|
+ String scoreList = StringUtils.join(qsList, ",");
|
|
|
+ if (scoreList != null) {
|
|
|
+ trialQuestionVO.setScoreList(scoreList.replace(UN_SELECTIVE_SCORE, "/"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list.add(trialQuestionVO);
|
|
|
+ }
|
|
|
+ vo.setQuestionList(list);
|
|
|
+ result.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return PageUtil.of(result, query);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|