SampleTest.java 7.3 KB

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