|
@@ -53,8 +53,8 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public UserPlanVo queryById(Long planId,Long UserId){
|
|
|
- UserPlan userPlan = this.baseMapper.selectById(planId);
|
|
|
+ public UserPlanVo queryById(UserPlanQueryBo bo){
|
|
|
+ UserPlan userPlan = this.baseMapper.selectById(bo.getPlanId());
|
|
|
//得到日历日期
|
|
|
UserPlanVo userPlanVo = new UserPlanVo();
|
|
|
userPlanVo.setUserId(userPlan.getUserId());
|
|
@@ -66,7 +66,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
userPlanVo.setPitchNum(userPlan.getPitchNum());
|
|
|
userPlanVo.setStudyNum(userPlan.getStudyNum());
|
|
|
userPlanVo.setPlanId(userPlan.getPlanId());
|
|
|
- List<GoodsUserVo> goodsVos = userPlanGoodsService.selectGoods(planId,UserId);
|
|
|
+ List<GoodsUserVo> goodsVos = userPlanGoodsService.selectGoods(bo.getPlanId(),bo.getUserId());
|
|
|
userPlanVo.setGoodsVos(goodsVos);
|
|
|
// List转成数组
|
|
|
Long[] array = new Long[goodsVos.size()];
|
|
@@ -79,6 +79,10 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
userPlanVo.setGoodsId(array);
|
|
|
//得到日历日期
|
|
|
List<CalendarStudyVo> calendarStudyVos = JSONObject.parseArray(userPlan.getSchedule(), CalendarStudyVo.class);
|
|
|
+ if (bo.getMonth() != null){
|
|
|
+ calendarStudyVos=calendarStudyVos.stream().filter(CalendarStudyVo -> CalendarStudyVo.getMonth().equals(bo.getMonth())).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
//得到学习的周
|
|
|
List<Long> cont = JSONObject.parseArray(userPlan.getStudyCount(), Long.class);
|
|
|
Long[] strings = new Long[cont.size()];
|
|
@@ -621,6 +625,70 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
return baseMapper.listGoods(bo);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public UserPlanVo userPlanSeven(UserPlanQueryBo bo) throws ParseException {
|
|
|
+ UserPlan userPlan = this.baseMapper.selectById(bo.getPlanId());
|
|
|
+ //得到日历日期
|
|
|
+ UserPlanVo userPlanVo = new UserPlanVo();
|
|
|
+ userPlanVo.setUserId(userPlan.getUserId());
|
|
|
+ userPlanVo.setExamDate(userPlan.getExamDate());
|
|
|
+ userPlanVo.setReminderTime(userPlan.getReminderTime());
|
|
|
+ userPlanVo.setStudyDay(userPlan.getStudyDay());
|
|
|
+ userPlanVo.setStartTime(userPlan.getStartTime());
|
|
|
+ userPlanVo.setEndTime(userPlan.getEndTime());
|
|
|
+ userPlanVo.setPitchNum(userPlan.getPitchNum());
|
|
|
+ userPlanVo.setStudyNum(userPlan.getStudyNum());
|
|
|
+ userPlanVo.setPlanId(userPlan.getPlanId());
|
|
|
+ List<GoodsUserVo> goodsVos = userPlanGoodsService.selectGoods(bo.getPlanId(),bo.getUserId());
|
|
|
+ userPlanVo.setGoodsVos(goodsVos);
|
|
|
+ // List转成数组
|
|
|
+ Long[] array = new Long[goodsVos.size()];
|
|
|
+ // 输出数组
|
|
|
+ List<Long> arrys = new ArrayList<>();
|
|
|
+ for (GoodsUserVo goodsVo : goodsVos) {
|
|
|
+ arrys.add(goodsVo.getGoodsId());
|
|
|
+ }
|
|
|
+ arrys.toArray(array);
|
|
|
+ userPlanVo.setGoodsId(array);
|
|
|
+ //得到日历日期
|
|
|
+ List<CalendarStudyVo> calendarStudyVos = JSONObject.parseArray(userPlan.getSchedule(), CalendarStudyVo.class);
|
|
|
+
|
|
|
+ Calendar cal=Calendar.getInstance();
|
|
|
+ cal.add(Calendar.WEEK_OF_MONTH, 0);
|
|
|
+ cal.set(Calendar.DAY_OF_WEEK, 2);
|
|
|
+ Long timeInMillisStart = cal.getTimeInMillis()/1000-86400;
|
|
|
+ Calendar cal2=Calendar.getInstance();
|
|
|
+ cal2.set(Calendar.DAY_OF_WEEK, cal.getActualMaximum(Calendar.DAY_OF_WEEK));
|
|
|
+ cal2.add(Calendar.DAY_OF_WEEK, 1);
|
|
|
+ Long timeInMillis = cal2.getTimeInMillis()/1000;
|
|
|
+ List<CalendarStudyVo> sevenDates = findSevenDates(timeInMillisStart, timeInMillis);
|
|
|
+ for (CalendarStudyVo sevenDate : sevenDates) {
|
|
|
+ for (DayStudyVo dayStudyVo : sevenDate.getDayStudyList()) {
|
|
|
+ List<CalendarStudyVo> collect = calendarStudyVos.stream().filter(CalendarStudyVo -> CalendarStudyVo.getMonth().equals(sevenDate.getMonth())).collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(collect)) {
|
|
|
+ for (CalendarStudyVo calendarStudyVo : collect) {
|
|
|
+ for (DayStudyVo studyVo : calendarStudyVo.getDayStudyList()) {
|
|
|
+ if (studyVo.getDate().equals(dayStudyVo.getDate())){
|
|
|
+ dayStudyVo.setStudyCourseKnob(studyVo.getStudyCourseKnob());
|
|
|
+ dayStudyVo.setPerform(studyVo.getPerform());
|
|
|
+ dayStudyVo.setDaySectionList(studyVo.getDaySectionList());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //得到学习的周
|
|
|
+ List<Long> cont = JSONObject.parseArray(userPlan.getStudyCount(), Long.class);
|
|
|
+ Long[] strings = new Long[cont.size()];
|
|
|
+ cont.toArray(strings);
|
|
|
+
|
|
|
+ userPlanVo.setCalendarStudyVo(sevenDates);
|
|
|
+ userPlanVo.setStudyCount(strings);
|
|
|
+ return userPlanVo;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 保存前的数据校验
|
|
@@ -634,4 +702,53 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
throw new IllegalArgumentException("此网课学习计划正在进行中,若想再次制定请将计划完成或删除");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //获得日历
|
|
|
+ public static List<CalendarStudyVo> findSevenDates(Long dBegin, Long dEnd) throws ParseException, java.text.ParseException {
|
|
|
+ Long timeStamp = System.currentTimeMillis(); //获取当前时间戳
|
|
|
+ SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String dBeginS = sdf.format(new Date(Long.parseLong(String.valueOf(dBegin*1000)))); // 时间戳转换成时间
|
|
|
+ String dEndS = sdf.format(new Date(Long.parseLong(String.valueOf(dEnd*1000)))); // 时间戳转换成时间
|
|
|
+
|
|
|
+ //日期工具类准备
|
|
|
+ DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+
|
|
|
+ //设置开始时间
|
|
|
+ Calendar calBegin = Calendar.getInstance();
|
|
|
+ calBegin.setTime(format.parse(dBeginS));
|
|
|
+
|
|
|
+ //设置结束时间
|
|
|
+ Calendar calEnd = Calendar.getInstance();
|
|
|
+ calEnd.setTime(format.parse(dEndS));
|
|
|
+
|
|
|
+ //装返回的日期集合容器
|
|
|
+ List<CalendarStudyVo> Datelist = new ArrayList<CalendarStudyVo>();
|
|
|
+
|
|
|
+ CalendarStudyVo calendarStudyVo = new CalendarStudyVo();
|
|
|
+ List<DayStudyVo> dayStudyList = new ArrayList<>();
|
|
|
+ // 每次循环给calBegin日期加一天,直到calBegin.getTime()时间等于dEnd
|
|
|
+ while (format.parse(dEndS).after(calBegin.getTime())) {
|
|
|
+ if (calendarStudyVo.getMonth() == null){
|
|
|
+ calendarStudyVo.setMonth(Convert.toLong(calBegin.get(java.util.Calendar.MONTH)+1));
|
|
|
+ calendarStudyVo.setYear(Convert.toLong(calBegin.get(java.util.Calendar.YEAR)));
|
|
|
+ }
|
|
|
+ if (calendarStudyVo.getMonth() != null && calendarStudyVo.getMonth() != (calBegin.get(java.util.Calendar.MONTH)+1)){
|
|
|
+ calendarStudyVo.setDayStudyList(dayStudyList);
|
|
|
+ Datelist.add(calendarStudyVo);
|
|
|
+ calendarStudyVo = new CalendarStudyVo();
|
|
|
+ dayStudyList = new ArrayList<>();
|
|
|
+ calendarStudyVo.setMonth(Convert.toLong(calBegin.get(java.util.Calendar.MONTH)+1));
|
|
|
+ calendarStudyVo.setYear(Convert.toLong(calBegin.get(java.util.Calendar.YEAR)));
|
|
|
+ }
|
|
|
+ DayStudyVo dayStudyVo = new DayStudyVo();
|
|
|
+ dayStudyVo.setDate(Convert.toLong(calBegin.get(Calendar.DATE)));
|
|
|
+ dayStudyVo.setStudyDay(Convert.toLong(calBegin.get(Calendar.DAY_OF_WEEK)-1));
|
|
|
+ dayStudyList.add(dayStudyVo);
|
|
|
+ // 根据日历的规则,为给定的日历字段添加或减去指定的时间量
|
|
|
+ calBegin.add(Calendar.DAY_OF_MONTH, 1);
|
|
|
+ }
|
|
|
+ calendarStudyVo.setDayStudyList(dayStudyList);
|
|
|
+ Datelist.add(calendarStudyVo);
|
|
|
+ return Datelist;
|
|
|
+ }
|
|
|
}
|