From c32f6726c6aaf501743bf70e87445e51c478ef55 Mon Sep 17 00:00:00 2001 From: zhangbb Date: Wed, 21 Aug 2019 14:11:06 +0800 Subject: [PATCH] =?UTF-8?q?1.=E9=87=8D=E6=96=B0=E6=B7=BB=E4=B8=8A=E8=A2=AB?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../executor/CreateTransactionExecutor.java | 77 ++++++++++++------- 1 file changed, 51 insertions(+), 26 deletions(-) diff --git a/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java b/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java index 31a71fa89..0527e6081 100644 --- a/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java +++ b/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java @@ -125,19 +125,6 @@ public class CreateTransactionExecutor implements Transaction { this.createFundPlan(rentPlan, bean,tx); irr = this.createCashFlow(bean,tx); - //额外生成分润的租金计划 - String splittingRatio = ProductParamUtil.getProductParameterValue(productId, "PRD0350", "product_rate", "splitting_ratio"); - System.out.println("==========================分润利率:"+splittingRatio+"=========================="); - if("".equals(splittingRatio)||splittingRatio==null){} - else{ - TabCalBean bean_sp = TbBeanTools.getTabInfo(calType, flowunid,plannumber,productId); - bean_sp.setProductType(productType); - bean_sp.getCb().setProductType(productType); - bean_sp.setRentPlan_tb("jbo.app.tenwa.calc.LC_RENT_PLAN_SP_TEMP"); - bean_sp.getCb().setYearRate(splittingRatio); - FundRentPlanBean rentPlan_sp = this.createRentPlan(bean_sp,tx); - } - jsonObject.appendElement("result", "true"); this.callBack(jsonObject, bean.getCb(), bean,rentPlan,false,tx); // 返回参数上做处理 @@ -197,19 +184,6 @@ public class CreateTransactionExecutor implements Transaction { this.createFundPlan(rentPlan, bean,tx); String irr = this.createCashFlow(bean,tx); - //额外生成分润的租金计划 - String splittingRatio = ProductParamUtil.getProductParameterValue(productId, "PRD0350", "product_rate", "splitting_ratio"); - System.out.println("==========================分润利率:"+splittingRatio+"=========================="); - if("".equals(splittingRatio)||splittingRatio==null){} - else{ - TabCalBean bean_sp = TbBeanTools.getTabInfo(calType, flowunid,plannumber,productId); - bean_sp.setProductType(productType); - bean_sp.getCb().setProductType(productType); - bean_sp.setRentPlan_tb("jbo.app.tenwa.calc.LC_RENT_PLAN_SP_TEMP"); - bean_sp.getCb().setYearRate(splittingRatio); - FundRentPlanBean rentPlan_sp = this.createRentPlan(bean_sp,tx); - } - jsonObject.appendElement("result", "true"); this.callBack(jsonObject, bean.getCb(), bean,rentPlan,false,tx); } @@ -314,6 +288,57 @@ public class CreateTransactionExecutor implements Transaction { } return "success"; } + + /** + * 插入分润计划 + * @param splittingRatio,Sqlca + * @return + * @throws JBOException + * @throws Exception + */ + public void insertRentPlan_SP (String splittingRatio,com.amarsoft.awe.util.Transaction Sqlca) throws Exception{ + BizObjectManager BmLRP=JBOFactory.getBizObjectManager(LC_RENT_PLAN.CLASS_NAME, Sqlca); + java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy/MM/dd"); + String day ="0"; + Long start = format.parse(startDate).getTime(); + + List BoLRP = BmLRP.createQuery("payment_number=:payment_number order by plan_list").setParameter("payment_number", this.plannumber).getResultList(false); + Connection conn = Sqlca.getConnection(Sqlca); + PreparedStatement ps = null; + BigDecimal corpus_sp = new BigDecimal("0.00"); + try{ + ps = conn.prepareStatement("update lc_rent_plan set CORPUS_SP = ?,INTEREST_SP = ? where payment_number = '" + this.plannumber + "' and plan_list = ?"); + for(int i = 0; i < BoLRP.size(); i ++){ + BigDecimal corpus = new BigDecimal(BoLRP.get(i).getAttribute("CORPUS").toString()); + BigDecimal allRemainCorpus =new BigDecimal(BoLRP.get(i).getAttribute("ALL_REMAIN_CORPUS").toString()); + BigDecimal interest =new BigDecimal(BoLRP.get(i).getAttribute("INTEREST").toString()); + BigDecimal ratio = new BigDecimal(splittingRatio).divide(new BigDecimal("100")); + + Long planDate = BoLRP.get(i).getAttribute("PLAN_DATE").getDate().getTime(); + //第一期的话,用计划日期减去起租日。(第一期本金加剩余总本金等于总本金) + if(i==0){ + day = String.valueOf((planDate-start)/(24*60*60*1000)); + }else{ + day = String.valueOf((planDate-(BoLRP.get(i-1).getAttribute("PLAN_DATE").getDate().getTime()))/(24*60*60*1000)); + } + corpus_sp = corpus.add(allRemainCorpus).multiply(ratio).multiply(new BigDecimal(day)).divide(new BigDecimal("360"),2,BigDecimal.ROUND_HALF_UP); + BigDecimal interest_sp = interest.subtract(corpus_sp); + ps.setString(1, corpus_sp.toString()); + ps.setString(2, interest_sp.toString()); + ps.setString(3, (i + 1) + ""); + ps.addBatch(); + } + ps.executeBatch(); + }catch(Exception e){ + e.printStackTrace(); + throw new RuntimeException("存储数据异常"); + } finally { + if(ps != null) ps.close(); + } + + + } + public void setCashFlow(String paymentNumber, String productId, com.amarsoft.awe.util.Transaction Sqlca) throws Exception { String sql = ""; sql += "INSERT INTO LC_CASH_FLOW (id,project_id,project_plan_number,contract_id,contract_plan_number,payment_number";