150 lines
5.7 KiB
Java
150 lines
5.7 KiB
Java
package com.tenwa.reckon.executor;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
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.KnowingRentTools;
|
|
import com.tenwa.reckon.help.KnowingTableTools;
|
|
import com.tenwa.reckon.help.PlanDateServiceImpl;
|
|
import com.tenwa.reckon.help.RentPlanContrCalDAOImpl;
|
|
import com.tenwa.reckon.help.RentPlanServiceImpl;
|
|
import com.tenwa.reckon.help.RentalServiceImpl;
|
|
import com.tenwa.reckon.util.DateUtil;
|
|
import com.tenwa.reckon.util.TransRateHelper;
|
|
|
|
public class EvenRentDayExecutor extends FundRentPlanExecutor {
|
|
|
|
public EvenRentDayExecutor(JBOTransaction tx) {
|
|
super(tx);
|
|
}
|
|
|
|
|
|
@Override
|
|
public FundRentPlanBean create(TabCalBean tcb,Integer startList) throws Exception {
|
|
FundRentPlanBean fpb = new FundRentPlanBean();
|
|
//删除租金计划
|
|
this.deleteRentPlan(tcb.getRentPlan_tb(), tcb, startList);
|
|
this.getPmtRentPlan(tcb.getCb(), fpb,tcb);
|
|
this.addRentPlan(fpb, tcb, startList);
|
|
return fpb;
|
|
}
|
|
|
|
|
|
public void getPmtRentPlan(ConditionBean cb, FundRentPlanBean frpb,TabCalBean tcb) throws Exception {
|
|
|
|
// 加载日期列表
|
|
PlanDateServiceImpl pdsi = new PlanDateServiceImpl(tx);
|
|
List<String> dateList = pdsi.getPlanDateList(cb,cb.getIncomeNumber()+"");//获取日期列表
|
|
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;
|
|
}
|
|
Collections.sort( dateList );
|
|
if(cb.getRentOrRate().equals("rent_period")||cb.getRentOrRate().equals("rent_period_360")){
|
|
Integer grace = cb.getGrace();
|
|
List<String> l=KnowingTableTools.convertKnowingBeanToDateList(tcb.getKnowingTables());//已知租金表 获取日期
|
|
for(int i=grace;i>0;i--){
|
|
l.add(0, dateList.get(i-1));
|
|
}
|
|
dateList=new ArrayList<String>();
|
|
dateList.addAll(l);
|
|
interestDateList=new ArrayList<String>();
|
|
interestDateList.addAll(l);
|
|
int leaseTerm=DateUtil.getMonthSpace(cb.getStartDate(),dateList.get(dateList.size()-1));
|
|
cb.setLeaseTerm(leaseTerm);
|
|
cb.setIncomeNumber(l.size());
|
|
}
|
|
frpb.setPlanDateList(dateList);
|
|
frpb.setInterestDateList(interestDateList);
|
|
|
|
List<String> rentList = new ArrayList<String>();
|
|
RentalServiceImpl rsi = new RentalServiceImpl();
|
|
// 加载租金列表
|
|
if(cb.getRentOrRate().equals("rent_period")||cb.getRentOrRate().equals("rent_period_360")){//已知租金表
|
|
Integer grace = cb.getGrace();
|
|
if(grace > 0){
|
|
rentList=rsi.getGraceRentList(cb, rentList,cb.getYearRate(),dateList);
|
|
}
|
|
rentList.addAll(KnowingTableTools.convertKnowingBeanToStrList(tcb.getKnowingTables()));
|
|
cb.setFirstPlanDate(dateList.get(0));
|
|
cb.setSecondPlanDate(dateList.get(1));
|
|
} else if(cb.getRentOrRate().equals("knowing_rent")){//已知租金规则
|
|
Integer grace = cb.getGrace();
|
|
if(grace > 0){
|
|
rentList=rsi.getGraceRentList(cb, rentList,cb.getYearRate(),dateList);
|
|
}
|
|
rentList.addAll(KnowingRentTools.convertKnowingBeanToStrList(tcb.getKnowingConfigs()));
|
|
}else{//按年利率 按租金
|
|
rentList = rsi.getRentListByCond(cb,interestDateList);
|
|
}
|
|
frpb.setRentList(rentList);
|
|
|
|
|
|
|
|
List<String> year_rate = new ArrayList<String>();
|
|
for (int i = 0; i < frpb.getPlanDateList().size(); i++) {
|
|
year_rate.add(cb.getYearRate());
|
|
}
|
|
frpb.setYearRateList(year_rate);
|
|
|
|
// 加载利息列表
|
|
InterestCalServiceImpl icsi = new InterestCalServiceImpl();
|
|
List<String> interests = icsi.getInterestList(frpb.getRentList(),interestDateList,cb.getStartDate(), cb.getCleanLeaseMoney(), cb.getYearRate(), cb.getPeriodType(), cb.getGrace(), cb.getIncomeNumberYear(), cb.getEquipEndValue(),cb.getRateAdjustType(),cb);
|
|
frpb.setInterestBusinessList(interests);
|
|
|
|
// 加载本金列表
|
|
CorpusServiceImpl csi = new CorpusServiceImpl();
|
|
List<String> corpusList = csi.getCorpusList(frpb.getRentList(), frpb.getInterestBusinessList());
|
|
|
|
frpb.setCorpusBusinessList(corpusList);
|
|
|
|
// 加载调整信息列表
|
|
RentPlanServiceImpl rpsi = new RentPlanServiceImpl();
|
|
rpsi.adjustLastRentPlan(frpb, cb.getCleanLeaseMoney(), cb.getEquipEndValue());
|
|
//
|
|
if("rate".equals(cb.getRentOrRate())){
|
|
rpsi.adjustFistAndLastRentPlan(frpb, tcb);
|
|
}
|
|
// 加载本金余额列表
|
|
List<String> corpusOverageBusinessList = TransRateHelper.getCorpusOvergeList(cb.getCleanLeaseMoney(), frpb.getCorpusBusinessList());
|
|
frpb.setCorpusOverageBusinessList(corpusOverageBusinessList);
|
|
|
|
}
|
|
|
|
public FundRentPlanBean createOnhire(TabCalBean tcb ) throws Exception {
|
|
ConditionBean cb = tcb.getCb();
|
|
// 查询他的租金计划
|
|
RentPlanContrCalDAOImpl rpccdi = new RentPlanContrCalDAOImpl();
|
|
FundRentPlanBean frpb = rpccdi.getRentAndDateByTcb(tcb, 1,tx);
|
|
frpb.setRentAdjustList(new ArrayList<String>());// 租金调整值
|
|
// 根据交易结构重新算出的租金计划日期
|
|
// 日期类返回租金列表
|
|
PlanDateServiceImpl pdsi = new PlanDateServiceImpl(tx);
|
|
frpb.setPlanDateList(pdsi.getPlanDateList(cb, String.valueOf(frpb.getRentList().size())));
|
|
if("2".equals(cb.getYearRateType())){
|
|
// 更新租金计划 的时间
|
|
pdsi.updateRentPlanDate(tcb.getRentPlan_tb(), tcb, 1, frpb.getPlanDateList());
|
|
pdsi.updateRentInterestDate(tcb.getRentPlan_tb(), tcb, 1, frpb.getInterestDateList());
|
|
}else{
|
|
this.deleteRentPlan(tcb.getRentPlan_tb(), tcb, 1);
|
|
this.getPmtRentPlan(cb, frpb,tcb);
|
|
frpb.setColumn_1(null);
|
|
frpb.setColumn_2(null);
|
|
this.addRentPlan(frpb, tcb,1);
|
|
}
|
|
return frpb;
|
|
}
|
|
|
|
}
|