SampleTest.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
  8. import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
  9. import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
  10. import cn.com.ctop.toutiao.modules.report.service.IReportService;
  11. import lombok.extern.slf4j.Slf4j;
  12. import org.jeecg.common.util.DateUtils;
  13. import org.junit.Test;
  14. import org.junit.runner.RunWith;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.boot.test.context.SpringBootTest;
  17. import org.springframework.test.context.junit4.SpringRunner;
  18. import java.util.Date;
  19. import java.util.HashMap;
  20. import java.util.List;
  21. import java.util.concurrent.CountDownLatch;
  22. import java.util.concurrent.ExecutorService;
  23. import java.util.concurrent.Executors;
  24. @RunWith(SpringRunner.class)
  25. @SpringBootTest
  26. @Slf4j
  27. public class SampleTest {
  28. @Autowired
  29. private ICtopOauthTokenService oauthTokenService;
  30. @Autowired
  31. private IByteDanceAdvertiserDataService advertiserDataService;
  32. @Autowired
  33. private IBytedanceEffectVideoInfoService effectVideoInfoService;
  34. @Autowired
  35. private IReportService reportService;
  36. @Autowired
  37. private IBindAccountLoginService bindAccountLoginService;
  38. @Autowired
  39. private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
  40. @Test
  41. public void getBytedanceData(){
  42. CtopOauthToken token5 = oauthTokenService.getTokenByAccountId(1668362864699400L);
  43. for(int i=10;i<120;i++){
  44. Date date = DateUtils.addDay(new Date(), -i);
  45. reportService.getAdvertiserReport(token5,date,date,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  46. }
  47. }
  48. @Test
  49. public void testOceanEngineJob() {
  50. List<CtopOauthToken>tokens = oauthTokenService.selectToutiaoToken();
  51. String date = DateUtils.addDay("2020-07-10",-2);
  52. tokens.forEach(token -> {
  53. // advertiserDataService.getAdvertiserCampaign(token,null,date);
  54. });
  55. }
  56. @Test
  57. public void loadEffectVideo(){
  58. String date = "2020-07-10";
  59. for(int i=0;i<150;i++){
  60. String getDate = DateUtils.addDay(date,i);
  61. effectVideoInfoService.loadEffectVideo(getDate);
  62. }
  63. }
  64. @Test
  65. public void kuaishouLogin() {
  66. Long start = System.currentTimeMillis();
  67. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  68. if (list != null && !list.isEmpty()) {
  69. for (BindAccountLogin login : list) {
  70. if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
  71. kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
  72. }
  73. }
  74. }
  75. Long end = System.currentTimeMillis();
  76. log.info("总用时:{}毫秒", end - start);
  77. }
  78. static ExecutorService executorService = null;
  79. static CountDownLatch countDownLatch = null;
  80. @Test
  81. public void kuaishouCommentDelete() {
  82. Long start = System.currentTimeMillis();
  83. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  84. if (list != null && !list.isEmpty()) {
  85. executorService = Executors.newFixedThreadPool(10);
  86. countDownLatch = new CountDownLatch(list.size());
  87. list.forEach(login -> {
  88. executorService.submit(() -> {
  89. try {
  90. if (null != login.getCookie() && !"".equals(login.getCookie().trim())) {
  91. kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
  92. }
  93. } catch (Exception e) {
  94. } finally {
  95. countDownLatch.countDown();
  96. }
  97. });
  98. });
  99. }
  100. try {
  101. countDownLatch.await();
  102. } catch (InterruptedException e) {
  103. e.printStackTrace();
  104. }
  105. Long end = System.currentTimeMillis();
  106. log.info("总用时:{}毫秒", end - start);
  107. }
  108. }