Browse Source

搜索条件新增

change 3 năm trước cách đây
mục cha
commit
7bcacf4651

+ 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);
 }

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

@@ -60,19 +60,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 +144,12 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
     @Autowired
     private IUserSubscribeService iUserSubscribeService;
 
+    @Autowired
+    private IUserPlanService userPlanService;
+
+    @Autowired
+    private UserPlanMapper userPlanMapper;
+
     @Value("${aliyun.sms.OpenTheGoodsCode}")
     private String OpenTheGoodsCode;
 
@@ -546,7 +547,137 @@ 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);
+            }
+        }
+    }
 
+    //获得可用学习天数
+    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>