SampleTest.java 22 KB

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