SampleTest.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  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.Check;
  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.entity.KuaiShouVideoGet;
  14. import cn.com.ctop.kuaishou.modules.batch.service.*;
  15. import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
  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.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.alibaba.fastjson.JSONArray;
  27. import lombok.extern.slf4j.Slf4j;
  28. import org.apache.catalina.User;
  29. import org.jeecg.common.util.DateUtils;
  30. import org.junit.Test;
  31. import org.junit.runner.RunWith;
  32. import org.openqa.selenium.By;
  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.Map;
  44. import java.util.concurrent.CountDownLatch;
  45. import java.util.concurrent.ExecutorService;
  46. import java.util.concurrent.Executors;
  47. import static org.jeecg.common.util.DateUtils.getAnotherDay;
  48. @RunWith(SpringRunner.class)
  49. @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
  50. @ActiveProfiles("wps")
  51. @Slf4j
  52. public class SampleTest {
  53. @Autowired
  54. private ICtopOauthTokenService oauthTokenService;
  55. @Autowired
  56. private IReportService reportService;
  57. @Autowired
  58. private IByteDanceAdvertiserDataService advertiserDataService;
  59. @Autowired
  60. private ICtopOauthTokenService tokenService;
  61. @Autowired
  62. private IKuaiShouVideoGetService videoGetService;
  63. @Autowired
  64. private IKuaishouVideoRelateCreativesService kuaishouVideoRelateCreativesService;
  65. @Autowired
  66. private IBindAccountLoginService bindAccountLoginService;
  67. @Autowired
  68. private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
  69. @Test
  70. public void loadBytedanceCreativeData() throws ParseException {
  71. List<KuaiShouVideoGet> KuaiShouVideoGets = videoGetService.selectPhotoIdsByAccountId(9743746L);
  72. if (!Check.isNull(KuaiShouVideoGets)) {
  73. JSONArray dateList = new JSONArray();
  74. JSONArray photoIds = new JSONArray();
  75. Map<String, Object> statdateMap = new HashMap<>();
  76. int count = 0;
  77. for (KuaiShouVideoGet video : KuaiShouVideoGets) {
  78. count++;
  79. if (count < 10) {
  80. photoIds.add(video.getPhotoId());
  81. statdateMap.put(video.getPhotoId(), video.getStatDate());
  82. } else {
  83. photoIds.add(video.getPhotoId());
  84. statdateMap.put(video.getPhotoId(), video.getStatDate());
  85. dateList.add(photoIds);
  86. photoIds = new JSONArray();
  87. count = 0;
  88. }
  89. }
  90. dateList.add(photoIds);
  91. kuaishouVideoRelateCreativesService.videoRelateCreatives(9743746L, dateList, statdateMap);
  92. }
  93. }
  94. @Test
  95. public void loadKuaishouCookie() {
  96. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  97. if (list != null && !list.isEmpty()) {
  98. int i = 0;
  99. for (BindAccountLogin login : list) {
  100. if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
  101. kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
  102. i++;
  103. }
  104. }
  105. }
  106. }
  107. static ExecutorService executorService = null;
  108. static CountDownLatch countDownLatch = null;
  109. @Test
  110. public void deleteKuaishouComment() {
  111. Long start = System.currentTimeMillis();
  112. List<BindAccountLogin> loginList = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  113. if (loginList != null && !loginList.isEmpty()) {
  114. executorService = Executors.newFixedThreadPool(5);
  115. countDownLatch = new CountDownLatch(loginList.size());
  116. loginList.forEach(login -> executorService.submit(() -> {
  117. try {
  118. kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
  119. } catch (Exception e) {
  120. log.error(e.getMessage(), e);
  121. } finally {
  122. countDownLatch.countDown();
  123. }
  124. }));
  125. try {
  126. countDownLatch.await();
  127. } catch (InterruptedException e) {
  128. e.printStackTrace();
  129. }
  130. Long end = System.currentTimeMillis();
  131. log.info("快手删评论所用时长:{}毫秒", end - start);
  132. }
  133. }
  134. @Autowired
  135. private IUserAllocationService allocationService;
  136. @Test
  137. public void testLoadBytedanceData() {
  138. List<UserAllocation> allocations = allocationService.getByParams(633L, null, 0);
  139. if (null != allocations && !allocations.isEmpty()) {
  140. for (UserAllocation allocation : allocations) {
  141. CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
  142. String startDate = "2020-11-10";
  143. String endDate = "2020-11-10";
  144. reportService.getAdvertiserReport(token, DateUtils.parseDate(startDate, "yyyy-MM-dd"), DateUtils.parseDate(endDate, "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
  145. }
  146. }
  147. System.out.println("任务结束");
  148. }
  149. @Test
  150. public void loadKuaishouPlanData() {
  151. Date getDate = DateUtils.addDay(new Date(), -1);
  152. //1:查询当日数据
  153. List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
  154. tokens.forEach(token -> kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token, getDate, getDate));
  155. }
  156. @Autowired
  157. private IBytedanceFundDailyService bytedanceFundDailyService;
  158. @Test
  159. public void loadFoudData() {
  160. List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
  161. for (CtopOauthToken token : tokens) {
  162. System.out.println(token.getAccountId() + "############################");
  163. for (int i = 20; i < 130; i++) {
  164. Date date = DateUtils.addDay(new Date(), -i);
  165. bytedanceFundDailyService.loadFundDataByPage(token, DateUtils.formatDate(date), DateUtils.formatDate(date), 1);
  166. System.out.println(i + "############################");
  167. }
  168. }
  169. }
  170. @Autowired
  171. private IKuaiShouHistoryReportTaskService reportTaskService;
  172. /**
  173. * 测试获取快手图片消耗数据任务
  174. */
  175. @Test
  176. public void loadKuaishouImageTask() {
  177. List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
  178. for (int i = 1; i < 130; i++) {
  179. Date getDate = DateUtils.addDay(new Date(), -i);
  180. String getDateStr = DateUtils.formatDate(getDate);
  181. tokens.forEach(token -> reportTaskService.createTask(token.getAccountId(), token.getAccessToken(), getDateStr, getDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_DAILY));
  182. }
  183. }
  184. @Autowired
  185. private IKuaiShouDailyReportTaskService dailyReportTaskService;
  186. /**
  187. * 测试获取快手图片消耗数据入库
  188. */
  189. @Test
  190. public void loadKuaishouImageTaskFile() {
  191. String nowDate = DateUtils.getDate("yyyy-MM-dd");
  192. List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
  193. for (int i = 1; i < 15; i++) {
  194. String statDate = getAnotherDay("yyyy-MM-dd", nowDate, -i);
  195. tokens.forEach(token -> dailyReportTaskService.getTaskList(token.getAccountId(), token.getAccessToken(), statDate));
  196. }
  197. // 查询快手token
  198. }
  199. @Test
  200. public void testLoadBytedanceImageData() {
  201. List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
  202. countDownLatch = new CountDownLatch(tokens.size());
  203. executorService = Executors.newFixedThreadPool(8);
  204. tokens.forEach(token -> executorService.submit(() -> {
  205. try {
  206. advertiserDataService.getMaterialList(token);
  207. } catch (Exception e) {
  208. } finally {
  209. countDownLatch.countDown();
  210. }
  211. }));
  212. try {
  213. countDownLatch.await();
  214. } catch (InterruptedException e) {
  215. e.printStackTrace();
  216. }
  217. System.out.println("素材数据获取完成");
  218. }
  219. @Autowired
  220. private IKuaishouReportDailyAgentService kuaishouReportDailyAgentService;
  221. @Test
  222. public void testData() {
  223. Date date = new Date();
  224. List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
  225. executorService = Executors.newFixedThreadPool(10);
  226. countDownLatch = new CountDownLatch(tokens.size());
  227. tokens.forEach(token -> executorService.submit(() -> {
  228. try {
  229. reportService.getAdvertiserPlanRuleData(token, date, date, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  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. }
  241. @Test
  242. public void testData11() {
  243. CtopOauthToken token = tokenService.getTokenByAccountId(9556344L);
  244. int dimeDiff = 5;
  245. Date now = new Date();
  246. String startTime = DateUtils.formatDate("2021-01-11 18:25:00");
  247. String endTime = DateUtils.formatDate(now, "2021-01-11 18:35:00");
  248. kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startTime, endTime);
  249. }
  250. @Test
  251. public void loadKuaishouAgentData() {
  252. kuaishouReportDailyAgentService.loginAgent();
  253. try {
  254. for (int i = 1; i < 30; i++) {
  255. kuaishouReportDailyAgentService.getAccount(i);
  256. }
  257. } catch (Exception e) {
  258. e.printStackTrace();
  259. }
  260. }
  261. @Test
  262. public void loadKuaishouData() {
  263. Date getDate = DateUtils.addDay(new Date(), -1);
  264. //1:查询当日数据
  265. List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
  266. for (CtopOauthToken token : tokens) {
  267. kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token, getDate, getDate);
  268. }
  269. }
  270. @Autowired
  271. private IBytedanceReportService bytedanceReportService;
  272. @Test
  273. public void loadBytedanceVideoReportData() {
  274. Date getDate = DateUtils.addDay(new Date(), -1);
  275. String date = DateUtils.formatDate(getDate);
  276. List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
  277. for (CtopOauthToken token : tokens) {
  278. bytedanceReportService.bytedanceVideoMaterialReport(token, date, date);
  279. }
  280. }
  281. @Test
  282. public void loadKuaishouHourlyReportData() {
  283. Date getDate = new Date();
  284. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
  285. String hour = simpleDateFormat.format(getDate);
  286. if ("00".equals(hour)) {
  287. getDate = DateUtils.addDay(getDate, -1);
  288. }
  289. //1:查询当日数据
  290. List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
  291. Date finalGetDate = getDate;
  292. tokens.forEach(token -> kuaishouInterfaceService.getAdvertiserReportHourly(token, finalGetDate, finalGetDate));
  293. }
  294. @Autowired
  295. private IKuaishouInterfaceService kuaishouInterfaceService;
  296. @Test
  297. public void loadKuaishouGroupData() throws ParseException {
  298. Date endDate = new Date();
  299. String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(endDate), -1);
  300. SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
  301. Date startDate = sim.parse(anotherDay);
  302. CtopOauthToken token = tokenService.getTokenByAccountId(7087890L);
  303. kuaishouInterfaceService.getGroupList(token, startDate, endDate);
  304. }
  305. @Test
  306. public void loadAccountData() {
  307. // List<UserAllocation> allocations = allocationService.getByParams(776L,null,0);
  308. // for (UserAllocation allocation:allocations) {
  309. CtopOauthToken token = tokenService.getTokenByAccountId(93238965516L);
  310. for (int i = 92; i < 100; i++) {
  311. Date getDate = DateUtils.addDay(new Date(), -i);
  312. reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  313. }
  314. // }
  315. }
  316. @Autowired
  317. private IWechatCheckinDataService wechatCheckinDataService;
  318. @Autowired
  319. private IWechatUserListService wechatUserInfoService;
  320. @Autowired
  321. private IWechatNoListService wechatNoListService;
  322. @Test
  323. public void getData() {
  324. //汇创 人员
  325. // wechatUserInfoService.getUserList();
  326. // //考勤记录
  327. // wechatCheckinDataService.getCheckinData("2020-11-01 00:00:00", "2020-12-01 23:59:59");
  328. //异常记录
  329. // wechatNoListService.getNoDateByNo("2020-11-01 00:00:00", "2020-12-01 23:59:59", "0");
  330. //优容
  331. wechatUserInfoService.getYRUserList();
  332. wechatCheckinDataService.getYRCheckinData("2020-11-01 00:00:00", "2020-11-30 23:59:59");
  333. wechatNoListService.getNoDateByNo("2020-11-01 00:00:00", "2020-12-01 23:59:59", "1");
  334. }
  335. @Autowired
  336. private IKuaiShouCommentService kuaiShouCommentService;
  337. @Test
  338. public void kuaishouDeleteComment() {
  339. kuaiShouCommentService.shieldComment(8018853L);
  340. }
  341. @Autowired
  342. private IByteDanceVideoReportDailyService videoReportDailyService;
  343. @Test
  344. public void formatVideoReportData() {
  345. for (int i = 1; i < 45; i++) {
  346. Date getDate = DateUtils.addDay(new Date(), -i);
  347. String date = DateUtils.formatDate(getDate);
  348. videoReportDailyService.videoInfoList(date, date);
  349. }
  350. }
  351. @Autowired
  352. private IRuleKuaiShouPlanService ruleKuaiShouPlanService;
  353. @Autowired
  354. private IBytedanceAccountReportTaskRecordService reportTaskRecordService;
  355. @Test
  356. public void execute() {
  357. List<UserAllocation> allocations = allocationService.listByMediaId("3",0);
  358. for (UserAllocation allocation:allocations) {
  359. BytedanceAccountReportTaskRecord reportTaskRecord1 = new BytedanceAccountReportTaskRecord(allocation.getAccountId(),"2020-10-01","2020-10-31");
  360. reportTaskRecordService.save(reportTaskRecord1);
  361. BytedanceAccountReportTaskRecord reportTaskRecord2 = new BytedanceAccountReportTaskRecord(allocation.getAccountId(),"2020-11-01","2020-11-30");
  362. reportTaskRecordService.save(reportTaskRecord2);
  363. BytedanceAccountReportTaskRecord reportTaskRecord3 = new BytedanceAccountReportTaskRecord(allocation.getAccountId(),"2020-12-01","2020-12-31");
  364. reportTaskRecordService.save(reportTaskRecord3);
  365. }
  366. }
  367. @Test
  368. public void loadBDAccoutData() {
  369. // List<BytedanceAccountReportTaskRecord> records = reportTaskRecordService.listByParams(1,"ACCOUNT_DAILY");
  370. List<BytedanceAccountReportTaskRecord> records = reportTaskRecordService.listByParams(100,"ACCOUNT_DAILY");
  371. executorService = Executors.newFixedThreadPool(8);
  372. countDownLatch = new CountDownLatch(records.size());
  373. records.forEach(record -> executorService.submit(() -> {
  374. try {
  375. // reportService.getAdvertiserReport(record, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  376. // log.info("账户数据获取完成:account:{},时间:{}-{}",record.getAccountId(),record.getStartDate(),record.getEndDate());
  377. bytedanceReportService.bytedanceMaterialReportV2(record);
  378. log.info("素材数据获取完成:account:{},时间:{}-{}",record.getAccountId(),record.getStartDate(),record.getEndDate());
  379. } catch (Exception e) {
  380. } finally {
  381. countDownLatch.countDown();
  382. }
  383. }));
  384. try {
  385. countDownLatch.await();
  386. } catch (InterruptedException e) {
  387. e.printStackTrace();
  388. }
  389. System.out.println("数据获取完成");
  390. bytedanceReportMaterialDailyMapper.updateImageReportCode();
  391. bytedanceReportMaterialDailyMapper.updateImageReportProjectId();
  392. bytedanceReportMaterialDailyMapper.updateImageReportProjectName();
  393. bytedanceReportMaterialDailyMapper.updateImageReportPlaneId();
  394. bytedanceReportMaterialDailyMapper.updateImageReportPlaneName();
  395. }
  396. @Resource
  397. private BytedanceReportMaterialDailyMapper bytedanceReportMaterialDailyMapper;
  398. private void load12AccountData(CtopOauthToken token) {
  399. reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-10-01", "yyyy-MM-dd"), DateUtils.parseDate("2020-10-31", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  400. reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-11-01", "yyyy-MM-dd"), DateUtils.parseDate("2020-11-30", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  401. reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-12-01", "yyyy-MM-dd"), DateUtils.parseDate("2020-12-31", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  402. }
  403. private void load12Data(CtopOauthToken token) {
  404. // bytedanceReportService.bytedanceMaterialReport(token, "2020-10-01", "2020-10-05");
  405. // bytedanceReportService.bytedanceMaterialReport(token, "2020-10-06", "2020-10-10");
  406. // bytedanceReportService.bytedanceMaterialReport(token, "2020-10-11", "2020-10-15");
  407. // bytedanceReportService.bytedanceMaterialReport(token, "2020-10-16", "2020-10-20");
  408. // bytedanceReportService.bytedanceMaterialReport(token, "2020-10-21", "2020-10-25");
  409. // bytedanceReportService.bytedanceMaterialReport(token, "2020-10-26", "2020-10-31");
  410. bytedanceReportService.bytedanceMaterialReport(token, "2020-10-03", "2020-10-04");
  411. }
  412. @Autowired
  413. private IKuaishouVideoEtlInfoService kuaishouVideoEtlInfoService;
  414. @Test
  415. public void etlKuaishouData() {
  416. String dateString = "2021-01-05";
  417. Date startDate = DateUtils.parseDate(dateString, "yyyy-MM-dd");
  418. for (int i = 0; i <= 10; i++) {
  419. Date getDate = DateUtils.addDay(startDate, i);
  420. kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
  421. bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
  422. }
  423. }
  424. @Autowired
  425. private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
  426. @Test
  427. public void loadBytedanceVideo() {
  428. CtopOauthToken token = tokenService.getTokenByAccountId(1673731601820686L);
  429. for (int i = 15; i < 60; i++) {
  430. reportService.getAdvertiserReport(token, DateUtils.addDay(new Date(), -i), DateUtils.addDay(new Date(), -i), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  431. }
  432. }
  433. @Test
  434. public void loadKuaishouVideo() {
  435. Date date = new Date();
  436. CtopOauthToken token = tokenService.getTokenByAccountId(9556344L);
  437. // kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, new Date(), new Date(), null, null);
  438. kuaishouInterfaceService.getVideoList(token, DateUtils.formatDate(DateUtils.addDay(date, -5)), DateUtils.formatDate(date));
  439. // 获取图片信息数据
  440. // kuaishouInterfaceService.getImageList(token, DateUtils.getNowDate("yyyy-MM-dd"));
  441. }
  442. @Autowired
  443. IRuleByteDanceAccountService ruleByteDanceAccountService;
  444. @Test
  445. public void cleanRuleDataAccount() {
  446. List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
  447. for (CtopOauthToken oauthToken : tokens) {
  448. ruleKuaiShouPlanService.cleanRuleDataTarget(oauthToken.getAccountId(), 1);
  449. }
  450. }
  451. @Autowired
  452. IAiKuaishouNewCreateCampaign aiKuaishouNewCreateCampaign;
  453. @Autowired
  454. private IAiKuaishouAccountTargetTemplateService aiKuaishouAccountTargetTemplateService;
  455. @Test
  456. public void createPlan() {
  457. List<AiKuaishouAccountTargetTemplate> accountTargetTemplates = aiKuaishouAccountTargetTemplateService.getAllEffectTemplate();
  458. if (null == accountTargetTemplates || accountTargetTemplates.isEmpty()) {
  459. return;
  460. }
  461. accountTargetTemplates.forEach(targetTemplate -> aiKuaishouNewCreateCampaign.kuaishouAiAdsNewMaterialCreativity(targetTemplate));
  462. }
  463. @Test
  464. public void testCreatePlan() {
  465. // List<AiKuaishouAccountTargetTemplate> accountTargetTemplates = aiKuaishouAccountTargetTemplateService.getAllEffectTemplate();
  466. // if (null == accountTargetTemplates || accountTargetTemplates.isEmpty()) {
  467. // return;
  468. // }
  469. AiKuaishouAccountTargetTemplate accountTargetTemplate1 = aiKuaishouAccountTargetTemplateService.getById(30002);
  470. aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate1);
  471. AiKuaishouAccountTargetTemplate accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getById(30001);
  472. aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2);
  473. }
  474. @Test
  475. public void etlKuaishouProjectData(){
  476. String dateString = "2020-03-17";
  477. Date startDate = DateUtils.parseDate(dateString,"yyyy-MM-dd");
  478. for(int i=0;i<=365;i++){
  479. Date getDate = DateUtils.addDay(startDate,i);
  480. kuaishouVideoEtlInfoService.etlKuaishouVideoInfoGroupByProjectId(getDate);
  481. }
  482. }
  483. }