Jasper子报告 - 不工作

时间:2018-03-27 11:26:45

标签: jasper-reports subreport

我有一份主要报告要求提交子报告。在主报告中,我在详细信息区域中有了绘图活动名称,并且在相同的详细信息带中我放了一个子报告。子报告提供了每个情节活动的详细信息。分报告的详细信息也在细节范围内。

例如 - 报告需要按照下图显示。

enter image description here

但是,结果显示只有P1-A1组合重复其属性的次数。 P1-A2,P2-A1未​​出现在报告输出中

关于此的任何想法

主报告的jrxml是

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.1.0.final using JasperReports Library version 6.1.0  -->
<!-- 2018-03-27T16:55:12 -->
<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="FarmerProfile_Plot" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="e34c98c9-c03e-4806-80ab-19605344bcbd">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="mysqlrdsprod"/>
    <parameter name="Field_Manager" class="java.lang.Integer"/>
    <parameter name="Company" class="java.lang.Integer"/>
    <parameter name="Farmer" class="java.lang.Integer"/>
    <parameter name="UtcOffSet" class="java.lang.Integer">
        <parameterDescription><![CDATA[]]></parameterDescription>
    </parameter>
    <queryString>
        <![CDATA[select distinct
dp.farmercropid,
dp.plotname,cfa.activityname,cfa.ActivityId,concat(dp.plotname,' - ',cfa.activityname)plotactivity
from plot dp
join plot_user dpu on dp.FarmerCropId=dpu.FarmerCropId and dp.companyid=$P{Company} and dp.partitionflag=1 and dpu.partitionflag=1 and dp.farmerid=$P{Farmer}
left join (select distinct childid from User_Hierarchy_Mapping where companyid=$P{Company} and UserId=$P{Field_Manager}) dhm on 
dhm.childid=dpu.FieldstaffId
left join customformattributes cfa on cfa.farmercropid = dp.farmercropid and cfa.companyid = $P{Company} and cfa.partitionflag = 1 and cfa.isactive = 1
]]>
    </queryString>
    <field name="farmercropid" class="java.lang.Integer">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="plotname" class="java.lang.String">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="activityname" class="java.lang.String">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="ActivityId" class="java.lang.Integer">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="plotactivity" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="328" splitType="Stretch">
            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
            <printWhenExpression><![CDATA[$V{REPORT_COUNT}.intValue()==1]]></printWhenExpression>
            <textField>
                <reportElement x="6" y="8" width="539" height="30" uuid="064e4fbc-9c4f-482f-b0d0-5ea860f6e6c6"/>
                <textFieldExpression><![CDATA[$F{plotactivity}]]></textFieldExpression>
            </textField>
            <subreport>
                <reportElement x="6" y="40" width="538" height="200" uuid="e5710a1d-d42e-4db5-9169-c74bdd6b9550"/>
                <subreportParameter name="Field_Manager">
                    <subreportParameterExpression><![CDATA[$P{Field_Manager}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="Company">
                    <subreportParameterExpression><![CDATA[$P{Company}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="Farmer">
                    <subreportParameterExpression><![CDATA[$P{Farmer}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="FarmerCrop">
                    <subreportParameterExpression><![CDATA[$F{farmercropid}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="ActivityId">
                    <subreportParameterExpression><![CDATA[$F{ActivityId}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="UtcOffSet">
                    <subreportParameterExpression><![CDATA[$P{UtcOffSet}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["test_detail.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </detail>
</jasperReport>

子报告jrxml如下

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.1.0.final using JasperReports Library version 6.1.0  -->
<!-- 2018-03-27T16:55:52 -->
<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="FarmerProfile_CustomDetails" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="1a13f736-f201-463a-9205-a54b60923c69">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="mysqlrdsprod"/>
    <style name="Crosstab_CH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Crosstab_CG" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Crosstab_CT" mode="Opaque" backcolor="#005FB3">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Crosstab_CD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="Dataset1" uuid="961ad23d-1b80-486c-ae05-6092092aeaf5">
        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="mysqlrdsprod"/>
        <parameter name="Field_Manager" class="java.lang.Integer"/>
        <parameter name="Company" class="java.lang.Integer"/>
        <parameter name="Farmer" class="java.lang.Integer"/>
        <parameter name="FarmerCrop" class="java.lang.Integer"/>
        <parameter name="ActivityId" class="java.lang.Integer"/>
        <parameter name="UtcOffSet" class="java.lang.Integer">
            <parameterDescription><![CDATA[]]></parameterDescription>
        </parameter>
        <queryString>
            <![CDATA[select distinct 
df.PlotName,
cfa.ActivityName
,AttributeName
,SUM(reading) reading
from customformattributes cfa 
join plot df on cfa.FarmerCropId=df.FarmerCropId
left join User_Hierarchy_Mapping uhm on cfa.companyid=uhm.companyid and uhm.UserId=$P{Field_Manager}  
where cfa.companyid=$P{Company}  
and cfa.isactive=1  
and cfa.partitionflag=1  
and df.companyid=$P{Company}  
 and df.farmercropid = $P{FarmerCrop}
and df.partitionflag=1   
 and    df.FarmerId=$P{Farmer}  
  and cfa.ActivityId = $P{ActivityId}
and cfa.IsActive=1 
and cfa.reading <> ' '  
       group by df.PlotName
,AttributeName
   order by  
df.FarmerCropId
,ActivityName]]>
        </queryString>
        <field name="PlotName" class="java.lang.String">
            <fieldDescription><![CDATA[]]></fieldDescription>
        </field>
        <field name="ActivityName" class="java.lang.String">
            <fieldDescription><![CDATA[]]></fieldDescription>
        </field>
        <field name="AttributeName" class="java.lang.String">
            <fieldDescription><![CDATA[]]></fieldDescription>
        </field>
        <field name="reading" class="java.lang.Double"/>
    </subDataset>
    <parameter name="Field_Manager" class="java.lang.Integer"/>
    <parameter name="Company" class="java.lang.Integer"/>
    <parameter name="Farmer" class="java.lang.Integer"/>
    <parameter name="FarmerCrop" class="java.lang.Integer"/>
    <parameter name="ActivityId" class="java.lang.Integer"/>
    <parameter name="UtcOffSet" class="java.lang.Integer">
        <parameterDescription><![CDATA[]]></parameterDescription>
    </parameter>
    <queryString>
        <![CDATA[select distinct 
df.PlotName,
cfa.ActivityName
,AttributeName
,SUM(reading) reading
from customformattributes cfa 
join plot df on cfa.FarmerCropId=df.FarmerCropId
left join User_Hierarchy_Mapping uhm on cfa.companyid=uhm.companyid and uhm.UserId=$P{Field_Manager}  
where cfa.companyid=$P{Company}  
and cfa.isactive=1  
and cfa.partitionflag=1  
and df.companyid=$P{Company}  
 and df.farmercropid = $P{FarmerCrop}
and df.partitionflag=1   
 and    df.FarmerId=$P{Farmer}  
and cfa.IsActive=1 
 and cfa.activityid = $P{ActivityId}
and cfa.reading <> ' '  
       group by df.PlotName
,AttributeName
   order by  
df.FarmerCropId
,ActivityName]]>
    </queryString>
    <field name="PlotName" class="java.lang.String">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="ActivityName" class="java.lang.String">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="AttributeName" class="java.lang.String">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="reading" class="java.lang.Double"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="70">
            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
            <componentElement>
                <reportElement isPrintRepeatedValues="false" x="0" y="0" width="555" height="70" isPrintInFirstWholeBand="true" uuid="94d02ef3-cd8f-46b1-9fcb-71c9396d2e4c"/>
                <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
                    <datasetRun subDataset="Dataset1" uuid="4e8d4e8b-5860-418a-8e3c-96dc2ffbb1b3">
                        <datasetParameter name="Field_Manager">
                            <datasetParameterExpression><![CDATA[$P{Field_Manager}]]></datasetParameterExpression>
                        </datasetParameter>
                        <datasetParameter name="Company">
                            <datasetParameterExpression><![CDATA[$P{Company}]]></datasetParameterExpression>
                        </datasetParameter>
                        <datasetParameter name="Farmer">
                            <datasetParameterExpression><![CDATA[$P{Farmer}]]></datasetParameterExpression>
                        </datasetParameter>
                        <datasetParameter name="FarmerCrop">
                            <datasetParameterExpression><![CDATA[$P{FarmerCrop}]]></datasetParameterExpression>
                        </datasetParameter>
                        <datasetParameter name="ActivityId">
                            <datasetParameterExpression><![CDATA[$P{ActivityId}]]></datasetParameterExpression>
                        </datasetParameter>
                        <datasetParameter name="UtcOffSet">
                            <datasetParameterExpression><![CDATA[$P{UtcOffSet}]]></datasetParameterExpression>
                        </datasetParameter>
                        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    </datasetRun>
                    <jr:column width="100" uuid="20f10ac9-00ef-4f3d-b519-24851884931b">
                        <jr:columnHeader style="Table_CH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="100" height="30" uuid="426e03e7-96f7-48b5-a631-e7e17e0d4144"/>
                                <text><![CDATA[AttributeName]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="100" height="30" uuid="22e1ce75-68f9-4623-93ac-fd6fb18fef90"/>
                                <textFieldExpression><![CDATA[$F{AttributeName}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="100" uuid="3014c135-c5c0-4d59-9d9b-dae47ff53d3c">
                        <jr:columnHeader style="Table_CH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="100" height="30" uuid="7dffa857-dd4c-4f59-8610-791f1a4b09d4"/>
                                <text><![CDATA[reading]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="100" height="30" uuid="1a0d1f4d-e4e2-4932-b9ec-147030c337ca"/>
                                <textFieldExpression><![CDATA[$F{reading}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </detail>
</jasperReport>

0 个答案:

没有答案