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.crawler.modules.pangolin.entity.PangolinApp; import cn.com.ctop.crawler.modules.pangolin.service.PangolinAppService; import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService; import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService; import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyReportTaskService; import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService; import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService; import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService; import cn.com.ctop.toutiao.modules.report.service.IReportService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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 IBytedanceReportService bytedanceReportService; @Autowired private IByteDanceVideoReportDailyService byteDanceVideoReportDailyService; @Autowired private ICtopOauthTokenService oauthTokenService; @Autowired private IReportService reportService; @Autowired private IUserAllocationService userAllocationService; @Test public void testOceanEngineJob() { Listtokens = userAllocationService.getByProjectId(107L,null); Date startDate = DateUtils.getDate(); tokens.forEach(token -> { CtopOauthToken getToken = oauthTokenService.getTokenByAccountId(token.getAccountId()); reportService.getAdvertiserReport(getToken,startDate,startDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY); }); } @Autowired private IBindAccountLoginService bindAccountLoginService; @Autowired private IKuaishouWebInterfaceService kuaishouWebInterfaceService; @Test public void kuaishouLogin() { Long start = System.currentTimeMillis(); List 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 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); } @Autowired private PangolinLoginService pangolinLoginService; @Autowired private PangolinCrawlerService pangolinCrawlerService; @Autowired private PangolinAppService pangolinAppService; @Test public void testPangolinLogin() { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("login_type", "pangolin"); queryWrapper.eq("status", 1); List list = bindAccountLoginService.list(queryWrapper); if (list != null && !list.isEmpty()) { for (BindAccountLogin login : list) { if (null == login.getCookie() || "".equals(login.getCookie().trim())) { pangolinLoginService.pangolinLogin(login.getAccountName(), login.getPassword()); } } } } @Test public void testPangolinData() { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("login_type", "pangolin"); queryWrapper.eq("status", 1); queryWrapper.isNotNull("cookie"); List list = bindAccountLoginService.list(queryWrapper); if (list != null && !list.isEmpty()) { for (BindAccountLogin bindAccountLogin : list) { pangolinCrawlerService.getChannelList(bindAccountLogin); pangolinCrawlerService.getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1); pangolinCrawlerService.getCheckList(bindAccountLogin); QueryWrapper queryWrapper1 = new QueryWrapper<>(); queryWrapper1.eq("account_name", bindAccountLogin.getAccountName()); List appList = pangolinAppService.list(queryWrapper1); if (appList != null && !appList.isEmpty()) { appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getId())); } } } } @Autowired private IKuaiShouDailyReportTaskService dailyReportTaskService; @Test public void testLoadKuaishouData(){ CtopOauthToken token = oauthTokenService.getTokenByAccountId(4801739L); for(int i=0;i<50;i++){ Date startDate = DateUtils.addDay(new Date(),-(i+30)); dailyReportTaskService.getTaskList(token.getAccountId(), token.getAccessToken(), DateUtils.formatDate(startDate)); } } }