yumeng 4 роки тому
батько
коміт
2360ae4d56

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

@@ -136,9 +136,42 @@ public class TestController {
 
 
     @GetMapping("/cleanNewlyData")
-    public void cleanNewlyData() {
+    public void cleanNewlyData(String date) {
+        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);
+
+
+            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);
+                    }
+                });
+            }
+
+
+
+            //1: 获取广告主信息数据
+            //   getAdvertiserReportHourly(token, getStartDate, getStartDate);
+            //  getAdvertiserReportDaily(token, getStartDate, getStartDate, "adScene");
+            //2:获取广告计划信息数据
+            // getAdvertiserCampaignReportHourly(token, getStartDate, getStartDate);
+            //3:获取广告组信息数据
+            // getAdvertiserGroupReportHourly(token, getStartDate, getStartDate);
+            //4: 获取广告创意信息数据
+            // getAdvertiserCreativeReportHourly(token, getStartDate, getStartDate);
+        }
+
+
         String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-        newlyService.cleanNewlyData(nowDate);
+        newlyService.cleanNewlyData(date);
         XxlJobHelper.log("快手清洗上新计划数据完成");
     }
 
@@ -1057,9 +1090,6 @@ public class TestController {
     }
 
 
-
-
-
     @Autowired
     private IByteDanceAdvertiserDataService advertiserDataService;
 

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

@@ -24,4 +24,6 @@ public interface EtlKuaishouReportAccountDailyMapper extends BaseMapper<EtlKuais
     List<JSONObject> getOnedayEtlReportList(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("accountId") Long accountId, @Param("value") String value, @Param("type") String type);
 
     Long getMaxChargeAccountId(@Param("userId") String userId);
+
+    Long getMaxCharge();
 }

+ 7 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouReportAccountDailyMapper.xml

@@ -258,6 +258,12 @@
                  INNER JOIN ctop_kuaishou_report_hourly_account t2 ON t1.account_id = t2.account_id
         where t2.stat_date = DATE_FORMAT(now(), '%Y-%m-%d')
           AND t1.user_id = #{userId}
-        order by charge desc limit 1
+        order by sum(charge) desc limit 1
+    </select>
+    <select id="getMaxCharge" resultType="java.lang.Long">
+          SELECT account_id
+        FROM  ctop_kuaishou_report_hourly_account
+        where stat_date = DATE_FORMAT(now(), '%Y-%m-%d')
+        order by sum(charge) desc limit 1
     </select>
 </mapper>

+ 4 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaishouReportAccountHourlyServiceImpl.java

@@ -16,9 +16,7 @@ import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportHourlyAccountMap
 import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaishouReportAccountHourlyService;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -140,11 +138,14 @@ public class EtlKuaishouReportAccountHourlyServiceImpl extends ServiceImpl<EtlKu
     public Result<Object> getMaxChargeAccountId(Long accountId, String userId) {
         if (Check.isNull(accountId)) {
             accountId = etlDailyAccountMapper.getMaxChargeAccountId(userId);
+            if (Check.isNull(accountId)) {
+                accountId = etlDailyAccountMapper.getMaxCharge();
+            }
         }
         JSONObject obj = new JSONObject();
         CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
         if (Check.isNull(oauthToken)) {
-            return Result.error("未获取到账户信息");
+            return Result.error("未获取到账户信息,accountId:" + accountId);
         }
         JSONObject fundJson = iKuaishouInterfaceService.fundGet(oauthToken);
         if (!Check.isNull(fundJson)) {