Преглед изворни кода

剧维度消耗拉取前删除

huangpingkang пре 1 година
родитељ
комит
74448802d8

+ 3 - 2
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/controller/BytedanceController.java

@@ -53,7 +53,7 @@ public class BytedanceController {
     @GetMapping("/accountReport")
     public void getChannel(String param) {
 
-        List<JSONObject>  infos = adminAdvertiserListService.getAdvertiserInfos();
+        List<JSONObject> infos = adminAdvertiserListService.getAdvertiserInfos();
         System.err.println(infos);
         adminAdvertiserListService.batchUpdateAdvertiserName(infos);
 
@@ -91,6 +91,7 @@ public class BytedanceController {
                 @Override
                 public void run() {
                     if (!Check.isNull(accessToken)) {
+                        productReportService.deleteBytedanceProductDailyReport(advertiserId, startDate, endDate);
                         productReportService.getBytedanceProductDailyReport(adverId, accessToken, startDate, endDate, 1, null, 1, null);
                     }
                 }
@@ -127,7 +128,7 @@ public class BytedanceController {
 
                 @Override
                 public void run() {
-                    if(!Check.isNull(advertiserAccount.getAccessToken())){
+                    if (!Check.isNull(advertiserAccount.getAccessToken())) {
                         byteDanceFlowDetailsReportService.getBytedanceFlowDetailsDailyReport(advertiserAccount.getAdvertiserId(), advertiserAccount.getAccessToken(), AccountTypeEnum.AD.getValue(), startDate, endDate, 1, null);
                     }
                 }

+ 2 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/BytedanceProductReportMapper.java

@@ -11,4 +11,6 @@ public interface BytedanceProductReportMapper {
     List<JSONObject> queryCostAccount(@Param("advertiserId") Long advertiserId, @Param("startDate") String startDate, @Param("endDate") String endDate);
 
     void replaceProductReportDailies(List<BytedanceProductReportDaily> reports);
+
+    void deleteProductReportDailies(@Param("advertiserId") Long advertiserId,@Param("startDate") Integer startDate,@Param("endDate")  Integer endDate);
 }

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

@@ -57,4 +57,9 @@
         </foreach>
     </insert>
 
+    <delete id="deleteProductReportDailies">
+        DELETE FROM media_api.bytedance_product_report_daily
+        WHERE advertiser_id = #{advertiserId} and stat_time_day >= #{startDate} and stat_time_day &lt;= #{endDate}
+    </delete>
+
 </mapper>

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

@@ -9,4 +9,6 @@ public interface IBytedanceProductReportService {
                                         Long errorId, Integer isLog, Integer isSend);
 
     List<JSONObject> getCostAccount(Long advertiserId, String startDate, String endDate);
+
+    void deleteBytedanceProductDailyReport(Long advertiserId, String startDate, String endDate);
 }

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

@@ -30,6 +30,11 @@ public class BytedanceProductReportServiceImpl implements IBytedanceProductRepor
     private BytedanceProductReportMapper productReportMapper;
 
     @Override
+    public void deleteBytedanceProductDailyReport(Long advertiserId, String startDate, String endDate) {
+        productReportMapper.deleteProductReportDailies(advertiserId, Integer.parseInt(startDate.replace("-", "")), Integer.parseInt(endDate.replace("-", "")));
+    }
+
+    @Override
     public void getBytedanceProductDailyReport(Long advertiserId, String accessToken, String startDate, String endDate, Integer page,
                                                Long errorId, Integer isLog, Integer isSend) {
         try {
@@ -98,7 +103,7 @@ public class BytedanceProductReportServiceImpl implements IBytedanceProductRepor
                     promoterReportMapper.deleteInfoByErrorId(errorId);
                 }
                 if (isSend != null && 1 == isSend) {
-                    AlertUtils.sendMessage(advertiserId, startDate, endDate, 1, "product_daily", 1,null);
+                    AlertUtils.sendMessage(advertiserId, startDate, endDate, 1, "product_daily", 1, null);
                 }
             }
         } catch (Exception e) {

+ 1 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedancePromoterReportJob.java

@@ -105,6 +105,7 @@ public class BytedancePromoterReportJob {
         productDailyExecutor.submit(new Runnable() {
             @Override
             public void run() {
+                productReportService.deleteBytedanceProductDailyReport(advertiserId, data, data);
                 productReportService.getBytedanceProductDailyReport(advertiserId, accessToken, data, data, 1, null, 1, null);
             }
         });