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; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.log.Log; import com.amarsoft.awe.util.SqlObject; import com.tenwa.reckon.bean.KnowingConfigBean; import com.tenwa.reckon.bean.KnowingTableBean; import com.tenwa.reckon.bean.SubsectionBean; import com.tenwa.reckon.bean.TabCalBean; /** * * @author SHIHONGFEI * @version 1.0 * @copyright (C) TENWA 2016 * @date 2016-07-24 * @desc ( 此类用于根据流程类型得出,交易结构,租金计划所用的表信息) */ public class TbBeanTools { public static Log logger=ARE.getLog(); /** * * ( 根据交易结构信息,测算类型得到测算所涉及的表信息) * * @param calType * @param cb * @return * @throws Exception */ @SuppressWarnings("unchecked") public static TabCalBean getTabInfo(String calType, String flowunid,String plannumber,String productId) throws Exception { logger.info("进入方法:getTabInfo"); TabCalBean tcb = new TabCalBean(); tcb = getTabInfo(calType); tcb.setPlanCValue(plannumber); BizObject condition=JBOFactory.createBizObjectQuery(tcb.getCondition_tb(), "select * from O where flowunid = :flowunid and "+tcb.getPlanCName()+"='"+plannumber+"'").setParameter("flowunid", flowunid).getSingleResult(false); tcb.setCondition(condition); //设置已知规则 BizObjectManager m2 = JBOFactory.getBizObjectManager(tcb.getRuleTb()); 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()); 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()); 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.createBizObjectQuery(FLOW_BUSSINESS_OBJECT.CLASS_NAME,"flow_unid=:flowunid").setParameter("flowunid", flowunid).getSingleResult(false); productId=flow.getAttribute("productId").getString(); } tcb.setProductId(productId); 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存为查询客户名的表,实际上应该为当前登录人所以需要在其他方法中覆盖 * @author 孙传良 * @param calType(流程类型:项目:proj_process;合同:cont_process; *
起租:onHire_process;多次起租只读onHire_ready_process *
项目只读:proj_ready_process;合同只读:cont_ready_process;客户:quoted_price) *
proj_process --vi_c1_condition --vi_fund_rent_plan_proj_temp *
proj_ready_process --vi_c1_condition --vi_fund_rent_plan_proj_temp *
cont_process --vi_c1_condition --vi_fund_rent_plan_temp *
cont_ready_process --vi_c1_condition --vi_fund_rent_plan_temp *
onHire_process --vi_c1_condition --vi_fund_rent_plan_before->vi_fund_rent_plan_temp *
onHire_more_process --vi_onHire_condition_temp --vi_fund_rent_plan_onHire_temp *
onHire_more_ready_process --vi_onHire_condition_temp --vi_fund_rent_plan_onHire_temp *
quoted_price --vi_quot_price_condition --vi_quot_price_rent_plan *
quoted_ready_price --vi_quot_price_condition --vi_quot_price_rent_plan * @return TabCalBean 返回操作表的bean类 */ public static TabCalBean getTabInfo(String calType) throws Exception{ TabCalBean tcb = new TabCalBean(); tcb.setCalType(calType); tcb.setFundFundPlan_tb("jbo.app.tenwa.calc.LC_FUND_PLAN_TEMP"); tcb.setCondition_tb("jbo.app.tenwa.calc.LC_CALC_CONDITION_TEMP"); tcb.setContractCashTb("jbo.app.tenwa.calc.LC_CASH_FLOW_TEMP"); tcb.setRentPlan_tb("jbo.app.tenwa.calc.LC_RENT_PLAN_TEMP"); tcb.setRuleTb("jbo.app.tenwa.calc.LC_CALC_RULES_TEMP"); tcb.setPeriodTb("jbo.app.tenwa.calc.LC_CALC_PERIOD_TEMP"); tcb.setSubsectionTb("jbo.app.tenwa.calc.LC_CALC_SUBSECTION_TEMP"); tcb.setCalcFund("jbo.app.tenwa.calc.LC_FUND_CONDITION_TEMP"); if ("proj_process".equals(calType) || "proj_ready_process".equals(calType)) {// 项目和项目只读都是来自同一个视图 tcb.setPlanCName("PROJECT_PLAN_NUMBER"); tcb.setUserId("vi_proj_cust");// 用来查询客户名的视图 } else if ("cont_process".equals(calType) || "cont_ready_process".equals(calType)) {// 合同 tcb.setPlanCName("CONTRACT_PLAN_NUMBER"); tcb.setUserId("vi_contract_cust"); } else if ("quoted_price".equals(calType) || "quoted_ready_price".equals(calType)) {// 客户报价 tcb.setFundFundPlan_tb("jbo.app.tenwa.calc.LC_CUSTOMER_FUND_PLAN"); tcb.setCondition_tb("jbo.app.tenwa.calc.LC_CUSTOMER_CONDITION"); tcb.setContractCashTb("jbo.app.tenwa.calc.LC_CUSTOMER_CASH_FLOW"); tcb.setRentPlan_tb("jbo.app.tenwa.calc.LC_CUSTOMER_RENT_PLAN"); tcb.setRuleTb("jbo.app.tenwa.calc.LC_CUSTOMER_RULES"); tcb.setPeriodTb("jbo.app.tenwa.calc.LC_CUSTOMER_PERIOD"); tcb.setSubsectionTb("jbo.app.tenwa.calc.LC_CUSTOMER_SUBSECTION"); tcb.setPlanCName("QUOT_ID"); } else if("pay_process".equals(calType)){//投放时 tcb.setPlanCName("PAYMENT_NUMBER"); tcb.setUserId("vi_contract_cust"); }else if ("onHire_process".equals(calType)) {// 起租时 tcb.setPlanCName("PAYMENT_NUMBER"); tcb.setUserId("vi_contract_cust"); }else {// 默认为合同 tcb.setPlanCName("PAYMENT_NUMBER"); tcb.setUserId("vi_contract_cust"); } return tcb; } }