//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package nc.bs.pub.action;

import nc.bs.framework.common.NCLocator;
import nc.bs.mmpac.pickm.rule.ToBuyingreqRule;

import nc.bs.mmpac.pickm.rule.ToPmoRule;
import nc.bs.mmpac.pmo.pac0002.pluginpoint.PMOPluginPoint;
import nc.bs.pubapp.pf.action.AbstractPfAction;
import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser;
import nc.itf.mmpac.pickm.IPickmMaintainService;
import nc.vo.mmpac.pickm.entity.AggPickmVO;
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nccloud.vo.mmpub.utils.power.MMDataPermissionUtil;

public class N_55A3_APPROVE extends AbstractPfAction<AggPickmVO> {
    public N_55A3_APPROVE() {
    }

    protected CompareAroundProcesser<AggPickmVO> getCompareAroundProcesserWithRules(Object userObj) {

        CompareAroundProcesser<AggPickmVO> processer = new CompareAroundProcesser<AggPickmVO>(PMOPluginPoint.COMMIT);
        addAfterRule(processer);
        return processer;
    }

    protected AggPickmVO[] processBP(Object userObj, AggPickmVO[] clientFullVOs, AggPickmVO[] originBills) {
        try {
            if (super.m_tmpVo.isCloudEntry) {
                if (clientFullVOs[0].getParentVO().getFprodmode() == 2) {
                    MMDataPermissionUtil.checkPermission(clientFullVOs, "55C3", "DPickmAuditBP", "vbillcode");
                } else {
                    MMDataPermissionUtil.checkPermission(clientFullVOs, "55A3", "PickmAuditBP", "vbillcode");
                }
            }

            for(AggPickmVO aggPickm : clientFullVOs) {
                aggPickm.getParentVO().setStatus(1);
            }

            return ((IPickmMaintainService)NCLocator.getInstance().lookup(IPickmMaintainService.class)).auditPickm(clientFullVOs);
        } catch (BusinessException e) {
            ExceptionUtils.wrappException(e);
            return null;
        }
    }

    private void addAfterRule(CompareAroundProcesser<AggPickmVO> processer) {

//        processer.addAfterRule(new ToBuyingreqRule());
//        processer.addAfterRule(new ToPmoRule());
    }


}
