Pārlūkot izejas kodu

Merge branch 'V1.1.3'

# Conflicts:
#	jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
yumeng 4 gadi atpakaļ
vecāks
revīzija
ed29b43331

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -186,6 +186,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/template/**", "anon");
         filterChainDefinitionMap.put("/batch/kuaiShouGroupTemplate/*", "anon");
         filterChainDefinitionMap.put("/kuaishouBatch/**", "anon");
+        filterChainDefinitionMap.put("/kuaishou/creative/*", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

+ 16 - 28
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -8,12 +8,10 @@ import cn.com.ctop.common.module.service.IBindAccountLoginService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IOauthConfigService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
-import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 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.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
@@ -26,14 +24,10 @@ import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataServ
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceAccountReportTaskRecord;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
 import cn.com.ctop.toutiao.modules.report.service.*;
-import com.alibaba.fastjson.JSONArray;
-import com.xxl.job.core.context.XxlJobHelper;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.catalina.User;
 import org.jeecg.common.util.DateUtils;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openqa.selenium.By;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
@@ -45,7 +39,6 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -77,13 +70,17 @@ public class SampleTest {
     private IOauthConfigService configService;
     @Autowired
     private CtopOauthTokenMapper oauthTokenMapper;
+    @Autowired
+    private IKuaishouInterfaceService iKuaishouInterfaceService;
 
 
     @Test
     public void loadBytedanceCreativeData() throws ParseException {
+        CtopOauthToken token = oauthTokenMapper.selectByAccountId(9784689L);
 
+        iKuaishouInterfaceService.getVideoList(token, null, null);
 
-        List<CtopOauthToken> oauthTokens = oauthTokenMapper.selectKuaiShouTokens(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
+      /*  List<CtopOauthToken> oauthTokens = oauthTokenMapper.selectKuaiShouTokens(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
         if (!Check.isNull(oauthTokens)) {
             Map<Long, String> configMap = configService.getConfigMapByMediaId(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_INT);
             for (CtopOauthToken oauthToken : oauthTokens) {
@@ -97,7 +94,7 @@ public class SampleTest {
             }
         } else {
             XxlJobHelper.log("----------------------刷新token获取数据返回结果为空----------------------------------");
-        }
+        }*/
 
 
       /*  Map<Long, String> configMap = configService.getConfigMapByMediaId(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_INT);
@@ -423,15 +420,16 @@ public class SampleTest {
 
     @Autowired
     private IBytedanceAccountReportTaskRecordService reportTaskRecordService;
+
     @Test
     public void execute() {
-        List<UserAllocation>  allocations = allocationService.listByMediaId("3",0);
-        for (UserAllocation allocation:allocations) {
-            BytedanceAccountReportTaskRecord reportTaskRecord1 = new BytedanceAccountReportTaskRecord(allocation.getAccountId(),"2020-10-01","2020-10-31");
+        List<UserAllocation> allocations = allocationService.listByMediaId("3", 0);
+        for (UserAllocation allocation : allocations) {
+            BytedanceAccountReportTaskRecord reportTaskRecord1 = new BytedanceAccountReportTaskRecord(allocation.getAccountId(), "2020-10-01", "2020-10-31");
             reportTaskRecordService.save(reportTaskRecord1);
-            BytedanceAccountReportTaskRecord reportTaskRecord2 = new BytedanceAccountReportTaskRecord(allocation.getAccountId(),"2020-11-01","2020-11-30");
+            BytedanceAccountReportTaskRecord reportTaskRecord2 = new BytedanceAccountReportTaskRecord(allocation.getAccountId(), "2020-11-01", "2020-11-30");
             reportTaskRecordService.save(reportTaskRecord2);
-            BytedanceAccountReportTaskRecord reportTaskRecord3 = new BytedanceAccountReportTaskRecord(allocation.getAccountId(),"2020-12-01","2020-12-31");
+            BytedanceAccountReportTaskRecord reportTaskRecord3 = new BytedanceAccountReportTaskRecord(allocation.getAccountId(), "2020-12-01", "2020-12-31");
             reportTaskRecordService.save(reportTaskRecord3);
         }
     }
@@ -537,26 +535,16 @@ public class SampleTest {
 //            }
 //        }
 
-        AiKuaishouAccountTargetTemplate accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getByAccountId(9845267L);
-        aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2,200);
-        accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getByAccountId(9845260L);
-        aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2,200);
-        accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getByAccountId(9845255L);
-        aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2,200);
-        accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getByAccountId(9845239L);
-        aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2,200);
-        accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getByAccountId(9845228L);
-        aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2,200);
+        AiKuaishouAccountTargetTemplate accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getById(120001);
+        aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2, 1);
     }
 
     @Autowired
     private IBytedancePlanDailyReportService planDailyReportService;
 
     @Test
-    public void etlKuaishouProjectData(){
+    public void etlKuaishouProjectData() {
         CtopOauthToken token = tokenService.getTokenByAccountId(1660666858777607L);
-        reportService.getAdvertiserPlanReport(token,DateUtils.parseDate("2021-01-25","yyyy-MM-dd"),DateUtils.parseDate("2021-01-25","yyyy-MM-dd"),CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        reportService.getAdvertiserPlanReport(token, DateUtils.parseDate("2021-01-25", "yyyy-MM-dd"), DateUtils.parseDate("2021-01-25", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
     }
-
-
 }

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml

@@ -12,7 +12,7 @@
         <result column="access_token_expires_in" property="accessTokenExpiresIn" jdbcType="TIMESTAMP"/>
         <result column="refresh_token_expires_in" property="refreshTokenExpiresIn" jdbcType="TIMESTAMP"/>
         <result column="agent_type" property="agentType" jdbcType="INTEGER"/>
-        <result column="app_id" property="appId" jdbcType="INTEGER"/>
+        <result column="app_id" property="appId" jdbcType="BIGINT"/>
         <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
         <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
     </resultMap>

+ 27 - 19
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouCreativeRefusalController.java

@@ -42,7 +42,7 @@ public class KuaiShouCreativeRefusalController {
     private IKuaiShouImageGetService imageGetService;
     @Autowired
     private IKuaiShouMaterialUploadService uploadService;
-    static ExecutorService executorService = Executors.newFixedThreadPool(50);
+    static ExecutorService executorService = Executors.newFixedThreadPool(100);
 
     /**
      * 吃创意拒审重提
@@ -65,9 +65,13 @@ public class KuaiShouCreativeRefusalController {
             if (Check.isNull(oauthToken)) {
                 throw new Exception("未获取到账户信息");
             }
+            Integer updateType = requestJson.getInteger("updateType"); //  0 更换封面 1 修改广告语
+            if (Check.isNull(updateType)) {
+                throw new Exception("请输入修改类型");
+            }
             JSONArray creativeIds = requestJson.getJSONArray("creativeIds");
             if (Check.isNull(creativeIds)) {
-                throw new Exception("请传入需要重提的创意id列表");
+                creativeIds = creativeService.getCreativeIds(accountId);
             }
             for (int i = 0; i < creativeIds.size(); i++) {
                 Long creativeId = creativeIds.getLong(i);
@@ -76,23 +80,29 @@ public class KuaiShouCreativeRefusalController {
                     public void run() {
                         KuaiShouCreative creative = creativeService.getCreativeByCreativeId(creativeId);
                         if (!Check.isNull(creative)) {
-                            JSONObject cutJson = cutFrameService.getCutFrameByVideoMd5(creative.getPhotoId(), creative.getImageToken());
-                            if (!Check.isNull(cutJson)) {
-                                String signature = cutJson.getString("signature");
-                                String url = cutJson.getString("url");
-                                String imageToken = getImageToken(signature, accountId, oauthToken.getAccessToken(), url);
-                                if (!Check.isNull(imageToken)) {
-                                    JSONObject updateJson = new JSONObject();
-                                    updateJson.put("creativeId", creativeId);
-                                    updateJson.put("imageToken", imageToken);
-                                    Map<String, Object> creativeMap = updateService.updateCreative(oauthToken.getAccessToken(), accountId, requestJson);
-                                    Integer code = (Integer) creativeMap.get("code");
-                                    if (code == 0) {
-                                        log.info("自动投放拒审重提成功,accountId:{},creativeId:{}", accountId, creativeId);
-                                    } else {
-                                        log.info("自动投放拒审重提失败,accountId:{},creativeId:{}", accountId, creativeId);
+                            JSONObject updateJson = new JSONObject();
+                            updateJson.put("creativeId", creativeId);
+                            if (updateType == 0) {  //  更换封面
+                                JSONObject cutJson = cutFrameService.getCutFrameByVideoMd5(creative.getPhotoId(), creative.getImageToken());
+                                if (!Check.isNull(cutJson)) {
+                                    String signature = cutJson.getString("signature");
+                                    String url = cutJson.getString("url");
+                                    String imageToken = getImageToken(signature, accountId, oauthToken.getAccessToken(), url);
+                                    if (!Check.isNull(imageToken)) {
+                                        updateJson.put("imageToken", imageToken);
+
                                     }
                                 }
+                            } else if (updateType == 1) { // 修改广告语
+                                String updateDescription = creativeService.convertMoString(creative.getDescription());
+                                updateJson.put("description", updateDescription);
+                            }
+                            Map<String, Object> creativeMap = updateService.updateCreative(oauthToken.getAccessToken(), accountId, updateJson);
+                            Integer code = (Integer) creativeMap.get("code");
+                            if (code == 0) {
+                                log.info("自动投放拒审重提成功,accountId:{},creativeId:{}", accountId, creativeId);
+                            } else {
+                                log.info("自动投放拒审重提失败,accountId:{},creativeId:{}", accountId, creativeId);
                             }
                         }
                     }
@@ -121,8 +131,6 @@ public class KuaiShouCreativeRefusalController {
         } else {
             imageToken = uploadService.kuauiShouImageUpload(url, md5, accountId, accessToken);
         }
-
-
         return imageToken;
 
     }

+ 1 - 58
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/MaterialRefuseController.java

@@ -192,7 +192,7 @@ public class MaterialRefuseController {
                 requestJson.put("creativeId", creativeId);
                 if (type == 0) {  // 替换修改广告语
                     String description = creativeJson.getString("description");
-                    requestJson.put("description", convertMoString(description));
+                    requestJson.put("description", creativeService.convertMoString(description));
                 } else if (type == 1) { // 替换广告语
                     String updateDescription = jsonObject.getString("updateDescription");
                     String updateActionBarText = jsonObject.getString("updateActionBarText");
@@ -234,61 +234,4 @@ public class MaterialRefuseController {
     }
 
 
-    public static synchronized String convertMoString(String sMo) {
-
-        if (Check.isNull(sMo)) {
-            return null;
-        }
-        String newString = null;
-        try {
-            if (sMo.contains(",")) {
-                return sMo.replace(',', ',');
-            } else if (sMo.contains("~")) {
-                newString = sMo.replace('~', '~');
-            } else if (sMo.contains("。")) {
-                newString = sMo.replace('。', '.');
-            } else if (sMo.contains(";")) {
-                newString = sMo.replace(';', ';');
-            } else if (sMo.contains("!")) {
-                newString = sMo.replace("!", "!");
-            } else if (sMo.contains("?")) {
-                newString = sMo.replace('?', '?');
-            } else if (sMo.contains(":")) {
-                newString = sMo.replace(':', ':');
-            } else if (sMo.contains("“")) {
-                newString = sMo.replace('“', '"');
-            } else if (sMo.contains("”")) {
-                newString = sMo.replace('”', '"');
-            } else if (sMo.contains("<")) {
-                newString = sMo.replace('>', '》').replace('<', '《');
-            } else if (sMo.contains(",")) {
-                newString = sMo.replace(',', ',');
-            } else if (sMo.contains(".")) {
-                newString = sMo.replace('.', '。');
-            } else if (sMo.contains(";")) {
-                newString = sMo.replace(';', ';');
-            } else if (sMo.contains("!")) {
-                newString = sMo.replace("!", "!");
-            } else if (sMo.contains("?")) {
-                newString = sMo.replace('?', '?');
-            } else if (sMo.contains(":")) {
-                newString = sMo.replace(':', ':');
-            } else if (sMo.contains(""")) {
-                newString = sMo.replace('"', '“');
-            } else if (sMo.contains(""")) {
-                newString = sMo.replace('"', '”');
-            } else if (sMo.contains("《")) {
-                newString = sMo.replace('》', '>').replace('《', '<');
-            } else if (sMo.contains("~")) {
-                newString = sMo.replace('~', '~');
-            } else {
-                newString = sMo;
-            }
-
-        } catch (Exception ex) {
-            return sMo;
-        }
-        return newString;
-    }
-
 }

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCreativeMapper.java

@@ -26,4 +26,6 @@ public interface KuaiShouCreativeMapper extends BaseMapper<KuaiShouCreative> {
     void delAllCreativesByCampaignId(@Param("accountId") Long accountId, @Param("campaignId") Long campaignId);
 
     List<KuaiShouCreative> queryCreativeInfoByCampaignId(@Param("accountId") Long accountId, @Param("campaignId") Long campaignId);
+
+    List<Long> getCreativeIds(@Param("accountId") Long accountId);
 }

+ 7 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml

@@ -141,4 +141,11 @@
          AND campaign_id = #{campaignId}
     </select>
 
+    <select id="getCreativeIds" resultType="java.lang.Long">
+     select  creative_id
+     from ctop_kuaishou_creative
+     where  account_id = #{accountId}
+     and  status = 42
+    </select>
+
 </mapper>

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCreativeService.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
@@ -57,4 +58,8 @@ public interface IKuaiShouCreativeService extends IService<KuaiShouCreative> {
     List<KuaiShouCreative> queryCreativeInfoByCampaignId(Long accountId, Long campaignId);
 
     KuaiShouCreative getCreativeByCreativeId(Long creativeId);
+
+    JSONArray getCreativeIds(Long accountId);
+
+    public String convertMoString(String sMo);
 }

+ 63 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreativeServiceImpl.java

@@ -207,5 +207,68 @@ public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMap
         return creative;
     }
 
+    @Override
+    public JSONArray getCreativeIds(Long accountId) {
+        List<Long> creativeIds = kuaiShouCreativeMapper.getCreativeIds(accountId);
+        return JSONArray.parseArray(creativeIds.toString());
+    }
+
+    @Override
+    public synchronized String convertMoString(String sMo) {
+        if (Check.isNull(sMo)) {
+            return null;
+        }
+        String newString = null;
+        try {
+            if (sMo.contains(",")) {
+                return sMo.replace(',', ',');
+            } else if (sMo.contains("~")) {
+                newString = sMo.replace('~', '~');
+            } else if (sMo.contains("。")) {
+                newString = sMo.replace('。', '.');
+            } else if (sMo.contains(";")) {
+                newString = sMo.replace(';', ';');
+            } else if (sMo.contains("!")) {
+                newString = sMo.replace("!", "!");
+            } else if (sMo.contains("?")) {
+                newString = sMo.replace('?', '?');
+            } else if (sMo.contains(":")) {
+                newString = sMo.replace(':', ':');
+            } else if (sMo.contains("“")) {
+                newString = sMo.replace('“', '"');
+            } else if (sMo.contains("”")) {
+                newString = sMo.replace('”', '"');
+            } else if (sMo.contains("<")) {
+                newString = sMo.replace('>', '》').replace('<', '《');
+            } else if (sMo.contains(",")) {
+                newString = sMo.replace(',', ',');
+            } else if (sMo.contains(".")) {
+                newString = sMo.replace('.', '。');
+            } else if (sMo.contains(";")) {
+                newString = sMo.replace(';', ';');
+            } else if (sMo.contains("!")) {
+                newString = sMo.replace("!", "!");
+            } else if (sMo.contains("?")) {
+                newString = sMo.replace('?', '?');
+            } else if (sMo.contains(":")) {
+                newString = sMo.replace(':', ':');
+            } else if (sMo.contains(""")) {
+                newString = sMo.replace('"', '“');
+            } else if (sMo.contains(""")) {
+                newString = sMo.replace('"', '”');
+            } else if (sMo.contains("《")) {
+                newString = sMo.replace('》', '>').replace('《', '<');
+            } else if (sMo.contains("~")) {
+                newString = sMo.replace('~', '~');
+            } else {
+                newString = sMo;
+            }
+
+        } catch (Exception ex) {
+            return sMo;
+        }
+        return newString;
+    }
+
 
 }

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

@@ -198,6 +198,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             }
             String result = HttpUtils.httpPostRequest(url, param, headers);
             JSONObject resultJson = JSONObject.parseObject(result);
+            System.err.println(resultJson);
             if (Check.isNull(resultJson)) {
                 return;