浏览代码

Merge branch 'test' into test-V2

yumeng 5 年之前
父节点
当前提交
cb8b3ff068
共有 27 个文件被更改,包括 877 次插入151 次删除
  1. 6 0
      jeecg-boot-module-system/pom.xml
  2. 65 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/RabbitConfig.java
  3. 2 1
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  4. 22 19
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ActorController.java
  5. 49 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestMqController.java
  6. 0 17
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CreateInternalServiceImpl.java
  7. 17 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/mq/Receiver.java
  8. 21 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/mq/Sender.java
  9. 5 0
      jeecg-boot-module-system/src/main/resources/application-dev.yml
  10. 9 2
      jeecg-boot-module-system/src/main/resources/application-test.yml
  11. 109 1
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  12. 2 2
      module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialInfo.java
  13. 0 9
      module-common/src/main/java/cn/com/ctop/common/module/utils/CsvUtils.java
  14. 0 10
      module-common/src/main/java/cn/com/ctop/common/module/utils/HttpUtils.java
  15. 0 48
      module-common/src/main/java/cn/com/ctop/common/module/utils/ImageUtils.java
  16. 0 12
      module-common/src/main/java/cn/com/ctop/common/module/utils/LoadFileUtil.java
  17. 254 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/MpsUtils.java
  18. 5 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/appium/controller/AppiumJobController.java
  19. 8 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/appium/service/IAppiumJobService.java
  20. 223 3
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/appium/service/impl/AppiumJobServiceImpl.java
  21. 17 6
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/service/impl/KuaishouCrawlerServiceImpl.java
  22. 9 1
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/util/AppiumUtil.java
  23. 1 1
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/util/KuaimiUtil.java
  24. 12 10
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/util/KuaishouUtil.java
  25. 2 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/service/impl/KuaishouWebInterfaceServiceImpl.java
  26. 33 0
      mondule-jbpm/pom.xml
  27. 6 1
      pom.xml

+ 6 - 0
jeecg-boot-module-system/pom.xml

@@ -36,6 +36,12 @@
     </repositories>
 
     <dependencies>
+        <!-- rabbitmq 依赖jar包-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-amqp</artifactId>
+            <version>1.5.2.RELEASE</version>
+        </dependency>
         <dependency>
             <groupId>org.jeecgframework.boot</groupId>
             <artifactId>jeecg-boot-base-common</artifactId>

+ 65 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/RabbitConfig.java

@@ -0,0 +1,65 @@
+package org.jeecg.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.Queue;
+import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
+import org.springframework.amqp.rabbit.connection.ConnectionFactory;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Scope;
+
+@Configuration
+@Slf4j
+public class RabbitConfig {
+    @Value("${spring.rabbitmq.host}")
+    private String host;
+
+    @Value("${spring.rabbitmq.port}")
+    private int port;
+
+    @Value("${spring.rabbitmq.username}")
+    private String username;
+
+    @Value("${spring.rabbitmq.password}")
+    private String password;
+
+
+    public static final String EXCHANGE_A = "my-mq-exchange_A";
+    public static final String EXCHANGE_B = "my-mq-exchange_B";
+    public static final String EXCHANGE_C = "my-mq-exchange_C";
+
+
+    public static final String QUEUE_A = "QUEUE_A";
+    public static final String QUEUE_B = "QUEUE_B";
+    public static final String QUEUE_C = "QUEUE_C";
+
+    public static final String ROUTINGKEY_A = "spring-boot-routingKey_A";
+    public static final String ROUTINGKEY_B = "spring-boot-routingKey_B";
+    public static final String ROUTINGKEY_C = "spring-boot-routingKey_C";
+
+    @Bean
+    public ConnectionFactory connectionFactory() {
+        CachingConnectionFactory connectionFactory = new CachingConnectionFactory(host, port);
+        connectionFactory.setUsername(username);
+        connectionFactory.setPassword(password);
+        connectionFactory.setVirtualHost("/");
+        connectionFactory.setPublisherConfirms(true);
+        return connectionFactory;
+    }
+
+    @Bean
+    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+    //必须是prototype类型
+    public RabbitTemplate rabbitTemplate() {
+        RabbitTemplate template = new RabbitTemplate(connectionFactory());
+        return template;
+    }
+
+    @Bean
+    public Queue helloQueue() {
+        return new Queue("hello");
+    }
+}

