Browse Source

Merge branch 'dingpan' of http://git.tjyourong.com.cn/ctop/adsp-boot into dingpan

zhaoxian 4 years ago
parent
commit
4ff151a44d
18 changed files with 357 additions and 32 deletions
  1. 64 8
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  2. 7 2
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  3. 5 4
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyGroupReportLoadJob.java
  4. 36 14
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDingPanCleanJob.java
  5. 3 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupMapper.java
  6. 8 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouVideoGetMapper.java
  7. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml
  8. 54 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml
  9. 4 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouGroupService.java
  10. 7 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java
  11. 18 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java
  12. 20 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java
  13. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/EtlKuaiShouGroupDailyReport.java
  14. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/EtlKuaiShouAccountMaterialOverviewMapper.java
  15. 56 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaiShouAccountMaterialOverviewMapper.xml
  16. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaiShouGroupDailyReportMapper.xml
  17. 15 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaiShouAccountMaterialOverviewServiceImpl.java
  18. 30 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaiShouGroupDailyReportServiceImpl.java

+ 64 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java

@@ -15,10 +15,7 @@ import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouAccessToken;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
-import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaiShouNewlyService;
-import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
-import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyService;
-import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyGroupService;
+import cn.com.ctop.kuaishou.modules.report.service.*;
 import cn.com.ctop.toutiao.modules.link.service.IETLReportBytedanceVideoService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
@@ -125,6 +122,68 @@ public class TestController {
     private IUserAllocationService allocationService;
     @Autowired
     private IEtlKuaiShouNewlyService kuaiShouNewlyService;
+    static ExecutorService materialExecutorService = Executors.newFixedThreadPool(8);
+
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IEtlKuaiShouGroupDailyReportService etlKuaiShouGroupDailyReportService;
+    @Autowired
+    private IEtlKuaiShouAccountMaterialOverviewService accountMaterialOverviewService;
+
+    @Autowired
+    private IEtlKuaiShouNewlyService newlyService;
+
+
+    @GetMapping("/cleanNewlyData")
+    public void cleanNewlyData() {
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        newlyService.cleanNewlyData(nowDate);
+        XxlJobHelper.log("快手清洗上新计划数据完成");
+    }
+
+
+    @GetMapping("/cleanGroupReport")
+    public void cleanGroupReport() throws Exception {
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        if (null == tokens || tokens.isEmpty()) {
+            XxlJobHelper.log("定时获取快手数据异常:未获取到可用的token");
+            XxlJobHelper.handleFail();
+            return;
+        }
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        for (CtopOauthToken token : tokens) {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    etlKuaiShouGroupDailyReportService.getGroupReport(token.getAccountId(), token.getAccessToken(), nowDate, nowDate, 1);
+                }
+            });
+        }
+    }
+
+
+    @GetMapping("/cleanAccountMaterialOverview")
+    public void cleanAccountMaterialOverview() throws Exception {
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String yesterdayDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        if (null == tokens || tokens.isEmpty()) {
+            XxlJobHelper.log("定时获取快手数据异常:未获取到可用的token");
+            XxlJobHelper.handleFail();
+            return;
+        }
+        for (CtopOauthToken token : tokens) {
+            materialExecutorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    accountMaterialOverviewService.cleanAccountMaterialOverview(token.getAccountId(), yesterdayDate);
+                }
+            });
+        }
+
+
+    }
 
 
     @GetMapping("/cleanDate")
@@ -998,10 +1057,7 @@ public class TestController {
     }
 
 
-    @Autowired
-    private IBytedancePlanDailyReportService planDailyReportService;
-    @Autowired
-    private ICtopOauthTokenService tokenService;
+
 
 
     @Autowired

