|
|
@@ -386,43 +386,132 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
|
|
|
public UserPlanVo userPlanSeven(UserPlanQueryBo bo) {
|
|
|
List<UserPlan> userPlans = baseMapper.selectByUserPlan(bo);
|
|
|
UserPlanVo userPlanVos = new UserPlanVo();
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
if (!CollectionUtils.isEmpty(userPlans)) {
|
|
|
UserPlan userPlan = userPlans.get(0);
|
|
|
- Calendar cal = Calendar.getInstance();
|
|
|
|
|
|
//得到日历日期
|
|
|
List<CalendarStudyVo> calendarStudyVos = JSONObject.parseArray(userPlan.getSchedule(), CalendarStudyVo.class);
|
|
|
|
|
|
|
|
|
- //获得计划的课程
|
|
|
- List<UserPlanCource> userPlanClsList = baseMapper.selectCourse(userPlan.getPlanId());
|
|
|
- //初始化需要得到的数组
|
|
|
- Integer[] array = new Integer[userPlanClsList.size()];
|
|
|
- //使用for循环得到数组
|
|
|
- for(int i = 0; i < userPlanClsList.size();i++){
|
|
|
- array[i] = Convert.toInt(userPlanClsList.get(i).getSourceId());
|
|
|
- }
|
|
|
- bo.setCourseId(array);
|
|
|
- List<CoursePlanVo> coursePlanVo = baseMapper.selectByListCourse(bo);
|
|
|
+ //获得计划的课程
|
|
|
+ List<UserPlanCource> userPlanClsList = baseMapper.selectCourse(userPlan.getPlanId());
|
|
|
+ //初始化需要得到的数组
|
|
|
+ Integer[] array = new Integer[userPlanClsList.size()];
|
|
|
+ //使用for循环得到数组
|
|
|
+ for(int i = 0; i < userPlanClsList.size();i++){
|
|
|
+ array[i] = Convert.toInt(userPlanClsList.get(i).getSourceId());
|
|
|
+ }
|
|
|
+ bo.setCourseId(array);
|
|
|
+ List<CoursePlanVo> coursePlanVo = baseMapper.selectByListCourse(bo);
|
|
|
|
|
|
userPlanVos.setCoursePlanVo(coursePlanVo);
|
|
|
List<DayStudyVo> dayStudyVos = new ArrayList<>();
|
|
|
- calendarStudyVos.stream().filter(c -> c.getMonth() == cal.get(Calendar.MONTH + 1)).forEach(c -> {
|
|
|
- List<DayStudyVo> collect = c.getDayStudyList().stream()
|
|
|
- .filter(v -> v.getDate() < 7 + cal.get(Calendar.DAY_OF_MONTH) || v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 7)
|
|
|
- .collect(Collectors.toList());
|
|
|
+ List<DayStudyVo> finalDayStudyVos = dayStudyVos;
|
|
|
+ calendarStudyVos.stream().filter(c -> c.getMonth() == (cal.get(Calendar.MONTH)+1))
|
|
|
+ .forEach(c -> {
|
|
|
+ finalDayStudyVos.addAll(c.getDayStudyList().stream()
|
|
|
+ .filter(v -> v.getDate() < 7 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 7)
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ });
|
|
|
+ switch (cal.get(Calendar.DAY_OF_WEEK)- 1){
|
|
|
+ case 0:
|
|
|
+ dayStudyVos=finalDayStudyVos.stream()
|
|
|
+ .filter(v -> v.getDate() <= cal.get(Calendar.DAY_OF_MONTH) + 7)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ dayStudyVos=finalDayStudyVos.stream()
|
|
|
+ .filter(v -> v.getDate() < 6 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() >= cal.get(Calendar.DAY_OF_MONTH) -1)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ dayStudyVos=finalDayStudyVos.stream()
|
|
|
+ .filter(v -> v.getDate() < 5 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() >= cal.get(Calendar.DAY_OF_MONTH) - 2)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ dayStudyVos=finalDayStudyVos.stream()
|
|
|
+ .filter(v -> v.getDate() < 4 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 3)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ dayStudyVos=finalDayStudyVos.stream()
|
|
|
+ .filter(v -> v.getDate() < 3 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 4)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ dayStudyVos=finalDayStudyVos.stream()
|
|
|
+ .filter(v -> v.getDate() < 2 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 5)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ dayStudyVos=finalDayStudyVos.stream()
|
|
|
+ .filter(v -> v.getDate() < 1 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 6)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ List<DayStudyVo> finalDayStudyVos1 = dayStudyVos;
|
|
|
+ calendarStudyVos.stream().forEach(c -> {
|
|
|
+ c.setDayStudyList(finalDayStudyVos1);
|
|
|
});
|
|
|
userPlanVos.setCalendarStudyVo(calendarStudyVos);
|
|
|
+ }else {
|
|
|
+ //得到日历日期
|
|
|
+ List<CalendarStudyVo> calendarStudyVos = new ArrayList<>();
|
|
|
+ Long firstDayOfMonth = getFirstDayOfMonth(cal.get(Calendar.MONTH)+1);
|
|
|
+ Long lastDayOfMonth = getLastDayOfMonth(cal.get(Calendar.MONTH)+1);
|
|
|
+ List<DayStudyVo> dayStudyVos = getDays(firstDayOfMonth,lastDayOfMonth);
|
|
|
+ switch (cal.get(Calendar.DAY_OF_WEEK)- 1){
|
|
|
+ case 0:
|
|
|
+ dayStudyVos=dayStudyVos.stream()
|
|
|
+ .filter(v -> v.getDate() <= cal.get(Calendar.DAY_OF_MONTH) + 7)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ dayStudyVos=dayStudyVos.stream()
|
|
|
+ .filter(v -> v.getDate() < 6 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() >= cal.get(Calendar.DAY_OF_MONTH) -1)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ dayStudyVos=dayStudyVos.stream()
|
|
|
+ .filter(v -> v.getDate() < 5 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() >= cal.get(Calendar.DAY_OF_MONTH) - 2)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ dayStudyVos=dayStudyVos.stream()
|
|
|
+ .filter(v -> v.getDate() < 4 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 3)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ dayStudyVos=dayStudyVos.stream()
|
|
|
+ .filter(v -> v.getDate() < 3 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 4)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ dayStudyVos=dayStudyVos.stream()
|
|
|
+ .filter(v -> v.getDate() < 2 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 5)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ dayStudyVos=dayStudyVos.stream()
|
|
|
+ .filter(v -> v.getDate() < 1 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() > cal.get(Calendar.DAY_OF_MONTH) - 6)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ CalendarStudyVo calendarStudyVo = new CalendarStudyVo();
|
|
|
+ calendarStudyVo.setDayStudyList(dayStudyVos);
|
|
|
+ calendarStudyVo.setYear(Convert.toLong(cal.get(Calendar.YEAR)));
|
|
|
+ calendarStudyVo.setMonth(Convert.toLong(cal.get(Calendar.MONTH)+1));
|
|
|
+ calendarStudyVos.add(calendarStudyVo);
|
|
|
+ userPlanVos.setCalendarStudyVo(calendarStudyVos);
|
|
|
}
|
|
|
|
|
|
|
|
|
return userPlanVos;
|
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
- Calendar cal = Calendar.getInstance();
|
|
|
- System.out.println();
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
private UserPlanVo generateSelfBo(UserPlanQueryBo bo) throws ParseException {
|
|
|
|