zhaoxian 2 년 전
부모
커밋
654f989235

+ 80 - 0
job-live/src/main/java/cn/com/ctop/job/live/entity/AccountToken.java

@@ -0,0 +1,80 @@
+package cn.com.ctop.job.live.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 对象 agent_token
+ *
+ * @author ruoyi
+ * @date 2022-07-15
+ */
+@Data
+public class AccountToken {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID
+     */
+    private String id;
+
+    /**
+     * 媒体ID(外部广告平台类型,快手/头条/抖音等)
+     */
+    private String mediaId;
+
+    /**
+     * $column.columnComment
+     */
+    private Long agentId;
+
+    /**
+     * 访问令牌
+     */
+    private String accessToken;
+
+    /**
+     * 访问令牌有效期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date accessTokenExpiresIn;
+
+    /**
+     * 刷新令牌
+     */
+    private String refreshToken;
+
+    /**
+     * 刷新令牌有效期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date refreshTokenExpiresIn;
+
+    /**
+     * 代理商类型 0:三方代理商 1:本代理商
+     */
+    private Integer agentType;
+
+    /**
+     * $column.columnComment
+     */
+    private Long appId;
+
+    /**
+     * $column.columnComment
+     */
+    private String secret;
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+}

+ 62 - 0
job-live/src/main/java/cn/com/ctop/job/live/handler/AdAccountReportJob.java

@@ -0,0 +1,62 @@
+package cn.com.ctop.job.live.handler;
+
+import cn.com.ctop.job.live.service.AgentTokenService;
+import cn.com.ctop.job.live.service.IKuaishouLiveAccountReportDailyService;
+import cn.com.ctop.job.live.utils.Check;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Slf4j
+@Component
+public class AdAccountReportJob {
+
+    @Autowired
+    private IKuaishouLiveAccountReportDailyService accountReportDailyService;
+
+    @Autowired
+    private AgentTokenService tokenService;
+
+    private static ExecutorService dailyExecutorService = Executors.newFixedThreadPool(3);
+    private static ExecutorService hourExecutorService = Executors.newFixedThreadPool(3);
+
+    /**
+     * 获取广告组信息
+     * 前1天
+     *
+     * @throws Exception
+     */
+    @XxlJob("AdAccountReportJob")
+    public void AdAccountReportJob() {
+        String param = XxlJobHelper.getJobParam(); // 执行参数
+        if (Check.isNull(param)) {
+            log.error("入参为空");
+            return;
+        }
+        String token = tokenService.getByAccountId(Long.valueOf(param));
+        if (Check.isNull(token)) {
+            log.error("此账户未获取到相关token,accountId:{}", param);
+            return;
+        }
+
+        dailyExecutorService.submit(
+                new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            accountReportDailyService.getKuaishouAccountReport(Long.valueOf(param), token, 1);
+                        } catch (Exception e) {
+                            log.info(String.valueOf(e));
+                            ;
+                        }
+                    }
+                });
+    }
+
+
+}

+ 62 - 0
job-live/src/main/java/cn/com/ctop/job/live/handler/AdCampaignReportJob.java

@@ -0,0 +1,62 @@
+package cn.com.ctop.job.live.handler;
+
+import cn.com.ctop.job.live.service.AgentTokenService;
+import cn.com.ctop.job.live.service.IKuaishouLiveCampaignReportDailyService;
+import cn.com.ctop.job.live.utils.Check;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Slf4j
+@Component
+public class AdCampaignReportJob {
+
+    @Autowired
+    private IKuaishouLiveCampaignReportDailyService campaignReportDailyService;
+
+    @Autowired
+    private AgentTokenService tokenService;
+
+    private static ExecutorService dailyExecutorService = Executors.newFixedThreadPool(3);
+    private static ExecutorService hourExecutorService = Executors.newFixedThreadPool(3);
+
+    /**
+     * 获取广告组信息
+     * 前1天
+     *
+     * @throws Exception
+     */
+    @XxlJob("AdCampaignReportJob")
+    public void AdCampaignReportJob() {
+        String param = XxlJobHelper.getJobParam(); // 执行参数
+        if (Check.isNull(param)) {
+            log.error("入参为空");
+            return;
+        }
+        String token = tokenService.getByAccountId(Long.valueOf(param));
+        if (Check.isNull(token)) {
+            log.error("此账户未获取到相关token,accountId:{}", param);
+            return;
+        }
+
+        dailyExecutorService.submit(
+                new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            campaignReportDailyService.getKuaishouCampaignReport(Long.valueOf(param), token, 1);
+                        } catch (Exception e) {
+                            log.info(String.valueOf(e));
+                            ;
+                        }
+                    }
+                });
+    }
+
+
+}

+ 62 - 0
job-live/src/main/java/cn/com/ctop/job/live/handler/AdCreativeReportJob.java

