package nc.bs.pub.action;

import nc.bs.pubapp.pf.action.AbstractPfAction;
import nc.bs.hr.baod_orders.ace.bp.AceBaod_ordersUnApproveBP;
import nc.bs.hr.baod_orders.plugin.bpplugin.Baod_ordersPluginPoint;
import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser;
import nc.vo.th.baod.entity.AggBaodVO;
import nc.impl.pubapp.pattern.rule.IRule;
import nc.vo.pub.VOStatus;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.bs.framework.common.NCLocator;

public class N_YGBD_UNAPPROVE extends AbstractPfAction<AggBaodVO> {

  public N_YGBD_UNAPPROVE() {
    super();
  }

  @Override
  protected CompareAroundProcesser<AggBaodVO> getCompareAroundProcesserWithRules(
      Object userObj) {
    CompareAroundProcesser<AggBaodVO> processor =
        new CompareAroundProcesser<AggBaodVO>(
            Baod_ordersPluginPoint.UNAPPROVE);
   // TODO 在此处添加前后规则
		   IRule<AggBaodVO> rule=null;
					  				   				     rule = new nc.bs.pubapp.pub.rule.UnapproveStatusCheckRule();
				   				   				    				   				   
				   				     processor.addBeforeRule(rule);
				   				   
  
				      return processor;
  }

  @Override
  protected AggBaodVO[] processBP(Object userObj,
      AggBaodVO[] clientFullVOs, AggBaodVO[] originBills) {
    for (int i = 0; clientFullVOs != null && i < clientFullVOs.length; i++) {
			        clientFullVOs[i].getParentVO().setStatus(VOStatus.UPDATED);
		    }
		    AggBaodVO[] bills = null;
      try {
          nc.itf.hr.IBaod_ordersMaintain operator = NCLocator.getInstance().lookup(nc.itf.hr.IBaod_ordersMaintain.class);
          bills=operator.unapprove(clientFullVOs,originBills);
      } catch (BusinessException e) {
				          ExceptionUtils.wrappBusinessException(e.getMessage());
			      }
    return bills;
  }

}
