he2802 4 gadi atpakaļ
vecāks
revīzija
647e03160b

+ 12 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/activity/PlanController.java

@@ -88,4 +88,16 @@ public class PlanController extends BaseController {
         bo.setUserId(loginUser.getUser().getUserId());
         return toAjax(userPlanService.updateGenerate(bo) ? 1 : 0);
     }
+
+
+    /**
+     * 获得用户学习计划
+     */
+    @ApiOperation("用户未完成任务重新更新任务")
+    @PostMapping("/editPlan")
+    public AjaxResult<Void> editPlan(@RequestBody UserPlanAddBo bo) throws ParseException {
+        ClientLoginUser loginUser = WxTokenService.getLoginUser(ServletUtils.getRequest());
+        bo.setUserId(loginUser.getUser().getUserId());
+        return toAjax(userPlanService.editPlan(bo) ? 1 : 0);
+    }
 }

+ 1 - 1
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/UserServiceImpl.java

@@ -367,7 +367,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         RanKingUser ranKingUser = baseMapper.selectByRank(query);
         if (ranKingUser != null && ranKingUser.getHourse() != null) {
             Integer rank = baseMapper.selectByRankOne(Convert.toInt(ranKingUser.getHourse()));
-            return rank;
+            return rank+1;
          }
         return 0;
     }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/service/impl/ActivityConfigurationUseServiceImpl.java

@@ -113,6 +113,9 @@ public class ActivityConfigurationUseServiceImpl extends ServiceImpl<ActivityCon
         if (baseMapper.queryByUse(bo) > 0){
             throw new IllegalArgumentException("已领取活动,请勿重复领取");
         }
+        if (bo.getConfigurationId() == null){
+            throw new IllegalArgumentException("活动ID为空");
+        }
         //未领取过领取活动
         bo.setCreateTime(DateUtils.getNowTime());
         ActivityConfigurationVo activityConfigurationVo = activityConfigurationService.queryById(bo.getConfigurationId());

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/service/impl/ActivityTaskUserServiceImpl.java

@@ -263,7 +263,7 @@ public class ActivityTaskUserServiceImpl extends ServiceImpl<ActivityTaskUserMap
         }
         validReceiver(bo);
 
-        ActivityTaskVo activityTaskVo = activityTaskService.queryByTaskId(bo.getTaskId());
+        ActivityTaskVo activityTaskVo = activityTaskService.queryByTaskId(Convert.toLong(bo.getTaskType()));
 
         //增加用户积分
         UserVo userVo = userService.queryById(bo.getUserId());

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserPlanMapper.java

