yumeng 3 éve
szülő
commit
0c8e7d8f70

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 70 - 48
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java


+ 57 - 34
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -111,7 +111,25 @@ public class SampleTest {
 
     @Test
     public void loadKuaishouCookie() throws ParseException {
-        sendMessageService.sendMessage("d2331a00e1be42ec8542167e321eeb01","测试消息");
+        List<Long> accList = new ArrayList<>();
+        accList.add(11789495L);
+        accList.add(11574866L);
+        for (int i = 0; i < accList.size(); i++) {
+            Long aLong = accList.get(i);
+            CtopOauthToken token = tokenService.getTokenByAccountId(aLong);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            Date parse = simpleDateFormat.parse("2021-12-17");
+            Date parse1 = simpleDateFormat.parse("2021-12-23");
+
+
+            kuaishouInterfaceService.getAdvertiserReportDaily(token, parse, parse1, null);
+            kuaiShouReportDailyMaterialService.getMaterialReportByAccountIdAndStatDate(token.getAccountId(), token.getAccessToken(), "2021-12-17", "2021-12-23", "DAILY", 1);
+
+
+        }
+
+
+        // sendMessageService.sendMessage("d2331a00e1be42ec8542167e321eeb01", "测试消息");
     }
 
 
@@ -266,17 +284,19 @@ public class SampleTest {
 
     @Autowired
     private IEtlKuaishouVideoInfoService etlKuaishouVideoInfo;
+
     @Test
-    public void loadkuaishouVideoData(){
+    public void loadkuaishouVideoData() {
         String startDate = "2021-05-07";
-        for(int i=0;i<=60;i++){
-            String getDate = DateUtils.formatDate(DateUtils.addDay(startDate,i));
+        for (int i = 0; i <= 60; i++) {
+            String getDate = DateUtils.formatDate(DateUtils.addDay(startDate, i));
             etlKuaishouVideoInfo.etlKuaishouVideoInfo(getDate);
         }
     }
 
     @Autowired
     private IKuaiShouReportDailyMaterialService kuaiShouReportDailyMaterialService;
+
     @Test
     public void loadKuaishouMatData() throws InterruptedException {
         String startDate = "2021-06-18";
@@ -287,16 +307,17 @@ public class SampleTest {
         tokens.forEach(token -> executorService.submit(() -> {
             try {
                 kuaiShouReportDailyMaterialService.getMaterialReportByAccountIdAndStatDate(token.getAccountId(), token.getAccessToken(), startDate, endDate, "DAILY", 1);
-            }catch (Exception e){
-            }finally {
+            } catch (Exception e) {
+            } finally {
                 countDownLatch.countDown();
             }
         }));
         countDownLatch.await();
         System.out.println("数据获取完成");
     }
+
     @Test
-    public void loadKuaiShouMatHourlyData() throws InterruptedException{
+    public void loadKuaiShouMatHourlyData() throws InterruptedException {
 //        kuaiShouReportDailyMaterialService.getMaterialReportByAccountIdAndStatDate(7411077l, tokenService.getOauthTokenByAccountId("7411077").getAccessToken(), "2021-07-02", "2021-07-02", "HOURLY", 1);
 
         String startDate = "2021-07-19";
@@ -308,8 +329,8 @@ public class SampleTest {
         tokens.forEach(token -> executorService.submit(() -> {
             try {
                 kuaiShouReportDailyMaterialService.getMaterialReportByAccountIdAndStatDate(token.getAccountId(), token.getAccessToken(), startDate, endDate, "HOURLY", 1);
-            }catch (Exception e){
-            }finally {
+            } catch (Exception e) {
+            } finally {
                 countDownLatch.countDown();
             }
         }));
@@ -334,7 +355,7 @@ public class SampleTest {
         int recordsCount = 0;
         int newRecordCount = 0;
 
-        while (beginDate.before(endDate)){
+        while (beginDate.before(endDate)) {
             System.out.println("开始拆分数据,当前时间为:" + beginDate);
             List<KuaishouOperationRecord> records = kuaishouOperationRecordMapper.selectCreativeRecordByStatDate(DateUtils.formatDate(beginDate, "yyyy-MM-dd"));    //开始拆分数据,当前时间为:Tue Apr 28 00:00:00 CST 2020
 //            List<KuaishouOperationRecord> records = kuaishouOperationRecordMapper.selectAccountRecordByStatDate(DateUtils.formatDate(beginDate, "yyyy-MM-dd"));
@@ -380,12 +401,12 @@ public class SampleTest {
                 this.saveOperationRecordListToDb(newRecords);
                 beginDate = DateUtils.addDay(beginDate, 1);
             } else {
-        System.out.print("     -> 今日的数据为空!!!");
-        beginDate = DateUtils.addDay(beginDate, 1);
+                System.out.print("     -> 今日的数据为空!!!");
+                beginDate = DateUtils.addDay(beginDate, 1);
             }
         }
         System.out.println("---------------------------------------------------------------");
-        System.out.println("------------获取数据结束"+recordsCount+"条原始数据变成了"+newRecordCount+"条数据------------");
+        System.out.println("------------获取数据结束" + recordsCount + "条原始数据变成了" + newRecordCount + "条数据------------");
         System.out.println("---------------------------------------------------------------");
     }
 
@@ -446,11 +467,12 @@ public class SampleTest {
         }
     }
 
-    public void testfreshBytedanceUrl(){
+    public void testfreshBytedanceUrl() {
         etlReportBytedanceVideoService.etlBytedanceVideoClipIdJob(null);
         etlReportBytedanceVideoService.etlBytedanceVideoPlanInfoJob();
         etlReportBytedanceVideoService.etlBytedanceVideoShotInfoJob();
     }
+
     @Autowired
     IKuaishouInterfaceService2 kuaishouInterfaceServiceImpl2;
 
@@ -472,21 +494,21 @@ public class SampleTest {
         Date endDate = DateUtils.parseDate("2021-07-22", "yyyy-MM-dd");
 
         List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
-        while (beginDate.before(endDate)){
+        while (beginDate.before(endDate)) {
             Date mulDate = beginDate;
             countDownLatch = new CountDownLatch(tokens.size());
             tokens.forEach(token -> executorService.submit(() -> {
-                try{
-                    if(!accountIdList.contains(token.getAccountId())){
-                        kuaishouInterfaceServiceImpl2.getOperationRecord( token.getAccountId(),
+                try {
+                    if (!accountIdList.contains(token.getAccountId())) {
+                        kuaishouInterfaceServiceImpl2.getOperationRecord(token.getAccountId(),
                                 token.getAccessToken(),
                                 3,      //先3组   后2计划
-                                DateUtils.formatDate(mulDate,"yyyy-MM-dd"),
-                                DateUtils.formatDate(mulDate,"yyyy-MM-dd"));
-                        System.out.println("获取完毕 -> accountId:" + token.getAccountId() +",日期:" + DateUtils.formatDate(mulDate,"yyyy-MM-dd"));
+                                DateUtils.formatDate(mulDate, "yyyy-MM-dd"),
+                                DateUtils.formatDate(mulDate, "yyyy-MM-dd"));
+                        System.out.println("获取完毕 -> accountId:" + token.getAccountId() + ",日期:" + DateUtils.formatDate(mulDate, "yyyy-MM-dd"));
                     }
-                }catch (Exception e){
-                }finally {
+                } catch (Exception e) {
+                } finally {
                     countDownLatch.countDown();
                 }
             }));
@@ -502,6 +524,7 @@ public class SampleTest {
     IKuaishouAudienceReportDailyService kuaishouAudienceReportDailyService;
     @Resource
     AiKuaishouUnitLevelOperationRecordMapper kuaishouUnitLevelOperationRecordMapper;
+
     @Test
     public void getAudienceReport() throws InterruptedException {
         int page = 1;
@@ -509,28 +532,28 @@ public class SampleTest {
         Date beginDate = DateUtils.parseDate("2021-05-01", "yyyy-MM-dd");
         Date endDate = DateUtils.parseDate("2021-06-01", "yyyy-MM-dd");
 
-        while (beginDate.before(endDate)){
+        while (beginDate.before(endDate)) {
             Date mulDate = beginDate;
-            List<AiKuaishouUnitLevelOperationRecord> planIdsAndUnitIds = kuaishouUnitLevelOperationRecordMapper.selectAllByAccountId(mulDate, DateUtils.addDay(mulDate,1));
+            List<AiKuaishouUnitLevelOperationRecord> planIdsAndUnitIds = kuaishouUnitLevelOperationRecordMapper.selectAllByAccountId(mulDate, DateUtils.addDay(mulDate, 1));
             countDownLatch = new CountDownLatch(planIdsAndUnitIds.size());
             planIdsAndUnitIds.forEach(planIdAndUnitId -> executorService.submit(() -> {
-                try{
+                try {
                     CtopOauthToken token = tokenService.getTokenByAccountId(planIdAndUnitId.getAccountId());
-                    if(!Check.isNull(token)){
+                    if (!Check.isNull(token)) {
                         Date startDate = mulDate;
                         Date enDate = DateUtils.addDay(startDate, 30);
                         // province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布clientId: 系统分布 businessInterestTags: 商业兴趣分布
-                        while (startDate.before(enDate)){
-                            kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, DateUtils.formatDate(startDate,"yyyy-MM-dd"), "ageSegment", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
-                            System.out.println("获取完毕 -> unit:" + planIdAndUnitId.getUnitId() +",日期:" + DateUtils.formatDate(startDate,"yyyy-MM-dd"));
+                        while (startDate.before(enDate)) {
+                            kuaishouAudienceReportDailyService.crowdAnalysisReport2(token, DateUtils.formatDate(startDate, "yyyy-MM-dd"), "ageSegment", planIdAndUnitId.getCampaignId(), planIdAndUnitId.getUnitId(), page, pageSize);
+                            System.out.println("获取完毕 -> unit:" + planIdAndUnitId.getUnitId() + ",日期:" + DateUtils.formatDate(startDate, "yyyy-MM-dd"));
                             startDate = DateUtils.addDay(startDate, 1);
                         }
 
-                    }else {
-                        System.out.println("token异常 -》 accountId:"+planIdAndUnitId.getAccountId());
+                    } else {
+                        System.out.println("token异常 -》 accountId:" + planIdAndUnitId.getAccountId());
                     }
-                }catch (Exception e){
-                }finally {
+                } catch (Exception e) {
+                } finally {
                     countDownLatch.countDown();
                 }
             }));

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

@@ -1725,7 +1725,7 @@ public class BatchServiceImpl implements IBatchService {
                 throw new Exception("请选择广告组");
             }
             unitJson.put("unit_id", unitId);
-            queryWrapper.eq("unit_id", unitId);
+            /*queryWrapper.eq("unit_id", unitId);
             queryWrapper.last("limit 1");
             KuaiShouGroup kuaiShouGroup = groupMapper.selectOne(queryWrapper);
             if (Check.isNull(kuaiShouGroup)) {
@@ -1734,17 +1734,17 @@ public class BatchServiceImpl implements IBatchService {
             String sceneId = kuaiShouGroup.getSceneId();
             if (Check.isNull(sceneId)) {
                 throw new Exception("未获取资源位置");
-            }
+            }*/
 
             //  JSONObject jsonObject = JSONArr(sceneId);
-            Integer scene = (Integer) JSONArray.parseArray(sceneId).get(0);
+        //    Integer scene = (Integer) JSONArray.parseArray(sceneId).get(0);
 
             // 广告组名称
             if (!Check.isNull(requestJson.getString("unitName"))) {
                 unitJson.put("unit_name", requestJson.getString("unitName"));
             }
 
-            // 资源位置
+     /*       // 资源位置
             JSONArray scene_id = requestJson.getJSONArray("sceneId");
             if (!Check.isNull(scene_id)) {
                 unitJson.put("scene_id", scene_id);
@@ -1824,12 +1824,12 @@ public class BatchServiceImpl implements IBatchService {
             if (!Check.isNull(requestJson.getInteger("convertId"))) {
                 unitJson.put("convert_id", requestJson.getInteger("convertId"));
             }
-
+*/
 
             // -----------------用户定向-----------
             JSONObject targetJson = new JSONObject();
 
-            // 地域
+  /*          // 地域
             if (!Check.isNull(requestJson.getJSONArray("region"))) {
                 targetJson.put("region", requestJson.getJSONArray("region"));
             }
@@ -1885,16 +1885,16 @@ public class BatchServiceImpl implements IBatchService {
 
             if (!Check.isNull(requestJson.getJSONArray("population"))) {
                 targetJson.put("population", requestJson.getJSONArray("population"));
-            }
+            }*/
             // 人群包排除
             if (!Check.isNull(requestJson.getJSONArray("excludePopulation"))) {
                 targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
             }
 
-            if (!Check.isNull(requestJson.getJSONArray("thirdPlatformCode"))) {
+          /*  if (!Check.isNull(requestJson.getJSONArray("thirdPlatformCode"))) {
                 targetJson.put("third_platform_code", requestJson.getJSONArray("thirdPlatformCode"));
-            }
-
+            }*/
+/*
             if (scene != 5) {
                 if (!Check.isNull(requestJson.getInteger("filterConvertedLevel"))) {
                     targetJson.put("filter_converted_level", requestJson.getInteger("filterConvertedLevel"));
@@ -1971,7 +1971,7 @@ public class BatchServiceImpl implements IBatchService {
             }
             if (!behaviorInterest.isEmpty()) {
                 targetJson.put("behavior_interest", behaviorInterest);
-            }
+            }*/
             unitJson.put("target", targetJson);
             returnJson = updateService.updateUnit(token.getAccessToken(), unitJson);
         } catch (Exception e) {

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

@@ -610,8 +610,8 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
             headers.put("Content-Type", "application/json");
             String result = HttpUtils.kuaiShouhttpPostRequest(url, unitJson.toJSONString(), headers);
             JSONObject resultJson = JSONObject.parseObject(result);
-            log.info("修改广告组返回信息:{}", resultJson);
-            if (!Check.isNull(resultJson)) {
+            log.info("组id:{},修改广告组返回信息:{}", unitJson.getLong("unit_id"), resultJson);
+            /*if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
                     JSONObject data = resultJson.getJSONObject("data");
@@ -661,7 +661,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                     returnJson.put("code", -1);
                     returnJson.put("message", resultJson.getString("message"));
                 }
-            }
+            }*/
         } catch (Exception e) {
             e.printStackTrace();
             returnJson.put("code", -1);