change 3 жил өмнө
parent
commit
b8055e71e3
22 өөрчлөгдсөн 271 нэмэгдсэн , 1952 устгасан
  1. 11 0
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/exam/ExamApplyController.java
  2. 102 0
      zhongzheng-api/src/main/java/com/zhongzheng/controller/plan/UserPlanController.java
  3. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/IExamApplyService.java
  4. 16 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamApplyServiceImpl.java
  5. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/vo/ExamApplyVo.java
  6. 9 19
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserPlanAddBo.java
  7. 13 4
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserPlanCourceAddBo.java
  8. 10 5
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserPlanCourceEditBo.java
  9. 7 5
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserPlanCourceQueryBo.java
  10. 23 20
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserPlanEditBo.java
  11. 9 19
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserPlanQueryBo.java
  12. 9 24
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/domain/UserPlan.java
  13. 10 7
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/domain/UserPlanCource.java
  14. 2 2
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserPlanCourceMapper.java
  15. 2 23
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserPlanMapper.java
  16. 7 7
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserPlanCourceService.java
  17. 7 25
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserPlanService.java
  18. 6 2
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserPlanCourceServiceImpl.java
  19. 16 1598
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserPlanServiceImpl.java
  20. 1 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/CalendarStudyVo.java
  21. 3 1
      zhongzheng-system/src/main/resources/mapper/modules/user/UserPlanCourceMapper.xml
  22. 3 190
      zhongzheng-system/src/main/resources/mapper/modules/user/UserPlanMapper.xml

+ 11 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/exam/ExamApplyController.java

@@ -127,6 +127,17 @@ public class ExamApplyController extends BaseController {
         return toAjax(iExamApplyGoodsService.addGoods(bo) ? 1 : 0);
     }
 
+    /**
+     * 获取考试地点 考培地点
+     */
+    @ApiOperation("查看考试安排绑定商品")
+    @PreAuthorize("@ss.hasPermi('system:apply:query')")
+    @GetMapping("/goodsInfo")
+    public AjaxResult<ExamApplyVo> getGoodsInfo(ExamApplyQueryBo bo) {
+        ExamApplyVo examApplyVos = iExamApplyService.getGoodsInfo(bo);
+        return  AjaxResult.success(examApplyVos);
+    }
+
     /**
      * 查询考试配置绑定商品列表
      */

+ 102 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/plan/UserPlanController.java

@@ -0,0 +1,102 @@
+package com.zhongzheng.controller.plan;
+
+import java.util.List;
+import java.util.Arrays;
+
+import lombok.RequiredArgsConstructor;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.zhongzheng.common.annotation.Log;
+import com.zhongzheng.common.core.controller.BaseController;
+import com.zhongzheng.common.core.domain.AjaxResult;
+import com.zhongzheng.common.enums.BusinessType;
+import com.zhongzheng.modules.user.vo.UserPlanVo;
+import com.zhongzheng.modules.user.bo.UserPlanQueryBo;
+import com.zhongzheng.modules.user.bo.UserPlanAddBo;
+import com.zhongzheng.modules.user.bo.UserPlanEditBo;
+import com.zhongzheng.modules.user.service.IUserPlanService;
+import com.zhongzheng.common.utils.poi.ExcelUtil;
+import com.zhongzheng.common.core.page.TableDataInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * 学习计划Controller
+ * 
+ * @author ruoyi
+ * @date 2021-12-08
+ */
+@Api(value = "学习计划控制器", tags = {"学习计划管理"})
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
+@RestController
+@RequestMapping("/system/plan")
+public class UserPlanController extends BaseController {
+
+    private final IUserPlanService iUserPlanService;
+
+    /**
+     * 查询学习计划列表
+     */
+    @ApiOperation("查询学习计划列表")
+    @PreAuthorize("@ss.hasPermi('system:plan:list')")
+    @GetMapping("/list")
+    public TableDataInfo<UserPlanVo> list(UserPlanQueryBo bo) {
+        startPage();
+        List<UserPlanVo> list = iUserPlanService.queryList(bo);
+        return getDataTable(list);
+    }
+    
+
+    /**
+     * 获取学习计划详细信息
+     */
+    @ApiOperation("获取学习计划详细信息")
+    @PreAuthorize("@ss.hasPermi('system:plan:query')")
+    @GetMapping("/{planId}")
+    public AjaxResult<UserPlanVo> getInfo(@PathVariable("planId" ) Long planId) {
+        return AjaxResult.success(iUserPlanService.queryById(planId));
+    }
+
+    /**
+     * 新增学习计划
+     */
+    @ApiOperation("新增学习计划")
+    @PreAuthorize("@ss.hasPermi('system:plan:add')")
+    @Log(title = "学习计划", businessType = BusinessType.INSERT)
+    @PostMapping()
+    public AjaxResult<Void> add(@RequestBody UserPlanAddBo bo) {
+        return toAjax(iUserPlanService.insertByAddBo(bo) ? 1 : 0);
+    }
+
+    /**
+     * 修改学习计划
+     */
+    @ApiOperation("修改学习计划")
+    @PreAuthorize("@ss.hasPermi('system:plan:edit')")
+    @Log(title = "学习计划", businessType = BusinessType.UPDATE)
+    @PutMapping()
+    public AjaxResult<Void> edit(@RequestBody UserPlanEditBo bo) {
+        return toAjax(iUserPlanService.updateByEditBo(bo) ? 1 : 0);
+    }
+
+
+    /**
+     * 查询学习计划列表
+     */
+    @ApiOperation("获得展示的日历学习计划,不添加到数据库")
+    @PreAuthorize("@ss.hasPermi('system:plan:list')")
+    @GetMapping("/listPlan")
+    public TableDataInfo<UserPlanVo> listPlan(UserPlanQueryBo bo) {
+        startPage();
+        List<UserPlanVo> list = iUserPlanService.queryList(bo);
+        return getDataTable(list);
+    }
+}

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/IExamApplyService.java

@@ -56,4 +56,6 @@ public interface IExamApplyService extends IService<ExamApply> {
     List<ExamNumberGoodsVo> listGoods(ExamNumberGoodsQueryBo bo);
 
 	List<ExamApplySiteVo> getSiteInfo(ExamApplyQueryBo bo);
+
+	ExamApplyVo getGoodsInfo(ExamApplyQueryBo bo);
 }

+ 16 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamApplyServiceImpl.java

@@ -153,4 +153,20 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
         }
         return examApplySite;
     }
+
+    @Override
+    public ExamApplyVo getGoodsInfo(ExamApplyQueryBo bo) {
+        ExamApply db = this.baseMapper.selectById(bo.getApplyId());
+        ExamApplyVo examApplyVo = BeanUtil.toBean(db, ExamApplyVo.class);
+        List<ExamNumberGoodsVo> examNumberGoodsVos = baseMapper.examNumberGoodsVos(bo.getApplyId());
+        //初始化需要得到的数组
+        Long[] array = new Long[examNumberGoodsVos.size()];
+        //使用for循环得到数组
+        for(int i = 0; i < examNumberGoodsVos.size();i++){
+            array[i] = examNumberGoodsVos.get(i).getGoodsId();
+        }
+        examApplyVo.setExamNumberGoods(examNumberGoodsVos);
+        examApplyVo.setExamNumberGoodsNum(array);
+        return examApplyVo;
+    }
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/vo/ExamApplyVo.java

@@ -82,4 +82,7 @@ public class ExamApplyVo {
 
 	@ApiModelProperty("商品")
 	private List<ExamNumberGoodsVo> examNumberGoods;
+
+	@ApiModelProperty("商品")
+	private Long[] examNumberGoodsNum;
 }

+ 9 - 19
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserPlanAddBo.java

@@ -9,18 +9,21 @@ import java.util.Date;
 
 
 /**
- * 【请填写功能名称】添加对象 user_plan
+ * 学习计划添加对象 user_plan
  *
- * @author change
- * @date 2021-06-24
+ * @author ruoyi
+ * @date 2021-12-08
  */
 @Data
