yumeng 5 years ago
parent
commit
daa7531322

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

@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.util.DateUtils;
+import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -92,6 +93,78 @@ public class TestController {
     private IMaterialCutFrameService cutFrameService;
 
 
+    @GetMapping(value = "/getAccountList")
+    public void getAccountList() throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date getDate = DateUtils.addDay(new Date(), -1);
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取快手数据异常:未获取到可用的token");
+                    return;
+                }
+
+                executorService = Executors.newFixedThreadPool(3);
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            //1: 获取广告主信息数据
+                            kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate, getDate);
+                        }
+                    });
+                });
+            }
+        };
+        thread.start();
+
+    }
+
+
+    @GetMapping(value = "/getVideo")
+    public String getVideo(String startDate, String endDate) throws IOException {
+
+        try {
+
+
+            Thread thread = new Thread() {
+                @Override
+                public void run() {
+
+
+                    QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
+                    tokenQueryWrapper.eq("media_id", 2);
+                    List<CtopOauthToken> list = tokenService.list(tokenQueryWrapper);
+
+                    executorService = Executors.newFixedThreadPool(8);
+                    list.forEach(token -> {
+                        executorService.submit(new Runnable() {
+                            @Override
+                            public void run() {
+                                try {
+                                    //获取全量视频素材数据
+                                    kuaishouInterfaceService.getVideoList(token, null, null);
+                                    // 获取图片信息数据
+                                    //   kuaishouInterfaceService.getImageList(token, startDate, endDate);
+                                } catch (Exception e) {
+                                    e.printStackTrace();
+                                } finally {
+                                }
+                            }
+                        });
+                    });
+                    log.info("快手物料数据同步完成");
+                }
+            };
+            thread.start();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "Success";
+    }
+
     @GetMapping(value = "/createCutTask")
     public String createCutTask(String startDate, String endDate) throws IOException {
 

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

@@ -124,10 +124,10 @@ public class UserAllocationController {
             QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("user_id", userId);
             queryWrapper.eq("project_id", projectId);
-            Project project = projectService.getById(projectId);
-            if (!Check.isNull(project)) {
+           /*  Project project = projectService.getById(projectId);
+                if (!Check.isNull(project)) {
                 queryWrapper.eq("media_id", project.getMediaId());
-            }
+            }*/
 
             List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
             result.setSuccess(true);

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

@@ -281,6 +281,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         for (int i = 0; i < details.size(); i++) {
             JSONObject detailJson = details.getJSONObject(i);
             if (!Check.isNull(detailJson)) {
+                System.err.println(detailJson);
                 detailJson.put("photo_share", detailJson.getString("share"));
                 detailJson.put("photo_comment", detailJson.getString("comment"));
                 detailJson.put("photo_like", detailJson.getString("like"));
@@ -291,6 +292,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 detailJson.remove("show");
                 detailJson.remove("adScene");
                 detailJson.remove("stat_hour");
+                detailJson.remove("event_valid_clues");
+                detailJson.remove("event_valid_clues_cost");
                 KuaishouReportDailyAccount kuaishouReportDailyAccount = JsonUtil.jsonToObj(detailJson, KuaishouReportDailyAccount.class);
                 kuaishouReportDailyAccount.setAccountId(token.getAccountId());
                 dailyAccountMapper.insertSelective(kuaishouReportDailyAccount);