|
@@ -5,28 +5,17 @@ import cn.com.ctop.check.entity.CtopCheckTaskList;
|
|
|
import cn.com.ctop.check.service.ICtopCheckTaskListService;
|
|
|
import cn.com.ctop.common.module.entity.BindAccountLogin;
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
-import cn.com.ctop.common.module.entity.UReportSubscriber;
|
|
|
+import cn.com.ctop.common.module.entity.MaterialImageInfo;
|
|
|
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.IBindAccountLoginService;
|
|
|
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
+import cn.com.ctop.common.module.service.IMaterialImageInfoService;
|
|
|
+import cn.com.ctop.common.module.service.IUserAllocationService;
|
|
|
import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyReportTaskService;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
|
|
|
-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.service.IKuaishouReportDailyAgentService;
|
|
|
-import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
|
|
|
-import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
|
|
|
-import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
|
|
|
-import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
|
|
|
-import cn.com.ctop.oa.modules.service.IWechatCheckinDataService;
|
|
|
-import cn.com.ctop.oa.modules.service.IWechatDepartmentService;
|
|
|
-import cn.com.ctop.oa.modules.service.IWechatUserListService;
|
|
|
-import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
|
|
|
import cn.com.ctop.toutiao.modules.report.service.IReportService;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
@@ -37,9 +26,6 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.ActiveProfiles;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.text.ParseException;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -59,86 +45,26 @@ public class SampleTest {
|
|
|
@Autowired
|
|
|
private IReportService reportService;
|
|
|
@Autowired
|
|
|
- private IUserAllocationService userAllocationService;
|
|
|
- @Autowired
|
|
|
- private IByteDanceAdvertiserDataService advertiserDataService;
|
|
|
- @Autowired
|
|
|
private IKuaiShouHistoryReportTaskService kuaiShouHistoryReportTaskService;
|
|
|
@Autowired
|
|
|
- private IKuaiShouDailyReportTaskService dailyReportTaskService;
|
|
|
- private IBytedanceReportService bytedanceReportService;
|
|
|
+ private IMaterialImageInfoService imageInfoService;
|
|
|
@Test
|
|
|
public void loadBytedanceMatData(){
|
|
|
executorService = Executors.newFixedThreadPool(5);
|
|
|
List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
|
|
|
-// for(int i=14;i<45;i++){
|
|
|
-// Date getDate2 = DateUtils.addDay(new Date(), -i);
|
|
|
- String date2 = DateUtils.formatDate(new Date());
|
|
|
- for (CtopOauthToken token:tokens) {
|
|
|
- //获取头条素材报表两天前的数据
|
|
|
-// XxlJobLogger.log("账户"+token.getAccountId() + "素材报表数据任务开始,任务时间:" + date2 + "~" + date2);
|
|
|
- reportService.getAdvertiserPlanReport(token,new Date(),new Date(),CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
|
-// XxlJobLogger.log("账户"+token.getAccountId() + "素材报表数据任务完成,任务时间:" + date2 + "~" + date2);
|
|
|
-// }
|
|
|
+ for (CtopOauthToken token:tokens) {
|
|
|
+ reportService.getAdvertiserPlanReport(token,new Date(),new Date(),CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void loadBytedanceCreativeData() {
|
|
|
- UserAllocation allocation = userAllocationService.getByAccountId(1648083559613447L);
|
|
|
- CtopOauthToken token = oauthTokenService.getTokenByAccountId(1648083559613447L);
|
|
|
-// advertiserDataService.getAdvertiserPlan(token, "", null, null);
|
|
|
- List<ByteDanceAdvertisePlan> plans = advertisePlanService.getAllPlans(token.getAccountId(),DateUtils.formatDate(new Date()));
|
|
|
- if(null!=plans&&!plans.isEmpty()){
|
|
|
- for (ByteDanceAdvertisePlan plan:plans) {
|
|
|
- Map<String, Object> creativeDetail = creativeService.getCreativeDetail(token.getAccountId(), plan.getId());
|
|
|
- if(null!=creativeDetail.get("data")){
|
|
|
- JSONObject data = (JSONObject) creativeDetail.get("data");
|
|
|
- checkMonitorLink(data,plan,allocation);
|
|
|
- }
|
|
|
- }
|
|
|
+ public void initImageCode(){
|
|
|
+ List<MaterialImageInfo> imageInfos = imageInfoService.list();
|
|
|
+ for (MaterialImageInfo image:imageInfos) {
|
|
|
+ imageInfoService.initImageCode(image);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void checkMonitorLink(JSONObject data, ByteDanceAdvertisePlan plan, UserAllocation allocation) {
|
|
|
- String downloadUrl = plan.getDownloadUrl();
|
|
|
- boolean errorflag = false;
|
|
|
- String errorMsg = "";
|
|
|
- String token = plan.getName().split("-")[0];
|
|
|
- String tokenInfo = "surl_token="+token;
|
|
|
- String appType = plan.getAppType();
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IWechatDepartmentService wechatDepartment;
|
|
|
- @Autowired
|
|
|
- private IKuaishouInterfaceService kuaishouInterfaceService;
|
|
|
- @Autowired
|
|
|
- private IWechatUserListService wechatUserInfoService;
|
|
|
- @Autowired
|
|
|
- private IWechatCheckinDataService wechatCheckinDataService;
|
|
|
- @Autowired
|
|
|
- private ICtopOauthTokenService tokenService;
|
|
|
-
|
|
|
-
|
|
|
- @Test
|
|
|
- public void getDepartment() throws ParseException {
|
|
|
- List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- Date parse1 = simpleDateFormat.parse("2020-09-12");
|
|
|
- Date parse2 = simpleDateFormat.parse("2020-09-17");
|
|
|
- for (CtopOauthToken token : tokens) {
|
|
|
-
|
|
|
- kuaishouInterfaceService.getAdvertiserGroupReportDaily(token, parse1, parse2);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- // wechatCheckinDataService.getCheckinData();
|
|
|
- // wechatUserInfoService.getUserList();
|
|
|
- // wechatDepartment.getDepartment();
|
|
|
- // kuaishouInterfaceService.getSuZaoList("a34853c230e1b949eddbe569023dbc40", 7022550L, 1, "2020-09-15", "2020-09-16");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
@Test
|
|
|
public void loadBytedanceCreativeData() {
|
|
@@ -181,7 +107,6 @@ public class SampleTest {
|
|
|
}
|
|
|
|
|
|
static ExecutorService executorService = null;
|
|
|
- //线程计数器/bytedance/bytedanceMaterialReport
|
|
|
static CountDownLatch countDownLatch = null;
|
|
|
|
|
|
@Test
|
|
@@ -269,40 +194,9 @@ public class SampleTest {
|
|
|
for(int i=2;i<100;i++){
|
|
|
String date = DateUtils.formatDate(DateUtils.addDay(new Date(),-i));
|
|
|
for (CtopOauthToken token:tokens) {
|
|
|
- bytedanceReportService.bytedanceVideoMaterialReport(token, date, date);
|
|
|
+// bytedanceReportService.bytedanceVideoMaterialReport(token, date, date);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
- IUReportExportService uReportExportService;
|
|
|
- @Autowired
|
|
|
- EmailSendMsgHandle emailSendMsgHandle;
|
|
|
- @Autowired
|
|
|
- IUReportService uReportService;
|
|
|
-
|
|
|
- @Test
|
|
|
- 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 = "您订阅的日报在附件中请注意查收》》》";
|
|
|
- //下载文件到本地
|
|
|
- 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"));
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- //发完全部订阅,删除文件
|
|
|
- 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();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|