فهرست منبع

V1.1.3 自动投放 素材接口加入状态判断

yumeng 4 سال پیش
والد
کامیت
3df5ee8da9

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

@@ -112,6 +112,23 @@ public class TestController {
     @Autowired
     private IBytedanceReportService bytedanceReportService;
 
+    @Autowired
+    private IUserAllocationService allocationService;
+
+
+    @GetMapping("/getVideoByProjectId")
+    public String getVideoByProjectId(Long projectId) {
+        QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("project_id", projectId);
+        List<UserAllocation> list = allocationService.list(queryWrapper);
+        for (UserAllocation allocation : list) {
+            CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
+            kuaishouInterfaceService.getVideoList(token, null, null);
+        }
+        return "success";
+    }
+
+
     @GetMapping("/testKuaishou")
     public String kuaishouCallback(@RequestParam("auth_code") String authCode, @RequestParam("state") String state) {
         try {
@@ -686,11 +703,6 @@ public class TestController {
     }
 
 
-
-
-
-
-
     @GetMapping(value = "/createCutTask")
     public String createCutTask(String startDate, String endDate) throws IOException {
         List<MaterialInfo> materialInfos = materialInfoService.getListByDate(startDate, endDate);
@@ -1332,25 +1344,25 @@ public class TestController {
     }
 
     @GetMapping("loadMatData")
-    public Map<String,Object>getData(String startDate,String endDate,Long accountId){
-        Map<String,Object>result = new HashMap<>();
+    public Map<String, Object> getData(String startDate, String endDate, Long accountId) {
+        Map<String, Object> result = new HashMap<>();
         CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
-        Date start = DateUtils.parseDate(startDate,"yyyy-MM-dd");
-        int days = DateUtils.getdaysOfTwoDate(startDate,endDate)+1;
-        for (int i=0;i<days;i++){
-            String getDate = DateUtils.formatDate(DateUtils.addDay(start,i));
+        Date start = DateUtils.parseDate(startDate, "yyyy-MM-dd");
+        int days = DateUtils.getdaysOfTwoDate(startDate, endDate) + 1;
+        for (int i = 0; i < days; i++) {
+            String getDate = DateUtils.formatDate(DateUtils.addDay(start, i));
             bytedanceReportService.bytedanceMaterialReport(token, getDate, getDate);
         }
-        ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
         return result;
     }
 
     @GetMapping("loadAccountData")
-    public Map<String,Object>getData(Long accountId){
-        Map<String,Object>result = new HashMap<>();
+    public Map<String, Object> getData(Long accountId) {
+        Map<String, Object> result = new HashMap<>();
         CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
-        reportService.getAdvertiserReport(token, DateUtils.parseDate("2021-01-01","yyyy-MM-dd"), DateUtils.parseDate("2021-01-31","yyyy-MM-dd"),CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
-        ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
+        reportService.getAdvertiserReport(token, DateUtils.parseDate("2021-01-01", "yyyy-MM-dd"), DateUtils.parseDate("2021-01-31", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
         return result;
     }
 }

+ 30 - 13
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -5,6 +5,7 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountTargetTemplate;
@@ -23,6 +24,7 @@ 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.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.junit.Test;
@@ -65,6 +67,10 @@ public class SampleTest {
     private IBindAccountLoginService bindAccountLoginService;
     @Autowired
     private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
+    @Autowired
+    private IProjectService projectService;
+    @Autowired
+    private IUserAllocationService allocationService;
  /*   @Autowired
     private IByteDanceAdvertiserDataService advertiserDataService;
 
@@ -80,16 +86,27 @@ public class SampleTest {
 
 
 
+
+
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
         Date parse = simpleDateFormat.parse("2021-02-02");
         kuaishouInterfaceService.getAdvertiserReportDaily(token, parse, parse);*/
 
-        CtopOauthToken token = new CtopOauthToken();
+        QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("project_id", 900886);
+        List<UserAllocation> list = allocationService.list(queryWrapper);
+        for (UserAllocation allocation : list) {
+            CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
+            kuaishouInterfaceService.getVideoList(token, null, null);
+        }
+
+
+      /*  CtopOauthToken token = new CtopOauthToken();
         token.setAccountId(9767055L);
         token.setAccessToken("28e4e6b124e1443d6971ba4c699de6c9");
 
         kuaishouInterfaceService.getVideoList(token, null, null);
-        kuaishouInterfaceService.getVideoInfo("28e4e6b124e1443d6971ba4c699de6c9",9767055L,"5208131540349742192");
+        kuaishouInterfaceService.getVideoInfo("28e4e6b124e1443d6971ba4c699de6c9", 9767055L, "5208131540349742192");*/
 
      /*   CtopOauthToken tokenByAccountId = tokenService.getTokenByAccountId(1662234704806924L);
         advertiserDataService.getMaterialList(tokenByAccountId);*/
@@ -161,8 +178,7 @@ public class SampleTest {
         }
     }
 
-    @Autowired
-    private IUserAllocationService allocationService;
+
 
     @Test
     public void testLoadBytedanceData() {
@@ -538,8 +554,8 @@ public class SampleTest {
     }
 
     @Test
-    public void testLoadBytedanceDataV2(){
-        String accountIds=
+    public void testLoadBytedanceDataV2() {
+        String accountIds =
                 "1675440464386062," +
                         "1688606248211533," +
                         "1669181787105294," +
@@ -592,22 +608,23 @@ public class SampleTest {
                         "1674634579279885," +
                         "1650263841162253," +
                         "1672178052130888";
-        String [] accountArray = accountIds.split(",");
-        for (int i=0;i<accountArray.length;i++){
+        String[] accountArray = accountIds.split(",");
+        for (int i = 0; i < accountArray.length; i++) {
             CtopOauthToken token = tokenService.getTokenByAccountId(Long.parseLong(accountArray[i]));
 
-            reportService.getAdvertiserReport(token, DateUtils.parseDate("2021-01-14","yyyy-MM-dd"), DateUtils.parseDate("2021-01-14","yyyy-MM-dd"),CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+            reportService.getAdvertiserReport(token, DateUtils.parseDate("2021-01-14", "yyyy-MM-dd"), DateUtils.parseDate("2021-01-14", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
         }
     }
 
 
     @Test
-    public void checkBytedanceReport(){
+    public void checkBytedanceReport() {
         CtopOauthToken token = tokenService.getTokenByAccountId(1678959391271949L);
         String startDate = "2021-01-01 00:00:00";
         String endDate = "2021-01-31 00:00:00";
-        bytedanceReportService.checkoutData(token,startDate,endDate);
+        bytedanceReportService.checkoutData(token, startDate, endDate);
     }
+
     @Test
     public void etlKuaishouProjectData() {
         CtopOauthToken token = tokenService.getTokenByAccountId(1660666858777607L);
@@ -653,8 +670,8 @@ public class SampleTest {
     @Test
     public void etlBytedanceVideoReportClean() {
         //for (int i = 1; i <= 1; i++) {
-          //  String statDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -i));
-            ietlReportBytedanceVideoService.cleanETL("2020-12-31");
+        //  String statDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -i));
+        ietlReportBytedanceVideoService.cleanETL("2020-12-31");
         //}
     }
 

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml

@@ -113,7 +113,7 @@
             and stat_date &lt;= #{endTime}
         </if>
         <if test="appVersion != null and appVersion != '' ">
-            photo_name like concat(#{appVersion}'%')
+            photo_name like concat(#{appVersion},'%')
         </if>
         and status = 0
         group by signature

+ 4 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouVideoRelateCreativesMapper.xml

@@ -44,7 +44,7 @@
             and t1.photo_id in (
             select photo_id from ctop_kuaishou_video_get
             where account_id = #{accountId}
-            and photo_name like concat(#{appVersion}'%')
+            and photo_name like CONCAT(#{appVersion},'%')
             and status = 0
             )
         </if>
@@ -74,7 +74,7 @@
             and photo_id in (
             select photo_id from ctop_kuaishou_video_get
             where account_id = #{accountId}
-            and photo_name like concat(#{appVersion}'%')
+            and photo_name like concat(#{appVersion},'%')
             and status = 0
             )
         </if>
@@ -83,6 +83,7 @@
     </select>
 
     <select id="getHistoryTopVideoList" resultType="com.alibaba.fastjson.JSONObject">
+        select
         t1.photo_id,
         t1.signature,
         t1.charge
@@ -105,7 +106,7 @@
         and stat_date &gt;= #{startDate}
         and stat_date &lt;= #{endDate}
         <if test="appVersion != null and appVersion != '' ">
-            and photo_name like concat(#{appVersion}'%')
+            and photo_name like concat(#{appVersion},'%')
         </if>
         and status = 0
         and signature is not null