Browse Source

员工完播

xdd 1 month ago
parent
commit
13f154c3a3

+ 5 - 3
fs-service-system/src/main/java/com/fs/company/mapper/CompanyUserMapper.java

@@ -16,6 +16,7 @@ import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 
+import java.time.LocalDate;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -268,10 +269,11 @@ public interface CompanyUserMapper
      * 获取对应的销售观看记录数
      *
      * @param companyUserId
-     * @param periodId
      * @return
      */
-    Long queryCompanyUserWatchCount(@Param("companyUserId") Long companyUserId, @Param("periodId") Long periodId);
+    Long queryCompanyUserWatchCount(@Param("companyUserId") Long companyUserId,
+                                    @Param("previousDay") LocalDate previousDay);
 
-    Long queryCompanyUserWatchCountCompleted(@Param("companyUserId") Long companyUserId,@Param("periodId") Long periodId);
+    Long queryCompanyUserWatchCountCompleted(@Param("companyUserId") Long companyUserId,
+                                             @Param("previousDay") LocalDate previousDay);
 }

+ 1 - 1
fs-service-system/src/main/java/com/fs/sop/mapper/QwSopLogsMapper.java

@@ -291,7 +291,7 @@ public interface QwSopLogsMapper extends BaseMapper<QwSopLogs> {
 
     @DataSource(DataSourceType.SOP)
     Long selectQwSopLogsCountByQwUserId(@Param("data") List<String> qwUserIdList,
-                                        @Param("periodId") Long periodId,
+                                        @Param("periodId") String periodId,
                                         @Param("previousDay") LocalDate previousDay);
 
 }

+ 1 - 0
fs-service-system/src/main/java/com/fs/sop/mapper/QwSopMapper.java

@@ -374,4 +374,5 @@ public interface QwSopMapper extends BaseMapper<QwSop> {
 
     List<QwSop> selectQwSopAllList();
 
+    List<QwSop> selectQwSopListByQwUserIds(List<String> qwUserIdList);
 }

+ 3 - 0
fs-service-system/src/main/java/com/fs/sop/mapper/SopUserLogsMapper.java

@@ -172,4 +172,7 @@ public interface SopUserLogsMapper {
     List<SopUserLogs> selectSopUserLogByChatIds(@Param("ids") List<String> ids);
 
     List<SopUserLogs> queryExecuteLogBySopId(@Param("sopId") String id);
+
+    @DataSource(DataSourceType.SOP)
+    List<String> selectSopUserLogsByQwUserIds(@Param("qwUserIds") List<String> qwUserIdList);
 }

+ 2 - 2
fs-service-system/src/main/java/com/fs/statis/domain/FsStatisSalerWatch.java

