|
@@ -1,7 +1,6 @@
|
|
package cn.com.qmth.stmms.ms.marking.api;
|
|
package cn.com.qmth.stmms.ms.marking.api;
|
|
|
|
|
|
import cn.com.qmth.stmms.ms.commons.utils.SqlUtil;
|
|
import cn.com.qmth.stmms.ms.commons.utils.SqlUtil;
|
|
-import cn.com.qmth.stmms.ms.core.domain.ExamQuestion;
|
|
|
|
import cn.com.qmth.stmms.ms.core.domain.Level;
|
|
import cn.com.qmth.stmms.ms.core.domain.Level;
|
|
import cn.com.qmth.stmms.ms.core.domain.MarkStage;
|
|
import cn.com.qmth.stmms.ms.core.domain.MarkStage;
|
|
import cn.com.qmth.stmms.ms.core.domain.MarkSubject;
|
|
import cn.com.qmth.stmms.ms.core.domain.MarkSubject;
|
|
@@ -106,55 +105,126 @@ public class MakrerApi {
|
|
*/
|
|
*/
|
|
@RequestMapping(value = "{marker}/stat/levels", method = RequestMethod.GET)
|
|
@RequestMapping(value = "{marker}/stat/levels", method = RequestMethod.GET)
|
|
public List<LevelStatDTO> levelStats(@PathVariable MarkUser marker, @RequestParam Long questionId) throws Exception {
|
|
public List<LevelStatDTO> levelStats(@PathVariable MarkUser marker, @RequestParam Long questionId) throws Exception {
|
|
- List<LevelStatDTO> levelStatDTOs = new ArrayList<>();
|
|
|
|
|
|
+// List<LevelStatDTO> levelStatDTOs = new ArrayList<>();
|
|
// markTaskRepo.countGroupByLevel(marker.getId())
|
|
// markTaskRepo.countGroupByLevel(marker.getId())
|
|
// .forEach(o -> {
|
|
// .forEach(o -> {
|
|
// levelStatAssembler.toDTO(o);
|
|
// levelStatAssembler.toDTO(o);
|
|
// levelStatDTOs.add();
|
|
// levelStatDTOs.add();
|
|
// });
|
|
// });
|
|
- ExamQuestion examQuestion = examQuestionRepo.findOne(questionId);
|
|
|
|
- if (Objects.isNull(examQuestion)) {
|
|
|
|
- throw new Exception("当前考试试卷为空");
|
|
|
|
- }
|
|
|
|
- //获取当前考试当前科目所在地区的所有questionId
|
|
|
|
- List<ExamQuestion> examQuestionList = examQuestionRepo.findAllByAreaCodeAndSubjectAndWorkId(examQuestion.getAreaCode(), examQuestion.getSubject(), examQuestion.getWorkId());
|
|
|
|
- List<Long> questionIds = examQuestionList.stream()
|
|
|
|
- .map(m -> m.getId())
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
- StringBuilder startSql = new StringBuilder("select t.`result`,sum(if(t.questionId <> t.currentQuesId, 0, t.sumCount)) as sumCount from(SELECT t.result,COUNT(*) as sumCount,t.question_id as questionId,? as currentQuesId FROM mark_task t WHERE t.`question_id` in ( ");
|
|
|
|
- String endSql = " ) and t.stage = 1 GROUP BY t.`result`,t.question_id ORDER BY t.result) t group by t.`result` ";
|
|
|
|
- questionIds.forEach(o -> startSql.append(o).append(","));
|
|
|
|
- //当前老师当前试卷的评档次数
|
|
|
|
- StringBuilder sql = new StringBuilder(startSql.toString().substring(0, startSql.toString().length() - 1));
|
|
|
|
- sql.append(endSql);
|
|
|
|
- String finalSql = sqlUtil.sqlPrint(sql.toString(), questionId);
|
|
|
|
- List list = sqlUtil.execSqlForMap(finalSql);
|
|
|
|
|
|
+// ExamQuestion examQuestion = examQuestionRepo.findOne(questionId);
|
|
|
|
+// if (Objects.isNull(examQuestion)) {
|
|
|
|
+// throw new Exception("当前考试试卷为空");
|
|
|
|
+// }
|
|
|
|
+// //获取当前考试当前科目所在地区的所有questionId
|
|
|
|
+// List<ExamQuestion> examQuestionList = examQuestionRepo.findAllByAreaCodeAndSubjectAndWorkId(examQuestion.getAreaCode(), examQuestion.getSubject(), examQuestion.getWorkId());
|
|
|
|
+// List<Long> questionIds = examQuestionList.stream()
|
|
|
|
+// .map(m -> m.getId())
|
|
|
|
+// .collect(Collectors.toList());
|
|
|
|
+// StringBuilder startSql = new StringBuilder("select t.`result`,sum(if(t.questionId <> t.currentQuesId, 0, t.sumCount)) as sumCount from(SELECT t.result,COUNT(*) as sumCount,t.question_id as questionId,? as currentQuesId FROM mark_task t WHERE t.`question_id` in ( ");
|
|
|
|
+// String endSql = " ) and t.stage = 1 GROUP BY t.`result`,t.question_id ORDER BY t.result) t group by t.`result` ";
|
|
|
|
+// questionIds.forEach(o -> startSql.append(o).append(","));
|
|
|
|
+// //当前老师当前试卷的评档次数
|
|
|
|
+// StringBuilder sql = new StringBuilder(startSql.toString().substring(0, startSql.toString().length() - 1));
|
|
|
|
+// sql.append(endSql);
|
|
|
|
+// String finalSql = sqlUtil.sqlPrint(sql.toString(), questionId);
|
|
|
|
+// List list = sqlUtil.execSqlForMap(finalSql);
|
|
|
|
+// MarkSubject markSubject = markSubjectRepo.findOne(marker.getWorkId() + "-" + marker.getSubject().toString());
|
|
|
|
+// List<Level> levels = levelRepo.findByWorkId(markSubject.getWorkId());
|
|
|
|
+// Map<String, Level> levelMap = levels.stream().collect(Collectors.toMap(Level::getCode, l -> l));
|
|
|
|
+//// Map<String, LevelStatDTO> filterLevelMap = new HashMap<>();
|
|
|
|
+// for (int i = 0; i < list.size(); i++) {
|
|
|
|
+// Map map = (Map) list.get(i);
|
|
|
|
+// List finalList = (List) map.values().stream()
|
|
|
|
+// .collect(Collectors.toList());
|
|
|
|
+// Object[] o = finalList.toArray();
|
|
|
|
+// LevelStatDTO levelStatDTO = levelStatAssembler.toDTO(o);
|
|
|
|
+// if (levelStatDTO.getId() == null) {
|
|
|
|
+// //当前老师未评档的次数
|
|
|
|
+//// int gcount = markTaskRepo.countByLevel(marker.getId());
|
|
|
|
+// int gcount = markTaskRepo.countByQuestionIdInAndStageAndResultIsNull(questionIds, MarkStage.LEVEL);
|
|
|
|
+// levelStatDTO.setGcount(gcount);
|
|
|
|
+// levelStatDTOs.add(levelStatDTO);
|
|
|
|
+// } else {
|
|
|
|
+// //当前老师每个档位已评档位的次数
|
|
|
|
+//// int gcount = markTaskRepo.countByLevelAndResult(marker.getId(), levelStatDTO.getId().toString());
|
|
|
|
+// int gcount = markTaskRepo.countByQuestionIdInAndStageAndResult(questionIds, MarkStage.LEVEL, levelStatDTO.getId().toString());
|
|
|
|
+// levelStatDTO.setGcount(gcount);
|
|
|
|
+// }
|
|
|
|
+// if (Objects.nonNull(levelMap.get(levelStatDTO.getId()))) {
|
|
|
|
+// levelStatDTOs.add(levelStatDTO);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// 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);
|
|
|
|
+//
|
|
|
|
+// //当前老师当前档位评档次数(所有考试)
|
|
|
|
+//// int gcount = markTaskRepo.countByLevelAndResult(marker.getId(), level.getCode());
|
|
|
|
+// int gcount = markTaskRepo.countByQuestionIdInAndStageAndResult(questionIds, MarkStage.LEVEL, level.getCode());
|
|
|
|
+// dto.setGcount(gcount);
|
|
|
|
+// levelStatDTOs.add(dto);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //当前老师当前试卷的评档次数(不分档位)
|
|
|
|
+//// long kdtotal = markTaskRepo.countByMarkerIdAndQuestionId(marker.getId(), questionId);
|
|
|
|
+// long kdtotal = markTaskRepo.countByQuestionIdIn(questionIds);
|
|
|
|
+// //当前老师所有的评档次数(不分档位)
|
|
|
|
+// long total = markTaskRepo.countByMarkerId(marker.getId());
|
|
|
|
+//// long total = markTaskRepo.countByQuestionId(questionId);
|
|
|
|
+//
|
|
|
|
+// levelStatDTOs.forEach(o -> {
|
|
|
|
+// if (o.getId() != null) {
|
|
|
|
+// o.setPt(levelMap.get(o.getId()).getPt());
|
|
|
|
+// o.setKdpt(levelMap.get(o.getId()).getKdpt());
|
|
|
|
+// double p = (double) o.getCount() / total;
|
|
|
|
+// BigDecimal bd = new BigDecimal(p).setScale(3, RoundingMode.HALF_EVEN);
|
|
|
|
+// o.setPercent(bd.doubleValue());
|
|
|
|
+//
|
|
|
|
+// double gp = (double) o.getGcount() / kdtotal;
|
|
|
|
+// BigDecimal gbd = new BigDecimal(gp).setScale(3, RoundingMode.HALF_EVEN);
|
|
|
|
+// o.setGpercent(gbd.doubleValue());
|
|
|
|
+// }
|
|
|
|
+// });
|
|
|
|
+// return levelStatDTOs;
|
|
|
|
+ List<LevelStatDTO> levelStatDTOs = new ArrayList<>();
|
|
|
|
+// ExamQuestion examQuestion = examQuestionRepo.findOne(questionId);
|
|
|
|
+// if (Objects.isNull(examQuestion)) {
|
|
|
|
+// throw new Exception("当前考试试卷为空");
|
|
|
|
+// }
|
|
MarkSubject markSubject = markSubjectRepo.findOne(marker.getWorkId() + "-" + marker.getSubject().toString());
|
|
MarkSubject markSubject = markSubjectRepo.findOne(marker.getWorkId() + "-" + marker.getSubject().toString());
|
|
List<Level> levels = levelRepo.findByWorkId(markSubject.getWorkId());
|
|
List<Level> levels = levelRepo.findByWorkId(markSubject.getWorkId());
|
|
Map<String, Level> levelMap = levels.stream().collect(Collectors.toMap(Level::getCode, l -> l));
|
|
Map<String, Level> levelMap = levels.stream().collect(Collectors.toMap(Level::getCode, l -> l));
|
|
-// Map<String, LevelStatDTO> filterLevelMap = new HashMap<>();
|
|
|
|
- for (int i = 0; i < list.size(); i++) {
|
|
|
|
- Map map = (Map) list.get(i);
|
|
|
|
- List finalList = (List) map.values().stream()
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
- Object[] o = finalList.toArray();
|
|
|
|
- LevelStatDTO levelStatDTO = levelStatAssembler.toDTO(o);
|
|
|
|
- if (levelStatDTO.getId() == null) {
|
|
|
|
- //当前老师未评档的次数
|
|
|
|
-// int gcount = markTaskRepo.countByLevel(marker.getId());
|
|
|
|
- int gcount = markTaskRepo.countByQuestionIdInAndStageAndResultIsNull(questionIds, MarkStage.LEVEL);
|
|
|
|
- levelStatDTO.setGcount(gcount);
|
|
|
|
- levelStatDTOs.add(levelStatDTO);
|
|
|
|
- } else {
|
|
|
|
- //当前老师每个档位已评档位的次数
|
|
|
|
-// int gcount = markTaskRepo.countByLevelAndResult(marker.getId(), levelStatDTO.getId().toString());
|
|
|
|
- int gcount = markTaskRepo.countByQuestionIdInAndStageAndResult(questionIds, MarkStage.LEVEL, levelStatDTO.getId().toString());
|
|
|
|
- levelStatDTO.setGcount(gcount);
|
|
|
|
- }
|
|
|
|
- if (Objects.nonNull(levelMap.get(levelStatDTO.getId()))) {
|
|
|
|
- levelStatDTOs.add(levelStatDTO);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ //统计workId下各考点的数量
|
|
|
|
+ paperRepo.countGroupByLevel(questionId)
|
|
|
|
+ .forEach(o -> {
|
|
|
|
+// levelStatDTOs.add(levelStatAssembler.toDTO(o));
|
|
|
|
+ LevelStatDTO levelStatDTO = levelStatAssembler.toDTO(o);
|
|
|
|
+ if (Objects.isNull(levelStatDTO.getId())) {
|
|
|
|
+ int gcount = markTaskRepo.countByLevel(marker.getId());
|
|
|
|
+ levelStatDTO.setGcount(gcount);
|
|
|
|
+ levelStatDTOs.add(levelStatDTO);
|
|
|
|
+ } else {
|
|
|
|
+ int gcount = markTaskRepo.countByLevelAndResult(marker.getId(), levelStatDTO.getId().toString());
|
|
|
|
+ levelStatDTO.setGcount(gcount);
|
|
|
|
+ }
|
|
|
|
+ if (Objects.nonNull(levelMap.get(levelStatDTO.getId()))) {
|
|
|
|
+ levelStatDTOs.add(levelStatDTO);
|
|
|
|
+ }
|
|
|
|
+// if (levelStatDTO.getId() == null) {
|
|
|
|
+// //当前老师未评档的次数
|
|
|
|
+// // int gcount = markTaskRepo.countByLevel(marker.getId());
|
|
|
|
+// int gcount = markTaskRepo.countByQuestionIdInAndStageAndResultIsNull(questionIds, MarkStage.LEVEL);
|
|
|
|
+// levelStatDTO.setGcount(gcount);
|
|
|
|
+// levelStatDTOs.add(levelStatDTO);
|
|
|
|
+// }
|
|
|
|
+ });
|
|
|
|
+
|
|
for (Level level : levels) {
|
|
for (Level level : levels) {
|
|
//所有档位依次比较
|
|
//所有档位依次比较
|
|
long count = levelStatDTOs.stream().filter(l -> String.valueOf(l.getId()).equals(level.getCode())).count();
|
|
long count = levelStatDTOs.stream().filter(l -> String.valueOf(l.getId()).equals(level.getCode())).count();
|
|
@@ -165,28 +235,30 @@ public class MakrerApi {
|
|
dto.setPercent(0.0);
|
|
dto.setPercent(0.0);
|
|
|
|
|
|
//当前老师当前档位评档次数(所有考试)
|
|
//当前老师当前档位评档次数(所有考试)
|
|
-// int gcount = markTaskRepo.countByLevelAndResult(marker.getId(), level.getCode());
|
|
|
|
- int gcount = markTaskRepo.countByQuestionIdInAndStageAndResult(questionIds, MarkStage.LEVEL, level.getCode());
|
|
|
|
|
|
+ int gcount = markTaskRepo.countByLevelAndResult(marker.getId(), level.getCode());
|
|
|
|
+// int gcount = markTaskRepo.countByQuestionIdInAndStageAndResult(questionIds, MarkStage.LEVEL, level.getCode());
|
|
dto.setGcount(gcount);
|
|
dto.setGcount(gcount);
|
|
levelStatDTOs.add(dto);
|
|
levelStatDTOs.add(dto);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//当前老师当前试卷的评档次数(不分档位)
|
|
//当前老师当前试卷的评档次数(不分档位)
|
|
-// long kdtotal = markTaskRepo.countByMarkerIdAndQuestionId(marker.getId(), questionId);
|
|
|
|
- long kdtotal = markTaskRepo.countByQuestionIdIn(questionIds);
|
|
|
|
|
|
+ long kdtotal = markTaskRepo.countByMarkerIdAndQuestionId(marker.getId(), questionId);
|
|
|
|
+// long kdtotal = markTaskRepo.countByQuestionIdIn(questionIds);
|
|
//当前老师所有的评档次数(不分档位)
|
|
//当前老师所有的评档次数(不分档位)
|
|
- long total = markTaskRepo.countByMarkerId(marker.getId());
|
|
|
|
|
|
+ long total = paperRepo.countByWorkIdAndQuestionId(markSubject.getWorkId(), questionId);
|
|
// long total = markTaskRepo.countByQuestionId(questionId);
|
|
// long total = markTaskRepo.countByQuestionId(questionId);
|
|
|
|
|
|
levelStatDTOs.forEach(o -> {
|
|
levelStatDTOs.forEach(o -> {
|
|
if (o.getId() != null) {
|
|
if (o.getId() != null) {
|
|
o.setPt(levelMap.get(o.getId()).getPt());
|
|
o.setPt(levelMap.get(o.getId()).getPt());
|
|
o.setKdpt(levelMap.get(o.getId()).getKdpt());
|
|
o.setKdpt(levelMap.get(o.getId()).getKdpt());
|
|
|
|
+ o.setCount(Objects.isNull(o.getCount()) ? 0 : o.getCount());
|
|
double p = (double) o.getCount() / total;
|
|
double p = (double) o.getCount() / total;
|
|
BigDecimal bd = new BigDecimal(p).setScale(3, RoundingMode.HALF_EVEN);
|
|
BigDecimal bd = new BigDecimal(p).setScale(3, RoundingMode.HALF_EVEN);
|
|
o.setPercent(bd.doubleValue());
|
|
o.setPercent(bd.doubleValue());
|
|
|
|
|
|
|
|
+ o.setGcount(Objects.isNull(o.getGcount()) ? 0 : o.getGcount());
|
|
double gp = (double) o.getGcount() / kdtotal;
|
|
double gp = (double) o.getGcount() / kdtotal;
|
|
BigDecimal gbd = new BigDecimal(gp).setScale(3, RoundingMode.HALF_EVEN);
|
|
BigDecimal gbd = new BigDecimal(gp).setScale(3, RoundingMode.HALF_EVEN);
|
|
o.setGpercent(gbd.doubleValue());
|
|
o.setGpercent(gbd.doubleValue());
|
|
@@ -195,6 +267,9 @@ public class MakrerApi {
|
|
return levelStatDTOs;
|
|
return levelStatDTOs;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private PaperRepo paperRepo;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 各试题统计数据
|
|
* 各试题统计数据
|
|
*
|
|
*
|