Sfoglia il codice sorgente

Merge branch 'dev-xym-add-alerts' of Server/growth-manager into master

xueyiming 3 mesi fa
parent
commit
6d50613dc4
45 ha cambiato i file con 2272 aggiunte e 100 eliminazioni
  1. 1 1
      api-module/src/main/java/com/tzld/piaoquan/api/common/enums/ReplyStrategyServiceEnum.java
  2. 2 1
      api-module/src/main/java/com/tzld/piaoquan/api/common/enums/SecretEnum.java
  3. 17 0
      api-module/src/main/java/com/tzld/piaoquan/api/component/TouLiuHttpClient.java
  4. 2 2
      api-module/src/main/java/com/tzld/piaoquan/api/controller/AccountDetailController.java
  5. 27 0
      api-module/src/main/java/com/tzld/piaoquan/api/controller/CgiReplyController.java
  6. 24 0
      api-module/src/main/java/com/tzld/piaoquan/api/model/bo/FilterData.java
  7. 10 0
      api-module/src/main/java/com/tzld/piaoquan/api/model/bo/ReplyBucketData.java
  8. 9 0
      api-module/src/main/java/com/tzld/piaoquan/api/service/CgiReplyService.java
  9. 87 0
      api-module/src/main/java/com/tzld/piaoquan/api/service/impl/CgiReplyServiceImpl.java
  10. 5 5
      api-module/src/main/java/com/tzld/piaoquan/api/service/impl/GhDetailServiceImpl.java
  11. 10 4
      api-module/src/main/java/com/tzld/piaoquan/api/service/impl/ThirdPartyServiceImpl.java
  12. 11 3
      api-module/src/main/java/com/tzld/piaoquan/api/service/impl/WeComServiceImpl.java
  13. 310 0
      api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/BuckStrategyV1.java
  14. 4 4
      api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/ThirdPartyPushMessageStrategyV1.java
  15. 3 3
      api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/WeComPushMessageStrategyV1.java
  16. 1 0
      api-module/src/main/resources/application-prod.properties
  17. 5 3
      api-module/src/main/resources/application-test.properties
  18. 4 0
      api-module/src/main/resources/application.properties
  19. 1 1
      api-module/src/main/resources/mybatis-generator-config.xml
  20. 28 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/common/enums/FieshuTableColumnDataTypeEnum.java
  21. 1 1
      common-module/src/main/java/com/tzld/piaoquan/growth/common/common/enums/GhTypeEnum.java
  22. 1 1
      common-module/src/main/java/com/tzld/piaoquan/growth/common/common/enums/StrategyStatusEnum.java
  23. 3 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/AttachmentWithMsgResultMapper.java
  24. 6 3
      common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/CgiReplyBucketDataMapper.java
  25. 10 4
      common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/GhDetailMapper.java
  26. 35 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/UserCountMapper.java
  27. 148 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/model/bo/FeishuTableDTO.java
  28. 1 1
      common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/CgiReplyBucketData.java
  29. 1 1
      common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/CgiReplyBucketDataExample.java
  30. 1 1
      common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/GhDetail.java
  31. 1 1
      common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/GhDetailExample.java
  32. 103 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/UserCount.java
  33. 713 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/UserCountExample.java
  34. 28 15
      common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/MessageAttachmentServiceImpl.java
  35. 7 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/utils/DateUtil.java
  36. 28 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/utils/LarkRobotUtil.java
  37. 15 0
      common-module/src/main/resources/mapper/AttachmentWithMsgResultMapper.xml
  38. 15 9
      common-module/src/main/resources/mapper/CgiReplyBucketDataMapper.xml
  39. 9 9
      common-module/src/main/resources/mapper/GhDetailMapper.xml
  40. 261 0
      common-module/src/main/resources/mapper/UserCountMapper.xml
  41. 213 0
      offline-module/src/main/java/com/tzld/piaoquan/offline/job/AutoReplyVideoDataJob.java
  42. 1 1
      offline-module/src/main/java/com/tzld/piaoquan/offline/job/PushMessageDataJob.java
  43. 19 22
      offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComHistoryDataJob.java
  44. 83 4
      offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComUserDataJob.java
  45. 8 0
      pom.xml

+ 1 - 1
api-module/src/main/java/com/tzld/piaoquan/api/common/enums/ReplyStrategyServiceEnum.java

