SampleTest.java 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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.entity.UserAllocation;
  5. import cn.com.ctop.common.module.service.IBindAccountLoginService;
  6. import cn.com.ctop.common.module.service.ICtopOauthTokenService;
  7. import cn.com.ctop.common.module.service.IUserAllocationService;
  8. import cn.com.ctop.common.module.utils.CtopAdConstant;
  9. import cn.com.ctop.kuaishou.modules.batch.service.*;
  10. import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
  11. import cn.com.ctop.kuaishou.modules.material.service.IEtlKuaishouVideoInfoService;
  12. import cn.com.ctop.kuaishou.modules.report.mapper.EtlKuaishouAccountMaterialReportDailyMapper;
  13. import cn.com.ctop.kuaishou.modules.report.service.*;
  14. import cn.com.ctop.oa.modules.service.IWechatCheckinDataService;
  15. import cn.com.ctop.oa.modules.service.IWechatNoListService;
  16. import cn.com.ctop.oa.modules.service.IWechatUserListService;
  17. import cn.com.ctop.toutiao.modules.link.service.IETLReportBytedanceVideoService;
  18. import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
  19. import cn.com.ctop.toutiao.modules.material.service.IByteDanceCampaignService;
  20. import cn.com.ctop.toutiao.modules.report.entity.BytedanceAccountReportTaskRecord;
  21. import cn.com.ctop.toutiao.modules.report.service.*;
  22. import lombok.extern.slf4j.Slf4j;
  23. import org.jeecg.common.util.DateUtils;
  24. import org.junit.Test;
  25. import org.junit.runner.RunWith;
  26. import org.springframework.beans.factory.annotation.Autowired;
  27. import org.springframework.boot.test.context.SpringBootTest;
  28. import org.springframework.test.context.ActiveProfiles;
  29. import org.springframework.test.context.junit4.SpringRunner;
  30. import javax.annotation.Resource;
  31. import java.text.ParseException;
  32. import java.text.SimpleDateFormat;
  33. import java.util.Date;
  34. import java.util.HashMap;
  35. import java.util.List;
  36. import java.util.concurrent.CountDownLatch;
  37. import java.util.concurrent.ExecutorService;
  38. import java.util.concurrent.Executors;
  39. import static org.jeecg.common.util.DateUtils.getAnotherDay;
  40. @RunWith(SpringRunner.class)
  41. @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
  42. @ActiveProfiles("wps")
  43. @Slf4j
  44. public class SampleTest {
  45. @Autowired
  46. private ICtopOauthTokenService tokenService;
  47. @Autowired
  48. private IBindAccountLoginService bindAccountLoginService;
  49. @Autowired
  50. private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
  51. @Test
  52. public void loadKuaishouCookie() {
  53. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  54. if (list != null && !list.isEmpty()) {
  55. int i = 0;
  56. for (BindAccountLogin login : list) {
  57. if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
  58. kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
  59. i++;
  60. }
  61. }
  62. }
  63. }
  64. static ExecutorService executorService = null;
  65. static CountDownLatch countDownLatch = null;
  66. @Test
  67. public void deleteKuaishouComment() {
  68. Long start = System.currentTimeMillis();
  69. List<BindAccountLogin> loginList = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  70. if (loginList != null && !loginList.isEmpty()) {
  71. executorService = Executors.newFixedThreadPool(5);
  72. countDownLatch = new CountDownLatch(loginList.size());
  73. loginList.forEach(login -> executorService.submit(() -> {
  74. try {
  75. kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
  76. } catch (Exception e) {
  77. log.error(e.getMessage(), e);
  78. } finally {
  79. countDownLatch.countDown();
  80. }
  81. }));
  82. try {
  83. countDownLatch.await();
  84. } catch (InterruptedException e) {
  85. e.printStackTrace();
  86. }
  87. Long end = System.currentTimeMillis();
  88. log.info("快手删评论所用时长:{}毫秒", end - start);
  89. }
  90. }
  91. @Autowired
  92. private IBytedanceReportService bytedanceReportService;
  93. @Test
  94. public void loadBytedanceVideoReportData() {
  95. Date getDate = DateUtils.addDay(new Date(), -1);
  96. String date = DateUtils.formatDate(getDate);
  97. List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
  98. for (CtopOauthToken token : tokens) {
  99. bytedanceReportService.bytedanceVideoMaterialReport(token, date, date);
  100. }
  101. }
  102. @Autowired
  103. private IWechatNoListService wechatNoListService;
  104. @Test
  105. public void getData() {
  106. //汇创 人员
  107. // wechatUserInfoService.getUserList();
  108. // //考勤记录
  109. // wechatCheckinDataService.getCheckinData("2021-03-01 00:00:00", "2021-03-31 23:59:59");
  110. //异常记录
  111. wechatNoListService.getNoDateByNo("2021-03-01 00:00:00", "2021-03-31 23:59:59", "0");
  112. //优容
  113. // wechatUserInfoService.getYRUserList();
  114. // wechatCheckinDataService.getYRCheckinData("2021-03-01 00:00:00", "2021-03-31 23:59:59");
  115. wechatNoListService.getNoDateByNo("2021-03-01 00:00:00", "2021-03-31 23:59:59", "1");
  116. }
  117. @Autowired
  118. private IByteDanceVideoReportDailyService videoReportDailyService;
  119. @Test
  120. public void formatVideoReportData() {
  121. for (int i = 1; i < 45; i++) {
  122. Date getDate = DateUtils.addDay(new Date(), -i);
  123. String date = DateUtils.formatDate(getDate);
  124. videoReportDailyService.videoInfoList(date, date);
  125. }
  126. }
  127. @Autowired
  128. private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
  129. @Autowired
  130. IBytedanceVideoReportService bytedanceVideoReportService;
  131. @Autowired
  132. IETLReportBytedanceVideoService ietlReportBytedanceVideoService;
  133. @Autowired
  134. IKuaishouReportDailyImageService kuaishouReportDailyImageService;
  135. @Autowired
  136. IRuleByteDanceAccountService ruleByteDanceAccountService;
  137. @Test
  138. public void loadBDAccoutData() {
  139. Date startDate = DateUtils.addDay(new Date(), -2000);
  140. for (int i = 0; i <= 2000; i++) {
  141. Date getDate = DateUtils.addDay(startDate, i);
  142. bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
  143. }
  144. }
  145. @Resource
  146. private EtlKuaishouAccountMaterialReportDailyMapper etlKuaishouAccountMaterialReportDailyMapper;
  147. @Test
  148. public void etlKuaishouVideoInfo() {
  149. etlKuaishouAccountMaterialReportDailyMapper.etlKuaishouAccountMaterialReportDailyData(DateUtils.formatDate());
  150. }
  151. @Autowired
  152. private IByteDanceCampaignService campaignService;
  153. @Test
  154. public void testLoadBytedanceCampaign(){
  155. List<CtopOauthToken>tokens = tokenService.selectToutiaoToken();
  156. for(CtopOauthToken token :tokens){
  157. campaignService.getAdvertiserCampaign(token, null, null);
  158. }
  159. }
  160. }