Explorar o código

素材库修改 && 自动投放接口调整

yumeng %!s(int64=4) %!d(string=hai) anos
pai
achega
963f47c211

+ 9 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialAscriptionController.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.ctop.controller;
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.entity.MaterialAscription;
 import cn.com.ctop.common.module.entity.MaterialAscription;
 import cn.com.ctop.common.module.service.IMaterialAscriptionService;
 import cn.com.ctop.common.module.service.IMaterialAscriptionService;
+import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -118,7 +119,14 @@ public class MaterialAscriptionController {
         Result<MaterialAscription> result = new Result<>();
         Result<MaterialAscription> result = new Result<>();
         QueryWrapper<MaterialAscription> ascriptionQueryWrapper = new QueryWrapper<>();
         QueryWrapper<MaterialAscription> ascriptionQueryWrapper = new QueryWrapper<>();
         ascriptionQueryWrapper.eq("material_id", materialAscription.getMaterialId());
         ascriptionQueryWrapper.eq("material_id", materialAscription.getMaterialId());
-        boolean ok = materialAscriptionService.update(materialAscription, ascriptionQueryWrapper);
+        ascriptionQueryWrapper.last("limit 1");
+        MaterialAscription one = materialAscriptionService.getOne(ascriptionQueryWrapper);
+        boolean ok;
+        if (Check.isNull(one)) {
+            ok = materialAscriptionService.save(materialAscription);
+        } else {
+            ok = materialAscriptionService.update(materialAscription, ascriptionQueryWrapper);
+        }
         if (ok) {
         if (ok) {
             result.success("修改成功!");
             result.success("修改成功!");
         }
         }

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

@@ -8,6 +8,7 @@ import cn.com.ctop.common.module.vo.ResFileDTO;
 import cn.com.ctop.crawler.modules.core.entity.CrawlerDouyinMusicTask;
 import cn.com.ctop.crawler.modules.core.entity.CrawlerDouyinMusicTask;
 import cn.com.ctop.crawler.modules.core.service.CrawlerDouyinMusicTaskService;
 import cn.com.ctop.crawler.modules.core.service.CrawlerDouyinMusicTaskService;
 import cn.com.ctop.crawler.modules.douyin.service.DouyinMusicService;
 import cn.com.ctop.crawler.modules.douyin.service.DouyinMusicService;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplate;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
@@ -15,6 +16,7 @@ import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataServ
 import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
 import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
 import cn.com.ctop.toutiao.modules.report.service.*;
 import cn.com.ctop.toutiao.modules.report.service.*;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -90,6 +92,46 @@ public class TestController {
     static ExecutorService suzhaoService = Executors.newFixedThreadPool(5);
     static ExecutorService suzhaoService = Executors.newFixedThreadPool(5);
     @Autowired
     @Autowired
     private IKuaiShouDailyAgentService dailyAgentService;
     private IKuaiShouDailyAgentService dailyAgentService;
+    @Autowired
+    private IKuaishouTemplateService templateService;
+
+
+    @GetMapping(value = "/updateTemplate")
+    public void updateTemplate(Long projectId, String startDate, String endDate) {
+
+        List<Long> list = new ArrayList();
+        list.add(7022550L);
+        list.add(7409586L);
+        list.add(5473041L);
+        list.add(5852766L);
+        list.add(6962896L);
+        list.add(7409919L);
+        for (int i = 0; i < list.size(); i++) {
+            Long accountId = list.get(i);
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            templateService.getTemplateByAccountId(oauthToken.getAccountId(), oauthToken.getAccessToken(), 1);
+
+            QueryWrapper<KuaishouTemplate> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("account_id", accountId);
+            List<KuaishouTemplate> list1 = templateService.list(queryWrapper);
+            if (!Check.isNull(list1)) {
+                for (KuaishouTemplate template : list1) {
+                    JSONObject param = new JSONObject();
+                    param.put("templateId", template.getTemplateId());
+                    param.put("accountId", template.getAccountId());
+                    param.put("templateName", template.getTemplateName());
+                    param.put("filterConvertedLevel", 5);
+                    templateService.updateTemplate(oauthToken.getAccountId(), oauthToken.getAccessToken(), param);
+
+                }
+
+            }
+
+
+        }
+
+
+    }
 
 
 
 
     @GetMapping(value = "/getCreativeByProjectId")
     @GetMapping(value = "/getCreativeByProjectId")

+ 1 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -83,6 +83,7 @@ public class KuaishouInterfaceConstant {
      * 创建定向模板
      * 创建定向模板
      */
      */
     public static final String TEMPLATE_CREATE = "/rest/openapi/v1/target/template/create";
     public static final String TEMPLATE_CREATE = "/rest/openapi/v1/target/template/create";
+    public static final String TEMPLATE_UPDATE = "/rest/openapi/v1/target/template/update";
     /**
     /**
      * 获取地域信息
      * 获取地域信息
      */
      */

+ 1 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouMaterialControer.java

@@ -106,6 +106,7 @@ public class KuaiShouMaterialControer {
 
 
     @PostMapping(value = "/getHistoryVideoList")
     @PostMapping(value = "/getHistoryVideoList")
     public JSONObject getHistoryVideoList(@RequestBody JSONObject requestJson) {
     public JSONObject getHistoryVideoList(@RequestBody JSONObject requestJson) {
+        System.err.println(requestJson);
         JSONObject returnJson = new JSONObject();
         JSONObject returnJson = new JSONObject();
         try {
         try {
             if (Check.isNull(requestJson)) {
             if (Check.isNull(requestJson)) {

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

@@ -155,7 +155,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                 } else {
                 } else {
                     JSONObject target = getTarget(groupCreateJson);
                     JSONObject target = getTarget(groupCreateJson);
                     if (!Check.isNull(target)) {
                     if (!Check.isNull(target)) {
-                        createJson.put("getTarget", target); // 定向数据
+                        createJson.put("target", target); // 定向数据
                     }
                     }
                 }
                 }
                 Map<String, Object> unitMap = iKuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), createJson, 1);
                 Map<String, Object> unitMap = iKuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), createJson, 1);
@@ -183,7 +183,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                 }
                 }
                 returnArr.add(returnJson);
                 returnArr.add(returnJson);
             }
             }
