diff --git a/calc/com/tenwa/reckon/executor/CashFlowExecutor.java b/calc/com/tenwa/reckon/executor/CashFlowExecutor.java index 187de77c6..afa7aa61d 100644 --- a/calc/com/tenwa/reckon/executor/CashFlowExecutor.java +++ b/calc/com/tenwa/reckon/executor/CashFlowExecutor.java @@ -145,7 +145,7 @@ public class CashFlowExecutor { sql +=" if(fundplan.pay_type='pay_type_in',fundplan.plan_money,-fundplan.plan_money) cleanfow " ; sql +=" from "+Tools.getTable(tcb.getFundFundPlan_tb())+" fundplan " ; sql +=" left join code_library tdd on fundplan.fee_type = tdd.itemno and tdd.codeno='FeeType' " ; - sql +=" where fundplan.flowunid = '"+ tcb.getDocId()+"' and fundplan."+tcb.getPlanCName()+"='"+tcb.getPlanCValue()+"' and fundplan.fee_type in ('feetype2','feetype1','feetype10','feetype16','feetype17','feetype33') "; + sql +=" where fundplan.flowunid = '"+ tcb.getDocId()+"' and fundplan."+tcb.getPlanCName()+"='"+tcb.getPlanCValue()+"' and fundplan.fee_type in ('feetype2','feetype1','feetype10','feetype16','feetype17','feetype33','feetype24') "; //根据客户(张文竹)不管是否灵活产品,配置的GPS差额和个人意外险差额添加到IRR计算 if( !"0".equals(personalInsuranceDifference) ){ sql +=" union all select plan_date,'"+personalInsuranceDifference+"' flowin,'个人意外险差额:"+personalInsuranceDifference+"' flowindetail,'' flowout,'' flowoutdetil,'"+personalInsuranceDifference+"' cleanfow from lc_fund_plan_temp where flowunid = '"+tcb.getDocId()+"' and fee_type='feetype10' "; diff --git a/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java b/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java index 330cbe4b8..8a452effd 100644 --- a/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java +++ b/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java @@ -183,18 +183,25 @@ public class CreateTransactionExecutor implements Transaction { */ @Override public void runTrans( JBOTransaction tx ) throws Exception { + //获取产品类型 + com.amarsoft.awe.util.Transaction Sqlca = com.amarsoft.awe.util.Transaction.createTransaction(tx); JSONObject jsonObject = JSONObject.createObject(); TabCalBean bean = TbBeanTools.getTabInfoTrans( calType, flowunid, plannumber, productId, tx ); this.deletePayCondition(this.getFlowunid(),bean.getPlanCName(), bean.getPlanCValue(), tx); DictTools.setYearRate(bean); + ASResultSet rs = Sqlca.getASResultSet(new SqlObject("select attribute2, attribute5 from business_type where typeno='"+productId+"'")); + String productType = ""; + if ( rs.next() ) { + productType = rs.getString( "attribute2" ); + bean.getCb().setFlexible( rs.getString( "attribute5" ) ); + } String yearRate = bean.getCb().getYearRate(); this.preHandle(bean.getCb(),bean); + checkYearRate( bean.getCb(), bean, new BigDecimal( bean.getCb().getYearRate() ) ); if(bean.getCb().getRentOrRate().equals("rent")&&new BigDecimal(bean.getCb().getIncomeNumber()).multiply(new BigDecimal(bean.getCb().getRentValue())).compareTo(new BigDecimal(bean.getCb().getCleanLeaseMoney()))<0){ throw new BusinessException("按租金算年利率租金总和必须大于融资额"); } - //获取产品类型 - com.amarsoft.awe.util.Transaction Sqlca = com.amarsoft.awe.util.Transaction.createTransaction(tx); - String productType = Sqlca.getString(new SqlObject("select attribute2 from business_type where typeno='"+productId+"'")); +// String productType = Sqlca.getString(new SqlObject("select attribute2 from business_type where typeno='"+productId+"'")); bean.setProductType(productType); bean.getCb().setProductType(productType); jsonObject.appendElement("year_rate", yearRate); diff --git a/calc/com/tenwa/reckon/help/CalculationLogUtil.java b/calc/com/tenwa/reckon/help/CalculationLogUtil.java new file mode 100644 index 000000000..fb6bc6b28 --- /dev/null +++ b/calc/com/tenwa/reckon/help/CalculationLogUtil.java @@ -0,0 +1,74 @@ +package com.tenwa.reckon.help; + +import java.util.List; +import java.util.Map; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.amarsoft.are.ARE; +import com.amarsoft.are.jbo.JBOException; +import com.amarsoft.are.log.Log; +import com.amarsoft.are.util.StringFunction; +import com.amarsoft.awe.util.SqlObject; +import com.amarsoft.awe.util.Transaction; +import com.tenwa.comm.exception.BusinessException; +import com.tenwa.comm.util.jboutil.DataOperatorUtil; +import com.tenwa.reckon.util.DateUtil; +import com.tenwa.reckon.util.UUIDUtil; + +public class CalculationLogUtil { + private static Log logger=ARE.getLog(); + + public static void insertCalculationFailLog(String flow_unid,String message,String message_position) { + Transaction tran = Transaction.createTransaction("als"); + try { + String project_no = ""; + String application_no = ""; + List> pslData = DataOperatorUtil.getDataBySql("SELECT project_no,application_no FROM lb_project_info_temp WHERE flowunid='"+flow_unid+"'"); + if(pslData != null && pslData.size() > 0){ + project_no = pslData.get(0).get("project_no") == null ? "" : pslData.get(0).get("project_no"); + application_no = pslData.get(0).get("application_no") == null ? "" : pslData.get(0).get("application_no"); + } + String sql = "INSERT INTO lb_calculation_fail_log (id,project_no,flow_unid,application_no,message,inputtime,message_position) VALUES" + + " ('"+UUIDUtil.getUUID()+"','"+project_no+"','"+flow_unid+"','"+application_no+"','"+message+"','"+DateUtil.getSystemTimeByFormat("yyyy/MM/dd HH:mm:ss")+"','"+message_position+"') "; + SqlObject so = new SqlObject(""); + so.setOriginalSql(sql); + tran.executeSQL(so); + tran.commit(); + } catch (Exception e) { + logger.info(e.getMessage()); + logger.info("新增测算日志失败"); + e.printStackTrace(); + try { + if(tran != null) + tran.rollback(); + } catch (JBOException e1) { + e1.printStackTrace(); + } + }finally{ + try { + if(tran != null){ + tran.disConnect(); + } + } catch (JBOException e) { + e.printStackTrace(); + } + } + } + public static void main(String[] args) { + try { + int a = 10 ; + int b = 0 ; + System.out.println(a/b); + + throw new BusinessException( "ROA小于产品配置!" ); + }catch(Exception e ){ + e.getStackTrace(); + + Object json = JSON.toJSON(e.getStackTrace()); + System.out.println(json.toString()); + System.out.println(e.toString()); + } + } +} diff --git a/calc/com/tenwa/reckon/help/ConditionHelper.java b/calc/com/tenwa/reckon/help/ConditionHelper.java index 25e6a8c10..c03c9c91c 100644 --- a/calc/com/tenwa/reckon/help/ConditionHelper.java +++ b/calc/com/tenwa/reckon/help/ConditionHelper.java @@ -1,11 +1,11 @@ package com.tenwa.reckon.help; import java.math.BigDecimal; -import java.math.BigInteger; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.alibaba.fastjson.JSON; import com.amarsoft.app.als.sys.tools.Tools; import com.amarsoft.app.util.ProductParamUtil; import com.amarsoft.are.jbo.BizObject; @@ -13,7 +13,6 @@ import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; import com.amarsoft.are.util.json.JSONObject; -import com.amarsoft.awe.util.SqlObject; import com.tenwa.comm.exception.BusinessException; import com.tenwa.comm.util.jboutil.DataOperatorUtil; import com.tenwa.reckon.bean.ConditionBean; @@ -98,6 +97,7 @@ public class ConditionHelper { if(irrMin == null || irrMin.isEmpty() || irrMan == null || irrMan.isEmpty()){ throw new BusinessException( "灵活产品IRR区间值必须配置,请联业务人员!" ); } + System.out.println("IRR:"+irr); if( !( irr.compareTo( new BigDecimal( irrMan ) ) <= 0 && irr.compareTo( new BigDecimal( irrMin ) ) >= 0 ) ){ // throw new BusinessException( "IRR: "+irr.setScale( 2, 4 ).toString()+",不在产品配置区间范围内!" ); throw new BusinessException( "不在产品配置区间范围内!" ); @@ -148,14 +148,18 @@ public class ConditionHelper { personalInsuranceDifference = "0"; } } + String discountInterest = cb.getDiscountInterest(); + if(discountInterest == null || discountInterest.isEmpty() ){ + discountInterest = "0"; + } // 收入 - BigDecimal in = allInterest.divide( interestRate , 2, 4 ).add( handlingChargeMoney.divide( handRate, 2, 4 ) ).add( gpsDifference.divide( gpsInstallFee, 2, 4 ) ).add( new BigDecimal( cb.getDiscountInterest() ).divide(discountInterestRate , 2 ,4 ) ).add( new BigDecimal( personalInsuranceDifference ).divide( personalInsuranceRate , 2 ,4 ) ); + BigDecimal in = allInterest.divide( interestRate , 2, 4 ).add( handlingChargeMoney.divide( handRate, 2, 4 ) ).add( gpsDifference.divide( gpsInstallFee, 2, 4 ) ).add( new BigDecimal( discountInterest ).divide(discountInterestRate , 2 ,4 ) ).add( new BigDecimal( personalInsuranceDifference ).divide( personalInsuranceRate , 2 ,4 ) ); // 租赁年限 int leaseTerm = cb.getLeaseTerm()/12; // 融资额 BigDecimal cleanLeaseMoney = new BigDecimal( cb.getCleanLeaseMoney() ); - String rentSql = "select corpus,ALL_REMAIN_CORPUS from LC_RENT_PLAN_TEMP where flowunid ='"+cb.getDocId()+"' order by plan_date"; + String rentSql = "select corpus,ALL_REMAIN_CORPUS from LC_RENT_PLAN_TEMP where flowunid ='"+cb.getDocId()+"' GROUP BY plan_list order by plan_date"; List> rentPlanData =DataOperatorUtil.getDataBySql(tx, rentSql, null); BigDecimal cautionMoney = new BigDecimal( cb.getCautionMoney() ); BigDecimal costMoney = BigDecimal.ZERO; @@ -188,6 +192,7 @@ public class ConditionHelper { .append(",运营费率:").append(new BigDecimal( operatingRate ).divide( percentage ) ).append(",风险计提比率:").append( new BigDecimal( riskAccrualRatio ).divide( percentage ) ) .append(",收入:").append(in).append(",成本:").append(cost).append(",运营费用:").append(operatingExpenses).append(",风险计提:").append(withdrawalRisk); System.out.println(sb.toString()); + System.out.println("roa:"+roa); if ( roa.compareTo( new BigDecimal( roaValue ).divide( new BigDecimal("100") ) ) < 0 ) { throw new BusinessException( "ROA小于产品配置!" ); } @@ -198,6 +203,8 @@ public class ConditionHelper { params.put( "STRATEGIC_COEFFICIENT", strategicCoefficient ); params.put( "STRATEGY_ROA", roa.toString() ); } catch ( Exception e ) { + CalculationLogUtil.insertCalculationFailLog(cb.getDocId(), e.toString() ,JSON.toJSON( e.getStackTrace() [0]).toString() ); + e.printStackTrace(); throw new BusinessException( e.getMessage() ); } }