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-87c2c4800839master
parent
20545734a0
commit
0656751020
|
@ -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,55 +68,84 @@ 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()));
|
|
||||||
|
|
||||||
if (lsNumPuntoVenta.size() > 0) {
|
Timestamp dataInicio = new Timestamp(((java.util.Date) this.datInicial.getValue()).getTime());
|
||||||
Integer puntuVentaId = null;
|
Timestamp dataFinal = new Timestamp(((java.util.Date) this.datFinal.getValue()).getTime());
|
||||||
try {
|
|
||||||
puntuVentaId = Integer.parseInt(lsNumPuntoVenta.iterator().next());
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
}
|
|
||||||
parametros.put("PUNTOVENTA_ID", puntuVentaId);
|
|
||||||
}
|
|
||||||
|
|
||||||
String empresa = "";
|
if (dataInicio.equals(dataFinal)) {
|
||||||
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 + "%";
|
GregorianCalendar auxDataInicio = (GregorianCalendar) GregorianCalendar.getInstance();
|
||||||
parametros.put("NOMBEMPRESA_SEARCH", empresaSearch);
|
auxDataInicio.setTimeInMillis(dataInicio.getTime());
|
||||||
|
|
||||||
Date now = new Date();
|
int year = auxDataInicio.get(Calendar.YEAR);
|
||||||
parametros.put("NOW", now);
|
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();
|
auxDataInicio.set(year, month, date, hourOfDay, minute, second);
|
||||||
args.put("relatorio", relatorio);
|
dataInicio = new Timestamp(auxDataInicio.getTimeInMillis());
|
||||||
|
|
||||||
openWindow("/component/reportView.zul",
|
GregorianCalendar auxDataFinal = (GregorianCalendar) GregorianCalendar.getInstance();
|
||||||
Labels.getLabel("relatorioTrechoVendidoController.window.title"), args, MODAL);
|
auxDataFinal.setTimeInMillis(dataFinal.getTime());
|
||||||
} else {
|
|
||||||
try {
|
hourOfDay = 23;
|
||||||
Messagebox.show(Labels.getLabel("relatorioTrechoVendidoController.no.agencia"),
|
minute = 59;
|
||||||
Labels.getLabel("relatorioTrechoVendidoController.window.title"),
|
second = 59;
|
||||||
Messagebox.OK, Messagebox.INFORMATION);
|
|
||||||
} catch (InterruptedException ex) {
|
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) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue