|
@@ -63,6 +63,9 @@ public class MakrerApi {
|
|
@Autowired
|
|
@Autowired
|
|
SqlUtil sqlUtil;
|
|
SqlUtil sqlUtil;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ PaperRepo paperRepo;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 评卷员信息
|
|
* 评卷员信息
|
|
*
|
|
*
|
|
@@ -105,124 +108,23 @@ 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<>();
|
|
|
|
-// markTaskRepo.countGroupByLevel(marker.getId())
|
|
|
|
-// .forEach(o -> {
|
|
|
|
-// levelStatAssembler.toDTO(o);
|
|
|
|
-// 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);
|
|
|
|
-// 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<>();
|
|
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));
|
|
//统计workId下各考点的数量
|
|
//统计workId下各考点的数量
|
|
paperRepo.countGroupByLevel(questionId)
|
|
paperRepo.countGroupByLevel(questionId)
|
|
.forEach(o -> {
|
|
.forEach(o -> {
|
|
-// levelStatDTOs.add(levelStatAssembler.toDTO(o));
|
|
|
|
LevelStatDTO levelStatDTO = levelStatAssembler.toDTO(o);
|
|
LevelStatDTO levelStatDTO = levelStatAssembler.toDTO(o);
|
|
if (Objects.isNull(levelStatDTO.getId())) {
|
|
if (Objects.isNull(levelStatDTO.getId())) {
|
|
- int gcount = markTaskRepo.countByLevel(marker.getId());
|
|
|
|
|
|
+ //求任务数为null的条数
|
|
|
|
+ int gcount = markTaskRepo.countByQuestionIdAndStageAndResultIsNull(questionId, MarkStage.LEVEL);
|
|
levelStatDTO.setGcount(gcount);
|
|
levelStatDTO.setGcount(gcount);
|
|
- levelStatDTOs.add(levelStatDTO);
|
|
|
|
} else {
|
|
} else {
|
|
- int gcount = markTaskRepo.countByLevelAndResult(marker.getId(), levelStatDTO.getId().toString());
|
|
|
|
|
|
+ int gcount = markTaskRepo.countByQuestionIdAndStageAndResult(questionId, MarkStage.LEVEL, levelStatDTO.getId().toString());
|
|
levelStatDTO.setGcount(gcount);
|
|
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);
|
|
|
|
-// }
|
|
|
|
|
|
+ levelStatDTOs.add(levelStatDTO);
|
|
});
|
|
});
|
|
|
|
|
|
for (Level level : levels) {
|
|
for (Level level : levels) {
|
|
@@ -235,19 +137,16 @@ 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.countByQuestionIdAndStageAndResult(questionId, 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.countByQuestionId(questionId);
|
|
//当前老师所有的评档次数(不分档位)
|
|
//当前老师所有的评档次数(不分档位)
|
|
long total = paperRepo.countByWorkIdAndQuestionId(markSubject.getWorkId(), questionId);
|
|
long total = paperRepo.countByWorkIdAndQuestionId(markSubject.getWorkId(), questionId);
|
|
-// long total = markTaskRepo.countByQuestionId(questionId);
|
|
|
|
|
|
|
|
levelStatDTOs.forEach(o -> {
|
|
levelStatDTOs.forEach(o -> {
|
|
if (o.getId() != null) {
|
|
if (o.getId() != null) {
|
|
@@ -262,14 +161,14 @@ public class MakrerApi {
|
|
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());
|
|
|
|
+
|
|
|
|
+ int gcount = markTaskRepo.countByQuestionIdAndMarkerIdAndStageAndResult(questionId, marker.getId(), MarkStage.LEVEL, o.getId().toString());
|
|
|
|
+ o.setGcount(gcount);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
return levelStatDTOs;
|
|
return levelStatDTOs;
|
|
}
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private PaperRepo paperRepo;
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 各试题统计数据
|
|
* 各试题统计数据
|
|
*
|
|
*
|