apzl_leasing/calc/com/tenwa/reckon/check/PaymentPlanCheck.java
2018-06-03 22:26:41 +08:00

102 lines
4.4 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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<String> message=new ArrayList<String>();
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<BizObject> contractCondition=JBOFactory.createBizObjectQuery(LC_CONTRACT_CONDITION.CLASS_NAME,"contract_id=:contractid").setParameter("contractid", contractid).getResultList(false);
List<BizObject> 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<BizObject> feeList=JBOFactory.createBizObjectQuery(CODE_LIBRARY.CLASS_NAME,sql).getResultList(false);
//费用金额 比费用项多一个融资金额
List<BigDecimal> contractFee=new ArrayList<BigDecimal>();//
List<BigDecimal> paymentFee=new ArrayList<BigDecimal>();
for(int i=0;i<=feeList.size();i++){
contractFee.add(BigDecimal.ZERO);
paymentFee.add(BigDecimal.ZERO);
}
for(int i=0;i<feeList.size();i++){
//合同所有方案
for(BizObject c:contractCondition){
contractFee.set(i,contractFee.get(i).add(new BigDecimal(c.getAttribute(feeList.get(i).getAttribute("relativecode").getString()).getDouble())));
if(i==feeList.size()-1){
contractFee.set(i+1,contractFee.get(i+1).add(new BigDecimal(c.getAttribute("CLEAN_LEASE_MONEY").getDouble())));
}
}
//合同所有投放方案
for(BizObject c:paymentCondition){
paymentFee.set(i,paymentFee.get(i).add(new BigDecimal(c.getAttribute(feeList.get(i).getAttribute("relativecode").getString()).getDouble())));
if(i==feeList.size()-1){
paymentFee.set(i+1,paymentFee.get(i+1).add(new BigDecimal(c.getAttribute("CLEAN_LEASE_MONEY").getDouble())));
}
}
}
Boolean boolean1=false;//判断融资额是否全额
for(int i=contractFee.size()-1;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();
}
}