diff --git a/web/src/main/java/com/ibeetl/jlw/constants/TeacherOpenCourseScoreDashboardConstant.java b/web/src/main/java/com/ibeetl/jlw/constants/TeacherOpenCourseScoreDashboardConstant.java index ecb791ce..138ca370 100644 --- a/web/src/main/java/com/ibeetl/jlw/constants/TeacherOpenCourseScoreDashboardConstant.java +++ b/web/src/main/java/com/ibeetl/jlw/constants/TeacherOpenCourseScoreDashboardConstant.java @@ -7,4 +7,7 @@ package com.ibeetl.jlw.constants; * @date 2023/05/16 04:27:05 */ public class TeacherOpenCourseScoreDashboardConstant { + public static final String STUDENT_ASK_MAX_SCORE = "30"; + public static final String DISCUSS_MAX_SCORE = "30"; + } diff --git a/web/src/main/java/com/ibeetl/jlw/service/StudentHandsOnTaskReportService.java b/web/src/main/java/com/ibeetl/jlw/service/StudentHandsOnTaskReportService.java index 7434943d..fc6eab88 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/StudentHandsOnTaskReportService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/StudentHandsOnTaskReportService.java @@ -254,6 +254,7 @@ public class StudentHandsOnTaskReportService extends CoreBaseService list = studentHandsOnTaskReportDao.getValuesByQuery(studentHandsOnTaskReportQuery); + if (null != list && list.size() > 0) { return list.get(0); } else { diff --git a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseScoreDashboardService.java b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseScoreDashboardService.java index 805474f5..df59c26f 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseScoreDashboardService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseScoreDashboardService.java @@ -14,6 +14,7 @@ import com.ibeetl.admin.core.util.PlatformException; import com.ibeetl.admin.core.util.TimeTool; import com.ibeetl.admin.core.web.JsonResult; import com.ibeetl.admin.core.web.JsonReturnCode; +import com.ibeetl.jlw.constants.TeacherOpenCourseScoreDashboardConstant; import com.ibeetl.jlw.dao.*; import com.ibeetl.jlw.entity.*; import com.ibeetl.jlw.enums.ChatLogSendTypeEnum; @@ -75,7 +76,7 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService queryByCondition(PageQuery query) { PageQuery ret = teacherOpenCourseScoreDashboardDao.queryByCondition(query); @@ -451,6 +455,62 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService teacherOpenCourseChatLogList = teacherOpenCourseChatLogService.queryObjectList(teacherOpenCourseChatLog); + + //查询章节练习配置 + List chapterExerciseList = teacherOpenCourseQuestionSettingDao.createLambdaQuery() + .andEq(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseId, teacherOpenCourseId) + .andEq(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingType, ResourcesQuestionSnapshotFromTypeEnum.CHAPTER_EXERCISE) + .andEq(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingStatus, 1).select(); + + + //查询本课程的所有实操任务 + TeacherOpenCourseHandsOn param = new TeacherOpenCourseHandsOn(); + param.setTeacherOpenCourseId(teacherOpenCourseId); + List handsOnList = teacherOpenCourseHandsOnService.queryObjectList(param); + + //查询本课程的所有实操任务子项 + List teacherOpenCourseHandsOnSimulationTasksList = null; + List handOnIdList = null; + if (CollectionUtil.isNotEmpty(handsOnList)) { + handOnIdList = handsOnList.stream().map(TeacherOpenCourseHandsOn::getHandsOnId).collect(Collectors.toList()); + + TeacherOpenCourseHandsOnSimulationTasks query = new TeacherOpenCourseHandsOnSimulationTasks(); + query.setTeacherOpenCourseId(teacherOpenCourseId); + teacherOpenCourseHandsOnSimulationTasksList = teacherOpenCourseHandsOnSimulationTasksService.queryObjectList(query); + } + if (CollectionUtil.isEmpty(teacherOpenCourseHandsOnSimulationTasksList)) { + teacherOpenCourseHandsOnSimulationTasksList = new ArrayList<>(); + } + if (CollectionUtil.isEmpty(handOnIdList)) { + handOnIdList = new ArrayList<>(); + } + + //查该课程的所有作业 + List homeworkList = teacherOpenCourseQuestionSettingDao.createLambdaQuery() + .andEq(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseId, teacherOpenCourseId) + .andEq(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingStatus, 1) + .andIn(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingType, Arrays.asList(ResourcesQuestionSnapshotFromTypeEnum.HOMEWORK_QUESTION, ResourcesQuestionSnapshotFromTypeEnum.HOMEWORK_FILE)) + .select(); + + //查该课程的所有考试 + List examList = teacherOpenCourseQuestionSettingDao.createLambdaQuery() + .andEq(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseId, teacherOpenCourseId) + .andEq(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingStatus, 1) + .andEq(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingType, ResourcesQuestionSnapshotFromTypeEnum.EXAM).select(); + + //查询权重 TeacherOpenCourseScoreWeight weight = weightDao.single(teacherOpenCourseId); TeacherOpenCourseMergeStudentQuery studentQuery = new TeacherOpenCourseMergeStudentQuery(); @@ -459,23 +519,48 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService students = mergeStudentDao.getValuesByQueryNotWithPermission(studentQuery); - List studentScores = new ArrayList<>(); - //班次数 for (TeacherOpenCourseMergeStudent teacherOpenCourseMergeStudent : students) { Long studentId = teacherOpenCourseMergeStudent.getStudentId(); - //通过id查询学生 Student student = studentService.queryById(studentId); + TeacherOpenCourseScoreDashboard teacherOpenCourseScoreDashboard = teacherOpenCourseScoreDashboardDao.createLambdaQuery() + .andEq(TeacherOpenCourseScoreDashboard::getTeacherOpenCourseId, teacherOpenCourseId) + .andEq(TeacherOpenCourseScoreDashboard::getStudentId, studentId) + .singleSimple(); + if (teacherOpenCourseScoreDashboard == null) { + teacherOpenCourseScoreDashboard = new TeacherOpenCourseScoreDashboard(); + teacherOpenCourseScoreDashboard.setTeacherOpenCourseId(teacherOpenCourseId); + teacherOpenCourseScoreDashboard.setStudentId(studentId); + teacherOpenCourseScoreDashboard.setOrgId(student.getOrgId()); + teacherOpenCourseScoreDashboard.setStudentSn(student.getStudentSn()); + teacherOpenCourseScoreDashboard.setStudentName(student.getStudentName()); + teacherOpenCourseScoreDashboard.setExamScore(BigDecimal.ZERO); + teacherOpenCourseScoreDashboard.setCourseScore(BigDecimal.ZERO); + teacherOpenCourseScoreDashboard.setChatScore(BigDecimal.ZERO); + teacherOpenCourseScoreDashboard.setSigninScore(BigDecimal.ZERO); + teacherOpenCourseScoreDashboard.setRealOperationScore(BigDecimal.ZERO); + teacherOpenCourseScoreDashboard.setQuestionHomeworkScore(BigDecimal.ZERO); + teacherOpenCourseScoreDashboard.setTotalScore(BigDecimal.ZERO); + teacherOpenCourseScoreDashboard.setManualScore(BigDecimal.ZERO); + teacherOpenCourseScoreDashboard.setUserId(student.getUserId()); + teacherOpenCourseScoreDashboard.setCreateTime(now); + teacherOpenCourseScoreDashboardDao.insert(teacherOpenCourseScoreDashboard); + } + + if (teacherOpenCourseScoreDashboard.getTeacherOpenCourseScoreDashboardId() == null) { + log.error("teacherOpenCourseScoreDashboard.getTeacherOpenCourseScoreDashboardId()为空,studentId:{},openCourseId:{}", studentId, teacherOpenCourseId); + continue; + } + if (student == null) { log.error("学生不存在,studentId={}", studentId); continue; } TeacherOpenCourseScoreDashboard scoreDashboard = new TeacherOpenCourseScoreDashboard(); - scoreDashboard.setStudentId(studentId); - scoreDashboard.setTeacherOpenCourseId(teacherOpenCourseId); + scoreDashboard.setTeacherOpenCourseScoreDashboardId(teacherOpenCourseScoreDashboard.getTeacherOpenCourseScoreDashboardId()); //签到成绩 { @@ -522,17 +607,11 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService chapterExerciseList = teacherOpenCourseQuestionSettingDao.createLambdaQuery() - .andEq(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseId, teacherOpenCourseId) - .andEq(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingType, ResourcesQuestionSnapshotFromTypeEnum.CHAPTER_EXERCISE) - .andEq(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingStatus, 1).select(); - if (!CollectionUtil.isEmpty(chapterExerciseList)) { List teacherOpenCourseQuestionSettingIdList = chapterExerciseList.stream().map(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingId).collect(Collectors.toList()); //查询章节练习成绩 - List questionLogSummaryList = questionLogSummaryService.createLambdaQuery() + List questionLogSummaryList = questionLogSummaryDao.createLambdaQuery() .andEq(QuestionLogSummary::getPersonId, studentId) .andEq(QuestionLogSummary::getQuestionLogSummaryStatus, 1) .andIn(QuestionLogSummary::getQuestionSettingId, teacherOpenCourseQuestionSettingIdList).select(); @@ -555,13 +634,15 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService> teacherOpenCourseHandsOnSimulationTasksMap = teacherOpenCourseHandsOnSimulationTasksList.stream().collect(Collectors.groupingBy(TeacherOpenCourseHandsOnSimulationTasks::getHandsOnId)); + List studentHandsOnTaskVideoList = videoDao.createLambdaQuery() + .andEq(StudentHandsOnTaskVideo::getTeacherOpenCourseId, teacherOpenCourseId) + .andEq(StudentHandsOnTaskVideo::getStudentId, studentId).select(); - List handsOnList = teacherOpenCourseHandsOnService.queryObjectList(param); + Map> studentHandsOnTaskVideoMap = studentHandsOnTaskVideoList.stream().collect(Collectors.groupingBy(StudentHandsOnTaskVideo::getHandsOnTaskId)); - if (CollectionUtil.isNotEmpty(handsOnList)) { + List studentHandsOnTaskPptList = pptDao.createLambdaQuery() + .andEq(StudentHandsOnTaskPpt::getTeacherOpenCourseId, teacherOpenCourseId) + .andEq(StudentHandsOnTaskPpt::getStudentId, studentId).select(); - List handOnIdList = handsOnList.stream().map(TeacherOpenCourseHandsOn::getHandsOnId).collect(Collectors.toList()); + Map> studentHandsOnTaskPptMap = studentHandsOnTaskPptList.stream().collect(Collectors.groupingBy(StudentHandsOnTaskPpt::getHandsOnTaskId)); - //查询本课程的所有实操任务子项 - TeacherOpenCourseHandsOnSimulationTasks query = new TeacherOpenCourseHandsOnSimulationTasks(); - param.setTeacherOpenCourseId(teacherOpenCourseId); - List teacherOpenCourseHandsOnSimulationTasksList = teacherOpenCourseHandsOnSimulationTasksService.queryObjectList(query); + List studentHandsOnTaskStepList = stepDao.createLambdaQuery() + .andEq(StudentHandsOnTaskStep::getTeacherOpenCourseId, teacherOpenCourseId) + .andEq(StudentHandsOnTaskStep::getStudentId, studentId).select(); - if (CollectionUtil.isNotEmpty(teacherOpenCourseHandsOnSimulationTasksList)) { + Map> studentHandsOnTaskStepMap = studentHandsOnTaskStepList.stream().collect(Collectors.groupingBy(StudentHandsOnTaskStep::getHandsOnTaskId)); - Map> teacherOpenCourseHandsOnSimulationTasksMap = teacherOpenCourseHandsOnSimulationTasksList.stream().collect(Collectors.groupingBy(TeacherOpenCourseHandsOnSimulationTasks::getHandsOnId)); + List studentHandsOnTaskReportList = reportDao.createLambdaQuery() + .andEq(StudentHandsOnTaskReport::getTeacherOpenCourseId, teacherOpenCourseId) + .andEq(StudentHandsOnTaskReport::getStudentId, studentId).select(); - List studentHandsOnTaskVideoList = videoDao.createLambdaQuery() - .andEq(StudentHandsOnTaskVideo::getTeacherOpenCourseId, teacherOpenCourseId) - .andEq(StudentHandsOnTaskVideo::getStudentId, studentId).select(); + Map> studentHandsOnTaskReportMap = studentHandsOnTaskReportList.stream().collect(Collectors.groupingBy(StudentHandsOnTaskReport::getHandsOnTaskId)); - Map> studentHandsOnTaskVideoMap = studentHandsOnTaskVideoList.stream().collect(Collectors.groupingBy(StudentHandsOnTaskVideo::getHandsOnTaskId)); + List studentHandsOnTaskTheoryList = theoryDao.createLambdaQuery() + .andEq(StudentHandsOnTaskTheory::getTeacherOpenCourseId, teacherOpenCourseId) + .andEq(StudentHandsOnTaskTheory::getStudentId, studentId).select(); - List studentHandsOnTaskPptList = pptDao.createLambdaQuery() - .andEq(StudentHandsOnTaskPpt::getTeacherOpenCourseId, teacherOpenCourseId) - .andEq(StudentHandsOnTaskPpt::getStudentId, studentId).select(); + Map> studentHandsOnTaskTheoryMap = studentHandsOnTaskTheoryList.stream().collect(Collectors.groupingBy(StudentHandsOnTaskTheory::getHandsOnTaskId)); - Map> studentHandsOnTaskPptMap = studentHandsOnTaskPptList.stream().collect(Collectors.groupingBy(StudentHandsOnTaskPpt::getHandsOnTaskId)); - - List studentHandsOnTaskStepList = stepDao.createLambdaQuery() - .andEq(StudentHandsOnTaskStep::getTeacherOpenCourseId, teacherOpenCourseId) - .andEq(StudentHandsOnTaskStep::getStudentId, studentId).select(); - - Map> studentHandsOnTaskStepMap = studentHandsOnTaskStepList.stream().collect(Collectors.groupingBy(StudentHandsOnTaskStep::getHandsOnTaskId)); - - List studentHandsOnTaskReportList = reportDao.createLambdaQuery() - .andEq(StudentHandsOnTaskReport::getTeacherOpenCourseId, teacherOpenCourseId) - .andEq(StudentHandsOnTaskReport::getStudentId, studentId).select(); - - Map> studentHandsOnTaskReportMap = studentHandsOnTaskReportList.stream().collect(Collectors.groupingBy(StudentHandsOnTaskReport::getHandsOnTaskId)); - - List studentHandsOnTaskTheoryList = theoryDao.createLambdaQuery() - .andEq(StudentHandsOnTaskTheory::getTeacherOpenCourseId, teacherOpenCourseId) - .andEq(StudentHandsOnTaskTheory::getStudentId, studentId).select(); - - Map> studentHandsOnTaskTheoryMap = studentHandsOnTaskTheoryList.stream().collect(Collectors.groupingBy(StudentHandsOnTaskTheory::getHandsOnTaskId)); + //1平均分2平均完成进度 + if (weight == null || "1".equals(weight.getCoursePracticeResultSetting())) { + BigDecimal allHandOnScore = BigDecimal.ZERO; - //1平均分2平均完成进度 - if (weight == null || "1".equals(weight.getCoursePracticeResultSetting())) { - BigDecimal allHandOnScore = BigDecimal.ZERO; + for (Long handOnId : handOnIdList) { - for (Long handOnId : handOnIdList) { + //获取这个实操任务的所有子项,并算出总分 + List list = teacherOpenCourseHandsOnSimulationTasksMap.get(handOnId); - //获取这个实操任务的所有子项,并算出总分 - List list = teacherOpenCourseHandsOnSimulationTasksMap.get(handOnId); + if (CollectionUtil.isEmpty(list)) { + continue; + } + BigDecimal handOnTaskScoreSum = BigDecimal.ZERO; + for (TeacherOpenCourseHandsOnSimulationTasks item : list) { + BigDecimal taskScore = new BigDecimal(ObjectUtil.defaultIfBlank(item.getTaskScore(), "0")); + handOnTaskScoreSum = handOnTaskScoreSum.add(taskScore); + } - if (CollectionUtil.isEmpty(list)) { - continue; - } - BigDecimal handOnTaskScoreSum = BigDecimal.ZERO; - for (TeacherOpenCourseHandsOnSimulationTasks item : list) { - BigDecimal taskScore = new BigDecimal(ObjectUtil.defaultIfBlank(item.getTaskScore(), "0")); - handOnTaskScoreSum = handOnTaskScoreSum.add(taskScore); + //得到这个学生的分数,一个学生一个实操任务只有一条记录 + HandsOnAchievement handsOnAchievement = new HandsOnAchievement(); + handsOnAchievement.setHandOnId(handOnId); + handsOnAchievement.setStudentId(studentId); + handsOnAchievement.setHandOnAchievementStatus(1); + HandsOnAchievement handsOnAchievementRes = handsOnAchievementService.queryObject(handsOnAchievement); + if (handsOnAchievementRes != null) { + String totalScore = handsOnAchievementRes.getTotalScore(); + if (StringUtils.isNotBlank(totalScore)) { + //转换为百分制 + BigDecimal formatScore = new BigDecimal(totalScore).multiply(new BigDecimal(100)).divide(handOnTaskScoreSum, 1, RoundingMode.HALF_UP); + allHandOnScore = allHandOnScore.add(formatScore); } + } + } + BigDecimal avgScore = allHandOnScore.divide(new BigDecimal(handOnIdList.size()), 1, RoundingMode.HALF_UP); + scoreDashboard.setRealOperationScore(avgScore); + } else if ("2".equals(weight.getCoursePracticeResultSetting())) { - //得到这个学生的分数,一个学生一个实操任务只有一条记录 - HandsOnAchievement handsOnAchievement = new HandsOnAchievement(); - handsOnAchievement.setHandOnId(handOnId); - handsOnAchievement.setStudentId(studentId); - handsOnAchievement.setHandOnAchievementStatus(1); - HandsOnAchievement handsOnAchievementRes = handsOnAchievementService.queryObject(handsOnAchievement); - if (handsOnAchievementRes != null) { - String totalScore = handsOnAchievementRes.getTotalScore(); - if (StringUtils.isNotBlank(totalScore)) { - //转换为百分制 - BigDecimal formatScore = new BigDecimal(totalScore).multiply(new BigDecimal(100)).divide(handOnTaskScoreSum, 1, RoundingMode.HALF_UP); - allHandOnScore = allHandOnScore.add(formatScore); + BigDecimal allDoStepSuccessProportion = BigDecimal.ZERO; + for (Long handOnId : handOnIdList) { + //获取这个实操任务的所有子项 + List list = teacherOpenCourseHandsOnSimulationTasksMap.get(handOnId); + + if (CollectionUtil.isNotEmpty(list)) { + //得出这个实操任务的完成率 + int doStepTimes = 0; + for (TeacherOpenCourseHandsOnSimulationTasks task : list) { + if (studentHandsOnTaskVideoMap.containsKey(task.getTaskId()) + || studentHandsOnTaskPptMap.containsKey(task.getTaskId()) + || studentHandsOnTaskStepMap.containsKey(task.getTaskId()) + || studentHandsOnTaskReportMap.containsKey(task.getTaskId()) + || studentHandsOnTaskTheoryMap.containsKey(task.getTaskId())) { + doStepTimes++; } } - } - BigDecimal avgScore = allHandOnScore.divide(new BigDecimal(handOnIdList.size()), 1, RoundingMode.HALF_UP); - scoreDashboard.setRealOperationScore(avgScore); - } else if ("2".equals(weight.getCoursePracticeResultSetting())) { - - BigDecimal allDoStepSuccessProportion = BigDecimal.ZERO; - for (Long handOnId : handOnIdList) { - //获取这个实操任务的所有子项 - List list = teacherOpenCourseHandsOnSimulationTasksMap.get(handOnId); - - if (CollectionUtil.isNotEmpty(list)) { - //得出这个实操任务的完成率 - int doStepTimes = 0; - for (TeacherOpenCourseHandsOnSimulationTasks task : list) { - if (studentHandsOnTaskVideoMap.containsKey(task.getTaskId()) - || studentHandsOnTaskPptMap.containsKey(task.getTaskId()) - || studentHandsOnTaskStepMap.containsKey(task.getTaskId()) - || studentHandsOnTaskReportMap.containsKey(task.getTaskId()) - || studentHandsOnTaskTheoryMap.containsKey(task.getTaskId())) { - doStepTimes++; - } - } - //计算完成率 - BigDecimal divide = new BigDecimal(doStepTimes).divide(new BigDecimal(list.size()), 5, RoundingMode.HALF_UP); - if (divide.compareTo(BigDecimal.ONE) > 0) { - divide = BigDecimal.ONE; - } - allDoStepSuccessProportion = allDoStepSuccessProportion.add(divide); + //计算完成率 + BigDecimal divide = new BigDecimal(doStepTimes).divide(new BigDecimal(list.size()), 5, RoundingMode.HALF_UP); + if (divide.compareTo(BigDecimal.ONE) > 0) { + divide = BigDecimal.ONE; } + allDoStepSuccessProportion = allDoStepSuccessProportion.add(divide); } - //计算平均完成率并乘以100得出分数 - BigDecimal avgScore = allDoStepSuccessProportion.multiply(new BigDecimal(100)).divide(new BigDecimal(handOnIdList.size()), 1, RoundingMode.HALF_UP); - scoreDashboard.setRealOperationScore(avgScore); } + //计算平均完成率并乘以100得出分数 + BigDecimal avgScore = allDoStepSuccessProportion.multiply(new BigDecimal(100)).divide(new BigDecimal(handOnIdList.size()), 1, RoundingMode.HALF_UP); + scoreDashboard.setRealOperationScore(avgScore); } } } @@ -704,32 +766,39 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService select2 = teacherOpenCourseQuestionSettingDao.createLambdaQuery() - .andEq(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseId, teacherOpenCourseId) - .andEq(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingType, ResourcesQuestionSnapshotFromTypeEnum.HOMEWORK_QUESTION).select(); - if (CollectionUtil.isEmpty(select2)) { - scoreDashboard.setQuestionHomeworkScore(BigDecimal.ZERO); - } else { - List collect = select2.stream().map(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingId).collect(Collectors.toList()); - List select1 = questionLogSummaryService.createLambdaQuery() + //查询题目类型作业和文件类型作业 + scoreDashboard.setQuestionHomeworkScore(BigDecimal.ZERO); + + if (!CollectionUtil.isEmpty(homeworkList)) { + List settingIdList = homeworkList.stream().map(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingId).collect(Collectors.toList()); + List questionLogSummaryList = questionLogSummaryDao.createLambdaQuery() .andEq(QuestionLogSummary::getPersonId, studentId) - .andIn(QuestionLogSummary::getQuestionSettingId, collect).select(); - if (CollectionUtil.isEmpty(select1)) { - scoreDashboard.setQuestionHomeworkScore(BigDecimal.ZERO); - } else { + .andIn(QuestionLogSummary::getQuestionSettingId, settingIdList) + .andEq(QuestionLogSummary::getQuestionLogSummaryStatus, 1).select(); + if (!CollectionUtil.isEmpty(questionLogSummaryList)) { + Map> questionLogSummaryMap = questionLogSummaryList.stream().collect(Collectors.groupingBy(QuestionLogSummary::getQuestionSettingId)); + BigDecimal b = BigDecimal.ZERO; - for (QuestionLogSummary questionLogSummary : select1) { - b = b.add(questionLogSummary.getQuestionLogSummaryStudentTotalScore()); + for (Map.Entry> entry : questionLogSummaryMap.entrySet()) { + List value = entry.getValue(); + //以防万一有多条记录,取最近的一条 + value.sort(Comparator.comparing(QuestionLogSummary::getQuestionLogSummaryAddTime).reversed()); + QuestionLogSummary questionLogSummary = value.get(0); + + if (ResourcesQuestionSnapshotFromTypeEnum.HOMEWORK_FILE.equals(questionLogSummary.getQuestionSettingType())) { + //文件作业类型 没有最大分数,直接取学生得分 + b = b.add(ObjectUtil.defaultIfNull(questionLogSummary.getQuestionLogSummaryStudentTotalScore(), BigDecimal.ZERO)); + } else { + //题目类型作业 有最大分数,需要转换为百分制 + + BigDecimal questionSettingTotalScore = ObjectUtil.defaultIfNull(questionLogSummary.getQuestionSettingTotalScore(), BigDecimal.valueOf(100)); + BigDecimal questionLogSummaryStudentTotalScore = ObjectUtil.defaultIfNull(questionLogSummary.getQuestionLogSummaryStudentTotalScore(), BigDecimal.ZERO); + //转为百分制 + b = b.add(questionLogSummaryStudentTotalScore.multiply(new BigDecimal(100)).divide(questionSettingTotalScore, 1, RoundingMode.HALF_UP)); + } } + //总分除以总作业数得出平均分 + b = b.divide(new BigDecimal(homeworkList.size()), 1, RoundingMode.HALF_UP); scoreDashboard.setQuestionHomeworkScore(b); } } @@ -737,78 +806,148 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService select3 = teacherOpenCourseQuestionSettingDao.createLambdaQuery() - .andEq(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseId, teacherOpenCourseId) - .andEq(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingType, ResourcesQuestionSnapshotFromTypeEnum.EXAM).select(); - if (CollectionUtil.isEmpty(select3)) { - scoreDashboard.setExamScore(BigDecimal.ZERO); - } else { - if (weight == null || "1".equals(weight.getCoursePracticeResultSetting())) { - List collect = select3.stream().map(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingId).collect(Collectors.toList()); - List select1 = questionLogSummaryService.createLambdaQuery() + scoreDashboard.setExamScore(BigDecimal.ZERO); + + if (!CollectionUtil.isEmpty(examList)) { + if (weight == null || "1".equals(weight.getExaminationResultSetting())) { + List settingIdList = examList.stream().map(TeacherOpenCourseQuestionSetting::getTeacherOpenCourseQuestionSettingId).collect(Collectors.toList()); + //查询学生考试记录 + List questionLogSummaryList = questionLogSummaryDao.createLambdaQuery() .andEq(QuestionLogSummary::getPersonId, studentId) - .andIn(QuestionLogSummary::getQuestionSettingId, collect).select(); - if (CollectionUtil.isEmpty(select1)) { - scoreDashboard.setExamScore(BigDecimal.ZERO); - } else { + .andIn(QuestionLogSummary::getQuestionSettingId, settingIdList) + .andEq(QuestionLogSummary::getQuestionLogSummaryStatus, 1) + .select(); + + if (!CollectionUtil.isEmpty(questionLogSummaryList)) { + Map> questionLogSummaryMap = questionLogSummaryList.stream().collect(Collectors.groupingBy(QuestionLogSummary::getQuestionSettingId)); + BigDecimal b = BigDecimal.ZERO; - for (QuestionLogSummary questionLogSummary : select1) { - b = b.add(questionLogSummary.getQuestionLogSummaryStudentTotalScore()); + for (Map.Entry> entry : questionLogSummaryMap.entrySet()) { + List value = entry.getValue(); + //以防万一有多条记录,取最近的一条 + value.sort(Comparator.comparing(QuestionLogSummary::getQuestionLogSummaryAddTime).reversed()); + QuestionLogSummary questionLogSummary = value.get(0); + BigDecimal questionSettingTotalScore = ObjectUtil.defaultIfNull(questionLogSummary.getQuestionSettingTotalScore(), BigDecimal.valueOf(100)); + BigDecimal questionLogSummaryStudentTotalScore = ObjectUtil.defaultIfNull(questionLogSummary.getQuestionLogSummaryStudentTotalScore(), BigDecimal.ZERO); + //转为百分制 + b = b.add(questionLogSummaryStudentTotalScore.multiply(new BigDecimal(100)).divide(questionSettingTotalScore, 1, RoundingMode.HALF_UP)); + } - scoreDashboard.setExamScore(b); + //总分除以总作业数得出平均分 + b = b.divide(new BigDecimal(examList.size()), 1, RoundingMode.HALF_UP); + scoreDashboard.setQuestionHomeworkScore(b); } } } } - //互动 - List chatLogList = courseChatLogDao.createLambdaQuery() - .andEq(TeacherOpenCourseChatLog::getStudentId, studentId) - .andEq(TeacherOpenCourseChatLog::getTeacherOpenCourseId, teacherOpenCourseId).select(); - //提问次数 - long count = chatLogList.stream().filter(v -> v.getChatLogSendType().equals(ChatLogSendTypeEnum.student_ask) - || v.getChatLogSendType().equals(ChatLogSendTypeEnum.specify_ask)).count(); - //回复次数 - long count2 = chatLogList.stream().filter(v -> - v.getChatLogSendType().equals(ChatLogSendTypeEnum.normal)).count(); - //答题次数 - long count3 = chatLogList.stream().filter(v -> - v.getChatLogSendType().equals(ChatLogSendTypeEnum.normal) - && v.getStudentScore() != null - ).count(); - BigDecimal chatScore = BigDecimal.ZERO; - if (weight != null && StringUtils.isNotEmpty(weight.getInteractionResultSetting())) { - String interactionResultSetting = weight.getInteractionResultSetting(); - if (interactionResultSetting.contains("1")) { - chatScore = NumberUtil.mul(count2, NumberUtil.toBigDecimal(weight.getInteractionResultMessageScore())); - } - if (interactionResultSetting.contains("2")) { - chatScore = NumberUtil.mul(count, NumberUtil.toBigDecimal(weight.getInteractionResultQuestionScore())); - } - if (interactionResultSetting.contains("3")) { - chatScore = NumberUtil.mul(count3, NumberUtil.toBigDecimal(weight.getInteractionResultAnswerScore())); + //互动分数 + { + scoreDashboard.setChatScore(BigDecimal.ZERO); + if (CollectionUtil.isNotEmpty(teacherOpenCourseChatLogList) && weight != null && StringUtils.isNotBlank(weight.getInteractionResultSetting())) { + BigDecimal totalChatScore = BigDecimal.ZERO; + //1留言2提问3回答 + String interactionResultSetting = weight.getInteractionResultSetting(); + + //回答分数处理 + { + if (interactionResultSetting.contains("3")) { + //老师提问该学生 + List teacherAskIds = teacherOpenCourseChatLogList.stream().filter(v -> { + return (ChatLogSendTypeEnum.random_ask.equals(v.getChatLogSendType()) || ChatLogSendTypeEnum.specify_ask.equals(v.getChatLogSendType())) + && ObjectUtil.equals(studentId, v.getStudentId()); + }).map(TeacherOpenCourseChatLog::getTeacherOpenCourseChatLogId).collect(Collectors.toList()); + + if (CollectionUtil.isNotEmpty(teacherAskIds)) { + //学生回答的次数,回答多次也只算一次 + long count = teacherOpenCourseChatLogList.stream().filter(v -> { + return ObjectUtil.equals(studentId, v.getStudentId()) + && teacherAskIds.contains(v.getTeacherOpenCourseChatLogParentId()); + }).map(TeacherOpenCourseChatLog::getTeacherOpenCourseChatLogParentId).distinct().count(); + + + BigDecimal interactionResultAnswerScore = new BigDecimal(ObjectUtil.defaultIfBlank(weight.getInteractionResultAnswerScore(), "0")); + totalChatScore = totalChatScore.add(interactionResultAnswerScore.multiply(new BigDecimal(count))); + } + } + } + + //提问分数处理 + { + if (interactionResultSetting.contains("2")) { + //学生提问老师 + List studentAskIds = teacherOpenCourseChatLogList.stream().filter(v -> { + return ChatLogSendTypeEnum.student_ask.equals(v.getChatLogSendType()) + && ObjectUtil.equals(studentId, v.getStudentId()); + }).map(TeacherOpenCourseChatLog::getTeacherOpenCourseChatLogId).collect(Collectors.toList()); + + long count = studentAskIds.size(); + BigDecimal interactionResultQuestionScore = new BigDecimal(ObjectUtil.defaultIfBlank(weight.getInteractionResultQuestionScore(), "0")); + BigDecimal multiply = interactionResultQuestionScore.multiply(new BigDecimal(count)); + if (multiply.compareTo(new BigDecimal(TeacherOpenCourseScoreDashboardConstant.STUDENT_ASK_MAX_SCORE)) > 0) { + multiply = new BigDecimal(TeacherOpenCourseScoreDashboardConstant.STUDENT_ASK_MAX_SCORE); + } + totalChatScore = totalChatScore.add(multiply); + } + } + + //留言分数处理 + { + if (interactionResultSetting.contains("1")) { + //老师发起的讨论,学生的班级在讨论的班级中 + List discussionIdList = teacherOpenCourseChatLogList.stream().filter(v -> { + return ChatLogSendTypeEnum.discuss.equals(v.getChatLogSendType()) + && ( + StringUtils.isBlank(v.getSchoolClassIds()) + || Arrays.asList(v.getSchoolClassIds().split(",")).contains(student.getClassId().toString()) + ); + }).map(TeacherOpenCourseChatLog::getTeacherOpenCourseChatLogId).collect(Collectors.toList()); + + //学生回复的讨论的次数 + long count = teacherOpenCourseChatLogList.stream().filter(v -> { + return ( + ObjectUtil.equals(studentId, v.getStudentId()) + && ChatLogSendTypeEnum.normal.equals(v.getChatLogSendType()) + && StringUtils.isNotBlank(v.getChatLogFullId()) + && discussionIdList.contains(Long.valueOf(v.getChatLogFullId().split("_")[0])) + ); + }).count(); + BigDecimal interactionResultMessageScore = new BigDecimal(ObjectUtil.defaultIfBlank(weight.getInteractionResultMessageScore(), "0")); + BigDecimal multiply = interactionResultMessageScore.multiply(new BigDecimal(count)); + if (multiply.compareTo(new BigDecimal(TeacherOpenCourseScoreDashboardConstant.DISCUSS_MAX_SCORE)) > 0) { + multiply = new BigDecimal(TeacherOpenCourseScoreDashboardConstant.DISCUSS_MAX_SCORE); + } + totalChatScore = totalChatScore.add(multiply); + } + } + scoreDashboard.setChatScore(totalChatScore); } - } else { - chatScore = BigDecimal.valueOf(count2); } - scoreDashboard.setChatScore(chatScore); - - - BigDecimal totalScore = scoreDashboard.getSigninScore() - .add(scoreDashboard.getCourseScore()) - .add(scoreDashboard.getRealOperationScore()) - .add(scoreDashboard.getQuestionHomeworkScore()) - .add(scoreDashboard.getExamScore()) - .add(scoreDashboard.getChatScore()); - scoreDashboard.setTotalScore(totalScore); - if (weight != null) { - lastStatus(weight, totalScore, scoreDashboard); + + //总分 + { + scoreDashboard.setTotalScore(BigDecimal.ZERO); + if (weight != null) { + BigDecimal totalScore = BigDecimal.ZERO; + BigDecimal formatSignScore = scoreDashboard.getSigninScore().multiply(new BigDecimal(ObjectUtil.defaultIfBlank(weight.getSignInResult(), "0"))); + BigDecimal formatCourseScore = scoreDashboard.getCourseScore().multiply(new BigDecimal(ObjectUtil.defaultIfBlank(weight.getChapterContactResult(), "0"))); + BigDecimal formatRealOperationScore = scoreDashboard.getRealOperationScore().multiply(new BigDecimal(ObjectUtil.defaultIfBlank(weight.getCoursePracticeResult(), "0"))); + BigDecimal formatQuestionHomeworkScore = scoreDashboard.getQuestionHomeworkScore().multiply(new BigDecimal(ObjectUtil.defaultIfBlank(weight.getHomeworkResult(), "0"))); + BigDecimal formatExamScore = scoreDashboard.getExamScore().multiply(new BigDecimal(ObjectUtil.defaultIfBlank(weight.getExaminationResult(), "0"))); + BigDecimal formatChatScore = scoreDashboard.getChatScore().multiply(new BigDecimal(ObjectUtil.defaultIfBlank(weight.getInteractionResult(), "0"))); + totalScore = totalScore.add(formatSignScore).add(formatCourseScore).add(formatRealOperationScore).add(formatQuestionHomeworkScore).add(formatExamScore).add(formatChatScore); + + //加上手动的分数 + totalScore = totalScore.add(ObjectUtil.defaultIfNull(teacherOpenCourseScoreDashboard.getManualScore(), BigDecimal.ZERO)); + totalScore = totalScore.setScale(1, RoundingMode.HALF_UP); + scoreDashboard.setTotalScore(totalScore); + + //成绩状态 + lastStatus(weight, totalScore, scoreDashboard); + } } - studentScores.add(scoreDashboard); + updateTemplate(scoreDashboard); } - //通过课程id删除存量数据 - teacherOpenCourseScoreDashboardDao.deleteByTeacherOpenCourseId(teacherOpenCourseId); - teacherOpenCourseScoreDashboardDao.insertBatch(studentScores); return true; } @@ -907,4 +1046,70 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService getPageList(StudentHandsOnTaskReportQuery condition,@SCoreUser CoreUser coreUser){ - if(null == coreUser){ + public JsonResult getPageList(StudentHandsOnTaskReportQuery condition, @SCoreUser CoreUser coreUser) { + if (null == coreUser) { return JsonResult.failMessage("请登录后再操作"); - }else{ + } else { PageQuery page = condition.getPageQuery(); studentHandsOnTaskReportService.queryByConditionQuery(page); return JsonResult.success(page); @@ -62,23 +70,34 @@ public class StudentHandsOnTaskReportController{ @GetMapping(API + "/getInfo.do") - public JsonResultgetInfo(StudentHandsOnTaskReportQuery param,@SCoreUser CoreUser coreUser) { - if(null == coreUser){ + public JsonResult getInfo(StudentHandsOnTaskReportQuery param, @SCoreUser CoreUser coreUser) { + if (null == coreUser) { return JsonResult.failMessage("请登录后再操作"); - }else{ + } else { StudentHandsOnTaskReport studentHandsOnTaskReport = studentHandsOnTaskReportService.getInfo(param, coreUser); - return JsonResult.success(studentHandsOnTaskReport); + if (studentHandsOnTaskReport != null) { + TeacherOpenCourseHandsOnSimulationTasks teacherOpenCourseHandsOnSimulationTasks = new TeacherOpenCourseHandsOnSimulationTasks(); + teacherOpenCourseHandsOnSimulationTasks.setTaskId(studentHandsOnTaskReport.getHandsOnTaskId()); + TeacherOpenCourseHandsOnSimulationTasks res = teacherOpenCourseHandsOnSimulationTasksService.queryObject(teacherOpenCourseHandsOnSimulationTasks); + if (res != null) { + studentHandsOnTaskReport.set("maxScore", res.getTaskScore()); + } else { + studentHandsOnTaskReport.set("maxScore", 100); + } + } + + return JsonResult.success(studentHandsOnTaskReport); } } @GetMapping(API + "/getList.do") - public JsonResult>getList(StudentHandsOnTaskReportQuery param,@SCoreUser CoreUser coreUser) { - if(null == coreUser){ + public JsonResult> getList(StudentHandsOnTaskReportQuery param, @SCoreUser CoreUser coreUser) { + if (null == coreUser) { return JsonResult.failMessage("请登录后再操作"); - }else{ - Listlist = studentHandsOnTaskReportService.getValuesByQuery(param); - return JsonResult.success(list); + } else { + List list = studentHandsOnTaskReportService.getValuesByQuery(param); + return JsonResult.success(list); } } @@ -88,7 +107,7 @@ public class StudentHandsOnTaskReportController{ @GetMapping(MODEL + "/index.do") @Function("studentHandsOnTaskReport.query") public ModelAndView index() { - ModelAndView view = new ModelAndView("/jlw/studentHandsOnTaskReport/index.html") ; + ModelAndView view = new ModelAndView("/jlw/studentHandsOnTaskReport/index.html"); view.addObject("search", StudentHandsOnTaskReportQuery.class.getName()); return view; } @@ -106,10 +125,10 @@ public class StudentHandsOnTaskReportController{ @Function("studentHandsOnTaskReport.add") public ModelAndView add(Long studentHandsOnTaskReportId) { ModelAndView view = new ModelAndView("/jlw/studentHandsOnTaskReport/add.html"); - if(null != studentHandsOnTaskReportId){ + if (null != studentHandsOnTaskReportId) { StudentHandsOnTaskReport studentHandsOnTaskReport = studentHandsOnTaskReportService.queryById(studentHandsOnTaskReportId); view.addObject("studentHandsOnTaskReport", studentHandsOnTaskReport); - }else { + } else { view.addObject("studentHandsOnTaskReport", new StudentHandsOnTaskReport()); } return view; @@ -119,7 +138,7 @@ public class StudentHandsOnTaskReportController{ @PostMapping(MODEL + "/list.json") @Function("studentHandsOnTaskReport.query") - public JsonResult list(StudentHandsOnTaskReportQuery condition){ + public JsonResult list(StudentHandsOnTaskReportQuery condition) { PageQuery page = condition.getPageQuery(); studentHandsOnTaskReportService.queryByCondition(page); return JsonResult.success(page); @@ -127,29 +146,29 @@ public class StudentHandsOnTaskReportController{ @PostMapping(MODEL + "/addAll.json") @Function("studentHandsOnTaskReport.add") - public JsonResult addAll(StudentHandsOnTaskReportQuery studentHandsOnTaskReportQuery,@SCoreUser CoreUser coreUser){ - if(null == coreUser){ + public JsonResult addAll(StudentHandsOnTaskReportQuery studentHandsOnTaskReportQuery, @SCoreUser CoreUser coreUser) { + if (null == coreUser) { return JsonResult.failMessage("请登录后再操作"); - }else{ - studentHandsOnTaskReportQuery.setUserId(coreUser.getId()); - studentHandsOnTaskReportQuery.setOrgId(coreUser.getOrgId()); + } else { + studentHandsOnTaskReportQuery.setUserId(coreUser.getId()); + studentHandsOnTaskReportQuery.setOrgId(coreUser.getOrgId()); String msg = studentHandsOnTaskReportService.addAll(studentHandsOnTaskReportQuery); if (StringUtils.isBlank(msg)) { return JsonResult.success(); } else { - return JsonResult.failMessage("新增失败,"+msg); + return JsonResult.failMessage("新增失败," + msg); } } } @PostMapping(MODEL + "/add.json") @Function("studentHandsOnTaskReport.add") - public JsonResult add(@Validated(ValidateConfig.ADD.class) StudentHandsOnTaskReportQuery studentHandsOnTaskReportQuery, BindingResult result,@SCoreUser CoreUser coreUser){ - if(result.hasErrors()){ + public JsonResult add(@Validated(ValidateConfig.ADD.class) StudentHandsOnTaskReportQuery studentHandsOnTaskReportQuery, BindingResult result, @SCoreUser CoreUser coreUser) { + if (result.hasErrors()) { return JsonResult.failMessage(result); - }else{ - studentHandsOnTaskReportQuery.setUserId(coreUser.getId()); - studentHandsOnTaskReportQuery.setOrgId(coreUser.getOrgId()); + } else { + studentHandsOnTaskReportQuery.setUserId(coreUser.getId()); + studentHandsOnTaskReportQuery.setOrgId(coreUser.getOrgId()); return studentHandsOnTaskReportService.add(studentHandsOnTaskReportQuery, coreUser); } } @@ -157,16 +176,16 @@ public class StudentHandsOnTaskReportController{ @PostMapping(MODEL + "/edit.json") @Function("studentHandsOnTaskReport.edit") public JsonResult update(@Validated(ValidateConfig.UPDATE.class) StudentHandsOnTaskReportQuery studentHandsOnTaskReportQuery, @SCoreUser CoreUser coreUser, BindingResult result) { - if(result.hasErrors()){ + if (result.hasErrors()) { return JsonResult.failMessage(result); - }else { - studentHandsOnTaskReportQuery.setUserId(coreUser.getId()); - studentHandsOnTaskReportQuery.setOrgId(coreUser.getOrgId()); + } else { + studentHandsOnTaskReportQuery.setUserId(coreUser.getId()); + studentHandsOnTaskReportQuery.setOrgId(coreUser.getOrgId()); String msg = studentHandsOnTaskReportService.edit(studentHandsOnTaskReportQuery, coreUser); if (StringUtils.isBlank(msg)) { return JsonResult.success(); } else { - return JsonResult.failMessage("更新失败,"+msg); + return JsonResult.failMessage("更新失败," + msg); } } } @@ -174,16 +193,16 @@ public class StudentHandsOnTaskReportController{ @GetMapping(MODEL + "/view.json") @Function("studentHandsOnTaskReport.query") - public JsonResultqueryInfo(Long studentHandsOnTaskReportId) { - StudentHandsOnTaskReport studentHandsOnTaskReport = studentHandsOnTaskReportService.queryById( studentHandsOnTaskReportId); - return JsonResult.success(studentHandsOnTaskReport); + public JsonResult queryInfo(Long studentHandsOnTaskReportId) { + StudentHandsOnTaskReport studentHandsOnTaskReport = studentHandsOnTaskReportService.queryById(studentHandsOnTaskReportId); + return JsonResult.success(studentHandsOnTaskReport); } @GetMapping(MODEL + "/getValues.json") @Function("studentHandsOnTaskReport.query") - public JsonResult>getValues(StudentHandsOnTaskReportQuery param) { - Listlist = studentHandsOnTaskReportService.getValuesByQuery(param); - return JsonResult.success(list); + public JsonResult> getValues(StudentHandsOnTaskReportQuery param) { + List list = studentHandsOnTaskReportService.getValuesByQuery(param); + return JsonResult.success(list); } @@ -196,10 +215,10 @@ public class StudentHandsOnTaskReportController{ } @PostMapping(API + "/add.do") - public JsonResult addStudentHandsOnTaskReport(@RequestBody @Validated(ValidateConfig.ADD.class) StudentHandsOnTaskReportQuery studentHandsOnTaskReportQuery, BindingResult result,@SCoreUser CoreUser coreUser){ - if(result.hasErrors()){ + public JsonResult addStudentHandsOnTaskReport(@RequestBody @Validated(ValidateConfig.ADD.class) StudentHandsOnTaskReportQuery studentHandsOnTaskReportQuery, BindingResult result, @SCoreUser CoreUser coreUser) { + if (result.hasErrors()) { return JsonResult.failMessage(result); - }else{ + } else { studentHandsOnTaskReportQuery.setUserId(coreUser.getId()); studentHandsOnTaskReportQuery.setOrgId(coreUser.getOrgId()); return studentHandsOnTaskReportService.add(studentHandsOnTaskReportQuery, coreUser); @@ -207,26 +226,26 @@ public class StudentHandsOnTaskReportController{ } @PostMapping(API + "/edit.do") - public JsonResult editStudentHandsOnTaskReport(@RequestBody @Validated(ValidateConfig.UPDATE.class) StudentHandsOnTaskReportQuery studentHandsOnTaskReportQuery,@SCoreUser CoreUser coreUser, BindingResult result) { - if(result.hasErrors()){ - return JsonResult.failMessage(result); - }else { - studentHandsOnTaskReportQuery.setUserId(coreUser.getId()); - studentHandsOnTaskReportQuery.setOrgId(coreUser.getOrgId()); - String msg = studentHandsOnTaskReportService.edit(studentHandsOnTaskReportQuery, coreUser); - if (StringUtils.isBlank(msg)) { - return JsonResult.success(); - } else { - return JsonResult.failMessage("更新失败,"+msg); - } + public JsonResult editStudentHandsOnTaskReport(@RequestBody StudentHandsOnTaskReportQuery studentHandsOnTaskReportQuery, @SCoreUser CoreUser coreUser, BindingResult result) { + if(studentHandsOnTaskReportQuery.getStudentHandsOnTaskReportId()==null){ + return JsonResult.failMessage("未完成实操任务"); + } + studentHandsOnTaskReportQuery.setUserId(coreUser.getId()); + studentHandsOnTaskReportQuery.setOrgId(coreUser.getOrgId()); + String msg = studentHandsOnTaskReportService.edit(studentHandsOnTaskReportQuery, coreUser); + if (StringUtils.isBlank(msg)) { + return JsonResult.success(); + } else { + return JsonResult.failMessage("更新失败," + msg); } + } //导出信息 @GetMapping(MODEL + "/excel/export.json") @Function("studentHandsOnTaskReport.exportDocument") - public void export(HttpServletRequest request,HttpServletResponse response,StudentHandsOnTaskReportQuery studentHandsOnTaskReportQuery,@SCoreUser CoreUser coreUser) { - if(null == coreUser){ + public void export(HttpServletRequest request, HttpServletResponse response, StudentHandsOnTaskReportQuery studentHandsOnTaskReportQuery, @SCoreUser CoreUser coreUser) { + if (null == coreUser) { return; } HSSFWorkbook workbook = null; @@ -288,7 +307,7 @@ public class StudentHandsOnTaskReportController{ //设置表格特定的列宽度 if (null != widthMap.get(headerCode[i])) { String width = widthMap.get(headerCode[i]).toString().split("\\.")[0]; - Integer w = Integer.parseInt(width) > header[i].length()*3?Integer.parseInt(width):header[i].length()*3; + Integer w = Integer.parseInt(width) > header[i].length() * 3 ? Integer.parseInt(width) : header[i].length() * 3; sheet.setColumnWidth(i, w * 190); } //创建一个单元格 @@ -303,7 +322,7 @@ public class StudentHandsOnTaskReportController{ //遍历结果集,把内容加入表格 for (int i = 0; i < mapList.size(); i++) { HSSFRow row = sheet.createRow(i + 1); - row.setHeight((short) (50*10)); + row.setHeight((short) (50 * 10)); Map map = mapList.get(i); for (int j = 0; j < headerCode.length; j++) { HSSFCell cell = row.createCell(j); @@ -316,13 +335,13 @@ public class StudentHandsOnTaskReportController{ //八进制输出流 response.setContentType("application/octet-stream"); //这后面可以设置导出Excel的名称,此例中名为student.xls - String fileName = ToolUtils.web2fileName(request,"studentHandsOnTaskReport(" + TimeTool.getNowTime("YMD") + ").xls"); - response.setHeader("Content-disposition", "attachment;filename="+fileName); + String fileName = ToolUtils.web2fileName(request, "studentHandsOnTaskReport(" + TimeTool.getNowTime("YMD") + ").xls"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName); //刷新缓冲 response.flushBuffer(); //workbook将Excel写入到response的输出流中,供页面下载 workbook.write(response.getOutputStream()); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } finally { try { @@ -332,14 +351,15 @@ public class StudentHandsOnTaskReportController{ if (null != response && null != response.getOutputStream()) { response.getOutputStream().close(); } - } catch (Exception e) { } + } catch (Exception e) { + } } } //导出信息 @GetMapping(MODEL + "/excel/export.do") - public void exportDo(HttpServletRequest request,HttpServletResponse response,StudentHandsOnTaskReportQuery studentHandsOnTaskReportQuery,@SCoreUser CoreUser coreUser) { - if(null == coreUser){ + public void exportDo(HttpServletRequest request, HttpServletResponse response, StudentHandsOnTaskReportQuery studentHandsOnTaskReportQuery, @SCoreUser CoreUser coreUser) { + if (null == coreUser) { return; } HSSFWorkbook workbook = null; @@ -401,7 +421,7 @@ public class StudentHandsOnTaskReportController{ //设置表格特定的列宽度 if (null != widthMap.get(headerCode[i])) { String width = widthMap.get(headerCode[i]).toString().split("\\.")[0]; - Integer w = Integer.parseInt(width) > header[i].length()*3?Integer.parseInt(width):header[i].length()*3; + Integer w = Integer.parseInt(width) > header[i].length() * 3 ? Integer.parseInt(width) : header[i].length() * 3; sheet.setColumnWidth(i, w * 190); } //创建一个单元格 @@ -416,7 +436,7 @@ public class StudentHandsOnTaskReportController{ //遍历结果集,把内容加入表格 for (int i = 0; i < mapList.size(); i++) { HSSFRow row = sheet.createRow(i + 1); - row.setHeight((short) (50*10)); + row.setHeight((short) (50 * 10)); Map map = mapList.get(i); for (int j = 0; j < headerCode.length; j++) { HSSFCell cell = row.createCell(j); @@ -429,13 +449,13 @@ public class StudentHandsOnTaskReportController{ //八进制输出流 response.setContentType("application/octet-stream"); //这后面可以设置导出Excel的名称,此例中名为student.xls - String fileName = ToolUtils.web2fileName(request,"studentHandsOnTaskReport(" + TimeTool.getNowTime("YMD") + ").xls"); - response.setHeader("Content-disposition", "attachment;filename="+fileName); + String fileName = ToolUtils.web2fileName(request, "studentHandsOnTaskReport(" + TimeTool.getNowTime("YMD") + ").xls"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName); //刷新缓冲 response.flushBuffer(); //workbook将Excel写入到response的输出流中,供页面下载 workbook.write(response.getOutputStream()); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } finally { try { @@ -445,7 +465,8 @@ public class StudentHandsOnTaskReportController{ if (null != response && null != response.getOutputStream()) { response.getOutputStream().close(); } - } catch (Exception e) { } + } catch (Exception e) { + } } } diff --git a/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseScoreDashboardController.java b/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseScoreDashboardController.java index 3148b913..2a01223f 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseScoreDashboardController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseScoreDashboardController.java @@ -14,7 +14,6 @@ import com.ibeetl.jlw.dao.StudentDao; import com.ibeetl.jlw.entity.FileEntity; import com.ibeetl.jlw.entity.Student; import com.ibeetl.jlw.entity.TeacherOpenCourseScoreDashboard; -import com.ibeetl.jlw.job.TeacherOpenCourseScoreDashboardJob; import com.ibeetl.jlw.service.TeacherOpenCourseScoreDashboardService; import com.ibeetl.jlw.web.query.TeacherOpenCourseScoreDashboardQuery; import org.apache.commons.collections4.MapUtils; @@ -22,6 +21,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.beetl.ext.fn.Json; import org.beetl.sql.core.engine.PageQuery; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.BindingResult; @@ -283,12 +283,12 @@ public class TeacherOpenCourseScoreDashboardController { //导出信息 @RequestMapping(MODEL + "/excel/export.json") - public void export( HttpServletResponse response, TeacherOpenCourseScoreDashboardQuery teacherOpenCourseScoreDashboardQuery, @SCoreUser CoreUser coreUser) throws IOException { + public void export(HttpServletResponse response, TeacherOpenCourseScoreDashboardQuery teacherOpenCourseScoreDashboardQuery, @SCoreUser CoreUser coreUser) throws IOException { if (null == coreUser) { throw new PlatformException("请登录后再操作"); } - teacherOpenCourseScoreDashboardService.export( response, teacherOpenCourseScoreDashboardQuery, coreUser); + teacherOpenCourseScoreDashboardService.export(response, teacherOpenCourseScoreDashboardQuery, coreUser); } @@ -338,4 +338,14 @@ public class TeacherOpenCourseScoreDashboardController { } } + @PostMapping(API + "/updateManualScore") + public JsonResult updateManualScore(TeacherOpenCourseScoreDashboardQuery teacherOpenCourseScoreDashboardQuery) { + + teacherOpenCourseScoreDashboardService.updateManualScore(teacherOpenCourseScoreDashboardQuery.getTeacherOpenCourseScoreDashboardId(), + teacherOpenCourseScoreDashboardQuery.getStudentId(), + teacherOpenCourseScoreDashboardQuery.getTeacherOpenCourseId(), + teacherOpenCourseScoreDashboardQuery.getManualScore()); + return JsonResult.success(); + } } +