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

package nc.bs.ic.m4d.cancelsign;

import com.yonyou.cloud.ncc.plugin.entity.OperationInfo;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import nc.bs.ic.general.cancelsign.CancelSignBPTemplate;
import nc.bs.ic.general.cancelsign.ICancelSignBP;
import nc.bs.ic.general.cancelsign.ICancelSignRuleProvider;
import nc.bs.ic.general.cancelsign.rule.CancelSignCheckAssetFlag;
import nc.bs.ic.general.cancelsign.rule.CheckHandoverState;
import nc.bs.ic.m4d.base.BPPlugInPoint;
import nc.bs.ic.m4d.base.UpdateSCOnhandRule;
import nc.bs.ic.m4d.cancelsign.rule.AfterCancelSignRuleForLiabilityProcess;
import nc.bs.ic.m4d.cancelsign.rule.PushDeleteIAandTOBills;
import nc.bs.ic.pub.util.SagasUtils;
import nc.bs.scmpub.rule.VOSagaFrozenValidateRule;
import nc.impl.pubapp.pattern.rule.processer.AroundProcesser;
import nc.itf.ic.m4d.compensate.IMaterialOutSagasCompensate;
import nc.vo.ic.m4d.entity.MaterialOutVO;
import nc.vo.ic.pub.util.VOEntityUtil;
import nc.vo.scmpub.res.billtype.ICBillType;

public class CancelSignBP implements ICancelSignBP<MaterialOutVO>, ICancelSignRuleProvider<MaterialOutVO> {
    public CancelSignBP() {
    }

    public void addAfterRule(MaterialOutVO[] vos, AroundProcesser<MaterialOutVO> processor) {
        processor.addAfterRule(new UpdateSCOnhandRule(true));
        processor.addAfterRule(new AfterCancelSignRuleForLiabilityProcess());
        processor.addAfterRule(new PushDeleteIAandTOBills());

//        processor.addAfterRule(new PullProcess());
    }

    public void addBeforeRule(MaterialOutVO[] vos, AroundProcesser<MaterialOutVO> processor) {
        processor.addBeforeRule(new VOSagaFrozenValidateRule(true));
        processor.addBeforeRule(new CancelSignCheckAssetFlag());
        processor.addBeforeRule(new CheckHandoverState());
    }

    public MaterialOutVO[] cancelSign(MaterialOutVO[] vos) {
        CancelSignBPTemplate<MaterialOutVO> cancelBP = new CancelSignBPTemplate(BPPlugInPoint.CancelSignBP, this);
        SagasUtils.frozenAndAddSaga(vos, ICBillType.MaterialOut.getCode(), "1", (OperationInfo)null);
        Map<String, Serializable> paramMap = new HashMap();
        paramMap.put("actionname", "cancelsign_4D");
        paramMap.put("hid", VOEntityUtil.getPksFromAggVO(vos));
        SagasUtils.compensate(paramMap, IMaterialOutSagasCompensate.class);
        return (MaterialOutVO[])cancelBP.cancelSign(vos);
    }
}