+ 2 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -100,9 +100,10 @@ public class ShiroConfig {
 		filterChainDefinitionMap.put("/actuator/metrics/**", "anon");
 		filterChainDefinitionMap.put("/actuator/httptrace/**", "anon");
 		filterChainDefinitionMap.put("/actuator/redis/**", "anon");
+        //消息队列
+        filterChainDefinitionMap.put("/mq/**", "anon");
         //模板测试
         filterChainDefinitionMap.put("/test/**", "anon");
-        //报表测试
 		//oauth接口
         filterChainDefinitionMap.put("/auth/**", "anon");
 		filterChainDefinitionMap.put("/ctop/syncdata/**", "anon");

+ 22 - 19
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ActorController.java

@@ -42,25 +42,6 @@ public class ActorController {
     public Result<Actor> getDetail(@RequestParam(name = "actorId") Long actorId) {
         Result<Actor> result = new Result<>();
         Actor actor = actorService.getById(actorId);
-//        ActorComment actorComment = new ActorComment();
-//        actorComment.setActorId(actorId);
-//        QueryWrapper<ActorComment> actorCommentQueryWrapper = QueryGenerator.initQueryWrapper(actorComment, null);
-//        List<ActorComment> actorCommentList = actorCommentService.list(actorCommentQueryWrapper);
-//
-//        ActorPhoto actorPhoto = new ActorPhoto();
-//        actorPhoto.setActorId(actorId);
-//        QueryWrapper<ActorPhoto> actorPhotoQueryWrapper = QueryGenerator.initQueryWrapper(actorPhoto, null);
-//        List<ActorPhoto> actorPhotoList = actorPhotoService.list(actorPhotoQueryWrapper);
-//
-//        ActorVideo actorVideo = new ActorVideo();
-//        actorVideo.setActorId(actorId);
-//        QueryWrapper<ActorVideo> actorVideoQueryWrapper = QueryGenerator.initQueryWrapper(actorVideo, null);
-//        List<ActorVideo> actorVideoList = actorVideoService.list(actorVideoQueryWrapper);
-//        Map<String, Object> map = new HashMap<String, Object>();
-//        map.put("actor", actor);
-//        map.put("actorCommentList", actorCommentList);
-//        map.put("actorPhotoList", actorPhotoList);
-//        map.put("actorVideoList", actorVideoList);
         result.setResult(actor);
         result.setSuccess(true);
         return result;
@@ -338,4 +319,26 @@ public class ActorController {
 
         return result;
     }
+
+    public static String longestCommonPrefix(String[] strs) {
+        if (strs.length == 0) {
+            return "";
+        }
+        String prefix = strs[0];
+        for (int i = 1; i < strs.length; i++) {
+            while (strs[i].indexOf(prefix) != 0) {
+                prefix = prefix.substring(0, prefix.length() - 1);
+                if (prefix.isEmpty()) {
+                    return "";
+                }
+            }
+        }
+        return prefix;
+    }
+
+
+    public static void main(String[] args) {
+        String[] strings = {"abcd", "adc", "ab", "a"};
+        System.out.println(longestCommonPrefix(strings));
+    }
 }

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

@@ -0,0 +1,49 @@
+package org.jeecg.modules.ctop.controller;
+
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
+import cn.com.ctop.crawler.modules.appium.service.IAppiumJobService;
+import cn.com.ctop.crawler.modules.appium.service.IAppiumTaskService;
+import org.jeecg.modules.mq.Sender;
+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.HashMap;
+import java.util.Map;
+
+@RestController
+@RequestMapping("mq")
+public class TestMqController {
+    @Autowired
+    private Sender sender;
+    @Autowired
+    private IAppiumJobService jobService;
+    @Autowired
+    private IAppiumTaskService appiumTaskService;
+
+    @GetMapping("hello")
+    public Map<String, Object> sayHello() {
+        Map<String, Object> result = new HashMap<>();
+        sender.send();
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS.getCode());
+        return result;
+    }
+
+    @GetMapping("task1")
+    public Map<String, Object> task1() {
+        Map<String, Object> result = new HashMap<>();
+        jobService.loginTask(2L);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS.getCode());
+        return result;
+    }
+
+    @GetMapping("task2")
+    public Map<String, Object> task2() {
+        Map<String, Object> result = new HashMap<>();
+        appiumTaskService.runTask(1, 1);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS.getCode());
+        return result;
+    }
+}

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

@@ -207,23 +207,6 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
         return resultMap;
     }
 
