Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
windows
Project
Project
Details
Activity
Releases
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
zhanhai
windows
Commits
dae5a1a3
Commit
dae5a1a3
authored
Dec 11, 2023
by
LSL
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
浙农中际融担协议
parent
71df628e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
0 deletions
+118
-0
ContractJob.java
src/main/java/com/jqtx/windows/job/ContractJob.java
+118
-0
No files found.
src/main/java/com/jqtx/windows/job/ContractJob.java
0 → 100644
View file @
dae5a1a3
package
com
.
jqtx
.
windows
.
job
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.CharsetUtil
;
import
cn.hutool.extra.ssh.Sftp
;
import
com.jqtx.infrastructure.oss.starter.config.OssUtils
;
import
com.jqtx.windows.common.config.SftpConfig
;
import
com.jqtx.windows.component.impl.LoanComponentImpl
;
import
com.jqtx.windows.component.model.LoanModel
;
import
com.jqtx.windows.component.model.UploadPdfDetailRequest
;
import
com.jqtx.windows.component.model.UploadPdfRequest
;
import
com.xxl.job.core.context.XxlJobHelper
;
import
com.xxl.job.core.handler.annotation.XxlJob
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
@Component
@Slf4j
public
class
ContractJob
{
/**
* oss的路径
*/
private
static
final
String
ossPath
=
"ZN/contract/"
;
/**
* sftp的路径
*/
private
static
final
String
sftpPath
=
"/upload/contract/"
;
/**
* sftp文件后缀
*/
private
static
final
String
suffix
=
"jkfwxy"
;
@Autowired
private
OssUtils
ossUtils
;
@Autowired
private
LoanComponentImpl
loanComponent
;
@Autowired
private
SftpConfig
sftpConfig
;
@Value
(
"${inf.oss.privateDomain}"
)
private
String
privateDomain
;
@XxlJob
(
"redeemJob"
)
public
void
run
()
{
String
param
=
XxlJobHelper
.
getJobParam
();
Sftp
sftp
=
new
Sftp
(
sftpConfig
.
getSshHost
(),
sftpConfig
.
getSshPort
(),
sftpConfig
.
getSshUser
(),
sftpConfig
.
getSshPass
(),
CharsetUtil
.
CHARSET_UTF_8
);
try
{
String
date
=
""
;
if
(
StringUtils
.
isNotEmpty
(
param
))
{
date
=
param
;
}
else
{
Calendar
cal
=
Calendar
.
getInstance
();
//获取前面的时间用-负号
cal
.
setTime
(
new
Date
());
cal
.
add
(
Calendar
.
DAY_OF_MONTH
,
-
1
);
Date
time
=
cal
.
getTime
();
date
=
DateUtil
.
format
(
time
,
"yyyyMMdd"
);
}
String
dir
=
sftpPath
+
date
;
if
(
sftp
.
isDir
(
dir
))
{
List
<
String
>
list
=
sftp
.
lsDirs
(
dir
);
for
(
String
loanNo
:
list
)
{
uploadProtocolPdf
(
loanNo
,
sftp
,
dir
);
}
}
}
catch
(
Exception
e
)
{
log
.
info
(
"浙农同步中际融担协议错误:{}"
,
e
.
getMessage
());
}
finally
{
//关闭sftp连接
sftp
.
close
();
}
}
public
void
uploadProtocolPdf
(
String
loanNo
,
Sftp
sftp
,
String
dir
)
{
List
<
String
>
list
=
sftp
.
lsFiles
(
dir
+
"/"
+
loanNo
);
for
(
String
fileName
:
list
)
{
//只拿以 jkfwxy.pdf 结尾的文件
if
(
fileName
.
indexOf
(
suffix
)
!=
-
1
)
{
String
url
=
getUrl
(
dir
+
"/"
+
fileName
,
sftp
,
fileName
);
getUploadPdfRequest
(
url
,
loanNo
);
}
}
}
public
String
getUrl
(
String
dir
,
Sftp
sftp
,
String
fileName
)
{
sftp
.
get
(
dir
,
fileName
);
ossUtils
.
ossUpload
(
ossPath
+
fileName
,
FileUtil
.
file
(
"/"
+
fileName
));
FileUtil
.
del
(
"/"
+
fileName
);
return
privateDomain
+
ossPath
+
fileName
;
}
public
UploadPdfRequest
getUploadPdfRequest
(
String
url
,
String
loanNo
)
{
LoanModel
loanModel
=
loanComponent
.
getByLoanNo
(
loanNo
);
UploadPdfRequest
uploadPdfRequest
=
new
UploadPdfRequest
();
uploadPdfRequest
.
setLoanNo
(
loanModel
.
getLoanNo
());
uploadPdfRequest
.
setOrderNo
(
loanModel
.
getOrderNo
());
UploadPdfDetailRequest
uploadPdfDetailRequest
=
new
UploadPdfDetailRequest
();
uploadPdfDetailRequest
.
setUrl
(
url
);
ArrayList
<
UploadPdfDetailRequest
>
list
=
new
ArrayList
<>();
list
.
add
(
uploadPdfDetailRequest
);
uploadPdfRequest
.
setDetailRequestList
(
list
);
return
uploadPdfRequest
;
}
}
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