|
@@ -31,6 +31,7 @@ import com.qmth.boot.api.constant.ApiConstant;
|
|
import com.qmth.boot.core.concurrent.service.ConcurrentService;
|
|
import com.qmth.boot.core.concurrent.service.ConcurrentService;
|
|
|
|
|
|
import cn.com.qmth.am.bean.DataKey;
|
|
import cn.com.qmth.am.bean.DataKey;
|
|
|
|
+import cn.com.qmth.am.bean.ExportExcelDto;
|
|
import cn.com.qmth.am.bean.ModelSpeed;
|
|
import cn.com.qmth.am.bean.ModelSpeed;
|
|
import cn.com.qmth.am.bean.StudentScoreVo;
|
|
import cn.com.qmth.am.bean.StudentScoreVo;
|
|
import cn.com.qmth.am.config.SysProperty;
|
|
import cn.com.qmth.am.config.SysProperty;
|
|
@@ -43,6 +44,7 @@ import cn.com.qmth.am.service.QuestionService;
|
|
import cn.com.qmth.am.service.StudentScoreService;
|
|
import cn.com.qmth.am.service.StudentScoreService;
|
|
import cn.com.qmth.am.service.StudentService;
|
|
import cn.com.qmth.am.service.StudentService;
|
|
import cn.com.qmth.am.utils.Calculator;
|
|
import cn.com.qmth.am.utils.Calculator;
|
|
|
|
+import cn.com.qmth.am.utils.ExportUtils;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@@ -68,6 +70,57 @@ public class AdminController {
|
|
@Autowired
|
|
@Autowired
|
|
private ConcurrentService concurrentService;
|
|
private ConcurrentService concurrentService;
|
|
|
|
|
|
|
|
+ @ApiOperation(value = "导出数据")
|
|
|
|
+ @RequestMapping(value = "export", method = RequestMethod.GET)
|
|
|
|
+ public void exportExcel(HttpServletResponse response, @RequestParam Long examId,
|
|
|
|
+ @RequestParam(required = false) String subjectCode, @RequestParam(required = false) Boolean exZero,
|
|
|
|
+ @RequestParam(required = false) Integer count, @RequestParam(required = false) Integer score) {
|
|
|
|
+ List<ExportExcelDto> ret = new ArrayList<>();
|
|
|
|
+ List<QuestionEntity> qs = questionService.findByExamIdAndSubject(examId, subjectCode);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(qs)) {
|
|
|
|
+
|
|
|
|
+ for (QuestionEntity q : qs) {
|
|
|
|
+ List<StudentScoreEntity> scores = studentScoreService.findBy(q.getId(), exZero, count, score);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(scores)) {
|
|
|
|
+ ExportExcelDto dto = new ExportExcelDto();
|
|
|
|
+ ret.add(dto);
|
|
|
|
+ double[] a = new double[scores.size()];
|
|
|
|
+ double[] b = new double[scores.size()];
|
|
|
|
+ int i = 0;
|
|
|
|
+ for (StudentScoreEntity s : scores) {
|
|
|
|
+ a[i] = s.getAiScore();
|
|
|
|
+ b[i] = s.getMarkingScore();
|
|
|
|
+ i++;
|
|
|
|
+ }
|
|
|
|
+ dto.setExamId(q.getExamId() + "");
|
|
|
|
+ dto.setXgxs(new BigDecimal(Calculator.correlation(a, b)).setScale(2, BigDecimal.ROUND_HALF_UP)
|
|
|
|
+ .doubleValue() + "");
|
|
|
|
+ double avg1 = new BigDecimal(Calculator.mean(a)).setScale(2, BigDecimal.ROUND_HALF_UP)
|
|
|
|
+ .doubleValue();
|
|
|
|
+ dto.setAiAvg(avg1 + "");
|
|
|
|
+ double avg2 = new BigDecimal(Calculator.mean(b)).setScale(2, BigDecimal.ROUND_HALF_UP)
|
|
|
|
+ .doubleValue();
|
|
|
|
+ dto.setSubjectCode(q.getSubjectCode());
|
|
|
|
+ dto.setMarkingAvg(avg2 + "");
|
|
|
|
+ dto.setSubjectName(q.getSubjectName());
|
|
|
|
+ dto.setQuestionTitle(q.getTitle());
|
|
|
|
+ dto.setQuetionNum(q.getMainNumber() + "-" + q.getSubNumber());
|
|
|
|
+ dto.setFullScore(q.getFullScore().toString());
|
|
|
|
+ dto.setTotalCount(scores.size() + "");
|
|
|
|
+ dto.setValidCount(scores.size() + "");
|
|
|
|
+ double avgdiff = Calculator.subtract(avg1, avg2, 2);
|
|
|
|
+ if (avgdiff < 0) {
|
|
|
|
+ avgdiff = 0 - avgdiff;
|
|
|
|
+ }
|
|
|
|
+ dto.setAvgDiff(avgdiff + "");
|
|
|
|
+ fill(scores, dto, q.getFullScore(), score);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ ExportUtils.exportExcel("机评数据", ExportExcelDto.class, ret, response);
|
|
|
|
+ }
|
|
|
|
+
|
|
@ApiOperation(value = "分析数据")
|
|
@ApiOperation(value = "分析数据")
|
|
@RequestMapping(value = "fenxi", method = RequestMethod.GET)
|
|
@RequestMapping(value = "fenxi", method = RequestMethod.GET)
|
|
public void fenxi(HttpServletResponse response, @RequestParam Long examId,
|
|
public void fenxi(HttpServletResponse response, @RequestParam Long examId,
|
|
@@ -119,6 +172,52 @@ public class AdminController {
|
|
returnJson(sb.toString(), response);
|
|
returnJson(sb.toString(), response);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void fill(List<StudentScoreEntity> scores, ExportExcelDto dto, Double questionScore, Integer score) {
|
|
|
|
+ int total = scores.size();
|
|
|
|
+ int st = 0;
|
|
|
|
+ Map<DataKey, Integer> ret = new HashMap<>();
|
|
|
|
+ for (StudentScoreEntity s : scores) {
|
|
|
|
+ DataKey k = getKey(s.getAiScore() - s.getMarkingScore());
|
|
|
|
+ Integer tem = ret.get(k);
|
|
|
|
+ if (tem == null) {
|
|
|
|
+ tem = 0;
|
|
|
|
+ }
|
|
|
|
+ ret.put(k, tem + 1);
|
|
|
|
+ }
|
|
|
|
+ List<DataKey> ks = new ArrayList<>(ret.keySet());
|
|
|
|
+ ks.sort(new Comparator<DataKey>() {
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public int compare(DataKey o1, DataKey o2) {
|
|
|
|
+ int c1 = o1.getIndex();
|
|
|
|
+ int c2 = o2.getIndex();
|
|
|
|
+ if (c1 < c2) {
|
|
|
|
+ return -1;
|
|
|
|
+ } else if (c1 > c2) {
|
|
|
|
+ return 1;
|
|
|
|
+ } else {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ double roundedValue = Math.round(questionScore * 0.3);
|
|
|
|
+ if (score != null) {
|
|
|
|
+ roundedValue = score;
|
|
|
|
+ }
|
|
|
|
+ dto.setSameScoreRange(roundedValue + "");
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
|
+ for (DataKey k : ks) {
|
|
|
|
+ Integer c = ret.get(k);
|
|
|
|
+ if (k.getIndex() < roundedValue) {
|
|
|
|
+ st = st + c;
|
|
|
|
+ }
|
|
|
|
+ sb.append(" " + k.getKey() + " " + c + " " + Calculator.percentage(c, total, 2) + " \r\n");
|
|
|
|
+ }
|
|
|
|
+ dto.setSame(Calculator.percentage(st, total, 2));
|
|
|
|
+ dto.setSameCount(st + "");
|
|
|
|
+ dto.setSameDesc(sb.toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
private void fill(List<StudentScoreEntity> scores, StringBuilder sb, Double questionScore, Integer score) {
|
|
private void fill(List<StudentScoreEntity> scores, StringBuilder sb, Double questionScore, Integer score) {
|
|
int total = scores.size();
|
|
int total = scores.size();
|
|
int st = 0;
|
|
int st = 0;
|