SampleTest.java 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. package org.jeecg;
  2. import cn.com.ctop.common.module.entity.BindAccountLogin;
  3. import cn.com.ctop.common.module.entity.CtopOauthToken;
  4. import cn.com.ctop.common.module.service.IBindAccountLoginService;
  5. import cn.com.ctop.common.module.service.ICtopOauthTokenService;
  6. import cn.com.ctop.common.module.utils.CtopAdConstant;
  7. import cn.com.ctop.crawler.modules.pangolin.entity.PangolinApp;
  8. import cn.com.ctop.crawler.modules.pangolin.service.PangolinAppService;
  9. import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService;
  10. import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService;
  11. import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
  12. import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
  13. import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
  14. import cn.com.ctop.toutiao.modules.report.service.IReportService;
  15. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  16. import lombok.extern.slf4j.Slf4j;
  17. import org.jeecg.common.util.DateUtils;
  18. import org.junit.Test;
  19. import org.junit.runner.RunWith;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.boot.test.context.SpringBootTest;
  22. import org.springframework.test.context.junit4.SpringRunner;
  23. import java.text.SimpleDateFormat;
  24. import java.util.Date;
  25. import java.util.HashMap;
  26. import java.util.List;
  27. import java.util.concurrent.CountDownLatch;
  28. import java.util.concurrent.ExecutorService;
  29. import java.util.concurrent.Executors;
  30. @RunWith(SpringRunner.class)
  31. @SpringBootTest
  32. @Slf4j
  33. public class SampleTest {
  34. @Autowired
  35. private IBytedanceReportService bytedanceReportService;
  36. @Autowired
  37. private IByteDanceVideoReportDailyService byteDanceVideoReportDailyService;
  38. @Autowired
  39. private ICtopOauthTokenService oauthTokenService;
  40. @Autowired
  41. private IReportService reportService;
  42. @Test
  43. public void testOceanEngineJob() {
  44. try {
  45. CtopOauthToken byId = oauthTokenService.getById(1654059015242756L);
  46. /* SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  47. Date start = simpleDateFormat.parse("2020-01-01");
  48. Date end = simpleDateFormat.parse("2020-06-03");*/
  49. String nowDate = "2020-06-03";
  50. String endDate = "2020-01-01";
  51. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  52. Date start = simpleDateFormat.parse(nowDate);
  53. Date end = simpleDateFormat.parse(endDate);
  54. List<Date> dates = DateUtils.findDates(end, start);
  55. for (int i = 0; i < dates.size(); i++) {
  56. String formatDate = simpleDateFormat.format(dates.get(i));
  57. Date parse = simpleDateFormat.parse(formatDate);
  58. reportService.getAdvertiserReport(byId, parse, parse, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  59. }
  60. } catch (Exception e) {
  61. e.printStackTrace();
  62. }
  63. String account = "3248395570@qq.com";
  64. /* String password = "Ydxq-704127411";
  65. oceanEngineService.login(account,password);
  66. oceanEngineService.douyinHotHandler(1,1);
  67. oceanEngineService.effectCaseHandler(1);
  68. oceanEngineService.hotMaterialHandler(1,4,"抖音");
  69. oceanEngineService.hotMaterialHandler(1,8,"头条");
  70. oceanEngineService.hotMaterialHandler(1,1,"西瓜");
  71. oceanEngineService.hotMaterialHandler(1,3,"火山");
  72. oceanEngineService.hotMaterialHandler(1,9,"穿山甲");
  73. log.info("巨量创意抓取完成");*/
  74. }
  75. @Autowired
  76. private IBindAccountLoginService bindAccountLoginService;
  77. @Autowired
  78. private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
  79. @Test
  80. public void kuaishouLogin() {
  81. Long start = System.currentTimeMillis();
  82. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  83. if (list != null && !list.isEmpty()) {
  84. for (BindAccountLogin login : list) {
  85. if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
  86. kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
  87. }
  88. }
  89. }
  90. Long end = System.currentTimeMillis();
  91. log.info("总用时:{}毫秒", end - start);
  92. }
  93. static ExecutorService executorService = null;
  94. static CountDownLatch countDownLatch = null;
  95. @Test
  96. public void kuaishouCommentDelete() {
  97. Long start = System.currentTimeMillis();
  98. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  99. if (list != null && !list.isEmpty()) {
  100. executorService = Executors.newFixedThreadPool(10);
  101. countDownLatch = new CountDownLatch(list.size());
  102. list.forEach(login -> {
  103. executorService.submit(() -> {
  104. try {
  105. if (null != login.getCookie() && !"".equals(login.getCookie().trim())) {
  106. kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
  107. }
  108. } catch (Exception e) {
  109. } finally {
  110. countDownLatch.countDown();
  111. }
  112. });
  113. });
  114. }
  115. try {
  116. countDownLatch.await();
  117. } catch (InterruptedException e) {
  118. e.printStackTrace();
  119. }
  120. Long end = System.currentTimeMillis();
  121. log.info("总用时:{}毫秒", end - start);
  122. }
  123. @Autowired
  124. private PangolinLoginService pangolinLoginService;
  125. @Autowired
  126. private PangolinCrawlerService pangolinCrawlerService;
  127. @Autowired
  128. private PangolinAppService pangolinAppService;
  129. @Test
  130. public void testPangolinLogin() {
  131. QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
  132. queryWrapper.eq("login_type", "pangolin");
  133. queryWrapper.eq("status", 1);
  134. List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
  135. if (list != null && !list.isEmpty()) {
  136. for (BindAccountLogin login : list) {
  137. if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
  138. pangolinLoginService.pangolinLogin(login.getAccountName(), login.getPassword());
  139. }
  140. }
  141. }
  142. }
  143. @Test
  144. public void testPangolinData() {
  145. QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
  146. queryWrapper.eq("login_type", "pangolin");
  147. queryWrapper.eq("status", 1);
  148. queryWrapper.isNotNull("cookie");
  149. List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
  150. if (list != null && !list.isEmpty()) {
  151. for (BindAccountLogin bindAccountLogin : list) {
  152. pangolinCrawlerService.getChannelList(bindAccountLogin);
  153. pangolinCrawlerService.getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1);
  154. pangolinCrawlerService.getCheckList(bindAccountLogin);
  155. QueryWrapper<PangolinApp> queryWrapper1 = new QueryWrapper<>();
  156. queryWrapper1.eq("account_name", bindAccountLogin.getAccountName());
  157. List<PangolinApp> appList = pangolinAppService.list(queryWrapper1);
  158. if (appList != null && !appList.isEmpty()) {
  159. appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getId()));
  160. }
  161. }
  162. }
  163. }
  164. }