Browse Source

手动同步应用、生成水印

yumeng 4 năm trước cách đây
mục cha
commit
16d803f4ae

+ 42 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java

@@ -4,6 +4,7 @@ package org.jeecg.modules.ctop.controller;
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.entity.*;
 import cn.com.ctop.common.module.entity.*;
+import cn.com.ctop.common.module.enums.MaterialSupplierEnum;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.JsonUtil;
 import cn.com.ctop.common.module.utils.JsonUtil;
@@ -25,7 +26,6 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.DateUtils;
-import org.jeecg.modules.ctop.service.IKuaiShouUploadService;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
@@ -70,8 +70,47 @@ public class MaterialInfoController {
     private IProjectMemberService memberService;
     private IProjectMemberService memberService;
     @Autowired
     @Autowired
     private IMaterialImageInfoService iMaterialImageInfoService;
     private IMaterialImageInfoService iMaterialImageInfoService;
-    @Autowired
-    private IKuaiShouUploadService uploadService;
+
+
+    @GetMapping("/supplierWatermark")
+    public Result<String> supplierWatermark(String id) {
+        Result<String> result = new Result<>();
+        try {
+            if (Check.isNull(id)) {
+                throw new Exception("请选择素材");
+            }
+            MaterialInfo materialInfo = materialInfoService.getById(id);
+            if (Check.isNull(materialInfo)) {
+                throw new Exception("素材信息为空");
+            }
+            QueryWrapper<MaterialParameter> parameterQueryWrapper = new QueryWrapper<>();
+            parameterQueryWrapper.eq("material_id", materialInfo.getCode());
+            parameterQueryWrapper.last("limit 1");
+            MaterialParameter parameter = materialParameterService.getOne(parameterQueryWrapper);
+            if (Check.isNull(parameter)) {
+                throw new Exception("素材基本信息为空");
+            }
+
+            Long templateId = MaterialSupplierEnum.getTemplateIdBySize(Integer.valueOf(parameter.getWidth()), Integer.valueOf(parameter.getHeight()));
+            String s = null;
+            if (!Check.isNull(templateId)) {
+                s = materialInfoService.watermarkVideoBySupplierCode(materialInfo.getCode(), materialInfo.getUrl(), templateId);
+
+            }
+            if (Check.isNull(s)) {
+                result.setSuccess(false);
+                result.setMessage("水印生成失败");
+            } else {
+                result.setSuccess(true);
+                result.setResult(s);
+            }
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
 
 
 
 
     @PostMapping("/correlationUpload")
     @PostMapping("/correlationUpload")

+ 20 - 12
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -4,11 +4,14 @@ import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CorpWexinUtils;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.crawler.modules.pangolin.entity.PangolinApp;
 import cn.com.ctop.crawler.modules.pangolin.entity.PangolinApp;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinAppService;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinAppService;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceCampaignService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceCampaignService;
@@ -16,6 +19,8 @@ import cn.com.ctop.toutiao.modules.material.vo.BytedanceCampaignEditVo;
 import cn.com.ctop.toutiao.modules.report.service.IReportService;
 import cn.com.ctop.toutiao.modules.report.service.IReportService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.cp.bean.WxCpMessage;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.entity.KuaishouEffectVideoInfo;
 import org.jeecg.modules.ctop.entity.KuaishouEffectVideoInfo;
 import org.jeecg.modules.ctop.service.IKuaishouEffectVideoInfoService;
 import org.jeecg.modules.ctop.service.IKuaishouEffectVideoInfoService;
@@ -30,6 +35,11 @@ import java.util.List;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Executors;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.cp.api.WxCpService;
+import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
+import me.chanjar.weixin.cp.bean.WxCpMessage;
+import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
 
 
 @RunWith(SpringRunner.class)
 @RunWith(SpringRunner.class)
 @SpringBootTest
 @SpringBootTest
@@ -41,20 +51,18 @@ public class SampleTest {
     private IByteDanceAdvertiserDataService advertiserDataService;
     private IByteDanceAdvertiserDataService advertiserDataService;
     @Autowired
     @Autowired
     private IReportService reportService;
     private IReportService reportService;
+    @Autowired
+    private IKuaishouInterfaceService interfaceService;
+
     @Test
     @Test
     public void loadBytedanceCampaignData() {
     public void loadBytedanceCampaignData() {
-//        List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
-//        tokens.forEach(token -> campaignService.getAdvertiserCampaign(token, null, null));
-//        campaignService.createCampaign(1649600126891015L,"测试广告组123",null,"BUDGET_MODE_DAY",15000,"APP",null);
-//        campaignService.getAdvertiserCampaign(token, null, null);
-
-        campaignService.updateCampaignStatus(1649600126891015L,"1673352811480076,1673351071217708","enable");
-        BytedanceCampaignEditVo vo = new BytedanceCampaignEditVo();
-        vo.setAccountId(1649600126891015L);
-        vo.setId(1673352811480076L);
-        vo.setCampaignName("咩哈哈哈哈哈");
-        vo.setBudget(10000);
-        campaignService.updateCampaign(vo);
+
+
+       // CorpWexinUtils.sendMessageByWeChatId("34585ddd4bd86e57756cf6a51b9443a5","测试消息发送");
+        interfaceService.getAppList(23212L,"493aedfee07d9c500c50077e7c808145");
+
+
+
     }
     }
 
 
     @Autowired
     @Autowired

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialInfoService.java

@@ -24,7 +24,7 @@ public interface IMaterialInfoService extends IService<MaterialInfo> {
      * @param videoUrl
      * @param videoUrl
      * @param templateId
      * @param templateId
      */
      */
-    void watermarkVideoBySupplierCode(String videoSignature, String videoUrl, Long templateId);
+    String watermarkVideoBySupplierCode(String videoSignature, String videoUrl, Long templateId);
 
 
     MaterialInfo getMaterialInfoByCodeAndProjectId(String code, Long projectId);
     MaterialInfo getMaterialInfoByCodeAndProjectId(String code, Long projectId);
 
 

+ 40 - 35
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -107,7 +107,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
 
 
 
 
     @Override
     @Override
-    public void watermarkVideoBySupplierCode(String videoSignature, String videoUrl, Long templateId) {
+    public String watermarkVideoBySupplierCode(String videoSignature, String videoUrl, Long templateId) {
         try {
         try {
 
 
             QueryWrapper<SupplierWatermark> supplierWatermarkQueryWrapper = new QueryWrapper<>();
             QueryWrapper<SupplierWatermark> supplierWatermarkQueryWrapper = new QueryWrapper<>();
@@ -116,48 +116,44 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
             SupplierWatermark one = supplierWatermarkService.getOne(supplierWatermarkQueryWrapper);
             SupplierWatermark one = supplierWatermarkService.getOne(supplierWatermarkQueryWrapper);
             if (!Check.isNull(one)) {
             if (!Check.isNull(one)) {
                 log.info("供应商水印已存在,videoCode:{}", videoSignature);
                 log.info("供应商水印已存在,videoCode:{}", videoSignature);
-                return;
+                return one.getWatermarkUrl();
             }
             }
+            String path = URLDecoder.decode(videoUrl).replace("https://media-1301855440.cos.ap-chongqing.myqcloud.com/", "");
+            String taskId = videoWatermarkHandle(path, templateId);
+            DescribeTaskDetailResponse taskDetailResponse = null;
+            for (int i = 0; i < 30; i++) {
+                try {
+                    Thread.sleep(2000);
+                } catch (InterruptedException e) {
+                    log.error(e.getMessage());
+                }
+                taskDetailResponse = getTaskDetailResponse(taskId);
+                if (taskDetailResponse.getStatus().equals("FINISH")) {
+                    break;
+                }
+            }
+            if (taskDetailResponse.getStatus().equals("FINISH")) {
+                String url = taskDetailResponse.getWorkflowTask().getMediaProcessResultSet()[0].getTranscodeTask().getOutput().getPath();
+                SupplierWatermark supplierWatermark = new SupplierWatermark();
+                supplierWatermark.setVideoSignature(videoSignature);
+                String watermarkUrl = "https://media-1301855440.cos.ap-chongqing.myqcloud.com" + url;
+                supplierWatermark.setWatermarkUrl(watermarkUrl);
+                boolean save = supplierWatermarkService.save(supplierWatermark);
+                if (save) {
+                    log.info("供应商水印生成完毕,videoCode:{}", videoSignature);
 
 
-
-            Thread thread = new Thread() {
-                @Override
-                public void run() {
-                    String path = URLDecoder.decode(videoUrl).replace("https://media-1301855440.cos.ap-chongqing.myqcloud.com/", "");
-                    String taskId = videoWatermarkHandle(path, templateId);
-                    DescribeTaskDetailResponse taskDetailResponse = null;
-                    for (int i = 0; i < 20; i++) {
-                        try {
-                            Thread.sleep(2000);
-                        } catch (InterruptedException e) {
-                            log.error(e.getMessage());
-                        }
-                        taskDetailResponse = getTaskDetailResponse(taskId);
-                        if (taskDetailResponse.getStatus().equals("FINISH")) {
-                            break;
-                        }
-                    }
-                    if (taskDetailResponse.getStatus().equals("FINISH")) {
-                        String url = taskDetailResponse.getWorkflowTask().getMediaProcessResultSet()[0].getTranscodeTask().getOutput().getPath();
-                        SupplierWatermark supplierWatermark = new SupplierWatermark();
-                        supplierWatermark.setVideoSignature(videoSignature);
-                        supplierWatermark.setWatermarkUrl("https://media-1301855440.cos.ap-chongqing.myqcloud.com" + url);
-                        boolean save = supplierWatermarkService.save(supplierWatermark);
-                        if (save) {
-                            log.info("供应商水印生成完毕,videoCode:{}", videoSignature);
-
-                        }
-                    }
                 }
                 }
-            };
-            thread.start();
+                return watermarkUrl;
+            }
+
 
 
         } catch (Exception e) {
         } catch (Exception e) {
             log.info("供应商水印生成异常,videoCode:{}", videoSignature);
             log.info("供应商水印生成异常,videoCode:{}", videoSignature);
             e.printStackTrace();
             e.printStackTrace();
 
 
-        }
 
 
+        }
+        return null;
 
 
     }
     }
 
 
@@ -443,7 +439,16 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                                 // 默认抽帧 素造供应商
                                 // 默认抽帧 素造供应商
                                 Long templateId = MaterialSupplierEnum.getTemplateIdBySize(Integer.valueOf(width), Integer.valueOf(height));
                                 Long templateId = MaterialSupplierEnum.getTemplateIdBySize(Integer.valueOf(width), Integer.valueOf(height));
                                 if (!Check.isNull(templateId)) {
                                 if (!Check.isNull(templateId)) {
-                                    watermarkVideoBySupplierCode(materialInfo.getCode(), materialInfo.getUrl(), templateId);
+
+                                    Thread thread = new Thread() {
+                                        @Override
+                                        public void run() {
+                                            watermarkVideoBySupplierCode(materialInfo.getCode(), materialInfo.getUrl(), templateId);
+                                        }
+                                    };
+                                    thread.start();
+
+
                                 }
                                 }
                             }
                             }
 
 

+ 36 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java

@@ -2239,6 +2239,12 @@ public class BatchController {
     }
     }
 
 
 
 
+    /**
+     * 同步素材
+     *
+     * @param accountId
+     * @return
+     */
     @GetMapping(value = "/syncVideo")
     @GetMapping(value = "/syncVideo")
     public Result<Boolean> syncVideo(Long accountId) {
     public Result<Boolean> syncVideo(Long accountId) {
         Result<Boolean> result = new Result<>();
         Result<Boolean> result = new Result<>();
@@ -2258,4 +2264,34 @@ public class BatchController {
     }
     }
 
 
 
 
+    /**
+     * 同步应用
+     *
+     * @param accountId
+     * @return
+     */
+    @GetMapping(value = "/syncAppList")
+    public Result<Boolean> syncAppList(Long accountId) {
+        Result<Boolean> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("入参为空");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            iKuaishouInterfaceService.getAppList(oauthToken.getAccountId(), oauthToken.getAccessToken());
+            result.setSuccess(true);
+            result.setResult(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setResult(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
+
 }
 }

+ 0 - 7
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java

@@ -265,13 +265,6 @@ public interface IKuaishouInterfaceService {
      */
      */
     void getAppList(Long advertiserId, String accessToken);
     void getAppList(Long advertiserId, String accessToken);
 
 
-    /**
-     * 获取应用列表
-     *
-     * @param advertiserId
-     * @param accessToken
-     */
-    void getAppList2(Long advertiserId, String accessToken);
 
 
     /**
     /**
      * 文件上传 发送请求
      * 文件上传 发送请求

+ 5 - 10
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -2424,13 +2424,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         return returnMap;
         return returnMap;
     }
     }
 
 
-    /**
-     * 获取应用列表
-     *
-     * @param advertiserId
-     * @param accessToken
-     */
-    @Override
+
+    /*@Override
     public void getAppList(Long advertiserId, String accessToken) {
     public void getAppList(Long advertiserId, String accessToken) {
         try {
         try {
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.APP_LIST;
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.APP_LIST;
@@ -2476,7 +2471,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
         }
         }
-    }
+    }*/
 
 
 
 
     public Object jsonToObj(Object t, String jsonStr) throws
     public Object jsonToObj(Object t, String jsonStr) throws
@@ -3242,8 +3237,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
      * @param accessToken
      * @param accessToken
      */
      */
     @Override
     @Override
-    public void getAppList2(Long advertiserId, String accessToken) {
-        Integer pageSize = 20;
+    public void getAppList(Long advertiserId, String accessToken) {
+        Integer pageSize = 50;
         Integer page = 1;
         Integer page = 1;
         getAppList2ByPage(advertiserId, accessToken, page, pageSize);
         getAppList2ByPage(advertiserId, accessToken, page, pageSize);
     }
     }