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.entity.UserAllocation; import cn.com.ctop.common.module.service.IBindAccountLoginService; import cn.com.ctop.common.module.service.ICtopOauthTokenService; import cn.com.ctop.common.module.service.IUserAllocationService; import cn.com.ctop.common.module.utils.CtopAdConstant; import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService; import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService; import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService; 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.ActiveProfiles; 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(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("wps") @Slf4j public class SampleTest { @Autowired private ICtopOauthTokenService oauthTokenService; @Autowired private IKuaishouReportDailyAgentService kuaishouReportDailyAgentService; @Autowired private IKuaiShouDailyAgentService kuaiShouDailyAgentService; @Autowired private IReportService reportService; @Test public void loadBytedanceCreativeData() { String accountIdString = "1661556811389966,1650504410207245,1652711697337351,1652711697724429,1650504410574859,1668459522250759"; String[] accountIds = accountIdString.split(","); for(int i=0;i list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY,1); if(list!=null&&!list.isEmpty()){ int i=0; for (BindAccountLogin login:list) { if(null==login.getCookie()||"".equals(login.getCookie().trim())){ if(i>5){ break; } kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login); i++; } } } } static ExecutorService executorService = null; //线程计数器 static CountDownLatch countDownLatch = null; @Test public void deleteKuaishouComment(){ Long start = System.currentTimeMillis(); ListloginList = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY,1); if (loginList != null && !loginList.isEmpty()) { executorService = Executors.newFixedThreadPool(5); countDownLatch = new CountDownLatch(loginList.size()); loginList.forEach(login -> executorService.submit(()->{ try { kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(),login); }catch (Exception e){ log.error(e.getMessage(),e); }finally { countDownLatch.countDown(); } })); try { countDownLatch.await(); } catch (InterruptedException e) { e.printStackTrace(); } Long end = System.currentTimeMillis(); log.info("快手删评论所用时长:{}毫秒",end-start); } } @Autowired private IUserAllocationService allocationService; @Test public void testLoadBytedanceData() { Listallocations = allocationService.getByParams(435L,null,0); for (UserAllocation allocation:allocations) { for(int i=2;i<10;i++){ CtopOauthToken token = oauthTokenService.getTokenByAccountId(allocation.getAccountId()); Date getDate = DateUtils.addDay(new Date(),-i); reportService.getAdvertiserReport(token,getDate,getDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY); } } } @Test public void loadKuaishouAgentData() { // for(int i=0;i<20;i++){ // String currentDate = DateUtils.formatDate(DateUtils.addDay(new Date(),-i)); // kuaishouReportDailyAgentService.getReport(currentDate,DateUtils.getNowDate("yyyy-MM-dd")); // } // kuaishouReportDailyAgentService.loginAgent(); try { for(int i=1;i<30;i++){ kuaishouReportDailyAgentService.getAccount(i); } }catch (Exception e){ e.printStackTrace(); } // String currentDate = D ateUtils.formatDate(DateUtils.addDay(new Date(),-1)); // kuaishouReportDailyAgentService.getReport(currentDate,DateUtils.getNowDate("yyyy-MM-dd")); } }