apzl_leasing/calc/com/tenwa/reckon/executor/EvenInterestExecutor.java
2019-10-09 16:09:13 +08:00

109 lines
4.5 KiB
Java

package com.tenwa.reckon.executor;
import java.util.ArrayList;
import java.util.List;
import com.amarsoft.are.jbo.JBOTransaction;
import com.tenwa.reckon.bean.ConditionBean;
import com.tenwa.reckon.bean.FundRentPlanBean;
import com.tenwa.reckon.bean.TabCalBean;
import com.tenwa.reckon.help.CorpusServiceImpl;
import com.tenwa.reckon.help.InterestCalServiceImpl;
import com.tenwa.reckon.help.PlanDateServiceImpl;
import com.tenwa.reckon.help.RentPlanServiceImpl;
import com.tenwa.reckon.help.RentalServiceImpl;
import com.tenwa.reckon.util.IrrTools;
import com.tenwa.reckon.util.TransRateHelper;
public class EvenInterestExecutor extends FundRentPlanExecutor {
public EvenInterestExecutor(JBOTransaction tx) {
super(tx);
// TODO Auto-generated constructor stub
}
@Override
public FundRentPlanBean create(TabCalBean tcb,Integer startList) throws Exception {
FundRentPlanBean fpb = new FundRentPlanBean();
ConditionBean cb = tcb.getCb();
String year_rate = cb.getYearRate();
//删除租金计划
this.deleteRentPlan(tcb.getRentPlan_tb(), tcb, startList);
this.rentPlanEvenInterestCal(cb, fpb);
String irr=cb.getYearRate();
cb.setCleanLeaseMoney(cb.getCleanLeaseMoney());
calFina(cb, tcb, 1, fpb);//做财务计划测算
cb.setYearRate(year_rate);//把年利率置回去
List<String> rateList = new ArrayList<String>();
for (int i = 0; i < fpb.getCorpusBusinessList().size(); i++) {
rateList.add(irr);
}
fpb.setYearRateList(rateList);
this.addRentPlan(fpb, tcb,startList);
return fpb;
}
public void rentPlanEvenInterestCal(ConditionBean cb, FundRentPlanBean frpb) throws Exception {
PlanDateServiceImpl pdsi= new PlanDateServiceImpl(tx);
//先找到总本金值
String leaseMoney = cb.getCleanLeaseMoney();
List<String> interest = new InterestCalServiceImpl().getInterestList(leaseMoney, cb.getLeaseTerm(), cb.getIncomeNumber() + cb.getGrace(), cb.getEquipEndValue(), cb.getYearRate());
List<String> corpus = null;
/*if("one_1".equals(cb.getCorpusType())){//按月付息一次还本
corpus = new CorpusServiceImpl().getCorpusListForOne(cb.getCleanLeaseMoney(), cb.getIncomeNumber(), cb.getEquipEndValue(), cb.getGrace());
}else if("three_1".equals(cb.getCorpusType())){//按月付息按季还本
corpus = new CorpusServiceImpl().getCorpusListForThree(cb.getCleanLeaseMoney(), cb.getIncomeNumber(), cb.getEquipEndValue(), cb.getGrace());
}else{*/
corpus = new CorpusServiceImpl().getCorpusListFinalPayment(cb, cb.getCleanLeaseMoney(), cb.getIncomeNumber(), cb.getEquipEndValue(), cb.getGrace());
//}
List<String> rentList = new RentalServiceImpl().getRentListByCond(cb.getCleanLeaseMoney(), cb.getEquipEndValue(), corpus, interest,cb);
List<String> dateList =pdsi.getPlanDateList(cb, String.valueOf(frpb.getRentList().size()));
List<String> interestDateList=pdsi.getInterestDateList(cb);
//节假日调整
dateList=pdsi.getAdjustDate(dateList,cb.getPlanDateHoilday());
interestDateList=pdsi.getAdjustDate(interestDateList, cb.getInterestDateHoliday());
if("start_date".equals(cb.getInterestDayType())){
interestDateList=dateList;
}
frpb.setInterestDateList(interestDateList);
frpb.setPlanDateList(dateList);
frpb.setColumn_1(corpus);
frpb.setColumn_2(interest);
frpb.setRentList(rentList);
List<String> rentListTemp = rentList;
List<String> rentRemainList = new RentalServiceImpl().getRentRemainList(rentListTemp);
frpb.setAllRemainRentList(rentRemainList);
String irr = IrrTools.getIRRByEvenInterest(cb, frpb);//获取均息法下的利率
cb.setYearRate(irr);
}
public void calFina(ConditionBean cb, TabCalBean tcb, int startList, FundRentPlanBean frpb) throws Exception {
// 加载利息列表
InterestCalServiceImpl icsi = new InterestCalServiceImpl();
List<String> interests = icsi.getInterestList(frpb.getRentList(), cb.getCleanLeaseMoney(), cb.getYearRate(), cb.getPeriodType(), cb.getGrace(), cb.getIncomeNumberYear(), cb.getEquipEndValue(),cb.getRateAdjustType());
// frpb.setInterestBusinessList(frpb.getColumn_2());
frpb.setInterestBusinessList(interests);
// 加载本金列表
CorpusServiceImpl csi = new CorpusServiceImpl();
List<String> corpusList = csi.getCorpusList(frpb.getRentList(), frpb.getInterestBusinessList());
// frpb.setCorpusBusinessList(frpb.getColumn_1());
frpb.setCorpusBusinessList(corpusList);
// 加载调整信息列表
RentPlanServiceImpl rpsi = new RentPlanServiceImpl();
rpsi.adjustLastRentPlan(frpb, cb.getCleanLeaseMoney(), cb.getEquipEndValue());
// 加载本金余额列表
frpb.setCorpusOverageBusinessList(TransRateHelper.getCorpusOvergeList(cb.getCleanLeaseMoney(), frpb.getCorpusBusinessList()));
}
}