|
@@ -9,7 +9,6 @@ import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial;
|
|
|
import cn.com.ctop.kuaishou.modules.report.entity.VideoGetvo;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -57,16 +56,13 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
|
|
|
param.put("advertiser_id", accountId);
|
|
|
param.put("temporal_granularity", "DAILY");
|
|
|
param.put("view_type", 5);
|
|
|
- param.put("page_size", 1000);
|
|
|
+ param.put("page_size", 2000);
|
|
|
param.put("page", page);
|
|
|
-
|
|
|
String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
- // log.info("快手返回数据:{}",resultJson);
|
|
|
if (Check.isNull(resultJson)) {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
Integer total_count = resultJson.getInteger("total_count");
|
|
|
if (total_count == 0) {
|
|
|
return;
|
|
@@ -75,9 +71,8 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
|
|
|
if (Check.isNull(details)) {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
List<KuaiShouReportDailyMaterial> addList = new ArrayList<>();
|
|
|
- long l1 = System.currentTimeMillis();
|
|
|
+ List<Long> photoIdList = new ArrayList<>();
|
|
|
for (int i = 0; i < details.size(); i++) {
|
|
|
JSONObject detailJson = details.getJSONObject(i);
|
|
|
detailJson.put("photo_like", detailJson.getInteger("like"));
|
|
@@ -85,28 +80,41 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
|
|
|
detailJson.put("photo_comment", detailJson.getInteger("comment"));
|
|
|
detailJson.put("photo_show", detailJson.getInteger("show"));
|
|
|
KuaiShouReportDailyMaterial material = JSONObject.toJavaObject(detailJson, KuaiShouReportDailyMaterial.class);
|
|
|
- VideoGetvo videoGetvo = dailyMaterialMapper.getVideoGetByPhotoId(material.getPhotoId());
|
|
|
- if (!Check.isNull(videoGetvo)) {
|
|
|
- material.setChannelType(videoGetvo.getChannelType());
|
|
|
- material.setSignature(videoGetvo.getSignature());
|
|
|
- }
|
|
|
material.setAccountId(accountId);
|
|
|
-
|
|
|
+ photoIdList.add(material.getPhotoId());
|
|
|
addList.add(material);
|
|
|
}
|
|
|
- // log.info("addList:{}",addList);
|
|
|
+ addList = this.getVideoInfoByList(addList, photoIdList);
|
|
|
dailyMaterialMapper.batchReplace(addList);
|
|
|
getMaterialReportByAccountIdAndStatDate(accountId, token, startDate, endDate, page + 1);
|
|
|
}
|
|
|
|
|
|
+ private List<KuaiShouReportDailyMaterial> getVideoInfoByList(List<KuaiShouReportDailyMaterial> addList, List<Long> photoIdList) {
|
|
|
+ List<JSONObject> videoInfoList = dailyMaterialMapper.getVideoInfoByList(photoIdList);
|
|
|
+ Map<Long, JSONObject> videoMap = new HashMap<>();
|
|
|
+ for (int i = 0; i < videoInfoList.size(); i++) {
|
|
|
+ JSONObject jsonObject = videoInfoList.get(i);
|
|
|
+ videoMap.put(jsonObject.getLong("photoId"), jsonObject);
|
|
|
+ }
|
|
|
+ for (KuaiShouReportDailyMaterial dailyMaterial : addList) {
|
|
|
+ JSONObject jsonObject = videoMap.get(dailyMaterial.getPhotoId());
|
|
|
+ if (Check.isNull(jsonObject)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ dailyMaterial.setSignature(jsonObject.getString("signature"));
|
|
|
+ dailyMaterial.setChannelType(jsonObject.getInteger("channelType"));
|
|
|
+ }
|
|
|
+ return addList;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<KuaiShouReportDailyMaterial> getSignatureByDate(String date) {
|
|
|
return dailyMaterialMapper.getSignatureByDate(date);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public KuaiShouReportDailyMaterial getEtlDataByParams(String signature, String date,Long projectId) {
|
|
|
- return dailyMaterialMapper.getEtlDataByParams(signature,date,projectId);
|
|
|
+ public KuaiShouReportDailyMaterial getEtlDataByParams(String signature, String date, Long projectId) {
|
|
|
+ return dailyMaterialMapper.getEtlDataByParams(signature, date, projectId);
|
|
|
}
|
|
|
|
|
|
@Override
|