Commit 3753a2f6 authored by LSL's avatar LSL

浙农定时

parent 22213142
......@@ -7,7 +7,7 @@ CREATE TABLE `windows_redeem` (
`raise_time` varchar(50) DEFAULT NULL COMMENT '格式为yyddmm',
`backed_time` varchar(50) DEFAULT NULL COMMENT '格式为yyddmm',
`hold_day` varchar(50) DEFAULT NULL COMMENT '借款持有天数',
`redeem_ben` varchar(50) DEFAULT NULL COMMENT '7 应代偿本金保留两位有效数字(单位:元)',
`redeem_ben` varchar(50) DEFAULT NULL COMMENT '应代偿本金保留两位有效数字(单位:元)',
`redeem_xi` varchar(50) DEFAULT NULL COMMENT '应代偿利息',
`redeem_fa` varchar(50) DEFAULT NULL COMMENT '应代偿罚息',
`redeem_amount` varchar(50) DEFAULT NULL COMMENT '应代偿合计',
......
......@@ -101,21 +101,21 @@ public class BackedCommand extends AbstractCommand {
}
planList = loanPlanComponent.getByLoan(loanNo);
LoanModel LoanModel = loanComponent.getByLoanNo(loanNo);
LoanModel loanModel = loanComponent.getByLoanNo(loanNo);
List<LoanPlanModel> overduedList = planList.stream().filter(i -> i.getStatus() == DebtPlanStatusEnum.OVERDUED.getCode()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(overduedList)) {
LoanModel.setLoanStatus(DebtInfoStatusEnum.OVERDUED.getCode());
loanModel.setLoanStatus(DebtInfoStatusEnum.OVERDUED.getCode());
} else {
//存在还款中计划改为还款中
List<LoanPlanModel> backingList = planList.stream().filter(i -> i.getStatus() == DebtPlanStatusEnum.BACKING.getCode()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(backingList)) {
LoanModel.setLoanStatus(DebtInfoStatusEnum.SETTLED.getCode());
loanModel.setLoanStatus(DebtInfoStatusEnum.SETTLED.getCode());
}
}
//修改 windows_loan 还款状态
loanComponent.updateByLoanNo(LoanModel);
return LoanModel.getLoanStatus();
loanComponent.updateByLoanNo(loanModel);
return loanModel.getLoanStatus();
}
......
......@@ -6,22 +6,26 @@ 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.snow.SnowSequenceHelper;
import com.jqtx.windows.component.LoanComponent;
import com.jqtx.windows.component.LoanPlanComponent;
import com.jqtx.windows.component.enums.LoanStatusEnum;
import com.jqtx.windows.component.impl.BackedBurdenComponentImpl;
import com.jqtx.windows.component.impl.LoanPlanComponentImpl;
import com.jqtx.windows.component.model.BurdenModel;
import com.jqtx.windows.component.model.LoanPlanModel;
import com.jqtx.windows.component.model.RepayModel;
import com.jqtx.windows.web.request.BackedRequest;
import com.jqtx.windows.component.model.*;
import com.jqtx.windows.infrastructure.feign.enums.DebtInfoStatusEnum;
import com.jqtx.windows.infrastructure.feign.enums.DebtPlanStatusEnum;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Component
@Slf4j
......@@ -30,19 +34,22 @@ public class BackedBurdenJob {
private OssUtils ossUtils;
@Autowired
private LoanPlanComponentImpl loanPlanComponent;
private LoanPlanComponent loanPlanComponent;
@Autowired
private BackedBurdenComponentImpl backedBurdenComponent;
@Autowired
private LoanComponent loanComponent;
@XxlJob("backedBurdenJob")
public void run() {
Sftp sftp = new Sftp("115.238.89.106", 9901, "xiaohua_fr", "R7MADMx1lwMN5k4v", CharsetUtil.CHARSET_UTF_8);
String date = DateUtil.format(new Date(), "yyyyMMdd");
sftp.cd("/download/assurance/"+date);
sftp.get("assurance_"+date+".txt","/assurance_sftp.txt");
ossUtils.ossUpload("ZN/assurance_/"+"assurance_"+date+".txt", FileUtil.file("/assurance_sftp.txt"));
sftp.cd("/download/assurance/" + date);
sftp.get("assurance_" + date + ".txt", "/assurance_sftp.txt");
ossUtils.ossUpload("ZN/assurance_/" + "assurance_" + date + ".txt", FileUtil.file("/assurance_sftp.txt"));
FileUtil.del("/sftp.txt");
String stringObject = ossUtils.getStringObject("ZN/assurance_/" + "assurance_" + date + ".txt");
log.info("date:{}", stringObject);
......@@ -57,6 +64,7 @@ public class BackedBurdenJob {
/**
* 组装还融担的全部model
*
* @param jsonResult
* @return
*/
......@@ -74,7 +82,7 @@ public class BackedBurdenJob {
model.setRepayDate(split1[2]);
model.setPlanIndex(split1[3]);
model.setPepayBurden(split1[4]);
model.setPlanNo(getPlanNo(split1[0],split1[3]));
model.setPlanNo(getPlanNo(split1[0], split1[3]));
//model.setMemo(split1[0]);
list.add(model);
}
......@@ -83,39 +91,44 @@ public class BackedBurdenJob {
/**
* 获取planNo
*
* @param loanNo
* @param planIndex
* @return
*/
private String getPlanNo(String loanNo,String planIndex){
private String getPlanNo(String loanNo, String planIndex) {
LoanPlanModel planModel = loanPlanComponent.getPlanNoByLoan(loanNo, planIndex);
return planModel.getPlanNo();
}
/**
* 还融担
*
* @param model
*/
private void backedBurden(BurdenModel model){
private void backedBurden(BurdenModel model) {
//生成融担还款编号
String refundNo = SnowSequenceHelper.nextSequence(SnowSequenceHelper.REFUND_NO);
//生成 windows_repay 信息
RepayModel repayModel = creditRepay(model);
RepayModel repayModel = creditRepay(model, refundNo);
//生成 windows_backed_detail 信息
//修改 windows_plan backAmt 信息
//修改 windows_plan 还款状态
BackedDetailModel backedDetailModel = creditBackedDetailModel(model, refundNo);
//修改 windows_plan backAmt 信息 还款状态
upWindowsPlan(model);
//修改 windows_loan 还款状态
LoanModel loanModel = loanComponent.getByLoanNo(model.getLoanNo());
upWindowsLoan(loanModel);
}
/**
* 生成 windows_repay
*
* @param model
* @return
*/
public RepayModel creditRepay(BurdenModel model) {
public RepayModel creditRepay(BurdenModel model, String refundNo) {
RepayModel windowsRepay = new RepayModel();
windowsRepay.setLoanNo(model.getLoanNo());
String refundNo = SnowSequenceHelper.nextSequence(SnowSequenceHelper.REFUND_NO);
windowsRepay.setBackedNo(refundNo);
windowsRepay.setBackedAmt(new BigDecimal(model.getPepayBurden()));
windowsRepay.setIsSettle(0);
......@@ -128,4 +141,63 @@ public class BackedBurdenJob {
return windowsRepay;
}
/**
* 生成 windows_backed_detail
*
* @param model
* @return
*/
public BackedDetailModel creditBackedDetailModel(BurdenModel model, String refundNo) {
BackedDetailModel debtBackedModel = new BackedDetailModel();
debtBackedModel.setBackedNo(refundNo);
debtBackedModel.setPlanNo(model.getPlanNo());
debtBackedModel.setBackedDate(LocalDate.now());
debtBackedModel.setBackedAmt(new BigDecimal(model.getPepayBurden()));
debtBackedModel.setBackedBen(BigDecimal.ZERO);
debtBackedModel.setBackedXi(BigDecimal.ZERO);
debtBackedModel.setBackedFu(BigDecimal.ZERO);
debtBackedModel.setBackedFa(BigDecimal.ZERO);
debtBackedModel.setBackedBurden(new BigDecimal(model.getPepayBurden()));
debtBackedModel.setBackedSpeaccount(BigDecimal.ZERO);
debtBackedModel.setBackedBreak(BigDecimal.ZERO);
debtBackedModel.setBackedType("BURDEN");
debtBackedModel.setGmtCreated(LocalDateTime.now());
debtBackedModel.setGmtModified(LocalDateTime.now());
return debtBackedModel;
}
/**
* 生成 windows_backed_detail
*
* @param model
* @return
*/
public void upWindowsPlan(BurdenModel model) {
LoanPlanModel planModel = loanPlanComponent.getPlanNoByLoan(model.getLoanNo(), model.getPlanIndex());
planModel.setBackedBurden(new BigDecimal(model.getPepayBurden()));
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());
}
loanPlanComponent.updateByLoanPlanModel(planModel);
}
private void upWindowsLoan(LoanModel loanModel) {
List<LoanPlanModel> planList = loanPlanComponent.getByLoan(loanModel.getLoanNo());
List<LoanPlanModel> overduedList = planList.stream().filter(i -> i.getStatus() == DebtPlanStatusEnum.OVERDUED.getCode()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(overduedList)) {
loanModel.setLoanStatus(DebtInfoStatusEnum.OVERDUED.getCode());
} else {
//存在还款中计划改为还款中
List<LoanPlanModel> backingList = planList.stream().filter(i -> i.getStatus() == DebtPlanStatusEnum.BACKING.getCode()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(backingList)) {
loanModel.setLoanStatus(DebtInfoStatusEnum.SETTLED.getCode());
}
}
//修改 windows_loan 还款状态
loanComponent.updateByLoanNo(loanModel);
}
}
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