|
@@ -3,6 +3,7 @@ package com.zhongzheng.modules.course.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
@@ -16,6 +17,16 @@ import com.zhongzheng.modules.course.mapper.CourseSectionMapper;
|
|
|
import com.zhongzheng.modules.course.service.ICourseSectionBusinessService;
|
|
|
import com.zhongzheng.modules.course.service.ICourseService;
|
|
|
import com.zhongzheng.modules.course.vo.CourseVo;
|
|
|
+import com.zhongzheng.modules.goods.vo.GoodsPeriodStatusVo;
|
|
|
+import com.zhongzheng.modules.goods.vo.GoodsPeriodVo;
|
|
|
+import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
|
|
|
+import com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo;
|
|
|
+import com.zhongzheng.modules.user.bo.UserPlanQueryBo;
|
|
|
+import com.zhongzheng.modules.user.domain.UserStudyRecordPhoto;
|
|
|
+import com.zhongzheng.modules.user.service.IUserStudyRecordPhotoService;
|
|
|
+import com.zhongzheng.modules.user.service.IUserStudyRecordService;
|
|
|
+import com.zhongzheng.modules.user.vo.SubjectStudyRecordVo;
|
|
|
+import com.zhongzheng.modules.user.vo.UserStudyRecordPhotoVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -23,6 +34,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;
|
|
@@ -40,6 +52,12 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
|
|
@Autowired
|
|
|
private CourseMapper courseMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IUserStudyRecordPhotoService userStudyRecordPhotoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserStudyRecordService iUserStudyRecordService;
|
|
|
+
|
|
|
@Override
|
|
|
public CourseVo queryById(Long courseId){
|
|
|
Course db = this.baseMapper.selectById(courseId);
|
|
@@ -136,6 +154,61 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
|
|
return this.removeByIds(ids);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<GoodsPeriodVo> listGoodsPeriodVo(UserPlanQueryBo bo) {
|
|
|
+ List<GoodsPeriodVo> goodsPeriodVos = baseMapper.listGoodsPeriodVo(bo);
|
|
|
+ for (GoodsPeriodVo goodsPeriodVo : goodsPeriodVos) {
|
|
|
+ Long secLong = 0L;
|
|
|
+ Long studyLong = 0L;
|
|
|
+ SubjectStudyRecordQueryBo subjectStudyRecordQueryBo = new SubjectStudyRecordQueryBo();
|
|
|
+ subjectStudyRecordQueryBo.setGoodsId(goodsPeriodVo.getGoodsId());
|
|
|
+ subjectStudyRecordQueryBo.setUserId(bo.getUserId());
|
|
|
+ subjectStudyRecordQueryBo.setGradeId(goodsPeriodVo.getGradeId());
|
|
|
+ List<SubjectStudyRecordVo> subjectStudyRecordVos = iUserStudyRecordService.listSubject(subjectStudyRecordQueryBo);
|
|
|
+ if (!CollectionUtils.isEmpty(subjectStudyRecordVos)) {
|
|
|
+ for (SubjectStudyRecordVo subjectStudyRecordVo : subjectStudyRecordVos) {
|
|
|
+ secLong = new BigDecimal(secLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getSectionNum().toString())).longValue();
|
|
|
+ studyLong = new BigDecimal(studyLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getRecordNum().toString())).longValue();
|
|
|
+ }
|
|
|
+ if (secLong.equals(studyLong) && goodsPeriodVo.getExamNum().equals(goodsPeriodVo.getRecordNum())) {
|
|
|
+ if (goodsPeriodVo.getCheat() != 0 || goodsPeriodVo.getExamCheat() != 0) {
|
|
|
+ goodsPeriodVo.setPeriodStatus(3L);
|
|
|
+ }else if (goodsPeriodVo.getPending() != 0 || goodsPeriodVo.getExamPending() != 0) {
|
|
|
+ goodsPeriodVo.setPeriodStatus(2L);
|
|
|
+ } else {
|
|
|
+ goodsPeriodVo.setPeriodStatus(1L);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ goodsPeriodVo.setPeriodStatus(-1L);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return goodsPeriodVos;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<GoodsPeriodStatusVo> listSection(ClassGradeUserQueryBo bo) {
|
|
|
+ List<GoodsPeriodStatusVo> goodsPeriodStatusVos = baseMapper.listSection(bo);
|
|
|
+ for (GoodsPeriodStatusVo goodsPeriodStatusVo : goodsPeriodStatusVos) {
|
|
|
+ LambdaQueryWrapper<UserStudyRecordPhoto> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(UserStudyRecordPhoto::getPeriodId, goodsPeriodStatusVo.getId());
|
|
|
+ goodsPeriodStatusVo.setUserStudyRecordPhoto(entity2PhotoVo(userStudyRecordPhotoService.list(lqw)));
|
|
|
+ }
|
|
|
+ return goodsPeriodStatusVos;
|
|
|
+ }
|
|
|
+ private List<UserStudyRecordPhotoVo> entity2PhotoVo(Collection<UserStudyRecordPhoto> collection) {
|
|
|
+ List<UserStudyRecordPhotoVo> voList = collection.stream()
|
|
|
+ .map(any -> BeanUtil.toBean(any, UserStudyRecordPhotoVo.class))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (collection instanceof Page) {
|
|
|
+ Page<UserStudyRecordPhoto> page = (Page<UserStudyRecordPhoto>)collection;
|
|
|
+ Page<UserStudyRecordPhotoVo> pageVo = new Page<>();
|
|
|
+ BeanUtil.copyProperties(page,pageVo);
|
|
|
+ pageVo.addAll(voList);
|
|
|
+ voList = pageVo;
|
|
|
+ }
|
|
|
+ return voList;
|
|
|
+ }
|
|
|
private boolean checkNameUnique(Course entity) {
|
|
|
Course info = getOne(new LambdaQueryWrapper<Course>()
|
|
|
.eq(Course::getPrefixName,entity.getPrefixName()).eq(Course::getCourseName,entity.getCourseName()).last("limit 1"));
|