如何解决“从bean中检索字段值时出错:...”

时间:2019-07-02 08:28:59

标签: jasper-reports javabeans subreport

我正在尝试创建一个包含子报表的Masterreport。坐了3天的错误,我找不到任何解决方案。.这个词的答案不能解决我的问题,所以请您帮忙...。我已经尝试删除该字段,但是没有不行

错误是:“从bean检索字段值时出错:monat”

static public class tagesmeldung {
        private String abteilung;
        private double punkte;
        private double stunden;
        private double minusstd;
        private double grad;
        private double praemie;
        private double sonderpkt;
        private AbasDate datum;
        private List<Monatsmeldung> Monatsmeldung;

        public String getAbteilung() {
            return abteilung;
        }
        public void setAbteilung(String abteilung) {
            this.abteilung = abteilung;
        }
        public double getPunkte() {
            return punkte;
        }
        public void setPunkte(double punkte) {
            this.punkte = punkte;
        }
        public double getStunden() {
            return stunden;
        }
        public void setStunden(double stunden) {
            this.stunden = stunden;
        }
        public double getMinusstd() {
            return minusstd;
        }
        public void setMinusstd(double minusstd) {
            this.minusstd = minusstd;
        }
        public double getGrad() {
            return grad;
        }
        public void setGrad(double grad) {
            this.grad = grad;
        }
        public double getPraemie() {
            return praemie;
        }
        public void setPraemie(double praemie) {
            this.praemie = praemie;
        }
        public double getSonderpkt() {
            return sonderpkt;
        }
        public void setSonderpkt(double sonderpkt) {
            this.sonderpkt = sonderpkt;
        }
        public AbasDate getDatum() {
            return datum;
        }
        public void setDatum(AbasDate datum) {
            this.datum = datum;
        }
        public List<Monatsmeldung> getMonatsmeldung() {
            return Monatsmeldung;
        }
        public void setMonatsmeldung(List<Monatsmeldung> Monatsmeldung) {
            this.Monatsmeldung = Monatsmeldung;
        }

    }

    static public class Monatsmeldung{
        private String abteilung;
        private AbasDate datum;
        private String monat;
        private double punkte;
        private double sonderp;
        private double stunden;
        private double minusstd;
        private double grad;
        private double praemie;

        public String getAbteilung() {
            return abteilung;
        }
        public void setAbteilung(String abteilung) {
            this.abteilung = abteilung;
        }
        public String getMonat() {
            return monat;
        }
        public void setMonat(String monat) {
            this.monat = monat;
        }
        public double getPunkte() {
            return punkte;
        }
        public void setPunkte(double punkte) {
            this.punkte = punkte;
        }
        public double getSonderp() {
            return sonderp;
        }
        public void setSonderp(double sonderp) {
            this.sonderp = sonderp;
        }
        public double getStunden() {
            return stunden;
        }
        public void setStunden(double stunden) {
            this.stunden = stunden;
        }
        public double getMinusstd() {
            return minusstd;
        }
        public void setMinusstd(double minusstd) {
            this.minusstd = minusstd;
        }
        public double getGrad() {
            return grad;
        }
        public void setGrad(double grad) {
            this.grad = grad;
        }
        public double getPraemie() {
            return praemie;
        }
        public void setPraemie(double praemie) {
            this.praemie = praemie;
        }
        public AbasDate getDatum() {
            return datum;
        }
        public void setDatum(AbasDate datum) {
            this.datum = datum;
        }


    }


