Bladeren bron

今正
-企微看课分析定制查询条件-公司细分到部门和社群

lk 1 week geleden
bovenliggende
commit
21677d779f

+ 1 - 1
fs-admin/src/main/java/com/fs/course/controller/FsCourseWatchLogController.java

@@ -100,7 +100,7 @@ public class FsCourseWatchLogController extends BaseController
     {
         logger.info("会员课程数据汇总 参数: {}",param);
 
-        if(param.getCompanyId() == null){
+        if(param.getCompanyId() == null && (param.getUserIds() == null || param.getUserIds().isEmpty())){
             throw new CustomException("必须选择公司!");
         }
         if (param.getSTime()==null||param.getETime()==null){

+ 11 - 1
fs-service/src/main/java/com/fs/course/mapper/FsCourseWatchLogMapper.java

@@ -260,7 +260,16 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
             "<if test= 'sendType == 1 '> " +
             " LEFT JOIN company_user cu on cu.user_id=o.company_user_id\n" +
             "</if>\n" +
-            "where o.company_id=#{companyId} " +
+            "<where> \n" +
+            "<if test = 'companyId != null and companyId != 0'>\n" +
+            "and o.company_id=#{companyId} \n" +
+            "</if>\n" +
+            "<if test = 'userIds != null and userIds.size() > 0'>\n" +
+            "and o.company_user_id in \n" +
+            "        <foreach collection='userIds' item='id' open='(' separator=',' close=')'>\n" +
+            "            #{id}\n" +
+            "        </foreach>\n" +
+            "</if>\n" +
             "<if test= 'sendType != null '> " +
             "       and  send_type= #{sendType} " +
             "</if>\n" +
@@ -282,6 +291,7 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
             "<if test ='videoId !=null'> " +
             "     and o.video_id = #{videoId} " +
             "</if>" +
+            "</where>" +
             "GROUP BY o.video_id," +
             "<if test= 'sendType != 1 '> " +
             " o.qw_user_id," +

+ 25 - 0
fs-service/src/main/java/com/fs/course/param/FsCourseWatchLogStatisticsListParam.java

@@ -4,8 +4,12 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fs.common.utils.DateUtils;
 import lombok.Data;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.StringJoiner;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 @Data
 public class FsCourseWatchLogStatisticsListParam {
@@ -56,4 +60,25 @@ public class FsCourseWatchLogStatisticsListParam {
      * 标识('course','company')
      */
     private  String dimension ;
+    /**
+     * 今正要求把公司筛选条件优化到细分至部门,销售(前端判断,只有今正传)
+     */
+    private List<String> userIds;
+    public List<String> getUserIds() {
+        if (userIds == null || userIds.isEmpty()) {
+            return userIds;
+        }
+        ArrayList<String> longs = new ArrayList<>();
+        userIds.forEach(userId -> {
+            if (userId.contains("user_")){
+                StringJoiner joiner = new StringJoiner("");
+                Matcher matcher = Pattern.compile("\\d+").matcher(userId);
+                while (matcher.find()) {
+                    joiner.add(matcher.group());
+                }
+                longs.add(joiner.toString());
+            }
+        });
+        return longs;
+    }
 }

+ 1 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsCourseWatchLogServiceImpl.java

@@ -763,6 +763,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
 
     @Override
     public List<FsCourseWatchLogStatisticsListVO> selectFsCourseWatchLogStatisticsListVO(FsCourseWatchLogStatisticsListParam param) {
+        if (param.getUserIds() != null && !param.getUserIds().isEmpty())param.setUserIds(param.getUserIds());
         return fsCourseWatchLogMapper.selectFsCourseWatchLogStatisticsListVO(param);
     }
 

+ 26 - 0
fs-service/src/main/java/com/fs/qw/param/QwWatchLogStatisticsListParam.java

@@ -4,8 +4,12 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fs.common.utils.DateUtils;
 import lombok.Data;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.StringJoiner;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 @Data
 public class QwWatchLogStatisticsListParam {
@@ -41,4 +45,26 @@ public class QwWatchLogStatisticsListParam {
     private Long pageNum;
     private Long pageSize;
     private List<Long> filterDeptIds;
+    /**
+     * 今正要求把公司筛选条件优化到细分至部门,销售(前端判断,只有今正传)
+     */
+    private List<String> userIds;
+    public List<String> getUserIds() {
+        if (userIds == null || userIds.isEmpty()) {
+            return userIds;
+        }
+        ArrayList<String> longs = new ArrayList<>();
+        userIds.forEach(userId -> {
+            if (userId.contains("user_")){
+                StringJoiner joiner = new StringJoiner("");
+                Matcher matcher = Pattern.compile("\\d+").matcher(userId);
+                while (matcher.find()) {
+                    joiner.add(matcher.group());
+                }
+                longs.add(joiner.toString());
+            }
+
+        });
+        return longs;
+    }
 }

+ 4 - 2
fs-service/src/main/java/com/fs/qw/service/impl/QwWatchLogServiceImpl.java

@@ -403,7 +403,7 @@ public class QwWatchLogServiceImpl extends ServiceImpl<QwWatchLogMapper, QwWatch
     public TableDataInfo selectQwWatchLogAllStatisticsListVONew(QwWatchLogStatisticsListParam param) {
         // 获取当前公司下的所有销售
         List<Long> userIds;
-        if(param.getCompanyUserId()  == null){
+        if(param.getCompanyUserId()  == null && (param.getUserIds() == null || param.getUserIds().isEmpty())){
             List<CompanyUser> companyUsers = companyUserMapper.selectCompanyUserByCompanyId(param.getCompanyId());
             if(CollectionUtils.isEmpty(companyUsers)){
                 throw new CustomException("该公司下面没有任何销售!");
@@ -412,7 +412,9 @@ public class QwWatchLogServiceImpl extends ServiceImpl<QwWatchLogMapper, QwWatch
                     .map(CompanyUser::getUserId)
                     .filter(Objects::nonNull)
                     .collect(Collectors.toList());
-        } else {
+        } else if((param.getUserIds() != null && !param.getUserIds().isEmpty())){
+            userIds = param.getUserIds().stream().map(Long::valueOf).collect(Collectors.toList());
+        }else{
             userIds = new ArrayList<>();
             userIds.add(param.getCompanyUserId());
         }

+ 10 - 1
fs-service/src/main/resources/mapper/course/FsCourseWatchLogMapper.xml

@@ -1058,7 +1058,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="sendType == 1">
             LEFT JOIN company_user cu ON cu.user_id = o.company_user_id
         </if>
-        WHERE o.company_id = #{companyId}
+        WHERE 1=1
+        <if test = 'companyId != null and companyId != 0'>
+            and o.company_id=#{companyId}
+            </if>
+        <if test = 'userIds != null and userIds.size() > 0'>
+        and o.company_user_id in
+                <foreach collection='userIds' item='id' open='(' separator=',' close=')'>
+                        #{id}
+                   </foreach>
+        </if>
         <!-- 发送类型筛选 -->
         <if test="sendType != null">
             AND send_type = #{sendType}