From a7d4d301ad73e6da905f5bfa66e19874f6ea28de Mon Sep 17 00:00:00 2001 From: zhulh Date: Tue, 13 Aug 2019 16:22:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BE=9B=E8=87=AA=E5=8A=A8=E6=B5=8B?= =?UTF-8?q?=E7=AE=97=E5=85=A5=E5=8F=A3=EF=BC=8C=E9=9C=80=E8=A6=81=E5=90=8E?= =?UTF-8?q?=E7=BB=AD=E8=A1=A5=E4=B8=8A=E6=B5=8B=E7=AE=97=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../executor/CreateTransactionExecutor.java | 140 ++++++++++++------ .../tenwa/reckon/executor/Transaction.java | 19 +-- calc/com/tenwa/reckon/util/TbBeanTools.java | 68 +++++++-- .../LBProjectIntoTempInitCarBusiness.java | 57 ++++--- 4 files changed, 198 insertions(+), 86 deletions(-) diff --git a/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java b/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java index 018050c7d..ae3a38de6 100644 --- a/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java +++ b/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java @@ -68,7 +68,7 @@ import com.tenwa.reckon.util.ObjectConvertUtils; import com.tenwa.reckon.util.TbBeanTools; /** - * + * * @author chuang 租金测算主入口 */ public class CreateTransactionExecutor implements Transaction { @@ -88,7 +88,7 @@ public class CreateTransactionExecutor implements Transaction { private String orgID; private String flow_name; private String ebanknumber; - + public String getStartDate() { return startDate; } @@ -124,7 +124,7 @@ public class CreateTransactionExecutor implements Transaction { FundRentPlanBean rentPlan = this.createRentPlan(bean,tx); this.createFundPlan(rentPlan, bean,tx); irr = this.createCashFlow(bean,tx); - + //额外生成分润的租金计划 String splittingRatio = ProductParamUtil.getProductParameterValue(productId, "PRD0350", "product_rate", "splitting_ratio"); System.out.println("==========================分润利率:"+splittingRatio+"=========================="); @@ -137,7 +137,7 @@ public class CreateTransactionExecutor implements Transaction { 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); // 返回参数上做处理 @@ -172,7 +172,51 @@ public class CreateTransactionExecutor implements Transaction { } } - + + /** + * 正常测算 + */ + @Override + public void runTrans( JBOTransaction tx ) throws Exception { + 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); + String yearRate = bean.getCb().getYearRate(); + this.preHandle(bean.getCb(),bean); + 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+"'")); + bean.setProductType(productType); + bean.getCb().setProductType(productType); + jsonObject.appendElement("year_rate", yearRate); + FundRentPlanBean rentPlan = this.createRentPlan(bean,tx); + 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); + } + + + + /** * 起租测算 */ @@ -211,12 +255,12 @@ public class CreateTransactionExecutor implements Transaction { } } } - + /** * 车贷起租测算 * @param Sqlca * @return - * @throws Exception + * @throws Exception */ public String carRunOnhire(com.amarsoft.awe.util.Transaction Sqlca) throws Exception { JBOTransaction tx=null; @@ -264,9 +308,9 @@ public class CreateTransactionExecutor implements Transaction { Sqlca.executeSQL(new SqlObject("update lc_fund_plan set plan_date = '" + startDate + "' where payment_number = '" + this.plannumber + "' and pay_type = 'pay_type_in' and fee_type != 'feetype4' and fee_type != 'feetype12'")); Sqlca.executeSQL(new SqlObject("update lc_fund_plan set plan_date = '" + startDate + "' where payment_number = '" + this.plannumber + "' and fee_type = 'feetype10'")); this.setCashFlow(this.plannumber, this.productId, Sqlca); - - - + + + } return "success"; } @@ -281,7 +325,7 @@ public class CreateTransactionExecutor implements Transaction { sql += ",net_flow"; //sql += ",flowunid";//create_date,creator_ "+DateUtil.getSystemDate()+"' create_date ,'"+SecurityUtil.getPrincipal().getId()+"' creator_" sql += " )"; - + sql +=" select replace(uuid(),'-','') id,max(t.project_id),max(t.project_plan_number),max(t.contract_id),max(t.contract_plan_number),max(t.payment_number),t.plan_date,sum(t.flowin) fundin,ifnull(group_concat(if(t.flowindetail='',null,t.flowindetail)),'-') fundindetails, "; sql +=" sum(t.flowout) fundout ,ifnull(group_concat(if(t.flowoutdetail='',null,t.flowoutdetail)),'-')fundoutdetails ,sum(t.cleanfow)netflow " ; sql +=" from (" ; @@ -314,7 +358,7 @@ public class CreateTransactionExecutor implements Transaction { sql +=" )t group by t.plan_date "; Sqlca.executeSQL(new SqlObject(sql)); } - + //固定还款日 public static List getPlanDateListFixed(int incomeNumber, String periodType, String incomeIntervalMonth, String startDate) throws ParseException { List planDate = new ArrayList(); @@ -360,8 +404,8 @@ public class CreateTransactionExecutor implements Transaction { } return planDate; } - - + + //起租日即为还款日 public static List getPlanDateList(int incomeNumber, String periodType, String incomeIntervalMonth, String startDate) throws ParseException { List planDate = new ArrayList(); @@ -384,7 +428,7 @@ public class CreateTransactionExecutor implements Transaction { } return planDate; } - + /** * 中途中止 */ @@ -416,14 +460,14 @@ public class CreateTransactionExecutor implements Transaction { } return JSONEncoder.encode(jsonObject); } - + /** * 删除方案 * @param tx * @return */ public String deletePlan(JBOTransaction tx){ - + Map condtion=new HashMap(); condtion.put("flowunid", flowunid); condtion.put(this.planCName, plannumber); @@ -457,11 +501,11 @@ public class CreateTransactionExecutor implements Transaction { } JBOFactory.getBizObjectManager(LC_PAY_CONDTION_TEMP.CLASS_NAME, tx).createQuery(sql).setParameter("flowunid", flowunid).setParameter("plannumber", planCValue).executeUpdate(); } - + @Override public FundRentPlanBean createRentPlan(TabCalBean bean,JBOTransaction tx) throws Exception { ConditionBean cb = bean.getCb(); - + bean.setCb(cb); DictTools.getReversDict(cb); String settleMethod = cb.getSettleMethod(); @@ -512,7 +556,7 @@ public class CreateTransactionExecutor implements Transaction { FundFundPlanExecutor fundFundExecutor = new FundFundPlanExecutor(); fundFundExecutor.runTerminate(bean.getCb(), bean, planBean,tx,bo); } - + @Override public String createCashFlow(TabCalBean bean,JBOTransaction tx) throws Exception { CashFlowExecutor executor = new CashFlowExecutor(tx); @@ -536,9 +580,9 @@ public class CreateTransactionExecutor implements Transaction { helper.run(jsonObject, cb, bean, rentPlan,flag); } - - + + /** * 删除已知规则 */ @@ -550,13 +594,13 @@ public class CreateTransactionExecutor implements Transaction { bm.createQuery("delete from O where flowunid=:flowunid and "+this.planCName+"=:plannumber").setParameter("flowunid",this.flowunid).setParameter("plannumber",this.plannumber).executeUpdate(); BizObjectManager bm2=JBOFactory.getBizObjectManager(tcb.getPeriodTb()); bm2.createQuery("delete from O where flowunid=:flowunid and "+this.planCName+"=:plannumber").setParameter("flowunid",this.flowunid).setParameter("plannumber",this.plannumber).executeUpdate(); - + return null; } /** * 删除 * @return - * @throws Exception + * @throws Exception */ public String runDeleSubsection() throws Exception{ TabCalBean tcb=TbBeanTools.getTabInfo(this.calType); @@ -566,7 +610,7 @@ public class CreateTransactionExecutor implements Transaction { } /** * 已知规则 - * @throws Exception + * @throws Exception */ @SuppressWarnings("unchecked") @Override @@ -627,7 +671,7 @@ public class CreateTransactionExecutor implements Transaction { */ @Override public String runRentChange() throws Exception{ - + JSONObject jsonObject = JSONObject.createObject(); JBOTransaction tx=null; try { @@ -689,7 +733,7 @@ public class CreateTransactionExecutor implements Transaction { return "false"; } return "true"; - + } /** * 判断租金变更信息是否存在 @@ -707,7 +751,7 @@ public class CreateTransactionExecutor implements Transaction { return "false"; } } - + /** * 判断商务条件是否保存 */ @@ -757,7 +801,7 @@ public class CreateTransactionExecutor implements Transaction { for(String key:map.keySet()){ fundColMoney.put(fundCol.get(key), map.get(key).toString()); } - + Map> fundmap=ProductParamUtil.getProductComponentType(productId, "PRD0315"); Map fundColMoneyRatio=new HashMap(); fundColMoneyRatio.putAll(fundColMoney); @@ -817,7 +861,7 @@ public class CreateTransactionExecutor implements Transaction { * @param sourceFile * @param sourceMap * @return - * @throws Exception + * @throws Exception */ public String importRentOrCorpusTable(String fileName, InputStream sourceFile,MapsourceMap) throws Exception{ @@ -846,7 +890,7 @@ public class CreateTransactionExecutor implements Transaction { KnowingTableBean.checkKnowingTableBean(table, i); tableBeans.add(table); } - + //先校验本金之和是否等于融资额 BigDecimal moneyTotal = BigDecimal.ZERO; Date upperDate=null; @@ -865,7 +909,7 @@ public class CreateTransactionExecutor implements Transaction { }else if(rentOrRate.equals("corpus_period")&&moneyTotal.compareTo(new BigDecimal(cleanLeaseMoney).subtract(new BigDecimal(sourceMap.get("EQUIP_END_VALUE"))))!=0){ throw new BusinessException("上传Excel中的本金之和需要等于融资额,请核实后再进行上传!"); } - + BizObjectManager bm=JBOFactory.getBizObjectManager(tcb.getPeriodTb()); bm.createQuery("delete from O where flowunid=:flowunid and "+sourceMap.get("planCName")+"=:plannumber").setParameter("flowunid", sourceMap.get("flowunid")).setParameter("plannumber", sourceMap.get("plannumber")).executeUpdate(); JSONObject json=JSONObject.createObject(); @@ -888,7 +932,7 @@ public class CreateTransactionExecutor implements Transaction { json.appendElement("index", tableBeans.size()); return JSONEncoder.encode(json); } - + /** * 不规则测算 导入租金计划 * */ @@ -922,7 +966,7 @@ public class CreateTransactionExecutor implements Transaction { tx.rollback(); throw e; }catch(Exception e){ - + tx.rollback(); return 0; }finally{ @@ -930,14 +974,14 @@ public class CreateTransactionExecutor implements Transaction { tx.commit(); } } - - - } + + + } /** * 租金计划变更 更新现金流前先计算增值税 * @param tx * @return - * @throws Exception + * @throws Exception */ public String updateRentTax() throws Exception{ BizObjectManager bm=JBOFactory.getBizObjectManager(LC_RENT_PLAN_TEMP.CLASS_NAME); @@ -1000,8 +1044,8 @@ public class CreateTransactionExecutor implements Transaction { otherProperty1.put("flow_name", flow_name); LeaseFlowBaseService service1=new LeaseFlowBaseServiceImp(); service1.copyEbankInfoToProcess(tx, fromCondtion1, null,otherProperty1, ServiceOperatorEnum.FormalToTemp); - - String sMessage="true"; + + String sMessage="true"; return ""; } /** @@ -1039,7 +1083,7 @@ public class CreateTransactionExecutor implements Transaction { tx.commit(); return "Success"; } - + //提前结清更新LC_EBANK_TEMP表 public String deleteEbank(JBOTransaction tx)throws Exception{ BizObjectManager letManage = JBOFactory.getBizObjectManager(LC_EBANK_TEMP.CLASS_NAME, tx); @@ -1054,7 +1098,7 @@ public class CreateTransactionExecutor implements Transaction { tx.commit(); return "Success"; } - + public String getCalType() { return calType; } @@ -1063,7 +1107,7 @@ public class CreateTransactionExecutor implements Transaction { this.calType = calType; } - + public String getFlowunid() { return flowunid; } @@ -1080,8 +1124,8 @@ public class CreateTransactionExecutor implements Transaction { this.rentOrRate = rentOrRate; } - - + + public String getCleanLeasemoney() { return cleanLeasemoney; } @@ -1090,8 +1134,8 @@ public class CreateTransactionExecutor implements Transaction { this.cleanLeasemoney = cleanLeasemoney; } - - + + public String getEquipEndValue() { return equipEndValue; } @@ -1173,5 +1217,5 @@ public class CreateTransactionExecutor implements Transaction { } - + } diff --git a/calc/com/tenwa/reckon/executor/Transaction.java b/calc/com/tenwa/reckon/executor/Transaction.java index 0a12f7688..731c10de2 100644 --- a/calc/com/tenwa/reckon/executor/Transaction.java +++ b/calc/com/tenwa/reckon/executor/Transaction.java @@ -13,10 +13,11 @@ import com.tenwa.reckon.bean.TabCalBean; public interface Transaction { /** - * + * * @param 组装商务报价 */ public String run(); + public void runTrans( JBOTransaction tx ) throws Exception; public FundRentPlanBean createRentPlan(TabCalBean bean,JBOTransaction tx) throws Exception; public void createFundPlan(FundRentPlanBean rentPlan, TabCalBean bean,JBOTransaction tx) throws Exception; public String createCashFlow(TabCalBean bean,JBOTransaction tx) throws Exception; @@ -37,29 +38,29 @@ public interface Transaction { * @return */ public String runDelteKnowing() throws Exception; - + public String runOnhire(); - + public String checkKnowingConfig() throws Exception; - + public String updateCashFlow() throws Exception; /** * 租金计划变更 * @return */ public String runRentChange() throws Exception; - + public String cancelRentChange(JBOTransaction tx) throws Exception; - + public String checkIsRentChange() throws Exception; - + /** * 中途终止操作 * @return - * + * */ public String runTerminate() throws Exception; - + public int importRentPlan(String fileName,InputStream sourceFile,MapsourceMap) throws Exception; public void createFundPlanTerminate(FundRentPlanBean rentPlan, TabCalBean bean,JBOTransaction tx,BizObject bo) throws Exception; } diff --git a/calc/com/tenwa/reckon/util/TbBeanTools.java b/calc/com/tenwa/reckon/util/TbBeanTools.java index cfc61ffd9..afa5e69b9 100644 --- a/calc/com/tenwa/reckon/util/TbBeanTools.java +++ b/calc/com/tenwa/reckon/util/TbBeanTools.java @@ -3,6 +3,7 @@ package com.tenwa.reckon.util; import java.util.ArrayList; import java.util.List; +import com.amarsoft.are.jbo.JBOTransaction; import jbo.com.tenwa.entity.comm.flow.FLOW_BUSSINESS_OBJECT; import com.amarsoft.are.ARE; @@ -18,7 +19,7 @@ import com.tenwa.reckon.bean.TabCalBean; /** - * + * * @author SHIHONGFEI * @version 1.0 * @copyright (C) TENWA 2016 @@ -26,16 +27,16 @@ import com.tenwa.reckon.bean.TabCalBean; * @desc ( 此类用于根据流程类型得出,交易结构,租金计划所用的表信息) */ public class TbBeanTools { - public static Log logger=ARE.getLog(); + public static Log logger=ARE.getLog(); /** - * + * * ( 根据交易结构信息,测算类型得到测算所涉及的表信息) - * + * * @param calType * @param cb * @return - * @throws Exception + * @throws Exception */ @SuppressWarnings("unchecked") public static TabCalBean getTabInfo(String calType, String flowunid,String plannumber,String productId) throws Exception { @@ -61,7 +62,7 @@ public class TbBeanTools { tables.add(ObjectConvertUtils.converBizObjectToBean(KnowingTableBean.class, obj)); } tcb.setKnowingTables(tables); - + //分段测算 BizObjectManager breakBm=JBOFactory.getBizObjectManager(tcb.getSubsectionTb()); List subList=breakBm.createQuery("flowunid=:flowunid and "+tcb.getPlanCName()+"='"+tcb.getPlanCValue()+"' order by START_LIST asc").setParameter("flowunid", flowunid).getResultList(false); @@ -70,8 +71,8 @@ public class TbBeanTools { subs.add(ObjectConvertUtils.converBizObjectToBean(SubsectionBean.class, obj)); } tcb.setSubsections(subs); - - + + tcb.setDocId(flowunid); if(productId==null||productId==""){ BizObject flow=JBOFactory.createBizObjectQuery(FLOW_BUSSINESS_OBJECT.CLASS_NAME,"flow_unid=:flowunid").setParameter("flowunid", flowunid).getSingleResult(false); @@ -81,10 +82,55 @@ public class TbBeanTools { logger.info("方法getTabInfo处理结束"); return tcb; } - - + + @SuppressWarnings("unchecked") + public static TabCalBean getTabInfoTrans( String calType, String flowunid, String plannumber, String productId, JBOTransaction tx ) throws Exception { + logger.info("进入方法:getTabInfo"); + TabCalBean tcb = new TabCalBean(); + tcb = getTabInfo(calType); + tcb.setPlanCValue(plannumber); + BizObject condition = JBOFactory.getBizObjectManager( tcb.getCondition_tb(), tx ).createQuery( "select * from O where flowunid = :flowunid and "+tcb.getPlanCName()+"='"+plannumber+"'" ).setParameter( "flowunid", flowunid ).getSingleResult( false ); + tcb.setCondition(condition); + //设置已知规则 + BizObjectManager m2 = JBOFactory.getBizObjectManager( tcb.getRuleTb(), tx ); + List objs = m2.createQuery("flowunid=:flowunid and "+tcb.getPlanCName()+"='"+tcb.getPlanCValue()+"' order by start_list asc").setParameter("flowunid", flowunid).getResultList(false); + List configs = new ArrayList(); + for(BizObject obj : objs){ + configs.add(ObjectConvertUtils.converBizObjectToBean(KnowingConfigBean.class, obj)); + } + tcb.setKnowingConfigs(configs); + //设置已知租金表 + BizObjectManager m3 = JBOFactory.getBizObjectManager( tcb.getPeriodTb(), tx ); + List objs3 = m3.createQuery("flowunid=:flowunid and "+tcb.getPlanCName()+"='"+tcb.getPlanCValue()+"' order by PLAN_LIST asc").setParameter("flowunid", flowunid).getResultList(false); + List tables = new ArrayList(); + for(BizObject obj : objs3){ + tables.add(ObjectConvertUtils.converBizObjectToBean(KnowingTableBean.class, obj)); + } + tcb.setKnowingTables(tables); + + //分段测算 + BizObjectManager breakBm=JBOFactory.getBizObjectManager( tcb.getSubsectionTb(), tx ); + List subList=breakBm.createQuery("flowunid=:flowunid and "+tcb.getPlanCName()+"='"+tcb.getPlanCValue()+"' order by START_LIST asc").setParameter("flowunid", flowunid).getResultList(false); + List subs=new ArrayList(); + for(BizObject obj:subList){ + subs.add(ObjectConvertUtils.converBizObjectToBean(SubsectionBean.class, obj)); + } + tcb.setSubsections(subs); + + + tcb.setDocId(flowunid); + if(productId==null||productId==""){ + BizObject flow = JBOFactory.getBizObjectManager( FLOW_BUSSINESS_OBJECT.CLASS_NAME, tx ).createQuery( "flow_unid=:flowunid" ).setParameter( "flowunid", flowunid ).getSingleResult( false ); + productId=flow.getAttribute("productId").getString(); + } + tcb.setProductId(productId); + logger.info("方法getTabInfo处理结束"); + return tcb; + } + + /** - * + * * 根据calType 类型返回在该类型下查询的表和字段名 该方法流程类型返回要和该类中其他重载方法一致 *
在这里返回的都是表名,可以通过tabcalbean中的方法转换为视图或者正式表 *
该方法中会吧userid存为查询客户名的表,实际上应该为当前登录人所以需要在其他方法中覆盖 diff --git a/src_tenwa/com/tenwa/lease/flow/project/commbusiness/LBProjectIntoTempInitCarBusiness.java b/src_tenwa/com/tenwa/lease/flow/project/commbusiness/LBProjectIntoTempInitCarBusiness.java index e90facdaa..d81d092ee 100644 --- a/src_tenwa/com/tenwa/lease/flow/project/commbusiness/LBProjectIntoTempInitCarBusiness.java +++ b/src_tenwa/com/tenwa/lease/flow/project/commbusiness/LBProjectIntoTempInitCarBusiness.java @@ -2,6 +2,7 @@ package com.tenwa.lease.flow.project.commbusiness; +import com.tenwa.util.SerialNumberUtil; import jbo.app.tenwa.calc.LC_CALC_CONDITION_TEMP; import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT_TEMP; import jbo.app.tenwa.customer.CUSTOMER_ADDRESS; @@ -59,7 +60,7 @@ public class LBProjectIntoTempInitCarBusiness extends BaseBussiness { public String serial = null; @Override public Object run(Transaction Sqlca) throws Exception { - this.initBussinessParam(Sqlca); + this.initBussinessParam(Sqlca); if(this.getAttribute("serial")!=null) serial = this.getAttribute("serial").toString(); ASUser asUser=new ASUser(this.getAttribute("CurUserID").toString()); @@ -80,7 +81,7 @@ public class LBProjectIntoTempInitCarBusiness extends BaseBussiness { } BizObjectManager bmCTT =JBOFactory.getBizObjectManager(CUSTOMER_TYPE_TEMP.CLASS_NAME,tx); BizObjectManager bomC = JBOFactory.getBizObjectManager(className); //自然人表或者法人信息表 - BizObjectManager bm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO_TEMP.CLASS_NAME,tx); + BizObjectManager bm = JBOFactory.getBizObjectManager(LB_PROJECT_INFO_TEMP.CLASS_NAME,tx); BizObjectManager bmLULT = JBOFactory.getBizObjectManager(LB_UNION_LESSEE_TEMP.CLASS_NAME,tx); BizObjectManager bmLECT = JBOFactory.getBizObjectManager(LB_EQUIPMENT_CAR_TEMP.CLASS_NAME,tx); BizObjectManager bmCI = JBOFactory.getBizObjectManager(CUSTOMER_INFO_TEMP.CLASS_NAME,tx); @@ -95,13 +96,13 @@ public class LBProjectIntoTempInitCarBusiness extends BaseBussiness { //证件表中如果这个人做过承租人也做过担保有 相同的证件号码就有2条信息,一个作为担保人,一个承租人 List boCT1 = bomCT1.createQuery("certtype='"+certType+"' and certid='"+certId+"'").getResultList(false); if(boCT1.size()>0){ - for(BizObject CT1:boCT1){ + for(BizObject CT1:boCT1){ String customeridForCust = CT1.getAttribute("customerid").getString(); BizObject boCTT1 = bomCTT1.createQuery("customerid='"+customeridForCust+"'").getSingleResult(false); if(boCTT1!=null){ custType = boCTT1.getAttribute("CUSTTYPE").getString(); if("cust_type.cust".equals(custType)){ - break; + break; } } } @@ -127,7 +128,7 @@ public class LBProjectIntoTempInitCarBusiness extends BaseBussiness { MapotherProperty=new HashMap(); otherProperty.put("FLOWUNID", flowunid); otherProperty.put(CUSTOMER_INFO_TEMP.customerid, customerId); - + //更新customer_info,CUSTOMER_CERT MapinfoProperty=new HashMap(); infoProperty.put("FLOWUNID", flowunid); @@ -148,10 +149,10 @@ public class LBProjectIntoTempInitCarBusiness extends BaseBussiness { companyProperty.put("FLOWUNID", flowunid); companyProperty.put(CUSTOMER_INFO_TEMP.customerid, customerId); companyProperty.put("enterprisename", custName); - + MapfromCondtion=new HashMap(); fromCondtion.put("CUSTOMERID",customerId); - + //otherProperty.put(CUSTOMER_INFO_TEMP.distributor_id, distributoIid); //拷到临时表 DataOperatorUtil.copySingleJBO(CUSTOMER_INFO.CLASS_NAME, fromCondtion, CUSTOMER_INFO_TEMP.CLASS_NAME, null, infoProperty, tx); @@ -166,11 +167,11 @@ public class LBProjectIntoTempInitCarBusiness extends BaseBussiness { } DataOperatorUtil.copySingleJBO(CUSTOMER_TYPE.CLASS_NAME, fromCondtion, CUSTOMER_TYPE_TEMP.CLASS_NAME, null, otherProperty, tx); BizObject lul = JBOFactory.getBizObjectManager(LB_UNION_LESSEE.CLASS_NAME,tx).createQuery(" customer_id=:customer_id ").setParameter("customer_id", customerId).getSingleResult(false); - + BizObject lpi = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME,tx).createQuery(" id=:project_id ").setParameter("project_id", lul == null ?"":lul.getAttribute("project_id").toString()).getSingleResult(false); //无论是不是存量客户都在 项目表 和 客户和项目关联表 中都新增一条数据,客户和项目是一对多的 - this.saveProjInfo(bm, tx, asUser,distributoIid,lpi == null ? null : lpi.getAttribute("is_netcar").toString()); + this.saveProjInfo(bm, tx, asUser,distributoIid,lpi == null ? null : lpi.getAttribute("is_netcar").toString()); this.saveEquipmentCar(bmLECT, tx, asUser,vndrName); //车辆租赁物信息表 this.saveUnionLessee(bmLULT,tx,customerId,asUser); this.saveBusinessStatus(bsbom, tx, asUser);//项目进度表 @@ -195,7 +196,7 @@ public class LBProjectIntoTempInitCarBusiness extends BaseBussiness { this.saveUnionLessee(bmLULT, tx, customerId, asUser);//union表 this.saveProjInfo(bm, tx, asUser,distributoIid,null);//保存项目信息表 this.saveBusinessStatus(bsbom, tx, asUser);//项目进度表 - + /**接口平台初始化数据*/ if(serial!=null){ //共同申请人 @@ -205,7 +206,7 @@ public class LBProjectIntoTempInitCarBusiness extends BaseBussiness { cftbo.setAttributeValue("flowunid",this.getAttribute("FlowUnid")); cftbo.setAttributeValue("PROJECT_ID",this.getAttribute("ProjectId")); BusinessApplicationPfToTemp.savePartner(cftbo,cftbom,serial); - + //担保人拷表 Map fromCondtion = new HashMap(); fromCondtion.put("SERIAL",serial); @@ -213,24 +214,44 @@ public class LBProjectIntoTempInitCarBusiness extends BaseBussiness { otherProperty.put("FLOWUNID",this.getAttribute("FlowUnid").toString()); otherProperty.put("PROJECT_ID",this.getAttribute("ProjectId").toString()); DataOperatorUtil.copyJBOSet(PF_GUARANTEE_UNIT.CLASS_NAME,fromCondtion,LB_GUARANTEE_UNIT_TEMP.CLASS_NAME,null,otherProperty,null,tx); - + //扣款卡信息拷表 otherProperty.put("customerid",customerId); otherProperty.put("acc_info","Debit"); otherProperty.put("acc_type","Debit"); otherProperty.put("CUSTTYPE","lessee"); DataOperatorUtil.copyJBOSet(PF_CUSTOMER_ACCOUNT.CLASS_NAME,fromCondtion,CUSTOMER_ACCOUNT_TEMP.CLASS_NAME,null,otherProperty,null,tx); - + //商务条件拷表 + String calType = "proj_process"; otherProperty.clear(); otherProperty.put("FLOWUNID",this.getAttribute("FlowUnid").toString()); + BizObject proj = JBOFactory.getBizObjectManager( "jbo.com.tenwa.lease.comm.LB_PROJECT_INFO_TEMP", tx ).createQuery( "flowunid=:flowunid" ).setParameter( "flowunid", flowunid ).getSingleResult( false ); + String sSerialType = ( proj == null ) ? "" : proj.getAttribute( "PROJECT_NO" ).getString(); + String planNumber = SerialNumberUtil.getPlannumber( sSerialType, calType, tx ); + otherProperty.put("PROJECT_PLAN_NUMBER", planNumber); + // TO DO 补上商务条件剩余信息 + + DataOperatorUtil.copyJBOSet(PF_CALC_CONDITION.CLASS_NAME,fromCondtion,LC_CALC_CONDITION_TEMP.CLASS_NAME,null,otherProperty,null,tx); + + // 自动测算 + autoCalc( flowunid, calType, planNumber, this.getAttribute("ProductId").toString(), tx ); } } - String sMessage="true"; + String sMessage="true"; return sMessage; } - + + public void autoCalc( String flowunid, String calType, String planNumber, String productId, JBOTransaction tx ) throws Exception { + CreateTransactionExecutor cte = new CreateTransactionExecutor(); + cte.setCalType( calType ); + cte.setFlowunid( flowunid ); + cte.setPlannumber( planNumber ); + cte.setProductId( productId ); + cte.runTrans( tx ); + } + private BizObject saveCustomerInfo(BizObjectManager bomCI,JBOTransaction tx,ASUser asUser,String distributoIid)throws JBOException{ BizObject bmC = bomCI.newObject();//保存客户信息 try { @@ -259,7 +280,7 @@ public class LBProjectIntoTempInitCarBusiness extends BaseBussiness { e.printStackTrace(); } return bmC; - } + } private void savePersonOrCompany(BizObjectManager bomC,JBOTransaction tx,String colName,String customerId,ASUser asUser)throws JBOException{ BizObject boCRT = bomC.newObject();//新建自然人||法人 try { @@ -296,7 +317,7 @@ public class LBProjectIntoTempInitCarBusiness extends BaseBussiness { } } }else{ - + } bomC.saveObject(boCRT); } catch (Exception e) { @@ -306,7 +327,7 @@ public class LBProjectIntoTempInitCarBusiness extends BaseBussiness { } //存储客户类型信息(仅用于承租人) private void saveCustomerType(BizObjectManager bomCT,JBOTransaction tx,String customerId,ASUser asUser) throws JBOException{ - + BizObject boCT = bomCT.newObject();//保存客户类型 try { boCT.setAttributeValue("CUSTOMERID", customerId);