SampleTest.java 24 KB

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