From 175e7f6c289bc5cb2f555fe3229e6030afe8b332 Mon Sep 17 00:00:00 2001 From: sunhonglai Date: Tue, 1 Apr 2025 08:32:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=AF=BE=E7=A8=8B=E5=92=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B=E5=AD=A6=E4=B9=A0=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5=E8=BF=9B=E5=BA=A6=EF=BC=8C=E5=A2=9E=E5=8A=A0=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E6=92=AD=E6=94=BE=E8=BF=9B=E5=BA=A6=E7=9A=84=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xboe/school/study/api/StudyCourseApi.java | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/servers/boe-server-all/src/main/java/com/xboe/school/study/api/StudyCourseApi.java b/servers/boe-server-all/src/main/java/com/xboe/school/study/api/StudyCourseApi.java index 0245480f..e9d03030 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/school/study/api/StudyCourseApi.java +++ b/servers/boe-server-all/src/main/java/com/xboe/school/study/api/StudyCourseApi.java @@ -264,27 +264,27 @@ public class StudyCourseApi extends ApiBaseController{ Map contentMap = cclist.stream().collect(Collectors.toMap(CourseContent::getId, Function.identity())); for (StudyCourseItem item : items) { CourseContent content = contentMap.get(item.getContentId()); - if(item.getContentId().equals(content.getId())){ - // 计算学习进度item.getLastStudyTime() /content.getDuration() - if(null==item.getLastStudyTime() - || item.getLastStudyTime()<=0 - || null==content.getDuration() - || content.getDuration()<=0){ - continue; - } - - BigDecimal lastStudyTime = new BigDecimal(item.getLastStudyTime()); - BigDecimal duration = new BigDecimal(content.getDuration()); - BigDecimal progress = lastStudyTime.divide(duration, 10, RoundingMode.HALF_UP); - // 如果progress<0则为0,如果progress>1则为1 - if(progress.compareTo(BigDecimal.ZERO) < 0){ - progress = BigDecimal.ZERO; - }else if(progress.compareTo(BigDecimal.ONE) > 0){ - progress = BigDecimal.ONE; - } - - item.setProgressVideo(progress); + if(null == content){ + continue; } + + if(null==item.getLastStudyTime() + || item.getLastStudyTime()<=0 + || null==content.getDuration() + || content.getDuration()<=0){ + continue; + } + + BigDecimal lastStudyTime = new BigDecimal(item.getLastStudyTime()); + BigDecimal duration = new BigDecimal(content.getDuration()); + BigDecimal progress = lastStudyTime.divide(duration, 10, RoundingMode.HALF_UP); + if(progress.compareTo(BigDecimal.ZERO) < 0){ + progress = BigDecimal.ZERO; + }else if(progress.compareTo(BigDecimal.ONE) > 0){ + progress = BigDecimal.ONE; + } + + item.setProgressVideo(progress); } }