package com.tenwa.reckon.handler; import java.util.Map; import com.amarsoft.app.util.ProductParamUtil; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; import com.amarsoft.awe.dw.handler.impl.CommonHandler; import com.tenwa.reckon.bean.TabCalBean; import com.tenwa.reckon.check.PaymentPlanCheck; import com.tenwa.reckon.util.TbBeanTools; public class PaymentPlanHandler extends CommonHandler{ @Override protected boolean validityCheck(BizObject bo, boolean isInsert) { try { String message=""; String calType=this.asPage.getAttribute("calType"); if("pay_process".equals(this.asPage.getAttribute("calType"))){ message=PaymentPlanCheck.paymentPlanCheck(bo); } if(message.length()>2){ this.errors=message; return false; } String productId=this.asPage.getAttribute("ProductId"); Map> map=ProductParamUtil.getProductComponentType(productId, "PRD0315"); TabCalBean tcb=TbBeanTools.getTabInfo(calType); BizObjectManager bm=JBOFactory.getBizObjectManager(tcb.getCalcFund()); bm.createQuery("delete from O where flowunid='"+bo.getAttribute("flowunid").getString()+"' and "+tcb.getPlanCName()+"='"+ bo.getAttribute(tcb.getPlanCName()).getString()+"'").executeUpdate(); for(String key:map.keySet()){ if(key.toUpperCase().indexOf("FEETYPE")>=0){ BizObject fund=bm.newObject(); fund.setAttributeValue("flowunid",bo.getAttribute("flowunid")); fund.setAttributeValue(tcb.getPlanCName(), bo.getAttribute(tcb.getPlanCName())); fund.setAttributeValue("money",bo.getAttribute(key)); fund.setAttributeValue("money_ratio",bo.getAttribute(key+"_ratio")); bm.saveObject(fund); } } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } // TODO Auto-generated method stub return super.validityCheck(bo, isInsert); } @Override protected void beforeInsert(JBOTransaction tx, BizObject bo) throws Exception { if("proj_process".equals(this.asPage.getAttribute("calType"))){ bo.setAttributeValue("CONTRACT_PLAN_NUMBER", null); bo.setAttributeValue("PAYMENT_NUMBER", null); }else if("cont_process".equals(this.asPage.getAttribute("calType"))){ bo.setAttributeValue("PAYMENT_NUMBER", null); } } }