|
@@ -15,6 +15,7 @@ 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.jeecg.common.util.DateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -22,9 +23,12 @@ import org.springframework.stereotype.Service;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
|
|
|
/**
|
|
|
* @Description: 快手-获取视频接口
|
|
@@ -151,7 +155,7 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public List<KuaiShouVideoGet> getNewVideoBetweenTime(Long accountId, String startTime, String endTime,Integer channelType,String appVersion,Integer videoCnt) {
|
|
|
+ public List<KuaiShouVideoGet> getNewVideoBetweenTime(Long accountId, String startTime, String endTime, Integer channelType, String appVersion, Integer videoCnt) {
|
|
|
QueryWrapper<KuaiShouVideoGet> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.isNotNull("signature");
|
|
|
if (null != accountId && accountId != 0) {
|
|
@@ -161,15 +165,15 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
|
|
|
queryWrapper.le("stat_date", endTime);
|
|
|
queryWrapper.gt("stat_date", startTime);
|
|
|
}
|
|
|
- if(null!=channelType&&channelType!=2){
|
|
|
- queryWrapper.eq("channel_type",channelType);
|
|
|
+ if (null != channelType && channelType != 2) {
|
|
|
+ queryWrapper.eq("channel_type", channelType);
|
|
|
}
|
|
|
|
|
|
- if(null!=appVersion&&!appVersion.trim().equals("")){
|
|
|
- queryWrapper.likeRight("photo_name",appVersion);
|
|
|
+ if (null != appVersion && !appVersion.trim().equals("")) {
|
|
|
+ queryWrapper.likeRight("photo_name", appVersion);
|
|
|
}
|
|
|
- if(null!=videoCnt&&videoCnt!=0){
|
|
|
- queryWrapper.last("limit "+videoCnt);
|
|
|
+ if (null != videoCnt && videoCnt != 0) {
|
|
|
+ queryWrapper.last("limit " + videoCnt);
|
|
|
}
|
|
|
return this.list(queryWrapper);
|
|
|
}
|
|
@@ -277,12 +281,71 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<KuaiShouVideoGet> getZeroVideoByParams(Long accountId, String startTime, String endTime, Long videoCnt,String appVersion,Integer channelType,Integer relativeCnt) {
|
|
|
- return videoGetMapper.getZeroVideoByParams(accountId,startTime,endTime,videoCnt,appVersion,channelType,relativeCnt);
|
|
|
+ public List<KuaiShouVideoGet> getZeroVideoByParams(Long accountId, String startTime, String endTime, Long videoCnt, String appVersion, Integer channelType, Integer relativeCnt) {
|
|
|
+ return videoGetMapper.getZeroVideoByParams(accountId, startTime, endTime, videoCnt, appVersion, channelType, relativeCnt);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<KuaiShouVideoGet> getHistoryTopVideoByParams(Long accountId, String startTime, String endTime, Long videoCnt, String appVersion, Integer channelType) {
|
|
|
- return videoGetMapper.getHistoryTopVideoByParams(accountId,startTime,endTime,videoCnt,appVersion,channelType);
|
|
|
+ return videoGetMapper.getHistoryTopVideoByParams(accountId, startTime, endTime, videoCnt, appVersion, channelType);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 素造接口,获取同步供应商素材标签数据
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void getSuZaoList(String token, Long accountId, int page,String startDate) {
|
|
|
+ String url = "https://ad.e.kuaishou.com/rest/openapi/v1/ad_creator/video/list";
|
|
|
+ Map<String, String> headers = new HashMap<String, String>();
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ headers.put("Access-Token", token);
|
|
|
+ Map<String, Object> param = new HashMap<String, Object>();
|
|
|
+ param.put("advertiser_id", accountId);
|
|
|
+ param.put("page", page);
|
|
|
+ param.put("page_size", 200);
|
|
|
+ param.put("start_date", startDate);
|
|
|
+ param.put("end_date", DateUtils.formatDate(new Date(),DateUtils.NEW_FORMAT));
|
|
|
+ String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ System.out.println(result);
|
|
|
+ if (Check.isNull(resultJson)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
+ String message = resultJson.getString("message");
|
|
|
+ if (null == code || code != 0) {
|
|
|
+ log.error("获取快手素造列表数据异常:{},accountId:{}", message, accountId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject dataJson = resultJson.getJSONObject("data");
|
|
|
+ if (Check.isNull(dataJson)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONArray details = dataJson.getJSONArray("details");
|
|
|
+ if (Check.isNull(details)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<KuaiShouVideoGet> videoGetList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
+ JSONObject detailJson = details.getJSONObject(i);
|
|
|
+ if (Check.isNull(detailJson)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
|
|
|
+ videoGet.setMaterialTag(detailJson.getString("material_tag"));
|
|
|
+ videoGet.setSupplierAccountId(detailJson.getLong("supplier_account_id"));
|
|
|
+ videoGet.setSupplierAccountName(detailJson.getString("supplier_account_name"));
|
|
|
+ videoGet.setId(accountId + detailJson.getString("photo_id"));
|
|
|
+ videoGetList.add(videoGet);
|
|
|
+ }
|
|
|
+ if (!Check.isNull(videoGetList)) {
|
|
|
+ videoGetMapper.updateBatch(videoGetList);
|
|
|
+ }
|
|
|
+ getSuZaoList(token, accountId, page + 1,startDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<JSONObject> getAccountIds() {
|
|
|
+ return videoGetMapper.getAccountIds();
|
|
|
}
|
|
|
}
|