package com.tenwa.reckon.executor; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import com.amarsoft.app.als.sys.tools.Tools; import com.amarsoft.app.awe.config.InitDBType; import com.amarsoft.app.util.ProductParamUtil; import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; import com.amarsoft.awe.util.SqlObject; import com.amarsoft.awe.util.Transaction; import com.tenwa.comm.util.jboutil.DataOperatorUtil; import com.tenwa.reckon.bean.ConditionBean; import com.tenwa.reckon.bean.TabCalBean; import com.tenwa.reckon.util.DateUtils; import com.tenwa.reckon.util.IRRCalculateUtil; import com.tenwa.reckon.util.IrrTools; public class CashFlowExecutor { private JBOTransaction tx; public CashFlowExecutor(JBOTransaction tx){ this.tx=tx; } public String run(ConditionBean cb , TabCalBean tcb) throws Exception{ this.delete(tcb, cb); this.add(cb, tcb); String irr = this.getIrr(cb,tcb); cb.setIrr(irr); return irr; } private String getIrr(ConditionBean cb ,TabCalBean tcb) throws Exception{ String cashSql = "select NET_FLOW,PLAN_DATE from "+Tools.getTable(tcb.getContractCashTb())+" where flowunid ='"+tcb.getDocId()+"' and "+tcb.getPlanCName()+"='"+tcb.getPlanCValue()+"' order by plan_date"; List> cashes =DataOperatorUtil.getDataBySql(tx, cashSql, null); List netList = new ArrayList(); List dateList = new ArrayList(); for(Map cash :cashes){ netList.add(cash.get("NET_FLOW")); dateList.add(cash.get("PLAN_DATE")); } String irr=""; if("STAGE_IRR".equals(cb.getIrrType())){//按期IRR BigDecimal issueRate=IRRCalculateUtil.getIRR2(netList); irr=issueRate.multiply(new BigDecimal(1200/cb.getIncomeIntervalMonth())).setScale(6,BigDecimal.ROUND_HALF_UP).toString(); }else if("MONTH_IRR".equals(cb.getIrrType())){//按月IRR String upperListDate=""; List newNetList=new ArrayList(); List newDateList=new ArrayList(); for(int i=0;i inflowPour=new ArrayList(); String plandate=""; for(int i=0;i1){ for(int y=1;y> productCashInIRRList = ProductParamUtil.getProductComponentType(productId, "PRD0315"); Set>> entry = productCashInIRRList.entrySet(); for(Entry> e : entry){ Map parameMap = e.getValue(); boolean flag = false; if("N".equals(parameMap.get("CostType10"))){ flag = true; } if(flag){ sql +=" and tdd.relativecode<>'"+e.getKey()+"' "; } } } //sql +=" and fundplan."+tcb.getContOrProjCName()+" = '"+tcb.getContOrProjCValue()+"'" ; sql +=" )t group by t.plan_date "; Transaction Sqlca =null; Sqlca = Transaction.createTransaction(tx); SqlObject asql = new SqlObject(sql); Sqlca.executeSQL(asql); } }