119 lines
4.0 KiB
Java

package com.tenwa.reckon.executor.rentChange;
import java.util.ArrayList;
import java.util.List;
import com.amarsoft.are.jbo.JBOTransaction;
import com.tenwa.reckon.bean.AdjustBean;
import com.tenwa.reckon.bean.ConditionBean;
import com.tenwa.reckon.bean.FundRentPlanBean;
import com.tenwa.reckon.bean.TabCalBean;
import com.tenwa.reckon.executor.EvenCorpusExecutor;
import com.tenwa.reckon.executor.EvenInterestChangeExecutor;
import com.tenwa.reckon.executor.EvenRentDayExecutor;
import com.tenwa.reckon.executor.EvenRentExecutor;
import com.tenwa.reckon.executor.EvenSubsectionExecutor;
import com.tenwa.reckon.executor.FundRentPlanExecutor;
import com.tenwa.reckon.help.AdjustHelper;
import com.tenwa.reckon.help.PlanDateServiceImpl;
import com.tenwa.reckon.help.RentPlanContrCalDAOImpl;
import com.tenwa.reckon.util.DictTools;
import com.tenwa.reckon.util.Tools;
/**
* 租金计划变更测算
* @author tenwapc
*
*/
public class RentChangeExe {
public JBOTransaction tx;
public RentChangeExe(JBOTransaction tx){
this.tx=tx;
}
public FundRentPlanBean before(ConditionBean cb,AdjustBean ab,TabCalBean tcb) throws Exception{
//1.转化工具类
cb = DictTools.getReversDict(cb);
//2.查询现租金计划
FundRentPlanBean frpb = new RentPlanContrCalDAOImpl().getRentAndDateByTcb(tcb, 1,tx);
frpb.setYearRate(ab.getYearRate().toString());
frpb.setYearRateList(null);
frpb.setRentAdjustList(null);
//3.拼装开始期次后的商务条件
cb = AdjustHelper.getConditionBeanByAdjustBean(cb, ab, frpb);
if(cb.getSettleMethod().equals("even_rent")){
frpb.setColumn_1(null);
frpb.setColumn_2(null);
}
return frpb;
}
public FundRentPlanExecutor getPmtExe(ConditionBean cb){
FundRentPlanExecutor executor=null;
String settleMethod = cb.getSettleMethod();
if (settleMethod.equals("even_interest")) {
executor = new EvenInterestChangeExecutor(tx);
} else if (settleMethod.equals("even_corpus")||settleMethod.equals("even_corpus_rate")) {
executor = new EvenCorpusExecutor(tx);
}else if(settleMethod.equals("even_rent_day")){
executor=new EvenRentDayExecutor(tx);
}else if(settleMethod.equals("even_subsection")){
executor=new EvenSubsectionExecutor(tx);
} else {
executor = new EvenRentExecutor(tx);
}
return executor;
}
public FundRentPlanBean create(ConditionBean cb,AdjustBean ab,TabCalBean tcb) throws Exception{
Integer startList = ab.getStartList();
// 根据表信息进行对表数据的清除操作
FundRentPlanBean frpb = this.before(cb, ab, tcb);
FundRentPlanExecutor executor = this.getPmtExe(cb);
// 得到正常pmt租金测算后的租金计划
if(ab.getAdjustList()>cb.getOldIncomeNumber()){
cb.setDeferStr(true);
frpb = executor.create(tcb,startList);
}else{
frpb = executor.createOnhire(tcb);
}
//重置起租日
String start_date="";
if(ab.getPaydayAdjust()==null||ab.getPaydayAdjust().equals("")){
//如果变更调整中的日期为空,那么就以开始调整期数当期为起租日
start_date=frpb.getPlanDateList().get(ab.getStartList()-1).toString();
//start_date=adb.getPaydayAdjust();
}else{
if(ab.getStartList()==1){
start_date=cb.getStartDate();
}else{
start_date=ab.getPaydayAdjust();
}
}
cb.setStartDate(start_date);
cb.setFirstPlanDate(ab.getPaydayAdjust());
cb.setSecondPlanDate(null);
PlanDateServiceImpl pdsi= new PlanDateServiceImpl(tx);
List<String> plandatelist=pdsi.getPlanDateList(cb,null);
pdsi.updateRentPlanDate(tcb.getRentPlan_tb(), tcb, startList, plandatelist);
frpb.setYearRateList(new ArrayList<String>());
for (int i = 0; i < frpb.getRentList().size(); i++) {
frpb.getYearRateList().add(cb.getYearRate());
}
// 调用保存的操作
FundRentPlanBean frpbOld = new RentPlanContrCalDAOImpl().getRentAndDateByTcb(tcb, 1,tx);
frpbOld.addRentList(frpb, startList);
Tools.removeList(frpbOld.getPlanDateList(), startList);
frpbOld.getPlanDateList().addAll(plandatelist);
cb.setIncomeNumber(ab.getAdjustList());
Integer incomeNumberYear =cb.getIncomeIntervalMonth();
cb.setLeaseTerm(incomeNumberYear*(cb.getIncomeNumber()));
return frpbOld;
}
}