diff --git a/web/src/main/java/com/ibeetl/jlw/service/HandsOnService.java b/web/src/main/java/com/ibeetl/jlw/service/HandsOnService.java index 4447982e..adea53d2 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/HandsOnService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/HandsOnService.java @@ -1,6 +1,7 @@ package com.ibeetl.jlw.service; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import cn.jlw.util.ToolUtils; import com.alibaba.fastjson.JSON; @@ -11,12 +12,10 @@ import com.ibeetl.admin.core.util.PlatformException; import com.ibeetl.admin.core.web.JsonResult; import com.ibeetl.admin.core.web.JsonReturnCode; import com.ibeetl.jlw.dao.HandsOnDao; -import com.ibeetl.jlw.entity.HandsOn; -import com.ibeetl.jlw.entity.HandsOnSimulationTasks; +import com.ibeetl.jlw.entity.*; import com.ibeetl.jlw.entity.vo.StudentHandsOnVO; -import com.ibeetl.jlw.web.query.HandsOnQuery; -import com.ibeetl.jlw.web.query.HandsOnSimulationTasksQuery; -import com.ibeetl.jlw.web.query.TeacherOpenCourseHandsOnQuery; +import com.ibeetl.jlw.enums.HandsOnTaskEnum; +import com.ibeetl.jlw.web.query.*; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.beetl.sql.core.SqlId; @@ -26,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -46,6 +46,25 @@ public class HandsOnService extends CoreBaseService{ @Autowired private HandsOnDao handsOnDao; @Autowired private HandsOnSimulationTasksService handsOnSimulationTasksService; + @Autowired + private StudentService studentService; + + @Autowired + private StudentHandsOnTaskVideoService videoService; + + @Autowired + private StudentHandsOnTaskPptService pptService; + + @Autowired + private StudentHandsOnTaskTheoryService theoryService; + + @Autowired + private StudentHandsOnTaskStepService stepService; + + @Autowired + private StudentHandsOnTaskReportService reportService; + + public PageQueryqueryByCondition(PageQuery query){ PageQuery ret = handsOnDao.queryByCondition(query); queryListAfter(ret.getList()); @@ -263,4 +282,123 @@ public class HandsOnService extends CoreBaseService{ return studentHandsOnVOS; } + + /** + * 查询课程课程中心实操 FIXME 这里应该是分页的,但是没做,赶不及,已通知前端改为不分页 + * + * @param courseInfo + * @param coreUser + * @return + */ + public JsonResult> getCourseCentreHandsListByOpenCourseIdAndStudent(Long courseInfo, CoreUser coreUser) { + Long userId = coreUser.getId(); + Student student = studentService.getByUserId(userId); + if (student == null) { + return JsonResult.fail(); + } + Long studentId = student.getStudentId(); + HandsOnQuery handsOnQuery = new HandsOnQuery(); + handsOnQuery.setCourseInfoId(courseInfo); + handsOnQuery.setHandsOnStatus(1); + List handsOnList = this.getValuesByQueryNotPermission(handsOnQuery); + + List tasksList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(handsOnList)) { + //查询实操任务 + List handIds = handsOnList.stream().map(HandsOn::getHandsOnId).collect(Collectors.toList()); + HandsOnSimulationTasksQuery tasksQuery = new HandsOnSimulationTasksQuery(); + tasksQuery.setHandsOnIdPlural(CollectionUtil.join(handIds, ",")); + tasksList = handsOnSimulationTasksService.getValuesByQueryNotPermission(tasksQuery); + + } + List studentHandsOnVOS = new ArrayList<>(); + for (HandsOn handsOn : handsOnList) { + StudentHandsOnVO studentHandsOnVO = new StudentHandsOnVO(); + Long handsOnId = handsOn.getHandsOnId(); + studentHandsOnVO.setChapterId(handsOn.getCourseChildNode()); + studentHandsOnVO.setTeacherOpenCourseId(handsOn.getTeacherOpenCourseId()); + List tasks = tasksList.stream().filter(v -> v.getHandsOnId().equals(handsOnId)).collect(Collectors.toList()); + studentHandsOnVO.setHandsOnId(handsOnId); + studentHandsOnVO.setHandsOnName(handsOn.getHandsOnName()); + studentHandsOnVO.setHandsOnTaskNum(tasks.size()); + //总分 + BigDecimal bigDecimal = BigDecimal.ZERO; + if (CollectionUtils.isNotEmpty(tasks)) { + //做题数 + BigDecimal decimal = BigDecimal.ZERO; + for (HandsOnSimulationTasks task : tasks) { + Long taskId = task.getTaskId(); + if (HandsOnTaskEnum.TASK_VIDEO.status.equals(task.getTaskType())) { + StudentHandsOnTaskVideoQuery videoQuery = new StudentHandsOnTaskVideoQuery(); + videoQuery.setHandsOnTaskId(taskId); + videoQuery.setStudentId(studentId); + videoQuery.setCourseType(2); + List videoList = videoService.getValuesByQueryNotWithPermission(videoQuery); + if (CollectionUtils.isNotEmpty(videoList)) { + StudentHandsOnTaskVideo studentHandsOnTaskVideo = videoList.get(0); + BigDecimal videoScore = studentHandsOnTaskVideo.getVideoScore(); + bigDecimal = bigDecimal.add(videoScore == null ? BigDecimal.ZERO : videoScore); + decimal = decimal.add(BigDecimal.ONE); + } + } else if (HandsOnTaskEnum.TASK_PPT.status.equals(task.getTaskType())) { + StudentHandsOnTaskPptQuery pptQuery = new StudentHandsOnTaskPptQuery(); + pptQuery.setHandsOnTaskId(taskId); + pptQuery.setStudentId(studentId); + pptQuery.setCourseType(2); + List pptList = pptService.getValuesByQueryNotWithPermission(pptQuery); + if (CollectionUtils.isNotEmpty(pptList)) { + StudentHandsOnTaskPpt studentHandsOnTaskPpt = pptList.get(0); + BigDecimal videoScore = studentHandsOnTaskPpt.getPptScore(); + bigDecimal = bigDecimal.add(videoScore == null ? BigDecimal.ZERO : videoScore); + decimal = decimal.add(BigDecimal.ONE); + } + } else if (HandsOnTaskEnum.TASK_THEORY.status.equals(task.getTaskType())) { + StudentHandsOnTaskTheoryQuery theoryQuery = new StudentHandsOnTaskTheoryQuery(); + theoryQuery.setHandsOnTaskId(taskId); + theoryQuery.setStudentId(studentId); + theoryQuery.setCourseType(2); + List taskTheoryList = theoryService.getValuesByQueryNotWithPermission(theoryQuery); + if (CollectionUtils.isNotEmpty(taskTheoryList)) { + BigDecimal videoScore = taskTheoryList.stream().map(StudentHandsOnTaskTheory::getTheoryScore).reduce(BigDecimal.ZERO, BigDecimal::add); + bigDecimal = bigDecimal.add(videoScore == null ? BigDecimal.ZERO : videoScore); + decimal = decimal.add(BigDecimal.ONE); + } + } else if (HandsOnTaskEnum.TASK_PRACTICAL_TRAINING.status.equals(task.getTaskType())) { + StudentHandsOnTaskStepQuery stepQuery = new StudentHandsOnTaskStepQuery(); + stepQuery.setHandsOnTaskId(taskId); + stepQuery.setStudentId(studentId); + stepQuery.setCourseType(2); + List stepList = stepService.getValuesByQueryNotWithPermission(stepQuery); + if (CollectionUtils.isNotEmpty(stepList)) { + StudentHandsOnTaskStep taskTheory = stepList.get(0); + BigDecimal videoScore = taskTheory.getTheoryScore(); + bigDecimal = bigDecimal.add(videoScore == null ? BigDecimal.ZERO : videoScore); + decimal = decimal.add(BigDecimal.ONE); + } + } else if (HandsOnTaskEnum.TASK_REPORT_WRITING.status.equals(task.getTaskType())) { + StudentHandsOnTaskReportQuery reportQuery = new StudentHandsOnTaskReportQuery(); + reportQuery.setHandsOnTaskId(taskId); + reportQuery.setStudentId(studentId); + reportQuery.setCourseType(2); + List reportList = reportService.getValuesByQueryNotWithPermission(reportQuery); + if (CollectionUtils.isNotEmpty(reportList)) { + StudentHandsOnTaskReport taskTheory = reportList.get(0); + BigDecimal videoScore = taskTheory.getReportScore(); + bigDecimal = bigDecimal.add(videoScore == null ? BigDecimal.ZERO : videoScore); + decimal = decimal.add(BigDecimal.ONE); + } + } + } + int schedule = NumberUtil.div(decimal, BigDecimal.valueOf(tasks.size()), 2).multiply(BigDecimal.valueOf(100)).intValue(); + studentHandsOnVO.setSchedule(schedule); + } else { + studentHandsOnVO.setSchedule(0); + } + studentHandsOnVO.setStudentScore(bigDecimal); + studentHandsOnVOS.add(studentHandsOnVO); + } + + return JsonResult.success(studentHandsOnVOS); + } + } diff --git a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseHandsOnService.java b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseHandsOnService.java index f84e1e84..f2ed99f6 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseHandsOnService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseHandsOnService.java @@ -519,6 +519,7 @@ public class TeacherOpenCourseHandsOnService extends CoreBaseService videoList = videoService.getValuesByQueryNotWithPermission(videoQuery); if (CollectionUtils.isNotEmpty(videoList)) { StudentHandsOnTaskVideo studentHandsOnTaskVideo = videoList.get(0); @@ -530,6 +531,7 @@ public class TeacherOpenCourseHandsOnService extends CoreBaseService pptList = pptService.getValuesByQueryNotWithPermission(pptQuery); if (CollectionUtils.isNotEmpty(pptList)) { StudentHandsOnTaskPpt studentHandsOnTaskPpt = pptList.get(0); @@ -541,6 +543,7 @@ public class TeacherOpenCourseHandsOnService extends CoreBaseService taskTheoryList = theoryService.getValuesByQueryNotWithPermission(theoryQuery); if (CollectionUtils.isNotEmpty(taskTheoryList)) { BigDecimal videoScore = taskTheoryList.stream().map(StudentHandsOnTaskTheory::getTheoryScore).reduce(BigDecimal.ZERO, BigDecimal::add); @@ -551,6 +554,7 @@ public class TeacherOpenCourseHandsOnService extends CoreBaseService stepList = stepService.getValuesByQueryNotWithPermission(stepQuery); if (CollectionUtils.isNotEmpty(stepList)) { StudentHandsOnTaskStep taskTheory = stepList.get(0); @@ -562,6 +566,7 @@ public class TeacherOpenCourseHandsOnService extends CoreBaseService reportList = reportService.getValuesByQueryNotWithPermission(reportQuery); if (CollectionUtils.isNotEmpty(reportList)) { StudentHandsOnTaskReport taskTheory = reportList.get(0); diff --git a/web/src/main/java/com/ibeetl/jlw/web/HandsOnController.java b/web/src/main/java/com/ibeetl/jlw/web/HandsOnController.java index e13177c8..de1367ef 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/HandsOnController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/HandsOnController.java @@ -422,4 +422,15 @@ public class HandsOnController{ return JsonResult.success(handsListCenterByOpenCourseId); } + + /** + * 查询课程课程中心实操 + * @param courseInfoId + * @param coreUser + * @return + */ + @GetMapping(API + "/getCourseCentreHandsListCenterByOpenCourseId.do") + public JsonResult getCourseCentreHandsListCenterByOpenCourseId(Long courseInfoId,@SCoreUser CoreUser coreUser) { + return handsOnService.getCourseCentreHandsListByOpenCourseIdAndStudent(courseInfoId,coreUser); + } }