@@ -0,0 +1,62 @@
+package cn.com.ctop.job.live.handler;
+
+import cn.com.ctop.job.live.service.AgentTokenService;
+import cn.com.ctop.job.live.service.IKuaishouLiveCreativeReportDailyService;
+import cn.com.ctop.job.live.utils.Check;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Slf4j
+@Component
+public class AdCreativeReportJob {
+
+    @Autowired
+    private IKuaishouLiveCreativeReportDailyService creativeReportDailyService;
+
+    @Autowired
+    private AgentTokenService tokenService;
+
+    private static ExecutorService dailyExecutorService = Executors.newFixedThreadPool(3);
+    private static ExecutorService hourExecutorService = Executors.newFixedThreadPool(3);
+
+    /**
+     * 获取广告组信息
+     * 前1天
+     *
+     * @throws Exception
+     */
+    @XxlJob("AdCreativeReportJob")
+    public void AdCreativeReportJob() {
+        String param = XxlJobHelper.getJobParam(); // 执行参数
+        if (Check.isNull(param)) {
+            log.error("入参为空");
+            return;
+        }
+        String token = tokenService.getByAccountId(Long.valueOf(param));
+        if (Check.isNull(token)) {
+            log.error("此账户未获取到相关token,accountId:{}", param);
+            return;
+        }
+
+        dailyExecutorService.submit(
+                new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            creativeReportDailyService.getKuaishouCreativeReport(Long.valueOf(param), token, 1);
+                        } catch (Exception e) {
+                            log.info(String.valueOf(e));
+                            ;
+                        }
+                    }
+                });
+    }
+
+
+}

+ 62 - 0
job-live/src/main/java/cn/com/ctop/job/live/handler/AdUnitReportJob.java

@@ -0,0 +1,62 @@
+package cn.com.ctop.job.live.handler;
+
+import cn.com.ctop.job.live.service.AgentTokenService;
+import cn.com.ctop.job.live.service.IKuaishouLiveUnitReportDailyService;
+import cn.com.ctop.job.live.utils.Check;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Slf4j
+@Component
+public class AdUnitReportJob {
+
+    @Autowired
+    private IKuaishouLiveUnitReportDailyService unitReportDailyService;
+
+    @Autowired
+    private AgentTokenService tokenService;
+
+    private static ExecutorService dailyExecutorService = Executors.newFixedThreadPool(3);
+    private static ExecutorService hourExecutorService = Executors.newFixedThreadPool(3);
+
+    /**
+     * 获取广告组信息
+     * 前1天
+     *
+     * @throws Exception
+     */
+    @XxlJob("AdUnitListReportJob")
+    public void AdUnitListReportJob() {
+        String param = XxlJobHelper.getJobParam(); // 执行参数
+        if (Check.isNull(param)) {
+            log.error("入参为空");
+            return;
+        }
+        String token = tokenService.getByAccountId(Long.valueOf(param));
+        if (Check.isNull(token)) {
+            log.error("此账户未获取到相关token,accountId:{}", param);
+            return;
+        }
+
+        dailyExecutorService.submit(
+                new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            unitReportDailyService.getKuaishouUnitReport(Long.valueOf(param), token, 1);
+                        } catch (Exception e) {
+                            log.info(String.valueOf(e));
+                            ;
+                        }
+                    }
+                });
+    }
+
+
+}

+ 15 - 0
job-live/src/main/java/cn/com/ctop/job/live/mapper/AgentTokenMapper.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.job.live.mapper;
+
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * token信息
+ *
+ * @author jeecg-boot 2021-09-07
+ * @version V1.0
+ */
+public interface AgentTokenMapper {
+
+    String getByAccountId(@Param("accountId") Long accountId);
+
+}

+ 10 - 0
job-live/src/main/java/cn/com/ctop/job/live/mapper/xml/AgentTokenMapper.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.job.live.mapper.AgentTokenMapper">
+
+    <select id="getByAccountId" resultType="java.lang.String">
+        select access_token
+        from `ruixuan`.`agent_token`
+        WHERE media_id = 2 limit 1
+    </select>
+</mapper>

+ 13 - 0
job-live/src/main/java/cn/com/ctop/job/live/service/AgentTokenService.java

@@ -0,0 +1,13 @@
+package cn.com.ctop.job.live.service;
+
+/**
+ * token信息
+ *
+ * @author jeecg-boot 2021-09-07
+ * @version V1.0
+ */
+public interface AgentTokenService {
+
+    String getByAccountId(Long accountId);
+
+}

+ 27 - 0
job-live/src/main/java/cn/com/ctop/job/live/service/impl/AgentTokenServiceImpl.java

@@ -0,0 +1,27 @@
+package cn.com.ctop.job.live.service.impl;
+
+import cn.com.ctop.job.live.mapper.AgentTokenMapper;
+import cn.com.ctop.job.live.service.AgentTokenService;
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * token信息
+ *
+ * @author jeecg-boot 2021-09-07
+ * @version V1.0
+ */
+@Service
+public class AgentTokenServiceImpl implements AgentTokenService {
+    @Autowired
+    private AgentTokenMapper tokenMapper;
+
+    @Override
+    public String getByAccountId(Long accountId) {
+        return tokenMapper.getByAccountId(accountId);
+    }
+
+}

+ 2 - 2
job-live/src/main/resources/application.yml

@@ -109,8 +109,8 @@ xxl:
   job:
   job:
     accessToken:
     accessToken:
     executor:
     executor:
-      appname: module-job-kuaishou
-      port: 9997
+      appname: module-job-live
+      port: 9999
       ip:
       ip:
       logpath: /data/applogs/xxl-job/jobhandler
       logpath: /data/applogs/xxl-job/jobhandler
       logretentiondays: 30
       logretentiondays: 30