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
98d1a363
Commit
98d1a363
authored
May 15, 2024
by
LSL
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
还款对账文件
parent
16fea8d5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
278 additions
and
0 deletions
+278
-0
BackedFileModel.java
...ava/com/jqtx/windows/component/model/BackedFileModel.java
+28
-0
BackedJob.java
src/main/java/com/jqtx/windows/job/BackedJob.java
+250
-0
No files found.
src/main/java/com/jqtx/windows/component/model/BackedFileModel.java
0 → 100644
View file @
98d1a363
package
com
.
jqtx
.
windows
.
component
.
model
;
import
lombok.Data
;
@Data
public
class
BackedFileModel
{
private
String
loanReqNo
;
private
String
repayNo
;
private
String
repayMode
;
private
String
repayType
;
private
String
repayDate
;
private
String
repayTerm
;
private
String
repayAmount
;
private
String
repayPrincipal
;
private
String
repayInterest
;
private
String
repayOverdue
;
private
String
repayZhibaoFee
;
}
src/main/java/com/jqtx/windows/job/BackedJob.java
0 → 100644
View file @
98d1a363
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.*
;
import
com.jqtx.windows.component.enums.LoanStatusEnum
;
import
com.jqtx.windows.component.impl.BackedBurdenComponentImpl
;
import
com.jqtx.windows.component.model.BackedDetailModel
;
import
com.jqtx.windows.component.model.BackedFileModel
;
import
com.jqtx.windows.component.model.LoanPlanModel
;
import
com.jqtx.windows.component.model.RepayModel
;
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.stereotype.Component
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
@Component
@Slf4j
public
class
BackedJob
{
@Autowired
private
OssUtils
ossUtils
;
@Autowired
private
LoanPlanComponent
loanPlanComponent
;
@Autowired
private
BackedBurdenComponentImpl
backedBurdenComponent
;
@Autowired
private
LoanComponent
loanComponent
;
@Autowired
private
LoanRepayComponent
loanRepayComponent
;
@Autowired
private
BackedDetailComponent
backedDetailComponent
;
@Autowired
private
OverduedComponent
overduedComponent
;
@Autowired
private
SftpConfig
sftpConfig
;
@XxlJob
(
"backedJob"
)
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"
);
}
if
(
sftp
.
isDir
(
"/download/repayment_check/"
+
date
))
{
sftp
.
cd
(
"/download/repayment_check/"
+
date
);
sftp
.
get
(
"repayment_check_"
+
date
+
".txt"
,
"/repayment_check_sftp.txt"
);
ossUtils
.
ossUpload
(
"ZN/repayment_check_tow/"
+
"repayment_check_"
+
date
+
".txt"
,
FileUtil
.
file
(
"/repayment_check_sftp.txt"
));
String
stringObject
=
getStringObject
(
"ZN/repayment_check_tow/"
+
"repayment_check_"
+
date
+
".txt"
);
log
.
info
(
"oss还款数据:{}"
,
stringObject
);
//存储并去平账
List
<
BackedFileModel
>
getlist
=
getlist
(
stringObject
);
for
(
BackedFileModel
model
:
getlist
)
{
backed
(
model
);
}
FileUtil
.
del
(
"/repayment_check_sftp.txt"
);
}
else
{
log
.
info
(
"浙农还款文件不存在:{}"
,
date
);
}
}
catch
(
Exception
e
)
{
log
.
info
(
"浙农还款错误:{}"
,
e
.
getMessage
());
}
finally
{
//关闭sftp连接
sftp
.
close
();
}
}
public
String
getStringObject
(
String
uri
)
{
byte
[]
bytes
=
new
byte
[
0
];
try
{
bytes
=
ossUtils
.
ossDownLoad
(
uri
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
new
String
(
bytes
);
}
/**
* 组装还融担的全部model
*
* @param jsonResult
* @return
*/
private
List
<
BackedFileModel
>
getlist
(
String
jsonResult
)
{
ArrayList
<
BackedFileModel
>
list
=
new
ArrayList
<>();
String
[]
split
=
jsonResult
.
split
(
"\n"
);
if
(
split
==
null
)
{
return
list
;
}
for
(
String
modelstr
:
split
)
{
String
[]
split1
=
modelstr
.
split
(
"\\|"
);
BackedFileModel
model
=
new
BackedFileModel
();
model
.
setLoanReqNo
(
split1
[
0
]);
model
.
setRepayNo
(
split1
[
1
]);
model
.
setRepayMode
(
split1
[
2
]);
model
.
setRepayType
(
split1
[
3
]);
model
.
setRepayDate
(
split1
[
4
]);
model
.
setRepayTerm
(
split1
[
5
]);
model
.
setRepayAmount
(
split1
[
6
]);
model
.
setRepayPrincipal
(
split1
[
7
]);
model
.
setRepayInterest
(
split1
[
8
]);
model
.
setRepayOverdue
(
split1
[
9
]);
model
.
setRepayZhibaoFee
(
split1
[
10
]);
list
.
add
(
model
);
}
return
list
;
}
/**
* 获取planNo
*
* @param loanNo
* @param planIndex
* @return
*/
private
String
getPlanNo
(
String
loanNo
,
String
planIndex
)
{
LoanPlanModel
planModel
=
loanPlanComponent
.
getPlanNoByLoan
(
loanNo
,
planIndex
);
return
planModel
.
getPlanNo
();
}
/**
* 还融担
*
* @param model
*/
private
void
backed
(
BackedFileModel
model
)
{
RepayModel
repayModell
=
loanRepayComponent
.
getByBackedNo
(
model
.
getRepayNo
());
if
(
repayModell
==
null
||
StringUtils
.
isEmpty
(
repayModell
.
getBackedNo
()))
{
//生成融担还款编号
String
repayNo
=
model
.
getRepayNo
();
//生成 windows_repay 信息
RepayModel
repayModel
=
creditRepay
(
model
,
repayNo
);
loanRepayComponent
.
insert
(
repayModel
);
//生成 windows_backed_detail 信息
BackedDetailModel
backedDetailModel
=
creditBackedDetailModel
(
model
,
repayNo
);
backedDetailComponent
.
insert
(
backedDetailModel
);
/*//修改 windows_plan backAmt 信息 还款状态*/
upWindowsPlan
(
model
);
}
else
{
log
.
info
(
"浙农还款已存在:{}"
,
model
.
getRepayNo
());
}
}
/**
* 生成 windows_repay
*
* @param model
* @return
*/
public
RepayModel
creditRepay
(
BackedFileModel
model
,
String
refundNo
)
{
RepayModel
windowsRepay
=
new
RepayModel
();
windowsRepay
.
setLoanNo
(
model
.
getLoanReqNo
());
windowsRepay
.
setBackedNo
(
refundNo
);
windowsRepay
.
setBackedAmt
(
new
BigDecimal
(
model
.
getRepayAmount
()));
windowsRepay
.
setIsSettle
(
0
);
windowsRepay
.
setBackedType
(
"PROTOCOL"
);
windowsRepay
.
setRepayResult
(
"SUCCESS"
);
windowsRepay
.
setRepayStatus
(
"FINISHED"
);
windowsRepay
.
setCreator
(
"浙农"
);
windowsRepay
.
setGmtCreated
(
gettime
(
model
.
getRepayDate
()));
windowsRepay
.
setGmtModified
(
gettime
(
model
.
getRepayDate
()));
return
windowsRepay
;
}
private
LocalDateTime
gettime
(
String
time
)
{
String
s
=
time
+
"000001"
;
DateTimeFormatter
dateTimeFormatter
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmss"
);
LocalDateTime
parse
=
LocalDateTime
.
parse
(
s
,
dateTimeFormatter
);
return
parse
;
}
/**
* @param model
* @param refundNo
* @return
*/
public
BackedDetailModel
creditBackedDetailModel
(
BackedFileModel
model
,
String
refundNo
)
{
//LocalDate.now()
BackedDetailModel
debtBackedModel
=
new
BackedDetailModel
();
debtBackedModel
.
setBackedNo
(
refundNo
);
debtBackedModel
.
setPlanNo
(
getPlanNo
(
model
.
getLoanReqNo
(),
model
.
getRepayTerm
()));
debtBackedModel
.
setBackedDate
(
LocalDate
.
now
().
minusDays
(
1
));
debtBackedModel
.
setBackedAmt
(
new
BigDecimal
(
model
.
getRepayAmount
()));
debtBackedModel
.
setBackedBen
(
new
BigDecimal
(
model
.
getRepayPrincipal
()));
debtBackedModel
.
setBackedXi
(
new
BigDecimal
(
model
.
getRepayInterest
()));
debtBackedModel
.
setBackedFu
(
BigDecimal
.
ZERO
);
debtBackedModel
.
setBackedFa
(
new
BigDecimal
(
model
.
getRepayOverdue
()));
debtBackedModel
.
setBackedBurden
(
BigDecimal
.
ZERO
);
debtBackedModel
.
setBackedSpeaccount
(
BigDecimal
.
ZERO
);
debtBackedModel
.
setBackedBreak
(
BigDecimal
.
ZERO
);
debtBackedModel
.
setBackedType
(
"PROTOCOL"
);
debtBackedModel
.
setGmtCreated
(
gettime
(
model
.
getRepayDate
()));
debtBackedModel
.
setGmtModified
(
gettime
(
model
.
getRepayDate
()));
return
debtBackedModel
;
}
/**
* @param model
*/
public
void
upWindowsPlan
(
BackedFileModel
model
)
{
LoanPlanModel
planModel
=
loanPlanComponent
.
getPlanNoByLoan
(
model
.
getLoanReqNo
(),
model
.
getRepayTerm
());
planModel
.
setBackedBen
(
new
BigDecimal
(
model
.
getRepayPrincipal
()));
planModel
.
setBackedXi
(
new
BigDecimal
(
model
.
getRepayInterest
()));
planModel
.
setBackedFa
(
new
BigDecimal
(
model
.
getRepayOverdue
()));
BigDecimal
planAmt
=
planModel
.
getPlanBen
().
add
(
planModel
.
getPlanXi
()).
add
(
planModel
.
getPlanFu
()).
add
(
planModel
.
getPlanFa
()).
add
(
planModel
.
getPlanBurden
());
BigDecimal
backedAmt
=
planModel
.
getBackedBen
().
add
(
planModel
.
getBackedXi
()).
add
(
planModel
.
getBackedFu
()).
add
(
planModel
.
getBackedFa
()).
add
(
planModel
.
getBackedBurden
());
if
(!(
planAmt
.
compareTo
(
backedAmt
)
>
0
))
{
planModel
.
setStatus
(
LoanStatusEnum
.
SETTLED
.
getCode
());
overduedComponent
.
updateOverduedByPlanNo
(
planModel
.
getPlanNo
(),
model
.
getRepayDate
());
}
loanPlanComponent
.
updateByLoanPlanModel
(
planModel
);
}
}
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