|
@@ -15,6 +15,7 @@ import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService
|
|
import cn.com.ctop.kuaishou.modules.material.entity.KuaishouAccessToken;
|
|
import cn.com.ctop.kuaishou.modules.material.entity.KuaishouAccessToken;
|
|
import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
|
|
import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
|
|
import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
|
|
import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
|
|
|
|
+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.IByteDanceAdvertiserDataService;
|
|
import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
|
|
import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
|
|
import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
|
|
import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
|
|
@@ -22,6 +23,7 @@ import cn.com.ctop.toutiao.modules.report.service.*;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.xxl.job.core.context.XxlJobHelper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.ibatis.annotations.Param;
|
|
import org.apache.ibatis.annotations.Param;
|
|
@@ -54,7 +56,7 @@ import static org.jeecg.common.util.DateUtils.getAnotherDay;
|
|
@RequestMapping("/test")
|
|
@RequestMapping("/test")
|
|
@Slf4j
|
|
@Slf4j
|
|
public class TestController {
|
|
public class TestController {
|
|
- @Autowired
|
|
|
|
|
|
+ @Resource
|
|
private CtopOauthTokenMapper tokenMapper;
|
|
private CtopOauthTokenMapper tokenMapper;
|
|
@Autowired
|
|
@Autowired
|
|
private IKuaishouInterfaceService kuaishouInterfaceService;
|
|
private IKuaishouInterfaceService kuaishouInterfaceService;
|
|
@@ -107,11 +109,28 @@ public class TestController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private IBindAccountAuthService bindAccountAuthService;
|
|
private IBindAccountAuthService bindAccountAuthService;
|
|
- @Autowired
|
|
|
|
|
|
+ @Resource
|
|
private UserAllocationMapper allocationMapper;
|
|
private UserAllocationMapper allocationMapper;
|
|
@Autowired
|
|
@Autowired
|
|
private IBytedanceReportService bytedanceReportService;
|
|
private IBytedanceReportService bytedanceReportService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IUserAllocationService allocationService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping("/getVideoByProjectId")
|
|
|
|
+ public String getVideoByProjectId(Long projectId) {
|
|
|
|
+ QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("project_id", projectId);
|
|
|
|
+ List<UserAllocation> list = allocationService.list(queryWrapper);
|
|
|
|
+ for (UserAllocation allocation : list) {
|
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
|
|
|
|
+ kuaishouInterfaceService.getVideoList(token, null, null);
|
|
|
|
+ }
|
|
|
|
+ return "success";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
@GetMapping("/testKuaishou")
|
|
@GetMapping("/testKuaishou")
|
|
public String kuaishouCallback(@RequestParam("auth_code") String authCode, @RequestParam("state") String state) {
|
|
public String kuaishouCallback(@RequestParam("auth_code") String authCode, @RequestParam("state") String state) {
|
|
try {
|
|
try {
|
|
@@ -242,7 +261,6 @@ public class TestController {
|
|
} catch (InterruptedException e) {
|
|
} catch (InterruptedException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
- System.out.println("数据获取完成");
|
|
|
|
// bytedanceReportMaterialDailyMapper.updateImageReportCode();
|
|
// bytedanceReportMaterialDailyMapper.updateImageReportCode();
|
|
// bytedanceReportMaterialDailyMapper.updateImageReportProjectId();
|
|
// bytedanceReportMaterialDailyMapper.updateImageReportProjectId();
|
|
// bytedanceReportMaterialDailyMapper.updateImageReportProjectName();
|
|
// bytedanceReportMaterialDailyMapper.updateImageReportProjectName();
|
|
@@ -686,11 +704,6 @@ public class TestController {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
@GetMapping(value = "/createCutTask")
|
|
@GetMapping(value = "/createCutTask")
|
|
public String createCutTask(String startDate, String endDate) throws IOException {
|
|
public String createCutTask(String startDate, String endDate) throws IOException {
|
|
List<MaterialInfo> materialInfos = materialInfoService.getListByDate(startDate, endDate);
|
|
List<MaterialInfo> materialInfos = materialInfoService.getListByDate(startDate, endDate);
|
|
@@ -1332,24 +1345,57 @@ public class TestController {
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("loadMatData")
|
|
@GetMapping("loadMatData")
|
|
- public Map<String,Object>getData(String startDate,String endDate,Long accountId){
|
|
|
|
- Map<String,Object>result = new HashMap<>();
|
|
|
|
|
|
+ public Map<String, Object> getData(String startDate, String endDate, Long accountId) {
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
- Date start = DateUtils.parseDate(startDate,"yyyy-MM-dd");
|
|
|
|
- int days = DateUtils.getdaysOfTwoDate(startDate,endDate)+1;
|
|
|
|
- for (int i=0;i<days;i++){
|
|
|
|
- String getDate = DateUtils.formatDate(DateUtils.addDay(start,i));
|
|
|
|
|
|
+ Date start = DateUtils.parseDate(startDate, "yyyy-MM-dd");
|
|
|
|
+ int days = DateUtils.getdaysOfTwoDate(startDate, endDate) + 1;
|
|
|
|
+ for (int i = 0; i < days; i++) {
|
|
|
|
+ String getDate = DateUtils.formatDate(DateUtils.addDay(start, i));
|
|
bytedanceReportService.bytedanceMaterialReport(token, getDate, getDate);
|
|
bytedanceReportService.bytedanceMaterialReport(token, getDate, getDate);
|
|
}
|
|
}
|
|
- ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
|
|
|
|
|
|
+ ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("loadAccountData")
|
|
@GetMapping("loadAccountData")
|
|
- public Map<String,Object>getData(Long accountId){
|
|
|
|
- Map<String,Object>result = new HashMap<>();
|
|
|
|
|
|
+ public Map<String, Object> getData(Long accountId) {
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
- reportService.getAdvertiserReport(token, DateUtils.parseDate("2021-01-01","yyyy-MM-dd"), DateUtils.parseDate("2021-01-31","yyyy-MM-dd"),CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
|
|
|
+ reportService.getAdvertiserReport(token, DateUtils.parseDate("2021-01-01", "yyyy-MM-dd"), DateUtils.parseDate("2021-01-31", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
|
+ ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private ExecutorService executor = Executors.newFixedThreadPool(10);
|
|
|
|
+ private CountDownLatch countDownLatch;
|
|
|
|
+ @Autowired
|
|
|
|
+ IBytedanceVideoReportService bytedanceVideoReportService;
|
|
|
|
+ @Autowired
|
|
|
|
+ IETLReportBytedanceVideoService etlReportBytedanceVideoService;
|
|
|
|
+ @GetMapping("execute")
|
|
|
|
+ public Map<String,Object> execute(String date) throws Exception {
|
|
|
|
+ Map<String,Object>result = new HashMap<>();
|
|
|
|
+// List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
|
|
|
|
+// countDownLatch = new CountDownLatch(tokens.size());
|
|
|
|
+// tokens.forEach(token -> executor.submit(() -> {
|
|
|
|
+// try {
|
|
|
|
+// bytedanceVideoReportService.pullVideoReport(token,date,date,1);
|
|
|
|
+// } catch (Exception e) {
|
|
|
|
+// XxlJobHelper.log("头条视频报表基础数据拉取异常:{}",e.getMessage());
|
|
|
|
+// } finally {
|
|
|
|
+// countDownLatch.countDown();
|
|
|
|
+// }
|
|
|
|
+// }));
|
|
|
|
+// try {
|
|
|
|
+// countDownLatch.await();
|
|
|
|
+// } catch (InterruptedException e) {
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// }
|
|
|
|
+ Map<String,Object> params = new HashMap<>();
|
|
|
|
+ params.put("stat_datetime",date);
|
|
|
|
+ etlReportBytedanceVideoService.removeByMap(params);
|
|
|
|
+ etlReportBytedanceVideoService.cleanETL(date);
|
|
ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
|
|
ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|