Browse Source

Merge branch '20250425-wyp-qwDatastatTotal' of Server/growth-manager into master

wangyunpeng 2 months ago
parent
commit
a095f4d6e4

+ 13 - 2
api-module/src/main/java/com/tzld/piaoquan/api/controller/contentplatform/ContentPlatformDatastatController.java

@@ -1,5 +1,6 @@
 package com.tzld.piaoquan.api.controller.contentplatform;
 
+import com.tzld.piaoquan.api.annotation.JwtIgnore;
 import com.tzld.piaoquan.api.job.ContentPlatformDatastatJob;
 import com.tzld.piaoquan.api.model.param.contentplatform.GzhDatastatListParam;
 import com.tzld.piaoquan.api.model.param.contentplatform.QwDatastatListParam;
@@ -47,18 +48,28 @@ public class ContentPlatformDatastatController {
         return CommonResponse.success(datastatService.qwDatastatExport(param));
     }
 
-    @ApiOperation(value = "公众号数据统计同步任务")
+    @ApiOperation(value = "公众号数据统计同步任务", hidden = true)
     @GetMapping("/job/syncGzhDatastat")
+    @JwtIgnore
     public CommonResponse<String> syncContentPlatformGzhDatastatJob() {
         job.syncContentPlatformGzhDatastatJob(null);
         return CommonResponse.success();
     }
 
-    @ApiOperation(value = "企微数据统计同步任务")
+    @ApiOperation(value = "企微数据统计同步任务", hidden = true)
     @GetMapping("/job/syncQwDatastat")
+    @JwtIgnore
     public CommonResponse<String> syncContentPlatformQwDatastatJob() {
         job.syncContentPlatformQwDatastatJob(null);
         return CommonResponse.success();
     }
 
+    @ApiOperation(value = "企微数据统计总计同步任务", hidden = true)
+    @GetMapping("/job/syncQwDatastatTotal")
+    @JwtIgnore
+    public CommonResponse<String> syncContentPlatformQwDatastatTotalJob() {
+        job.syncContentPlatformQwDatastatTotalJob(null);
+        return CommonResponse.success();
+    }
+
 }

+ 30 - 0
api-module/src/main/java/com/tzld/piaoquan/api/dao/mapper/contentplatform/ContentPlatformQwDataStatTotalMapper.java

@@ -0,0 +1,30 @@
+package com.tzld.piaoquan.api.dao.mapper.contentplatform;
+
+import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotal;
+import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotalExample;
+import java.util.List;
+import org.apache.ibatis.annotations.Param;
+
+public interface ContentPlatformQwDataStatTotalMapper {
+    long countByExample(ContentPlatformQwDataStatTotalExample example);
+
+    int deleteByExample(ContentPlatformQwDataStatTotalExample example);
+
+    int deleteByPrimaryKey(Long id);
+
+    int insert(ContentPlatformQwDataStatTotal record);
+
+    int insertSelective(ContentPlatformQwDataStatTotal record);
+
+    List<ContentPlatformQwDataStatTotal> selectByExample(ContentPlatformQwDataStatTotalExample example);
+
+    ContentPlatformQwDataStatTotal selectByPrimaryKey(Long id);
+
+    int updateByExampleSelective(@Param("record") ContentPlatformQwDataStatTotal record, @Param("example") ContentPlatformQwDataStatTotalExample example);
+
+    int updateByExample(@Param("record") ContentPlatformQwDataStatTotal record, @Param("example") ContentPlatformQwDataStatTotalExample example);
+
+    int updateByPrimaryKeySelective(ContentPlatformQwDataStatTotal record);
+
+    int updateByPrimaryKey(ContentPlatformQwDataStatTotal record);
+}

+ 8 - 3
api-module/src/main/java/com/tzld/piaoquan/api/dao/mapper/contentplatform/ext/ContentPlatformDataStatMapperExt.java

@@ -4,6 +4,7 @@ import com.tzld.piaoquan.api.model.param.contentplatform.GzhDatastatListParam;
 import com.tzld.piaoquan.api.model.param.contentplatform.QwDatastatListParam;
 import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhDataStat;
 import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStat;
+import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotal;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -31,10 +32,10 @@ public interface ContentPlatformDataStatMapperExt {
                                                                   @Param("offset") int offset,
                                                                   @Param("pageSize") Integer pageSize);
 
