SampleTest.java 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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 com.xxl.job.core.context.XxlJobHelper;
  28. import lombok.extern.slf4j.Slf4j;
  29. import org.jeecg.common.util.DateUtils;
  30. import org.junit.Test;
  31. import org.junit.runner.RunWith;
  32. import org.springframework.beans.factory.annotation.Autowired;
  33. import org.springframework.boot.test.context.SpringBootTest;
  34. import org.springframework.test.context.ActiveProfiles;
  35. import org.springframework.test.context.junit4.SpringRunner;
  36. import javax.annotation.Resource;
  37. import java.text.ParseException;
  38. import java.text.SimpleDateFormat;
  39. import java.util.Date;
  40. import java.util.HashMap;
  41. import java.util.List;
  42. import java.util.concurrent.CountDownLatch;
  43. import java.util.concurrent.ExecutorService;
  44. import java.util.concurrent.Executors;
  45. import static org.jeecg.common.util.DateUtils.getAnotherDay;
  46. @RunWith(SpringRunner.class)
  47. @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
  48. @ActiveProfiles("wps")
  49. @Slf4j
  50. public class SampleTest {
  51. @Autowired
  52. private ICtopOauthTokenService oauthTokenService;
  53. @Autowired
  54. private IReportService reportService;
  55. @Autowired
  56. private IByteDanceAdvertiserDataService advertiserDataService;
  57. @Autowired
  58. private ICtopOauthTokenService tokenService;
  59. @Autowired
  60. private IKuaiShouVideoGetService videoGetService;
  61. @Autowired
  62. private IKuaishouVideoRelateCreativesService kuaishouVideoRelateCreativesService;
  63. @Autowired
  64. private IBindAccountLoginService bindAccountLoginService;
  65. @Autowired
  66. private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
  67. @Autowired
  68. private IProjectService projectService;
  69. @Autowired
  70. private IUserAllocationService allocationService;
  71. /* @Autowired
  72. private IByteDanceAdvertiserDataService advertiserDataService;
  73. */
  74. @Test
  75. public void loadBytedanceCreativeData() throws ParseException {
  76. // 1662234704806924
  77. /* CtopOauthToken token = new CtopOauthToken();
  78. token.setAccountId(9549277L);
  79. token.setAccessToken("bc5327c8f2bd8a67513e51148c9206c8");
  80. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  81. Date parse = simpleDateFormat.parse("2021-02-02");
  82. kuaishouInterfaceService.getAdvertiserReportDaily(token, parse, parse);*/
  83. QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
  84. queryWrapper.eq("project_id", 900886);
  85. List<UserAllocation> list = allocationService.list(queryWrapper);
  86. for (UserAllocation allocation : list) {
  87. CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
  88. kuaishouInterfaceService.getVideoList(token, null, null);
  89. }
  90. /* CtopOauthToken token = new CtopOauthToken();
  91. token.setAccountId(9767055L);
  92. token.setAccessToken("28e4e6b124e1443d6971ba4c699de6c9");
  93. kuaishouInterfaceService.getVideoList(token, null, null);
  94. kuaishouInterfaceService.getVideoInfo("28e4e6b124e1443d6971ba4c699de6c9", 9767055L, "5208131540349742192");*/
  95. /* CtopOauthToken tokenByAccountId = tokenService.getTokenByAccountId(1662234704806924L);
  96. advertiserDataService.getMaterialList(tokenByAccountId);*/
  97. /* getVideoByPage(token, "", 1);
  98. List<KuaiShouVideoGet> KuaiShouVideoGets = videoGetService.selectPhotoIdsByAccountId(9743746L);
  99. if (!Check.isNull(KuaiShouVideoGets)) {
  100. JSONArray dateList = new JSONArray();
  101. JSONArray photoIds = new JSONArray();
  102. Map<String, Object> statdateMap = new HashMap<>();
  103. int count = 0;
  104. for (KuaiShouVideoGet video : KuaiShouVideoGets) {
  105. count++;
  106. if (count < 10) {
  107. photoIds.add(video.getPhotoId());
  108. statdateMap.put(video.getPhotoId(), video.getStatDate());
  109. } else {
  110. photoIds.add(video.getPhotoId());
  111. statdateMap.put(video.getPhotoId(), video.getStatDate());
  112. dateList.add(photoIds);
  113. photoIds = new JSONArray();
  114. count = 0;
  115. }
  116. }
  117. dateList.add(photoIds);
  118. kuaishouVideoRelateCreativesService.videoRelateCreatives(9743746L, dateList, statdateMap);
  119. }*/
  120. }
  121. @Test
  122. public void loadKuaishouCookie() {
  123. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  124. if (list != null && !list.isEmpty()) {
  125. int i = 0;
  126. for (BindAccountLogin login : list) {
  127. if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
  128. kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
  129. i++;
  130. }
  131. }
  132. }
  133. }
  134. static ExecutorService executorService = null;
  135. static CountDownLatch countDownLatch = null;
  136. @Test
  137. public void deleteKuaishouComment() {
  138. Long start = System.currentTimeMillis();
  139. List<BindAccountLogin> loginList = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  140. if (loginList != null && !loginList.isEmpty()) {
  141. executorService = Executors.newFixedThreadPool(5);
  142. countDownLatch = new CountDownLatch(loginList.size());
  143. loginList.forEach(login -> executorService.submit(() -> {
  144. try {
  145. kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
  146. } catch (Exception e) {
  147. log.error(e.getMessage(), e);
  148. } finally {
  149. countDownLatch.countDown();
  150. }
  151. }));
  152. try {
  153. countDownLatch.await();
  154. } catch (InterruptedException e) {
  155. e.printStackTrace();
  156. }
  157. Long end = System.currentTimeMillis();
  158. log.info("快手删评论所用时长:{}毫秒", end - start);
  159. }
  160. }
  161. @Test
  162. public void testLoadBytedanceData() {
  163. List<UserAllocation> allocations = allocationService.getByParams(633L, null, 0);
  164. if (null != allocations && !allocations.isEmpty()) {
  165. for (UserAllocation allocation : allocations) {
  166. CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
  167. String startDate = "2020-11-10";
  168. String endDate = "2020-11-10";
  169. reportService.getAdvertiserReport(token, DateUtils.parseDate(startDate, "yyyy-MM-dd"), DateUtils.parseDate(endDate, "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
  170. }
  171. }
  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. 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. bytedanceReportMaterialDailyMapper.updateImageReportCode();
  387. bytedanceReportMaterialDailyMapper.updateImageReportProjectId();
  388. bytedanceReportMaterialDailyMapper.updateImageReportProjectName();
  389. bytedanceReportMaterialDailyMapper.updateImageReportPlaneId();
  390. bytedanceReportMaterialDailyMapper.updateImageReportPlaneName();
  391. }
  392. @Resource
  393. private BytedanceReportMaterialDailyMapper bytedanceReportMaterialDailyMapper;
  394. private void load12AccountData(CtopOauthToken token) {
  395. reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-10-01", "yyyy-MM-dd"), DateUtils.parseDate("2020-10-31", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  396. reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-11-01", "yyyy-MM-dd"), DateUtils.parseDate("2020-11-30", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  397. reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-12-01", "yyyy-MM-dd"), DateUtils.parseDate("2020-12-31", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  398. }
  399. private void load12Data(CtopOauthToken token) {
  400. bytedanceReportService.bytedanceMaterialReport(token, "2020-10-11", "2020-10-13");
  401. bytedanceReportService.bytedanceMaterialReport(token, "2020-10-14", "2020-10-16");
  402. bytedanceReportService.bytedanceMaterialReport(token, "2020-10-17", "2020-10-19");
  403. bytedanceReportService.bytedanceMaterialReport(token, "2020-10-20", "2020-10-21");
  404. }
  405. @Autowired
  406. private IKuaishouVideoEtlInfoService kuaishouVideoEtlInfoService;
  407. @Test
  408. public void etlKuaishouData() {
  409. String dateString = "2021-01-05";
  410. Date startDate = DateUtils.parseDate(dateString, "yyyy-MM-dd");
  411. for (int i = 0; i <= 10; i++) {
  412. Date getDate = DateUtils.addDay(startDate, i);
  413. kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
  414. bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
  415. }
  416. }
  417. @Autowired
  418. private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
  419. @Test
  420. public void loadBytedanceVideo() {
  421. CtopOauthToken token = tokenService.getTokenByAccountId(1673731601820686L);
  422. for (int i = 15; i < 60; i++) {
  423. reportService.getAdvertiserReport(token, DateUtils.addDay(new Date(), -i), DateUtils.addDay(new Date(), -i), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  424. }
  425. }
  426. @Test
  427. public void loadKuaishouVideo() {
  428. Date date = new Date();
  429. CtopOauthToken token = tokenService.getTokenByAccountId(9556344L);
  430. // kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, new Date(), new Date(), null, null);
  431. kuaishouInterfaceService.getVideoList(token, DateUtils.formatDate(DateUtils.addDay(date, -5)), DateUtils.formatDate(date));
  432. // 获取图片信息数据
  433. // kuaishouInterfaceService.getImageList(token, DateUtils.getNowDate("yyyy-MM-dd"));
  434. }
  435. @Autowired
  436. IRuleByteDanceAccountService ruleByteDanceAccountService;
  437. @Test
  438. public void cleanRuleDataAccount() {
  439. List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
  440. for (CtopOauthToken oauthToken : tokens) {
  441. ruleKuaiShouPlanService.cleanRuleDataTarget(oauthToken.getAccountId(), 1);
  442. }
  443. }
  444. @Autowired
  445. IAiKuaishouNewCreateCampaign aiKuaishouNewCreateCampaign;
  446. @Autowired
  447. private IAiKuaishouAccountTargetTemplateService aiKuaishouAccountTargetTemplateService;
  448. @Test
  449. public void createPlan() {
  450. List<AiKuaishouAccountTargetTemplate> accountTargetTemplates = aiKuaishouAccountTargetTemplateService.getAllEffectTemplate();
  451. if (null == accountTargetTemplates || accountTargetTemplates.isEmpty()) {
  452. return;
  453. }
  454. accountTargetTemplates.forEach(targetTemplate -> aiKuaishouNewCreateCampaign.kuaishouAiAdsNewMaterialCreativity(targetTemplate));
  455. }
  456. @Test
  457. public void testCreatePlan() {
  458. // List<AiKuaishouAccountTargetTemplate> accountTargetTemplates = aiKuaishouAccountTargetTemplateService.getAllEffectTemplate();
  459. // if (null == accountTargetTemplates || accountTargetTemplates.isEmpty()) {
  460. // return;
  461. // }
  462. // for (AiKuaishouAccountTargetTemplate template:accountTargetTemplates){
  463. // if(template.getAccountId()!=9556344L){
  464. // AiKuaishouAccountTargetTemplate accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getByAccountId(template.getAccountId());
  465. // aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2,50);
  466. // }
  467. // }
  468. /**
  469. * 120002
  470. * 150001
  471. * 150002
  472. * 150003
  473. * 150004
  474. */
  475. AiKuaishouAccountTargetTemplate accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getById(120002);
  476. aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2, 250);
  477. accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getById(150001);
  478. aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2, 250);
  479. accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getById(150002);
  480. aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2, 250);
  481. accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getById(150003);
  482. aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2, 250);
  483. accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getById(150004);
  484. aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2, 250);
  485. }
  486. @Test
  487. public void testLoadBytedanceDataV2() {
  488. List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
  489. countDownLatch = new CountDownLatch(tokens.size());
  490. for(int i=2;i<20;i++){
  491. String statDate= DateUtils.formatDate(DateUtils.addDay(new Date(), -i));
  492. tokens.forEach(token -> bytedanceVideoReportService.pullVideoReport(token, statDate, statDate, 1));
  493. }
  494. }
  495. @Test
  496. public void checkBytedanceReport() {
  497. CtopOauthToken token = tokenService.getTokenByAccountId(1678959391271949L);
  498. String startDate = "2021-01-01 00:00:00";
  499. String endDate = "2021-01-31 00:00:00";
  500. bytedanceReportService.checkoutData(token, startDate, endDate);
  501. }
  502. @Test
  503. public void etlKuaishouProjectData() {
  504. CtopOauthToken token = tokenService.getTokenByAccountId(1660666858777607L);
  505. reportService.getAdvertiserPlanReport(token, DateUtils.parseDate("2021-01-25", "yyyy-MM-dd"), DateUtils.parseDate("2021-01-25", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  506. }
  507. @Autowired
  508. IBytedanceVideoReportService bytedanceVideoReportService;
  509. @Test
  510. public void etlBytedanceVideoReport() {
  511. // for (int i = 1; i <= 62; i++) {
  512. // etlBytedanceVideo(DateUtils.formatDate(DateUtils.addDay(new Date(), -i)));
  513. // }
  514. etlBytedanceVideo("2021-02-03");
  515. }
  516. private void etlBytedanceVideo(String statDate) {
  517. List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
  518. executorService = Executors.newFixedThreadPool(10);
  519. countDownLatch = new CountDownLatch(tokens.size());
  520. tokens.forEach(token -> executorService.submit(() -> {
  521. try {
  522. bytedanceVideoReportService.pullVideoReport(token, statDate, statDate, 1);
  523. } catch (Exception e) {
  524. } finally {
  525. countDownLatch.countDown();
  526. }
  527. }));
  528. try {
  529. countDownLatch.await();
  530. } catch (InterruptedException e) {
  531. e.printStackTrace();
  532. }
  533. }
  534. @Autowired
  535. IETLReportBytedanceVideoService ietlReportBytedanceVideoService;
  536. @Test
  537. public void etlBytedanceVideoReportClean() {
  538. //for (int i = 1; i <= 1; i++) {
  539. // String statDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -i));
  540. ietlReportBytedanceVideoService.cleanETL("2020-12-31");
  541. //}
  542. }
  543. @Test
  544. public void etlBytedanceVideoReportClean1() {
  545. //executorService = Executors.newFixedThreadPool(31);
  546. //countDownLatch = new CountDownLatch(31);
  547. for (int i = 3; i <= 31; i++) {
  548. String statDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -i));
  549. ietlReportBytedanceVideoService.cleanETL(statDate);
  550. }
  551. }
  552. }