|
@@ -0,0 +1,50 @@
|
|
|
+package cn.com.ctop.job.kuaishou.handler;
|
|
|
+
|
|
|
+import cn.com.ctop.common.module.entity.BindAccountLogin;
|
|
|
+import cn.com.ctop.common.module.service.IBindAccountLoginService;
|
|
|
+import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
|
+import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
|
|
|
+import com.xxl.job.core.context.XxlJobHelper;
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
+
|
|
|
+@Component
|
|
|
+public class DeleteKuaishouCommentJob {
|
|
|
+ @Autowired
|
|
|
+ private IBindAccountLoginService bindAccountLoginService;
|
|
|
+ @Autowired
|
|
|
+ private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
|
|
|
+ static ExecutorService executorService = Executors.newFixedThreadPool(5);
|
|
|
+ static CountDownLatch countDownLatch = null;
|
|
|
+ @XxlJob("deleteKuaishouComment")
|
|
|
+ public void deleteKuaishouComment(){
|
|
|
+ Long start = System.currentTimeMillis();
|
|
|
+ List<BindAccountLogin> loginList = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
|
|
|
+ if (loginList != null && !loginList.isEmpty()) {
|
|
|
+ countDownLatch = new CountDownLatch(loginList.size());
|
|
|
+ loginList.forEach(login -> executorService.submit(() -> {
|
|
|
+ try {
|
|
|
+ kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
|
|
|
+ } 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|