129 lines
6.1 KiB
Java
129 lines
6.1 KiB
Java
package com.tenwa.reckon.executor.rentTerminate;
|
||
|
||
import java.math.BigDecimal;
|
||
import java.util.ArrayList;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
|
||
import com.amarsoft.app.als.sys.tools.Tools;
|
||
import com.amarsoft.app.awe.config.InitDBType;
|
||
import com.amarsoft.are.jbo.BizObject;
|
||
import com.amarsoft.are.jbo.BizObjectManager;
|
||
import com.amarsoft.are.jbo.JBOFactory;
|
||
import com.amarsoft.are.jbo.JBOTransaction;
|
||
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
|
||
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.constant.Scale;
|
||
import com.tenwa.reckon.executor.FundRentPlanExecutor;
|
||
import com.tenwa.reckon.executor.rentChange.RentChangeExe;
|
||
import com.tenwa.reckon.help.RentPlanContrCalDAOImpl;
|
||
|
||
public class RentTerminateExe {
|
||
|
||
public JBOTransaction tx;
|
||
|
||
public RentTerminateExe(JBOTransaction tx){
|
||
this.tx=tx;
|
||
}
|
||
|
||
private void before(ConditionBean cb,BizObject bo,TabCalBean tcb) throws Exception{
|
||
String payMoneyday =bo.getAttribute("PAYDAY_ADJUST").getString();
|
||
String contractTotal=bo.getAttribute("CONTRACT_TOTAL").getString();
|
||
BigDecimal discussrent = new BigDecimal(bo.getAttribute("AGREED_INTEREST").getString()).add(new BigDecimal(bo.getAttribute("REPURCHASE_MONEY").getString()));
|
||
|
||
BizObjectManager bm=JBOFactory.getBizObjectManager(tcb.getRentPlan_tb(), tx);
|
||
StringBuffer sql = new StringBuffer();
|
||
sql.append(" select ifnull(max(ifnull(plan_list,0)),0) + 1 as plan_list from "+Tools.getTable(tcb.getRentPlan_tb()))
|
||
.append(" where flowunid = '" + tcb.getDocId() + "' ")
|
||
.append(" and plan_date < '" + payMoneyday + "' ");
|
||
if("ORACLE".equals(InitDBType.DBTYPE)){
|
||
sql=new StringBuffer(sql.toString().replaceAll("ifnull", "nvl"));
|
||
}
|
||
List<Map<String,String>> list=DataOperatorUtil.getDataBySql(tx, sql.toString(), null);
|
||
String rent_list = "0";
|
||
if(list.size()>0){
|
||
rent_list =list.get(0).get("plan_list");
|
||
}
|
||
BigDecimal corpusOverage = new BigDecimal(bo.getAttribute("CORPUS_OVERAGE").getString()) ;
|
||
BigDecimal endCorpus =new BigDecimal(bo.getAttribute("REPURCHASE_MONEY").getString());
|
||
BigDecimal endInterest =new BigDecimal(bo.getAttribute("AGREED_INTEREST").getString());
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = <20>̶<EFBFBD><CCB6><EFBFBD><EFBFBD><EFBFBD> < δ<><CEB4><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD>:δ<><CEB4><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD>-<2D>̶<EFBFBD><CCB6><EFBFBD><EFBFBD><EFBFBD>?0
|
||
BigDecimal corpusMoney = BigDecimal.ZERO;
|
||
if(endCorpus .compareTo(corpusOverage) < 0 ){//<2F>̶<EFBFBD><CCB6><EFBFBD><EFBFBD><EFBFBD> < δ<><CEB4><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD>
|
||
corpusMoney = corpusOverage.subtract(endCorpus).setScale(Scale.RENT_SCALE, BigDecimal.ROUND_HALF_UP);
|
||
}
|
||
BigDecimal yearRate =endInterest.divide(endCorpus,Scale.RATE_SCALE, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(1200)).setScale(Scale.GENERAL_RATE, BigDecimal.ROUND_HALF_UP) ;
|
||
String table = tcb.getRentPlan_tb();
|
||
BizObject oldbm = null;
|
||
if("jbo.app.tenwa.calc.LC_RENT_PLAN_TEMP".equals(table)){
|
||
oldbm = bm.createQuery("flowunid=:flowunid and plan_list='1'").setParameter("flowunid", tcb.getDocId()).getSingleResult(false);
|
||
}
|
||
if(new BigDecimal(bo.getAttribute("REPURCHASE_RATIO").getString()).compareTo(new BigDecimal(100))==0){
|
||
//ɾ<><C9BE>ԭ<EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD>
|
||
bm.createQuery("delete from O where flowunid=:flowunid and plan_list>=:rentlist").setParameter("flowunid",tcb.getDocId()).setParameter("rentlist", rent_list).executeUpdate();
|
||
}else{
|
||
|
||
AdjustBean ab=new AdjustBean();
|
||
ab.setStartList(Integer.parseInt(rent_list));
|
||
ab.setYearRate(new BigDecimal(cb.getYearRate()));
|
||
ab.setAdjustList(cb.getIncomeNumber());
|
||
BizObject rent=bm.createQuery("select * from O where flowunid=:flowunid and plan_list="+(Integer.parseInt(rent_list))).setParameter("flowunid",tcb.getDocId()).getSingleResult(false);
|
||
ab.setPaydayAdjust(rent.getAttribute("plan_date").getString());
|
||
cb.setRepurchaseMoney(endCorpus.toString());
|
||
this.createPlan(cb, ab, tcb,corpusMoney.toString());
|
||
bm.createQuery("delete from O where flowunid=:flowunid and plan_list=:rentlist").setParameter("flowunid",tcb.getDocId()).setParameter("rentlist", rent_list).executeUpdate();
|
||
}
|
||
|
||
BizObject rentNew=bm.newObject();
|
||
rentNew.setAttributeValue("flowunid", tcb.getDocId());
|
||
rentNew.setAttributeValue(tcb.getPlanCName(), tcb.getPlanCValue());
|
||
rentNew.setAttributeValue("plan_list", rent_list);
|
||
rentNew.setAttributeValue("plan_date",payMoneyday);
|
||
rentNew.setAttributeValue("plan_status","δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
rentNew.setAttributeValue("rent", endCorpus);
|
||
rentNew.setAttributeValue("PENALTY",bo.getAttribute("AGREED_PENALTY").getString());
|
||
rentNew.setAttributeValue("corpus_business", endCorpus);
|
||
rentNew.setAttributeValue("year_rate", yearRate);
|
||
rentNew.setAttributeValue("interest_business", "0");
|
||
rentNew.setAttributeValue("interest", "0");
|
||
rentNew.setAttributeValue("corpus", endCorpus);
|
||
rentNew.setAttributeValue("ALL_REMAIN_CORPUS", corpusMoney);
|
||
if(oldbm!=null){
|
||
rentNew.setAttributeValue("project_id", oldbm.getAttribute("project_id").getString());
|
||
rentNew.setAttributeValue("project_plan_number", oldbm.getAttribute("project_plan_number").getString());
|
||
rentNew.setAttributeValue("contract_id", oldbm.getAttribute("contract_id").getString());
|
||
rentNew.setAttributeValue("contract_plan_number",oldbm.getAttribute("contract_plan_number").getString());
|
||
}
|
||
bm.saveObject(rentNew);
|
||
|
||
|
||
}
|
||
|
||
|
||
public FundRentPlanBean create(ConditionBean cb,BizObject bo,TabCalBean tcb) throws Exception{
|
||
// <20><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>жԱ<D0B6><D4B1><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
this.before(cb, bo, tcb);
|
||
FundRentPlanBean frpb = new RentPlanContrCalDAOImpl().getRentAndDateByTcb(tcb, 1,tx);
|
||
return frpb;
|
||
}
|
||
|
||
public void createPlan(ConditionBean cb,AdjustBean ab,TabCalBean tcb,String money) throws Exception{
|
||
RentChangeExe exe=new RentChangeExe(tx);
|
||
Integer startList = ab.getStartList();
|
||
// <20><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>жԱ<D0B6><D4B1><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
FundRentPlanBean frpb = exe.before(cb, ab, tcb);
|
||
cb.setCleanLeaseMoney(money);
|
||
FundRentPlanExecutor executor = exe.getPmtExe(cb);
|
||
// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>pmt<6D><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD>
|
||
frpb = executor.create(tcb,startList+1);
|
||
frpb.setYearRateList(new ArrayList<String>());
|
||
for (int i = 0; i < frpb.getRentList().size(); i++) {
|
||
frpb.getYearRateList().add(cb.getYearRate());
|
||
}
|
||
cb.setIncomeNumber(ab.getAdjustList());
|
||
}
|
||
}
|