yumeng 5 vuotta sitten
vanhempi
commit
c524a8319a

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

@@ -17,6 +17,8 @@ import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCreativeMapper;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCreativeStatisticMapper;
 import cn.com.ctop.toutiao.service.IByteDanceAdvertiserDataService;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -201,6 +203,75 @@ public class TestController {
     }
 
 
+    @Autowired
+    private IUserAllocationService userAllocationService;
+    @Autowired
+    private KuaishouReportDailyCreativeStatisticMapper reportDailyCreativeStatisticMapper;
+
+
+    @Autowired
+    private KuaishouReportDailyCreativeMapper reportDailyCreativeMapper;
+
+    @GetMapping(value = "/getCreativeReportByProjectId")
+    public void getCreativeReportByProjectId(Long projectId) {
+
+        try {
+            Map<String, Object> deleteMap = new HashMap<>();
+            String date = DateUtils.getDate("yyyy-MM-dd");
+            String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", date, -1);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            Date endDate = simpleDateFormat.parse(anotherDay);
+            QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
+            userAllocationQueryWrapper.eq("project_id", projectId);
+            List<UserAllocation> list = userAllocationService.list(userAllocationQueryWrapper);
+            if (!Check.isNull(list)) {
+                for (UserAllocation allocation : list) {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            if (!Check.isNull(allocation)) {
+
+                                QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
+                                oauthTokenQueryWrapper.eq("media_id", 2);
+                                oauthTokenQueryWrapper.eq("account_id", allocation.getAccountId());
+                                CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
+                                if (!Check.isNull(ctopOauthToken)) {
+                                    deleteMap.put("account_id", allocation.getAccountId());
+                                    deleteMap.put("stat_date", anotherDay);
+                                    reportDailyCreativeStatisticMapper.deleteByMap(deleteMap);
+                                    reportDailyCreativeMapper.deleteByMap(deleteMap);
+
+                                    // 1.计划数据
+                                    kuaishouInterfaceService.getCampaignList(ctopOauthToken, null, null);
+                                    // 2:广告组数据
+                                    kuaishouInterfaceService.getGroupList(ctopOauthToken, null, null);
+                                    // 3:创意数据
+                                    kuaishouInterfaceService.getCreativeList(ctopOauthToken, null, null);
+
+                                    QueryWrapper<KuaiShouCampaign> campaignQueryWrapper = new QueryWrapper<>();
+                                    campaignQueryWrapper.eq("account_id", ctopOauthToken.getAccountId());
+                                    List<KuaiShouCampaign> campaigns = campaignService.list(campaignQueryWrapper);
+                                    if (!Check.isNull(list)) {
+                                        for (KuaiShouCampaign campaign : campaigns) {
+                                            kuaishouInterfaceService.getAdvertiserCreativeReportDailyV2(campaign.getCampaignId(), ctopOauthToken, endDate, endDate);
+                                        }
+                                    }
+                                }
+                            }
+
+                        }
+                    });
+
+
+                }
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+
+    }
+
+
     @GetMapping(value = "/getPlanAndGroupByAccount")
     public void getPlanAndGroupByAccount(Long accountId) {
         QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
@@ -240,9 +311,11 @@ public class TestController {
             public void run() {
                 try {
                     System.err.println("获取创意,accountId:" + token.getAccountId());
+                    // 1.计划数据
                     kuaishouInterfaceService.getCampaignList(token, null, null);
-                    //1:获取全量广告组数据
+                    // 2:广告组数据
                     kuaishouInterfaceService.getGroupList(token, null, null);
+                    // 3:创意数据
                     kuaishouInterfaceService.getCreativeList(token, null, null);
 
                     Thread.sleep(1 * 200);
@@ -280,8 +353,6 @@ public class TestController {
         thread.start();
     }
 
-    @Autowired
-    private IUserAllocationService userAllocationService;
 
     @Autowired
     private IBytedancePlanDailyReportService planDailyReportService;