-@ApiModel("【请填写功能名称】添加对象")
+@ApiModel("学习计划添加对象")
 public class UserPlanAddBo {
 
     /** 计划json格式 */
     @ApiModelProperty("计划json格式")
     private String schedule;
+    /** 用户id */
+    @ApiModelProperty("用户id")
+    private Long userId;
     /** 考试日期 */
     @ApiModelProperty("考试日期")
     private Long examDate;
@@ -29,7 +32,7 @@ public class UserPlanAddBo {
     private String reminderTime;
     /** 0周日  1周一 2周二 3周三 4周四 5周五 6周六 */
     @ApiModelProperty("0周日  1周一 2周二 3周三 4周四 5周五 6周六")
-    private Integer[] studyCount;
+    private String studyCount;
     /** 复习天数 */
     @ApiModelProperty("复习天数")
     private Long studyDay;
@@ -46,7 +49,7 @@ public class UserPlanAddBo {
     @ApiModelProperty("$column.columnComment")
     private Long updateTime;
     /** 0 失效 1启用 */
-    @ApiModelProperty("0 失效 1启用 2修改计划")
+    @ApiModelProperty("0 失效 1启用")
     private Integer status;
     /** 总结数 */
     @ApiModelProperty("总结数")
@@ -54,17 +57,4 @@ public class UserPlanAddBo {
     /** 已学习节数 */
     @ApiModelProperty("已学习节数")
     private Long studyNum;
-
-    /** 计划json格式 */
-    @ApiModelProperty("计划Id")
-    private Long planId;
-
-
-    /** 用户Id */
-    @ApiModelProperty("用户Id")
-    private Long userId;
-
-    /** 定制的课程 */
-    @ApiModelProperty("定制的课程")
-    private Integer[] courseId;
 }

+ 13 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserPlanCourceAddBo.java

@@ -9,16 +9,25 @@ import java.util.Date;
 
 
 /**
- * 【请填写功能名称】添加对象 user_plan_cource
+ * 学习计划绑定课程添加对象 user_plan_cource
  *
- * @author change
- * @date 2021-06-24
+ * @author ruoyi
+ * @date 2021-12-08
  */
 @Data
-@ApiModel("【请填写功能名称】添加对象")
+@ApiModel("学习计划绑定课程添加对象")
 public class UserPlanCourceAddBo {
 
+    /** 计划id */
+    @ApiModelProperty("计划id")
+    private Long planId;
     /** 课程或题库学习计划 */
     @ApiModelProperty("课程或题库学习计划")
     private Long sourceId;
+    /** $column.columnComment */
+    @ApiModelProperty("$column.columnComment")
+    private Long createTime;
+    /** $column.columnComment */
+    @ApiModelProperty("$column.columnComment")
+    private Long updateTime;
 }

+ 10 - 5
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserPlanCourceEditBo.java

@@ -8,16 +8,15 @@ import java.util.Date;
 
 
 /**
- * 【请填写功能名称】编辑对象 user_plan_cource
+ * 学习计划绑定课程编辑对象 user_plan_cource
  *
- * @author change
- * @date 2021-06-24
+ * @author ruoyi
+ * @date 2021-12-08
  */
 @Data
-@ApiModel("【请填写功能名称】编辑对象")
+@ApiModel("学习计划绑定课程编辑对象")
 public class UserPlanCourceEditBo {
 
-
     /** 计划id */
     @ApiModelProperty("计划id")
     private Long planId;
@@ -25,4 +24,10 @@ public class UserPlanCourceEditBo {
     /** 课程或题库学习计划 */
     @ApiModelProperty("课程或题库学习计划")
     private Long sourceId;
+
+
+    /** $column.columnComment */
+    @ApiModelProperty("$column.columnComment")
+    private Long updateTime;
+
 }

+ 7 - 5
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserPlanCourceQueryBo.java

@@ -12,14 +12,14 @@ import java.util.HashMap;
 import com.zhongzheng.common.core.domain.BaseEntity;
 
 /**
- * 【请填写功能名称】分页查询对象 user_plan_cource
+ * 学习计划绑定课程分页查询对象 user_plan_cource
  *
- * @author change
- * @date 2021-06-24
+ * @author ruoyi
+ * @date 2021-12-08
  */
 @Data
 @EqualsAndHashCode(callSuper = true)
-@ApiModel("【请填写功能名称】分页查询对象")
+@ApiModel("学习计划绑定课程分页查询对象")
 public class UserPlanCourceQueryBo extends BaseEntity {
 
 	/** 分页大小 */
@@ -36,8 +36,10 @@ public class UserPlanCourceQueryBo extends BaseEntity {
 	private String isAsc;
 
 
+	/** 计划id */
+	@ApiModelProperty("计划id")
+	private Long planId;
 	/** 课程或题库学习计划 */
 	@ApiModelProperty("课程或题库学习计划")
 	private Long sourceId;
-
 }

+ 23 - 20
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserPlanEditBo.java

@@ -8,63 +8,66 @@ import java.util.Date;
 
 
 /**
- * 【请填写功能名称】编辑对象 user_plan
+ * 学习计划编辑对象 user_plan
  *
- * @author change
- * @date 2021-06-24
+ * @author ruoyi
+ * @date 2021-12-08
  */
 @Data
-@ApiModel("【请填写功能名称】编辑对象")
+@ApiModel("学习计划编辑对象")
 public class UserPlanEditBo {
 
+    /** $column.columnComment */
+    @ApiModelProperty("$column.columnComment")
+    private Long planId;
 
     /** 计划json格式 */
     @ApiModelProperty("计划json格式")
     private String schedule;
+
+    /** 用户id */
+    @ApiModelProperty("用户id")
+    private Long userId;
+
     /** 考试日期 */
     @ApiModelProperty("考试日期")
     private Long examDate;
+
     /** 提醒时间 */
     @ApiModelProperty("提醒时间")
     private String reminderTime;
+
     /** 0周日  1周一 2周二 3周三 4周四 5周五 6周六 */
     @ApiModelProperty("0周日  1周一 2周二 3周三 4周四 5周五 6周六")
-    private Integer[] studyCount;
+    private String studyCount;
+
     /** 复习天数 */
     @ApiModelProperty("复习天数")
     private Long studyDay;
+
     /** 结束时间 */
     @ApiModelProperty("结束时间")
     private Long endTime;
+
     /** 起始时间 */
     @ApiModelProperty("起始时间")
     private Long startTime;
-    /** $column.columnComment */
-    @ApiModelProperty("$column.columnComment")
-    private Long createTime;
+
     /** $column.columnComment */
     @ApiModelProperty("$column.columnComment")
     private Long updateTime;
+
     /** 0 失效 1启用 */
-    @ApiModelProperty("0 失效 1启用 2修改计划")
+    @ApiModelProperty("0 失效 1启用")
     private Integer status;
+
     /** 总结数 */
     @ApiModelProperty("总结数")
     private Long pitchNum;
+
     /** 已学习节数 */
     @ApiModelProperty("已学习节数")
     private Long studyNum;
 
-    /** 计划json格式 */
-    @ApiModelProperty("计划Id")
-    private Long planId;
-
-
-    /** 用户Id */
-    @ApiModelProperty("用户Id")
-    private Long userId;
 
-    /** 定制的课程 */
-    @ApiModelProperty("定制的课程")
-    private Integer[] courseId;
 }

+ 9 - 19
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserPlanQueryBo.java

@@ -6,21 +6,20 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import java.util.Date;
-import java.util.List;
 import java.util.Map;
 import java.util.HashMap;
 
 import com.zhongzheng.common.core.domain.BaseEntity;
 
 /**
- * 【请填写功能名称】分页查询对象 user_plan
+ * 学习计划分页查询对象 user_plan
  *
- * @author change
- * @date 2021-06-24
+ * @author ruoyi
+ * @date 2021-12-08
  */
 @Data
 @EqualsAndHashCode(callSuper = true)
-@ApiModel("【请填写功能名称】分页查询对象")
+@ApiModel("学习计划分页查询对象")
 public class UserPlanQueryBo extends BaseEntity {
 
 	/** 分页大小 */
@@ -37,15 +36,11 @@ public class UserPlanQueryBo extends BaseEntity {
 	private String isAsc;
 
 
-	/** 计划json格式 */
-	@ApiModelProperty("计划Id")
-	private Long planId;
 	/** 计划json格式 */
 	@ApiModelProperty("计划json格式")
 	private String schedule;
-
-	/** 用户Id */
-	@ApiModelProperty("用户Id")
+	/** 用户id */
+	@ApiModelProperty("用户id")
 	private Long userId;
 	/** 考试日期 */
 	@ApiModelProperty("考试日期")
@@ -54,8 +49,8 @@ public class UserPlanQueryBo extends BaseEntity {
 	@ApiModelProperty("提醒时间")
 	private String reminderTime;
 	/** 0周日  1周一 2周二 3周三 4周四 5周五 6周六 */
-	@ApiModelProperty("0周日  1周一 2周二 3周三 4周四 5周五 6周六,例如[1,2,3,4,5]")
-	private Long[] studyCount;
+	@ApiModelProperty("0周日  1周一 2周二 3周三 4周四 5周五 6周六")
+	private String studyCount;
 	/** 复习天数 */
 	@ApiModelProperty("复习天数")
 	private Long studyDay;
@@ -66,7 +61,7 @@ public class UserPlanQueryBo extends BaseEntity {
 	@ApiModelProperty("起始时间")
 	private Long startTime;
 	/** 0 失效 1启用 */
-	@ApiModelProperty("0 失效 1启用  2修改计划")
+	@ApiModelProperty("0 失效 1启用")
 	private Integer status;
 	/** 总结数 */
 	@ApiModelProperty("总结数")
@@ -74,9 +69,4 @@ public class UserPlanQueryBo extends BaseEntity {
 	/** 已学习节数 */
 	@ApiModelProperty("已学习节数")
 	private Long studyNum;
-
-	/** 定制的课程 */
-	@ApiModelProperty("定制的课程")
-	private Integer[] courseId;
-
 }

+ 9 - 24
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/domain/UserPlan.java

@@ -10,10 +10,10 @@ import java.math.BigDecimal;
 import com.zhongzheng.common.annotation.Excel;
 
 /**
- * 【请填写功能名称】对象 user_plan
- * 
- * @author change
- * @date 2021-06-24
+ * 学习计划对象 user_plan
+ *
+ * @author ruoyi
+ * @date 2021-12-08
  */
 @Data
 @NoArgsConstructor
@@ -23,50 +23,35 @@ public class UserPlan implements Serializable {
 
 private static final long serialVersionUID=1L;
 
-
-    /** 用户id */
-    private Long userId;
-
+    /** $column.columnComment */
+    @TableId(value = "plan_id")
+    private Long planId;
     /** 计划json格式 */
     private String schedule;
-
+    /** 用户id */
+    private Long userId;
     /** 考试日期 */
     private Long examDate;
-
     /** 提醒时间 */
     private String reminderTime;
-
     /** 0周日  1周一 2周二 3周三 4周四 5周五 6周六 */
     private String studyCount;
-
     /** 复习天数 */
     private Long studyDay;
-
     /** 结束时间 */
     private Long endTime;
-
     /** 起始时间 */
     private Long startTime;
-
     /** $column.columnComment */
     @TableField(fill = FieldFill.INSERT)
     private Long createTime;
-
     /** $column.columnComment */
     @TableField(fill = FieldFill.INSERT_UPDATE)
     private Long updateTime;
-
     /** 0 失效 1启用 */
     private Integer status;
-
     /** 总结数 */
     private Long pitchNum;
-
     /** 已学习节数 */
     private Long studyNum;
-
-    /** $column.columnComment */
-    @TableId(value = "plan_id")
-    private Long planId;
-
 }

+ 10 - 7
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/domain/UserPlanCource.java

@@ -10,10 +10,10 @@ import java.math.BigDecimal;
 import com.zhongzheng.common.annotation.Excel;
 
 /**
- * 【请填写功能名称】对象 user_plan_cource
- * 
- * @author change
- * @date 2021-06-24
+ * 学习计划绑定课程对象 user_plan_cource
+ *
+ * @author ruoyi
+ * @date 2021-12-08
  */
 @Data
 @NoArgsConstructor
@@ -23,11 +23,14 @@ public class UserPlanCource implements Serializable {
 
 private static final long serialVersionUID=1L;
 
-
     /** 计划id */
     private Long planId;
-
     /** 课程或题库学习计划 */
     private Long sourceId;
-
+    /** $column.columnComment */
+    @TableField(fill = FieldFill.INSERT)
+    private Long createTime;
+    /** $column.columnComment */
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private Long updateTime;
 }

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

@@ -4,10 +4,10 @@ import com.zhongzheng.modules.user.domain.UserPlanCource;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
 /**
- * 【请填写功能名称】Mapper接口
+ * 学习计划绑定课程Mapper接口
  *
  * @author ruoyi
- * @date 2021-06-24
+ * @date 2021-12-08
  */
 public interface UserPlanCourceMapper extends BaseMapper<UserPlanCource> {
 

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

@@ -1,35 +1,14 @@
 package com.zhongzheng.modules.user.mapper;
 
-import com.zhongzheng.modules.exam.vo.ExamArrangementTimeVo;
-import com.zhongzheng.modules.user.bo.UserPlanQueryBo;
 import com.zhongzheng.modules.user.domain.UserPlan;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.zhongzheng.modules.user.domain.UserPlanCource;
-import com.zhongzheng.modules.user.vo.CoursePlanVo;
-
-import java.util.List;
 
 /**
- * 【请填写功能名称】Mapper接口
+ * 学习计划Mapper接口
  *
  * @author ruoyi
- * @date 2021-06-24
+ * @date 2021-12-08
  */
 public interface UserPlanMapper extends BaseMapper<UserPlan> {
 
-    CoursePlanVo selectByCourse(UserPlanQueryBo bo);
-
-    ExamArrangementTimeVo selectByExam(Long categoryId);
-
-    List<CoursePlanVo> selectByListCourse(UserPlanQueryBo bo);
-
-    List<UserPlan> selectByUserPlan(UserPlanQueryBo bo);
-
-    void insertSource(CoursePlanVo coursePlanVo);
-
-    List<UserPlanCource> selectCourse(Long planId);
-
-    Integer selectCountCourse(UserPlanQueryBo bo);
-
-    List<Long> selectByCourseId(Long courseId);
 }

+ 7 - 7
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserPlanCourceService.java

@@ -11,10 +11,10 @@ import java.util.Collection;
 import java.util.List;
 
 /**
- * 【请填写功能名称】Service接口
+ * 学习计划绑定课程Service接口
  *
- * @author change
- * @date 2021-06-24
+ * @author ruoyi
+ * @date 2021-12-08
  */
 public interface IUserPlanCourceService extends IService<UserPlanCource> {
 	/**
@@ -29,15 +29,15 @@ public interface IUserPlanCourceService extends IService<UserPlanCource> {
 	List<UserPlanCourceVo> queryList(UserPlanCourceQueryBo bo);
 
 	/**
-	 * 根据新增业务对象插入【请填写功能名称】
-	 * @param bo 【请填写功能名称】新增业务对象
+	 * 根据新增业务对象插入学习计划绑定课程
+	 * @param bo 学习计划绑定课程新增业务对象
 	 * @return
 	 */
 	Boolean insertByAddBo(UserPlanCourceAddBo bo);
 
 	/**
-	 * 根据编辑业务对象修改【请填写功能名称】
-	 * @param bo 【请填写功能名称】编辑业务对象
+	 * 根据编辑业务对象修改学习计划绑定课程
+	 * @param bo 学习计划绑定课程编辑业务对象
 	 * @return
 	 */
 	Boolean updateByEditBo(UserPlanCourceEditBo bo);

+ 7 - 25
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserPlanService.java

@@ -1,29 +1,27 @@
 package com.zhongzheng.modules.user.service;
 
 import com.zhongzheng.modules.user.domain.UserPlan;
-import com.zhongzheng.modules.user.vo.CalendarStudyVo;
 import com.zhongzheng.modules.user.vo.UserPlanVo;
 import com.zhongzheng.modules.user.bo.UserPlanQueryBo;
 import com.zhongzheng.modules.user.bo.UserPlanAddBo;
 import com.zhongzheng.modules.user.bo.UserPlanEditBo;
 import com.baomidou.mybatisplus.extension.service.IService;
 
-import java.text.ParseException;
 import java.util.Collection;
 import java.util.List;
 
 /**
- * 【请填写功能名称】Service接口
+ * 学习计划Service接口
  *
  * @author ruoyi
- * @date 2021-06-24
+ * @date 2021-12-08
  */
 public interface IUserPlanService extends IService<UserPlan> {
 	/**
 	 * 查询单个
 	 * @return
 	 */
-	UserPlanVo queryById(Long userId);
+	UserPlanVo queryById(Long planId);
 
 	/**
 	 * 查询列表
@@ -31,15 +29,15 @@ public interface IUserPlanService extends IService<UserPlan> {
 	List<UserPlanVo> queryList(UserPlanQueryBo bo);
 
 	/**
-	 * 根据新增业务对象插入【请填写功能名称】
-	 * @param bo 【请填写功能名称】新增业务对象
+	 * 根据新增业务对象插入学习计划
+	 * @param bo 学习计划新增业务对象
 	 * @return
 	 */
 	Boolean insertByAddBo(UserPlanAddBo bo);
 
 	/**
-	 * 根据编辑业务对象修改【请填写功能名称】
-	 * @param bo 【请填写功能名称】编辑业务对象
+	 * 根据编辑业务对象修改学习计划
+	 * @param bo 学习计划编辑业务对象
 	 * @return
 	 */
 	Boolean updateByEditBo(UserPlanEditBo bo);
@@ -51,20 +49,4 @@ public interface IUserPlanService extends IService<UserPlan> {
 	 * @return
 	 */
 	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
-
-
-	/**
-	 * 校验并删除数据
-	 * @param bo
-	 * @return
-	 */
-	UserPlanVo generate(UserPlanQueryBo bo) throws ParseException;
-
-	List<UserPlanVo> userPlan(UserPlanQueryBo bo);
-
-	Boolean updateGenerate(UserPlanAddBo bo) throws ParseException;
-
-	UserPlanVo userPlanSeven(UserPlanQueryBo bo);
-
-	boolean editPlan(UserPlanQueryBo bo) throws ParseException;
 }

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

@@ -22,10 +22,10 @@ import java.util.List;
 import java.util.stream.Collectors;
 
 /**
- * 【请填写功能名称】Service业务层处理
+ * 学习计划绑定课程Service业务层处理
  *
  * @author ruoyi
- * @date 2021-06-24
+ * @date 2021-12-08
  */
 @Service
 public class UserPlanCourceServiceImpl extends ServiceImpl<UserPlanCourceMapper, UserPlanCource> implements IUserPlanCourceService {
@@ -39,6 +39,7 @@ public class UserPlanCourceServiceImpl extends ServiceImpl<UserPlanCourceMapper,
     @Override
     public List<UserPlanCourceVo> queryList(UserPlanCourceQueryBo bo) {
         LambdaQueryWrapper<UserPlanCource> lqw = Wrappers.lambdaQuery();
+        lqw.eq(bo.getPlanId() != null, UserPlanCource::getPlanId, bo.getPlanId());
         lqw.eq(bo.getSourceId() != null, UserPlanCource::getSourceId, bo.getSourceId());
         return entity2Vo(this.list(lqw));
     }
@@ -67,6 +68,8 @@ public class UserPlanCourceServiceImpl extends ServiceImpl<UserPlanCourceMapper,
     public Boolean insertByAddBo(UserPlanCourceAddBo bo) {
         UserPlanCource add = BeanUtil.toBean(bo, UserPlanCource.class);
         validEntityBeforeSave(add);
+        add.setCreateTime(DateUtils.getNowTime());
+        add.setUpdateTime(DateUtils.getNowTime());
         return this.save(add);
     }
 
@@ -74,6 +77,7 @@ public class UserPlanCourceServiceImpl extends ServiceImpl<UserPlanCourceMapper,
     public Boolean updateByEditBo(UserPlanCourceEditBo bo) {
         UserPlanCource update = BeanUtil.toBean(bo, UserPlanCource.class);
         validEntityBeforeSave(update);
+        update.setUpdateTime(DateUtils.getNowTime());
         return this.updateById(update);
     }
 

+ 16 - 1598
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserPlanServiceImpl.java

@@ -1,25 +1,8 @@
 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;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.google.gson.JsonArray;
 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.*;
-import io.micrometer.core.instrument.util.TimeUtils;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -30,37 +13,26 @@ import com.zhongzheng.modules.user.bo.UserPlanQueryBo;
 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.vo.UserPlanVo;
 import com.zhongzheng.modules.user.service.IUserPlanService;
-import org.springframework.transaction.annotation.Transactional;
 
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 import java.util.stream.Collectors;
 
 /**
- * 【请填写功能名称】Service业务层处理
+ * 学习计划Service业务层处理
  *
- * @author change
- * @date 2021-06-24
+ * @author ruoyi
+ * @date 2021-12-08
  */
 @Service
 public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> implements IUserPlanService {
 
-
-    @Autowired
-    private IUserPlanCourceService userPlanCourceService;
-
-    @Autowired
-    private IUserStudyRecordService userStudyRecordService;
-
-    @Autowired
-    private IOrderPossessUserService iOrderPossessUserService;
-
     @Override
-    public UserPlanVo queryById(Long userId){
-        UserPlan db = this.baseMapper.selectById(userId);
+    public UserPlanVo queryById(Long planId){
+        UserPlan db = this.baseMapper.selectById(planId);
         return BeanUtil.toBean(db, UserPlanVo.class);
     }
 
@@ -68,9 +40,10 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
     public List<UserPlanVo> queryList(UserPlanQueryBo bo) {
         LambdaQueryWrapper<UserPlan> lqw = Wrappers.lambdaQuery();
         lqw.eq(StrUtil.isNotBlank(bo.getSchedule()), UserPlan::getSchedule, bo.getSchedule());
+        lqw.eq(bo.getUserId() != null, UserPlan::getUserId, bo.getUserId());
         lqw.eq(bo.getExamDate() != null, UserPlan::getExamDate, bo.getExamDate());
         lqw.eq(StrUtil.isNotBlank(bo.getReminderTime()), UserPlan::getReminderTime, bo.getReminderTime());
-        lqw.eq(bo.getStudyCount() != null, UserPlan::getStudyCount, bo.getStudyCount());
+        lqw.eq(StrUtil.isNotBlank(bo.getStudyCount()), UserPlan::getStudyCount, bo.getStudyCount());
         lqw.eq(bo.getStudyDay() != null, UserPlan::getStudyDay, bo.getStudyDay());
         lqw.eq(bo.getEndTime() != null, UserPlan::getEndTime, bo.getEndTime());
         lqw.eq(bo.getStartTime() != null, UserPlan::getStartTime, bo.getStartTime());
@@ -81,11 +54,11 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
     }
 
     /**
-     * 实体类转化成视图对象
-     *
-     * @param collection 实体类集合
-     * @return
-     */
+    * 实体类转化成视图对象
+    *
+    * @param collection 实体类集合
+    * @return
+    */
     private List<UserPlanVo> entity2Vo(Collection<UserPlan> collection) {
         List<UserPlanVo> voList = collection.stream()
                 .map(any -> BeanUtil.toBean(any, UserPlanVo.class))
@@ -133,1559 +106,4 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
         }
         return this.removeByIds(ids);
     }
-
-    @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);
-            if (bo.getStatus() != null && bo.getStatus() == 1){
-                UserPlan userPlan = new UserPlan();
-                String s = JSON.toJSONString(userPlanVo.getCalendarStudyVo());
-                String s1 = JSON.toJSONString(userPlanVo.getStudyCount());
-                userPlan.setStudyDay(bo.getStudyDay());
-                userPlan.setStudyCount(s1);
-                userPlan.setUserId(bo.getUserId());
-                userPlan.setSchedule(s);
-                userPlan.setPitchNum(userPlanVo.getPitchNum());
-                userPlan.setStudyNum(0L);
-                userPlan.setCreateTime(DateUtils.getNowTime());
-                userPlan.setUpdateTime(DateUtils.getNowTime());
-                userPlan.setExamDate(userPlanVo.getExamDate());
-                if (bo.getStatus() != null){
-                    userPlan.setStatus(bo.getStatus());
-                }
-                if (bo.getStatus() == 1) {
-                    boolean save = this.save(userPlan);
-                    for (CoursePlanVo coursePlanVo : userPlanVo.getCoursePlanVo()) {
-                        coursePlanVo.setPlanId(userPlan.getPlanId());
-                        baseMapper.insertSource(coursePlanVo);
-                    }
-                }
-                if (bo.getStatus() == 2){
-                    userPlan.setPlanId(bo.getPlanId());
-                    boolean save = this.updateById(userPlan);
-                    for (CoursePlanVo coursePlanVo : userPlanVo.getCoursePlanVo()) {
-                        coursePlanVo.setPlanId(userPlan.getPlanId());
-                        baseMapper.insertSource(coursePlanVo);
-                    }
-                }
-            }
-            return userPlanVo;
-        }else{
-            validEntitySave(bo);
-            UserPlanVo userPlanVo = generateSelfBo(bo);
-            if (bo.getStatus() != null && bo.getStatus() == 1) {
-                UserPlan userPlan = new UserPlan();
-                String s = JSON.toJSONString(userPlanVo.getCalendarStudyVo());
-                String s1 = JSON.toJSONString(userPlanVo.getStudyCount());
-
-                userPlan.setStudyDay(bo.getStudyDay());
-                userPlan.setStudyCount(s1);
-                userPlan.setUserId(bo.getUserId());
-                userPlan.setSchedule(s);
-                userPlan.setExamDate(bo.getExamDate());
-                userPlan.setReminderTime(bo.getReminderTime());
-                userPlan.setPitchNum(userPlanVo.getPitchNum());
-                userPlan.setStudyNum(0L);
-                userPlan.setCreateTime(DateUtils.getNowTime());
-                userPlan.setUpdateTime(DateUtils.getNowTime());
-                userPlan.setStartTime(bo.getStartTime());
-                userPlan.setEndTime(bo.getEndTime());
-                userPlan.setStudyDay(bo.getStudyDay());
-                if (bo.getStatus() != null){
-                    userPlan.setStatus(bo.getStatus());
-                }
-                if (bo.getStatus() == 1) {
-                    boolean save = this.save(userPlan);
-                    for (CoursePlanVo coursePlanVo : userPlanVo.getCoursePlanVo()) {
-                        coursePlanVo.setPlanId(userPlan.getPlanId());
-                        baseMapper.insertSource(coursePlanVo);
-                    }
-                }
-                if (bo.getStatus() == 2){
-                    userPlan.setPlanId(bo.getPlanId());
-                    boolean save = this.updateById(userPlan);
-                    for (CoursePlanVo coursePlanVo : userPlanVo.getCoursePlanVo()) {
-                        coursePlanVo.setPlanId(userPlan.getPlanId());
-                        baseMapper.insertSource(coursePlanVo);
-                    }
-                }
-            }
-            return userPlanVo;
-        }
-    }
-
-    private void validEntitySave(UserPlanQueryBo bo) {
-        if (bo.getStudyDay() == null){
-            throw new IllegalArgumentException("复习天数为空");
-        }
-        if (bo.getCourseId() == null){
-            throw new IllegalArgumentException("课程为空");
-        }
-        if (bo.getStudyCount() == null){
-            throw new IllegalArgumentException("周复习为空");
-        }
-        if (bo.getExamDate() == null){
-            throw new IllegalArgumentException("考试时间为空");
-        }
-
-        if (bo.getStartTime() == null || bo.getEndTime() == null){
-            throw new IllegalArgumentException("起止天数为空");
-        }
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    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());
-            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<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());
-            //初始化需要得到的数组
-            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);
-                                }
-                            });
-                });
-            });
-
-            //更新当天学习节数是否已经完成
-            //代表前面是否有未完成课程
-            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());
-                //更新当天学习节数是否已经完成
-                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);
-                                }
-                            }
-                        }
-
-                    }
-
-                } 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;
-                }
-
-            }
-            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);
-            out:if (!CollectionUtils.isEmpty(userPlanVo.getCalendarStudyVo())){
-                for (CalendarStudyVo calendarStudyVo : userPlanVo.getCalendarStudyVo()) {
-                    if (calendarStudyVo.getMonth() == (cal.get(Calendar.MONTH)+1)){
-                        break out;
-                    }
-                }
-                //得到日历日期
-                Long firstDayOfMonth = getFirstDayOfMonth(cal.get(Calendar.MONTH)+1);
-                Long lastDayOfMonth = getLastDayOfMonth(cal.get(Calendar.MONTH)+1);
-                List<DayStudyVo> dayStudyVosOne = getDays(firstDayOfMonth,lastDayOfMonth);
-                CalendarStudyVo calendarStudyVo = new CalendarStudyVo();
-                calendarStudyVo.setDayStudyList(dayStudyVosOne);
-                calendarStudyVo.setYear(Convert.toLong(cal.get(Calendar.YEAR)));
-                calendarStudyVo.setMonth(Convert.toLong(cal.get(Calendar.MONTH)+1));
-                calendarStudyVos.add(calendarStudyVo);
-                userPlanVo.setCalendarStudyVo(calendarStudyVos);
-            }
-            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) {
-            UserPlan userPlan = new UserPlan();
-            userPlan.setPlanId(bo.getPlanId());
-            userPlan.setStatus(0);
-            userPlan.setUpdateTime(DateUtils.getNowTime());
-            int i = baseMapper.updateById(userPlan);
-        }else {
-            //自定义学习计划,自动生成计划
-                UserPlanVo userPlanVo = generateSelfBo(userPlanQueryBo);
-                if (bo.getStatus() != null) {
-                    UserPlan userPlan = new UserPlan();
-                    String s = JSON.toJSONString(userPlanVo.getCalendarStudyVo());
-                    String s1 = JSON.toJSONString(userPlanVo.getStudyCount());
-                    userPlan.setUpdateTime(DateUtils.getNowTime());
-                    userPlan.setStudyDay(bo.getStudyDay());
-                    userPlan.setStudyCount(s1);
-                    userPlan.setUserId(bo.getUserId());
-                    userPlan.setSchedule(s);
-                    userPlan.setExamDate(bo.getExamDate());
-                    userPlan.setReminderTime(bo.getReminderTime());
-                    userPlan.setPitchNum(userPlanVo.getPitchNum());
-                    userPlan.setStudyNum(0L);
-                    userPlan.setCreateTime(DateUtils.getNowTime());
-                    userPlan.setUpdateTime(DateUtils.getNowTime());
-                    userPlan.setStartTime(bo.getStartTime());
-                    userPlan.setEndTime(bo.getEndTime());
-                    userPlan.setStudyDay(bo.getStudyDay());
-                    if (bo.getStatus() != null) {
-                        userPlan.setStatus(bo.getStatus());
-                    }
-                    if (bo.getStatus() == 1) {
-                        boolean save = this.save(userPlan);
-                        for (CoursePlanVo coursePlanVo : userPlanVo.getCoursePlanVo()) {
-                            coursePlanVo.setPlanId(userPlan.getPlanId());
-                            baseMapper.insertSource(coursePlanVo);
-                        }
-                    }
-                    if (bo.getStatus() == 2) {
-                        userPlan.setPlanId(bo.getPlanId());
-                        userPlan.setStatus(1);
-                        boolean save = this.updateById(userPlan);
-                        LambdaQueryWrapper<UserPlanCource> lqw = Wrappers.lambdaQuery();
-                        lqw.eq(bo.getPlanId() != null,UserPlanCource::getPlanId,bo.getPlanId());
-                        userPlanCourceService.remove(lqw);
-                        for (CoursePlanVo coursePlanVo : userPlanVo.getCoursePlanVo()) {
-                            coursePlanVo.setPlanId(userPlan.getPlanId());
-                            baseMapper.insertSource(coursePlanVo);
-                        }
-                    }
-            }
-
-        }
-        return true;
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    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);
-
-            //得到日历日期
-            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);
-
-            userPlanVos.setCoursePlanVo(coursePlanVo);
-            List<DayStudyVo> dayStudyVos = new ArrayList<>();
-            List<DayStudyVo> finalDayStudyVos = dayStudyVos;
-
-            //更新当天学习节数是否已经完成
-            //代表前面是否有未完成课程
-            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());
-                //更新当天学习节数是否已经完成
-                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);
-                                }
-                            }
-                        }
-
-                    }
-
-                } 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;
-                }
-
-            }
-
-            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()
-                                .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);
-            out:if (!CollectionUtils.isEmpty(userPlanVos.getCoursePlanVo())){
-                for (CalendarStudyVo calendarStudyVo : userPlanVos.getCalendarStudyVo()) {
-                    if (calendarStudyVo.getMonth() == (cal.get(Calendar.MONTH)+1)){
-                        break out;
-                    }
-                }
-                //得到日历日期
-                Long firstDayOfMonth = getFirstDayOfMonth(cal.get(Calendar.MONTH)+1);
-                Long lastDayOfMonth = getLastDayOfMonth(cal.get(Calendar.MONTH)+1);
-                List<DayStudyVo> dayStudyVosOne = getDays(firstDayOfMonth,lastDayOfMonth);
-                switch (cal.get(Calendar.DAY_OF_WEEK)- 1){
-                    case 0:
-                        dayStudyVosOne=dayStudyVosOne.stream()
-                                .filter(v -> v.getDate() <= cal.get(Calendar.DAY_OF_MONTH) + 7)
-                                .collect(Collectors.toList());
-                        break;
-                    case 1:
-                        dayStudyVosOne=dayStudyVosOne.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:
-                        dayStudyVosOne=dayStudyVosOne.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:
-                        dayStudyVosOne=dayStudyVosOne.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:
-                        dayStudyVosOne=dayStudyVosOne.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:
-                        dayStudyVosOne=dayStudyVosOne.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:
-                        dayStudyVosOne=dayStudyVosOne.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(dayStudyVosOne);
-                calendarStudyVo.setYear(Convert.toLong(cal.get(Calendar.YEAR)));
-                calendarStudyVo.setMonth(Convert.toLong(cal.get(Calendar.MONTH)+1));
-                calendarStudyVos.add(calendarStudyVo);
-                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;
-    }
-
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public boolean editPlan(UserPlanQueryBo bo) throws ParseException {
-        List<UserPlan> userPlans = baseMapper.selectByUserPlan(bo);
-        if (CollectionUtils.isEmpty(userPlans)){
-            throw new IllegalArgumentException("没有该计划");
-        }
-        UserPlan userPlan = userPlans.get(0);
-
-        //得到日历日期
-        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);
-
-        for (CoursePlanVo planVo : coursePlanVo) {
-            List<UserStudyRecord> studyCount = userStudyRecordService.selectUserStudy(bo.getUserId(), Convert.toInt(planVo.getCourseId()));
-            List<UserStudyRecord> myList = studyCount.stream().distinct().collect(Collectors.toList());
-
-            List<Long> listId= baseMapper.selectByCourseId(planVo.getCourseId());
-            Map<Long,Long> listMap = new HashMap<>();
-            for (Long aLong : listId) {
-                listMap.put(aLong,planVo.getCourseId());
-            }
-            for (UserStudyRecord userStudyRecord : myList) {
-                listMap.remove(userStudyRecord);
-            }
-
-
-            //最近考试时间七天前到现在的天数,学习视频时长
-            Date date1 = new Date(userPlan.getExamDate()*1000L);
-            //获得相隔天数
-            //得到学习的周
-            List<Long> cont = JSONObject.parseArray(userPlan.getStudyCount(), Long.class);
-            Long[] longs = new Long[cont.size()];
-            cont.toArray(longs);
-
-            int dutyDays = getDutyDays(new Date(), date1,longs,7L);
-
-            //计算每天需要学习多少节课
-            int size = listMap.size();
-
-            int Sec = (int)Math.ceil((double)listMap.size()/dutyDays);
-
-            //总节数
-            Integer sectionNum = listMap.size();
-            if(sectionNum <= 0){
-                throw new IllegalArgumentException("该课程没有节数,无法生成计划");
-            }
-
-            //key和value都循环
-            listId = new ArrayList<>();
-            for(Map.Entry<Long,Long> entry : listMap.entrySet()) {
-                listId.add(entry.getKey());
-            }
-
-            //获得今天日期,将每天节数写入
-            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()){
-                    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)) {
-                        if (sectionNum == 0){
-                            break;
-                        }
-                        if (Sec < sectionNum) {
-                            dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec)+dayStudyVo.getStudyCourseKnob());
-                            sectionNum = sectionNum-Sec;
-                            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());
-                            sectionNum = 0;
-                            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)){
-                        if (Sec < sectionNum) {
-                            dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec)+dayStudyVo.getStudyCourseKnob());
-
-                            Map<Long, Long> courseDayMap = dayStudyVo.getCourseDayMap();
-                            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());
-                            Map<Long, Long> courseDayMap = dayStudyVo.getCourseDayMap();
-                            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;
-
-                        }
-                    }
-                }
-            }
-
-            //原有课程不满足课程节数则再创建课程
-            if (sectionNum != 0){
-                while (sectionNum != 0 ) {
-                    if (CollectionUtils.isEmpty(calendarStudyVos)) {
-                        month = cal.get(Calendar.MONTH)+1;
-                    }else {
-                        ++month;
-                    }
-                    Long firstDayOfMonth = getFirstDayOfMonth(month);
-                    Long lastDayOfMonth = getLastDayOfMonth(month);
-
-                    List<DayStudyVo> dayStudyVos = getDays(firstDayOfMonth, lastDayOfMonth);
-                    for (DayStudyVo dayStudyVo : dayStudyVos) {
-                        if (dayStudyVo.getDate() > Calendar.getInstance().get(Calendar.DAY_OF_MONTH) && month == (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)) {
-                            if (sectionNum == 0){
-                                break;
-                            }
-                            if (Sec < sectionNum) {
-                                dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
-                                sectionNum = sectionNum-Sec;
-                                Map<Long, Long> courseDayMap = dayStudyVo.getCourseDayMap();
-                                if (courseDayMap == null) {
-                                    courseDayMap = new HashMap<>();
-                                }
-                                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));
-                                Map<Long, Long> courseDayMap = dayStudyVo.getCourseDayMap();
-                                if (courseDayMap == null) {
-                                    courseDayMap = new HashMap<>();
-                                }
-                                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);
-                            }
-                        }else if(month > (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
-                            if (Sec < sectionNum) {
-                                dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
-                                sectionNum = sectionNum-Sec;
-                                Map<Long, Long> courseDayMap = dayStudyVo.getCourseDayMap();
-                                if (courseDayMap == null) {
-                                    courseDayMap = new HashMap<>();
-                                }
-                                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));
-                                Map<Long, Long> courseDayMap = dayStudyVo.getCourseDayMap();
-                                if (courseDayMap == null) {
-                                    courseDayMap = new HashMap<>();
-                                }
-                                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);
-                            }
-                        }
-                    }
-                    CalendarStudyVo calendarStudyVo = new CalendarStudyVo();
-                    calendarStudyVo.setYear(Convert.toLong(year));
-                    calendarStudyVo.setMonth(Convert.toLong(month));
-                    calendarStudyVo.setDayStudyList(dayStudyVos);
-                    List<CalendarStudyVo> calendarStudyVo1 = calendarStudyVos;
-                    calendarStudyVo1.add(calendarStudyVo);
-                }
-            }
-
-        }
-        UserPlan userPlan1 = new UserPlan();
-        userPlan1.setPlanId(userPlan.getPlanId());
-        String calendar = JSON.toJSONString(calendarStudyVos);
-        userPlan1.setSchedule(calendar);
-        userPlan1.setUpdateTime(DateUtils.getNowTime());
-        int i = baseMapper.updateById(userPlan1);
-
-
-        return true;
-    }
-
-
-    private UserPlanVo generateSelfBo(UserPlanQueryBo bo) throws ParseException {
-
-
-        //获得当前课程最近一个考试计划  考生考生计划或者最近考试计划
-        List<CoursePlanVo> coursePlanVo = baseMapper.selectByListCourse(bo);
-
-        UserPlanVo userPlanVo1 = null;
-        Long category=coursePlanVo.get(0).getCategoryId();
-        for (CoursePlanVo planVo : coursePlanVo) {
-            if (!category.equals(planVo.getCategoryId())){
-                throw new IllegalArgumentException("课程类型不符合同一类型");
-            }
-            if (userPlanVo1 == null) {
-                userPlanVo1 = generateList(bo, planVo);
-            }else {
-                userPlanVo1 = generateOr(bo,planVo,userPlanVo1);
-            }
-        }
-        return userPlanVo1;
-    }
-
-    private UserPlanVo generateOr(UserPlanQueryBo bo, CoursePlanVo planVo, UserPlanVo userPlanVo1) throws ParseException {
-        //最近考试时间七天前到现在的天数,学习视频时长
-        Date date1 = new Date(bo.getExamDate()*1000L);
-        //获得相隔天数
-        Long[] longs =bo.getStudyCount();
-        int dutyDays = getDutyDays(new Date(), date1,longs,7L);
-
-        //计算每天需要学习多少节课
-        int Sec = (int)Math.ceil((double)planVo.getSectionNum()/dutyDays);
-
-        //总节数
-        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);
-        Integer month = 0;
-        //将原有的月份添加课程的节数
-        for (CalendarStudyVo calendarStudyVo : userPlanVo1.getCalendarStudyVo()) {
-            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)) {
-                    if (sectionNum == 0){
-                        break;
-                    }
-                    if (Sec < sectionNum) {
-                        dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec)+dayStudyVo.getStudyCourseKnob());
-                        sectionNum = sectionNum-Sec;
-                        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());
-                        sectionNum = 0;
-                        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)){
-                    if (Sec < sectionNum) {
-                        dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec)+dayStudyVo.getStudyCourseKnob());
-
-                        Map<Long, Long> courseDayMap = dayStudyVo.getCourseDayMap();
-                        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());
-                        Map<Long, Long> courseDayMap = dayStudyVo.getCourseDayMap();
-                        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;
-
-                    }
-                }
-            }
-        }
-
-        //原有课程不满足课程节数则再创建课程
-        if (sectionNum != 0){
-            while (sectionNum != 0 ) {
-                if (CollectionUtils.isEmpty(userPlanVo1.getCalendarStudyVo())) {
-                    month = cal.get(Calendar.MONTH)+1;
-                }else {
-                    ++month;
-                }
-                Long firstDayOfMonth = getFirstDayOfMonth(month);
-                Long lastDayOfMonth = getLastDayOfMonth(month);
-
-                List<DayStudyVo> dayStudyVos = getDays(firstDayOfMonth, lastDayOfMonth);
-                for (DayStudyVo dayStudyVo : dayStudyVos) {
-                    if (dayStudyVo.getDate() > Calendar.getInstance().get(Calendar.DAY_OF_MONTH) && month == (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)) {
-                        if (sectionNum == 0){
-                            break;
-                        }
-                        if (Sec < sectionNum) {
-                            dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
-                            sectionNum = sectionNum-Sec;
-                            Map<Long, Long> courseDayMap = dayStudyVo.getCourseDayMap();
-                            if (courseDayMap == null) {
-                                courseDayMap = new HashMap<>();
-                            }
-                            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));
-                            Map<Long, Long> courseDayMap = dayStudyVo.getCourseDayMap();
-                            if (courseDayMap == null) {
-                                courseDayMap = new HashMap<>();
-                            }
-                            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);
-                        }
-                    }else if(month != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
-                        if (Sec < sectionNum) {
-                            dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
-                            sectionNum = sectionNum-Sec;
-                            Map<Long, Long> courseDayMap = dayStudyVo.getCourseDayMap();
-                            if (courseDayMap == null) {
-                                courseDayMap = new HashMap<>();
-                            }
-                            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));
-                            Map<Long, Long> courseDayMap = dayStudyVo.getCourseDayMap();
-                            if (courseDayMap == null) {
-                                courseDayMap = new HashMap<>();
-                            }
-                            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);
-                        }
-                    }
-                }
-                CalendarStudyVo calendarStudyVo = new CalendarStudyVo();
-                calendarStudyVo.setYear(Convert.toLong(year));
-                calendarStudyVo.setMonth(Convert.toLong(month));
-                calendarStudyVo.setDayStudyList(dayStudyVos);
-                List<CalendarStudyVo> calendarStudyVo1 = userPlanVo1.getCalendarStudyVo();
-                calendarStudyVo1.add(calendarStudyVo);
-                userPlanVo1.setCalendarStudyVo(calendarStudyVo1);
-            }
-        }
-        //查询是否解锁题库
-        userPlanVo1.setStudyCount(longs);
-        userPlanVo1.setUserId(bo.getUserId());
-        userPlanVo1.setStudyDay(0L);
-        userPlanVo1.setPitchNum(Convert.toLong(sectionNum)+userPlanVo1.getPitchNum());
-        List<CoursePlanVo> coursePlanVo = userPlanVo1.getCoursePlanVo();
-        coursePlanVo.add(planVo);
-        userPlanVo1.setCoursePlanVo(coursePlanVo);
-        return userPlanVo1;
-    }
-
-    private UserPlanVo generateList(UserPlanQueryBo bo, CoursePlanVo coursePlanVo) throws ParseException {
-        UserPlanVo userPlanVo = new UserPlanVo();
-        //最近考试时间七天前到现在的天数,学习视频时长
-        Date date1 = new Date(bo.getStartTime()*1000L);
-        Date date = new Date(bo.getEndTime()*1000L);
-        Calendar ca = Calendar.getInstance();
-        ca.setTime(date1);
-
-        //获得相隔天数
-        Long[] longs =bo.getStudyCount();
-        int dutyDays = getDutyDays(date1, date,longs,0L);
-
-        //计算每天需要学习多少节课
-        int Sec = (int)Math.ceil((double)coursePlanVo.getSectionNum()/dutyDays);
-
-        //总节数
-        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();
-        int year = cal.get(Calendar.YEAR);
-        //课程节数不足结束循环
-        while (sectionNum != 0 ) {
-            int month=0;
-            //获得当月
-            if (!CollectionUtils.isEmpty(calendarStudyVos) && calendarStudyVos.size() > 0){
-                for (CalendarStudyVo calendarStudyVo : calendarStudyVos) {
-                    if (month < calendarStudyVo.getMonth()){
-                        month = Convert.toInt(calendarStudyVo.getMonth()+1);
-                    }
-                }
-            }else {
-                month = cal.get(Calendar.MONTH) + 1;
-            }
-
-            Long firstDayOfMonth = getFirstDayOfMonth(month);
-            Long lastDayOfMonth = getLastDayOfMonth(month);
-
-            List<DayStudyVo> dayStudyVos = getDays(firstDayOfMonth, lastDayOfMonth);
-            for (DayStudyVo dayStudyVo : dayStudyVos) {
-                if (dayStudyVo.getDate() > ca.get(Calendar.DAY_OF_MONTH) && month == (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)) {
-                    if (sectionNum == 0){
-                        break;
-                    }
-                    if (Sec < sectionNum) {
-                        dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
-                        sectionNum = sectionNum-Sec;
-                        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));
-                        sectionNum = 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);
-                        dayStudyVo.setPerform(0);
-                    }
-                }else if(month != (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)){
-                    if (Sec < sectionNum) {
-                        dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
-                        sectionNum = sectionNum-Sec;
-                        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));
-                        sectionNum = 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);
-                        dayStudyVo.setPerform(0);
-                    }
-                }
-            }
-            CalendarStudyVo calendarStudyVo = new CalendarStudyVo();
-            calendarStudyVo.setYear(Convert.toLong(year));
-            calendarStudyVo.setMonth(Convert.toLong(month));
-            calendarStudyVo.setDayStudyList(dayStudyVos);
-            calendarStudyVos.add(calendarStudyVo);
-        }
-
-        //查询是否解锁题库
-
-
-        userPlanVo.setCalendarStudyVo(calendarStudyVos);
-        List<CoursePlanVo> coursePlanVos = new ArrayList<>();
-        userPlanVo.setStudyCount(longs);
-        userPlanVo.setUserId(bo.getUserId());
-
-        userPlanVo.setStudyDay(0L);
-        coursePlanVos.add(coursePlanVo);
-        userPlanVo.setCoursePlanVo(coursePlanVos);
-        return userPlanVo;
-    }
-
-    private UserPlanVo generateSelf(UserPlanQueryBo bo) throws ParseException {
-        UserPlanVo userPlanVo = new UserPlanVo();
-
-        //获得当前课程最近一个考试计划  考生考生计划或者最近考试计划
-        CoursePlanVo coursePlanVo = baseMapper.selectByCourse(bo);
-        ExamArrangementTimeVo examArrangementTimeVo = baseMapper.selectByExam(coursePlanVo.getCategoryId());
-        if (examArrangementTimeVo == null){
-            throw new IllegalArgumentException("当前课程无考试时间");
-        }
-        userPlanVo.setExamDate(examArrangementTimeVo.getStartTime());
-        //最近考试时间七天前到现在的天数,学习视频时长
-        Date date1 = new Date(examArrangementTimeVo.getStartTime()*1000L);
-        //获得相隔天数
-        Long[] longs ={1L,2L,3L,4L,5L,6L};
-        int dutyDays = getDutyDays(new Date(), date1,longs,7L);
-
-        //计算每天需要学习多少节课
-        int Sec = (int)Math.ceil((double)coursePlanVo.getSectionNum()/dutyDays);
-
-        //总节数
-        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();
-        int year = cal.get(Calendar.YEAR);
-        //课程节数不足结束循环
-        while (sectionNum != 0 ) {
-            int month=0;
-            //获得当月
-            if (!CollectionUtils.isEmpty(calendarStudyVos) && calendarStudyVos.size() > 0){
-                for (CalendarStudyVo calendarStudyVo : calendarStudyVos) {
-                    if (month < calendarStudyVo.getMonth()){
-                        month = Convert.toInt(calendarStudyVo.getMonth()+1);
-                    }
-                }
-            }else {
-                month = cal.get(Calendar.MONTH) + 1;
-            }
-
-            Long firstDayOfMonth = getFirstDayOfMonth(month);
-            Long lastDayOfMonth = getLastDayOfMonth(month);
-
-            List<DayStudyVo> dayStudyVos = getDays(firstDayOfMonth, lastDayOfMonth);
-            for (DayStudyVo dayStudyVo : dayStudyVos) {
-                if (dayStudyVo.getDate() > Calendar.getInstance().get(Calendar.DAY_OF_MONTH) && month == (cal.get(Calendar.MONTH) + 1) && ifTrue(dayStudyVo.getStudyDay(),longs)) {
-                    if (sectionNum == 0){
-                        break;
-                    }
-                    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;
-                    }
-                }
-                dayStudyVo.setPerform(0);
-            }
-            CalendarStudyVo calendarStudyVo = new CalendarStudyVo();
-            calendarStudyVo.setYear(Convert.toLong(year));
-            calendarStudyVo.setMonth(Convert.toLong(month));
-            calendarStudyVo.setDayStudyList(dayStudyVos);
-            calendarStudyVos.add(calendarStudyVo);
-        }
-
-        //查询是否解锁题库
-
-
-        userPlanVo.setCalendarStudyVo(calendarStudyVos);
-        List<CoursePlanVo> coursePlanVos = new ArrayList<>();
-        userPlanVo.setStudyCount(longs);
-        userPlanVo.setUserId(bo.getUserId());
-
-        userPlanVo.setStudyDay(0L);
-        coursePlanVos.add(coursePlanVo);
-        userPlanVo.setCoursePlanVo(coursePlanVos);
-        return userPlanVo;
-    }
-
-    private boolean ifTrue(Long studyDay,Long[] studyDays) {
-        for (Long day : studyDays) {
-            if (day.equals(studyDay)){
-                return true;
-            }
-        }
-        return false;
-    }
-
-
-    /**
-     * 计算两个日期之间相差的天数
-     * @param bdate  较大的时间
-     * @return 相差天数
-     * @throws ParseException
-     */
-    public static int daysBetween(Date bdate) throws ParseException
-    {
-        Date smdate=new Date();
-        //获得七天前的日期
-        Calendar c = Calendar.getInstance();
-        c.setTime(bdate);
-        c.add(Calendar.DATE, - 7);
-        bdate = c.getTime();
-        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
-        smdate=sdf.parse(sdf.format(smdate));
-        bdate=sdf.parse(sdf.format(bdate));
-        Calendar cal = Calendar.getInstance();
-        cal.setTime(smdate);
-        long time1 = cal.getTimeInMillis();
-        cal.setTime(bdate);
-        long time2 = cal.getTimeInMillis();
-        long between_days=(time2-time1)/(1000*3600*24);
-
-        return Integer.parseInt(String.valueOf(between_days))-1;
-    }
-
-
-
-    private static List<DayStudyVo> getDays(long time_start, long time_end) {
-        try {
-            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-            Date c_start = dateFormat.parse(dateFormat.format(new Date(time_start * 1000).getTime()));
-            Date c_end = dateFormat.parse(dateFormat.format(new Date(time_end * 1000).getTime()));
-            Calendar tempStart = Calendar.getInstance();
-            tempStart.setTime(c_start);
-            Calendar tempEnd = Calendar.getInstance();
-            tempEnd.setTime(c_end);
-            tempEnd.add(Calendar.DATE, +1);
-            List<DayStudyVo> dayStudyVos = new ArrayList<>();
-            while (tempStart.before(tempEnd)) {
-                String format = dateFormat.format(tempStart.getTime());
-                String strh = format.substring(format.length() -2,format.length());
-                int week = tempStart.get(Calendar.DAY_OF_WEEK)- 1;
-                DayStudyVo dayStudyVo = new DayStudyVo();
-                dayStudyVo.setStudyDay(Convert.toLong(week));
-                dayStudyVo.setDate(Convert.toLong(strh));
-                dayStudyVos.add(dayStudyVo);
-                tempStart.add(Calendar.DAY_OF_YEAR, 1);
-            }
-            return dayStudyVos;
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-
-    /**
-     * 获取当前月第一天
-     * @param month
-     * @return
-     */
-    public static Long getFirstDayOfMonth(int month) {
-        Calendar calendar = Calendar.getInstance();
-        // 设置月份
-        calendar.set(Calendar.MONTH, month - 1);
-        // 获取某月最小天数
-        int firstDay = calendar.getActualMinimum(Calendar.DAY_OF_MONTH);
-        // 设置日历中月份的最小天数
-        calendar.set(Calendar.DAY_OF_MONTH, firstDay);
-
-        Date time = calendar.getTime();
-        return time.getTime() / 1000;
-    }
-
-    public static Long getLastDayOfMonth(int month) {
-        Calendar calendar = Calendar.getInstance();
-        // 设置月份
-        calendar.set(Calendar.MONTH, month - 1);
-        // 获取某月最大天数
-        int lastDay=0;
-        //2月的平年瑞年天数
-        if(month==2) {
-            lastDay = calendar.getLeastMaximum(Calendar.DAY_OF_MONTH);
-        }else {
-            lastDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
-        }
-        // 设置日历中月份的最大天数
-        calendar.set(Calendar.DAY_OF_MONTH, lastDay);
-        Date time = calendar.getTime();
-        return time.getTime() / 1000;
-    }
-
-
-
-    private static int getDutyDays(Date  startDateStr, Date endDateStr,Long[] longs,Long studyDay) throws ParseException {
-        int result = 0;
-        Date endDate = endDateStr;
-        Calendar c = Calendar.getInstance();
-        c.setTime(endDate);
-        c.add(Calendar.DATE, - Convert.toInt(studyDay));
-        endDate = c.getTime();
-
-        Date startDate = startDateStr;
-
-        while (startDate.compareTo(endDate) <= 0) {
-            for (Long integer : longs) {
-                if (startDate.getDay() != integer) {
-                    result++;
-                    break;
-                }
-            }
-            startDate.setDate(startDate.getDate() + 1);
-        }
-        return result-1;
-    }
-
-    //获得今天时间的0点
-    public static int getTimesmorning(){
-        Calendar cal = Calendar.getInstance();
-
-        cal.set(Calendar.HOUR_OF_DAY, 0);
-
-        cal.set(Calendar.SECOND, 0);
-
-        cal.set(Calendar.MINUTE, 0);
-
-        cal.set(Calendar.MILLISECOND, 0);
-
-        return (int) (cal.getTimeInMillis()/1000);
-
-    }
-
-    //获得当天24点时间
-    public static int getTimesnight(){
-        Calendar cal = Calendar.getInstance();
-
-        cal.set(Calendar.HOUR_OF_DAY, 24);
-
-        cal.set(Calendar.SECOND, 0);
-
-        cal.set(Calendar.MINUTE, 0);
-
-        cal.set(Calendar.MILLISECOND, 0);
-
-        return (int) (cal.getTimeInMillis()/1000);
-
-    }
-
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/CalendarStudyVo.java

@@ -26,7 +26,7 @@ public class CalendarStudyVo {
     private Long year;
 
     /** 月份天 */
-    @ApiModelProperty("月天")
+    @ApiModelProperty("月天数计划")
     private List<DayStudyVo> dayStudyList;
 
 }

+ 3 - 1
zhongzheng-system/src/main/resources/mapper/modules/user/UserPlanCourceMapper.xml

@@ -7,7 +7,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <resultMap type="com.zhongzheng.modules.user.domain.UserPlanCource" id="UserPlanCourceResult">
         <result property="planId" column="plan_id"/>
         <result property="sourceId" column="source_id"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
     </resultMap>
 
 
-</mapper>
+</mapper>

+ 3 - 190
zhongzheng-system/src/main/resources/mapper/modules/user/UserPlanMapper.xml

@@ -5,8 +5,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 <mapper namespace="com.zhongzheng.modules.user.mapper.UserPlanMapper">
 
     <resultMap type="com.zhongzheng.modules.user.domain.UserPlan" id="UserPlanResult">
-        <result property="userId" column="user_id"/>
+        <result property="planId" column="plan_id"/>
         <result property="schedule" column="schedule"/>
+        <result property="userId" column="user_id"/>
         <result property="examDate" column="exam_date"/>
         <result property="reminderTime" column="reminder_time"/>
         <result property="studyCount" column="study_count"/>
@@ -18,195 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="status" column="status"/>
         <result property="pitchNum" column="pitch_num"/>
         <result property="studyNum" column="study_num"/>
-        <result property="planId" column="plan_id"/>
-    </resultMap>
-
-    <resultMap type="com.zhongzheng.modules.user.vo.CoursePlanVo" id="CourseResult">
-        <result property="courseId" column="course_id"/>
-        <result property="categoryId" column="category_id"/>
-        <result property="price" column="price"/>
-        <result property="duration" column="duration"/>
-        <result property="startTime" column="start_time"/>
-        <result property="endTime" column="end_time"/>
-        <result property="coverUrl" column="cover_url"/>
-        <result property="introduction" column="introduction"/>
-        <result property="status" column="status"/>
-        <result property="teacherIds" column="teacher_ids"/>
-        <result property="courseName" column="course_name"/>
-        <result property="chapterNum" column="chapter_num"/>
-        <result property="sectionNum" column="section_num"/>
-        <result property="categoryName" column="category_name"/>
-    </resultMap>
-
-
-    <resultMap type="com.zhongzheng.modules.exam.vo.ExamArrangementTimeVo" id="ExamArrangementTimeResult">
-        <result property="arrangementId" column="arrangement_id"/>
-        <result property="startTime" column="start_time"/>
-        <result property="endTime" column="end_time"/>
     </resultMap>
 
-    <select id="selectByCourse" parameterType="com.zhongzheng.modules.user.bo.UserPlanQueryBo"  resultMap="CourseResult">
-        SELECT
-        rs.course_id,
-        rs.category_id,
-        rs.price,
-        rs.duration,
-        rs.start_time,
-        rs.end_time,
-        rs.cover_url,
-        rs.introduction,
-        rs.create_time,
-        rs.update_time,
-        rs.STATUS,
-        rs.teacher_ids,
-        rs.course_name,
-        sum( rs.section_num ) AS section_num,
-        count( rs.chapter_id ) AS chapter_num,
-        mc.category_name,
-        mc.category_id,
-        sum( rs.total_time ) AS duration
-        FROM
-        (
-        SELECT
-        c.*,
-        count( cs.section_id ) AS section_num,
-        cs.chapter_id,
-        IFNULL( sum( cs.video_time ), 0 ) AS total_time
-        FROM
-        course c
-        LEFT JOIN course_chapter cc ON c.course_id = cc.course_id
-        LEFT JOIN course_section cs ON cc.chapter_id = cs.chapter_id
-        WHERE
-        1 = 1
-        <if test="courseId != null and courseId !=''">
-            and c.course_id in
-            <foreach collection="courseId" open="(" separator="," close=")" item="courseId">
-                #{courseId}
-            </foreach>
-        </if>
-        GROUP BY
-        cs.chapter_id,
-        c.course_id
-        ) rs
-        LEFT JOIN major_category mc ON rs.category_id = mc.category_id
-        GROUP BY
-        course_id
-        LIMIT 1
-    </select>
-
-    <select id="selectByExam" parameterType="Long"  resultMap="ExamArrangementTimeResult">
-        SELECT
-            e.*
-        FROM
-            exam_arrangement s
-                LEFT JOIN exam_arrangement_time e ON e.arrangement_id = s.id
-        WHERE 1=1
-          AND s.status != 0 AND
-        <if test="categoryId != null and categoryId !='' ">
-          s.exam_type_id = #{categoryId}
-        </if>
-        ORDER BY e.start_time LIMIT 1
-    </select>
-
-
-    <select id="selectByListCourse" parameterType="com.zhongzheng.modules.user.bo.UserPlanQueryBo"  resultMap="CourseResult">
-        SELECT
-        rs.course_id,
-        rs.price,
-        rs.start_time,
-        rs.end_time,
-        rs.cover_url,
-        rs.create_time,
-        rs.update_time,
-        rs.STATUS,
-        rs.teacher_ids,
-        rs.course_name,
-        sum( section_num ) AS section_num,
-        count( chapter_id ) AS chapter_num,
-        mc.category_name,
-        mc.category_id,
-        sum( total_time ) AS duration
-        FROM
-        (
-        SELECT
-        c.*,
-        count( cs.section_id ) AS section_num,
-        cs.chapter_id,
-        IFNULL( sum( cs.video_time ), 0 ) AS total_time
-        FROM
-        course c
-        LEFT JOIN course_chapter cc ON c.course_id = cc.course_id
-        LEFT JOIN course_section cs ON cc.chapter_id = cs.chapter_id
-        WHERE
-        1 = 1
-        <if test="courseId != null and courseId !=''">
-            and c.course_id in
-            <foreach collection="courseId" open="(" separator="," close=")" item="courseId">
-                #{courseId}
-            </foreach>
-        </if>
-        GROUP BY cs.chapter_id,c.course_id)rs LEFT JOIN major_category mc on rs.category_id = mc.category_id
-        GROUP BY course_id
-    </select>
-
-    <select id="selectByUserPlan" parameterType="com.zhongzheng.modules.user.bo.UserPlanQueryBo"  resultMap="UserPlanResult">
-        SELECT * FROM user_plan where 1=1 AND `status` =1
-                                  AND user_id = #{userId}
-        <if test="planId != null and planId !=''">
-            and plan_id = #{planId}
-        </if>
-        order by exam_date
-    </select>
-
-    <insert id="insertSource" parameterType="map" useGeneratedKeys="true">
-        insert into user_plan_cource (
-        plan_id,
-        source_id
-        )values
-
-            (#{planId},
-            #{courseId})
-
-    </insert>
-    <resultMap type="com.zhongzheng.modules.user.domain.UserPlanCource" id="UserPlanCourceResult">
-        <result property="planId" column="plan_id"/>
-        <result property="sourceId" column="source_id"/>
-    </resultMap>
-    <select id="selectCourse" parameterType="Long"  resultMap="UserPlanCourceResult">
-        SELECT * FROM user_plan_cource where 1=1 AND plan_id=#{planId}
-    </select>
-
-
-    <select id="selectCountCourse" parameterType="com.zhongzheng.modules.user.bo.UserPlanQueryBo"  resultType="int">
-        SELECT
-            COUNT(c.source_id)
-        FROM user_plan_cource c
-        LEFT JOIN user_plan u ON u.plan_id = c.plan_id
-        WHERE 1=1 and u.status=1
-        <if test="courseId != null and courseId !=''">
-            and c.source_id in
-            <foreach collection="courseId" open="(" separator="," close=")" item="courseId">
-                #{courseId}
-            </foreach>
-        </if>
-        <if test="userId != null and userId !=''">
-            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>
+</mapper>