drools下用dmn实现一个中文例子

问题

在这里插入图片描述
因为有重复的,所以只实现黄色部分

请求body

{
    "model-namespace": "https://kiegroup.org/dmn/_23E0BA9E-73E3-4E66-818E-343F46FAAF1E",
    "model-name": "aliMember",
    "dmn-context": {
        
        "currentValues":{
            "currentGrowth":100,
            "currentPoint":200,
            "currentDate":"2022-10-10",
            "currentMemberLevel":"黄金会员",
            "currentYuEBaoDaliyBalance":10000,
            "formerYuEBaoDaliyBalance":10000
        },
        "behavior": {
            "behaviorType": "信用卡还款",
            "behaviorAmount": 40
        },
        "growthBehaviorCount": {
            "手机充值": {
                "2022-10":1,
                "2022-11":2
            },
            "余额宝": {
                "2022-11":10000
            }
        }, 
        "pointBehaviorCount": {
            "支付": {
                "2022-10-10":10
            },
            "账户服务": {
                "2022-10":5
            },
            "余额宝": {
                "2022-10":0
            }
        }
    }
}

返回结果

{
    "type": "SUCCESS",
    "msg": "OK from container 'aliMember_1.0.0-SNAPSHOT'",
    "result": {
        "dmn-evaluation-result": {
            "messages": [],
            "model-namespace": "https://kiegroup.org/dmn/_23E0BA9E-73E3-4E66-818E-343F46FAAF1E",
            "model-name": "aliMember",
            "decision-name": [],
            "dmn-context": {
                "积分兑换权益": [
                    "300元提现免费额度",
                    "300元信用卡还款免费额度"
                ],
                "pointToAdd": 5,
                "current支付point": 10,
                "pointOutput": 205,
                "growthToAdd": 0,
                "年底后会员等级变更为": "大众会员",
                "growthBehaviorCount": {
                    "余额宝": {
                        "2022-11": 10000
                    },
                    "手机充值": {
                        "2022-10": 1,
                        "2022-11": 2
                    }
                },
                "growthOutput": 100,
                "pointBehaviorCount": {
                    "账户服务": {
                        "2022-10": 5
                    },
                    "支付": {
                        "2022-10-10": 10
                    },
                    "余额宝": {
                        "2022-10": 0
                    }
                },
                "会员权益": "免费还款额度(2000/每月),免费提现(1积分兑换3元提现额度、单笔提现最高50000),话费充值(满100减2),超优汇率(2次/每季度)",
                "behavior": {
                    "behaviorAmount": 40,
                    "behaviorType": "信用卡还款"
                },
                "currentValues": {
                    "currentYuEBaoDaliyBalance": 10000,
                    "formerYuEBaoDaliyBalance": 10000,
                    "currentMemberLevel": "黄金会员",
                    "currentDate": "2022-10-10",
                    "currentGrowth": 100,
                    "currentPoint": 200
                },
                "current账户服务point": 5,
                "余额宝积分本月加过多少": 0
            },
            "decision-results": {
                "_D27FAFC9-B2DB-400C-A78B-14F1D5795A86": {
                    "messages": [],
                    "decision-id": "_D27FAFC9-B2DB-400C-A78B-14F1D5795A86",
                    "decision-name": "growthOutput",
                    "result": 100,
                    "status": "SUCCEEDED"
                },
                "_62C49CD6-B8D6-4470-97C0-4F006EC41C4B": {
                    "messages": [],
                    "decision-id": "_62C49CD6-B8D6-4470-97C0-4F006EC41C4B",
                    "decision-name": "current支付point",
                    "result": 10,
                    "status": "SUCCEEDED"
                },
                "_C0103FF4-5B49-4909-9E5A-4FA56E788697": {
                    "messages": [],
                    "decision-id": "_C0103FF4-5B49-4909-9E5A-4FA56E788697",
                    "decision-name": "current账户服务point",
                    "result": 5,
                    "status": "SUCCEEDED"
                },
                "_B9316637-7ED6-4D27-980E-F8BF1D3F5905": {
                    "messages": [],
                    "decision-id": "_B9316637-7ED6-4D27-980E-F8BF1D3F5905",
                    "decision-name": "pointOutput",
                    "result": 205,
                    "status": "SUCCEEDED"
                },
                "_D98E0410-7259-4271-B528-3BB44659F7B0": {
                    "messages": [],
                    "decision-id": "_D98E0410-7259-4271-B528-3BB44659F7B0",
                    "decision-name": "积分兑换权益",
                    "result": [
                        "300元提现免费额度",
                        "300元信用卡还款免费额度"
                    ],
                    "status": "SUCCEEDED"
                },
                "_50E9A543-8B4C-401D-A93F-5B9E4CA035B8": {
                    "messages": [],
                    "decision-id": "_50E9A543-8B4C-401D-A93F-5B9E4CA035B8",
                    "decision-name": "pointToAdd",
                    "result": 5,
                    "status": "SUCCEEDED"
                },
                "_3B1CC618-14DE-44E5-B825-2AC1C55E7F60": {
                    "messages": [],
                    "decision-id": "_3B1CC618-14DE-44E5-B825-2AC1C55E7F60",
                    "decision-name": "年底后会员等级变更为",
                    "result": "大众会员",
                    "status": "SUCCEEDED"
                },
                "_AFB5BF4D-354C-4C72-A181-8DF0E41BC5DB": {
                    "messages": [],
                    "decision-id": "_AFB5BF4D-354C-4C72-A181-8DF0E41BC5DB",
                    "decision-name": "会员权益",
                    "result": "免费还款额度(2000/每月),免费提现(1积分兑换3元提现额度、单笔提现最高50000),话费充值(满100减2),超优汇率(2次/每季度)",
                    "status": "SUCCEEDED"
                },
                "_6A4C6E38-A70D-46CC-97EF-5A6391BC6CB8": {
                    "messages": [],
                    "decision-id": "_6A4C6E38-A70D-46CC-97EF-5A6391BC6CB8",
                    "decision-name": "余额宝积分本月加过多少",
                    "result": 0,
                    "status": "SUCCEEDED"
                },
                "_008F19CE-1A67-4A48-A3A8-413D2A20E370": {
                    "messages": [],
                    "decision-id": "_008F19CE-1A67-4A48-A3A8-413D2A20E370",
                    "decision-name": "growthToAdd",
                    "result": 0,
                    "status": "SUCCEEDED"
                }
            }
        }
    }
}

在这里插入图片描述
dmn文件待上传

有几个经验 或者叫违反常识的地方

  1. currentValues.currentDate是date类型的,但需要 date(currentValues.currentDate).year 才能用.year .month .day
  2. 不能用 date(currentValues.currentDate).year+“-”+date(currentValues.currentDate).year 而是用string(date(currentValues.currentDate).year)+“-”+string(date(currentValues.currentDate).month)
  3. if get value(pointBehaviorCount.支付,
    string(date(currentValues.currentDate).year)+“-”
    +string(date(currentValues.currentDate).month)+“-”
    +string(date(currentValues.currentDate).day) ) < 20 then else 0 会报类型转换错误
    if get value(pointBehaviorCount.支付,
    string(date(currentValues.currentDate).year)+“-”
    +string(date(currentValues.currentDate).month)+“-”
    +string(date(currentValues.currentDate).day) )+0 < 20 then else 0 这样就ok了 . 不知为什么
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值