@@ -30,4 +30,6 @@ public interface UserPlanMapper extends BaseMapper<UserPlan> {
     List<UserPlanCource> selectCourse(Long planId);
 
     Integer selectCountCourse(UserPlanQueryBo bo);
+
+    List<Long> selectByCourseId(Long courseId);
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserStudyRecordMapper.java

@@ -18,5 +18,5 @@ public interface UserStudyRecordMapper extends BaseMapper<UserStudyRecord> {
 
     List<UserStudyRecordVo> selectList(UserStudyRecordQueryBo bo);
 
-    List<UserStudyRecord> selectUserStudy(@Param("userId") Long userId, @Param("courseId") Integer[] courseId, @Param("startTime") int timesMorning, @Param("endTime") int timesNight);
+    List<UserStudyRecord> selectUserStudy(@Param("userId") Long userId, @Param("courseId") Integer courseId);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserPlanService.java

@@ -65,4 +65,6 @@ public interface IUserPlanService extends IService<UserPlan> {
 	Boolean updateGenerate(UserPlanAddBo bo) throws ParseException;
 
 	UserPlanVo userPlanSeven(UserPlanQueryBo bo);
+
+	boolean editPlan(UserPlanAddBo bo);
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserStudyRecordService.java

@@ -53,5 +53,5 @@ public interface IUserStudyRecordService extends IService<UserStudyRecord> {
 	 */
 	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
 
-    List<UserStudyRecord> selectUserStudy(Long userId, Integer[] courseId, int timesMorning,int timesNight);
+    List<UserStudyRecord> selectUserStudy(Long userId, Integer courseId);
 }

+ 297 - 74
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserPlanServiceImpl.java

@@ -2,6 +2,7 @@ package com.zhongzheng.modules.user.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.convert.Convert;
+import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
@@ -12,6 +13,7 @@ import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.modules.exam.vo.ExamArrangementTimeVo;
 import com.zhongzheng.modules.user.domain.UserPlanCource;
 import com.zhongzheng.modules.user.domain.UserStudyRecord;
+import com.zhongzheng.modules.user.service.IOrderPossessUserService;
 import com.zhongzheng.modules.user.service.IUserPlanCourceService;
 import com.zhongzheng.modules.user.service.IUserStudyRecordService;
 import com.zhongzheng.modules.user.vo.*;
@@ -29,6 +31,7 @@ import com.zhongzheng.modules.user.bo.UserPlanEditBo;
 import com.zhongzheng.modules.user.domain.UserPlan;
 import com.zhongzheng.modules.user.mapper.UserPlanMapper;
 import com.zhongzheng.modules.user.service.IUserPlanService;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.text.DateFormat;
 import java.text.ParseException;
@@ -52,6 +55,9 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
     @Autowired
     private IUserStudyRecordService userStudyRecordService;
 
+    @Autowired
+    private IOrderPossessUserService iOrderPossessUserService;
+
     @Override
     public UserPlanVo queryById(Long userId){
         UserPlan db = this.baseMapper.selectById(userId);
@@ -129,12 +135,22 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public UserPlanVo generate(UserPlanQueryBo bo) throws ParseException {
         //判断是否课程已被生成过课程
         Integer rank = baseMapper.selectCountCourse(bo);
         if (rank > 0){
             throw new IllegalArgumentException("您当前有课程的计划,请到计划修改上修改计划");
         }
+        //查询是否拥有该课程
+        Arrays.stream(bo.getCourseId()).forEach(a ->{
+            Integer i = Validator.isNotNull(iOrderPossessUserService.queryByTypeAndId(Convert.toLong(a),1,bo.getUserId()))?1:0;
+            if (i < 1){
+                throw new IllegalArgumentException("您没有拥有该课程");
+            }
+        });
+
+
         //自定义学习计划,自动生成计划
         if (bo.getCourseId() != null && bo.getStudyCount() == null){
             UserPlanVo userPlanVo = generateSelf(bo);
@@ -237,6 +253,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public List<UserPlanVo> userPlan(UserPlanQueryBo bo) {
         List<UserPlan> userPlans = baseMapper.selectByUserPlan(bo);
         List<UserPlanVo> userPlanVos = new ArrayList<>();
@@ -289,60 +306,81 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                                 }
                             });
                 });
+            });
 
+            //更新当天学习节数是否已经完成
+            //代表前面是否有未完成课程
+            Long studyNum = 0L;
+            boolean goal = true;
+            for (CoursePlanVo b : coursePlanVo) {
+                if (goal == false) {
+                    break;
+                }
+                List<UserStudyRecord> studyCount = userStudyRecordService.selectUserStudy(bo.getUserId(), Convert.toInt(b.getCourseId()));
+                List<UserStudyRecord> myList = studyCount.stream().distinct().collect(Collectors.toList());
+                studyNum= studyNum+Convert.toLong(myList.size());
                 //更新当天学习节数是否已经完成
-                //代表前面是否有未完成课程
-                List<UserStudyRecord> studyCount = userStudyRecordService.selectUserStudy(bo.getUserId(), array, getTimesmorning(), getTimesnight());
-                boolean goal = true;
-                for (CoursePlanVo b : coursePlanVo) {
-                    if (goal == false) {
-                        break;
-                    }
-                    //更新当天学习节数是否已经完成
-                    List<UserStudyRecord> collect = studyCount.stream().filter(v -> v.getCourseId().equals(s.getCourseId())).collect(Collectors.toList());
-                    if (collect.size() >= b.getStudyGoal()) {
-                        calendarStudyVos.stream().filter(c -> c.getMonth() == cal.get(Calendar.MONTH) + 1).forEach(c -> {
-                            c.getDayStudyList().stream()
-                                    .forEach(d -> {
-                                        if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() == cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0) {
-                                            d.setPerform(1);
-                                        }
-                                        if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() < cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0) {
-                                            d.setPerform(2);
-                                        }
-                                    });
-                        });
-                    } else {
-                        calendarStudyVos.stream().filter(c -> c.getMonth() == cal.get(Calendar.MONTH) + 1).forEach(c -> {
-                            for (DayStudyVo d : c.getDayStudyList()) {
+                if (b.getStudyGoal() != null && studyCount.size() >= b.getStudyGoal() ) {
+                    for (CalendarStudyVo calendarStudyVo : calendarStudyVos) {
+                        if (calendarStudyVo.getMonth() == cal.get(Calendar.MONTH) + 1) {
+                            for (DayStudyVo d : calendarStudyVo.getDayStudyList()) {
+                                if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() == cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0) {
+                                    if (d.getPerform() == 1){
+                                        break;
+                                    }
+                                    Map<Long, Long> sectionIdMap = d.getSectionIdMap();
+                                    for (UserStudyRecord userStudyRecord : studyCount) {
+                                        sectionIdMap.remove(userStudyRecord.getSectionId());
+                                    }
+                                    if (sectionIdMap.isEmpty()) {
+                                        d.setPerform(1);
+                                    } else {
+                                        d.setPerform(0);
+                                        goal = false;
+                                    }
+                                }
                                 if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() < cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0) {
                                     d.setPerform(2);
                                 }
-                                if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() == cal.get(Calendar.DAY_OF_MONTH)) {
-                                    d.setPerform(0);
-                                }
                             }
-                        });
-                        goal = false;
+                        }
+
                     }
 
