2013-02-20 3 views
2

Мы используем iReport 5.0.1 и успешно конвертировали многие из наших пакетов Crystal Reports.iReport Ошибка вычисления выражения

Я работаю с данными, которые представляют собой смесь целочисленного и двойного типа данных, и я выполняю вычисления внутри полей переменных в разделе подробностей.

У меня тогда есть 3 переменные, суммирующие подробные данные. Первой переменной является прямая сумма детализированной переменной над ней. Второй добавляет либо один параметр, либо второй параметр, в зависимости от оператора IF..THEN..ELSE, а третий вычитает те же самые значения параметров на основе аналогичного оператора IF..THEN..ELSE.

Мне нужно округлить 3 поля переменных в нижнем колонтитуле группы, поэтому я применяю Math.round (variable_name) к каждой из трех переменных. Исходный и последний (вычитание параметров) работают отлично. Средняя переменная (добавление параметров) выдает ошибку «Ошибка оценки выражения: Math.round (variable_name)». Если я выберу форматирование, все будет хорошо.

Я скопировал и вставил рабочие переменные, переименовав его в правильное имя, чтобы убедиться, что я не пропущу что-то в том, как я их первоначально установил, но безрезультатно. Когда я запускаю его с использованием Empty Datasource, он запускается, но, конечно, без данных.

Это привело бы меня к мысли, что проблема связана с данными, но я проверил ее повсюду, и все данные действительны для источников данных, а не NULL, пустые или символьные данные.

Я довольно в тупике. Отчет компилируется и работает отлично в Crystal Reports, используя довольно близкие к тем же функциям.

Если у кого-то есть какие-либо рекомендации, я рад слушать, и я отправляю XML-отчет ниже.

Благодарим вас за любую помощь, которую вы можете предложить.

М. Снайдер

<?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="MarginRequirement"   language="groovy" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20"   rightMargin="20" topMargin="20" bottomMargin="20" uuid="70f7c2ab-dba2-420a-98b9-  dc041beb65a7"> 
     <property name="ireport.zoom" value="1.0"/> 
     <property name="ireport.x" value="0"/> 
     <property name="ireport.y" value="0"/> 
     <property name="ireport.jasperserver.reportUnit"   value="/reports/Risk_Management/MarginRequirement"/> 
     <property name="ireport.jasperserver.url"   value="http://reports.beefnw.com/jasperserver/services/repository"/> 
<parameter name="LCF" class="java.lang.Float"> 
    <defaultValueExpression><![CDATA[0.0]]></defaultValueExpression> 
</parameter> 
<parameter name="LCO" class="java.lang.Float"> 
    <defaultValueExpression><![CDATA[0.0]]></defaultValueExpression> 
</parameter> 
<parameter name="FCF" class="java.lang.Float"> 
    <defaultValueExpression><![CDATA[0.00]]></defaultValueExpression> 
</parameter> 
<parameter name="FCO" class="java.lang.Float"> 
    <defaultValueExpression><![CDATA[0.0]]></defaultValueExpression> 
</parameter> 
<parameter name="GF" class="java.lang.Float"> 
    <defaultValueExpression><![CDATA[0.0]]></defaultValueExpression> 
</parameter> 
<parameter name="GO" class="java.lang.Float"> 
    <defaultValueExpression><![CDATA[0.0]]></defaultValueExpression> 
</parameter> 
<queryString> 
    <![CDATA[select *, 
    if (mid(symbol,-3,1) in("F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"),   "Future", "Option") AS type from margin_requirements 
    order by location, clearing_house 
    ]]> 
</queryString> 
<field name="open_price" class="java.lang.Float"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="equity" class="java.lang.Float"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="close_price" class="java.lang.Float"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="open_total_value" class="java.lang.Float"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="close_total_value" class="java.lang.Float"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="liquidating_value" class="java.lang.Float"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="commission" class="java.lang.Float"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="account_id" class="java.lang.Integer"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="position_id" class="java.lang.Integer"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="id" class="java.lang.Integer"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="contract_weight" class="java.lang.Integer"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="contracts" class="java.lang.Integer"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="account_name" class="java.lang.String"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="account_number" class="java.lang.String"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="location" class="java.lang.String"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="clearing_house" class="java.lang.String"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="type" class="java.lang.String"/> 
<field name="group" class="java.lang.String"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="symbol" class="java.lang.String"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="fill_date" class="java.sql.Date"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="updated_at" class="java.sql.Timestamp"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<field name="created_at" class="java.sql.Timestamp"> 
    <fieldDescription><![CDATA[]]></fieldDescription> 
