syh пре 5 година
родитељ
комит
13ca9ba637

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

@@ -1,10 +1,8 @@
 package org.jeecg;
 
 import cn.com.ctop.common.module.utils.HttpUtils2;
-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 com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.http.impl.client.BasicCookieStore;
 import org.jeecg.modules.ctop.service.ICreateInternalService;
@@ -106,9 +104,7 @@ public class SampleTest {
 
     @Test
     public void test() {
-        JSONObject object = new JSONObject();
-        createInternalService.createInternal(object);
-        StatusCode.KUAISHOU_CRAWLER_APP_SUCCESS.getCode();
+        jobService.refreshWebPhone();
     }
 
     @Test

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

@@ -21,4 +21,6 @@ public interface IAppiumJobService extends IService<AppiumJob> {
     boolean bindCreative(String account, String password, String creativeName, String ksId);
 
     Map<String, Object> startTask(String account, String password, String creativeName, Integer num);
+
+    boolean refreshWebPhone();
 }

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

@@ -183,6 +183,8 @@ public class AppiumJobServiceImpl extends ServiceImpl<AppiumJobMapper, AppiumJob
             appiumTaskLogMapper.insert(log);
             log.setId(log.getId());
             try {
+                //一键新机
+                boolean success = refreshWebPhone();
                 String ksId = loginTask(2L);
                 if (null == ksId) {
                     updateStatus(appiumDevice, log, -1, 1);
@@ -203,6 +205,57 @@ public class AppiumJobServiceImpl extends ServiceImpl<AppiumJobMapper, AppiumJob
         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);