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

package nc.bs.so.m30.maintain;

import nc.bs.scmpub.rule.CrossRuleValidateRule;
import nc.bs.scmpub.rule.VOSagaFrozenValidateRule;
import nc.bs.so.m30.maintain.rule.insert.WritebackMaterialPriceRule;
import nc.bs.so.m30.maintain.rule.update.RewriteBillUpdateRule;
import nc.bs.so.m30.maintain.rule.update.RewritePromotePriceUpdateRule;
import nc.bs.so.m30.plugin.BP30PlugInPoint;
import nc.bs.so.m30.rule.atp.SaleOrderVOATPAfterRule;
import nc.bs.so.m30.rule.atp.SaleOrderVOATPBeforeRule;
import nc.bs.so.m30.rule.billcode.CheckUniqueBillCodeRule;
import nc.bs.so.m30.rule.billcode.UpdateBillCodeRule;
import nc.bs.so.m30.rule.businessinfo.SaveTransferMsgRule;
import nc.bs.so.m30.rule.credit.RenovateARByHidsBeginRule;
import nc.bs.so.m30.rule.credit.RenovateARByHidsEndRule;
import nc.bs.so.m30.rule.feature.CfgMatchCheckRule;
import nc.bs.so.m30.rule.feature.CfgMatchSaveRule;
import nc.bs.so.m30.rule.m35.ArsubOffsetBeforeSaveRule;
import nc.bs.so.m30.rule.m35.LrgCashMarCheckRule;
import nc.bs.so.m30.rule.maintaincheck.*;
import nc.bs.so.m30.rule.maintainprocess.*;
import nc.bs.so.m30.rule.pm.CheckBusiForPMRule;
import nc.bs.so.m30.rule.pm.CheckProjectMFGRule;
import nc.bs.so.m30.rule.pm.CheckProjectValueRule;
import nc.bs.so.m30.rule.reserve.AutoReserveRule;
import nc.bs.so.m30.rule.reserve.ReserveUpdateRule;
import nc.bs.so.m30.rule.rewrite.price.RewritePriceFormRule;
import nc.bs.so.pub.rule.CheckApproverRule;
import nc.impl.pubapp.bd.userdef.UserDefSaveRule;
import nc.impl.pubapp.pattern.data.bill.BillUpdate;
import nc.impl.pubapp.pattern.rule.ICompareRule;
import nc.impl.pubapp.pattern.rule.IRule;
import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser;
import nc.itf.scmpub.reference.uap.group.SysInitGroupQuery;
import nc.vo.credit.engrossmaintain.pub.action.M30EngrossAction;
import nc.vo.ml.NCLangRes4VoTransl;
import nc.vo.pubapp.pattern.log.TimeLog;
import nc.vo.pubapp.util.SetUpdateAuditInfoRule;
import nc.vo.scmpub.rule.AutoMaterialAssignRule;
import nc.vo.so.m30.entity.SaleOrderBVO;
import nc.vo.so.m30.entity.SaleOrderHVO;
import nc.vo.so.m30.entity.SaleOrderVO;

public class UpdateSaleOrderBP {
    public UpdateSaleOrderBP() {
    }

    public SaleOrderVO[] update(SaleOrderVO[] bills, SaleOrderVO[] originBills) {
        CompareAroundProcesser<SaleOrderVO> processer = new CompareAroundProcesser(BP30PlugInPoint.UpdateBP);
        TimeLog.logStart();
        this.addBeforeRule(processer);
        processer.before(bills, originBills);
        TimeLog.info(NCLangRes4VoTransl.getNCLangRes().getStrByID("4006011_0", "04006011-0069"));
        TimeLog.logStart();
        BillUpdate<SaleOrderVO> bo = new BillUpdate();
        SaleOrderVO[] vos = (SaleOrderVO[])bo.update(bills, originBills);
        TimeLog.info(NCLangRes4VoTransl.getNCLangRes().getStrByID("4006011_0", "04006011-0070"));
        TimeLog.logStart();
        this.addAfterRule(processer);
        processer.after(vos, originBills);
        TimeLog.info(NCLangRes4VoTransl.getNCLangRes().getStrByID("4006011_0", "04006011-0071"));
        return vos;
    }

