SampleTest.java 8.3 KB

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