SampleTest.java 7.3 KB

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