决策引擎
决策引擎是一种计算机程序,用于计算一个系统的决策。
目标
- 提供规则集、决策表、交叉决策表(决策矩阵)、决策树、评分卡、复杂评分卡、规则流等八种类型的业务规则设计工具
- 并发执行规则
数据库设计
规则
- 表名称:
rules
字段名称 | 字段类型 | 描述 |
---|---|---|
id | string | primary key |
created | int | 创建时间 |
updated | int | 更新时间 |
merchant | string | 商户 |
code | string | 规则编码 |
type | string(enum) | 规则类型 |
information | json(dict) | 规则信息 |
name | string | 规则名称 |
description | string | 规则描述 |
type
enum列表
- raw - 原始脚本
- ruleset - 规则集
- normal_score_card - 普通评分卡
- complex_score_card - 复杂评分卡
- decision_tree - 决策树
- decision_table - 决策表
- decision_matrix - 决策矩阵
information
json字段介绍
type == raw
时的information
|
|
type == ruleset
时的information
|
|
type == decision_table
时的information
|
|
type == decision_matrix
时的information
|
|
type == normal_score_card
时的information
|
|
type == complex_score_card
时的information
|
|
type == decision_tree
时的information
|
|
决策流
- 表名称:
decision_flow
字段名称 | 字段类型 | 描述 |
---|---|---|
id | string | primary key |
created | int | 创建时间 |
updated | int | 更新时间 |
merchant | string | 商户 |
code | string | 决策流编码 |
name | string | 决策流名称 |
description | string | 决策流描述 |
决策流-规则节点
- 表名称:
decision_flow_node
字段名称 | 字段类型 | 描述 |
---|---|---|
id | string | primary key |
created | int | 创建时间 |
updated | int | 更新时间 |
merchant | string | 商户 |
decision_flow_code | string | 决策流编码 |
rule_code | string | 规则编码 |
next_node | list[string] | 下一步规则节点编码列表 |
name | string | 规则节点名称 |
description | string | 规则节点描述 |
数据库图
接口文档
规则
创建
Request
- Method:
POST
- URL:
/v1/rule
- Headers:
Content-Type: application/json
Body
|
|
Response
|
|
描述
无
查询
Request
- Method:
GET
- URL:
/v1/rule
- Headers:
Content-Type: application/json
- Parameters
merchant
/merchant_eq
- 商户号merchant_in
- 批量查询商户code
/code_eq
- 规则编码code_in
- 批量规则编码type
/type_eq
- 规则类型type_in
- 批量规则类型
Body
无
Response
|
|
描述
无
更新
Request
- Method:
PUT
- URL:
/v1/rule
- Headers:
Content-Type: application/json
Body
|
|
Response
|
|
描述
只允许更新
information
,name
,description
删除
Request
- Method:
DELETE
- URL:
/v1/rule
- Headers:
Content-Type: application/json
Body
|
|
Response
|
|
描述
无
决策流-规则节点
创建
Request
- Method:
POST
- URL:
/v1/decision-flow-node
- Headers:
Content-Type: application/json
Body
|
|
Response
|
|
描述
无
获取
Request
- Method:
GET
- URL:
/v1/decision-flow-node
- Headers:
Content-Type: application/json
- Parameters
merchant
/merchant_eq
- 商户号merchant_in
- 批量查询商户rule_code
/rule_code_eq
- 规则编码rule_code_in
- 批量规则编码decision_flow_code
/decision_flow_code_eq
- 规则编码decision_flow_code_in
- 批量规则编码
Body
无
Response
|
|
描述
无
更新
Request
- Method:
PUT
- URL:
/v1/decision-flow-node
- Headers:
Content-Type: application/json
Body
|
|
Response
|
|
描述
只允许修改
next_node
,name
,description
删除
Request
- Method:
DELETE
- URL:
/v1/decision-flow-node
- Headers:
Content-Type: application/json
Body
|
|
Response
|
|
描述
无
决策流
创建
Request
- Method:
POST
- URL:
/v1/decison-flow
- Headers:
Content-Type: application/json
Body
|
|
Response
|
|
描述
无
获取
Request
- Method:
GET
- URL:
/v1/decision-flow
- Headers:
Content-Type: application/json
- Parameters
merchant
/merchant_eq
- 商户号merchant_in
- 批量查询商户code
/code_eq
- 决策流编码code_in
- 批量决策流编码
Body
无
Response
|
|
描述
无
更新
Request
- Method:
PUT
- URL:
/v1/decision-flow
- Headers:
Content-Type: application/json
Body
|
|
Response
|
|
描述
无
删除
Request
- Method:
DELETE
- URL:
/v1/decision-flow
- Headers:
Content-Type: application/json
Body
|
|
Response
|
|
描述
无
关键流程图
单个规则执行
决策流执行
参考文章
- 原文作者:Daryl
- 原文链接:https://siskinc.github.io/post/%E5%86%B3%E7%AD%96%E5%BC%95%E6%93%8E/
- 版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议进行许可,非商业转载请注明出处(作者,原文链接),商业转载请联系作者获得授权。