瀏覽代碼

修改人工数据为空的情况

xueyiming 3 月之前
父節點
當前提交
61b27d053d

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

@@ -140,29 +140,31 @@ public class BuckStrategyV1 implements ReplyStrategyService {
         }
         // 获取人工实验数据
         List<GroupData> groupDataBaseList = touLiuHttpClient.sendPenGongBaseRequest(ghId);
-        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);
+            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);
+                        msgDataList1.add(msgData);
+                    }
                 }
+                // 补充人工数据
+                groupDataList.addAll(groupDataBaseList);
+            } else {
+                log.error("get base data is null,ghId:" + ghId);
             }
-            // 补充人工数据
-            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()));
@@ -281,7 +283,7 @@ public class BuckStrategyV1 implements ReplyStrategyService {
                 cgiReplyBucketData.setMsgType(1);
                 cgiReplyBucketData.setTitle(x.getTitle());
                 VideoDetail videoDetail = videoDetailMap.get(x.getVideoId());
-                if (videoDetail !=null && StringUtils.isNotEmpty(videoDetail.getCover())) {
+                if (videoDetail != null && StringUtils.isNotEmpty(videoDetail.getCover())) {
                     cgiReplyBucketData.setCoverUrl(videoDetail.getCover());
                 } else {
                     cgiReplyBucketData.setCoverUrl(CDN_URL + x.getCoverUrl());

+ 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=""/>-->
 

+ 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);
+}

+ 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);
+        }
+    }
+}

+ 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();

+ 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>

+ 51 - 10
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;
@@ -53,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();
@@ -232,12 +233,48 @@ 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 {
-            int count = 0;
-            int newCount = 0;
             String cursor = "";
             do {
                 String res = getUserDetailList(staff.getCarrierId(), cursor, corpId);
@@ -250,10 +287,13 @@ public class WeComUserDataJob {
                 }
                 JSONArray externalContactList = jsonObject.getJSONArray("external_contact_list");
                 for (int i = 0; i < externalContactList.size(); i++) {
-                    JSONObject externalContact = externalContactList.getJSONObject(i).getJSONObject("external_contact");
                     JSONObject followInfo = externalContactList.getJSONObject(i).getJSONObject("follow_info");
                     Long createAt = followInfo.getLong("createtime");
-                    String externalUserId = externalContact.getString("external_userid");
+                    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)) {
@@ -262,9 +302,10 @@ public class WeComUserDataJob {
                 cursor = nextCursor;
             } while (StringUtils.isNotEmpty(cursor));
         } catch (IOException e) {
-            LarkRobotUtil.sendMessage("updateUser error" + e);
-            log.error("updateUser error", e);
+            log.error("getUserList error", e);
         }
+        result.put("count", count);
+        result.put("newCount", newCount);
         return result;
     }
 }