Error retrieving field value from bean : mascara

0 respostas
D

Ola turma.

Já verifiquei o jasper e os atributos os mesmos estão iguais.

fonte:

package testebudnyweb;

import conexao.Conexao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;

/**
 *
 * @author user
 */
public class FichaTecnicaMultNivel {
    
    /** Creates a new instance of FichaTecnicaMultNivel */
    public FichaTecnicaMultNivel() {
    }
    
    public static void main(String[] args) {
        List<Ficha> lista = new ArrayList<Ficha>();
        List<Boolean> fichaAberta = new ArrayList<Boolean>();
        
        Connection conn = Conexao.getInstance().getConnection();
        String relatorioJASPER = null;
        //relatorioJASPER = "/WEB-INF/classes/relatorios/comercial/BoletimEntrega.jasper";
        
        //ServletOutputStream servletOutputStream = response.getOutputStream();
        //InputStream reportStream = getServletConfig().getServletContext().getResourceAsStream(relatorioJASPER);
        StringBuffer sql = new StringBuffer();
        try {
            
            HashMap parameters = new HashMap();
            parameters.put("empresa", "EMPRESA");
            parameters.put("cnpj", "CNPJ:  Insc. Est.: ");
            parameters.put("usuario", "Usuario: DAVI");
            
            sql.append("select codpro, descripro, abrevuni, qtdadefct ");
            sql.append("from fichatec ");
            sql.append("left join produto on empresapro=empfct and codpro=componfct ");
            sql.append("left join unidade on empuni=empfct and coduni=unidpro ");
            sql.append("where empfct='001' ");
            sql.append("and codprofct='200010' ");
            sql.append("order by descripro;");
            
            Statement statement = conn.createStatement();
            ResultSet result = statement.executeQuery( sql.toString() );
            Integer i = 1;
            while ( result.next() ) {
                Ficha ficha = new Ficha();
                if ( i < 10 ) {
                    ficha.setMascara( "0" + i );
                } else {
                    ficha.setMascara( i.toString() );
                }
                i++;
                ficha.setCodpro( result.getString( 1 ) );
                ficha.setDescripro( result.getString( 2 ) );
                ficha.setUnidade( result.getString( 3 ) );
                ficha.setQtdade( result.getDouble( 4 ) );
                lista.add(ficha);
                fichaAberta.add(false);
            }
            int j = fichaAberta.indexOf(false);
            while ( j != -1){
                Ficha resultado = (Ficha) lista.get(j);
                fichaAberta.set(j, true);
                sql = new StringBuffer();
                sql.append("select codpro, descripro, abrevuni, ");
                sql.append(resultado.getQtdade()+"*qtdadefct as qtdadefct ");
                sql.append("from fichatec ");
                sql.append("left join produto on empresapro=empfct and codpro=componfct ");
                sql.append("left join unidade on empuni=empfct and coduni=unidpro ");
                sql.append("where empfct='001' ");
                sql.append("and codprofct='" + resultado.getCodpro() + "' ");
                sql.append("order by descripro;");
                
                statement = conn.createStatement();
                result = statement.executeQuery( sql.toString() );
                i = 1;
                while ( result.next() ) {
                    Ficha ficha = new Ficha();
                    if ( i < 10 ) {
                        ficha.setMascara( resultado.getMascara() + "." + "0" + i );
                    } else {
                        ficha.setMascara( resultado.getMascara() + "." + i.toString() );
                    }
                    i++;
                    ficha.setCodpro( result.getString( 1 ) );
                    ficha.setDescripro( result.getString( 2 ) );
                    ficha.setUnidade( result.getString( 3 ) );
                    ficha.setQtdade( result.getDouble( 4 ) );
                    lista.add(ficha);
                    fichaAberta.add(false);
                }
                j = fichaAberta.indexOf(false);
            }
            
            sql = new StringBuffer();
            
            for (int h = 0; h < lista.size(); h++) {
                System.out.println(lista.get(h).getMascara());
            }
            
            Collections.sort(lista, new Comparator<Ficha>() {
                public int compare(Ficha o1, Ficha o2) {
                    return o1.getMascara().compareTo(o2.getMascara());
                }
            });
            
            for (int h = 0; h < lista.size(); h++) {
                System.out.println(lista.get(h).getMascara());
            }
            
            JRBeanCollectionDataSource jr = new JRBeanCollectionDataSource(lista);
            
            JasperPrint jasperPrint = JasperManager.fillReport("E:/ProjetosJava/Netbeans/TesteBudnyWeb/src/testebudnyweb/FichaTecnicaMultNivel.jasper", parameters, jr);
            JasperExportManager.exportReportToPdfFile(jasperPrint, "Saida.pdf");
            
        } catch(Exception e) {
            System.out.println(e.getMessage() + sql.toString());
        }
    }
}

class Ficha {
    private String mascara;
    private String codpro;
    private String descripro;
    private String unidade;
    private double qtdade;
    
    public Ficha(){}
    
    public Ficha(String mascara, String codpro, String descripro, double qtdade){
        this.mascara = mascara;
        this.codpro = codpro;
        this.descripro = descripro;
        this.qtdade = qtdade;
    }
    
    public String getMascara() {
        return mascara;
    }
    
    public void setMascara(String mascara) {
        this.mascara = mascara;
    }
    
    public String getCodpro() {
        return codpro;
    }
    
    public void setCodpro(String codpro) {
        this.codpro = codpro;
    }
    
    public String getDescripro() {
        return descripro;
    }
    
    public void setDescripro(String descripro) {
        this.descripro = descripro;
    }
    
    public double getQtdade() {
        return qtdade;
    }
    
    public void setQtdade(double qtdade) {
        this.qtdade = qtdade;
    }
    
    public void setUnidade(String unidade) {
        this.unidade = unidade;
    }
    
    
}

Alguém sabe o que mais pode ser?

Criado 19 de setembro de 2007
Respostas 0
Participantes 1