
package nc.bs.pub.action;

import nc.bs.framework.common.NCLocator;
import nccloud.bs.ic.ic.aggbusi.plugin.bpplugin.NccsynergyPluginPoint;
import nc.bs.pubapp.pf.action.AbstractPfAction;
import nc.bs.pubapp.pub.rule.UnapproveStatusCheckRule;
import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser;
import nc.itf.ic.ic.INccsynergyMaintain;
import nc.vo.sap.syproconfig.AggSyProConfigVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.VOStatus;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;

public class N_4008_UNAPPROVE extends AbstractPfAction<AggSyProConfigVO> {

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

                return processor;
        }

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

}
