Java - ayuda con reportes y parametros

 
Vista:
sin imagen de perfil

ayuda con reportes y parametros

Publicado por joaquin (13 intervenciones) el 10/09/2015 12:17:11
Resulta que quiero hacer un reporte sacando datos de dos tablas distintas. Tengo esto, pero no funciona:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
      List lista = new ArrayList();
    for(int i=0;i<tabla_elaboracion_dias.getRowCount();i++)
    {
        ConsultaElaboracion consulta= new ConsultaElaboracion(tabla_elaboracion_dias.getValueAt(i, 0).toString(),
                tabla_elaboracion_dias.getValueAt(i, 1).toString());
        lista.add(consulta);
    }
            for(int i=0;i<tabla_elaboracion.getRowCount();i++)
    {
        ConsultaElaboraciones consultas= new ConsultaElaboraciones( tabla_elaboracion.getValueAt(i, 2).toString(),
                tabla_elaboracion.getValueAt(i, 3).toString(),
                tabla_elaboracion.getValueAt(i, 4).toString());
        lista.add(consultas);
    }
        try {
         JasperReport reporte = JasperCompileManager.compileReport("src/Reportes/SemanalElab.jrxml");
 
            Map parametro = new HashMap();
            parametro.put("semana", cmbSemanaElaboracion.getSelectedItem());
            parametro.put("ano", cmbAno2.getSelectedItem());
            JasperPrint jprint= JasperFillManager.fillReport(reporte, parametro,new JRBeanCollectionDataSource(lista));
            JasperViewer.viewReport(jprint,false);
        } catch (JRException ex) {
            Logger.getLogger(Paneles.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

Los datos que quiero sacar de la tabla tabla_elaboracion no estan guardados en ningun sitio, pues los saco de la siguiente consulta:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public void diferencialElaboracion() {
        String[] titulo = {"Codigo", "Nombre", "Pedido Total", "Servido Total", "Diferencial"};
        String[] fila = new String[5];
        model = new DefaultTableModel(null, titulo);
 
        String Sql = "SELECT codigo, nombre,"
                + "SUM(CASE WHEN pedido>0 THEN pedido ELSE 0 END) AS 'pedido_total',"
                + "SUM(CASE WHEN servido>0 THEN servido ELSE 0 END) AS 'servido_total',"
                + "(SUM(servido)- SUM(pedido)) AS 'diferencial'"
                + "FROM t_general WHERE destino = 'ELABORACION'"
                + "AND semana='" + cmbSemanaElaboracion.getSelectedItem() + "'"
                + "AND ano='" + cmbAno2.getSelectedItem() + "' GROUP BY codigo";
        conn = Conexion_DB.Conexion();
 
        try {
            sent = conn.createStatement();
            ResultSet rs = sent.executeQuery(Sql);
            while (rs.next()) {
                fila[0] = rs.getString("codigo");
                fila[1] = rs.getString("nombre");
                fila[2] = rs.getString("pedido_total");
                fila[3] = rs.getString("servido_total");
                fila[4] = rs.getString("diferencial");
                model.addRow(fila);
            }
            tabla_elaboracion.setModel(model);
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, ex);
        }
 
    }


se podria hacer lo que pido?
y otra cosa, cada vez que arranco un reporte basico que pone que el uuid no esta permitido
gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder