소스 검색

视频库-更新视频关联创意数 参数调整

zhaoxian 3 년 전
부모
커밋
d19202619d

+ 5 - 2
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouVideoRelateCreativesJob.java

@@ -40,6 +40,7 @@ public class KuaishouVideoRelateCreativesJob {
 
     /**
      * 视频库-更新视频关联创意数
+     *
      * @throws Exception
      */
     @XxlJob("kuaishouVideoRelateCreativesJob")
@@ -90,7 +91,7 @@ public class KuaishouVideoRelateCreativesJob {
             int count = 0;
             for (KuaiShouVideoGet video : KuaiShouVideoGets) {
                 count++;
-                if (count < 20) {
+                if (count < 19) {
                     photoIds.add(video.getPhotoId());
                     statdateMap.put(video.getPhotoId(), video);
                 } else {
@@ -101,7 +102,9 @@ public class KuaishouVideoRelateCreativesJob {
                     count = 0;
                 }
             }
-            dateList.add(photoIds);
+            if (photoIds.size() > 0) {
+                dateList.add(photoIds);
+            }
             kuaishouVideoRelateCreativesService.videoRelateCreatives(accountId, dateList, statdateMap);
         }
     }

+ 13 - 9
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouVideoRelateCreativesServiceImpl.java

@@ -114,7 +114,9 @@ public class KuaishouVideoRelateCreativesServiceImpl extends ServiceImpl<Kuaisho
                 params.put("advertiser_id", accountId);
                 params.put("photo_ids", photoIds.getJSONArray(i));
                 String result = HttpUtils.httpPostRequest(url, params, header);
+                log.info(params.toJSONString());
                 JSONObject resultJson = JSONObject.parseObject(result);
+                log.info(resultJson.toJSONString());
                 if (!Check.isNull(resultJson)) {
                     Integer code = resultJson.getInteger("code");
                     if (code == 0) {
@@ -151,17 +153,17 @@ public class KuaishouVideoRelateCreativesServiceImpl extends ServiceImpl<Kuaisho
     }
 
     @Override
-    public List<KuaishouVideoRelateCreatives> listByParams(Long accountId,Integer matNum) {
+    public List<KuaishouVideoRelateCreatives> listByParams(Long accountId, Integer matNum) {
         QueryWrapper<KuaishouVideoRelateCreatives> queryWrapper = new QueryWrapper<>();
-        if(null!=accountId&&accountId!=0){
-            queryWrapper.eq("account_id",accountId);
+        if (null != accountId && accountId != 0) {
+            queryWrapper.eq("account_id", accountId);
         }
-        if(null == matNum||matNum == 0){
+        if (null == matNum || matNum == 0) {
             matNum = 10;
         }
-        queryWrapper.le("creative_count",30);
+        queryWrapper.le("creative_count", 30);
         queryWrapper.orderByDesc("stat_date");
-        queryWrapper.last("limit "+matNum);
+        queryWrapper.last("limit " + matNum);
         return this.list(queryWrapper);
     }
 
@@ -188,18 +190,20 @@ public class KuaishouVideoRelateCreativesServiceImpl extends ServiceImpl<Kuaisho
             int count = 0;
             for (KuaiShouVideoGet video : KuaiShouVideoGets) {
                 count++;
-                if (count < 20) {
+                if (count < 19) {
                     photoIds.add(video.getPhotoId());
                     statdateMap.put(video.getPhotoId(), video);
                 } else {
                     photoIds.add(video.getPhotoId());
-                    statdateMap.put(video.getPhotoId(),video);
+                    statdateMap.put(video.getPhotoId(), video);
                     dateList.add(photoIds);
                     photoIds = new JSONArray();
                     count = 0;
                 }
             }
-            dateList.add(photoIds);
+            if (photoIds.size() > 0) {
+                dateList.add(photoIds);
+            }
             this.videoRelateCreatives(accountId, dateList, statdateMap);
         }
     }