SampleTest.java 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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.batch.service.IKuaishouInterfaceService;
  8. import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
  9. import cn.com.ctop.kuaishou.modules.report.mapper.EtlKuaishouAccountMaterialReportDailyMapper;
  10. import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyImageService;
  11. import cn.com.ctop.oa.modules.service.IWechatNoListService;
  12. import cn.com.ctop.toutiao.modules.link.service.IETLReportBytedanceVideoService;
  13. import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
  14. import cn.com.ctop.toutiao.modules.report.entity.BytedanceCheckReportTaskInfo;
  15. import cn.com.ctop.toutiao.modules.report.service.*;
  16. import com.xxl.job.core.context.XxlJobHelper;
  17. import lombok.extern.slf4j.Slf4j;
  18. import org.jeecg.common.util.DateUtils;
  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.ActiveProfiles;
  24. import org.springframework.test.context.junit4.SpringRunner;
  25. import javax.annotation.Resource;
  26. import java.text.ParseException;
  27. import java.text.SimpleDateFormat;
  28. import java.util.Date;
  29. import java.util.HashMap;
  30. import java.util.List;
  31. import java.util.concurrent.CountDownLatch;
  32. import java.util.concurrent.ExecutorService;
  33. import java.util.concurrent.Executors;
  34. @RunWith(SpringRunner.class)
  35. @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
  36. @ActiveProfiles("wps")
  37. @Slf4j
  38. public class SampleTest {
  39. @Autowired
  40. private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
  41. @Autowired
  42. IBytedanceVideoReportService bytedanceVideoReportService;
  43. @Autowired
  44. IETLReportBytedanceVideoService ietlReportBytedanceVideoService;
  45. @Autowired
  46. IKuaishouReportDailyImageService kuaishouReportDailyImageService;
  47. @Autowired
  48. IRuleByteDanceAccountService ruleByteDanceAccountService;
  49. @Autowired
  50. private ICtopOauthTokenService tokenService;
  51. @Autowired
  52. private IBindAccountLoginService bindAccountLoginService;
  53. @Autowired
  54. private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
  55. @Autowired
  56. private IByteDanceAdvertiserDataService advertiserDataService;
  57. @Autowired
  58. private IWechatNoListService wechatNoListService;
  59. @Autowired
  60. private IETLReportBytedanceVideoService bytedanceVideoService;
  61. @Autowired
  62. private IByteDanceVideoReportDailyService videoReportDailyService;
  63. @Resource
  64. private EtlKuaishouAccountMaterialReportDailyMapper etlKuaishouAccountMaterialReportDailyMapper;
  65. @Autowired
  66. private IReportService reportService;
  67. @Resource
  68. private IBytedanceCheckReportTaskInfoService checkReportTaskInfoService;
  69. @Autowired
  70. private IEtlBytedanceReportVideoDailyService etlBytedanceReportVideoDailyService;
  71. static ExecutorService executorService = null;
  72. static CountDownLatch countDownLatch = null;
  73. @Autowired
  74. private IBytedanceReportService bytedanceReportService;
  75. @Autowired
  76. private IETLReportBytedanceVideoService etlReportBytedanceVideoService;
  77. @Autowired
  78. private IKuaishouInterfaceService iKuaishouInterfaceService;
  79. @Test
  80. public void loadKuaishouCookie() throws ParseException {
  81. CtopOauthToken token = tokenService.getTokenByAccountId(10291211L);
  82. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  83. Date parse = simpleDateFormat.parse("2021-07-11");
  84. Date pars1 = simpleDateFormat.parse("2021-07-12");
  85. iKuaishouInterfaceService.getGroupList(token, parse, pars1);
  86. }
  87. @Test
  88. public void deleteKuaishouComment() {
  89. Long start = System.currentTimeMillis();
  90. List<BindAccountLogin> loginList = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  91. if (loginList != null && !loginList.isEmpty()) {
  92. executorService = Executors.newFixedThreadPool(5);
  93. countDownLatch = new CountDownLatch(loginList.size());
  94. loginList.forEach(login -> executorService.submit(() -> {
  95. try {
  96. kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
  97. } catch (Exception e) {
  98. log.error(e.getMessage(), e);
  99. } finally {
  100. countDownLatch.countDown();
  101. }
  102. }));
  103. try {
  104. countDownLatch.await();
  105. } catch (InterruptedException e) {
  106. e.printStackTrace();
  107. }
  108. Long end = System.currentTimeMillis();
  109. log.info("快手删评论所用时长:{}毫秒", end - start);
  110. }
  111. }
  112. @Test
  113. public void loadBytedanceVideoReportData() {
  114. CtopOauthToken token = tokenService.getTokenByAccountId(1696831659659278L);
  115. advertiserDataService.getMaterialList(token);
  116. }
  117. @Test
  118. public void etlBytedanceVideoInfo() {
  119. String startDate = "2021-02-01";
  120. for (int i = 0; i < 100; i++) {
  121. bytedanceVideoService.cleanData(DateUtils.addDay(startDate, i));
  122. }
  123. }
  124. @Test
  125. public void getData() {
  126. //汇创 人员
  127. // wechatUserInfoService.getUserList();
  128. // //考勤记录
  129. // wechatCheckinDataService.getCheckinData("2021-03-01 00:00:00", "2021-03-31 23:59:59");
  130. //异常记录
  131. wechatNoListService.getNoDateByNo("2021-03-01 00:00:00", "2021-03-31 23:59:59", "0");
  132. //优容
  133. // wechatUserInfoService.getYRUserList();
  134. // wechatCheckinDataService.getYRCheckinData("2021-03-01 00:00:00", "2021-03-31 23:59:59");
  135. wechatNoListService.getNoDateByNo("2021-03-01 00:00:00", "2021-03-31 23:59:59", "1");
  136. }
  137. @Test
  138. public void formatVideoReportData() {
  139. for (int i = 1; i < 45; i++) {
  140. Date getDate = DateUtils.addDay(new Date(), -i);
  141. String date = DateUtils.formatDate(getDate);
  142. videoReportDailyService.videoInfoList(date, date);
  143. }
  144. }
  145. @Test
  146. public void loadBDAccoutData() {
  147. Date startDate = DateUtils.addDay(new Date(), -2000);
  148. for (int i = 0; i <= 2000; i++) {
  149. Date getDate = DateUtils.addDay(startDate, i);
  150. bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
  151. }
  152. }
  153. @Test
  154. public void etlKuaishouVideoInfo() {
  155. etlKuaishouAccountMaterialReportDailyMapper.etlKuaishouAccountMaterialReportDailyData(DateUtils.formatDate());
  156. }
  157. @Test
  158. public void testLoadBytedanceCampaign() {
  159. CtopOauthToken token = tokenService.getTokenByAccountId(1681669009084429L);
  160. bytedanceReportService.bytedanceMaterialReport(token, "2021-05-01", "2021-05-06");
  161. }
  162. @Test
  163. public void etlBytedanceVideoReportInfo() throws Exception {
  164. etlBytedanceReportVideoDailyService.etlBytedanceVideo();
  165. }
  166. @Test
  167. public void loadBytedanceAccountReport() {
  168. CtopOauthToken token1 = tokenService.getTokenByAccountId(1693648201498637L);
  169. reportService.getAdvertiserReport(token1, DateUtils.parseDate("2021-04-01", "yyyy-MM-dd"), DateUtils.parseDate("2021-04-12", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  170. }
  171. @Test
  172. public void checkCostData() {
  173. String date = "2021-06-11";
  174. for (int i = 0; i < 7; i++) {
  175. String getDate = DateUtils.addDay(date, i);
  176. //1:初始化
  177. checkReportTaskInfoService.initTask(getDate);
  178. //2: checkCost
  179. List<BytedanceCheckReportTaskInfo> taskInfos = checkReportTaskInfoService.getListByParams(null, getDate, 0);
  180. if (null != taskInfos && !taskInfos.isEmpty()) {
  181. for (BytedanceCheckReportTaskInfo task : taskInfos) {
  182. checkReportTaskInfoService.checkCost(task);
  183. }
  184. log.info("{}:数据获取完成", getDate);
  185. }
  186. }
  187. }
  188. @Test
  189. public void refreshReportData() throws Exception {
  190. //1:查询异常任务数据
  191. List<BytedanceCheckReportTaskInfo> taskInfos = checkReportTaskInfoService.getListByParams(null, null, 50001);
  192. if (null != taskInfos && !taskInfos.isEmpty()) {
  193. countDownLatch = new CountDownLatch(taskInfos.size());
  194. taskInfos.forEach(taskInfo -> {
  195. try {
  196. checkReportTaskInfoService.reloadData(taskInfo);
  197. checkReportTaskInfoService.checkCost(taskInfo);
  198. } catch (Exception e) {
  199. } finally {
  200. countDownLatch.countDown();
  201. }
  202. });
  203. countDownLatch.await();
  204. XxlJobHelper.log("{}数据更新完成");
  205. }
  206. }
  207. @Test
  208. public void testfreshBytedanceUrl() {
  209. etlReportBytedanceVideoService.etlBytedanceVideoClipIdJob();
  210. etlReportBytedanceVideoService.etlBytedanceVideoPlanInfoJob();
  211. etlReportBytedanceVideoService.etlBytedanceVideoShotInfoJob();
  212. }
  213. @Test
  214. public void loadEffecfData() {
  215. String startDate = "2021-05-01";
  216. for (int i = 0; i <= 70; i++) {
  217. String getDate = DateUtils.addDay(startDate, i);
  218. bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(DateUtils.parseDate(getDate, "yyyy-MM-dd"));
  219. }
  220. }
  221. }