Browse Source

feat: 调整会员看课数据汇总表(增加销售公司)

caoliqin 4 days ago
parent
commit
aa78219561

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

@@ -36,6 +36,14 @@ public class FsUserWatchStatistics extends BaseEntity{
     @Excel(name = "营期开始日期", width = 30, dateFormat = "yyyy-MM-dd")
     @Excel(name = "营期开始日期", width = 30, dateFormat = "yyyy-MM-dd")
     private Date periodStartingTime;
     private Date periodStartingTime;
 
 
+    /** 销售公司ids */
+//    @Excel(name = "销售公司ids")
+    private String companyId;
+
+    /** 销售公司名称 */
+    @Excel(name = "销售公司")
+    private String companyName;
+
     /** 新增会员数量 */
     /** 新增会员数量 */
     @Excel(name = "新增会员数量")
     @Excel(name = "新增会员数量")
     private Integer newUserNum;
     private Integer newUserNum;

+ 6 - 23
fs-service-system/src/main/java/com/fs/course/service/impl/FsUserWatchStatisticsServiceImpl.java

@@ -115,10 +115,6 @@ public class FsUserWatchStatisticsServiceImpl extends ServiceImpl<FsUserWatchSta
     @Transactional
     @Transactional
     public void insertStatistics() {
     public void insertStatistics() {
         // 1、获取统计结果
         // 1、获取统计结果
-        // 获取所有营期
-//        FsUserCoursePeriod periodParam = new FsUserCoursePeriod();
-//        List<FsUserCoursePeriod> fsUserCoursePeriods = fsUserCoursePeriodMapper.selectFsUserCoursePeriodList(periodParam);
-
         //获取会员数量和新增会员数量
         //获取会员数量和新增会员数量
         List<FsUserWatchStatistics> userTotal = fsUserMapper.selectFsUserTotal();
         List<FsUserWatchStatistics> userTotal = fsUserMapper.selectFsUserTotal();
         FsUserWatchStatistics userTotalStatistics = new FsUserWatchStatistics();
         FsUserWatchStatistics userTotalStatistics = new FsUserWatchStatistics();
@@ -129,30 +125,17 @@ public class FsUserWatchStatisticsServiceImpl extends ServiceImpl<FsUserWatchSta
         // 获取看课统计
         // 获取看课统计
         List<FsUserWatchStatistics> courseWatchStatistics = baseMapper.getCourseWatchStatistics();
         List<FsUserWatchStatistics> courseWatchStatistics = baseMapper.getCourseWatchStatistics();
 
 
-        // 转化map
-        Map<Long, FsUserWatchStatistics> watchStatisticsMap = courseWatchStatistics.stream()
-                .collect(Collectors.toMap(
-                        FsUserWatchStatistics::getPeriodId,
-                        Function.identity()
-                ));
+//        // 转化map
+//        Map<Long, FsUserWatchStatistics> watchStatisticsMap = courseWatchStatistics.stream()
+//                .collect(Collectors.toMap(
+//                        FsUserWatchStatistics::getPeriodId,
+//                        Function.identity()
+//                ));
         // 组装数据
         // 组装数据
-//        List<FsUserWatchStatistics> list = fsUserCoursePeriods.stream().map(v -> {
-//            FsUserWatchStatistics fsUserWatchStatistics = new FsUserWatchStatistics();
-//            BeanUtils.copyProperties(v, fsUserWatchStatistics);
-//            FsUserWatchStatistics count = watchStatisticsMap.getOrDefault(v.getPeriodId(), fsUserWatchStatistics);
-//            fsUserWatchStatistics.setWatchNum(count.getWatchNum());
-//            fsUserWatchStatistics.setCompleteWatchNum(count.getCompleteWatchNum());
-//            fsUserWatchStatistics.setCompleteWatchRate(count.getCompleteWatchRate());
-//            return fsUserWatchStatistics;
-//        }).collect(Collectors.toList());
         for (FsUserWatchStatistics courseWatchStatistic : courseWatchStatistics) {
         for (FsUserWatchStatistics courseWatchStatistic : courseWatchStatistics) {
-            FsUserWatchStatistics count = watchStatisticsMap.getOrDefault(courseWatchStatistic.getPeriodId(), courseWatchStatistic);
             // 单独set,不用copy,避免copy出来的结果被前面的覆盖
             // 单独set,不用copy,避免copy出来的结果被前面的覆盖
             courseWatchStatistic.setUserNum(userTotalStatistics.getUserNum() != null ? userTotalStatistics.getUserNum():0);
             courseWatchStatistic.setUserNum(userTotalStatistics.getUserNum() != null ? userTotalStatistics.getUserNum():0);
             courseWatchStatistic.setNewUserNum(userTotalStatistics.getNewUserNum() != null ? userTotalStatistics.getNewUserNum():0);
             courseWatchStatistic.setNewUserNum(userTotalStatistics.getNewUserNum() != null ? userTotalStatistics.getNewUserNum():0);
-            courseWatchStatistic.setWatchNum(count.getWatchNum() !=null ? count.getWatchNum():0);
-            courseWatchStatistic.setCompleteWatchNum(count.getCompleteWatchNum() != null ? count.getCompleteWatchNum():0);
-            courseWatchStatistic.setCompleteWatchRate(count.getCompleteWatchRate() != null ? count.getCompleteWatchRate(): BigDecimal.ZERO);
             courseWatchStatistic.setCreateTime(new Date());
             courseWatchStatistic.setCreateTime(new Date());
             courseWatchStatistic.setUpdateTime(new Date());
             courseWatchStatistic.setUpdateTime(new Date());
         }
         }

+ 21 - 2
fs-service-system/src/main/resources/mapper/course/FsUserWatchStatisticsMapper.xml

@@ -9,6 +9,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="periodId"    column="period_id"    />
         <result property="periodId"    column="period_id"    />
         <result property="periodName"    column="period_name"    />
         <result property="periodName"    column="period_name"    />
         <result property="periodStartingTime"    column="period_starting_time"    />
         <result property="periodStartingTime"    column="period_starting_time"    />
+        <result property="companyId"    column="company_id"    />
+        <result property="companyName"    column="company_name"    />
         <result property="newUserNum"    column="new_user_num"    />
         <result property="newUserNum"    column="new_user_num"    />
         <result property="userNum"    column="user_num"    />
         <result property="userNum"    column="user_num"    />
         <result property="watchNum"    column="watch_num"    />
         <result property="watchNum"    column="watch_num"    />
@@ -17,7 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
     </resultMap>
 
 
     <sql id="selectFsUserWatchStatisticsVo">
     <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 from fs_user_watch_statistics
+        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
     </sql>
     </sql>
 
 
     <select id="selectFsUserWatchStatisticsList" parameterType="FsUserWatchStatistics" resultMap="FsUserWatchStatisticsResult">
     <select id="selectFsUserWatchStatisticsList" parameterType="FsUserWatchStatistics" resultMap="FsUserWatchStatisticsResult">
@@ -26,6 +28,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="periodId != null "> and period_id = #{periodId}</if>
             <if test="periodId != null "> and period_id = #{periodId}</if>
             <if test="periodName != null  and periodName != ''"> and period_name like concat('%', #{periodName}, '%')</if>
             <if test="periodName != null  and periodName != ''"> and period_name like concat('%', #{periodName}, '%')</if>
             <if test="periodStartingTime != null "> and period_starting_time = #{periodStartingTime}</if>
             <if test="periodStartingTime != null "> and period_starting_time = #{periodStartingTime}</if>
+            <if test="companyId != null and companyId !='' "> and company_id = #{companyId}</if>
+            <if test="companyName != null  and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
             <if test="newUserNum != null "> and new_user_num = #{newUserNum}</if>
             <if test="newUserNum != null "> and new_user_num = #{newUserNum}</if>
             <if test="userNum != null "> and user_num = #{userNum}</if>
             <if test="userNum != null "> and user_num = #{userNum}</if>
             <if test="watchNum != null "> and watch_num = #{watchNum}</if>
             <if test="watchNum != null "> and watch_num = #{watchNum}</if>
@@ -45,6 +49,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="periodId != null">period_id,</if>
             <if test="periodId != null">period_id,</if>
             <if test="periodName != null">period_name,</if>
             <if test="periodName != null">period_name,</if>
             <if test="periodStartingTime != null">period_starting_time,</if>
             <if test="periodStartingTime != null">period_starting_time,</if>
+            <if test="companyId != null and companyId !='' ">company_id,</if>
+            <if test="companyName != null">company_name,</if>
             <if test="newUserNum != null">new_user_num,</if>
             <if test="newUserNum != null">new_user_num,</if>
             <if test="userNum != null">user_num,</if>
             <if test="userNum != null">user_num,</if>
             <if test="watchNum != null">watch_num,</if>
             <if test="watchNum != null">watch_num,</if>
@@ -55,6 +61,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="periodId != null">#{periodId},</if>
             <if test="periodId != null">#{periodId},</if>
             <if test="periodName != null">#{periodName},</if>
             <if test="periodName != null">#{periodName},</if>
             <if test="periodStartingTime != null">#{periodStartingTime},</if>
             <if test="periodStartingTime != null">#{periodStartingTime},</if>
+            <if test="companyId != null and companyId !='' ">#{companyId},</if>
+            <if test="companyName != null">#{companyName},</if>
             <if test="newUserNum != null">#{newUserNum},</if>
             <if test="newUserNum != null">#{newUserNum},</if>
             <if test="userNum != null">#{userNum},</if>
             <if test="userNum != null">#{userNum},</if>
             <if test="watchNum != null">#{watchNum},</if>
             <if test="watchNum != null">#{watchNum},</if>
@@ -69,6 +77,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="periodId != null">period_id = #{periodId},</if>
             <if test="periodId != null">period_id = #{periodId},</if>
             <if test="periodName != null">period_name = #{periodName},</if>
             <if test="periodName != null">period_name = #{periodName},</if>
             <if test="periodStartingTime != null">period_starting_time = #{periodStartingTime},</if>
             <if test="periodStartingTime != null">period_starting_time = #{periodStartingTime},</if>
+            <if test="companyId != null and companyId !='' ">company_id = #{companyId},</if>
+            <if test="companyName != null">company_name = #{companyName},</if>
             <if test="newUserNum != null">new_user_num = #{newUserNum},</if>
             <if test="newUserNum != null">new_user_num = #{newUserNum},</if>
             <if test="userNum != null">user_num = #{userNum},</if>
             <if test="userNum != null">user_num = #{userNum},</if>
             <if test="watchNum != null">watch_num = #{watchNum},</if>
             <if test="watchNum != null">watch_num = #{watchNum},</if>
@@ -103,10 +113,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             ) AS completeWatchRate,
             ) AS completeWatchRate,
             fwl.period_id
             fwl.period_id
             ,fs_user_course_period.period_name,
             ,fs_user_course_period.period_name,
-            fs_user_course_period.period_starting_time
+            fs_user_course_period.period_starting_time,
+            fs_user_course_period.company_id,
+            GROUP_CONCAT(DISTINCT company.company_name) company_name
         FROM
         FROM
             fs_course_watch_log fwl
             fs_course_watch_log fwl
                 LEFT JOIN fs_user_course_period ON fwl.period_id = fs_user_course_period.period_id
                 LEFT JOIN fs_user_course_period ON fwl.period_id = fs_user_course_period.period_id
+                LEFT JOIN company ON FIND_IN_SET( company.company_id, fs_user_course_period.company_id ) > 0
         WHERE
         WHERE
             fwl.send_type = 1
             fwl.send_type = 1
             and fs_user_course_period.period_name is not null
             and fs_user_course_period.period_name is not null
@@ -120,6 +133,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="periodId != null">period_id,</if>
             <if test="periodId != null">period_id,</if>
             <if test="periodName != null">period_name,</if>
             <if test="periodName != null">period_name,</if>
             <if test="periodStartingTime != null">period_starting_time,</if>
             <if test="periodStartingTime != null">period_starting_time,</if>
+            <if test="companyId != null and companyId !='' ">company_id,</if>
+            <if test="companyName != null">company_name,</if>
             <if test="newUserNum != null">new_user_num,</if>
             <if test="newUserNum != null">new_user_num,</if>
             <if test="userNum != null">user_num,</if>
             <if test="userNum != null">user_num,</if>
             <if test="watchNum != null">watch_num,</if>
             <if test="watchNum != null">watch_num,</if>
@@ -131,6 +146,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="periodId != null">#{periodId},</if>
             <if test="periodId != null">#{periodId},</if>
             <if test="periodName != null">#{periodName},</if>
             <if test="periodName != null">#{periodName},</if>
             <if test="periodStartingTime != null">#{periodStartingTime},</if>
             <if test="periodStartingTime != null">#{periodStartingTime},</if>
+            <if test="companyId != null and companyId !='' ">#{companyId},</if>
+            <if test="companyName != null">#{companyName},</if>
             <if test="newUserNum != null">#{newUserNum},</if>
             <if test="newUserNum != null">#{newUserNum},</if>
             <if test="userNum != null">#{userNum},</if>
             <if test="userNum != null">#{userNum},</if>
             <if test="watchNum != null">#{watchNum},</if>
             <if test="watchNum != null">#{watchNum},</if>
@@ -140,6 +157,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </trim>
         </trim>
         on duplicate key update
         on duplicate key update
         <trim suffixOverrides=",">
         <trim suffixOverrides=",">
+            <if test="companyId != null and companyId !='' ">company_id = #{companyId},</if>
+            <if test="companyName != null">company_name = #{companyName},</if>
             <if test="newUserNum != null">new_user_num = #{newUserNum},</if>
             <if test="newUserNum != null">new_user_num = #{newUserNum},</if>
             <if test="userNum != null">user_num = #{userNum},</if>
             <if test="userNum != null">user_num = #{userNum},</if>
             <if test="watchNum != null">watch_num = #{watchNum},</if>
             <if test="watchNum != null">watch_num = #{watchNum},</if>