فهرست منبع

Merge branch 'test' of http://39.106.184.70:3000/ctop/adsp-boot into test

jiequan.bi 5 سال پیش
والد
کامیت
2606fa2d4f

+ 4 - 6
jeecg-boot-base-common/src/main/java/org/jeecg/common/system/vo/LoginUser.java

@@ -1,14 +1,12 @@
 package org.jeecg.common.system.vo;
 
-import java.util.Date;
-
-import org.springframework.format.annotation.DateTimeFormat;
-
 import com.fasterxml.jackson.annotation.JsonFormat;
-
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
 
 /**
  * <p>
@@ -73,7 +71,7 @@ public class LoginUser {
 	 * 状态(1:正常 2:冻结 )
 	 */
 	private Integer status;
-	
+
 	private String delFlag;
 	/**
      * 同步工作流引擎1同步0不同步

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

@@ -384,6 +384,14 @@ public class AdvertiserController {
                 }
             }
         }
+
+        List<UserAllocation> allocations = userAllocationService.getByProjectId(projectId, systemType);
+        if (null != allocations && !allocations.isEmpty()) {
+            for (UserAllocation allocation : allocations) {
+                SheetInfoVo vo = advertiserService.getXxlStatisticInfo(projectId, systemType, allocation.getAccountId(), allocation.getAuthName());
+                sheets.add(vo);
+            }
+        }
         result.put("data", sheets);
         ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
         return result;
@@ -413,6 +421,14 @@ public class AdvertiserController {
             }
         }
 
+        List<UserAllocation> allocations = userAllocationService.getByProjectId(projectId, systemType);
+        if (null != allocations && !allocations.isEmpty()) {
+            for (UserAllocation allocation : allocations) {
+                SheetInfoVo vo = advertiserService.getXxlStatisticInfo(projectId, systemType, allocation.getAccountId(), allocation.getAuthName());
+                sheets.add(vo);
+            }
+        }
+
         OutputStream outputStream = response.getOutputStream();
         String date = DateUtils.formatDate(new Date());
         HttpUtils.setResponseHeader(response, "爱上消消消日报" + date + ".xls");

+ 9 - 6
jeecg-boot-module-system/src/main/resources/application-test.yml

@@ -34,6 +34,9 @@ spring:
           starttls:
             enable: true
             required: true
+  ## quartz定时任务,采用数据库方式
+  quartz:
+    job-store-type: jdbc
   #json 时间戳统一转换
   jackson:
     date-format:   yyyy-MM-dd HH:mm:ss
@@ -95,11 +98,11 @@ spring:
         filters: stat,slf4j
         # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
-#      datasource:
-#        master:
-#          url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
-#          username: hcst
-#          password: test@20190531
+      #      datasource:
+      #        master:
+      #          url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+      #          username: hcst
+      #          password: test@20190531
       datasource:
         master:
           url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
@@ -130,7 +133,7 @@ mybatis-plus:
       id-type: 4
       # 默认数据库表下划线命名
       table-underline: true
- # configuration:
+  # configuration:
   #  map-underscore-to-camel-case: false
   #分页pageHelper
 pagehelper:

+ 47 - 70
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -5,13 +5,14 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
-import cn.com.ctop.crawler.modules.oceanengine.service.IOceanEngineService;
-import cn.com.ctop.kuaishou.modules.batch.entity.vo.ConvertVo;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import cn.com.ctop.crawler.modules.pangolin.entity.PangolinApp;
+import cn.com.ctop.crawler.modules.pangolin.service.PangolinAppService;
+import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService;
+import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
-import io.swagger.models.auth.In;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.junit.Test;
@@ -21,7 +22,6 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -34,10 +34,6 @@ import java.util.concurrent.Executors;
 @Slf4j
 public class SampleTest {
     @Autowired
-    private IOceanEngineService oceanEngineService;
-    @Autowired
-    private IKuaishouInterfaceService interfaceService;
-    @Autowired
     private IBytedanceReportService bytedanceReportService;
     @Autowired
     private IByteDanceVideoReportDailyService byteDanceVideoReportDailyService;
@@ -46,10 +42,6 @@ public class SampleTest {
 
     @Test
     public void testOceanEngineJob() {
-
-
-
-
         try {
             CtopOauthToken byId = oauthTokenService.getById(303094936123368L);
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
@@ -69,21 +61,6 @@ public class SampleTest {
         } catch (Exception e) {
             e.printStackTrace();
         }
-
-/*
-        List list = new ArrayList();
-        list.add(1);
-        list.add(2);
-        list.add(3);
-        list.add(7);
-        for (int i = 0; i < list.size(); i++) {
-            Integer o = (Integer) list.get(i);
-            List<ConvertVo> convertList = interfaceService.getConvertList(6435317L, "42761e184c6e966236fcfd167375a875", o);
-            System.err.println(convertList);
-        }*/
-
-
-
         String account = "3248395570@qq.com";
        /* String password = "Ydxq-704127411";
         oceanEngineService.login(account,password);
@@ -149,48 +126,48 @@ public class SampleTest {
         Long end = System.currentTimeMillis();
         log.info("总用时:{}毫秒", end - start);
     }
-//    @Autowired
-//    private PangolinLoginService pangolinLoginService;
-//    @Autowired
-//    private PangolinCrawlerService pangolinCrawlerService;
-//    @Autowired
-//    private PangolinAppService pangolinAppService;
-//    @Test
-//    public void testPangolinLogin(){
-//        QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
-//        queryWrapper.eq("login_type","pangolin");
-//        queryWrapper.eq("status",1);
-//        List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
-//        if(list!=null&&!list.isEmpty()){
-//            for (BindAccountLogin login:list) {
-//                if(null==login.getCookie()||"".equals(login.getCookie().trim())){
-//                    pangolinLoginService.pangolinLogin(login.getAccountName(), login.getPassword());
-//                }
-//            }
-//        }
-//    }
-//
-//    @Test
-//    public void testPangolinData(){
-//        QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
-//        queryWrapper.eq("login_type", "pangolin");
-//        queryWrapper.eq("status", 1);
-//        queryWrapper.isNotNull("cookie");
-//        List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
-//        if (list != null && !list.isEmpty()) {
-//            for (BindAccountLogin bindAccountLogin : list) {
-//                pangolinCrawlerService.getChannelList(bindAccountLogin);
-//                pangolinCrawlerService.getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1);
-//                pangolinCrawlerService.getCheckList(bindAccountLogin);
-//                QueryWrapper<PangolinApp> queryWrapper1 = new QueryWrapper<>();
-//                queryWrapper1.eq("account_name", bindAccountLogin.getAccountName());
-//                List<PangolinApp> appList = pangolinAppService.list(queryWrapper1);
-//                if (appList != null && !appList.isEmpty()) {
-//                    appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getId()));
-//                }
-//            }
-//        }
-//    }
+    @Autowired
+    private PangolinLoginService pangolinLoginService;
+    @Autowired
+    private PangolinCrawlerService pangolinCrawlerService;
+    @Autowired
+    private PangolinAppService pangolinAppService;
+    @Test
+    public void testPangolinLogin(){
+        QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("login_type","pangolin");
+        queryWrapper.eq("status",1);
+        List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
+        if(list!=null&&!list.isEmpty()){
+            for (BindAccountLogin login:list) {
+                if(null==login.getCookie()||"".equals(login.getCookie().trim())){
+                    pangolinLoginService.pangolinLogin(login.getAccountName(), login.getPassword());
+                }
+            }
+        }
+    }
+
+    @Test
+    public void testPangolinData(){
+        QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("login_type", "pangolin");
+        queryWrapper.eq("status", 1);
+        queryWrapper.isNotNull("cookie");
+        List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
+        if (list != null && !list.isEmpty()) {
+            for (BindAccountLogin bindAccountLogin : list) {
+                pangolinCrawlerService.getChannelList(bindAccountLogin);
+                pangolinCrawlerService.getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1);
+                pangolinCrawlerService.getCheckList(bindAccountLogin);
+                QueryWrapper<PangolinApp> queryWrapper1 = new QueryWrapper<>();
+                queryWrapper1.eq("account_name", bindAccountLogin.getAccountName());
+                List<PangolinApp> appList = pangolinAppService.list(queryWrapper1);
+                if (appList != null && !appList.isEmpty()) {
+                    appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getId()));
+                }
+            }
+        }
+    }
 }
 
 

+ 1 - 1
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/PangolinLoginService.java

@@ -1,5 +1,5 @@
 package cn.com.ctop.crawler.modules.pangolin.service;
 
 public interface PangolinLoginService {
-    public void pangolinLogin(String username,String password);
+    void pangolinLogin(String username,String password);
 }

+ 33 - 33
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinLoginServiceImpl.java

@@ -5,9 +5,8 @@ import cn.com.ctop.common.module.service.IBindAccountLoginService;
 import cn.com.ctop.common.module.utils.ChaojiyingUtils;
 import cn.com.ctop.common.module.utils.HttpUtils2;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.gson.Gson;
 import org.apache.http.impl.client.BasicCookieStore;
 import org.apache.http.impl.cookie.BasicClientCookie;
@@ -17,6 +16,7 @@ import org.openqa.selenium.chrome.ChromeOptions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+
 import java.util.*;
 
 
@@ -45,33 +45,38 @@ public class PangolinLoginServiceImpl implements PangolinLoginService {
             webDriver.manage().deleteAllCookies();
             //获取登录页面
             webDriver.get(url);
+            Thread.sleep(3000L);
+            WebElement accountElement = webDriver.findElement(By.xpath("//input[@id='username']"));
+            accountElement.sendKeys(username);
+            Thread.sleep(3000L);
+            WebElement passwordElement = webDriver.findElement(By.xpath("//input[@id='password']"));
+            passwordElement.sendKeys(password);
+            WebElement captchaElement = webDriver.findElement(By.xpath("//div[@class='ant-form-item-control ']/img"));
+            String outputType = captchaElement.getScreenshotAs(OutputType.BASE64);
+            String res = ChaojiyingUtils.process(outputType,1902);
+            JSONObject capachaObject = JSONObject.parseObject(res);
+            Integer code = capachaObject.getInteger("err_no");
+            String captcha = capachaObject.getString("pic_str");
+            WebElement captchaInputElement = webDriver.findElement(By.xpath("//input[@id='captcha']"));
+            captchaInputElement.sendKeys(captcha);
+            WebElement loginElement = webDriver.findElement(By.xpath("//button[@type='submit']"));
+            Thread.sleep(3000L);
+            //点击登录
+            loginElement.click();
+            Thread.sleep(3000L);
+            webDriver.get("https://pangolin.bytedance.com");
+            Thread.sleep(3000L);
             List<WebElement> list = webDriver.findElements(By.xpath("//input[@id='captcha']"));
-            do {
-                Thread.sleep(3000L);
-                WebElement accountElement = webDriver.findElement(By.xpath("//input[@id='username']"));
-                accountElement.sendKeys(username);
-                Thread.sleep(3000L);
-                WebElement passwordElement = webDriver.findElement(By.xpath("//input[@id='password']"));
-                passwordElement.sendKeys(password);
-                WebElement captchaElement = webDriver.findElement(By.xpath("//div[@class='ant-form-item-control ']/img"));
-                String outputType = captchaElement.getScreenshotAs(OutputType.BASE64);
-                String res = ChaojiyingUtils.process(outputType,1902);
-                ObjectMapper mapper = new ObjectMapper();
-                JsonNode n = mapper.readTree(res);
-                String captcha = n.get("pic_str").asText();
-                WebElement captchaInputElement = webDriver.findElement(By.xpath("//input[@id='captcha']"));
-                captchaInputElement.sendKeys(captcha);
-                WebElement loginElement = webDriver.findElement(By.xpath("//button[@type='submit']"));
-                Thread.sleep(3000L);
-                //点击登录
-                loginElement.click();
-                Thread.sleep(3000L);
-                webDriver.get("https://pangolin.bytedance.com");
-                list = webDriver.findElements(By.xpath("//input[@id='captcha']"));
-            }while (list != null && list.size() > 0);
-
-
-
+            QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("account_name",username);
+            queryWrapper.eq("login_type","pangolin");
+            BindAccountLogin bindAccountLogin = bindAccountLoginService.getOne(queryWrapper);
+            if(null != code && code == 0 && null != list && !list.isEmpty()){
+                //表示验证码正确,登录不成功
+                bindAccountLogin.setStatus("2");
+                bindAccountLoginService.updateById(bindAccountLogin);
+                return ;
+            }
             Set<Cookie> cookies = webDriver.manage().getCookies();
             List<String> cookieList = new ArrayList<>();
             Iterator iterator = cookies.iterator();
@@ -92,11 +97,6 @@ public class PangolinLoginServiceImpl implements PangolinLoginService {
                 clientCookie.setPath(cookieMap.get("path"));
                 HttpUtils2.cookieStore.addCookie(clientCookie);
             }
-
-            QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
-            queryWrapper.eq("account_name",username);
-            queryWrapper.eq("login_type","pangolin");
-            BindAccountLogin bindAccountLogin = bindAccountLoginService.getOne(queryWrapper);
             if (bindAccountLogin != null){
                 bindAccountLogin.setCookie(new Gson().toJson(cookieList));
                 bindAccountLoginService.updateById(bindAccountLogin);

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

@@ -3175,7 +3175,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     public List<ConvertVo> getConvertList(Long accountId, String accessToken, Integer type) {
         List<ConvertVo> convertVoList = new ArrayList<>();
         try {
-
             log.info("获取转化目标:accountId:{}", accountId);
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CONVERT_LIST;
             Map<String, String> headers = new HashMap<>();
@@ -3184,7 +3183,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             JSONObject requestJson = new JSONObject();
             requestJson.put("advertiser_id", accountId);
             requestJson.put("type", type);
-
             String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
             JSONObject resultJson = JSONObject.parseObject(result);
             Integer code = resultJson.getInteger("code");
@@ -3197,11 +3195,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                             ConvertVo convertVo = JsonUtil.jsonToObj(details.getJSONObject(i), ConvertVo.class);
                             convertVoList.add(convertVo);
                         }
-
                     }
-
                 }
-
             }
         } catch (Exception e) {
             e.printStackTrace();