|
@@ -3,11 +3,15 @@ package com.zhongzheng.modules.user.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.microsoft.schemas.office.visio.x2012.main.SectionType;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.modules.bank.domain.Exam;
|
|
|
+import com.zhongzheng.modules.face.service.IFaceService;
|
|
|
+import com.zhongzheng.modules.goods.vo.GoodsUserVo;
|
|
|
import com.zhongzheng.modules.grade.bo.UserPeriodAddBo;
|
|
|
import com.zhongzheng.modules.grade.bo.UserPeriodStatusAddBo;
|
|
|
import com.zhongzheng.modules.grade.domain.UserPeriod;
|
|
@@ -16,8 +20,11 @@ import com.zhongzheng.modules.grade.service.IUserPeriodService;
|
|
|
import com.zhongzheng.modules.grade.service.IUserPeriodStatusService;
|
|
|
import com.zhongzheng.modules.grade.vo.UserPeriodStatusVo;
|
|
|
import com.zhongzheng.modules.user.bo.*;
|
|
|
+import com.zhongzheng.modules.user.domain.UserPlan;
|
|
|
import com.zhongzheng.modules.user.domain.UserStudyRecord;
|
|
|
import com.zhongzheng.modules.user.mapper.UserStudyRecordMapper;
|
|
|
+import com.zhongzheng.modules.user.service.IUserPlanGoodsService;
|
|
|
+import com.zhongzheng.modules.user.service.IUserPlanService;
|
|
|
import com.zhongzheng.modules.user.service.IUserStudyRecordPhotoService;
|
|
|
import com.zhongzheng.modules.user.service.IUserStudyRecordService;
|
|
|
import com.zhongzheng.modules.user.vo.*;
|
|
@@ -30,6 +37,7 @@ import com.github.pagehelper.Page;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.Calendar;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
@@ -60,11 +68,12 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
|
@Autowired
|
|
|
private IUserPeriodStatusService iUserPeriodStatusService;
|
|
|
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private IUserPlanService userPlanService;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public UserStudyRecordVo queryById(Long recordId){
|
|
|
+ public UserStudyRecordVo queryById(Long recordId) {
|
|
|
UserStudyRecord db = this.baseMapper.selectById(recordId);
|
|
|
return BeanUtil.toBean(db, UserStudyRecordVo.class);
|
|
|
}
|
|
@@ -78,7 +87,7 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
|
lqw.eq(bo.getGoodsId() != null, UserStudyRecord::getGoodsId, bo.getGoodsId());
|
|
|
lqw.eq(bo.getModuleId() != null, UserStudyRecord::getModuleId, bo.getModuleId());
|
|
|
lqw.orderByDesc(UserStudyRecord::getRecordId);
|
|
|
- return BeanUtil.toBean(this.getOne(lqw.last("limit 1")), UserStudyRecordVo.class);
|
|
|
+ return BeanUtil.toBean(this.getOne(lqw.last("limit 1")), UserStudyRecordVo.class);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -99,19 +108,19 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 实体类转化成视图对象
|
|
|
- *
|
|
|
- * @param collection 实体类集合
|
|
|
- * @return
|
|
|
- */
|
|
|
+ * 实体类转化成视图对象
|
|
|
+ *
|
|
|
+ * @param collection 实体类集合
|
|
|
+ * @return
|
|
|
+ */
|
|
|
private List<UserStudyRecordVo> entity2Vo(Collection<UserStudyRecord> collection) {
|
|
|
List<UserStudyRecordVo> voList = collection.stream()
|
|
|
.map(any -> BeanUtil.toBean(any, UserStudyRecordVo.class))
|
|
|
.collect(Collectors.toList());
|
|
|
if (collection instanceof Page) {
|
|
|
- Page<UserStudyRecord> page = (Page<UserStudyRecord>)collection;
|
|
|
+ Page<UserStudyRecord> page = (Page<UserStudyRecord>) collection;
|
|
|
Page<UserStudyRecordVo> pageVo = new Page<>();
|
|
|
- BeanUtil.copyProperties(page,pageVo);
|
|
|
+ BeanUtil.copyProperties(page, pageVo);
|
|
|
pageVo.addAll(voList);
|
|
|
voList = pageVo;
|
|
|
}
|
|
@@ -125,11 +134,11 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
|
validEntityBeforeSave(add);
|
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
|
- add.setStartTime(DateUtils.getNowTime()-add.getStudyDuration());
|
|
|
+ add.setStartTime(DateUtils.getNowTime() - add.getStudyDuration());
|
|
|
add.setEndTime(DateUtils.getNowTime());
|
|
|
this.save(add);
|
|
|
//新增学时记录,照片
|
|
|
- userPeriodSave(add,bo);
|
|
|
+ userPeriodSave(add, bo);
|
|
|
//完成当天学习计划
|
|
|
userPlanSave(add);
|
|
|
return 0;
|
|
@@ -148,16 +157,16 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
|
*
|
|
|
* @param entity 实体类数据
|
|
|
*/
|
|
|
- private void validEntityBeforeSave(UserStudyRecord entity){
|
|
|
+ private void validEntityBeforeSave(UserStudyRecord entity) {
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void userPeriodSave(UserStudyRecord entity,UserStudyRecordAddBo bo){
|
|
|
+ private void userPeriodSave(UserStudyRecord entity, UserStudyRecordAddBo bo) {
|
|
|
//记录学时审核
|
|
|
Long periodId = null;
|
|
|
// 学习无记录加一条学时审核记录
|
|
|
- if (baseMapper.selectStudyRecord(entity) < 1){
|
|
|
+ if (baseMapper.selectStudyRecord(entity) < 1) {
|
|
|
UserPeriod userPeriod = new UserPeriod();
|
|
|
userPeriod.setUserId(entity.getUserId());
|
|
|
userPeriod.setCourseId(entity.getCourseId());
|
|
@@ -182,7 +191,7 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
|
userPeriodStatusAddBo.setCreateTime(DateUtils.getNowTime());
|
|
|
userPeriodStatusAddBo.setUpdateTime(DateUtils.getNowTime());
|
|
|
iUserPeriodStatusService.save(userPeriodStatusAddBo);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//待审有结束时间跳过下面两步
|
|
|
if (baseMapper.selectPeriod(entity) < 1) {
|
|
|
//有学习记录时审核记录0作弊或3待重修更改为待审核,完整播放也添加结束时间
|
|
@@ -197,18 +206,18 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
|
userPeriodStatusAddBo.setRecordStartTime(entity.getStartTime());
|
|
|
userPeriodStatusAddBo.setCreateTime(DateUtils.getNowTime());
|
|
|
userPeriodStatusAddBo.setUpdateTime(DateUtils.getNowTime());
|
|
|
- if (entity.getStatus() != null && entity.getStatus() ==1) {
|
|
|
+ if (entity.getStatus() != null && entity.getStatus() == 1) {
|
|
|
userPeriodStatusAddBo.setRecordEndTime(entity.getEndTime());
|
|
|
}
|
|
|
iUserPeriodStatusService.save(userPeriodStatusAddBo);
|
|
|
periodId = userPeriodStatusAddBo.getId();
|
|
|
- } else if (userPeriodStatus.getStatus() == 3){
|
|
|
+ } else if (userPeriodStatus.getStatus() == 3) {
|
|
|
userPeriodStatus.setPeriodStatus(1);
|
|
|
userPeriodStatus.setStatus(2);
|
|
|
userPeriodStatus.setRecordStartTime(entity.getStartTime());
|
|
|
userPeriodStatus.setCreateTime(DateUtils.getNowTime());
|
|
|
userPeriodStatus.setUpdateTime(DateUtils.getNowTime());
|
|
|
- if (entity.getStatus() != null && entity.getStatus() ==1) {
|
|
|
+ if (entity.getStatus() != null && entity.getStatus() == 1) {
|
|
|
userPeriodStatus.setRecordEndTime(entity.getEndTime());
|
|
|
}
|
|
|
iUserPeriodStatusService.updateById(userPeriodStatus);
|
|
@@ -239,14 +248,65 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void userPlanSave(UserStudyRecord entity){
|
|
|
+ private void userPlanSave(UserStudyRecord entity) {
|
|
|
//搜索该用户得商品有没有计划没有跳过,完整播放且计划里没有该学习记录更新学习计划状态
|
|
|
- // if (baseMapper.userPlanSave(entity.getGoodsId()) > 0){}
|
|
|
+ if (baseMapper.userPlanSave(entity.getGoodsId()) > 0 && entity.getStatus().equals(1)) {
|
|
|
+ Long planId = baseMapper.userPlanSaveId(entity.getGoodsId());
|
|
|
+ entity.setPlanId(planId);
|
|
|
+ if (baseMapper.selectPland(entity) < 1) {
|
|
|
+ this.updateById(entity);
|
|
|
+ List<Long> goodsIds = baseMapper.getPlanGoods(planId);
|
|
|
+ //更新计划
|
|
|
+ UserPlanQueryBo userPlanQueryBo = new UserPlanQueryBo();
|
|
|
+ userPlanQueryBo.setPlanId(planId);
|
|
|
+ userPlanQueryBo.setUserId(entity.getUserId());
|
|
|
+ UserPlanVo userPlanVo = userPlanService.queryById(userPlanQueryBo);
|
|
|
+ Calendar rightNow = Calendar.getInstance();
|
|
|
+ boolean status = true;
|
|
|
+ //得到日历日期
|
|
|
+ List<CalendarStudyVo> calendarStudyVo = userPlanVo.getCalendarStudyVo();
|
|
|
+ calendarStudyVo = calendarStudyVo.stream().filter(CalendarStudyVo -> CalendarStudyVo.getMonth().equals(rightNow.get(Calendar.MONTH) + 1)).collect(Collectors.toList());
|
|
|
+ //对比今天学习的数量是否更新完成
|
|
|
+ if (CollectionUtils.isNotEmpty(calendarStudyVo)) {
|
|
|
+ for (CalendarStudyVo studyVo : calendarStudyVo) {
|
|
|
+ List<DayStudyVo> collect = studyVo.getDayStudyList();
|
|
|
+ collect = studyVo.getDayStudyList().stream().filter(dayStudyVo -> dayStudyVo.getDate().equals(rightNow.get(Calendar.DAY_OF_MONTH))).collect(Collectors.toList());
|
|
|
+ for (DayStudyVo dayStudyVo : collect) {
|
|
|
+ for (DaySectionVo daySectionVo : dayStudyVo.getDaySectionList()) {
|
|
|
+ Long count = baseMapper.selectPlandCount(daySectionVo.getGoodsId(), entity.getPlanId());
|
|
|
+ if (count < daySectionVo.getStudyGoodsKnob()) {
|
|
|
+ status = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (status) {
|
|
|
+ List<CalendarStudyVo> calendarStudyUp = userPlanVo.getCalendarStudyVo();
|
|
|
+ for (CalendarStudyVo studyVo : calendarStudyUp) {
|
|
|
+ if (studyVo.getMonth().equals((rightNow.get(Calendar.MONTH) + 1)) && studyVo.getYear().equals(rightNow.get(Calendar.YEAR))) {
|
|
|
+ for (DayStudyVo dayStudyVo : studyVo.getDayStudyList()) {
|
|
|
+ if (dayStudyVo.getDate().equals(Calendar.DAY_OF_MONTH)) {
|
|
|
+ dayStudyVo.setPerform(1);
|
|
|
+ for (DaySectionVo daySectionVo : dayStudyVo.getDaySectionList()) {
|
|
|
+ daySectionVo.setGoodsPerform(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ UserPlan userPlan = new UserPlan();
|
|
|
+ userPlan.setSchedule(JSON.toJSONString(calendarStudyUp));
|
|
|
+ userPlan.setPlanId(userPlanVo.getPlanId());
|
|
|
+ userPlanService.updateById(userPlan);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
+ if (isValid) {
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
|
return this.removeByIds(ids);
|
|
@@ -254,7 +314,7 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
|
|
|
|
@Override
|
|
|
public List<UserStudyRecord> selectUserStudy(Long userId, Integer courseId) {
|
|
|
- return baseMapper.selectUserStudy(userId,courseId);
|
|
|
+ return baseMapper.selectUserStudy(userId, courseId);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -274,20 +334,20 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
|
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 (CollectionUtils.isNotEmpty(baseMapper.sectionType(subjectStudyRecordVo.getCourseId(),1L))){
|
|
|
+ if (CollectionUtils.isNotEmpty(baseMapper.sectionType(subjectStudyRecordVo.getCourseId(), 1L))) {
|
|
|
sectionType = sectionType.concat("1,");
|
|
|
}
|
|
|
- if (CollectionUtils.isNotEmpty(baseMapper.sectionType(subjectStudyRecordVo.getCourseId(),2L))){
|
|
|
+ if (CollectionUtils.isNotEmpty(baseMapper.sectionType(subjectStudyRecordVo.getCourseId(), 2L))) {
|
|
|
sectionType = sectionType.concat("2,");
|
|
|
}
|
|
|
- if (CollectionUtils.isNotEmpty(baseMapper.sectionType(subjectStudyRecordVo.getCourseId(),3L))){
|
|
|
+ if (CollectionUtils.isNotEmpty(baseMapper.sectionType(subjectStudyRecordVo.getCourseId(), 3L))) {
|
|
|
sectionType = sectionType.concat("3,");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(sectionType)) {
|
|
|
subjectStudyRecordVo.setSectionType(sectionType.substring(0, sectionType.length() - 1));
|
|
|
}
|
|
|
}
|
|
|
- BigDecimal divide =new BigDecimal("0");
|
|
|
+ BigDecimal divide = new BigDecimal("0");
|
|
|
if (secLong != 0) {
|
|
|
divide = new BigDecimal(studyLong.toString()).divide(new BigDecimal(secLong.toString()), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
@@ -310,7 +370,7 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
|
public List<SectionStudyRecordVo> listSection(SubjectStudyRecordQueryBo bo) {
|
|
|
List<SectionStudyRecordVo> sectionStudyRecordVos = baseMapper.listSection(bo);
|
|
|
for (SectionStudyRecordVo sectionStudyRecordVo : sectionStudyRecordVos) {
|
|
|
- if (sectionStudyRecordVo.getStartTime() == null){
|
|
|
+ if (sectionStudyRecordVo.getStartTime() == null) {
|
|
|
sectionStudyRecordVo.setStatus(2L);
|
|
|
}
|
|
|
}
|
|
@@ -330,7 +390,7 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
|
String s = "";
|
|
|
for (String examType : examTypes) {
|
|
|
if (StringUtils.isNotBlank(examType)) {
|
|
|
- s= s.concat(examType + ",");
|
|
|
+ s = s.concat(examType + ",");
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(s)) {
|