Ver código fonte

Merge remote-tracking branch 'origin/master'

syh 5 anos atrás
pai
commit
76630c01c8

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

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.utils.DateUtils;
 import cn.com.ctop.crawler.modules.account.entity.KuaishouAdAccount;
 import cn.com.ctop.crawler.modules.account.service.IKuaishouAdAccountService;
 import cn.com.ctop.kuaishou.modules.app.entity.AppAd;
@@ -20,6 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -35,6 +38,57 @@ public class AdCoverController {
     private IKuaishouAdAccountService kuaishouAdAccountService;
     @Autowired
     private ISysCategoryService sysCategoryService;
+
+    @ResponseBody
+    @RequestMapping(value = "/summary/today", method = RequestMethod.GET)
+    public Result<Map<String, Object>> getTodaySummary() {
+        Result<Map<String, Object>> result = new Result<Map<String, Object>>();
+        QueryWrapper<AppAd> appAdWrapper = new QueryWrapper<AppAd>();
+        QueryWrapper<AppVideo> appVideoWrapper = new QueryWrapper<AppVideo>();
+        QueryWrapper<KuaishouAdAccount> advertiserWrapper = new QueryWrapper<KuaishouAdAccount>();
+        QueryWrapper<KuaishouAdAccount> productWrapper = new QueryWrapper<KuaishouAdAccount>();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        String now = sdf.format(new Date());
+        String startDate = now + " 00:00:00";
+        String endDate = now + " 23:59:59";
+        appAdWrapper.between("time", startDate, endDate);
+        appVideoWrapper.between("time", startDate, endDate);
+        advertiserWrapper.between("create_time", startDate, endDate);
+        productWrapper.between("create_time", startDate, endDate);
+        productWrapper.groupBy("product");
+        int appAdCount = appAdService.count(appAdWrapper);
+        int appVideoCount = appVideoService.count(appVideoWrapper);
+        int advertiserCount = kuaishouAdAccountService.count(advertiserWrapper);
+        int productCount = kuaishouAdAccountService.count(productWrapper);
+        Map<String, Object> map = new HashMap<String, Object>();
+        map.put("adCount", appAdCount);
+        map.put("videoCount", appVideoCount);
+        map.put("advertiserCount", advertiserCount);
+        map.put("productCount", productCount);
+        result.setResult(map);
+        result.setSuccess(true);
+        return result;
+    }
+
+    @ResponseBody
+    @RequestMapping(value = "/summary/all", method = RequestMethod.GET)
+    public Result<Map<String, Object>> getAllSummary() {
+        Result<Map<String, Object>> result = new Result<Map<String, Object>>();
+        QueryWrapper<KuaishouAdAccount> productWrapper = new QueryWrapper<KuaishouAdAccount>();
+        productWrapper.groupBy("product");
+        int appAdCount = appAdService.count();
+        int appVideoCount = appVideoService.count();
+        int advertiserCount = kuaishouAdAccountService.count();
+        int productCount = kuaishouAdAccountService.count(productWrapper);
+        Map<String, Object> map = new HashMap<String, Object>();
+        map.put("adCount", appAdCount);
+        map.put("videoCount", appVideoCount);
+        map.put("advertiserCount", advertiserCount);
+        map.put("productCount", productCount);
+        result.setResult(map);
+        result.setSuccess(true);
+        return result;
+    }
     @ResponseBody
     @RequestMapping(value="/feeds", method = RequestMethod.GET)
     public Result<List<AppAd>> getVideoList(HttpServletRequest req){

+ 10 - 12
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCommentAutoDelete.java

@@ -23,18 +23,16 @@ public class KuaishouCommentAutoDelete implements Job {
         QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<BindAccountLogin>();
         queryWrapper.eq("login_type", "kuaishou");
         queryWrapper.eq("status", 1);
-        while (true) {
-            List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
-            if (list != null && list.size() > 0) {
-                for (BindAccountLogin account : list) {
-                    try {
-                        System.out.println("正在删除评论:" + account.getAccountName());
-                        kuaishouWebInterfaceService.adkuaishouWebLogin(account.getAccountName(), account.getPassword());
-                        kuaishouWebInterfaceService.deleteAllComment(new HashMap<>());
-                        Thread.sleep(10000);
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    }
+        List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
+        if (list != null && list.size() > 0) {
+            for (BindAccountLogin account : list) {
+                try {
+                    System.out.println("正在删除评论:" + account.getAccountName());
+                    kuaishouWebInterfaceService.adkuaishouWebLogin(account.getAccountName(), account.getPassword());
+                    kuaishouWebInterfaceService.deleteAllComment(new HashMap<>());
+                    Thread.sleep(10000);
+                } catch (Exception e) {
+                    e.printStackTrace();
                 }
             }
         }

+ 4 - 13
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CreateInternalServiceImpl.java

@@ -33,9 +33,9 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
         String url = "https://ad.oceanengine.com/pages/login/index.html";
 //        System.getProperties().setProperty("webdriver.chrome.driver", "D:/chromedriver.exe");
         System.getProperties().setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver");
+        ChromeOptions chromeOptions = new ChromeOptions();
+        WebDriver webDriver = new ChromeDriver(chromeOptions);
         try {
-            ChromeOptions chromeOptions = new ChromeOptions();
-            WebDriver webDriver = new ChromeDriver(chromeOptions);
             chromeOptions.addArguments("--headless");
             chromeOptions.addArguments("--incognito");
             chromeOptions.addArguments("--no-sandbox");
@@ -44,8 +44,6 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
             chromeOptions.addArguments("--user-agent=" + HttpUtils.USER_AGENT);
             chromeOptions.setAcceptInsecureCerts(true);
             webDriver.get(url);  //获取登录页面
-
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
             for (Cookie cookie : webDriver.manage().getCookies()) {
                 BasicClientCookie ck = new BasicClientCookie(cookie.getName(), cookie.getValue());
                 ck.setDomain("ad.oceanengine.com");
@@ -112,8 +110,6 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                 param2.put("landing_type", 3);
                 param2.put("campaign_type", 1);
                 param2.put("budget", param3);
-
-//                webDriver.get("https://ad.toutiao.com/pages/campaign/create.html");
                 for (Cookie cookie : webDriver.manage().getCookies()) {
                     if ("csrftoken".equals(cookie.getName())) {
                         csrftoken = cookie.getValue();
@@ -174,7 +170,6 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                 param5.put("projectid", "");
                 param5.put("localGeolocation", new ArrayList<String>());
                 param5.put("external_action", 4);
-//                param5.put("external_url", "");
                 param5.put("open_url", ""); //  应用直达链接
                 param5.put("style_type", 0);
                 param5.put("location_type", 4); //受众位置类型
@@ -195,7 +190,6 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                     param5.put("start_time", requestJson.getString("startDate")); //广告投放起始时间
                     param5.put("end_time", requestJson.getString("endDate"));//广告投放结束时间
                 }
-
                 param5.put("week_schedule", new ArrayList<String>());  //投放时段
                 param5.put("week_time", new ArrayList<ArrayList<Integer>>());//投放时段
                 int pricing = requestJson.getIntValue("pricing");
@@ -209,7 +203,6 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                 } else {
                     param5.put("bid", requestJson.getIntValue("convertPrice"));
                 }
-
                 param5.put("package", requestJson.getString("packageName"));
                 param5.put("smart_bid_type", requestJson.getIntValue("bidType")); //自动出价类型,OCPM支持
                 param5.put("adjust_cpa", 0); //是否调整自动出价   允许值: "0", "1"  默认值: 0
@@ -220,13 +213,11 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                 String createResult = HttpUtils.httpPostRequest("https://ad.oceanengine.com/overture/ad/create/", param5, header);
                 System.out.println(createResult);
             }
-//            webDriver.close();
-
-
         } catch (Exception e) {
             e.printStackTrace();
+        } finally {
+            webDriver.quit();
         }
         return null;
     }
-
 }

+ 4 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/service/impl/KuaishouWebInterfaceServiceImpl.java

@@ -188,8 +188,8 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
 
     @Override
     public void adkuaishouWebLogin(String phone, String password) {
-//        System.getProperties().setProperty("webdriver.chrome.driver", "D:/chromedriver.exe");
-        System.getProperties().setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver");
+        System.getProperties().setProperty("webdriver.chrome.driver", "D:/chromedriver.exe");
+//        System.getProperties().setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver");
         ChromeOptions chromeOptions = new ChromeOptions();
         WebDriver webDriver = new ChromeDriver(chromeOptions);
         try {
@@ -239,7 +239,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
         } catch (Exception e) {
             e.printStackTrace();
         } finally {
-            webDriver.close();
+            webDriver.quit();
 //            HttpUtils.cookieStore.clear();
         }
     }
@@ -287,7 +287,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
             e.printStackTrace();
         } finally {
 //            HttpUtils.cookieStore.clear();
-            webDriver.close();
+            webDriver.quit();
         }
     }