Browse Source

广告项目预警2

zhaoxian 1 year ago
parent
commit
bdb7f107c5

+ 65 - 21
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/controller/BytedanceController.java

@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.Date;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
@@ -88,31 +89,27 @@ public class BytedanceController {
 
 
     @GetMapping(value = "/testReport")
     @GetMapping(value = "/testReport")
     public String testReport() {
     public String testReport() {
-        List<Long> accountIds = tokenService.getAllToutiaoAccountIds();
-        for (Long id : accountIds) {
-            String token = tokenService.getByAccountId(id);
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        //昨天
+        String yesterda = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+
+//        List<Long> accountIds = tokenService.getAllToutiaoAccountIds();
+        List<JSONObject> accountIds = tokenService.getByProjectId(18450885L);
+
+        for (JSONObject obj : accountIds) {
+//            String token = tokenService.getByAccountId(id);
             OauthToken oauthToken = new OauthToken();
             OauthToken oauthToken = new OauthToken();
-            oauthToken.setAccessToken(token);
-            oauthToken.setAccountId(id);
-            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-            String yesterda = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
-            String start = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -8);
-            Date getDate = new Date();
-            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
-            String hour = simpleDateFormat.format(getDate);
+            oauthToken.setAccessToken(obj.getString("accessToken"));
+            oauthToken.setAccountId(obj.getLong("accountId"));
             dailyExecutorService.submit(
             dailyExecutorService.submit(
                     new Runnable() {
                     new Runnable() {
                         @Override
                         @Override
                         public void run() {
                         public void run() {
                             try {
                             try {
                                 Thread.sleep(500);
                                 Thread.sleep(500);
-                                //                            materialReportDailyService.bytedanceDailyMaterialReportJobV3Video(oauthToken, yesterda2, yesterda, 1, 100);
-//                                listService.getProjectList(oauthToken, start, yesterda, 1);
-//                                advertiserDataService.getV3AdvertiserReport(oauthToken, start, yesterda, CtopAdConstant.BYTEDANCE_REPORT_V3_TYPE_DAILY);
-//                                materialReportDailyService.bytedanceDailyMaterialReportJobV3Video(oauthToken, yesterda, yesterda, 1, 100);
-//                              materialReportDailyService.bytedanceDailyMaterialReportJobV3Image(oauthToken, yesterda2, yesterda, 1, 100);
-                                advertiserDataService.getV3PromotionProjectReport(oauthToken, "2023-07-01", "2023-07-06", CtopAdConstant.BYTEDANCE_REPORT_V3_TYPE_DAILY);
-                                advertiserDataService.getV3PromotionMaterialReport(oauthToken, "2023-07-01", "2023-07-06", CtopAdConstant.BYTEDANCE_REPORT_V3_TYPE_DAILY);
+//                                fileVideoService.getFileVideoData(oauthToken, null, null, 1, 100);
+
+                                advertiserDataService.getAdvertiserReport(oauthToken, yesterda, yesterda, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
                             } catch (Exception e) {
                             } catch (Exception e) {
                                 e.printStackTrace();
                                 e.printStackTrace();
                             }
                             }
@@ -123,10 +120,56 @@ public class BytedanceController {
         return "ok";
         return "ok";
     }
     }
 
 
+
+    @GetMapping(value = "/testReportHour")
+    public String testReportHour() {
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String yesterda = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+
+        //获取 两个日期之间的所有 日期
+        List<String> dates = DateUtils.getAllDatesOfTwoTimes("2024-05-29", "2024-06-11");
+
+//                tokenService.getAllToutiaoAccountIds();
+        List<Long> accountIds = new ArrayList<>();
+        accountIds.add(1799928973572105l);
+        accountIds.add(1800189297615018l);
+        for (String date : dates) {
+            for (Long id : accountIds) {
+                String token = tokenService.getByAccountId(id);
+                OauthToken oauthToken = new OauthToken();
+                oauthToken.setAccessToken(token);
+                oauthToken.setAccountId(id);
+                dailyExecutorService.submit(
+                        new Runnable() {
+                            @Override
+                            public void run() {
+                                try {
+                                    Thread.sleep(500);
+//                                    materialReportDailyService.bytedanceDailyMaterialReportJobV3Video(oauthToken, yesterda2, yesterda, 1, 100);
+//                                    listService.getProjectList(oauthToken, start, yesterda, 1);
+//                                    advertiserDataService.getV3AdvertiserReport(oauthToken, start, yesterda, CtopAdConstant.BYTEDAN1CE_REPORT_V3_TYPE_DAILY);
+//                                    materialReportDailyService.bytedanceDailyMaterialReportJobV3Video(oauthToken, "2024-01-01", "2024-01-10", 1, 100);
+//                                    materialReportDailyService.bytedanceDailyMaterialReportJobV3Image(oauthToken, yesterda2, yesterda, 1, 100);
+//                                    advertiserDataService.getV3PromotionProjectReport(oauthToken, date, date, CtopAdConstant.BYTEDANCE_REPORT_V3_TYPE_HOURLY);
+                                    advertiserDataService.getAdvertiserReport(oauthToken, date, date, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+
+//                                    advertiserDataService.getV3PromotionProjectReport(oauthToken, date, date, CtopAdConstant.BYTEDANCE_REPORT_V3_TYPE_DAILY);
+//                                    advertiserDataService.getV3PromotionMaterialReport(oauthToken, "2023-05-01", "2023-05-31", CtopAdConstant.BYTEDANCE_REPORT_V3_TYPE_DAILY);
+//                                    advertiserDataServices.getPositionAdvertiserReport(oauthToken, "2023-07-01", "2023-07-18", CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+                                } catch (Exception e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        });
+            }
+        }
+        return "ok";
+    }
+
     @GetMapping(value = "/testOneReport")
     @GetMapping(value = "/testOneReport")
     public String testOneReport(Long accountId) {
     public String testOneReport(Long accountId) {
-//        String token = tokenService.getByAccountId(accountId);
-        String token = tokenService.getAgentToken(accountId);
+        String token = tokenService.getByAccountId(accountId);
+//        String token = tokenService.getAgentToken(accountId);
         if (Check.isNull(token)) {
         if (Check.isNull(token)) {
             log.error("此账户未获取到相关token,accountId:{}", accountId);
             log.error("此账户未获取到相关token,accountId:{}", accountId);
             return "no";
             return "no";
@@ -148,6 +191,8 @@ public class BytedanceController {
                     public void run() {
                     public void run() {
                         try {
                         try {
                             Thread.sleep(500);
                             Thread.sleep(500);
+                            advertiserDataService.getAdvertiserReport(oauthToken, yesterda, yesterda, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+
 //                            materialReportDailyService.bytedanceDailyMaterialReportJobV3Video(oauthToken, start, yesterda, 1, 100);
 //                            materialReportDailyService.bytedanceDailyMaterialReportJobV3Video(oauthToken, start, yesterda, 1, 100);
 //                            advertiserDataService.getV3AdvertiserConfig(oauthToken);
 //                            advertiserDataService.getV3AdvertiserConfig(oauthToken);
 //                            advertiserDataService.getV3PromotionMaterialReport(oauthToken, yesterda, yesterda, CtopAdConstant.BYTEDANCE_REPORT_V3_TYPE_DAILY);
 //                            advertiserDataService.getV3PromotionMaterialReport(oauthToken, yesterda, yesterda, CtopAdConstant.BYTEDANCE_REPORT_V3_TYPE_DAILY);
@@ -155,7 +200,6 @@ public class BytedanceController {
 //                            listService.getProjectList(oauthToken, start, yesterda, 1);
 //                            listService.getProjectList(oauthToken, start, yesterda, 1);
 //                            materialReportDailyService.bytedanceDailyMaterialReportJobV3Image(oauthToken, yesterda2, yesterda, 1, 100);
 //                            materialReportDailyService.bytedanceDailyMaterialReportJobV3Image(oauthToken, yesterda2, yesterda, 1, 100);
 //                            advertiserDataServices.getPositionAdvertiserReport(oauthToken, yesterda, yesterda, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
 //                            advertiserDataServices.getPositionAdvertiserReport(oauthToken, yesterda, yesterda, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
-//                            advertiserDataService.getAdvertiserReport(oauthToken, nowDate, nowDate, CtopAdConstant.BYTEDANCE_REPORT_V3_TYPE_HOURLY);
 //                            advertiserDataService.getAgentReport(oauthToken, yesterda, yesterda, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
 //                            advertiserDataService.getAgentReport(oauthToken, yesterda, yesterda, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
 
 
                         } catch (Exception e) {
                         } catch (Exception e) {

+ 6 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/OauthTokenMapper.java

@@ -23,4 +23,10 @@ public interface OauthTokenMapper extends BaseMapper<OauthToken> {
     String getAgentToken(@Param("agentId") Long agentId);
     String getAgentToken(@Param("agentId") Long agentId);
 
 
     List<JSONObject> getAgentTokens();
     List<JSONObject> getAgentTokens();
+
+    List<JSONObject> getByProjectId(@Param("projectId") Long projectId);
+
+    JSONObject getProjectByAccountId(@Param("accountId") Long accountId);
+
+    List<JSONObject> getBytedanceOcpxTypeList();
 }
 }

+ 33 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/OauthTokenMapper.xml

@@ -40,4 +40,37 @@
           AND update_time > DATE_FORMAT(now(), '%Y%m%d')
           AND update_time > DATE_FORMAT(now(), '%Y%m%d')
     </select>
     </select>
 
 
+
+    <select id="getByProjectId" resultType="com.alibaba.fastjson.JSONObject">
+        select t1.access_token as 'accessToken',t1.account_id as 'accountId',t1.access_token_expires_in as 'accessTokenExpiresIn'
+        from `jeecg-boot`.ctop_oauth_token t1
+                 left join `jeecg-boot`.ctop_user_allocation t2
+                           on t1.account_id = t2.account_id
+        where t2.account_status = 0
+          and t2.project_id = #{projectId}
+        group by t1.account_id
+    </select>
+
+    <select id="getProjectByAccountId" resultType="com.alibaba.fastjson.JSONObject">
+        select id                   'projectId',
+               project_name         'projectName',
+               max_bid              'maxBid',
+               bid_type             'bidType',
+               ocpx_action_type     'ocpxActionType',
+               deep_conversion_type 'deepConversionType'
+        from `jeecg-boot`.ctop_project
+        where id = (
+            select project_id
+            from `jeecg-boot`.ctop_user_allocation
+            where account_id = #{accountId}
+            limit 1
+            )
+    </select>
+
+
+    <select id="getBytedanceOcpxTypeList" resultType="com.alibaba.fastjson.JSONObject">
+        select ocpx_action_type as 'ocpxActionType', ocpx_action_name as 'ocpxActionName'
+        from `jeecg-boot`.ctop_bytedance_ocpx_action_type_config
+    </select>
+
 </mapper>
 </mapper>

+ 2 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IOauthTokenService.java

@@ -23,4 +23,6 @@ public interface IOauthTokenService extends IService<OauthToken> {
     String getAgentToken(Long accountId);
     String getAgentToken(Long accountId);
 
 
     List<JSONObject> getAgentTokens();
     List<JSONObject> getAgentTokens();
+
+    List<JSONObject> getByProjectId(Long projectId);
 }
 }

+ 6 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/OauthTokenServiceImpl.java

@@ -45,4 +45,10 @@ public class OauthTokenServiceImpl extends ServiceImpl<OauthTokenMapper, OauthTo
     public List<JSONObject> getAgentTokens() {
     public List<JSONObject> getAgentTokens() {
         return tokenMapper.getAgentTokens();
         return tokenMapper.getAgentTokens();
     }
     }
+
+    @Override
+    public List<JSONObject> getByProjectId(Long projectId) {
+        return tokenMapper.getByProjectId(projectId);
+    }
+
 }
 }