123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- 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.kuaishou.modules.report.entity.EtlKuaishouAccountMaterialReportDaily;
- import cn.com.ctop.kuaishou.modules.report.mapper.EtlKuaishouAccountMaterialReportDailyMapper;
- import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyImageService;
- import cn.com.ctop.oa.modules.service.IWechatNoListService;
- import cn.com.ctop.toutiao.modules.link.service.IETLReportBytedanceVideoService;
- import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
- import cn.com.ctop.toutiao.modules.report.entity.BytedanceCheckReportTaskInfo;
- import cn.com.ctop.toutiao.modules.report.service.*;
- import com.xxl.job.core.context.XxlJobHelper;
- 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 javax.annotation.Resource;
- import java.text.ParseException;
- 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 IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
- @Autowired
- IBytedanceVideoReportService bytedanceVideoReportService;
- @Autowired
- IETLReportBytedanceVideoService ietlReportBytedanceVideoService;
- @Autowired
- IKuaishouReportDailyImageService kuaishouReportDailyImageService;
- @Autowired
- IRuleByteDanceAccountService ruleByteDanceAccountService;
- @Autowired
- private ICtopOauthTokenService tokenService;
- @Autowired
- private IBindAccountLoginService bindAccountLoginService;
- @Autowired
- private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
- @Autowired
- private IByteDanceAdvertiserDataService advertiserDataService;
- @Autowired
- private IWechatNoListService wechatNoListService;
- @Autowired
- private IETLReportBytedanceVideoService bytedanceVideoService;
- @Autowired
- private IByteDanceVideoReportDailyService videoReportDailyService;
- @Resource
- private EtlKuaishouAccountMaterialReportDailyMapper etlKuaishouAccountMaterialReportDailyMapper;
- @Autowired
- private IReportService reportService;
- @Resource
- private IBytedanceCheckReportTaskInfoService checkReportTaskInfoService;
- @Autowired
- private IEtlBytedanceReportVideoDailyService etlBytedanceReportVideoDailyService;
- static ExecutorService executorService = null;
- static CountDownLatch countDownLatch = null;
- @Autowired
- private IBytedanceReportService bytedanceReportService;
- @Autowired
- private IETLReportBytedanceVideoService etlReportBytedanceVideoService;
- @Test
- public void loadKuaishouCookie() throws ParseException {
- CtopOauthToken tokenByAccountId = tokenService.getTokenByAccountId(1700996735138951L);
- advertiserDataService.getMaterialList(tokenByAccountId);
- CtopOauthToken tokenByAccountId1 = tokenService.getTokenByAccountId(1700996735589383L);
- advertiserDataService.getMaterialList(tokenByAccountId1);
- }
- @Test
- public void deleteKuaishouComment() {
- Long start = System.currentTimeMillis();
- List<BindAccountLogin> loginList = 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);
- }
- }
- @Test
- public void loadBytedanceVideoReportData() {
- CtopOauthToken token = tokenService.getTokenByAccountId(1696831659659278L);
- advertiserDataService.getMaterialList(token);
- }
- @Test
- public void etlBytedanceVideoInfo() {
- String startDate = "2021-02-01";
- for (int i = 0; i < 100; i++) {
- bytedanceVideoService.cleanData(DateUtils.addDay(startDate, i));
- }
- }
- @Test
- public void getData() {
- //汇创 人员
- // wechatUserInfoService.getUserList();
- // //考勤记录
- // wechatCheckinDataService.getCheckinData("2021-03-01 00:00:00", "2021-03-31 23:59:59");
- //异常记录
- wechatNoListService.getNoDateByNo("2021-03-01 00:00:00", "2021-03-31 23:59:59", "0");
- //优容
- // wechatUserInfoService.getYRUserList();
- // wechatCheckinDataService.getYRCheckinData("2021-03-01 00:00:00", "2021-03-31 23:59:59");
- wechatNoListService.getNoDateByNo("2021-03-01 00:00:00", "2021-03-31 23:59:59", "1");
- }
- @Test
- public void formatVideoReportData() {
- for (int i = 1; i < 45; i++) {
- Date getDate = DateUtils.addDay(new Date(), -i);
- String date = DateUtils.formatDate(getDate);
- videoReportDailyService.videoInfoList(date, date);
- }
- }
- @Test
- public void loadBDAccoutData() {
- Date startDate = DateUtils.addDay(new Date(), -2000);
- for (int i = 0; i <= 2000; i++) {
- Date getDate = DateUtils.addDay(startDate, i);
- bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
- }
- }
- @Test
- public void etlKuaishouVideoInfo() {
- etlKuaishouAccountMaterialReportDailyMapper.etlKuaishouAccountMaterialReportDailyData(DateUtils.formatDate());
- }
- @Test
- public void testLoadBytedanceCampaign() {
- CtopOauthToken token = tokenService.getTokenByAccountId(1681669009084429L);
- bytedanceReportService.bytedanceMaterialReport(token, "2021-05-01", "2021-05-06");
- }
- @Test
- public void etlBytedanceVideoReportInfo() throws Exception {
- etlBytedanceReportVideoDailyService.etlBytedanceVideo();
- }
- @Test
- public void loadBytedanceAccountReport() {
- CtopOauthToken token1 = tokenService.getTokenByAccountId(1693648201498637L);
- reportService.getAdvertiserReport(token1, DateUtils.parseDate("2021-04-01", "yyyy-MM-dd"), DateUtils.parseDate("2021-04-12", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
- }
- @Test
- public void checkCostData(){
- String date = "2021-06-11";
- for (int i=0;i<7;i++){
- String getDate = DateUtils.addDay(date,i);
- //1:初始化
- checkReportTaskInfoService.initTask(getDate);
- //2: checkCost
- List<BytedanceCheckReportTaskInfo>taskInfos = checkReportTaskInfoService.getListByParams(null,getDate,0);
- if(null!=taskInfos&&!taskInfos.isEmpty()){
- for (BytedanceCheckReportTaskInfo task:taskInfos) {
- checkReportTaskInfoService.checkCost(task);
- }
- log.info("{}:数据获取完成",getDate);
- }
- }
- }
- @Test
- public void refreshReportData()throws Exception{
- //1:查询异常任务数据
- List<BytedanceCheckReportTaskInfo>taskInfos = checkReportTaskInfoService.getListByParams(null,null,50001);
- if(null!=taskInfos&&!taskInfos.isEmpty()){
- countDownLatch = new CountDownLatch(taskInfos.size());
- taskInfos.forEach(taskInfo -> {
- try {
- checkReportTaskInfoService.reloadData(taskInfo);
- checkReportTaskInfoService.checkCost(taskInfo);
- }catch (Exception e){
- }finally {
- countDownLatch.countDown();
- }
- });
- countDownLatch.await();
- XxlJobHelper.log("{}数据更新完成");
- }
- }
- @Test
- public void testfreshBytedanceUrl(){
- etlReportBytedanceVideoService.etlBytedanceVideoClipIdJob();
- etlReportBytedanceVideoService.etlBytedanceVideoPlanInfoJob();
- etlReportBytedanceVideoService.etlBytedanceVideoShotInfoJob();
- }
- }
|