|
@@ -1,7 +1,6 @@
|
|
|
package cn.com.ctop.kuaishou.modules.batch.service.impl;
|
|
|
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
-import cn.com.ctop.common.module.entity.MaterialCutFrame;
|
|
|
import cn.com.ctop.common.module.entity.OauthConfig;
|
|
|
import cn.com.ctop.common.module.entity.UserAllocation;
|
|
|
import cn.com.ctop.common.module.enums.MaterialEnum;
|
|
@@ -213,43 +212,56 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
log.info("快手视频列表信息为空=》accountId:{}", token.getAccountId());
|
|
|
return;
|
|
|
}
|
|
|
- KuaiShouAdvertiserBaseInfo baseInfo = KuaiShouAdvertiserBaseInfoService.getBaseInfo(token.getAccountId());
|
|
|
- Long userId = null;
|
|
|
- if (!Check.isNull(baseInfo)) {
|
|
|
- userId = Long.valueOf(baseInfo.getUserId());
|
|
|
- }
|
|
|
+ List<KuaiShouVideoGet> videoGetList = new ArrayList<>();
|
|
|
for (int i = 0; i < details.size(); i++) {
|
|
|
- var detailJson = details.getJSONObject(i);
|
|
|
+ JSONObject detailJson = details.getJSONObject(i);
|
|
|
+ if (Check.isNull(detailJson)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
|
|
|
+ String photo_id = detailJson.getString("photo_id");
|
|
|
+ videoGet.setId(token.getAccountId() + photo_id);
|
|
|
+ videoGet.setAccountId(token.getAccountId());
|
|
|
+ videoGet.setCoverUrl(detailJson.getString("cover_url"));
|
|
|
+ videoGet.setPhotoId(photo_id);
|
|
|
+ videoGet.setPhotoName(detailJson.getString("photo_name"));
|
|
|
+ videoGet.setStatDate(detailJson.getDate("upload_time"));
|
|
|
+ String signature = detailJson.getString("signature");
|
|
|
+ videoGet.setSignature(signature);
|
|
|
Integer source = detailJson.getInteger("source");
|
|
|
if (source == 2) {
|
|
|
- continue;
|
|
|
+ videoGet.setChannelType(1);
|
|
|
+ } else {
|
|
|
+ videoGet.setChannelType(0);
|
|
|
}
|
|
|
- KuaiShouVideoGet byId = kuaiShouVideoGetService.getById(token.getAccountId() + detailJson.getString("photo_id"));
|
|
|
- if (!Check.isNull(byId)) {
|
|
|
- continue;
|
|
|
+ Integer new_status = detailJson.getInteger("new_status");
|
|
|
+ if (new_status == 1) {
|
|
|
+ videoGet.setStatus(0);
|
|
|
+ } else {
|
|
|
+ videoGet.setStatus(1);
|
|
|
}
|
|
|
- var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
|
|
|
- kuaiShouVideoGet.setId(token.getAccountId() + kuaiShouVideoGet.getPhotoId());
|
|
|
- kuaiShouVideoGet.setAccountId(token.getAccountId());
|
|
|
- kuaiShouVideoGet.setStatDate(detailJson.getDate("upload_time"));
|
|
|
- kuaiShouVideoGet.setUpdateTime(new Date());
|
|
|
- Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
|
|
|
+ videoGet.setUrl(detailJson.getString("url"));
|
|
|
+ Integer width = detailJson.getInteger("width");
|
|
|
+ videoGet.setWidth(width);
|
|
|
+ Integer height = detailJson.getInteger("height");
|
|
|
+ videoGet.setHeight(height);
|
|
|
+ Integer type = MaterialEnum.getTypeBySize(width, height);
|
|
|
if (!Check.isNull(type)) {
|
|
|
- kuaiShouVideoGet.setMaterialType(type);
|
|
|
+ videoGet.setMaterialType(type);
|
|
|
}
|
|
|
-
|
|
|
- kuaiShouVideoGet.setUserId(userId);
|
|
|
- kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
|
|
|
-
|
|
|
+ videoGetList.add(videoGet);
|
|
|
Thread thread = new Thread() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- videoGetService.getKeyFrame(token.getAccessToken(), token.getAccountId(), kuaiShouVideoGet.getSignature(), kuaiShouVideoGet.getPhotoId());
|
|
|
+ videoGetService.getKeyFrame(token.getAccessToken(), token.getAccountId(), signature, photo_id);
|
|
|
}
|
|
|
};
|
|
|
thread.start();
|
|
|
-
|
|
|
}
|
|
|
+ if (!Check.isNull(videoGetList)) {
|
|
|
+ videoGetService.replaceBatch(videoGetList);
|
|
|
+ }
|
|
|
+
|
|
|
getVideoListByPage(token, startDate, endDate, page + 1);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -919,7 +931,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
|
|
|
historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
|
|
|
getVideoList(token, null, null);
|
|
|
- getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, null, null);
|
|
|
+ // getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, null, null);
|
|
|
String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
String videoEndDate = DateUtils.addDay(nowDate, -180);
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
@@ -1587,45 +1599,61 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
if (!Check.isNull(resultJson)) {
|
|
|
Integer code = resultJson.getInteger("code");
|
|
|
if (code == 0) {
|
|
|
- JSONArray dataArray = resultJson.getJSONArray("data");
|
|
|
- if (!Check.isNull(dataArray)) {
|
|
|
- KuaiShouAdvertiserBaseInfo baseInfo = KuaiShouAdvertiserBaseInfoService.getBaseInfo(accountId);
|
|
|
- Long userId = null;
|
|
|
- if (!Check.isNull(baseInfo)) {
|
|
|
- userId = Long.valueOf(baseInfo.getUserId());
|
|
|
+ JSONArray details = resultJson.getJSONArray("data");
|
|
|
+ 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;
|
|
|
}
|
|
|
- for (int i = 0; i < dataArray.size(); i++) {
|
|
|
- JSONObject detailJson = dataArray.getJSONObject(i);
|
|
|
- if (!Check.isNull(detailJson)) {
|
|
|
-
|
|
|
- KuaiShouVideoGet byId = kuaiShouVideoGetService.getById(accountId + photoId);
|
|
|
- if (!Check.isNull(byId)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
|
|
|
- kuaiShouVideoGet.setId(accountId + photoId);
|
|
|
-
|
|
|
- kuaiShouVideoGet.setAccountId(accountId);
|
|
|
- kuaiShouVideoGet.setStatDate(detailJson.getDate("upload_time"));
|
|
|
- kuaiShouVideoGet.setUpdateTime(new Date());
|
|
|
- Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
|
|
|
- if (!Check.isNull(type)) {
|
|
|
- kuaiShouVideoGet.setMaterialType(type);
|
|
|
- }
|
|
|
-
|
|
|
- kuaiShouVideoGet.setUserId(userId);
|
|
|
- kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
|
|
|
-
|
|
|
- Thread thread = new Thread() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- videoGetService.getKeyFrame(accessToken, accountId, kuaiShouVideoGet.getSignature(), kuaiShouVideoGet.getPhotoId());
|
|
|
- }
|
|
|
- };
|
|
|
- thread.start();
|
|
|
- }
|
|
|
+ KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
|
|
|
+ String photo_id = detailJson.getString("photo_id");
|
|
|
+ videoGet.setId(accountId + photo_id);
|
|
|
+ videoGet.setAccountId(accountId);
|
|
|
+ videoGet.setCoverUrl(detailJson.getString("cover_url"));
|
|
|
+
|
|
|
+ videoGet.setPhotoId(photo_id);
|
|
|
+ videoGet.setPhotoName(detailJson.getString("photo_name"));
|
|
|
+ videoGet.setStatDate(detailJson.getDate("upload_time"));
|
|
|
+ String signature = detailJson.getString("signature");
|
|
|
+ videoGet.setSignature(signature);
|
|
|
+ Integer source = detailJson.getInteger("source");
|
|
|
+ if (source == 2) {
|
|
|
+ videoGet.setChannelType(1);
|
|
|
+ } else {
|
|
|
+ videoGet.setChannelType(0);
|
|
|
+ }
|
|
|
+ Integer new_status = detailJson.getInteger("new_status");
|
|
|
+ if (new_status == 1) {
|
|
|
+ videoGet.setStatus(0);
|
|
|
+ } else {
|
|
|
+ videoGet.setStatus(1);
|
|
|
}
|
|
|
+ videoGet.setUrl(detailJson.getString("url"));
|
|
|
+ Integer width = detailJson.getInteger("width");
|
|
|
+ videoGet.setWidth(width);
|
|
|
+ Integer height = detailJson.getInteger("height");
|
|
|
+ videoGet.setHeight(height);
|
|
|
+ Integer type = MaterialEnum.getTypeBySize(width, height);
|
|
|
+ if (!Check.isNull(type)) {
|
|
|
+ videoGet.setMaterialType(type);
|
|
|
+ }
|
|
|
+ videoGetList.add(videoGet);
|
|
|
+ Thread thread = new Thread() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ videoGetService.getKeyFrame(accessToken, accountId, signature, photo_id);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ thread.start();
|
|
|
+ }
|
|
|
+ if (!Check.isNull(videoGetList)) {
|
|
|
+ videoGetService.replaceBatch(videoGetList);
|
|
|
}
|
|
|
+
|
|
|
} else {
|
|
|
log.error("获取广告视频信息返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
|
|
|
}
|
|
@@ -1633,9 +1661,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
} else {
|
|
|
log.error("获取广告视频信息返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
+ } catch (
|
|
|
+ Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2917,7 +2947,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
private IKuaiShouVideoGetService videoGetService;
|
|
|
static ExecutorService suZhaoService = Executors.newFixedThreadPool(15);
|
|
|
|
|
|
- @Override
|
|
|
+ /* @Override
|
|
|
public void getSuZaoList(String token, Long accountId, int page, String startDate, String endDate) {
|
|
|
String url = "https://ad.e.kuaishou.com/rest/openapi/v1/ad_creator/video/list";
|
|
|
Map<String, String> headers = new HashMap<String, String>();
|
|
@@ -2933,6 +2963,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
}
|
|
|
String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ System.err.println(resultJson);
|
|
|
if (Check.isNull(resultJson)) {
|
|
|
return;
|
|
|
}
|
|
@@ -2952,49 +2983,60 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
if (Check.isNull(details)) {
|
|
|
return;
|
|
|
}
|
|
|
- KuaiShouAdvertiserBaseInfo baseInfo = KuaiShouAdvertiserBaseInfoService.getBaseInfo(accountId);
|
|
|
- Long userId = null;
|
|
|
- if (!Check.isNull(baseInfo)) {
|
|
|
- userId = Long.valueOf(baseInfo.getUserId());
|
|
|
- }
|
|
|
+
|
|
|
+ List<KuaiShouVideoGet> videoGetList = new ArrayList<>();
|
|
|
for (int i = 0; i < details.size(); i++) {
|
|
|
- JSONObject jsonObject = details.getJSONObject(i);
|
|
|
- if (!Check.isNull(jsonObject)) {
|
|
|
- KuaiShouVideoGet kuaiShouVideoGet = new KuaiShouVideoGet();
|
|
|
- Long photo_id = jsonObject.getLong("photo_id");
|
|
|
- kuaiShouVideoGet.setId(String.valueOf(accountId) + String.valueOf(photo_id));
|
|
|
- kuaiShouVideoGet.setPhotoId(String.valueOf(photo_id));
|
|
|
- kuaiShouVideoGet.setUrl(jsonObject.getString("watermark_url"));
|
|
|
- kuaiShouVideoGet.setWidth(jsonObject.getInteger("width"));
|
|
|
- kuaiShouVideoGet.setHeight(jsonObject.getInteger("height"));
|
|
|
- kuaiShouVideoGet.setCoverUrl(jsonObject.getString("cover_url"));
|
|
|
- kuaiShouVideoGet.setAccountId(accountId);
|
|
|
- String md5 = jsonObject.getString("md5");
|
|
|
- kuaiShouVideoGet.setSignature(md5);
|
|
|
- kuaiShouVideoGet.setStatDate(jsonObject.getDate("sync_date"));
|
|
|
- kuaiShouVideoGet.setChannelType(1);
|
|
|
- kuaiShouVideoGet.setUserId(userId);
|
|
|
- kuaiShouVideoGet.setMaterialId(jsonObject.getString("material_id"));
|
|
|
- Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
|
|
|
- if (!Check.isNull(type)) {
|
|
|
- kuaiShouVideoGet.setMaterialType(type);
|
|
|
- }
|
|
|
- kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
|
|
|
- suZhaoService.submit(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- List<MaterialCutFrame> cutFrames = cutFrameService.getListByVideoSignature(md5);
|
|
|
- if (null == cutFrames || cutFrames.isEmpty()) {
|
|
|
- videoGetService.getKeyFrame(token, accountId, md5, String.valueOf(photo_id));
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+ JSONObject detailJson = details.getJSONObject(i);
|
|
|
+ if (Check.isNull(detailJson)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
|
|
|
+ String photo_id = detailJson.getString("photo_id");
|
|
|
+ videoGet.setId(accountId + photo_id);
|
|
|
+ videoGet.setAccountId(accountId);
|
|
|
+ videoGet.setCoverUrl(detailJson.getString("cover_url"));
|
|
|
+ videoGet.setPhotoId(photo_id);
|
|
|
+ videoGet.setPhotoName(detailJson.getString("photo_name"));
|
|
|
+ videoGet.setStatDate(detailJson.getDate("upload_time"));
|
|
|
+ String signature = detailJson.getString("signature");
|
|
|
+ videoGet.setSignature(signature);
|
|
|
+ Integer source = detailJson.getInteger("source");
|
|
|
+ if (source == 2) {
|
|
|
+ videoGet.setChannelType(1);
|
|
|
+ } else {
|
|
|
+ videoGet.setChannelType(0);
|
|
|
}
|
|
|
+ Integer new_status = detailJson.getInteger("new_status");
|
|
|
+ if (new_status == 1) {
|
|
|
+ videoGet.setStatus(0);
|
|
|
+ } else {
|
|
|
+ videoGet.setStatus(1);
|
|
|
+ }
|
|
|
+ videoGet.setUrl(detailJson.getString("url"));
|
|
|
+ Integer width = detailJson.getInteger("width");
|
|
|
+ videoGet.setWidth(width);
|
|
|
+ Integer height = detailJson.getInteger("height");
|
|
|
+ videoGet.setHeight(height);
|
|
|
+ Integer type = MaterialEnum.getTypeBySize(width, height);
|
|
|
+ if (!Check.isNull(type)) {
|
|
|
+ videoGet.setMaterialType(type);
|
|
|
+ }
|
|
|
+ videoGetList.add(videoGet);
|
|
|
+ Thread thread = new Thread() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ videoGetService.getKeyFrame(token, accountId, signature, photo_id);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ thread.start();
|
|
|
+ }
|
|
|
+ if (!Check.isNull(videoGetList)) {
|
|
|
+ videoGetService.replaceBatch(videoGetList);
|
|
|
}
|
|
|
|
|
|
getSuZaoList(token, accountId, page + 1, startDate, endDate);
|
|
|
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
@Autowired
|
|
|
private IMaterialCutFrameService cutFrameService;
|