Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
di
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
续晓东
di
Commits
227cabc7
Commit
227cabc7
authored
Mar 27, 2020
by
续晓东
🤺
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改参数
parent
9ea7d2ab
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
10 deletions
+16
-10
PullFileTask.java
src/main/java/com/jianju/di/task/PullFileTask.java
+13
-9
FtpUtil.java
src/main/java/com/jianju/di/utils/FtpUtil.java
+3
-1
No files found.
src/main/java/com/jianju/di/task/PullFileTask.java
View file @
227cabc7
...
@@ -71,13 +71,14 @@ public class PullFileTask {
...
@@ -71,13 +71,14 @@ public class PullFileTask {
//每日23点执行;
//每日23点执行;
@Scheduled
(
cron
=
"0
0 23
* * ?"
)
@Scheduled
(
cron
=
"0
10 20
* * ?"
)
//@Scheduled(fixedRate = 10000)
//@Scheduled(fixedRate = 10000)
//@PostConstruct
public
void
PullFileAndSendDi
()
throws
Exception
{
public
void
PullFileAndSendDi
()
throws
Exception
{
FtpUtil
.
FtpConfig
ftpConfig
=
new
FtpUtil
.
FtpConfig
().
setHost
(
host
).
setPort
(
port
).
setUserName
(
userName
).
setPassword
(
password
);
FtpUtil
.
FtpConfig
ftpConfig
=
new
FtpUtil
.
FtpConfig
().
setHost
(
host
).
setPort
(
port
).
setUserName
(
userName
).
setPassword
(
password
);
Calendar
c
=
Calendar
.
getInstance
();
Calendar
c
=
Calendar
.
getInstance
();
c
.
setTime
(
new
Date
());
c
.
setTime
(
new
Date
());
c
.
add
(
Calendar
.
DATE
,
-
1
);
c
.
add
(
Calendar
.
DATE
,
-
2
);
String
fileName
=
"#"
+
dateFormat
.
format
(
c
.
getTime
());
String
fileName
=
"#"
+
dateFormat
.
format
(
c
.
getTime
());
log
.
info
(
"开始下载----"
+
fileName
);
log
.
info
(
"开始下载----"
+
fileName
);
...
@@ -90,18 +91,20 @@ public class PullFileTask {
...
@@ -90,18 +91,20 @@ public class PullFileTask {
PostGISMannager
postGIS
=
new
PostGISMannager
(
dbHost
,
dbPort
,
PostGISMannager
postGIS
=
new
PostGISMannager
(
dbHost
,
dbPort
,
dbName
,
tbName
,
dbUserName
,
dbPassword
);
dbName
,
tbName
,
dbUserName
,
dbPassword
);
postGIS
.
createOlrDay
(
tbName
);
postGIS
.
createOlrDay
(
tbName
);
if
(
postGIS
.
insertOlrToPG
(
tbName
,
localPath
+
fileName
)>
0
){
if
(
postGIS
.
insertOlrToPG
(
tbName
,
localPath
+
fileName
)>
0
){
// 发送Di
// 发送Di
afterDown
=
System
.
currentTimeMillis
();
afterDown
=
System
.
currentTimeMillis
();
Date
start
=
new
Date
(
beforeDown
);
Date
start
=
new
Date
(
beforeDown
);
String
diJson
=
sendDi
(
c
.
getTime
(),
new
Date
(
beforeDown
),
new
Date
(
afterDown
),
fileName
,
"1"
);
String
diJson
=
sendDi
(
c
.
getTime
(),
new
Date
(
beforeDown
),
new
Date
(
afterDown
),
fileName
,
"1"
);
OkHttpClient
httpClient
=
new
OkHttpClient
();
OkHttpClient
httpClient
=
new
OkHttpClient
();
RequestBody
requestBody
=
RequestBody
.
create
(
MediaType
.
parse
(
"application/json; charset=utf-8"
),
JSONObject
.
toJSONString
(
diJson
)
);
RequestBody
requestBody
=
RequestBody
.
create
(
MediaType
.
parse
(
"application/json; charset=utf-8"
),
diJson
);
Request
request
=
new
Request
.
Builder
()
Request
request
=
new
Request
.
Builder
()
.
url
(
"127.0.0.1:29999/transfer"
)
.
url
(
"
http://
127.0.0.1:29999/transfer"
)
.
post
(
requestBody
)
.
post
(
requestBody
)
.
build
();
.
build
();
//发送请求获取响应
//发送请求获取响应
...
@@ -111,6 +114,7 @@ public class PullFileTask {
...
@@ -111,6 +114,7 @@ public class PullFileTask {
if
(
response
.
isSuccessful
()){
if
(
response
.
isSuccessful
()){
//打印服务端返回结果
//打印服务端返回结果
log
.
info
(
"请求代理返回结果==========:"
+
response
.
body
().
string
());
log
.
info
(
"请求代理返回结果==========:"
+
response
.
body
().
string
());
log
.
info
(
"请求di的Json========="
+
diJson
);
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
@@ -157,11 +161,11 @@ public class PullFileTask {
...
@@ -157,11 +161,11 @@ public class PullFileTask {
}
}
//
@PostConstruct
@PostConstruct
public
void
a
()
throws
Exception
{
public
void
a
()
throws
Exception
{
FtpUtil
.
FtpConfig
ftpConfig
=
new
FtpUtil
.
FtpConfig
().
setHost
(
host
).
setPort
(
port
).
setUserName
(
userName
).
setPassword
(
password
);
FtpUtil
.
FtpConfig
ftpConfig
=
new
FtpUtil
.
FtpConfig
().
setHost
(
host
).
setPort
(
port
).
setUserName
(
userName
).
setPassword
(
password
);
Date
dateStart
=
dateFormat
.
parse
(
"20
191119
"
);
Date
dateStart
=
dateFormat
.
parse
(
"20
200325
"
);
Date
dateEnd
=
dateFormat
.
parse
(
"20
191119
"
);
Date
dateEnd
=
dateFormat
.
parse
(
"20
200325
"
);
Calendar
c
=
Calendar
.
getInstance
();
Calendar
c
=
Calendar
.
getInstance
();
PostGISMannager
postGIS
=
new
PostGISMannager
(
dbHost
,
dbPort
,
PostGISMannager
postGIS
=
new
PostGISMannager
(
dbHost
,
dbPort
,
dbName
,
tbName
,
dbUserName
,
dbPassword
);
dbName
,
tbName
,
dbUserName
,
dbPassword
);
...
...
src/main/java/com/jianju/di/utils/FtpUtil.java
View file @
227cabc7
...
@@ -144,6 +144,7 @@ public class FtpUtil {
...
@@ -144,6 +144,7 @@ public class FtpUtil {
try
{
try
{
FTPClient
ftpClient
=
connectClient
(
ftpConfig
);
FTPClient
ftpClient
=
connectClient
(
ftpConfig
);
boolean
changeResult
=
ftpClient
.
changeWorkingDirectory
(
remotePath
);
boolean
changeResult
=
ftpClient
.
changeWorkingDirectory
(
remotePath
);
if
(!
changeResult
)
{
if
(!
changeResult
)
{
throw
new
RuntimeException
(
"切换目录失败"
);
throw
new
RuntimeException
(
"切换目录失败"
);
}
}
...
@@ -203,7 +204,7 @@ public class FtpUtil {
...
@@ -203,7 +204,7 @@ public class FtpUtil {
// 关闭本地文件流
// 关闭本地文件流
inputStream
.
close
();
inputStream
.
close
();
// 退出FTP
// 退出FTP
ftpClient
.
logout
();
//
ftpClient.logout();
//归还对象
//归还对象
offer
(
ftpClient
);
offer
(
ftpClient
);
return
result
;
return
result
;
...
@@ -221,6 +222,7 @@ public class FtpUtil {
...
@@ -221,6 +222,7 @@ public class FtpUtil {
*/
*/
private
static
FTPClient
connectClient
(
FtpConfig
ftpConfig
)
throws
IOException
{
private
static
FTPClient
connectClient
(
FtpConfig
ftpConfig
)
throws
IOException
{
FTPClient
ftpClient
=
getClient
();
FTPClient
ftpClient
=
getClient
();
ftpClient
.
enterLocalPassiveMode
();
// 连接FTP服务器
// 连接FTP服务器
ftpClient
.
connect
(
ftpConfig
.
host
,
ftpConfig
.
port
);
ftpClient
.
connect
(
ftpConfig
.
host
,
ftpConfig
.
port
);
// 登录FTP
// 登录FTP
...
...
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