-                    UserPlan userPlan1 = new UserPlan();
-                    userPlan1.setPlanId(s.getPlanId());
-                    String calendar = JSON.toJSONString(calendarStudyVos);
-                    userPlan1.setSchedule(calendar);
-                    userPlan1.setUpdateTime(DateUtils.getNowTime());
-                    baseMapper.updateById(userPlan1);
+                } else {
+                    for (CalendarStudyVo calendarStudyVo : calendarStudyVos) {
+                        for (DayStudyVo d : calendarStudyVo.getDayStudyList()) {
+                            if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() < cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0) {
+                                d.setPerform(2);
+                            }
+                            if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() == cal.get(Calendar.DAY_OF_MONTH)) {
+                                d.setPerform(0);
+                            }
+                        }
+                    }
+                    goal = false;
                 }
 
-                userPlanVo.setCoursePlanVo(coursePlanVo);
+            }
+            UserPlan userPlan1 = new UserPlan();
+            userPlan1.setPlanId(userPlan.getPlanId());
+            String calendar = JSON.toJSONString(calendarStudyVos);
+            userPlan1.setSchedule(calendar);
+            userPlan1.setUpdateTime(DateUtils.getNowTime());
+            userPlan1.setStudyNum(studyNum);
+            int i = baseMapper.updateById(userPlan1);
+
+
+            userPlanVo.setCoursePlanVo(coursePlanVo);
                 userPlanVos.add(userPlanVo);
