Selaa lähdekoodia

添加智能投放素材视频拉取任务

syh 4 vuotta sitten
vanhempi
commit
75b2684e82

+ 1 - 12
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -401,7 +401,7 @@ public class SampleTest {
 
     @Test
     public void execute() {
-        String accountIds = "1675239584963662,1676540490482759,1675237415468045";
+        String accountIds = "1675239584963662,1675237415468045";
         String[] arrays = accountIds.split(",");
         for (int i = 0; i < arrays.length; i++) {
             Long accountId = Long.parseLong(arrays[i]);
@@ -411,17 +411,6 @@ public class SampleTest {
         }
     }
 
-    @Test
-    public void loadBytedanceData() {
-        String accountIds = "1676540490482759";
-        String[] arrays = accountIds.split(",");
-        for (int i = 0; i < arrays.length; i++) {
-            Long accountId = Long.parseLong(arrays[i]);
-            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
-            load12Data(token);
-        }
-    }
-
     private void load12AccountData(CtopOauthToken token) {
         reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-12-01", "yyyy-MM-dd"), DateUtils.parseDate("2020-12-11", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
         reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-12-11", "yyyy-MM-dd"), DateUtils.parseDate("2020-12-21", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);

+ 43 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAiSuzaoVideoJob.java

@@ -0,0 +1,43 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountTargetTemplate;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAccountTargetTemplateService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouNewCreateCampaign;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.List;
+
+@Component
+public class KuaishouAiSuzaoVideoJob {
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    @Autowired
+    IAiKuaishouNewCreateCampaign aiKuaishouNewCreateCampaign;
+    @Autowired
+    private IAiKuaishouAccountTargetTemplateService aiKuaishouAccountTargetTemplateService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @XxlJob("kuaishouAiSuzaoVideoJob")
+    public void kuaishouAiSuzaoVideoJob() {
+        List<AiKuaishouAccountTargetTemplate> accountTargetTemplates = aiKuaishouAccountTargetTemplateService.getAllEffectTemplate();
+        if(null==accountTargetTemplates||accountTargetTemplates.isEmpty()){
+            return;
+        }
+        accountTargetTemplates.forEach(targetTemplate -> {
+            CtopOauthToken token = tokenService.getTokenByAccountId(targetTemplate.getAccountId());
+            int timeStart = -3;
+            int timeEnd = 0;
+            Long now = System.currentTimeMillis();
+            String startTime = DateUtils.formatDate(new Date(now + timeStart*60*1000),"yyyy-MM-dd HH:mm:ss");
+            String endTime = DateUtils.formatDate(new Date(now + timeEnd*60*1000),"yyyy-MM-dd HH:mm:ss");
+            kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startTime,endTime);
+        });
+    }
+}

+ 0 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouNewCreateCampaignServiceImpl.java

@@ -73,9 +73,6 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
         Long now = System.currentTimeMillis();
         String startTime = DateUtils.formatDate(new Date(now + timeStart*60*1000),"yyyy-MM-dd HH:mm:ss");
         String endTime = DateUtils.formatDate(new Date(now + timeEnd*60*1000),"yyyy-MM-dd HH:mm:ss");
-        kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startTime,endTime);
-
-
         // 3、获取5分钟内,ctop_kuaishou_video_get 的视频数据,记为 N,如果有数据则执行下面步骤
         List<KuaiShouVideoGet> newVideos = videoGetService.getNewVideoBetweenTime(accountId,startTime,endTime);
         int newVideosCnt = newVideos.size();

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

@@ -1,8 +1,10 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.MaterialCutFrame;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.enums.MaterialEnum;
+import cn.com.ctop.common.module.service.IMaterialCutFrameService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.*;
 import cn.com.ctop.kuaishou.modules.batch.entity.*;
@@ -2922,7 +2924,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         }
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
-//        System.out.println(resultJson.toJSONString());
         if (Check.isNull(resultJson)) {
             return;
         }
@@ -2973,12 +2974,12 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 suZhaoService.submit(new Runnable() {
                     @Override
                     public void run() {
-                        videoGetService.getKeyFrame(token, accountId, md5, String.valueOf(photo_id));
-
+                        List<MaterialCutFrame> cutFrames = cutFrameService.getListByVideoSignature(md5);
+                        if(null!=cutFrames&&!cutFrames.isEmpty()){
+                            videoGetService.getKeyFrame(token, accountId, md5, String.valueOf(photo_id));
+                        }
                     }
                 });
-
-
             }
         }
 
@@ -2986,6 +2987,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
     }
 
+    @Autowired
+    private IMaterialCutFrameService cutFrameService;
     private static ExecutorService executorService = Executors.newFixedThreadPool(10);
 
     @Override

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

@@ -24,10 +24,8 @@ public class KuaiShouGetAccountFundServiceImpl implements IKuaiShouGetAccountFun
         Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", "application/json");
         headers.put("Access-Token", token.getAccessToken());
-
         JSONObject params=new JSONObject();
         params.put("advertiser_id",advertiserId);
-
         JSONObject jsonObject = JSONObject.parseObject(HttpUtils.httpGetRequest("https://ad.e.kuaishou.com/rest/openapi/v1/advertiser/fund/get", headers,params));
         if(jsonObject.getInteger("code")!=0){
             XxlJobHelper.log("查询账户余额失败==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
@@ -38,7 +36,6 @@ public class KuaiShouGetAccountFundServiceImpl implements IKuaiShouGetAccountFun
 
     @Override
     public JSONObject getAccountReportBy(CtopOauthToken token, Long advertiserId) {
-
         JSONObject result= new JSONObject();
         Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", "application/json");