From 4ccaa7ecf5cfcb1c85b0071d3ec3cc60d4a0ec37 Mon Sep 17 00:00:00 2001 From: zhulh Date: Tue, 27 Jul 2021 15:15:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=88=86=E6=AE=B5=E8=9E=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LoanSimulation/LoanBasicInfo.jsp | 3 +- WebContent/WEB-INF/etc/jbo/jbo_calc.xml | 253 ++++++++++++++++++ .../executor/CreateTransactionExecutor.java | 2 + .../reckon/executor/FundFundPlanExecutor.java | 70 +++-- .../executor/SegmentedFinancingExecutor.java | 209 +++++++++++++++ .../reckon/help/CalcConditionCopyService.java | 214 ++++++++------- calc/com/tenwa/reckon/util/IrrTools.java | 166 ++++++------ 7 files changed, 712 insertions(+), 205 deletions(-) create mode 100644 calc/com/tenwa/reckon/executor/SegmentedFinancingExecutor.java diff --git a/WebContent/Accounting/LoanSimulation/LoanBasicInfo.jsp b/WebContent/Accounting/LoanSimulation/LoanBasicInfo.jsp index a21918983..94b26cd98 100644 --- a/WebContent/Accounting/LoanSimulation/LoanBasicInfo.jsp +++ b/WebContent/Accounting/LoanSimulation/LoanBasicInfo.jsp @@ -445,7 +445,7 @@ CalcControl.InitStartDate=function(){ break; } //是按起租日计算的情况,直接读取当前日期 - if(calcRules["method"][methodName]["DefaultDueDay"] != "02") { + if( calcRules["method"][methodName]["DefaultDueDay"] && calcRules["method"][methodName]["DefaultDueDay"] != "02") { rentDay = calcRules["method"][methodName]["ActualDay"]; } @@ -1248,6 +1248,7 @@ function run() setItemValue(0,getRow(),p.toUpperCase(),result.info[p]); } } + subsection_list.window.reloadSelf(); if(result.message){ alert(result.message); } diff --git a/WebContent/WEB-INF/etc/jbo/jbo_calc.xml b/WebContent/WEB-INF/etc/jbo/jbo_calc.xml index 14aada50c..c112d9eb2 100644 --- a/WebContent/WEB-INF/etc/jbo/jbo_calc.xml +++ b/WebContent/WEB-INF/etc/jbo/jbo_calc.xml @@ -1080,6 +1080,7 @@ + @@ -1423,6 +1424,7 @@ + @@ -2783,6 +2785,7 @@ + @@ -3368,6 +3371,7 @@ + @@ -4804,5 +4808,254 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java b/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java index dfdbc9e3b..b51bb2ecc 100644 --- a/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java +++ b/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java @@ -710,6 +710,8 @@ public class CreateTransactionExecutor implements Transaction { executor=new CarEvenInterestExecutor(tx,bean.getProductId());//车贷均息入口 }else if(settleMethod.equals("car_even_rent")){ executor=new CarEvenRentExecutor(tx,bean.getProductId());//车贷等租入口 + } else if ( "segmented_financing".equals( settleMethod ) ) { + executor = new SegmentedFinancingExecutor( tx ); } else { executor = new EvenRentExecutor(tx); } diff --git a/calc/com/tenwa/reckon/executor/FundFundPlanExecutor.java b/calc/com/tenwa/reckon/executor/FundFundPlanExecutor.java index 934a69736..b3301fadd 100644 --- a/calc/com/tenwa/reckon/executor/FundFundPlanExecutor.java +++ b/calc/com/tenwa/reckon/executor/FundFundPlanExecutor.java @@ -29,7 +29,7 @@ import com.tenwa.reckon.bean.TabCalBean; import com.tenwa.reckon.util.UUIDUtil; public class FundFundPlanExecutor { - + public void run(ConditionBean cb , TabCalBean tcb,FundRentPlanBean rentPlan,JBOTransaction tx) throws Exception{ cb.setDocId(tcb.getDocId()); List fundPlanBeans=new ArrayList(); @@ -43,6 +43,36 @@ public class FundFundPlanExecutor { cb.setDeductionLastPlanDate(cb.getLastPlanDate());//不生成保证金抵扣及退还计划 } fundPlanBeans = this.create(tcb,fundPlanBeans,tx); + + // 补上分段融贴息计划 + if ( "segmented_financing".equals( cb.getSettleMethod() ) ) { + BizObjectManager bom = JBOFactory.getBizObjectManager( "jbo.app.tenwa.calc.LC_CALC_SUBSECTION_INFO_TEMP", tx ); + List bos = bom.createQuery( "flowunid = :flowunid" ).setParameter( "flowunid", tcb.getDocId() ).getResultList( false ); + for ( BizObject bo : bos ) { + String discount = bo.getAttribute( "DISCOUNT" ).getString(); + String subsectionNumber = bo.getAttribute( "SUBSECTION_NUMBER" ).getString(); + String isBalanceLending = bo.getAttribute( "IS_BALANCE_LENDING" ).getString(); + String discountCollectionPeriod = bo.getAttribute( "DISCOUNT_COLLECTION_PERIOD" ).getString(); + FundPlanBean fundPlanBean = new FundPlanBean(); + fundPlanBean.setFeeType( "feetype27" ); + fundPlanBean.setPlanList( subsectionNumber ); + fundPlanBean.setSettleMethod( "payfund6" ); + fundPlanBean.setPayType( "pay_type_in" ); + if ( "Y".equals( isBalanceLending ) ) { + fundPlanBean.setPlanDate( getPlanDate( "PaymentTime1", cb ) ); + } else { + if ( "0".equals( discountCollectionPeriod ) ) { + fundPlanBean.setPlanDate( getPlanDate( "PaymentTime1", cb ) ); + } else { + fundPlanBean.setPlanDate( rentPlan.getPlanDateList().get( Integer.parseInt( discountCollectionPeriod ) - 1 ) ); + } + } + fundPlanBean.setPlanMoney( discount ); + fundPlanBean.setPayCust( "" ); + fundPlanBeans.add( fundPlanBean ); + } + } + this.delete(tcb,tx); this.add(fundPlanBeans, tcb,tx); } @@ -110,7 +140,7 @@ public class FundFundPlanExecutor { if(Float.parseFloat(sdhandlingCharge)>0){ ffcp=new FundPlanBean(); ffcp.setId(UUID.randomUUID().toString().replaceAll("-", "")); - ffcp.setFeeType("feetype30");//商定违约金 + ffcp.setFeeType("feetype30");//商定违约金 ffcp.setPlanList("1"); ffcp.setSettleMethod("payfund6"); ffcp.setPayType("pay_type_in"); @@ -136,7 +166,7 @@ public class FundFundPlanExecutor { if(Float.parseFloat(otherIn)>0){ ffcp=new FundPlanBean(); ffcp.setId(UUID.randomUUID().toString().replaceAll("-", "")); - ffcp.setFeeType("feetype8");//其他应收 + ffcp.setFeeType("feetype8");//其他应收 ffcp.setPlanList("1"); ffcp.setSettleMethod("payfund6"); ffcp.setPayType("pay_type_in"); @@ -147,7 +177,7 @@ public class FundFundPlanExecutor { } return fundPlanBeans; } - + //创建资金计划 private List create(TabCalBean tcb,List fundPlanBeans,JBOTransaction tx) throws Exception{ //获取产品租赁物类型配置 @@ -167,7 +197,7 @@ public class FundFundPlanExecutor { if("quoted_price".equals(tcb.getCalType())){ custid=tcb.getDocId(); }else if(tcb.getUserId()==null||tcb.getUserId().equals("")){ - + } else{ String sql2="select customer_id from "+tcb.getUserId()+" where flowunid='"+tcb.getDocId()+"'"; List> list=DataOperatorUtil.getDataBySql(tx, sql2, null); @@ -175,10 +205,10 @@ public class FundFundPlanExecutor { custid=list.get(0).get("customer_id"); } } - + BizObject con=tcb.getCondition(); ConditionBean cb=tcb.getCb(); - + //String sql="select itemno from O where codeno='FeeType' and relativecode=:code"; Item[] items = CodeCache.getItems("FeeType"); for(Map.Entry> entry:map.entrySet()){ @@ -192,11 +222,11 @@ public class FundFundPlanExecutor { && "EQUIP_END_VALUE".equals(key)) { continue; } - + //取值 BigDecimal temp = null; - - if("business_product".equals(tcb.getProductType()) + + if("business_product".equals(tcb.getProductType()) && "CLEAN_LEASE_MONEY".equals(key)) { temp = new BigDecimal(con.getAttribute("EQUIP_AMT").getDouble()); } else if("UNITE_MONEY_OUT".equals(key)){ @@ -204,7 +234,7 @@ public class FundFundPlanExecutor { }else{ temp = new BigDecimal(con.getAttribute(key).getDouble()); } - + Item item = null; for(Item it : items) { if(key.equals(it.getRelativeCode())) { @@ -212,7 +242,7 @@ public class FundFundPlanExecutor { break; } } - + //BizObject item=JBOFactory.createBizObjectQuery(CODE_LIBRARY.CLASS_NAME, sql).setParameter("code", entry.getKey()).getSingleResult(false); if (item!=null && temp.compareTo(BigDecimal.ZERO)>0) { FundPlanBean ffcp = new FundPlanBean(); @@ -224,7 +254,7 @@ public class FundFundPlanExecutor { ffcp.setId(boLFP.getAttribute("id").getString()); bomLFP.deleteObject(boLFP); } - + } ffcp.setFeeType(item.getItemNo());//费用类型 ffcp.setPlanList("1"); @@ -283,7 +313,7 @@ public class FundFundPlanExecutor { BizObjectManager bm=JBOFactory.getBizObjectManager(tcb.getFundFundPlan_tb(), tx); bm.createQuery(sql).executeUpdate(); } - + //保存资金计划到表 private void add(List fp,TabCalBean tcb,JBOTransaction tx) throws Exception{ com.amarsoft.awe.util.Transaction tran = com.amarsoft.awe.util.Transaction.createTransaction(tx); @@ -341,17 +371,17 @@ public class FundFundPlanExecutor { fundPlan.setAttributeValue("PAY_OBJ", fund.getPayObj()); fundPlan.setAttributeValue("SETTLE_METHOD",fund.getSettleMethod()); fundPlan.setAttributeValue("PAY_TYPE", fund.getPayType()); - + //联合方出资比例 //BigDecimal unionRatio=new BigDecimal(tcb.getCb().getUnioRatio()); //fundPlan.setAttributeValue("plan_money_union",new BigDecimal(fundPlan.getAttribute("PLAN_MONEY").getString()).multiply(unionRatio).divide(new BigDecimal(100), 2,BigDecimal.ROUND_HALF_UP).toString()); //fundPlan.setAttributeValue("plan_money_company", new BigDecimal(fundPlan.getAttribute("PLAN_MONEY").getString()).subtract(new BigDecimal(fundPlan.getAttribute("plan_money_union").getString())).toString()); - + bm.saveObject(fundPlan); }*/ } - - //生成抵扣保证金 保证金退还 资金计划 + + //生成抵扣保证金 保证金退还 资金计划 private static List splitFundFundPlan(FundRentPlanBean planBean,ConditionBean cb,String custID,String remainType,String reduceType) throws Exception{ List planDates = planBean.getPlanDateList(); List rentPlans = planBean.getRentList(); @@ -410,8 +440,8 @@ public class FundFundPlanExecutor { } return newFundPlans; } - - //生成抵扣保证金 保证金退还 资金计划 + + //生成抵扣保证金 保证金退还 资金计划 private static List splitFundFundPlanList(FundRentPlanBean planBean,ConditionBean cb,String custID,String remainType,String reduceType) throws Exception{ List planDates = planBean.getPlanDateList(); List rentPlans = planBean.getRentList(); diff --git a/calc/com/tenwa/reckon/executor/SegmentedFinancingExecutor.java b/calc/com/tenwa/reckon/executor/SegmentedFinancingExecutor.java new file mode 100644 index 000000000..7a7813894 --- /dev/null +++ b/calc/com/tenwa/reckon/executor/SegmentedFinancingExecutor.java @@ -0,0 +1,209 @@ +package com.tenwa.reckon.executor; + +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.reckon.bean.ConditionBean; +import com.tenwa.reckon.bean.FundRentPlanBean; +import com.tenwa.reckon.bean.TabCalBean; +import com.tenwa.reckon.help.PlanDateServiceImpl; +import com.tenwa.reckon.util.IrrTools; +import com.tenwa.reckon.util.RentTools; +import org.apache.commons.lang3.StringUtils; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +public class SegmentedFinancingExecutor extends FundRentPlanExecutor { + + public SegmentedFinancingExecutor(JBOTransaction tx) { + super( tx ); + } + + @Override + public FundRentPlanBean create( TabCalBean tcb, Integer startList ) throws Exception { + this.deleteRentPlan( tcb.getRentPlan_tb(), tcb, startList ); + + // 年还款次数 + String flowunid = tcb.getDocId(); + BigDecimal incomeNumberYear = new BigDecimal( tcb.getCb().getIncomeNumberYear() ); + BizObjectManager bom = JBOFactory.getBizObjectManager( "jbo.app.tenwa.calc.LC_CALC_SUBSECTION_INFO_TEMP", tx ); + BizObjectManager bomLSRPT = JBOFactory.getBizObjectManager( "jbo.app.tenwa.calc.LC_SUBSECTION_RENT_PLAN_TEMP", tx ); + bomLSRPT.createQuery( "delete from O where flowunid = :flowunid" ).setParameter( "flowunid", flowunid ).executeUpdate(); + // 遍历分段融表 + List bos = bom.createQuery( "flowunid = :flowunid order by subsection_number" ).setParameter( "flowunid", flowunid ) + .getResultList( true ); + List dates = new ArrayList<>(); + List interests = new ArrayList<>(); + List corpuss = new ArrayList<>(); + List rents = new ArrayList<>(); + List overCorpuss = new ArrayList<>(); + PlanDateServiceImpl pdsi = new PlanDateServiceImpl( tx ); + ConditionBean cb = tcb.getCb(); + for ( BizObject bo : bos ) { + // 分段号 + String subsectionNumber = bo.getAttribute( "SUBSECTION_NUMBER" ).getString(); + // 融资金额 + BigDecimal cleanLeaseMoney = new BigDecimal( bo.getAttribute( "CLEAN_LEASE_MONEY" ).getString() ); + // 标准利率 + BigDecimal rate = new BigDecimal( bo.getAttribute( "RATE" ).getString() ).divide( new BigDecimal( 100 ), 20, 4 ); + // 期利率 + BigDecimal preRate = rate.divide( incomeNumberYear, 20, 4 ); + // 期次 + BigDecimal incomeNumber = new BigDecimal( bo.getAttribute( "INCOME_NUMBER" ).getString() ); + cb.setIncomeNumber( incomeNumber.intValue() ); + List planDateList = pdsi.getPlanDateList( cb, null ); + if ( planDateList.size() > dates.size() ) { + dates = planDateList; + } + // 贴息计算方式 + String discountCalcMethod = bo.getAttribute( "DISCOUNT_CALC_METHOD" ).getString(); + // 融资利率 + BigDecimal financingRate; + if ( "1".equals( discountCalcMethod ) ) { // 根据利率计算贴息金额 + // 贴息后利率 + BigDecimal discountRate = new BigDecimal( bo.getAttribute( "DISCOUNT_RATE" ).getString() ).divide( new BigDecimal( 100 ), 20, 4 ); + // 期利率 + BigDecimal preDiscountRate = discountRate.divide( incomeNumberYear, 20, 4 ); + // 标准利率计算租金 + String rent = RentTools.getPMT( preRate.toString(), incomeNumber.toString(), cleanLeaseMoney.negate().toString(), "0", "0" ); + // 贴息后利率计算租金 + String afterDiscountRent = RentTools.getPMT( preDiscountRate.toString(), incomeNumber.toString(), cleanLeaseMoney.negate().toString(), "0", "0" ); + // 计算贴息 + BigDecimal discount = new BigDecimal( rent ).setScale( 2, 4 ).multiply( incomeNumber ).subtract( new BigDecimal( afterDiscountRent ).setScale( 2, 4 ).multiply( incomeNumber ) ); + bo.setAttributeValue( "DISCOUNT", discount ); + + String fr = bo.getAttribute( "FINANCING_RATE" ).getString(); + if ( StringUtils.isEmpty( fr ) ) { + financingRate = discountRate.divide( new BigDecimal( 100 ), 20, 4 ); + bo.setAttributeValue( "FINANCING_RATE", discountRate.toString() ); + } else { + financingRate = new BigDecimal( fr ).divide( new BigDecimal( 100 ), 20, 4 ); + } + bo.setAttributeValue( tcb.getPlanCName(), tcb.getPlanCValue() ); + bom.saveObject( bo ); + } else { + // 贴息金额 + BigDecimal discount = new BigDecimal( bo.getAttribute( "DISCOUNT" ).getString() ); + // 标准利率计算租金 + String rent = RentTools.getPMT( preRate.toString(), incomeNumber.toString(), cleanLeaseMoney.negate().toString(), "0", "0" ); + // 贴息后租金 + BigDecimal afterDiscountRent = new BigDecimal( rent ).setScale( 2, 4 ).multiply( incomeNumber ).subtract( discount ).divide( incomeNumber, 2, 4 ); + List cashFlow = new ArrayList<>(); + cashFlow.add( cleanLeaseMoney.negate() ); + for ( int i = 0; i < incomeNumber.intValue(); i ++ ) { + cashFlow.add( afterDiscountRent ); + } + BigDecimal discountRate = getIRR( cashFlow, incomeNumberYear ).setScale( 6, 4 ); + bo.setAttributeValue( "DISCOUNT_RATE", discountRate.toString() ); + String fr = bo.getAttribute( "FINANCING_RATE" ).getString(); + if ( StringUtils.isEmpty( fr ) ) { + financingRate = discountRate.divide( new BigDecimal( 100 ), 20, 4 ); + bo.setAttributeValue( "FINANCING_RATE", discountRate.toString() ); + } else { + financingRate = new BigDecimal( fr ).divide( new BigDecimal( 100 ), 20, 4 ); + } + bo.setAttributeValue( tcb.getPlanCName(), tcb.getPlanCValue() ); + bom.saveObject( bo ); + } + // 融资期利率 + BigDecimal preFinancingRate = financingRate.divide( incomeNumberYear, 20, 4 ); + // 实际租金 + String rent = RentTools.getPMT( preFinancingRate.toString(), incomeNumber.toString(), cleanLeaseMoney.negate().toString(), "0", "0" ); + BigDecimal r = new BigDecimal( rent ).setScale( 2, 4 ); + for ( int i = 0; i < incomeNumber.intValue(); i ++ ) { + BigDecimal interest; + BigDecimal corpus; + if ( i == incomeNumber.intValue() - 1 ) { + corpus = cleanLeaseMoney; + if ( corpus.compareTo( r ) >= 0 ) { + r = corpus; + interest = BigDecimal.ZERO; + } else { + interest = r.subtract( corpus ); + } + cleanLeaseMoney = BigDecimal.ZERO; + } else { + interest = cleanLeaseMoney.multiply( preFinancingRate ).setScale( 2, 4 ); + corpus = r.subtract( interest ); + cleanLeaseMoney = cleanLeaseMoney.subtract( corpus ); + } + BizObject boLSRPT = bomLSRPT.newObject(); + boLSRPT.setAttributeValue( "FLOWUNID", flowunid ); + boLSRPT.setAttributeValue( tcb.getPlanCName(), tcb.getPlanCValue() ); + boLSRPT.setAttributeValue( "PLAN_LIST", i + 1 ); + boLSRPT.setAttributeValue( "PLAN_DATE", planDateList.get( i ) ); + boLSRPT.setAttributeValue( "INTEREST_DATE", planDateList.get( i ) ); + boLSRPT.setAttributeValue( "PLAN_STATUS", "未回笼" ); + boLSRPT.setAttributeValue( "RENT", r.toString() ); + boLSRPT.setAttributeValue( "CORPUS", corpus.toString() ); + boLSRPT.setAttributeValue( "INTEREST", interest.toString() ); + boLSRPT.setAttributeValue( "ALL_REMAIN_CORPUS", cleanLeaseMoney.toString() ); + boLSRPT.setAttributeValue( "CORPUS_BUSINESS", corpus.toString() ); + boLSRPT.setAttributeValue( "INTEREST_BUSINESS", interest.toString() ); + boLSRPT.setAttributeValue( "SUBSECTION_NUMBER", subsectionNumber ); + bomLSRPT.saveObject( boLSRPT ); + if ( interests.size() - 1 > i ) { + interests.set( i, new BigDecimal( interests.get( i ) ).add( interest ).toString() ); + corpuss.set( i, new BigDecimal( corpuss.get( i ) ).add( corpus ).toString() ); + overCorpuss.set( i, new BigDecimal( overCorpuss.get( i ) ).add( cleanLeaseMoney ).toString() ); + rents.set( i, new BigDecimal( rents.get( i ) ).add( r ).toString() ); + } else { + interests.add( interest.toString() ); + corpuss.add( corpus.toString() ); + overCorpuss.add( cleanLeaseMoney.toString() ); + rents.add( r.toString() ); + } + } + } + FundRentPlanBean fundRentPlanBean = new FundRentPlanBean(); + fundRentPlanBean.setCorpusOverageBusinessList( overCorpuss ); + fundRentPlanBean.setCorpusBusinessList( corpuss ); + fundRentPlanBean.setInterestBusinessList( interests ); + fundRentPlanBean.setPlanDateList( dates ); + fundRentPlanBean.setRentList( rents ); + + this.addRentPlan( fundRentPlanBean, tcb, startList ); + return fundRentPlanBean; + } + + public static BigDecimal getIRR( List cashFlows, BigDecimal incomeNumberYear ) { + List cashFlow = new ArrayList<>(); + for ( int o = 0; o < cashFlows.size(); o ++ ) { + Object obj = cashFlows.get( o ); + if ( obj instanceof BigDecimal ) { + cashFlow.add( ( BigDecimal ) obj ); + } else { + cashFlow.add( new BigDecimal( obj.toString() ) ); + } + } + BigDecimal up = BigDecimal.ONE; + BigDecimal down = BigDecimal.ZERO; + BigDecimal two = new BigDecimal( "2" ); + BigDecimal irr = new BigDecimal( "0.01" ); + BigDecimal accuracy = new BigDecimal( "0.0000001" ); + BigDecimal out; + + int i = 0; + while ( irr.abs().compareTo( accuracy ) > 0 && i < 200 ) { + out = cashFlow.get( 0 ); + for ( int j = 1; j < cashFlow.size(); j ++ ) { + out = out.add( cashFlow.get( j ).divide( new BigDecimal( Math.pow( BigDecimal.ONE.add( irr ).doubleValue(), j ) ), 20, 4 ) ); + } + + if ( out.compareTo( BigDecimal.ZERO ) > 0 ) { + down = irr; + irr = irr.add( up ).divide( two, 20, 4 ); + } else if ( out.compareTo( BigDecimal.ZERO ) < 0 ) { + up = irr; + irr = irr.add( down ).divide( two, 20, 4 ); + } + i ++; + } + irr = irr.multiply( incomeNumberYear ).multiply( new BigDecimal( 100 ) ); + + return irr; + } +} diff --git a/calc/com/tenwa/reckon/help/CalcConditionCopyService.java b/calc/com/tenwa/reckon/help/CalcConditionCopyService.java index c1672c2c7..b8b5a8de6 100644 --- a/calc/com/tenwa/reckon/help/CalcConditionCopyService.java +++ b/calc/com/tenwa/reckon/help/CalcConditionCopyService.java @@ -4,46 +4,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import jbo.app.tenwa.calc.LC_CALC_CONDITION; -import jbo.app.tenwa.calc.LC_CALC_CONDITION_HIS; -import jbo.app.tenwa.calc.LC_CALC_CONDITION_TEMP; -import jbo.app.tenwa.calc.LC_CALC_PERIOD; -import jbo.app.tenwa.calc.LC_CALC_PERIOD_TEMP; -import jbo.app.tenwa.calc.LC_CALC_RULES; -import jbo.app.tenwa.calc.LC_CALC_RULES_TEMP; -import jbo.app.tenwa.calc.LC_CALC_SUBSECTION; -import jbo.app.tenwa.calc.LC_CALC_SUBSECTION_TEMP; -import jbo.app.tenwa.calc.LC_CASH_FLOW; -import jbo.app.tenwa.calc.LC_CASH_FLOW_HIS; -import jbo.app.tenwa.calc.LC_CASH_FLOW_TEMP; -import jbo.app.tenwa.calc.LC_CONTRACT_CASH_FLOW; -import jbo.app.tenwa.calc.LC_CONTRACT_CONDITION; -import jbo.app.tenwa.calc.LC_CONTRACT_FUND_PLAN; -import jbo.app.tenwa.calc.LC_CONTRACT_PERIOD; -import jbo.app.tenwa.calc.LC_CONTRACT_RENT_PLAN; -import jbo.app.tenwa.calc.LC_CONTRACT_RULES; -import jbo.app.tenwa.calc.LC_CONTRACT_SUBSECTION; -import jbo.app.tenwa.calc.LC_CUSTOMER_CASH_FLOW; -import jbo.app.tenwa.calc.LC_CUSTOMER_CONDITION; -import jbo.app.tenwa.calc.LC_CUSTOMER_FUND_PLAN; -import jbo.app.tenwa.calc.LC_CUSTOMER_PERIOD; -import jbo.app.tenwa.calc.LC_CUSTOMER_RENT_PLAN; -import jbo.app.tenwa.calc.LC_CUSTOMER_RULES; -import jbo.app.tenwa.calc.LC_CUSTOMER_SUBSECTION; -import jbo.app.tenwa.calc.LC_FUND_PLAN; -import jbo.app.tenwa.calc.LC_FUND_PLAN_TEMP; -import jbo.app.tenwa.calc.LC_PAY_CASH_FLOW; -import jbo.app.tenwa.calc.LC_PAY_RENT_PLAN; -import jbo.app.tenwa.calc.LC_PROJ_CASH_FLOW; -import jbo.app.tenwa.calc.LC_PROJ_CONDITION; -import jbo.app.tenwa.calc.LC_PROJ_FUND_PLAN; -import jbo.app.tenwa.calc.LC_PROJ_PERIOD; -import jbo.app.tenwa.calc.LC_PROJ_RENT_PLAN; -import jbo.app.tenwa.calc.LC_PROJ_RULES; -import jbo.app.tenwa.calc.LC_PROJ_SUBSECTION; -import jbo.app.tenwa.calc.LC_RENT_PLAN; -import jbo.app.tenwa.calc.LC_RENT_PLAN_HIS; -import jbo.app.tenwa.calc.LC_RENT_PLAN_TEMP; +import jbo.app.tenwa.calc.*; import jbo.com.tenwa.entity.comm.flow.FLOW_BUSSINESS_OBJECT; import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO_TEMP; import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO; @@ -70,14 +31,14 @@ public class CalcConditionCopyService { public void custToTemp(String flowunid,String quotid,String planCName,String planCValue,JBOTransaction tx) throws JBOException, RecordNotFoundException, Exception{ Map fromCondition=new HashMap(); fromCondition.put("quot_id", quotid); - + Map otherProperty=new HashMap(); otherProperty.put("FLOWUNID", flowunid); otherProperty.put(planCName, planCValue); - + Map toCondition=new HashMap(); toCondition.put(planCName, planCValue); - + //商务条件 DataOperatorUtil.copyJBOSet(LC_CUSTOMER_CONDITION.CLASS_NAME, fromCondition,LC_CALC_CONDITION_TEMP.CLASS_NAME, toCondition, otherProperty, null, tx); //测算租金规则 @@ -93,22 +54,22 @@ public class CalcConditionCopyService { //分段测算 DataOperatorUtil.copyJBOSet(LC_CUSTOMER_SUBSECTION.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION_TEMP.CLASS_NAME, toCondition, otherProperty, null, tx); } - - - + + + //临时表到项目表 public void tempToProj(String flowunid,JBOTransaction tx) throws Exception{ - + BizObject flow=JBOFactory.createBizObjectQuery(FLOW_BUSSINESS_OBJECT.CLASS_NAME,"flow_unid=:flowunid").setParameter("flowunid", flowunid).getSingleResult(false); - + String projid=flow.getAttribute("proj_id").getString(); - + Map fromCondition=new HashMap(); fromCondition.put("FLOWUNID", flowunid); - + Map toCondition=new HashMap(); toCondition.put("PROJECT_ID", projid); - + Map otherProperty=new HashMap(); otherProperty.put("project_id", projid); //商务条件 @@ -126,15 +87,19 @@ public class CalcConditionCopyService { DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION_TEMP.CLASS_NAME, fromCondition, LC_PROJ_SUBSECTION.CLASS_NAME, toCondition, otherProperty, null, tx); //前提条件 DataOperatorUtil.copyJBOSet(LC_CONDITION_TEMP.CLASS_NAME, fromCondition, LC_CONDITION.CLASS_NAME, toCondition, otherProperty, null, tx); + // 分段融导表 + DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION_INFO_TEMP.CLASS_NAME, fromCondition, LC_PROJ_SUBSECTION_INFO.CLASS_NAME, toCondition, otherProperty, null, tx); + // 分段租金计划导表 + DataOperatorUtil.copyJBOSet(LC_SUBSECTION_RENT_PLAN_TEMP.CLASS_NAME, fromCondition, LC_PROJ_SUBSECTION_RENT_PLAN.CLASS_NAME, toCondition, otherProperty, null, tx); } - + //项目表到临时表 public void porjToTemp(String flowunid,String projid,JBOTransaction tx) throws Exception{ - + Map fromCondition=new HashMap(); fromCondition.put("PROJECT_ID", projid); - - + + Map otherProperty=new HashMap(); otherProperty.put("FLOWUNID", flowunid); //商务条件 @@ -153,39 +118,42 @@ public class CalcConditionCopyService { DataOperatorUtil.copyJBOSet(LC_PROJ_SUBSECTION.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION_TEMP.CLASS_NAME, null, otherProperty, null, tx); //前提条件 DataOperatorUtil.copyJBOSet(LC_CONDITION.CLASS_NAME, fromCondition, LC_CONDITION_TEMP.CLASS_NAME, null, otherProperty, null, tx); - + // 分段融导表 + DataOperatorUtil.copyJBOSet(LC_PROJ_SUBSECTION_INFO.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION_INFO_TEMP.CLASS_NAME, null, otherProperty, null, tx); + // 分段租金计划导表 + DataOperatorUtil.copyJBOSet(LC_PROJ_SUBSECTION_RENT_PLAN.CLASS_NAME, fromCondition, LC_SUBSECTION_RENT_PLAN_TEMP.CLASS_NAME, null, otherProperty, null, tx); } //项目表到合同临时表 public void projToContract(String flowunid,String projid,String contractid,JBOTransaction tx) throws Exception{ - - + + BizObject proj=JBOFactory.createBizObjectQuery(LB_PROJECT_INFO.CLASS_NAME,"id=:id").setParameter("id", projid).getSingleResult(false); String project_id=proj.getAttribute("project_no").getString();//项目编号 - - + + Map fromCondition=new HashMap(); fromCondition.put("PROJECT_ID", projid); List list=DataOperatorUtil.getSetJBO(LC_PROJ_CONDITION.CLASS_NAME, fromCondition, tx); - + Map otherProperty=new HashMap(); otherProperty.put("FLOWUNID", flowunid); - + for(BizObject bo:list){ - + String projPlanNumber=bo.getAttribute("PROJECT_PLAN_NUMBER").getString(); - + String contractPlanNumber=projPlanNumber.replace(project_id, contractid); - + fromCondition.clear(); fromCondition.put("PROJECT_ID", projid); fromCondition.put("PROJECT_PLAN_NUMBER", projPlanNumber); - + otherProperty.clear(); otherProperty.put("FLOWUNID", flowunid); otherProperty.put("CONTRACT_PLAN_NUMBER", contractPlanNumber); - + //商务条件 DataOperatorUtil.copyJBOSet(LC_PROJ_CONDITION.CLASS_NAME, fromCondition,LC_CALC_CONDITION_TEMP.CLASS_NAME, null, otherProperty, null, tx); //测算租金规则 @@ -200,28 +168,31 @@ public class CalcConditionCopyService { DataOperatorUtil.copyJBOSet(LC_PROJ_PERIOD.CLASS_NAME, fromCondition, LC_CALC_PERIOD_TEMP.CLASS_NAME, null, otherProperty, null, tx); //分段测算 DataOperatorUtil.copyJBOSet(LC_PROJ_SUBSECTION.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION_TEMP.CLASS_NAME, null, otherProperty, null, tx); + // 分段融导表 + DataOperatorUtil.copyJBOSet(LC_PROJ_SUBSECTION_INFO.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION_INFO_TEMP.CLASS_NAME, null, otherProperty, null, tx); + // 分段租金计划导表 + DataOperatorUtil.copyJBOSet(LC_PROJ_SUBSECTION_RENT_PLAN.CLASS_NAME, fromCondition, LC_SUBSECTION_RENT_PLAN_TEMP.CLASS_NAME, null, otherProperty, null, tx); otherProperty.clear(); otherProperty.put("FLOWUNID", flowunid); otherProperty.put("PLAN_NUMBER", contractPlanNumber); //付款前提 DataOperatorUtil.copyJBOSet(LC_PAY_CONDTION.CLASS_NAME, fromCondition, LC_PAY_CONDTION_TEMP.CLASS_NAME, null, otherProperty, null, tx); - } } //合同层 单次起租 临时 到正式 public void tempToContractOne(String flowunid,String contractid,JBOTransaction tx) throws Exception{ - + BizObject contract=JBOFactory.createBizObjectQuery(LB_CONTRACT_INFO_TEMP.CLASS_NAME,"flowunid=:flowunid").setParameter("flowunid", flowunid).getSingleResult(false); - + String paymentNumber=SerialNumberUtil.getPlannumber(contract.getAttribute("CONTRACT_NO").getString(),"pay_process", tx); - - + + Map fromCondition=new HashMap(); fromCondition.put("FLOWUNID", flowunid); - + Map toCondition=new HashMap(); toCondition.put("contract_id", contractid); - + Map otherProperty=new HashMap(); otherProperty.put("contract_id", contractid); otherProperty.put("PAYMENT_NUMBER", paymentNumber); @@ -239,7 +210,10 @@ public class CalcConditionCopyService { DataOperatorUtil.copyJBOSet(LC_CALC_PERIOD_TEMP.CLASS_NAME, fromCondition, LC_CONTRACT_PERIOD.CLASS_NAME, toCondition, otherProperty, null, tx); //分段测算 DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION_TEMP.CLASS_NAME, fromCondition, LC_CONTRACT_SUBSECTION.CLASS_NAME, toCondition, otherProperty, null, tx); - + // 分段融导表 + DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION_INFO_TEMP.CLASS_NAME, fromCondition, LC_CONTRACT_SUBSECTION_INFO.CLASS_NAME, toCondition, otherProperty, null, tx); + // 分段租金计划导表 + DataOperatorUtil.copyJBOSet(LC_SUBSECTION_RENT_PLAN_TEMP.CLASS_NAME, fromCondition, LC_CONTRACT_SUBSECTION_RENT_PLAN.CLASS_NAME, toCondition, otherProperty, null, tx); //商务条件 DataOperatorUtil.copyJBOSet(LC_CALC_CONDITION_TEMP.CLASS_NAME, fromCondition,LC_CALC_CONDITION.CLASS_NAME, toCondition, otherProperty, null, tx); @@ -255,22 +229,27 @@ public class CalcConditionCopyService { DataOperatorUtil.copyJBOSet(LC_CALC_PERIOD_TEMP.CLASS_NAME, fromCondition, LC_CALC_PERIOD.CLASS_NAME, toCondition, otherProperty, null, tx); //分段测算 DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION_TEMP.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION.CLASS_NAME, toCondition, otherProperty, null, tx); + // 分段融导表 + DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION_INFO_TEMP.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION_INFO.CLASS_NAME, toCondition, otherProperty, null, tx); + // 分段租金计划导表 + DataOperatorUtil.copyJBOSet(LC_SUBSECTION_RENT_PLAN_TEMP.CLASS_NAME, fromCondition, LC_SUBSECTION_RENT_PLAN.CLASS_NAME, toCondition, otherProperty, null, tx); + //付款前提 LeaseFlowBaseService service=new LeaseFlowBaseServiceImp(); service.copyOrLoadPayCondtionInfo(tx, fromCondition,toCondition,otherProperty, ServiceOperatorEnum.TempToFormal,null); - + HandlingApportionManager.setSingleHandlingApportion(flowunid,contractid,paymentNumber,tx); } - + //合同层 多次起租 临时 到正式 public void tempToContractMany(String flowunid,String contractid,JBOTransaction tx) throws Exception{ - + Map fromCondition=new HashMap(); fromCondition.put("FLOWUNID", flowunid); - + Map toCondition=new HashMap(); toCondition.put("contract_id", contractid); - + Map otherProperty=new HashMap(); otherProperty.put("contract_id", contractid); //商务条件 @@ -287,17 +266,22 @@ public class CalcConditionCopyService { DataOperatorUtil.copyJBOSet(LC_CALC_PERIOD_TEMP.CLASS_NAME, fromCondition, LC_CONTRACT_PERIOD.CLASS_NAME, toCondition, otherProperty, null, tx); //分段测算 DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION_TEMP.CLASS_NAME, fromCondition, LC_CONTRACT_SUBSECTION.CLASS_NAME, toCondition, otherProperty, null, tx); + // 分段融导表 + DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION_INFO_TEMP.CLASS_NAME, fromCondition, LC_CONTRACT_SUBSECTION_INFO.CLASS_NAME, toCondition, otherProperty, null, tx); + // 分段租金计划导表 + DataOperatorUtil.copyJBOSet(LC_SUBSECTION_RENT_PLAN_TEMP.CLASS_NAME, fromCondition, LC_CONTRACT_SUBSECTION_RENT_PLAN.CLASS_NAME, toCondition, otherProperty, null, tx); + //付款前提 LeaseFlowBaseService service=new LeaseFlowBaseServiceImp(); service.copyOrLoadPayCondtionInfo(tx, fromCondition,toCondition,otherProperty, ServiceOperatorEnum.TempToFormal,null); } - + //合同正式到临时 public void contractTotemp(String flowunid,String contractid,JBOTransaction tx) throws Exception{ - + Map fromCondition=new HashMap(); fromCondition.put("contract_id", contractid); - + Map otherProperty=new HashMap(); otherProperty.put("FLOWUNID", flowunid); //商务条件 @@ -314,21 +298,26 @@ public class CalcConditionCopyService { DataOperatorUtil.copyJBOSet(LC_CONTRACT_PERIOD.CLASS_NAME, fromCondition, LC_CALC_PERIOD_TEMP.CLASS_NAME, null, otherProperty, null, tx); //分段测算 DataOperatorUtil.copyJBOSet(LC_CONTRACT_SUBSECTION.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION_TEMP.CLASS_NAME, null, otherProperty, null, tx); + // 分段融导表 + DataOperatorUtil.copyJBOSet(LC_CONTRACT_SUBSECTION_INFO.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION_INFO_TEMP.CLASS_NAME, null, otherProperty, null, tx); + // 分段租金计划导表 + DataOperatorUtil.copyJBOSet(LC_CONTRACT_SUBSECTION_RENT_PLAN.CLASS_NAME, fromCondition, LC_SUBSECTION_RENT_PLAN_TEMP.CLASS_NAME, null, otherProperty, null, tx); + } - + //临时到投放 public void tempToPay(String flowunid,String paymentNumber,JBOTransaction tx) throws Exception{ - + BizObject flow=JBOFactory.createBizObjectQuery(FLOW_BUSSINESS_OBJECT.CLASS_NAME,"flow_unid=:flowunid").setParameter("flowunid", flowunid).getSingleResult(false); - + String contractid=flow.getAttribute("contract_id").getString(); - + Map fromCondition=new HashMap(); fromCondition.put("PAYMENT_NUMBER", paymentNumber); fromCondition.put("flowunid", flowunid); Map toCondition=new HashMap(); toCondition.put("PAYMENT_NUMBER", paymentNumber); - + Map otherProperty=new HashMap(); otherProperty.put("contract_id", contractid); //商务条件 @@ -345,15 +334,19 @@ public class CalcConditionCopyService { DataOperatorUtil.copyJBOSet(LC_CALC_PERIOD_TEMP.CLASS_NAME, fromCondition, LC_CALC_PERIOD.CLASS_NAME, toCondition, otherProperty, null, tx); //分段测算 DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION_TEMP.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION.CLASS_NAME, toCondition, otherProperty, null, tx); - + // 分段融导表 + DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION_INFO_TEMP.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION_INFO.CLASS_NAME, toCondition, otherProperty, null, tx); + // 分段租金计划导表 + DataOperatorUtil.copyJBOSet(LC_SUBSECTION_RENT_PLAN_TEMP.CLASS_NAME, fromCondition, LC_SUBSECTION_RENT_PLAN.CLASS_NAME, toCondition, otherProperty, null, tx); + HandlingApportionManager.setHandlingApportion(flowunid,contractid,paymentNumber,tx); } //投放到临时 public void payToTemp(String flowunid,String paymentNumber,JBOTransaction tx) throws Exception{ - + Map fromCondition=new HashMap(); fromCondition.put("PAYMENT_NUMBER", paymentNumber); - + Map otherProperty=new HashMap(); otherProperty.put("FLOWUNID", flowunid); //商务条件 @@ -370,21 +363,24 @@ public class CalcConditionCopyService { DataOperatorUtil.copyJBOSet(LC_CALC_PERIOD.CLASS_NAME, fromCondition, LC_CALC_PERIOD_TEMP.CLASS_NAME, null, otherProperty, null, tx); //分段测算 DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION_TEMP.CLASS_NAME, null, otherProperty, null, tx); - + // 分段融导表 + DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION_INFO.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION_INFO_TEMP.CLASS_NAME, null, otherProperty, null, tx); + // 分段租金计划导表 + DataOperatorUtil.copyJBOSet(LC_SUBSECTION_RENT_PLAN.CLASS_NAME, fromCondition, LC_SUBSECTION_RENT_PLAN_TEMP.CLASS_NAME, null, otherProperty, null, tx); } //临时到起租 public void tempToOnhire(String flowunid,String paymentNumber,String contractid,JBOTransaction tx) throws Exception{ - + Map fromCondition=new HashMap(); fromCondition.put("FLOWUNID", flowunid); fromCondition.put("PAYMENT_NUMBER", paymentNumber); - + Map toCondition=new HashMap(); toCondition.put("PAYMENT_NUMBER", paymentNumber); - + Map otherProperty=new HashMap(); otherProperty.put("contract_id", contractid); - + CalcRentCompare com=new CalcRentCompare(); //商务条件 DataOperatorUtil.copyJBOSet(LC_CALC_CONDITION_TEMP.CLASS_NAME, fromCondition,LC_CALC_CONDITION.CLASS_NAME, toCondition, otherProperty, null, tx); @@ -394,14 +390,18 @@ public class CalcConditionCopyService { DataOperatorUtil.copyJBOSet(LC_FUND_PLAN_TEMP.CLASS_NAME, fromCondition,LC_FUND_PLAN.CLASS_NAME, toCondition, otherProperty, com, tx); //现金流 DataOperatorUtil.copyJBOSet(LC_CASH_FLOW_TEMP.CLASS_NAME, fromCondition, LC_CASH_FLOW.CLASS_NAME, toCondition, otherProperty, null, tx); - + // 分段融导表 + DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION_INFO_TEMP.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION_INFO.CLASS_NAME, toCondition, otherProperty, null, tx); + // 分段租金计划导表 + DataOperatorUtil.copyJBOSet(LC_SUBSECTION_RENT_PLAN_TEMP.CLASS_NAME, fromCondition, LC_SUBSECTION_RENT_PLAN.CLASS_NAME, toCondition, otherProperty, null, tx); + //HandlingApportionManager.setHandlingApportion(flowunid,contractid,paymentNumber,tx); } //起租到临时 public void onhireToTemp(String flowunid,String paymentNumber,JBOTransaction tx) throws Exception{ Map fromCondition=new HashMap(); fromCondition.put("PAYMENT_NUMBER", paymentNumber); - + Map otherProperty=new HashMap(); otherProperty.put("FLOWUNID", flowunid); //商务条件 @@ -418,13 +418,17 @@ public class CalcConditionCopyService { DataOperatorUtil.copyJBOSet(LC_CALC_PERIOD.CLASS_NAME, fromCondition, LC_CALC_PERIOD_TEMP.CLASS_NAME, null, otherProperty, null, tx); //分段测算 DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION_TEMP.CLASS_NAME, null, otherProperty, null, tx); + // 分段融导表 + DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION_INFO.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION_INFO_TEMP.CLASS_NAME, null, otherProperty, null, tx); + // 分段租金计划导表 + DataOperatorUtil.copyJBOSet(LC_SUBSECTION_RENT_PLAN.CLASS_NAME, fromCondition, LC_SUBSECTION_RENT_PLAN_TEMP.CLASS_NAME, null, otherProperty, null, tx); } - + //起租到临时 public void onhireToTempList(String flowunid,String contractid,JBOTransaction tx) throws Exception{ Map fromCondition=new HashMap(); fromCondition.put("contract_id", contractid); - + Map otherProperty=new HashMap(); otherProperty.put("FLOWUNID", flowunid); //商务条件 @@ -450,6 +454,10 @@ public class CalcConditionCopyService { DataOperatorUtil.copyJBOSet(LC_CALC_PERIOD.CLASS_NAME, fromCondition, LC_CALC_PERIOD_TEMP.CLASS_NAME, null, otherProperty, null, tx); //分段测算 DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION_TEMP.CLASS_NAME, null, otherProperty, null, tx); + // 分段融导表 + DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION_INFO.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION_INFO_TEMP.CLASS_NAME, null, otherProperty, null, tx); + // 分段租金计划导表 + DataOperatorUtil.copyJBOSet(LC_SUBSECTION_RENT_PLAN.CLASS_NAME, fromCondition, LC_SUBSECTION_RENT_PLAN_TEMP.CLASS_NAME, null, otherProperty, null, tx); } //租金计划历史 public void onhireToHis(String flowunid,String paymentNumber,JBOTransaction tx) throws Exception{ @@ -463,6 +471,10 @@ public class CalcConditionCopyService { DataOperatorUtil.copyJBOSet(LC_RENT_PLAN.CLASS_NAME, fromCondition,LC_RENT_PLAN_HIS.CLASS_NAME, null, other, null, tx); //现金流 DataOperatorUtil.copyJBOSet(LC_CASH_FLOW.CLASS_NAME, fromCondition, LC_CASH_FLOW_HIS.CLASS_NAME, null, other, null, tx); + // 分段融导表 + DataOperatorUtil.copyJBOSet(LC_CALC_SUBSECTION_INFO.CLASS_NAME, fromCondition, LC_CALC_SUBSECTION_INFO_HIS.CLASS_NAME, null, other, null, tx); + // 分段租金计划导表 + DataOperatorUtil.copyJBOSet(LC_SUBSECTION_RENT_PLAN.CLASS_NAME, fromCondition, LC_SUBSECTION_RENT_PLAN_HIS.CLASS_NAME, null, other, null, tx); } - + } diff --git a/calc/com/tenwa/reckon/util/IrrTools.java b/calc/com/tenwa/reckon/util/IrrTools.java index 1f8138c69..821279350 100644 --- a/calc/com/tenwa/reckon/util/IrrTools.java +++ b/calc/com/tenwa/reckon/util/IrrTools.java @@ -17,7 +17,7 @@ import com.tenwa.reckon.constant.Scale; import com.tenwa.reckon.exception.LeasingException; /** - * + * * @author SHIHONGFEI * @version 1.0 * @copyright (C) TENWA 2011 @@ -27,9 +27,9 @@ import com.tenwa.reckon.exception.LeasingException; public class IrrTools { /** - * + * * ( 根据配置信息构建现金流执行语句,如有其它现金流信息的可在此构建时修改) - * + * * @param cfgb_list * @param tcb * @return @@ -55,9 +55,9 @@ public class IrrTools { } /** - * + * * ( 得到去除重复的时间集合,返回一个含有一个时间,对应他的现金集合的下标的键值对 ,如按天则substring(0, 7)需处理) - * + * * @param ccfbList * @return */ @@ -80,9 +80,9 @@ public class IrrTools { } /** - * + * * ( 根据时间得到新的现金流集合 ) - * + * * @param ht_date 现金流对应日期 * @param cdbList 现金流集合 * @return @@ -106,10 +106,10 @@ public class IrrTools { String quot_id = "";// 报价编号 String contract_id = ""; // 合同号 String plan_date = obj[i].toString();// 日期 - + String fund_in = "0"; // 流入量 String fund_in_details = ""; // 流入量清单 - + String fund_out = "0"; // 流出量 String fund_out_details = ""; // 流出量清单 @@ -152,7 +152,7 @@ public class IrrTools { /** * 根据租金现金流,偿还间隔,租金间隔,年还款次数测算irr - * + * * @param l_inflow_pour所有现金流入流出 * @param chjg偿还间隔 * @param zjjg租金间隔 @@ -235,7 +235,7 @@ public class IrrTools { /** * XIRR计算公式 参数1 l_inflow_pour 是对于的现金流,参数2l_date 是对于的现金流时间 这个需要一一对于.
* 这个算法对于的是EXECL中的XIRR算法.可以用于精确到日的 日IRR计算 - * + * * @param l_inflow_pour * 现金流List * @param l_date @@ -277,9 +277,9 @@ public class IrrTools { } /** - * + * * ( 得到保证金抵扣现金流明细) - * + * * @param rent_list * @param caut_money * @return @@ -321,9 +321,9 @@ public class IrrTools { } /** - * + * * 保证金抵扣金额小于保证金金额 最后要做一笔流出 为保证金金额减去保证金抵扣金额) - * + * * @param cdbList * 现金流 * @param caution_money @@ -352,9 +352,9 @@ public class IrrTools { } /** - * + * * ( 得到预收租金抵扣现金流明细) - * + * * @param rent_list * @param rentbefore_money * @return @@ -400,9 +400,9 @@ public class IrrTools { } /** - * + * * 预收租金抵扣金额小于预收租金金额 最后要做一笔流出 为预收租金金额减去预收租金抵扣金额) - * + * * @param cdbList * 现金流 * @param Column_8 @@ -430,9 +430,9 @@ public class IrrTools { } /** - * + * * ( 得到可以保证金抵扣的租金下标值) - * + * * @param cdbList * @param caut_money * @param d_total @@ -453,10 +453,10 @@ public class IrrTools { int_s = int_s.indexOf(",") > -1 ? int_s.substring(0, int_s.length() - 1) : int_s;// 得到可以抵扣的租金的下标 return int_s; } - + /** - * + * * ( 对最后一项现金流明细进行整理,如有变更的可以重写此方法) * 其他情况 * @param cdbList @@ -471,10 +471,10 @@ public class IrrTools { String planDate = cdb.getPlanDate(); // 日期 (只有年月) String income_number_year = cb.getIncomeNumberYear(); int onhire_id = cdb.getOnhire_id(); - + //起租类型 注意: 期初 数字 1 字符串 period_type_1 #分割线# 期末 数字0 字符串 period_type_0 String periodType = cb.getPeriodType(); - + // 更新流入,净流量值 期末余值 if ( null != equip_end_value && !"".equals(equip_end_value) && Double.parseDouble(equip_end_value) > Double.parseDouble("0.00") ) {// 期末残值大于0时 //‘期末余值’期末情况下的统一处理方式:直接加在最后一期现金流数据中 @@ -484,53 +484,53 @@ public class IrrTools { cdb.setNetFlow(String.valueOf(Double.parseDouble(cdb.getNetFlow()) + Double.parseDouble(equip_end_value))); } } - + //期末购买权在月付双月付情况下在下方单独处理 if (null != nominal_price && !"".equals(nominal_price) && Double.parseDouble(nominal_price) > Double.parseDouble("0.00") && !"income_1".equals(income_number_year) && !"income_2".equals(income_number_year) && !"6".equals(income_number_year) && !"12".equals(income_number_year) || ( "period_type_0".equals(periodType) || "0".equals(periodType) ) ) {// 期末购买权【原名称:名义货价】大于0时 cdb.setFundIn(String.valueOf(Double.parseDouble(cdb.getFundIn()) + Double.parseDouble(nominal_price))); cdb.setFundInDetails(cdb.getFundInDetails() + ";期末购买权:" + NumTools.formatNumberDouble(Double.parseDouble(NumTools.formatNumberDoubleScale(nominal_price, 2))) + ";"); cdb.setNetFlow(String.valueOf(Double.parseDouble(cdb.getNetFlow()) + Double.parseDouble(nominal_price))); } - + // 重新设置此元素的值 cdbList.set(cdbList.size() - 1, cdb); - + // 处理特殊的保证金抵扣 保证金抵扣金额小于保证金金额 最后要做一笔流出 为保证金金额减去保证金抵扣金额 cdbList = IrrTools.getRentDetailsByDeductOut(cdbList, cb.getCautionMoney(), cb.getCautionDeductionMoney()); - + List new_cdbList = new ArrayList(); for (CashDetailsBean obj : cdbList) { new_cdbList.add(obj); } - - - //TODO:sea 期末购买权在月付情况下:最后一期日期加一月作为单独的一行数据,其它情况下:最后一期的日期 + + + //TODO:sea 期末购买权在月付情况下:最后一期日期加一月作为单独的一行数据,其它情况下:最后一期的日期 //2014-06-11 期末余值新的处理逻辑:【符合】‘期末购买权月付/双月付情况’这个前提下, 期初情况的‘期末余值’与‘期末购买权’一致放在新增的一期一起作为最后一期现金流的数据 if(null != nominal_price && !"".equals(nominal_price) && Double.parseDouble(nominal_price) > Double.parseDouble("0.00") && !Tools.isNullOrEmpty(planDate) && ( "income_1".equals(income_number_year) || "12".equals(income_number_year) || "income_2".equals(income_number_year) || "6".equals(income_number_year) ) && ("period_type_1".equals(periodType) || "1".equals(periodType)) ){//月付/双月付情况下 //重新取一次值 CashDetailsBean new_cdb = new CashDetailsBean();//cdbList.get(cdbList.size() - 1); planDate = planDate+"-01";//构建成完整的日期格式 - //2014-01-01 日期加1个月 + //2014-01-01 日期加1个月 planDate = DateTools.getDateAdd(planDate, 1, "mm"); new_cdb.setPlanDate(planDate.substring(0, 7)+"-01"); new_cdb.setFundOut("0"); new_cdb.setFundOutDetails(""); - + new_cdb.setFundIn(String.valueOf(Double.parseDouble(nominal_price) + Double.parseDouble(equip_end_value))); new_cdb.setFundInDetails("期末购买权:" + NumTools.formatNumberDouble(Double.parseDouble(NumTools.formatNumberDoubleScale(nominal_price, 2))) + ";期末余值:" + NumTools.formatNumberDouble(Double.parseDouble(NumTools.formatNumberDoubleScale(equip_end_value, 2)))); new_cdb.setNetFlow( String.valueOf( Double.parseDouble(nominal_price) + Double.parseDouble(equip_end_value) ) ); - + new_cdb.setOnhire_id( onhire_id + 1 );//现金流按固定格式补0情况下,所以这里月付情况下,直接最后一次变量加1做为最终的期末购买权排序依据 new_cdbList.add(new_cdb); }else{ - + //TODO:2014-06-11 期末余值新的处理逻辑:【不符合】‘期末购买权月付情况’这个前提下, 期初情况的‘期末余值’与‘期末购买权’一致放在新增的一期一起作为最后一期现金流的数据 //TODO:这里存在少处理不是月付情况,例如:季付情况下,‘期末余值’是不是不能直接最后一期加一个月,是加一个租赁间隔,是加一个季度三个月,中间需要补两个0 if( !Tools.isNullOrEmpty(planDate) && null != equip_end_value && !"".equals(equip_end_value) && Double.parseDouble(equip_end_value) > Double.parseDouble("0.00") && ("period_type_1".equals(periodType) || "1".equals(periodType)) ){// 期初 //重新取一次值 CashDetailsBean new_cdb = new CashDetailsBean();//cdbList.get(cdbList.size() - 1); planDate = planDate+"-01";//构建成完整的日期格式 - //2014-01-01 日期加1个月 + //2014-01-01 日期加1个月 planDate = DateTools.getDateAdd(planDate, 1, "mm"); new_cdb.setPlanDate(planDate.substring(0, 7)+"-01"); new_cdb.setFundOut("0"); @@ -541,13 +541,13 @@ public class IrrTools { new_cdb.setOnhire_id( onhire_id + 1 );//现金流按固定格式补0情况下,所以这里月付情况下,直接最后一次变量加1做为最终的期末购买权排序依据 new_cdbList.add(new_cdb); } - + } - + return new_cdbList; } - + /** *

对最后一项现金流明细进行整理,针对项目类型为‘VP业务’情况下,期末购买权不计算入最后一期现金流中。

* @author sea @@ -562,31 +562,31 @@ public class IrrTools { // 更新流入,净流量值 if (null != equip_end_value && !"".equals(equip_end_value) && Double.parseDouble(equip_end_value) > 0) {// 期末残值大于0时 cdb.setFundIn(String.valueOf(Double.parseDouble(cdb.getFundIn()) + Double.parseDouble(equip_end_value))); - + cdb.setFundInDetails(cdb.getFundInDetails() + ";期末余值:" + NumTools.formatNumberDouble(Double.parseDouble(NumTools.formatNumberDoubleScale(equip_end_value, 2)))); - + cdb.setNetFlow(String.valueOf(Double.parseDouble(cdb.getNetFlow()) + Double.parseDouble(equip_end_value))); } - + if (null != nominal_price && !"".equals(nominal_price) && Double.parseDouble(nominal_price) > 0) {// 期末购买权【原名称:名义货价】大于0时 cdb.setFundIn(String.valueOf(Double.parseDouble(cdb.getFundIn()) + Double.parseDouble(nominal_price))); //项目类型为‘VP业务’情况下,期末购买权不算入流入中 cdb.setFundInDetails( cdb.getFundInDetails() ); cdb.setNetFlow( cdb.getNetFlow() ); } - + // 重新设置此元素的值 cdbList.set(cdbList.size() - 1, cdb); - + // 2011-10-26 // 处理特殊的保证金抵扣 保证金抵扣金额小于保证金金额 最后要做一笔流出 为保证金金额减去保证金抵扣金额 cdbList = IrrTools.getRentDetailsByDeductOut(cdbList, cb.getCautionMoney(), cb.getCautionDeductionMoney()); - + return cdbList; - + } /** - * + * * ( 现金流明细构建) * 按月计算IRR * @param cdbList @@ -595,7 +595,7 @@ public class IrrTools { public static String getIrr(List cdbList) { // 得到租金列表 List rent_list = getRentListByCashDetails(cdbList); - /* + /* * 后三个参数为固定按月计算 * @param chjg 固定值1 * @param zjjg 固定值1 @@ -606,7 +606,7 @@ public class IrrTools { } /** - * + * * @Title: getIrr * @author zhangc * @Description: 牛顿分切法计算XIRR @@ -624,7 +624,7 @@ public class IrrTools { return IrrTools.getXIRR(rent_list, planDate_list).toString(); //return IrrTools.getIRR(rent_list, "1","1","12"); } - + public static String getIrrNew( List netList,List dateList,String process) throws Exception { // 得到租金列表 //List rent_list = getRentListByCashDetails(cashlist,process); @@ -634,9 +634,9 @@ public class IrrTools { //return IrrTools.getIRR(rent_list, "1","1","12"); } /** - * + * * ( 现金流明细构建) - * + * * @param cdbList * @param cb * @return @@ -651,9 +651,9 @@ public class IrrTools { } /** - * + * * ( 现金流明细构建) - * + * * @param cdbList * @param cb * @return @@ -668,9 +668,9 @@ public class IrrTools { } /** - * + * * ( 根据现金流明细得到新的租金列表,用于算irr值) - * + * * @param cdbList */ private static List getRentListByCashDetails(List cdbList) { @@ -680,7 +680,7 @@ public class IrrTools { } return rent_list; } - + private static List getRentListByCashDetails(List cdbList,String process) throws Exception { List rent_list = new ArrayList(); for (Object cdb : cdbList) { @@ -691,12 +691,12 @@ public class IrrTools { }else{ rent_list.add(((ContractCashDetailTemp)cdb).getNetFlow().toString()); }*/ - + rent_list.add(((BizObject)cdb).getAttribute("NET_FLOW").getString()); } return rent_list; } - + private static List getRentListByCashDetailsPlanDate(List cdbList,String process) throws Exception { List rent_list = new ArrayList(); for (Object cdb : cdbList) { @@ -706,9 +706,9 @@ public class IrrTools { } /** - * + * * ( 算出均息法下的均息法租金列表的irr,并把其当做年利率传递做第二次正常租金测算) - * + * * @param cb * 交易结构bean * @param frpb @@ -734,7 +734,7 @@ public class IrrTools { } else { l_inflow_pour.add("-" + leasing_money); } - + for (int i = grace; i < rent_list.size(); i++) { l_inflow_pour.add(rent_list.get(i).toString()); } @@ -745,16 +745,16 @@ public class IrrTools { l_inflow_pour.set(l_inflow_pour.size()-1, new BigDecimal(l_inflow_pour.get(l_inflow_pour.size()-1)).add(new BigDecimal(cb.getEquipEndValue())).toString()); } } - + irr = IrrTools.getIRR(l_inflow_pour, String.valueOf(12 / Integer.parseInt(cb.getIncomeNumberYear())), String.valueOf(12 / Integer.parseInt(cb.getIncomeNumberYear())), cb.getIncomeNumberYear()); irr = Double.parseDouble(irr) + ""; return irr; } /** - * + * * (根据现金流获得对应的年利率) - * + * * @param alCash * 现金流 用HashMap key为net_flow 存的每期的值 * @param income_number_year @@ -770,7 +770,7 @@ public class IrrTools { } return NumTools.formatNumberDoubleScale(Double.parseDouble(getIRR(alirr, "1", "1", income_number_year)) * 100 + "", 6); } - + /** *

根据原始现金流集合按固定模式补0构建成独特格式的现金流。

* @author sea @@ -784,26 +784,26 @@ public class IrrTools { List list = new ArrayList(); List cashList = new ArrayList(); // 期初(期末)支付 注意: 期初 数字 1 字符串 period_type_1 #分割线# 期末 数字0 字符串 period_type_0 - String periodType = cb.getPeriodType(); + String periodType = cb.getPeriodType(); if (ccfbList != null && ccfbList.size() > 0 && ccfbList.size() > size) {//现金流的长度如果小于2条,该方法不适用,特别是期初情况下,理论上现金流只存在一行数据了 - + //第0期现金流集合 CashDetailsBean objFirst = new CashDetailsBean(); objFirst = ccfbList.get(0);//默认第0期的值等于原始现金流的第0期 - - double firstIn = 0.00; - double firstOut = 0.00; + + double firstIn = 0.00; + double firstOut = 0.00; String firstFundInDetails = ""; String firstFundOutDetails = ""; for (int i = 0; i < size; i++) { CashDetailsBean oneObj = ccfbList.get(i); //第i期流入流出 - firstIn = firstIn + NumberUtils.parseDouble( NumberUtils.nullToZero( oneObj.getFundIn() ) ); - firstOut = firstOut + NumberUtils.parseDouble( NumberUtils.nullToZero( oneObj.getFundOut() ) ); + firstIn = firstIn + NumberUtils.parseDouble( NumberUtils.nullToZero( oneObj.getFundIn() ) ); + firstOut = firstOut + NumberUtils.parseDouble( NumberUtils.nullToZero( oneObj.getFundOut() ) ); firstFundInDetails = firstFundInDetails +oneObj.getFundInDetails(); firstFundOutDetails = firstFundOutDetails+oneObj.getFundOutDetails(); } - + //期初前收情况下:做合并处理 if("1".equals(periodType) || "period_type_1".equals(periodType)){ //封装新的第0期 @@ -816,7 +816,7 @@ public class IrrTools { objFirst.setNetFlow(NumberUtils.doubleToString( firstIn + firstRent - firstOut ) ); objFirst.setOnhire_id(1000); cashList.add(objFirst); - + //封装后续所有现金流 int key = 2; int onhire_id = 1000; @@ -868,7 +868,7 @@ public class IrrTools { } return cashList; } - + /** *

计算固定格式情况现金流补0个数。

* @author sea @@ -894,7 +894,7 @@ public class IrrTools { } return num; } - + /** *

生成补0的现金流对象。

* @author sea @@ -915,14 +915,14 @@ public class IrrTools { newObj.setOnhire_id(onhire_id); return newObj; } - - + + /** * 牛顿迭代法求IRR * @param cashList:现金流List * @return IRR */ - public BigDecimal getIRR(List cashList){ + public static BigDecimal getIRR(List cashList){ //long startTime = System.currentTimeMillis(); BigDecimal diff = BigDecimal.ONE; //租金现值总和与总本金的差值 BigDecimal irr = BigDecimal.ZERO; @@ -970,7 +970,7 @@ public class IrrTools { BigDecimal daoRate=BigDecimal.ZERO; // 1/(1+irr) BigDecimal netflowNow; //净流量现值 BigDecimal error = new BigDecimal("0.0000000001"); //误差 - int size = cashList.size(); //现金流大小 + int size = cashList.size(); //现金流大小 int j = 0; //迭代次数 double k = 0; String startDate = ""; @@ -990,7 +990,7 @@ public class IrrTools { }catch(Exception e){ e.printStackTrace(); } - + } j++; irr = irr.subtract(diff.divide(derivative, 20, BigDecimal.ROUND_HALF_UP)); //迭代关系式