change 4 роки тому
батько
коміт
04e4ab2a98

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

@@ -711,7 +711,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
 
 
             //最近考试时间七天前到现在的天数,学习视频时长
-            Date date1 = new Date(bo.getExamDate()*1000L);
+            Date date1 = new Date(userPlan.getExamDate()*1000L);
             //获得相隔天数
             //得到学习的周
             List<Long> cont = JSONObject.parseArray(userPlan.getStudyCount(), Long.class);
@@ -721,6 +721,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
             int dutyDays = getDutyDays(new Date(), date1,longs,7L);
 
             //计算每天需要学习多少节课
+            int size = listMap.size();
 
             int Sec = (int)Math.ceil((double)listMap.size()/dutyDays);
 
@@ -731,6 +732,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
             }
 
             //key和value都循环
+            listId = new ArrayList<>();
             for(Map.Entry<Long,Long> entry : listMap.entrySet()) {
                 listId.add(entry.getKey());
             }
@@ -739,6 +741,24 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
             Calendar cal = Calendar.getInstance();
             int year = cal.get(Calendar.YEAR);
             Integer month = 0;
+
+            for (CalendarStudyVo calendarStudyVo : calendarStudyVos) {
+                if (month < calendarStudyVo.getMonth()){
+                    month = Convert.toInt(calendarStudyVo.getMonth());
+                }
+                for (DayStudyVo dayStudyVo : calendarStudyVo.getDayStudyList()) {
+                    if (dayStudyVo.getDate() > Calendar.getInstance().get(Calendar.DAY_OF_MONTH) && calendarStudyVo.getMonth() == (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)) {
+                        dayStudyVo.setStudyCourseKnob(0L);
+                        dayStudyVo.setCourseDayMap(new HashMap<>());
+                        dayStudyVo.setSectionIdMap(new HashMap<>());
+                    }else if(calendarStudyVo.getMonth() > (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
+                        dayStudyVo.setStudyCourseKnob(0L);
+                        dayStudyVo.setCourseDayMap(new HashMap<>());
+                        dayStudyVo.setSectionIdMap(new HashMap<>());
+                    }
+                }
+            }
+
             //将原有的月份添加课程的节数
             for (CalendarStudyVo calendarStudyVo : calendarStudyVos) {
                 if (month < calendarStudyVo.getMonth()){
@@ -779,7 +799,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                             dayStudyVo.setSectionIdMap(sectionIdMap);
                             dayStudyVo.setCourseDayMap(courseDayMap);
                         }
-                    }else if(calendarStudyVo.getMonth() != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
+                    }else if(calendarStudyVo.getMonth() > (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
                         if (Sec < sectionNum) {
                             dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec)+dayStudyVo.getStudyCourseKnob());
 
@@ -879,7 +899,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                                 sectionNum = 0;
                                 dayStudyVo.setPerform(0);
                             }
-                        }else if(month != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
+                        }else if(month > (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
                             if (Sec < sectionNum) {
                                 dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
                                 sectionNum = sectionNum-Sec;