|
|
@ -42,6 +42,10 @@ import com.yxt.anrui.buscenter.api.bussalesorderborrower.BusSalesOrderBorrowerFe |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicle; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicleFeign; |
|
|
|
import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusVinStateSetQuery; |
|
|
|
import com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectedReceivablesDetailed; |
|
|
|
import com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectedReceivablesDetailedFeign; |
|
|
|
import com.yxt.anrui.fin.api.finuncollectedreceivablesdetailedjr.FinUncollectedReceivablesDetailedJR; |
|
|
|
import com.yxt.anrui.fin.api.finuncollectedreceivablesdetailedjr.FinUncollectedReceivablesDetailedJRFeign; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.FinKingDeeFeign; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.bdcustomer.BdCustomer; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.voucher.Voucher; |
|
|
@ -61,6 +65,7 @@ import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.PrivilegeQuery; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanbepadsincereveh.LoanBePadsincereVehDetailsVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loancaseappealapply.LoanCaseAppealApply; |
|
|
|
import com.yxt.anrui.riskcenter.api.loancaseappealapply.flowable.LoanCaseAppealApplyNodeVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loancaseappealapply.flowable.SubmitLoanCaseAppealApplyDto; |
|
|
@ -80,9 +85,14 @@ import com.yxt.anrui.riskcenter.api.loancaseprogresstrial.LoanCaseProgressTrial; |
|
|
|
import com.yxt.anrui.riskcenter.api.loancaseprogressveh.LoanCaseProgressVeh; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanfile.LoanFile; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanfile.LoanFileEnum; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymenthistory.LoanRepaymentHistory; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepaymentplandetails.LoanRepaymentPlanDetails; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepurchaseapply.LoanRepurchaseApply; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrepurchasecost.LoanRepurchaseCost; |
|
|
|
import com.yxt.anrui.riskcenter.api.loanrestorereportapply.AlrepaidAndArrVo; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansecondarysalesnotapply.LoanSecondarySalesNotApply; |
|
|
|
import com.yxt.anrui.riskcenter.api.loansecondarysalesnotveh.LoanSecondarySalesNotVehDetailsVo; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanbepadsincereveh.LoanBePadsincereVehService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loancasecloseveh.LoanCaseCloseVehService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loancaseexecuteveh.LoanCaseExecuteVehService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loancaseprogress.LoanCaseProgressService; |
|
|
@ -91,6 +101,7 @@ import com.yxt.anrui.riskcenter.biz.loancaseprogressexecutemeasure.LoanCaseProgr |
|
|
|
import com.yxt.anrui.riskcenter.biz.loancaseprogresstrial.LoanCaseProgressTrialService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loancaseprogressveh.LoanCaseProgressVehService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanfile.LoanFileService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanrepaymenthistory.LoanRepaymentHistoryService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanrepaymentplandetails.LoanRepaymentPlanDetailsService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanrepurchaseapply.LoanRepurchaseApplyService; |
|
|
|
import com.yxt.anrui.riskcenter.biz.loanrepurchasecost.LoanRepurchaseCostService; |
|
|
@ -115,19 +126,6 @@ import java.util.*; |
|
|
|
import java.util.concurrent.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* Project: anrui-riskcenter(案件结案申请) <br/> |
|
|
|
* File: LoanCaseCloseApplyService.java <br/> |
|
|
|
* Class: com.yxt.anrui.riskcenter.biz.loancasecloseapply.LoanCaseCloseApplyService <br/> |
|
|
|
* Description: 案件结案申请 业务逻辑. <br/> |
|
|
|
* Copyright: Copyright (c) 2011 <br/> |
|
|
|
* Company: https://gitee.com/liuzp315 <br/>
|
|
|
|
* Makedate: 2024-02-08 11:07:38 <br/> |
|
|
|
* |
|
|
|
* @author liupopo |
|
|
|
* @version 1.0 |
|
|
|
* @since 1.0 |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class LoanCaseCloseApplyService extends MybatisBaseService<LoanCaseCloseApplyMapper, LoanCaseCloseApply> { |
|
|
|
|
|
|
@ -161,7 +159,6 @@ public class LoanCaseCloseApplyService extends MybatisBaseService<LoanCaseCloseA |
|
|
|
private FlowTaskFeign flowTaskFeign; |
|
|
|
@Autowired |
|
|
|
private FlowFeign flowFeign; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private BusSalesOrderVehicleFeign busSalesOrderVehicleFeign; |
|
|
|
@Autowired |
|
|
@ -180,6 +177,14 @@ public class LoanCaseCloseApplyService extends MybatisBaseService<LoanCaseCloseA |
|
|
|
private LoanRepurchaseApplyService loanRepurchaseApplyService; |
|
|
|
@Autowired |
|
|
|
private LoanRepurchaseCostService loanRepurchaseCostService; |
|
|
|
@Autowired |
|
|
|
private LoanBePadsincereVehService loanBePadsincereVehService; |
|
|
|
@Autowired |
|
|
|
private FinUncollectedReceivablesDetailedJRFeign finUncollectedReceivablesDetailedJRFeign; |
|
|
|
@Autowired |
|
|
|
private FinSelectedReceivablesDetailedFeign finSelectedReceivablesDetailedFeign; |
|
|
|
@Autowired |
|
|
|
private LoanRepaymentHistoryService loanRepaymentHistoryService; |
|
|
|
|
|
|
|
public PagerVo<LoanCaseCloseApplyVo> listPageVo(PagerQuery<LoanCaseCloseApplyQuery> pq) { |
|
|
|
LoanCaseCloseApplyQuery query = pq.getParams(); |
|
|
@ -509,6 +514,8 @@ public class LoanCaseCloseApplyService extends MybatisBaseService<LoanCaseCloseA |
|
|
|
UpdateFlowFieldVo ufVo = resultBean.getData(); |
|
|
|
updateFlowFiled(BeanUtil.beanToMap(resultBean.getData())); |
|
|
|
if ("Event_end".equals(resultBean.getData().getTaskDefKey())) { |
|
|
|
//认损应收
|
|
|
|
pushRiskToFin1(businessSid); |
|
|
|
try { |
|
|
|
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() |
|
|
|
.setNameFormat("demo-pool-%d").build(); |
|
|
@ -572,6 +579,180 @@ public class LoanCaseCloseApplyService extends MybatisBaseService<LoanCaseCloseA |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void pushRiskToFin1(String businessSid) { |
|
|
|
LoanCaseCloseApply loanCaseCloseApply = fetchBySid(businessSid); |
|
|
|
SysOrganizationVo sysOrganizationVo = sysOrganizationFeign.fetchBySid(loanCaseCloseApply.getDeptSid()).getData(); |
|
|
|
//结案车辆列表
|
|
|
|
List<LoanCaseCloseVehDetailsVo> loanCaseCloseVehDetailsVos = loanCaseCloseVehService.selByMainSid(businessSid); |
|
|
|
for (LoanCaseCloseVehDetailsVo loanCaseCloseVehDetailsVo : loanCaseCloseVehDetailsVos) { |
|
|
|
//查询车辆还款计划明细
|
|
|
|
List<LoanRepaymentPlanDetails> loanRepaymentPlanDetails = loanRepaymentPlanDetailsService.selectByBusVinSid(loanCaseCloseVehDetailsVo.getBusVinSid()); |
|
|
|
//查询车辆是否有垫款金额
|
|
|
|
List<LoanBePadsincereVehDetailsVo> loanBePadsincereVehDetailsVos = loanBePadsincereVehService.selByBusVinSid(loanCaseCloseVehDetailsVo.getBusVinSid()); |
|
|
|
//获取明细sid集合
|
|
|
|
List<String> jhmxSids = loanRepaymentPlanDetails.stream().map(c -> c.getSid()). |
|
|
|
collect(Collectors.toList()); |
|
|
|
//查询金融应收所有应收款
|
|
|
|
List<FinUncollectedReceivablesDetailedJR> data = finUncollectedReceivablesDetailedJRFeign.selByBusSid(jhmxSids).getData(); |
|
|
|
if (!data.isEmpty()) { |
|
|
|
for (FinUncollectedReceivablesDetailedJR datum : data) { |
|
|
|
List<FinSelectedReceivablesDetailed> finSelectedReceivablesDetaileds = finSelectedReceivablesDetailedFeign.fetchByReceivablesSid(datum.getSid()).getData(); |
|
|
|
if (finSelectedReceivablesDetaileds.isEmpty()) { |
|
|
|
List<FinSelectedReceivablesDetailed> selectList = new ArrayList<>(); |
|
|
|
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed(); |
|
|
|
fin.setCreateBySid(loanCaseCloseApply.getCreateBySid()); |
|
|
|
fin.setRemarks("认损"); |
|
|
|
fin.setVIN(loanCaseCloseVehDetailsVo.getVinNo()); |
|
|
|
fin.setUseOrgSid(loanCaseCloseApply.getUseOrgSid()); |
|
|
|
fin.setReceivablesName(datum.getPayCostTitleValue()); |
|
|
|
fin.setSubscriptionMoney(datum.getReveivableMoney()); |
|
|
|
fin.setSubscriptionDate(DateUtil.today()); |
|
|
|
fin.setAuditState(3); |
|
|
|
fin.setAuditDate(DateUtil.today()); |
|
|
|
fin.setReceivablesSid(datum.getSid()); |
|
|
|
fin.setKxState("01"); |
|
|
|
fin.setPurchaseSystemSid(""); |
|
|
|
fin.setPurchaseSystemName(""); |
|
|
|
fin.setStaffUserSid(""); |
|
|
|
fin.setUseOrgName(loanCaseCloseApply.getUseOrgName()); |
|
|
|
fin.setOrgSidPath(sysOrganizationVo.getOrgSidPath()); |
|
|
|
selectList.add(fin); |
|
|
|
finSelectedReceivablesDetailedFeign.saveAll(selectList); |
|
|
|
} else { |
|
|
|
BigDecimal ys = finSelectedReceivablesDetaileds.stream().map(FinSelectedReceivablesDetailed::getSubscriptionMoney).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
if (ys.compareTo(datum.getReveivableMoney()) == -1) { |
|
|
|
List<FinSelectedReceivablesDetailed> selectList = new ArrayList<>(); |
|
|
|
FinSelectedReceivablesDetailed fin = new FinSelectedReceivablesDetailed(); |
|
|
|
fin.setCreateBySid(loanCaseCloseApply.getCreateBySid()); |
|
|
|
fin.setRemarks("认损"); |
|
|
|
fin.setVIN(loanCaseCloseVehDetailsVo.getVinNo()); |
|
|
|
fin.setUseOrgSid(loanCaseCloseApply.getUseOrgSid()); |
|
|
|
fin.setReceivablesName(datum.getPayCostTitleValue()); |
|
|
|
fin.setSubscriptionMoney(datum.getReveivableMoney().subtract(ys)); |
|
|
|
fin.setSubscriptionDate(DateUtil.today()); |
|
|
|
fin.setAuditState(3); |
|
|
|
fin.setAuditDate(DateUtil.today()); |
|
|
|
fin.setReceivablesSid(datum.getSid()); |
|
|
|
fin.setKxState("01"); |
|
|
|
fin.setPurchaseSystemSid(""); |
|
|
|
fin.setPurchaseSystemName(""); |
|
|
|
fin.setStaffUserSid(""); |
|
|
|
fin.setUseOrgName(loanCaseCloseApply.getUseOrgName()); |
|
|
|
fin.setOrgSidPath(sysOrganizationVo.getOrgSidPath()); |
|
|
|
selectList.add(fin); |
|
|
|
finSelectedReceivablesDetailedFeign.saveAll(selectList); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//月还
|
|
|
|
List<LoanRepaymentHistory> loanRepaymentHistories = loanRepaymentHistoryService.selHistoryByPlanSids(jhmxSids); |
|
|
|
if (loanRepaymentHistories.isEmpty()) { |
|
|
|
for (LoanRepaymentPlanDetails plan : loanRepaymentPlanDetails) { |
|
|
|
List<LoanRepaymentHistory> histories = new ArrayList<>(); |
|
|
|
LoanRepaymentHistory history = new LoanRepaymentHistory(); |
|
|
|
history.setCreateBySid(loanCaseCloseApply.getCreateBySid()); |
|
|
|
history.setDataTime(new Date()); |
|
|
|
history.setUpdateState("1"); |
|
|
|
history.setUpdateTime(new Date()); |
|
|
|
history.setActualDate(plan.getDueDate()); |
|
|
|
history.setActualMoney(plan.getDueMoney()); |
|
|
|
history.setBuckleKey("003"); |
|
|
|
history.setBuckle("审核通过"); |
|
|
|
history.setReturnWayKey(""); |
|
|
|
history.setReturnWay(""); |
|
|
|
history.setPayState(0); |
|
|
|
history.setIsEnable(3); |
|
|
|
history.setPlanDetailSid(plan.getSid()); |
|
|
|
history.setScheduleSid(""); |
|
|
|
history.setRemarks("认损"); |
|
|
|
histories.add(history); |
|
|
|
loanRepaymentHistoryService.saveList(histories); |
|
|
|
} |
|
|
|
} else { |
|
|
|
for (LoanRepaymentPlanDetails plan : loanRepaymentPlanDetails) { |
|
|
|
List<LoanRepaymentHistory> loanRepaymentHistories1 = loanRepaymentHistoryService.selHistoryByPlanSid(plan.getSid()); |
|
|
|
BigDecimal sh = loanRepaymentHistories1.stream().map(LoanRepaymentHistory::getActualMoney).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
if (!loanBePadsincereVehDetailsVos.isEmpty()) { |
|
|
|
List<String> periods = loanBePadsincereVehDetailsVos.stream().map(v -> v.getPeriod()).collect(Collectors.toList()); |
|
|
|
if (periods.contains(plan.getPeriod())) { |
|
|
|
for (LoanBePadsincereVehDetailsVo loanBePadsincereVehDetailsVo : loanBePadsincereVehDetailsVos) { |
|
|
|
if (plan.getPeriod().equals(loanBePadsincereVehDetailsVo.getPeriod())) { |
|
|
|
sh = sh.subtract(new BigDecimal(loanBePadsincereVehDetailsVo.getPadMoney())); |
|
|
|
if (sh.compareTo(plan.getDueMoney()) == -1) { |
|
|
|
List<LoanRepaymentHistory> histories = new ArrayList<>(); |
|
|
|
LoanRepaymentHistory history = new LoanRepaymentHistory(); |
|
|
|
history.setCreateBySid(loanCaseCloseApply.getCreateBySid()); |
|
|
|
history.setDataTime(new Date()); |
|
|
|
history.setUpdateState("1"); |
|
|
|
history.setUpdateTime(new Date()); |
|
|
|
history.setActualDate(plan.getDueDate()); |
|
|
|
history.setActualMoney(plan.getDueMoney().subtract(sh)); |
|
|
|
history.setBuckleKey("003"); |
|
|
|
history.setBuckle("审核通过"); |
|
|
|
history.setReturnWayKey(""); |
|
|
|
history.setReturnWay(""); |
|
|
|
history.setPayState(0); |
|
|
|
history.setIsEnable(3); |
|
|
|
history.setPlanDetailSid(plan.getSid()); |
|
|
|
history.setScheduleSid(""); |
|
|
|
history.setRemarks("认损"); |
|
|
|
histories.add(history); |
|
|
|
loanRepaymentHistoryService.saveList(histories); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (sh.compareTo(plan.getDueMoney()) == -1) { |
|
|
|
List<LoanRepaymentHistory> histories = new ArrayList<>(); |
|
|
|
LoanRepaymentHistory history = new LoanRepaymentHistory(); |
|
|
|
history.setCreateBySid(loanCaseCloseApply.getCreateBySid()); |
|
|
|
history.setDataTime(new Date()); |
|
|
|
history.setUpdateState("1"); |
|
|
|
history.setUpdateTime(new Date()); |
|
|
|
history.setActualDate(plan.getDueDate()); |
|
|
|
history.setActualMoney(plan.getDueMoney().subtract(sh)); |
|
|
|
history.setBuckleKey("003"); |
|
|
|
history.setBuckle("审核通过"); |
|
|
|
history.setReturnWayKey(""); |
|
|
|
history.setReturnWay(""); |
|
|
|
history.setPayState(0); |
|
|
|
history.setIsEnable(3); |
|
|
|
history.setPlanDetailSid(plan.getSid()); |
|
|
|
history.setScheduleSid(""); |
|
|
|
history.setRemarks("认损"); |
|
|
|
histories.add(history); |
|
|
|
loanRepaymentHistoryService.saveList(histories); |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
if (sh.compareTo(plan.getDueMoney()) == -1) { |
|
|
|
List<LoanRepaymentHistory> histories = new ArrayList<>(); |
|
|
|
LoanRepaymentHistory history = new LoanRepaymentHistory(); |
|
|
|
history.setCreateBySid(loanCaseCloseApply.getCreateBySid()); |
|
|
|
history.setDataTime(new Date()); |
|
|
|
history.setUpdateState("1"); |
|
|
|
history.setUpdateTime(new Date()); |
|
|
|
history.setActualDate(plan.getDueDate()); |
|
|
|
history.setActualMoney(plan.getDueMoney().subtract(sh)); |
|
|
|
history.setBuckleKey("003"); |
|
|
|
history.setBuckle("审核通过"); |
|
|
|
history.setReturnWayKey(""); |
|
|
|
history.setReturnWay(""); |
|
|
|
history.setPayState(0); |
|
|
|
history.setIsEnable(3); |
|
|
|
history.setPlanDetailSid(plan.getSid()); |
|
|
|
history.setScheduleSid(""); |
|
|
|
history.setRemarks("认损"); |
|
|
|
histories.add(history); |
|
|
|
loanRepaymentHistoryService.saveList(histories); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void pushRiskToFin(String sid){ |
|
|
|
LoanCaseCloseApply loanCaseCloseApply = fetchBySid(sid); |
|
|
|
if(loanCaseCloseApply != null){ |
|
|
@ -1135,6 +1316,7 @@ public class LoanCaseCloseApplyService extends MybatisBaseService<LoanCaseCloseA |
|
|
|
List<LoanCaseProgressVeh> loanCaseProgressVehs = loanCaseProgressVehService.selByMainSid(sid); |
|
|
|
for (LoanCaseProgressVeh loanCaseProgressVeh : loanCaseProgressVehs) { |
|
|
|
LoanCaseCloseVehDetailsVo loanCaseCloseVehDetailsVo = new LoanCaseCloseVehDetailsVo(); |
|
|
|
loanCaseCloseVehDetailsVo.setBusVinSid(loanCaseProgressVeh.getBusVinSid()); |
|
|
|
loanCaseCloseVehDetailsVo.setVinNo(loanCaseProgressVeh.getVinNo()); |
|
|
|
loanCaseCloseVehDetailsVo.setCarNum(loanCaseProgressVeh.getVehMark()); |
|
|
|
loanCaseCloseVehDetailsVo.setAffiliatedCompany(loanCaseProgressVeh.getAffiliatedCompany()); |
|
|
|