SampleTest.java 26 KB

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