
package nc.bs.pub.action;

import nc.bs.framework.common.NCLocator;
import nccloud.bs.hrkq.hrkq.aggbusi.plugin.bpplugin.MonthOtTimeVOPluginPoint;
import nc.bs.pubapp.pf.action.AbstractPfAction;
import nc.bs.pubapp.pub.rule.UnapproveStatusCheckRule;
import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser;
import nccloud.itf.hrkq.hrkq.IMonthottimevoMaintain;
import nc.vo.hrkq.monthottime.AggMonthOtTimeVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.VOStatus;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;

public class N_6QOT_UNAPPROVE extends AbstractPfAction<AggMonthOtTimeVO> {

        @Override
        protected CompareAroundProcesser<AggMonthOtTimeVO> getCompareAroundProcesserWithRules(
                        Object userObj) {
                CompareAroundProcesser<AggMonthOtTimeVO> processor = new CompareAroundProcesser<AggMonthOtTimeVO>(
                                MonthOtTimeVOPluginPoint.UNAPPROVE);
                // TODO 在此处添加前后规则
                processor.addBeforeRule(new UnapproveStatusCheckRule());

                return processor;
        }

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

}
