我们正试图通过JSON建立一个JasperReport来进行估算。头和行(多行)都很好。但是,JSON文件中还有一个节点需要在详细表中进行循环。我们使用subdataset无法实现。目前,我们使用JSONQL来迭代行。
我们无法循环使用 taxes
节点通过子数据集。
以下是JSON输入的示例。
{ "tax": [ { "tax_slab_name": "VAT Exempt", "tax_amount": "AED 20.00" }, { "tax_slab_name": "VAT 0%", "tax_amount": "30.00阿联酋迪拉姆" }, { "tax_slab_name": "VAT 5 %", "tax_amount": "50.00阿联酋迪拉姆" } ], "header": [ { "stimate_no": "EST-000054", "bill_to_address", "111 Stamm Cliffs Suite 285, Heaney Ville, Jebel Ali, Dubai, United Arab Emirates (UAE)", "ship_to_address": "111 Stamm Cliffs Suite 285, Heaney Ville, Jebel Ali, Dubai, United Arab Emirates (UAE)", "ship_to_address": "66015 شارع بلال السهلي, ممر ميسر مدني, Jebel Ali, Dubai, United Arab Emirates (UAE)", "important_date": "2020-05-08", "expiredy_date": "2020-05-23", "sub_total": 14000, "discount": 0, "tax_amt": 450, "total": 14450, "conditions": "除非另有说明,否则所有费用都以美元为单位。E.和O.E.", "状态": "SAVED", "contact_name": "Kerluke, Bartell and Dickinson (مجموعة الداوود وأولاده)" } ], "行"。[ { "item_name": "企业产品开发-JavaJSFPF", "tax_slab": 1, "uom": "box", "数量": 1, "税率": 1000, "金额": 1000 }, { "item_name": "服务器设置", "税率": 2, "数量": 1, "税率": 1000, "金额": 1000 }, { "item_name": "Server Setup", "tax_slab": 2, "uom": "cm", "数量": 2, "税率": 2000, "金额": 4000 }, { "item_name": "备份和灾难恢复服务", "tax_slab": 2, "uom": "cm", "数量": 2, "税率": 2000, "金额": 4000 } ] }
数据源类型。JSONQL
JasperReport版本: 6.12.2 (最新)
不要紧。用sub-data-set搞定了。
<subDataset name="TaxSDS" uuid="1701ce05-88ab-4435-85c5-3ad38e0b941b">
<queryString language="jsonql">
<![CDATA[..taxes]]>
</queryString>
<field name="tax_slab_name" class="java.lang.String">
<property name="net.sf.jasperreports.jsonql.field.expression" value="tax_slab_name"/>
<fieldDescription><![CDATA[Tax Slabs]]></fieldDescription>
</field>
<field name="tax_slab_amt" class="java.lang.String">
<property name="net.sf.jasperreports.jsonql.field.expression" value="tax_amount"/>
<fieldDescription><![CDATA[Tax Amount]]></fieldDescription>
</field>
</subDataset>
<subDataset name="LinesSDS" uuid="1701ce05-88ab-4435-85c5-3ad38e0b941b">
<queryString language="jsonql">
<![CDATA[..lines]]>
</queryString>
<field name="item_name" class="java.lang.String">
<property name="net.sf.jasperreports.jsonql.field.expression" value="item_name"/>
<fieldDescription><![CDATA[Item]]></fieldDescription>
</field>
<field name="uom" class="java.lang.String">
<property name="net.sf.jasperreports.jsonql.field.expression" value="uom"/>
<fieldDescription><![CDATA[UOM]]></fieldDescription>
</field>
</subDataset>
<queryString language="jsonql">
<![CDATA[]]>
</queryString>
<field name="invoiceNo" class="java.lang.String">
<property name="net.sf.jasperreports.jsonql.field.expression" value="header.estimate_no"/>
<fieldDescription><![CDATA[Estimate No]]></fieldDescription>
</field>