فهرست منبع

feat:三个表格上面加一项“上线率”统计

caoliqin 1 هفته پیش
والد
کامیت
1388dac6c3

+ 2 - 12
fs-admin/src/main/java/com/fs/course/controller/FsUserWatchCourseStatisticsController.java

@@ -46,12 +46,6 @@ public class FsUserWatchCourseStatisticsController extends BaseController
     {
         startPage();
         List<FsUserWatchCourseStatistics> list = fsUserWatchCourseStatisticsService.selectFsUserWatchCourseStatisticsList(fsUserWatchCourseStatistics);
-        if(!list.isEmpty()){
-            for (FsUserWatchCourseStatistics userWatchCourseStatistics : list) {
-                userWatchCourseStatistics.setCompleteWatchRatePercent(userWatchCourseStatistics.getCompleteWatchRate() + "%");
-                userWatchCourseStatistics.setAnswerRightRatePercent(userWatchCourseStatistics.getAnswerRightRate() + "%");
-            }
-        }
         return getDataTable(list);
     }
 
@@ -64,12 +58,6 @@ public class FsUserWatchCourseStatisticsController extends BaseController
     public AjaxResult export(FsUserWatchCourseStatistics fsUserWatchCourseStatistics)
     {
         List<FsUserWatchCourseStatistics> list = fsUserWatchCourseStatisticsService.selectFsUserWatchCourseStatisticsList(fsUserWatchCourseStatistics);
-        if(!list.isEmpty()){
-            for (FsUserWatchCourseStatistics userWatchCourseStatistics : list) {
-                userWatchCourseStatistics.setCompleteWatchRatePercent(userWatchCourseStatistics.getCompleteWatchRate() + "%");
-                userWatchCourseStatistics.setAnswerRightRatePercent(userWatchCourseStatistics.getAnswerRightRate() + "%");
-            }
-        }
         ExcelUtil<FsUserWatchCourseStatistics> util = new ExcelUtil<FsUserWatchCourseStatistics>(FsUserWatchCourseStatistics.class);
         return util.exportExcel(list, "会员观看数据明细");
     }
@@ -129,6 +117,7 @@ public class FsUserWatchCourseStatisticsController extends BaseController
         if(!list.isEmpty()){
             for (FsUserWatchCourseStatistics userWatchCourseStatistics : list) {
                 userWatchCourseStatistics.setCompleteWatchRatePercent(userWatchCourseStatistics.getCompleteWatchRate() + "%");
+                userWatchCourseStatistics.setOnlineRatePercent(userWatchCourseStatistics.getOnlineRate() + "%");
             }
         }
         return getDataTable(list);
@@ -146,6 +135,7 @@ public class FsUserWatchCourseStatisticsController extends BaseController
             FsUserWatchCourseStatisticsExportVO vo = new FsUserWatchCourseStatisticsExportVO();
             BeanUtils.copyProperties(v, vo);
             vo.setCompleteWatchRatePercent(v.getCompleteWatchRate() + "%");
+            vo.setOnlineRatePercent(v.getOnlineRate() + "%");
             return vo;
         }).collect(Collectors.toList());
         ExcelUtil<FsUserWatchCourseStatisticsExportVO> util = new ExcelUtil<FsUserWatchCourseStatisticsExportVO>(FsUserWatchCourseStatisticsExportVO.class);

+ 2 - 0
fs-admin/src/main/java/com/fs/course/controller/FsUserWatchStatisticsController.java

@@ -47,6 +47,7 @@ public class FsUserWatchStatisticsController extends BaseController
         if(!list.isEmpty()){
             for (FsUserWatchStatistics userWatchStatistics : list) {
                 userWatchStatistics.setCompleteWatchRatePercent(userWatchStatistics.getCompleteWatchRate() + "%");
+                userWatchStatistics.setOnlineRatePercent(userWatchStatistics.getOnlineRate() + "%");
             }
         }
         return getDataTable(list);
@@ -64,6 +65,7 @@ public class FsUserWatchStatisticsController extends BaseController
         if(!list.isEmpty()){
             for (FsUserWatchStatistics userWatchStatistics : list) {
                 userWatchStatistics.setCompleteWatchRatePercent(userWatchStatistics.getCompleteWatchRate() + "%");
+                userWatchStatistics.setOnlineRatePercent(userWatchStatistics.getOnlineRate() + "%");
             }
         }
         ExcelUtil<FsUserWatchStatistics> util = new ExcelUtil<FsUserWatchStatistics>(FsUserWatchStatistics.class);

