SampleTest.java 24 KB

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