he2802 hace 4 años
padre
commit
35b53290d6

+ 21 - 3
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserPlanServiceImpl.java

@@ -218,6 +218,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
     public List<UserPlanVo> userPlan(UserPlanQueryBo bo) {
         List<UserPlan> userPlans = baseMapper.selectByUserPlan(bo);
         List<UserPlanVo> userPlanVos = new ArrayList<>();
+        Calendar cal = Calendar.getInstance();
         for (UserPlan userPlan : userPlans) {
             UserPlanVo userPlanVo = new UserPlanVo();
             userPlanVo.setUserId(userPlan.getUserId());
@@ -232,24 +233,41 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
 
             //得到日历日期
             List<CalendarStudyVo> calendarStudyVos = JSONObject.parseArray(userPlan.getSchedule(), CalendarStudyVo.class);
-            //得到
+            //得到学习的周
             List<Long> cont = JSONObject.parseArray(userPlan.getStudyCount(), Long.class);
             Long[] strings = new Long[cont.size()];
             cont.toArray(strings);
+
             userPlanVo.setCalendarStudyVo(calendarStudyVos);
             userPlanVo.setStudyCount(strings);
             userPlanVo.setCoursePlanVo(null);
-            List<UserPlanCource> userPlanClsList = baseMapper.selectCourse(userPlan.getPlanId());
 
+            //获得计划的课程
+            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);
+
+            //获得当天的学习课程节数
+            coursePlanVo.stream().forEach(s -> {
+                calendarStudyVos.stream().filter(c -> c.getMonth()==cal.get(Calendar.MONTH) + 1).forEach(c -> {
+                    c.getDayStudyList().stream()
+                            .filter(g -> g.getDate() == cal.get(Calendar.DAY_OF_MONTH))
+                            .forEach(d -> {
+                                if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0){
+                                    Map<Long, Long> courseDayMap = d.getCourseDayMap();
+                                    Long aLong = courseDayMap.get(s.getCourseId());
+                                    s.setStudyGoal(aLong);
+                                }
+                            });
+                });
+            });
+
             userPlanVo.setCoursePlanVo(coursePlanVo);
             userPlanVos.add(userPlanVo);
         }