public void y5allerepAfter(ButtonEvent event, ScreenControl screenControl, DbContext ctx, PraemieEditor head) throws EventException{
        // TODO Auto-generated method stub


        String[] sReport = { "Prämien", "Kostenstellenauswertung" };

        String sWahl = HHFunc.Menu("Report auswählen", sReport);


        if (sWahl.equals("Prämien")){


    ArrayList<tagesmeldung> alTag = new ArrayList<tagesmeldung>();
    ArrayList<Monatsmeldung> alMon = new ArrayList<Monatsmeldung>();
    tagesmeldung zeile = null;
    PraemieJasper.Monatsmeldung zeilem;
    int iMonat = 0;

    String sMonat, sDate, sJahr, sTag;
       double dPunkte = 0, dSonderp = 0, dStunden = 0, dMinusstd = 0, dPraemie = 0;
      BigDecimal dGrad; 
String sJRFileName  = "/erp/abas/hh/win/jasper/layout/hhjasper/praemie/tagesmeldung.jrxml";
String sJRSubFileName = "/erp/abas/hh/win/jasper/layout/hhjasper/praemie/";


    Iterable<Row> rows = head.table().getRows();
for (Row row : rows) {

zeile = new tagesmeldung();


    zeile.setDatum(head.getY5datum());
    zeile.setAbteilung(row.getY5abttext());
        zeile.setPunkte(row.getY5punkte().doubleValue());
    zeile.setStunden(row.getY5stunden().doubleValue());
    zeile.setMinusstd(row.getY5minstunden().doubleValue());
    zeile.setGrad(row.getY5grad().doubleValue());
    zeile.setPraemie(row.getY5praemie().doubleValue());
    zeile.setSonderpkt(row.getY5spunkte().doubleValue());

    alTag.add(zeile);
    }   


      sMonat = head.getY5datum().toString().substring(4, 6);
      iMonat = Integer.valueOf(sMonat);
      sJahr = head.getY5datum().toString().substring(0, 4);
      sDate = sJahr + sMonat;
      sTag = head.getY5datum().toString().substring(0, 1);  

SelectionBuilder<Praemie> selectionBuilder
=SelectionBuilder.create(Praemie.class);
            selectionBuilder.add(Conditions.starts(Praemie.META.swd, "P" + sDate));
            Query<Praemie> queryPr = ctx.createQuery(selectionBuilder.build());


    for (Praemie prae : queryPr){
     Iterable<Row> zeilen = prae.table().getRows();

    for (Row row1 : zeilen) {



    dPunkte = dPunkte + row1.getY5punkte().doubleValue();
    dSonderp = dSonderp + row1.getY5spunkte().doubleValue();
    dStunden = dStunden + row1.getY5stunden().doubleValue();
    dMinusstd = dMinusstd + row1.getY5minstunden().doubleValue();
    dGrad = this.grad(dPunkte, dStunden);
    dPraemie = this.praemie(dGrad.doubleValue());



    zeilem = new Monatsmeldung();

    zeilem.setDatum(head.getY5datum());
    zeilem.setAbteilung(row1.getY5abttext());

    if ( sMonat.equals("01")) zeilem.setMonat("Januar");
        if ( sMonat.equals("02")) zeilem.setMonat("Februar");
    if ( sMonat.equals("03")) zeilem.setMonat("März");
        if ( sMonat.equals("04")) zeilem.setMonat("April");
        if ( sMonat.equals("05")) zeilem.setMonat("Mai");
        if ( sMonat.equals("06")) zeilem.setMonat("Juni");
    if ( sMonat.equals("07")) zeilem.setMonat("Juli");
    if ( sMonat.equals("08")) zeilem.setMonat("August");
    if ( sMonat.equals("09")) zeilem.setMonat("September");
    if ( sMonat.equals("10")) zeilem.setMonat("Oktober");
    if ( sMonat.equals("11")) zeilem.setMonat("November");
    if ( sMonat.equals("12")) zeilem.setMonat("Dezember");


            zeilem.setPunkte(dPunkte);
            zeilem.setSonderp(dSonderp);
            zeilem.setStunden(dStunden);
            zeilem.setMinusstd(dMinusstd);
            zeilem.setGrad(dGrad.doubleValue());
            zeilem.setPraemie(dPraemie);

            alMon.add(zeilem);

            zeile.setMonatsmeldung(alMon);

            alTag.add(zeile);

      }
  }  

try{

    Map<String, Object> jasperParameters = new HashMap();

    jasperParameters.put( "SUBREPORT_DIR", sJRSubFileName ) ;
    jasperParameters.put( "SUB_REP", new JRBeanCollectionDataSource( alMon ));

         JasperDesign jasperDesign = JRXmlLoader.load(sJRFileName);
         JasperReport jasperReport = 
         JasperCompileManager.compileReport(jasperDesign);
         JasperCompileManager.compileReportToFile( jasperDesign, sJRSubFileName + "monatsmeldung.jasper");
        JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, j 
        asperParameters,new JRBeanCollectionDataSource( alTag ) );


    CallJR.showReport(ctx, sJRFileName, alTag);

    } catch (Exception e) {
    ctx.out().println(e.getMessage());
   } 

}

