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

package nc.bs.mmpac.pmo.pac0002.bp;

import nc.bs.mmpac.pmo.pac0002.bp.rule.WithUpdatePickmRule;
import nc.bs.mmpac.pmo.pac0002.pluginpoint.PMOPluginPoint;
import nc.bs.mmpac.pmo.pac0002.rule.PMOATPUpdateWithParaRule;
import nc.bs.mmpac.pmo.pac0002.rule.PMODeleteAutoDeleteMosRule;
import nc.bs.mmpac.pmo.pac0002.rule.PMODeleteAutoDeletePutPlanRule;
import nc.bs.mmpac.pmo.pac0002.rule.PMODeleteBatchCodeRule;
import nc.bs.mmpac.pmo.pac0002.rule.PMODeletePickmRule;
import nc.bs.mmpac.pmo.pac0002.rule.PMODeleteSNRule;
import nc.bs.mmpac.pmo.pac0002.rule.PMOMarkWrSNWhenDeleteRule;
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckDeleteHaveSubRule;
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckDeleteStatusRule;
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckSnBindRule;
import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckTurnedDeleteRule;
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteDeleteNum4INVP;
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteDeleteNum4MPS;
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteDeleteNum4PMO;
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteDeleteNum4PSCRecive;
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteDeleteNum4PSM;
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteDeleteNum4Renovate;
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteDeleteNum4SFC;
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteDeleteNum4SO;
import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteDeleteNum4TO;
import nc.bs.mmpub.rule.MMVOSagaFrozenValidateRule;
import nc.bs.pubapp.pub.rule.ReturnBillCodeRule;
import nc.impl.pubapp.pattern.rule.IRule;
import nc.impl.pubapp.pattern.rule.processer.AroundProcesser;
import nc.util.mmf.framework.gc.GCDeleteBPTemplate;
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
import nc.vo.mmpac.pmo.pac0002.util.PmoSagaUtil;

public class PMODeleteBP {
    public PMODeleteBP() {
    }

    public void delete(PMOAggVO[] bills) {
        GCDeleteBPTemplate<PMOAggVO> bp = new GCDeleteBPTemplate(PMOPluginPoint.DELETE);
        IRule<PMOAggVO> checkFrozenRule = new MMVOSagaFrozenValidateRule(true);
        checkFrozenRule.process(bills);
        PmoSagaUtil.addSagaAndCompensate4Delete(bills);
        this.addBeforeRule(bp.getAroundProcesser());
        this.addAfterRule(bp.getAroundProcesser());
        bp.delete(bills);
    }

    private void addBeforeRule(AroundProcesser<PMOAggVO> processer) {
        IRule<PMOAggVO> statusRule = new PMOCheckDeleteStatusRule();
        processer.addBeforeRule(statusRule);
        IRule<PMOAggVO> checkturnrule = new PMOCheckTurnedDeleteRule();
        processer.addBeforeRule(checkturnrule);
        IRule<PMOAggVO> snBindRule = new PMOCheckSnBindRule();
        processer.addBeforeRule(snBindRule);
        IRule<PMOAggVO> checkFactoryrule = new PMOATPUpdateWithParaRule(true, "55A2");
        processer.addBeforeRule(checkFactoryrule);
        IRule<PMOAggVO> rewritePSCRecive = new RewriteDeleteNum4PSCRecive();
        processer.addBeforeRule(rewritePSCRecive);
        IRule<PMOAggVO> rewritewr = new RewriteDeleteNum4Renovate();
        processer.addBeforeRule(rewritewr);
        IRule<PMOAggVO> rewriteso = new RewriteDeleteNum4SO();
        processer.addBeforeRule(rewriteso);
        IRule<PMOAggVO> rewritepsm = new RewriteDeleteNum4PSM();
        processer.addBeforeRule(rewritepsm);
        IRule<PMOAggVO> rewritepo = new RewriteDeleteNum4MPS();
        processer.addBeforeRule(rewritepo);
        IRule<PMOAggVO> rewriteinvp = new RewriteDeleteNum4INVP();
        processer.addBeforeRule(rewriteinvp);
        IRule<PMOAggVO> rewriteto = new RewriteDeleteNum4TO();
        processer.addBeforeRule(rewriteto);
        IRule<PMOAggVO> rewritesfc = new RewriteDeleteNum4SFC();
        processer.addBeforeRule(rewritesfc);
    }

    private void addAfterRule(AroundProcesser<PMOAggVO> processer) {
        IRule<PMOAggVO> checksubbill = new PMOCheckDeleteHaveSubRule();
        processer.addAfterRule(checksubbill);
        IRule<PMOAggVO> pmorule = new RewriteDeleteNum4PMO();
        processer.addAfterRule(pmorule);
        IRule<PMOAggVO> deletePickmRule = new PMODeletePickmRule();
        processer.addAfterRule(deletePickmRule);
        IRule<PMOAggVO> deletebatchbill = new PMODeleteBatchCodeRule();
        processer.addAfterRule(deletebatchbill);
        IRule<PMOAggVO> autoDeletePutPlan = new PMODeleteAutoDeletePutPlanRule();
        processer.addAfterRule(autoDeletePutPlan);
        IRule<PMOAggVO> autoDeleteMos = new PMODeleteAutoDeleteMosRule();
        processer.addAfterRule(autoDeleteMos);
        IRule<PMOAggVO> snDeleteRule = new PMODeleteSNRule();
        processer.addAfterRule(snDeleteRule);
        IRule<PMOAggVO> wrMarkRule = new PMOMarkWrSNWhenDeleteRule();
        processer.addAfterRule(wrMarkRule);
        IRule<PMOAggVO> checkFactoryrule = new PMOATPUpdateWithParaRule(false, "55A2");
        processer.addAfterRule(checkFactoryrule);
        IRule<PMOAggVO> billcoderule = new ReturnBillCodeRule("55A2", "vbillcode", "pk_group", "pk_org");
        processer.addAfterRule(billcoderule);
        processer.addAfterRule(new WithUpdatePickmRule());
    }
}
