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