-            });
+
         }
 
         return userPlanVos;
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Boolean updateGenerate(UserPlanAddBo bo) throws ParseException {
         UserPlanQueryBo userPlanQueryBo = BeanUtil.toBean(bo, UserPlanQueryBo.class);
         if (bo.getStatus() == 0) {
@@ -441,6 +479,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public UserPlanVo userPlanSeven(UserPlanQueryBo bo) {
         List<UserPlan> userPlans = baseMapper.selectByUserPlan(bo);
         UserPlanVo userPlanVos = new UserPlanVo();
@@ -467,30 +506,48 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
             List<DayStudyVo> dayStudyVos = new ArrayList<>();
             List<DayStudyVo> finalDayStudyVos = dayStudyVos;
 
+            //更新当天学习节数是否已经完成
             //代表前面是否有未完成课程
-            List<UserStudyRecord> studyCount = userStudyRecordService.selectUserStudy(bo.getUserId(),array,getTimesmorning(),getTimesnight());
+            Long studyNum = 0L;
             boolean goal = true;
-            for (CoursePlanVo s : coursePlanVo) {
-                if (goal == false){
+            for (CoursePlanVo b : coursePlanVo) {
+                if (goal == false) {
                     break;
                 }
+                List<UserStudyRecord> studyCount = userStudyRecordService.selectUserStudy(bo.getUserId(), Convert.toInt(b.getCourseId()));
+                List<UserStudyRecord> myList = studyCount.stream().distinct().collect(Collectors.toList());
+                studyNum= studyNum+Convert.toLong(myList.size());
                 //更新当天学习节数是否已经完成
-                List<UserStudyRecord> collect = studyCount.stream().filter(v -> v.getCourseId().equals(s.getCourseId())).collect(Collectors.toList());
-                if (collect.size() >= s.getStudyGoal()){
-                    calendarStudyVos.stream().filter(c -> c.getMonth()==cal.get(Calendar.MONTH) + 1).forEach(c -> {
-                        c.getDayStudyList().stream()
-                                .forEach(d -> {
-                                    if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate()== cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0){
-                                        d.setPerform(1);
+                if (b.getStudyGoal() != null && studyCount.size() >= b.getStudyGoal() ) {
+                    for (CalendarStudyVo calendarStudyVo : calendarStudyVos) {
+                        if (calendarStudyVo.getMonth() == cal.get(Calendar.MONTH) + 1) {
+                            for (DayStudyVo d : calendarStudyVo.getDayStudyList()) {
+                                if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() == cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0) {
+                                    if (d.getPerform() == 1){
+                                        break;
                                     }
-                                    if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate()< cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0){
-                                        d.setPerform(2);
+                                    Map<Long, Long> sectionIdMap = d.getSectionIdMap();
+                                    for (UserStudyRecord userStudyRecord : studyCount) {
+                                        sectionIdMap.remove(userStudyRecord.getSectionId());
                                     }
-                                });
-                    });
-                }else {
-                    calendarStudyVos.stream().filter(c -> c.getMonth()==cal.get(Calendar.MONTH) + 1).forEach(c -> {
-                        for (DayStudyVo d : c.getDayStudyList()) {
+                                    if (sectionIdMap.isEmpty()) {
+                                        d.setPerform(1);
+                                    } else {
+                                        d.setPerform(0);
+                                        goal = false;
+                                    }
+                                }
+                                if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() < cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0) {
+                                    d.setPerform(2);
+                                }
+                            }
+                        }
+
+                    }
+
+                } else {
+                    for (CalendarStudyVo calendarStudyVo : calendarStudyVos) {
+                        for (DayStudyVo d : calendarStudyVo.getDayStudyList()) {
                             if (d.getStudyCourseKnob() != null && d.getStudyCourseKnob() != 0 && d.getDate() < cal.get(Calendar.DAY_OF_MONTH) && d.getPerform() == 0) {
                                 d.setPerform(2);
                             }
@@ -498,17 +555,21 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                                 d.setPerform(0);
                             }
                         }
-                    });
-                    goal=false;
+                    }
+                    goal = false;
                 }
-                UserPlan userPlan1 = new UserPlan();
-                userPlan1.setPlanId(s.getPlanId());
-                String calendar = JSON.toJSONString(calendarStudyVos);
-                userPlan1.setSchedule(calendar);
-                userPlan1.setUpdateTime(DateUtils.getNowTime());
-                baseMapper.updateById(userPlan1);
+
             }
 
+            UserPlan userPlan1 = new UserPlan();
+            userPlan1.setPlanId(userPlan.getPlanId());
+            String calendar = JSON.toJSONString(calendarStudyVos);
+            userPlan1.setSchedule(calendar);
+            userPlan1.setUpdateTime(DateUtils.getNowTime());
+            userPlan1.setStudyNum(studyNum);
+            int i = baseMapper.updateById(userPlan1);
+
+
             calendarStudyVos.stream().filter(c -> c.getMonth() == (cal.get(Calendar.MONTH)+1))
                    .forEach(c -> {
                        finalDayStudyVos.addAll(c.getDayStudyList().stream()
@@ -533,22 +594,22 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                     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)
+                            .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)
+                            .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)
+                            .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)
+                            .filter(v ->  v.getDate() < 1 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() >= cal.get(Calendar.DAY_OF_MONTH) - 6)
                             .collect(Collectors.toList());
                     break;
             }
@@ -581,22 +642,22 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                     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)
+                            .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)
+                            .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)
+                            .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)
+                            .filter(v ->  v.getDate() < 1 + cal.get(Calendar.DAY_OF_MONTH) && v.getDate() >= cal.get(Calendar.DAY_OF_MONTH) - 6)
                             .collect(Collectors.toList());
                     break;
             }
