SampleTest.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  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.ai.service.IAiKuaishouNewCreateCampaign;
  10. import cn.com.ctop.kuaishou.modules.batch.service.*;
  11. import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
  12. import cn.com.ctop.kuaishou.modules.material.service.IEtlKuaishouVideoInfoService;
  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.report.entity.BytedanceAccountReportTaskRecord;
  20. import cn.com.ctop.toutiao.modules.report.service.*;
  21. import lombok.extern.slf4j.Slf4j;
  22. import org.jeecg.common.util.DateUtils;
  23. import org.junit.Test;
  24. import org.junit.runner.RunWith;
  25. import org.springframework.beans.factory.annotation.Autowired;
  26. import org.springframework.boot.test.context.SpringBootTest;
  27. import org.springframework.test.context.ActiveProfiles;
  28. import org.springframework.test.context.junit4.SpringRunner;
  29. import java.text.ParseException;
  30. import java.text.SimpleDateFormat;
  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. import static org.jeecg.common.util.DateUtils.getAnotherDay;
  38. @RunWith(SpringRunner.class)
  39. @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
  40. @ActiveProfiles("dev")
  41. @Slf4j
  42. public class SampleTest {
  43. @Autowired
  44. private ICtopOauthTokenService oauthTokenService;
  45. @Autowired
  46. private IReportService reportService;
  47. @Autowired
  48. private IByteDanceAdvertiserDataService advertiserDataService;
  49. @Autowired
  50. private ICtopOauthTokenService tokenService;
  51. @Autowired
  52. private IKuaiShouVideoGetService videoGetService;
  53. @Autowired
  54. private IKuaishouVideoRelateCreativesService kuaishouVideoRelateCreativesService;
  55. @Autowired
  56. private IBindAccountLoginService bindAccountLoginService;
  57. @Autowired
  58. private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
  59. /* @Autowired
  60. private IByteDanceAdvertiserDataService advertiserDataService;
  61. */
  62. @Autowired
  63. private IKuaishouReportDailyGroupService reportDailyGroupService;
  64. @Autowired
  65. private IEtlKuaiShouAccountMaterialOverviewService kuaiShouAccountMaterialOverviewService;
  66. @Autowired
  67. private IKuaiShouGroupService kuaiShouGroupService;
  68. @Test
  69. public void loadBytedanceCreativeData() throws ParseException {
  70. Date getDate = DateUtils.addDay(new Date(), -1);
  71. Date getDate2 = DateUtils.addDay(new Date(), -2);
  72. CtopOauthToken token = new CtopOauthToken();
  73. token.setAccountId(9901975L);
  74. token.setAccessToken("1c7cebebc3174c39fe941d136df65b1d");
  75. kuaiShouGroupService.getGroupListByPage("90f31a01c2137aa11c8686e86064b630",9845316L,null,1);
  76. // kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate2, getDate, "adScene");
  77. /* JSONObject materialOverview = kuaiShouAccountMaterialOverviewService.getMaterialOverview(5473041L, "2021-03-09");
  78. System.err.println(materialOverview);*/
  79. /* CtopOauthToken token = new CtopOauthToken();
  80. token.setAccountId(9901975L);
  81. token.setAccessToken("e609f9d3f56f3d6b4653f32c98a6d119");
  82. kuaiShouAccountMaterialOverviewService.cleanAccountMaterialOverview(9901975L, "2021-03-09");
  83. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  84. Date parse = simpleDateFormat.parse("2021-03-09");
  85. reportDailyGroupService.getAdvertiserGroupReportDaily(token, parse, parse);*/
  86. // 1662234704806924
  87. /* CtopOauthToken token = new CtopOauthToken();
  88. token.setAccountId(9549277L);
  89. token.setAccessToken("bc5327c8f2bd8a67513e51148c9206c8");
  90. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  91. Date parse = simpleDateFormat.parse("2021-02-02");
  92. kuaishouInterfaceService.getAdvertiserReportDaily(token, parse, parse);*/
  93. /* CtopOauthToken token = new CtopOauthToken();
  94. token.setAccountId(9767055L);
  95. token.setAccessToken("28e4e6b124e1443d6971ba4c699de6c9");
  96. kuaishouInterfaceService.getVideoList(token, null, null);
  97. kuaishouInterfaceService.getVideoInfo("28e4e6b124e1443d6971ba4c699de6c9", 9767055L, "5208131540349742192");*/
  98. /* CtopOauthToken tokenByAccountId = tokenService.getTokenByAccountId(1662234704806924L);
  99. advertiserDataService.getMaterialList(tokenByAccountId);*/
  100. /* getVideoByPage(token, "", 1);
  101. List<KuaiShouVideoGet> KuaiShouVideoGets = videoGetService.selectPhotoIdsByAccountId(9743746L);
  102. if (!Check.isNull(KuaiShouVideoGets)) {
  103. JSONArray dateList = new JSONArray();
  104. JSONArray photoIds = new JSONArray();
  105. Map<String, Object> statdateMap = new HashMap<>();
  106. int count = 0;
  107. for (KuaiShouVideoGet video : KuaiShouVideoGets) {
  108. count++;
  109. if (count < 10) {
  110. photoIds.add(video.getPhotoId());
  111. statdateMap.put(video.getPhotoId(), video.getStatDate());
  112. } else {
  113. photoIds.add(video.getPhotoId());
  114. statdateMap.put(video.getPhotoId(), video.getStatDate());
  115. dateList.add(photoIds);
  116. photoIds = new JSONArray();
  117. count = 0;
  118. }
  119. }
  120. dateList.add(photoIds);
  121. kuaishouVideoRelateCreativesService.videoRelateCreatives(9743746L, dateList, statdateMap);
  122. }*/
  123. }
  124. @Test
  125. public void loadKuaishouCookie() {
  126. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  127. if (list != null && !list.isEmpty()) {
  128. int i = 0;
  129. for (BindAccountLogin login : list) {
  130. if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
  131. kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
  132. i++;
  133. }
  134. }
  135. }
  136. }
  137. @Test
  138. public void loadKuaishouCamgaignData(){
  139. Date getDate = DateUtils.parseDate("2021-03-24","yyyy-MM-dd");
  140. List<UserAllocation> list = allocationService.getByParams(50L,null,0);
  141. list.forEach(userAllocation -> {
  142. CtopOauthToken token = tokenService.getOauthTokenByAccountId(userAllocation.getAccountId().toString());
  143. kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token, getDate, getDate);
  144. });
  145. }
  146. static ExecutorService executorService = null;
  147. static CountDownLatch countDownLatch = null;
  148. @Test
  149. public void deleteKuaishouComment() {
  150. Long start = System.currentTimeMillis();
  151. List<BindAccountLogin> loginList = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  152. if (loginList != null && !loginList.isEmpty()) {
  153. executorService = Executors.newFixedThreadPool(5);
  154. countDownLatch = new CountDownLatch(loginList.size());
  155. loginList.forEach(login -> executorService.submit(() -> {
  156. try {
  157. kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
  158. } catch (Exception e) {
  159. log.error(e.getMessage(), e);
  160. } finally {
  161. countDownLatch.countDown();
  162. }
  163. }));
  164. try {
  165. countDownLatch.await();
  166. } catch (InterruptedException e) {
  167. e.printStackTrace();
  168. }
  169. Long end = System.currentTimeMillis();
  170. log.info("快手删评论所用时长:{}毫秒", end - start);
  171. }
  172. }
  173. @Autowired
  174. private IUserAllocationService allocationService;
  175. @Test
  176. public void testLoadBytedanceData() {
  177. List<UserAllocation> allocations = allocationService.getByParams(633L, null, 0);
  178. if (null != allocations && !allocations.isEmpty()) {
  179. for (UserAllocation allocation : allocations) {
  180. CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
  181. String startDate = "2020-11-10";
  182. String endDate = "2020-11-10";
  183. reportService.getAdvertiserReport(token, DateUtils.parseDate(startDate, "yyyy-MM-dd"), DateUtils.parseDate(endDate, "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
  184. }
  185. }
  186. System.out.println("任务结束");
  187. }
  188. @Test
  189. public void loadKuaishouPlanData() {
  190. Date getDate = DateUtils.addDay(new Date(), -1);
  191. //1:查询当日数据
  192. List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
  193. tokens.forEach(token -> kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token, getDate, getDate));
  194. }
  195. @Autowired
  196. private IBytedanceFundDailyService bytedanceFundDailyService;
  197. @Test
  198. public void loadFoudData() {
  199. List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
  200. for (CtopOauthToken token : tokens) {
  201. System.out.println(token.getAccountId() + "############################");
  202. for (int i = 20; i < 130; i++) {
  203. Date date = DateUtils.addDay(new Date(), -i);
  204. bytedanceFundDailyService.loadFundDataByPage(token, DateUtils.formatDate(date), DateUtils.formatDate(date), 1);
  205. System.out.println(i + "############################");
  206. }
  207. }
  208. }
  209. @Autowired
  210. private IKuaiShouHistoryReportTaskService reportTaskService;
  211. /**
  212. * 测试获取快手图片消耗数据任务
  213. */
  214. @Test
  215. public void loadKuaishouImageTask() {
  216. List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
  217. for (int i = 1; i < 130; i++) {
  218. Date getDate = DateUtils.addDay(new Date(), -i);
  219. String getDateStr = DateUtils.formatDate(getDate);
  220. tokens.forEach(token -> reportTaskService.createTask(token.getAccountId(), token.getAccessToken(), getDateStr, getDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_DAILY));
  221. }
  222. }
  223. @Autowired
  224. private IKuaiShouDailyReportTaskService dailyReportTaskService;
  225. /**
  226. * 测试获取快手图片消耗数据入库
  227. */
  228. @Test
  229. public void loadKuaishouImageTaskFile() {
  230. String nowDate = DateUtils.getDate("yyyy-MM-dd");
  231. List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
  232. for (int i = 1; i < 15; i++) {
  233. String statDate = getAnotherDay("yyyy-MM-dd", nowDate, -i);
  234. tokens.forEach(token -> dailyReportTaskService.getTaskList(token.getAccountId(), token.getAccessToken(), statDate));
  235. }
  236. // 查询快手token
  237. }
  238. @Test
  239. public void testLoadBytedanceImageData() {
  240. List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
  241. countDownLatch = new CountDownLatch(tokens.size());
  242. executorService = Executors.newFixedThreadPool(8);
  243. tokens.forEach(token -> executorService.submit(() -> {
  244. try {
  245. advertiserDataService.getMaterialList(token);
  246. } catch (Exception e) {
  247. } finally {
  248. countDownLatch.countDown();
  249. }
  250. }));
  251. try {
  252. countDownLatch.await();
  253. } catch (InterruptedException e) {
  254. e.printStackTrace();
  255. }
  256. System.out.println("素材数据获取完成");
  257. }
  258. @Autowired
  259. private IKuaishouReportDailyAgentService kuaishouReportDailyAgentService;
  260. @Test
  261. public void testData() {
  262. Date date = new Date();
  263. List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
  264. executorService = Executors.newFixedThreadPool(10);
  265. countDownLatch = new CountDownLatch(tokens.size());
  266. tokens.forEach(token -> executorService.submit(() -> {
  267. try {
  268. reportService.getAdvertiserPlanRuleData(token, date, date, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  269. } catch (Exception e) {
  270. } finally {
  271. countDownLatch.countDown();
  272. }
  273. }));
  274. try {
  275. countDownLatch.await();
  276. } catch (InterruptedException e) {
  277. e.printStackTrace();
  278. }
  279. }
  280. @Test
  281. public void loadKuaishouAgentData() {
  282. kuaishouReportDailyAgentService.loginAgent();
  283. try {
  284. for (int i = 1; i < 30; i++) {
  285. kuaishouReportDailyAgentService.getAccount(i);
  286. }
  287. } catch (Exception e) {
  288. e.printStackTrace();
  289. }
  290. }
  291. @Test
  292. public void loadKuaishouData() {
  293. Date getDate = DateUtils.addDay(new Date(), -1);
  294. //1:查询当日数据
  295. List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
  296. for (CtopOauthToken token : tokens) {
  297. kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token, getDate, getDate);
  298. }
  299. }
  300. @Autowired
  301. private IBytedanceReportService bytedanceReportService;
  302. @Test
  303. public void loadBytedanceVideoReportData() {
  304. Date getDate = DateUtils.addDay(new Date(), -1);
  305. String date = DateUtils.formatDate(getDate);
  306. List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
  307. for (CtopOauthToken token : tokens) {
  308. bytedanceReportService.bytedanceVideoMaterialReport(token, date, date);
  309. }
  310. }
  311. @Test
  312. public void loadKuaishouHourlyReportData() {
  313. Date getDate = new Date();
  314. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
  315. String hour = simpleDateFormat.format(getDate);
  316. if ("00".equals(hour)) {
  317. getDate = DateUtils.addDay(getDate, -1);
  318. }
  319. //1:查询当日数据
  320. List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
  321. Date finalGetDate = getDate;
  322. tokens.forEach(token -> kuaishouInterfaceService.getAdvertiserReportHourly(token, finalGetDate, finalGetDate));
  323. }
  324. @Autowired
  325. private IKuaishouInterfaceService kuaishouInterfaceService;
  326. @Test
  327. public void loadKuaishouGroupData() throws ParseException {
  328. Date endDate = new Date();
  329. String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(endDate), -1);
  330. SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
  331. Date startDate = sim.parse(anotherDay);
  332. CtopOauthToken token = tokenService.getTokenByAccountId(7087890L);
  333. kuaishouInterfaceService.getGroupList(token, startDate, endDate);
  334. }
  335. @Test
  336. public void loadAccountData() {
  337. // List<UserAllocation> allocations = allocationService.getByParams(776L,null,0);
  338. // for (UserAllocation allocation:allocations) {
  339. CtopOauthToken token = tokenService.getTokenByAccountId(93238965516L);
  340. for (int i = 92; i < 100; i++) {
  341. Date getDate = DateUtils.addDay(new Date(), -i);
  342. reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  343. }
  344. // }
  345. }
  346. @Autowired
  347. private IWechatCheckinDataService wechatCheckinDataService;
  348. @Autowired
  349. private IWechatUserListService wechatUserInfoService;
  350. @Autowired
  351. private IWechatNoListService wechatNoListService;
  352. @Test
  353. public void getData() {
  354. //汇创 人员
  355. // wechatUserInfoService.getUserList();
  356. // //考勤记录
  357. // wechatCheckinDataService.getCheckinData("2020-11-01 00:00:00", "2020-12-01 23:59:59");
  358. //异常记录
  359. // wechatNoListService.getNoDateByNo("2020-11-01 00:00:00", "2020-12-01 23:59:59", "0");
  360. //优容
  361. wechatUserInfoService.getYRUserList();
  362. wechatCheckinDataService.getYRCheckinData("2020-11-01 00:00:00", "2020-11-30 23:59:59");
  363. wechatNoListService.getNoDateByNo("2020-11-01 00:00:00", "2020-12-01 23:59:59", "1");
  364. }
  365. @Autowired
  366. private IKuaiShouCommentService kuaiShouCommentService;
  367. @Test
  368. public void kuaishouDeleteComment() {
  369. kuaiShouCommentService.shieldComment(8018853L);
  370. }
  371. @Autowired
  372. private IByteDanceVideoReportDailyService videoReportDailyService;
  373. @Test
  374. synchronized public void formatVideoReportData() {
  375. for (int i = 1; i < 45; i++) {
  376. Date getDate = DateUtils.addDay(new Date(), -i);
  377. String date = DateUtils.formatDate(getDate);
  378. videoReportDailyService.videoInfoList(date, date);
  379. }
  380. }
  381. @Autowired
  382. private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
  383. @Autowired
  384. IBytedanceVideoReportService bytedanceVideoReportService;
  385. @Autowired
  386. IETLReportBytedanceVideoService ietlReportBytedanceVideoService;
  387. @Autowired
  388. IKuaishouReportDailyImageService kuaishouReportDailyImageService;
  389. @Autowired
  390. IRuleByteDanceAccountService ruleByteDanceAccountService;
  391. @Autowired
  392. IAiKuaishouNewCreateCampaign aiKuaishouNewCreateCampaign;
  393. @Autowired
  394. private IKuaishouVideoEtlInfoService kuaishouVideoEtlInfoService;
  395. @Autowired
  396. private IBytedanceAccountReportTaskRecordService reportTaskRecordService;
  397. @Test
  398. public void execute() {
  399. List<UserAllocation> allocations = allocationService.listByMediaId("3", 0);
  400. for (UserAllocation allocation : allocations) {
  401. BytedanceAccountReportTaskRecord reportTaskRecord1 = new BytedanceAccountReportTaskRecord(allocation.getAccountId(), "2020-10-01", "2020-10-31");
  402. reportTaskRecordService.save(reportTaskRecord1);
  403. BytedanceAccountReportTaskRecord reportTaskRecord2 = new BytedanceAccountReportTaskRecord(allocation.getAccountId(), "2020-11-01", "2020-11-30");
  404. reportTaskRecordService.save(reportTaskRecord2);
  405. BytedanceAccountReportTaskRecord reportTaskRecord3 = new BytedanceAccountReportTaskRecord(allocation.getAccountId(), "2020-12-01", "2020-12-31");
  406. reportTaskRecordService.save(reportTaskRecord3);
  407. }
  408. }
  409. @Test
  410. public void loadBDAccoutData() {
  411. Date startDate = DateUtils.addDay(new Date(),-2000);
  412. for(int i=0;i<=2000;i++){
  413. Date getDate = DateUtils.addDay(startDate,i);
  414. bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
  415. }
  416. }
  417. @Test
  418. public void etlKuaishouData() {
  419. String dateString = "2021-01-05";
  420. Date startDate = DateUtils.parseDate(dateString, "yyyy-MM-dd");
  421. for (int i = 0; i <= 10; i++) {
  422. Date getDate = DateUtils.addDay(startDate, i);
  423. kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
  424. bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
  425. }
  426. }
  427. @Autowired
  428. private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
  429. @Test
  430. public void loadBytedanceVideo() {
  431. CtopOauthToken token = tokenService.getTokenByAccountId(1673731601820686L);
  432. for (int i = 15; i < 60; i++) {
  433. reportService.getAdvertiserReport(token, DateUtils.addDay(new Date(), -i), DateUtils.addDay(new Date(), -i), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  434. }
  435. }
  436. @Test
  437. public void loadKuaishouVideo() {
  438. Date date = new Date();
  439. CtopOauthToken token = tokenService.getTokenByAccountId(9556344L);
  440. // kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, new Date(), new Date(), null, null);
  441. kuaishouInterfaceService.getVideoList(token, DateUtils.formatDate(DateUtils.addDay(date, -5)), DateUtils.formatDate(date));
  442. // 获取图片信息数据
  443. // kuaishouInterfaceService.getImageList(token, DateUtils.getNowDate("yyyy-MM-dd"));
  444. }
  445. @Test
  446. public void testLoadBytedanceDataV2() {
  447. String accountIds = "1675440464386062";
  448. String[] accountArray = accountIds.split(",");
  449. for (int i = 0; i < accountArray.length; i++) {
  450. CtopOauthToken token = tokenService.getTokenByAccountId(Long.parseLong(accountArray[i]));
  451. reportService.getAdvertiserReport(token, DateUtils.parseDate("2021-01-14", "yyyy-MM-dd"), DateUtils.parseDate("2021-01-14", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  452. }
  453. }
  454. @Test
  455. public void loadKuaiShouImage() {
  456. List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
  457. executorService = Executors.newFixedThreadPool(22);
  458. countDownLatch = new CountDownLatch(tokens.size());
  459. tokens.forEach(token -> executorService.submit(() -> {
  460. try {
  461. kuaishouReportDailyImageService.getMaterialImageReport(token.getAccountId(), token.getAccessToken(), "2021-01-17", "2021-01-31", 1);
  462. } catch (Exception e) {
  463. } finally {
  464. countDownLatch.countDown();
  465. }
  466. }));
  467. try {
  468. countDownLatch.await();
  469. } catch (InterruptedException e) {
  470. e.printStackTrace();
  471. }
  472. }
  473. @Autowired
  474. private IEtlKuaishouAccountMaterialReportDailyService dailyService;
  475. @Test
  476. public void etlKuaishouInfo() {
  477. Date startDate = DateUtils.parseDate("2020-05-03", "yyyy-MM-dd");
  478. for (int i = 0; i < 365; i++) {
  479. dailyService.etlKuaishouAccountMaterialReportDailyData(DateUtils.formatDate(DateUtils.addDay(startDate, i)));
  480. }
  481. }
  482. @Autowired
  483. private IEtlKuaishouVideoInfoService videoEtlInfoService;
  484. @Test
  485. public void etlKuaishouVideoInfo() {
  486. Date startDate = DateUtils.parseDate("2021-03-01", "yyyy-MM-dd");
  487. for (int i = 0; i < 365; i++) {
  488. // dailyService.etlKuaishouAccountMaterialReportDailyData(DateUtils.formatDate(DateUtils.addDay(startDate,i)));
  489. videoEtlInfoService.etlKuaishouVideoInfo(DateUtils.formatDate(DateUtils.addDay(startDate, i)));
  490. }
  491. }
  492. }