SampleTest.java 28 KB

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