@@ -612,6 +673,11 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
         return userPlanVos;
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean editPlan(UserPlanAddBo bo) {
+        return true;
+    }
 
 
     private UserPlanVo generateSelfBo(UserPlanQueryBo bo) throws ParseException {
@@ -643,8 +709,11 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
 
         //总节数
         Integer sectionNum = planVo.getSectionNum();
-
-
+        if(sectionNum <= 0){
+            throw new IllegalArgumentException("该课程没有节数,无法生成计划");
+        }
+        //查出节的ID
+        List<Long> listId= baseMapper.selectByCourseId(planVo.getCourseId());
         //获得今天日期,将每天节数写入
         Calendar cal = Calendar.getInstance();
         int year = cal.get(Calendar.YEAR);
@@ -665,6 +734,15 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                         Map<Long, Long> courseDayMap = dayStudyVo.getCourseDayMap();
                         courseDayMap.put(planVo.getCourseId(),Convert.toLong(Sec));
                         dayStudyVo.setCourseDayMap(courseDayMap);
+                        //添加课程学习节ID
+                        Map<Long,Long> sectionIdMap = new HashMap<>();
+                        for (int i = 0; i < Sec; i++) {
+                            if (listId.size() >= Sec) {
+                                sectionIdMap.put(listId.get(0),planVo.getCourseId());
+                                listId.remove(0);
+                            }
+                        }
+                        dayStudyVo.setSectionIdMap(sectionIdMap);
                         dayStudyVo.setPerform(0);
                     }else if (Sec >= sectionNum){
                         dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum)+dayStudyVo.getStudyCourseKnob());
@@ -672,6 +750,12 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                         dayStudyVo.setPerform(0);
                         Map<Long, Long> courseDayMap = dayStudyVo.getCourseDayMap();
                         courseDayMap.put(planVo.getCourseId(),Convert.toLong(Sec));
+                        //添加课程学习节ID
+                        Map<Long,Long> sectionIdMap = new HashMap<>();
+                        for (Long aLong : listId) {
+                            sectionIdMap.put(aLong,planVo.getCourseId());
+                        }
+                        dayStudyVo.setSectionIdMap(sectionIdMap);
                         dayStudyVo.setCourseDayMap(courseDayMap);
                     }
                 }else if(calendarStudyVo.getMonth() != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
@@ -682,7 +766,15 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                         courseDayMap.put(planVo.getCourseId(),Convert.toLong(Sec));
                         dayStudyVo.setCourseDayMap(courseDayMap);
                         dayStudyVo.setPerform(0);
-
+                        //添加课程学习节ID
+                        Map<Long,Long> sectionIdMap = new HashMap<>();
+                        for (int i = 0; i < Sec; i++) {
+                            if (listId.size() >= Sec) {
+                                sectionIdMap.put(listId.get(0),planVo.getCourseId());
+                                listId.remove(0);
+                            }
+                        }
+                        dayStudyVo.setSectionIdMap(sectionIdMap);
                         sectionNum = sectionNum-Sec;
                     }else if (Sec >= sectionNum){
                         dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum)+dayStudyVo.getStudyCourseKnob());
@@ -690,7 +782,12 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                         courseDayMap.put(planVo.getCourseId(),Convert.toLong(Sec));
                         dayStudyVo.setCourseDayMap(courseDayMap);
                         dayStudyVo.setPerform(0);
-
+                        //添加课程学习节ID
+                        Map<Long,Long> sectionIdMap = new HashMap<>();
+                        for (Long aLong : listId) {
+                            sectionIdMap.put(aLong,planVo.getCourseId());
+                        }
+                        dayStudyVo.setSectionIdMap(sectionIdMap);
                         sectionNum = 0;
 
                     }
@@ -724,6 +821,18 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                             }
                             courseDayMap.put(planVo.getCourseId(),Convert.toLong(Sec));
                             dayStudyVo.setCourseDayMap(courseDayMap);