-    Integer getQwTotalDatastatCount(@Param("param") QwDatastatListParam param, @Param("createAccountId") Long createAccountId);
+    Integer getQwTotalDatastatCount(@Param("param") QwDatastatListParam param, @Param("channel") String channel);
 
-    List<ContentPlatformQwDataStat> getQwTotalDatastatList(@Param("param") QwDatastatListParam param,
-                                                           @Param("createAccountId") Long createAccountId,
+    List<ContentPlatformQwDataStatTotal> getQwTotalDatastatList(@Param("param") QwDatastatListParam param,
+                                                           @Param("channel") String channel,
                                                            @Param("offset") int offset,
                                                            @Param("pageSize") Integer pageSize);
 
@@ -58,4 +59,8 @@ public interface ContentPlatformDataStatMapperExt {
     void batchInsertGzhDatastat(@Param("records") List<ContentPlatformGzhDataStat> saveList);
 
     void batchInsertQwDatastat(@Param("records") List<ContentPlatformQwDataStat> saveList);
+
+    void batchInsertQwDatastatTotal(@Param("records") List<ContentPlatformQwDataStatTotal> saveList);
+
+    List<ContentPlatformQwDataStatTotal> getQwTotalDatastatScoreList(@Param("dt") String dt, @Param("channels") List<String> channels);
 }

+ 70 - 9
api-module/src/main/java/com/tzld/piaoquan/api/job/ContentPlatformDatastatJob.java

@@ -1,14 +1,11 @@
 package com.tzld.piaoquan.api.job;
 
 import com.aliyun.odps.data.Record;
-import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformGzhAccountMapper;
-import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformGzhDataStatMapper;
-import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformQwDataStatMapper;
-import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformQwPlanMapper;
+import com.tzld.piaoquan.api.component.AigcApiService;
+import com.tzld.piaoquan.api.dao.mapper.contentplatform.*;
 import com.tzld.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformDataStatMapperExt;
 import com.tzld.piaoquan.api.model.po.contentplatform.*;
 import com.tzld.piaoquan.api.model.vo.WxAccountDatastatVO;
-import com.tzld.piaoquan.api.component.AigcApiService;
 import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformPlanService;
 import com.tzld.piaoquan.growth.common.utils.DateUtil;
 import com.tzld.piaoquan.growth.common.utils.OdpsUtil;
@@ -21,10 +18,7 @@ import org.springframework.stereotype.Component;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -40,6 +34,9 @@ public class ContentPlatformDatastatJob {
     @Autowired
     private ContentPlatformQwDataStatMapper qwDataStatMapper;
 
+    @Autowired
+    private ContentPlatformQwDataStatTotalMapper qwDataStatTotalMapper;
+
     @Autowired
     private ContentPlatformQwPlanMapper qwPlanMapper;
 
@@ -155,6 +152,12 @@ public class ContentPlatformDatastatJob {
         return qwDataStatMapper.countByExample(example);
     }
 
+    private long getQwDatastatTotalCount(String dt) {
+        ContentPlatformQwDataStatTotalExample example = new ContentPlatformQwDataStatTotalExample();
+        example.createCriteria().andDateStrEqualTo(dt);
+        return qwDataStatTotalMapper.countByExample(example);
+    }
+
     @XxlJob("syncContentPlatformQwDatastatJob")
     public ReturnT<String> syncContentPlatformQwDatastatJob(String param) {
         String dt = DateUtil.getBeforeDayDateString("yyyyMMdd");
@@ -246,4 +249,62 @@ public class ContentPlatformDatastatJob {
         return qwPlanMapper.selectByExample(example);
     }
 
+
+    @XxlJob("syncContentPlatformQwDatastatTotalJob")
+    public ReturnT<String> syncContentPlatformQwDatastatTotalJob(String param) {
+        String dt = DateUtil.getBeforeDayDateString("yyyyMMdd");
+        long count = getQwDatastatTotalCount(dt);
+        if (count > 0) {
+            return ReturnT.SUCCESS;
+        }
+        Map<String, ContentPlatformQwDataStatTotal> saveMap = new HashMap<>();
+        String outSql = String.format("SELECT * FROM loghubods.qw_out_touliu_behavior_total WHERE dt=%s;", dt);
+        List<Record> outDataList = OdpsUtil.getOdpsData(outSql);
+        Long now = System.currentTimeMillis();
+        if (CollectionUtils.isNotEmpty(outDataList)) {
+            for (Record record : outDataList) {
+                ContentPlatformQwDataStatTotal item = new ContentPlatformQwDataStatTotal();
+                String channel = (String) record.get(33);
+                int firstLevelCount = Integer.parseInt((String) record.get(6));
+                if (firstLevelCount == 0) {
+                    continue;
+                }
+                item.setDateStr(dt);
+                item.setChannel(channel);
+                item.setFirstLevelCount(firstLevelCount);
+                item.setCreateTimestamp(now);
+                saveMap.put(channel, item);
+            }
+        }
+        String out2Sql = String.format("SELECT * FROM loghubods.qw_out2_touliu_behavior_total WHERE dt=%s;", dt);
+        List<Record> out2DataList = OdpsUtil.getOdpsData(out2Sql);
+        if (CollectionUtils.isNotEmpty(out2DataList)) {
+            for (Record record : out2DataList) {
+                ContentPlatformQwDataStatTotal item = new ContentPlatformQwDataStatTotal();
+                String channel = (String) record.get(33);
+                int firstLevelCount = Integer.parseInt((String) record.get(6));
+                if (firstLevelCount == 0) {
+                    continue;
+                }
+                item.setDateStr(dt);
+                item.setChannel(channel);
+                item.setFirstLevelCount(firstLevelCount);
+                item.setCreateTimestamp(now);
+                saveMap.put(channel, item);
+            }
+        }
+        List<ContentPlatformQwDataStatTotal> saveList = new ArrayList<>(saveMap.values());
+        if (CollectionUtils.isNotEmpty(saveList)) {
+            List<String> channels = saveList.stream().map(ContentPlatformQwDataStatTotal::getChannel).distinct().collect(Collectors.toList());
+            List<ContentPlatformQwDataStatTotal> channelScoreList = dataStatMapperExt.getQwTotalDatastatScoreList(dt, channels);
+            Map<String, Double> channelScoreMap = channelScoreList.stream()
+                    .collect(Collectors.toMap(ContentPlatformQwDataStatTotal::getChannel, ContentPlatformQwDataStatTotal::getScore, (a, b) -> a));
+            for (ContentPlatformQwDataStatTotal item : saveList) {
+                item.setScore(channelScoreMap.get(item.getChannel()));
+            }
+            dataStatMapperExt.batchInsertQwDatastatTotal(saveList);
+        }
+        return ReturnT.SUCCESS;
+    }
+
 }

+ 79 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/po/contentplatform/ContentPlatformQwDataStatTotal.java

@@ -0,0 +1,79 @@
+package com.tzld.piaoquan.api.model.po.contentplatform;
+
+public class ContentPlatformQwDataStatTotal {
+    private Long id;
+
+    private String dateStr;
+
+    private String channel;
+
+    private Integer firstLevelCount;
+
+    private Double score;
+
+    private Long createTimestamp;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getDateStr() {
+        return dateStr;
+    }
+
+    public void setDateStr(String dateStr) {
+        this.dateStr = dateStr;
+    }
+
+    public String getChannel() {
+        return channel;
+    }
+
+    public void setChannel(String channel) {
+        this.channel = channel;
+    }
+
+    public Integer getFirstLevelCount() {
+        return firstLevelCount;
+    }
+
+    public void setFirstLevelCount(Integer firstLevelCount) {
+        this.firstLevelCount = firstLevelCount;
+    }
+
+    public Double getScore() {
+        return score;
+    }
+
+    public void setScore(Double score) {
+        this.score = score;
+    }
+
+    public Long getCreateTimestamp() {
+        return createTimestamp;
+    }
+
+    public void setCreateTimestamp(Long createTimestamp) {
+        this.createTimestamp = createTimestamp;
+    }
+
+    @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(", dateStr=").append(dateStr);
+        sb.append(", channel=").append(channel);
+        sb.append(", firstLevelCount=").append(firstLevelCount);
+        sb.append(", score=").append(score);
+        sb.append(", createTimestamp=").append(createTimestamp);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 591 - 0
api-module/src/main/java/com/tzld/piaoquan/api/model/po/contentplatform/ContentPlatformQwDataStatTotalExample.java

@@ -0,0 +1,591 @@
+package com.tzld.piaoquan.api.model.po.contentplatform;
+
+import com.tzld.piaoquan.growth.common.utils.page.Page;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ContentPlatformQwDataStatTotalExample {
+    protected String orderByClause;
+
+    protected boolean distinct;
+
+    protected List<Criteria> oredCriteria;
+
+    protected Page page;
+
+    public ContentPlatformQwDataStatTotalExample() {
+        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 andDateStrIsNull() {
+            addCriterion("date_str is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateStrIsNotNull() {
+            addCriterion("date_str is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateStrEqualTo(String value) {
+            addCriterion("date_str =", value, "dateStr");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateStrNotEqualTo(String value) {
+            addCriterion("date_str <>", value, "dateStr");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateStrGreaterThan(String value) {
+            addCriterion("date_str >", value, "dateStr");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateStrGreaterThanOrEqualTo(String value) {
+            addCriterion("date_str >=", value, "dateStr");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateStrLessThan(String value) {
+            addCriterion("date_str <", value, "dateStr");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateStrLessThanOrEqualTo(String value) {
+            addCriterion("date_str <=", value, "dateStr");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateStrLike(String value) {
+            addCriterion("date_str like", value, "dateStr");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateStrNotLike(String value) {
+            addCriterion("date_str not like", value, "dateStr");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateStrIn(List<String> values) {
+            addCriterion("date_str in", values, "dateStr");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateStrNotIn(List<String> values) {
+            addCriterion("date_str not in", values, "dateStr");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateStrBetween(String value1, String value2) {
+            addCriterion("date_str between", value1, value2, "dateStr");
+            return (Criteria) this;
+        }
+
+        public Criteria andDateStrNotBetween(String value1, String value2) {
+            addCriterion("date_str not between", value1, value2, "dateStr");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelIsNull() {
+            addCriterion("channel is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelIsNotNull() {
+            addCriterion("channel is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelEqualTo(String value) {
+            addCriterion("channel =", value, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelNotEqualTo(String value) {
+            addCriterion("channel <>", value, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelGreaterThan(String value) {
+            addCriterion("channel >", value, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelGreaterThanOrEqualTo(String value) {
+            addCriterion("channel >=", value, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelLessThan(String value) {
+            addCriterion("channel <", value, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelLessThanOrEqualTo(String value) {
+            addCriterion("channel <=", value, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelLike(String value) {
+            addCriterion("channel like", value, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelNotLike(String value) {
+            addCriterion("channel not like", value, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelIn(List<String> values) {
+            addCriterion("channel in", values, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelNotIn(List<String> values) {
+            addCriterion("channel not in", values, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelBetween(String value1, String value2) {
+            addCriterion("channel between", value1, value2, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andChannelNotBetween(String value1, String value2) {
+            addCriterion("channel not between", value1, value2, "channel");
+            return (Criteria) this;
+        }
+
+        public Criteria andFirstLevelCountIsNull() {
+            addCriterion("first_level_count is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andFirstLevelCountIsNotNull() {
+            addCriterion("first_level_count is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andFirstLevelCountEqualTo(Integer value) {
+            addCriterion("first_level_count =", value, "firstLevelCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andFirstLevelCountNotEqualTo(Integer value) {
+            addCriterion("first_level_count <>", value, "firstLevelCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andFirstLevelCountGreaterThan(Integer value) {
+            addCriterion("first_level_count >", value, "firstLevelCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andFirstLevelCountGreaterThanOrEqualTo(Integer value) {
+            addCriterion("first_level_count >=", value, "firstLevelCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andFirstLevelCountLessThan(Integer value) {
+            addCriterion("first_level_count <", value, "firstLevelCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andFirstLevelCountLessThanOrEqualTo(Integer value) {
+            addCriterion("first_level_count <=", value, "firstLevelCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andFirstLevelCountIn(List<Integer> values) {
+            addCriterion("first_level_count in", values, "firstLevelCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andFirstLevelCountNotIn(List<Integer> values) {
+            addCriterion("first_level_count not in", values, "firstLevelCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andFirstLevelCountBetween(Integer value1, Integer value2) {
+            addCriterion("first_level_count between", value1, value2, "firstLevelCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andFirstLevelCountNotBetween(Integer value1, Integer value2) {
+            addCriterion("first_level_count not between", value1, value2, "firstLevelCount");
+            return (Criteria) this;
+        }
+
+        public Criteria andScoreIsNull() {
+            addCriterion("score is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andScoreIsNotNull() {
+            addCriterion("score is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andScoreEqualTo(Double value) {
+            addCriterion("score =", value, "score");
+            return (Criteria) this;
+        }
+
+        public Criteria andScoreNotEqualTo(Double value) {
+            addCriterion("score <>", value, "score");
+            return (Criteria) this;
+        }
+
+        public Criteria andScoreGreaterThan(Double value) {
+            addCriterion("score >", value, "score");
+            return (Criteria) this;
+        }
+
+        public Criteria andScoreGreaterThanOrEqualTo(Double value) {
+            addCriterion("score >=", value, "score");
+            return (Criteria) this;
+        }
+
+        public Criteria andScoreLessThan(Double value) {
+            addCriterion("score <", value, "score");
+            return (Criteria) this;
+        }
+
+        public Criteria andScoreLessThanOrEqualTo(Double value) {
+            addCriterion("score <=", value, "score");
+            return (Criteria) this;
+        }
+
+        public Criteria andScoreIn(List<Double> values) {
+            addCriterion("score in", values, "score");
+            return (Criteria) this;
+        }
+
+        public Criteria andScoreNotIn(List<Double> values) {
+            addCriterion("score not in", values, "score");
+            return (Criteria) this;
+        }
+
+        public Criteria andScoreBetween(Double value1, Double value2) {
+            addCriterion("score between", value1, value2, "score");
+            return (Criteria) this;
+        }
+
+        public Criteria andScoreNotBetween(Double value1, Double value2) {
+            addCriterion("score not between", value1, value2, "score");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimestampIsNull() {
+            addCriterion("create_timestamp is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimestampIsNotNull() {
+            addCriterion("create_timestamp is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimestampEqualTo(Long value) {
+            addCriterion("create_timestamp =", value, "createTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimestampNotEqualTo(Long value) {
+            addCriterion("create_timestamp <>", value, "createTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimestampGreaterThan(Long value) {
+            addCriterion("create_timestamp >", value, "createTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimestampGreaterThanOrEqualTo(Long value) {
+            addCriterion("create_timestamp >=", value, "createTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimestampLessThan(Long value) {
+            addCriterion("create_timestamp <", value, "createTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimestampLessThanOrEqualTo(Long value) {
+            addCriterion("create_timestamp <=", value, "createTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimestampIn(List<Long> values) {
+            addCriterion("create_timestamp in", values, "createTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimestampNotIn(List<Long> values) {
+            addCriterion("create_timestamp not in", values, "createTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimestampBetween(Long value1, Long value2) {
+            addCriterion("create_timestamp between", value1, value2, "createTimestamp");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimestampNotBetween(Long value1, Long value2) {
+            addCriterion("create_timestamp not between", value1, value2, "createTimestamp");
+            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);
+        }
+    }
+}

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

@@ -133,14 +133,20 @@ public class ContentPlatformDatastatServiceImpl implements ContentPlatformDatast
         ContentPlatformAccount user = LoginUserContext.getUser();
         Page<QwDatastatItemVO> result = new Page<>(param.getPageNum(), param.getPageSize());
         int offset = (param.getPageNum() - 1) * param.getPageSize();
-        int count = dataStatMapperExt.getQwTotalDatastatCount(param, user.getId());
+        int count = dataStatMapperExt.getQwTotalDatastatCount(param, user.getChannel());
         result.setTotalSize(count);
         if (count == 0) {
             return result;
         }
-        List<ContentPlatformQwDataStat> datastatList = dataStatMapperExt.getQwTotalDatastatList(param,
-                user.getId(), offset, param.getPageSize());
-        List<QwDatastatItemVO> list = buildQwRootSourceIdDatastatItemVOList(datastatList);
+        List<ContentPlatformQwDataStatTotal> datastatList = dataStatMapperExt.getQwTotalDatastatList(param,
+                user.getChannel(), offset, param.getPageSize());
+        List<QwDatastatItemVO> list = datastatList.stream().map(datastat -> {
+            QwDatastatItemVO vo = new QwDatastatItemVO();
+            vo.setDateStr(datastat.getDateStr());
+            vo.setFirstLevel(datastat.getFirstLevelCount());
+            vo.setScore(datastat.getScore());
+            return vo;
+        }).collect(Collectors.toList());
         result.setObjs(list);
         return result;
     }

+ 231 - 0
api-module/src/main/resources/mapper/contentplatform/ContentPlatformQwDataStatTotalMapper.xml

@@ -0,0 +1,231 @@
+<?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.contentplatform.ContentPlatformQwDataStatTotalMapper">
+  <resultMap id="BaseResultMap" type="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotal">
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="date_str" jdbcType="VARCHAR" property="dateStr" />
+    <result column="channel" jdbcType="VARCHAR" property="channel" />
+    <result column="first_level_count" jdbcType="INTEGER" property="firstLevelCount" />
+    <result column="score" jdbcType="DOUBLE" property="score" />
+    <result column="create_timestamp" jdbcType="BIGINT" property="createTimestamp" />
+  </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, date_str, channel, first_level_count, score, create_timestamp
+  </sql>
+  <select id="selectByExample" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotalExample" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from content_platform_qw_datastat_total
+    <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 content_platform_qw_datastat_total
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+    delete from content_platform_qw_datastat_total
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotalExample">
+    delete from content_platform_qw_datastat_total
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotal">
+    insert into content_platform_qw_datastat_total (id, date_str, channel, 
+      first_level_count, score, create_timestamp
+      )
+    values (#{id,jdbcType=BIGINT}, #{dateStr,jdbcType=VARCHAR}, #{channel,jdbcType=VARCHAR}, 
+      #{firstLevelCount,jdbcType=INTEGER}, #{score,jdbcType=DOUBLE}, #{createTimestamp,jdbcType=BIGINT}
+      )
+  </insert>
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotal">
+    insert into content_platform_qw_datastat_total
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="dateStr != null">
+        date_str,
+      </if>
+      <if test="channel != null">
+        channel,
+      </if>
+      <if test="firstLevelCount != null">
+        first_level_count,
+      </if>
+      <if test="score != null">
+        score,
+      </if>
+      <if test="createTimestamp != null">
+        create_timestamp,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=BIGINT},
+      </if>
+      <if test="dateStr != null">
+        #{dateStr,jdbcType=VARCHAR},
+      </if>
+      <if test="channel != null">
+        #{channel,jdbcType=VARCHAR},
+      </if>
+      <if test="firstLevelCount != null">
+        #{firstLevelCount,jdbcType=INTEGER},
+      </if>
+      <if test="score != null">
+        #{score,jdbcType=DOUBLE},
+      </if>
+      <if test="createTimestamp != null">
+        #{createTimestamp,jdbcType=BIGINT},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotalExample" resultType="java.lang.Long">
+    select count(*) from content_platform_qw_datastat_total
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    update content_platform_qw_datastat_total
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=BIGINT},
+      </if>
+      <if test="record.dateStr != null">
+        date_str = #{record.dateStr,jdbcType=VARCHAR},
+      </if>
+      <if test="record.channel != null">
+        channel = #{record.channel,jdbcType=VARCHAR},
+      </if>
+      <if test="record.firstLevelCount != null">
+        first_level_count = #{record.firstLevelCount,jdbcType=INTEGER},
+      </if>
+      <if test="record.score != null">
+        score = #{record.score,jdbcType=DOUBLE},
+      </if>
+      <if test="record.createTimestamp != null">
+        create_timestamp = #{record.createTimestamp,jdbcType=BIGINT},
+      </if>
+    </set>
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExample" parameterType="map">
+    update content_platform_qw_datastat_total
+    set id = #{record.id,jdbcType=BIGINT},
+      date_str = #{record.dateStr,jdbcType=VARCHAR},
+      channel = #{record.channel,jdbcType=VARCHAR},
+      first_level_count = #{record.firstLevelCount,jdbcType=INTEGER},
+      score = #{record.score,jdbcType=DOUBLE},
+      create_timestamp = #{record.createTimestamp,jdbcType=BIGINT}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotal">
+    update content_platform_qw_datastat_total
+    <set>
+      <if test="dateStr != null">
+        date_str = #{dateStr,jdbcType=VARCHAR},
+      </if>
+      <if test="channel != null">
+        channel = #{channel,jdbcType=VARCHAR},
+      </if>
+      <if test="firstLevelCount != null">
+        first_level_count = #{firstLevelCount,jdbcType=INTEGER},
+      </if>
+      <if test="score != null">
+        score = #{score,jdbcType=DOUBLE},
+      </if>
+      <if test="createTimestamp != null">
+        create_timestamp = #{createTimestamp,jdbcType=BIGINT},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotal">
+    update content_platform_qw_datastat_total
+    set date_str = #{dateStr,jdbcType=VARCHAR},
+      channel = #{channel,jdbcType=VARCHAR},
+      first_level_count = #{firstLevelCount,jdbcType=INTEGER},
+      score = #{score,jdbcType=DOUBLE},
+      create_timestamp = #{createTimestamp,jdbcType=BIGINT}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+</mapper>

+ 25 - 12
api-module/src/main/resources/mapper/contentplatform/ext/ContentPlatformDataStatMapperExt.xml

@@ -67,21 +67,16 @@
 
     <select id="getQwTotalDatastatCount" resultType="java.lang.Integer">
         select count(1)
-        from (select cpqd.date_str
-        from content_platform_qw_datastat cpqd
-         join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
-        where cpqp.create_account_id = #{createAccountId}
-        group by cpqd.date_str) t
+        from content_platform_qw_datastat_total
+        where channel = #{channel}
     </select>
 
     <select id="getQwTotalDatastatList"
-            resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStat">
-        select cpqd.date_str, sum(cpqd.first_level_count) as first_level_count, avg(cpqd.score) as score
-        from content_platform_qw_datastat cpqd
-         join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
-        where cpqp.create_account_id = #{createAccountId}
-        group by cpqd.date_str
-        order by cpqd.date_str desc
+            resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotal">
+        select date_str, channel, first_level_count, score
+        from content_platform_qw_datastat_total
+        where channel = #{channel}
+        order by date_str desc
         limit #{offset}, #{pageSize}
     </select>
 
@@ -147,5 +142,23 @@
         </foreach>
     </insert>
 
+    <insert id="batchInsertQwDatastatTotal">
+        insert into content_platform_qw_datastat_total (date_str, channel, first_level_count, score, create_timestamp)
+        values
+        <foreach collection="records" item="item" separator=",">
+            (#{item.dateStr}, #{item.channel}, #{item.firstLevelCount}, #{item.score}, #{item.createTimestamp})
+        </foreach>
+    </insert>
+
+    <select id="getQwTotalDatastatScoreList"
+            resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotal">
+        select cpa.channel, round(avg(cpqd.score), 2) as score
+        from content_platform_qw_datastat cpqd
+        join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
+        join content_platform_account cpa on cpa.id = cpqp.create_account_id
+        where cpqd.date_str = #{dt}
+        group by cpa.channel
+    </select>
+
 
 </mapper>

+ 2 - 2
api-module/src/main/resources/mapper/contentplatform/ext/ContentPlatformPlanMapperExt.xml

@@ -135,7 +135,7 @@
           and type = #{param.type}
           and status = 1
         <if test="param.scene != null">
-            and scene &lt; #{param.scene}
+            and scene = #{param.scene}
         </if>
         <if test="param.title != null and param.title != ''">
             and id in (select plan_id from content_platform_qw_plan_video where title like concat('%', #{param.title},
@@ -151,7 +151,7 @@
         and type = #{param.type}
         and status = 1
         <if test="param.scene != null">
-            and scene &lt; #{param.scene}
+            and scene = #{param.scene}
         </if>
         <if test="param.title != null and param.title != ''">
             and id in (select plan_id from content_platform_qw_plan_video where title like concat('%', #{param.title},

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

@@ -56,6 +56,7 @@
         <table tableName="content_platform_gzh_plan" domainObjectName="ContentPlatformGzhPlan" alias=""/>
         <table tableName="content_platform_gzh_plan_video" domainObjectName="ContentPlatformGzhPlanVideo" alias=""/>
         <table tableName="content_platform_qw_datastat" domainObjectName="ContentPlatformQwDataStat" alias=""/>
+        <table tableName="content_platform_qw_datastat_total" domainObjectName="ContentPlatformQwDataStatTotal" alias=""/>
         <table tableName="content_platform_qw_plan" domainObjectName="ContentPlatformQwPlan" alias=""/>
         <table tableName="content_platform_qw_plan_video" domainObjectName="ContentPlatformQwPlanVideo" alias=""/>
         <table tableName="content_platform_verify_code" domainObjectName="ContentPlatformVerifyCode" alias=""/>