|
@@ -28,6 +28,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fasterxml.jackson.databind.type.TypeFactory;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import lombok.var;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.http.ParseException;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -207,11 +208,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void getVideoList(CtopOauthToken token) {
|
|
|
- getVideoListByPage(token, 1);
|
|
|
+ public void getVideoList(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
+ getVideoListByPage(token, startDate, endDate, 1);
|
|
|
}
|
|
|
|
|
|
- private void getVideoListByPage(CtopOauthToken token, int page) {
|
|
|
+ private void getVideoListByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_LIST;
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Content-Type", "application/json");
|
|
@@ -220,6 +221,10 @@ 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(new Date()));
|
|
|
+ param.put("end_date", DateUtils.formatDate(new Date()));
|
|
|
+ }
|
|
|
String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
Integer code = resultJson.getInteger("code");
|
|
@@ -244,7 +249,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
videoGets.add(kuaiShouVideoGet);
|
|
|
}
|
|
|
kuaiShouVideoGetService.replaceBatch(videoGets);
|
|
|
- getVideoListByPage(token, page + 1);
|
|
|
+ getVideoListByPage(token, startDate, endDate, page + 1);
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
@@ -943,6 +948,17 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
getAdvertiserGroupReportDaily(token, getStartDate, getEndDate);
|
|
|
//4: 获取广告创意信息数据
|
|
|
getAdvertiserCreativeReportDaily(token, getStartDate, getEndDate);
|
|
|
+
|
|
|
+ //获取全量广告计划数据
|
|
|
+ getCampaignList(token, null, null);
|
|
|
+ //获取全量广告主数据
|
|
|
+ getGroupList(token, null, null);
|
|
|
+ //获取全量创意数据
|
|
|
+ getCreativeList(token, null, null);
|
|
|
+ //获取全量视频素材数据
|
|
|
+ getVideoList(token, null, null);
|
|
|
+ //获取图片信息数据
|
|
|
+ getImageList(token, null, null);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -1070,17 +1086,21 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void getCampaignList(CtopOauthToken token) {
|
|
|
- getCampaignListByPage(token.getAccessToken(), token.getAccountId(), 1);
|
|
|
+ public void getCampaignList(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
+ getCampaignListByPage(token.getAccessToken(), token.getAccountId(), startDate, endDate, 1);
|
|
|
}
|
|
|
|
|
|
- private void getCampaignListByPage(String accessToken, Long accountId, int page) {
|
|
|
+ private void getCampaignListByPage(String accessToken, Long accountId, Date startDate, Date endDate, int page) {
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_LIST;
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Access-Token", accessToken);
|
|
|
headers.put("Content-Type", " application/json");
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("advertiser_id", accountId);
|
|
|
+ if(startDate != null && endDate != null){
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
+ }
|
|
|
param.put("page", page);
|
|
|
param.put("page_size", 200);
|
|
|
|
|
@@ -1102,7 +1122,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
return;
|
|
|
}
|
|
|
addCampaign(accountId, details);
|
|
|
- getCampaignListByPage(accessToken, accountId, page + 1);
|
|
|
+ getCampaignListByPage(accessToken, accountId, startDate, endDate, page + 1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1113,13 +1133,17 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public void getCampaignList(String accessToken, Long advertiserId, Integer page) {
|
|
|
+ public void getCampaignList(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page) {
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_LIST;
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Access-Token", accessToken);
|
|
|
headers.put("Content-Type", " application/json");
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("advertiser_id", advertiserId);
|
|
|
+ if(startDate != null && endDate != null){
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
+ }
|
|
|
param.put("page", page);
|
|
|
param.put("page_size", 200);
|
|
|
try {
|
|
@@ -1132,7 +1156,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
JSONArray details = dataJson.getJSONArray("details");
|
|
|
if (!Check.isNull(details)) {
|
|
|
addCampaign(advertiserId, details);
|
|
|
- getCampaignList(accessToken, advertiserId, page + 1);
|
|
|
+ getCampaignList(accessToken, advertiserId, startDate, endDate, page + 1);
|
|
|
}
|
|
|
} else {
|
|
|
log.error("获取广告计划信息返回结果异常,advertiserId:{},异常信息:{}", advertiserId, resultJson);
|
|
@@ -1202,8 +1226,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void getGroupList(CtopOauthToken token) {
|
|
|
- getGroupListByPage(token, 1);
|
|
|
+ public void getGroupList(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
+ getGroupListByPage(token, startDate, endDate, 1);
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
@@ -1228,13 +1252,15 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
//1:获取全量广告计划数据
|
|
|
- getCampaignList(token);
|
|
|
+ getCampaignList(token,null,null);
|
|
|
//1:获取全量广告组数据
|
|
|
- getGroupList(token);
|
|
|
+ getGroupList(token,null,null);
|
|
|
//1:获取全量创意数据
|
|
|
- getCreativeList(token);
|
|
|
+ getCreativeList(token,null,null);
|
|
|
//2:获取全量视频素材数据
|
|
|
- getVideoList(token);
|
|
|
+ getVideoList(token,null,null);
|
|
|
+ //获取图片信息数据
|
|
|
+ getImageList(token, null, null);
|
|
|
countDownLatch.countDown();
|
|
|
}
|
|
|
});
|
|
@@ -1269,12 +1295,16 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
hourlyCreativeStatisticService.deleteHourlyReport(deleteDate);
|
|
|
}
|
|
|
|
|
|
- private void getGroupListByPage(CtopOauthToken token, int page) {
|
|
|
+ private void getGroupListByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("advertiser_id", token.getAccountId());
|
|
|
param.put("page_size", 200);
|
|
|
param.put("page", page);
|
|
|
+ if(startDate != null && endDate != null){
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
+ }
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
|
headers.put("Content-Type", " application/json");
|
|
@@ -1296,7 +1326,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
return;
|
|
|
}
|
|
|
addGroup(token.getAccountId(), details);
|
|
|
- getGroupListByPage(token, page + 1);
|
|
|
+ getGroupListByPage(token, startDate, endDate, page + 1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1307,12 +1337,16 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public void getGroupList(String accessToken, Long advertiserId, Integer page) {
|
|
|
+ public void getGroupList(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page) {
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("advertiser_id", advertiserId);
|
|
|
param.put("page_size", 200);
|
|
|
param.put("page", page);
|
|
|
+ if(startDate != null && endDate != null){
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
+ }
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Access-Token", accessToken);
|
|
|
headers.put("Content-Type", " application/json");
|
|
@@ -1327,7 +1361,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
JSONArray details = dataJson.getJSONArray("details");
|
|
|
if (!Check.isNull(details)) {
|
|
|
addGroup(advertiserId, details);
|
|
|
- getGroupList(accessToken, advertiserId, page + 1);
|
|
|
+ getGroupList(accessToken, advertiserId, startDate, endDate, page + 1);
|
|
|
}
|
|
|
|
|
|
} else {
|
|
@@ -1467,17 +1501,21 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void getCreativeList(CtopOauthToken token) {
|
|
|
- getCreativeListByPage(token.getAccessToken(), token.getAccountId(), 1);
|
|
|
+ public void getCreativeList(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
+ getCreativeListByPage(token.getAccessToken(), token.getAccountId(), startDate, endDate, 1);
|
|
|
}
|
|
|
|
|
|
- public void getCreativeListByPage(String accessToken, Long advertiserId, Integer page) {
|
|
|
+ public void getCreativeListByPage(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page) {
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Content-Type", " application/json");
|
|
|
headers.put("Access-Token", accessToken);
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("advertiser_id", advertiserId);
|
|
|
+ if(startDate != null && endDate != null){
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
+ }
|
|
|
param.put("page_size", 200);
|
|
|
param.put("page", page);
|
|
|
|
|
@@ -1527,7 +1565,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
}
|
|
|
}
|
|
|
creativeService.replaceBatch(creatives);
|
|
|
- getCreativeListByPage(accessToken, advertiserId, page + 1);
|
|
|
+ getCreativeListByPage(accessToken, advertiserId, startDate, endDate, page + 1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1590,13 +1628,17 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
* @param advertiserId
|
|
|
*/
|
|
|
@Override
|
|
|
- public void getCreativeList(String accessToken, Long advertiserId, Integer page) {
|
|
|
+ public void getCreativeList(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page) {
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
|
|
|
Map<String, String> headers = new HashMap<String, String>();
|
|
|
headers.put("Content-Type", " application/json");
|
|
|
headers.put("Access-Token", accessToken);
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("advertiser_id", advertiserId);
|
|
|
+ if(startDate != null && endDate != null){
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
+ }
|
|
|
param.put("page_size", 200);
|
|
|
param.put("page", page);
|
|
|
try {
|
|
@@ -1635,7 +1677,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- getCreativeList(accessToken, advertiserId, page + 1);
|
|
|
+ getCreativeList(accessToken, advertiserId, startDate, endDate, page + 1);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -2533,4 +2575,138 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ @Autowired IKuaiShouImageGetService kuaiShouImageGetService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询图片列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void getImageList(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
+ getImageList(token, startDate, endDate, 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询图片列表
|
|
|
+ */
|
|
|
+ private void getImageList(CtopOauthToken token, Date startDate, Date endDate, int page ) {
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_LIST;
|
|
|
+ Map<String, String> headers = new HashMap<String, String>();
|
|
|
+ headers.put("Content-Type", " application/json");
|
|
|
+ headers.put("Access-Token", token.getAccessToken());
|
|
|
+
|
|
|
+ //传参
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ param.put("page_size", 500);
|
|
|
+ param.put("page", page);
|
|
|
+ //
|
|
|
+ String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
+
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
+ String message = resultJson.getString("message");
|
|
|
+ if (null == code || code != 0) {
|
|
|
+ log.error("获取快手图片列表数据异常:{},accountId:{}", message, token.getAccountId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
|
|
|
+ if (null == details || details.size() <= 0) {
|
|
|
+ log.info("快手图片列表信息为空=》accountId:{}", token.getAccountId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<KuaiShouImageGet> imageGets = new ArrayList<>();
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
+ var detailJson = details.getJSONObject(i);
|
|
|
+ var kuaiShouImageGet = JSONObject.toJavaObject(detailJson, KuaiShouImageGet.class);
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(String.valueOf(kuaiShouImageGet.getImageToken()))){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ kuaiShouImageGet.setAccountId(token.getAccountId());
|
|
|
+ kuaiShouImageGet.setCreateTime(new Date());
|
|
|
+ kuaiShouImageGet.setUpdateTime(new Date());
|
|
|
+ imageGets.add(kuaiShouImageGet);
|
|
|
+ }
|
|
|
+ kuaiShouImageGetService.replaceBatch(imageGets);
|
|
|
+ getImageList(token, startDate, endDate, page + 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询图片列表---测试使用
|
|
|
+ */
|
|
|
+ public void getImageList(String token, Long accountId, Date startDate, Date endDate, int page ) {
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_LIST;
|
|
|
+ Map<String, String> headers = new HashMap<String, String>();
|
|
|
+ headers.put("Content-Type", " application/json");
|
|
|
+ headers.put("Access-Token", token);
|
|
|
+
|
|
|
+ //传参
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
+ param.put("advertiser_id", accountId);
|
|
|
+ if(startDate != null && endDate != null){
|
|
|
+ param.put("startDate", DateUtils.formatDate(startDate));
|
|
|
+ param.put("endDate", DateUtils.formatDate(endDate));
|
|
|
+ }
|
|
|
+ param.put("page_size", 500);
|
|
|
+ param.put("page", page);
|
|
|
+ //
|
|
|
+
|
|
|
+ //String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
+
|
|
|
+ //test start
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ Map<String,Object> map1 = new HashMap<>();
|
|
|
+
|
|
|
+ List<KuaiShouImageGet> list = new ArrayList<>();
|
|
|
+ KuaiShouImageGet kuaiShouImageGet1 = new KuaiShouImageGet();
|
|
|
+ kuaiShouImageGet1.setUrl("http://static.yximgs.com/udata/pkg/markb21f94845c4350.jpg");
|
|
|
+ kuaiShouImageGet1.setWidth(720L);
|
|
|
+ kuaiShouImageGet1.setHeight(1280L);
|
|
|
+ kuaiShouImageGet1.setSize(441029L);
|
|
|
+ kuaiShouImageGet1.setFormat("jpg");
|
|
|
+ kuaiShouImageGet1.setImageToken("market0a8a3104ee6b4f148ab21f94845c4350.jpg");
|
|
|
+ kuaiShouImageGet1.setSignature("44a20b91b0727fa2abb68b19c0456422");
|
|
|
+ list.add(kuaiShouImageGet1);
|
|
|
+
|
|
|
+ map1.put("details",list);
|
|
|
+ map1.put("total_count",4);
|
|
|
+ map.put("data",map1);
|
|
|
+ map.put("message","OK");
|
|
|
+ map.put("code",0);
|
|
|
+ String result = JSONObject.toJSONString(map);
|
|
|
+ //test end
|
|
|
+
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
+ String message = resultJson.getString("message");
|
|
|
+ if (null == code || code != 0) {
|
|
|
+ log.error("获取快手图片列表数据异常:{},accountId:{}", message, accountId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
|
|
|
+ if (null == details || details.size() <= 0) {
|
|
|
+ log.info("快手图片列表信息为空=》accountId:{}", accountId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<KuaiShouImageGet> imageGets = new ArrayList<>();
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
+ var detailJson = details.getJSONObject(i);
|
|
|
+ var kuaiShouImageGet = JSONObject.toJavaObject(detailJson, KuaiShouImageGet.class);
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(String.valueOf(kuaiShouImageGet.getImageToken()))){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ kuaiShouImageGet.setAccountId(accountId);
|
|
|
+ kuaiShouImageGet.setCreateTime(new Date());
|
|
|
+ kuaiShouImageGet.setUpdateTime(new Date());
|
|
|
+ imageGets.add(kuaiShouImageGet);
|
|
|
+ }
|
|
|
+ kuaiShouImageGetService.replaceBatch(imageGets);
|
|
|
+ getImageList(token, accountId, startDate, endDate, page+1 );
|
|
|
+ }
|
|
|
}
|