+                            //添加课程学习节ID
+                            Map<Long,Long> sectionIdMap = dayStudyVo.getSectionIdMap();
+                            if (sectionIdMap == null) {
+                                courseDayMap = new HashMap<>();
+                            }
+                            for (int i = 0; i < Sec; i++) {
+                                if (listId.size() >= Sec) {
+                                    sectionIdMap.put(listId.get(0),planVo.getCourseId());
+                                    listId.remove(0);
+                                }
+                            }
+                            dayStudyVo.setSectionIdMap(sectionIdMap);
                             dayStudyVo.setPerform(0);
                         }else if (Sec >= sectionNum){
                             dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
@@ -733,6 +842,19 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                             }
                             courseDayMap.put(planVo.getCourseId(),Convert.toLong(Sec));
                             dayStudyVo.setCourseDayMap(courseDayMap);
+
+                            //添加课程学习节ID
+                            Map<Long,Long> sectionIdMap = dayStudyVo.getSectionIdMap();
+                            if (sectionIdMap == null) {
+                                courseDayMap = new HashMap<>();
+                            }
+                            for (int i = 0; i < Sec; i++) {
+                                if (listId.size() >= Sec) {
+                                    sectionIdMap.put(listId.get(0),planVo.getCourseId());
+                                    listId.remove(0);
+                                }
+                            }
+                            dayStudyVo.setSectionIdMap(sectionIdMap);
                             sectionNum = 0;
                             dayStudyVo.setPerform(0);
                         }
@@ -746,6 +868,19 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                             }
                             courseDayMap.put(planVo.getCourseId(),Convert.toLong(Sec));
                             dayStudyVo.setCourseDayMap(courseDayMap);
+
+                            //添加课程学习节ID
+                            Map<Long,Long> sectionIdMap = dayStudyVo.getSectionIdMap();
+                            if (sectionIdMap == null) {
+                                courseDayMap = new HashMap<>();
+                            }
+                            for (int i = 0; i < Sec; i++) {
+                                if (listId.size() >= Sec) {
+                                    sectionIdMap.put(listId.get(0),planVo.getCourseId());
+                                    listId.remove(0);
+                                }
+                            }
+                            dayStudyVo.setSectionIdMap(sectionIdMap);
                             dayStudyVo.setPerform(0);
                         }else if (Sec >= sectionNum){
                             dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
@@ -756,6 +891,19 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                             courseDayMap.put(planVo.getCourseId(),Convert.toLong(Sec));
                             dayStudyVo.setCourseDayMap(courseDayMap);
                             sectionNum = 0;
+
+                            //添加课程学习节ID
+                            Map<Long,Long> sectionIdMap = dayStudyVo.getSectionIdMap();
+                            if (sectionIdMap == null) {
+                                courseDayMap = new HashMap<>();
+                            }
+                            for (int i = 0; i < Sec; i++) {
+                                if (listId.size() >= Sec) {
+                                    sectionIdMap.put(listId.get(0),planVo.getCourseId());
+                                    listId.remove(0);
+                                }
+                            }
+                            dayStudyVo.setSectionIdMap(sectionIdMap);
                             dayStudyVo.setPerform(0);
                         }
                     }
@@ -797,7 +945,12 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
 
         //总节数
         Integer sectionNum = coursePlanVo.getSectionNum();
+        if(sectionNum <= 0){
+            throw new IllegalArgumentException("该课程没有节数,无法生成计划");
+        }
         userPlanVo.setPitchNum(Convert.toLong(sectionNum));
+        //查出节的ID
+        List<Long> listId= baseMapper.selectByCourseId(coursePlanVo.getCourseId());
 
         //获得今天日期,将每天节数写入
         List<CalendarStudyVo> calendarStudyVos = new ArrayList<>();
@@ -832,6 +985,15 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                         Map<Long,Long> studyDstudyVo = new HashMap<Long, Long>();
                         studyDstudyVo.put(coursePlanVo.getCourseId(),Convert.toLong(Sec));
                         dayStudyVo.setCourseDayMap(studyDstudyVo);
