补充自动测算先决条件

This commit is contained in:
zhulh 2019-08-15 12:01:38 +08:00
parent 662a1f9b27
commit 815317cec8

View File

@ -2,6 +2,8 @@ package com.tenwa.lease.flow.project.commbusiness;
import com.amarsoft.app.als.sys.tools.DateUtil;
import com.amarsoft.app.util.ProductParamUtil;
import com.tenwa.util.SerialNumberUtil;
import jbo.app.tenwa.calc.LC_CALC_CONDITION_TEMP;
@ -35,10 +37,9 @@ import jbo.sys.PF_CALC_CONDITION;
import jbo.sys.PF_CUSTOMER_ACCOUNT;
import jbo.sys.PF_GUARANTEE_UNIT;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
@ -55,6 +56,8 @@ import com.tenwa.flow.baseBussion.BaseBussiness;
import com.tenwa.flow.util.FlowUtil;
import com.tenwa.reckon.executor.CreateTransactionExecutor;
import com.tenwa.reckon.product.ProductCondition;
import org.apache.commons.lang3.time.DateUtils;
/**
* 项目基本信息初始化
* @author 我是周亚辉
@ -233,19 +236,30 @@ public class LBProjectIntoTempInitCarBusiness extends BaseBussiness {
otherProperty.put("FLOWUNID",this.getAttribute("FlowUnid").toString());
String planNumber = SerialNumberUtil.getPlannumber(this.getAttribute("ProjectNo").toString(), calType, tx );
otherProperty.put("PROJECT_PLAN_NUMBER", planNumber);
ASObjectModel doTemp = new ASObjectModel("LoanSimulationBasicInfo");
/*设置模板属性*/
Vector<ValidateRule> vali=new Vector<ValidateRule>();
//费用规则
ProductCondition pc=new ProductCondition();
String calcRules=pc.getProductRules(doTemp, this.getAttribute("ProductId").toString(),vali);
// TO DO 补上商务条件剩余信息
BizObject fcc = DataOperatorUtil.getSingleJBO( PF_CALC_CONDITION.CLASS_NAME, fromCondtion, tx );
String productId = this.getAttribute( "ProductId" ).toString();
// 净融资额
setCleanLeaseMoney( otherProperty, productId, fcc );
// 调息方式
setProductAdjustRules( otherProperty, productId );
// 投放日
String today = DateUtil.getToday();
otherProperty.put( "LEASE_AMT_DATE", today );
otherProperty.put( "START_DATE", today );
// 租金推算方式
otherProperty.put( "RENT_OR_RATE", "rate" );
// 设置年利率
setYearRate( otherProperty, productId );
// 设置还款间隔
setIncomeNubmer( otherProperty, productId, fcc );
// 计算第一第二期租金支付日
setFirstSecondPlan( otherProperty, productId, fcc );
DataOperatorUtil.copyJBOSet(PF_CALC_CONDITION.CLASS_NAME,fromCondtion,LC_CALC_CONDITION_TEMP.CLASS_NAME,null,otherProperty,null,tx);
System.out.println( "=====================" + flowunid + "====================" );
// 自动测算
autoCalc( flowunid, calType, planNumber, this.getAttribute("ProductId").toString(), tx );
autoCalc( flowunid, calType, planNumber, productId, tx );
}
}
String sMessage="true";
@ -261,6 +275,73 @@ public class LBProjectIntoTempInitCarBusiness extends BaseBussiness {
cte.runTrans( tx );
}
public void setCleanLeaseMoney( Map<String, String> otherProperty, String productId, BizObject fcc ) throws Exception {
String equipAmt = fcc.getAttribute( "EQUIP_AMT" ).toString();
String firstPayment = fcc.getAttribute( "FIRST_PAYMENT" ).toString();
String gpsFee = fcc.getAttribute( "GPS_FEE" ).toString();
BigDecimal financingMoney = BigDecimal.ZERO;
financingMoney = financingMoney.add( new BigDecimal( "".equals( gpsFee ) ? "0" : gpsFee ) );
// TODO 补充其他融资项
otherProperty.put( "CLEAN_LEASE_MONEY",
new BigDecimal( "".equals( equipAmt ) ? "0" : equipAmt ).subtract(
new BigDecimal( "".equals( firstPayment ) ? "0" : firstPayment ) ).add( financingMoney ).toString() );
}
public void setProductAdjustRules( Map<String, String> otherProperty, String productId ) throws Exception {
Map<String,Map<String,String>> map = ProductParamUtil.getProductComponentType( productId, "PRD0320" );
if ( map.containsKey( "ADJUST_INTEREST" ) ){
Map<String,String> rule=map.get( "ADJUST_INTEREST" );
if ( null != rule.get( "rate_float_type" ) && null != rule.get( "adjust_style" ) ) {
//调息方式
otherProperty.put( "ADJUST_TYPE", rule.get("rate_float_type") );
otherProperty.put( "ADJUST_STYLE", rule.get("adjust_style") );
}
}
}
public void setFirstSecondPlan( Map<String, String> otherProperty, String productId, BizObject fcc ) throws Exception {
String periodType = otherProperty.get( "PERIOD_TYPE" );
String leaseAmtDate = otherProperty.get( "LEASE_AMT_DATE" );
String incomeIntervalMonth = otherProperty.get( "INCOME_INTERVAL_MONTH" );
String defaultDueDay = fcc.getAttribute( "DefaultDueDay" ).toString();
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy/MM/dd" );
Date lad = sdf.parse( leaseAmtDate );
lad = DateUtils.setDays( lad, Integer.parseInt( defaultDueDay ) );
String firstPlanDate = "";
String secondPlanDate = "";
if ( "period_type_1".equals( periodType ) ) {
firstPlanDate = leaseAmtDate;
secondPlanDate = sdf.format( DateUtils.addMonths( lad, Integer.parseInt( incomeIntervalMonth ) ) );
} else {
firstPlanDate = sdf.format( DateUtils.addMonths( lad, Integer.parseInt( incomeIntervalMonth ) ) );
secondPlanDate = sdf.format( DateUtils.addMonths( lad, Integer.parseInt( incomeIntervalMonth ) * 2 ) );
}
otherProperty.put( "FIRST_PLAN_DATE", firstPlanDate );
otherProperty.put( "SECOND_PLAN_DATE", secondPlanDate );
}
public void setIncomeNubmer( Map<String, String> otherProperty, String productId, BizObject fcc ) throws Exception {
otherProperty.put( "INCOME_NUMBER_YEAR", "income_12" );
String incomeIntervalMonth = "1";
otherProperty.put( "INCOME_INTERVAL_MONTH", incomeIntervalMonth );
String incomeNumber = fcc.getAttribute( "INCOME_NUMBER" ).toString();
otherProperty.put( "LEASE_TERM", Integer.parseInt( incomeNumber ) * Integer.parseInt( incomeIntervalMonth ) + "" );
}
public void setYearRate( Map<String, String> otherProperty, String productId ) throws Exception {
Map<String, Map<String, String>> productRates = ProductParamUtil.getProductComponentType( productId, "PRD0350" );
Map<String, String> productRate = productRates.get( "product_rate" );
String periodType = ProductParamUtil.getProductParameterValue( productId, "PRD0350", "period_type", "begin_end" );
periodType = periodType == null ? "period_type_0" : periodType;
otherProperty.put( "PERIOD_TYPE", periodType );
if ( productRate != null ) {
String yearRate = productRate.get("ProductRate") == null ? "0" : productRate.get("ProductRate");
otherProperty.put( "YEAR_RATE", yearRate );
}
}
private BizObject saveCustomerInfo(BizObjectManager bomCI,JBOTransaction tx,ASUser asUser,String distributoIid)throws JBOException{
BizObject bmC = bomCI.newObject();//保存客户信息
try {