فهرست منبع

Merge branch 'master' of http://git.tjyourong.com.cn/ctop/adsp-boot

xuzuoyun 5 سال پیش
والد
کامیت
1669318bd8

+ 115 - 47
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java

@@ -298,64 +298,132 @@ public class CallbackController {
                 return returnMap;
 
             }
-
             data.remove("advertiser_ids");
             StringBuilder text = new StringBuilder();
             for (int i = 0; i < advertiser_ids.size(); i++) {
                 Long advertiser_id = advertiser_ids.getLong(i);
-                data.put("advertiser_id", advertiser_id);
-                CtopOauthToken token = new CtopOauthToken(advertiserId, data);
-                ctopOauthTokenService.saveOrUpdate(token);
-                //获取广告主信息
-                Map<String, Object> advertiserDataMap = advertiserDataService.getAdvertiserInfo(token.getAccountId() + "");
-                Boolean getSuccess = (Boolean) advertiserDataMap.get("success");
-                if (null == getSuccess || !getSuccess) {
-                    log.info("获取广告主信息失败,accountId:{},message:{}", token.getAccountId(), (String) advertiserDataMap.get("message"));
-                    continue;
-                }
+                JSONObject adJson = advertiserDataService.getAdvertiserList(data.getString("access_token"), advertiser_id);
+                Integer returnCode = adJson.getInteger("code");
+                if (returnCode == 0) {
+                    JSONArray dataArr = adJson.getJSONArray("data");
+                    if (!Check.isNull(dataArr)) {
+                        for (int j = 0; j < dataArr.size(); j++) {
+                            JSONObject dataJson = dataArr.getJSONObject(j);
+                            Long advertiser_id1 = dataJson.getLong("advertiser_id");
+                            data.put("advertiser_id", advertiser_id1);
+                            CtopOauthToken token = new CtopOauthToken(advertiserId, data);
+                            ctopOauthTokenService.saveOrUpdate(token);
+                            //获取广告主信息
+                            Map<String, Object> advertiserDataMap = advertiserDataService.getAdvertiserInfo(token.getAccountId() + "");
+                            Boolean getSuccess = (Boolean) advertiserDataMap.get("success");
+                            if (null == getSuccess || !getSuccess) {
+                                log.info("获取广告主信息失败,accountId:{},message:{}", token.getAccountId(), (String) advertiserDataMap.get("message"));
+                                text.append("账户id:" + advertiser_id + "暂未获取数据权限,请检查账户")
+                                        .append("<br/>");
+                                continue;
+                            }
 
-                Long accountId = token.getAccountId();
-                QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
-                userAllocationQueryWrapper.eq("account_id", accountId);
-                userAllocationQueryWrapper.eq("media_id", 1);
-                userAllocationQueryWrapper.orderByDesc("create_time");
-                userAllocationQueryWrapper.last("limit 1");
-                UserAllocation checkUserAllocation = allocationMapper.selectOne(userAllocationQueryWrapper);
-                if (!Check.isNull(checkUserAllocation)) {
-                    text.append("accountId:" + accountId + ",授权名称为:" + (String) advertiserDataMap.get("name") + ",绑定失败,失败原因:已被" + checkUserAllocation.getUserName() + "绑定。")
-                            .append("<br/>");
-                    continue;
-                }
-                text.append("accountId:" + accountId + ",授权名称为:" + (String) advertiserDataMap.get("name") + ",绑定成功。").append("<br/>");
-                String systemType = json.getString("systemType");
-                UserAllocation userAllocation = new UserAllocation();
-                userAllocation.setUserId(userId);
-                userAllocation.setUserName(userName);
-                userAllocation.setAccountId(token.getAccountId());
-                userAllocation.setAdvertiserName(advertiserName);
-                userAllocation.setMediaId(mediaId);
-                userAllocation.setProjectId(projectId);
-                userAllocation.setProjectName(projectName);
-                userAllocation.setSystemType(systemType);
-                userAllocation.setAuthName((String) advertiserDataMap.get("name"));
-                userAllocation.setAdvertiserId(advertiserId);
-                userAllocation.setWarningProportion(warningProportion);
-                userAllocation.setWarningAmount(warningAmount);
-                userAllocation.setCreateTime(new Date());
-                userAllocation.setUpdateTime(new Date());
-                int j = allocationMapper.insert(userAllocation);
-                if (j > 0) {
-                    log.info("同步分配用户表完成,task_id:{},accountId:{}", state, token.getAccountId());
+                            Long accountId = token.getAccountId();
+                            QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
+                            userAllocationQueryWrapper.eq("account_id", accountId);
+                            userAllocationQueryWrapper.eq("media_id", 1);
+                            userAllocationQueryWrapper.orderByDesc("create_time");
+                            userAllocationQueryWrapper.last("limit 1");
+                            UserAllocation checkUserAllocation = allocationMapper.selectOne(userAllocationQueryWrapper);
+                            if (!Check.isNull(checkUserAllocation)) {
+                                text.append("账户id:" + accountId + ",授权名称为:" + (String) advertiserDataMap.get("name") + ",绑定失败,失败原因:已被" + checkUserAllocation.getUserName() + "绑定。")
+                                        .append("<br/>");
+                                continue;
+                            }
+                            text.append("accountId:" + accountId + ",授权名称为:" + (String) advertiserDataMap.get("name") + ",绑定成功。").append("<br/>");
+                            String systemType = json.getString("systemType");
+                            UserAllocation userAllocation = new UserAllocation();
+                            userAllocation.setUserId(userId);
+                            userAllocation.setUserName(userName);
+                            userAllocation.setAccountId(token.getAccountId());
+                            userAllocation.setAdvertiserName(advertiserName);
+                            userAllocation.setMediaId(mediaId);
+                            userAllocation.setProjectId(projectId);
+                            userAllocation.setProjectName(projectName);
+                            userAllocation.setSystemType(systemType);
+                            userAllocation.setAuthName((String) advertiserDataMap.get("name"));
+                            userAllocation.setAdvertiserId(advertiserId);
+                            userAllocation.setWarningProportion(warningProportion);
+                            userAllocation.setWarningAmount(warningAmount);
+                            userAllocation.setCreateTime(new Date());
+                            userAllocation.setUpdateTime(new Date());
+                            int g = allocationMapper.insert(userAllocation);
+                            if (g > 0) {
+                                log.info("同步分配用户表完成,task_id:{},accountId:{}", state, token.getAccountId());
+                            }
+                            //账号绑定
+                            bindAccountAuthService.addBindAccount(token.getAccountId(), KuaishouInterfaceConstant.LOGIN_TYPE_BYTEDANCE, advertiserId);
+                            new Thread(() -> reportService.loadBytedanceHistoryData(token)).start();
+                        }
+
+                    }
+
+                } else {
+                    data.put("advertiser_id", advertiser_id);
+                    CtopOauthToken token = new CtopOauthToken(advertiserId, data);
+                    ctopOauthTokenService.saveOrUpdate(token);
+                    //获取广告主信息
+                    Map<String, Object> advertiserDataMap = advertiserDataService.getAdvertiserInfo(token.getAccountId() + "");
+                    Boolean getSuccess = (Boolean) advertiserDataMap.get("success");
+                    if (null == getSuccess || !getSuccess) {
+                        log.info("获取广告主信息失败,accountId:{},message:{}", token.getAccountId(), (String) advertiserDataMap.get("message"));
+                        text.append("accountId:" + advertiser_id + "暂未获取数据权限,请检查账户")
+                                .append("<br/>");
+                        continue;
+                    }
+
+                    Long accountId = token.getAccountId();
+                    QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
+                    userAllocationQueryWrapper.eq("account_id", accountId);
+                    userAllocationQueryWrapper.eq("media_id", 1);
+                    userAllocationQueryWrapper.orderByDesc("create_time");
+                    userAllocationQueryWrapper.last("limit 1");
+                    UserAllocation checkUserAllocation = allocationMapper.selectOne(userAllocationQueryWrapper);
+                    if (!Check.isNull(checkUserAllocation)) {
+                        text.append("账户id:" + accountId + ",授权名称为:" + (String) advertiserDataMap.get("name") + ",绑定失败,失败原因:已被" + checkUserAllocation.getUserName() + "绑定。")
+                                .append("<br/>");
+                        continue;
+                    }
+                    text.append("账户id:" + accountId + ",授权名称为:" + (String) advertiserDataMap.get("name") + ",绑定成功。").append("<br/>");
+                    String systemType = json.getString("systemType");
+                    UserAllocation userAllocation = new UserAllocation();
+                    userAllocation.setUserId(userId);
+                    userAllocation.setUserName(userName);
+                    userAllocation.setAccountId(token.getAccountId());
+                    userAllocation.setAdvertiserName(advertiserName);
+                    userAllocation.setMediaId(mediaId);
+                    userAllocation.setProjectId(projectId);
+                    userAllocation.setProjectName(projectName);
+                    userAllocation.setSystemType(systemType);
+                    userAllocation.setAuthName((String) advertiserDataMap.get("name"));
+                    userAllocation.setAdvertiserId(advertiserId);
+                    userAllocation.setWarningProportion(warningProportion);
+                    userAllocation.setWarningAmount(warningAmount);
+                    userAllocation.setCreateTime(new Date());
+                    userAllocation.setUpdateTime(new Date());
+                    int g = allocationMapper.insert(userAllocation);
+                    if (g > 0) {
+                        log.info("同步分配用户表完成,task_id:{},accountId:{}", state, token.getAccountId());
+                    }
+                    //账号绑定
+                    bindAccountAuthService.addBindAccount(token.getAccountId(), KuaishouInterfaceConstant.LOGIN_TYPE_BYTEDANCE, advertiserId);
+                    new Thread(() -> reportService.loadBytedanceHistoryData(token)).start();
                 }
-                //账号绑定
-                bindAccountAuthService.addBindAccount(token.getAccountId(), KuaishouInterfaceConstant.LOGIN_TYPE_BYTEDANCE, advertiserId);
-                new Thread(() -> reportService.loadBytedanceHistoryData(token)).start();
+
+
             }
 
+
             returnMap.put("code", 0);
             returnMap.put("desc", text.toString());
 
-        } catch (Exception e) {
+        } catch (
+                Exception e) {
             e.printStackTrace();
             returnMap.put("code", -1);
             returnMap.put("desc", "回调token异常");

+ 103 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialCutFrameController.java

@@ -1,7 +1,13 @@
 package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.common.module.entity.MaterialCutFrame;
+import cn.com.ctop.common.module.entity.MaterialCutFrameTask;
+import cn.com.ctop.common.module.entity.MaterialInfo;
+import cn.com.ctop.common.module.entity.MaterialParameter;
 import cn.com.ctop.common.module.service.IMaterialCutFrameService;
+import cn.com.ctop.common.module.service.IMaterialCutFrameTaskService;
+import cn.com.ctop.common.module.service.IMaterialInfoService;
+import cn.com.ctop.common.module.utils.Check;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -17,6 +23,8 @@ import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 import java.util.Arrays;
 import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 
 /**
@@ -33,6 +41,10 @@ import java.util.List;
 public class MaterialCutFrameController {
     @Autowired
     private IMaterialCutFrameService materialCutFrameService;
+    @Autowired
+    private IMaterialInfoService materialInfoService;
+    @Autowired
+    private IMaterialCutFrameTaskService materialCutFrameTaskServiceTask;
 
     /**
      * 分页列表查询
@@ -168,4 +180,95 @@ public class MaterialCutFrameController {
         }
         return result;
     }
+
+
+    @AutoLog(value = "腾讯云抽帧按照素材创建时间筛选素材进行抽帧操作")
+    @ApiOperation(value = "腾讯云抽帧", notes = "腾讯云抽帧")
+    @GetMapping(value = "/getCosCutFrameByTime")
+    public Result getCosCutFrameByTime(@RequestParam(name = "startDate", required = true) String startDate,
+                                 @RequestParam(name = "endDate", required = true) String endDate) {
+        Result result = new Result();
+        result.setSuccess(true);
+
+        try {
+            List<MaterialInfo> materialInfos = materialInfoService.getListByDate(startDate, endDate);
+            if (!Check.isNull(materialInfos)) {
+                for (MaterialInfo materialInfo : materialInfos) {
+                    if (!Check.isNull(materialInfo)) {
+                        String code = materialInfo.getCode();
+                        materialCutFrameService.getCosCutFrame(materialInfo.getUrl(), code);
+                    }
+                }
+            }
+        }catch (Exception e){
+            log.error(e.getMessage());
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+
+        return result;
+    }
+
+    @AutoLog(value = "腾讯云抽帧--根据md5抽帧")
+    @ApiOperation(value = "腾讯云抽帧", notes = "腾讯云抽帧")
+    @GetMapping(value = "/getCosCutFrame")
+    public Result getCosCutFrame(@RequestParam(name = "code", required = true) String code) {
+        Result result = new Result();
+        result.setSuccess(true);
+
+        try {
+            MaterialInfo materialInfo = materialInfoService.getMaterialInfoByCode(code);
+            if (!Check.isNull(materialInfo)) {
+                materialCutFrameService.getCosCutFrame(materialInfo.getUrl(), code);
+            }
+        }catch (Exception e){
+            log.error(e.getMessage());
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+
+        return result;
+    }
+
+
+    @AutoLog(value = "腾讯云抽帧--获取任务状态并将图片入库")
+    @ApiOperation(value = "腾讯云抽帧", notes = "腾讯云抽帧")
+    @GetMapping(value = "/loadCosCutFrame")
+    public Result loadCosCutFrame() {
+        Result result = new Result();
+        result.setSuccess(true);
+
+        log.info("开始抽帧定时任务");
+        QueryWrapper<MaterialCutFrameTask> taskQueryWrapper = new QueryWrapper<>();
+        taskQueryWrapper.eq("job_status", 0);
+        taskQueryWrapper.eq("cloud_type",2);  //2为腾讯云 1为阿里云
+        List<MaterialCutFrameTask> list = materialCutFrameTaskServiceTask.list(taskQueryWrapper);
+
+        if (Check.isNull(list)) {
+            result.setCode(500);
+            result.setSuccess(false);
+            return result;
+        }
+
+        ExecutorService executorService = Executors.newFixedThreadPool(5);
+        list.forEach(cutFrameTask -> {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                    //获取广告计划信息数据
+                    materialCutFrameService.loadCosCutFrame(cutFrameTask.getJobId(), cutFrameTask.getVideoSignature());
+                    }catch (Exception e){
+                        log.error(e.getMessage());
+                        e.printStackTrace();
+                    }
+                }
+            });
+        });
+
+        return result;
+    }
+
+
+
 }

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/CutFrameJob.java

@@ -35,6 +35,7 @@ public class CutFrameJob implements Job {
                 log.info("开始抽帧定时任务");
                 QueryWrapper<MaterialCutFrameTask> taskQueryWrapper = new QueryWrapper<>();
                 taskQueryWrapper.eq("job_status", 0);
+                //taskQueryWrapper.eq("cloud_type", 2);
                 List<MaterialCutFrameTask> list = taskService.list(taskQueryWrapper);
 
                 if (Check.isNull(list)) {
@@ -47,6 +48,7 @@ public class CutFrameJob implements Job {
                         public void run() {
                             //获取广告计划信息数据
                             materialCutFrameService.loadCutFrame(cutFrameTask.getJobId(), cutFrameTask.getVideoSignature());
+                            //materialCutFrameService.loadCosCutFrame(cutFrameTask.getJobId(), cutFrameTask.getVideoSignature());  //腾讯云任务状态查询以及图片下载
                         }
                     });
                 });

+ 7 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectMemberServiceImpl.java

@@ -86,9 +86,15 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
         } else if (roleCode.equals("admin")) {
             projectMemberList = memberMapper.adminProjects(mediaIds);
         } else if (roleCode.equals("operator") || roleCode.equals("operationAssistant") || roleCode.equals("touTiaoOperationManager")) {
-            projectMemberList = memberMapper.operationProjects(userId, mediaIds);
+            projectMemberList = memberMapper.designProjects(userId, mediaIds);
+        }else{
+            //如果以上角色都不是的话直接查询此角色所属项目
+            projectMemberList = memberMapper.designProjects(userId, mediaIds);
         }
 
+        if(null == projectMemberList){
+            projectMemberList = new ArrayList<>();
+        }
         return projectMemberList;
     }
 

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialCutFrameTask.java

@@ -60,4 +60,6 @@ public class MaterialCutFrameTask {
      */
     @ApiModelProperty(value = "updateTime")
     private Date updateTime;
+
+    private Integer cloud_type;
 }

