瀏覽代碼

fix 做题历史

he2802 3 年之前
父節點
當前提交
e457d9d811

+ 12 - 1
zhongzheng-admin/src/main/java/com/zhongzheng/controller/schedule/ScheduleController.java

@@ -92,8 +92,19 @@ public class ScheduleController extends BaseController {
      */
     @ApiOperation("计划更新每晚0点更新")
     @GetMapping("/UpPlan")
-    public AjaxResult UpPlan(UserQueryBo bo) throws ParseException {
+    public AjaxResult UpPlan(UserQueryBo bo){
         iScheduleService.UpPlan(bo);
         return AjaxResult.success();
     }
+
+    /**
+     * 计划更新每晚0点更新
+     * @return
+     */
+    @ApiOperation("更新过期时间")
+    @GetMapping("/UpExam")
+    public AjaxResult UpExam(UserQueryBo bo){
+        iScheduleService.UpExam(bo);
+        return AjaxResult.success();
+    }
 }

+ 3 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/polyv/mapper/PolyvVideoMapper.java

@@ -4,6 +4,7 @@ import com.zhongzheng.modules.exam.vo.ExamUserApplyVo;
 import com.zhongzheng.modules.polyv.domain.PolyvVideo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.modules.polyv.vo.PolyvVideoVo;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -17,5 +18,6 @@ public interface PolyvVideoMapper extends BaseMapper<PolyvVideo> {
 
     PolyvVideo selectByVID(String VId);
 
-    List<ExamUserApplyVo> listUserApply();
+
+    Long selectGoodsPlanCount(@Param("goodsId") Long aLong,@Param("planId") Long planId);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/schedule/service/IScheduleService.java

@@ -34,4 +34,6 @@ public interface IScheduleService extends IService<PolyvVideo> {
     void updateIssue(UserQueryBo bo) throws ParseException;
 
     void UpPlan(UserQueryBo bo);
+
+    void UpExam(UserQueryBo bo);
 }

+ 211 - 11
zhongzheng-system/src/main/java/com/zhongzheng/modules/schedule/service/impl/ScheduleServiceImpl.java

@@ -19,7 +19,15 @@ import com.zhongzheng.common.utils.polyv.PolyvUtils;
 import com.zhongzheng.modules.base.service.IProfileTpService;
 import com.zhongzheng.modules.base.vo.ProfileTpVo;
 import com.zhongzheng.modules.base.vo.UserProfileVo;
+import com.zhongzheng.modules.exam.bo.ExamApplyQueryBo;
+import com.zhongzheng.modules.exam.bo.ExamBeforeQueryBo;
+import com.zhongzheng.modules.exam.domain.ExamApply;
+import com.zhongzheng.modules.exam.domain.ExamBefore;
 import com.zhongzheng.modules.exam.domain.ExamNumber;
+import com.zhongzheng.modules.exam.mapper.ExamApplyMapper;
+import com.zhongzheng.modules.exam.mapper.ExamBeforeMapper;
+import com.zhongzheng.modules.exam.vo.ExamApplyVo;
+import com.zhongzheng.modules.exam.vo.ExamBeforeVo;
 import com.zhongzheng.modules.exam.vo.ExamUserApplyVo;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
@@ -60,19 +68,14 @@ import com.zhongzheng.modules.polyv.vo.PolyvVideoQuerVo;
 import com.zhongzheng.modules.polyv.vo.PolyvVideoVo;
 import com.zhongzheng.modules.polyv.vo.PolyvVo;
 import com.zhongzheng.modules.schedule.service.IScheduleService;
-import com.zhongzheng.modules.user.bo.UserExamGoodsQueryBo;
-import com.zhongzheng.modules.user.bo.UserExamGoodsSupplementAddBo;
-import com.zhongzheng.modules.user.bo.UserQueryBo;
-import com.zhongzheng.modules.user.bo.UserSubscribeQueryBo;
+import com.zhongzheng.modules.user.bo.*;
 import com.zhongzheng.modules.user.domain.UserExamGoods;
+import com.zhongzheng.modules.user.domain.UserPlan;
+import com.zhongzheng.modules.user.domain.UserPlanGoods;
 import com.zhongzheng.modules.user.domain.UserSubscribe;
-import com.zhongzheng.modules.user.service.IUserExamGoodsService;
-import com.zhongzheng.modules.user.service.IUserExamGoodsSupplementService;
-import com.zhongzheng.modules.user.service.IUserService;
-import com.zhongzheng.modules.user.service.IUserSubscribeService;
-import com.zhongzheng.modules.user.vo.UserExamGoodsVo;
-import com.zhongzheng.modules.user.vo.UserSubscribeVo;
-import com.zhongzheng.modules.user.vo.UserVo;
+import com.zhongzheng.modules.user.mapper.UserPlanMapper;
+import com.zhongzheng.modules.user.service.*;
+import com.zhongzheng.modules.user.vo.*;
 import com.zhongzheng.modules.wx.service.IWxPayService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -149,6 +152,18 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
     @Autowired
     private IUserSubscribeService iUserSubscribeService;
 
+    @Autowired
+    private IUserPlanService userPlanService;
+
+    @Autowired
+    private UserPlanMapper userPlanMapper;
+
+    @Autowired
+    private ExamApplyMapper examApplyMapper;
+
+    @Autowired
+    private ExamBeforeMapper examBeforeMapper;
+
     @Value("${aliyun.sms.OpenTheGoodsCode}")
     private String OpenTheGoodsCode;
 
@@ -546,7 +561,192 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
 
     @Override
     public void UpPlan(UserQueryBo bo) {
+        UserPlanQueryBo userPlanQueryBo = new UserPlanQueryBo();
+        userPlanQueryBo.setStatus(new ArrayList<Integer>(Arrays.asList(1)));
+        List<UserPlanVo> userPlanVos = userPlanService.queryList(userPlanQueryBo);
+        Calendar rightNow = Calendar.getInstance();
+        boolean status = false;
+        for (UserPlanVo userPlanVo : userPlanVos) {
+            List<CalendarStudyVo> calendarStudyUp = userPlanVo.getCalendarStudyVo();
+            for (CalendarStudyVo studyVo : calendarStudyUp) {
+                if (studyVo.getMonth().equals(Convert.toLong(rightNow.get(Calendar.MONTH) + 1)) && studyVo.getYear().equals(Convert.toLong(rightNow.get(Calendar.YEAR)))) {
+                    for (DayStudyVo dayStudyVo : studyVo.getDayStudyList()) {
+                        if (dayStudyVo.getDate().equals(Convert.toLong(rightNow.get(Calendar.DAY_OF_MONTH)))) {
+                            if (dayStudyVo.getPerform() != null && dayStudyVo.getPerform().equals(2)) {
+                                dayStudyVo.setPerform(0);
+                                status = true;
+                                for (DaySectionVo daySectionVo : dayStudyVo.getDaySectionList()) {
+                                    daySectionVo.setGoodsPerform(0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            if (status) {
+                UserPlan userPlan = new UserPlan();
+                List<CalendarStudyVo> clCalendarStudyVos = userPlanVo.getCalendarStudyVo();
+                Long secAll = 0L;
+                Long sumUp = 0L;
+                for (CalendarStudyVo clCalendarStudyVo : clCalendarStudyVos) {
+                    for (DayStudyVo dayStudyVo : clCalendarStudyVo.getDayStudyList()) {
+                        Calendar c5 = Calendar.getInstance();
+                        if ((clCalendarStudyVo.getMonth() <= (c5.get(Calendar.MONTH) + 1) && dayStudyVo.getDate() > c5.get(Calendar.DAY_OF_MONTH)) && (clCalendarStudyVo.getMonth() <= (c5.get(Calendar.MONTH) + 1) || clCalendarStudyVo.getYear() <= (c5.get(Calendar.YEAR)))) {
+                            dayStudyVo.setStudyCourseKnob(null);
+                            dayStudyVo.setDaySectionList(null);
+                        }
+                    }
+                }
+                for (Long aLong : userPlanVo.getGoodsId()) {
+                    //最近考试时间七天前到现在的天数,学习视频时长
+                    Date date1 = new Date(userPlanVo.getEndTime() * 1000L);
+                    //获得相隔天数
+                    int dutyDays = getDutyDays(new Date(), date1, userPlanVo.getStudyCount(), userPlanVo.getStudyDay());
+                    if (dutyDays < 1) {
+                        return;
+                    }
+                    List<Long> seLongs = userPlanMapper.selectGoods(aLong);
+                    Long allNum = 0L;
+                    for (Long seLong : seLongs) {
+                        allNum += seLong;
+                    }
+                    Long reduce = baseMapper.selectGoodsPlanCount(aLong,userPlanVo.getPlanId());
+                    sumUp = allNum-reduce;
+                    //计算每天需要学习多少节课
+                    int Sec = (int) Math.ceil((double) allNum / dutyDays);
+                    secAll += Sec;
+                    for (CalendarStudyVo clCalendarStudyVo : clCalendarStudyVos) {
+                        for (DayStudyVo dayStudyVo : clCalendarStudyVo.getDayStudyList()) {
+                            if (Arrays.asList(userPlanVo.getStudyCount()).contains(dayStudyVo.getStudyDay())) {
+                                if (allNum < 0) {
+                                    break;
+                                }
+                                Calendar c5 = Calendar.getInstance();
+                                if (dayStudyVo.getDate() <= c5.get(Calendar.DAY_OF_MONTH) && clCalendarStudyVo.getMonth() == (c5.get(Calendar.MONTH) + 1) && clCalendarStudyVo.getYear() == (c5.get(Calendar.YEAR))) {
+                                    continue;
+                                }
+
+                                if (dayStudyVo.getStudyCourseKnob() != null) {
+                                    if (allNum < Sec) {
+                                        dayStudyVo.setStudyCourseKnob(dayStudyVo.getStudyCourseKnob() + allNum);
+                                    } else {
+                                        dayStudyVo.setStudyCourseKnob(dayStudyVo.getStudyCourseKnob() + Sec);
+                                    }
+                                } else {
+                                    if (allNum < Sec) {
+                                        dayStudyVo.setStudyCourseKnob(allNum);
+                                    } else {
+                                        dayStudyVo.setStudyCourseKnob(Convert.toLong(Sec));
+                                    }
+                                }
+
+                                dayStudyVo.setPerform(0);
+                                List<DaySectionVo> daySectionList = new ArrayList<>();
+                                if (!com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isEmpty(dayStudyVo.getDaySectionList())) {
+                                    daySectionList = dayStudyVo.getDaySectionList();
+                                }
+                                DaySectionVo daySectionVo = new DaySectionVo();
+                                daySectionVo.setGoodsId(aLong);
+                                if (allNum < Sec) {
+                                    daySectionVo.setStudyGoodsKnob(Convert.toLong(allNum));
+                                } else {
+                                    daySectionVo.setStudyGoodsKnob(Convert.toLong(Sec));
+                                }
+
+                                daySectionVo.setGoodsPerform(0);
+                                daySectionList.add(daySectionVo);
+                                dayStudyVo.setDaySectionList(daySectionList);
+                                allNum -= Sec;
+
+                            }
+                        }
+                    }
+                }
+                String s = JSON.toJSONString(clCalendarStudyVos);
+                userPlan.setSchedule(s);
+                userPlan.setPlanId(userPlanVo.getPlanId());
+                userPlan.setUpdateTime(DateUtils.getNowTime());
+                userPlanMapper.updateById(userPlan);
+            }
+        }
+    }
 
+    @Override
+    public void UpExam(UserQueryBo bo) {
+        ExamApplyQueryBo examApplyQueryBo = new ExamApplyQueryBo();
+        examApplyQueryBo.setStatus(new ArrayList<Integer>(Arrays.asList(1)));
+        List<ExamApplyVo> examApplyVos = examApplyMapper.queryExam(examApplyQueryBo);
+        for (ExamApplyVo examApplyVo : examApplyVos) {
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
+            calendar.setTimeInMillis(System.currentTimeMillis());
+            if ((examApplyVo.getApplyEndTime()) < calendar.getTimeInMillis()/1000){
+                ExamApply update = new ExamApply();
+                update.setApplyId(examApplyVo.getApplyId());
+                update.setStatus(2);
+                update.setUpdateTime(DateUtils.getNowTime());
+                examApplyMapper.updateById(update);
+            }
+        }
+        ExamBeforeQueryBo examBeforeQueryBo = new ExamBeforeQueryBo();
+        examBeforeQueryBo.setStatus(new ArrayList<Integer>(Arrays.asList(1)));
+        List<ExamBeforeVo> examBeforeVos = examBeforeMapper.queryBefore(examBeforeQueryBo);
+        for (ExamBeforeVo examBeforeVo : examBeforeVos) {
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
+            calendar.setTimeInMillis(System.currentTimeMillis());
+            if ((examBeforeVo.getBeforeEndTime()) < calendar.getTimeInMillis()/1000){
+                ExamBefore update = new ExamBefore();
+                update.setBeforeId(examBeforeVo.getBeforeId());
+                update.setStatus(2);
+                update.setUpdateTime(DateUtils.getNowTime());
+                examBeforeMapper.updateById(update);
+            }
+        }
+
+        UserPlanQueryBo userPlanQueryBo = new UserPlanQueryBo();
+        userPlanQueryBo.setStatus(new ArrayList<Integer>(Arrays.asList(1)));
+        List<UserPlanVo> userPlanVos = userPlanService.queryList(userPlanQueryBo);
+        for (UserPlanVo userPlanVo : userPlanVos) {
+            UserPlan userPlan = new UserPlan();
+            userPlan.setPlanId(userPlanVo.getPlanId());
+            userPlan.setUpdateTime(DateUtils.getNowTime());
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
+            calendar.setTimeInMillis(System.currentTimeMillis());
+            if ((userPlanVo.getEndTime()) < calendar.getTimeInMillis()/1000 && userPlanVo.getStatus().equals(1)){
+                if (userPlanVo.getPitchNum().equals(userPlanVo.getStudyNum())){
+                    userPlan.setStatus(2);
+                }else {
+                    userPlan.setStatus(3);
+                }
+                userPlanMapper.updateById(userPlan);
+            }
+
+        }
+    }
+
+    //获得可用学习天数
+    private static int getDutyDays(Date  startDateStr, Date endDateStr,Long[] longs,Long studyDay)  {
+        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;
+        int day = startDate.getDay();
+        while (startDate.compareTo(endDate) <= 0) {
+            for (Long integer : longs) {
+                if (startDate.getDay() == integer) {
+                    result++;
+                    break;
+                }
+            }
+            startDate.setDate(startDate.getDate() + 1);
+        }
+        return result-1;
     }
 
     private void updateApply() throws ParseException {

+ 0 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserPlanServiceImpl.java

@@ -502,7 +502,6 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
                             break;
                         }
                         Calendar c5 = Calendar.getInstance();
-                        c.setTime(new Date(bo.getStartTime()));
                         if (dayStudyVo.getDate() <= c5.get(Calendar.DAY_OF_MONTH) && clCalendarStudyVo.getMonth() == (c5.get(Calendar.MONTH) + 1) && clCalendarStudyVo.getYear() == (c5.get(Calendar.YEAR))){
                             continue;
                         }

+ 10 - 0
zhongzheng-system/src/main/resources/mapper/modules/polyv/PolyvVideoMapper.xml

@@ -58,4 +58,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             AND vid = #{Vid}
         </if>
     </select>
+
+    <select id="selectGoodsPlanCount" parameterType="map"  resultType="long">
+        SELECT
+            COUNT( 1 )
+        FROM
+            user_study_record usr
+        WHERE
+            usr.plan_id = #{planId}
+          and usr.goods_id = #{goodsId}
+    </select>
 </mapper>