-1
我正在做一些相当简单的事情,希望我只是想念一条简单的声明,我正在尝试做一个小组并完成总结,但似乎无法使DataWeave完成任务我。任何帮助将非常感激!Mule DataWeave Group by And Sum
我有下面的XML
<?xml version="1.0" encoding="UTF-8"?>
<getRecordsResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<getRecordsResult>
<company>0a6979a72ba5020092d4a5a667da15ac</company>
<u_billed_amount>504</u_billed_amount>
</getRecordsResult>
<getRecordsResult>
<company>548839a72ba5020092d4a5a667da15e0</company>
<u_billed_amount>29.17</u_billed_amount>
</getRecordsResult>
<getRecordsResult>
<company>0a6979a72ba5020092d4a5a667da15ac</company>
<u_billed_amount>33.75</u_billed_amount>
</getRecordsResult>
而且在dataWeave表达如下 -
%dw 1.0
%output application/xml
%namespace ns0 http://www.service-now.com/u_incident_task
---
results: {(
payload.getRecordsResponse.*getRecordsResult groupBy $.company map {
amtToBill: ($.u_billed_amount)
}
)}
其产生期望的分组,但是我需要总结结算的金额。
<?xml version='1.0' encoding='UTF-8'?>
<results>
<amtToBill>
<u_billed_amount>29.17</u_billed_amount>
</amtToBill>
<amtToBill>
<u_billed_amount>504</u_billed_amount>
<u_billed_amount>33.75</u_billed_amount>
</amtToBill>
</results>
我需要的是以下
<?xml version='1.0' encoding='UTF-8'?>
<results>
<amtToBill>
<u_billed_amount>29.17</u_billed_amount>
</amtToBill>
<amtToBill>
<u_billed_amount>537.75</u_billed_amount>
</amtToBill>
</results>
我知道必须有在dataWeave求和,我还没有找到它。
当我发现我的答案,当我公司添加的结果就会失控 –