gpt4 book ai didi

java - Drools 嵌套聚合

转载 作者:行者123 更新时间:2023-12-02 09:57:44 25 4
gpt4 key购买 nike

我在流口水时有以下规则。发生的情况是 $expense 是根据每张卡进行评估的。但我希望它以每个用户为基础进行评估($u)。

rule "test":

when
$u: User()
$card: Card(user_id == $u.id)
$expense: Double() from
accumulate (
$transaction: Transactions(
card_id == $card.id,
transaction_date >= 'startDate',
transaction_date <= 'endDate'
),
sum($transaction.amount)
then
// do something with expense.
// but I want to the expense to be the expense for a user. not a card.
end

最佳答案

我认为您需要在交易中添加用户 ID 字段才能实现此功能。在这种情况下,您可以从规则中删除该卡,以便它可以在用户基础上运行。

关于java - Drools 嵌套聚合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55869971/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com