Kaynağa Gözat

数据统计

wangyunpeng 2 ay önce
ebeveyn
işleme
85edd75d6a

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

@@ -0,0 +1,57 @@
+package com.tzld.piaoquan.api.dao.mapper.contentplatform.ext;
+
+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 org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface ContentPlatformDataStatMapperExt {
+
+    int getGzhAccountDatastatCount(@Param("param") GzhDatastatListParam param, @Param("createAccountId") Long createAccountId);
+
+    List<ContentPlatformGzhDataStat> getGzhAccountDatastatList(@Param("param") GzhDatastatListParam param,
+                                                               @Param("createAccountId") Long createAccountId,
+                                                               @Param("offset") int offset,
+                                                               @Param("pageSize") Integer pageSize);
+
+    int getGzhTotalDatastatCount(@Param("param") GzhDatastatListParam param, @Param("createAccountId") Long createAccountId);
+
+    List<ContentPlatformGzhDataStat> getGzhTotalDatastatList(@Param("param") GzhDatastatListParam param,
+                                                             @Param("createAccountId") Long createAccountId,
+                                                             @Param("offset") int offset,
+                                                             @Param("pageSize") Integer pageSize);
+
+    int getQwRootSourceIdDatastatCount(@Param("param") QwDatastatListParam param, @Param("createAccountId") Long createAccountId);
+
+    List<ContentPlatformQwDataStat> getQwRootSourceIdDatastatList(@Param("param") QwDatastatListParam param,
+                                                                  @Param("createAccountId") Long createAccountId,
+                                                                  @Param("offset") int offset,
+                                                                  @Param("pageSize") Integer pageSize);
+
+    int getQwTotalDatastatCount(@Param("param") QwDatastatListParam param, @Param("createAccountId") Long createAccountId);
+
+    List<ContentPlatformQwDataStat> getQwTotalDatastatList(@Param("param") QwDatastatListParam param,
+                                                           @Param("createAccountId") Long createAccountId,
+                                                           @Param("offset") int offset,
+                                                           @Param("pageSize") Integer pageSize);
+
+    int getQwSceneDatastatCount(@Param("param") QwDatastatListParam param,
+                                @Param("scene") Integer scene,
+                                @Param("createAccountId") Long createAccountId);
+
+    List<ContentPlatformQwDataStat> getQwSceneDatastatList(@Param("param") QwDatastatListParam param,
+                                                           @Param("scene") Integer scene,
+                                                           @Param("createAccountId") Long createAccountId,
+                                                           @Param("offset") int offset,
+                                                           @Param("pageSize") Integer pageSize);
+
+    int getQwReplyDatastatCount(@Param("param") QwDatastatListParam param, @Param("createAccountId") Long createAccountId);
+
+    List<ContentPlatformQwDataStat> getReplyDatastatList(@Param("param") QwDatastatListParam param,
+                                                         @Param("createAccountId") Long createAccountId,
+                                                         @Param("offset") int offset,
+                                                         @Param("pageSize") Integer pageSize);
+}

+ 6 - 6
api-module/src/main/java/com/tzld/piaoquan/api/model/po/contentplatform/ContentPlatformGzhDataStat.java

