CORREÇÕES - Relatório de Trecho Vendido Por Agência

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@29522 d1611594-4594-4d17-8e1d-87c2c4800839
master
julio 2013-07-29 14:57:53 +00:00
parent 20545734a0
commit 0656751020
1 changed files with 85 additions and 69 deletions

View File

@ -1,7 +1,10 @@
package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios; package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios;
import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -13,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.zkoss.util.resource.Labels; import org.zkoss.util.resource.Labels;
import org.zkoss.zhtml.Messagebox;
import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zul.Bandbox; import org.zkoss.zul.Bandbox;
@ -39,6 +41,8 @@ import com.trg.search.Filter;
public class RelatorioTrechoVendidoController extends MyGenericForwardComposer { public class RelatorioTrechoVendidoController extends MyGenericForwardComposer {
private static final long serialVersionUID = 1L; 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); private static Logger log = Logger.getLogger(RelatorioTrechoVendidoController.class);
@ -48,8 +52,7 @@ public class RelatorioTrechoVendidoController extends MyGenericForwardComposer {
@Autowired @Autowired
private EmpresaService empresaService; private EmpresaService empresaService;
private ArrayList<String> lsNumPuntoVenta = new ArrayList<String>(); private ArrayList<PuntoVenta> lsNumPuntoVenta = new ArrayList<PuntoVenta>();
private ArrayList<String> lsNumEmpresa = new ArrayList<String>();
@Autowired @Autowired
private transient PagedListWrapper<PuntoVenta> plwPuntoVenta; private transient PagedListWrapper<PuntoVenta> plwPuntoVenta;
@ -65,19 +68,56 @@ public class RelatorioTrechoVendidoController extends MyGenericForwardComposer {
private void executarRelatorio() throws Exception { private void executarRelatorio() throws Exception {
if (lsNumPuntoVenta.size() > 0) {
Map<String, Object> parametros = new HashMap<String, Object>(); Map<String, Object> parametros = new HashMap<String, Object>();
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())); Timestamp dataInicio = new Timestamp(((java.util.Date) this.datInicial.getValue()).getTime());
Timestamp dataFinal = new Timestamp(((java.util.Date) this.datFinal.getValue()).getTime());
if (dataInicio.equals(dataFinal)) {
GregorianCalendar auxDataInicio = (GregorianCalendar) GregorianCalendar.getInstance();
auxDataInicio.setTimeInMillis(dataInicio.getTime());
int year = auxDataInicio.get(Calendar.YEAR);
int month = auxDataInicio.get(Calendar.MONTH);
int date = auxDataInicio.get(Calendar.DATE);
int hourOfDay = 00;
int minute = 00;
int second = 00;
auxDataInicio.set(year, month, date, hourOfDay, minute, second);
dataInicio = new Timestamp(auxDataInicio.getTimeInMillis());
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) { if (lsNumPuntoVenta.size() > 0) {
Integer puntuVentaId = null; String puntoVentaExpression = null;
try { for (PuntoVenta p : lsNumPuntoVenta) {
puntuVentaId = Integer.parseInt(lsNumPuntoVenta.iterator().next()); if (lsNumPuntoVenta.indexOf(p) == 0) {
} catch (Exception e) { puntoVentaExpression = p.getPuntoventaId().toString();
log.error(e.getMessage()); } else {
puntoVentaExpression += ", " + p.getPuntoventaId().toString();
} }
parametros.put("PUNTOVENTA_ID", puntuVentaId); }
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 = ""; String empresa = "";
@ -106,14 +146,6 @@ public class RelatorioTrechoVendidoController extends MyGenericForwardComposer {
openWindow("/component/reportView.zul", openWindow("/component/reportView.zul",
Labels.getLabel("relatorioTrechoVendidoController.window.title"), args, MODAL); 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) {
}
}
} }
public void onSelect$puntoVentaList(Event ev) { public void onSelect$puntoVentaList(Event ev) {
@ -124,7 +156,7 @@ public class RelatorioTrechoVendidoController extends MyGenericForwardComposer {
lsNumPuntoVenta.clear(); lsNumPuntoVenta.clear();
for (Object objPuntoVenta : lsSelecionados) { for (Object objPuntoVenta : lsSelecionados) {
strListPuntoVenta = ((PuntoVenta) objPuntoVenta).getNombpuntoventa() + " " + strListPuntoVenta; strListPuntoVenta = ((PuntoVenta) objPuntoVenta).getNombpuntoventa() + " " + strListPuntoVenta;
lsNumPuntoVenta.add(((PuntoVenta) objPuntoVenta).getPuntoventaId().toString()); lsNumPuntoVenta.add(((PuntoVenta) objPuntoVenta));
} }
this.bbPesquisaPuntoVenta.setValue(strListPuntoVenta); this.bbPesquisaPuntoVenta.setValue(strListPuntoVenta);
} }
@ -161,14 +193,14 @@ public class RelatorioTrechoVendidoController extends MyGenericForwardComposer {
plwPuntoVenta.init(puntoVentaBusqueda, puntoVentaList, pagingPuntoVenta); plwPuntoVenta.init(puntoVentaBusqueda, puntoVentaList, pagingPuntoVenta);
if (puntoVentaList.getData().length == 0) { // if (puntoVentaList.getData().length == 0) {
try { // try {
Messagebox.show(Labels.getLabel("MSG.ningunRegistro"), // Messagebox.show(Labels.getLabel("MSG.ningunRegistro"),
Labels.getLabel("relatorioTrechoVendidoController.window.title"), // Labels.getLabel("relatorioTrechoVendidoController.window.title"),
Messagebox.OK, Messagebox.INFORMATION); // Messagebox.OK, Messagebox.INFORMATION);
} catch (InterruptedException ex) { // } catch (InterruptedException ex) {
} // }
} // }
} }
@Override @Override
@ -186,22 +218,6 @@ public class RelatorioTrechoVendidoController extends MyGenericForwardComposer {
this.dataSource = dataSource; this.dataSource = dataSource;
} }
public ArrayList<String> getLsNumPuntoVenta() {
return lsNumPuntoVenta;
}
public void setLsNumPuntoVenta(ArrayList<String> lsNumPuntoVenta) {
this.lsNumPuntoVenta = lsNumPuntoVenta;
}
public ArrayList<String> getLsNumEmpresa() {
return lsNumEmpresa;
}
public void setLsNumEmpresa(ArrayList<String> lsNumEmpresa) {
this.lsNumEmpresa = lsNumEmpresa;
}
public List<Empresa> getLsEmpresa() { public List<Empresa> getLsEmpresa() {
return lsEmpresa; return lsEmpresa;
} }