Przeglądaj źródła

Merge remote-tracking branch 'origin/V1.1.5' into V1.1.5

zhaoxian 4 lat temu
rodzic
commit
306865cfbe

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

@@ -133,27 +133,25 @@ public class TestController {
 
 
     @GetMapping("/cleanNewlyData")
-    public void cleanNewlyData() {
-        Date endDate = new Date();
-        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
-        for (int i = 0; i < 7; i++) {
-            Date getStartDate = DateUtils.addDay(endDate, -i);
-            String s = DateUtils.formatDate(getStartDate);
-            newlyService.cleanNewlyData(s);
+    public void cleanNewlyData(String startDate, String endDate) throws ParseException {
+
+
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date parse1 = simpleDateFormat.parse(startDate);
+        Date parse2 = simpleDateFormat.parse(endDate);
+     /*   CtopOauthToken token = new CtopOauthToken();
+        token.setAccountId(9791267L);
+        token.setAccessToken("b8ab3b361cd30339ef7e18dcc1305123");*/
+
+        List<CtopOauthToken> ctopOauthTokens = tokenService.selectKuaiShouToken();
+        // kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate, getDate, "adScene");
+        ctopOauthTokens.forEach(token -> executorService.submit(() -> {
+            kuaishouInterfaceService.getAdvertiserReportDaily(token, parse1, parse2, "adScene");
+        }));
+
 
 
-            for (CtopOauthToken token : tokens) {
-                executorService.submit(new Runnable() {
-                    @Override
-                    public void run() {
-                        accountMaterialOverviewService.cleanAccountMaterialOverview(token.getAccountId(), s);
-                        reportDailyGroupService.getAdvertiserGroupReportDaily(token, getStartDate, getStartDate);
-                        etlKuaiShouGroupDailyReportService.getGroupReport(token.getAccountId(), token.getAccessToken(), s, s, 1);
-                    }
-                });
-            }
         }
-    }
 
     @GetMapping("/getVideoByProjectId")
     public String getVideoByProjectId(Long projectId) {
@@ -1034,7 +1032,6 @@ public class TestController {
     }
 
 
-
     @Autowired
     private IBytedanceEffectVideoInfoService effectVideoInfoService;
 

+ 0 - 62
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyAccountReportLoadJob.java

@@ -1,62 +0,0 @@
-package org.jeecg.modules.ctop.job;
-
-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 lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.util.DateUtils;
-import org.quartz.Job;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.Date;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-/**
- * 快手广告主分天数据
- *
- * @author syh
- */
-@Slf4j
-public class KuaishouDailyAccountReportLoadJob implements Job {
-    @Autowired
-    private ICtopOauthTokenService tokenService;
-    @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
-    static ExecutorService executorService = null;
-
-    @Override
-    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        Thread thread = new Thread() {
-            @Override
-            public void run() {
-                Date getDate2 = DateUtils.addDay(new Date(), -2);
-                Date getDate = DateUtils.addDay(new Date(), -1);
-                //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
-                if (null == tokens || tokens.size() <= 0) {
-                    log.info("定时获取快手数据异常:未获取到可用的token");
-                    return;
-                }
-
-                executorService = Executors.newFixedThreadPool(3);
-                tokens.forEach(token -> {
-                    executorService.submit(new Runnable() {
-                        @Override
-                        public void run() {
-                            //跑两天前的账户报表---次留统计用
-                            kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate2, getDate2, "adScene");
-                            //1: 获取广告主信息数据
-                            kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate, getDate, "adScene");
-                        }
-                    });
-                });
-            }
-        };
-        thread.start();
-
-    }
-}

+ 0 - 60
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyAccountReportNextDayStayJob.java

@@ -1,60 +0,0 @@
-package org.jeecg.modules.ctop.job;
-
-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 lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.util.DateUtils;
-import org.quartz.Job;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.Date;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-/**
- * 快手广告主次留数据--凌晨跑两天前的次留,统一跑起来
- *
- * @author sunzhen
- */
-@Slf4j
-public class KuaishouDailyAccountReportNextDayStayJob implements Job {
-    @Autowired
-    private ICtopOauthTokenService tokenService;
-    @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
-    static ExecutorService executorService = null;
-
-    @Override
-    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        log.info("快手次留率定时任务开始");
-        Thread thread = new Thread() {
-            @Override
-            public void run() {
-                Date getDate = DateUtils.addDay(new Date(), -1);
-                //1:查询当日数据
-                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
-                if (null == tokens || tokens.size() <= 0) {
-                    log.info("定时获取快手数据异常:未获取到可用的token");
-                    return;
-                }
-
-                executorService = Executors.newFixedThreadPool(3);
-                tokens.forEach(token -> {
-                    executorService.submit(new Runnable() {
-                        @Override
-                        public void run() {
-                            //1: 获取广告主信息数据
-                            kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate, getDate, "adScene");
-                        }
-                    });
-                });
-            }
-        };
-        thread.start();
-
-    }
-}

