|
@@ -47,6 +47,7 @@ import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.lang.reflect.ParameterizedType;
|
|
|
import java.lang.reflect.Type;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
@@ -186,11 +187,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public void getVideoList(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
- getVideoListByPage(token, startDate, endDate, 1);
|
|
|
+ public void getVideoList(CtopOauthToken token, String statDate) {
|
|
|
+ getVideoListByPage(token, statDate, 1);
|
|
|
}
|
|
|
|
|
|
- private void getVideoListByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
|
|
|
+ private void getVideoListByPage(CtopOauthToken token, String statDate, int page) {
|
|
|
try {
|
|
|
log.info("获取视频数据,accountId:{}", token.getAccountId());
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_LIST;
|
|
@@ -201,9 +202,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
param.put("advertiser_id", token.getAccountId());
|
|
|
param.put("page_size", 500);
|
|
|
param.put("page", page);
|
|
|
- if (startDate != null && endDate != null) {
|
|
|
- param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
- param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
+ if (!Check.isNull(statDate)) {
|
|
|
+ param.put("start_date", statDate);
|
|
|
+ param.put("end_date", statDate);
|
|
|
}
|
|
|
String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
@@ -218,12 +219,12 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
log.info("快手视频列表信息为空=》accountId:{}", token.getAccountId());
|
|
|
return;
|
|
|
}
|
|
|
- List<KuaiShouVideoGet> videoGets = new ArrayList<>();
|
|
|
for (int i = 0; i < details.size(); i++) {
|
|
|
var detailJson = details.getJSONObject(i);
|
|
|
var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
|
|
|
kuaiShouVideoGet.setId(token.getAccountId() + kuaiShouVideoGet.getPhotoId());
|
|
|
kuaiShouVideoGet.setAccountId(token.getAccountId());
|
|
|
+ kuaiShouVideoGet.setStatDate(DateUtils.parseDate(statDate, "yyyy-MM-dd"));
|
|
|
kuaiShouVideoGet.setUpdateTime(new Date());
|
|
|
Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
|
|
|
if (!Check.isNull(type)) {
|
|
@@ -231,7 +232,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
}
|
|
|
kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
|
|
|
}
|
|
|
- getVideoListByPage(token, startDate, endDate, page + 1);
|
|
|
+ getVideoListByPage(token, statDate, page + 1);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -890,9 +891,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
//获取全量创意数据
|
|
|
getCreativeList(token, null, null);
|
|
|
//获取全量视频素材数据
|
|
|
- getVideoList(token, null, null);
|
|
|
+
|
|
|
//获取图片信息数据
|
|
|
- getImageList(token, null, null);
|
|
|
+
|
|
|
|
|
|
getAppList(token.getAccountId(), token.getAccessToken());
|
|
|
|
|
@@ -903,6 +904,18 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
|
|
|
historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
|
|
|
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
+ String videoEndDate = DateUtils.addDay(nowDate, -180);
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date end = simpleDateFormat.parse(nowDate);
|
|
|
+ Date start = simpleDateFormat.parse(videoEndDate);
|
|
|
+ List<Date> dates = DateUtils.findDates(start, end);
|
|
|
+ for (int i = 0; i < dates.size(); i++) {
|
|
|
+ String formatDate = simpleDateFormat.format(dates.get(i));
|
|
|
+ getVideoList(token, formatDate);
|
|
|
+ getImageList(token, formatDate);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -2531,15 +2544,15 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
* 查询图片列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public void getImageList(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
- getImageList(token, startDate, endDate, 1);
|
|
|
+ public void getImageList(CtopOauthToken token, String statDate) {
|
|
|
+ getImageList(token, statDate, 1);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询图片列表
|
|
|
*/
|
|
|
- private void getImageList(CtopOauthToken token, Date startDate, Date endDate, int page) {
|
|
|
+ private void getImageList(CtopOauthToken token, String statDate, int page) {
|
|
|
try {
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_LIST;
|
|
|
Map<String, String> headers = new HashMap<String, String>();
|
|
@@ -2549,9 +2562,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
//传参
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("advertiser_id", token.getAccountId());
|
|
|
- if (startDate != null && endDate != null) {
|
|
|
- param.put("startDate", DateUtils.formatDate(startDate));
|
|
|
- param.put("endDate", DateUtils.formatDate(endDate));
|
|
|
+ if (!Check.isNull(statDate)) {
|
|
|
+ param.put("startDate", DateUtils.formatDate(statDate));
|
|
|
+ param.put("endDate", DateUtils.formatDate(statDate));
|
|
|
}
|
|
|
param.put("page_size", 500);
|
|
|
param.put("page", page);
|
|
@@ -2588,13 +2601,14 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
if (!Check.isNull(type)) {
|
|
|
kuaiShouImageGet.setMaterialType(type);
|
|
|
}
|
|
|
+ kuaiShouImageGet.setStatDate(DateUtils.parseDate(statDate, "yyyy-MM-dd"));
|
|
|
|
|
|
kuaiShouImageGet.setCreateTime(new Date());
|
|
|
kuaiShouImageGet.setUpdateTime(new Date());
|
|
|
imageGets.add(kuaiShouImageGet);
|
|
|
}
|
|
|
kuaiShouImageGetService.replaceBatch(imageGets);
|
|
|
- getImageList(token, startDate, endDate, page + 1);
|
|
|
+ getImageList(token, statDate, page + 1);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
|
|
@@ -2907,9 +2921,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
JSONObject dataJson = resultJson.getJSONObject("data");
|
|
|
if (!Check.isNull(dataJson)) {
|
|
|
Integer total_count = dataJson.getInteger("total_count");
|
|
|
- if (total_count > 2000) {
|
|
|
+ /* if (total_count > 2000) {
|
|
|
return;
|
|
|
- }
|
|
|
+ }*/
|
|
|
JSONArray details = dataJson.getJSONArray("details");
|
|
|
if (Check.isNull(details)) {
|
|
|
return;
|