|
@@ -14,11 +14,11 @@ import cn.com.ctop.common.module.utils.LoadFileUtil;
|
|
|
import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.http.ParseException;
|
|
|
-import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.modules.ctop.service.IKuaiShouUploadService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -43,11 +43,6 @@ import java.util.concurrent.Executors;
|
|
|
@Service
|
|
|
public class KuaiShouUploadServiceImpl implements IKuaiShouUploadService {
|
|
|
private static ExecutorService executorService = Executors.newFixedThreadPool(6);
|
|
|
-
|
|
|
- @Value("${oss.replace.replace-value}")
|
|
|
- private String replaceValue;
|
|
|
- @Value("${oss.replace.replace-old-value}")
|
|
|
- private String replaceOldValue;
|
|
|
@Value("${oss.replace.download}")
|
|
|
private String downloadUrl;
|
|
|
|
|
@@ -60,11 +55,13 @@ public class KuaiShouUploadServiceImpl implements IKuaiShouUploadService {
|
|
|
private MaterialParameterMapper parameterMapper;
|
|
|
@Autowired
|
|
|
private IKuaiShouVideoGetService kuaiShouVideoGetService;
|
|
|
+ @Autowired
|
|
|
+ private IKuaishouInterfaceService kuaishouInterfaceService;
|
|
|
|
|
|
@Override
|
|
|
public void upload(MaterialInfo materialInfo) {
|
|
|
try {
|
|
|
- String url = materialInfo.getUrl().replace(replaceOldValue, replaceValue);
|
|
|
+ String url = materialInfo.getUrl();
|
|
|
log.info("replaceUrl:{}", url);
|
|
|
String localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
|
|
|
FileSystemResource resource = new FileSystemResource(new File(localUrl));
|
|
@@ -95,7 +92,7 @@ public class KuaiShouUploadServiceImpl implements IKuaiShouUploadService {
|
|
|
if (!Check.isNull(list)) {
|
|
|
for (UserAllocation allocation : list) {
|
|
|
Long accountId = allocation.getAccountId();
|
|
|
- CtopOauthToken ctopOauthToken = oauthTokenService.getAccessTokenByAccountIdAndMediaId(2,accountId);
|
|
|
+ CtopOauthToken ctopOauthToken = oauthTokenService.getAccessTokenByAccountIdAndMediaId(2, accountId);
|
|
|
if (Check.isNull(ctopOauthToken)) {
|
|
|
log.error("快手账户信息为空,accountId:{}", accountId);
|
|
|
continue;
|
|
@@ -125,18 +122,19 @@ public class KuaiShouUploadServiceImpl implements IKuaiShouUploadService {
|
|
|
if (resultJson.getInteger("code") == 0) {
|
|
|
JSONObject dataJson = resultJson.getJSONObject("data");
|
|
|
if (!Check.isNull(dataJson)) {
|
|
|
- String photoId = dataJson.getString("photo_id");
|
|
|
- String signature = dataJson.getString("signature");
|
|
|
- KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
|
|
|
- videoGet.setAccountId(accountId);
|
|
|
- videoGet.setId(accountId + photoId);
|
|
|
- videoGet.setUrl(materialInfo.getUrl());
|
|
|
- videoGet.setCoverUrl(materialInfo.getUrl()+ "?x-oss-process=video/snapshot,t_00000,m_fast");
|
|
|
- videoGet.setStatDate(DateUtils.getNowDate());
|
|
|
- videoGet.setMaterialType(finalType);
|
|
|
- videoGet.setPhotoId(photoId);
|
|
|
- videoGet.setSignature(signature);
|
|
|
- kuaiShouVideoGetService.saveOrUpdate(videoGet);
|
|
|
+ Thread thread = new Thread() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ try {
|
|
|
+ Thread.sleep(2 * 1000L);
|
|
|
+ kuaishouInterfaceService.getVideoInfo(ctopOauthToken.getAccessToken(), ctopOauthToken.getAccountId(), dataJson.getString("photo_id"));
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ thread.start();
|
|
|
+
|
|
|
}
|
|
|
log.info("快手素材同步完成,accountId:{},code:{},返回信息:{}", accountId, materialInfo.getCode(), resultJson);
|
|
|
} else {
|