@@ -101,9 +101,9 @@ public class FsStatisSalerWatch {
     private Long onlineCompletePlayback;
 
     /**
-     * 训练营id
+     * 营id
      */
-    private Long periodId;
+    private String periodId;
 
     /**
      * 数据日期

+ 17 - 8
fs-service-system/src/main/java/com/fs/statis/service/impl/FsStatisSalerWatchServiceImpl.java

@@ -5,7 +5,10 @@ import com.fs.company.mapper.CompanyUserMapper;
 import com.fs.course.domain.FsUserCoursePeriod;
 import com.fs.course.mapper.FsUserCoursePeriodMapper;
 import com.fs.qw.mapper.QwUserMapper;
+import com.fs.sop.domain.QwSop;
 import com.fs.sop.mapper.QwSopLogsMapper;
+import com.fs.sop.mapper.QwSopMapper;
+import com.fs.sop.mapper.SopUserLogsMapper;
 import com.fs.statis.domain.FsStatisSalerWatch;
 import com.fs.statis.dto.StatsWatchLogPageListDTO;
 import com.fs.statis.mapper.FsStatisSalerWatchMapper;
@@ -37,13 +40,20 @@ public class FsStatisSalerWatchServiceImpl implements FsStatisSalerWatchService
 
     private final FsUserCoursePeriodMapper fsUserCoursePeriodMapper;
 
+    private final QwSopMapper qwSopMapper;
+
+    private final SopUserLogsMapper sopUserLogsMapper;
+
+
     @Autowired
-    public FsStatisSalerWatchServiceImpl(FsStatisSalerWatchMapper fsStatisSalerWatchMapper, CompanyUserMapper companyUserMapper, QwUserMapper qwUserMapper, QwSopLogsMapper qwSopLogsMapper, FsUserCoursePeriodMapper fsUserCoursePeriodMapper) {
+    public FsStatisSalerWatchServiceImpl(FsStatisSalerWatchMapper fsStatisSalerWatchMapper, CompanyUserMapper companyUserMapper, QwUserMapper qwUserMapper, QwSopLogsMapper qwSopLogsMapper, FsUserCoursePeriodMapper fsUserCoursePeriodMapper, QwSopMapper qwSopMapper, SopUserLogsMapper sopUserLogsMapper) {
         this.fsStatisSalerWatchMapper = fsStatisSalerWatchMapper;
         this.companyUserMapper = companyUserMapper;
         this.qwUserMapper = qwUserMapper;
         this.qwSopLogsMapper = qwSopLogsMapper;
         this.fsUserCoursePeriodMapper = fsUserCoursePeriodMapper;
+        this.qwSopMapper = qwSopMapper;
+        this.sopUserLogsMapper = sopUserLogsMapper;
     }
 
     /**
@@ -116,7 +126,6 @@ public class FsStatisSalerWatchServiceImpl implements FsStatisSalerWatchService
         // 获取前一天的时间
         List<CompanyUser> companyUserList = this.companyUserMapper.selectAllCompanyUserList();
 
-
         List<FsStatisSalerWatch> writeData = new ArrayList<>();
 
         LocalDate previousDay = LocalDate.now().minusDays(1);
@@ -126,18 +135,18 @@ public class FsStatisSalerWatchServiceImpl implements FsStatisSalerWatchService
                 log.info("销售{} 对应公司id {} 为空!",companyUser.getUserId(),companyUser.getCompanyId());
                 continue;
             }
-            // 确定当前销售对应的营期
-            List<Long> periodList = fsUserCoursePeriodMapper.queryPeriod(companyUser.getCompanyId(),previousDay);
-
             // 找到销售关联的企微账号
             List<String> qwUserIdList = qwUserMapper.findQwUserIdListByCompanyUserId(companyUser.getUserId());
 
-            for (Long periodId : periodList) {
+            // 确定当前销售对应的sop执行记录
+            List<String> periodList = sopUserLogsMapper.selectSopUserLogsByQwUserIds(qwUserIdList);
+
+            for (String periodId : periodList) {
                 // 去sop记录表找对应的SOP发送记录,记录数作为营期人数
                 Long periodCount = qwSopLogsMapper.selectQwSopLogsCountByQwUserId(qwUserIdList,periodId,previousDay);
                 // 再去course_watch_log找对应的销售观看记录作为已报名数
-                Long registerCount = companyUserMapper.queryCompanyUserWatchCount(companyUser.getUserId(),periodId);
-                Long completedCount = companyUserMapper.queryCompanyUserWatchCountCompleted(companyUser.getUserId(),periodId);
+                Long registerCount = companyUserMapper.queryCompanyUserWatchCount(companyUser.getUserId(),previousDay);
+                Long completedCount = companyUserMapper.queryCompanyUserWatchCountCompleted(companyUser.getUserId(),previousDay);
 
 
                 FsStatisSalerWatch fsStatisSalerWatch = new FsStatisSalerWatch();

+ 4 - 4
fs-service-system/src/main/resources/mapper/company/CompanyUserMapper.xml

@@ -508,8 +508,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyUserId != null">
                 AND company_user_id = #{companyUserId}
             </if>
-            <if test="periodId != null">
-                AND period_id = #{periodId}
+            <if test="previousDay != null">
+                and camp_period_time = ${previousDay}
             </if>
         </where>
     </select>
@@ -520,8 +520,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyUserId != null">
                 AND company_user_id = #{companyUserId}
             </if>
-            <if test="periodId != null">
-                AND period_id = #{periodId}
+            <if test="previousDay != null">
+                and camp_period_time = ${previousDay}
             </if>
         </where>
     </select>

+ 9 - 0
fs-service-system/src/main/resources/mapper/sop/SopUserLogsMapper.xml

@@ -292,5 +292,14 @@
 
          where sop_id=#{sopId}
     </select>
+    <select id="selectSopUserLogsByQwUserIds" resultType="java.lang.String">
+        select id from sop_user_logs
+        <where>
+            qw_user_id in
+              <foreach collection="qwUserIds" item="item" open="(" close=")" separator=",">
+                  #{item}
+              </foreach>
+        </where>
+    </select>
 
 </mapper>

+ 1 - 1
fs-service-system/src/main/resources/mapper/statis/FsStatisSalerWatchMapper.xml

@@ -33,7 +33,7 @@
     <select id="queryList" resultType="com.fs.statis.domain.FsStatisSalerWatch">
         select * from fs_statis_saler_watch
         <where>
-            <if test="userIds != null and userIds.length > 0">
+            <if test="userIds != null and userIds.size() > 0">
                 AND company_user_id IN
                  <foreach collection="userIds" open="(" close=")" separator="," item="item">
                      ${item}