change 3 éve
szülő
commit
7a9c10fdf8

+ 5 - 3
zhongzheng-api/src/main/java/com/zhongzheng/controller/plan/UserPlanController.java

@@ -78,7 +78,9 @@ public class UserPlanController extends BaseController {
     @ApiOperation("新增学习计划")
     @ApiOperation("新增学习计划")
     @Log(title = "学习计划", businessType = BusinessType.INSERT)
     @Log(title = "学习计划", businessType = BusinessType.INSERT)
     @PostMapping()
     @PostMapping()
-    public AjaxResult<Void> add(@RequestBody UserPlanAddBo bo) {
+    public AjaxResult<Void> add(@RequestBody UserPlanAddBo bo) throws ParseException {
+        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
+        bo.setUserId(loginUser.getUser().getUserId());
         return toAjax(iUserPlanService.insertByAddBo(bo) ? 1 : 0);
         return toAjax(iUserPlanService.insertByAddBo(bo) ? 1 : 0);
     }
     }
 
 
@@ -87,8 +89,8 @@ public class UserPlanController extends BaseController {
      */
      */
     @ApiOperation("修改学习计划")
     @ApiOperation("修改学习计划")
     @Log(title = "学习计划", businessType = BusinessType.UPDATE)
     @Log(title = "学习计划", businessType = BusinessType.UPDATE)
-    @PutMapping()
-    public AjaxResult<Void> edit(@RequestBody UserPlanEditBo bo) {
+    @PostMapping("edit")
+    public AjaxResult<Void> edit(@RequestBody UserPlanEditBo bo) throws ParseException {
         return toAjax(iUserPlanService.updateByEditBo(bo) ? 1 : 0);
         return toAjax(iUserPlanService.updateByEditBo(bo) ? 1 : 0);
     }
     }
 
 

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserPlanAddBo.java

@@ -57,4 +57,8 @@ public class UserPlanAddBo {
     /** 已学习节数 */
     /** 已学习节数 */
     @ApiModelProperty("已学习节数")
     @ApiModelProperty("已学习节数")
     private Long studyNum;
     private Long studyNum;
+
+    /** 生成计划的课程 */
+    @ApiModelProperty("生成计划的课程")
+    private Long[] goodsId;
 }
 }

+ 2 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserPlanQueryBo.java

@@ -6,6 +6,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.EqualsAndHashCode;
 
 
 import java.util.Date;
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.HashMap;
 
 
@@ -64,7 +65,7 @@ public class UserPlanQueryBo extends BaseEntity {
 	private Long startTime;
 	private Long startTime;
 	/** 0 失效 1启用 */
 	/** 0 失效 1启用 */
 	@ApiModelProperty("0 失效 1启用")
 	@ApiModelProperty("0 失效 1启用")
-	private Integer status;
+	private List<Integer> status;
 	/** 总结数 */
 	/** 总结数 */
 	@ApiModelProperty("总结数")
 	@ApiModelProperty("总结数")
 	private Long pitchNum;
 	private Long pitchNum;

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

@@ -36,14 +36,14 @@ public interface IUserPlanService extends IService<UserPlan> {
 	 * @param bo 学习计划新增业务对象
 	 * @param bo 学习计划新增业务对象
 	 * @return
 	 * @return
 	 */
 	 */
-	Boolean insertByAddBo(UserPlanAddBo bo);
+	Boolean insertByAddBo(UserPlanAddBo bo) throws ParseException;
 
 
 	/**
 	/**
 	 * 根据编辑业务对象修改学习计划
 	 * 根据编辑业务对象修改学习计划
 	 * @param bo 学习计划编辑业务对象
 	 * @param bo 学习计划编辑业务对象
 	 * @return
 	 * @return
 	 */
 	 */
-	Boolean updateByEditBo(UserPlanEditBo bo);
+	Boolean updateByEditBo(UserPlanEditBo bo) throws ParseException;
 
 
 	/**
 	/**
 	 * 校验并删除数据
 	 * 校验并删除数据

+ 137 - 14
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserPlanServiceImpl.java

@@ -4,6 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.lang.Validator;
 import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.modules.course.vo.CourseVo;
 import com.zhongzheng.modules.course.vo.CourseVo;
@@ -42,7 +44,11 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
     @Override
     @Override
     public UserPlanVo queryById(Long planId){
     public UserPlanVo queryById(Long planId){
         UserPlan db = this.baseMapper.selectById(planId);
         UserPlan db = this.baseMapper.selectById(planId);
-        return BeanUtil.toBean(db, UserPlanVo.class);
+        UserPlanVo userPlanVo = BeanUtil.toBean(db, UserPlanVo.class);
+        //得到日历日期
+        List<CalendarStudyVo> calendarStudyVos = JSONObject.parseArray(userPlanVo.getSchedule(), CalendarStudyVo.class);
+        userPlanVo.setCalendarStudyVo(calendarStudyVos);
+        return userPlanVo;
     }
     }
 
 
     @Override
     @Override
@@ -56,10 +62,17 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
         lqw.eq(bo.getStudyDay() != null, UserPlan::getStudyDay, bo.getStudyDay());
         lqw.eq(bo.getStudyDay() != null, UserPlan::getStudyDay, bo.getStudyDay());
         lqw.eq(bo.getEndTime() != null, UserPlan::getEndTime, bo.getEndTime());
         lqw.eq(bo.getEndTime() != null, UserPlan::getEndTime, bo.getEndTime());
         lqw.eq(bo.getStartTime() != null, UserPlan::getStartTime, bo.getStartTime());
         lqw.eq(bo.getStartTime() != null, UserPlan::getStartTime, bo.getStartTime());
-        lqw.eq(bo.getStatus() != null, UserPlan::getStatus, bo.getStatus());
+        lqw.in(bo.getStatus() != null, UserPlan::getStatus, bo.getStatus());
         lqw.eq(bo.getPitchNum() != null, UserPlan::getPitchNum, bo.getPitchNum());
         lqw.eq(bo.getPitchNum() != null, UserPlan::getPitchNum, bo.getPitchNum());
         lqw.eq(bo.getStudyNum() != null, UserPlan::getStudyNum, bo.getStudyNum());
         lqw.eq(bo.getStudyNum() != null, UserPlan::getStudyNum, bo.getStudyNum());
-        return entity2Vo(this.list(lqw));
+        List<UserPlanVo> userPlanVos = entity2Vo(this.list(lqw));
+        for (UserPlanVo userPlanVo : userPlanVos) {
+            //得到日历日期
+            List<CalendarStudyVo> calendarStudyVos = JSONObject.parseArray(userPlanVo.getSchedule(), CalendarStudyVo.class);
+            userPlanVo.setCalendarStudyVo(calendarStudyVos);
+        }
+
+        return userPlanVos;
     }
     }
 
 
     /**
     /**
@@ -83,20 +96,130 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
     }
     }
 
 
     @Override
     @Override
-    public Boolean insertByAddBo(UserPlanAddBo bo) {
-        UserPlan add = BeanUtil.toBean(bo, UserPlan.class);
-        validEntityBeforeSave(add);
-        add.setCreateTime(DateUtils.getNowTime());
-        add.setUpdateTime(DateUtils.getNowTime());
-        return this.save(add);
+    public Boolean insertByAddBo(UserPlanAddBo bo) throws ParseException {
+        UserPlan userPlan = new UserPlan();
+        List<CalendarStudyVo> clCalendarStudyVos = findDates(bo.getStartTime(),bo.getEndTime());
+        Long sumUp=0L;
+        for (Long aLong : bo.getGoodsId()) {
+            //最近考试时间七天前到现在的天数,学习视频时长
+            Date date1 = new Date(bo.getEndTime() * 1000L);
+            //获得相隔天数
+            int dutyDays = getDutyDays(new Date(), date1, bo.getStudyCount(), bo.getStudyDay());
+
+            List<Long> seLongs = baseMapper.selectGoods(aLong);
+            Long allNum = 0L;
+            for (Long seLong : seLongs) {
+                allNum += seLong;
+            }
+            sumUp += allNum;
+            //计算每天需要学习多少节课
+            int Sec = (int) Math.ceil((double) allNum / dutyDays);
+            for (CalendarStudyVo clCalendarStudyVo : clCalendarStudyVos) {
+                for (DayStudyVo dayStudyVo : clCalendarStudyVo.getDayStudyList()) {
+                    if (Arrays.asList(bo.getStudyCount()).contains(dayStudyVo.getStudyDay())){
+                        if (dayStudyVo.getStudyCourseKnob() != null) {
+                            dayStudyVo.setStudyCourseKnob(dayStudyVo.getStudyCourseKnob() + Sec);
+                        }else {
+                            dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
+                        }
+                        dayStudyVo.setPerform(0);
+                        List<DaySectionVo> daySectionList = new ArrayList<>();
+                        if (!CollectionUtils.isEmpty(dayStudyVo.getDaySectionList())) {
+                            daySectionList = dayStudyVo.getDaySectionList();
+                        }
+                        DaySectionVo daySectionVo = new DaySectionVo();
+                        daySectionVo.setGoodsId(aLong);
+                        daySectionVo.setStudyGoodsKnob(Convert.toLong(Sec));
+                        daySectionVo.setGoodsPerform(0);
+                        daySectionList.add(daySectionVo);
+                        dayStudyVo.setDaySectionList(daySectionList);
+
+                    }
+                }
+            }
+        }
+        String s = JSON.toJSONString(clCalendarStudyVos);
+        String s1 = JSON.toJSONString(bo.getStudyCount());
+        userPlan.setUserId(bo.getUserId());
+        userPlan.setSchedule(s);
+        userPlan.setStudyCount(s1);
+        userPlan.setPitchNum(sumUp);
+        userPlan.setStudyDay(bo.getStudyDay());
+        userPlan.setStudyNum(0L);
+        userPlan.setCreateTime(DateUtils.getNowTime());
+        userPlan.setUpdateTime(DateUtils.getNowTime());
+        userPlan.setExamDate(bo.getExamDate());
+        userPlan.setStatus(1);
+        userPlan.setUserId(bo.getUserId());
+        userPlan.setStartTime(bo.getStartTime());
+        userPlan.setEndTime(bo.getEndTime());
+        userPlan.setReminderTime(bo.getReminderTime());
+        this.save(userPlan);
+        return true;
     }
     }
 
 
     @Override
     @Override
-    public Boolean updateByEditBo(UserPlanEditBo bo) {
-        UserPlan update = BeanUtil.toBean(bo, UserPlan.class);
-        validEntityBeforeSave(update);
-        update.setUpdateTime(DateUtils.getNowTime());
-        return this.updateById(update);
+    public Boolean updateByEditBo(UserPlanEditBo bo) throws ParseException {
+        UserPlan userPlan = new UserPlan();
+        List<CalendarStudyVo> clCalendarStudyVos = findDates(bo.getStartTime(),bo.getEndTime());
+        Long sumUp=0L;
+        for (Long aLong : bo.getGoodsId()) {
+            //最近考试时间七天前到现在的天数,学习视频时长
+            Date date1 = new Date(bo.getEndTime() * 1000L);
+            //获得相隔天数
+            int dutyDays = getDutyDays(new Date(), date1, bo.getStudyCount(), bo.getStudyDay());
+
+            List<Long> seLongs = baseMapper.selectGoods(aLong);
+            Long allNum = 0L;
+            for (Long seLong : seLongs) {
+                allNum += seLong;
+            }
+            sumUp += allNum;
+            //计算每天需要学习多少节课
+            int Sec = (int) Math.ceil((double) allNum / dutyDays);
+            for (CalendarStudyVo clCalendarStudyVo : clCalendarStudyVos) {
+                for (DayStudyVo dayStudyVo : clCalendarStudyVo.getDayStudyList()) {
+                    if (Arrays.asList(bo.getStudyCount()).contains(dayStudyVo.getStudyDay())){
+                        if (dayStudyVo.getStudyCourseKnob() != null) {
+                            dayStudyVo.setStudyCourseKnob(dayStudyVo.getStudyCourseKnob() + Sec);
+                        }else {
+                            dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
+                        }
+                        dayStudyVo.setPerform(0);
+                        List<DaySectionVo> daySectionList = new ArrayList<>();
+                        if (!CollectionUtils.isEmpty(dayStudyVo.getDaySectionList())) {
+                            daySectionList = dayStudyVo.getDaySectionList();
+                        }
+                        DaySectionVo daySectionVo = new DaySectionVo();
+                        daySectionVo.setGoodsId(aLong);
+                        daySectionVo.setStudyGoodsKnob(Convert.toLong(Sec));
+                        daySectionVo.setGoodsPerform(0);
+                        daySectionList.add(daySectionVo);
+                        dayStudyVo.setDaySectionList(daySectionList);
+
+                    }
+                }
+            }
+        }
+        String s = JSON.toJSONString(clCalendarStudyVos);
+        String s1 = JSON.toJSONString(bo.getStudyCount());
+        userPlan.setUserId(bo.getUserId());
+        userPlan.setSchedule(s);
+        userPlan.setStudyCount(s1);
+        userPlan.setPitchNum(sumUp);
+        userPlan.setStudyDay(bo.getStudyDay());
+        userPlan.setStudyNum(0L);
+        userPlan.setCreateTime(DateUtils.getNowTime());
+        userPlan.setUpdateTime(DateUtils.getNowTime());
+        userPlan.setExamDate(bo.getExamDate());
+        userPlan.setStatus(1);
+        userPlan.setUserId(bo.getUserId());
+        userPlan.setStartTime(bo.getStartTime());
+        userPlan.setEndTime(bo.getEndTime());
+        userPlan.setReminderTime(bo.getReminderTime());
+        userPlan.setPlanId(bo.getPlanId());
+        this.updateById(userPlan);
+        return true;
     }
     }
 
 
     /**
     /**

+ 3 - 0
zhongzheng-system/src/main/resources/mapper/modules/user/UserSubscribeMapper.xml

@@ -82,6 +82,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="goodsId != null and goodsId != '' ">
         <if test="goodsId != null and goodsId != '' ">
             and us.goods_id = #{goodsId}
             and us.goods_id = #{goodsId}
         </if>
         </if>
+        <if test="result != null and result != '' ">
+            and us.result = #{result}
+        </if>
         <if test="subscribeId != null and subscribeId != '' ">
         <if test="subscribeId != null and subscribeId != '' ">
             and us.subscribe_id = #{subscribeId}
             and us.subscribe_id = #{subscribeId}
         </if>
         </if>