SampleTest.java 26 KB

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