|
|
@@ -3,17 +3,34 @@ package com.zhongzheng.modules.user.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.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
|
import com.zhongzheng.common.utils.ip.IpUtils;
|
|
|
+import com.zhongzheng.modules.course.domain.CoursePhotoLog;
|
|
|
+import com.zhongzheng.modules.course.service.ICoursePhotoLogService;
|
|
|
+import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
|
+import com.zhongzheng.modules.grade.domain.UserPeriod;
|
|
|
+import com.zhongzheng.modules.grade.domain.UserPeriodStatus;
|
|
|
+import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
|
+import com.zhongzheng.modules.grade.service.IUserPeriodService;
|
|
|
+import com.zhongzheng.modules.grade.service.IUserPeriodStatusService;
|
|
|
+import com.zhongzheng.modules.user.bo.RepairUserStudyBo;
|
|
|
import com.zhongzheng.modules.user.bo.UserStudyLogAddBo;
|
|
|
import com.zhongzheng.modules.user.bo.UserStudyLogEditBo;
|
|
|
import com.zhongzheng.modules.user.bo.UserStudyLogQueryBo;
|
|
|
import com.zhongzheng.modules.user.domain.UserStudyLog;
|
|
|
+import com.zhongzheng.modules.user.domain.UserStudyRecord;
|
|
|
+import com.zhongzheng.modules.user.domain.UserStudyRecordPhoto;
|
|
|
import com.zhongzheng.modules.user.domain.UserVisitLog;
|
|
|
import com.zhongzheng.modules.user.mapper.UserStudyLogMapper;
|
|
|
import com.zhongzheng.modules.user.service.IUserStudyLogService;
|
|
|
+import com.zhongzheng.modules.user.service.IUserStudyRecordPhotoService;
|
|
|
+import com.zhongzheng.modules.user.service.IUserStudyRecordService;
|
|
|
import com.zhongzheng.modules.user.vo.UserStudyLogVo;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
@@ -34,6 +51,24 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class UserStudyLogServiceImpl extends ServiceImpl<UserStudyLogMapper, UserStudyLog> implements IUserStudyLogService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IClassGradeUserService iClassGradeUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserStudyRecordService iUserStudyRecordService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserPeriodService iUserPeriodService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserPeriodStatusService iUserPeriodStatusService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserStudyRecordPhotoService iUserStudyRecordPhotoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICoursePhotoLogService iCoursePhotoLogService;
|
|
|
+
|
|
|
@Override
|
|
|
public UserStudyLogVo queryById(Long id){
|
|
|
UserStudyLog db = this.baseMapper.selectById(id);
|
|
|
@@ -126,4 +161,77 @@ public class UserStudyLogServiceImpl extends ServiceImpl<UserStudyLogMapper, Use
|
|
|
return baseMapper.getOneNoTenant(userId);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String repairUserStudy(RepairUserStudyBo bo) {
|
|
|
+ ClassGradeUser classGradeUser = iClassGradeUserService.getOne(new LambdaQueryWrapper<ClassGradeUser>().eq(ClassGradeUser::getOrderGoodsId, bo.getOrderGoodsId()).eq(ClassGradeUser::getGradeId, bo.getGradeId()));
|
|
|
+ if (ObjectUtils.isNull(classGradeUser)){
|
|
|
+ throw new CustomException("班级学员不存在,请检查");
|
|
|
+ }
|
|
|
+ //添加时间
|
|
|
+ Long time = bo.getTime();
|
|
|
+
|
|
|
+ //学习记录
|
|
|
+ List<UserStudyRecord> userStudyRecords = iUserStudyRecordService
|
|
|
+ .list(new LambdaQueryWrapper<UserStudyRecord>().eq(UserStudyRecord::getOrderGoodsId, bo.getOrderGoodsId()).eq(UserStudyRecord::getGradeId, bo.getGradeId()));
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(userStudyRecords)){
|
|
|
+ throw new CustomException("学习记录不存在,请检查");
|
|
|
+ }
|
|
|
+ //学时审核记录
|
|
|
+ List<UserPeriod> userPeriods = iUserPeriodService
|
|
|
+ .list(new LambdaQueryWrapper<UserPeriod>().eq(UserPeriod::getOrderGoodsId, bo.getOrderGoodsId()).eq(UserPeriod::getGradeId, bo.getGradeId()));
|
|
|
+ if (CollectionUtils.isNotEmpty(userPeriods)){
|
|
|
+ List<Long> periodIds = userPeriods.stream().map(UserPeriod::getId).collect(Collectors.toList());
|
|
|
+ List<UserPeriodStatus> periodStatusList = iUserPeriodStatusService.list(new LambdaQueryWrapper<UserPeriodStatus>().in(UserPeriodStatus::getPeriodId, periodIds));
|
|
|
+
|
|
|
+ //获取学习照片
|
|
|
+ if (CollectionUtils.isNotEmpty(periodStatusList)){
|
|
|
+ List<Long> periodStatusIds = periodStatusList.stream().map(UserPeriodStatus::getId).collect(Collectors.toList());
|
|
|
+ List<UserStudyRecordPhoto> photoList = iUserStudyRecordPhotoService.list(new LambdaQueryWrapper<UserStudyRecordPhoto>().in(UserStudyRecordPhoto::getPeriodId, periodStatusIds));
|
|
|
+ if (CollectionUtils.isNotEmpty(photoList)){
|
|
|
+ photoList.forEach(x -> {
|
|
|
+ x.setCreateTime(x.getCreateTime()+time);
|
|
|
+ x.setUpdateTime(x.getUpdateTime()+time);
|
|
|
+ });
|
|
|
+ iUserStudyRecordPhotoService.updateBatchById(photoList);
|
|
|
+ }
|
|
|
+ periodStatusList.forEach(y -> {
|
|
|
+ y.setCreateTime(y.getCreateTime()+time);
|
|
|
+ y.setUpdateTime(y.getUpdateTime()+time);
|
|
|
+ y.setRecordStartTime(y.getRecordStartTime()+time);
|
|
|
+ y.setRecordEndTime(y.getRecordEndTime()+time);
|
|
|
+ y.setAuditTime(y.getAuditTime()+time);
|
|
|
+ });
|
|
|
+ iUserPeriodStatusService.updateBatchById(periodStatusList);
|
|
|
+ }
|
|
|
+
|
|
|
+ userPeriods.forEach(k -> {
|
|
|
+ k.setCreateTime(k.getCreateTime()+time);
|
|
|
+ k.setUpdateTime(k.getUpdateTime()+time);
|
|
|
+ });
|
|
|
+ iUserPeriodService.updateBatchById(userPeriods);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<CoursePhotoLog> coursePhotoLogs = iCoursePhotoLogService
|
|
|
+ .list(new LambdaQueryWrapper<CoursePhotoLog>().eq(CoursePhotoLog::getOrderGoodsId, bo.getOrderGoodsId()).eq(CoursePhotoLog::getGradeId, bo.getGradeId()));
|
|
|
+ if (CollectionUtils.isNotEmpty(coursePhotoLogs)){
|
|
|
+ coursePhotoLogs.forEach(j -> {
|
|
|
+ j.setCreateTime(j.getCreateTime()+time);
|
|
|
+ j.setUpdateTime(j.getUpdateTime()+time);
|
|
|
+ });
|
|
|
+ iCoursePhotoLogService.updateBatchById(coursePhotoLogs);
|
|
|
+ }
|
|
|
+
|
|
|
+ userStudyRecords.forEach(l -> {
|
|
|
+ l.setCreateTime(l.getCreateTime()+time);
|
|
|
+ l.setUpdateTime(l.getUpdateTime()+time);
|
|
|
+ l.setStartTime(l.getStartTime()+time);
|
|
|
+ l.setEndTime(l.getEndTime()+time);
|
|
|
+ l.setFirstStartTime(l.getFirstStartTime()+time);
|
|
|
+ });
|
|
|
+ iUserStudyRecordService.updateBatchById(userStudyRecords);
|
|
|
+
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
}
|