+ 4 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialCutFrameService.java

@@ -21,4 +21,8 @@ public interface IMaterialCutFrameService extends IService<MaterialCutFrame> {
 
     List<MaterialCutFrame> getListByVideoSignature(String signature);
 
+    void getCosCutFrame(String url, String materialId) throws IOException;  //腾讯云抽帧
+
+    void loadCosCutFrame(String jobId, String videoSignature);  //腾讯云抽帧任务状态查询以及数据入库
+
 }

+ 94 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialCutFrameServiceImpl.java

@@ -7,9 +7,11 @@ import cn.com.ctop.common.module.mapper.MaterialCutFrameMapper;
 import cn.com.ctop.common.module.service.IMaterialCutFrameService;
 import cn.com.ctop.common.module.service.IMaterialCutFrameTaskService;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CosUtil;
 import cn.com.ctop.common.module.utils.LoadFileUtil;
 import cn.com.ctop.common.module.utils.MpsUtils;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.aliyuncs.DefaultAcsClient;
 import com.aliyuncs.IAcsClient;
@@ -20,7 +22,9 @@ import com.aliyuncs.mts.model.v20140618.SubmitSnapshotJobResponse;
 import com.aliyuncs.profile.DefaultProfile;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.gson.JsonObject;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -224,5 +228,95 @@ public class MaterialCutFrameServiceImpl extends ServiceImpl<MaterialCutFrameMap
     }
 
 
