SampleTest.java 11 KB

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