基于Groovy的规则脚本引擎

预研笔记
https://blog.youkuaiyun.com/weixin_34206899/article/details/87268761

protected RuleManager ruleMananger;
	public Map<String, Object> execute(String directoryName, String ruleName,
			Map<String, Object> problem, String[] strings) {
		try {
			return ruleMananger.execute(directoryName, ruleName, problem, strings);
		} catch (EcadBaseException e) {
			e.printStackTrace();
			ruleMananger.storeRuleExceptionLog(null, e);
			throw new BusinessException(e.getMess());
		}
	}
public interface RuleManager extends BaseManager {
	
	
	public static final String ID = "序号";
	
	public static final String IDS = "序号集";
	
	public static final String DATE = "日期";
	
	public static final String START_DATE = "开始日期";
	
	public static final String END_DATE = "结束日期";
	
	public static final String BALANCE = "结算标识";
	
	Map<String, Object> execute(String directoryName,String ruleName,
			Map<String, Object> problem,String[] strings);
	
	Map<String, Object> execute(String directoryName,String ruleName,
			Map<String, Object> problem);
	
	
	List<Map<String,Object>> getAllRuleTableDetail(String[] binds,Object... objects);
	
	Object getSingleRuleTableDetail(String[] binds,Object... objects);
	
	Map<String,Object> getRuleTableDetail(String[] binds,Object... objects);
	
	List<Map<String,Object>> getMultipleRuleTableDetail(String[] binds,Object... objects);
	
	@Transactional
	void storeRuleExceptionLog(String gourpNo,String process,EcadBaseException ecadBaseException);
	
	@Transactional
	void storeRuleExceptionLog(String process,EcadBaseException ecadBaseException);
	
	@Transactional
	void refreshVersionHashCode();
	
	
	Boolean isLoader();
}
package com.vtradex.rule.server.service.rule.pojo;

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

import org.springframework.util.Assert;

import com.vtradex.engine.exception.EcadBaseException;
import com.vtradex.engine.groovy.Launcher;
import com.vtradex.rule.server.loader.IRuleTableLoader;
import com.vtradex.rule.server.loader.IThornRuleLoader;
import com.vtradex.rule.server.model.exception.RuleExceptionLog;
import com.vtradex.rule.server.model.rule.Directory;
import com.vtradex.rule.server.model.rule.Version;
import com.vtradex.rule.server.service.rule.RuleManager;
import com.vtradex.thorn.server.exception.BusinessException;
import com.vtradex.thorn.server.model.security.User;
import com.vtradex.thorn.server.service.pojo.DefaultBaseManager;
import com.vtradex.thorn.server.util.BeanUtils;
import com.vtradex.thorn.server.util.Constant;
import com.vtradex.thorn.server.web.security.UserHolder;


public class DefaultRuleManager extends DefaultBaseManager implements
		RuleManager {
	
	private IThornRuleLoader thornRuleLoader;
	private IRuleTableLoader ruleTableLoader;
	
	public IThornRuleLoader getIThornRuleLoader(){
		if(thornRuleLoader == null){
			thornRuleLoader = (IThornRuleLoader)applicationContext.getBean("thornRuleLoader");
		}
		return thornRuleLoader;
	}
	
	public IRuleTableLoader getIRuleTableLoader(){
		if(ruleTableLoader == null){
			ruleTableLoader = (IRuleTableLoader)applicationContext.getBean("ruleTableLoader");
		}
		return ruleTableLoader;
	}
	
	
	public Boolean isLoader(){
		return getIThornRuleLoader().isLoader() && getIRuleTableLoader().isLoader();
	}
	
	protected Directory getDirectoryByUnqie(String name){
		String hashCode = BeanUtils.getFormat(name);
		String hql = "FROM Directory directory WHERE directory.hashCode = :hashCode";
		return (Directory)commonDao.findByQueryUniqueResult(hql, new String[]{"hashCode"}, new Object[]{hashCode});
	}
	
	public Map<String, Object> execute(String directoryName,String ruleName,
			Map<String, Object> problem){
		return execute(directoryName, ruleName, problem,new String[]{
				Constant.NULL,Constant.NULL,Constant.NULL,
				Constant.NULL,Constant.NULL});
	}
	
	public Map<String, Object> execute(String directory
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值