需要检查在Drools决策表中配置的值是否在范围内(上限和下限)

发布于 2025-02-11 19:20:46 字数 155 浏览 3 评论 0原文

我是流口水的新手。现在,我需要验证一个值在Drools决策表中配置的范围内。

方案:薪水是条件,等级是行动(输出)。

我需要这样的薪水 (0-10000) - A级, (10000-15000) - B级,

请帮助我设计流口水决策表。 我可以使用“”

I am new to Drools. Now I need to validate one value is within the range configured in drools decision table.

Scenario: Salary is the condition and grade is the action (output).

I need to configure the salary like this
(0 - 10000) - Grade A,
(10000 - 15000) - Grade B

Please help me to design the drools decision table.
Can I use "in"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

染柒℉ 2025-02-18 19:20:46

您将使用<>(或< = and > =)就像您一样'D在Java或DRL中进行正常比较。

伪代码,它看起来像这样:

| CONDITION        | CONDITION       | ACTION  |
| salary >= $param | salary < $param | $result |
| MIN              | MAX             | GRADE   |
| 0                | 10000           | A       |
| 10000            | 15000           | B       |

中的是流口水中的有效关键字,但这不是为此。它是用于确定是否在给定列表中的值。例如,如果您想检查一些值$颜色是红色,蓝色或绿色的颜色,则您会喜欢:$ color(“红色”,“蓝色”,“绿色”)。不适合弄清楚一个数字是否在范围内。

You'd use < and > (or <= and >=) just like you'd do a normal comparison in Java or DRL.

Pseudo-code, it would look something like this:

| CONDITION        | CONDITION       | ACTION  |
| salary >= $param | salary < $param | $result |
| MIN              | MAX             | GRADE   |
| 0                | 10000           | A       |
| 10000            | 15000           | B       |

in is a valid keyword in Drools, but it's not for this. It's for identifying if a value is in a given list. For example, if you wanted to check that some value $color is one of red, blue, or green, you'd do like: $color in ("red", "blue", "green"). It's not appropriate for figuring out if a number is in a range.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文