SampleTest.java 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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.batch.service.IKuaishouInterfaceService;
  13. import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
  14. import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
  15. import cn.com.ctop.toutiao.modules.material.service.IByteDanceCampaignService;
  16. import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
  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.jeecg.modules.ctop.service.IProjectMemberService;
  24. import org.jeecg.modules.ctop.service.IRuleEngineService;
  25. import org.junit.Test;
  26. import org.junit.runner.RunWith;
  27. import org.kie.api.runtime.KieSession;
  28. import org.springframework.beans.factory.annotation.Autowired;
  29. import org.springframework.boot.test.context.SpringBootTest;
  30. import org.springframework.test.context.junit4.SpringRunner;
  31. import javax.annotation.Resource;
  32. import java.util.HashMap;
  33. import java.util.List;
  34. import java.util.Map;
  35. import java.util.concurrent.CountDownLatch;
  36. import java.util.concurrent.ExecutorService;
  37. import java.util.concurrent.Executors;
  38. @RunWith(SpringRunner.class)
  39. @SpringBootTest
  40. @Slf4j
  41. public class SampleTest {
  42. @Autowired
  43. private ICtopOauthTokenService oauthTokenService;
  44. @Autowired
  45. private IByteDanceAdvertiserDataService advertiserDataService;
  46. @Autowired
  47. private IByteDanceCreativeService creativeService;
  48. @Autowired
  49. private IKuaishouInterfaceService iKuaishouInterfaceService;
  50. @Test
  51. public void loadBytedanceCreativeData() {
  52. /**
  53. *
  54. */
  55. CtopOauthToken token = oauthTokenService.getTokenByAccountId(23212L);
  56. iKuaishouInterfaceService.getCampaignList(token, null, null);
  57. // advertiserDataService.getMaterialList(token);
  58. }
  59. @Test
  60. public void test() {
  61. /**
  62. *
  63. */
  64. // CtopOauthToken token = oauthTokenService.getTokenByAccountId(23212L);
  65. // iKuaishouInterfaceService.getCampaignList(token,null,null);
  66. // advertiserDataService.getMaterialList(token);
  67. // HttpUtils.httpPostRequest()
  68. Map<String, Object> paramsMap = new HashMap<>();
  69. paramsMap.put("campaignType",2);
  70. String url = "https://ad.e.kuaishou.com/rest/dsp/control-panel/cover/list/actionBarText";
  71. String s = HttpUtils.httpGet(url, paramsMap, null);
  72. System.err.println(s);
  73. }
  74. @Autowired
  75. private IBindAccountLoginService bindAccountLoginService;
  76. @Autowired
  77. private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
  78. @Test
  79. public void kuaishouLogin() {
  80. Long start = System.currentTimeMillis();
  81. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  82. if (list != null && !list.isEmpty()) {
  83. for (BindAccountLogin login : list) {
  84. if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
  85. kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
  86. }
  87. }
  88. }
  89. Long end = System.currentTimeMillis();
  90. log.info("总用时:{}毫秒", end - start);
  91. }
  92. static ExecutorService executorService = Executors.newFixedThreadPool(10);
  93. ;
  94. static CountDownLatch countDownLatch = null;
  95. @Test
  96. public void kuaishouCommentDelete() {
  97. Long start = System.currentTimeMillis();
  98. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  99. if (list != null && !list.isEmpty()) {
  100. countDownLatch = new CountDownLatch(list.size());
  101. list.forEach(login -> {
  102. executorService.submit(() -> {
  103. try {
  104. if (null != login.getCookie() && !"".equals(login.getCookie().trim())) {
  105. kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
  106. }
  107. } catch (Exception e) {
  108. } finally {
  109. countDownLatch.countDown();
  110. }
  111. });
  112. });
  113. }
  114. try {
  115. countDownLatch.await();
  116. } catch (InterruptedException e) {
  117. e.printStackTrace();
  118. }
  119. Long end = System.currentTimeMillis();
  120. log.info("总用时:{}毫秒", end - start);
  121. }
  122. @Autowired
  123. private PangolinLoginService pangolinLoginService;
  124. @Autowired
  125. private PangolinCrawlerService pangolinCrawlerService;
  126. @Autowired
  127. private PangolinAppService pangolinAppService;
  128. @Test
  129. public void testPangolinLogin() {
  130. QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
  131. queryWrapper.eq("login_type", "pangolin");
  132. queryWrapper.eq("status", 1);
  133. List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
  134. if (list != null && !list.isEmpty()) {
  135. for (BindAccountLogin login : list) {
  136. if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
  137. pangolinLoginService.pangolinLogin(login.getAccountName(), login.getPassword());
  138. }
  139. }
  140. }
  141. }
  142. @Test
  143. public void testPangolinData() {
  144. QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
  145. queryWrapper.eq("login_type", "pangolin");
  146. queryWrapper.eq("status", 1);
  147. queryWrapper.isNotNull("cookie");
  148. List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
  149. if (list != null && !list.isEmpty()) {
  150. for (BindAccountLogin bindAccountLogin : list) {
  151. pangolinCrawlerService.getChannelList(bindAccountLogin);
  152. pangolinCrawlerService.getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1);
  153. pangolinCrawlerService.getCheckList(bindAccountLogin);
  154. QueryWrapper<PangolinApp> queryWrapper1 = new QueryWrapper<>();
  155. queryWrapper1.eq("account_name", bindAccountLogin.getAccountName());
  156. List<PangolinApp> appList = pangolinAppService.list(queryWrapper1);
  157. if (appList != null && !appList.isEmpty()) {
  158. appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getAppId()));
  159. }
  160. }
  161. }
  162. }
  163. @Autowired
  164. private IByteDanceCampaignService campaignService;
  165. @Test
  166. public void testGetCampaign() {
  167. CtopOauthToken token = oauthTokenService.getOauthTokenByAccountId("1649600126891015");
  168. campaignService.getAdvertiserCampaign(token, "1672261893872756", null);
  169. }
  170. @Autowired
  171. private IKuaishouEffectVideoInfoService effectVideoInfoService;
  172. @Test
  173. public void loadKuaishouEffectVideoInfo() {
  174. List<KuaishouEffectVideoInfo> videoInfos = effectVideoInfoService.list();
  175. for (KuaishouEffectVideoInfo video : videoInfos) {
  176. if (null != video.getSignature() && !"".equals(video.getSignature())) {
  177. effectVideoInfoService.updateFinalCostDateBySignature(video.getSignature());
  178. effectVideoInfoService.updateInitialCostDateBySignature(video.getSignature());
  179. effectVideoInfoService.updateTotalCostBySignature(video.getSignature());
  180. // effectVideoInfoService.updateTowWeekCostBySignature(video.getSignature());
  181. }
  182. }
  183. }
  184. @Test
  185. public void getIndustryInfo() {
  186. String access_token = "cbdf6502c04978ae401cb92a64530fb73a8c7dbe";
  187. // 请求地址
  188. String url = "https://ad.oceanengine.com/open_api/2/tools/industry/get/";
  189. JSONObject jsonObject = HttpUtils.bytedanceGetRequest(access_token, url, new JSONObject());
  190. System.out.println(jsonObject.toJSONString());
  191. }
  192. @Test
  193. public void loadImageInfo() throws Exception {
  194. List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
  195. for (CtopOauthToken token : tokens) {
  196. advertiserDataService.getImageByPage(token, null, 1);
  197. Thread.sleep(1000L);
  198. }
  199. }
  200. @Resource
  201. private KieSession kieSession;
  202. @Autowired
  203. private IRuleEngineService ruleEngineService;
  204. @Autowired
  205. private IProjectMemberService projectMemberService;
  206. @Test
  207. public void testLoadAccount() {
  208. String userId = "c3611c88d0c8414abd3d2ee2a5a0ee7a";
  209. List<Map<String, Object>> result = projectMemberService.getProjectAccountByUserId(userId);
  210. }
  211. }