SampleTest.java 25 KB

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