这是masterreport的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="tagesmeldung" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" whenResourceMissingType="Empty" uuid="3ea250e9-21b8-43c6-b368-a9305389e542">
    <property name="ireport.zoom" value="1.771561000000001"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["W:\\jasper\\layout\\hhjasper\\praemie\\"]]></defaultValueExpression>
    </parameter>
    <queryString language="json">
        <![CDATA[]]>
    </queryString>
    <field name="datum" class="java.lang.String"/>
    <field name="abteilung" class="java.lang.String"/>
    <field name="punkte" class="java.lang.String"/>
    <field name="stunden" class="java.lang.String"/>
    <field name="minusstd" class="java.lang.String"/>
    <field name="grad" class="java.lang.String"/>
    <field name="praemie" class="java.lang.String"/>
    <field name="sonderpkt" class="java.lang.String"/>
    <field name="monat" class="java.lang.String"/>
    <field name="punkte_mon" class="java.lang.String"/>
    <field name="sonderpkt_mon" class="java.lang.String"/>
    <field name="stunden_mon" class="java.lang.String"/>
    <field name="minusstd_mon" class="java.lang.String"/>
    <field name="grad_mon" class="java.lang.String"/>
    <field name="praemie_mon" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <pageHeader>
        <band height="50">
            <staticText>
                <reportElement x="38" y="12" width="216" height="20" uuid="50e46f03-b1d3-43ad-9e09-3430f80d849f"/>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Tagesmeldung Produktivität für]]></text>
            </staticText>
            <textField>
                <reportElement x="269" y="12" width="171" height="20" uuid="bb77527d-1b76-4e53-a2a6-007bbcc2a2a9"/>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{datum}]]></textFieldExpression>
            </textField>
        </band>
    </pageHeader>
    <columnHeader>
        <band height="30" splitType="Stretch">
            <textField>
                <reportElement x="27" y="7" width="66" height="20" uuid="687081e1-9517-46fa-8763-9609161b5dd5"/>
                <textFieldExpression><![CDATA[$F{datum}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="116" y="7" width="44" height="20" uuid="f2d88e40-fab3-4551-a939-972c0708fded"/>
                <textElement textAlignment="Right"/>
                <text><![CDATA[Punkte]]></text>
            </staticText>
            <staticText>
                <reportElement x="179" y="7" width="46" height="20" uuid="46f39132-7c82-4a42-8b2a-52b94e9e56b1"/>
                <textElement textAlignment="Right"/>
                <text><![CDATA[Stunden]]></text>
            </staticText>
            <staticText>
                <reportElement x="238" y="7" width="61" height="20" uuid="4323e845-7f45-4f0c-9374-575622feaf3b"/>
                <textElement textAlignment="Right"/>
                <text><![CDATA[Minus-std.]]></text>
            </staticText>
            <staticText>
                <reportElement x="312" y="7" width="48" height="20" uuid="2f89ef90-cf84-4a32-8bf1-04d801b8c3b7"/>
                <textElement textAlignment="Right"/>
                <text><![CDATA[Grad]]></text>
            </staticText>
            <staticText>
                <reportElement x="374" y="7" width="41" height="20" uuid="f0ac53f1-3e09-4e69-9f7f-76921cda289b"/>
                <textElement textAlignment="Right"/>
                <text><![CDATA[Prämie]]></text>
            </staticText>
            <staticText>
                <reportElement x="440" y="7" width="54" height="20" uuid="747423aa-be0a-4c6f-9f62-c09ccdcdef82"/>
                <textElement textAlignment="Right"/>
                <text><![CDATA[Sonderpkt]]></text>
            </staticText>
            <line>
                <reportElement x="0" y="27" width="541" height="1" uuid="01b25399-0b84-4c25-ad0b-7183d3ac6b03"/>
            </line>
        </band>
    </columnHeader>
    <detail>
        <band height="42" splitType="Stretch">
            <textField>
                <reportElement x="27" y="3" width="76" height="20" uuid="cd5e5c50-437b-40b9-a0fb-038977dad854"/>
                <textFieldExpression><![CDATA[$F{abteilung}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="116" y="3" width="44" height="20" uuid="98c1a78e-b209-4649-9c04-bf26fd3e312f"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$F{punkte}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="179" y="3" width="46" height="20" uuid="81c956f6-d811-4d59-9a69-dba315abbd01"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$F{stunden}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="238" y="3" width="61" height="20" uuid="91fa70d4-d52a-489c-b2a6-4aa2c013f867"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$F{minusstd}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="312" y="3" width="48" height="20" uuid="e0e1e8d7-d8ca-4b83-bb59-64248f0705f8"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$F{grad}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="374" y="3" width="41" height="20" uuid="eac65045-2f6e-43f4-afd2-8f2b29498b6e"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$F{praemie}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="440" y="3" width="54" height="20" uuid="9ce65d97-ea6f-465d-a81f-37437dfe8a21"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$F{sonderpkt}]]></textFieldExpression>
            </textField>
            <line>
                <reportElement x="1" y="37" width="541" height="1" uuid="cf79a153-e1d1-4390-b2bb-19f61e02d09c"/>
            </line>
        </band>
    </detail>
    <pageFooter>
        <band height="50">
            <textField>
                <reportElement x="4" y="35" width="23" height="14" uuid="bfa34750-f973-495c-9c56-b49085192120"/>
                <textElement>
                    <font size="8"/>
                </textElement>
                <textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="30" y="35" width="243" height="13" uuid="2f5e395f-53f9-4255-92fd-7fd1042c1906"/>
                <textElement>
                    <font size="8"/>
                </textElement>
                <text><![CDATA[\\hhabas-au\hh\jasper\layout\hhjasper\praemie\tagesmeldung.jrxml]]></text>
            </staticText>
        </band>
    </pageFooter>
    <summary>
        <band height="151">
            <rectangle>
                <reportElement mode="Transparent" x="22" y="5" width="514" height="138" uuid="4584a401-ad44-414e-894d-9d45429b0636"/>
            </rectangle>
            <subreport isUsingCache="false">
                <reportElement stretchType="RelativeToBandHeight" x="22" y="5" width="514" height="138" uuid="9b4faa79-12a0-421d-a721-6cbcbe8f685d"/>
                <subreportExpression><![CDATA["//erp/abas/hh/win/jasper/layout/hhjasper/praemie/monatsmeldung.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </summary>
</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="monatsmeldung" language="groovy" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" whenResourceMissingType="Empty" uuid="dfe2d8f6-4691-4cf8-a772-a0cefc2357a8">
    <property name="ireport.zoom" value="1.9487171000000014"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <queryString language="json">
        <![CDATA[]]>
    </queryString>
    <field name="datum" class="java.lang.String"/>
    <field name="abteilung" class="java.lang.String"/>
    <field name="punkte" class="java.lang.String"/>
    <field name="sonderp" class="java.lang.String"/>
    <field name="stunden" class="java.lang.String"/>
    <field name="minusstd" class="java.lang.String"/>
    <field name="grad" class="java.lang.String"/>
    <field name="praemie" class="java.lang.String"/>
    <field name="monat" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <pageHeader>
        <band height="87" splitType="Stretch">
            <staticText>
                <reportElement x="17" y="10" width="153" height="20" uuid="2135dd58-bf20-46b7-8557-2cf1ed134b31"/>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Prämien für den Monat]]></text>
            </staticText>
            <staticText>
                <reportElement x="17" y="30" width="114" height="18" uuid="3b9d737f-6139-441e-8592-af104747f8cb"/>
                <text><![CDATA[Letzter bewerteter Tag]]></text>
            </staticText>
            <textField>
                <reportElement x="170" y="30" width="100" height="18" uuid="b0f3b257-2c51-4fbc-8652-75b5056edf94"/>
                <textFieldExpression><![CDATA[$F{datum}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="17" y="71" width="55" height="16" uuid="69e22240-166c-435f-82a7-ae43e40a677b"/>
                <textElement>
                    <font isUnderline="true"/>
                </textElement>
                <text><![CDATA[Abteilung]]></text>
            </staticText>
            <staticText>
                <reportElement x="108" y="71" width="46" height="16" uuid="e0d54660-d1f7-4c98-b78a-3ecab0b4e2ba"/>
                <textElement>
                    <font isUnderline="true"/>
                </textElement>
                <text><![CDATA[Punkte]]></text>
            </staticText>
            <staticText>
                <reportElement x="176" y="71" width="53" height="16" uuid="7ef34e52-8071-4488-9364-1ed823d6280e"/>
                <textElement>
                    <font isUnderline="true"/>
                </textElement>
                <text><![CDATA[Sonderp.]]></text>
            </staticText>
            <staticText>
                <reportElement x="253" y="71" width="47" height="16" uuid="2267a230-1032-42c4-a015-afff70b23c4d"/>
                <textElement>
                    <font isUnderline="true"/>
                </textElement>
                <text><![CDATA[Stunden]]></text>
            </staticText>
            <staticText>
                <reportElement x="327" y="71" width="49" height="16" uuid="0d9a65a6-4e73-42b7-9b54-70f0c8f640ac"/>
                <textElement>
                    <font isUnderline="true"/>
                </textElement>
                <text><![CDATA[Minusstd]]></text>
            </staticText>
            <staticText>
                <reportElement x="399" y="71" width="34" height="16" uuid="35251935-f1a8-4086-aedf-d06e60dafcd3"/>
                <textElement>
                    <font isUnderline="true"/>
                </textElement>
                <text><![CDATA[Grad]]></text>
            </staticText>
            <staticText>
                <reportElement x="452" y="71" width="53" height="16" uuid="27989788-6c12-4d18-b6bc-473dad68d406"/>
                <textElement>
                    <font isUnderline="true"/>
                </textElement>
                <text><![CDATA[Prämie]]></text>
            </staticText>
            <textField>
                <reportElement x="200" y="10" width="100" height="20" uuid="dd499969-3189-4bdb-aaa6-3fe0afdaa90a"/>
                <textFieldExpression><![CDATA[$F{monat}]]></textFieldExpression>
            </textField>
        </band>
    </pageHeader>
    <detail>
        <band height="30" splitType="Stretch">
            <textField>
                <reportElement x="17" y="0" width="75" height="16" uuid="733a8d78-60e6-43e5-a7ac-605da18a7b4c"/>
                <textFieldExpression><![CDATA[$F{abteilung}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="100" y="0" width="54" height="16" uuid="a13e8e3e-709c-485a-992f-eca7c334794e"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$F{punkte}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="174" y="0" width="55" height="16" uuid="ec728f09-1232-477a-8bca-ee43d19ba9f9"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$F{sonderp}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="243" y="0" width="57" height="16" uuid="35f36edc-eb00-4a90-aec3-fd7fba6fe0f8"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$F{stunden}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="317" y="0" width="59" height="16" uuid="f0075fd7-3e23-49b8-81d1-fc7935f622f3"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$F{minusstd}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="390" y="0" width="43" height="16" uuid="6e30d6b8-58b9-4cf3-8239-dd5b8d37a42a"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$F{grad}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="452" y="0" width="53" height="16" uuid="50d48a89-a427-4cb8-9ed5-9a6073532c56"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$F{praemie}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport> `

0 个答案:

没有答案