    private void addAfterRule(CompareAroundProcesser<SaleOrderVO> processer) {
        IRule<SaleOrderVO> rule = null;
        IRule<SaleOrderVO> var5 = new UpdateSoBalanceWhenUpdateRule();
        processer.addAfterRule(var5);
        IRule<SaleOrderVO> var6 = new RenovateARByHidsEndRule(M30EngrossAction.M30Edit);
        processer.addAfterRule(var6);
        IRule<SaleOrderVO> var7 = new ThisGatheringRule();
        processer.addAfterRule(var7);
        IRule<SaleOrderVO> var8 = new CheckUniqueBillCodeRule();
        processer.addAfterRule(var8);
        ICompareRule<SaleOrderVO> compareRule = new RewriteBillUpdateRule();
        processer.addAfterRule(compareRule);
        IRule<SaleOrderVO> var9 = new SaveTransferMsgRule();
        processer.addAfterRule(var9);
        IRule<SaleOrderVO> var10 = new RewritePriceFormRule();
        processer.addAfterRule(var10);
        IRule<SaleOrderVO> var11 = new UpdateSoBalanceWhenUpdateM30HeadRule();
        processer.addAfterRule(var11);
        boolean icEnable = SysInitGroupQuery.isICEnabled();
        if (icEnable) {
            IRule<SaleOrderVO> var12 = new SaleOrderVOATPAfterRule();
            processer.addAfterRule(var12);
            IRule<SaleOrderVO> var13 = new ReserveUpdateRule();
            processer.addAfterRule(var13);
            IRule<SaleOrderVO> var14 = new AutoReserveRule();
            processer.addAfterRule(var14);
        }

        if (SysInitGroupQuery.isPRICEEnabled()) {
            ICompareRule<SaleOrderVO> var15 = new RewritePromotePriceUpdateRule();
            processer.addAfterRule(var15);
        }

        /**
         * 销售订单新增回写参考物料售价规则
         */
        IRule<SaleOrderVO> var16 = new WritebackMaterialPriceRule();
        processer.addAfterRule(var16);

    }

    private void addBeforeRule(CompareAroundProcesser<SaleOrderVO> processer) {
        IRule<SaleOrderVO> rule = null;
        IRule<SaleOrderVO> var5 = new VOSagaFrozenValidateRule();
        processer.addBeforeRule(var5);
        IRule<SaleOrderVO> var6 = new CheckCanUpdateWhenAuditing();
        processer.addBeforeRule(var6);
        IRule<SaleOrderVO> var7 = new CheckApproverRule();
        processer.addBeforeRule(var7);
        IRule<SaleOrderVO> var8 = new CfgMatchSaveRule();
        processer.addBeforeRule(var8);
        IRule<SaleOrderVO> var9 = new CfgMatchCheckRule();
        processer.addBeforeRule(var9);
        IRule<SaleOrderVO> var10 = new FillupRedundanceDataRule();
        processer.addBeforeRule(var10);
        IRule<SaleOrderVO> var11 = new FillupFretexchangeRule();
        processer.addBeforeRule(var11);
        IRule<SaleOrderVO> var12 = new SetUpdateAuditInfoRule();
        processer.addBeforeRule(var12);
        ICompareRule<SaleOrderVO> compareRule = new UpdateBillCodeRule();
        processer.addBeforeRule(compareRule);
        IRule<SaleOrderVO> var13 = new CheckMaterilaOVidRule();
        processer.addBeforeRule(var13);
        IRule<SaleOrderVO> var14 = new CheckNumPriceMnyRule();
        processer.addBeforeRule(var14);
        IRule<SaleOrderVO> var15 = new SaleOrderCheckNumAndMnyRule();
        processer.addBeforeRule(var15);
        IRule<SaleOrderVO> var16 = new CheckSettleOrgRepeat();
        processer.addBeforeRule(var16);
        IRule<SaleOrderVO> var17 = new CheckDateRule();
        processer.addBeforeRule(var17);
        processer.addBeforeRule(new AutoMaterialAssignRule("cmaterialid", new String[]{"pk_org"}, new String[]{"pk_org", "csendstockorgid", "csettleorgid", "carorgid", "cprofitcenterid", "csprofitcenterid"}));
        IRule<SaleOrderVO> var18 = new CheckSaveBillRule();
        processer.addBeforeRule(var18);
        IRule<SaleOrderVO> var19 = new RenovateARByHidsBeginRule(M30EngrossAction.M30Edit);
        processer.addBeforeRule(var19);
        boolean icEnable = SysInitGroupQuery.isICEnabled();
        if (icEnable) {
            IRule<SaleOrderVO> var20 = new SaleOrderVOATPBeforeRule();
            processer.addBeforeRule(var20);
        }

        IRule<SaleOrderVO> var21 = new LrgCashMarCheckRule();
        processer.addBeforeRule(var21);
        IRule<SaleOrderVO> var22 = new ArsubOffsetBeforeSaveRule();
        processer.addBeforeRule(var22);
        IRule<SaleOrderVO> var23 = new CheckLrgTotalMoney();
        processer.addBeforeRule(var23);
        IRule<SaleOrderVO> var24 = new CrossRuleValidateRule();
        processer.addBeforeRule(var24);
        IRule<SaleOrderVO> var25 = new UserDefSaveRule(new Class[]{SaleOrderHVO.class, SaleOrderBVO.class});
        processer.addBeforeRule(var25);
        IRule<SaleOrderVO> var26 = new CheckProjectValueRule();
        processer.addBeforeRule(var26);
        IRule<SaleOrderVO> var27 = new CheckBusiForPMRule();
        processer.addBeforeRule(var27);
        IRule<SaleOrderVO> var28 = new CheckValueWhenIsdeliveryRule();
        processer.addBeforeRule(var28);
        IRule<SaleOrderVO> var29 = new CheckProjectMFGRule();
        processer.addBeforeRule(var29);
    }
}