+ 17 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyAccountReportLoadJob.java

@@ -31,7 +31,23 @@ public class KuaishouDailyAccountReportLoadJob {
     public void execute() throws Exception {
         Date getDate = DateUtils.addDay(new Date(), -1);
         Date getDate2 = DateUtils.addDay(new Date(), -2);
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        if (null == tokens || tokens.isEmpty()) {
+            XxlJobHelper.log("定时获取快手数据异常:未获取到可用的token");
+            XxlJobHelper.handleFail();
+            return;
+        }
+        tokens.forEach(token -> executorService.submit(() -> {
+            kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate2, getDate, null);
+        }));
+    }
+
 
+    @XxlJob("kuaishouDailyAccountAdSceneReport")
+    public void kuaishouDailyAccountAdSceneReport() throws Exception {
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        Date getDate2 = DateUtils.addDay(new Date(), -2);
         //1:查询当日数据
         List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
         if (null == tokens || tokens.isEmpty()) {
@@ -43,4 +59,5 @@ public class KuaishouDailyAccountReportLoadJob {
             kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate2, getDate, "adScene");
         }));
     }
+
 }

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouMaterialControer.java

@@ -100,7 +100,7 @@ public class KuaiShouMaterialControer {
             if (!Check.isNull(videoLastTime)) {
                 startTime = videoLastTime.getLastTime();
             } else {
-                startTime = DateUtils.addTime(endDate, 5);
+                startTime = DateUtils.addTime(endDate, 72);
             }
             Map<String, Object> requestMap = new HashMap<>();
             requestMap.put("startTime", DateUtils.formatDate(startTime, "yyyy-MM-dd HH:mm:ss"));

+ 6 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -276,11 +276,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
     }
 
-
     @Override
     public void getAdvertiserReportDaily(CtopOauthToken token, Date startDate, Date endDate, String reportDims) {
         try {
-            Thread.sleep(200L);
+            Thread.sleep(400L);
             getAccountDailyReportByPage(token, startDate, endDate, 1, reportDims);
         } catch (Exception e) {
             e.printStackTrace();
@@ -325,7 +324,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             log.info("快手广告主报表信息为空=》accountId:{}", token.getAccountId());
             return;
         }
-
         List<KuaishouReportDailyAccount> addList = new ArrayList<>();
         for (int i = 0; i < details.size(); i++) {
             JSONObject detailJson = details.getJSONObject(i);
@@ -336,12 +334,14 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 detailJson.put("photo_show", detailJson.getString("show"));
                 KuaishouReportDailyAccount KuaishouReportDailyAccount = JSONObject.toJavaObject(detailJson, KuaishouReportDailyAccount.class);
                 KuaishouReportDailyAccount.setAccountId(token.getAccountId());
-                //      dailyAccountMapper.insertSelective(KuaishouReportDailyAccount);
                 addList.add(KuaishouReportDailyAccount);
             }
         }
-
-        dailyAccountMapper.replaceBatch(addList);
+        if (Check.isNull(reportDims)) {
+            dailyAccountMapper.replaceBatch(addList);
+        } else {
+            dailyAccountMapper.replaceBatchAdScene(addList);
+        }
         getAccountDailyReportByPage(token, startDate, endDate, page + 1, reportDims);
     }
 

+ 21 - 20
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAccountMapper.java

@@ -1,15 +1,12 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
 import cn.com.ctop.common.module.vo.KuaishouReportAccountDailyDTOEntity;
