Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
TestSpider
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Bugzilla
Bugzilla
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
尚立鹏
TestSpider
Commits
f6bd2d52
Commit
f6bd2d52
authored
Feb 09, 2023
by
shanglipeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify rpa
parent
fbd8d21a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
118 additions
and
22 deletions
+118
-22
pom.xml
pom.xml
+56
-0
TestTask.java
src/main/java/com/greatchn/etax/test/TestTask.java
+35
-0
RpaConfig.java
src/main/java/com/greatchn/rpa/config/RpaConfig.java
+3
-2
TaskExecutor.java
src/main/java/com/greatchn/yzh/TaskExecutor.java
+22
-18
rpa.yaml
src/main/resources/rpa.yaml
+2
-2
No files found.
pom.xml
View file @
f6bd2d52
...
...
@@ -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>
...
...
src/main/java/com/greatchn/etax/test/TestTask.java
0 → 100644
View file @
f6bd2d52
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);
// }
}
}
src/main/java/com/greatchn/rpa/config/RpaConfig.java
View file @
f6bd2d52
...
...
@@ -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
(
URISyntax
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
throw
new
IllegalArgumentException
(
"Selenium 驱动不可用!"
);
}
}
...
...
src/main/java/com/greatchn/yzh/TaskExecutor.java
View file @
f6bd2d52
...
...
@@ -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
()
{
...
...
src/main/resources/rpa.yaml
View file @
f6bd2d52
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment