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
71409ae5
Commit
71409ae5
authored
Mar 23, 2020
by
Xuxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成pullwenjian
parent
f77b2a13
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
9 deletions
+35
-9
PullFileTask.java
src/main/java/com/jianju/di/task/PullFileTask.java
+33
-8
application.yml
src/main/resources/application.yml
+2
-1
No files found.
src/main/java/com/jianju/di/task/PullFileTask.java
View file @
71409ae5
package
com
.
jianju
.
di
.
task
;
package
com
.
jianju
.
di
.
task
;
import
com.jianju.di.Manager.PostGISMannager
;
import
com.jianju.di.utils.FtpUtil
;
import
com.jianju.di.utils.FtpUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
/**
* @author D
*/
@Component
@Component
@Slf4j
public
class
PullFileTask
{
public
class
PullFileTask
{
/**
/**
...
@@ -25,13 +33,15 @@ public class PullFileTask {
...
@@ -25,13 +33,15 @@ public class PullFileTask {
private
String
password
;
private
String
password
;
@Value
(
"${ftp.remotepath}"
)
@Value
(
"${ftp.remotepath}"
)
private
String
remotePath
;
private
String
remotePath
;
@Value
(
"${ftp.localpath}"
)
private
String
localPath
;
/**
/**
* 数据库注入参数
* 数据库注入参数
*/
*/
@Value
(
"${postgis.host}"
)
@Value
(
"${postgis.host}"
)
private
String
dbHost
;
private
String
dbHost
;
@Value
(
"${postgis.p
ro
t}"
)
@Value
(
"${postgis.p
or
t}"
)
private
String
dbPort
;
private
String
dbPort
;
@Value
(
"${postgis.username}"
)
@Value
(
"${postgis.username}"
)
private
String
dbUserName
;
private
String
dbUserName
;
...
@@ -41,21 +51,36 @@ public class PullFileTask {
...
@@ -41,21 +51,36 @@ public class PullFileTask {
private
String
dbName
;
private
String
dbName
;
@Value
(
"${postgis.tbname}"
)
@Value
(
"${postgis.tbname}"
)
private
String
tbName
;
private
String
tbName
;
private
static
final
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
private
static
final
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"YYYYMMdd"
);
//每日0点与中午12点执行;
//@Scheduled(cron ="0 0 12,18 * * ?" )
@Scheduled
(
fixedRate
=
10000
)
@Scheduled
(
fixedRate
=
10000
)
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
);
boolean
b
=
FtpUtil
.
existFile
(
ftpConfig
,
remotePath
,
"b.html"
);
Calendar
c
=
Calendar
.
getInstance
();
if
(
b
)
c
.
setTime
(
new
Date
());
{
c
.
add
(
Calendar
.
DATE
,
-
2
);
boolean
download
=
FtpUtil
.
download
(
ftpConfig
,
remotePath
,
"b.html"
,
"E:/新建文件夹"
,
System
.
currentTimeMillis
()
+
".html"
);
String
fileName
=
"#"
+
dateFormat
.
format
(
c
.
getTime
());
log
.
info
(
"开始下载"
+
"#"
+
fileName
);
boolean
download
=
FtpUtil
.
download
(
ftpConfig
,
remotePath
,
fileName
,
localPath
,
fileName
);
if
(
download
)
if
(
download
)
{
{
log
.
info
(
"下载成功"
);
// PostGISMannager postGIS = new PostGISMannager(dbHost, dbPort,
// dbName, tbName, dbUserName, dbPassword);
// postGIS.createTableGDAS("GODAS");
// postGIS.insertGodasToPG("GODAS", );
}
}
}
else
{
log
.
info
(
"下载失败"
);
}
}
}
}
}
src/main/resources/application.yml
View file @
71409ae5
...
@@ -6,7 +6,8 @@ ftp:
...
@@ -6,7 +6,8 @@ ftp:
port
:
21
port
:
21
username
:
ncc
username
:
ncc
password
:
ncc123
password
:
ncc123
remotepath
:
/NOAA/NCEP/noaa18_olr
remotepath
:
/NOAA/NCEP/noaa18_olr/
localpath
:
C:\Users\D\Desktop\证书\
postgis
:
postgis
:
host
:
10.40.16.39
host
:
10.40.16.39
port
:
27088
port
:
27088
...
...
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