Jelajahi Sumber

Merge branch 'master' of codeup.aliyun.com:60c06368dbbed34fe0f0c263/job/hr_job-kuaishou into pingkang

huangpingkang 1 tahun lalu
induk
melakukan
05cccfade8

+ 56 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/controller/HistoryController.java

@@ -0,0 +1,56 @@
+package cn.com.ctop.job.kuaishou.controller;
+
+import cn.com.ctop.job.kuaishou.data.service.IKuaiShouAccountReportService;
+import cn.com.ctop.job.kuaishou.data.service.IKuaiShouGroupReportService;
+import cn.com.ctop.job.kuaishou.data.utils.Check;
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+
+/**
+ * zian Y
+ * 2022/2/9
+ **/
+
+@RestController
+@RequestMapping("/history")
+@Api(tags = "kuaishou")
+@Slf4j
+public class HistoryController {
+    private static ExecutorService dailyExecutorService = Executors.newFixedThreadPool(3);
+    @Autowired
+    private IKuaiShouAccountReportService kuaiShouAccountReportService;
+    @Autowired
+    private IKuaiShouGroupReportService groupReportService;
+
+    @GetMapping("/getData")
+    public JSONObject getData(Long advertiserId, String startDate, String endDate) {
+        JSONObject json = new JSONObject();
+        dailyExecutorService.submit(new Runnable() {
+            @Override
+            public void run() {
+
+                String token = kuaiShouAccountReportService.getTokenByAdvertiserId(advertiserId);
+                if (Check.isNull(token)) {
+                    return;
+                }
+/*                kuaiShouAccountReportService.queryAccountReportDaily(token, advertiserId, startDate, endDate, 1);
+                groupReportService.queryGroupReportDaily(token, advertiserId, startDate, endDate, 1);*/
+                kuaiShouAccountReportService.queryAccountDailyFlows(token, advertiserId, startDate, endDate, 1, 1, null, 2);
+            }
+        });
+        json.put("code", 200);
+        json.put("message", "成功");
+        return json;
+    }
+
+
+}

+ 2 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/mapper/KuaiShouAccountReportMapper.java

@@ -27,4 +27,6 @@ public interface KuaiShouAccountReportMapper {
 
     @DS("selectdb")
     List<JSONObject> queryCostAccount(@Param("startDate")Integer startDate,@Param("endDate")Integer endDate);
+
+    String getTokenByAdvertiserId(@Param("advertiserId") Long advertiserId);
 }

+ 7 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/mapper/xml/KuaiShouAccountReportMapper.xml

@@ -299,4 +299,11 @@
         LEFT JOIN tidb.deepthink.kuaishou_auth_list t3 ON t2.admin_advertiser_id = t3.admin_advertiser_id
         where t3.type=1
     </select>
+    <select id="getTokenByAdvertiserId" resultType="java.lang.String">
+        select t2.access_token
+        from deepthink.kuaishou_advertiser_list t1
+                 left join deepthink.kuaishou_auth_list t2
+                           on t1.admin_advertiser_id = t2.admin_advertiser_id
+        where t1.advertiser_id = #{advertiserId} limit 1
+    </select>
 </mapper>

+ 1 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/IKuaiShouAccountReportService.java

@@ -11,4 +11,5 @@ public interface IKuaiShouAccountReportService {
 
     void queryAccountDailyFlows(String accessToken, Long advertiserId, String startDate, String endDate, int page, Integer isLog, Long errId, Integer isSend);
 
+    String getTokenByAdvertiserId(Long advertiserId);
 }

+ 5 - 0
job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/data/service/impl/KuaiShouAccountReportServiceImpl.java

@@ -213,6 +213,11 @@ public class KuaiShouAccountReportServiceImpl implements IKuaiShouAccountReportS
     }
 
     @Override
+    public String getTokenByAdvertiserId(Long advertiserId) {
+        return accountReportMapper.getTokenByAdvertiserId(advertiserId);
+    }
+
+    @Override
     public void updateKsAccountStatus() {
         accountReportMapper.updateKsAccountStatus();
     }