|
@@ -4,6 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.convert.Convert;
|
|
import cn.hutool.core.convert.Convert;
|
|
import cn.hutool.core.lang.Validator;
|
|
import cn.hutool.core.lang.Validator;
|
|
import cn.hutool.core.util.StrUtil;
|
|
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.CollectionUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.modules.course.vo.CourseVo;
|
|
import com.zhongzheng.modules.course.vo.CourseVo;
|
|
@@ -42,7 +44,11 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
@Override
|
|
@Override
|
|
public UserPlanVo queryById(Long planId){
|
|
public UserPlanVo queryById(Long planId){
|
|
UserPlan db = this.baseMapper.selectById(planId);
|
|
UserPlan db = this.baseMapper.selectById(planId);
|
|
- return BeanUtil.toBean(db, UserPlanVo.class);
|
|
|
|
|
|
+ UserPlanVo userPlanVo = BeanUtil.toBean(db, UserPlanVo.class);
|
|
|
|
+ //得到日历日期
|
|
|
|
+ List<CalendarStudyVo> calendarStudyVos = JSONObject.parseArray(userPlanVo.getSchedule(), CalendarStudyVo.class);
|
|
|
|
+ userPlanVo.setCalendarStudyVo(calendarStudyVos);
|
|
|
|
+ return userPlanVo;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -56,10 +62,17 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
lqw.eq(bo.getStudyDay() != null, UserPlan::getStudyDay, bo.getStudyDay());
|
|
lqw.eq(bo.getStudyDay() != null, UserPlan::getStudyDay, bo.getStudyDay());
|
|
lqw.eq(bo.getEndTime() != null, UserPlan::getEndTime, bo.getEndTime());
|
|
lqw.eq(bo.getEndTime() != null, UserPlan::getEndTime, bo.getEndTime());
|
|
lqw.eq(bo.getStartTime() != null, UserPlan::getStartTime, bo.getStartTime());
|
|
lqw.eq(bo.getStartTime() != null, UserPlan::getStartTime, bo.getStartTime());
|
|
- lqw.eq(bo.getStatus() != null, UserPlan::getStatus, bo.getStatus());
|
|
|
|
|
|
+ lqw.in(bo.getStatus() != null, UserPlan::getStatus, bo.getStatus());
|
|
lqw.eq(bo.getPitchNum() != null, UserPlan::getPitchNum, bo.getPitchNum());
|
|
lqw.eq(bo.getPitchNum() != null, UserPlan::getPitchNum, bo.getPitchNum());
|
|
lqw.eq(bo.getStudyNum() != null, UserPlan::getStudyNum, bo.getStudyNum());
|
|
lqw.eq(bo.getStudyNum() != null, UserPlan::getStudyNum, bo.getStudyNum());
|
|
- return entity2Vo(this.list(lqw));
|
|
|
|
|
|
+ List<UserPlanVo> userPlanVos = entity2Vo(this.list(lqw));
|
|
|
|
+ for (UserPlanVo userPlanVo : userPlanVos) {
|
|
|
|
+ //得到日历日期
|
|
|
|
+ List<CalendarStudyVo> calendarStudyVos = JSONObject.parseArray(userPlanVo.getSchedule(), CalendarStudyVo.class);
|
|
|
|
+ userPlanVo.setCalendarStudyVo(calendarStudyVos);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return userPlanVos;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -83,20 +96,130 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Boolean insertByAddBo(UserPlanAddBo bo) {
|
|
|
|
- UserPlan add = BeanUtil.toBean(bo, UserPlan.class);
|
|
|
|
- validEntityBeforeSave(add);
|
|
|
|
- add.setCreateTime(DateUtils.getNowTime());
|
|
|
|
- add.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
- return this.save(add);
|
|
|
|
|
|
+ public Boolean insertByAddBo(UserPlanAddBo bo) throws ParseException {
|
|
|
|
+ UserPlan userPlan = new UserPlan();
|
|
|
|
+ List<CalendarStudyVo> clCalendarStudyVos = findDates(bo.getStartTime(),bo.getEndTime());
|
|
|
|
+ Long sumUp=0L;
|
|
|
|
+ for (Long aLong : bo.getGoodsId()) {
|
|
|
|
+ //最近考试时间七天前到现在的天数,学习视频时长
|
|
|
|
+ Date date1 = new Date(bo.getEndTime() * 1000L);
|
|
|
|
+ //获得相隔天数
|
|
|
|
+ int dutyDays = getDutyDays(new Date(), date1, bo.getStudyCount(), bo.getStudyDay());
|
|
|
|
+
|
|
|
|
+ List<Long> seLongs = baseMapper.selectGoods(aLong);
|
|
|
|
+ Long allNum = 0L;
|
|
|
|
+ for (Long seLong : seLongs) {
|
|
|
|
+ allNum += seLong;
|
|
|
|
+ }
|
|
|
|
+ sumUp += allNum;
|
|
|
|
+ //计算每天需要学习多少节课
|
|
|
|
+ int Sec = (int) Math.ceil((double) allNum / dutyDays);
|
|
|
|
+ for (CalendarStudyVo clCalendarStudyVo : clCalendarStudyVos) {
|
|
|
|
+ for (DayStudyVo dayStudyVo : clCalendarStudyVo.getDayStudyList()) {
|
|
|
|
+ if (Arrays.asList(bo.getStudyCount()).contains(dayStudyVo.getStudyDay())){
|
|
|
|
+ if (dayStudyVo.getStudyCourseKnob() != null) {
|
|
|
|
+ dayStudyVo.setStudyCourseKnob(dayStudyVo.getStudyCourseKnob() + Sec);
|
|
|
|
+ }else {
|
|
|
|
+ dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
|
|
|
|
+ }
|
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
|
+ List<DaySectionVo> daySectionList = new ArrayList<>();
|
|
|
|
+ if (!CollectionUtils.isEmpty(dayStudyVo.getDaySectionList())) {
|
|
|
|
+ daySectionList = dayStudyVo.getDaySectionList();
|
|
|
|
+ }
|
|
|
|
+ DaySectionVo daySectionVo = new DaySectionVo();
|
|
|
|
+ daySectionVo.setGoodsId(aLong);
|
|
|
|
+ daySectionVo.setStudyGoodsKnob(Convert.toLong(Sec));
|
|
|
|
+ daySectionVo.setGoodsPerform(0);
|
|
|
|
+ daySectionList.add(daySectionVo);
|
|
|
|
+ dayStudyVo.setDaySectionList(daySectionList);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ String s = JSON.toJSONString(clCalendarStudyVos);
|
|
|
|
+ String s1 = JSON.toJSONString(bo.getStudyCount());
|
|
|
|
+ userPlan.setUserId(bo.getUserId());
|
|
|
|
+ userPlan.setSchedule(s);
|
|
|
|
+ userPlan.setStudyCount(s1);
|
|
|
|
+ userPlan.setPitchNum(sumUp);
|
|
|
|
+ userPlan.setStudyDay(bo.getStudyDay());
|
|
|
|
+ userPlan.setStudyNum(0L);
|
|
|
|
+ userPlan.setCreateTime(DateUtils.getNowTime());
|
|
|
|
+ userPlan.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
+ userPlan.setExamDate(bo.getExamDate());
|
|
|
|
+ userPlan.setStatus(1);
|
|
|
|
+ userPlan.setUserId(bo.getUserId());
|
|
|
|
+ userPlan.setStartTime(bo.getStartTime());
|
|
|
|
+ userPlan.setEndTime(bo.getEndTime());
|
|
|
|
+ userPlan.setReminderTime(bo.getReminderTime());
|
|
|
|
+ this.save(userPlan);
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Boolean updateByEditBo(UserPlanEditBo bo) {
|
|
|
|
- UserPlan update = BeanUtil.toBean(bo, UserPlan.class);
|
|
|
|
- validEntityBeforeSave(update);
|
|
|
|
- update.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
- return this.updateById(update);
|
|
|
|
|
|
+ public Boolean updateByEditBo(UserPlanEditBo bo) throws ParseException {
|
|
|
|
+ UserPlan userPlan = new UserPlan();
|
|
|
|
+ List<CalendarStudyVo> clCalendarStudyVos = findDates(bo.getStartTime(),bo.getEndTime());
|
|
|
|
+ Long sumUp=0L;
|
|
|
|
+ for (Long aLong : bo.getGoodsId()) {
|
|
|
|
+ //最近考试时间七天前到现在的天数,学习视频时长
|
|
|
|
+ Date date1 = new Date(bo.getEndTime() * 1000L);
|
|
|
|
+ //获得相隔天数
|
|
|
|
+ int dutyDays = getDutyDays(new Date(), date1, bo.getStudyCount(), bo.getStudyDay());
|
|
|
|
+
|
|
|
|
+ List<Long> seLongs = baseMapper.selectGoods(aLong);
|
|
|
|
+ Long allNum = 0L;
|
|
|
|
+ for (Long seLong : seLongs) {
|
|
|
|
+ allNum += seLong;
|
|
|
|
+ }
|
|
|
|
+ sumUp += allNum;
|
|
|
|
+ //计算每天需要学习多少节课
|
|
|
|
+ int Sec = (int) Math.ceil((double) allNum / dutyDays);
|
|
|
|
+ for (CalendarStudyVo clCalendarStudyVo : clCalendarStudyVos) {
|
|
|
|
+ for (DayStudyVo dayStudyVo : clCalendarStudyVo.getDayStudyList()) {
|
|
|
|
+ if (Arrays.asList(bo.getStudyCount()).contains(dayStudyVo.getStudyDay())){
|
|
|
|
+ if (dayStudyVo.getStudyCourseKnob() != null) {
|
|
|
|
+ dayStudyVo.setStudyCourseKnob(dayStudyVo.getStudyCourseKnob() + Sec);
|
|
|
|
+ }else {
|
|
|
|
+ dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
|
|
|
|
+ }
|
|
|
|
+ dayStudyVo.setPerform(0);
|
|
|
|
+ List<DaySectionVo> daySectionList = new ArrayList<>();
|
|
|
|
+ if (!CollectionUtils.isEmpty(dayStudyVo.getDaySectionList())) {
|
|
|
|
+ daySectionList = dayStudyVo.getDaySectionList();
|
|
|
|
+ }
|
|
|
|
+ DaySectionVo daySectionVo = new DaySectionVo();
|
|
|
|
+ daySectionVo.setGoodsId(aLong);
|
|
|
|
+ daySectionVo.setStudyGoodsKnob(Convert.toLong(Sec));
|
|
|
|
+ daySectionVo.setGoodsPerform(0);
|
|
|
|
+ daySectionList.add(daySectionVo);
|
|
|
|
+ dayStudyVo.setDaySectionList(daySectionList);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ String s = JSON.toJSONString(clCalendarStudyVos);
|
|
|
|
+ String s1 = JSON.toJSONString(bo.getStudyCount());
|
|
|
|
+ userPlan.setUserId(bo.getUserId());
|
|
|
|
+ userPlan.setSchedule(s);
|
|
|
|
+ userPlan.setStudyCount(s1);
|
|
|
|
+ userPlan.setPitchNum(sumUp);
|
|
|
|
+ userPlan.setStudyDay(bo.getStudyDay());
|
|
|
|
+ userPlan.setStudyNum(0L);
|
|
|
|
+ userPlan.setCreateTime(DateUtils.getNowTime());
|
|
|
|
+ userPlan.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
+ userPlan.setExamDate(bo.getExamDate());
|
|
|
|
+ userPlan.setStatus(1);
|
|
|
|
+ userPlan.setUserId(bo.getUserId());
|
|
|
|
+ userPlan.setStartTime(bo.getStartTime());
|
|
|
|
+ userPlan.setEndTime(bo.getEndTime());
|
|
|
|
+ userPlan.setReminderTime(bo.getReminderTime());
|
|
|
|
+ userPlan.setPlanId(bo.getPlanId());
|
|
|
|
+ this.updateById(userPlan);
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|