SampleTest.java 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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.service.PangolinAppService;
  8. import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService;
  9. import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService;
  10. import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
  11. import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
  12. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  13. import lombok.extern.slf4j.Slf4j;
  14. import org.jeecg.common.util.DateUtils;
  15. import org.jeecg.modules.ctop.entity.KuaishouMatcostAccountMay;
  16. import org.jeecg.modules.ctop.service.IKuaishouMatcostAccountMayService;
  17. import org.junit.Test;
  18. import org.junit.runner.RunWith;
  19. import org.springframework.beans.factory.annotation.Autowired;
  20. import org.springframework.boot.test.context.SpringBootTest;
  21. import org.springframework.test.context.junit4.SpringRunner;
  22. import java.math.BigDecimal;
  23. import java.util.HashMap;
  24. import java.util.List;
  25. import java.util.concurrent.CountDownLatch;
  26. import java.util.concurrent.ExecutorService;
  27. import java.util.concurrent.Executors;
  28. @RunWith(SpringRunner.class)
  29. @SpringBootTest
  30. @Slf4j
  31. public class SampleTest {
  32. @Autowired
  33. private ICtopOauthTokenService oauthTokenService;
  34. @Autowired
  35. private IByteDanceAdvertiserDataService advertiserDataService;
  36. @Test
  37. public void testOceanEngineJob() {
  38. CtopOauthToken token = oauthTokenService.getTokenByAccountId(1629785592929294L);
  39. advertiserDataService.getMaterialList(token);
  40. }
  41. @Autowired
  42. private IBindAccountLoginService bindAccountLoginService;
  43. @Autowired
  44. private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
  45. @Test
  46. public void kuaishouLogin() {
  47. Long start = System.currentTimeMillis();
  48. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  49. if (list != null && !list.isEmpty()) {
  50. for (BindAccountLogin login : list) {
  51. if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
  52. kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
  53. }
  54. }
  55. }
  56. Long end = System.currentTimeMillis();
  57. log.info("总用时:{}毫秒", end - start);
  58. }
  59. static ExecutorService executorService = null;
  60. static CountDownLatch countDownLatch = null;
  61. @Test
  62. public void kuaishouCommentDelete() {
  63. Long start = System.currentTimeMillis();
  64. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  65. if (list != null && !list.isEmpty()) {
  66. executorService = Executors.newFixedThreadPool(10);
  67. countDownLatch = new CountDownLatch(list.size());
  68. list.forEach(login -> {
  69. executorService.submit(() -> {
  70. try {
  71. if (null != login.getCookie() && !"".equals(login.getCookie().trim())) {
  72. kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
  73. }
  74. } catch (Exception e) {
  75. } finally {
  76. countDownLatch.countDown();
  77. }
  78. });
  79. });
  80. }
  81. try {
  82. countDownLatch.await();
  83. } catch (InterruptedException e) {
  84. e.printStackTrace();
  85. }
  86. Long end = System.currentTimeMillis();
  87. log.info("总用时:{}毫秒", end - start);
  88. }
  89. @Autowired
  90. private PangolinLoginService pangolinLoginService;
  91. @Autowired
  92. private PangolinCrawlerService pangolinCrawlerService;
  93. @Autowired
  94. private PangolinAppService pangolinAppService;
  95. @Test
  96. public void testPangolinLogin() {
  97. QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
  98. queryWrapper.eq("login_type", "pangolin");
  99. queryWrapper.eq("status", 1);
  100. List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
  101. if (list != null && !list.isEmpty()) {
  102. for (BindAccountLogin login : list) {
  103. if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
  104. pangolinLoginService.pangolinLogin(login.getAccountName(), login.getPassword());
  105. }
  106. }
  107. }
  108. }
  109. @Autowired
  110. private IKuaishouMatcostAccountMayService matcostAccountMayService;
  111. @Test
  112. public void testLoadMinDate(){
  113. loadData();
  114. }
  115. private void loadData(){
  116. KuaishouMatcostAccountMay matcostAccountMay = matcostAccountMayService.getOne();
  117. if(null!=matcostAccountMay){
  118. BigDecimal cost = matcostAccountMayService.getCostByParams(matcostAccountMay);
  119. if(null!=cost&&!cost.toString().trim().equals("")){
  120. matcostAccountMayService.updateCostByCode(matcostAccountMay.getVideoCode(),cost);
  121. }else{
  122. matcostAccountMayService.updateCostByCode(matcostAccountMay.getVideoCode(),BigDecimal.ZERO);
  123. }
  124. loadData();
  125. }
  126. }
  127. @Test
  128. public void testPangolinData() {
  129. QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
  130. queryWrapper.eq("login_type", "pangolin");
  131. queryWrapper.eq("status", 1);
  132. queryWrapper.isNotNull("cookie");
  133. List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
  134. if (list != null && !list.isEmpty()) {
  135. for (BindAccountLogin bindAccountLogin : list) {
  136. // pangolinCrawlerService.getChannelList(bindAccountLogin);
  137. pangolinCrawlerService.getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1);
  138. pangolinCrawlerService.getCheckList(bindAccountLogin);
  139. // QueryWrapper<PangolinApp> queryWrapper1 = new QueryWrapper<>();
  140. // queryWrapper1.eq("account_name", bindAccountLogin.getAccountName());
  141. // List<PangolinApp> appList = pangolinAppService.list(queryWrapper1);
  142. // if (appList != null && !appList.isEmpty()) {
  143. // appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getAppId()));
  144. // }
  145. }
  146. }
  147. }
  148. }