+ 7 - 2
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -68,15 +68,20 @@ public class SampleTest {
    */
     @Autowired
     private IKuaishouReportDailyGroupService reportDailyGroupService;
+    @Autowired
+    private IEtlKuaiShouAccountMaterialOverviewService kuaiShouAccountMaterialOverviewService;
 
 
     @Test
     public void loadBytedanceCreativeData() throws ParseException {
 
-        CtopOauthToken tokenByAccountId = tokenService.getTokenByAccountId(9901975L);
+        CtopOauthToken token = new CtopOauthToken();
+        token.setAccountId(9901975L);
+        token.setAccessToken("e609f9d3f56f3d6b4653f32c98a6d119");
+        kuaiShouAccountMaterialOverviewService.cleanAccountMaterialOverview(9901975L, "2021-03-09");
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
         Date parse = simpleDateFormat.parse("2021-03-09");
-        reportDailyGroupService.getAdvertiserGroupReportDaily(tokenByAccountId, parse, parse);
+        reportDailyGroupService.getAdvertiserGroupReportDaily(token, parse, parse);
 
         //    1662234704806924
        /* CtopOauthToken token = new CtopOauthToken();

+ 5 - 4
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyGroupReportLoadJob.java

@@ -2,7 +2,7 @@ package cn.com.ctop.job.kuaishou.handler;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyGroupService;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import org.jeecg.common.util.DateUtils;
@@ -24,8 +24,9 @@ public class KuaishouDailyGroupReportLoadJob {
     @Autowired
     private ICtopOauthTokenService tokenService;
     @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
+    private IKuaishouReportDailyGroupService reportDailyGroupService;
     static ExecutorService executorService = Executors.newFixedThreadPool(3);
+
     @XxlJob("kuaishouDailyGroupReport")
     public void execute() throws Exception {
         Date getDate = DateUtils.addDay(new Date(), -1);
@@ -34,8 +35,8 @@ public class KuaishouDailyGroupReportLoadJob {
         if (null == tokens || tokens.size() <= 0) {
             XxlJobHelper.log("定时获取快手数据异常:未获取到可用的token");
             XxlJobHelper.handleFail();
-            return ;
+            return;
         }
-        tokens.forEach(token -> executorService.submit(() -> kuaishouInterfaceService.getAdvertiserGroupReportDaily(token, getDate, getDate)));
+        tokens.forEach(token -> executorService.submit(() -> reportDailyGroupService.getAdvertiserGroupReportDaily(token, getDate, getDate)));
     }
 }

+ 36 - 14
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDingPanCleanJob.java

@@ -2,7 +2,7 @@ package cn.com.ctop.job.kuaishou.handler;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaiShouAccountMaterialOverviewService;
 import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaiShouGroupDailyReportService;
 import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaiShouNewlyService;
 import com.xxl.job.core.context.XxlJobHelper;
@@ -11,8 +11,6 @@ import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.text.SimpleDateFormat;
-import java.util.Date;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -22,42 +20,66 @@ public class KuaishouDingPanCleanJob {
     @Autowired
     private ICtopOauthTokenService tokenService;
     @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
-
-    @Autowired
     private IEtlKuaiShouGroupDailyReportService etlKuaiShouGroupDailyReportService;
+    @Autowired
+    private IEtlKuaiShouAccountMaterialOverviewService accountMaterialOverviewService;
 
     @Autowired
     private IEtlKuaiShouNewlyService newlyService;
 
 
     static ExecutorService executorService = Executors.newFixedThreadPool(8);
+    static ExecutorService materialExecutorService = Executors.newFixedThreadPool(8);
 
     @XxlJob("cleanNewlyData")
     public void cleanNewlyData() {
         String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-        newlyService.cleanNewlyData(nowDate);
+        String yesterdayDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+        newlyService.cleanNewlyData(yesterdayDate);
         XxlJobHelper.log("快手清洗上新计划数据完成");
     }
 
 
     @XxlJob("cleanGroupReport")
     public void cleanGroupReport() throws Exception {
-        Date getDate = new Date();
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
-        String hour = simpleDateFormat.format(getDate);
-        if (null != hour && "00".equals(hour)) {
-            getDate = DateUtils.addDay(getDate, -1);
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        if (null == tokens || tokens.isEmpty()) {
+            XxlJobHelper.log("定时获取快手数据异常:未获取到可用的token");
+            XxlJobHelper.handleFail();
+            return;
         }
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        for (CtopOauthToken token : tokens) {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    etlKuaiShouGroupDailyReportService.getGroupReport(token.getAccountId(), token.getAccessToken(), nowDate, nowDate, 1);
+                }
+            });
+        }
+    }
 
+
+    @XxlJob("cleanAccountMaterialOverview")
+    public void cleanAccountMaterialOverview() throws Exception {
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String yesterdayDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
         List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
         if (null == tokens || tokens.isEmpty()) {
             XxlJobHelper.log("定时获取快手数据异常:未获取到可用的token");
             XxlJobHelper.handleFail();
             return;
         }
-        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-        tokens.forEach(token -> executorService.submit(() -> etlKuaiShouGroupDailyReportService.getGroupReport(token.getAccountId(), token.getAccessToken(), nowDate, nowDate, 1)));
+        for (CtopOauthToken token : tokens) {
+            materialExecutorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    accountMaterialOverviewService.cleanAccountMaterialOverview(token.getAccountId(), yesterdayDate);
+                }
+            });
+        }
+
+
     }
 
 }

+ 3 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupMapper.java

@@ -1,9 +1,9 @@
 package cn.com.ctop.kuaishou.modules.batch.mapper;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
-import org.jeecg.common.api.vo.Result;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -35,4 +35,6 @@ public interface KuaiShouGroupMapper extends BaseMapper<KuaiShouGroup> {
     void deleteByAccountId(@Param("accountId") Long accountId);
 
     Integer getNewDataByAccountIdAndDate(Long accountId, String statDate);
+
+    List<JSONObject> getUnitListByMapAndAccountId(@Param("unitIds") Map<Long, Long> unitMap, @Param("accountId") Long accountId);
 }

+ 8 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouVideoGetMapper.java

@@ -32,4 +32,12 @@ public interface KuaiShouVideoGetMapper extends BaseMapper<KuaiShouVideoGet> {
     void etlVideoBaseInfoByStaDate(@Param("statDate") String statDate);
 
     List<JSONObject> getVideoInfoByPhotoIds(@Param("photoIdList") List<Long> photoIdList);
+
+    Integer getTotalCountByAccount(@Param("accountId") Long accountId);
+
+    Integer getTotalCountByAccountAndStatDate(@Param("accountId") Long accountId, @Param("statDate") String statDate);
+
+    Integer getEffectiveCountByAccountId(Long accountId);
+
+    Integer getHotMoneyCountByAccountId(Long accountId);
 }

+ 21 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml

@@ -144,9 +144,30 @@
      where account_id = #{accountId}
      and DATE_FORMAT(group_create_time,'%Y-%m-%d') = #{statDate}
     </select>
+
     <delete id="deleteByAccountId">
         delete from ctop_kuaishou_group
         where  account_id = #{accountId}
     </delete>
 
+    <select id="getUnitListByMapAndAccountId" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        unit_id as unitId,
+        put_status as unitStatus,
+        bid_type as bidType,
+        (case when bid_type = 2
+        then bid
+        when bid_type = 10
+        then cpa_bid
+        else 0
+        end
+        ) as bid
+        from ctop_kuaishou_group
+        where account_id = #{accountId}
+        and unit_id in
+        <foreach collection="unitIds" item="unitIds" separator="," open="(" close=")">
+            #{unitIds}
+        </foreach>
+    </select>
+
 </mapper>

+ 54 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml

@@ -166,4 +166,58 @@
         and signature is not null
         group by photo_id
     </select>
+    <select id="getTotalCountByAccount" resultType="java.lang.Integer">
+        select
+        count(distinct signature)
+        from ctop_kuaishou_video_get
+        where  account_id = #{accountId}
+    </select>
+    <select id="getTotalCountByAccountAndStatDate" resultType="java.lang.Integer">
+        SELECT
+    	count(DISTINCT signature)
+        FROM
+	    ctop_kuaishou_video_get
+        WHERE
+	    account_id = #{accountId}
+        AND DATE_FORMAT(stat_date, '%Y-%m-%d') = #{statDate}
+    </select>
+    <select id="getEffectiveCountByAccountId" resultType="java.lang.Integer">
+        SELECT
+        count(1)
+        FROM
+        (
+        SELECT
+        signature
+        FROM
+        ctop_kuaishou_video_get
+        WHERE
+        account_id = #{accountId}
+        GROUP BY
+        signature
+        ) t1
+        LEFT JOIN ctop_kuaishou_video_etl_info t2 ON t1.signature = t2.video_code
+        WHERE
+        t2.effect_date IS NOT NULL
+        AND t2.effect_day_num &lt;= 7
+
+    </select>
+    <select id="getHotMoneyCountByAccountId" resultType="java.lang.Integer">
+        SELECT
+        count(1)
+        FROM
+        (
+        SELECT
+        signature
+        FROM
+        ctop_kuaishou_video_get
+        WHERE
+        account_id = #{accountId}
+        GROUP BY
+        signature
+        ) t1
+        LEFT JOIN ctop_kuaishou_video_etl_info t2 ON t1.signature = t2.video_code
+        WHERE
+        t2.faddish_date is not null
+        and faddish_day_num &lt;=14
+    </select>
 </mapper>

+ 4 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouGroupService.java

@@ -1,10 +1,11 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
-import org.jeecg.common.api.vo.Result;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 广告组信息
@@ -43,4 +44,6 @@ public interface IKuaiShouGroupService extends IService<KuaiShouGroup> {
     void deleteByAccountId(Long accountId);
 
     Integer getNewDataByAccountIdAndDate(Long accountId, String statDate);
+
+    Map<Long, JSONObject> getBidMapByMap(Long accountId, Map<Long, Long> unitIdMap);
 }

+ 7 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java

@@ -41,4 +41,11 @@ public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
 
     List<KuaiShouVideoGet> getVideoInfoGroupBySignature(String date);
 
+    Integer getTotalCountByAccount(Long accountId);
+
+    Integer getTotalCountByAccountAndStatDate(Long accountId, String statDate);
+
+    Integer getEffectiveCountByAccountId(Long accountId);
+
+    Integer getHotMoneyCountByAccountId(Long accountId);
 }

+ 18 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java

@@ -145,6 +145,24 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
         return groupMapper.getNewDataByAccountIdAndDate(accountId, statDate);
     }
 
+    @Override
+    public Map<Long, JSONObject> getBidMapByMap(Long accountId, Map<Long, Long> unitIdMap) {
+        Map<Long, JSONObject> unitMap = new HashMap<>();
+        if (Check.isNullMap(unitIdMap)) {
+            return unitMap;
+        }
+        List<JSONObject> unitList = groupMapper.getUnitListByMapAndAccountId(unitIdMap, accountId);
+        if (Check.isNull(unitList)) {
+            return unitMap;
+        }
+        for (int i = 0; i < unitList.size(); i++) {
+            JSONObject jsonObject = unitList.get(i);
+            unitMap.put(jsonObject.getLong("unitId"), jsonObject);
+        }
+
+        return unitMap;
+    }
+
 
     @Override
     public void getGroupByUnitId(String accessToken, Long accountId, Long unitId) {

+ 20 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java

@@ -245,4 +245,24 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
         queryWrapper.groupBy("signature");
         return this.list(queryWrapper);
     }
+
+    @Override
+    public Integer getTotalCountByAccount(Long accountId) {
+        return videoGetMapper.getTotalCountByAccount(accountId);
+    }
+
+    @Override
+    public Integer getTotalCountByAccountAndStatDate(Long accountId, String statDate) {
+        return videoGetMapper.getTotalCountByAccountAndStatDate(accountId, statDate);
+    }
+
+    @Override
+    public Integer getEffectiveCountByAccountId(Long accountId) {
+        return videoGetMapper.getEffectiveCountByAccountId(accountId);
+    }
+
+    @Override
+    public Integer getHotMoneyCountByAccountId(Long accountId) {
+        return videoGetMapper.getHotMoneyCountByAccountId(accountId);
+    }
 }

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/EtlKuaiShouGroupDailyReport.java

@@ -76,6 +76,8 @@ public class EtlKuaiShouGroupDailyReport {
     @Excel(name = "出价", width = 15)
     @ApiModelProperty(value = "出价")
     private Long bid;
+    private Integer bidType;
+    private Integer unitStatus;
     /**
      * 曝光数
      */

+ 1 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/EtlKuaiShouAccountMaterialOverviewMapper.java

@@ -12,4 +12,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface EtlKuaiShouAccountMaterialOverviewMapper extends BaseMapper<EtlKuaiShouAccountMaterialOverview> {
 
+    void replaceInsert(EtlKuaiShouAccountMaterialOverview etlKuaiShouAccountMaterialOverview);
 }

+ 56 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaiShouAccountMaterialOverviewMapper.xml

@@ -2,4 +2,60 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.EtlKuaiShouAccountMaterialOverviewMapper">
 
+    <insert id="replaceInsert"
+            parameterType="cn.com.ctop.kuaishou.modules.report.entity.EtlKuaiShouAccountMaterialOverview">
+        replace into ctop_etl_kuaishou_account_material_overview
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                id,
+            </if>
+            <if test="accountId != null">
+                account_id,
+            </if>
+            <if test="newlyCount != null">
+                newly_count,
+            </if>
+            <if test="newlyUseCount != null">
+                newly_use_count,
+            </if>
+            <if test="totalCount != null">
+                total_count,
+            </if>
+            <if test="effectiveCount != null">
+                effective_count,
+            </if>
+            <if test="hotMoneyCount != null">
+                hot_money_count,
+            </if>
+            <if test="stateDate != null">
+                state_date
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                #{id},
+            </if>
+            <if test="accountId != null">
+                #{accountId},
+            </if>
+            <if test="newlyCount != null">
+                #{newlyCount},
+            </if>
+            <if test="newlyUseCount != null">
+                #{newlyUseCount},
+            </if>
+            <if test="totalCount != null">
+                #{totalCount},
+            </if>
+            <if test="effectiveCount != null">
+                #{effectiveCount},
+            </if>
+            <if test="hotMoneyCount != null">
+                #{hotMoneyCount},
+            </if>
+            <if test="stateDate != null">
+                #{stateDate}
+            </if>
+        </trim>
+    </insert>
 </mapper>

+ 6 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaiShouGroupDailyReportMapper.xml

@@ -9,6 +9,9 @@
         campaign_name,
         unit_id,
         unit_name,
+        unit_status,
+        bid_type,
+        bid,
         charge,
         photo_show,
         aclick,
@@ -33,6 +36,9 @@
             #{addList.campaignName},
             #{addList.unitId},
             #{addList.unitName},
+            #{addList.unitStatus},
+            #{addList.bidType},
+            #{addList.bid},
             #{addList.charge},
             #{addList.photoShow},
             #{addList.aclick},

+ 15 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaiShouAccountMaterialOverviewServiceImpl.java

@@ -5,6 +5,7 @@ import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaiShouAccountMaterialOver
 import cn.com.ctop.kuaishou.modules.report.mapper.EtlKuaiShouAccountMaterialOverviewMapper;
 import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaiShouAccountMaterialOverviewService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -19,10 +20,22 @@ import org.springframework.stereotype.Service;
 public class EtlKuaiShouAccountMaterialOverviewServiceImpl extends ServiceImpl<EtlKuaiShouAccountMaterialOverviewMapper, EtlKuaiShouAccountMaterialOverview> implements IEtlKuaiShouAccountMaterialOverviewService {
     @Autowired
     private IKuaiShouVideoGetService videoGetService;
+    @Autowired
+    private EtlKuaiShouAccountMaterialOverviewMapper accountMaterialOverviewMapper;
 
     @Override
     public void cleanAccountMaterialOverview(Long accountId, String statDate) {
-
-
+        Integer totalCount = videoGetService.getTotalCountByAccount(accountId);
+        Integer newlyCount = videoGetService.getTotalCountByAccountAndStatDate(accountId, statDate);
+        Integer effectiveCount = videoGetService.getEffectiveCountByAccountId(accountId);
+        Integer hotMoneyCount = videoGetService.getHotMoneyCountByAccountId(accountId);
+        EtlKuaiShouAccountMaterialOverview etlKuaiShouAccountMaterialOverview = new EtlKuaiShouAccountMaterialOverview();
+        etlKuaiShouAccountMaterialOverview.setAccountId(accountId);
+        etlKuaiShouAccountMaterialOverview.setStateDate(DateUtils.parseDate(statDate, "yyyy-MM-dd"));
+        etlKuaiShouAccountMaterialOverview.setTotalCount(totalCount);
+        etlKuaiShouAccountMaterialOverview.setNewlyCount(newlyCount);
+        etlKuaiShouAccountMaterialOverview.setEffectiveCount(effectiveCount);
+        etlKuaiShouAccountMaterialOverview.setHotMoneyCount(hotMoneyCount);
+        accountMaterialOverviewMapper.replaceInsert(etlKuaiShouAccountMaterialOverview);
     }
 }

+ 30 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaiShouGroupDailyReportServiceImpl.java

@@ -4,6 +4,7 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
 import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaiShouGroupDailyReport;
 import cn.com.ctop.kuaishou.modules.report.mapper.EtlKuaiShouGroupDailyReportMapper;
 import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaiShouGroupDailyReportService;
@@ -34,6 +35,8 @@ import java.util.Map;
 public class EtlKuaiShouGroupDailyReportServiceImpl extends ServiceImpl<EtlKuaiShouGroupDailyReportMapper, EtlKuaiShouGroupDailyReport> implements IEtlKuaiShouGroupDailyReportService {
     @Autowired
     private EtlKuaiShouGroupDailyReportMapper groupDailyReportMapper;
+    @Autowired
+    private IKuaiShouGroupService groupService;
 
 
     @Override
@@ -137,9 +140,36 @@ public class EtlKuaiShouGroupDailyReportServiceImpl extends ServiceImpl<EtlKuaiS
             addList.add(groupDailyReport);
         }
         if (!Check.isNull(addList)) {
+            addList = getBid(accountId, addList);
             groupDailyReportMapper.replaceBatch(addList);
         }
     }
 
+    private List<EtlKuaiShouGroupDailyReport> getBid(Long accountId, List<EtlKuaiShouGroupDailyReport> addList) {
+        if (Check.isNull(addList)) {
+            return addList;
+        }
+        Map<Long, Long> unitIdMap = new HashMap<>();
+        for (EtlKuaiShouGroupDailyReport groupDailyReport : addList) {
+            unitIdMap.put(groupDailyReport.getUnitId(), groupDailyReport.getUnitId());
+        }
+        Map<Long, JSONObject> unitMap = groupService.getBidMapByMap(accountId, unitIdMap);
+        if (Check.isNullMap(unitMap)) {
+            return addList;
+        }
+        for (EtlKuaiShouGroupDailyReport groupDailyReport : addList) {
+            JSONObject unitJson = unitMap.get(groupDailyReport.getUnitId());
+            if (Check.isNull(unitJson)) {
+                continue;
+            }
+            groupDailyReport.setUnitStatus(unitJson.getInteger("unitStatus"));
+            groupDailyReport.setBidType(unitJson.getInteger("bidType"));
+            groupDailyReport.setBid(unitJson.getLong("bid"));
+        }
+
+        return addList;
+
+    }
+
 
 }