-import cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountDaily;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouVideoInfoDTO;
-import cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO;
+import cn.com.ctop.kuaishou.modules.report.entity.*;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouReportDailyAccount> {
@@ -20,37 +17,41 @@ public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouRep
 
     List<JSONObject> selectCost(@Param("accountId") Long accountId, @Param("startDate") String startDate, @Param("endDate") String endDate);
 
-    List<ProjectAccountDTO> getKuaishouProjectInfo(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectList")List<Long> projectList, @Param("yn")Integer yn);
+    List<ProjectAccountDTO> getKuaishouProjectInfo(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projectList") List<Long> projectList, @Param("yn") Integer yn);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(@Param("projectId")Long projectId, @Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectList")List<Long> projectList, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
+    List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(@Param("projectId") Long projectId, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projectList") List<Long> projectList, @Param("accountIds") List<Long> accountIds, @Param("yn") Integer yn);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(@Param("projectList")List<Long> projectList, @Param("startDate")String startDate, @Param("endDate")String endDate, @Param("accountId")Long accountId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
+    List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(@Param("projectList") List<Long> projectList, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("accountId") Long accountId, @Param("accountIds") List<Long> accountIds, @Param("yn") Integer yn);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(@Param("projectList")List<Long> projectList, @Param("startDate")String startDate, @Param("endDate")String endDate, @Param("campaignId")Long campaignId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
+    List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(@Param("projectList") List<Long> projectList, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("campaignId") Long campaignId, @Param("accountIds") List<Long> accountIds, @Param("yn") Integer yn);
 
-    List<Long> queryProjectMemberByUserId(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
+    List<Long> queryProjectMemberByUserId(@Param("userId") String userId, @Param("mediaIds") List<Long> mediaIds);
 
-    List<Long> queryProjectInfoBySaleId(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
+    List<Long> queryProjectInfoBySaleId(@Param("userId") String userId, @Param("mediaIds") List<Long> mediaIds);
 
-    List<ProjectAccountDTO> queryProjectMemberByIds(@Param("projectIds")List<Long> projectIds);
+    List<ProjectAccountDTO> queryProjectMemberByIds(@Param("projectIds") List<Long> projectIds);
 
-    String getRoleCodeByUserId(@Param("userId")String userId);
+    String getRoleCodeByUserId(@Param("userId") String userId);
 
-    List<Long> queryProjectMemberByAdmins(@Param("mediaIds")List<Long> mediaIds);
+    List<Long> queryProjectMemberByAdmins(@Param("mediaIds") List<Long> mediaIds);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(@Param("projectList")List<Long> projectList, @Param("startDate")String startDate, @Param("endDate")String endDate, @Param("unitId")Long unitId, @Param("accountIds") List<Long> accoundIds, @Param("yn")Integer yn);
+    List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(@Param("projectList") List<Long> projectList, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("unitId") Long unitId, @Param("accountIds") List<Long> accoundIds, @Param("yn") Integer yn);
 
-    KuaishouVideoInfoDTO getVideoUrl(@Param("photoId")Long photoId);
+    KuaishouVideoInfoDTO getVideoUrl(@Param("photoId") Long photoId);
 
-    List<Long> getUserProjectAccountIds(@Param("userId")String userId, @Param("yn")Integer yn);
+    List<Long> getUserProjectAccountIds(@Param("userId") String userId, @Param("yn") Integer yn);
 
-    List<Long> getUserProjectAccountIdsByAdmin(@Param("yn")Integer yn);
+    List<Long> getUserProjectAccountIdsByAdmin(@Param("yn") Integer yn);
 
-    List<Long> getSaleProjectAccountIds(@Param("userId")String userId, @Param("yn")Integer yn);
+    List<Long> getSaleProjectAccountIds(@Param("userId") String userId, @Param("yn") Integer yn);
 
-    List<KuaishouReportAccountDailyDTOEntity> getKuaishouProjectInfoEntity(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectList")List<Long> projectList, @Param("yn")Integer yn);
+    List<KuaishouReportAccountDailyDTOEntity> getKuaishouProjectInfoEntity(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("projectList") List<Long> projectList, @Param("yn") Integer yn);
 
     void replaceBatch(@Param("addList") List<KuaishouReportDailyAccount> addList);
 
+    void replaceBatchAdScene(@Param("addList") List<KuaishouReportDailyAccount> addList);
+
     List<EtlKuaishouReportAccountDaily> queryEveryDayDataForAccount();
+
+    BigDecimal getSumChargeByAccountIdAndStatDate(@Param("accountId") Long accountId, @Param("statDate") String statDate);
 }

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

@@ -205,6 +205,128 @@
     </insert>
 
 
+    <insert id="replaceBatchAdScene">
+        replace into ctop_kuaishou_report_daily_account_ad_scene(
+        account_id,
+        ad_scene,
+        charge,
+        photo_show,
+        aclick,
+        bclick,
+        photo_share,
+        photo_comment,
+        photo_like,
+        follow,
+        cancel_follow,
+        report,
+        block,
+        negative,
+        download_started,
+        download_completed,
+        activation,
+        submit,
+        stat_date,
+        photo_click,
+        photo_click_ratio,
+        action_ratio,
+        impression_1k_cost,
+        photo_click_cost,
+        action_cost,
+        event_pay_first_day,
+        event_pay_purchase_amount_first_day,
+        event_pay_first_day_roi,
+        event_pay,
+        event_pay_purchase_amount,
+        event_pay_roi,
+        event_register,
+        event_register_cost,
+        event_register_ratio,
+        event_jin_jian_app,
+        event_jin_jian_app_cost,
+        event_credit_grant_app,
+        event_credit_grant_app_cost,
+        event_credit_grant_app_ratio,
+        event_order_paid,
+        event_order_paid_purchase_amount,
+        event_jin_jian_landing_page,
+        event_jin_jian_landing_page_cost,
+        event_credit_grant_landing_page,
+        event_credit_grant_landing_page_cost,
+        event_credit_grant_landing_ratio,
+        event_next_day_stay_cost,
+        event_next_day_stay_ratio,
+        form_action_ratio,
+        event_order_paid_cost,
+        event_next_day_stay,
+        form_cost,
+        form_count,
+        play_3s_ratio
+
+        )
+        values
+        <foreach collection="addList" item="add" separator=",">
+            (
+            #{add.accountId},
+            #{add.adScene},
+            #{add.charge},
+            #{add.photoShow},
+            #{add.aclick},
+            #{add.bclick},
+            #{add.photoShare},
+            #{add.photoComment},
+            #{add.photoLike},
+            #{add.follow},
+            #{add.cancelFollow},
+            #{add.report},
+            #{add.block},
+            #{add.negative},
+            #{add.downloadStarted},
+            #{add.downloadCompleted},
+            #{add.activation},
+            #{add.submit},
+            #{add.statDate},
+            #{add.photoClick},
+            #{add.photoClickRatio},
+            #{add.actionRatio},
+            #{add.impression1kCost},
+            #{add.photoClickCost},
+            #{add.actionCost},
+            #{add.eventPayFirstDay},
+            #{add.eventPayPurchaseAmountFirstDay},
+            #{add.eventPayFirstDayRoi},
+            #{add.eventPay},
+            #{add.eventPayPurchaseAmount},
+            #{add.eventPayRoi},
+            #{add.eventRegister},
+            #{add.eventRegisterCost},
+            #{add.eventRegisterRatio},
+            #{add.eventJinJianApp},
+            #{add.eventJinJianAppCost},
+            #{add.eventCreditGrantApp},
+            #{add.eventCreditGrantAppCost},
+            #{add.eventCreditGrantAppRatio},
+            #{add.eventOrderPaid},
+            #{add.eventOrderPaidPurchaseAmount},
+            #{add.eventJinJianLandingPage},
+            #{add.eventJinJianLandingPageCost},
+            #{add.eventCreditGrantLandingPage},
+            #{add.eventCreditGrantLandingPageCost},
+            #{add.eventCreditGrantLandingRatio},
+            #{add.eventNextDayStayCost},
+            #{add.eventNextDayStayRatio},
+            #{add.formActionRatio},
+            #{add.eventOrderPaidCost},
+            #{add.eventNextDayStay},
+            #{add.formCost},
+            #{add.formCount},
+            #{add.play3sRatio}
+
+            )
+        </foreach>
+
+    </insert>
+
+
     <insert id="insertSelective" parameterType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount">
         replace into ctop_kuaishou_report_daily_account
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -1368,5 +1490,10 @@
     WHERE stat_date = DATE_FORMAT(date_sub(now(), interval 1 day), '%Y-%m-%d')
     GROUP BY account_id
     </select>
+    <select id="getSumChargeByAccountIdAndStatDate" resultType="java.math.BigDecimal">
+        select  sum(charge)  from  ctop_kuaishou_report_daily_account
+        where account_id = #{accountId}
+        and stat_date = #{statDate}
+    </select>
 
 </mapper>