@@ -11,7 +11,7 @@ public class ContentPlatformGzhDataStat {
 
     private Integer firstLevelCount;
 
-    private Double socre;
+    private Double score;
 
     private Long createTimestamp;
 
@@ -55,12 +55,12 @@ public class ContentPlatformGzhDataStat {
         this.firstLevelCount = firstLevelCount;
     }
 
-    public Double getSocre() {
-        return socre;
+    public Double getScore() {
+        return score;
     }
 
-    public void setSocre(Double socre) {
-        this.socre = socre;
+    public void setScore(Double score) {
+        this.score = score;
     }
 
     public Long getCreateTimestamp() {
@@ -82,7 +82,7 @@ public class ContentPlatformGzhDataStat {
         sb.append(", accountId=").append(accountId);
         sb.append(", fansIncreaseCount=").append(fansIncreaseCount);
         sb.append(", firstLevelCount=").append(firstLevelCount);
-        sb.append(", socre=").append(socre);
+        sb.append(", score=").append(score);
         sb.append(", createTimestamp=").append(createTimestamp);
         sb.append("]");
         return sb.toString();

+ 24 - 24
api-module/src/main/java/com/tzld/piaoquan/api/model/po/contentplatform/ContentPlatformGzhDataStatExample.java

@@ -425,63 +425,63 @@ public class ContentPlatformGzhDataStatExample {
             return (Criteria) this;
         }
 
-        public Criteria andSocreIsNull() {
-            addCriterion("socre is null");
+        public Criteria andScoreIsNull() {
+            addCriterion("score is null");
             return (Criteria) this;
         }
 
-        public Criteria andSocreIsNotNull() {
-            addCriterion("socre is not null");
+        public Criteria andScoreIsNotNull() {
+            addCriterion("score is not null");
             return (Criteria) this;
         }
 
-        public Criteria andSocreEqualTo(Double value) {
-            addCriterion("socre =", value, "socre");
+        public Criteria andScoreEqualTo(Double value) {
+            addCriterion("score =", value, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreNotEqualTo(Double value) {
-            addCriterion("socre <>", value, "socre");
+        public Criteria andScoreNotEqualTo(Double value) {
+            addCriterion("score <>", value, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreGreaterThan(Double value) {
-            addCriterion("socre >", value, "socre");
+        public Criteria andScoreGreaterThan(Double value) {
+            addCriterion("score >", value, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreGreaterThanOrEqualTo(Double value) {
-            addCriterion("socre >=", value, "socre");
+        public Criteria andScoreGreaterThanOrEqualTo(Double value) {
+            addCriterion("score >=", value, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreLessThan(Double value) {
-            addCriterion("socre <", value, "socre");
+        public Criteria andScoreLessThan(Double value) {
+            addCriterion("score <", value, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreLessThanOrEqualTo(Double value) {
-            addCriterion("socre <=", value, "socre");
+        public Criteria andScoreLessThanOrEqualTo(Double value) {
+            addCriterion("score <=", value, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreIn(List<Double> values) {
-            addCriterion("socre in", values, "socre");
+        public Criteria andScoreIn(List<Double> values) {
+            addCriterion("score in", values, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreNotIn(List<Double> values) {
-            addCriterion("socre not in", values, "socre");
+        public Criteria andScoreNotIn(List<Double> values) {
+            addCriterion("score not in", values, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreBetween(Double value1, Double value2) {
-            addCriterion("socre between", value1, value2, "socre");
+        public Criteria andScoreBetween(Double value1, Double value2) {
+            addCriterion("score between", value1, value2, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreNotBetween(Double value1, Double value2) {
-            addCriterion("socre not between", value1, value2, "socre");
+        public Criteria andScoreNotBetween(Double value1, Double value2) {
+            addCriterion("score not between", value1, value2, "score");
             return (Criteria) this;
         }
 

+ 6 - 6
api-module/src/main/java/com/tzld/piaoquan/api/model/po/contentplatform/ContentPlatformQwDataStat.java

@@ -9,7 +9,7 @@ public class ContentPlatformQwDataStat {
 
     private Integer firstLevelCount;
 
-    private Double socre;
+    private Double score;
 
     private Long createTimestamp;
 
@@ -45,12 +45,12 @@ public class ContentPlatformQwDataStat {
         this.firstLevelCount = firstLevelCount;
     }
 
-    public Double getSocre() {
-        return socre;
+    public Double getScore() {
+        return score;
     }
 
-    public void setSocre(Double socre) {
-        this.socre = socre;
+    public void setScore(Double score) {
+        this.score = score;
     }
 
     public Long getCreateTimestamp() {
@@ -71,7 +71,7 @@ public class ContentPlatformQwDataStat {
         sb.append(", dateStr=").append(dateStr);
         sb.append(", rootSourceId=").append(rootSourceId);
         sb.append(", firstLevelCount=").append(firstLevelCount);
-        sb.append(", socre=").append(socre);
+        sb.append(", score=").append(score);
         sb.append(", createTimestamp=").append(createTimestamp);
         sb.append("]");
         return sb.toString();

+ 24 - 24
api-module/src/main/java/com/tzld/piaoquan/api/model/po/contentplatform/ContentPlatformQwDataStatExample.java

@@ -375,63 +375,63 @@ public class ContentPlatformQwDataStatExample {
             return (Criteria) this;
         }
 
-        public Criteria andSocreIsNull() {
-            addCriterion("socre is null");
+        public Criteria andScoreIsNull() {
+            addCriterion("score is null");
             return (Criteria) this;
         }
 
-        public Criteria andSocreIsNotNull() {
-            addCriterion("socre is not null");
+        public Criteria andScoreIsNotNull() {
+            addCriterion("score is not null");
             return (Criteria) this;
         }
 
-        public Criteria andSocreEqualTo(Double value) {
-            addCriterion("socre =", value, "socre");
+        public Criteria andScoreEqualTo(Double value) {
+            addCriterion("score =", value, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreNotEqualTo(Double value) {
-            addCriterion("socre <>", value, "socre");
+        public Criteria andScoreNotEqualTo(Double value) {
+            addCriterion("score <>", value, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreGreaterThan(Double value) {
-            addCriterion("socre >", value, "socre");
+        public Criteria andScoreGreaterThan(Double value) {
+            addCriterion("score >", value, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreGreaterThanOrEqualTo(Double value) {
-            addCriterion("socre >=", value, "socre");
+        public Criteria andScoreGreaterThanOrEqualTo(Double value) {
+            addCriterion("score >=", value, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreLessThan(Double value) {
-            addCriterion("socre <", value, "socre");
+        public Criteria andScoreLessThan(Double value) {
+            addCriterion("score <", value, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreLessThanOrEqualTo(Double value) {
-            addCriterion("socre <=", value, "socre");
+        public Criteria andScoreLessThanOrEqualTo(Double value) {
+            addCriterion("score <=", value, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreIn(List<Double> values) {
-            addCriterion("socre in", values, "socre");
+        public Criteria andScoreIn(List<Double> values) {
+            addCriterion("score in", values, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreNotIn(List<Double> values) {
-            addCriterion("socre not in", values, "socre");
+        public Criteria andScoreNotIn(List<Double> values) {
+            addCriterion("score not in", values, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreBetween(Double value1, Double value2) {
-            addCriterion("socre between", value1, value2, "socre");
+        public Criteria andScoreBetween(Double value1, Double value2) {
+            addCriterion("score between", value1, value2, "score");
             return (Criteria) this;
         }
 
-        public Criteria andSocreNotBetween(Double value1, Double value2) {
-            addCriterion("socre not between", value1, value2, "socre");
+        public Criteria andScoreNotBetween(Double value1, Double value2) {
+            addCriterion("score not between", value1, value2, "score");
             return (Criteria) this;
         }
 

+ 6 - 2
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/ContentPlatformPlanService.java

@@ -1,8 +1,7 @@
 package com.tzld.piaoquan.api.service.contentplatform;
 
 import com.tzld.piaoquan.api.model.param.contentplatform.*;
-import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPlan;
-import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPlanVideo;
+import com.tzld.piaoquan.api.model.po.contentplatform.*;
 import com.tzld.piaoquan.api.model.vo.contentplatform.GzhPlanItemVO;
 import com.tzld.piaoquan.api.model.vo.contentplatform.QwPlanItemVO;
 import com.tzld.piaoquan.api.model.vo.contentplatform.VideoContentItemVO;
@@ -28,4 +27,9 @@ public interface ContentPlatformPlanService {
     List<ContentPlatformGzhPlan> getGzhPlanListByCooperateAccountId(Long accountId);
 
     List<ContentPlatformGzhPlanVideo> getGzhPlanVideoListByCooperateAccountId(String ghId);
+
+    List<ContentPlatformQwPlan> getQwPlanListByRootSourceIds(List<String> rootSourceIds);
+
+    List<ContentPlatformQwPlanVideo> getQwPlanVideoListByPlanIds(List<Long> planIds);
+
 }

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

@@ -1,26 +1,214 @@
 package com.tzld.piaoquan.api.service.contentplatform.impl;
 
+import com.tzld.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformDataStatMapperExt;
+import com.tzld.piaoquan.api.model.config.LoginUserContext;
 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.*;
 import com.tzld.piaoquan.api.model.vo.contentplatform.GzhDatastatItemVO;
 import com.tzld.piaoquan.api.model.vo.contentplatform.QwDatastatItemVO;
+import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformCooperateAccountService;
 import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformDatastatService;
+import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformPlanService;
 import com.tzld.piaoquan.growth.common.utils.page.Page;
-import lombok.Data;
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class ContentPlatformDatastatServiceImpl implements ContentPlatformDatastatService {
+
+    @Autowired
+    ContentPlatformDataStatMapperExt dataStatMapperExt;
+    @Autowired
+    ContentPlatformCooperateAccountService cooperateAccountService;
+    @Autowired
+    ContentPlatformPlanService planService;
+
     @Override
     public Page<GzhDatastatItemVO> gzhDatastatList(GzhDatastatListParam param) {
-        return null;
+        switch (param.getType()) {
+            case 0:
+                return gzhTotalDatastatList(param);
+            case 1:
+                return gzhAccountDatastatList(param);
+            default:
+                return gzhAccountDatastatList(param);
+        }
+    }
+
+    private Page<GzhDatastatItemVO> gzhTotalDatastatList(GzhDatastatListParam param) {
+        ContentPlatformAccount user = LoginUserContext.getUser();
+        Page<GzhDatastatItemVO> result = new Page<>(param.getPageNum(), param.getPageSize());
+        int offset = (param.getPageNum() - 1) * param.getPageSize();
+        int count = dataStatMapperExt.getGzhTotalDatastatCount(param, user.getId());
+        result.setTotalSize(count);
+        if (count == 0) {
+            return result;
+        }
+        List<ContentPlatformGzhDataStat> datastatList = dataStatMapperExt.getGzhTotalDatastatList(param,
+                user.getId(), offset, param.getPageSize());
+        List<GzhDatastatItemVO> list = buildGzhDatastatItemVOList(param.getType(), datastatList);
+        result.setObjs(list);
+        return result;
+    }
+
+    private Page<GzhDatastatItemVO> gzhAccountDatastatList(GzhDatastatListParam param) {
+        ContentPlatformAccount user = LoginUserContext.getUser();
+        Page<GzhDatastatItemVO> result = new Page<>(param.getPageNum(), param.getPageSize());
+        int offset = (param.getPageNum() - 1) * param.getPageSize();
+        int count = dataStatMapperExt.getGzhAccountDatastatCount(param, user.getId());
+        result.setTotalSize(count);
+        if (count == 0) {
+            return result;
+        }
+        List<ContentPlatformGzhDataStat> datastatList = dataStatMapperExt.getGzhAccountDatastatList(param,
+                user.getId(), offset, param.getPageSize());
+        List<GzhDatastatItemVO> list = buildGzhDatastatItemVOList(param.getType(), datastatList);
+        result.setObjs(list);
+        return result;
+    }
+
+    private List<GzhDatastatItemVO> buildGzhDatastatItemVOList(Integer type, List<ContentPlatformGzhDataStat> datastatList) {
+        if (CollectionUtils.isEmpty(datastatList)) {
+            return null;
+        }
+        Map<Long, ContentPlatformGzhAccount> accountMap = new HashMap<>();
+        if (type != 0) {
+            List<Long> accountIds = datastatList.stream().map(ContentPlatformGzhDataStat::getAccountId).distinct().collect(Collectors.toList());
+            List<ContentPlatformGzhAccount> accountList = cooperateAccountService.getAccountListByIds(accountIds);
+            accountMap = accountList.stream().collect(Collectors.toMap(ContentPlatformGzhAccount::getId, a -> a));
+        }
+        List<GzhDatastatItemVO> result = new ArrayList<>();
+        for (ContentPlatformGzhDataStat datastat : datastatList) {
+            GzhDatastatItemVO vo = new GzhDatastatItemVO();
+            vo.setDateStr(datastat.getDateStr());
+            ContentPlatformGzhAccount account = accountMap.get(datastat.getAccountId());
+            if (Objects.nonNull(account)) {
+                vo.setName(account.getName());
+            }
+            vo.setFansIncreaseCount(datastat.getFansIncreaseCount());
+            vo.setFirstLevel(datastat.getFirstLevelCount());
+            vo.setScore(datastat.getScore());
+            if (Objects.nonNull(vo.getFansIncreaseCount()) && vo.getFansIncreaseCount() > 0) {
+                vo.setOpenRate(vo.getFirstLevel() / (double) vo.getFansIncreaseCount());
+            }
+            result.add(vo);
+        }
+        return result;
     }
 
     @Override
     public Page<QwDatastatItemVO> qwDatastatList(QwDatastatListParam param) {
-        return null;
+        switch (param.getType()) {
+            case 0:
+                return qwTotalDatastatList(param);
+            case 1:
+                return qwSceneDatastatList(param, 0);
+            case 2:
+                return qwSceneDatastatList(param, 1);
+            case 3:
+                return qwReplyDatastatList(param);
+            case 4:
+                return qwRootSourceIdDatastatList(param);
+            default:
+                return qwRootSourceIdDatastatList(param);
+        }
+    }
+
+    private Page<QwDatastatItemVO> qwTotalDatastatList(QwDatastatListParam param) {
+        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());
+        result.setTotalSize(count);
+        if (count == 0) {
+            return result;
+        }
+        List<ContentPlatformQwDataStat> datastatList = dataStatMapperExt.getQwTotalDatastatList(param,
+                user.getId(), offset, param.getPageSize());
+        List<QwDatastatItemVO> list = buildQwRootSourceIdDatastatItemVOList(datastatList);
+        result.setObjs(list);
+        return result;
+    }
+
+    private Page<QwDatastatItemVO> qwSceneDatastatList(QwDatastatListParam param, Integer scene) {
+        ContentPlatformAccount user = LoginUserContext.getUser();
+        Page<QwDatastatItemVO> result = new Page<>(param.getPageNum(), param.getPageSize());
+        int offset = (param.getPageNum() - 1) * param.getPageSize();
+        int count = dataStatMapperExt.getQwSceneDatastatCount(param, scene, user.getId());
+        result.setTotalSize(count);
+        if (count == 0) {
+            return result;
+        }
+        List<ContentPlatformQwDataStat> datastatList = dataStatMapperExt.getQwSceneDatastatList(param, scene,
+                user.getId(), offset, param.getPageSize());
+        List<QwDatastatItemVO> list = buildQwRootSourceIdDatastatItemVOList(datastatList);
+        result.setObjs(list);
+        return result;
+    }
+
+    private Page<QwDatastatItemVO> qwReplyDatastatList(QwDatastatListParam param) {
+        ContentPlatformAccount user = LoginUserContext.getUser();
+        Page<QwDatastatItemVO> result = new Page<>(param.getPageNum(), param.getPageSize());
+        int offset = (param.getPageNum() - 1) * param.getPageSize();
+        int count = dataStatMapperExt.getQwReplyDatastatCount(param, user.getId());
+        result.setTotalSize(count);
+        if (count == 0) {
+            return result;
+        }
+        List<ContentPlatformQwDataStat> datastatList = dataStatMapperExt.getReplyDatastatList(param,
+                user.getId(), offset, param.getPageSize());
+        List<QwDatastatItemVO> list = buildQwRootSourceIdDatastatItemVOList(datastatList);
+        result.setObjs(list);
+        return result;
+    }
+
+    private Page<QwDatastatItemVO> qwRootSourceIdDatastatList(QwDatastatListParam param) {
+        ContentPlatformAccount user = LoginUserContext.getUser();
+        Page<QwDatastatItemVO> result = new Page<>(param.getPageNum(), param.getPageSize());
+        int offset = (param.getPageNum() - 1) * param.getPageSize();
+        int count = dataStatMapperExt.getQwRootSourceIdDatastatCount(param, user.getId());
+        result.setTotalSize(count);
+        if (count == 0) {
+            return result;
+        }
+        List<ContentPlatformQwDataStat> datastatList = dataStatMapperExt.getQwRootSourceIdDatastatList(param,
+                user.getId(), offset, param.getPageSize());
+        List<QwDatastatItemVO> list = buildQwRootSourceIdDatastatItemVOList(datastatList);
+        result.setObjs(list);
+        return result;
+    }
+
+    private List<QwDatastatItemVO> buildQwRootSourceIdDatastatItemVOList(List<ContentPlatformQwDataStat> datastatList) {
+        if (CollectionUtils.isEmpty(datastatList)) {
+            return null;
+        }
+        List<String> rootSourceIds = datastatList.stream().map(ContentPlatformQwDataStat::getRootSourceId).distinct().collect(Collectors.toList());
+        List<ContentPlatformQwPlan> qwPlanList = planService.getQwPlanListByRootSourceIds(rootSourceIds);
+        Map<String, Long> qwPlanMap = qwPlanList.stream().collect(Collectors.toMap(ContentPlatformQwPlan::getRootSourceId, ContentPlatformQwPlan::getId));
+        List<Long> planIds = qwPlanList.stream().map(ContentPlatformQwPlan::getId).distinct().collect(Collectors.toList());
+        List<ContentPlatformQwPlanVideo> qwPlanVideoList = planService.getQwPlanVideoListByPlanIds(planIds);
+        Map<Long, List<ContentPlatformQwPlanVideo>> qwPlanVideoMap = qwPlanVideoList.stream().collect(Collectors.groupingBy(ContentPlatformQwPlanVideo::getPlanId));
+        List<QwDatastatItemVO> result = new ArrayList<>();
+        for (ContentPlatformQwDataStat datastat : datastatList) {
+            QwDatastatItemVO vo = new QwDatastatItemVO();
+            vo.setDateStr(datastat.getDateStr());
+            vo.setScore(datastat.getScore());
+            Long planId = qwPlanMap.get(datastat.getRootSourceId());
+            if (Objects.nonNull(planId)) {
+                List<ContentPlatformQwPlanVideo> planVideoList = qwPlanVideoMap.get(planId);
+                if (CollectionUtils.isNotEmpty(planVideoList)) {
+                    vo.setVideoId(planVideoList.get(0).getVideoId());
+                    vo.setTitle(planVideoList.get(0).getTitle());
+                }
+            }
+            result.add(vo);
+        }
+        return result;
     }
 
     @Override

+ 19 - 3
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformPlanServiceImpl.java

@@ -3,9 +3,7 @@ package com.tzld.piaoquan.api.service.contentplatform.impl;
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.api.common.enums.ExceptionEnum;
 import com.tzld.piaoquan.api.common.exception.CommonException;
-import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformGzhPlanMapper;
-import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformGzhPlanVideoMapper;
-import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformQwPlanVideoMapper;
+import com.tzld.piaoquan.api.dao.mapper.contentplatform.*;
 import com.tzld.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformPlanMapperExt;
 import com.tzld.piaoquan.api.model.config.LoginUserContext;
 import com.tzld.piaoquan.api.model.param.contentplatform.*;
@@ -51,12 +49,16 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
     @Autowired
     private ContentPlatformGzhPlanVideoMapper gzhPlanVideoMapper;
     @Autowired
+    private ContentPlatformQwPlanMapper qwPlanMapper;
+    @Autowired
     private ContentPlatformQwPlanVideoMapper qwPlanVideoMapper;
     @Autowired
     private CgiReplyBucketDataMapper cgiReplyBucketDataMapper;
     @Autowired
     private CgiReplyBucketDataMapperExt cgiReplyBucketDataMapperExt;
     @Autowired
+    private ContentPlatformVideoMapper contentPlatformVideoMapper;
+    @Autowired
     private ContentPlatformCooperateAccountService cooperateAccountService;
     @Autowired
     private GhDetailService ghDetailService;
@@ -403,4 +405,18 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
         return planMapperExt.getGzhPlanVideoListByCooperateAccountId(ghId);
     }
 
+    @Override
+    public List<ContentPlatformQwPlan> getQwPlanListByRootSourceIds(List<String> rootSourceIds) {
+        ContentPlatformQwPlanExample example = new ContentPlatformQwPlanExample();
+        example.createCriteria().andRootSourceIdIn(rootSourceIds);
+        return qwPlanMapper.selectByExample(example);
+    }
+
+    @Override
+    public List<ContentPlatformQwPlanVideo> getQwPlanVideoListByPlanIds(List<Long> planIds) {
+        ContentPlatformQwPlanVideoExample example = new ContentPlatformQwPlanVideoExample();
+        example.createCriteria().andPlanIdIn(planIds);
+        return qwPlanVideoMapper.selectByExample(example);
+    }
+
 }

+ 14 - 14
api-module/src/main/resources/mapper/contentplatform/ContentPlatformGzhDataStatMapper.xml

@@ -7,7 +7,7 @@
     <result column="account_id" jdbcType="BIGINT" property="accountId" />
     <result column="fans_increase_count" jdbcType="INTEGER" property="fansIncreaseCount" />
     <result column="first_level_count" jdbcType="INTEGER" property="firstLevelCount" />
-    <result column="socre" jdbcType="DOUBLE" property="socre" />
+    <result column="score" jdbcType="DOUBLE" property="score" />
     <result column="create_timestamp" jdbcType="BIGINT" property="createTimestamp" />
   </resultMap>
   <sql id="Example_Where_Clause">
@@ -69,7 +69,7 @@
     </where>
   </sql>
   <sql id="Base_Column_List">
-    id, date_str, account_id, fans_increase_count, first_level_count, socre, create_timestamp
+    id, date_str, account_id, fans_increase_count, first_level_count, score, create_timestamp
   </sql>
   <select id="selectByExample" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhDataStatExample" resultMap="BaseResultMap">
     select
@@ -106,10 +106,10 @@
   </delete>
   <insert id="insert" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhDataStat">
     insert into content_platform_gzh_datastat (id, date_str, account_id, 
-      fans_increase_count, first_level_count, socre, 
+      fans_increase_count, first_level_count, score, 
       create_timestamp)
     values (#{id,jdbcType=BIGINT}, #{dateStr,jdbcType=VARCHAR}, #{accountId,jdbcType=BIGINT}, 
-      #{fansIncreaseCount,jdbcType=INTEGER}, #{firstLevelCount,jdbcType=INTEGER}, #{socre,jdbcType=DOUBLE}, 
+      #{fansIncreaseCount,jdbcType=INTEGER}, #{firstLevelCount,jdbcType=INTEGER}, #{score,jdbcType=DOUBLE}, 
       #{createTimestamp,jdbcType=BIGINT})
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhDataStat">
@@ -130,8 +130,8 @@
       <if test="firstLevelCount != null">
         first_level_count,
       </if>
-      <if test="socre != null">
-        socre,
+      <if test="score != null">
+        score,
       </if>
       <if test="createTimestamp != null">
         create_timestamp,
@@ -153,8 +153,8 @@
       <if test="firstLevelCount != null">
         #{firstLevelCount,jdbcType=INTEGER},
       </if>
-      <if test="socre != null">
-        #{socre,jdbcType=DOUBLE},
+      <if test="score != null">
+        #{score,jdbcType=DOUBLE},
       </if>
       <if test="createTimestamp != null">
         #{createTimestamp,jdbcType=BIGINT},
@@ -185,8 +185,8 @@
       <if test="record.firstLevelCount != null">
         first_level_count = #{record.firstLevelCount,jdbcType=INTEGER},
       </if>
-      <if test="record.socre != null">
-        socre = #{record.socre,jdbcType=DOUBLE},
+      <if test="record.score != null">
+        score = #{record.score,jdbcType=DOUBLE},
       </if>
       <if test="record.createTimestamp != null">
         create_timestamp = #{record.createTimestamp,jdbcType=BIGINT},
@@ -203,7 +203,7 @@
       account_id = #{record.accountId,jdbcType=BIGINT},
       fans_increase_count = #{record.fansIncreaseCount,jdbcType=INTEGER},
       first_level_count = #{record.firstLevelCount,jdbcType=INTEGER},
-      socre = #{record.socre,jdbcType=DOUBLE},
+      score = #{record.score,jdbcType=DOUBLE},
       create_timestamp = #{record.createTimestamp,jdbcType=BIGINT}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -224,8 +224,8 @@
       <if test="firstLevelCount != null">
         first_level_count = #{firstLevelCount,jdbcType=INTEGER},
       </if>
-      <if test="socre != null">
-        socre = #{socre,jdbcType=DOUBLE},
+      <if test="score != null">
+        score = #{score,jdbcType=DOUBLE},
       </if>
       <if test="createTimestamp != null">
         create_timestamp = #{createTimestamp,jdbcType=BIGINT},
@@ -239,7 +239,7 @@
       account_id = #{accountId,jdbcType=BIGINT},
       fans_increase_count = #{fansIncreaseCount,jdbcType=INTEGER},
       first_level_count = #{firstLevelCount,jdbcType=INTEGER},
-      socre = #{socre,jdbcType=DOUBLE},
+      score = #{score,jdbcType=DOUBLE},
       create_timestamp = #{createTimestamp,jdbcType=BIGINT}
     where id = #{id,jdbcType=BIGINT}
   </update>

+ 14 - 14
api-module/src/main/resources/mapper/contentplatform/ContentPlatformQwDataStatMapper.xml

@@ -6,7 +6,7 @@
     <result column="date_str" jdbcType="VARCHAR" property="dateStr" />
     <result column="root_source_id" jdbcType="VARCHAR" property="rootSourceId" />
     <result column="first_level_count" jdbcType="INTEGER" property="firstLevelCount" />
-    <result column="socre" jdbcType="DOUBLE" property="socre" />
+    <result column="score" jdbcType="DOUBLE" property="score" />
     <result column="create_timestamp" jdbcType="BIGINT" property="createTimestamp" />
   </resultMap>
   <sql id="Example_Where_Clause">
@@ -68,7 +68,7 @@
     </where>
   </sql>
   <sql id="Base_Column_List">
-    id, date_str, root_source_id, first_level_count, socre, create_timestamp
+    id, date_str, root_source_id, first_level_count, score, create_timestamp
   </sql>
   <select id="selectByExample" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatExample" resultMap="BaseResultMap">
     select
@@ -105,10 +105,10 @@
   </delete>
   <insert id="insert" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStat">
     insert into content_platform_qw_datastat (id, date_str, root_source_id, 
-      first_level_count, socre, create_timestamp
+      first_level_count, score, create_timestamp
       )
     values (#{id,jdbcType=BIGINT}, #{dateStr,jdbcType=VARCHAR}, #{rootSourceId,jdbcType=VARCHAR}, 
-      #{firstLevelCount,jdbcType=INTEGER}, #{socre,jdbcType=DOUBLE}, #{createTimestamp,jdbcType=BIGINT}
+      #{firstLevelCount,jdbcType=INTEGER}, #{score,jdbcType=DOUBLE}, #{createTimestamp,jdbcType=BIGINT}
       )
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStat">
@@ -126,8 +126,8 @@
       <if test="firstLevelCount != null">
         first_level_count,
       </if>
-      <if test="socre != null">
-        socre,
+      <if test="score != null">
+        score,
       </if>
       <if test="createTimestamp != null">
         create_timestamp,
@@ -146,8 +146,8 @@
       <if test="firstLevelCount != null">
         #{firstLevelCount,jdbcType=INTEGER},
       </if>
-      <if test="socre != null">
-        #{socre,jdbcType=DOUBLE},
+      <if test="score != null">
+        #{score,jdbcType=DOUBLE},
       </if>
       <if test="createTimestamp != null">
         #{createTimestamp,jdbcType=BIGINT},
@@ -175,8 +175,8 @@
       <if test="record.firstLevelCount != null">
         first_level_count = #{record.firstLevelCount,jdbcType=INTEGER},
       </if>
-      <if test="record.socre != null">
-        socre = #{record.socre,jdbcType=DOUBLE},
+      <if test="record.score != null">
+        score = #{record.score,jdbcType=DOUBLE},
       </if>
       <if test="record.createTimestamp != null">
         create_timestamp = #{record.createTimestamp,jdbcType=BIGINT},
@@ -192,7 +192,7 @@
       date_str = #{record.dateStr,jdbcType=VARCHAR},
       root_source_id = #{record.rootSourceId,jdbcType=VARCHAR},
       first_level_count = #{record.firstLevelCount,jdbcType=INTEGER},
-      socre = #{record.socre,jdbcType=DOUBLE},
+      score = #{record.score,jdbcType=DOUBLE},
       create_timestamp = #{record.createTimestamp,jdbcType=BIGINT}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -210,8 +210,8 @@
       <if test="firstLevelCount != null">
         first_level_count = #{firstLevelCount,jdbcType=INTEGER},
       </if>
-      <if test="socre != null">
-        socre = #{socre,jdbcType=DOUBLE},
+      <if test="score != null">
+        score = #{score,jdbcType=DOUBLE},
       </if>
       <if test="createTimestamp != null">
         create_timestamp = #{createTimestamp,jdbcType=BIGINT},
@@ -224,7 +224,7 @@
     set date_str = #{dateStr,jdbcType=VARCHAR},
       root_source_id = #{rootSourceId,jdbcType=VARCHAR},
       first_level_count = #{firstLevelCount,jdbcType=INTEGER},
-      socre = #{socre,jdbcType=DOUBLE},
+      score = #{score,jdbcType=DOUBLE},
       create_timestamp = #{createTimestamp,jdbcType=BIGINT}
     where id = #{id,jdbcType=BIGINT}
   </update>

+ 127 - 0
api-module/src/main/resources/mapper/contentplatform/ext/ContentPlatformDataStatMapperExt.xml

@@ -0,0 +1,127 @@
+<?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.ext.ContentPlatformDataStatMapperExt">
+
+  <select id="getGzhAccountDatastatCount" resultType="java.lang.Integer">
+    select count(1)
+    from content_platform_gzh_datastat cpgd
+    join content_platform_gzh_account cpgza on cpgd.account_id = cpgza.id
+    where cpgza.create_account_id = #{createAccountId}
+    <if test="param.accountId!= null and param.accountId!= ''">
+      and cpgza.account_id = #{param.accountId}
+    </if>
+  </select>
+
+  <select id="getGzhAccountDatastatList"
+          resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhDataStat">
+    select cpgd.*
+    from content_platform_gzh_datastat cpgd
+    join content_platform_gzh_account cpgza on cpgd.account_id = cpgza.id
+    where cpgza.create_account_id = #{createAccountId}
+    <if test="param.accountId!= null and param.accountId!= ''">
+      and cpgza.account_id = #{param.accountId}
+    </if>
+    order by cpgd.date_str desc
+    limit #{offset}, #{pageSize}
+  </select>
+
+  <select id="getGzhTotalDatastatCount" resultType="java.lang.Integer">
+    select count(1)
+    from content_platform_gzh_datastat cpgd
+    join content_platform_gzh_account cpgza on cpgd.account_id = cpgza.id
+    where cpgza.create_account_id = #{createAccountId}
+    group by cpgd.date_str
+  </select>
+
+  <select id="getGzhTotalDatastatList"
+          resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhDataStat">
+    select date_str, sum(fans_increase_count) as fans_increase_count, sum(first_level_count) as first_level_count,
+           avg(score) as score
+    from content_platform_gzh_datastat cpgd
+    join content_platform_gzh_account cpgza on cpgd.account_id = cpgza.id
+    where cpgza.create_account_id = #{createAccountId}
+    group by cpgd.date_str
+    order by cpgd.date_str desc
+    limit #{offset}, #{pageSize}
+  </select>
+
+  <select id="getQwRootSourceIdDatastatCount" resultType="java.lang.Integer">
+    select count(1)
+    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}
+  </select>
+
+  <select id="getQwRootSourceIdDatastatList"
+          resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStat">
+    select cpqd.*
+    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}
+    order by cpqd.date_str desc
+    limit #{offset}, #{pageSize}
+  </select>
+
+  <select id="getQwTotalDatastatCount" resultType="java.lang.Integer">
+    select count(1)
+    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
+  </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
+    limit #{offset}, #{pageSize}
+  </select>
+
+  <select id="getQwSceneDatastatCount" resultType="java.lang.Integer">
+    select count(1)
+    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}
+      and cpqp.scene = #{scene}
+    group by cpqd.date_str
+  </select>
+
+  <select id="getQwSceneDatastatList"
+          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}
+      and cpqp.scene = #{scene}
+    group by cpqd.date_str
+    order by cpqd.date_str desc
+    limit #{offset}, #{pageSize}
+  </select>
+
+  <select id="getQwReplyDatastatCount" resultType="java.lang.Integer">
+    select count(1)
+    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}
+      and cpqp.type = 0
+    group by cpqd.date_str
+  </select>
+
+  <select id="getReplyDatastatList"
+          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}
+      and cpqp.type = 0
+    group by cpqd.date_str
+    order by cpqd.date_str desc
+    limit #{offset}, #{pageSize}
+  </select>
+
+
+</mapper>