123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- package org.jeecg;
- import cn.com.ctop.common.module.entity.BindAccountLogin;
- import cn.com.ctop.common.module.entity.CtopOauthToken;
- import cn.com.ctop.common.module.service.IBindAccountLoginService;
- import cn.com.ctop.common.module.service.ICtopOauthTokenService;
- import cn.com.ctop.common.module.utils.CtopAdConstant;
- import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
- import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
- import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
- import cn.com.ctop.toutiao.modules.report.service.IReportService;
- import lombok.extern.slf4j.Slf4j;
- import org.jeecg.common.util.DateUtils;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.boot.test.context.SpringBootTest;
- import org.springframework.test.context.junit4.SpringRunner;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.concurrent.CountDownLatch;
- import java.util.concurrent.ExecutorService;
- import java.util.concurrent.Executors;
- @RunWith(SpringRunner.class)
- @SpringBootTest
- @Slf4j
- public class SampleTest {
- @Autowired
- private ICtopOauthTokenService oauthTokenService;
- @Autowired
- private IByteDanceAdvertiserDataService advertiserDataService;
- @Autowired
- private IBytedanceEffectVideoInfoService effectVideoInfoService;
- @Autowired
- private IReportService reportService;
- @Autowired
- private IBindAccountLoginService bindAccountLoginService;
- @Autowired
- private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
- @Test
- public void getBytedanceData(){
- CtopOauthToken token5 = oauthTokenService.getTokenByAccountId(1668362864699400L);
- for(int i=10;i<120;i++){
- Date date = DateUtils.addDay(new Date(), -i);
- reportService.getAdvertiserReport(token5,date,date,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
- }
- }
- @Test
- public void testOceanEngineJob() {
- List<CtopOauthToken>tokens = oauthTokenService.selectToutiaoToken();
- String date = DateUtils.addDay("2020-07-10",-2);
- tokens.forEach(token -> {
- // advertiserDataService.getAdvertiserCampaign(token,null,date);
- });
- }
- @Test
- public void loadEffectVideo(){
- String date = "2020-07-10";
- for(int i=0;i<150;i++){
- String getDate = DateUtils.addDay(date,i);
- effectVideoInfoService.loadEffectVideo(getDate);
- }
- }
- @Test
- public void kuaishouLogin() {
- Long start = System.currentTimeMillis();
- List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
- if (list != null && !list.isEmpty()) {
- for (BindAccountLogin login : list) {
- if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
- kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
- }
- }
- }
- Long end = System.currentTimeMillis();
- log.info("总用时:{}毫秒", end - start);
- }
- static ExecutorService executorService = null;
- static CountDownLatch countDownLatch = null;
- @Test
- public void kuaishouCommentDelete() {
- Long start = System.currentTimeMillis();
- List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
- if (list != null && !list.isEmpty()) {
- executorService = Executors.newFixedThreadPool(10);
- countDownLatch = new CountDownLatch(list.size());
- list.forEach(login -> {
- executorService.submit(() -> {
- try {
- if (null != login.getCookie() && !"".equals(login.getCookie().trim())) {
- kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
- }
- } catch (Exception e) {
- } finally {
- countDownLatch.countDown();
- }
- });
- });
- }
- try {
- countDownLatch.await();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- Long end = System.currentTimeMillis();
- log.info("总用时:{}毫秒", end - start);
- }
- }
|