SampleTest.java 25 KB

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