Commit f6bd2d52 authored by shanglipeng's avatar shanglipeng

modify rpa

parent fbd8d21a
......@@ -175,6 +175,62 @@
<target>17</target>
</configuration>
</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>
</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 {
public File getExe() {
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()) {
throw new IllegalArgumentException("Selenium 驱动不可用!");
}
return exe;
} catch (URISyntaxException ex) {
} catch (Exception ex) {
throw new IllegalArgumentException("Selenium 驱动不可用!");
}
}
......
......@@ -39,26 +39,30 @@ public final class TaskExecutor {
tianjin = new Tianjin(RpaConfig.build("rpa.yaml"));
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);
// 任务处理
while (monitor.doNext()) {
// 读取任务,并执行任务锁处理
System.out.println("TODO 执行任务!");
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException ignored) {
}
{
// var executorService = new ScheduledThreadPoolExecutor(1, new RpaThreadFactory("RPA", true));
// var schedule = executorService.scheduleWithFixedDelay(this::doHeartbeat, 1, 3, TimeUnit.SECONDS);
// // 任务处理
// while (monitor.doNext()) {
// // 读取任务,并执行任务锁处理
// System.out.println("TODO 执行任务!");
// try {
// 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() {
......
selenium:
driver: driver/chromedriver109.exe
driver: /Google/Chrome/Application/chromedriver109.exe
browser:
chrome: C:\Program Files\Google\Chrome\Application\chrome.exe
chrome: /Google/Chrome/Application/chrome.exe
rpa:
proxy:
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