Commit 232241ed authored by 张庆's avatar 张庆

新增MQ

parent 04daa939
......@@ -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();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment