SampleTest.java 23 KB

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