</field> 
<variable name="loc_clHouse" class="java.lang.String" resetType="None"> 
    <variableExpression><![CDATA[$F{location} + " - " + $F{clearing_house}]]></variableExpression> 
</variable> 
<variable name="LC_Orig" class="java.lang.Float" resetType="None"> 
    <variableExpression><![CDATA[$F{group}=="LIVE_CATTLE"?((($F{contracts}*$F{contract_weight}*$F{open_price})/100)*-1) + (($F{contracts}*$F{contract_weight}*$F{close_price})/100):0.0]]></variableExpression> 
</variable> 
<variable name="LCOrig_Total" class="java.lang.Float" resetType="Group" resetGroup="ClearingHouse" calculation="Sum"> 
    <variableExpression><![CDATA[Math.round($V{LC_Orig})]]></variableExpression> 
</variable> 
<variable name="Suppression" class="java.lang.String" resetType="None"> 
    <variableExpression><![CDATA["NO"]]></variableExpression> 
</variable> 
<variable name="LCUpPrice" class="java.lang.Float" resetType="None"> 
    <variableExpression><![CDATA[$F{type}=="Future"?$F{close_price}+$P{LCF}:$F{close_price}+$P{LCO}]]></variableExpression> 
</variable> 
<variable name="LCDownPrice" class="java.lang.Float" resetType="None"> 
    <variableExpression><![CDATA[$F{type}=="Future"?$F{close_price}-$P{LCF}:$P{LCO} > $F{close_price}?0.0:$F{close_price}-$P{LCO}]]></variableExpression> 
</variable> 
<variable name="LC_Decrease" class="java.lang.Float" resetType="None"> 
    <variableExpression><![CDATA[$F{group}=="LIVE_CATTLE"?((($F{contracts}*$F{contract_weight}*$F{open_price})/100)*-1)+(($F{contracts}*$F{contract_weight}*$V{LCDownPrice})/100):0.0]]></variableExpression> 
</variable> 
<variable name="LCDecr_Total" class="java.lang.Float" resetType="Group" resetGroup="ClearingHouse" calculation="Sum"> 
    <variableExpression><![CDATA[Math.round($V{LC_Decrease})]]></variableExpression> 
</variable> 
<variable name="LCIncr_Total" class="java.lang.Float" resetType="Group" resetGroup="ClearingHouse" calculation="Sum"> 
    <variableExpression><![CDATA[Math.round($V{LC_Increase})]]></variableExpression> 
</variable> 
<variable name="LC_Increase" class="java.lang.Float" resetType="None"> 
    <variableExpression><![CDATA[$F{group}=="LIVE_CATTLE"?((($F{contracts}*$F{contract_weight}*$F{open_price})/100)*-1)+(($F{contracts}*$F{contract_weight}*$V{LCUpPrice})/100):0.0]]></variableExpression> 
