|
@@ -9,13 +9,12 @@ import cn.com.ctop.common.module.entity.UReportSubscriber;
|
|
|
import cn.com.ctop.common.module.entity.UserAllocation;
|
|
|
import cn.com.ctop.common.module.message.handle.impl.EmailSendMsgHandle;
|
|
|
import cn.com.ctop.common.module.service.*;
|
|
|
-import cn.com.ctop.common.module.service.impl.UReportExportRest;
|
|
|
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.material.service.IByteDanceAdvertiserDataService;
|
|
|
import cn.com.ctop.toutiao.modules.report.service.IReportService;
|
|
|
-import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
import org.junit.Test;
|
|
@@ -46,29 +45,27 @@ public class SampleTest {
|
|
|
private IKuaiShouDailyAgentService kuaiShouDailyAgentService;
|
|
|
@Autowired
|
|
|
private IReportService reportService;
|
|
|
+ @Autowired
|
|
|
+ private IByteDanceAdvertiserDataService byteDanceAdvertiserDataService;
|
|
|
|
|
|
@Test
|
|
|
public void loadBytedanceCreativeData() {
|
|
|
- String accountIdString = "1661556811389966,1650504410207245,1652711697337351,1652711697724429,1650504410574859,1668459522250759";
|
|
|
- String[] accountIds = accountIdString.split(",");
|
|
|
- for(int i=0;i<accountIds.length;i++){
|
|
|
- CtopOauthToken token = oauthTokenService.getTokenByAccountId(Long.parseLong(accountIds[i]));
|
|
|
- reportService.getAdvertiserPlanReport(token,new Date(),new Date(),CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
|
- }
|
|
|
+ byteDanceAdvertiserDataService.advertiserList("2093115cd521740b024a5811d361712e0b5c3303");
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
|
private IBindAccountLoginService bindAccountLoginService;
|
|
|
@Autowired
|
|
|
private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
|
|
|
+
|
|
|
@Test
|
|
|
- public void loadKuaishouCookie(){
|
|
|
- List<BindAccountLogin> 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){
|
|
|
+ public void loadKuaishouCookie() {
|
|
|
+ List<BindAccountLogin> 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);
|
|
@@ -77,23 +74,24 @@ public class SampleTest {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
static ExecutorService executorService = null;
|
|
|
//线程计数器
|
|
|
static CountDownLatch countDownLatch = null;
|
|
|
|
|
|
@Test
|
|
|
- public void deleteKuaishouComment(){
|
|
|
+ public void deleteKuaishouComment() {
|
|
|
Long start = System.currentTimeMillis();
|
|
|
- List<BindAccountLogin>loginList = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY,1);
|
|
|
+ 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(()->{
|
|
|
+ loginList.forEach(login -> executorService.submit(() -> {
|
|
|
try {
|
|
|
- kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(),login);
|
|
|
- }catch (Exception e){
|
|
|
- log.error(e.getMessage(),e);
|
|
|
- }finally {
|
|
|
+ kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ } finally {
|
|
|
countDownLatch.countDown();
|
|
|
}
|
|
|
}));
|
|
@@ -103,19 +101,21 @@ public class SampleTest {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
Long end = System.currentTimeMillis();
|
|
|
- log.info("快手删评论所用时长:{}毫秒",end-start);
|
|
|
+ log.info("快手删评论所用时长:{}毫秒", end - start);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
@Autowired
|
|
|
private IUserAllocationService allocationService;
|
|
|
+
|
|
|
@Test
|
|
|
public void testLoadBytedanceData() {
|
|
|
- List<UserAllocation>allocations = allocationService.getByParams(435L,null,0);
|
|
|
- for (UserAllocation allocation:allocations) {
|
|
|
- for(int i=2;i<10;i++){
|
|
|
+ List<UserAllocation> allocations = 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);
|
|
|
+ Date getDate = DateUtils.addDay(new Date(), -i);
|
|
|
+ reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -129,10 +129,10 @@ public class SampleTest {
|
|
|
//
|
|
|
kuaishouReportDailyAgentService.loginAgent();
|
|
|
try {
|
|
|
- for(int i=1;i<30;i++){
|
|
|
+ for (int i = 1; i < 30; i++) {
|
|
|
kuaishouReportDailyAgentService.getAccount(i);
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
// String currentDate = D ateUtils.formatDate(DateUtils.addDay(new Date(),-1));
|
|
@@ -144,19 +144,20 @@ public class SampleTest {
|
|
|
|
|
|
@Autowired
|
|
|
private ICtopCheckTaskListService checkTaskListService;
|
|
|
+
|
|
|
@Test
|
|
|
- public void checkDataStateJobTest(){
|
|
|
+ public void checkDataStateJobTest() {
|
|
|
//查询需要检查的任务列表
|
|
|
- List<CtopCheckTaskList> ctopCheckTaskList= checkTaskListService.queryExecuteList("checkDataStateJob");
|
|
|
- if(ctopCheckTaskList!=null){
|
|
|
- ctopCheckTaskList.forEach(it-> groovyScriptExecutor.execute(it));
|
|
|
+ List<CtopCheckTaskList> ctopCheckTaskList = checkTaskListService.queryExecuteList("checkDataStateJob");
|
|
|
+ if (ctopCheckTaskList != null) {
|
|
|
+ ctopCheckTaskList.forEach(it -> groovyScriptExecutor.execute(it));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void loadAccountData() {
|
|
|
CtopOauthToken token = oauthTokenService.getTokenByAccountId(1665922219192387L);
|
|
|
- reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-09-01","yy-MM-dd"), DateUtils.parseDate("2020-09-01","yy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
|
+ reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-09-01", "yy-MM-dd"), DateUtils.parseDate("2020-09-01", "yy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
@@ -167,24 +168,25 @@ public class SampleTest {
|
|
|
IUReportService uReportService;
|
|
|
|
|
|
@Test
|
|
|
- public void sendUReport(){
|
|
|
- uReportService.uReportList().forEach(uReport->{
|
|
|
+ public void sendUReport() {
|
|
|
+ uReportService.uReportList().forEach(uReport -> {
|
|
|
List<UReportSubscriber> uReportSubscriber = uReportService.getUReportSubscriberByFileId(uReport.getString("id"));
|
|
|
- if(!uReportSubscriber.isEmpty()){
|
|
|
- String title=uReport.getString("name").replace(".ureport.xml","");
|
|
|
- String content="您订阅的日报在附件中请注意查收》》》";
|
|
|
+ if (!uReportSubscriber.isEmpty()) {
|
|
|
+ String title = uReport.getString("name").replace(".ureport.xml", "");
|
|
|
+ String content = "您订阅的日报在附件中请注意查收》》》";
|
|
|
//下载文件到本地
|
|
|
uReportExportService.exportExcel(uReport.getString("name"));
|
|
|
- uReportSubscriber.forEach(sender->{
|
|
|
- emailSendMsgHandle.SendAttachment("bijiequan@c-top.com.cn",title,content,
|
|
|
- new File(System.getProperty("user.dir")+ File.separator + "uReport"+File.separator+uReport.getString("name").replace("ureport.xml","")+"xlsx"));
|
|
|
- }); }
|
|
|
+ uReportSubscriber.forEach(sender -> {
|
|
|
+ emailSendMsgHandle.SendAttachment("bijiequan@c-top.com.cn", title, content,
|
|
|
+ new File(System.getProperty("user.dir") + File.separator + "uReport" + File.separator + uReport.getString("name").replace("ureport.xml", "") + "xlsx"));
|
|
|
+ });
|
|
|
+ }
|
|
|
});
|
|
|
//发完全部订阅,删除文件
|
|
|
- File file =new File(System.getProperty("user.dir")+ File.separator + "uReport");
|
|
|
- File[] files=file.listFiles();
|
|
|
- if(files!=null&&files.length>0){
|
|
|
- for (File f: files){
|
|
|
+ File file = new File(System.getProperty("user.dir") + File.separator + "uReport");
|
|
|
+ File[] files = file.listFiles();
|
|
|
+ if (files != null && files.length > 0) {
|
|
|
+ for (File f : files) {
|
|
|
f.delete();
|
|
|
}
|
|
|
}
|