package com.tenwa.reckon.check; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import jbo.app.tenwa.calc.LC_CALC_CONDITION; import jbo.app.tenwa.calc.LC_CONTRACT_CONDITION; import jbo.com.tenwa.entity.comm.flow.FLOW_BUSSINESS_OBJECT; import jbo.sys.CODE_LIBRARY; import com.amarsoft.app.awe.config.InitDBType; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.JBOException; import com.amarsoft.are.jbo.JBOFactory; public class PaymentPlanCheck { public static String paymentPlanCheck(BizObject condition) throws Exception{ List message=new ArrayList(); String flowunid=condition.getAttribute("flowunid").getString();//流程编号 BizObject flow=JBOFactory.createBizObjectQuery(FLOW_BUSSINESS_OBJECT.CLASS_NAME,"flow_unid=:flowunid").setParameter("flowunid", flowunid).getSingleResult(false); String contractid=flow.getAttribute("contract_id").getString(); List contractCondition=JBOFactory.createBizObjectQuery(LC_CONTRACT_CONDITION.CLASS_NAME,"contract_id=:contractid").setParameter("contractid", contractid).getResultList(false); List paymentCondition=JBOFactory.createBizObjectQuery(LC_CALC_CONDITION.CLASS_NAME,"contract_id=:contractid and payment_number<>'"+condition.getAttribute("payment_number").getString()+"'").setParameter("contractid", contractid).getResultList(false); //费用项 String sql="codeno='FeeType' and relativecode is not null and relativecode<>''"; if("ORACLE".equals(InitDBType.DBTYPE)){ sql="codeno='FeeType' and relativecode is not null"; } List feeList=JBOFactory.createBizObjectQuery(CODE_LIBRARY.CLASS_NAME,sql).getResultList(false); //费用金额 比费用项多一个融资金额 List contractFee=new ArrayList();// List paymentFee=new ArrayList(); for(int i=0;i<=feeList.size();i++){ contractFee.add(BigDecimal.ZERO); paymentFee.add(BigDecimal.ZERO); } for(int i=0;i=0;i--){ BigDecimal money=BigDecimal.ZERO; String feeName=""; if(i==feeList.size()){ money=new BigDecimal(condition.getAttribute("CLEAN_LEASE_MONEY").getDouble()); feeName="融资额"; if(contractFee.get(i).compareTo(paymentFee.get(i).add(money))==0){ boolean1=true; } }else{ money=new BigDecimal(condition.getAttribute(feeList.get(i).getAttribute("relativecode").getString()).getDouble()); feeName=feeList.get(i).getAttribute("itemname").getString(); } if(boolean1){ if(contractFee.get(i).compareTo(paymentFee.get(i).add(money))!=0){ if(i==feeList.size()){ }else{ message.add("投放计划"+feeName+"应等于合同"+feeName+"(合同"+feeName+":"+contractFee.get(i)+",投放计划"+feeName+":"+paymentFee.get(i)+",剩余"+feeName+":"+contractFee.get(i).subtract(paymentFee.get(i))+",本次投放"+feeName+":"+money+")"); } } }else if(contractFee.get(i).compareTo(paymentFee.get(i).add(money))<0){ if(i==feeList.size()){ message.add("投放计划融资额已超出合同融资额(合同融资额:"+contractFee.get(i)+",投放计划融资额:"+paymentFee.get(i)+",剩余融资额:"+contractFee.get(i).subtract(paymentFee.get(i))+",本次投放融资额:"+money+")"); }else{ message.add("投放计划"+feeName+"已超出合同"+feeName+"(合同"+feeName+":"+contractFee.get(i)+",投放计划"+feeName+":"+paymentFee.get(i)+",剩余"+feeName+":"+contractFee.get(i).subtract(paymentFee.get(i))+",本次投放"+feeName+":"+money+")"); } } } if(boolean1&&message.size()>0){ message.add(0, "合同所有融资已在本次投放完毕,所有投放方案资金项总和应等于合同资金项总和"); } return message.toString(); } }