浏览代码

资料审核

change 3 年之前
父节点
当前提交
632e293dbb

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

@@ -69,10 +69,22 @@ public class UserPlanController extends BaseController {
      * 获取学习计划详细信息
      */
     @ApiOperation("获取学习计划详细信息")
-    @GetMapping("/{planId}")
-    public AjaxResult<UserPlanVo> getInfo(@PathVariable("planId" ) Long planId) {
+    @GetMapping("/inFo")
+    public AjaxResult<UserPlanVo> getInfo(UserPlanQueryBo bo) {
         ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
-        return AjaxResult.success(iUserPlanService.queryById(planId,loginUser.getUser().getUserId()));
+        bo.setUserId(loginUser.getUser().getUserId());
+        return AjaxResult.success(iUserPlanService.queryById(bo));
+    }
+
+    /**
+     * 获得七天活动计划
+     */
+    @ApiOperation("获得七天活动计划")
+    @GetMapping("/userPlanSeven")
+    public AjaxResult<UserPlanVo> userPlanSeven(UserPlanQueryBo bo) throws ParseException {
+        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
+        bo.setUserId(loginUser.getUser().getUserId());
+        return AjaxResult.success(iUserPlanService.userPlanSeven(bo));
     }
 
     /**

+ 8 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserPlanQueryBo.java

@@ -42,6 +42,14 @@ public class UserPlanQueryBo extends BaseEntity {
 	/** 计划json格式 */
 	@ApiModelProperty("计划json格式")
 	private String schedule;
+
+	/** 计划ID */
+	@ApiModelProperty("计划ID")
+	private Long planId;
+
+	/** 月份 */
+	@ApiModelProperty("月份")
+	private Long month;
 	/** 用户id */
 	@ApiModelProperty("用户id")
 	private Long userId;

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

@@ -24,7 +24,7 @@ public interface IUserPlanService extends IService<UserPlan> {
 	 * 查询单个
 	 * @return
 	 */
-	UserPlanVo queryById(Long planId,Long UserId);
+	UserPlanVo queryById(UserPlanQueryBo bo);
 
 	/**
 	 * 查询列表
@@ -56,4 +56,6 @@ public interface IUserPlanService extends IService<UserPlan> {
     UserPlanVo listPlan(UserPlanEditBo bo) throws ParseException;
 
 	List<GoodsVo> listGoods(UserPlanQueryBo bo);
+
+	UserPlanVo userPlanSeven(UserPlanQueryBo bo) throws ParseException;
 }

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

@@ -53,8 +53,8 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
 
 
     @Override
-    public UserPlanVo queryById(Long planId,Long UserId){
-        UserPlan userPlan = this.baseMapper.selectById(planId);
+    public UserPlanVo queryById(UserPlanQueryBo bo){
+        UserPlan userPlan = this.baseMapper.selectById(bo.getPlanId());
         //得到日历日期
         UserPlanVo userPlanVo = new UserPlanVo();
         userPlanVo.setUserId(userPlan.getUserId());
@@ -66,7 +66,7 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
         userPlanVo.setPitchNum(userPlan.getPitchNum());
         userPlanVo.setStudyNum(userPlan.getStudyNum());
         userPlanVo.setPlanId(userPlan.getPlanId());
-        List<GoodsUserVo> goodsVos = userPlanGoodsService.selectGoods(planId,UserId);
+        List<GoodsUserVo> goodsVos = userPlanGoodsService.selectGoods(bo.getPlanId(),bo.getUserId());
         userPlanVo.setGoodsVos(goodsVos);
         // List转成数组
         Long[] array = new Long[goodsVos.size()];
@@ -79,6 +79,10 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
         userPlanVo.setGoodsId(array);
         //得到日历日期
         List<CalendarStudyVo> calendarStudyVos = JSONObject.parseArray(userPlan.getSchedule(), CalendarStudyVo.class);
+        if (bo.getMonth() != null){
+            calendarStudyVos=calendarStudyVos.stream().filter(CalendarStudyVo -> CalendarStudyVo.getMonth().equals(bo.getMonth())).collect(Collectors.toList());
+        }
+
         //得到学习的周
         List<Long> cont = JSONObject.parseArray(userPlan.getStudyCount(), Long.class);
         Long[] strings = new Long[cont.size()];
@@ -621,6 +625,70 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
         return baseMapper.listGoods(bo);
     }
 
+    @Override
+    public UserPlanVo userPlanSeven(UserPlanQueryBo bo) throws ParseException {
+        UserPlan userPlan = this.baseMapper.selectById(bo.getPlanId());
+        //得到日历日期
+        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<GoodsUserVo> goodsVos = userPlanGoodsService.selectGoods(bo.getPlanId(),bo.getUserId());
+        userPlanVo.setGoodsVos(goodsVos);
+        // List转成数组
+        Long[] array = new Long[goodsVos.size()];
+        // 输出数组
+        List<Long> arrys = new ArrayList<>();
+        for (GoodsUserVo goodsVo : goodsVos) {
+            arrys.add(goodsVo.getGoodsId());
+        }
+        arrys.toArray(array);
+        userPlanVo.setGoodsId(array);
+        //得到日历日期
+        List<CalendarStudyVo> calendarStudyVos = JSONObject.parseArray(userPlan.getSchedule(), CalendarStudyVo.class);
+
+        Calendar cal=Calendar.getInstance();
+        cal.add(Calendar.WEEK_OF_MONTH, 0);
+        cal.set(Calendar.DAY_OF_WEEK, 2);
+        Long timeInMillisStart = cal.getTimeInMillis()/1000-86400;
+        Calendar cal2=Calendar.getInstance();
+        cal2.set(Calendar.DAY_OF_WEEK, cal.getActualMaximum(Calendar.DAY_OF_WEEK));
+        cal2.add(Calendar.DAY_OF_WEEK, 1);
+        Long timeInMillis = cal2.getTimeInMillis()/1000;
+        List<CalendarStudyVo> sevenDates = findSevenDates(timeInMillisStart, timeInMillis);
+        for (CalendarStudyVo sevenDate : sevenDates) {
+            for (DayStudyVo dayStudyVo : sevenDate.getDayStudyList()) {
+                List<CalendarStudyVo> collect = calendarStudyVos.stream().filter(CalendarStudyVo -> CalendarStudyVo.getMonth().equals(sevenDate.getMonth())).collect(Collectors.toList());
+                if (!CollectionUtils.isEmpty(collect)) {
+                    for (CalendarStudyVo calendarStudyVo : collect) {
+                        for (DayStudyVo studyVo : calendarStudyVo.getDayStudyList()) {
+                            if (studyVo.getDate().equals(dayStudyVo.getDate())){
+                                dayStudyVo.setStudyCourseKnob(studyVo.getStudyCourseKnob());
+                                dayStudyVo.setPerform(studyVo.getPerform());
+                                dayStudyVo.setDaySectionList(studyVo.getDaySectionList());
+                                break;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        //得到学习的周
+        List<Long> cont = JSONObject.parseArray(userPlan.getStudyCount(), Long.class);
+        Long[] strings = new Long[cont.size()];
+        cont.toArray(strings);
+
+        userPlanVo.setCalendarStudyVo(sevenDates);
+        userPlanVo.setStudyCount(strings);
+        return userPlanVo;
+    }
+
 
     /**
      * 保存前的数据校验
@@ -634,4 +702,53 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
             throw new IllegalArgumentException("此网课学习计划正在进行中,若想再次制定请将计划完成或删除");
         }
     }
+
+    //获得日历
+    public static List<CalendarStudyVo> findSevenDates(Long dBegin, Long dEnd) throws ParseException, java.text.ParseException {
+        Long timeStamp = System.currentTimeMillis();  //获取当前时间戳
+        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
+        String dBeginS = sdf.format(new Date(Long.parseLong(String.valueOf(dBegin*1000))));      // 时间戳转换成时间
+        String dEndS = sdf.format(new Date(Long.parseLong(String.valueOf(dEnd*1000))));      // 时间戳转换成时间
+
+        //日期工具类准备
+        DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+
+        //设置开始时间
+        Calendar calBegin = Calendar.getInstance();
+        calBegin.setTime(format.parse(dBeginS));
+
+        //设置结束时间
+        Calendar calEnd = Calendar.getInstance();
+        calEnd.setTime(format.parse(dEndS));
+
+        //装返回的日期集合容器
+        List<CalendarStudyVo> Datelist = new ArrayList<CalendarStudyVo>();
+
+        CalendarStudyVo calendarStudyVo = new CalendarStudyVo();
+        List<DayStudyVo> dayStudyList = new ArrayList<>();
+        // 每次循环给calBegin日期加一天,直到calBegin.getTime()时间等于dEnd
+        while (format.parse(dEndS).after(calBegin.getTime()))  {
+            if (calendarStudyVo.getMonth() == null){
+                calendarStudyVo.setMonth(Convert.toLong(calBegin.get(java.util.Calendar.MONTH)+1));
+                calendarStudyVo.setYear(Convert.toLong(calBegin.get(java.util.Calendar.YEAR)));
+            }
+            if (calendarStudyVo.getMonth() != null && calendarStudyVo.getMonth() != (calBegin.get(java.util.Calendar.MONTH)+1)){
+                calendarStudyVo.setDayStudyList(dayStudyList);
+                Datelist.add(calendarStudyVo);
+                calendarStudyVo = new CalendarStudyVo();
+                dayStudyList = new ArrayList<>();
+                calendarStudyVo.setMonth(Convert.toLong(calBegin.get(java.util.Calendar.MONTH)+1));
+                calendarStudyVo.setYear(Convert.toLong(calBegin.get(java.util.Calendar.YEAR)));
+            }
+            DayStudyVo dayStudyVo = new DayStudyVo();
+            dayStudyVo.setDate(Convert.toLong(calBegin.get(Calendar.DATE)));
+            dayStudyVo.setStudyDay(Convert.toLong(calBegin.get(Calendar.DAY_OF_WEEK)-1));
+            dayStudyList.add(dayStudyVo);
+            // 根据日历的规则,为给定的日历字段添加或减去指定的时间量
+            calBegin.add(Calendar.DAY_OF_MONTH, 1);
+        }
+        calendarStudyVo.setDayStudyList(dayStudyList);
+        Datelist.add(calendarStudyVo);
+        return Datelist;
+    }
 }