DomainMethodReference

用于支持跨域调用

方法签名

@DomainMethodReference(configuration = class,entityId = "",methodName = "",fallback = true)

方法入参

  • Class clazz: 配置类 一般继承 BasedGroupDomainReferenceConfiguration
  • String entityId:调用Class实体编号(对应xml的 id)
  • String methodName:调用Class方法的名称
  • Boolean fallback:如果调用失败 是否执行 本身方法 默认是false (直接报错提示)

示例代码

//示例1
//物料域的 Invent app 有一个InventCountUitl Class 类 现在需要从 物料域2 Sales app 调用 其中的 countListMake方法执行其业务逻辑
//物料域的  Invent App 内方法 
public class InventCountUtil extends BaseInventCountUtil{
    /**
     * 库存盘点-批量制单
     * @param inventCountIdList  盘点单号
     * @param make 制单状态
     */
    @Util
    public void countListMake(List<String> inventCountIdList, boolean make){
        for (String inventCountId : inventCountIdList) {
            GongqiSession.ttsbegin();
            BillLineAbnormalInfo.util().clearByBillId(GOTHelper.getEntityId(InventCountLine.class), inventCountId);
            GongqiSession.ttscommit();
            try {
                GongqiSession.ttsbegin();
                countMake(inventCountId, make);
                GongqiSession.ttscommit();
            } catch (Exception e) {
                try {
                    GongqiSession.ttsrollback();
                } catch (Exception e2) {
                }
                GongqiSession.ttsbegin();
                BillLineAbnormalInfo.util().findOrCreate(GOTHelper.getEntityId(InventCountLine.class), SysTimeHelper.now().getTime(), inventCountId, e.getMessage());
                GongqiSession.ttscommit();
            }
        }
    }
}


//物料域2 的 Sales App 内方法

public class Sales2InverntUtil extends BaseSales2InverntUtil{

    /**
     * 跨域调用Invent 对应 实体id是gongqi.df.invent.80400005 的class 里面的 countListMake 方法
     */
    @Util
    @DomainMethodReference(configuration = ArInterfaceConfig.class,entityId = "gongqi.df.invent.80400005",methodName = "countListMake")
    public void countListMake(List<String> inventCountIdList, boolean make){
            throw new ERPException("未找到对应调用方法");
    }
}


//物料域2 的 Sales App 内方法具体调用

    public CommandResult afterInit(CommandArg arg) {
        Sales2InverntUtil.Util().countListMake();
        return  super.afterInit(arg);
    }

配置 class

import java.util.Map;

import gongqi.erp.os.domain.BasedGroupDomainReferenceConfiguration;

public class ArInterfaceConfig extends  BasedGroupDomainReferenceConfiguration {

    @Override
    protected boolean filterDomain(String domainName, Map<String, Map<String, String>> domainLayers) {
        if (domainLayers.containsKey("obj")) {
            return domainLayers.get("obj").get("namespace").contains("fund");//可以根据namespace 判断调用域
        }
        return false;
    }


}

[!NOTE]

调用的方法参数 不支持 Table 对象类 其他的正常类型基本支持

返回值类型也保存一致

一致性事务

如果 配置使用了 seate xa ,可以保持两个域之间的事务一致性 如:资金域调用物料域,资金域调用失败数据回滚 要求物料域也回滚

要求 两边事务正常开启,一边失败回滚 另一边也同样失败回滚

results matching ""

    No results matching ""