From 4de1e30a99be17342bd819e5f4337069980e8a47 Mon Sep 17 00:00:00 2001 From: "huan.xu" <275942173@qq.com> Date: Mon, 18 May 2020 18:01:34 +0800 Subject: [PATCH] =?UTF-8?q?loading=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TeachingGradeController.java | 69 +++++++++---------- .../yyyf/service/AssessUserTargetService.java | 3 + .../impl/AssessUserTargetServiceImpl.java | 6 ++ 3 files changed, 43 insertions(+), 35 deletions(-) diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/TeachingGradeController.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/TeachingGradeController.java index 7eb9154..1627172 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/TeachingGradeController.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/TeachingGradeController.java @@ -5,8 +5,8 @@ import com.blockchain.common.base.constant.YyyfConstant; import com.blockchain.server.train.dto.ExamPaperDto; import com.blockchain.server.train.dto.TrainCaseTargetDto; import com.blockchain.server.yyyf.dto.PractiseProDto; +import com.blockchain.server.yyyf.dto.StudentTargetErrorStatisticsDto; import com.blockchain.server.yyyf.entity.AssessUser; -import com.blockchain.server.yyyf.entity.AssessUserTarget; import com.blockchain.server.yyyf.service.AssessUserService; import com.blockchain.server.yyyf.service.AssessUserTargetService; import com.blockchain.server.yyyf.utils.ResponseUtils; @@ -87,16 +87,15 @@ public class TeachingGradeController { try { int answerCount= assessUserService.selectCountByByIssueId(issueId); + //获取案例信息 + HashOperations examPaperOpsForHash = redisTemplate.opsForHash(); + ExamPaperDto examPaperDto = examPaperOpsForHash.get(YyyfConstant.EXAM_PAPER_KEY, projectId); + List trainCaseTargeList = examPaperDto.getTrainCaseTargeList(); Map wrongStatistics = null;//错误信息 //无人考试 时封装错误率 if (answerCount==0) { - //获取案例信息 - HashOperations examPaperOpsForHash = redisTemplate.opsForHash(); - ExamPaperDto examPaperDto = examPaperOpsForHash.get(YyyfConstant.EXAM_PAPER_KEY, projectId); - List trainCaseTargeList = examPaperDto.getTrainCaseTargeList(); - wrongStatistics = new HashMap<>(); Map maxErrorRateInfo = new HashMap<>();//最大错误率信息记录 @@ -129,7 +128,7 @@ public class TeachingGradeController { wrongStatistics.put("errorRates", errorRates); } else { - wrongStatistics = getWrongStatistics(issueId, totalNum - answerCount); + wrongStatistics = getWrongStatistics(issueId, totalNum, trainCaseTargeList); } @@ -151,43 +150,43 @@ public class TeachingGradeController { * @author huan.xu * @date 2019-11-08 18:27:22 **/ - private Map getWrongStatistics(String issueId, Integer notExamNum) { + private Map getWrongStatistics(String issueId, Integer totalNum,List trainCaseTargeList) { Map wrongStatistics = new HashMap(); - List list = this.assessUserTargetService.selectAllStudentAssessUserTargetByIssueId(issueId); + List studentTargetErrorStatisticsDtoLis = this.assessUserTargetService.getStudentTargetErrorStatisticsDtoListByIssueId(issueId); -/* Map maxErrorRateInfo = null;//最大错误率信息记录 Map minErrorRateInfo = null;//最小错误率信息记录 //记录考核点名称 - String[] taskNames = new String[taskList.size()]; + String[] taskNames = new String[trainCaseTargeList.size()]; //记录错误率 - double[] errorRates = new double[taskList.size()]; - for (int i = 0; i < taskList.size(); i++) { - Map task = taskList.get(i); - taskNames[i] = task.get("taskName").toString(); - *//*Map con = new HashMap(); - con.put("issueId", issueId); - con.put("classId", classId); - con.put("appTaskId", task.get("appTaskId"));*//* + double[] errorRates = new double[trainCaseTargeList.size()]; + + + + int i=0; + for (TrainCaseTargetDto trainCaseTargetDto:trainCaseTargeList) { + String targetName = trainCaseTargetDto.getName(); + taskNames[i]=targetName ; + //获取该考核点用户的答题情况 List> userTasks = new ArrayList>(); - userTasks = userTasksMap.get(task.get("appTaskId")); - int errorCount = notExamNum;//错误人数 - for (Map userTask : userTasks) { + int errorCount = 0;//错误人数 + for (StudentTargetErrorStatisticsDto studentTargetErrorStatisticsDto:studentTargetErrorStatisticsDtoLis) { //答题错误记录人数 - if (Integer.valueOf(userTask.get("answer").toString()) == 1) { - errorCount++; - } + if(studentTargetErrorStatisticsDto.getTargetId().equals(trainCaseTargetDto.getId())){ + errorCount++; + break; + } } - int totalNum = userTasks.size() + notExamNum; + double errorRate = (double) (errorCount) / (double) (totalNum) * 100;//计算错误率 errorRate = Double.valueOf(String.format("%.2f", errorRate));//四舍五入保留两位小数 errorRates[i] = errorRate; //处理最大和最小错误率信息 if (maxErrorRateInfo == null) { maxErrorRateInfo = new HashMap(); - maxErrorRateInfo.put("projectName", task.get("projectName").toString()); - maxErrorRateInfo.put("taskName", task.get("taskName").toString()); + maxErrorRateInfo.put("projectName", targetName); + maxErrorRateInfo.put("taskName", targetName); maxErrorRateInfo.put("headCount", totalNum); maxErrorRateInfo.put("errorCount", errorCount); maxErrorRateInfo.put("errorRate", errorRate); @@ -196,8 +195,8 @@ public class TeachingGradeController { double prevMaxErrorRate = Double.valueOf(maxErrorRateInfo.get("errorRate").toString()); if (errorRate > prevMaxErrorRate) { //本次错误率大于上次,则记录本次信息 - maxErrorRateInfo.put("projectName", task.get("projectName").toString()); - maxErrorRateInfo.put("taskName", task.get("taskName").toString()); + maxErrorRateInfo.put("projectName", targetName); + maxErrorRateInfo.put("taskName",targetName); maxErrorRateInfo.put("headCount", totalNum); maxErrorRateInfo.put("errorCount", errorCount); maxErrorRateInfo.put("errorRate", errorRate); @@ -205,8 +204,8 @@ public class TeachingGradeController { } if (minErrorRateInfo == null) { minErrorRateInfo = new HashMap(); - minErrorRateInfo.put("projectName", task.get("projectName").toString()); - minErrorRateInfo.put("taskName", task.get("taskName").toString()); + minErrorRateInfo.put("projectName", targetName); + minErrorRateInfo.put("taskName",targetName); minErrorRateInfo.put("headCount", totalNum); minErrorRateInfo.put("errorCount", errorCount); minErrorRateInfo.put("errorRate", errorRate); @@ -215,8 +214,8 @@ public class TeachingGradeController { double prevMinErrorRate = Double.valueOf(minErrorRateInfo.get("errorRate").toString()); if (prevMinErrorRate > errorRate) { //本次错误率小于上次最小错误率,则记录本次信息 - minErrorRateInfo.put("projectName", task.get("projectName").toString()); - minErrorRateInfo.put("taskName", task.get("taskName").toString()); + minErrorRateInfo.put("projectName",targetName); + minErrorRateInfo.put("taskName", targetName); minErrorRateInfo.put("headCount", totalNum); minErrorRateInfo.put("errorCount", errorCount); minErrorRateInfo.put("errorRate", errorRate); @@ -226,7 +225,7 @@ public class TeachingGradeController { wrongStatistics.put("maxErrorRateInfo", maxErrorRateInfo); wrongStatistics.put("minErrorRateInfo", minErrorRateInfo); wrongStatistics.put("taskNames", taskNames); - wrongStatistics.put("errorRates", errorRates);*/ + wrongStatistics.put("errorRates", errorRates); return wrongStatistics; } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTargetService.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTargetService.java index c876774..07e27f9 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTargetService.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTargetService.java @@ -1,5 +1,6 @@ package com.blockchain.server.yyyf.service; +import com.blockchain.server.yyyf.dto.StudentTargetErrorStatisticsDto; import com.blockchain.server.yyyf.entity.AssessUserTarget; import java.util.List; @@ -29,4 +30,6 @@ public interface AssessUserTargetService{ List selectAllStudentAssessUserTargetByIssueId(String issueId); + + List getStudentTargetErrorStatisticsDtoListByIssueId(String issueId); } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserTargetServiceImpl.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserTargetServiceImpl.java index 79b418c..b7dff30 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserTargetServiceImpl.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserTargetServiceImpl.java @@ -1,5 +1,6 @@ package com.blockchain.server.yyyf.service.impl; +import com.blockchain.server.yyyf.dto.StudentTargetErrorStatisticsDto; import com.blockchain.server.yyyf.entity.AssessUserTarget; import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper; import com.blockchain.server.yyyf.service.AssessUserTargetService; @@ -48,4 +49,9 @@ public class AssessUserTargetServiceImpl implements AssessUserTargetService { return this.assessUserTargetMapper.selectAllStudentAssessUserTargetByIssueId(issueId); } + @Override + public List getStudentTargetErrorStatisticsDtoListByIssueId(String issueId) { + return this.assessUserTargetMapper.getStudentTargetErrorStatisticsDtoListByIssueId(issueId); + } + } \ No newline at end of file