</variable> 
<group name="ClearingHouse"> 
    <groupExpression><![CDATA[$V{loc_clHouse}]]></groupExpression> 
    <groupHeader> 
     <band height="25"> 
      <printWhenExpression><![CDATA[$V{Suppression}=="YES"]]></printWhenExpression> 
      <textField> 
       <reportElement uuid="51b78c4d-3747-4282-8b9f-17be6f84feea" x="0" y="0" width="100" height="20"/> 
       <textElement/> 
       <textFieldExpression><![CDATA[$V{loc_clHouse}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement uuid="ad970881-452b-42aa-bb9f-a19e735643c5" x="179" y="5" width="100" height="20"/> 
       <textElement/> 
       <textFieldExpression><![CDATA[$V{Suppression}]]></textFieldExpression> 
      </textField> 
     </band> 
    </groupHeader> 
    <groupFooter> 
     <band height="116"> 
      <textField> 
       <reportElement uuid="79587964-7211-4761-9221-0c063a1aebf0" x="0" y="0" width="100" height="20"/> 
       <textElement/> 
       <textFieldExpression><![CDATA[$V{loc_clHouse}]]></textFieldExpression> 
      </textField> 
      <textField pattern="¤ #,##0.00"> 
       <reportElement uuid="3bd9ce71-5cf4-4ae3-b678-8f3942fc9e7a" x="100" y="0" width="100" height="20"/> 
       <textElement textAlignment="Right"/> 
       <textFieldExpression><![CDATA[$V{LCOrig_Total}]]></textFieldExpression> 
      </textField> 
      <textField pattern="¤ #,##0.00"> 
       <reportElement uuid="20ef4729-88b0-4ab2-a5a6-56594bb716d5" x="100" y="40" width="100" height="20"/> 
       <textElement textAlignment="Right"/> 
       <textFieldExpression><![CDATA[$V{LCDecr_Total}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement uuid="16a8b6f9-5e24-4ee6-9e84-e2730d78dea1" x="100" y="20" width="100" height="20"/> 
       <textElement textAlignment="Right"/> 
       <textFieldExpression><![CDATA[$V{LCIncr_Total}]]></textFieldExpression> 
      </textField> 
     </band> 
    </groupFooter> 
</group> 
<background> 
    <band splitType="Stretch"/> 
</background> 
<title> 
    <band height="79" splitType="Stretch"/> 
</title> 
<pageHeader> 
    <band height="142" splitType="Stretch"> 
     <image> 
      <reportElement uuid="eef5e5ab-7b5d-4f86-a20f-5dd51bbd56bd" x="5" y="4" width="310" height="93"/> 
      <imageExpression><![CDATA["/home/marlin/bnw_logo_trans.gif"]]></imageExpression> 
     </image> 
     <rectangle> 
      <reportElement uuid="957ac037-7238-46e1-809c-4ded5f76b72b" x="0" y="102" width="572" height="38" forecolor="#E6D8AB" backcolor="#E6D8AB"/> 
     </rectangle> 
     <staticText> 
      <reportElement uuid="3b2925af-f556-4c0c-84bb-e5b5b021128e" x="126" y="110" width="341" height="30"/> 
      <textElement textAlignment="Center"> 
       <font size="18" isBold="true"/> 
      </textElement> 
      <text><![CDATA[MARGIN REQUIREMENT REPORT]]></text> 
     </staticText> 
    </band> 
</pageHeader> 
<columnHeader> 
    <band height="27" splitType="Stretch"> 
     <rectangle> 
      <reportElement uuid="a2f2bf6a-6f14-48e5-9d19-5f153caed5a5" x="0" y="0" width="572" height="27" forecolor="#E6D8AB" backcolor="#E6D8AB"/> 
     </rectangle> 
    </band> 
</columnHeader> 
<detail> 
    <band height="96" splitType="Stretch"> 
     <printWhenExpression><![CDATA[$V{Suppression}=="NO"]]></printWhenExpression> 
     <textField> 
      <reportElement uuid="ed06c6f7-7b44-4033-8c4a-9364d9c22e13" x="100" y="0" width="100" height="20"/> 
      <textElement/> 
      <textFieldExpression><![CDATA[$V{LC_Orig}]]></textFieldExpression> 
     </textField> 
     <textField> 
      <reportElement uuid="55b4791f-dfe7-415c-89d5-ebd937c6a329" x="0" y="0" width="100" height="20"/> 
      <textElement/> 
      <textFieldExpression><![CDATA[$V{Suppression}]]></textFieldExpression> 
     </textField> 
     <textField> 
      <reportElement uuid="aba93e69-1ab0-476a-81e0-c65d8f482233" x="100" y="40" width="100" height="20"/> 
      <textElement/> 
      <textFieldExpression><![CDATA[$V{LC_Decrease}]]></textFieldExpression> 
     </textField> 
     <textField> 
      <reportElement uuid="6f9026a6-abf5-4017-974c-9e972bed8181" x="0" y="20" width="100" height="20"/> 
      <textElement/> 
      <textFieldExpression><![CDATA[$P{LCF}]]></textFieldExpression> 
     </textField> 
     <textField> 
      <reportElement uuid="ff53c29d-4006-4b99-8b77-295717483c79" x="0" y="40" width="100" height="20"/> 
      <textElement/> 
      <textFieldExpression><![CDATA[$P{LCO}]]></textFieldExpression> 
     </textField> 
     <textField> 
      <reportElement uuid="e305cdbe-e93c-47bb-aedd-f2fc1478e33d" x="100" y="20" width="100" height="20"/> 
      <textElement/> 
      <textFieldExpression><![CDATA[$V{LC_Increase}]]></textFieldExpression> 
     </textField> 
    </band> 
</detail> 
<columnFooter> 
    <band splitType="Stretch"/> 
</columnFooter> 
<pageFooter> 
    <band height="54" splitType="Stretch"/> 
</pageFooter> 
<summary> 
    <band height="42" splitType="Stretch"/> 
</summary> 
    </jasperReport> 

ответ

Смежные вопросы