+    //腾讯云抽帧
+    @Override
+    public void getCosCutFrame(String url, String materialId) throws IOException {
+        try {
+
+            QueryWrapper<MaterialCutFrameTask> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("video_signature", materialId);
+            queryWrapper.last("limit 1");
+            MaterialCutFrameTask checkCutFrame = cutFrameTaskService.getOne(queryWrapper);
+            if (!Check.isNull(checkCutFrame)) {
+                log.info("已存推荐封面");
+                return;
+            }
+
+            //抽帧ossOutputObject1
+            String ossOutputObject1 = "/cutFrame/" + materialId + "/_";
+            String replaceUrl = url.replace("https://" + CosUtil.bucket + ".cos.ap-chongqing.myqcloud.com", "");  //地址
+            String resp = CosUtil.processMedia(replaceUrl, ossOutputObject1);
+            JSONObject respJson = JSONObject.parseObject(resp);
+            String jobId = respJson.getString("TaskId"); //{"Response": {"TaskId": "2600000655-WorkflowTask-c0b385f27c4993437029b5da175542aet0","RequestId": "4c23ce23-087f-4d4b-b73b-907d77d6d78d" } }
+            MaterialCutFrameTask cutFrameTask = new MaterialCutFrameTask();
+            cutFrameTask.setJobStatus(0);
+            cutFrameTask.setJobId(jobId);
+            cutFrameTask.setCloud_type(2);
+            cutFrameTask.setVideoSignature(materialId);
+            cutFrameTaskService.save(cutFrameTask);
+        } catch (Exception e) {
+            log.error(e.getMessage());
+        }
+    }
+
+
+    //抽帧任务状态查询,如果完成则把抽帧入库
+    @Override
+    public void loadCosCutFrame(String jobId, String videoSignature) {
+        try {
+            String resp = CosUtil.describeTaskDetail(jobId);
+            if(StringUtils.isBlank(resp)){
+                return;
+            }
+
+            JSONObject respJson = JSONObject.parseObject(resp);
+            String status = respJson.getString("Status");
+
+            if(!"FINISH".equals(status)){
+                return;
+            }
+
+            JSONArray resultSetArray = respJson.getJSONObject("WorkflowTask").getJSONArray("MediaProcessResultSet");
+            if (Check.isNull(resultSetArray)) {
+                return;
+            }
+            JSONObject resultSetObject = resultSetArray.getJSONObject(0);
+            if (Check.isNull(resultSetObject)) {
+                return;
+            }
+            JSONArray snapshotArray = resultSetObject.getJSONObject("SampleSnapshotTask").getJSONObject("Output").getJSONArray("ImagePathSet");
+
+            if (Check.isNull(snapshotArray)) {
+                return;
+            }
+
+            for (int i=0; i< snapshotArray.size(); i++){
+                String imagePath = snapshotArray.getString(i);
+                String urlStr = "https://" + CosUtil.bucket + ".cos.ap-chongqing.myqcloud.com" + imagePath;
+
+                //下载到本地获取图片md5
+                String cutFramePath = LoadFileUtil.downLoadFromUrl(urlStr, imageUpLoadPath);
+                String cutFrameMd5 = LoadFileUtil.getMD5(cutFramePath);
+
+                MaterialCutFrame cutFrame = new MaterialCutFrame();
+                cutFrame.setSignature(cutFrameMd5);
+                cutFrame.setUrl(urlStr);
+                cutFrame.setVideoSignature(videoSignature);
+                cutFrame.setImageIndex(i);
+                this.save(cutFrame);
+            }
+
+            QueryWrapper<MaterialCutFrameTask> updateQueryWrapper = new QueryWrapper<>();
+            updateQueryWrapper.eq("job_id", jobId);
+            updateQueryWrapper.eq("video_signature", videoSignature);
+            MaterialCutFrameTask updateTask = new MaterialCutFrameTask();
+            updateTask.setJobStatus(1);
+            cutFrameTaskService.update(updateTask, updateQueryWrapper);
+        } catch (Exception e) {
+            log.error(e.getMessage());
+        }
+
+    }
+
 
 }

