|
@@ -1,31 +1,20 @@
|
|
|
package org.jeecg;
|
|
|
|
|
|
-import cn.com.ctop.bytedance.service.IByteDanceHourlyAccountWarningService;
|
|
|
+import cn.com.ctop.bytedance.entity.BytedancePlanDailyReport;
|
|
|
+import cn.com.ctop.bytedance.service.IBytedancePlanDailyReportService;
|
|
|
import cn.com.ctop.bytedance.service.IReportService;
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
-import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
|
|
|
+import cn.com.ctop.common.module.entity.UserAllocation;
|
|
|
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.common.module.utils.HttpUtils2;
|
|
|
import cn.com.ctop.crawler.modules.appium.service.IAppiumJobService;
|
|
|
-import cn.com.ctop.crawler.modules.appium.service.IAppiumTaskService;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IAccountWarningService;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.http.impl.client.BasicCookieStore;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
-import org.jeecg.modules.ctop.service.IBidWarningService;
|
|
|
-import org.jeecg.modules.ctop.service.ICreateInternalService;
|
|
|
import org.jeecg.modules.mq.Sender;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
|
-import org.openqa.selenium.By;
|
|
|
-import org.openqa.selenium.JavascriptExecutor;
|
|
|
-import org.openqa.selenium.WebDriver;
|
|
|
-import org.openqa.selenium.WebElement;
|
|
|
-import org.openqa.selenium.chrome.ChromeDriver;
|
|
|
-import org.openqa.selenium.chrome.ChromeOptions;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
@@ -34,8 +23,6 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
-import java.util.concurrent.ExecutorService;
|
|
|
-import java.util.concurrent.Executors;
|
|
|
|
|
|
@RunWith(SpringRunner.class)
|
|
|
@SpringBootTest
|
|
@@ -45,183 +32,84 @@ public class SampleTest {
|
|
|
private String chromeDriver;
|
|
|
@Autowired
|
|
|
private IAppiumJobService jobService;
|
|
|
- @Autowired
|
|
|
- private ICreateInternalService createInternalService;
|
|
|
- @Autowired
|
|
|
- private IAppiumTaskService appiumTaskService;
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testKs() throws InterruptedException {
|
|
|
- String url = "https://ad.e.kuaishou.com/#/welcome?redirectUrl=https%3A%2F%2Fad.e.kuaishou.com%2F%23%2Findex";
|
|
|
- System.getProperties().setProperty("webdriver.chrome.driver", chromeDriver);
|
|
|
- ChromeOptions chromeOptions = new ChromeOptions();
|
|
|
-// chromeOptions.addArguments("--headless");
|
|
|
- chromeOptions.addArguments("--incognito");
|
|
|
- chromeOptions.addArguments("--disable-gpu");
|
|
|
-// chromeOptions.addArguments("--no-sandbox");
|
|
|
- chromeOptions.addArguments("--window-size=1920,1080");
|
|
|
- chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
|
|
|
- chromeOptions.setAcceptInsecureCerts(true);
|
|
|
- WebDriver webDriver = new ChromeDriver(chromeOptions);
|
|
|
- try {
|
|
|
- Thread.sleep(3000L);
|
|
|
- HttpUtils2.cookieStore = new BasicCookieStore();
|
|
|
- webDriver.manage().deleteAllCookies();
|
|
|
- //获取登录页面
|
|
|
- webDriver.get(url);
|
|
|
- Thread.sleep(3000L);
|
|
|
- WebElement accountElement = webDriver.findElement(By.xpath("//div[@class='phone ']/input[@type='text']"));
|
|
|
- accountElement.sendKeys("19845004383");
|
|
|
- Thread.sleep(3000L);
|
|
|
- WebElement passwordElement = webDriver.findElement(By.xpath("//div[@class='password ']/input[@type='password']"));
|
|
|
- passwordElement.sendKeys("a123456");
|
|
|
- WebElement loginElement = webDriver.findElement(By.xpath("//div[@class='foot']"));
|
|
|
- Thread.sleep(3000L);
|
|
|
- //点击登录
|
|
|
- loginElement.click();
|
|
|
- Thread.sleep(3000L);
|
|
|
- //获取推广按钮
|
|
|
- WebElement spreadElement = webDriver.findElement(By.linkText("推广"));
|
|
|
- spreadElement.click();
|
|
|
- Thread.sleep(3000L);
|
|
|
- //选择广告创意
|
|
|
- WebElement creativeElement = webDriver.findElement(By.xpath("//div[text()='广告创意']"));
|
|
|
- creativeElement.click();
|
|
|
- Thread.sleep(3000L);
|
|
|
- //输入创意名称,点击搜索
|
|
|
- WebElement searchElement = webDriver.findElement(By.xpath("//input[@type='text']"));
|
|
|
- searchElement.sendKeys("2-这个是你画的吗-设计-11.19");
|
|
|
- Thread.sleep(3000L);
|
|
|
- WebElement searchButton = webDriver.findElement(By.xpath("//button[@class='ant-btn ant-input-search-button ant-btn-primary']"));
|
|
|
- searchButton.click();
|
|
|
- Thread.sleep(3000L);
|
|
|
- WebElement tiyanElement = webDriver.findElement(By.linkText("体验"));
|
|
|
- tiyanElement.click();
|
|
|
- Thread.sleep(2000L);
|
|
|
- WebElement inputKsIdElement = webDriver.findElement(By.xpath("//textarea[@placeholder='请输入快手账号…']"));
|
|
|
- inputKsIdElement.sendKeys("123456765");
|
|
|
- Thread.sleep(2000L);
|
|
|
- WebElement chufaElement = webDriver.findElement(By.xpath("//button[@class='creative-experience-btn-enable']"));
|
|
|
- chufaElement.click();
|
|
|
-
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- webDriver.manage().deleteAllCookies();
|
|
|
- webDriver.close();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void test() {
|
|
|
- jobService.refreshWebPhone();
|
|
|
- }
|
|
|
|
|
|
@Test
|
|
|
public void testMq() {
|
|
|
Sender sender = new Sender();
|
|
|
sender.send();
|
|
|
}
|
|
|
-
|
|
|
- @Test
|
|
|
- public void loadKuaishouDataSingle() throws Exception {
|
|
|
- String url = "https://a201903112120030590198943.szwego.com/static/index.html#/shop_detail/A201903112120030590198943";
|
|
|
- System.getProperties().setProperty("webdriver.chrome.driver", chromeDriver);
|
|
|
- ChromeOptions chromeOptions = new ChromeOptions();
|
|
|
-// chromeOptions.addArguments("--headless");
|
|
|
- chromeOptions.addArguments("--incognito");
|
|
|
- chromeOptions.addArguments("--disable-gpu");
|
|
|
-// chromeOptions.addArguments("--no-sandbox");
|
|
|
- chromeOptions.addArguments("--window-size=1920,1080");
|
|
|
- chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
|
|
|
- chromeOptions.setAcceptInsecureCerts(true);
|
|
|
- WebDriver webDriver = new ChromeDriver(chromeOptions);
|
|
|
- webDriver.get(url);
|
|
|
- Thread.sleep(3000L);
|
|
|
- ((JavascriptExecutor) webDriver).executeScript("window.scrollTo(0,document.body.scrollHeight)");
|
|
|
- Thread.sleep(3000L);
|
|
|
- List<WebElement> elementList = webDriver.findElements(By.xpath("//div[@class='word-break ellipsis-two f14 g3']"));
|
|
|
- for (WebElement element : elementList) {
|
|
|
- System.out.println(element.getText());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IKuaishouInterfaceService kuaishouInterfaceService;
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testMail() throws Exception {
|
|
|
- // String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page
|
|
|
- kuaishouInterfaceService.getTargetingTags(23212L, "101a5c994d0a87322f305a306a30e38e");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IBidWarningService bidWarningService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IAccountWarningService accountWarningService;
|
|
|
- @Autowired
|
|
|
- private CtopOauthTokenMapper oauthTokenMapper;
|
|
|
- static ExecutorService executorService = Executors.newFixedThreadPool(5);
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testMa() throws Exception {
|
|
|
- // accountWarningService.accountWarning(23212L);
|
|
|
- QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
|
|
|
- oauthTokenQueryWrapper.eq("media_id", 2);
|
|
|
- List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(oauthTokenQueryWrapper);
|
|
|
- for (CtopOauthToken token : ctopOauthTokens) {
|
|
|
- kuaishouInterfaceService.getCreativeList(token, null, null);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
@Autowired
|
|
|
private ICtopOauthTokenService tokenService;
|
|
|
@Autowired
|
|
|
private IReportService reportService;
|
|
|
-@Autowired
|
|
|
-private IByteDanceHourlyAccountWarningService byteDanceHourlyAccountWarningService;
|
|
|
- @Test
|
|
|
- public void testMa2() throws Exception {
|
|
|
|
|
|
+ @Test
|
|
|
+ public void getBytedancePlanReport(){
|
|
|
|
|
|
- byteDanceHourlyAccountWarningService.byteDanceAccountWarning(1655337394471943L,"2020-02-06","2020-02-05");
|
|
|
- /*Date getDate = new Date();
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
|
|
|
- String hour = simpleDateFormat.format(getDate);
|
|
|
- if (null != hour && "00".equals(hour)) {
|
|
|
- getDate = DateUtils.addDay(getDate, -1);
|
|
|
- }
|
|
|
+ Date getDate = DateUtils.addDay(new Date(), -4);
|
|
|
//1:查询当日数据
|
|
|
List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
|
|
|
if (null == tokens || tokens.size() <= 0) {
|
|
|
- log.info("定时获取头条小时数据异常:未获取到可用的token");
|
|
|
+ log.info("定时获取头条数据异常:为获取到可用的token");
|
|
|
return;
|
|
|
}
|
|
|
- Date finalGetDate = getDate;
|
|
|
-
|
|
|
-
|
|
|
- QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
|
|
|
- oauthTokenQueryWrapper.eq("account_id", 1655337394471943L);
|
|
|
- CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);*/
|
|
|
-
|
|
|
+ tokens.forEach(token -> {
|
|
|
+ //3:获取广告计划信息数据
|
|
|
+ reportService.getAdvertiserPlanReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
+ });
|
|
|
+
|
|
|
+ //清洗关于作业帮数据
|
|
|
+ //1:查询作业帮相关的用户数据
|
|
|
+ QueryWrapper<UserAllocation> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.eq("project_id",215);
|
|
|
+ List<UserAllocation> allocations = userAllocationService.list(wrapper);
|
|
|
+ if(null!=allocations&&allocations.size()>0){
|
|
|
+ allocations.forEach(allocation->{
|
|
|
+ //根据accountId和时间,查询相关的日报表信息
|
|
|
+ QueryWrapper<BytedancePlanDailyReport> queryWrapper = new QueryWrapper<>();
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String dateString = dateFormat.format(getDate)+" 00:00:00";
|
|
|
+ System.out.println(dateString);
|
|
|
+ queryWrapper.eq("advertiser_id",allocation.getAccountId())
|
|
|
+// .eq("stat_datetime",dateString)
|
|
|
+ ;
|
|
|
+ List<BytedancePlanDailyReport>bytedancePlanDailyReports = planDailyReportService.list(queryWrapper);
|
|
|
+ if(null!=bytedancePlanDailyReports&&bytedancePlanDailyReports.size()>0){
|
|
|
+ bytedancePlanDailyReports.forEach(report->{
|
|
|
+ String adName = report.getAdName();
|
|
|
+ System.out.println(adName);
|
|
|
+ String[] tags = adName.split("-");
|
|
|
+ report.setAdsense(tags[1]);
|
|
|
+ report.setPlanCode(tags[2]);
|
|
|
+ String tag = tags[3];
|
|
|
+ if(tag.contains("其他")){
|
|
|
+ report.setMaterialType("其他");
|
|
|
+ }else if (tag.contains("图片轮播")){
|
|
|
+ report.setMaterialType("图片轮播");
|
|
|
+ }else if(tag.contains("大字报")){
|
|
|
+ report.setMaterialType("大字报");
|
|
|
+ }else if(tag.contains("文字动画")){
|
|
|
+ report.setMaterialType("文字动画");
|
|
|
+ }else{
|
|
|
+ report.setMaterialType("其他");
|
|
|
+ }
|
|
|
+ planDailyReportService.updateById(report);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //1: 获取广告主信息数据
|
|
|
- // reportService.getAdvertiserReport(ctopOauthToken, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
|
- //2:获取广告组信息数据
|
|
|
- //reportService.getAdvertiserCampaignReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
|
- //3:获取广告计划信息数据
|
|
|
- //reportService.getAdvertiserPlanReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
|
- //4: 获取广告创意信息数据
|
|
|
- //reportService.getAdvertiserCreativeReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
|
+ @Test
|
|
|
+ public void loadRegistOrderData(){
|
|
|
|
|
|
+ }
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IUserAllocationService userAllocationService;
|
|
|
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ private IBytedancePlanDailyReportService planDailyReportService;
|
|
|
|
|
|
}
|
|
|
|