-            callback("url", returnArr);
+            callback("http://192.168.1.193:31012/ai_callback_add_group", returnArr);
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
             log.error("创建组错误!!!!!");
             log.error("创建组错误!!!!!");
@@ -292,7 +292,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                 }
                 }
                 returnArr.add(returnJson);
                 returnArr.add(returnJson);
             }
             }
-            callback("url", returnArr);
+            callback("http://192.168.1.193:31012/ai_callback_add_creative", returnArr);
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
         }
         }

+ 28 - 21
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouTemplateServiceImpl.java

@@ -346,8 +346,12 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
             }
             }
 
 
             JSONObject param = new JSONObject();
             JSONObject param = new JSONObject();
+            param.put("template_id", requestJson.getLong("templateId"));
             param.put("advertiser_id", accountId);
             param.put("advertiser_id", accountId);
-            param.put("template_name", requestJson.getString("templateName"));
+            if(!Check.isNull(requestJson.getString("templateName"))){
+                param.put("template_name", requestJson.getString("templateName"));
+            }
+
             JSONObject targetJson = new JSONObject();
             JSONObject targetJson = new JSONObject();
             if (!Check.isNull(requestJson.getJSONArray("region"))) {
             if (!Check.isNull(requestJson.getJSONArray("region"))) {
                 targetJson.put("region", requestJson.getJSONArray("region"));
                 targetJson.put("region", requestJson.getJSONArray("region"));
@@ -362,14 +366,11 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
                 targetJson.put("ages_range", requestJson.getJSONArray("agesRange"));
                 targetJson.put("ages_range", requestJson.getJSONArray("agesRange"));
             }
             }
 
 
-            JSONObject ageJson = new JSONObject();
-            if (!Check.isNull(requestJson.getInteger("min"))) {
+
+            if (!Check.isNull(requestJson.getInteger("min")) && !Check.isNull(requestJson.getInteger("max"))) {
+                JSONObject ageJson = new JSONObject();
                 ageJson.put("min", requestJson.getInteger("min"));
                 ageJson.put("min", requestJson.getInteger("min"));
-            }
-            if (!Check.isNull(requestJson.getInteger("max"))) {
                 ageJson.put("max", requestJson.getInteger("max"));
                 ageJson.put("max", requestJson.getInteger("max"));
-            }
-            if (!Check.isNull(ageJson)) {
                 targetJson.put("age", ageJson);
                 targetJson.put("age", ageJson);
             }
             }
 
 
@@ -424,23 +425,27 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
             if (!Check.isNull(requestJson.getJSONArray("excludePopulation"))) {
             if (!Check.isNull(requestJson.getJSONArray("excludePopulation"))) {
                 targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
                 targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
             }
             }
-            JSONObject intelliExtendJson = new JSONObject();
+
 
 
             if (!Check.isNull(requestJson.getInteger("isOpen"))) {
             if (!Check.isNull(requestJson.getInteger("isOpen"))) {
+                JSONObject intelliExtendJson = new JSONObject();
                 intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
                 intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
+
+                if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
+                    intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
+                }
+                if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
+                    intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
+                }
+                if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
+                    intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
+                }
+                if (!Check.isNull(intelliExtendJson)) {
+                    targetJson.put("intelli_extend", intelliExtendJson);
+                }
+
             }
             }
-            if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
-                intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
-            }
-            if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
-                intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
-            }
-            if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
-                intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
-            }
-            if (!Check.isNull(intelliExtendJson)) {
-                targetJson.put("intelli_extend", intelliExtendJson);
-            }
+
             if (!Check.isNull(targetJson)) {
             if (!Check.isNull(targetJson)) {
                 param.put("target", targetJson);
                 param.put("target", targetJson);
             }
             }
@@ -448,9 +453,11 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
             Map<String, String> headers = new HashMap<String, String>();
             Map<String, String> headers = new HashMap<String, String>();
             headers.put("Access-Token", accessToken);
             headers.put("Access-Token", accessToken);
             headers.put("Content-Type", " application/json");
             headers.put("Content-Type", " application/json");
-            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_CREATE;
+            System.err.println("入参:" + param.toJSONString());
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_UPDATE;
             String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
             String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
             JSONObject resultJson = JSONObject.parseObject(result);
             JSONObject resultJson = JSONObject.parseObject(result);
+            System.err.println("返回:" + resultJson.toJSONString());
             if (!Check.isNull(resultJson)) {
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
                 if (code == 0) {