+ 2 - 12
fs-company/src/main/java/com/fs/course/controller/FsUserWatchCourseStatisticsController.java

@@ -46,12 +46,6 @@ public class FsUserWatchCourseStatisticsController extends BaseController
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         fsUserWatchCourseStatistics.setCompanyId( loginUser.getCompany().getCompanyId());
         List<FsUserWatchCourseStatistics> list = fsUserWatchCourseStatisticsService.selectFsUserWatchCourseStatisticsList(fsUserWatchCourseStatistics);
-        if(!list.isEmpty()){
-            for (FsUserWatchCourseStatistics userWatchCourseStatistics : list) {
-                userWatchCourseStatistics.setCompleteWatchRatePercent(userWatchCourseStatistics.getCompleteWatchRate() + "%");
-                userWatchCourseStatistics.setAnswerRightRatePercent(userWatchCourseStatistics.getAnswerRightRate() + "%");
-            }
-        }
         return getDataTable(list);
     }
 
@@ -63,12 +57,6 @@ public class FsUserWatchCourseStatisticsController extends BaseController
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         fsUserWatchCourseStatistics.setCompanyId( loginUser.getCompany().getCompanyId());
         List<FsUserWatchCourseStatistics> list = fsUserWatchCourseStatisticsService.selectFsUserWatchCourseStatisticsList(fsUserWatchCourseStatistics);
-        if(!list.isEmpty()){
-            for (FsUserWatchCourseStatistics userWatchCourseStatistics : list) {
-                userWatchCourseStatistics.setCompleteWatchRatePercent(userWatchCourseStatistics.getCompleteWatchRate() + "%");
-                userWatchCourseStatistics.setAnswerRightRatePercent(userWatchCourseStatistics.getAnswerRightRate() + "%");
-            }
-        }
         ExcelUtil<FsUserWatchCourseStatistics> util = new ExcelUtil<FsUserWatchCourseStatistics>(FsUserWatchCourseStatistics.class);
         return util.exportExcel(list, "会员观看数据明细");
     }
@@ -87,6 +75,7 @@ public class FsUserWatchCourseStatisticsController extends BaseController
         if(!list.isEmpty()){
             for (FsUserWatchCourseStatistics userWatchCourseStatistics : list) {
                 userWatchCourseStatistics.setCompleteWatchRatePercent(userWatchCourseStatistics.getCompleteWatchRate() + "%");
+                userWatchCourseStatistics.setOnlineRatePercent(userWatchCourseStatistics.getOnlineRate() + "%");
             }
         }
         return getDataTable(list);
@@ -106,6 +95,7 @@ public class FsUserWatchCourseStatisticsController extends BaseController
             FsUserWatchCourseStatisticsExportVO vo = new FsUserWatchCourseStatisticsExportVO();
             BeanUtils.copyProperties(v, vo);
             vo.setCompleteWatchRatePercent(v.getCompleteWatchRate() + "%");
+            vo.setOnlineRatePercent(v.getOnlineRate() + "%");
             return vo;
         }).collect(Collectors.toList());
         ExcelUtil<FsUserWatchCourseStatisticsExportVO> util = new ExcelUtil<FsUserWatchCourseStatisticsExportVO>(FsUserWatchCourseStatisticsExportVO.class);

+ 7 - 0
fs-service-system/src/main/java/com/fs/course/domain/FsUserWatchCourseStatistics.java

