From 0656751020c1148a6c19fe0b4e88b77aaff1c668 Mon Sep 17 00:00:00 2001 From: julio Date: Mon, 29 Jul 2013 14:57:53 +0000 Subject: [PATCH] =?UTF-8?q?CORRE=C3=87=C3=95ES=20-=20Relat=C3=B3rio=20de?= =?UTF-8?q?=20Trecho=20Vendido=20Por=20Ag=C3=AAncia?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@29522 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../RelatorioTrechoVendidoController.java | 154 ++++++++++-------- 1 file changed, 85 insertions(+), 69 deletions(-) diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioTrechoVendidoController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioTrechoVendidoController.java index d8371cbe6..50aff0866 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioTrechoVendidoController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioTrechoVendidoController.java @@ -1,7 +1,10 @@ package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Calendar; import java.util.Date; +import java.util.GregorianCalendar; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -13,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; import org.zkoss.util.resource.Labels; -import org.zkoss.zhtml.Messagebox; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.event.Event; import org.zkoss.zul.Bandbox; @@ -39,6 +41,8 @@ import com.trg.search.Filter; public class RelatorioTrechoVendidoController extends MyGenericForwardComposer { private static final long serialVersionUID = 1L; + private static final String TODOS = "TODAS"; + private static final String TODOS_VALUE = new Integer(-1).toString(); private static Logger log = Logger.getLogger(RelatorioTrechoVendidoController.class); @@ -48,8 +52,7 @@ public class RelatorioTrechoVendidoController extends MyGenericForwardComposer { @Autowired private EmpresaService empresaService; - private ArrayList lsNumPuntoVenta = new ArrayList(); - private ArrayList lsNumEmpresa = new ArrayList(); + private ArrayList lsNumPuntoVenta = new ArrayList(); @Autowired private transient PagedListWrapper plwPuntoVenta; @@ -65,55 +68,84 @@ public class RelatorioTrechoVendidoController extends MyGenericForwardComposer { private void executarRelatorio() throws Exception { - if (lsNumPuntoVenta.size() > 0) { - Map parametros = new HashMap(); - parametros.put("DATA_INICIO", new java.sql.Date(((java.util.Date) this.datInicial.getValue()).getTime())); - parametros.put("DATA_FINAL", new java.sql.Date(((java.util.Date) this.datFinal.getValue()).getTime())); + Map parametros = new HashMap(); - if (lsNumPuntoVenta.size() > 0) { - Integer puntuVentaId = null; - try { - puntuVentaId = Integer.parseInt(lsNumPuntoVenta.iterator().next()); - } catch (Exception e) { - log.error(e.getMessage()); - } - parametros.put("PUNTOVENTA_ID", puntuVentaId); - } + Timestamp dataInicio = new Timestamp(((java.util.Date) this.datInicial.getValue()).getTime()); + Timestamp dataFinal = new Timestamp(((java.util.Date) this.datFinal.getValue()).getTime()); - String empresa = ""; - try { - Empresa e = (Empresa) cmbEmpresa.getSelectedItem().getValue(); - if (!e.equals(null)) { - empresa = e.getNombempresa(); - } - } catch (NullPointerException e) { - empresa = ""; - } catch (Exception e) { - log.error(e.getMessage()); - } - parametros.put("NOMBEMPRESA", empresa); + if (dataInicio.equals(dataFinal)) { - String empresaSearch = "%" + empresa + "%"; - parametros.put("NOMBEMPRESA_SEARCH", empresaSearch); + GregorianCalendar auxDataInicio = (GregorianCalendar) GregorianCalendar.getInstance(); + auxDataInicio.setTimeInMillis(dataInicio.getTime()); - Date now = new Date(); - parametros.put("NOW", now); + int year = auxDataInicio.get(Calendar.YEAR); + int month = auxDataInicio.get(Calendar.MONTH); + int date = auxDataInicio.get(Calendar.DATE); - Relatorio relatorio = new RelatorioTrechoVendido(parametros, dataSource.getConnection()); + int hourOfDay = 00; + int minute = 00; + int second = 00; - Map args = new HashMap(); - args.put("relatorio", relatorio); + auxDataInicio.set(year, month, date, hourOfDay, minute, second); + dataInicio = new Timestamp(auxDataInicio.getTimeInMillis()); - openWindow("/component/reportView.zul", - Labels.getLabel("relatorioTrechoVendidoController.window.title"), args, MODAL); - } else { - try { - Messagebox.show(Labels.getLabel("relatorioTrechoVendidoController.no.agencia"), - Labels.getLabel("relatorioTrechoVendidoController.window.title"), - Messagebox.OK, Messagebox.INFORMATION); - } catch (InterruptedException ex) { - } + GregorianCalendar auxDataFinal = (GregorianCalendar) GregorianCalendar.getInstance(); + auxDataFinal.setTimeInMillis(dataFinal.getTime()); + + hourOfDay = 23; + minute = 59; + second = 59; + + auxDataFinal.set(year, month, date, hourOfDay, minute, second); + dataFinal = new Timestamp(auxDataFinal.getTimeInMillis()); } + + parametros.put("DATA_INICIO", dataInicio); + parametros.put("DATA_FINAL", dataFinal); + + if (lsNumPuntoVenta.size() > 0) { + String puntoVentaExpression = null; + for (PuntoVenta p : lsNumPuntoVenta) { + if (lsNumPuntoVenta.indexOf(p) == 0) { + puntoVentaExpression = p.getPuntoventaId().toString(); + } else { + puntoVentaExpression += ", " + p.getPuntoventaId().toString(); + } + } + System.out.println(puntoVentaExpression); + parametros.put("PUNTOVENTA_ID", puntoVentaExpression); + parametros.put("PUNTOVENTA", puntoVentaExpression); + } else { + parametros.put("PUNTOVENTA_ID", TODOS_VALUE); + parametros.put("PUNTOVENTA", TODOS); + } + + String empresa = ""; + try { + Empresa e = (Empresa) cmbEmpresa.getSelectedItem().getValue(); + if (!e.equals(null)) { + empresa = e.getNombempresa(); + } + } catch (NullPointerException e) { + empresa = ""; + } catch (Exception e) { + log.error(e.getMessage()); + } + parametros.put("NOMBEMPRESA", empresa); + + String empresaSearch = "%" + empresa + "%"; + parametros.put("NOMBEMPRESA_SEARCH", empresaSearch); + + Date now = new Date(); + parametros.put("NOW", now); + + Relatorio relatorio = new RelatorioTrechoVendido(parametros, dataSource.getConnection()); + + Map args = new HashMap(); + args.put("relatorio", relatorio); + + openWindow("/component/reportView.zul", + Labels.getLabel("relatorioTrechoVendidoController.window.title"), args, MODAL); } public void onSelect$puntoVentaList(Event ev) { @@ -124,7 +156,7 @@ public class RelatorioTrechoVendidoController extends MyGenericForwardComposer { lsNumPuntoVenta.clear(); for (Object objPuntoVenta : lsSelecionados) { strListPuntoVenta = ((PuntoVenta) objPuntoVenta).getNombpuntoventa() + " " + strListPuntoVenta; - lsNumPuntoVenta.add(((PuntoVenta) objPuntoVenta).getPuntoventaId().toString()); + lsNumPuntoVenta.add(((PuntoVenta) objPuntoVenta)); } this.bbPesquisaPuntoVenta.setValue(strListPuntoVenta); } @@ -161,14 +193,14 @@ public class RelatorioTrechoVendidoController extends MyGenericForwardComposer { plwPuntoVenta.init(puntoVentaBusqueda, puntoVentaList, pagingPuntoVenta); - if (puntoVentaList.getData().length == 0) { - try { - Messagebox.show(Labels.getLabel("MSG.ningunRegistro"), - Labels.getLabel("relatorioTrechoVendidoController.window.title"), - Messagebox.OK, Messagebox.INFORMATION); - } catch (InterruptedException ex) { - } - } + // if (puntoVentaList.getData().length == 0) { + // try { + // Messagebox.show(Labels.getLabel("MSG.ningunRegistro"), + // Labels.getLabel("relatorioTrechoVendidoController.window.title"), + // Messagebox.OK, Messagebox.INFORMATION); + // } catch (InterruptedException ex) { + // } + // } } @Override @@ -186,22 +218,6 @@ public class RelatorioTrechoVendidoController extends MyGenericForwardComposer { this.dataSource = dataSource; } - public ArrayList getLsNumPuntoVenta() { - return lsNumPuntoVenta; - } - - public void setLsNumPuntoVenta(ArrayList lsNumPuntoVenta) { - this.lsNumPuntoVenta = lsNumPuntoVenta; - } - - public ArrayList getLsNumEmpresa() { - return lsNumEmpresa; - } - - public void setLsNumEmpresa(ArrayList lsNumEmpresa) { - this.lsNumEmpresa = lsNumEmpresa; - } - public List getLsEmpresa() { return lsEmpresa; }