|
@@ -1,21 +1,23 @@
|
|
|
package cn.com.qmth.stmms.ms.marking.api;
|
|
|
|
|
|
+import cn.com.qmth.stmms.ms.commons.utils.ServletUtil;
|
|
|
import cn.com.qmth.stmms.ms.core.domain.*;
|
|
|
-import cn.com.qmth.stmms.ms.core.domain.user.MarkRight;
|
|
|
-import cn.com.qmth.stmms.ms.core.domain.user.MarkUser;
|
|
|
-import cn.com.qmth.stmms.ms.core.domain.user.MarkerGroup;
|
|
|
-import cn.com.qmth.stmms.ms.core.domain.user.Role;
|
|
|
+import cn.com.qmth.stmms.ms.core.domain.user.*;
|
|
|
import cn.com.qmth.stmms.ms.core.repository.*;
|
|
|
import cn.com.qmth.stmms.ms.marking.assembler.LevelStatAssembler;
|
|
|
import cn.com.qmth.stmms.ms.marking.assembler.QuestionStatAssembler;
|
|
|
import cn.com.qmth.stmms.ms.marking.dto.LevelStatDTO;
|
|
|
import cn.com.qmth.stmms.ms.marking.dto.LevleProgressDTO;
|
|
|
import cn.com.qmth.stmms.ms.marking.dto.QuestionStatDTO;
|
|
|
+import cn.com.qmth.stmms.ms.marking.service.GroupingService;
|
|
|
+import cn.com.qmth.stmms.ms.marking.service.MarkerGroupLeaderService;
|
|
|
import cn.com.qmth.stmms.ms.marking.service.StageControlService;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import org.hibernate.annotations.NaturalId;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -62,6 +64,9 @@ public class MarkSubjectApi {
|
|
|
@Autowired
|
|
|
MarkTaskRepo markTaskRepo;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ MarkerGroupLeaderService markerGroupLeaderService;
|
|
|
+
|
|
|
|
|
|
* 查询所有科目状态
|
|
|
*
|
|
@@ -125,14 +130,14 @@ public class MarkSubjectApi {
|
|
|
}
|
|
|
|
|
|
|
|
|
- * 该评卷科目的分档统计信息
|
|
|
+ * 管理员-该评卷科目的分档统计信息
|
|
|
*
|
|
|
* @param markSubject 评卷科目id
|
|
|
* @param questionId 试题id
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "{markSubject}/stat/levels", method = RequestMethod.GET)
|
|
|
- public List<LevelStatDTO> levelStat(HttpServletRequest request, @PathVariable MarkSubject markSubject, @RequestParam Long questionId) {
|
|
|
+ public List<LevelStatDTO> levelStat(@PathVariable MarkSubject markSubject, @RequestParam Long questionId) {
|
|
|
List<LevelStatDTO> levelStatDTOs = new ArrayList<>();
|
|
|
paperRepo.countGroupByLevelAll(questionId, markSubject.getTest())
|
|
|
.forEach(o -> levelStatDTOs.add(levelStatAssembler.toDTO(o)));
|
|
@@ -180,6 +185,109 @@ public class MarkSubjectApi {
|
|
|
return levelStatDTOs;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 科组长-该评卷科目的分档统计信息
|
|
|
+ *
|
|
|
+ * @param markSubject 评卷科目id
|
|
|
+ * @param questionId 试题id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "{markSubject}/mark_leader/stat/levels", method = RequestMethod.GET)
|
|
|
+ public List<LevelStatDTO> markLeaderLevelStat(@PathVariable MarkSubject markSubject, @RequestParam Long questionId) {
|
|
|
+ Long markerId = ServletUtil.getUserId();
|
|
|
+ List<MarkerGroupLeader> markerGroupLeaders = markerGroupLeaderService.listByWorkIdAndSubjectAndStageAndMarkLeaderId(markSubject.getWorkId(), markSubject, markerId);
|
|
|
+ List<Long> paperIds = null;
|
|
|
+ if (!CollectionUtils.isEmpty(markerGroupLeaders)) {
|
|
|
+ List<Long> markers = markerGroupLeaders.stream().map(m -> m.getMarkerId()).distinct().collect(Collectors.toList());
|
|
|
+ paperIds = markerGroupLeaderService.listPaperIdsByWorkIdAndSubjectAndStageAndMarkerIds(markSubject.getWorkId(), markSubject.getSubject(), markSubject.getStage(), markers);
|
|
|
+ }
|
|
|
+ List<LevelStatDTO> levelStatDTOs = new ArrayList<>();
|
|
|
+ List<Level> levels = levelRepo.findByWorkId(markSubject.getWorkId());
|
|
|
+ if (CollectionUtils.isEmpty(paperIds)) {
|
|
|
+ paperRepo.countGroupByLevelAll(questionId, markSubject.getTest())
|
|
|
+ .forEach(o -> levelStatDTOs.add(levelStatAssembler.toDTO(o)));
|
|
|
+ for (Level level : levels) {
|
|
|
+ long count = levelStatDTOs.stream().filter(l -> String.valueOf(l.getId()).equals(level.getCode())).count();
|
|
|
+
|
|
|
+ if (count == 0) {
|
|
|
+ LevelStatDTO dto = new LevelStatDTO();
|
|
|
+ dto.setId(level.getCode());
|
|
|
+ dto.setCount(0);
|
|
|
+ dto.setPercent(0.0);
|
|
|
+ levelStatDTOs.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ long total = paperRepo.countByWorkIdAndQuestionId(markSubject.getWorkId(), questionId);
|
|
|
+
|
|
|
+ long gtotal = paperRepo.countByWorkIdAndSubject(markSubject.getWorkId(), markSubject.getSubject());
|
|
|
+ levelStatDTOs.forEach(o -> {
|
|
|
+ if (o.getId() != null) {
|
|
|
+
|
|
|
+ double p = total == 0 ? 0 : (double) o.getCount() / total * 100;
|
|
|
+ BigDecimal bd = new BigDecimal(p).setScale(3, RoundingMode.HALF_EVEN);
|
|
|
+ o.setPercent(bd.doubleValue());
|
|
|
+
|
|
|
+ Level level = levels.stream().filter(l -> l.getCode().equals(o.getId())).collect(Collectors.toList()).get(0);
|
|
|
+ o.setKdpt(level.getKdpt());
|
|
|
+
|
|
|
+ long gcount = paperRepo.countByWorkIdAndSubjectAndLevel(markSubject.getWorkId(), markSubject.getSubject(), String.valueOf(o.getId()));
|
|
|
+ o.setGcount((int) gcount);
|
|
|
+
|
|
|
+ double gp = gtotal == 0 ? 0 : (double) o.getGcount() / gtotal * 100;
|
|
|
+ BigDecimal gbd = new BigDecimal(gp).setScale(3, RoundingMode.HALF_EVEN);
|
|
|
+ o.setGpercent(gbd.doubleValue());
|
|
|
+ o.setPt(level.getPt());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ paperRepo.countGroupByLevelAllAndIdIn(questionId, markSubject.getTest(), paperIds)
|
|
|
+ .forEach(o -> levelStatDTOs.add(levelStatAssembler.toDTO(o)));
|
|
|
+ for (Level level : levels) {
|
|
|
+ long count = levelStatDTOs.stream().filter(l -> String.valueOf(l.getId()).equals(level.getCode())).count();
|
|
|
+
|
|
|
+ if (count == 0) {
|
|
|
+ LevelStatDTO dto = new LevelStatDTO();
|
|
|
+ dto.setId(level.getCode());
|
|
|
+ dto.setCount(0);
|
|
|
+ dto.setPercent(0.0);
|
|
|
+ levelStatDTOs.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ long total = paperRepo.countByWorkIdAndQuestionIdAndIdIn(markSubject.getWorkId(), questionId, paperIds);
|
|
|
+
|
|
|
+ long gtotal = paperRepo.countByWorkIdAndSubjectAndIdIn(markSubject.getWorkId(), markSubject.getSubject(), paperIds);
|
|
|
+ List<Long> finalPaperIds = paperIds;
|
|
|
+ levelStatDTOs.forEach(o -> {
|
|
|
+ if (o.getId() != null) {
|
|
|
+
|
|
|
+ double p = total == 0 ? 0 : (double) o.getCount() / total * 100;
|
|
|
+ BigDecimal bd = new BigDecimal(p).setScale(3, RoundingMode.HALF_EVEN);
|
|
|
+ o.setPercent(bd.doubleValue());
|
|
|
+
|
|
|
+ Level level = levels.stream().filter(l -> l.getCode().equals(o.getId())).collect(Collectors.toList()).get(0);
|
|
|
+ o.setKdpt(level.getKdpt());
|
|
|
+
|
|
|
+ long gcount = paperRepo.countByWorkIdAndSubjectAndLevelAndIdIn(markSubject.getWorkId(), markSubject.getSubject(), String.valueOf(o.getId()), finalPaperIds);
|
|
|
+ o.setGcount((int) gcount);
|
|
|
+
|
|
|
+ double gp = gtotal == 0 ? 0 : (double) o.getGcount() / gtotal * 100;
|
|
|
+ BigDecimal gbd = new BigDecimal(gp).setScale(3, RoundingMode.HALF_EVEN);
|
|
|
+ o.setGpercent(gbd.doubleValue());
|
|
|
+ o.setPt(level.getPt());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ Collections.sort(levelStatDTOs, (o1, o2) -> {
|
|
|
+ if (o1.getId() == null || o2.getId() == null) {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ return o1.getId().toString().compareTo(o2.getId().toString());
|
|
|
+ });
|
|
|
+ return levelStatDTOs;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
* 该评卷科目的分档统计信息
|
|
@@ -220,6 +328,63 @@ public class MarkSubjectApi {
|
|
|
return levelStatDTOs;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 该评卷科目的分档统计信息
|
|
|
+ *
|
|
|
+ * @param markSubject 评卷科目id
|
|
|
+ * @param questionId 试题id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "{markSubject}/mark_leader/stat/scores", method = RequestMethod.GET)
|
|
|
+ public List<LevelStatDTO> markLeaderScoreStat(@PathVariable MarkSubject markSubject,
|
|
|
+ @RequestParam Long questionId) {
|
|
|
+ Long markerId = ServletUtil.getUserId();
|
|
|
+ List<MarkerGroupLeader> markerGroupLeaders = markerGroupLeaderService.listByWorkIdAndSubjectAndStageAndMarkLeaderId(markSubject.getWorkId(), markSubject, markerId);
|
|
|
+ List<Long> paperIds = null;
|
|
|
+ if (!CollectionUtils.isEmpty(markerGroupLeaders)) {
|
|
|
+ List<Long> markers = markerGroupLeaders.stream().map(m -> m.getMarkerId()).distinct().collect(Collectors.toList());
|
|
|
+ paperIds = markerGroupLeaderService.listPaperIdsByWorkIdAndSubjectAndStageAndMarkerIds(markSubject.getWorkId(), markSubject.getSubject(), markSubject.getStage(), markers);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<LevelStatDTO> levelStatDTOs = new ArrayList<>();
|
|
|
+ List<Level> levels = levelRepo.findByWorkId(markSubject.getWorkId());
|
|
|
+ if (CollectionUtils.isEmpty(paperIds)) {
|
|
|
+ paperRepo.countScoreGroupByLevelAll(questionId, markSubject.getTest())
|
|
|
+ .forEach(o -> levelStatDTOs.add(levelStatAssembler.toDTO(o)));
|
|
|
+ for (Level level : levels) {
|
|
|
+
|
|
|
+ LevelStatDTO dto = new LevelStatDTO();
|
|
|
+ dto.setId(level.getCode());
|
|
|
+ dto.setPercent(0.0);
|
|
|
+ int count = paperRepo.countByWorkIdAndSubjectAndQuestionIdAndLevelAndScoreNotNull(markSubject.getWorkId(), markSubject.getSubject(), questionId, level.getCode());
|
|
|
+ dto.setCount(count);
|
|
|
+ int gcount = paperRepo.countByWorkIdAndSubjectAndLevelAndScoreNotNull(markSubject.getWorkId(), markSubject.getSubject(), level.getCode());
|
|
|
+ dto.setGcount(gcount);
|
|
|
+ levelStatDTOs.add(dto);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ paperRepo.countScoreGroupByLevelAllAndIdIn(questionId, markSubject.getTest(), paperIds)
|
|
|
+ .forEach(o -> levelStatDTOs.add(levelStatAssembler.toDTO(o)));
|
|
|
+ for (Level level : levels) {
|
|
|
+ LevelStatDTO dto = new LevelStatDTO();
|
|
|
+ dto.setId(level.getCode());
|
|
|
+ dto.setPercent(0.0);
|
|
|
+ int count = paperRepo.countByWorkIdAndSubjectAndQuestionIdAndLevelAndScoreNotNullAndIdIn(markSubject.getWorkId(), markSubject.getSubject(), questionId, level.getCode(), paperIds);
|
|
|
+ dto.setCount(count);
|
|
|
+ int gcount = paperRepo.countByWorkIdAndSubjectAndLevelAndScoreNotNullAndIdIn(markSubject.getWorkId(), markSubject.getSubject(), level.getCode(), paperIds);
|
|
|
+ dto.setGcount(gcount);
|
|
|
+ levelStatDTOs.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Collections.sort(levelStatDTOs, (o1, o2) -> {
|
|
|
+ if (o1.getId() == null || o2.getId() == null) {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ return o1.getId().toString().compareTo(o2.getId().toString());
|
|
|
+ });
|
|
|
+ return levelStatDTOs;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* 该评卷科目下的评卷员分组列表
|
|
|
*
|
|
@@ -244,14 +409,14 @@ public class MarkSubjectApi {
|
|
|
}
|
|
|
if (MarkStage.LEVEL == markSubject.getStage() || MarkStage.SCORE == markSubject.getStage()) {
|
|
|
int count = markTaskRepo.countByWorkIdAndSubjectAndStage(markSubject.getWorkId(), markSubject.getSubject(), markSubject.getStage());
|
|
|
- if(count > 0){
|
|
|
+ if (count > 0) {
|
|
|
throw new RuntimeException("当前阶段已发布任务,不能编辑分组");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
markerGroup.setWorkId(markSubject.getWorkId());
|
|
|
markerGroup.setSubject(markSubject.getSubject());
|
|
|
- return markerGroupRepo.save(markerGroup);
|
|
|
+ return markerGroupLeaderService.save(markerGroup, markSubject.getStage().equals(MarkStage.INIT) ? MarkStage.LEVEL : markSubject.getStage());
|
|
|
}
|
|
|
|
|
|
|
|
@@ -275,14 +440,7 @@ public class MarkSubjectApi {
|
|
|
*/
|
|
|
@RequestMapping(value = "{markSubject}/markergroups/{domain}", method = RequestMethod.DELETE)
|
|
|
public void removeMarkerGroup(@PathVariable MarkSubject markSubject, @PathVariable MarkerGroup domain) {
|
|
|
- int count = 0;
|
|
|
- if (MarkStage.LEVEL == markSubject.getStage() || MarkStage.SCORE == markSubject.getStage()) {
|
|
|
- count = markTaskRepo.countByWorkIdAndSubjectAndStage(markSubject.getWorkId(), markSubject.getSubject(), markSubject.getStage());
|
|
|
- }
|
|
|
- if(count > 0){
|
|
|
- throw new RuntimeException("当前阶段已发布任务,不能删除分组");
|
|
|
- }
|
|
|
- markerGroupRepo.delete(domain);
|
|
|
+ markerGroupLeaderService.delete(markSubject, domain);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -391,7 +549,7 @@ public class MarkSubjectApi {
|
|
|
* @param markSubject 评卷科目id
|
|
|
*/
|
|
|
@RequestMapping(value = "{markSubject}/scoreProgress", method = RequestMethod.GET)
|
|
|
- public List scoreProgress(@PathVariable MarkSubject markSubject,@RequestParam(defaultValue = "") Long questionId) {
|
|
|
+ public List scoreProgress(@PathVariable MarkSubject markSubject, @RequestParam(defaultValue = "") Long questionId) {
|
|
|
return stageControlService.scoreProgress(markSubject, questionId);
|
|
|
}
|
|
|
|