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
232241ed
Commit
232241ed
authored
Oct 27, 2023
by
张庆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增MQ
parent
04daa939
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
45 deletions
+55
-45
SyncLoanCommand.java
src/main/java/com/jqtx/windows/command/SyncLoanCommand.java
+55
-45
No files found.
src/main/java/com/jqtx/windows/command/SyncLoanCommand.java
View file @
232241ed
...
...
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
import
cn.hutool.core.lang.Assert
;
import
com.alibaba.fastjson.JSON
;
import
com.jqtx.windows.common.converter.ProtocolConverter
;
import
com.jqtx.windows.common.exception.BizException
;
import
com.jqtx.windows.common.factory.AbstractCommand
;
import
com.jqtx.windows.common.factory.RuntimeContextHolder
;
import
com.jqtx.windows.common.utils.ValidateUtil
;
...
...
@@ -20,6 +21,7 @@ import com.jqtx.windows.component.seq.ISeqNoGenerateComponent;
import
com.jqtx.windows.infrastructure.feign.IProtocalFeignService
;
import
com.jqtx.windows.web.request.SyncLoanRequest
;
import
com.jqtx.windows.web.response.JsonResult
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -31,6 +33,7 @@ import java.util.stream.Collectors;
@Service
@Slf4j
public
class
SyncLoanCommand
extends
AbstractCommand
{
@Autowired
...
...
@@ -43,53 +46,60 @@ public class SyncLoanCommand extends AbstractCommand {
private
IProtocalFeignService
iProtocalFeignService
;
@Autowired
private
ProtocolConverter
protocolConverter
;
@Override
public
JsonResult
execute
()
{
String
request
=
RuntimeContextHolder
.
currentRuntimeContext
().
getRequestBody
();
SyncLoanRequest
syncLoanRequest
=
JSON
.
parseObject
(
request
,
SyncLoanRequest
.
class
);
//校验
ValidateUtil
.
valid
(
syncLoanRequest
);
//修改loan
LoanModel
loanModel
=
loanComponent
.
getByLoanNo
(
syncLoanRequest
.
getLoanNo
());
Assert
.
isFalse
(
loanModel
==
null
,
"借款不存在"
);
Assert
.
isFalse
(!
loanModel
.
getLoanStatus
().
equals
(
LoanStatusEnum
.
AUDITED
.
name
()),
"订单状态错误"
);
//新增plan
BigDecimal
loanAmt
=
syncLoanRequest
.
getPlanList
().
stream
().
map
(
SyncLoanRequest
.
LoanPlan
::
getPlanAmt
).
map
(
BigDecimal:
:
new
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
BigDecimal
raiseAmt
=
syncLoanRequest
.
getPlanList
().
stream
().
map
(
SyncLoanRequest
.
LoanPlan
::
getPlanBen
).
map
(
BigDecimal:
:
new
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
BigDecimal
rateAmt
=
syncLoanRequest
.
getPlanList
().
stream
().
map
(
SyncLoanRequest
.
LoanPlan
::
getPlanXi
).
map
(
BigDecimal:
:
new
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
BigDecimal
burdenAmt
=
syncLoanRequest
.
getPlanList
().
stream
().
map
(
SyncLoanRequest
.
LoanPlan
::
getPlanBurden
).
map
(
BigDecimal:
:
new
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
loanModel
.
setLoanAmt
(
loanAmt
);
loanModel
.
setRaiseAmt
(
raiseAmt
);
loanModel
.
setServiceAmt
(
BigDecimal
.
ZERO
);
loanModel
.
setRateAmt
(
rateAmt
);
loanModel
.
setBurdenAmt
(
burdenAmt
);
loanModel
.
setLoanUsage
(
syncLoanRequest
.
getLoanUsage
());
DateTimeFormatter
df
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
LocalDateTime
dateTime
=
LocalDateTime
.
parse
(
syncLoanRequest
.
getRaiseDate
(),
df
);
loanModel
.
setRaiseDate
(
dateTime
);
loanModel
.
setLoanStatus
(
LoanStatusEnum
.
BACKING
.
name
());
loanModel
.
setBankAccount
(
syncLoanRequest
.
getBankAccount
());
loanModel
.
setLoanTerm
(
syncLoanRequest
.
getLoanTerm
());
loanModel
.
setGmtModified
(
LocalDateTime
.
now
());
int
i
=
loanComponent
.
updateByLoanNo
(
loanModel
);
//新增plan
List
<
SyncLoanRequest
.
LoanPlan
>
planList
=
syncLoanRequest
.
getPlanList
();
planList
.
forEach
(
loanPlan
->
{
String
planNo
=
iSeqNoGenerateComponent
.
genCommonSeqNo
(
BizSeqNoConfig
.
PLAN_NO_KEY
,
BizSeqNoConfig
.
PLAN_NO_PREFIX
);
LoanPlanModel
loanPlanModel
=
BeanUtil
.
toBean
(
loanPlan
,
LoanPlanModel
.
class
);
loanPlanModel
.
setPlanNo
(
planNo
);
loanPlanModel
.
setLoanNo
(
loanModel
.
getLoanNo
());
loanPlanModel
.
setStatus
(
"BACKING"
);
//新增
loanPlanComponent
.
insert
(
loanPlanModel
);
});
//ok
UploadPdfRequest
uploadPdfRequest
=
new
UploadPdfRequest
();
uploadPdfRequest
.
setLoanNo
(
syncLoanRequest
.
getLoanNo
());
uploadPdfRequest
.
setOrderNo
(
syncLoanRequest
.
getOrderNo
());
List
<
UploadPdfDetailRequest
>
detailRequestList
=
syncLoanRequest
.
getProtocolList
().
stream
().
map
(
protocolConverter:
:
toModel
).
collect
(
Collectors
.
toList
());
uploadPdfRequest
.
setDetailRequestList
(
detailRequestList
);
iProtocalFeignService
.
uploadProtocolPdf
(
uploadPdfRequest
);
try
{
String
request
=
RuntimeContextHolder
.
currentRuntimeContext
().
getRequestBody
();
SyncLoanRequest
syncLoanRequest
=
JSON
.
parseObject
(
request
,
SyncLoanRequest
.
class
);
//校验
ValidateUtil
.
valid
(
syncLoanRequest
);
//修改loan
LoanModel
loanModel
=
loanComponent
.
getByLoanNo
(
syncLoanRequest
.
getLoanNo
());
Assert
.
isFalse
(
loanModel
==
null
,
"借款不存在"
);
Assert
.
isFalse
(!
loanModel
.
getLoanStatus
().
equals
(
LoanStatusEnum
.
AUDITED
.
name
()),
"订单状态错误"
);
//新增plan
BigDecimal
loanAmt
=
syncLoanRequest
.
getPlanList
().
stream
().
map
(
SyncLoanRequest
.
LoanPlan
::
getPlanAmt
).
map
(
BigDecimal:
:
new
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
BigDecimal
raiseAmt
=
syncLoanRequest
.
getPlanList
().
stream
().
map
(
SyncLoanRequest
.
LoanPlan
::
getPlanBen
).
map
(
BigDecimal:
:
new
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
BigDecimal
rateAmt
=
syncLoanRequest
.
getPlanList
().
stream
().
map
(
SyncLoanRequest
.
LoanPlan
::
getPlanXi
).
map
(
BigDecimal:
:
new
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
BigDecimal
burdenAmt
=
syncLoanRequest
.
getPlanList
().
stream
().
map
(
SyncLoanRequest
.
LoanPlan
::
getPlanBurden
).
map
(
BigDecimal:
:
new
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
loanModel
.
setLoanAmt
(
loanAmt
);
loanModel
.
setRaiseAmt
(
raiseAmt
);
loanModel
.
setServiceAmt
(
BigDecimal
.
ZERO
);
loanModel
.
setRateAmt
(
rateAmt
);
loanModel
.
setBurdenAmt
(
burdenAmt
);
loanModel
.
setLoanUsage
(
syncLoanRequest
.
getLoanUsage
());
DateTimeFormatter
df
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
LocalDateTime
dateTime
=
LocalDateTime
.
parse
(
syncLoanRequest
.
getRaiseDate
(),
df
);
loanModel
.
setRaiseDate
(
dateTime
);
loanModel
.
setLoanStatus
(
LoanStatusEnum
.
BACKING
.
name
());
loanModel
.
setBankAccount
(
syncLoanRequest
.
getBankAccount
());
loanModel
.
setLoanTerm
(
syncLoanRequest
.
getLoanTerm
());
loanModel
.
setGmtModified
(
LocalDateTime
.
now
());
int
i
=
loanComponent
.
updateByLoanNo
(
loanModel
);
//新增plan
List
<
SyncLoanRequest
.
LoanPlan
>
planList
=
syncLoanRequest
.
getPlanList
();
planList
.
forEach
(
loanPlan
->
{
String
planNo
=
iSeqNoGenerateComponent
.
genCommonSeqNo
(
BizSeqNoConfig
.
PLAN_NO_KEY
,
BizSeqNoConfig
.
PLAN_NO_PREFIX
);
LoanPlanModel
loanPlanModel
=
BeanUtil
.
toBean
(
loanPlan
,
LoanPlanModel
.
class
);
loanPlanModel
.
setPlanNo
(
planNo
);
loanPlanModel
.
setLoanNo
(
loanModel
.
getLoanNo
());
loanPlanModel
.
setStatus
(
"BACKING"
);
//新增
loanPlanComponent
.
insert
(
loanPlanModel
);
});
//ok
UploadPdfRequest
uploadPdfRequest
=
new
UploadPdfRequest
();
uploadPdfRequest
.
setLoanNo
(
syncLoanRequest
.
getLoanNo
());
uploadPdfRequest
.
setOrderNo
(
syncLoanRequest
.
getOrderNo
());
List
<
UploadPdfDetailRequest
>
detailRequestList
=
syncLoanRequest
.
getProtocolList
().
stream
().
map
(
protocolConverter:
:
toModel
).
collect
(
Collectors
.
toList
());
uploadPdfRequest
.
setDetailRequestList
(
detailRequestList
);
iProtocalFeignService
.
uploadProtocolPdf
(
uploadPdfRequest
);
}
catch
(
BizException
e
)
{
log
.
error
(
"同步放款错误:{}"
,
e
.
getMessage
(),
e
);
throw
new
BizException
(
"同步放款错误"
);
}
return
JsonResult
.
success
();
}
...
...
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