package nc.bs.hr.baod_orders.ace.bp;

import nc.bs.hr.baod_orders.plugin.bpplugin.Baod_ordersPluginPoint;
import nc.impl.pubapp.pattern.data.bill.template.UpdateBPTemplate;
import nc.impl.pubapp.pattern.rule.ICompareRule;
import nc.impl.pubapp.pattern.rule.IRule;
import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser;
import nc.vo.th.baod.entity.AggBaodVO;
import nc.vo.th.baod.entity.BaodItemVO;

/**
 * 修改保存的BP
 * 
 */
public class AceBaod_ordersUpdateBP {

  public AggBaodVO[] update(AggBaodVO[] bills, AggBaodVO[] originBills) {

    		    // 调用修改模板
        UpdateBPTemplate<AggBaodVO> bp = new UpdateBPTemplate<AggBaodVO>(Baod_ordersPluginPoint.UPDATE);

        // 执行前规则
        this.addBeforeRule(bp.getAroundProcesser());
        // 执行后规则
        this.addAfterRule(bp.getAroundProcesser());
        return bp.update(bills, originBills);
  }
  private void addAfterRule(CompareAroundProcesser<AggBaodVO> processer) {
  IRule<AggBaodVO> rule=null;
				  				   				    				     rule = new nc.bs.pubapp.pub.rule.BillCodeCheckRule();
				    				   				   				    				     				      ((nc.bs.pubapp.pub.rule.BillCodeCheckRule)rule).setCbilltype("YGBD");
				     				    				   				    				     				      ((nc.bs.pubapp.pub.rule.BillCodeCheckRule)rule).setCodeItem("vbillcode");
				     				    				   				    				     				      ((nc.bs.pubapp.pub.rule.BillCodeCheckRule)rule).setGroupItem("pk_group");
				     				    				   				    				     				      ((nc.bs.pubapp.pub.rule.BillCodeCheckRule)rule).setOrgItem("pk_org");
				     				    				   				   
				   				     processer.addAfterRule(rule);
				   				     
    }
  private void addBeforeRule(CompareAroundProcesser<AggBaodVO> processer) {
   IRule<AggBaodVO> rule=null;
					  				   				   				     rule = new nc.bs.pubapp.pub.rule.FillUpdateDataRule();
				    				   				   				    				     				    				   				    				      				       processer.addBeforeRule(rule);
				      				      				   				   				     ICompareRule<AggBaodVO> ruleCom = new nc.bs.pubapp.pub.rule.UpdateBillCodeRule();
				    				   				   				    				     ((nc.bs.pubapp.pub.rule.UpdateBillCodeRule)ruleCom).setCbilltype("YGBD");
				    				   				    				     ((nc.bs.pubapp.pub.rule.UpdateBillCodeRule)ruleCom).setCodeItem("vbillcode");
				    				   				    				     ((nc.bs.pubapp.pub.rule.UpdateBillCodeRule)ruleCom).setGroupItem("pk_group");
				    				   				    				     ((nc.bs.pubapp.pub.rule.UpdateBillCodeRule)ruleCom).setOrgItem("pk_org");
				    				   				    				      				       processer.addBeforeRule(ruleCom);
				      				      				   				   				     rule = new nc.bs.pubapp.pub.rule.FieldLengthCheckRule();
				    				   				   				    				     				    				   				    				      				       processer.addBeforeRule(rule);
				      				        }

}
