SampleTest.java 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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.IByteDanceCampaignService;
  14. import cn.com.ctop.toutiao.modules.report.service.*;
  15. import com.csvreader.CsvReader;
  16. import lombok.extern.slf4j.Slf4j;
  17. import org.jeecg.common.util.DateUtils;
  18. import org.junit.Test;
  19. import org.junit.runner.RunWith;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.boot.test.context.SpringBootTest;
  22. import org.springframework.test.context.ActiveProfiles;
  23. import org.springframework.test.context.junit4.SpringRunner;
  24. import javax.annotation.Resource;
  25. import java.io.IOException;
  26. import java.nio.charset.Charset;
  27. import java.text.ParseException;
  28. import java.util.ArrayList;
  29. import java.util.Date;
  30. import java.util.HashMap;
  31. import java.util.List;
  32. import java.util.concurrent.CountDownLatch;
  33. import java.util.concurrent.ExecutorService;
  34. import java.util.concurrent.Executors;
  35. @RunWith(SpringRunner.class)
  36. @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
  37. @ActiveProfiles("wps")
  38. @Slf4j
  39. public class SampleTest {
  40. @Autowired
  41. private ICtopOauthTokenService tokenService;
  42. @Autowired
  43. private IBindAccountLoginService bindAccountLoginService;
  44. @Autowired
  45. private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
  46. @Autowired
  47. private IKuaishouInterfaceService kuaishouInterfaceService;
  48. @Test
  49. public void loadKuaishouCookie() throws ParseException {
  50. try {
  51. // 用来保存数据
  52. ArrayList<String[]> csvFileList = new ArrayList<String[]>();
  53. // 定义一个CSV路径
  54. String csvFilePath = "D:\\test\\123.csv";
  55. // 创建CSV读对象 例如:CsvReader(文件路径,分隔符,编码格式);
  56. CsvReader reader = new CsvReader(csvFilePath, ',', Charset.forName("UTF-8"));
  57. // 跳过表头 如果需要表头的话,这句可以忽略
  58. reader.readHeaders();
  59. // 逐行读入除表头的数据
  60. while (reader.readRecord()) {
  61. System.out.println(reader.getRawRecord());
  62. csvFileList.add(reader.getValues());
  63. }
  64. reader.close();
  65. // 遍历读取的CSV文件
  66. for (int row = 0; row < csvFileList.size(); row++) {
  67. // 取得第row行第0列的数据
  68. String cell = csvFileList.get(row)[0];
  69. System.out.println("------------>" + cell);
  70. }
  71. } catch (IOException e) {
  72. e.printStackTrace();
  73. }
  74. /* CtopOauthToken tokenByAccountId = tokenService.getTokenByAccountId(9792526L);
  75. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
  76. Date parse = dateFormat.parse("2021-04-02");
  77. kuaishouInterfaceService.getAdvertiserReportDaily(tokenByAccountId, parse, parse, null);*/
  78. }
  79. static ExecutorService executorService = null;
  80. static CountDownLatch countDownLatch = null;
  81. @Test
  82. public void deleteKuaishouComment() {
  83. Long start = System.currentTimeMillis();
  84. List<BindAccountLogin> loginList = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  85. if (loginList != null && !loginList.isEmpty()) {
  86. executorService = Executors.newFixedThreadPool(5);
  87. countDownLatch = new CountDownLatch(loginList.size());
  88. loginList.forEach(login -> executorService.submit(() -> {
  89. try {
  90. kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
  91. } catch (Exception e) {
  92. log.error(e.getMessage(), e);
  93. } finally {
  94. countDownLatch.countDown();
  95. }
  96. }));
  97. try {
  98. countDownLatch.await();
  99. } catch (InterruptedException e) {
  100. e.printStackTrace();
  101. }
  102. Long end = System.currentTimeMillis();
  103. log.info("快手删评论所用时长:{}毫秒", end - start);
  104. }
  105. }
  106. @Autowired
  107. private IBytedanceReportService bytedanceReportService;
  108. @Test
  109. public void loadBytedanceVideoReportData() {
  110. String startDate = "2021-04-01";
  111. String endDate = "2021-04-26";
  112. List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
  113. Long start = System.currentTimeMillis();
  114. tokens.forEach(token -> {
  115. bytedanceReportService.bytedanceVideoMaterialReport(token, startDate, endDate);
  116. });
  117. Long end = System.currentTimeMillis();
  118. log.info("查询素材消耗用时:{}毫秒", end - start);
  119. }
  120. @Autowired
  121. private IWechatNoListService wechatNoListService;
  122. @Autowired
  123. private IETLReportBytedanceVideoService bytedanceVideoService;
  124. @Test
  125. public void etlBytedanceVideoInfo() {
  126. String startDate = "2021-02-01";
  127. for (int i = 0; i < 100; i++) {
  128. bytedanceVideoService.cleanData(DateUtils.addDay(startDate, i));
  129. }
  130. }
  131. @Test
  132. public void getData() {
  133. //汇创 人员
  134. // wechatUserInfoService.getUserList();
  135. // //考勤记录
  136. // wechatCheckinDataService.getCheckinData("2021-03-01 00:00:00", "2021-03-31 23:59:59");
  137. //异常记录
  138. wechatNoListService.getNoDateByNo("2021-03-01 00:00:00", "2021-03-31 23:59:59", "0");
  139. //优容
  140. // wechatUserInfoService.getYRUserList();
  141. // wechatCheckinDataService.getYRCheckinData("2021-03-01 00:00:00", "2021-03-31 23:59:59");
  142. wechatNoListService.getNoDateByNo("2021-03-01 00:00:00", "2021-03-31 23:59:59", "1");
  143. }
  144. @Autowired
  145. private IByteDanceVideoReportDailyService videoReportDailyService;
  146. @Test
  147. public void formatVideoReportData() {
  148. for (int i = 1; i < 45; i++) {
  149. Date getDate = DateUtils.addDay(new Date(), -i);
  150. String date = DateUtils.formatDate(getDate);
  151. videoReportDailyService.videoInfoList(date, date);
  152. }
  153. }
  154. @Autowired
  155. private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
  156. @Autowired
  157. IBytedanceVideoReportService bytedanceVideoReportService;
  158. @Autowired
  159. IETLReportBytedanceVideoService ietlReportBytedanceVideoService;
  160. @Autowired
  161. IKuaishouReportDailyImageService kuaishouReportDailyImageService;
  162. @Autowired
  163. IRuleByteDanceAccountService ruleByteDanceAccountService;
  164. @Test
  165. public void loadBDAccoutData() {
  166. Date startDate = DateUtils.addDay(new Date(), -2000);
  167. for (int i = 0; i <= 2000; i++) {
  168. Date getDate = DateUtils.addDay(startDate, i);
  169. bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
  170. }
  171. }
  172. @Resource
  173. private EtlKuaishouAccountMaterialReportDailyMapper etlKuaishouAccountMaterialReportDailyMapper;
  174. @Test
  175. public void etlKuaishouVideoInfo() {
  176. etlKuaishouAccountMaterialReportDailyMapper.etlKuaishouAccountMaterialReportDailyData(DateUtils.formatDate());
  177. }
  178. @Autowired
  179. private IByteDanceCampaignService campaignService;
  180. @Test
  181. public void testLoadBytedanceCampaign() {
  182. List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
  183. for (CtopOauthToken token : tokens) {
  184. campaignService.getAdvertiserCampaign(token, null, null);
  185. }
  186. }
  187. }