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.batch.service.IKuaishouInterfaceService; import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService; 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.material.service.IByteDanceCampaignService; import cn.com.ctop.toutiao.modules.report.service.*; import com.csvreader.CsvReader; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.util.DateUtils; import org.jeecg.common.util.RedisUtil; 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.io.IOException; import java.nio.charset.Charset; import java.text.ParseException; import java.util.ArrayList; 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 tokenService; @Autowired private IBindAccountLoginService bindAccountLoginService; @Autowired private IKuaishouWebInterfaceService kuaishouWebInterfaceService; @Autowired private IKuaishouInterfaceService kuaishouInterfaceService; @Autowired private RedisUtil redisUtil; @Test public void loadKuaishouCookie() throws ParseException { redisUtil.set("11sdfhgjksdhfjksdhfjksdhfkjsjkfhkjsddhfjksdhfkjhsjkfhjkshfjksdhfjksdhfjkshdjkfhsjkdfhkjsd1","hahahaha",5); Object o = redisUtil.get("11sdfhgjksdhfjksdhfjksdhfkjsjkfhkjsddhfjksdhfkjhsjkfhjkshfjksdhfjksdhfjkshdjkfhsjkdfhkjsd1"); System.err.println(o); /*try { // 用来保存数据 ArrayList csvFileList = new ArrayList(); // 定义一个CSV路径 String csvFilePath = "D:\\test\\123.csv"; // 创建CSV读对象 例如:CsvReader(文件路径,分隔符,编码格式); CsvReader reader = new CsvReader(csvFilePath, ',', Charset.forName("UTF-8")); // 跳过表头 如果需要表头的话,这句可以忽略 reader.readHeaders(); // 逐行读入除表头的数据 while (reader.readRecord()) { System.out.println(reader.getRawRecord()); csvFileList.add(reader.getValues()); } reader.close(); // 遍历读取的CSV文件 for (int row = 0; row < csvFileList.size(); row++) { // 取得第row行第0列的数据 String cell = csvFileList.get(row)[0]; System.out.println("------------>" + cell); } } catch (IOException e) { e.printStackTrace(); }*/ /* CtopOauthToken tokenByAccountId = tokenService.getTokenByAccountId(9792526L); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date parse = dateFormat.parse("2021-04-02"); kuaishouInterfaceService.getAdvertiserReportDaily(tokenByAccountId, parse, parse, null);*/ } static ExecutorService executorService = null; static CountDownLatch countDownLatch = null; @Test public void deleteKuaishouComment() { Long start = System.currentTimeMillis(); List 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); } } @Autowired private IBytedanceReportService bytedanceReportService; @Autowired private IByteDanceAdvertiserDataService advertiserDataService; @Test public void loadBytedanceVideoReportData() { CtopOauthToken token = tokenService.getTokenByAccountId(1696831659659278L); advertiserDataService.getMaterialList(token); } @Autowired private IWechatNoListService wechatNoListService; @Autowired private IETLReportBytedanceVideoService bytedanceVideoService; @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"); } @Autowired private IByteDanceVideoReportDailyService videoReportDailyService; @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); } } @Autowired private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService; @Autowired IBytedanceVideoReportService bytedanceVideoReportService; @Autowired IETLReportBytedanceVideoService ietlReportBytedanceVideoService; @Autowired IKuaishouReportDailyImageService kuaishouReportDailyImageService; @Autowired IRuleByteDanceAccountService ruleByteDanceAccountService; @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); } } @Resource private EtlKuaishouAccountMaterialReportDailyMapper etlKuaishouAccountMaterialReportDailyMapper; @Test public void etlKuaishouVideoInfo() { etlKuaishouAccountMaterialReportDailyMapper.etlKuaishouAccountMaterialReportDailyData(DateUtils.formatDate()); } @Autowired private IByteDanceCampaignService campaignService; @Test public void testLoadBytedanceCampaign() { List tokens = tokenService.selectToutiaoToken(); for (CtopOauthToken token : tokens) { campaignService.getAdvertiserCampaign(token, null, null); } } @Autowired private IEtlBytedanceReportVideoDailyService etlBytedanceReportVideoDailyService; @Test public void etlBytedanceVideoReportInfo()throws Exception{ etlBytedanceReportVideoDailyService.etlBytedanceVideo(); } @Autowired private IReportService reportService; @Test public void loadBytedanceAccountReport(){ /** * 1692555408132110 * 1692555631713287 * 1696734332089352 * 1696734333251598 */ CtopOauthToken token1 = tokenService.getTokenByAccountId(1692555408132110L); reportService.getAdvertiserReport(token1, DateUtils.parseDate("2021-05-01","yyyy-MM-dd"), DateUtils.parseDate("2021-05-12","yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY); CtopOauthToken token2 = tokenService.getTokenByAccountId(1692555631713287L); reportService.getAdvertiserReport(token2, DateUtils.parseDate("2021-05-01","yyyy-MM-dd"), DateUtils.parseDate("2021-05-12","yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY); CtopOauthToken token3 = tokenService.getTokenByAccountId(1696734332089352L); reportService.getAdvertiserReport(token3, DateUtils.parseDate("2021-05-01","yyyy-MM-dd"), DateUtils.parseDate("2021-05-12","yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY); CtopOauthToken token4 = tokenService.getTokenByAccountId(1696734333251598L); reportService.getAdvertiserReport(token4, DateUtils.parseDate("2021-05-01","yyyy-MM-dd"), DateUtils.parseDate("2021-05-12","yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY); CtopOauthToken token5 = tokenService.getTokenByAccountId(10129666L); kuaishouInterfaceService.getAdvertiserReportDaily(token5, DateUtils.parseDate("2021-05-07","yyyy-MM-dd"), DateUtils.parseDate("2021-05-11","yyyy-MM-dd"), null); CtopOauthToken token6 = tokenService.getTokenByAccountId(10097961L); kuaishouInterfaceService.getAdvertiserReportDaily(token6, DateUtils.parseDate("2021-05-07","yyyy-MM-dd"), DateUtils.parseDate("2021-05-11","yyyy-MM-dd"), null); CtopOauthToken token7 = tokenService.getTokenByAccountId(10098039L); kuaishouInterfaceService.getAdvertiserReportDaily(token7, DateUtils.parseDate("2021-05-07","yyyy-MM-dd"), DateUtils.parseDate("2021-05-11","yyyy-MM-dd"), null); } }