-    public Map<String, Object> bindAdByKuaishou() {
-        Map<String, Object> result = new HashMap<>();
-        String url = "https://ad.oceanengine.com/pages/login/index.html";
-        System.getProperties().setProperty("webdriver.chrome.driver", chromeDriver);
-        ChromeOptions chromeOptions = new ChromeOptions();
-        chromeOptions.addArguments("--headless");
-        chromeOptions.addArguments("--incognito");
-        chromeOptions.addArguments("--disable-gpu");
-        chromeOptions.addArguments("--no-sandbox");
-        chromeOptions.addArguments("--window-size=1920,1080");
-        chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
-        chromeOptions.setAcceptInsecureCerts(true);
-        WebDriver webDriver = new ChromeDriver(chromeOptions);
-        WebElement element = webDriver.findElement(By.xpath(""));
-        return result;
-    }
-
     @Override
     public Map<String, Object> createInternal(JSONObject requestJson) {
         Map<String, Object> resultMap = new HashMap<>();

+ 17 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/mq/Receiver.java

@@ -0,0 +1,17 @@
+package org.jeecg.modules.mq;
+
+import org.springframework.amqp.rabbit.annotation.RabbitHandler;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.stereotype.Component;
+
+@Component
+@RabbitListener(queues = "hello")
+public class Receiver {
+    /**
+     * 通过@RabbitHandler声明的方法,对hello队列中的消息进行处理
+     */
+    @RabbitHandler
+    public void receiver(String str) {
+        System.out.println("Receiver says:[" + str + "]");
+    }
+}

+ 21 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/mq/Sender.java

@@ -0,0 +1,21 @@
+package org.jeecg.modules.mq;
+
+import org.springframework.amqp.core.AmqpTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class Sender {
+
+    @Autowired
+    AmqpTemplate rabbitmqTemplate;
+
+    /**
+     * 发送消息
+     */
+    public void send() {
+        String content = "Sender says:" + "'hello, I'm sender'";
+        System.out.println(content);
+        rabbitmqTemplate.convertAndSend("hello", content);
+    }
+}

+ 5 - 0
jeecg-boot-module-system/src/main/resources/application-dev.yml

@@ -13,6 +13,11 @@ management:
         include: metrics,httptrace
 
 spring:
+  rabbitmq:
+    host: 39.106.184.70
+    port: 5672
+    username: guest
+    password: guest
   servlet:
     multipart:
       max-file-size: -1

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

@@ -13,6 +13,11 @@ management:
         include: metrics,httptrace
 
 spring:
+  rabbitmq:
+    host: 127.0.0.1
+    port: 5672
+    username: guest
+    password: guest
   servlet:
     multipart:
       max-file-size: -1
@@ -95,9 +100,11 @@ spring:
       datasource:
         master:
           #          url: jdbc:mysql://192.168.0.23:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
-          url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+          #          url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+          url: jdbc:mysql://33.97.120.42:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
           username: hcst
-          password: hcst2019
+          #          password: hcst2019
+          password: test@20190531
           driver-class-name: com.mysql.jdbc.Driver
           # 多数据源配置
           #multi-datasource1:

+ 109 - 1
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -1,10 +1,21 @@
 package org.jeecg;
 
+import cn.com.ctop.common.module.utils.HttpUtils2;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumJobService;
+import cn.com.ctop.crawler.modules.appium.service.IAppiumTaskService;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.http.impl.client.BasicCookieStore;
+import org.jeecg.modules.ctop.service.ICreateInternalService;
+import org.jeecg.modules.mq.Sender;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.chrome.ChromeOptions;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
@@ -12,10 +23,107 @@ import org.springframework.test.context.junit4.SpringRunner;
 @SpringBootTest
 @Slf4j
 public class SampleTest {
+    @Value("${jeecg.path.chrome-driver}")
+    private String chromeDriver;
     @Autowired
     private IAppiumJobService jobService;
+    @Autowired
+    private ICreateInternalService createInternalService;
+    @Autowired
+    private IAppiumTaskService appiumTaskService;
     @Test
-    public void testJob() {
+    public void testGetKuaishouId() {
         jobService.loginTask(2L);
     }
+
+    @Test
+    public void testKsDown() {
+        appiumTaskService.runTask(1, 1);
+    }
+
+    @Test
+    public void testKs() throws InterruptedException {
+        String url = "https://ad.e.kuaishou.com/#/welcome?redirectUrl=https%3A%2F%2Fad.e.kuaishou.com%2F%23%2Findex";
+        System.getProperties().setProperty("webdriver.chrome.driver", chromeDriver);
+        ChromeOptions chromeOptions = new ChromeOptions();
+//        chromeOptions.addArguments("--headless");
+        chromeOptions.addArguments("--incognito");
+        chromeOptions.addArguments("--disable-gpu");
+//        chromeOptions.addArguments("--no-sandbox");
+        chromeOptions.addArguments("--window-size=1920,1080");
+        chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
+        chromeOptions.setAcceptInsecureCerts(true);
+        WebDriver webDriver = new ChromeDriver(chromeOptions);
+        try {
+            Thread.sleep(3000L);
+            HttpUtils2.cookieStore = new BasicCookieStore();
+            webDriver.manage().deleteAllCookies();
+            //获取登录页面
+            webDriver.get(url);
+            Thread.sleep(3000L);
+            WebElement accountElement = webDriver.findElement(By.xpath("//div[@class='phone ']/input[@type='text']"));
+            accountElement.sendKeys("19845004383");
+            Thread.sleep(3000L);
+            WebElement passwordElement = webDriver.findElement(By.xpath("//div[@class='password ']/input[@type='password']"));
+            passwordElement.sendKeys("a123456");
+            WebElement loginElement = webDriver.findElement(By.xpath("//div[@class='foot']"));
+            Thread.sleep(3000L);
+            //点击登录
+            loginElement.click();
+            Thread.sleep(3000L);
+            //获取推广按钮
+            WebElement spreadElement = webDriver.findElement(By.linkText("推广"));
+            spreadElement.click();
+            Thread.sleep(3000L);
+            //选择广告创意
+            WebElement creativeElement = webDriver.findElement(By.xpath("//div[text()='广告创意']"));
+            creativeElement.click();
+            Thread.sleep(3000L);
+            //输入创意名称,点击搜索
+            WebElement searchElement = webDriver.findElement(By.xpath("//input[@type='text']"));
+            searchElement.sendKeys("2-这个是你画的吗-设计-11.19");
+            Thread.sleep(3000L);
+            WebElement searchButton = webDriver.findElement(By.xpath("//button[@class='ant-btn ant-input-search-button ant-btn-primary']"));
+            searchButton.click();
+            Thread.sleep(3000L);
+            WebElement tiyanElement = webDriver.findElement(By.linkText("体验"));
+            tiyanElement.click();
+            Thread.sleep(2000L);
+            WebElement inputKsIdElement = webDriver.findElement(By.xpath("//textarea[@placeholder='请输入快手账号…']"));
+            inputKsIdElement.sendKeys("123456765");
+            Thread.sleep(2000L);
+            WebElement chufaElement = webDriver.findElement(By.xpath("//button[@class='creative-experience-btn-enable']"));
+            chufaElement.click();
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            webDriver.manage().deleteAllCookies();
+            webDriver.close();
+        }
+    }
+
+    @Test
+    public void test() {
+        jobService.refreshWebPhone();
+    }
+
+    @Test
+    public void testCrawler() {
+        String account = "";
+        String password = "";
+        String creativeName = "";
+        //1:获取快手账号id
+        String ksId = jobService.loginTask(2L);
+        //2:绑定体验账号
+        boolean isbind = jobService.bindCreative(account, password, creativeName, ksId);
+        //3:转化
+        appiumTaskService.runTask(1, 1);
+    }
+
+    @Test
+    public void testMq() {
+        Sender sender = new Sender();
+        sender.send();
+    }
 }

+ 2 - 2
module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialInfo.java

@@ -68,8 +68,8 @@ public class MaterialInfo {
     /**
      * userId
      */
-    @Excel(name = "status", width = 15)
-    @ApiModelProperty(value = "status")
+    @Excel(name = "user_id", width = 15)
+    @ApiModelProperty(value = "user_id")
     private String userId;
 
 

+ 0 - 9
module-common/src/main/java/cn/com/ctop/common/module/utils/CsvUtils.java

@@ -47,13 +47,4 @@ public class CsvUtils {
         }
         wr.close();
     }
-
-    public static void main(String[] args) throws IOException {
-        String[] header = new String[]{"日期", "plan", "广告组", "花费", "曝光数", "点击数", "行为数", "点击率", "行为率", "平均千次曝光花费", "平均点击单价", "平均行为单价", "提交按钮点击", "表单提交率", "表单提交单价"};
-        String inPath = "D:\\工作文件\\360借条\\effect_unit_2019-08-02-00_2019-08-02-00.csv";
-        String outPath = "D:\\工作文件\\360借条\\effect_unit_2019-08-02-00_2019-08-02-00_bak.csv";
-        List<String[]> list = CsvUtils.readCsv(inPath, "utf8");
-        CsvUtils.writeCsv(outPath, list);
-
-    }
 }

+ 0 - 10
module-common/src/main/java/cn/com/ctop/common/module/utils/HttpUtils.java

@@ -543,16 +543,6 @@ public class HttpUtils {
         return result;
     }
 
-    public static void main(String[] args) {
-        Map<String, Object> params = new HashMap<>();
-        params.put("add", 1);
-        params.forEach((k, v) -> {
-
-        });
-
-    }
-
-
     public static String httpGetRequest(String url, Map<String, String> headers, TreeMap<String, Object> params) {
         HttpClient httpClient = createSslClientDefault();
         String strReturn = "";

+ 0 - 48
module-common/src/main/java/cn/com/ctop/common/module/utils/ImageUtils.java

@@ -140,54 +140,6 @@ public class ImageUtils {
     public int getContentLength(String content, Graphics2D graphics2D) {
         return graphics2D.getFontMetrics(graphics2D.getFont()).charsWidth(content.toCharArray(), 0, content.length());
     }
-
-    public static void main(String[] args) {
-        ImageUtils i = new ImageUtils();
-        String theme = "两件套";
-        Font font = new Font("Aa棉花糖", Font.BOLD + Font.PLAIN, 60);
-        String borderPath = "D:/border/mb/ff0099.png";
-        String coverPath = "D:/image/cover/" + theme;
-        String sourcePath = "D:/image/source/" + theme;
-        String targetPath = "D:/image/target/" + theme;
-        File coverFile = new File(coverPath);
-        if (!coverFile.exists()) {
-            coverFile.mkdirs();
-        }
-
-        int bx = 20;
-        int by = 50;
-        int cx = 70;
-        int cy = 200;
-
-        Color color = new Color(255, 0, 153, 255);
-        List<String> list = i.getContentList();
-        File sourceFile = new File(sourcePath);
-
-        String[] sourceFiles = sourceFile.list();
-        for (String str : sourceFiles) {
-            String imagePath = sourceFile.getAbsolutePath() + "/" + str;
-            new ImageUtils().resize(720, 1280, imagePath, targetPath + "/" + UUID.randomUUID() + ".jpg");
-        }
-
-        File file = new File(targetPath);
-        if (!file.exists()) {
-            file.mkdirs();
-        }
-        String[] files = file.list();
-        for (String str : files) {
-            String imagePath = file.getAbsolutePath() + "/" + str;
-            try {
-                File imageFile = new File(imagePath);
-                for (String content : list) {
-                    InputStream inputStream = new FileInputStream(imageFile);
-                    i.addTextInImage(theme, inputStream, content, color, font, borderPath, coverPath, bx, by, cx, cy);
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
     public List<String> getContentList() {
         List<String> list = new ArrayList<String>();
         //秋装

+ 0 - 12
module-common/src/main/java/cn/com/ctop/common/module/utils/LoadFileUtil.java

@@ -7,18 +7,6 @@ import java.net.HttpURLConnection;
 import java.net.URL;
 
 public class LoadFileUtil {
-
-    public static void main(String[] args) {
-        try {
-            //  downLoadFromUrl("", "");
-
-            delFile("D:\\tets1\\app\\TEST视频-1565073368755.mp4");
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
     /**
      * 上传文件
      *

+ 254 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/MpsUtils.java

@@ -0,0 +1,254 @@
+package cn.com.ctop.common.module.utils;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.exceptions.ClientException;
+import com.aliyuncs.exceptions.ServerException;
+import com.aliyuncs.mts.model.v20140618.*;
+import com.aliyuncs.profile.DefaultProfile;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@Configuration
+@PropertySource("classpath:config.properties")
+public class MpsUtils {
+    public static final String ossLocation = "oss-cn-beijing";
+    public static final String ossBucket = "ctop-part";
+    public static void main(String[] args){
+        String[] a = {"1","2","3","4","5"};
+        combinationSelect(a,3);
+        arrangementSelect(a,3);
+    }
+    /**
+     * 排列计算公式A<sup>m</sup><sub>n</sub> = n!/(n - m)!
+     * @param m
+     * @param n
+     * @return
+     */
+    public static long arrangement(int m, int n) {
+        return m <= n ? factorial(n) / factorial(n - m) : 0;
+    }
+
+    /**
+     * 排列选择(从列表中选择n个排列)
+     * @param dataList 待选列表
+     * @param n 选择个数
+     */
+    public static void arrangementSelect(String[] dataList, int n) {
+        System.out.println(String.format("A(%d, %d) = %d", dataList.length, n,
+                arrangement(n, dataList.length)));
+        arrangementSelect(dataList, new String[n], 0);
+    }
+
+    /**
+     * 排列选择
+     * @param dataList 待选列表
+     * @param resultList 前面(resultIndex-1)个的排列结果
+     * @param resultIndex 选择索引,从0开始
+     */
+    private static void arrangementSelect(String[] dataList, String[] resultList, int resultIndex) {
+        int resultLen = resultList.length;
+        // 全部选择完时,输出排列结果
+        if (resultIndex >= resultLen) {
+            System.out.println(Arrays.asList(resultList));
+            return;
+        }
+
+        // 递归选择下一个
+        for (int i = 0; i < dataList.length; i++) {
+            // 判断待选项是否存在于排列结果中
+            boolean exists = false;
+            for (int j = 0; j < resultIndex; j++) {
+                if (dataList[i].equals(resultList[j])) {
+                    exists = true;
+                    break;
+                }
+            }
+            // 排列结果不存在该项,才可选择
+            if (!exists) {
+                resultList[resultIndex] = dataList[i];
+                arrangementSelect(dataList, resultList, resultIndex + 1);
+            }
+        }
+    }
+
+    /**
+     * 计算阶乘数,即n! = n * (n-1) * ... * 2 * 1
+     * @param n
+     * @return
+     */
+    private static long factorial(int n) {
+        long sum = 1;
+        while( n > 0 ) {
+            sum = sum * n--;
+        }
+        return sum;
+    }
+
+    /**
+     * 组合计算公式C<sup>m</sup><sub>n</sub> = n! / (m! * (n - m)!)
+     * @param m
+     * @param n
+     * @return
+     */
+    public static long combination(int m, int n) {
+        return m <= n ? factorial(n) / (factorial(m) * factorial((n - m))) : 0;
+    }
+
+    /**
+     * 组合选择(从列表中选择n个组合)
+     * @param dataList 待选列表
+     * @param n 选择个数
+     */
+    public static void combinationSelect(String[] dataList, int n) {
+        System.out.println(String.format("C(%d, %d) = %d",
+                dataList.length, n, combination(n, dataList.length)));
+        combinationSelect(dataList, 0, new String[n], 0);
+    }
+
+    /**
+     * 组合选择
+     * @param dataList 待选列表
+     * @param dataIndex 待选开始索引
+     * @param resultList 前面(resultIndex-1)个的组合结果
+     * @param resultIndex 选择索引,从0开始
+     */
+    private static void combinationSelect(String[] dataList, int dataIndex, String[] resultList, int resultIndex) {
+        int resultLen = resultList.length;
+        int resultCount = resultIndex + 1;
+        // 全部选择完时,输出组合结果
+        if (resultCount > resultLen) {
+            System.out.println(Arrays.asList(resultList));
+            return;
+        }
+
+        // 递归选择下一个
+        for (int i = dataIndex; i < dataList.length + resultCount - resultLen; i++) {
+            resultList[resultIndex] = dataList[i];
+            combinationSelect(dataList, i + 1, resultList, resultIndex + 1);
+        }
+    }
+
+    public IAcsClient getClient(){
+        DefaultProfile profile = DefaultProfile.getProfile(
+                "cn-beijing",      // 地域ID
+                "LTAIbNbqWzSOklQV",      // RAM账号的AccessKey ID
+                "1rkPz7JNoXk8sJevPaeYHWqfkQXBGh"); // RAM账号Access Key Secret
+        IAcsClient client = new DefaultAcsClient(profile);
+        return client;
+    }
+
+    public String mergeOneVideo(String startPart,List<String> videoPart,String endPart){
+        IAcsClient client = getClient();
+        String pipelineId = getPipelineId(client);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        String outputFilename = "output/"+sdf.format(new Date())+"/"+ UUID.randomUUID()+".mp4";
+        List<String> videos = new ArrayList<>();
+        videos.add(startPart);
+        videos.addAll(videoPart);
+        videos.add(endPart);
+        mergeVideo(client,pipelineId,videos,outputFilename);
+        return outputFilename;
+    }
+
+    public String mergeVideo(IAcsClient client, String pipelineId, List<String> videos, String outputName){
+        String jobId = null;
+        SubmitJobsRequest request = new SubmitJobsRequest();
+        JSONArray mergeList = new JSONArray();
+        if (videos != null && videos.size() > 0){
+            for (int i = 0; i < videos.size();i++){
+                String url = videos.get(i);
+                if (i == 0){
+                    JSONObject input = new JSONObject();
+                    input.put("Location", ossLocation);
+                    input.put("Bucket", ossBucket);
+                    try {
+                        input.put("Object", URLEncoder.encode(url, "utf-8"));
+                    } catch (UnsupportedEncodingException e) {
+                        throw new RuntimeException("input URL encode failed");
+                    }
+                    request.setInput(input.toJSONString());
+                }else {
+                    JSONObject mergeVideo = new JSONObject();
+                    String mergeVideoURL;
+                    try {
+                        mergeVideoURL = String.format(
+                                "http://%s.%s.aliyuncs.com/%s",
+                                ossBucket,
+                                ossLocation,
+                                URLEncoder.encode(url, "utf-8"));
+                    } catch (UnsupportedEncodingException e) {
+                        throw new RuntimeException("mergeVideoURL encode failed");
+                    }
+                    mergeVideo.put("MergeURL", mergeVideoURL);
+                    mergeList.add(mergeVideo);
+                }
+            }
+        }
+        String outputOSSObject;
+        try {
+            outputOSSObject = URLEncoder.encode(outputName, "utf-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException("output URL encode failed");
+        }
+        JSONObject output = new JSONObject();
+        output.put("OutputObject", outputOSSObject);
+        JSONObject video = new JSONObject();
+        video.put("Width", "1280");
+        video.put("Height", "720");
+        output.put("Video", video.toJSONString());
+        output.put("MergeList", mergeList.toJSONString());
+        // Outputs
+        JSONArray outputs = new JSONArray();
+        outputs.add(output);
+        request.setOutputs(outputs.toJSONString());
+        request.setOutputBucket(ossBucket);
+        request.setOutputLocation(ossLocation);
+        // PipelineId
+        request.setPipelineId(pipelineId);
+        // call api
+        SubmitJobsResponse response;
+        try {
+            response = client.getAcsResponse(request);
+            System.out.println("RequestId is:"+response.getRequestId());
+            if (response.getJobResultList().get(0).getSuccess()) {
+                jobId = response.getJobResultList().get(0).getJob().getJobId();
+                System.out.println("JobId is:" + response.getJobResultList().get(0).getJob().getJobId());
+            } else {
+                System.out.println("SubmitJobs Failed code:" + response.getJobResultList().get(0).getCode() +
+                        " message:" + response.getJobResultList().get(0).getMessage());
+            }
+        } catch (ServerException e) {
+            e.printStackTrace();
+        } catch (ClientException e) {
+            e.printStackTrace();
+        }
+        return jobId;
+    }
+
+    public String getPipelineId(IAcsClient client){
+        String pipelineId = null;
+        // 创建API请求并设置参数
+        SearchPipelineRequest request = new SearchPipelineRequest();
+        // 发起请求并处理应答或异常
+        SearchPipelineResponse response;
+        try {
+            response = client.getAcsResponse(request);
+            pipelineId = response.getPipelineList().get(0).getId();
+            System.out.println("PipelineName is:" + response.getPipelineList().get(0).getName());
+            System.out.println("PipelineId is:" + response.getPipelineList().get(0).getId());
+        } catch (ServerException e) {
+            e.printStackTrace();
+        } catch (ClientException e) {
+            e.printStackTrace();
+        }
+        return pipelineId;
+    }
+}

+ 5 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/appium/controller/AppiumJobController.java

@@ -263,4 +263,9 @@ public class AppiumJobController {
         }
         return result;
     }
+
+    @PostMapping("startTask")
+    public Map<String, Object> startTask(String account, String password, String creativeName, Integer num) {
+        return appiumJobService.startTask(account, password, creativeName, num);
+    }
 }

+ 8 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/appium/service/IAppiumJobService.java

@@ -3,6 +3,8 @@ package cn.com.ctop.crawler.modules.appium.service;
 import cn.com.ctop.crawler.modules.appium.entity.AppiumJob;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.Map;
+
 /**
  * 爬虫调度任务
  *
@@ -15,4 +17,10 @@ public interface IAppiumJobService extends IService<AppiumJob> {
     void runTask(Long jobId, Long num);
 
     String loginTask(Long taskId);
+
+    boolean bindCreative(String account, String password, String creativeName, String ksId);
+
+    Map<String, Object> startTask(String account, String password, String creativeName, Integer num);
+
+    boolean refreshWebPhone();
 }

+ 223 - 3
module-crawler/src/main/java/cn/com/ctop/crawler/modules/appium/service/impl/AppiumJobServiceImpl.java

@@ -1,23 +1,33 @@
 package cn.com.ctop.crawler.modules.appium.service.impl;
 
+import cn.com.ctop.common.module.utils.HttpUtils2;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
-import cn.com.ctop.crawler.modules.appium.entity.AppiumJob;
-import cn.com.ctop.crawler.modules.appium.entity.AppiumTask;
-import cn.com.ctop.crawler.modules.appium.entity.AppiumTaskItem;
+import cn.com.ctop.crawler.modules.appium.entity.*;
 import cn.com.ctop.crawler.modules.appium.mapper.AppiumJobMapper;
 import cn.com.ctop.crawler.modules.appium.mapper.AppiumTaskItemMapper;
+import cn.com.ctop.crawler.modules.appium.mapper.AppiumTaskLogMapper;
+import cn.com.ctop.crawler.modules.appium.service.IAppiumDeviceService;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumJobService;
+import cn.com.ctop.crawler.modules.appium.service.IAppiumTaskService;
 import cn.com.ctop.crawler.modules.core.util.AppiumUtil;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import io.appium.java_client.android.AndroidDriver;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.http.impl.client.BasicCookieStore;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.chrome.ChromeDriver;
+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.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Stack;
 
 /**
  * 爬虫调度任务
@@ -33,6 +43,12 @@ public class AppiumJobServiceImpl extends ServiceImpl<AppiumJobMapper, AppiumJob
     private AppiumJobMapper appiumJobMapper;
     @Autowired
     private AppiumTaskItemMapper taskItemMapper;
+    @Value("${jeecg.path.chrome-driver}")
+    private String chromeDriver;
+    @Autowired
+    private IAppiumDeviceService appiumDeviceService;
+    @Autowired
+    private AppiumTaskLogMapper appiumTaskLogMapper;
 
     @Override
     public void runTask(Long jobId, Long num) {
@@ -76,4 +92,208 @@ public class AppiumJobServiceImpl extends ServiceImpl<AppiumJobMapper, AppiumJob
         System.out.println(kuaishouId);
         return kuaishouId;
     }
+
+    @Override
+    public boolean bindCreative(String account, String password, String creativeName, String ksId) {
+        boolean isBind = false;
+        String url = "https://ad.e.kuaishou.com/#/welcome?redirectUrl=https%3A%2F%2Fad.e.kuaishou.com%2F%23%2Findex";
+        System.getProperties().setProperty("webdriver.chrome.driver", chromeDriver);
+        ChromeOptions chromeOptions = new ChromeOptions();
+        chromeOptions.addArguments("--headless");
+        chromeOptions.addArguments("--incognito");
+        chromeOptions.addArguments("--disable-gpu");
+//        chromeOptions.addArguments("--no-sandbox");
+        chromeOptions.addArguments("--window-size=1920,1080");
+        chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
+        chromeOptions.setAcceptInsecureCerts(true);
+        WebDriver webDriver = new ChromeDriver(chromeOptions);
+        try {
+            Thread.sleep(3000L);
+            HttpUtils2.cookieStore = new BasicCookieStore();
+            webDriver.manage().deleteAllCookies();
+            //获取登录页面
+            webDriver.get(url);
+            Thread.sleep(3000L);
+            WebElement accountElement = webDriver.findElement(By.xpath("//div[@class='phone ']/input[@type='text']"));
+            accountElement.sendKeys(account);
+            Thread.sleep(3000L);
+            WebElement passwordElement = webDriver.findElement(By.xpath("//div[@class='password ']/input[@type='password']"));
+            passwordElement.sendKeys(password);
+            WebElement loginElement = webDriver.findElement(By.xpath("//div[@class='foot']"));
+            Thread.sleep(3000L);
+            //点击登录
+            loginElement.click();
+            Thread.sleep(3000L);
+            //获取推广按钮
+            WebElement spreadElement = webDriver.findElement(By.linkText("推广"));
+            spreadElement.click();
+            Thread.sleep(3000L);
+            //选择广告创意
+            WebElement creativeElement = webDriver.findElement(By.xpath("//div[text()='广告创意']"));
+            creativeElement.click();
+            Thread.sleep(3000L);
+            //输入创意名称,点击搜索
+            WebElement searchElement = webDriver.findElement(By.xpath("//input[@type='text']"));
+            searchElement.sendKeys(creativeName);
+            Thread.sleep(3000L);
+            WebElement searchButton = webDriver.findElement(By.xpath("//button[@class='ant-btn ant-input-search-button ant-btn-primary']"));
+            searchButton.click();
+            Thread.sleep(3000L);
+            WebElement tiyanElement = webDriver.findElement(By.linkText("体验"));
+            tiyanElement.click();
+            Thread.sleep(2000L);
+            WebElement inputKsIdElement = webDriver.findElement(By.xpath("//textarea[@placeholder='请输入快手账号…']"));
+            inputKsIdElement.sendKeys(ksId);
+            Thread.sleep(2000L);
+            WebElement chufaElement = webDriver.findElement(By.xpath("//button[@class='creative-experience-btn-enable']"));
+            chufaElement.click();
+            isBind = true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("绑定体验快手账号失败");
+        } finally {
+            webDriver.manage().deleteAllCookies();
+            webDriver.close();
+            return isBind;
+        }
+    }
+
+    @Autowired
+    private IAppiumTaskService appiumTaskService;
+
+    @Override
+    public Map<String, Object> startTask(String account, String password, String creativeName, Integer num) {
+        Map<String, Object> result = new HashMap<>();
+        int i = 0;
+        while (i < num) {
+            if (i > num) {
+                break;
+            }
+            //获取手机设备信息
+            AppiumDevice appiumDevice = appiumDeviceService.getById(2L);
+            appiumDevice.setStatus(2);
+            appiumDeviceService.updateById(appiumDevice);
+            AppiumTaskLog log = new AppiumTaskLog();
+            log.setDeviceId(2);
+            log.setDeviceIp(appiumDevice.getIp());
+            log.setDevicePort(appiumDevice.getPort());
+            log.setStatus(1);
+            log.setTaskId(1);
+            log.setTaskName("快手刷量任务");
+            appiumTaskLogMapper.insert(log);
+            log.setId(log.getId());
+            try {
+                //一键新机
+                boolean success = refreshWebPhone();
+                String ksId = loginTask(2L);
+                if (null == ksId) {
+                    updateStatus(appiumDevice, log, -1, 1);
+                    continue;
+                }
+                boolean isBind = bindCreative(account, password, creativeName, ksId);
+                if (!isBind) {
+                    updateStatus(appiumDevice, log, -2, 1);
+                    continue;
+                }
+                appiumTaskService.runTask(1, 1);
+                i++;
+            } catch (Exception e) {
+                updateStatus(appiumDevice, log, -3, 1);
+                continue;
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public boolean refreshWebPhone() {
+        boolean success = false;
+        String url = "https://lcloud.longene.com.cn/";
+        System.getProperties().setProperty("webdriver.chrome.driver", chromeDriver);
+        ChromeOptions chromeOptions = new ChromeOptions();
+//        chromeOptions.addArguments("--headless");
+        chromeOptions.addArguments("--incognito");
+        chromeOptions.addArguments("--disable-gpu");
+//        chromeOptions.addArguments("--no-sandbox");
+        chromeOptions.addArguments("--window-size=1920,1080");
+        chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
+        chromeOptions.setAcceptInsecureCerts(true);
+        WebDriver webDriver = new ChromeDriver(chromeOptions);
+        try {
+            Thread.sleep(3000L);
+            HttpUtils2.cookieStore = new BasicCookieStore();
+            webDriver.manage().deleteAllCookies();
+            //获取登录页面
+            webDriver.get(url);
+            Thread.sleep(3000L);
+            WebElement accountElement = webDriver.findElement(By.id("username"));
+            accountElement.sendKeys("18600471989");
+            Thread.sleep(3000L);
+            WebElement passwordElement = webDriver.findElement(By.id("userpwd"));
+            passwordElement.sendKeys("0759125184xu");
+            WebElement loginElement = webDriver.findElement(By.xpath("//input[@class='quc-submit quc-button quc-button-primary quc-button-sign-in']"));
+            Thread.sleep(3000L);
+            //点击登录
+            loginElement.click();
+            Thread.sleep(3000L);
+            //选择华东二站
+            WebElement spreadElement = webDriver.findElement(By.xpath("//a[@href='javascript:gotobranch(2)']"));
+            spreadElement.click();
+            Thread.sleep(3000L);
+            //
+            webDriver.get("https://ecsite.longene.com.cn/userWeb!batchipswitch?ids=4293&groupid=8729&mode=5&ipbind=0&region=0&ipareas=");
+            Thread.sleep(5000L);
+            webDriver.get("https://ecsite.longene.com.cn/userWeb!batchnewphone?groupid=8729&pkgnames=com.smile.gifmaker&ids=4293");
+            Thread.sleep(5000L);
+            success = true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("一键新机操作失败");
+        } finally {
+            webDriver.manage().deleteAllCookies();
+            webDriver.close();
+            return success;
+        }
+    }
+
+    private void updateStatus(AppiumDevice appiumDevice, AppiumTaskLog log, Integer logStatus, Integer deviceStatus) {
+        log.setStatus(3);
+        appiumTaskLogMapper.updateById(log);
+        appiumDevice.setStatus(1);
+        appiumDeviceService.updateById(appiumDevice);
+    }
+
+    public static boolean isValid(String s) {
+        if (null == s || s.length() <= 0) {
+            return true;
+        }
+        if (s.length() % 2 == 1) {
+            return false;
+        }
+        Stack<Character> stack = new Stack<>();
+        for (int i = 0; i < s.length(); i++) {
+            char getchar = s.charAt(i);
+            if (getchar == '(' || getchar == '{' || getchar == '[') {
+                stack.push(getchar);
+            }
+            if (getchar == ')' || getchar == '}' || getchar == ']') {
+                if (stack.empty()) {
+                    return false;
+                }
+                char sufix = stack.pop();
+                if ((getchar == ')' && sufix != '(') || (getchar == '}' && sufix != '{') || (getchar == ']' && sufix != '[')) {
+                    stack.push(sufix);
+                }
+            }
+        }
+        if (stack.empty()) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public static void main(String[] args) {
+        System.out.println(isValid("[]()[]"));
+    }
 }

文件差异内容过多而无法显示
+ 17 - 6
module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/service/impl/KuaishouCrawlerServiceImpl.java


+ 9 - 1
module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/util/AppiumUtil.java

@@ -741,7 +741,15 @@ public class AppiumUtil {
                             } else if (appiumTaskItem.getClickType().equals("point")) {
                                 Point point = element.getLocation();
                                 System.out.println(point.getX() + ":" + point.getY());
-                                tapPoint(androidDriver, point.getX() + appiumTaskItem.getOffsiteX(), point.getY() + appiumTaskItem.getOffsiteY());
+                                Integer x = point.getX();
+                                Integer y = point.getY();
+                                if (null != appiumTaskItem.getOffsiteX()) {
+                                    x += appiumTaskItem.getOffsiteX();
+                                }
+                                if (null != appiumTaskItem.getOffsiteY()) {
+                                    y += appiumTaskItem.getOffsiteY();
+                                }
+                                tapPoint(androidDriver, x, y);
                             } else if (appiumTaskItem.getClickType().equals("send")) {
                                 String text = appiumTaskItem.getTextEqualKey();
                                 element.sendKeys(text);

+ 1 - 1
module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/util/KuaimiUtil.java

@@ -10,7 +10,7 @@ import java.util.regex.Pattern;
  * 2019年11月12日10:04:00
  */
 public class KuaimiUtil {
-    public static final String KUAIMI_API_URL = "http://api.kmiyz.com/api/do.php";
+    public static final String KUAIMI_API_URL = "http://api.caihyz.com/api/do.php";
 
     public static String kuaimiLogin() throws Exception {
         String result = HttpUtils.httpPostNoParamRequest(KUAIMI_API_URL + "?action=loginIn&name=xuzuoyun&password=heaven01");

+ 12 - 10
module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/util/KuaishouUtil.java

@@ -1,21 +1,19 @@
 package cn.com.ctop.crawler.modules.core.util;
 
+import cn.com.ctop.common.module.entity.IpPool;
 import cn.com.ctop.crawler.modules.core.entity.HttpBody;
 import cn.com.ctop.crawler.modules.core.entity.HttpCookie;
 import cn.com.ctop.crawler.modules.core.entity.HttpEntity;
 import cn.com.ctop.crawler.modules.core.entity.HttpHeader;
 import cn.com.ctop.crawler.modules.log.entity.CrawlerLog;
 import com.google.gson.Gson;
+import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
-import org.apache.http.client.CookieStore;
 import org.apache.http.client.config.CookieSpecs;
 import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
 import org.apache.http.conn.ssl.TrustStrategy;
-import org.apache.http.cookie.ClientCookie;
-import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.BasicCookieStore;
 import org.apache.http.impl.client.CloseableHttpClient;
@@ -30,7 +28,7 @@ import java.security.cert.X509Certificate;
 import java.util.*;
 
 public class KuaishouUtil {
-    public static CrawlerLog requestData(HttpEntity httpEntity){
+    public static CrawlerLog requestData(HttpEntity httpEntity, IpPool ipPool) {
         long beginTime = System.currentTimeMillis();
         CrawlerLog crawlerLog = new CrawlerLog();
         String salt = "382700b563f4";
@@ -64,8 +62,14 @@ public class KuaishouUtil {
                     return true;
                 }
             }).build();
-            RequestConfig globalConfig = RequestConfig.custom().setConnectTimeout(30000).setSocketTimeout(30000).setCookieSpec(CookieSpecs.STANDARD).build();
+            RequestConfig globalConfig = null;
             SSLConnectionSocketFactory sslFactory = new SSLConnectionSocketFactory(sslContext);
+            if (ipPool != null) {
+                HttpHost proxy = new HttpHost(ipPool.getIp(), ipPool.getPort(), "http");
+                globalConfig = RequestConfig.custom().setProxy(proxy).setConnectTimeout(60000).setSocketTimeout(60000).setCookieSpec(CookieSpecs.STANDARD).build();
+            } else {
+                globalConfig = RequestConfig.custom().setConnectTimeout(60000).setSocketTimeout(60000).setCookieSpec(CookieSpecs.STANDARD).build();
+            }
             CloseableHttpClient httpClient = HttpClients.custom().setDefaultCookieStore(cookieStore).setDefaultRequestConfig(globalConfig).setConnectionReuseStrategy((response, context) -> false ).setSSLSocketFactory(sslFactory).build();
             HttpPost httppost = new HttpPost(httpEntity.getUrl()+httpEntity.getPath()+"?"+staticQueryString);
             HttpHeader header = httpEntity.getHttpHeader();
@@ -106,7 +110,7 @@ public class KuaishouUtil {
         return String.valueOf(nextInt);
     }
 
-    public static CrawlerLog kuaishouAppDataFeatch(String url,String path,String urlParam,String bodyParam,String headerParam,String token){
+    public static CrawlerLog kuaishouAppDataFeatch(String url, String path, String urlParam, String bodyParam, String headerParam, String token, IpPool ipPool) {
         HttpEntity httpEntity = new HttpEntity();
         Map<String,String> staticParams = HttpParamUtil.urlParamToMap(urlParam);
         Map<String,String> dynamicParams = HttpParamUtil.urlParamToMap(bodyParam);
@@ -128,8 +132,6 @@ public class KuaishouUtil {
         httpBody.setStaticParams(staticParams);
         httpEntity.setHttpHeader(header);
         httpEntity.setHttpBody(httpBody);
-        return KuaishouUtil.requestData(httpEntity);
+        return KuaishouUtil.requestData(httpEntity, ipPool);
     }
-
-
 }

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

@@ -24,7 +24,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.gson.Gson;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.LogFactory;
 import org.apache.fontbox.ttf.CmapSubtable;
 import org.apache.fontbox.ttf.GlyphData;
 import org.apache.fontbox.ttf.TTFParser;
@@ -715,6 +714,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
         }
     }
 
+    @Override
     public void sendPreview(Integer creativeId, String kwid) {
         try {
             List<Cookie> list = HttpUtils2.cookieStore.getCookies();
@@ -744,6 +744,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
         }
     }
 
+    @Override
     public void adekuaishouWebLogin(String phone, String password) throws IOException {
         ChromeDriverService service = new ChromeDriverService.Builder().usingDriverExecutable(new File("D:/chromedriver.exe")).usingAnyFreePort().build();
         service.start();
@@ -818,19 +819,12 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
                 clientCookie.setDomain("ad.e.kuaishou.com");
                 clientCookie.setPath(cookieMap.get("path"));
                 HttpUtils2.cookieStore.addCookie(clientCookie);
-//                clientCookie.setDomain("id.kuaishou.com");
-////                HttpUtils2.cookieStore.addCookie(clientCookie);
-////                clientCookie.setDomain("uc.e.kuaishou.com");
-////                HttpUtils2.cookieStore.addCookie(clientCookie);
             }
             String result = HttpUtils2.httpGetRequest("https://uc.e.kuaishou.com/rest/web/login?sid=kuaishou.ad.dsp&followUrl=https%3A%2F%2Fad.e.kuaishou.com%2F%23%2Findex");
             System.out.println(result);
         } catch (Exception e) {
             e.printStackTrace();
         } finally {
-//            webDriver.quit();
-//            service.stop();
-//            HttpUtils.cookieStore.clear();
         }
     }
 

+ 33 - 0
mondule-jbpm/pom.xml

@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>jeecg-boot-parent</artifactId>
+        <groupId>org.jeecgframework.boot</groupId>
+        <version>2.0.2</version>
+    </parent>
+    <groupId>cn.com.ctop</groupId>
+    <artifactId>jbpm</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>jbpm</name>
+
+    <properties>
+        <java.version>1.8</java.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>cn.com.ctop</groupId>
+            <artifactId>module-common</artifactId>
+            <version>2.0.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.activiti</groupId>
+            <artifactId>activiti-spring</artifactId>
+            <version>6.0.0</version>
+        </dependency>
+    </dependencies>
+
+
+</project>

+ 6 - 1
pom.xml

@@ -76,7 +76,7 @@
         <mybatis-plus.version>3.0.6</mybatis-plus.version>
         <druid.version>1.1.10</druid.version>
         <commons.version>2.6</commons.version>
-        <aliyun-java-sdk-core.version>3.2.3</aliyun-java-sdk-core.version>
+        <aliyun-java-sdk-core.version>3.5.0</aliyun-java-sdk-core.version>
         <aliyun-java-sdk-dysmsapi.version>1.0.0</aliyun-java-sdk-dysmsapi.version>
 
     </properties>
@@ -357,6 +357,11 @@
             <artifactId>aliyun-sdk-oss</artifactId>
             <version>2.8.3</version>
         </dependency>
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>aliyun-java-sdk-mts</artifactId>
+            <version>2.5.2</version>
+        </dependency>
     </dependencies>
 
     <dependencyManagement>