有 4 个字段基于其值组合,我们必须在 Mulesoft 中过滤数据
There are 4 fields based on its values combination we have to filter the data in Mulesoft
有 4 个字段基于其值组合,我们必须在 Mulesoft 中过滤数据。
示例:
输入载荷 1:
{
"Msg": {
"Code": "abc",
"Chcode": "123",
"Dcode": "55",
"Type": "pqr"
}
}
输入载荷 2:
{
"Msg": {
"Code": "klm",
"Chcode": "789",
"Dcode": "32",
"Type": "xyz"
}
}
输入载荷 3:
{
"Msg": {
"Code": "klm",
"Chcode": "456",
"Dcode": "22",
"Type": "shi"
}
}
过滤条件:输入有效载荷应与 Code、Chcode、Dcode 和 Type 匹配。
示例:输入负载应包含 Code=abc、Chcode=123、Dcode=55、Type=pqr
Code
Chcode
Dcode
Type
abc
123
55
pqr
ghl
456
22
shi
ghi
276
3u
foh
输入payload 1匹配过滤条件第一行code,Chcode,Dcode和Type相同。因此应该过滤该记录以进行处理。输入负载 3 与 Chcode、Dcode 和 Type 匹配,但与 Code 不匹配,因此忽略此记录。
像上面这些组合,共有45种组合,Mulesoft如何过滤这类记录。
此脚本是如何执行条件检查的示例:
%dw 2.0
output application/json
import * from dw::core::Arrays
import * from dw::core::Objects
var conditionsTable=[
{Code: "abc", Chcode: "123", Dcode:"55", Type: "pqr"},
{Code: "ghl", Chcode: "456", Dcode:"22", Type: "shi"},
{Code: "ghl", Chcode: "276", Dcode:"3u", Type: "foh"}
]
fun matchRecord(record, cond)=record everyEntry (value, key) -> cond[key] == value
fun matchConditions(record, conditions)=conditions some ((item) -> matchRecord(record, item))
---
matchConditions(payload.Msg, conditionsTable)
有 4 个字段基于其值组合,我们必须在 Mulesoft 中过滤数据。 示例:
输入载荷 1:
{
"Msg": {
"Code": "abc",
"Chcode": "123",
"Dcode": "55",
"Type": "pqr"
}
}
输入载荷 2:
{
"Msg": {
"Code": "klm",
"Chcode": "789",
"Dcode": "32",
"Type": "xyz"
}
}
输入载荷 3:
{
"Msg": {
"Code": "klm",
"Chcode": "456",
"Dcode": "22",
"Type": "shi"
}
}
过滤条件:输入有效载荷应与 Code、Chcode、Dcode 和 Type 匹配。
示例:输入负载应包含 Code=abc、Chcode=123、Dcode=55、Type=pqr
Code | Chcode | Dcode | Type |
---|---|---|---|
abc | 123 | 55 | pqr |
ghl | 456 | 22 | shi |
ghi | 276 | 3u | foh |
输入payload 1匹配过滤条件第一行code,Chcode,Dcode和Type相同。因此应该过滤该记录以进行处理。输入负载 3 与 Chcode、Dcode 和 Type 匹配,但与 Code 不匹配,因此忽略此记录。
像上面这些组合,共有45种组合,Mulesoft如何过滤这类记录。
此脚本是如何执行条件检查的示例:
%dw 2.0
output application/json
import * from dw::core::Arrays
import * from dw::core::Objects
var conditionsTable=[
{Code: "abc", Chcode: "123", Dcode:"55", Type: "pqr"},
{Code: "ghl", Chcode: "456", Dcode:"22", Type: "shi"},
{Code: "ghl", Chcode: "276", Dcode:"3u", Type: "foh"}
]
fun matchRecord(record, cond)=record everyEntry (value, key) -> cond[key] == value
fun matchConditions(record, conditions)=conditions some ((item) -> matchRecord(record, item))
---
matchConditions(payload.Msg, conditionsTable)