|
@@ -10,6 +10,8 @@ import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
import cn.com.ctop.common.module.utils.LoadFileUtil;
|
|
import cn.com.ctop.common.module.utils.LoadFileUtil;
|
|
import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAdvertiserBaseInfo;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAdvertiserBaseInfoService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
import cn.com.ctop.manage.modules.material.service.IMaterialUploadImageService;
|
|
import cn.com.ctop.manage.modules.material.service.IMaterialUploadImageService;
|
|
import cn.com.ctop.manage.modules.material.service.IMaterialUploadService;
|
|
import cn.com.ctop.manage.modules.material.service.IMaterialUploadService;
|
|
@@ -91,16 +93,16 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
|
|
for (int j = 0; j < materialArray.size(); j++) {
|
|
for (int j = 0; j < materialArray.size(); j++) {
|
|
String materialId = materialArray.getString(j);
|
|
String materialId = materialArray.getString(j);
|
|
MaterialInfo materialInfo = materialInfoMapper.selectById(materialId);
|
|
MaterialInfo materialInfo = materialInfoMapper.selectById(materialId);
|
|
- MaterialImageInfo materialImageInfo= materialImageInfoMapper.selectById(materialId);
|
|
|
|
- if (Check.isNull(materialInfo)&&Check.isNull(materialImageInfo)) {
|
|
|
|
|
|
+ MaterialImageInfo materialImageInfo = materialImageInfoMapper.selectById(materialId);
|
|
|
|
+ if (Check.isNull(materialInfo) && Check.isNull(materialImageInfo)) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
String url = "";
|
|
String url = "";
|
|
- if(Check.isNull(materialInfo)){
|
|
|
|
- url= (String) materialImageInfo.getUrl();
|
|
|
|
- }else {
|
|
|
|
- url= materialInfo.getUrl();
|
|
|
|
|
|
+ if (Check.isNull(materialInfo)) {
|
|
|
|
+ url = (String) materialImageInfo.getUrl();
|
|
|
|
+ } else {
|
|
|
|
+ url = materialInfo.getUrl();
|
|
}
|
|
}
|
|
String localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
|
|
String localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
|
|
|
|
|
|
@@ -115,7 +117,7 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
|
|
public void run() {
|
|
public void run() {
|
|
try {
|
|
try {
|
|
log.info("头条文件多线程上传:{},accountId:{}", Thread.currentThread().getName(), accountId);
|
|
log.info("头条文件多线程上传:{},accountId:{}", Thread.currentThread().getName(), accountId);
|
|
- if (materialInfo!=null&&"VIDEO".equals(materialInfo.getType())) {
|
|
|
|
|
|
+ if (materialInfo != null && "VIDEO".equals(materialInfo.getType())) {
|
|
fileInfoService.uploadVideoToBytedance(String.valueOf(accountId), localUrl, userId, materialInfo.getMaterialName());
|
|
fileInfoService.uploadVideoToBytedance(String.valueOf(accountId), localUrl, userId, materialInfo.getMaterialName());
|
|
|
|
|
|
} else if ("IMAGE".equals(materialImageInfo.getType())) {
|
|
} else if ("IMAGE".equals(materialImageInfo.getType())) {
|
|
@@ -133,6 +135,9 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouAdvertiserBaseInfoService advertiserBaseInfoService;
|
|
|
|
+
|
|
private void kuaiShouUpload(String mediaId, JSONArray materialArray, JSONArray accountArray, String userId) {
|
|
private void kuaiShouUpload(String mediaId, JSONArray materialArray, JSONArray accountArray, String userId) {
|
|
for (int j = 0; j < materialArray.size(); j++) {
|
|
for (int j = 0; j < materialArray.size(); j++) {
|
|
String materialId = materialArray.getString(j);
|
|
String materialId = materialArray.getString(j);
|
|
@@ -182,41 +187,23 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
|
|
String result = exceptInfoForRestTemplate(url, requestJson, headerMap);
|
|
String result = exceptInfoForRestTemplate(url, requestJson, headerMap);
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
if (!Check.isNull(resultJson)) {
|
|
if (!Check.isNull(resultJson)) {
|
|
|
|
+ KuaiShouAdvertiserBaseInfo baseInfo = advertiserBaseInfoService.getBaseInfo(accountId);
|
|
|
|
+
|
|
if (resultJson.getInteger("code") == 0) {
|
|
if (resultJson.getInteger("code") == 0) {
|
|
JSONObject dataJson = resultJson.getJSONObject("data");
|
|
JSONObject dataJson = resultJson.getJSONObject("data");
|
|
if (!Check.isNull(dataJson)) {
|
|
if (!Check.isNull(dataJson)) {
|
|
-
|
|
|
|
String signature = dataJson.getString("signature");
|
|
String signature = dataJson.getString("signature");
|
|
- /*
|
|
|
|
- String photoId = dataJson.getString("photo_id");
|
|
|
|
- KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
|
|
|
|
- videoGet.setAccountId(accountId);
|
|
|
|
- videoGet.setId(accountId + photoId);
|
|
|
|
- videoGet.setUrl(materialInfo.getUrl());
|
|
|
|
- QueryWrapper<MaterialParameter> parameterQueryWrapper = new QueryWrapper<>();
|
|
|
|
- parameterQueryWrapper.eq("material_id", signature);
|
|
|
|
- parameterQueryWrapper.last("limit 1");
|
|
|
|
-
|
|
|
|
- MaterialParameter materialParameter = parameterMapper.selectOne(parameterQueryWrapper);
|
|
|
|
- if (!Check.isNull(materialParameter)) {
|
|
|
|
- String width = materialParameter.getWidth();
|
|
|
|
- String height = materialParameter.getHeight();
|
|
|
|
- videoGet.setWidth(Integer.valueOf(width));
|
|
|
|
- videoGet.setHeight(Integer.valueOf(height));
|
|
|
|
- Integer type = MaterialEnum.getTypeBySize(Integer.valueOf(width), Integer.valueOf(height));
|
|
|
|
- if (!Check.isNull(type)) {
|
|
|
|
- videoGet.setMaterialType(type);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- videoGet.setPhotoId(photoId);
|
|
|
|
- videoGet.setSignature(signature);
|
|
|
|
- String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
|
- videoGet.setStatDate(DateUtils.parseDate(nowDate, "yyyy-MM-dd"));
|
|
|
|
- videoGet.setCoverUrl(materialInfo.getUrl() + "?x-oss-process=video/snapshot,t_0,m_fast");
|
|
|
|
- videoGet.setUploadDate(new Date());
|
|
|
|
- kuaiShouVideoGetService.saveOrUpdate(videoGet);*/
|
|
|
|
|
|
+ //同步 视频关联的封面
|
|
materialUploadImageService.uploadImage(signature, accountId, ctopOauthToken.getAccessToken());
|
|
materialUploadImageService.uploadImage(signature, accountId, ctopOauthToken.getAccessToken());
|
|
|
|
+ // 发送推送成功通知
|
|
|
|
+ UserAllocation allocation = userAllocationService.getByAccountId(accountId);
|
|
|
|
+ Project project = projectService.getById(allocation.getProjectId());
|
|
|
|
+ String message = messageTemplate.getMaterialSyncSucessTemplate(project.getProjectName(), baseInfo.getUserId(), baseInfo.getUserName(), materialInfo.getMaterialName(), resultJson.getString("message"));
|
|
|
|
+ sendMessageService.sendMessage(userId, message);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 异步获取视频信息
|
|
|
|
+ */
|
|
Thread thread = new Thread() {
|
|
Thread thread = new Thread() {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
@@ -233,10 +220,10 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
|
|
log.info("快手素材同步完成,accountId:{},code:{},返回信息:{}", accountId, materialInfo.getCode(), resultJson);
|
|
log.info("快手素材同步完成,accountId:{},code:{},返回信息:{}", accountId, materialInfo.getCode(), resultJson);
|
|
} else {
|
|
} else {
|
|
log.error("快手同步素材失败,返回信息:{},请求参数:{}", resultJson, requestJson);
|
|
log.error("快手同步素材失败,返回信息:{},请求参数:{}", resultJson, requestJson);
|
|
- // 发送消息到上传人
|
|
|
|
|
|
+ // 发送推送失败消息到上传人
|
|
UserAllocation allocation = userAllocationService.getByAccountId(accountId);
|
|
UserAllocation allocation = userAllocationService.getByAccountId(accountId);
|
|
Project project = projectService.getById(allocation.getProjectId());
|
|
Project project = projectService.getById(allocation.getProjectId());
|
|
- String message = messageTemplate.getMaterialSyncTemplate(project.getProjectName(), accountId, allocation.getAuthName(), materialInfo.getMaterialName(), resultJson.getString("message"));
|
|
|
|
|
|
+ String message = messageTemplate.getMaterialSyncTemplate(project.getProjectName(), baseInfo.getUserId(), baseInfo.getUserName(), materialInfo.getMaterialName(), resultJson.getString("message"));
|
|
sendMessageService.sendMessage(userId, message);
|
|
sendMessageService.sendMessage(userId, message);
|
|
}
|
|
}
|
|
}
|
|
}
|