UNPKG

yonbip-code-gen-mcp

Version:

YonBIP高级版代码生成MCP

102 lines (68 loc) 2.27 kB
# 自定义公式开发步骤 ## 1 开发自定义公式类 继承:nc.vo.pub.formulaset.function.NcInnerFunction 重写: function 方法 ## 2 配置xml文件 # 自定义公式代码模板 ```java import nc.vo.pub.formulaset.IFormulaConstant; import nc.vo.pub.formulaset.core.ParseException; import nc.vo.pub.formulaset.function.NcInnerFunction; import java.util.List; /** * demo 公式开发 */ public class DemoFunction extends NcInnerFunction { private static BaseDAO dao = new BaseDAO(); public DemoFunction(){ //参数个数 numberOfParameters = 1; //公式类型 functionType = IFormulaConstant.FUN_CUSTOM; //公式的描述 functionDesc = "这是一个演示公式"; } @Override public Object function(List param) throws ParseException { //参数校验 if(param.size() != numberOfParameters || param==null){ throw new ParseException("参数个数不匹配"); } //todo 实现公式逻辑 //示例公式逻辑: 操作数据库,查询一个vo 根据pk // CurrtypeVO vo = null; // try { // vo = (CurrtypeVO) getDAO().retrieveByPK(CurrtypeVO.class, currtypePk); // } catch (DAOException e) { // throw new RuntimeException(e); // } return "demo function"; } /** * 获取DAO * @return */ private BaseDAO getDAO() { return dao; } } ``` # xml 文件模板 ``` <?xml version="1.0" encoding="gb2312"?> <formula-array> <formula> <!-- 固定内容 --> <customType>0</customType> <!-- 函数名称 --> <functionName>DemoFunction(改为你自己的)</functionName> <!-- 函数类全路径 --> <functionClass>DemoFunction类全路径(改为你自己的)</functionClass> </formula> </formula-array> ``` # 注意(这个很重要,需要给用户进行输出) 配置完成需要重启 xml 文件路径为: 1 home\resources\formulaconfig\custfunction 目录下 2 或者在组件的resources下新建文件夹formulaconfig\custfunction, 导出补丁后打入home中