我按照this主题尝试将值metrics.LINES_OF_CODE_1
和metrics.MAINTAINABILITY_1
从子报表返回到主报表,但我得到的唯一值是null。我的JRXML文件位于以下位置:
主要报告
<?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="report7" language="groovy" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="fd6ce9ca-1ecb-4541-b6b2-446f4da339de">
<property name="ireport.jasperserver.reportUnit" value="/SAW/Database/report7"/>
<property name="ireport.jasperserver.url" value="http://172.16.230.131:8081/jasperserver/ser vices/repository"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["/Users/mjohansson/Downloads/"]]></defaultValueExpression>
</parameter>
<parameter name="ParameterMainReport" class="java.lang.String"/>
<queryString language="MongoDbQuery">
<![CDATA[{
'collectionName':'benchmark',
sort:{productivityAndProcessMetrics.operationalCost.overallCost:-1}
}]]>
</queryString>
<field name="systemID" class="java.lang.String"/>
<field name="productivityAndProcessMetrics.operationalCost.overallCost" class="java.lang.Double"/>
<variable name="metrics.LINES_OF_CODE_1" class="java.lang.Double" resetType="None" calculation="System"/>
<variable name="metrics.MAINTAINABILITY_1" class="java.lang.Double" resetType="None" calculation="System"/>
<title>
<band height="20">
<staticText>
<reportElement uuid="248b1d82-f1a8-4a3e-8fab-58ed34517b9c" x="0" y="0" width="175" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[System ID]]></text>
</staticText>
<staticText>
<reportElement uuid="a2b5c406-76a0-4ffa-b84f-fcf17d43a768" x="275" y="0" width="125" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Right">
<font isBold="true"/>
</textElement>
<text><![CDATA[LOC]]></text>
</staticText>
<staticText>
<reportElement uuid="26c40738-a9c9-4e3a-8f32-2d69f38be204" x="175" y="0" width="100" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Right">
<font isBold="true"/>
</textElement>
<text><![CDATA[MaintenanceCost]]></text>
</staticText>
<staticText>
<reportElement uuid="2cca751f-1ffa-4c6e-855c-24c5bf4a9b3f" x="400" y="0" width="125" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Right">
<font isBold="true"/>
</textElement>
<text><![CDATA[Maintainability]]></text>
</staticText>
</band>
</title>
<detail>
<band height="21" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement uuid="1510b437-bfe1-4610-aeea-78c24d5f0c42" x="0" y="1" width="175" height="20" isRemoveLineWhenBlank="true"/>
<box>
<topPen lineWidth="0.0"/>
<leftPen lineWidth="0.0"/>
<bottomPen lineWidth="0.0"/>
<rightPen lineWidth="0.0"/>
</box>
<textElement/>
<textFieldExpression> <![CDATA[($F{productivityAndProcessMetrics.operationalCost.overallCost}!=null)?$F{systemID}:""]]></textFieldExpression>
</textField>
<subreport>
<reportElement uuid="2252d608-802e-442f-a3ee-07619e955640" x="275" y="1" width="250" height="20" isRemoveLineWhenBlank="true"/>
<subreportParameter name="SystemID">
<subreportParameterExpression><![CDATA[($F{productivityAndProcessMetrics.operationalCost.overallCost}!=null)?$F{systemID}:null]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="ParameterSubReport">
<subreportParameterExpression><![CDATA[$P{ParameterMainReport}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<returnValue subreportVariable="metrics.LINES_OF_CODE_1" toVariable="metrics.LINES_OF_CODE_1"/>
<returnValue subreportVariable="metrics.MAINTAINABILITY_1" toVariable="metrics.MAINTAINABILITY_1"/>
<subreportExpression><![CDATA["repo:report7_subreport1.jrxml"]]></subreportExpression>
</subreport>
<textField pattern="#,##0.00" isBlankWhenNull="true">
<reportElement uuid="d81f0296-7dff-4cdc-9d48-ec477154fc0e" x="175" y="1" width="100" height="20" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{productivityAndProcessMetrics.operationalCost.overallCost}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="4c995889-51aa-42db-8e44-ef169372330c" x="525" y="1" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$V{metrics.LINES_OF_CODE_1}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="fb61c381-1862-4817-a7ad-23f24d142e6a" x="625" y="1" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$V{metrics.MAINTAINABILITY_1}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
子报告
<?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="report7_subreport1" language="groovy" pageWidth="250" pageHeight="802" columnWidth="250" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="3ec7fa69-029a-4882-8308-8496807fe30d">
<property name="ireport.jasperserver.reportUnit" value="/SAW/Database/report7"/>
<property name="ireport.jasperserver.url" value="http://172.16.230.131:8081/jasperserver/services/repository"/>
<parameter name="ParameterSubReport" class="java.lang.String"/>
<parameter name="SystemID" class="java.lang.String">
<parameterDescription><![CDATA[]]></parameterDescription>
</parameter>
<queryString language="MongoDbQuery">
<![CDATA[{
'collectionName':'systemMetrics',
'findQueryRegEx':{lang:'/^ALL_LANGUAGES_AGGREGATE/' ,sysID:'/^$P!{SystemID}/'}
}]]></queryString>
<field name="metrics.LINES_OF_CODE" class="java.lang.Double"/>
<field name="metrics.MAINTAINABILITY" class="java.lang.Double"/>
<field name="sysID" class="java.lang.String"/>
<variable name="metrics.LINES_OF_CODE_1" class="java.lang.Double" resetType="None">
<variableExpression><![CDATA[$F{metrics.LINES_OF_CODE}]]></variableExpression>
</variable>
<variable name="metrics.MAINTAINABILITY_1" class="java.lang.Double" resetType="None">
<variableExpression><![CDATA[$F{metrics.MAINTAINABILITY}]]></variableExpression>
</variable>
<background>
<band splitType="Stretch"/>
</background>
<summary>
<band height="20">
<textField pattern="#,##0.00" isBlankWhenNull="true">
<reportElement uuid="48938680-a5b7-4d16-b3e0-79e02a43336c" x="0" y="0" width="125" height="20"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$V{metrics.LINES_OF_CODE_1}]]></textFieldExpression>
</textField>
<textField pattern="#,##0.00" isBlankWhenNull="true">
<reportElement uuid="59f69b58-fd5c-44a8-abdd-410e30d48627" x="125" y="0" width="125" height="20"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$V{metrics.MAINTAINABILITY_1}]]></textFieldExpression>
</textField>
</band>
</summary>
</jasperReport>
我做错了什么?任何输入都会有所帮助。
答案 0 :(得分:0)
我通过在现场调用我的输出变量从“现在”到“自动”来设置评估时间来解决这个问题。
答案 1 :(得分:0)
对于那些无法改变评估时间的人(因为他们不希望将变量作为参数传递给另一个子报告以示例):
请勿在与子报告本身相同的波段中使用变量返回!
我想在乐队的渲染结束时完成了做法......
所以----&gt; “添加另一个乐队”并在里面使用你的变量;)
希望这会有所帮助,我花了几个小时才发现这个!