SampleTest.java 11 KB

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