change %!s(int64=4) %!d(string=hai) anos
pai
achega
33b626490f

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

@@ -20,4 +20,6 @@ public interface UserPlanMapper extends BaseMapper<UserPlan> {
     List<GoodsVo> listGoods(UserPlanQueryBo bo);
 
     Integer selectCountGoods(UserPlanEditBo bo);
+
+    List<Long> selectGoods(Long goodsId);
 }

+ 40 - 5
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserPlanServiceImpl.java

@@ -20,10 +20,8 @@ import com.zhongzheng.modules.user.mapper.UserPlanMapper;
 import com.zhongzheng.modules.user.vo.UserPlanVo;
 import com.zhongzheng.modules.user.service.IUserPlanService;
 
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import java.text.ParseException;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -115,9 +113,47 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
     @Override
     public UserPlanVo listPlan(UserPlanEditBo bo) {
         validEntityPlanBeforeSave(bo);
+        UserPlanVo userPlanVo = new UserPlanVo();
+        for (Long aLong : bo.getGoodsId()) {
+            //最近考试时间七天前到现在的天数,学习视频时长
+            Date date1 = new Date(bo.getEndTime() * 1000L);
+            //获得相隔天数
+            Long[] longs = {1L, 2L, 3L, 4L, 5L, 6L};
+            int dutyDays = getDutyDays(new Date(), date1, longs, bo.getStudyDay());
+
+            List<Long> seLongs = baseMapper.selectGoods(aLong);
+            Long allNum = 0L;
+            for (Long seLong : seLongs) {
+                allNum += seLong;
+            }
+            //计算每天需要学习多少节课
+            int Sec = (int) Math.ceil((double) allNum / dutyDays);
+        }
         return null;
     }
 
+    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;
+
+        while (startDate.compareTo(endDate) <= 0) {
+            for (Long integer : longs) {
+                if (startDate.getDay() != integer) {
+                    result++;
+                    break;
+                }
+            }
+            startDate.setDate(startDate.getDate() + 1);
+        }
+        return result-1;
+    }
+
     @Override
     public List<GoodsVo> listGoods(UserPlanQueryBo bo) {
         return baseMapper.listGoods(bo);
@@ -135,6 +171,5 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
         if (rank > 0){
             throw new IllegalArgumentException("此网课学习计划正在进行中,若想再次制定请将计划完成或删除");
         }
-
     }
 }

+ 1 - 1
zhongzheng-system/src/main/resources/mapper/modules/exam/ExamApplyMapper.xml

@@ -298,7 +298,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             exam_before eb
                 LEFT JOIN exam_before_goods ebg on eb.before_id=ebg.before_id
         WHERE
-            ebg.goods_id =3
+            ebg.goods_id =#{goodsId}
           and eb.`status`=1
     </select>
 

+ 39 - 2
zhongzheng-system/src/main/resources/mapper/modules/user/UserPlanMapper.xml

@@ -97,13 +97,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         user_plan up
         LEFT JOIN user_plan_goods upg ON up.plan_id = upg.plan_id
         <if test="goodsId != null and goodsId !=''">
-            and c.source_id in
+            and upg.source_id in
             <foreach collection="goodsId" open="(" separator="," close=")" item="goodsId">
                 #{goodsId}
             </foreach>
         </if>
         <if test="userId != null and userId !=''">
-            and u.user_id = #{userId}
+            and up.user_id = #{userId}
+        </if>
+    </select>
+
+    <select id="selectGoods" parameterType="long"  resultType="Long">
+        SELECT
+            (
+                SELECT
+                        COUNT( id )+(
+                        SELECT
+                            COUNT( n.id )
+                        FROM
+                            course_chapter_section n
+                                LEFT JOIN course_module_chapter p ON n.chapter_id = p.chapter_id
+                                LEFT JOIN course_menu m ON m.menu_id = p.module_id
+                        WHERE
+                            m.course_id = r.course_id
+                          AND m.type IN ( 1 ))+(
+                            SELECT
+                                COUNT( n.id )
+                            FROM
+                                course_chapter_section n
+                                    LEFT JOIN course_menu m ON m.menu_id = n.chapter_id
+                            WHERE
+                                m.course_id = r.course_id
+                              AND m.type IN ( 2 ))
+                FROM
+                    course_menu m
+                WHERE
+                    m.course_id = r.course_id
+                  AND m.type IN ( 3 )) AS section_num
+        FROM
+            course r
+                LEFT JOIN goods_course c ON c.course_id = r.course_id
+        WHERE
+            1 = 1
+        <if test="goodsId != null">
+            and c.goods_id =#{goodsId}
         </if>
     </select>
 </mapper>