@@ -86,10 +86,17 @@ public class FsUserWatchCourseStatistics extends BaseEntity{
     @Excel(name = "观看人数")
     private Integer watchNum;
 
+    /** 上线率+% */
+    @Excel(name = "上线率")
+    private String onlineRatePercent;
+
     /** 完播人数 */
     @Excel(name = "完播人数")
     private Integer completeWatchNum;
 
+    /** 上线率 */
+    private BigDecimal onlineRate;
+
     /** 完播率 */
 //    @Excel(name = "完播率")
     private BigDecimal completeWatchRate;

+ 7 - 0
fs-service-system/src/main/java/com/fs/course/domain/FsUserWatchStatistics.java

@@ -56,10 +56,17 @@ public class FsUserWatchStatistics extends BaseEntity{
     @Excel(name = "观看人数")
     private Integer watchNum;
 
+    /** 上线率+% */
+    @Excel(name = "上线率")
+    private String onlineRatePercent;
+
     /** 完播人数 */
     @Excel(name = "完播人数")
     private Integer completeWatchNum;
 
+    /** 上线率 */
+    private BigDecimal onlineRate;
+
     /** 完播率 */
 //    @Excel(name = "完播率")
     private BigDecimal completeWatchRate;

+ 20 - 1
fs-service-system/src/main/java/com/fs/course/service/impl/FsUserWatchCourseStatisticsServiceImpl.java

@@ -1,6 +1,7 @@
 package com.fs.course.service.impl;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -59,7 +60,15 @@ public class FsUserWatchCourseStatisticsServiceImpl extends ServiceImpl<FsUserWa
     @Override
     public List<FsUserWatchCourseStatistics> selectFsUserWatchCourseStatisticsList(FsUserWatchCourseStatistics fsUserWatchCourseStatistics)
     {
-        return baseMapper.selectFsUserWatchCourseStatisticsList(fsUserWatchCourseStatistics);
+        List<FsUserWatchCourseStatistics> list = baseMapper.selectFsUserWatchCourseStatisticsList(fsUserWatchCourseStatistics);
+        if(!list.isEmpty()){
+            for (FsUserWatchCourseStatistics userWatchCourseStatistics : list) {
+                userWatchCourseStatistics.setCompleteWatchRatePercent(userWatchCourseStatistics.getCompleteWatchRate() + "%");
+                userWatchCourseStatistics.setAnswerRightRatePercent(userWatchCourseStatistics.getAnswerRightRate() + "%");
+                userWatchCourseStatistics.setOnlineRatePercent(userWatchCourseStatistics.getOnlineRate() + "%");
+            }
+        }
+        return list;
     }
 
     @Override
@@ -192,6 +201,16 @@ public class FsUserWatchCourseStatisticsServiceImpl extends ServiceImpl<FsUserWa
                 vo.setAnswerRightRate(BigDecimal.ZERO);
             }
 
+            // 设置上线率
+            BigDecimal watchNum = new BigDecimal(vo.getWatchNum());
+            BigDecimal userNum = new BigDecimal(vo.getUserNum());
+            if(!userNum.equals(BigDecimal.ZERO)){
+                BigDecimal onlineRate = watchNum.divide(userNum, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
+                vo.setOnlineRate(onlineRate);
+            } else{
+                vo.setOnlineRate(BigDecimal.ZERO);
+            }
+
             vo.setCreateTime(new Date());
             vo.setUpdateTime(new Date());
             list.add(vo);

+ 12 - 0
fs-service-system/src/main/java/com/fs/course/service/impl/FsUserWatchStatisticsServiceImpl.java

@@ -1,6 +1,7 @@
 package com.fs.course.service.impl;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
 import java.util.*;
@@ -178,6 +179,17 @@ public class FsUserWatchStatisticsServiceImpl extends ServiceImpl<FsUserWatchSta
                                 fsUserWatchStatistics.setCompleteWatchNum(0);
                                 fsUserWatchStatistics.setCompleteWatchRate(BigDecimal.ZERO);
                             }
+
+                            // 计算上线率
+                            BigDecimal watchNum = new BigDecimal(fsUserWatchStatistics.getWatchNum());
+                            BigDecimal userNum = new BigDecimal(fsUserWatchStatistics.getUserNum());
+                            if(!userNum.equals(BigDecimal.ZERO)){
+                                BigDecimal onlineRate = watchNum.divide(userNum, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
+                                fsUserWatchStatistics.setOnlineRate(onlineRate);
+                            } else {
+                                fsUserWatchStatistics.setOnlineRate(BigDecimal.ZERO);
+                            }
+
                             fsUserWatchStatistics.setCreateTime(new Date());
                             fsUserWatchStatistics.setUpdateTime(new Date());
                             return fsUserWatchStatistics;

+ 4 - 0
fs-service-system/src/main/java/com/fs/course/vo/FsUserWatchCourseStatisticsExportVO.java

@@ -82,6 +82,10 @@ public class FsUserWatchCourseStatisticsExportVO extends BaseEntity{
     @Excel(name = "完播人数")
     private Integer completeWatchNum;
 
+    /** 上线率+% */
+    @Excel(name = "上线率")
+    private String onlineRatePercent;
+
     /** 完播率 */
 //    @Excel(name = "完播率")
     private BigDecimal completeWatchRate;

+ 13 - 1
fs-service-system/src/main/resources/mapper/course/FsUserWatchCourseStatisticsMapper.xml

@@ -22,6 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="userNum"    column="user_num"    />
         <result property="watchNum"    column="watch_num"    />
         <result property="completeWatchNum"    column="complete_watch_num"    />
+        <result property="onlineRate"    column="online_rate"    />
         <result property="completeWatchRate"    column="complete_watch_rate"    />
         <result property="answerNum"    column="answer_num"    />
         <result property="answerRightNum"    column="answer_right_num"    />
@@ -31,7 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectFsUserWatchCourseStatisticsVo">
-        select id, period_id, period_name, course_id, course_name, video_id, video_title, company_id, company_name, company_user_id, course_start_date_time, company_user_name, period_starting_time, new_user_num, user_num, watch_num, complete_watch_num, complete_watch_rate, answer_num, answer_right_num, answer_right_rate, red_packet_num, red_packet_amount from fs_user_watch_course_statistics
+        select id, period_id, period_name, course_id, course_name, video_id, video_title, company_id, company_name, company_user_id, course_start_date_time, company_user_name, period_starting_time, new_user_num, user_num, watch_num, complete_watch_num, online_rate, complete_watch_rate, answer_num, answer_right_num, answer_right_rate, red_packet_num, red_packet_amount from fs_user_watch_course_statistics
     </sql>
 
     <select id="selectFsUserWatchCourseStatisticsList" parameterType="FsUserWatchCourseStatistics" resultMap="FsUserWatchCourseStatisticsResult">
@@ -79,6 +80,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         sum(new_user_num) as new_user_num,
         sum(user_num) as user_num,
         sum(watch_num) as watch_num,
+        ifnull(
+        ROUND(
+        ( sum(watch_num) / sum(user_num) ) * 100, 2
+        ), 0
+        ) as online_rate,
         sum(complete_watch_num) as complete_watch_num ,
         complete_watch_rate as complete_watch_rate1,
         ifnull(
@@ -139,6 +145,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userNum != null">user_num,</if>
             <if test="watchNum != null">watch_num,</if>
             <if test="completeWatchNum != null">complete_watch_num,</if>
+            <if test="onlineRate != null">online_rate,</if>
             <if test="completeWatchRate != null">complete_watch_rate,</if>
             <if test="answerNum != null">answer_num,</if>
             <if test="answerRightNum != null">answer_right_num,</if>
@@ -163,6 +170,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userNum != null">#{userNum},</if>
             <if test="watchNum != null">#{watchNum},</if>
             <if test="completeWatchNum != null">#{completeWatchNum},</if>
+            <if test="onlineRate != null">#{onlineRate},</if>
             <if test="completeWatchRate != null">#{completeWatchRate},</if>
             <if test="answerNum != null">#{answerNum},</if>
             <if test="answerRightNum != null">#{answerRightNum},</if>
@@ -191,6 +199,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userNum != null">user_num = #{userNum},</if>
             <if test="watchNum != null">watch_num = #{watchNum},</if>
             <if test="completeWatchNum != null">complete_watch_num = #{completeWatchNum},</if>
+            <if test="onlineRate != null">online_rate = #{onlineRate},</if>
             <if test="completeWatchRate != null">complete_watch_rate = #{completeWatchRate},</if>
             <if test="answerNum != null">answer_num = #{answerNum},</if>
             <if test="answerRightNum != null">answer_right_num = #{answerRightNum},</if>
@@ -232,6 +241,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userNum != null">user_num,</if>
             <if test="watchNum != null">watch_num,</if>
             <if test="completeWatchNum != null">complete_watch_num,</if>
+            <if test="onlineRate != null">online_rate,</if>
             <if test="completeWatchRate != null">complete_watch_rate,</if>
             <if test="answerNum != null">answer_num,</if>
             <if test="answerRightNum != null">answer_right_num,</if>
@@ -257,6 +267,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userNum != null">#{userNum},</if>
             <if test="watchNum != null">#{watchNum},</if>
             <if test="completeWatchNum != null">#{completeWatchNum},</if>
+            <if test="onlineRate != null">#{onlineRate},</if>
             <if test="completeWatchRate != null">#{completeWatchRate},</if>
             <if test="answerNum != null">#{answerNum},</if>
             <if test="answerRightNum != null">#{answerRightNum},</if>
@@ -283,6 +294,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userNum != null">user_num = #{userNum},</if>
             <if test="watchNum != null">watch_num = #{watchNum},</if>
             <if test="completeWatchNum != null">complete_watch_num = #{completeWatchNum},</if>
+            <if test="onlineRate != null">online_rate = #{onlineRate},</if>
             <if test="completeWatchRate != null">complete_watch_rate = #{completeWatchRate},</if>
             <if test="answerNum != null">answer_num = #{answerNum},</if>
             <if test="answerRightNum != null">answer_right_num = #{answerRightNum},</if>

+ 8 - 1
fs-service-system/src/main/resources/mapper/course/FsUserWatchStatisticsMapper.xml

@@ -15,11 +15,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="userNum"    column="user_num"    />
         <result property="watchNum"    column="watch_num"    />
         <result property="completeWatchNum"    column="complete_watch_num"    />
+        <result property="onlineRate"    column="online_rate"    />
         <result property="completeWatchRate"    column="complete_watch_rate"    />
     </resultMap>
 
     <sql id="selectFsUserWatchStatisticsVo">
-        select id, period_id, period_name, period_starting_time, new_user_num, user_num, watch_num, complete_watch_num, complete_watch_rate, company_id, company_name from fs_user_watch_statistics
+        select id, period_id, period_name, period_starting_time, new_user_num, user_num, watch_num, complete_watch_num, online_rate, complete_watch_rate, company_id, company_name from fs_user_watch_statistics
     </sql>
 
     <select id="selectFsUserWatchStatisticsList" parameterType="FsUserWatchStatistics" resultMap="FsUserWatchStatisticsResult">
@@ -55,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userNum != null">user_num,</if>
             <if test="watchNum != null">watch_num,</if>
             <if test="completeWatchNum != null">complete_watch_num,</if>
+            <if test="onlineRate != null">online_rate,</if>
             <if test="completeWatchRate != null">complete_watch_rate,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -67,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userNum != null">#{userNum},</if>
             <if test="watchNum != null">#{watchNum},</if>
             <if test="completeWatchNum != null">#{completeWatchNum},</if>
+            <if test="onlineRate != null">#{onlineRate},</if>
             <if test="completeWatchRate != null">#{completeWatchRate},</if>
          </trim>
     </insert>
@@ -83,6 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userNum != null">user_num = #{userNum},</if>
             <if test="watchNum != null">watch_num = #{watchNum},</if>
             <if test="completeWatchNum != null">complete_watch_num = #{completeWatchNum},</if>
+            <if test="onlineRate != null">online_rate = #{onlineRate},</if>
             <if test="completeWatchRate != null">complete_watch_rate = #{completeWatchRate},</if>
         </trim>
         where id = #{id}
@@ -134,6 +138,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="watchNum != null">watch_num,</if>
             <if test="completeWatchNum != null">complete_watch_num,</if>
             <if test="completeWatchRate != null">complete_watch_rate,</if>
+            <if test="onlineRate != null">online_rate,</if>
             <if test="createTime != null">create_time,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -146,6 +151,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userNum != null">#{userNum},</if>
             <if test="watchNum != null">#{watchNum},</if>
             <if test="completeWatchNum != null">#{completeWatchNum},</if>
+            <if test="onlineRate != null">#{onlineRate},</if>
             <if test="completeWatchRate != null">#{completeWatchRate},</if>
             <if test="createTime != null">#{createTime},</if>
         </trim>
@@ -160,6 +166,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userNum != null">user_num = #{userNum},</if>
             <if test="watchNum != null">watch_num = #{watchNum},</if>
             <if test="completeWatchNum != null">complete_watch_num = #{completeWatchNum},</if>
+            <if test="onlineRate != null">online_rate = #{onlineRate},</if>
             <if test="completeWatchRate != null">complete_watch_rate = #{completeWatchRate},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
         </trim>