Commit f6bd2d52 authored by shanglipeng's avatar shanglipeng

modify rpa

parent fbd8d21a
...@@ -175,6 +175,62 @@ ...@@ -175,6 +175,62 @@
<target>17</target> <target>17</target>
</configuration> </configuration>
</plugin> </plugin>
<!-- 一、如果没有依赖第三方包,可以用maven-jar-plugin插件,只是修改META-INFO下的MANIFEST.MF信息,指定运行jar包的main入口-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<useUniqueVersions>false</useUniqueVersions>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.greatchn.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<!--二、可以把第三方包下载到lib目录-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!-- 拷贝项目依赖包到lib/目录下 -->
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<!-- 间接依赖也拷贝 -->
<excludeTransitive>false</excludeTransitive>
<!-- 带上版本号 -->
<stripVersion>false</stripVersion>
</configuration>
</execution>
</executions>
</plugin>
<!--三、把依赖也打进jar包:mainClass是jar包的main方法入口-->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.greatchn.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
......
package com.greatchn.etax.test;
import com.greatchn.etax.BaseEtax;
import com.greatchn.etax.FunctionResult;
import com.greatchn.etax.tianjin.LoginFunction;
import com.greatchn.etax.tianjin.SessionFunction;
import com.greatchn.etax.tianjin.SwitchTaxpayerFunction;
import com.greatchn.rpa.config.RpaConfig;
import org.openqa.selenium.By;
import java.util.Objects;
public class TestTask extends BaseEtax {
private static final String TEST_CONFIG = "etax/TestTask.yaml";
public TestTask(RpaConfig rpaConfig) {
this(rpaConfig, TEST_CONFIG);
}
public TestTask(RpaConfig rpaConfig, String etaxConfigPath) {
super(rpaConfig, etaxConfigPath);
if (!rpa().isCreate()) {
rpa().create();
}
}
public FunctionResult<Object> loginAndDoSth(String taxFileNo, String personId, String personPassword) {
return null;
//login
// {
// this.rpa().visit("https://tpass.tianjin.chinatax.gov.cn:8443/#/login?redirect_uri=https%3A%2F%2Fetax.tianjin.chinatax.gov.cn%2Foutsider%2Fsso%2FmainPage.do&client_id=x3ef652ax3294xz6beefnf5zadbf66cc&response_type=code&state=test");
// this.rpa().sendKey(By.cssSelector(""),taxFileNo);
// this.rpa().sendKey(By.cssSelector(""),personId);
// this.rpa().sendKey(By.cssSelector(""),personPassword);
// }
}
}
...@@ -96,12 +96,13 @@ public class RpaConfig { ...@@ -96,12 +96,13 @@ public class RpaConfig {
public File getExe() { public File getExe() {
try { try {
var exe = new File(ClassLoader.getSystemResource(driver).toURI()); // var exe = new File(ClassLoader.getSystemResource(driver).toURI());
var exe = new File(driver);
if (!exe.exists() || !exe.isFile()) { if (!exe.exists() || !exe.isFile()) {
throw new IllegalArgumentException("Selenium 驱动不可用!"); throw new IllegalArgumentException("Selenium 驱动不可用!");
} }
return exe; return exe;
} catch (URISyntaxException ex) { } catch (Exception ex) {
throw new IllegalArgumentException("Selenium 驱动不可用!"); throw new IllegalArgumentException("Selenium 驱动不可用!");
} }
} }
......
...@@ -39,26 +39,30 @@ public final class TaskExecutor { ...@@ -39,26 +39,30 @@ public final class TaskExecutor {
tianjin = new Tianjin(RpaConfig.build("rpa.yaml")); tianjin = new Tianjin(RpaConfig.build("rpa.yaml"));
monitor = new Monitor(); monitor = new Monitor();
tianjin.login("91120223MA079XXY07", "131026199607185115", "ds111111");
// tianjin.queryDutyPaidProof("91120223MA079XXY07", "131026199607185115", "ds111111","510211201000000362315","2019-01-01", "2019-12-31");
// 心跳 // 心跳
var executorService = new ScheduledThreadPoolExecutor(1, new RpaThreadFactory("RPA", true)); {
var schedule = executorService.scheduleWithFixedDelay(this::doHeartbeat, 1, 3, TimeUnit.SECONDS); // var executorService = new ScheduledThreadPoolExecutor(1, new RpaThreadFactory("RPA", true));
// 任务处理 // var schedule = executorService.scheduleWithFixedDelay(this::doHeartbeat, 1, 3, TimeUnit.SECONDS);
while (monitor.doNext()) { // // 任务处理
// 读取任务,并执行任务锁处理 // while (monitor.doNext()) {
System.out.println("TODO 执行任务!"); // // 读取任务,并执行任务锁处理
try { // System.out.println("TODO 执行任务!");
TimeUnit.SECONDS.sleep(1); // try {
} catch (InterruptedException ignored) { // TimeUnit.SECONDS.sleep(1);
} // } catch (InterruptedException ignored) {
// }
// }
// log.error("停止服务!");
// tianjin.shutdown();
// log.error("停止心跳定时任务!");
// schedule.cancel(true);
// executorService.shutdownNow();
// log.error("销毁监控服务!");
// monitor.exit();
// System.exit(0);
} }
log.error("停止服务!");
tianjin.shutdown();
log.error("停止心跳定时任务!");
schedule.cancel(true);
executorService.shutdownNow();
log.error("销毁监控服务!");
monitor.exit();
System.exit(0);
} }
private void doHeartbeat() { private void doHeartbeat() {
......
selenium: selenium:
driver: driver/chromedriver109.exe driver: /Google/Chrome/Application/chromedriver109.exe
browser: browser:
chrome: C:\Program Files\Google\Chrome\Application\chrome.exe chrome: /Google/Chrome/Application/chrome.exe
rpa: rpa:
proxy: proxy:
enable: true enable: true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment