mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-10 19:36:50 +08:00
查询课程和修改课程学习上报进度,增加视频播放进度的处理
This commit is contained in:
@@ -264,27 +264,27 @@ public class StudyCourseApi extends ApiBaseController{
|
|||||||
Map<String, CourseContent> contentMap = cclist.stream().collect(Collectors.toMap(CourseContent::getId, Function.identity()));
|
Map<String, CourseContent> contentMap = cclist.stream().collect(Collectors.toMap(CourseContent::getId, Function.identity()));
|
||||||
for (StudyCourseItem item : items) {
|
for (StudyCourseItem item : items) {
|
||||||
CourseContent content = contentMap.get(item.getContentId());
|
CourseContent content = contentMap.get(item.getContentId());
|
||||||
if(item.getContentId().equals(content.getId())){
|
if(null == content){
|
||||||
// 计算学习进度item.getLastStudyTime() /content.getDuration()
|
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);
|
|
||||||
// 如果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==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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user