+                        //添加课程学习节ID
+                        Map<Long,Long> sectionIdMap = new HashMap<>();
+                        for (int i = 0; i < Sec; i++) {
+                            if (listId.size() >= Sec) {
+                                sectionIdMap.put(listId.get(0),coursePlanVo.getCourseId());
+                                listId.remove(0);
+                            }
+                        }
+                        dayStudyVo.setSectionIdMap(sectionIdMap);
                         dayStudyVo.setPerform(0);
                     }else if (Sec >= sectionNum){
                         dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
@@ -839,6 +1001,12 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                         Map<Long,Long> studyDstudyVo = new HashMap<Long, Long>();
                         studyDstudyVo.put(coursePlanVo.getCourseId(),Convert.toLong(Sec));
                         dayStudyVo.setCourseDayMap(studyDstudyVo);
+                        //添加课程学习节ID
+                        Map<Long,Long> sectionIdMap = new HashMap<>();
+                        for (Long aLong : listId) {
+                            sectionIdMap.put(aLong,coursePlanVo.getCourseId());
+                        }
+                        dayStudyVo.setSectionIdMap(sectionIdMap);
                         dayStudyVo.setPerform(0);
                     }
                 }else if(month != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
@@ -848,6 +1016,15 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                         Map<Long,Long> studyDstudyVo = new HashMap<Long, Long>();
                         studyDstudyVo.put(coursePlanVo.getCourseId(),Convert.toLong(Sec));
                         dayStudyVo.setCourseDayMap(studyDstudyVo);
+                        //添加课程学习节ID
+                        Map<Long,Long> sectionIdMap = new HashMap<>();
+                        for (int i = 0; i < Sec; i++) {
+                            if (listId.size() >= Sec) {
+                                sectionIdMap.put(listId.get(0),coursePlanVo.getCourseId());
+                                listId.remove(0);
+                            }
+                        }
+                        dayStudyVo.setSectionIdMap(sectionIdMap);
                         dayStudyVo.setPerform(0);
                     }else if (Sec >= sectionNum){
                         dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
@@ -855,6 +1032,12 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                         Map<Long,Long> studyDstudyVo = new HashMap<Long, Long>();
                         studyDstudyVo.put(coursePlanVo.getCourseId(),Convert.toLong(Sec));
                         dayStudyVo.setCourseDayMap(studyDstudyVo);
+                        //添加课程学习节ID
+                        Map<Long,Long> sectionIdMap = new HashMap<>();
+                        for (Long aLong : listId) {
+                            sectionIdMap.put(aLong,coursePlanVo.getCourseId());
+                        }
+                        dayStudyVo.setSectionIdMap(sectionIdMap);
                         dayStudyVo.setPerform(0);
                     }
                 }
@@ -901,8 +1084,14 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
 
         //总节数
         Integer sectionNum = coursePlanVo.getSectionNum();
+        if(sectionNum <= 0){
+            throw new IllegalArgumentException("该课程没有节数,无法生成计划");
+        }
         userPlanVo.setPitchNum(Convert.toLong(sectionNum));
 
+        //查出节的ID
+        List<Long> listId= baseMapper.selectByCourseId(coursePlanVo.getCourseId());
+
         //获得今天日期,将每天节数写入
         List<CalendarStudyVo> calendarStudyVos = new ArrayList<>();
         Calendar cal = Calendar.getInstance();
