he2802 2 lat temu
rodzic
commit
d933ea3a6c

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseChapterVo.java

@@ -83,4 +83,6 @@ public class CourseChapterVo {
 	private String importNo;
 	@ApiModelProperty("公共标识:1公共章 0非公共章")
 	private Integer commonSign;
+	@ApiModelProperty("节总时间")
+	private Long totalTime;
 }

+ 12 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserCertificateServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
+import com.zhongzheng.modules.course.mapper.CourseMenuMapper;
 import com.zhongzheng.modules.course.vo.CourseChapterVo;
 import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
 import com.zhongzheng.modules.grade.service.IClassGradeUserService;
@@ -22,6 +23,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.pagehelper.Page;
 
+import java.math.BigDecimal;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -39,6 +41,9 @@ public class UserCertificateServiceImpl extends ServiceImpl<UserCertificateMappe
     @Autowired
     private IClassGradeUserService iClassGradeUserService;
 
+    @Autowired
+    private CourseMenuMapper courseMenuMapper;
+
     @Override
     public UserCertificateVo queryById(Long id){
         UserCertificate db = this.baseMapper.selectById(id);
@@ -80,6 +85,13 @@ public class UserCertificateServiceImpl extends ServiceImpl<UserCertificateMappe
         queryBo.setGoodsId(userCertificateVo.getGoodsId());
         queryBo.setGradeId(userCertificateVo.getGradeId());
         List<CourseChapterVo> chapterList =  iClassGradeUserService.findChapterList(queryBo);
+        BigDecimal totalTime = new BigDecimal(0);
+        for(CourseChapterVo chapterVo : chapterList){
+            Long secTotalTime = courseMenuMapper.countChapterTotalTime(chapterVo.getChapterId());
+            chapterVo.setTotalTime(secTotalTime);
+            totalTime=totalTime.add(new BigDecimal(secTotalTime));
+        }
+        userCertificateVo.setClassHours(totalTime.divide(new BigDecimal(45*60),BigDecimal.ROUND_HALF_UP));
         userCertificateVo.setChapterList(chapterList);
         return userCertificateVo;
     }