生成此报告详细信息时出现问题?

Issue in genearting the sub report details?

我已经创建了报告,它正在获取名字和姓氏以及发票 ID 的值,但是当我添加子报告时,其他值没有得到它只是打印标题。请解决我的问题并给我建议。

打印如下图

主要报告代码:

   <?xml version="1.0" encoding="UTF-8"?>
   <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Usage Rport" pageWidth="595" pageHeight="842" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" >
<property name="com.jasperassistant.designer.GridHeight" value="12"/>
<property name="com.jasperassistant.designer.GridWidth" value="12"/>
<property name="com.jasperassistant.designer.SnapToGrid" value="false"/>
<property name="com.jasperassistant.designer.Grid" value="false"/>
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<import value="org.joda.time.DateTime"/>
<parameter name="invoice_id" class="java.lang.Integer"/>
<parameter name="entity_id" class="java.lang.Integer"/>
<parameter name="entityPhoneCountryCode" class="java.lang.String"/>
<parameter name="entityPhoneAreaCode" class="java.lang.String"/>
<parameter name="entityPhoneContry" class="java.lang.String"/>
<parameter name="invoiceDate" class="java.lang.String"/>
<parameter name="invoiceDueDate" class="java.lang.String"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
    <defaultValueExpression><![CDATA["D:\Ravi Workspace\Openbrm\open-brm-openbrm-2.0\descriptors\reports\usage\"]]></defaultValueExpression>
</parameter>
<queryString>
    <![CDATA[select co.first_name,co.last_name,b.id as user_id from swiss_cdr_event e join order_process o join base_user b on b.id=e.user_id and e.order_id = o.order_id join contact co on e.user_id=co.user_id where o.invoice_id=$P{invoice_id} and b.entity_id=$P{entity_id} order by e.call_start_date asc;]]>
</queryString>
<field name="first_name" class="java.lang.String"/>
<field name="last_name" class="java.lang.String"/>
<field name="user_id" class="java.lang.Integer"/>
<title>
    <band height="20"/>
</title>
<pageHeader>
    <band height="111">
        <textField>
            <reportElement x="5" y="13" width="200" height="15" />
            <textElement>
                <font size="10" isBold="true"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{first_name}+" " +$F{last_name}]]></textFieldExpression>
        </textField>
        <staticText>
            <reportElement x="185" y="13" width="140" height="15" />
            <textElement textAlignment="Left">
                <font isBold="true"/>
            </textElement>
            <text><![CDATA[Rechnungs-Nr. ]]></text>
        </staticText>
        <staticText>
            <reportElement x="368" y="13" width="100" height="15" />
            <textElement>
                <font isBold="true"/>
            </textElement>
            <text><![CDATA[Jahr / Monat]]></text>
        </staticText>
        <staticText>
            <reportElement x="379" y="28" width="52" height="15" />
            <textElement>
                <font isBold="true"/>
            </textElement>
            <text><![CDATA[datiert]]></text>
        </staticText>
        <textField>
            <reportElement x="252" y="13" width="100" height="15" />
            <textElement>
                <font isBold="true"/>
            </textElement>
            <textFieldExpression class="java.lang.Integer"><![CDATA[$P{invoice_id}]]></textFieldExpression>
        </textField>
        <subreport>
            <reportElement x="434" y="28" width="119" height="18" />
            <subreportParameter name="invoiceId">
                <subreportParameterExpression><![CDATA[$P{invoice_id}]]></subreportParameterExpression>
            </subreportParameter>
            <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
            <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "run-details.jasper"]]></subreportExpression>
        </subreport>
        <subreport>
            <reportElement x="435" y="9" width="161" height="15" />
            <subreportParameter name="invoiceId">
                <subreportParameterExpression><![CDATA[$P{invoice_id}]]></subreportParameterExpression>
            </subreportParameter>
            <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
            <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "invoice-period-31.jasper"]]></subreportExpression>
        </subreport>
        <staticText>
            <reportElement x="185" y="28" width="100" height="15" />
            <textElement>
                <font isBold="true"/>
            </textElement>
            <text><![CDATA[Gesprächsnachweis]]></text>
        </staticText>
        <subreport>
            <reportElement x="6" y="57" width="590" height="43" />
            <subreportParameter name="invoiceId">
                <subreportParameterExpression><![CDATA[$P{invoice_id}]]></subreportParameterExpression>
            </subreportParameter>
            <subreportParameter name="entityId">
                <subreportParameterExpression><![CDATA[$P{entity_id}]]></subreportParameterExpression>
            </subreportParameter>
            <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
            <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "usage-31-de-details.jasper"]]></subreportExpression>
        </subreport>
    </band>
