三、新增功能MDD原生方式

一、编写规则

(和系统预制功能扩展方式规则相同,可跳过第一节)

图 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();
    }
}

规则二

MddActivityService 请查看MDD操作数据库

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

图 5

  • 点击确定

图 6

  • 再点击进来可以看到系统自动生成了请求地址

图 7

三、新增按钮

图 8

图 9

四、绑定命令

图 10

图 11

图 12

五、验证

请求入口

图 13

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

results matching ""

    No results matching ""