一、系统预制功能扩展方式

编写规则

图 1

规则一

package com.yonyou.ucf.mdf.domain.rules;

import com.yonyou.ucf.mdd.common.interfaces.context.ISimpleUser;
import com.yonyou.ucf.mdd.common.model.rule.RuleContext;
import com.yonyou.ucf.mdd.common.model.rule.RuleExecuteResult;
import com.yonyou.ucf.mdd.common.model.uimeta.UIMetaBaseInfo;
import com.yonyou.ucf.mdd.rule.base.AbstractRule;
import com.yonyou.ucf.mdf.app.exceptions.BusinessException;
import com.yonyou.ucf.mdf.domain.util.CommonUtil;
import org.imeta.orm.base.BizObject;
import org.springframework.stereotype.Component;

import java.util.Iterator;
import java.util.List;

/**
 * @author nishch
 * @version 1.0
 * @date 2020/4/14
 * @des
 */
@Component("activityRule")
public class ActivityRule extends AbstractRule {



    @Override
    public <T> RuleExecuteResult execute(RuleContext ruleContext, T... tObjs) throws Exception {
        //获取当前用户信息
        ISimpleUser user = CommonUtil.getCurrentUser();
        //获取UI元数据
        UIMetaBaseInfo uiMetaBaseInfo = ruleContext.getUiMetaBaseInfo();
        //取业务数据
        List<BizObject> bizObjectList = this.getBizObjects(uiMetaBaseInfo, ruleContext);
        Iterator var6 = bizObjectList.iterator();
        while(var6.hasNext()) {
            BizObject bizObject = (BizObject)var6.next();
            if(null==bizObject.get("name")){
                throw  new BusinessException("不能为空");
            }
        }
        //规则间数据传递
        ruleContext.setCusMapValue("mycontent","12345");
        return new RuleExecuteResult();
    }
}

规则二

package com.yonyou.ucf.mdf.domain.rules;

import com.yonyou.ucf.mdd.common.model.rule.RuleContext;
import com.yonyou.ucf.mdd.common.model.rule.RuleExecuteResult;
import com.yonyou.ucf.mdd.common.model.uimeta.UIMetaBaseInfo;
import com.yonyou.ucf.mdd.rule.base.AbstractRule;
import com.yonyou.ucf.mdf.domain.service.MddActivityService;
import org.imeta.orm.base.BizObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author nishch
 * @version 1.0
 * @date 2020/4/14
 * @des
 */
@Component("activityRule2")
public class ActivityRule2 extends AbstractRule {


    @Autowired
    MddActivityService mddActivityService;

    @Override
    public <T> RuleExecuteResult execute(RuleContext ruleContext, T... tObjs) throws Exception {
        //获取上个规则设置的值
        String preRule =ruleContext.getCusMapValue("mycontent").toString();
        System.out.println(preRule);
        //调用数据库操作
        UIMetaBaseInfo uiMetaBaseInfo = ruleContext.getUiMetaBaseInfo();
        //获取实体
        List<BizObject> bizObjectList = this.getBizObjects(uiMetaBaseInfo, ruleContext);
        BizObject bizObject = bizObjectList.get(0);
        mddActivityService.select(bizObject);
        return new RuleExecuteResult();
    }
}

绑定规则

图 2

图 3

图 4

测试

Copyright © 用友客户成功部 2020 all right reserved,powered by Gitbook修订时间: 2020-09-10 09:45:34

results matching ""

    No results matching ""