SampleTest.java 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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.service.IBindAccountLoginService;
  5. import cn.com.ctop.common.module.service.ICtopOauthTokenService;
  6. import cn.com.ctop.common.module.utils.CtopAdConstant;
  7. import cn.com.ctop.common.module.utils.HttpUtils;
  8. import cn.com.ctop.crawler.modules.pangolin.entity.PangolinApp;
  9. import cn.com.ctop.crawler.modules.pangolin.service.PangolinAppService;
  10. import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService;
  11. import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService;
  12. import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
  13. import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
  14. import cn.com.ctop.toutiao.modules.material.service.IByteDanceCampaignService;
  15. import cn.com.ctop.toutiao.modules.material.vo.BytedanceCampaignEditVo;
  16. import cn.com.ctop.toutiao.modules.report.service.IReportService;
  17. import com.alibaba.fastjson.JSONObject;
  18. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  19. import lombok.extern.slf4j.Slf4j;
  20. import org.jeecg.common.util.DateUtils;
  21. import org.jeecg.modules.ctop.entity.KuaishouEffectVideoInfo;
  22. import org.jeecg.modules.ctop.service.IKuaishouEffectVideoInfoService;
  23. import org.junit.Test;
  24. import org.junit.runner.RunWith;
  25. import org.springframework.beans.factory.annotation.Autowired;
  26. import org.springframework.boot.test.context.SpringBootTest;
  27. import org.springframework.test.context.junit4.SpringRunner;
  28. import java.util.HashMap;
  29. import java.util.List;
  30. import java.util.concurrent.CountDownLatch;
  31. import java.util.concurrent.ExecutorService;
  32. import java.util.concurrent.Executors;
  33. @RunWith(SpringRunner.class)
  34. @SpringBootTest
  35. @Slf4j
  36. public class SampleTest {
  37. @Autowired
  38. private ICtopOauthTokenService oauthTokenService;
  39. @Autowired
  40. private IByteDanceAdvertiserDataService advertiserDataService;
  41. @Autowired
  42. private IReportService reportService;
  43. @Test
  44. public void loadBytedanceCampaignData() {
  45. // List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
  46. // tokens.forEach(token -> campaignService.getAdvertiserCampaign(token, null, null));
  47. // campaignService.createCampaign(1649600126891015L,"测试广告组123",null,"BUDGET_MODE_DAY",15000,"APP",null);
  48. // campaignService.getAdvertiserCampaign(token, null, null);
  49. campaignService.updateCampaignStatus(1649600126891015L,"1673352811480076,1673351071217708","enable");
  50. BytedanceCampaignEditVo vo = new BytedanceCampaignEditVo();
  51. vo.setAccountId(1649600126891015L);
  52. vo.setId(1673352811480076L);
  53. vo.setCampaignName("咩哈哈哈哈哈");
  54. vo.setBudget(10000);
  55. campaignService.updateCampaign(vo);
  56. }
  57. @Autowired
  58. private IBindAccountLoginService bindAccountLoginService;
  59. @Autowired
  60. private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
  61. @Test
  62. public void kuaishouLogin() {
  63. Long start = System.currentTimeMillis();
  64. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  65. if (list != null && !list.isEmpty()) {
  66. for (BindAccountLogin login : list) {
  67. if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
  68. kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
  69. }
  70. }
  71. }
  72. Long end = System.currentTimeMillis();
  73. log.info("总用时:{}毫秒", end - start);
  74. }
  75. static ExecutorService executorService = Executors.newFixedThreadPool(10);;
  76. static CountDownLatch countDownLatch = null;
  77. @Test
  78. public void kuaishouCommentDelete() {
  79. Long start = System.currentTimeMillis();
  80. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  81. if (list != null && !list.isEmpty()) {
  82. countDownLatch = new CountDownLatch(list.size());
  83. list.forEach(login -> {
  84. executorService.submit(() -> {
  85. try {
  86. if (null != login.getCookie() && !"".equals(login.getCookie().trim())) {
  87. kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
  88. }
  89. } catch (Exception e) {
  90. } finally {
  91. countDownLatch.countDown();
  92. }
  93. });
  94. });
  95. }
  96. try {
  97. countDownLatch.await();
  98. } catch (InterruptedException e) {
  99. e.printStackTrace();
  100. }
  101. Long end = System.currentTimeMillis();
  102. log.info("总用时:{}毫秒", end - start);
  103. }
  104. @Autowired
  105. private PangolinLoginService pangolinLoginService;
  106. @Autowired
  107. private PangolinCrawlerService pangolinCrawlerService;
  108. @Autowired
  109. private PangolinAppService pangolinAppService;
  110. @Test
  111. public void testPangolinLogin() {
  112. QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
  113. queryWrapper.eq("login_type", "pangolin");
  114. queryWrapper.eq("status", 1);
  115. List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
  116. if (list != null && !list.isEmpty()) {
  117. for (BindAccountLogin login : list) {
  118. if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
  119. pangolinLoginService.pangolinLogin(login.getAccountName(), login.getPassword());
  120. }
  121. }
  122. }
  123. }
  124. @Test
  125. public void testPangolinData() {
  126. QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
  127. queryWrapper.eq("login_type", "pangolin");
  128. queryWrapper.eq("status", 1);
  129. queryWrapper.isNotNull("cookie");
  130. List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
  131. if (list != null && !list.isEmpty()) {
  132. for (BindAccountLogin bindAccountLogin : list) {
  133. pangolinCrawlerService.getChannelList(bindAccountLogin);
  134. pangolinCrawlerService.getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1);
  135. pangolinCrawlerService.getCheckList(bindAccountLogin);
  136. QueryWrapper<PangolinApp> queryWrapper1 = new QueryWrapper<>();
  137. queryWrapper1.eq("account_name", bindAccountLogin.getAccountName());
  138. List<PangolinApp> appList = pangolinAppService.list(queryWrapper1);
  139. if (appList != null && !appList.isEmpty()) {
  140. appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getAppId()));
  141. }
  142. }
  143. }
  144. }
  145. @Autowired
  146. private IByteDanceCampaignService campaignService;
  147. @Test
  148. public void testGetCampaign(){
  149. CtopOauthToken token = oauthTokenService.getOauthTokenByAccountId("1649600126891015");
  150. campaignService.getAdvertiserCampaign(token,"1672261893872756",null);
  151. }
  152. @Autowired
  153. private IKuaishouEffectVideoInfoService effectVideoInfoService;
  154. @Test
  155. public void loadKuaishouEffectVideoInfo(){
  156. List<KuaishouEffectVideoInfo>videoInfos = effectVideoInfoService.list();
  157. for (KuaishouEffectVideoInfo video:videoInfos) {
  158. if(null!=video.getSignature()&&!"".equals(video.getSignature())){
  159. // effectVideoInfoService.updateFinalCostDateBySignature(video.getSignature());
  160. // effectVideoInfoService.updateInitialCostDateBySignature(video.getSignature());
  161. // effectVideoInfoService.updateTotalCostBySignature(video.getSignature());
  162. if(null==video.getTwoWeekCost()){
  163. effectVideoInfoService.updateTowWeekCostBySignature(video.getSignature());
  164. }
  165. }
  166. }
  167. }
  168. @Test
  169. public void getIndustryInfo(){
  170. String access_token = "cbdf6502c04978ae401cb92a64530fb73a8c7dbe";
  171. // 请求地址
  172. String url = "https://ad.oceanengine.com/open_api/2/tools/industry/get/";
  173. JSONObject jsonObject = HttpUtils.bytedanceGetRequest(access_token, url, new JSONObject());
  174. System.out.println(jsonObject.toJSONString());
  175. }
  176. }