该类是一个规则类,用于检查是否需要客户确认生成关联订户订单的动作。该类使用了注解方式定义规则,包括了名称、描述、优先级、条件和动作等内容。在条件部分,判断了服务类型是否是固网,以及检查警告类型是否为空。在动作部分,调用check方法进行检查。同时,该类还实现了AbstractSubsRelaConfirmRule抽象类,重写了其中的部分方法。

package com.ztesoft.zsmart.bss.post.cc.rule.subsevent.changesubscriptionplan.rules;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jeasy.rules.annotation.Action;
import org.jeasy.rules.annotation.Condition;
import org.jeasy.rules.annotation.Fact;
import org.jeasy.rules.annotation.Rule;

import com.ztesoft.zsmart.bss.bizcommon.coreapi.util.CommonUtil;
import com.ztesoft.zsmart.bss.cc.abe.order.SubsEventCheckOrder;
import com.ztesoft.zsmart.bss.post.cc.rule.subsevent.common.rules.AbstractSubsRelaConfirmRule;
import com.ztesoft.zsmart.bss.post.common.constant.BindTypeDef4POST;
import com.ztesoft.zsmart.bss.post.common.constant.RuleFactNameDef;
import com.ztesoft.zsmart.bss.post.common.constant.SubsEventDef;
import com.ztesoft.zsmart.bss.post.common.graph.DirectedGraph;
import com.ztesoft.zsmart.bss.post.common.helper.PostFixHelper;
import com.ztesoft.zsmart.bss.post.infrastructure.order.extension.OrderRule;
import com.ztesoft.zsmart.bss.post.infrastructure.order.extension.OrderRuleCondition;
import com.ztesoft.zsmart.bss.post.infrastructure.order.extension.constant.OrderRuleScopeDef;
import com.ztesoft.zsmart.core.exception.BaseAppException;
import com.ztesoft.zsmart.core.service.DynamicDict;
import com.ztesoft.zsmart.core.utils.EqualsUtil;
import com.ztesoft.zsmart.core.utils.StringUtil;

/**
 * ASDF Description
 *
 * @author 0027024062<br>
 * @version 1.0<br>
 * @since V8.1E <br>
 */
@OrderRule
@Rule(name = 'CheckNeedSubsRelaConfirmRule', description = '启动业务前需要客户确认生成关联订户订单的动作', priority = 10)
@OrderRuleCondition(subsEventId = {
    SubsEventDef.CHANGE_SUBSCRIBER_PLAN_329
}, scope = OrderRuleScopeDef.FIX)
public class CheckNeedSubsRelaConfirmRule extends AbstractSubsRelaConfirmRule {

    /**
     * @param subsEventCheckOrder <br>
     * @return <br>
     * @throws BaseAppException <br>
     */
    @Condition
    public boolean isMatch(@Fact(RuleFactNameDef.SUBS_EVENT_CHECK_ORDER) SubsEventCheckOrder subsEventCheckOrder)
        throws BaseAppException {
        if (!PostFixHelper.isFix(subsEventCheckOrder.getServType())) {
            logger.debug('ServType[{}] is not fix product, return.', subsEventCheckOrder.getServType());
            return false;
        }
        return StringUtil.isEmpty(subsEventCheckOrder.getCheckAlertType());
    }

    @Override
    protected void checkByDifferentProd(DirectedGraph<Long> directedGraph, DynamicDict parentSubsDict,
        SubsEventCheckOrder subsEventCheckOrder, List<DynamicDict> subsList) throws BaseAppException {

    }

    @Override
    protected void checkCustomEvent(DirectedGraph<Long> directedGraph, DynamicDict parentSubsDict,
        SubsEventCheckOrder subsEventCheckOrder, HashMap<Long, DynamicDict> subsMappingSubsDict)
        throws BaseAppException {
        if (EqualsUtil.equals(subsEventCheckOrder.getSubsEventId(),
            Long.valueOf(SubsEventDef.CHANGE_SUBSCRIBER_PLAN_329))) {
            // Fallback/DiverseFrom关联关系的产品事件设置
            setOperSubsEventByFallbackBindType(subsMappingSubsDict);
        }

    }

    @Override
    protected void checkByBundleMember(DirectedGraph<Long> directedGraph, DynamicDict parentSubsDict,
        SubsEventCheckOrder subsEventCheckOrder, List<DynamicDict> subsList) throws BaseAppException {

    }

    @Override
    protected void checkForceAccept(SubsEventCheckOrder subsEventCheckOrder, DynamicDict sourceSubsDict,
        DynamicDict targetSubsDict) throws BaseAppException {

    }

    /**
     * 根据产品关系设置可选事件列表
     *
     * @param subsMappingSubsDict <br>
     * @throws BaseAppException <br>
     */
    private void setOperSubsEventByFallbackBindType(HashMap<Long, DynamicDict> subsMappingSubsDict)
        throws BaseAppException {
        String operSubsEventIds = StringUtil.getStringDivideByCommaFromList(new Object[] {
            SubsEventDef.MODIFY_432
        }, false);

        for (Map.Entry<Long, DynamicDict> subsMappingDict : subsMappingSubsDict.entrySet()) {
            if (CommonUtil.eitherEquals(subsMappingDict.getValue().getString('BIND_TYPE'),
                BindTypeDef4POST.IS_DIVERSE_FROM, BindTypeDef4POST.IS_BACKUP_OF)) {
                // 设置可选事件
                subsMappingDict.getValue().set('OPER_SUBS_EVENT_IDS', operSubsEventIds);
                subsMappingDict.getValue().set('DEFAULT_EVENT', SubsEventDef.MODIFY_432);
            }
        }
    }

    /**
     * 动作
     *
     * @param subsEventCheckOrder <br>
     * @throws BaseAppException <br>
     */
    @Action
    public void invoke(@Fact(RuleFactNameDef.SUBS_EVENT_CHECK_ORDER) SubsEventCheckOrder subsEventCheckOrder)
        throws BaseAppException {
        this.check(subsEventCheckOrder, null);
    }

}
CheckNeedSubsRelaConfirmRule: 检查是否需要客户确认生成关联订户订单

原文地址: https://www.cveoy.top/t/topic/ndjR 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录