Browse Source

Merge remote-tracking branch 'origin/master'

yumeng 3 years ago
parent
commit
167e9cd81f

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

@@ -267,7 +267,6 @@ public class CallbackController {
             if (!Check.isNull(ids)) {
                 for (Long id : ids) {
                     data.put("id", id);
-                    kuaishouAppPackageService.pushAppPackage(id, accountIds, data);
                 }
             }
         }

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

@@ -148,33 +148,6 @@ public class TestController {
     @Autowired
     private IEtlKuaishouAccountMaterialReportDailyService etlKuaishouAccountMaterialReportDailyService;
 
-
-    @GetMapping(value = "/cleanData")
-    public void cleanData() {
-       /* List<String> dateList = videoGetService.getDateList();
-        for (int i = 0; i < dateList.size(); i++) {
-            String s = dateList.get(i);
-            etlKuaishouVideoInfoService.etlKuaishouVideoInfo(s);
-        }*/
- /*      List<String> dateList = new ArrayList<>();
-        dateList.add("2021-08-11");
-        dateList.add("2021-08-10");*/
-        List<String> dateList = etlKuaishouAccountMaterialReportDailyService.getDateList();
-        for (int i = 0; i < dateList.size(); i++) {
-            String date = dateList.get(i);
-            List<Long> accountList = etlKuaishouAccountMaterialReportDailyService.getAccountListByDate(date);
-            for (int j = 0; j < accountList.size(); j++) {
-                Long accountId = accountList.get(j);
-                etlKuaishouAccountMaterialReportDailyService.cleanVideoInfo(accountId, date);
-            }
-
-
-        }
-
-
-    }
-
-
     @GetMapping(value = "/getProgramCreative")
     public void getProgramCreative() {
         List<Long> list = new ArrayList();

+ 2 - 2
jeecg-boot-module-system/src/main/resources/application-wps.yml

@@ -55,7 +55,7 @@ spring:
   autoconfigure:
     exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
   datasource:
-    url: jdbc:mysql://139.186.27.96:4000/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+    url: jdbc:mysql://139.186.196.102:4000/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
     username: data
     password: hcst@2021
     driver-class-name: com.mysql.jdbc.Driver
@@ -105,7 +105,7 @@ spring:
 #          password: hcst@2020
 #          driver-class-name: com.mysql.jdbc.Driver
         master:
-          url: jdbc:mysql://139.186.27.96:4000/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+          url: jdbc:mysql://139.186.27.96:3390/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
           username: data
           password: hcst@2021
           driver-class-name: com.mysql.jdbc.Driver

+ 36 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/DeleteKuaishouCommentJob.java

@@ -1,8 +1,11 @@
 package cn.com.ctop.job.kuaishou.handler;
 
 import cn.com.ctop.common.module.entity.BindAccountLogin;
+import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCommentService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
@@ -23,7 +26,6 @@ public class DeleteKuaishouCommentJob {
     private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
     static ExecutorService executorService = Executors.newFixedThreadPool(5);
     static CountDownLatch countDownLatch = null;
-    //TODO 待删除
     @XxlJob("deleteKuaishouComment")
     public void deleteKuaishouComment(){
         Long start = System.currentTimeMillis();
@@ -48,4 +50,37 @@ public class DeleteKuaishouCommentJob {
             XxlJobHelper.log("快手删评论所用时长:{}毫秒", end - start);
         }
     }
+
+    @Autowired
+    private IUserAllocationService userAllocationService;
+    @Autowired
+    private IKuaiShouCommentService kuaiShouCommentService;
+
+    @XxlJob("deleteComment")
+    public void deleteCommentV2(){
+        Long start = System.currentTimeMillis();
+        List<UserAllocation> allocations = userAllocationService.listByMediaId(CtopAdConstant.PLATFORM_TYPE_KUAISHOU, 0);
+        if (allocations != null && !allocations.isEmpty()) {
+            countDownLatch = new CountDownLatch(allocations.size());
+            allocations.forEach(allocation -> executorService.submit(() -> {
+                try {
+                    Integer deleteComment = allocation.getDeleteComment();
+                    if(deleteComment.equals(0)){
+                        kuaiShouCommentService.deleteComment(allocation);
+                    }
+                } catch (Exception e) {
+                    XxlJobHelper.log(e.getMessage(), e);
+                } finally {
+                    countDownLatch.countDown();
+                }
+            }));
+            try {
+                countDownLatch.await();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+            Long end = System.currentTimeMillis();
+            XxlJobHelper.log("快手删评论所用时长:{}毫秒", end - start);
+        }
+    }
 }

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

@@ -1,5 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
+import cn.com.ctop.common.module.entity.UserAllocation;
+
 /**
  * @author jeecg-boot
  * @version V1.0
@@ -16,4 +18,6 @@ public interface IKuaiShouCommentService {
      * @author ZHAOXA
      */
     void shieldComment(Long accountId);
+
+    void deleteComment(UserAllocation allocation);
 }

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

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
@@ -40,6 +41,49 @@ public class IKuaiShouCommentServiceImpl implements IKuaiShouCommentService {
         }
     }
 
+    @Override
+    public void deleteComment(UserAllocation allocation) {
+        CtopOauthToken token = oauthTokenService.getTokenByAccountId(allocation.getAccountId());
+        deleteCommentByPage(token,1);
+        log.info("删除评论完成:accounId=>{}",allocation.getAccountId());
+    }
+
+    private void deleteCommentByPage(CtopOauthToken token, int pageNum) {
+        //1:查询评论数据
+        JSONArray comments = getComments(token,pageNum,500);
+        if(null!=comments&&!comments.isEmpty()){
+            //存在评论则执行删除查询下一页,循环
+            shieldCommentApi(token.getAccessToken(), token.getAccountId(), comments);
+            deleteCommentByPage(token,pageNum+1);
+        }
+    }
+
+    private JSONArray getComments(CtopOauthToken token, int pageNum, int pageSize) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.COMMENT_LIST;
+        Map<String, String> header = new HashMap<>();
+        header.put("Access-Token", token.getAccessToken());
+        header.put("Content-Type", "application/json");
+        JSONObject params = new JSONObject();
+        params.put("advertiser_id", token.getAccountId());
+        //未隐藏数据
+        params.put("shield_status", NoEn.NO1.valueInt());
+        params.put("page", pageNum);
+        params.put("page_size", pageSize);
+        String result = HttpUtils.httpPostRequest(url, params, header);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (!Check.isNull(resultJson)) {
+            Integer code = resultJson.getInteger("code");
+            if (code == 0) {
+                JSONObject dataJson = resultJson.getJSONObject("data");
+                JSONArray details = dataJson.getJSONArray("details");
+                if (!Check.isNull(details)) {
+                   return  details;
+                }
+            }
+        }
+        return new JSONArray();
+    }
+
     /**
      * 查询评论
      *