</pageHeader>
<pageFooter>
    <band height="33">
        <textField>
            <reportElement x="195" y="15" width="80" height="15" />
            <textElement textAlignment="Right"/>
            <textFieldExpression><![CDATA["Seite "+$V{PAGE_NUMBER}+" von "]]></textFieldExpression>
        </textField>
        <textField evaluationTime="Report">
            <reportElement x="275" y="15" width="40" height="15" />
            <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
        </textField>
    </band>
</pageFooter>
<lastPageFooter>
    <band height="33">
        <textField>
            <reportElement x="205" y="18" width="80" height="15" />
            <textElement textAlignment="Right"/>
            <textFieldExpression><![CDATA["Seite "+$V{PAGE_NUMBER}+" von "]]></textFieldExpression>
        </textField>
        <textField evaluationTime="Report">
            <reportElement x="285" y="18" width="40" height="15" />
            <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
        </textField>
    </band>
</lastPageFooter>
<summary>
    <band height="20"/>
</summary>

子报表代码:

   <?xml version="1.0" encoding="UTF-8"?>
   <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Usage Rport" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" >
<property name="com.jasperassistant.designer.GridHeight" value="12"/>
<property name="com.jasperassistant.designer.GridWidth" value="12"/>
<property name="com.jasperassistant.designer.SnapToGrid" value="false"/>
<property name="com.jasperassistant.designer.Grid" value="false"/>
<import value="org.joda.time.DateTime"/>
<parameter name="invoice_id" class="java.lang.Integer"/>
<parameter name="entity_id" class="java.lang.Integer"/>
<parameter name="entityCity" class="java.lang.String"/>
<parameter name="customerCity" class="java.lang.String"/>
<parameter name="entityPhoneCountryCode" class="java.lang.String"/>
<parameter name="entityPhoneAreaCode" class="java.lang.String"/>
<parameter name="entityPhoneContry" class="java.lang.String"/>
<parameter name="invoiceDate" class="java.lang.String"/>
<parameter name="invoiceDueDate" class="java.lang.String"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
    <defaultValueExpression><![CDATA["D:\Ravi Workspace\Openbrm\open-brm-openbrm-2.0\descriptors\reports\usage\"]]></defaultValueExpression>
</parameter>
<queryString>
    <![CDATA[select e.calling_number,e.duration,e.call_start_date,e.cost,e.destination_number,e.destination_descr,co.first_name,co.last_name,b.id as user_id from swiss_cdr_event e join order_process o join base_user b on b.id=e.user_id and e.order_id = o.order_id join contact co on e.user_id=co.user_id where o.invoice_id=$P{invoice_id} and b.entity_id=$P{entity_id} order by e.call_start_date asc;]]>
</queryString>
<field name="calling_number" class="java.lang.String"/>
<field name="destination_number" class="java.lang.String"/>
<field name="duration" class="java.lang.Integer"/>
<field name="cost" class="java.math.BigDecimal"/>
<field name="call_start_date" class="java.sql.Timestamp"/>
<field name="destination_descr" class="java.lang.String"/>
<field name="first_name" class="java.lang.String"/>
<field name="last_name" class="java.lang.String"/>
<field name="user_id" class="java.lang.Integer"/>
<variable name="total" class="java.math.BigDecimal" calculation="Sum">
    <variableExpression><![CDATA[$F{cost}]]></variableExpression>
</variable>
<title>
    <band height="111"/>
</title>
<columnHeader>
    <band height="33">
        <staticText>
            <reportElement x="12" y="10" width="62" height="15" />
            <textElement>
                <font size="10" isBold="true"/>
            </textElement>
            <text><![CDATA[Datum/Uhrzeit]]></text>
        </staticText>
        <staticText>
            <reportElement x="240" y="10" width="85" height="15" />
            <textElement>
                <font size="10" isBold="true"/>
            </textElement>
            <text><![CDATA[Destination]]></text>
        </staticText>
        <staticText>
            <reportElement x="450" y="10" width="42" height="15" />
            <textElement textAlignment="Left" verticalAlignment="Middle">
                <font size="10" isBold="true"/>
            </textElement>
            <text><![CDATA[Menge]]></text>
        </staticText>
        <staticText>
            <reportElement x="90" y="10" width="62" height="15" />
            <text><![CDATA[Anruf von]]></text>
        </staticText>
        <staticText>
            <reportElement x="163" y="10" width="49" height="14" />
            <text><![CDATA[Service]]></text>
        </staticText>
        <staticText>
            <reportElement x="334" y="10" width="100" height="15" />
            <text><![CDATA[Rufnummer]]></text>
        </staticText>
        <staticText>
            <reportElement x="514" y="10" width="47" height="15" />
            <text><![CDATA[Betrag]]></text>
        </staticText>
    </band>
</columnHeader>
<detail>
    <band height="20">
        <textField>
            <reportElement x="360" y="3" width="193" height="16" />
            <textElement textAlignment="Right" verticalAlignment="Middle">
                <font size="9"/>
            </textElement>
            <textFieldExpression><![CDATA[new DecimalFormat("#,##0.00").format($F{cost})]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="12" y="3" width="96" height="16" />
            <textElement>
                <font size="9"/>
            </textElement>
            <textFieldExpression><![CDATA[new SimpleDateFormat("dd-MM-yyyy").format($F{call_start_date})]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="242" y="3" width="121" height="16" />
            <textElement>
                <font size="9"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{destination_descr}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="60" y="3" width="96" height="16" />
            <textElement>
                <font size="9"/>
            </textElement>
            <textFieldExpression><![CDATA[new SimpleDateFormat("HH:mm:ss").format($F{call_start_date})]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="450" y="4" width="100" height="16" />
            <textElement>
                <font size="9"/>
            </textElement>
            <textFieldExpression class="java.lang.Integer"><![CDATA[$F{duration}]]></textFieldExpression>
        </textField>
        <subreport>
            <reportElement x="302" y="0" width="129" height="20" />
            <subreportParameter name="invoiceId">
                <subreportParameterExpression><![CDATA[$P{invoice_id}]]></subreportParameterExpression>
            </subreportParameter>
            <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
            <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "entity-details-31.jasper"]]></subreportExpression>
        </subreport>
        <textField>
            <reportElement x="98" y="0" width="90" height="15" />
            <textFieldExpression><![CDATA[$P{entityCity}]]></textFieldExpression>
        </textField>
    </band>
</detail>
<summary>
    <band height="80">
        <staticText>
            <reportElement x="242" y="6" width="92" height="15" />
            <text><![CDATA[Total]]></text>
        </staticText>
        <textField>
            <reportElement x="431" y="6" width="100" height="15" />
            <textElement textAlignment="Right">
                <font size="9" isBold="true"/>
            </textElement>
            <textFieldExpression><![CDATA[$V{total} == null ? "0.00" : new DecimalFormat ("#,##0.00").format($V{total})]]></textFieldExpression>
        </textField>
    </band>
</summary>

在查看您的 jrxml 时,您还必须将 $P{entity_id} 传递给您的 sub_report。目前您只传递发票 ID $P{invoice_id}。由于您的子报告 sql 正在处理两个参数 $P{invoice_id} 和 $P{entity_id}。如果您没有传递,它将选择默认值或 null(如果没有默认值)。

还有一个建议,子报告应该只包含那些必需的 band 并正确安排您的文本字段,否则当您尝试在 excel 中下载时,您将遇到 excel 列格式问题。

当您单击子报表和 select 属性时,您将首先看到图像。

现在单击属性子报表选项卡中的参数。请看第二张图

您的主 jrxml 中有三个子报表。

1) 运行-details.jrxml 主jrxml中的子报表参数映射 发票编号:$P{invoice_id}

2) 发票期-31.jrxml

主jrxml中的子报表参数映射 发票编号:$P{invoice_id}

3) usage-31-de-details.jrxml

主jrxml中的子报表参数映射 发票编号:$P{invoice_id}

我在 3 个子报表中看到参数名称是 invoice_id。所以你应该改成 主jrxml中的子报表参数映射 invoice_id : $P{invoice_id}

并且还有 3 个子报告正在处理 entity_id 参数。您还必须传递该值。 现在 主jrxml中的子报表参数映射 invoice_id : $P{invoice_id} entity_id : $P{entity_id}

我不确定另一个子报表中使用的参数名称。