+ 1 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -380,6 +380,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                                 try {
                                     log.info("开始抽帧");
                                     materialCutFrameService.getCutFrame(videoUrl, materialInfo.getCode(), secondDuration, height, width);
+                                    //materialCutFrameService.getCosCutFrame(videoUrl, materialInfo.getCode());  //腾讯云抽帧
                                 } catch (Exception e) {
                                     e.printStackTrace();
                                 }

+ 148 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/CosUtil.java

@@ -0,0 +1,148 @@
+package cn.com.ctop.common.module.utils;
+
+import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
+import com.tencentcloudapi.common.profile.ClientProfile;
+import com.tencentcloudapi.common.profile.HttpProfile;
+import com.tencentcloudapi.mps.v20190612.MpsClient;
+import com.tencentcloudapi.mps.v20190612.models.*;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.codec.Base64;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
+
+
+@Slf4j
+public class CosUtil {
+    public static final String secretId = "AKIDE6IpMi8fJQRCg1iuWzFajjRs43kbbets";
+    public static final String secretKey = "tXzuwMfplTTK3c9GFUyETilasvQfePu9";
+    public static final String region = "ap-chongqing";
+    public static final String bucket = "media-1301855440";
+    public static final String host = "https://" + bucket +".cos.ap-chongqing.myqcloud.com";
+
+
+    //创建采样视频截图模板
+    public static void createSampleSnapshotTemplate(){
+        try{
+
+            Credential cred = new Credential(secretId, secretKey);
+
+            HttpProfile httpProfile = new HttpProfile();
+            httpProfile.setEndpoint("mps.tencentcloudapi.com");
+
+            ClientProfile clientProfile = new ClientProfile();
+            clientProfile.setHttpProfile(httpProfile);
+
+            MpsClient client = new MpsClient(cred, region, clientProfile);
+
+            String params = "{\"Name\":\"sampleSnapshotTemplate1\",\"SampleType\":\"Percent\",\"SampleInterval\":7}";
+
+            CreateSampleSnapshotTemplateRequest req = CreateSampleSnapshotTemplateRequest.fromJsonString(params, CreateSampleSnapshotTemplateRequest.class);
+
+            CreateSampleSnapshotTemplateResponse resp = client.CreateSampleSnapshotTemplate(req);
+
+            log.info(CreateSampleSnapshotTemplateRequest.toJsonString(resp));
+        } catch (TencentCloudSDKException e) {
+            log.error(e.toString());
+        }
+    }
+
+    /**
+     * 视频处理模块
+     * 查询已经创建的模板
+     */
+    public static void DescribeSampleSnapshotTemplates(){
+            try{
+                Credential cred = new Credential(secretId, secretKey);
+
+                HttpProfile httpProfile = new HttpProfile();
+                httpProfile.setEndpoint("mps.tencentcloudapi.com");
+
+                ClientProfile clientProfile = new ClientProfile();
+                clientProfile.setHttpProfile(httpProfile);
+
+                MpsClient client = new MpsClient(cred, region, clientProfile);
+
+                String params = "{}";
+                DescribeSampleSnapshotTemplatesRequest req = DescribeSampleSnapshotTemplatesRequest.fromJsonString(params, DescribeSampleSnapshotTemplatesRequest.class);
+
+                DescribeSampleSnapshotTemplatesResponse resp = client.DescribeSampleSnapshotTemplates(req);
+
+                log.info(DescribeSampleSnapshotTemplatesRequest.toJsonString(resp));
+            } catch (TencentCloudSDKException e) {
+                log.error(e.toString());
+            }
+    }
+
+    //查询抽帧任务状态
+    public static String describeTaskDetail(String taskId){
+            try{
+                Credential cred = new Credential(secretId, secretKey);
+
+                HttpProfile httpProfile = new HttpProfile();
+                httpProfile.setEndpoint("mps.tencentcloudapi.com");
+
+                ClientProfile clientProfile = new ClientProfile();
+                clientProfile.setHttpProfile(httpProfile);
+
+                MpsClient client = new MpsClient(cred, region, clientProfile);
+
+                String params = "{\"TaskId\":\"" + taskId + "\"}";
+                DescribeTaskDetailRequest req = DescribeTaskDetailRequest.fromJsonString(params, DescribeTaskDetailRequest.class);
+
+                DescribeTaskDetailResponse resp = client.DescribeTaskDetail(req);
+
+                log.info(DescribeTaskDetailRequest.toJsonString(resp));
+                return DescribeTaskDetailRequest.toJsonString(resp);
+            } catch (TencentCloudSDKException e) {
+                log.error(e.toString());
+                return null;
+            }
+    }
+
+    //抽帧      42095--已经创建好的采样截图模板,每7%抽一张,一共15张,第一张首帧
+    //videoPath视频路径,包括文件名 高清.mp4     snapshotPath 视频截图路径(包括名字) /高清
+    public static String processMedia(String videoPath, String snapshotPath){
+        try{
+            Credential cred = new Credential(secretId, secretKey);
+
+            HttpProfile httpProfile = new HttpProfile();
+            httpProfile.setEndpoint("mps.tencentcloudapi.com");
+
+            ClientProfile clientProfile = new ClientProfile();
+            clientProfile.setHttpProfile(httpProfile);
+
+            MpsClient client = new MpsClient(cred, region, clientProfile);
+
+            String params = "{\"InputInfo\":{\"Type\":\"COS\",\"CosInputInfo\":{\"Bucket\":\"" + bucket + "\",\"Region\":\"" + region + "\",\"Object\":\"" + videoPath + "\"}},\"MediaProcessTask\":{\"SampleSnapshotTaskSet\":[{\"Definition\":42095,\"OutputStorage\":{\"Type\":\"COS\",\"CosOutputStorage\":{\"Bucket\":\""+ bucket +"\",\"Region\":\"" + region + "\"}},\"OutputObjectPath\":\"" + snapshotPath + "\"}]}}";
+
+            ProcessMediaRequest req = ProcessMediaRequest.fromJsonString(params, ProcessMediaRequest.class);
+
+            ProcessMediaResponse resp = client.ProcessMedia(req);
+
+            log.info(ProcessMediaRequest.toJsonString(resp));
+            return ProcessMediaRequest.toJsonString(resp);
+        } catch (TencentCloudSDKException e) {
+            log.error(e.toString());
+            return null;
+        }
+    }
+
+
+    public static void main(String[] args) {
+        //创建采样截图模板
+        createSampleSnapshotTemplate();
+        //查询采样截图模板
+        //DescribeSampleSnapshotTemplates();
+        //查询抽帧任务状态
+        //describeTaskDetail();
+
+    }
+
+
+}

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

