SampleTest.java 27 KB

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