@@ -933,32 +1122,66 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                     if (Sec < sectionNum) {
                         dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
                         dayStudyVo.setPerform(0);
+                        //添加课程节数
                         Map<Long,Long> studyDstudyVo = new HashMap<Long, Long>();
                         studyDstudyVo.put(coursePlanVo.getCourseId(),Convert.toLong(Sec));
                         dayStudyVo.setCourseDayMap(studyDstudyVo);
+                        //添加课程学习节ID
+                        Map<Long,Long> sectionIdMap = new HashMap<>();
+                        for (int i = 0; i < Sec; i++) {
+                            if (listId.size() >= Sec) {
+                                sectionIdMap.put(listId.get(0),coursePlanVo.getCourseId());
+                                listId.remove(0);
+                            }
+                        }
+                        dayStudyVo.setSectionIdMap(sectionIdMap);
                         sectionNum = sectionNum-Sec;
                     }else if (Sec >= sectionNum){
                         dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
                         dayStudyVo.setPerform(0);
+                        //添加课程节数
                         Map<Long,Long> studyDstudyVo = new HashMap<Long, Long>();
                         studyDstudyVo.put(coursePlanVo.getCourseId(),Convert.toLong(Sec));
                         dayStudyVo.setCourseDayMap(studyDstudyVo);
+                        //添加课程学习节ID
+                        Map<Long,Long> sectionIdMap = new HashMap<>();
+                        for (Long aLong : listId) {
+                            sectionIdMap.put(aLong,coursePlanVo.getCourseId());
+                        }
+                        dayStudyVo.setSectionIdMap(sectionIdMap);
                         sectionNum = 0;
                     }
                 }else if(month != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
                     if (Sec < sectionNum) {
                         dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
                         dayStudyVo.setPerform(0);
+                        //添加课程节数
                         Map<Long,Long> studyDstudyVo = new HashMap<Long, Long>();
                         studyDstudyVo.put(coursePlanVo.getCourseId(),Convert.toLong(Sec));
                         dayStudyVo.setCourseDayMap(studyDstudyVo);
+                        //添加课程学习节ID
+                        Map<Long,Long> sectionIdMap = new HashMap<>();
+                        for (int i = 0; i < Sec; i++) {
+                            if (listId.size() >= Sec) {
+                                sectionIdMap.put(listId.get(0),coursePlanVo.getCourseId());
+                                listId.remove(0);
+                            }
+                        }
+                        dayStudyVo.setSectionIdMap(sectionIdMap);
                         sectionNum = sectionNum-Sec;
                     }else if (Sec >= sectionNum){
                         dayStudyVo.setStudyCourseKnob(Convert.toLong(sectionNum));
                         dayStudyVo.setPerform(0);
+                        //添加课程节数
                         Map<Long,Long> studyDstudyVo = new HashMap<Long, Long>();
                         studyDstudyVo.put(coursePlanVo.getCourseId(),Convert.toLong(Sec));
                         dayStudyVo.setCourseDayMap(studyDstudyVo);
+                        //添加课程学习节ID
+                        Map<Long,Long> sectionIdMap = new HashMap<>();
+                        for (Long aLong : listId) {
+                            sectionIdMap.put(aLong,coursePlanVo.getCourseId());
+                        }
+                        dayStudyVo.setSectionIdMap(sectionIdMap);
                         sectionNum = 0;
                     }
                 }

+ 2 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserStudyRecordServiceImpl.java

@@ -133,7 +133,7 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
     }
 
     @Override
-    public List<UserStudyRecord> selectUserStudy(Long userId, Integer[] courseId, int timesMorning, int timesNight) {
-        return baseMapper.selectUserStudy(userId,courseId,timesMorning,timesNight);
+    public List<UserStudyRecord> selectUserStudy(Long userId, Integer courseId) {
+        return baseMapper.selectUserStudy(userId,courseId);
     }
 }

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/DayStudyVo.java

@@ -39,6 +39,12 @@ public class DayStudyVo {
     private Map<Long,Long> courseDayMap;
 
 
+
+    /** 完成相应课节数 */
+    @ApiModelProperty("完成相应课节数ID")
+    private Map<Long,Long> sectionIdMap;
+
+
 }
 
 

+ 17 - 1
zhongzheng-system/src/main/resources/mapper/modules/user/UserPlanMapper.xml

@@ -158,7 +158,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by exam_date
     </select>
 
-    <insert id="insertSource" parameterType="map" useGeneratedKeys="true" keyProperty="id" >
+    <insert id="insertSource" parameterType="map" useGeneratedKeys="true">
         insert into user_plan_cource (
         plan_id,
         source_id
@@ -191,4 +191,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             and u.user_id = #{userId}
         </if>
     </select>
+
+
+    <select id="selectByCourseId" parameterType="map"  resultType="long">
+        SELECT
+        s.section_id
+        FROM
+        course_section s
+        LEFT JOIN course_chapter r ON  s.chapter_id = r.chapter_id
+        LEFT JOIN course c ON c.course_id = r.course_id
+        WHERE
+        1 = 1
+        <if test="courseId != null and courseId !=''">
+            AND c.course_id =#{courseId}
+        </if>
+        ORDER BY r.sort,s.sort ASC
+    </select>
 </mapper>

+ 1 - 7
zhongzheng-system/src/main/resources/mapper/modules/user/UserStudyRecordMapper.xml

@@ -41,13 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             and user_id =#{userId}
         </if>
         <if test="courseId != null and courseId !=''">
-            and course_id in
-            <foreach collection="courseId" open="(" separator="," close=")" item="courseId">
-                #{courseId}
-            </foreach>
-        </if>
-        <if test="startTime != null and startTime != ''">
-        and create_time BETWEEN #{startTime} and #{endTime}
+            and course_id = #{courseId}
         </if>
         and study_duration > 360
     </select>