@@ -952,14 +952,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     returnMap.put("campaignId", campaignId);
                     returnMap.put("success", true);
                     // 创建成功 拉取广告组信息
-                    Thread thread = new Thread() {
-                        @Override
-                        public void run() {
-                            getCampaign(accessToken, advertiserId, campaignId);
-                        }
-
-                    };
-                    thread.start();
+                    getCampaign(accessToken, advertiserId, campaignId);
                 } else {
                     log.error("创建广告计划失败,advertiser_id:{},返回信息:{}", advertiserId, resultJson);
                     returnMap.put("code", -1);

+ 3 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceAdvertiserDataService.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.toutiao.modules.material.service;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import com.alibaba.fastjson.JSONObject;
 
 import java.util.Map;
 
@@ -8,6 +9,8 @@ import java.util.Map;
  * @author jeecg-boot
  */
 public interface IByteDanceAdvertiserDataService {
+    JSONObject getAdvertiserList(String token, Long accountId);
+
     Map<String, Object> getAdvertiserInfo(String accountId);
 
     Map<String, Object> getAdvertiserPlan(CtopOauthToken token, String ids, String date, String updateDate);

+ 49 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -37,6 +37,55 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
     private IByteDanceVideoInfoService videoInfoService;
 
     @Override
+    public JSONObject getAdvertiserList(String token, Long accountId) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            String url = "https://ad.oceanengine.com/open_api/2/majordomo/advertiser/select/";
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Content-Type", "application/json");
+            headers.put("Access-Token", token);
+            TreeMap<String, Object> params = new TreeMap<>();
+            params.put("advertiser_id", accountId);
+            String result = HttpUtils.httpGetRequest(url, headers, params);
+            JSONObject jsonObject = JSONObject.parseObject(result);
+            if (Check.isNull(jsonObject)) {
+                throw new Exception("返回结果为空");
+
+            }
+
+            Integer code = jsonObject.getInteger("code");
+            if (code == 0) {
+                JSONObject data = jsonObject.getJSONObject("data");
+                if (Check.isNull(data)) {
+                    throw new Exception("data为空");
+                }
+                JSONArray list = data.getJSONArray("list");
+                if (Check.isNull(list)) {
+                    throw new Exception("账户列表为空");
+
+                }
+                returnJson.put("code", 0);
+                returnJson.put("data", list);
+
+            } else {
+                returnJson.put("code", -1);
+
+            }
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", -1);
+
+        }
+
+
+        return returnJson;
+
+
+    }
+
+    @Override
     public Map<String, Object> getAdvertiserInfo(String accountId) {
         Map<String, Object> resultMap = new HashMap<>();
         CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);

+ 11 - 0
pom.xml

@@ -395,6 +395,17 @@
             <artifactId>javacv-platform</artifactId>
             <version>1.4.2</version>
         </dependency>
+        <!--<dependency>
+            <groupId>com.qcloud</groupId>
+            <artifactId>cos_api</artifactId>
+            <version>5.6.24</version>
+        </dependency>-->
+
+        <dependency>
+            <groupId>com.tencentcloudapi</groupId>
+            <artifactId>tencentcloud-sdk-java</artifactId>
+            <version>3.1.62</version><!-- 注:这里只是示例版本号,请获取并替换为 最新的版本号 -->
+        </dependency>
     </dependencies>
 
     <dependencyManagement>