@@ -2,7 +2,7 @@ package com.tzld.piaoquan.api.common.enums;
 
 public enum ReplyStrategyServiceEnum {
 
-
+    BUCKET_STRATEGY_V1("BUCKET_STRATEGY_V1", "分桶策略v1"),
     THIRD_PARTY_PUSH_MESSAGE_STRATEGY_V1("THIRD_PARTY_PUSH_MESSAGE_STRATEGY_V1", "第三方微信公众号推送策略V1"),
     WE_COM_PUSH_MESSAGE_STRATEGY_V1("WE_COM_PUSH_MESSAGE_STRATEGY_V1", "企业微信推送策略V1"),
     ;

+ 2 - 1
api-module/src/main/java/com/tzld/piaoquan/api/common/enums/SecretEnum.java

@@ -14,7 +14,8 @@ public enum SecretEnum {
     SECRET_ENUM_6("ee93a44c4be4448ab0ac9334a296016e", "云誉", "yy"),
     SECRET_ENUM_7("da2c526d31d14430b49af808e90542dc", "创易", "cy"),
     SECRET_ENUM_8("e5758dbc43204434b71b8e025023170f", "微讯", "wx"),
-    SECRET_ENUM_9("1e836616178a4c32a9e8abea47eb6edd", "莱墘", "lq");
+    SECRET_ENUM_9("1e836616178a4c32a9e8abea47eb6edd", "莱墘", "lq"),
+    SECRET_ENUM_10("57a1c09a209445fc83a5fba81b0194bc", "博虎", "bh");
 
 
     SecretEnum(String secret, String desc, String channel) {

+ 17 - 0
api-module/src/main/java/com/tzld/piaoquan/api/component/TouLiuHttpClient.java

@@ -1,12 +1,16 @@
 package com.tzld.piaoquan.api.component;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.tzld.piaoquan.api.model.bo.GroupData;
 import com.tzld.piaoquan.api.model.bo.VideoDetail;
 import com.tzld.piaoquan.growth.common.component.HttpPoolClient;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
 import org.springframework.stereotype.Component;
+import reactor.core.publisher.Mono;
 
 import java.util.HashMap;
 import java.util.List;
@@ -79,4 +83,17 @@ public class TouLiuHttpClient {
         }
         return map;
     }
+
+    public List<GroupData> sendPenGongBaseRequest(String ghId) {
+        try {
+            String url = "http://47.99.132.47:8813/VideoRank";
+            JSONObject params = new JSONObject();
+            params.put("ghId", ghId);
+            String res = httpPoolClient.post(url, JSONObject.toJSONString(params));
+            return JSON.parseArray(res, GroupData.class);
+        } catch (Exception e) {
+            log.error("getVideoDetailRequest error", e);
+        }
+        return null;
+    }
 }

+ 2 - 2
api-module/src/main/java/com/tzld/piaoquan/api/controller/AccountDetailController.java

@@ -1,7 +1,7 @@
 package com.tzld.piaoquan.api.controller;
 
-import com.tzld.piaoquan.api.common.enums.GhTypeEnum;
-import com.tzld.piaoquan.api.common.enums.StrategyStatusEnum;
+import com.tzld.piaoquan.growth.common.common.enums.GhTypeEnum;
+import com.tzld.piaoquan.growth.common.common.enums.StrategyStatusEnum;
 import com.tzld.piaoquan.api.model.vo.GhDetailVo;
 import com.tzld.piaoquan.api.model.vo.GhTypeVo;
 import com.tzld.piaoquan.api.model.vo.StrategyStatusVo;

+ 27 - 0
api-module/src/main/java/com/tzld/piaoquan/api/controller/CgiReplyController.java

@@ -0,0 +1,27 @@
+package com.tzld.piaoquan.api.controller;
+
+import com.tzld.piaoquan.api.model.bo.BucketDataParam;
+import com.tzld.piaoquan.api.model.bo.ReplyBucketData;
+import com.tzld.piaoquan.api.service.CgiReplyService;
+import com.tzld.piaoquan.growth.common.common.base.CommonResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/cgi/reply")
+@Slf4j
+public class CgiReplyController {
+
+    @Autowired
+    private CgiReplyService cgiReplyService;
+
+    @PostMapping("/bucketData")
+    public CommonResponse<ReplyBucketData> getBucketData(@RequestBody BucketDataParam bucketDataParam) {
+        ReplyBucketData replyBucketData = cgiReplyService.getRgiReplyData(bucketDataParam);
+        return CommonResponse.success(replyBucketData);
+    }
+}

+ 24 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/bo/FilterData.java

@@ -0,0 +1,24 @@
+package com.tzld.piaoquan.api.model.bo;
+
+public class FilterData {
+
+    private String publishContentId;
+
+    private String filterReason;
+
+    public String getPublishContentId() {
+        return publishContentId;
+    }
+
+    public void setPublishContentId(String publishContentId) {
+        this.publishContentId = publishContentId;
+    }
+
+    public String getFilterReason() {
+        return filterReason;
+    }
+
+    public void setFilterReason(String filterReason) {
+        this.filterReason = filterReason;
+    }
+}

+ 10 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/bo/ReplyBucketData.java

@@ -4,8 +4,18 @@ import java.util.List;
 
 public class ReplyBucketData {
 
+    private List<FilterData> filterList;
+
     private List<GroupData> groupList;
 
+    public List<FilterData> getFilterList() {
+        return filterList;
+    }
+
+    public void setFilterList(List<FilterData> filterList) {
+        this.filterList = filterList;
+    }
+
     public List<GroupData> getGroupList() {
         return groupList;
     }

+ 9 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/CgiReplyService.java

@@ -0,0 +1,9 @@
+package com.tzld.piaoquan.api.service;
+
+import com.tzld.piaoquan.api.model.bo.BucketDataParam;
+import com.tzld.piaoquan.api.model.bo.ReplyBucketData;
+
+public interface CgiReplyService {
+    ReplyBucketData getRgiReplyData(BucketDataParam bucketDataParam);
+
+}

+ 87 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/impl/CgiReplyServiceImpl.java

@@ -0,0 +1,87 @@
+package com.tzld.piaoquan.api.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.tzld.piaoquan.growth.common.common.enums.GhTypeEnum;
+import com.tzld.piaoquan.api.common.enums.ReplyStrategyServiceEnum;
+import com.tzld.piaoquan.growth.common.dao.mapper.GhDetailMapper;
+import com.tzld.piaoquan.api.model.bo.BucketDataParam;
+import com.tzld.piaoquan.api.model.bo.ReplyBucketData;
+import com.tzld.piaoquan.growth.common.model.po.GhDetail;
+import com.tzld.piaoquan.growth.common.model.po.GhDetailExample;
+import com.tzld.piaoquan.api.service.CgiReplyService;
+import com.tzld.piaoquan.api.service.strategy.ReplyStrategyService;
+import com.tzld.piaoquan.growth.common.utils.LarkRobotUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.PostConstruct;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+@Service
+public class CgiReplyServiceImpl implements CgiReplyService {
+
+    @Autowired
+    private ApplicationContext applicationContext;
+
+    private Map<String, ReplyStrategyService> strategyServiceMap;
+
+    @Autowired
+    private GhDetailMapper ghDetailMapper;
+
+    @PostConstruct
+    public void init() {
+        strategyServiceMap = applicationContext.getBeansOfType(ReplyStrategyService.class);
+    }
+
+
+    @Override
+    public ReplyBucketData getRgiReplyData(BucketDataParam bucketDataParam) {
+        String ghId = bucketDataParam.getGhId();
+        GhDetailExample example = new GhDetailExample();
+        example.createCriteria().andGhIdEqualTo(ghId);
+        List<GhDetail> ghDetails = ghDetailMapper.selectByExample(example);
+        if (CollectionUtils.isEmpty(ghDetails)) {
+            LarkRobotUtil.sendMessage("公众号信息查询失败 ghId=" + ghId);
+            return null;
+        }
+        GhDetail ghDetail = ghDetails.get(0);
+        if (Objects.equals(ghDetail.getType(), GhTypeEnum.THIRD_PARTY_GH.type)) {
+            bucketDataParam.setChannel(ghDetail.getChannel());
+            bucketDataParam.setStrategyStatus(ghDetail.getStrategyStatus());
+            if (StringUtils.isNotEmpty(ghDetail.getVideoIds())) {
+                bucketDataParam.setVideos(JSONArray.parseArray(ghDetail.getVideoIds(), Long.class));
+            }
+            return getPushMessageData(bucketDataParam);
+        }
+        return getRgiBucketData(bucketDataParam);
+    }
+
+    private ReplyBucketData getRgiBucketData(BucketDataParam bucketDataParam) {
+        for (Map.Entry<String, ReplyStrategyService> stringReplyStrategyServiceEntry : strategyServiceMap.entrySet()) {
+            ReplyStrategyService replyStrategyService = stringReplyStrategyServiceEntry.getValue();
+            // 使用策略层
+            if (replyStrategyService.support(ReplyStrategyServiceEnum.BUCKET_STRATEGY_V1)) {
+                return replyStrategyService.getResult(bucketDataParam);
+            }
+        }
+        // 无执行策略 不会走到这里
+        return null;
+    }
+
+    private ReplyBucketData getPushMessageData(BucketDataParam bucketDataParam) {
+        for (Map.Entry<String, ReplyStrategyService> stringReplyStrategyServiceEntry : strategyServiceMap.entrySet()) {
+            ReplyStrategyService replyStrategyService = stringReplyStrategyServiceEntry.getValue();
+            // 使用策略层
+            if (replyStrategyService.support(ReplyStrategyServiceEnum.THIRD_PARTY_PUSH_MESSAGE_STRATEGY_V1)) {
+                return replyStrategyService.getResult(bucketDataParam);
+            }
+        }
+        // 无执行策略 不会走到这里
+        return null;
+    }
+}

+ 5 - 5
api-module/src/main/java/com/tzld/piaoquan/api/service/impl/GhDetailServiceImpl.java

@@ -1,11 +1,11 @@
 package com.tzld.piaoquan.api.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
-import com.tzld.piaoquan.api.common.enums.GhTypeEnum;
-import com.tzld.piaoquan.api.common.enums.StrategyStatusEnum;
-import com.tzld.piaoquan.api.dao.mapper.GhDetailMapper;
-import com.tzld.piaoquan.api.model.po.GhDetail;
-import com.tzld.piaoquan.api.model.po.GhDetailExample;
+import com.tzld.piaoquan.growth.common.common.enums.GhTypeEnum;
+import com.tzld.piaoquan.growth.common.common.enums.StrategyStatusEnum;
+import com.tzld.piaoquan.growth.common.dao.mapper.GhDetailMapper;
+import com.tzld.piaoquan.growth.common.model.po.GhDetail;
+import com.tzld.piaoquan.growth.common.model.po.GhDetailExample;
 import com.tzld.piaoquan.api.model.vo.GhDetailVo;
 import com.tzld.piaoquan.api.service.GhDetailService;
 import com.tzld.piaoquan.growth.common.common.base.CommonResponse;

+ 10 - 4
api-module/src/main/java/com/tzld/piaoquan/api/service/impl/ThirdPartyServiceImpl.java

@@ -3,13 +3,13 @@ package com.tzld.piaoquan.api.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.aliyun.odps.data.Record;
-import com.tzld.piaoquan.api.common.enums.GhTypeEnum;
+import com.tzld.piaoquan.growth.common.common.enums.GhTypeEnum;
 import com.tzld.piaoquan.api.common.enums.ReplyStrategyServiceEnum;
 import com.tzld.piaoquan.api.common.enums.SecretEnum;
-import com.tzld.piaoquan.api.dao.mapper.GhDetailMapper;
+import com.tzld.piaoquan.growth.common.dao.mapper.GhDetailMapper;
 import com.tzld.piaoquan.api.model.bo.*;
-import com.tzld.piaoquan.api.model.po.GhDetail;
-import com.tzld.piaoquan.api.model.po.GhDetailExample;
+import com.tzld.piaoquan.growth.common.model.po.GhDetail;
+import com.tzld.piaoquan.growth.common.model.po.GhDetailExample;
 import com.tzld.piaoquan.api.model.vo.PushMessageParam;
 import com.tzld.piaoquan.api.model.vo.PushMessageVo;
 import com.tzld.piaoquan.api.model.vo.ReportUvVo;
@@ -146,6 +146,12 @@ public class ThirdPartyServiceImpl implements ThirdPartyService {
             }
         }
 
+        //博虎UV需要去重
+        if (secretEnum == SecretEnum.SECRET_ENUM_10) {
+            List<ReportUvVo> res = new ArrayList<>();
+            return CommonResponse.success(res);
+        }
+
         //10点后可查询前一天数据
         long nowTimestamp = System.currentTimeMillis() / 1000;
         long limitTime = nowTimestamp - 34L * TimeConstant.HOUR;

+ 11 - 3
api-module/src/main/java/com/tzld/piaoquan/api/service/impl/WeComServiceImpl.java

@@ -58,7 +58,7 @@ public class WeComServiceImpl implements WeComService {
         }
         List<WeComPushMessageVo> res = new ArrayList<>();
         ReplyBucketData replyBucketData = getPushMessageData(param);
-        if(replyBucketData == null){
+        if (replyBucketData == null) {
             return CommonResponse.create(500, "数据异常");
         }
         List<GroupData> groupList = replyBucketData.getGroupList();
@@ -72,7 +72,8 @@ public class WeComServiceImpl implements WeComService {
         if (CollectionUtils.isEmpty(replyStaffs)) {
             return CommonResponse.create(ExceptionCodeEnum.PARAMS_ERROR, "用户查询不到");
         }
-        String name = replyStaffs.get(0).getName();
+        ReplyStaff replyStaff = replyStaffs.get(0);
+        String name = replyStaff.getName();
         for (GroupData groupData : groupList) {
             if (CollectionUtils.isEmpty(groupData.getMsgDataList())) {
                 continue;
@@ -88,7 +89,14 @@ public class WeComServiceImpl implements WeComService {
             }
             MsgData msgData = new MsgData();
             msgData.setMsgType(3);
-            msgData.setTitle(String.format("很高兴认识您!我是%s,每天给您推荐精彩视频~", name));
+            if (replyStaff.getId() == 1) {
+                msgData.setTitle("你好呀~我是智能助手芳华,专门陪您唠唠嗑、解解闷的!\uD83C\uDF39\n" +
+                        "刚发现好多有趣视频想分享给您!偷偷告诉我——您平时最爱看【健康养生】、【历史故事】这类知识干货,还是【人生智慧】【怀旧经典】这些暖心内容呀?\n" +
+                        "(悄悄加个选项\uD83D\uDC49【祝福音乐】\uD83C\uDFB5,马上帮您找!)");
+            } else {
+                msgData.setTitle(String.format("很高兴认识您!我是%s,每天给您推荐精彩视频~", name));
+            }
+
             msgDataList.add(0, msgData);
             weComPushMessageVo.setMsgDataList(msgDataList);
             res.add(weComPushMessageVo);

+ 310 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/BuckStrategyV1.java

@@ -0,0 +1,310 @@
+package com.tzld.piaoquan.api.service.strategy.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.piaoquan.api.common.enums.ReplyStrategyServiceEnum;
+import com.tzld.piaoquan.api.component.TouLiuHttpClient;
+import com.tzld.piaoquan.api.dao.mapper.AlgGhAutoreplyVideoRankDataMapper;
+import com.tzld.piaoquan.growth.common.dao.mapper.CgiReplyBucketDataMapper;
+import com.tzld.piaoquan.growth.common.dao.mapper.GhDetailMapper;
+import com.tzld.piaoquan.api.model.bo.*;
+import com.tzld.piaoquan.api.model.po.AlgGhAutoreplyVideoRankData;
+import com.tzld.piaoquan.api.model.po.AlgGhAutoreplyVideoRankDataExample;
+import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
+import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketDataExample;
+import com.tzld.piaoquan.api.service.strategy.ReplyStrategyService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+public class BuckStrategyV1 implements ReplyStrategyService {
+
+    /**
+     * 实验分桶数量
+     */
+//    private static final Integer bucketNum = 10;
+
+    /**
+     * 分桶实验策略,key为策略,arr为对应桶
+     * {"base":[0,1,2,3],"stg0909-base":[4,5],"stg0909-explore1":[6,7,8],"stg0909-explore2":[9]}
+     * {"stg0909-base":[5,6],"stg0909-explore1":[7],"stg0909-explore2":[8,9]}
+     */
+    private static final String bucketStrategyConfig = "{\"stg0909-base\":[5,6],\"stg0909-explore1\":[7],\"stg0909-explore2\":[8,9]}";
+
+    @Value("${bucketStrategyConfig:{}}")
+    private String bucketStrategyConfigV2;
+
+    /**
+     * 自动回复使用小程序Id
+     */
+    private static final String SMALL_APP_Id = "wxbdd2a2e93d9a6e25";
+
+    private static final String CDN_URL = "https://rescdn.piaoquantv.com/";
+
+    @Value("${small_page_url}")
+    private String GET_SMALL_PAGE_URL;
+
+    @Autowired
+    private AlgGhAutoreplyVideoRankDataMapper algGhAutoreplyVideoRankDataMapper;
+    @Autowired
+    private CgiReplyBucketDataMapper cgiReplyBucketDataMapper;
+    @Autowired
+    private TouLiuHttpClient touLiuHttpClient;
+    @Autowired
+    private GhDetailMapper ghDetailMapper;
+
+    @Override
+    public ReplyBucketData getResult(BucketDataParam bucketDataParam) {
+        // 0 获取策略key
+        JSONObject bucketStrategyConfigJsonObject = getStrategyConfig(bucketDataParam.getGhId());
+        Set<String> keyedSet = bucketStrategyConfigJsonObject.keySet();
+        // 1 处理文章--算法引擎--排序文章数据
+//        getWenzhangData();
+        // 2 处理小程序--读取离线数据表--获取策略排序小程序数据
+        List<CgiReplyBucketData> smallDataCgiReplyList = readStrategyOrderSmallData(keyedSet, bucketDataParam);
+        // 2.1 获取小程序落地页地址 http调用
+        smallDataCgiReplyList = setSmallPageUrl(smallDataCgiReplyList);
+        log.info(JSON.toJSONString(smallDataCgiReplyList));
+        // 3 入库读表
+        insertSmallData(smallDataCgiReplyList, keyedSet);
+        // 4 组装分桶数据
+        return getReplyBucketData(bucketStrategyConfigJsonObject, keyedSet, bucketDataParam.getGhId());
+    }
+
+    private JSONObject getStrategyConfig(String ghId) {
+        JSONObject allStrategyConfigs = JSON.parseObject(bucketStrategyConfigV2);
+        JSONObject currentGhIdStrategyConfig = null;
+        if (allStrategyConfigs.containsKey(ghId)) {
+            currentGhIdStrategyConfig = allStrategyConfigs.getJSONObject(ghId);
+        } else if (allStrategyConfigs.containsKey("default")) {
+            currentGhIdStrategyConfig = allStrategyConfigs.getJSONObject("default");
+        } else {
+            log.error("invalid strategy config: default key does not exist");
+            throw new RuntimeException("Default strategy config does not exist");
+        }
+        // check param
+        if (!currentGhIdStrategyConfig.containsKey("base")) {
+            throw new RuntimeException("Strategy config does not have manual base");
+        }
+        return currentGhIdStrategyConfig;
+    }
+
+    private ReplyBucketData getReplyBucketData(JSONObject bucketStrategyConfigJsonObject, Set<String> keyedSet, String ghId) {
+        // 策略小程序数据
+        ReplyBucketData replyBucketData = new ReplyBucketData();
+        List<GroupData> groupDataList = new ArrayList<>();
+        for (String key : keyedSet) {
+            if ("base".equals(key)) {
+                continue;
+            }
+            CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
+            cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andStrategyEqualTo(key).andGhIdEqualTo(ghId);
+            cgiReplyBucketDataExample.setOrderByClause("sort");
+            List<CgiReplyBucketData> cgiReplyBucketData = cgiReplyBucketDataMapper.selectByExample(cgiReplyBucketDataExample);
+            if (CollectionUtils.isEmpty(cgiReplyBucketData)) {
+                CgiReplyBucketDataExample cgiReplyBucketDataExampleNull = new CgiReplyBucketDataExample();
+                cgiReplyBucketDataExampleNull.createCriteria().andIsDeleteEqualTo(0).andStrategyEqualTo(key).andGhIdEqualTo("default");
+                cgiReplyBucketDataExampleNull.setOrderByClause("sort");
+                cgiReplyBucketData = cgiReplyBucketDataMapper.selectByExample(cgiReplyBucketDataExampleNull);
+            }
+            if (CollectionUtils.isEmpty(cgiReplyBucketData)) {
+                log.error("getReplyBucketData get data is null,key:" + key);
+                return null;
+            }
+
+            List<Integer> groupList = bucketStrategyConfigJsonObject.getJSONArray(key).toJavaList(Integer.class);
+            for (Integer group : groupList) {
+                GroupData groupData = new GroupData();
+                groupData.setGroupIndex(group);
+                List<MsgData> msgDataList = new ArrayList<>();
+                for (CgiReplyBucketData cgiReplyBucketDatum : cgiReplyBucketData) {
+                    MsgData msgData = new MsgData();
+                    BeanUtils.copyProperties(cgiReplyBucketDatum, msgData);
+                    if (cgiReplyBucketDatum.getMsgType().equals(1)) {
+                        msgData.setMiniAppId(SMALL_APP_Id);
+                    }
+                    msgDataList.add(msgData);
+                }
+                groupData.setMsgDataList(msgDataList);
+                groupDataList.add(groupData);
+            }
+        }
+        // 获取人工实验数据
+        List<GroupData> groupDataBaseList = touLiuHttpClient.sendPenGongBaseRequest(ghId);
+        if (!CollectionUtils.isEmpty(groupDataBaseList)) {
+            int baseBucketNum = bucketStrategyConfigJsonObject.getJSONArray("base").size();
+            if (groupDataBaseList.size() > baseBucketNum) {
+                groupDataBaseList = groupDataBaseList.subList(0, baseBucketNum);
+            }
+            if (!CollectionUtils.isEmpty(groupDataBaseList)) {
+                GroupData groupData = groupDataBaseList.get(0);
+                List<MsgData> msgDataList = groupData.getMsgDataList();
+                List<MsgData> changwenBase = msgDataList.stream().filter(x -> x.getMsgType().equals(2)).collect(Collectors.toList());
+                if (CollectionUtils.isEmpty(changwenBase)) {
+                    log.error("get base changwenBase is null,data:" + JSON.toJSONString(msgDataList));
+                } else {
+                    // 策略拼接base数据
+                    for (GroupData data : groupDataList) {
+                        List<MsgData> msgDataList1 = data.getMsgDataList();
+                        MsgData msgData = changwenBase.get(0);
+//                    msgData.setSort(3);
+                        msgDataList1.add(msgData);
+                    }
+                }
+                // 补充人工数据
+                groupDataList.addAll(groupDataBaseList);
+            } else {
+                log.error("get base data is null,ghId:" + ghId);
+            }
+        }
+        // groupDataList排序
+        replyBucketData.setGroupList(groupDataList.stream().sorted(Comparator.comparingInt(GroupData::getGroupIndex)).collect(Collectors.toList()));
+        return replyBucketData;
+    }
+
+
+    private void insertSmallData(List<CgiReplyBucketData> smallDataCgiReplyList, Set<String> keyedSet) {
+        if (CollectionUtils.isEmpty(smallDataCgiReplyList)) {
+            return;
+        }
+        for (String key : keyedSet) {
+            if ("base".equals(key)) {
+                continue;
+            }
+            List<CgiReplyBucketData> collect = smallDataCgiReplyList.stream().filter(x -> x.getStrategy().equals(key)).collect(Collectors.toList());
+            if (CollectionUtils.isEmpty(collect)) {
+                log.error("insertSmallData 算法排序数据异常,data:" + JSON.toJSONString(smallDataCgiReplyList));
+                continue;
+            }
+            // 清上个版本的策略数据
+            CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
+            cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andMsgTypeEqualTo(1).andStrategyEqualTo(key);
+            List<CgiReplyBucketData> cgiReplyBucketData1 = cgiReplyBucketDataMapper.selectByExample(cgiReplyBucketDataExample);
+            for (CgiReplyBucketData cgiReplyBucketData : cgiReplyBucketData1) {
+                cgiReplyBucketData.setIsDelete(1);
+                cgiReplyBucketDataMapper.updateByPrimaryKeySelective(cgiReplyBucketData);
+            }
+            // 入库
+            for (CgiReplyBucketData cgiReplyBucketData : collect) {
+                cgiReplyBucketDataMapper.insertSelective(cgiReplyBucketData);
+            }
+        }
+    }
+
+    private List<CgiReplyBucketData> setSmallPageUrl(List<CgiReplyBucketData> smallDataCgiReplyList) {
+        if (CollectionUtils.isEmpty(smallDataCgiReplyList)) {
+            return smallDataCgiReplyList;
+        }
+        Set<String> keys = smallDataCgiReplyList.stream().map(x -> x.getGhId() + "&" + x.getMiniVideoId() + "&" + x.getSort()).collect(Collectors.toSet());
+        Map<String, SmallPageUrlDetail> keyPageUrl = new HashMap<>();
+        // gh-id + videoId + sort 复用同一page_url及落地页id
+        for (String key : keys) {
+            String[] keyArr = key.split("&");
+            String ghId = keyArr[0];
+            String videoId = keyArr[1];
+            String sort = keyArr[2];
+            // 查询库里是否存在,如果存在即复用
+            CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
+            cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andMiniVideoIdEqualTo(Long.valueOf(videoId)).andGhIdEqualTo(ghId);
+            List<CgiReplyBucketData> cgiReplyBucketData = cgiReplyBucketDataMapper.selectByExample(cgiReplyBucketDataExample);
+            SmallPageUrlDetail smallPageUrlDetail = new SmallPageUrlDetail();
+            if (CollectionUtils.isEmpty(cgiReplyBucketData)) {
+                // 库里不存在,调用新生成
+                String putScene = "touliu";
+                String channel = "tencentgzh";
+                String response = touLiuHttpClient.sendAdFlowAddRequest(GET_SMALL_PAGE_URL, videoId, putScene, channel, "自动", "公众号", "自动回复小程序", "位置" + sort, ghId);
+                JSONObject jsonObject = JSON.parseObject(response);
+                if (jsonObject.getInteger("code").equals(0)) {
+                    smallPageUrlDetail = jsonObject.getObject("data", SmallPageUrlDetail.class);
+                    keyPageUrl.put(key, smallPageUrlDetail);
+                } else {
+                    log.error("httpClientService get page url error,response:" + response);
+                    throw new RuntimeException("httpClientService get page url error");
+                }
+            } else {
+                // 复用
+                CgiReplyBucketData cgiReplyBucketData1 = cgiReplyBucketData.get(0);
+                smallPageUrlDetail.setId(cgiReplyBucketData1.getPagePathUrlId());
+                smallPageUrlDetail.setUrl(cgiReplyBucketData1.getMiniPagePath());
+            }
+            keyPageUrl.put(key, smallPageUrlDetail);
+        }
+        // 处理数据
+        for (CgiReplyBucketData cgiReplyBucketData : smallDataCgiReplyList) {
+            String key = cgiReplyBucketData.getGhId() + "&" + cgiReplyBucketData.getMiniVideoId() + "&" + cgiReplyBucketData.getSort();
+            SmallPageUrlDetail smallPageUrlDetail = keyPageUrl.get(key);
+            if (Objects.isNull(smallPageUrlDetail)) {
+                log.error("setSmallPageUrl get map url is null" + JSON.toJSONString(keyPageUrl));
+                throw new RuntimeException("setSmallPageUrl get map url is null");
+            }
+            cgiReplyBucketData.setPagePathUrlId(smallPageUrlDetail.getId());
+            cgiReplyBucketData.setMiniPagePath(smallPageUrlDetail.getUrl());
+        }
+        return smallDataCgiReplyList;
+    }
+
+
+    private List<CgiReplyBucketData> readStrategyOrderSmallData(Set<String> keyedSet, BucketDataParam bucketDataParam) {
+        List<CgiReplyBucketData> result = new ArrayList<>();
+        for (String key : keyedSet) {
+            if ("base".equals(key)) {
+                // base作为人工控制
+                continue;
+            }
+            // 获取最新dt的策略
+            String dtVersion = algGhAutoreplyVideoRankDataMapper.selectLatestDtVersionByStrategyKey(key);
+            // 判断当前的dtVersion是否已经处理过了
+            CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
+            cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andStrategyDtEqualTo(dtVersion).andStrategyEqualTo(key);
+            long count = cgiReplyBucketDataMapper.countByExample(cgiReplyBucketDataExample);
+            if (count != 0) {
+                // 说明已处理过该dtVersion数据
+                continue;
+            }
+            // 获取最新dt数据
+            List<AlgGhAutoreplyVideoRankData> dtVersionStrategyData = getDtVersionStrategyData(key, dtVersion);
+            List<Long> videoIds = dtVersionStrategyData.stream().map(AlgGhAutoreplyVideoRankData::getVideoId).collect(Collectors.toList());
+            Map<Long, VideoDetail> videoDetailMap = touLiuHttpClient.getVideoDetailRequest(videoIds);
+            result.addAll(dtVersionStrategyData.stream().map(x -> {
+                CgiReplyBucketData cgiReplyBucketData = new CgiReplyBucketData();
+                cgiReplyBucketData.setStrategy(key);
+                cgiReplyBucketData.setSort(x.getSort());
+                cgiReplyBucketData.setStrategyDt(x.getDtVersion());
+                cgiReplyBucketData.setGhId(x.getGhId());
+                cgiReplyBucketData.setMsgType(1);
+                cgiReplyBucketData.setTitle(x.getTitle());
+                VideoDetail videoDetail = videoDetailMap.get(x.getVideoId());
+                if (videoDetail != null && StringUtils.isNotEmpty(videoDetail.getCover())) {
+                    cgiReplyBucketData.setCoverUrl(videoDetail.getCover());
+                } else {
+                    cgiReplyBucketData.setCoverUrl(CDN_URL + x.getCoverUrl());
+                }
+                cgiReplyBucketData.setMiniAppId(SMALL_APP_Id);
+                cgiReplyBucketData.setMiniVideoId(x.getVideoId());
+                return cgiReplyBucketData;
+            }).collect(Collectors.toList()));
+        }
+        // 获取最新数据版本
+        return CollectionUtils.isEmpty(result) ? null : result;
+    }
+
+    private List<AlgGhAutoreplyVideoRankData> getDtVersionStrategyData(String key, String dtVersion) {
+        AlgGhAutoreplyVideoRankDataExample algGhAutoreplyVideoRankDataExample = new AlgGhAutoreplyVideoRankDataExample();
+        algGhAutoreplyVideoRankDataExample.createCriteria().andIsDeleteEqualTo(0).andDtVersionEqualTo(dtVersion).andStrategyKeyEqualTo(key);
+        return algGhAutoreplyVideoRankDataMapper.selectByExample(algGhAutoreplyVideoRankDataExample);
+    }
+
+    @Override
+    public Boolean support(ReplyStrategyServiceEnum key) {
+        return ReplyStrategyServiceEnum.BUCKET_STRATEGY_V1.equals(key);
+    }
+}

+ 4 - 4
api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/ThirdPartyPushMessageStrategyV1.java

@@ -4,15 +4,15 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 
 import com.tzld.piaoquan.api.common.enums.ReplyStrategyServiceEnum;
-import com.tzld.piaoquan.api.common.enums.StrategyStatusEnum;
+import com.tzld.piaoquan.growth.common.common.enums.StrategyStatusEnum;
 import com.tzld.piaoquan.api.component.TouLiuHttpClient;
 import com.tzld.piaoquan.api.dao.mapper.AlgGhAutoreplyVideoRankDataMapper;
-import com.tzld.piaoquan.api.dao.mapper.CgiReplyBucketDataMapper;
+import com.tzld.piaoquan.growth.common.dao.mapper.CgiReplyBucketDataMapper;
 import com.tzld.piaoquan.api.model.bo.*;
 import com.tzld.piaoquan.api.model.po.AlgGhAutoreplyVideoRankData;
 import com.tzld.piaoquan.api.model.po.AlgGhAutoreplyVideoRankDataExample;
-import com.tzld.piaoquan.api.model.po.CgiReplyBucketData;
-import com.tzld.piaoquan.api.model.po.CgiReplyBucketDataExample;
+import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
+import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketDataExample;
 import com.tzld.piaoquan.api.service.strategy.ReplyStrategyService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;

+ 3 - 3
api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/WeComPushMessageStrategyV1.java

@@ -5,12 +5,12 @@ import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.api.common.enums.ReplyStrategyServiceEnum;
 import com.tzld.piaoquan.api.component.TouLiuHttpClient;
 import com.tzld.piaoquan.api.dao.mapper.AlgGhAutoreplyVideoRankDataMapper;
-import com.tzld.piaoquan.api.dao.mapper.CgiReplyBucketDataMapper;
+import com.tzld.piaoquan.growth.common.dao.mapper.CgiReplyBucketDataMapper;
 import com.tzld.piaoquan.api.model.bo.*;
 import com.tzld.piaoquan.api.model.po.AlgGhAutoreplyVideoRankData;
 import com.tzld.piaoquan.api.model.po.AlgGhAutoreplyVideoRankDataExample;
-import com.tzld.piaoquan.api.model.po.CgiReplyBucketData;
-import com.tzld.piaoquan.api.model.po.CgiReplyBucketDataExample;
+import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
+import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketDataExample;
 import com.tzld.piaoquan.api.service.strategy.ReplyStrategyService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;

+ 1 - 0
api-module/src/main/resources/application-prod.properties

@@ -14,5 +14,6 @@ pushMessage.callback.topic=3rd_party_push_message_callback_prod
 pushMessage.callback.groupId=GID_3RD_PARTY_PUSH_MESSAGE_CALLBACK_PROD
 pushMessage.callback.tag=mini
 
+apollo.meta: http://apolloconfig-internal.piaoquantv.com
 
 

+ 5 - 3
api-module/src/main/resources/application-test.properties

@@ -12,6 +12,8 @@ xxl.job.admin.addresses=http://xxl-job-test-internal.piaoquantv.com/xxl-job-admi
 
 small_page_url=https://testapi.piaoquantv.com
 
-pushMessage.callback.topic=3rd_party_push_message_callback_prod
-pushMessage.callback.groupId=GID_3RD_PARTY_PUSH_MESSAGE_CALLBACK_PROD
-pushMessage.callback.tag=mini
+pushMessage.callback.topic=3rd_party_push_message_callback_dev
+pushMessage.callback.groupId=GID_3RD_PARTY_PUSH_MESSAGE_CALLBACK_DEV
+pushMessage.callback.tag=mini
+
+apollo.meta: http://apolloconfig-internal.piaoquantv.com

+ 4 - 0
api-module/src/main/resources/application.properties

@@ -39,3 +39,7 @@ rocketmq.secretKey=nEbq3xWNQd1qLpdy2u71qFweHkZjSG
 rocketmq.nameSrvAddr=http://MQ_INST_1894469520484605_BXhXuzkZ.mq-internet-access.mq-internet.aliyuncs.com:80
 
 
+app.id=growth-manager
+apollo.bootstrap.enabled=true
+apollo.bootstrap.namespaces=application
+apollo.cacheDir=/datalog/apollo-cache-dir

+ 1 - 1
api-module/src/main/resources/mybatis-generator-config.xml

@@ -55,7 +55,7 @@
 <!--        <table tableName="we_com_guarantees_video" domainObjectName="GuaranteesVideo" alias=""/>-->
 <!--        <table tableName="we_com_staff" domainObjectName="Staff" alias=""/>-->
 <!--        <table tableName="we_com_message_attachment" domainObjectName="MessageAttachment" alias=""/>-->
-        <table tableName="we_com_attachment_with_msg_result" domainObjectName="AttachmentWithMsgResult" alias=""/>
+        <table tableName="we_com_user_count" domainObjectName="UserCount" alias=""/>
 <!--        <table tableName="we_com_send_msg_result" domainObjectName="SendMsgResult" alias=""/>-->
 <!--        <table tableName="we_com_corp" domainObjectName="Corp" alias=""/>-->
 

+ 28 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/common/enums/FieshuTableColumnDataTypeEnum.java

@@ -0,0 +1,28 @@
+package com.tzld.piaoquan.growth.common.common.enums;
+
+import lombok.Getter;
+
+@Getter
+public enum FieshuTableColumnDataTypeEnum {
+    TEXT("text"),
+    LARK_MD("lark_md"),
+    NUMBER("number"),
+    DATE("date"),
+    OPTIONS("options"),
+    ;
+
+    private String type;
+
+    FieshuTableColumnDataTypeEnum(String type) {
+        this.type = type;
+    }
+
+    public static FieshuTableColumnDataTypeEnum from(String type) {
+        for (FieshuTableColumnDataTypeEnum typeEnum : FieshuTableColumnDataTypeEnum.values()) {
+            if (typeEnum.getType().equals(type)) {
+                return typeEnum;
+            }
+        }
+        return null;
+    }
+}

+ 1 - 1
api-module/src/main/java/com/tzld/piaoquan/api/common/enums/GhTypeEnum.java → common-module/src/main/java/com/tzld/piaoquan/growth/common/common/enums/GhTypeEnum.java

@@ -1,4 +1,4 @@
-package com.tzld.piaoquan.api.common.enums;
+package com.tzld.piaoquan.growth.common.common.enums;
 
 import java.util.Objects;
 

+ 1 - 1
api-module/src/main/java/com/tzld/piaoquan/api/common/enums/StrategyStatusEnum.java → common-module/src/main/java/com/tzld/piaoquan/growth/common/common/enums/StrategyStatusEnum.java

@@ -1,4 +1,4 @@
-package com.tzld.piaoquan.api.common.enums;
+package com.tzld.piaoquan.growth.common.common.enums;
 
 import java.util.Objects;
 

+ 3 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/AttachmentWithMsgResultMapper.java

@@ -4,6 +4,7 @@ import com.tzld.piaoquan.growth.common.model.po.AttachmentWithMsgResult;
 import com.tzld.piaoquan.growth.common.model.po.AttachmentWithMsgResultExample;
 import java.util.List;
 
+import com.tzld.piaoquan.growth.common.model.po.HistoryMessage;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
@@ -32,4 +33,6 @@ public interface AttachmentWithMsgResultMapper {
     int updateByPrimaryKeySelective(AttachmentWithMsgResult record);
 
     int updateByPrimaryKey(AttachmentWithMsgResult record);
+
+    void insertList(@Param("list") List<AttachmentWithMsgResult> list);
 }

+ 6 - 3
api-module/src/main/java/com/tzld/piaoquan/api/dao/mapper/CgiReplyBucketDataMapper.java → common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/CgiReplyBucketDataMapper.java

@@ -1,12 +1,13 @@
-package com.tzld.piaoquan.api.dao.mapper;
+package com.tzld.piaoquan.growth.common.dao.mapper;
 
 
-import com.tzld.piaoquan.api.model.po.CgiReplyBucketData;
-import com.tzld.piaoquan.api.model.po.CgiReplyBucketDataExample;
+import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
+import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketDataExample;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+
 @Mapper
 public interface CgiReplyBucketDataMapper {
     long countByExample(CgiReplyBucketDataExample example);
@@ -30,4 +31,6 @@ public interface CgiReplyBucketDataMapper {
     int updateByPrimaryKeySelective(CgiReplyBucketData row);
 
     int updateByPrimaryKey(CgiReplyBucketData row);
+
+    List<Long> selectVideoId();
 }

+ 10 - 4
api-module/src/main/java/com/tzld/piaoquan/api/dao/mapper/GhDetailMapper.java → common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/GhDetailMapper.java

@@ -1,10 +1,16 @@
-package com.tzld.piaoquan.api.dao.mapper;
+package com.tzld.piaoquan.growth.common.dao.mapper;
 
-import com.tzld.piaoquan.api.model.po.GhDetail;
-import com.tzld.piaoquan.api.model.po.GhDetailExample;
-import java.util.List;
+
+import com.tzld.piaoquan.growth.common.model.po.GhDetail;
+import com.tzld.piaoquan.growth.common.model.po.GhDetailExample;
+import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
 
+@Mapper
+@Repository
 public interface GhDetailMapper {
     long countByExample(GhDetailExample example);
 

+ 35 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/UserCountMapper.java

@@ -0,0 +1,35 @@
+package com.tzld.piaoquan.growth.common.dao.mapper;
+
+import com.tzld.piaoquan.growth.common.model.po.UserCount;
+import com.tzld.piaoquan.growth.common.model.po.UserCountExample;
+import java.util.List;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface UserCountMapper {
+    long countByExample(UserCountExample example);
+
+    int deleteByExample(UserCountExample example);
+
+    int deleteByPrimaryKey(Long id);
+
+    int insert(UserCount record);
+
+    int insertSelective(UserCount record);
+
+    List<UserCount> selectByExample(UserCountExample example);
+
+    UserCount selectByPrimaryKey(Long id);
+
+    int updateByExampleSelective(@Param("record") UserCount record, @Param("example") UserCountExample example);
+
+    int updateByExample(@Param("record") UserCount record, @Param("example") UserCountExample example);
+
+    int updateByPrimaryKeySelective(UserCount record);
+
+    int updateByPrimaryKey(UserCount record);
+}

+ 148 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/model/bo/FeishuTableDTO.java

@@ -0,0 +1,148 @@
+package com.tzld.piaoquan.growth.common.model.bo;
+
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.piaoquan.growth.common.common.enums.FieshuTableColumnDataTypeEnum;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class FeishuTableDTO {
+    private Header header;
+    private List<Element> elements;
+
+    @Data
+    public static class Element {
+        private String tag;
+        private JSONObject text;
+        private long page_size;
+        private String row_height;
+        private HeaderStyle header_style;
+        private List<Column> columns;
+        private List<JSONObject> rows;
+    }
+
+    @Data
+    public static class Column {
+        private String name;
+        private String display_name;
+        private String data_type;
+        private String horizontal_align;
+        private String vertical_align;
+        private String width;
+        private String format;
+        private String dateFormat;
+    }
+
+    @Data
+    public static class HeaderStyle {
+        private String text_align;
+        private String text_size;
+        private String background_style;
+        private String text_color;
+        private boolean bold;
+        private long lines;
+    }
+
+    @Data
+    public static class Header {
+        private String template;
+        private Title title;
+    }
+
+    @Data
+    public static class Title {
+        private String content;
+        private String tag;
+    }
+
+    public static FeishuTableDTO createTable(String title, List<Column> columns, List<JSONObject> rows, boolean atAll) {
+        String tableStr = "{\n" +
+                "    \"header\":\n" +
+                "    {\n" +
+                "        \"template\": \"blue\",\n" +
+                "        \"title\":\n" +
+                "        {\n" +
+                "            \"content\": \"" + title + "\",\n " +
+                "            \"tag\": \"plain_text\"\n" +
+                "        }\n" +
+                "    },\n" +
+                "    \"elements\":\n" +
+                "    [\n" +
+                "        {\n" +
+                "            \"tag\": \"table\",\n" +
+                "            \"page_size\": " + rows.size() + ",\n" +
+                "            \"row_height\": \"low\",\n" +
+                "            \"header_style\":\n" +
+                "            {\n" +
+                "                \"text_align\": \"left\",\n" +
+                "                \"text_size\": \"normal\",\n" +
+                "                \"background_style\": \"none\",\n" +
+                "                \"text_color\": \"grey\",\n" +
+                "                \"bold\": true,\n" +
+                "                \"lines\": 1\n" +
+                "            },\n" +
+                "            \"columns\":\n" +
+                JSONObject.toJSONString(columns) +
+                "            ,\n" +
+                "            \"rows\":\n" +
+                JSONObject.toJSONString(rows) +
+                "        }\n" +
+                "    ]\n" +
+                "}";
+        FeishuTableDTO result =  JSONObject.parseObject(tableStr, FeishuTableDTO.class);
+        if (atAll) {
+            FeishuTableDTO.Element atAllElement = new FeishuTableDTO.Element();
+            atAllElement.setTag("div");
+            JSONObject atAllElementText = new JSONObject();
+            atAllElementText.put("content", "<at id=all></at>");
+            atAllElementText.put("tag", "lark_md");
+            atAllElement.setText(atAllElementText);
+            result.getElements().add(atAllElement);
+        }
+        return result;
+    }
+
+    public static Column createFeishuColumns(
+            String dataType,
+            String columnName,
+            String displayName,
+            String numberFormat) {
+
+        String width = "auto";
+        String verticalAlign = "top";
+        String horizontalAlign = "left";
+        Column column = new Column();
+
+        if (FieshuTableColumnDataTypeEnum.TEXT.getType().equals(dataType)) {
+            column.setName(columnName);
+            column.setDisplay_name(displayName);
+            column.setWidth(width);
+            column.setData_type(dataType);
+            column.setVertical_align(verticalAlign);
+            column.setHorizontal_align(horizontalAlign);
+        } else if (FieshuTableColumnDataTypeEnum.LARK_MD.getType().equals(dataType)) {
+            column.setName(columnName);
+            column.setDisplay_name(displayName);
+            column.setData_type(dataType);
+        } else if (FieshuTableColumnDataTypeEnum.NUMBER.getType().equals(dataType)) {
+            column.setName(columnName);
+            column.setDisplay_name(displayName);
+            column.setData_type(dataType);
+            column.setFormat(numberFormat);
+            column.setWidth(width);
+        } else if (FieshuTableColumnDataTypeEnum.DATE.getType().equals(dataType)) {
+            column.setName(columnName);
+            column.setDisplay_name(displayName);
+            column.setData_type(dataType);
+            column.setDateFormat("YYYY/MM/DD");
+        } else if (FieshuTableColumnDataTypeEnum.OPTIONS.getType().equals(dataType)) {
+            column.setName(columnName);
+            column.setDisplay_name(displayName);
+            column.setData_type(dataType);
+        }
+
+        return column;
+    }
+}
+

+ 1 - 1
api-module/src/main/java/com/tzld/piaoquan/api/model/po/CgiReplyBucketData.java → common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/CgiReplyBucketData.java

@@ -1,4 +1,4 @@
-package com.tzld.piaoquan.api.model.po;
+package com.tzld.piaoquan.growth.common.model.po;
 
 import java.util.Date;
 

+ 1 - 1
api-module/src/main/java/com/tzld/piaoquan/api/model/po/CgiReplyBucketDataExample.java → common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/CgiReplyBucketDataExample.java

@@ -1,4 +1,4 @@
-package com.tzld.piaoquan.api.model.po;
+package com.tzld.piaoquan.growth.common.model.po;
 
 import java.util.ArrayList;
 import java.util.Date;

+ 1 - 1
api-module/src/main/java/com/tzld/piaoquan/api/model/po/GhDetail.java → common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/GhDetail.java

@@ -1,4 +1,4 @@
-package com.tzld.piaoquan.api.model.po;
+package com.tzld.piaoquan.growth.common.model.po;
 
 import java.util.Date;
 

+ 1 - 1
api-module/src/main/java/com/tzld/piaoquan/api/model/po/GhDetailExample.java → common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/GhDetailExample.java

@@ -1,4 +1,4 @@
-package com.tzld.piaoquan.api.model.po;
+package com.tzld.piaoquan.growth.common.model.po;
 
 
 import com.tzld.piaoquan.growth.common.utils.page.Page;

+ 103 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/UserCount.java

@@ -0,0 +1,103 @@
+package com.tzld.piaoquan.growth.common.model.po;
+
+import java.util.Date;
+
+public class UserCount {
+    private Long id;
+
+    private Long staffId;
+
+    private String staffName;
+
+    private Integer allCount;
+
+    private Integer newCount;
+
+    private String date;
+
+    private Date createTime;
+
+    private Date updateTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getStaffId() {
+        return staffId;
+    }
+
+    public void setStaffId(Long staffId) {
+        this.staffId = staffId;
+    }
+
+    public String getStaffName() {
+        return staffName;
+    }
+
+    public void setStaffName(String staffName) {
+        this.staffName = staffName;
+    }
+
+    public Integer getAllCount() {
+        return allCount;
+    }
+
+    public void setAllCount(Integer allCount) {
+        this.allCount = allCount;
+    }
+
+    public Integer getNewCount() {
+        return newCount;
+    }
+
+    public void setNewCount(Integer newCount) {
+        this.newCount = newCount;
+    }
+
+    public String getDate() {
+        return date;
+    }
+
+    public void setDate(String date) {
+        this.date = date;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", staffId=").append(staffId);
+        sb.append(", staffName=").append(staffName);
+        sb.append(", allCount=").append(allCount);
+        sb.append(", newCount=").append(newCount);
+        sb.append(", date=").append(date);
+        sb.append(", createTime=").append(createTime);
+        sb.append(", updateTime=").append(updateTime);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 713 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/UserCountExample.java

@@ -0,0 +1,713 @@
+package com.tzld.piaoquan.growth.common.model.po;
+
+import com.tzld.piaoquan.growth.common.utils.page.Page;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class UserCountExample {
+    protected String orderByClause;
+
+    protected boolean distinct;
+
+    protected List<Criteria> oredCriteria;
+
+    protected Page page;
+
+    public UserCountExample() {
+        oredCriteria = new ArrayList<Criteria>();
+    }
+
+    public void setOrderByClause(String orderByClause) {
+        this.orderByClause = orderByClause;
+    }
+
+    public String getOrderByClause() {
+        return orderByClause;
+    }
+
+    public void setDistinct(boolean distinct) {
+        this.distinct = distinct;
+    }
+
+    public boolean isDistinct() {
+        return distinct;
+    }
+
+    public List<Criteria> getOredCriteria() {
+        return oredCriteria;
+    }
+
+    public void or(Criteria criteria) {
+        oredCriteria.add(criteria);
+    }
+
+    public Criteria or() {
+        Criteria criteria = createCriteriaInternal();
+        oredCriteria.add(criteria);
+        return criteria;
+    }
+
+    public Criteria createCriteria() {
+        Criteria criteria = createCriteriaInternal();
+        if (oredCriteria.size() == 0) {
+            oredCriteria.add(criteria);
+        }
+        return criteria;
+    }
+
+    protected Criteria createCriteriaInternal() {
+        Criteria criteria = new Criteria();
+        return criteria;
+    }
+
+    public void clear() {
+        oredCriteria.clear();
+        orderByClause = null;
+        distinct = false;
+    }
+
+    public void setPage(Page page) {
+        this.page=page;
+    }
+
+    public Page getPage() {
+        return page;
+    }
+
+    protected abstract static class GeneratedCriteria {
+        protected List<Criterion> criteria;
+
+        protected GeneratedCriteria() {
+            super();
+            criteria = new ArrayList<Criterion>();
+        }
+
+        public boolean isValid() {
+            return criteria.size() > 0;
+        }
+
+        public List<Criterion> getAllCriteria() {
+            return criteria;
+        }
+
+        public List<Criterion> getCriteria() {
+            return criteria;
+        }
+
+        protected void addCriterion(String condition) {
+            if (condition == null) {
+                throw new RuntimeException("Value for condition cannot be null");
+            }
+            criteria.add(new Criterion(condition));
+        }
+
+        protected void addCriterion(String condition, Object value, String property) {
+            if (value == null) {
+                throw new RuntimeException("Value for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value));
+        }
+
+        protected void addCriterion(String condition, Object value1, Object value2, String property) {
+            if (value1 == null || value2 == null) {
+                throw new RuntimeException("Between values for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value1, value2));
+        }
+
+        public Criteria andIdIsNull() {
+            addCriterion("id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIsNotNull() {
+            addCriterion("id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdEqualTo(Long value) {
+            addCriterion("id =", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotEqualTo(Long value) {
+            addCriterion("id <>", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThan(Long value) {
+            addCriterion("id >", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("id >=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThan(Long value) {
+            addCriterion("id <", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThanOrEqualTo(Long value) {
+            addCriterion("id <=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIn(List<Long> values) {
+            addCriterion("id in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotIn(List<Long> values) {
+            addCriterion("id not in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdBetween(Long value1, Long value2) {
+            addCriterion("id between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotBetween(Long value1, Long value2) {
+            addCriterion("id not between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdIsNull() {
+            addCriterion("staff_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdIsNotNull() {
+            addCriterion("staff_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdEqualTo(Long value) {
+            addCriterion("staff_id =", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdNotEqualTo(Long value) {
+            addCriterion("staff_id <>", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdGreaterThan(Long value) {
+            addCriterion("staff_id >", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("staff_id >=", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdLessThan(Long value) {
+            addCriterion("staff_id <", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdLessThanOrEqualTo(Long value) {
+            addCriterion("staff_id <=", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdIn(List<Long> values) {
+            addCriterion("staff_id in", values, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdNotIn(List<Long> values) {
+            addCriterion("staff_id not in", values, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdBetween(Long value1, Long value2) {
+            addCriterion("staff_id between", value1, value2, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdNotBetween(Long value1, Long value2) {
+            addCriterion("staff_id not between", value1, value2, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffNameIsNull() {
+            addCriterion("staff_name is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffNameIsNotNull() {
+            addCriterion("staff_name is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffNameEqualTo(String value) {
+            addCriterion("staff_name =", value, "staffName");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffNameNotEqualTo(String value) {
+            addCriterion("staff_name <>", value, "staffName");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffNameGreaterThan(String value) {
+            addCriterion("staff_name >", value, "staffName");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffNameGreaterThanOrEqualTo(String value) {
+            addCriterion("staff_name >=", value, "staffName");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffNameLessThan(String value) {
+            addCriterion("staff_name <", value, "staffName");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffNameLessThanOrEqualTo(String value) {
+            addCriterion("staff_name <=", value, "staffName");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffNameLike(String value) {
+            addCriterion("staff_name like", value, "staffName");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffNameNotLike(String value) {
+            addCriterion("staff_name not like", value, "staffName");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffNameIn(List<String> values) {
+            addCriterion("staff_name in", values, "staffName");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffNameNotIn(List<String> values) {
+            addCriterion("staff_name not in", values, "staffName");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffNameBetween(String value1, String value2) {
+            addCriterion("staff_name between", value1, value2, "staffName");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffNameNotBetween(String value1, String value2) {
+            addCriterion("staff_name not between", value1, value2, "staffName");
+            return (Criteria) this;
+        }
+
+        public Criteria andAllCountIsNull() {
+            addCriterion("all_count is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andAllCountIsNotNull() {
+            addCriterion("all_count is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andAllCountEqualTo(Integer value) {
+            addCriterion("all_count =", value, "allCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andAllCountNotEqualTo(Integer value) {
+            addCriterion("all_count <>", value, "allCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andAllCountGreaterThan(Integer value) {
+            addCriterion("all_count >", value, "allCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andAllCountGreaterThanOrEqualTo(Integer value) {
+            addCriterion("all_count >=", value, "allCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andAllCountLessThan(Integer value) {
+            addCriterion("all_count <", value, "allCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andAllCountLessThanOrEqualTo(Integer value) {
+            addCriterion("all_count <=", value, "allCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andAllCountIn(List<Integer> values) {
+            addCriterion("all_count in", values, "allCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andAllCountNotIn(List<Integer> values) {
+            addCriterion("all_count not in", values, "allCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andAllCountBetween(Integer value1, Integer value2) {
+            addCriterion("all_count between", value1, value2, "allCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andAllCountNotBetween(Integer value1, Integer value2) {
+            addCriterion("all_count not between", value1, value2, "allCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewCountIsNull() {
+            addCriterion("new_count is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewCountIsNotNull() {
+            addCriterion("new_count is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewCountEqualTo(Integer value) {
+            addCriterion("new_count =", value, "newCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewCountNotEqualTo(Integer value) {
+            addCriterion("new_count <>", value, "newCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewCountGreaterThan(Integer value) {
+            addCriterion("new_count >", value, "newCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewCountGreaterThanOrEqualTo(Integer value) {
+            addCriterion("new_count >=", value, "newCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewCountLessThan(Integer value) {
+            addCriterion("new_count <", value, "newCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewCountLessThanOrEqualTo(Integer value) {
+            addCriterion("new_count <=", value, "newCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewCountIn(List<Integer> values) {
+            addCriterion("new_count in", values, "newCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewCountNotIn(List<Integer> values) {
+            addCriterion("new_count not in", values, "newCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewCountBetween(Integer value1, Integer value2) {
+            addCriterion("new_count between", value1, value2, "newCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andNewCountNotBetween(Integer value1, Integer value2) {
+            addCriterion("new_count not between", value1, value2, "newCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateIsNull() {
+            addCriterion("`date` is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateIsNotNull() {
+            addCriterion("`date` is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateEqualTo(String value) {
+            addCriterion("`date` =", value, "date");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateNotEqualTo(String value) {
+            addCriterion("`date` <>", value, "date");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateGreaterThan(String value) {
+            addCriterion("`date` >", value, "date");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateGreaterThanOrEqualTo(String value) {
+            addCriterion("`date` >=", value, "date");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateLessThan(String value) {
+            addCriterion("`date` <", value, "date");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateLessThanOrEqualTo(String value) {
+            addCriterion("`date` <=", value, "date");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateLike(String value) {
+            addCriterion("`date` like", value, "date");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateNotLike(String value) {
+            addCriterion("`date` not like", value, "date");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateIn(List<String> values) {
+            addCriterion("`date` in", values, "date");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateNotIn(List<String> values) {
+            addCriterion("`date` not in", values, "date");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateBetween(String value1, String value2) {
+            addCriterion("`date` between", value1, value2, "date");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateNotBetween(String value1, String value2) {
+            addCriterion("`date` not between", value1, value2, "date");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNull() {
+            addCriterion("create_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNotNull() {
+            addCriterion("create_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeEqualTo(Date value) {
+            addCriterion("create_time =", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotEqualTo(Date value) {
+            addCriterion("create_time <>", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThan(Date value) {
+            addCriterion("create_time >", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("create_time >=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThan(Date value) {
+            addCriterion("create_time <", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("create_time <=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIn(List<Date> values) {
+            addCriterion("create_time in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotIn(List<Date> values) {
+            addCriterion("create_time not in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeBetween(Date value1, Date value2) {
+            addCriterion("create_time between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("create_time not between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNull() {
+            addCriterion("update_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNotNull() {
+            addCriterion("update_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeEqualTo(Date value) {
+            addCriterion("update_time =", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotEqualTo(Date value) {
+            addCriterion("update_time <>", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThan(Date value) {
+            addCriterion("update_time >", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("update_time >=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThan(Date value) {
+            addCriterion("update_time <", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("update_time <=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIn(List<Date> values) {
+            addCriterion("update_time in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotIn(List<Date> values) {
+            addCriterion("update_time not in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeBetween(Date value1, Date value2) {
+            addCriterion("update_time between", value1, value2, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("update_time not between", value1, value2, "updateTime");
+            return (Criteria) this;
+        }
+    }
+
+    public static class Criteria extends GeneratedCriteria {
+
+        protected Criteria() {
+            super();
+        }
+    }
+
+    public static class Criterion {
+        private String condition;
+
+        private Object value;
+
+        private Object secondValue;
+
+        private boolean noValue;
+
+        private boolean singleValue;
+
+        private boolean betweenValue;
+
+        private boolean listValue;
+
+        private String typeHandler;
+
+        public String getCondition() {
+            return condition;
+        }
+
+        public Object getValue() {
+            return value;
+        }
+
+        public Object getSecondValue() {
+            return secondValue;
+        }
+
+        public boolean isNoValue() {
+            return noValue;
+        }
+
+        public boolean isSingleValue() {
+            return singleValue;
+        }
+
+        public boolean isBetweenValue() {
+            return betweenValue;
+        }
+
+        public boolean isListValue() {
+            return listValue;
+        }
+
+        public String getTypeHandler() {
+            return typeHandler;
+        }
+
+        protected Criterion(String condition) {
+            super();
+            this.condition = condition;
+            this.typeHandler = null;
+            this.noValue = true;
+        }
+
+        protected Criterion(String condition, Object value, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.typeHandler = typeHandler;
+            if (value instanceof List<?>) {
+                this.listValue = true;
+            } else {
+                this.singleValue = true;
+            }
+        }
+
+        protected Criterion(String condition, Object value) {
+            this(condition, value, null);
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.secondValue = secondValue;
+            this.typeHandler = typeHandler;
+            this.betweenValue = true;
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue) {
+            this(condition, value, secondValue, null);
+        }
+    }
+}

+ 28 - 15
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/MessageAttachmentServiceImpl.java

@@ -67,27 +67,40 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
         List<Long> messageAttachmentIds = new ArrayList<>();
         for (MessageAttachment messageAttachment : messageAttachmentList) {
             MessageAttachmentExample example = new MessageAttachmentExample();
+            MessageAttachmentExample.Criteria criteria = example.createCriteria().andTypeEqualTo(messageAttachment.getType());
             if (messageAttachment.getType().equals(MessageAttachmentTypeEnum.IMAGE.getCode())) {
-                example.createCriteria()
-                        .andTypeEqualTo(messageAttachment.getType())
-                        .andMediaIdEqualTo(messageAttachment.getMediaId())
-                        .andPicUrlEqualTo(messageAttachment.getPicUrl());
+                if (messageAttachment.getMediaId() != null) {
+                    criteria.andMediaIdEqualTo(messageAttachment.getMediaId());
+                }
+                if (messageAttachment.getPicUrl() != null) {
+                    criteria.andPicUrlEqualTo(messageAttachment.getPicUrl());
+                }
             }
             if (messageAttachment.getType().equals(MessageAttachmentTypeEnum.MINI_PROGRAM.getCode())) {
-                example.createCriteria()
-                        .andTypeEqualTo(messageAttachment.getType())
-                        .andAppidEqualTo(messageAttachment.getAppid())
-                        .andMiniprogramVideoIdEqualTo(messageAttachment.getMiniprogramVideoId())
-                        .andStaffIdEqualTo(messageAttachment.getStaffId());
+                if (messageAttachment.getAppid() != null) {
+                    criteria.andAppidEqualTo(messageAttachment.getAppid());
+                }
+                if (messageAttachment.getMiniprogramVideoId() != null) {
+                    criteria.andMiniprogramVideoIdEqualTo(messageAttachment.getMiniprogramVideoId());
+                }
+                if (messageAttachment.getStaffId() != null) {
+                    criteria.andStaffIdEqualTo(messageAttachment.getStaffId());
+                }
             }
 
             if (messageAttachment.getType().equals(MessageAttachmentTypeEnum.LINK.getCode())) {
-                example.createCriteria()
-                        .andTypeEqualTo(messageAttachment.getType())
-                        .andTitleEqualTo(messageAttachment.getTitle())
-                        .andPicUrlEqualTo(messageAttachment.getPicUrl())
-                        .andDescEqualTo(messageAttachment.getDesc())
-                        .andUrlEqualTo(messageAttachment.getUrl());
+                if (messageAttachment.getTitle() != null) {
+                    criteria.andTitleEqualTo(messageAttachment.getTitle());
+                }
+                if (messageAttachment.getPicUrl() != null) {
+                    criteria.andPicUrlEqualTo(messageAttachment.getPicUrl());
+                }
+                if (messageAttachment.getDesc() != null) {
+                    criteria.andDescEqualTo(messageAttachment.getDesc());
+                }
+                if (messageAttachment.getUrl() != null) {
+                    criteria.andUrlEqualTo(messageAttachment.getUrl());
+                }
             }
 
             List<MessageAttachment> messageAttachments = messageAttachmentMapper.selectByExample(example);

+ 7 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/utils/DateUtil.java

@@ -39,6 +39,13 @@ public class DateUtil {
         return dateFormat.format(yesterday);
     }
 
+    public static String getBeforeDayDateString1() {
+        DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        LocalDate today = LocalDate.now();
+        LocalDate yesterday = today.minusDays(1);
+        return dateFormat.format(yesterday);
+    }
+
     public static String getThatDayDateString() {
         DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         LocalDate today = LocalDate.now();

+ 28 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/utils/LarkRobotUtil.java

@@ -19,6 +19,11 @@ public class LarkRobotUtil {
 
     private static final String TIP_URL = "https://open.feishu.cn/open-apis/bot/v2/hook/0eb8793a-5bb3-43d7-aa74-fed1c91e3d9b";
 
+    private static final String WE_COM_NOT_PUSH_URL = "https://open.feishu.cn/open-apis/bot/v2/hook/6fa54ed6-12f7-45c1-a33b-020d4f4483ef";
+
+
+    private static final String AUTO_REPLY_VIDEO_URL = "https://open.feishu.cn/open-apis/bot/v2/hook/0d80b7dc-47d1-4c27-a7e1-97f2fb6ba26e";
+
     private static final HttpPoolClientUtil HTTP_POOL_CLIENT_UTIL_DEFAULT = HttpClientUtil.create(3000, 10000, 20, 100, 3, 3000);
 
 
@@ -60,6 +65,29 @@ public class LarkRobotUtil {
         }
     }
 
+
+    public static void sendAutoReplyVideoMessage(JSONObject param) {
+        try {
+            HTTP_POOL_CLIENT_UTIL_DEFAULT.post(AUTO_REPLY_VIDEO_URL, param.toJSONString());
+        } catch (Exception e) {
+            log.error("Lark sendMessage error", e);
+        }
+    }
+
+    public static void sendNotPushMessage(String msg) {
+        try {
+            JSONObject param = new JSONObject();
+            param.put("msg_type", "text");
+            JSONObject content = new JSONObject();
+            content.put("text", msg);
+            param.put("content", content);
+            HTTP_POOL_CLIENT_UTIL_DEFAULT.post(WE_COM_NOT_PUSH_URL, param.toJSONString());
+        } catch (Exception e) {
+            log.error("Lark sendMessage error", e);
+        }
+    }
+
+
     private static String getSign(long timestamp) throws NoSuchAlgorithmException, InvalidKeyException {
         //把timestamp+"\n"+密钥当做签名字符串
         String stringToSign = timestamp + "\n" + SECRET;

+ 15 - 0
common-module/src/main/resources/mapper/AttachmentWithMsgResultMapper.xml

@@ -211,4 +211,19 @@
       update_time = #{updateTime,jdbcType=TIMESTAMP}
     where id = #{id,jdbcType=BIGINT}
   </update>
+
+  <insert id="insertList" parameterType="java.util.List">
+      insert IGNORE into we_com_attachment_with_msg_result
+      (
+      attachment_id,
+      msg_result_id
+      )
+      values
+      <foreach collection="list" item="item" separator=",">
+          (
+          #{item.attachmentId,jdbcType=BIGINT},
+          #{item.msgResultId,jdbcType=BIGINT}
+          )
+      </foreach>
+  </insert>
 </mapper>

+ 15 - 9
api-module/src/main/resources/mapper/CgiReplyBucketDataMapper.xml → common-module/src/main/resources/mapper/CgiReplyBucketDataMapper.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.tzld.piaoquan.api.dao.mapper.CgiReplyBucketDataMapper">
-  <resultMap id="BaseResultMap" type="com.tzld.piaoquan.api.model.po.CgiReplyBucketData">
+<mapper namespace="com.tzld.piaoquan.growth.common.dao.mapper.CgiReplyBucketDataMapper">
+  <resultMap id="BaseResultMap" type="com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData">
     <id column="id" jdbcType="BIGINT" property="id" />
     <result column="strategy" jdbcType="VARCHAR" property="strategy" />
     <result column="sort" jdbcType="INTEGER" property="sort" />
@@ -83,7 +83,7 @@
     mini_page_path, mini_video_id, page_path_url_id, news_publish_content_id, plan_id,
     is_delete, create_time, update_time
   </sql>
-  <select id="selectByExample" parameterType="com.tzld.piaoquan.api.model.po.CgiReplyBucketDataExample" resultMap="BaseResultMap">
+  <select id="selectByExample" parameterType="com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketDataExample" resultMap="BaseResultMap">
     select
     <if test="distinct">
       distinct
@@ -107,13 +107,13 @@
     delete from cgi_reply_bucket_data
     where id = #{id,jdbcType=BIGINT}
   </delete>
-  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.api.model.po.CgiReplyBucketDataExample">
+  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketDataExample">
     delete from cgi_reply_bucket_data
     <if test="_parameter != null">
       <include refid="Example_Where_Clause" />
     </if>
   </delete>
-  <insert id="insert" parameterType="com.tzld.piaoquan.api.model.po.CgiReplyBucketData">
+  <insert id="insert" parameterType="com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData">
     <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
       SELECT LAST_INSERT_ID()
     </selectKey>
@@ -130,7 +130,7 @@
       #{planId,jdbcType=VARCHAR}, #{isDelete,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
       #{updateTime,jdbcType=TIMESTAMP})
   </insert>
-  <insert id="insertSelective" parameterType="com.tzld.piaoquan.api.model.po.CgiReplyBucketData">
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData">
     <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
       SELECT LAST_INSERT_ID()
     </selectKey>
@@ -236,7 +236,7 @@
       </if>
     </trim>
   </insert>
-  <select id="countByExample" parameterType="com.tzld.piaoquan.api.model.po.CgiReplyBucketDataExample" resultType="java.lang.Long">
+  <select id="countByExample" parameterType="com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketDataExample" resultType="java.lang.Long">
     select count(*) from cgi_reply_bucket_data
     <if test="_parameter != null">
       <include refid="Example_Where_Clause" />
@@ -324,7 +324,7 @@
       <include refid="Update_By_Example_Where_Clause" />
     </if>
   </update>
-  <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.api.model.po.CgiReplyBucketData">
+  <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData">
     update cgi_reply_bucket_data
     <set>
       <if test="strategy != null">
@@ -378,7 +378,7 @@
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
-  <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.api.model.po.CgiReplyBucketData">
+  <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData">
     update cgi_reply_bucket_data
     set strategy = #{strategy,jdbcType=VARCHAR},
       sort = #{sort,jdbcType=INTEGER},
@@ -398,4 +398,10 @@
       update_time = #{updateTime,jdbcType=TIMESTAMP}
     where id = #{id,jdbcType=BIGINT}
   </update>
+
+  <select id="selectVideoId" resultType="java.lang.Long">
+    select distinct mini_video_id
+    from cgi_reply_bucket_data
+    where is_delete = 0;
+  </select>
 </mapper>

+ 9 - 9
api-module/src/main/resources/mapper/GhDetailMapper.xml → common-module/src/main/resources/mapper/GhDetailMapper.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.tzld.piaoquan.api.dao.mapper.GhDetailMapper">
-  <resultMap id="BaseResultMap" type="com.tzld.piaoquan.api.model.po.GhDetail">
+<mapper namespace="com.tzld.piaoquan.growth.common.dao.mapper.GhDetailMapper">
+  <resultMap id="BaseResultMap" type="com.tzld.piaoquan.growth.common.model.po.GhDetail">
     <id column="id" jdbcType="BIGINT" property="id" />
     <result column="gh_id" jdbcType="VARCHAR" property="ghId" />
     <result column="gh_name" jdbcType="VARCHAR" property="ghName" />
@@ -78,7 +78,7 @@
     id, gh_id, gh_name, `type`, category1, category2, is_delete, create_time, update_time, 
     channel, video_ids, strategy_status, autoreply_send_minigram_num
   </sql>
-  <select id="selectByExample" parameterType="com.tzld.piaoquan.api.model.po.GhDetailExample" resultMap="BaseResultMap">
+  <select id="selectByExample" parameterType="com.tzld.piaoquan.growth.common.model.po.GhDetailExample" resultMap="BaseResultMap">
     select
     <if test="distinct">
       distinct
@@ -105,13 +105,13 @@
     delete from gh_detail
     where id = #{id,jdbcType=BIGINT}
   </delete>
-  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.api.model.po.GhDetailExample">
+  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.growth.common.model.po.GhDetailExample">
     delete from gh_detail
     <if test="_parameter != null">
       <include refid="Example_Where_Clause" />
     </if>
   </delete>
-  <insert id="insert" parameterType="com.tzld.piaoquan.api.model.po.GhDetail">
+  <insert id="insert" parameterType="com.tzld.piaoquan.growth.common.model.po.GhDetail">
     insert into gh_detail (id, gh_id, gh_name, 
       `type`, category1, category2, 
       is_delete, create_time, update_time, 
@@ -123,7 +123,7 @@
       #{channel,jdbcType=VARCHAR}, #{videoIds,jdbcType=VARCHAR}, #{strategyStatus,jdbcType=INTEGER}, 
       #{autoreplySendMinigramNum,jdbcType=INTEGER})
   </insert>
-  <insert id="insertSelective" parameterType="com.tzld.piaoquan.api.model.po.GhDetail">
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.growth.common.model.po.GhDetail">
     insert into gh_detail
     <trim prefix="(" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -208,7 +208,7 @@
       </if>
     </trim>
   </insert>
-  <select id="countByExample" parameterType="com.tzld.piaoquan.api.model.po.GhDetailExample" resultType="java.lang.Long">
+  <select id="countByExample" parameterType="com.tzld.piaoquan.growth.common.model.po.GhDetailExample" resultType="java.lang.Long">
     select count(*) from gh_detail
     <if test="_parameter != null">
       <include refid="Example_Where_Clause" />
@@ -280,7 +280,7 @@
       <include refid="Update_By_Example_Where_Clause" />
     </if>
   </update>
-  <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.api.model.po.GhDetail">
+  <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.growth.common.model.po.GhDetail">
     update gh_detail
     <set>
       <if test="ghId != null">
@@ -322,7 +322,7 @@
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
-  <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.api.model.po.GhDetail">
+  <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.growth.common.model.po.GhDetail">
     update gh_detail
     set gh_id = #{ghId,jdbcType=VARCHAR},
       gh_name = #{ghName,jdbcType=VARCHAR},

+ 261 - 0
common-module/src/main/resources/mapper/UserCountMapper.xml

@@ -0,0 +1,261 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.tzld.piaoquan.growth.common.dao.mapper.UserCountMapper">
+  <resultMap id="BaseResultMap" type="com.tzld.piaoquan.growth.common.model.po.UserCount">
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="staff_id" jdbcType="BIGINT" property="staffId" />
+    <result column="staff_name" jdbcType="VARCHAR" property="staffName" />
+    <result column="all_count" jdbcType="INTEGER" property="allCount" />
+    <result column="new_count" jdbcType="INTEGER" property="newCount" />
+    <result column="date" jdbcType="VARCHAR" property="date" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
+  </resultMap>
+  <sql id="Example_Where_Clause">
+    <where>
+      <foreach collection="oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Update_By_Example_Where_Clause">
+    <where>
+      <foreach collection="example.oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List">
+    id, staff_id, staff_name, all_count, new_count, `date`, create_time, update_time
+  </sql>
+  <select id="selectByExample" parameterType="com.tzld.piaoquan.growth.common.model.po.UserCountExample" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from we_com_user_count
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null">
+      order by ${orderByClause}
+    </if>
+    <if test="page != null">
+      limit #{page.offset} , #{page.pageSize}
+    </if>
+  </select>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from we_com_user_count
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+    delete from we_com_user_count
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.growth.common.model.po.UserCountExample">
+    delete from we_com_user_count
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.tzld.piaoquan.growth.common.model.po.UserCount">
+    insert into we_com_user_count (id, staff_id, staff_name, 
+      all_count, new_count, `date`, 
+      create_time, update_time)
+    values (#{id,jdbcType=BIGINT}, #{staffId,jdbcType=BIGINT}, #{staffName,jdbcType=VARCHAR}, 
+      #{allCount,jdbcType=INTEGER}, #{newCount,jdbcType=INTEGER}, #{date,jdbcType=VARCHAR}, 
+      #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
+  </insert>
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.growth.common.model.po.UserCount">
+    insert into we_com_user_count
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="staffId != null">
+        staff_id,
+      </if>
+      <if test="staffName != null">
+        staff_name,
+      </if>
+      <if test="allCount != null">
+        all_count,
+      </if>
+      <if test="newCount != null">
+        new_count,
+      </if>
+      <if test="date != null">
+        `date`,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+      <if test="updateTime != null">
+        update_time,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=BIGINT},
+      </if>
+      <if test="staffId != null">
+        #{staffId,jdbcType=BIGINT},
+      </if>
+      <if test="staffName != null">
+        #{staffName,jdbcType=VARCHAR},
+      </if>
+      <if test="allCount != null">
+        #{allCount,jdbcType=INTEGER},
+      </if>
+      <if test="newCount != null">
+        #{newCount,jdbcType=INTEGER},
+      </if>
+      <if test="date != null">
+        #{date,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateTime != null">
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.tzld.piaoquan.growth.common.model.po.UserCountExample" resultType="java.lang.Long">
+    select count(*) from we_com_user_count
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    update we_com_user_count
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=BIGINT},
+      </if>
+      <if test="record.staffId != null">
+        staff_id = #{record.staffId,jdbcType=BIGINT},
+      </if>
+      <if test="record.staffName != null">
+        staff_name = #{record.staffName,jdbcType=VARCHAR},
+      </if>
+      <if test="record.allCount != null">
+        all_count = #{record.allCount,jdbcType=INTEGER},
+      </if>
+      <if test="record.newCount != null">
+        new_count = #{record.newCount,jdbcType=INTEGER},
+      </if>
+      <if test="record.date != null">
+        `date` = #{record.date,jdbcType=VARCHAR},
+      </if>
+      <if test="record.createTime != null">
+        create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="record.updateTime != null">
+        update_time = #{record.updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExample" parameterType="map">
+    update we_com_user_count
+    set id = #{record.id,jdbcType=BIGINT},
+      staff_id = #{record.staffId,jdbcType=BIGINT},
+      staff_name = #{record.staffName,jdbcType=VARCHAR},
+      all_count = #{record.allCount,jdbcType=INTEGER},
+      new_count = #{record.newCount,jdbcType=INTEGER},
+      `date` = #{record.date,jdbcType=VARCHAR},
+      create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      update_time = #{record.updateTime,jdbcType=TIMESTAMP}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.growth.common.model.po.UserCount">
+    update we_com_user_count
+    <set>
+      <if test="staffId != null">
+        staff_id = #{staffId,jdbcType=BIGINT},
+      </if>
+      <if test="staffName != null">
+        staff_name = #{staffName,jdbcType=VARCHAR},
+      </if>
+      <if test="allCount != null">
+        all_count = #{allCount,jdbcType=INTEGER},
+      </if>
+      <if test="newCount != null">
+        new_count = #{newCount,jdbcType=INTEGER},
+      </if>
+      <if test="date != null">
+        `date` = #{date,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateTime != null">
+        update_time = #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.growth.common.model.po.UserCount">
+    update we_com_user_count
+    set staff_id = #{staffId,jdbcType=BIGINT},
+      staff_name = #{staffName,jdbcType=VARCHAR},
+      all_count = #{allCount,jdbcType=INTEGER},
+      new_count = #{newCount,jdbcType=INTEGER},
+      `date` = #{date,jdbcType=VARCHAR},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      update_time = #{updateTime,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+</mapper>

+ 213 - 0
offline-module/src/main/java/com/tzld/piaoquan/offline/job/AutoReplyVideoDataJob.java

@@ -0,0 +1,213 @@
+package com.tzld.piaoquan.offline.job;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Lists;
+import com.tzld.piaoquan.growth.common.common.enums.FieshuTableColumnDataTypeEnum;
+import com.tzld.piaoquan.growth.common.common.enums.GhTypeEnum;
+import com.tzld.piaoquan.growth.common.common.enums.StrategyStatusEnum;
+import com.tzld.piaoquan.growth.common.component.HttpPoolClient;
+import com.tzld.piaoquan.growth.common.dao.mapper.CgiReplyBucketDataMapper;
+import com.tzld.piaoquan.growth.common.dao.mapper.GhDetailMapper;
+import com.tzld.piaoquan.growth.common.model.bo.FeishuTableDTO;
+import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
+import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketDataExample;
+import com.tzld.piaoquan.growth.common.model.po.GhDetail;
+import com.tzld.piaoquan.growth.common.model.po.GhDetailExample;
+import com.tzld.piaoquan.growth.common.utils.LarkRobotUtil;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Component
+public class AutoReplyVideoDataJob {
+
+    private static final List<String> auditGhIds = new ArrayList<String>() {{
+        add("gh_b63b9dde3f4b");
+        add("gh_330ef0db846d");
+        add("gh_330ef0db846d");
+        add("gh_e2318164f869");
+        add("gh_620af8e24fb9");
+        add("gh_620af8e24fb9");
+        add("gh_133c36b99b14");
+        add("gh_133c36b99b14");
+        add("gh_5ac72e2b9130");
+        add("gh_ef8ade0fad92");
+        add("gh_1e03b6de22bf");
+        add("gh_5538fe297e59");
+        add("gh_8c6fffcbaac1");
+        add("gh_8c6fffcbaac1");
+        add("gh_d0e830b7547e");
+        add("gh_fb234f4e32a5");
+        add("gh_84c5d01a61e7");
+        add("gh_87c4b8ae885e");
+        add("gh_29d8a63d5e5e");
+        add("gh_b144210318e5");
+        add("gh_b144210318e5");
+        add("gh_1f9bf4cfa788");
+        add("gh_4f47d12bbe04");
+        add("gh_8c6af276df98");
+        add("gh_1f16bc6ac60d");
+        add("gh_4920bc4c5720");
+        add("gh_5177a8c57917");
+        add("gh_5177a8c57917");
+        add("gh_5e3e6cd5e35c");
+        add("gh_5e3e6cd5e35c");
+        add("gh_d2c72bcc05c9");
+        add("gh_d2c72bcc05c9");
+        add("gh_5f2400da935c");
+        add("gh_5f2400da935c");
+        add("gh_669555ebea28");
+        add("gh_28ce883486c3");
+        add("gh_28ce883486c3");
+        add("gh_7057ef30222b");
+        add("gh_7057ef30222b");
+        add("gh_b0048adc0b46");
+        add("gh_6e61a2d5db85");
+        add("gh_01cd19465b39");
+        add("gh_01cd19465b39");
+        add("gh_126c99b39cea");
+        add("gh_4a1174e36ceb");
+        add("gh_f81c27eb8c48");
+        add("gh_f81c27eb8c48");
+        add("gh_3170dc15e246");
+        add("gh_1ccfb5620605");
+        add("gh_315be76a746d");
+        add("gh_4f47d12bbe04");
+        add("gh_4f47d12bbe04");
+        add("gh_4f47d12bbe04");
+    }};
+
+    private static final String VIDEO_DETAIL_URL = "https://longvideoapi.piaoquantv.com/longvideoapi/openapi/video/batchSelectVideoInfo";
+
+    private static final String REFRESH_GZH_URL = "http://aigc-api.cybertogether.net/aigc/publish/api/refreshGzhAutoReplyMsgData";
+
+
+    @Autowired
+    private CgiReplyBucketDataMapper cgiReplyBucketDataMapper;
+
+    @Autowired
+    private HttpPoolClient httpPoolClient;
+
+    @Autowired
+    private GhDetailMapper ghDetailMapper;
+
+
+    @XxlJob("validateAutoReplyVideoAuditStatusJob")
+    public ReturnT<String> validateAutoReplyVideoAuditStatus(String param) throws IOException {
+        List<Long> videoIds = cgiReplyBucketDataMapper.selectVideoId();
+        if (CollectionUtils.isEmpty(videoIds)) {
+            return ReturnT.SUCCESS;
+        }
+        List<Long> auditFailedVideoIds = new ArrayList<>();
+        List<List<Long>> partition = Lists.partition(videoIds, 20);
+        for (List<Long> videoIdList : partition) {
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("videoIdList", videoIdList);
+            String res = httpPoolClient.post(VIDEO_DETAIL_URL, jsonObject.toJSONString());
+            if (StringUtils.isEmpty(res)) {
+                continue;
+            }
+            JSONObject result = JSONObject.parseObject(res);
+            Integer code = result.getInteger("code");
+            if (code != 0) {
+                continue;
+            }
+            JSONArray jsonArray = result.getJSONArray("data");
+            for (int i = 0; i < jsonArray.size(); i++) {
+                JSONObject videoDetail = jsonArray.getJSONObject(i);
+                Integer auditStatus = videoDetail.getInteger("auditStatus");
+                Integer appAuditStatus = videoDetail.getInteger("appAuditStatus");
+                if (auditStatus != 5 || appAuditStatus != 5) {
+                    auditFailedVideoIds.add(videoDetail.getLong("id"));
+                }
+            }
+        }
+        if (CollectionUtils.isEmpty(auditFailedVideoIds)) {
+            return ReturnT.SUCCESS;
+        }
+
+        List<FeishuTableDTO.Column> columns = buildCheckPublishPlanAccountColumns();
+        List<JSONObject> rows = new ArrayList<>();
+
+        for (Long videoId : auditFailedVideoIds) {
+            CgiReplyBucketDataExample example = new CgiReplyBucketDataExample();
+            example.createCriteria().andMiniVideoIdEqualTo(videoId).andIsDeleteEqualTo(0);
+            List<CgiReplyBucketData> cgiReplyBucketDataList = cgiReplyBucketDataMapper.selectByExample(example);
+//            List<String> ghIds = new ArrayList<>();
+//            List<String> manualGhIds = new ArrayList<>();
+            for (CgiReplyBucketData cgiReplyBucketData : cgiReplyBucketDataList) {
+                String ghId = cgiReplyBucketData.getGhId();
+                GhDetailExample ghDetailExample = new GhDetailExample();
+                ghDetailExample.createCriteria().andGhIdEqualTo(ghId);
+                List<GhDetail> ghDetails = ghDetailMapper.selectByExample(ghDetailExample);
+                if (CollectionUtils.isEmpty(ghDetails)) {
+                    continue;
+                }
+                GhDetail ghDetail = ghDetails.get(0);
+
+//                if (Objects.equals(cgiReplyBucketData.getStrategy(), "manual")) {
+//                    ghDetail1.setStrategyStatus(StrategyStatusEnum.STRATEGY.status);
+//                    ghDetailMapper.updateByPrimaryKeySelective(ghDetail1);
+//                    manualGhIds.add(cgiReplyBucketData.getGhId());
+//                }
+
+//                ghIds.add(cgiReplyBucketData.getGhId());
+                JSONObject row = new JSONObject();
+                row.put("name", ghDetail.getGhName());
+                row.put("channel", ghDetail.getChannel());
+                row.put("video", videoId);
+                row.put("ghId", ghDetail.getGhId());
+                rows.add(row);
+                try {
+                    if (auditGhIds.contains(ghId)) {
+                        String url = REFRESH_GZH_URL + "?ghId=" + cgiReplyBucketData.getGhId();
+                        String res = httpPoolClient.get(url);
+                        log.info("refresh ghId={}, res={}", cgiReplyBucketData.getGhId(), res);
+                    }
+                } catch (Exception e) {
+                    log.error("refresh error", e);
+                }
+
+            }
+        }
+        FeishuTableDTO tableDTO = FeishuTableDTO.createTable("自动回复视频审核失败报警", columns, rows, false);
+        JSONObject content = JSONObject.parseObject(JSONObject.toJSONString(tableDTO));
+        JSONObject bodyParam = new JSONObject();
+        bodyParam.put("msg_type", "interactive");
+        bodyParam.put("card", content);
+        LarkRobotUtil.sendAutoReplyVideoMessage(bodyParam);
+        return ReturnT.SUCCESS;
+    }
+
+
+    private List<FeishuTableDTO.Column> buildCheckPublishPlanAccountColumns() {
+        List<FeishuTableDTO.Column> columns = new ArrayList<>();
+        FeishuTableDTO.Column nameColumn = FeishuTableDTO.createFeishuColumns(
+                FieshuTableColumnDataTypeEnum.TEXT.getType(), "name", "账号名称", null);
+        columns.add(nameColumn);
+        FeishuTableDTO.Column channelColumn = FeishuTableDTO.createFeishuColumns(
+                FieshuTableColumnDataTypeEnum.TEXT.getType(), "channel", "渠道id", null);
+        columns.add(channelColumn);
+        FeishuTableDTO.Column videoColumn = FeishuTableDTO.createFeishuColumns(
+                FieshuTableColumnDataTypeEnum.TEXT.getType(), "video", "审核不通过的视频id", null);
+        columns.add(videoColumn);
+        FeishuTableDTO.Column ghIdColumn = FeishuTableDTO.createFeishuColumns(
+                FieshuTableColumnDataTypeEnum.TEXT.getType(), "ghId", "ghId", null);
+        columns.add(ghIdColumn);
+        return columns;
+    }
+
+}

+ 1 - 1
offline-module/src/main/java/com/tzld/piaoquan/offline/job/PushMessageDataJob.java

@@ -85,7 +85,7 @@ public class PushMessageDataJob {
             if (mysqlCount == 0) {
                 break;
             }
-            String pt = DateUtil.getDateString(startTime.getTime());
+            String pt = DateUtil.getDateString(startTime.getTime(), "yyyyMMdd");
             String sql = String.format("SELECT count(*) FROM push_message_callback WHERE pt = %s;", pt);
             List<Record> recordList = odpsManager.query(sql);
             if (CollectionUtils.isEmpty(recordList)) {

+ 19 - 22
offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComHistoryDataJob.java

@@ -155,13 +155,12 @@ public class WeComHistoryDataJob {
             }
             stringBuilder.append(sendDetail.getRemark());
             long count = sendCountList.get(0) + sendCountList.get(1) + sendCountList.get(2) + sendCountList.get(3);
-            Long notSentCount = sendCountList.get(0);
-            if (notSentCount != 0) {
-                LarkRobotUtil.sendMessage("@薛一鸣 存在未发送记录,请检查");
+            if (count != 0 && count == sendCountList.get(0)) {
+                LarkRobotUtil.sendMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
                 if (sendDetail.getStaffId() == 3) {
-                    LarkRobotUtil.sendTipMessage("@王钧灏 存在未发送记录,请检查");
+                    LarkRobotUtil.sendTipMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
                 } else {
-                    LarkRobotUtil.sendTipMessage("@孟庆红 存在未发送记录,请检查");
+                    LarkRobotUtil.sendNotPushMessage("<at user_id=\"all\">所有人</at> " + sendDetail.getRemark() + " 存在未发送记录,请检查");
                 }
             }
             stringBuilder.append("总发送数量:").append(count).append("   ");
@@ -215,7 +214,7 @@ public class WeComHistoryDataJob {
                                         .getJSONObject(MessageAttachmentTypeEnum.IMAGE.getType());
                                 messageAttachment.setMediaId(image.getString("media_id"));
                                 messageAttachment.setPicUrl(image.getString("pic_url"));
-                                messageAttachment.setType(MessageAttachmentTypeEnum.MINI_PROGRAM.getCode());
+                                messageAttachment.setType(MessageAttachmentTypeEnum.IMAGE.getCode());
                                 messageAttachmentList.add(messageAttachment);
                             }
 
@@ -227,7 +226,7 @@ public class WeComHistoryDataJob {
                                 messageAttachment.setPicUrl(link.getString("picurl"));
                                 messageAttachment.setDesc(link.getString("desc"));
                                 messageAttachment.setUrl(link.getString("url"));
-                                messageAttachment.setType(MessageAttachmentTypeEnum.MINI_PROGRAM.getCode());
+                                messageAttachment.setType(MessageAttachmentTypeEnum.LINK.getCode());
                                 messageAttachmentList.add(messageAttachment);
 
                             }
@@ -289,7 +288,7 @@ public class WeComHistoryDataJob {
                                     .addMessageAttachment(messageAttachmentList, createTime);
                         }
                         insertHistoryMessageList(msgId, staffList.get(0), externalUsers, miniprogramRecordList,
-                                createTime, corpId, startTime, endTime, attachmentIds);
+                                createTime, corpId, startTime, endTime, attachmentIds, textContent);
                     }
                 }
                 String nextCursor = jsonObject.getString("next_cursor");
@@ -406,7 +405,8 @@ public class WeComHistoryDataJob {
 
     private void insertHistoryMessageList(String msgId, Staff staff, List<ExternalUser> externalUsers,
                                           List<MiniprogramRecord> miniprogramRecordList,
-                                          Long createTime, Long corpId, Long startTime, Long endTime, List<Long> attachmentIds) {
+                                          Long createTime, Long corpId, Long startTime, Long endTime,
+                                          List<Long> attachmentIds, String textContent) {
         if (CollectionUtils.isEmpty(externalUsers)) {
             return;
         }
@@ -438,6 +438,7 @@ public class WeComHistoryDataJob {
                 SendMsgResult sendMsgResult = new SendMsgResult();
                 sendMsgResult.setMsgId(msgId);
                 sendMsgResult.setUserId(userId);
+                sendMsgResult.setTextContent(textContent);
                 sendMsgResult.setStaffId(staff.getId());
                 if (sendTime != null) {
                     sendMsgResult.setSendTime(new Date(sendTime));
@@ -491,23 +492,19 @@ public class WeComHistoryDataJob {
         if (CollectionUtils.isEmpty(attachmentIds) || CollectionUtils.isEmpty(sendMsgResultIds)) {
             return;
         }
+        List<AttachmentWithMsgResult> list = new ArrayList<>();
         for (Long attachmentId : attachmentIds) {
             for (Long sendMsgResultId : sendMsgResultIds) {
-                AttachmentWithMsgResultExample example = new AttachmentWithMsgResultExample();
-                example.createCriteria().andAttachmentIdEqualTo(attachmentId).andMsgResultIdEqualTo(sendMsgResultId);
-                long l = attachmentWithMsgResultMapper.countByExample(example);
-                if (l == 0) {
-                    try {
-                        AttachmentWithMsgResult attachmentWithMsgResult = new AttachmentWithMsgResult();
-                        attachmentWithMsgResult.setAttachmentId(attachmentId);
-                        attachmentWithMsgResult.setMsgResultId(sendMsgResultId);
-                        attachmentWithMsgResultMapper.insertSelective(attachmentWithMsgResult);
-                    } catch (Exception e) {
-                        log.error("insert error", e);
-                    }
-                }
+                AttachmentWithMsgResult attachmentWithMsgResult = new AttachmentWithMsgResult();
+                attachmentWithMsgResult.setAttachmentId(attachmentId);
+                attachmentWithMsgResult.setMsgResultId(sendMsgResultId);
+                list.add(attachmentWithMsgResult);
             }
         }
+        List<List<AttachmentWithMsgResult>> partition = Lists.partition(list, 2000);
+        for (List<AttachmentWithMsgResult> AttachmentWithMsgResults : partition) {
+            attachmentWithMsgResultMapper.insertList(AttachmentWithMsgResults);
+        }
     }
 
     private String getGroupMsgList(Long startTime, Long endTime, String cursor, Long corpId) throws IOException {

+ 83 - 4
offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComUserDataJob.java

@@ -3,14 +3,12 @@ package com.tzld.piaoquan.offline.job;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.growth.common.component.HttpPoolClient;
-import com.tzld.piaoquan.growth.common.dao.mapper.CorpMapper;
-import com.tzld.piaoquan.growth.common.dao.mapper.StaffMapper;
-import com.tzld.piaoquan.growth.common.dao.mapper.StaffWithUserMapper;
-import com.tzld.piaoquan.growth.common.dao.mapper.WeComUserMapper;
+import com.tzld.piaoquan.growth.common.dao.mapper.*;
 import com.tzld.piaoquan.growth.common.model.bo.XxlJobParam;
 import com.tzld.piaoquan.growth.common.model.po.*;
 import com.tzld.piaoquan.growth.common.service.WeComAccessTokenService;
 import com.tzld.piaoquan.growth.common.service.WeComUserService;
+import com.tzld.piaoquan.growth.common.utils.DateUtil;
 import com.tzld.piaoquan.growth.common.utils.LarkRobotUtil;
 import com.xxl.job.core.biz.model.ReturnT;
 import com.xxl.job.core.handler.annotation.XxlJob;
@@ -21,7 +19,9 @@ import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 import static com.tzld.piaoquan.growth.common.common.constant.WeComConstant.*;
@@ -51,6 +51,9 @@ public class WeComUserDataJob {
     @Autowired
     private CorpMapper corpMapper;
 
+    @Autowired
+    private UserCountMapper userCountMapper;
+
     @XxlJob("updateStaffWithUserJob")
     public ReturnT<String> updateStaffWithUser(String param) {
         XxlJobParam xxlJobParam = new XxlJobParam();
@@ -229,4 +232,80 @@ public class WeComUserDataJob {
         }
         return null;
     }
+
+    @XxlJob("statisticsUserCountJob")
+    public ReturnT<String> statisticsUserCount(String param) {
+        StaffExample staffExample = new StaffExample();
+        List<Staff> staffList = staffMapper.selectByExample(staffExample);
+        String date;
+        if (StringUtils.isEmpty(param)) {
+            date = DateUtil.getBeforeDayDateString1();
+        } else {
+            date = param;
+        }
+        for (Staff staff : staffList) {
+            Map<String, Integer> userCountRes = getUserList(staff, 1L, date);
+            if (userCountRes == null || userCountRes.get("count") == 0) {
+                continue;
+            }
+            UserCountExample userCountExample = new UserCountExample();
+            userCountExample.createCriteria().andStaffIdEqualTo(staff.getId()).andDateEqualTo(date);
+            List<UserCount> userCounts = userCountMapper.selectByExample(userCountExample);
+            if (CollectionUtils.isEmpty(userCounts)) {
+                UserCount userCount = new UserCount();
+                userCount.setStaffId(staff.getId());
+                userCount.setStaffName(staff.getRemark());
+                userCount.setAllCount(userCountRes.get("count"));
+                userCount.setNewCount(userCountRes.get("newCount"));
+                userCount.setDate(date);
+                userCountMapper.insertSelective(userCount);
+            } else {
+                UserCount userCount = userCounts.get(0);
+                userCount.setAllCount(userCountRes.get("count"));
+                userCount.setNewCount(userCountRes.get("newCount"));
+                userCountMapper.updateByPrimaryKeySelective(userCount);
+            }
+        }
+        return ReturnT.SUCCESS;
+    }
+
+
+    private Map<String, Integer> getUserList(Staff staff, Long corpId, String date) {
+        Map<String, Integer> result = new HashMap<>();
+        int count = 0;
+        int newCount = 0;
+        try {
+            String cursor = "";
+            do {
+                String res = getUserDetailList(staff.getCarrierId(), cursor, corpId);
+                log.info("updateUserList res={} cursor={}", res, cursor);
+                JSONObject jsonObject = JSONObject.parseObject(res);
+                Integer errCode = jsonObject.getInteger("errcode");
+                if (errCode != 0) {
+                    log.error("updateUserList error carrierId={} cursor={}", staff.getCarrierId(), cursor);
+                    return null;
+                }
+                JSONArray externalContactList = jsonObject.getJSONArray("external_contact_list");
+                for (int i = 0; i < externalContactList.size(); i++) {
+                    JSONObject followInfo = externalContactList.getJSONObject(i).getJSONObject("follow_info");
+                    Long createAt = followInfo.getLong("createtime");
+                    String dateString = DateUtil.getDateString(createAt * 1000, "yyyy-MM-dd");
+                    if (dateString.equals(date)) {
+                        newCount++;
+                    }
+                    count++;
+                }
+                String nextCursor = jsonObject.getString("next_cursor");
+                if (cursor.equals(nextCursor)) {
+                    break;
+                }
+                cursor = nextCursor;
+            } while (StringUtils.isNotEmpty(cursor));
+        } catch (IOException e) {
+            log.error("getUserList error", e);
+        }
+        result.put("count", count);
+        result.put("newCount", newCount);
+        return result;
+    }
 }

+ 8 - 0
pom.xml

@@ -173,6 +173,14 @@
             <artifactId>ons-client</artifactId>
             <version>1.8.4.Final</version>
         </dependency>
+        
+        <!-- https://mvnrepository.com/artifact/com.ctrip.framework.apollo/apollo-client -->
+        <dependency>
+            <groupId>com.ctrip.framework.apollo</groupId>
+            <artifactId>apollo-client</artifactId>
+            <version>2.0.0</version>
+        </dependency>
+
     </dependencies>
 
 </project>