bug#22299
dev: GLEIMAR qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@107953 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
e8669ef688
commit
1675bca711
|
@ -24,7 +24,7 @@ public class RelatorioMensalDAER extends Relatorio {
|
||||||
|
|
||||||
private List<RelatorioMensalDAERBean> lsDadosRelatorio;
|
private List<RelatorioMensalDAERBean> lsDadosRelatorio;
|
||||||
private static Logger log = Logger.getLogger(RelatorioMensalDAER.class);
|
private static Logger log = Logger.getLogger(RelatorioMensalDAER.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parametros
|
* @param parametros
|
||||||
* @param conexao
|
* @param conexao
|
||||||
|
@ -38,9 +38,10 @@ public class RelatorioMensalDAER extends Relatorio {
|
||||||
try {
|
try {
|
||||||
String agencia = parametros.get("AGENCIA") != null ? parametros.get("AGENCIA").toString() : null;
|
String agencia = parametros.get("AGENCIA") != null ? parametros.get("AGENCIA").toString() : null;
|
||||||
Empresa empresa = parametros.get("EMPRESA") != null ? (Empresa) (parametros.get("EMPRESA")) : null;
|
Empresa empresa = parametros.get("EMPRESA") != null ? (Empresa) (parametros.get("EMPRESA")) : null;
|
||||||
|
String tipoVenta = parametros.get("TIPOVENTA_ID").toString();
|
||||||
|
|
||||||
// Executa query relatório e preenche objeto relatório
|
// Executa query relatório e preenche objeto relatório
|
||||||
lsDadosRelatorio = preencheAgrupaRelatorioBean(preparaExecutaQuery(parametros, conexao, empresa, agencia));
|
lsDadosRelatorio = preencheAgrupaRelatorioBean(preparaExecutaQuery(parametros, conexao, empresa, agencia, tipoVenta));
|
||||||
|
|
||||||
parametros.put("RELATORIOLIST", lsDadosRelatorio);
|
parametros.put("RELATORIOLIST", lsDadosRelatorio);
|
||||||
setLsDadosRelatorio(lsDadosRelatorio);
|
setLsDadosRelatorio(lsDadosRelatorio);
|
||||||
|
@ -58,8 +59,9 @@ public class RelatorioMensalDAER extends Relatorio {
|
||||||
* @return
|
* @return
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
private ResultSet preparaExecutaQuery(Map<String, Object> parametros, Connection conexao, Empresa empresa, String agencia) throws SQLException {
|
private ResultSet preparaExecutaQuery(Map<String, Object> parametros, Connection conexao, Empresa empresa, String agencia, String tipoVenta) throws SQLException {
|
||||||
String sql = getSql();
|
Boolean istipoVenta = (!tipoVenta.isEmpty());
|
||||||
|
String sql = getSql(istipoVenta);
|
||||||
NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql);
|
NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql);
|
||||||
ResultSet rset = null;
|
ResultSet rset = null;
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
||||||
|
@ -75,6 +77,7 @@ public class RelatorioMensalDAER extends Relatorio {
|
||||||
}
|
}
|
||||||
stmt.setInt("EMPRESA", empresa.getEmpresaId());
|
stmt.setInt("EMPRESA", empresa.getEmpresaId());
|
||||||
stmt.setString("AGENCIA", agencia);
|
stmt.setString("AGENCIA", agencia);
|
||||||
|
stmt.setString("TIPOVENTA_ID", tipoVenta);
|
||||||
rset = stmt.executeQuery();
|
rset = stmt.executeQuery();
|
||||||
return rset;
|
return rset;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +132,7 @@ public class RelatorioMensalDAER extends Relatorio {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getSql() {
|
protected String getSql(Boolean existeTpVenta) {
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
sql.append("SELECT ");
|
sql.append("SELECT ");
|
||||||
sql.append("( case when ct.numsecuencia = 1 then null ");
|
sql.append("( case when ct.numsecuencia = 1 then null ");
|
||||||
|
@ -149,11 +152,20 @@ public class RelatorioMensalDAER extends Relatorio {
|
||||||
sql.append(" AND cn.feccorrida BETWEEN TO_DATE(:DATA_INICIO, 'DD/MM/YYYY') AND TO_DATE(:DATA_FINAL, 'DD/MM/YYYY')) as normal, ");
|
sql.append(" AND cn.feccorrida BETWEEN TO_DATE(:DATA_INICIO, 'DD/MM/YYYY') AND TO_DATE(:DATA_FINAL, 'DD/MM/YYYY')) as normal, ");
|
||||||
sql.append(" ( SELECT COUNT(ce.corrida_id) FROM corrida ce WHERE ce.corrida_id = co.corrida_id AND ce.tiposervicio_id = 2 ");
|
sql.append(" ( SELECT COUNT(ce.corrida_id) FROM corrida ce WHERE ce.corrida_id = co.corrida_id AND ce.tiposervicio_id = 2 ");
|
||||||
sql.append(" AND ce.feccorrida BETWEEN TO_DATE(:DATA_INICIO, 'DD/MM/YYYY') AND TO_DATE(:DATA_FINAL, 'DD/MM/YYYY')) as extra, ");
|
sql.append(" AND ce.feccorrida BETWEEN TO_DATE(:DATA_INICIO, 'DD/MM/YYYY') AND TO_DATE(:DATA_FINAL, 'DD/MM/YYYY')) as extra, ");
|
||||||
sql.append(" ( SELECT COUNT(caja_id) FROM caja WHERE corrida_id = co.corrida_id AND ruta_id = co.ruta_id ");
|
sql.append(" ( SELECT COUNT(caja_id) FROM caja WHERE corrida_id = co.corrida_id AND ruta_id = co.ruta_id ");
|
||||||
|
if(existeTpVenta) {
|
||||||
|
sql.append(" AND tipoventa_id in (:TIPOVENTA_ID) ");
|
||||||
|
}
|
||||||
sql.append(" AND feccorrida BETWEEN TO_DATE(:DATA_INICIO, 'DD/MM/YYYY') AND TO_DATE(:DATA_FINAL, 'DD/MM/YYYY')) AS qtdbilhetes, ");
|
sql.append(" AND feccorrida BETWEEN TO_DATE(:DATA_INICIO, 'DD/MM/YYYY') AND TO_DATE(:DATA_FINAL, 'DD/MM/YYYY')) AS qtdbilhetes, ");
|
||||||
sql.append(" ( SELECT SUM(caja.preciobase+caja.importeseguro)FROM caja WHERE corrida_id = co.corrida_id AND ruta_id = co.ruta_id ");
|
sql.append(" ( SELECT SUM(caja.preciobase+caja.importeseguro)FROM caja WHERE corrida_id = co.corrida_id AND ruta_id = co.ruta_id ");
|
||||||
|
if(existeTpVenta) {
|
||||||
|
sql.append(" AND tipoventa_id in (:TIPOVENTA_ID) ");
|
||||||
|
}
|
||||||
sql.append(" AND feccorrida BETWEEN TO_DATE(:DATA_INICIO, 'DD/MM/YYYY') AND TO_DATE(:DATA_FINAL, 'DD/MM/YYYY')) AS manifbilhetes, ");
|
sql.append(" AND feccorrida BETWEEN TO_DATE(:DATA_INICIO, 'DD/MM/YYYY') AND TO_DATE(:DATA_FINAL, 'DD/MM/YYYY')) AS manifbilhetes, ");
|
||||||
sql.append(" ( SELECT SUM(caja.importetaxaembarque)FROM caja WHERE corrida_id = co.corrida_id AND ruta_id = co.ruta_id ");
|
sql.append(" ( SELECT SUM(caja.importetaxaembarque)FROM caja WHERE corrida_id = co.corrida_id AND ruta_id = co.ruta_id ");
|
||||||
|
if(existeTpVenta) {
|
||||||
|
sql.append(" AND tipoventa_id in (:TIPOVENTA_ID) ");
|
||||||
|
}
|
||||||
sql.append(" AND feccorrida BETWEEN TO_DATE(:DATA_INICIO, 'DD/MM/YYYY') AND TO_DATE(:DATA_FINAL, 'DD/MM/YYYY')) AS embarque, ");
|
sql.append(" AND feccorrida BETWEEN TO_DATE(:DATA_INICIO, 'DD/MM/YYYY') AND TO_DATE(:DATA_FINAL, 'DD/MM/YYYY')) AS embarque, ");
|
||||||
sql.append(" ' ' as encomendas ");
|
sql.append(" ' ' as encomendas ");
|
||||||
sql.append("FROM corrida co");
|
sql.append("FROM corrida co");
|
||||||
|
@ -166,7 +178,7 @@ public class RelatorioMensalDAER extends Relatorio {
|
||||||
sql.append(" LEFT OUTER JOIN punto_venta pv ON ( pv.PARADA_ID = ct.origen_id ) ");
|
sql.append(" LEFT OUTER JOIN punto_venta pv ON ( pv.PARADA_ID = ct.origen_id ) ");
|
||||||
sql.append("WHERE co.activo = 1 ");
|
sql.append("WHERE co.activo = 1 ");
|
||||||
sql.append(" AND cs.descclase in ('CONVENCIONAL', 'EXECUTIVO', 'SEMI-DIRETO') ");
|
sql.append(" AND cs.descclase in ('CONVENCIONAL', 'EXECUTIVO', 'SEMI-DIRETO') ");
|
||||||
sql.append(" AND oc.descorgao like '%ANTT%' ");
|
sql.append(" AND oc.descorgao like '%DAER%' ");
|
||||||
sql.append(" AND co.empresacorrida_id = :EMPRESA ");
|
sql.append(" AND co.empresacorrida_id = :EMPRESA ");
|
||||||
sql.append(" AND pv.puntoventa_Id = :AGENCIA ");
|
sql.append(" AND pv.puntoventa_Id = :AGENCIA ");
|
||||||
sql.append(" AND co.feccorrida BETWEEN TO_DATE(:DATA_INICIO, 'DD/MM/YYYY') AND TO_DATE(:DATA_FINAL, 'DD/MM/YYYY') ");
|
sql.append(" AND co.feccorrida BETWEEN TO_DATE(:DATA_INICIO, 'DD/MM/YYYY') AND TO_DATE(:DATA_FINAL, 'DD/MM/YYYY') ");
|
||||||
|
@ -194,7 +206,7 @@ public class RelatorioMensalDAER extends Relatorio {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void processaParametros() throws Exception {
|
protected void processaParametros() throws Exception {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios;
|
package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -7,24 +9,38 @@ import java.util.Map;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.BooleanUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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.Button;
|
||||||
import org.zkoss.zul.Combobox;
|
import org.zkoss.zul.Combobox;
|
||||||
|
import org.zkoss.zul.Radio;
|
||||||
|
import org.zkoss.zul.Row;
|
||||||
import org.zkoss.zul.Textbox;
|
import org.zkoss.zul.Textbox;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.EmpresaEmailConfig;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.TipoVenta;
|
||||||
import com.rjconsultores.ventaboletos.entidad.UsuarioUbicacion;
|
import com.rjconsultores.ventaboletos.entidad.UsuarioUbicacion;
|
||||||
|
import com.rjconsultores.ventaboletos.enums.MimeType;
|
||||||
import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioMensalDAER;
|
import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioMensalDAER;
|
||||||
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
|
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
|
||||||
import com.rjconsultores.ventaboletos.service.EmpresaService;
|
import com.rjconsultores.ventaboletos.relatorios.utilitarios.SaidaRelatorio;
|
||||||
|
import com.rjconsultores.ventaboletos.service.EmpresaEmailConfigService;
|
||||||
|
import com.rjconsultores.ventaboletos.service.TipoVentaService;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.SendMail;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.comissao.EmailConfigVO;
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar;
|
||||||
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
|
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.MyListbox;
|
||||||
|
|
||||||
@Controller("relatorioMensalDAERController")
|
@Controller("relatorioMensalDAERController")
|
||||||
@Scope("prototype")
|
@Scope("prototype")
|
||||||
|
@ -35,41 +51,68 @@ public class RelatorioMensalDAERController extends MyGenericForwardComposer {
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataSource dataSourceRead;
|
private DataSource dataSourceRead;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TipoVentaService tipoVentaService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmpresaService empresaService;
|
private EmpresaEmailConfigService empresaEmailConfigService;
|
||||||
|
|
||||||
//private Datebox datCompetencia;
|
|
||||||
private Textbox txtCompetencia;
|
private Textbox txtCompetencia;
|
||||||
|
private Textbox txtEmail;
|
||||||
private List<Empresa> lsEmpresas;
|
private List<Empresa> lsEmpresas;
|
||||||
private Combobox cmbEmpresa;
|
private Combobox cmbEmpresa;
|
||||||
private List<UsuarioUbicacion> lsAgencias;
|
private List<UsuarioUbicacion> lsAgencias;
|
||||||
private String agenciasUsuario;
|
private String agenciasUsuario;
|
||||||
|
private Boolean isPDF = true;
|
||||||
|
private List<TipoVenta> lsTipoVenta;
|
||||||
|
private MyListbox selectedTipoVentaList;
|
||||||
|
private List<TipoVenta> listSelectedTipoVenta;
|
||||||
|
private MyComboboxEstandar cmbTipoVenta;
|
||||||
|
private Radio rdTipoAnexoPDF;
|
||||||
|
private Radio rdTipoAnexoXLS;
|
||||||
|
private Radio rdEmailSim;
|
||||||
|
private Radio rdEmailNao;
|
||||||
|
private Row rowTipoAnexo;
|
||||||
|
private Row rowSendTo;
|
||||||
|
private Button btnEnviarEmailMensalDAER;
|
||||||
|
|
||||||
private void executarRelatorio(boolean enviarEmail) throws Exception {
|
|
||||||
|
private void executarRelatorio(boolean isEnviarEmail) throws Exception {
|
||||||
try {
|
try {
|
||||||
Map<String, Object> parametros = new HashMap<String, Object>();
|
Map<String, Object> parametros = new HashMap<String, Object>();
|
||||||
|
|
||||||
// Filtro Data Inicial
|
|
||||||
String competencia = txtCompetencia.getValue().toString();
|
String competencia = txtCompetencia.getValue().toString();
|
||||||
Date periodo = DateUtil.getDateFromString("01/"+competencia, "dd/MM/yyyy");
|
// Filtro Data Inicial
|
||||||
Date dateInicio = DateUtil.inicioFecha(periodo);
|
if(competencia.isEmpty()) {
|
||||||
parametros.put("DATA_INICIO", dateInicio);
|
Messagebox.show(Labels.getLabel("relatorioMensalDAERController.data.obrigatoria"),
|
||||||
|
Labels.getLabel("relatorioMensalDAERController.window.title"),
|
||||||
// Filtro Data Final
|
Messagebox.OK, Messagebox.INFORMATION);
|
||||||
competencia = txtCompetencia.getValue().toString();
|
return;
|
||||||
parametros.put("MES", competencia.substring(0,2));
|
} else {
|
||||||
parametros.put("ANO", competencia.substring(3));
|
|
||||||
|
Date periodo = DateUtil.getDateFromString("01/"+competencia, "dd/MM/yyyy");
|
||||||
|
Date dateInicio = DateUtil.inicioFecha(periodo);
|
||||||
|
parametros.put("DATA_INICIO", dateInicio);
|
||||||
|
|
||||||
|
// Filtro Data Final
|
||||||
|
competencia = txtCompetencia.getValue().toString();
|
||||||
|
parametros.put("MES", competencia.substring(0,2));
|
||||||
|
parametros.put("ANO", competencia.substring(3));
|
||||||
|
|
||||||
|
Date dateFim = DateUtil.getDataFinalCompetencia(competencia);
|
||||||
|
parametros.put("DATA_FINAL", dateFim);
|
||||||
|
}
|
||||||
|
|
||||||
Date dateFim = DateUtil.getDataFinalCompetencia(competencia);
|
|
||||||
parametros.put("DATA_FINAL", dateFim);
|
|
||||||
|
|
||||||
// Filtro Empresa
|
// Filtro Empresa
|
||||||
Empresa empresa = null;
|
Empresa empresa = null;
|
||||||
if (cmbEmpresa.getSelectedItem() != null) {
|
if (cmbEmpresa.getSelectedItem() != null) {
|
||||||
empresa = (Empresa) cmbEmpresa.getSelectedItem().getValue();
|
empresa = (Empresa) cmbEmpresa.getSelectedItem().getValue();
|
||||||
|
} else {
|
||||||
|
Messagebox.show(Labels.getLabel("relatorioMensalDAERController.empresa.obrigatoria"),
|
||||||
|
Labels.getLabel("relatorioMensalDAERController.window.title"),
|
||||||
|
Messagebox.OK, Messagebox.INFORMATION);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
parametros.put("EMPRESA", empresa);
|
parametros.put("EMPRESA", empresa);
|
||||||
parametros.put("NOMBEMPRESA", empresa != null ? empresa.getNombempresa() : "TODOS");
|
parametros.put("NOMBEMPRESA", empresa != null ? empresa.getNombempresa() : "TODOS");
|
||||||
|
|
||||||
|
@ -82,14 +125,47 @@ public class RelatorioMensalDAERController extends MyGenericForwardComposer {
|
||||||
parametros.put("RODOVIARIA", UsuarioLogado.getUsuarioLogado().getUsuarioUbicacionList().get(0).getPuntoVenta().getNombpuntoventa().toString());
|
parametros.put("RODOVIARIA", UsuarioLogado.getUsuarioLogado().getUsuarioUbicacionList().get(0).getPuntoVenta().getNombpuntoventa().toString());
|
||||||
parametros.put("ESTACION", "");
|
parametros.put("ESTACION", "");
|
||||||
|
|
||||||
|
StringBuilder tipVenta = new StringBuilder();
|
||||||
|
StringBuilder tipVentaIds = new StringBuilder();
|
||||||
|
for (TipoVenta venta : listSelectedTipoVenta) {
|
||||||
|
tipVenta.append(venta.getDesctipoventa()).append(",");
|
||||||
|
tipVentaIds.append(venta.getTipoventaId()).append(",");
|
||||||
|
}
|
||||||
|
|
||||||
|
// removendo ultima virgula
|
||||||
|
tipVentaIds = tipVentaIds.delete(tipVentaIds.length() -1, tipVentaIds.length());
|
||||||
|
tipVenta = tipVenta.delete(tipVenta.length() -1, tipVenta.length());
|
||||||
|
|
||||||
|
parametros.put("TIPOVENTA", tipVenta.append(";").toString());
|
||||||
|
parametros.put("TIPOVENTA_ID", tipVentaIds.toString());
|
||||||
|
|
||||||
// Instancia o relatório
|
// Instancia o relatório
|
||||||
Relatorio relatorio = new RelatorioMensalDAER(parametros, dataSourceRead.getConnection());
|
Relatorio relatorio = new RelatorioMensalDAER(parametros, dataSourceRead.getConnection());
|
||||||
Map<String, Object> args = new HashMap<String, Object>();
|
|
||||||
args.put("relatorio", relatorio);
|
if (isEnviarEmail) {
|
||||||
|
|
||||||
|
Boolean enviado = enviarEmailDAER(relatorio.getConteudo(isPDF ? SaidaRelatorio.PDF : SaidaRelatorio.XLS), empresa.getEmpresaId(), txtEmail.getValue().toString());
|
||||||
|
if (!enviado) {
|
||||||
|
Messagebox.show(
|
||||||
|
Labels.getLabel("relatorioMensalDAERController.recibo.email.naoEnvio"),
|
||||||
|
Labels.getLabel("relatorioMensalDAERController.window.title"),
|
||||||
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
||||||
|
} else {
|
||||||
|
Messagebox.show(
|
||||||
|
Labels.getLabel("relatorioMensalDAERController.recibo.email.msg"),
|
||||||
|
Labels.getLabel("relatorioMensalDAERController.window.title"),
|
||||||
|
Messagebox.OK, Messagebox.INFORMATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Map<String, Object> args = new HashMap<String, Object>();
|
||||||
|
args.put("relatorio", relatorio);
|
||||||
|
|
||||||
|
// Abre a janela do relatório
|
||||||
|
openWindow("/component/reportView.zul",
|
||||||
|
Labels.getLabel("relatorioMensalDAERController.window.title"), args, MODAL);
|
||||||
|
}
|
||||||
|
|
||||||
// Abre a janela do relatório
|
|
||||||
openWindow("/component/reportView.zul",
|
|
||||||
Labels.getLabel("relatorioMensalDAERController.window.title"), args, MODAL);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Erro ao executar relatório", e);
|
log.error("Erro ao executar relatório", e);
|
||||||
}
|
}
|
||||||
|
@ -103,12 +179,88 @@ public class RelatorioMensalDAERController extends MyGenericForwardComposer {
|
||||||
public void onClick$btnExecutarRelatorio(Event ev) throws Exception {
|
public void onClick$btnExecutarRelatorio(Event ev) throws Exception {
|
||||||
executarRelatorio(false);
|
executarRelatorio(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onClick$btnRemoveTipoVenta(Event ev) throws InterruptedException {
|
||||||
|
TipoVenta tVenta = (TipoVenta) selectedTipoVentaList.getSelectedItem().getValue();
|
||||||
|
listSelectedTipoVenta.remove(tVenta);
|
||||||
|
selectedTipoVentaList.setData(listSelectedTipoVenta);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClick$btnAddTipoVenta(Event ev) throws InterruptedException {
|
||||||
|
if (cmbTipoVenta.getSelectedItem() != null) {
|
||||||
|
listSelectedTipoVenta.add((TipoVenta) cmbTipoVenta.getSelectedItem().getValue());
|
||||||
|
selectedTipoVentaList.setData(listSelectedTipoVenta);
|
||||||
|
selectedTipoVentaList.setSelectedItem(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean enviarEmailDAER(byte[] anexo, Integer empresaId, String email) {
|
||||||
|
try {
|
||||||
|
EmailConfigVO emailConfig = carregarConfiguracoesEmail(empresaId);
|
||||||
|
if (emailConfig != null) {
|
||||||
|
SendMail mail = new SendMail();
|
||||||
|
mail.setEmailTo(email);
|
||||||
|
mail.setEmailFrom(emailConfig.getSmtpEmail());
|
||||||
|
mail.setSmtpHost(emailConfig.getSmtp());
|
||||||
|
mail.setSmtpPassword(emailConfig.getSenha());
|
||||||
|
mail.setSmtpPort(emailConfig.getSmtpPorta());
|
||||||
|
mail.setSmtpUser(emailConfig.getSmtpEmail());
|
||||||
|
mail.setAuth(emailConfig.isAutenticacao());
|
||||||
|
|
||||||
|
String assunto = null;
|
||||||
|
String texto = null;
|
||||||
|
String nomeArquivo = null;
|
||||||
|
String competencia = txtCompetencia.getValue().toString();
|
||||||
|
String formato = isPDF ? ".PDF" : ".XLS";
|
||||||
|
|
||||||
|
assunto = Labels.getLabel("relatorioMensalDAERController.recibo.email.assunto", new String[] { Labels.getLabel("relatorioMensalDAERController.lbCompetencia.label"), competencia });
|
||||||
|
texto = Labels.getLabel("relatorioMensalDAERController.recibo.email.texto", new String[] { Labels.getLabel("relatorioMensalDAERController.lbCompetencia.label"), competencia });
|
||||||
|
nomeArquivo = "Relatorio_DAER_" + competencia;
|
||||||
|
|
||||||
|
mail.setSubject(assunto);
|
||||||
|
mail.setText(texto);
|
||||||
|
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream(anexo.length);
|
||||||
|
baos.write(anexo, 0, anexo.length);
|
||||||
|
|
||||||
|
mail.addAnexo(Labels.getLabel("relatorioMensalDAERController.recibo.email.nomeAnexo", new String[] { nomeArquivo }).concat(formato), baos, isPDF ? MimeType.PDF : MimeType.XLS );
|
||||||
|
mail.send();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (
|
||||||
|
|
||||||
|
Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private EmailConfigVO carregarConfiguracoesEmail(Integer empresaId) {
|
||||||
|
EmailConfigVO emailConfigVO = null;
|
||||||
|
EmpresaEmailConfig empresaEmailConfig = empresaEmailConfigService.buscarPorEmpresa(new Empresa(empresaId));
|
||||||
|
|
||||||
|
if (empresaEmailConfig != null) {
|
||||||
|
emailConfigVO = new EmailConfigVO();
|
||||||
|
emailConfigVO.setAutenticacao(BooleanUtils.toBoolean(empresaEmailConfig.getIndAutenticacao()));
|
||||||
|
emailConfigVO.setSenha(empresaEmailConfig.getSenha());
|
||||||
|
emailConfigVO.setSmtp(empresaEmailConfig.getSmtp());
|
||||||
|
emailConfigVO.setSmtpEmail(empresaEmailConfig.getSmtpEmail());
|
||||||
|
emailConfigVO.setSmtpUser(empresaEmailConfig.getSmtpEmail());
|
||||||
|
emailConfigVO.setSmtpPorta(empresaEmailConfig.getSmtpPorta());
|
||||||
|
}
|
||||||
|
|
||||||
|
return emailConfigVO;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doAfterCompose(Component comp) throws Exception {
|
public void doAfterCompose(Component comp) throws Exception {
|
||||||
super.doAfterCompose(comp);
|
super.doAfterCompose(comp);
|
||||||
lsEmpresas = UsuarioLogado.getUsuarioLogado().getEmpresa();
|
lsEmpresas = UsuarioLogado.getUsuarioLogado().getEmpresa();
|
||||||
lsAgencias = UsuarioLogado.getUsuarioLogado().getUsuarioUbicacionActivoList();
|
lsAgencias = UsuarioLogado.getUsuarioLogado().getUsuarioUbicacionActivoList();
|
||||||
|
lsTipoVenta = tipoVentaService.obtenerTodos();
|
||||||
|
listSelectedTipoVenta = new ArrayList<TipoVenta>();
|
||||||
StringBuilder agencias = new StringBuilder();
|
StringBuilder agencias = new StringBuilder();
|
||||||
|
|
||||||
for (int i =0; i< lsAgencias.size() ; i++) {
|
for (int i =0; i< lsAgencias.size() ; i++) {
|
||||||
|
@ -119,6 +271,56 @@ public class RelatorioMensalDAERController extends MyGenericForwardComposer {
|
||||||
}
|
}
|
||||||
this.agenciasUsuario = agencias.toString();
|
this.agenciasUsuario = agencias.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onCheck$rdTipoAnexoPDF() {
|
||||||
|
if (rdTipoAnexoPDF.isChecked()) {
|
||||||
|
tipoRelatorio(true, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tipoRelatorio(boolean PDF, boolean XLS) {
|
||||||
|
isPDF = (PDF ? PDF : XLS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onCheck$rdTipoAnexoXLS() {
|
||||||
|
if (rdTipoAnexoXLS.isChecked()) {
|
||||||
|
tipoRelatorio(false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onCheck$rdEmailSim() {
|
||||||
|
if (rdEmailSim.isChecked()) {
|
||||||
|
controlRowVisibility(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onCheck$rdEmailNao() {
|
||||||
|
if (rdEmailNao.isChecked()) {
|
||||||
|
controlRowVisibility(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void controlRowVisibility(Boolean isvisivel) {
|
||||||
|
rowTipoAnexo.setVisible(isvisivel);
|
||||||
|
rowSendTo.setVisible(isvisivel);
|
||||||
|
btnEnviarEmailMensalDAER.setDisabled(!isvisivel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyListbox getSelectedTipoVentaidadeList() {
|
||||||
|
return selectedTipoVentaList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectedTipoVentaList(MyListbox selectedTipoVentaList) {
|
||||||
|
this.selectedTipoVentaList = selectedTipoVentaList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TipoVenta> getListSelectedTipoVenta() {
|
||||||
|
return listSelectedTipoVenta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setListSelectedTipoVenta(List<TipoVenta> listSelectedTipoVenta) {
|
||||||
|
this.listSelectedTipoVenta = listSelectedTipoVenta;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Empresa> getLsEmpresas() {
|
public List<Empresa> getLsEmpresas() {
|
||||||
return lsEmpresas;
|
return lsEmpresas;
|
||||||
|
@ -127,7 +329,7 @@ public class RelatorioMensalDAERController extends MyGenericForwardComposer {
|
||||||
public void setLsEmpresa(List<Empresa> lsEmpresas) {
|
public void setLsEmpresa(List<Empresa> lsEmpresas) {
|
||||||
this.lsEmpresas = lsEmpresas;
|
this.lsEmpresas = lsEmpresas;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UsuarioUbicacion> getLsAgencias() {
|
public List<UsuarioUbicacion> getLsAgencias() {
|
||||||
return lsAgencias;
|
return lsAgencias;
|
||||||
}
|
}
|
||||||
|
@ -136,6 +338,12 @@ public class RelatorioMensalDAERController extends MyGenericForwardComposer {
|
||||||
this.lsAgencias = lsAgencias;
|
this.lsAgencias = lsAgencias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<TipoVenta> getLsTipoVenta() {
|
||||||
|
return lsTipoVenta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLsCategorias(List<TipoVenta> lsTipoVenta) {
|
||||||
|
this.lsTipoVenta = lsTipoVenta;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -303,6 +303,7 @@ indexController.mniRelatorioOrigemDestino.label = Desempenho Por Serviço
|
||||||
indexController.mniRelatorioPassageirosViajar.label = Passageiros a Viajar
|
indexController.mniRelatorioPassageirosViajar.label = Passageiros a Viajar
|
||||||
indexController.mniRelatorioResumoLinhas.label = Resumo de Linhas
|
indexController.mniRelatorioResumoLinhas.label = Resumo de Linhas
|
||||||
indexController.mniRelatorioIndiceIRK.label = Indice IRK
|
indexController.mniRelatorioIndiceIRK.label = Indice IRK
|
||||||
|
indexController.mniRelatorioMensalDAER.label = Relatório Mensal DAER
|
||||||
indexController.mniRelatorioKmProgramada.label = Km Programada
|
indexController.mniRelatorioKmProgramada.label = Km Programada
|
||||||
indexController.mniRelatorioAcompanhamentoEquivalentes.label = Indicadores (Acompanhamento de Equivalentes)
|
indexController.mniRelatorioAcompanhamentoEquivalentes.label = Indicadores (Acompanhamento de Equivalentes)
|
||||||
indexController.mniRelatorioLinhasHorario.label = Linhas por Horário
|
indexController.mniRelatorioLinhasHorario.label = Linhas por Horário
|
||||||
|
@ -692,13 +693,31 @@ relatorioMensalDAERController.window.title= Boletim Estatistico Mensal Rodoviari
|
||||||
relatorioMensalDAERController.lbCompetenciaLayout.label = (MM/YYYY)
|
relatorioMensalDAERController.lbCompetenciaLayout.label = (MM/YYYY)
|
||||||
relatorioMensalDAERController.lbCompetencia.label = Mes e Ano
|
relatorioMensalDAERController.lbCompetencia.label = Mes e Ano
|
||||||
relatorioMensalDAERController.lbEmpresa.value = Empresa
|
relatorioMensalDAERController.lbEmpresa.value = Empresa
|
||||||
relatorioMensalDAERController.labelTipoPassagems.value=Tipos de Passagens
|
|
||||||
relatorioMensalDAERController.tipo.obrigatoria = Tipo de passagens é obrigatório
|
relatorioMensalDAERController.tipo.obrigatoria = Tipo de passagens é obrigatório
|
||||||
relatorioMensalDAERController.lbTipoPassgens.value = Tipos de Passagens
|
relatorioMensalDAERController.lbTipoVenta.value = Tipos de Passagens
|
||||||
relatorioMensalDAERController.labelRemoveTipoPassagem.value = Remover tipo Passagem
|
relatorioMensalDAERController.lbRemoveTipoVenta.value = Remover tipo Passagem
|
||||||
relatorioMensalDAERController.labelAdicionaTipoPassagem.value = Adicionar tipo Passagem
|
relatorioMensalDAERController.lbAdicionaTipoVenta.value = Adicionar tipo Passagem
|
||||||
relatorioMensalDAERController.lbRelatorio.value = Emitir Relatório
|
relatorioMensalDAERController.lbRelatorio.value = Emitir Relatório
|
||||||
relatorioMensalDAERController.lbEnviarEmailDAER.label = E-mail Recibo
|
relatorioMensalDAERController.lbEnviarEmailDAER.label = E-mail Recibo
|
||||||
|
relatorioMensalDAERController.tipo.obrigatoria = Tipo de passagens é obrigatório
|
||||||
|
relatorioMensalDAERController.empresa.obrigatoria = Campo empresa é obrigatório
|
||||||
|
relatorioMensalDAERController.data.obrigatoria = Campo data é obrigatório
|
||||||
|
relatorioMensalDAERController.relatorio.vazio = Não existe resultado para os dados informados
|
||||||
|
relatorioMensalDAERController.lbTipoAnexo.label = Tipo Anexo
|
||||||
|
relatorioMensalDAERController.lbPDF.value = PDF
|
||||||
|
relatorioMensalDAERController.lbXLS.value = XLS
|
||||||
|
relatorioMensalDAERController.lbSim.value = Sim
|
||||||
|
relatorioMensalDAERController.lbNao.value = Nao
|
||||||
|
relatorioMensalDAERController.recibo.email.naoEnvio = Não foi possível enviar email - Verifique as configurações
|
||||||
|
relatorioMensalDAERController.recibo.email.msg = E-mail enviado com sucesso
|
||||||
|
relatorioMensalDAERController.recibo.email.assunto = Boletim Estatistico Mensal Rodoviarias DAER {0}: {1}
|
||||||
|
relatorioMensalDAERController.recibo.email.texto = Boletim Estatistico Mensal Rodoviarias DAER {0}: {1} em anexo.
|
||||||
|
relatorioMensalDAERController.recibo.email.nomeAnexo = Boletim_Estatistico_DAER-{0}
|
||||||
|
relatorioMensalDAERController.lbEnviaEmail.label = Enviar email
|
||||||
|
relatorioMensalDAERController.lbEnviaEmailPara.label = Enviar email Para:
|
||||||
|
relatorioMensalDAERController.lbCompetencia.label = Competência
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#Relatorio Trecho Vendido
|
#Relatorio Trecho Vendido
|
||||||
relatorioTrechoVendidoController.lbDataIni.value = Data Inicial
|
relatorioTrechoVendidoController.lbDataIni.value = Data Inicial
|
||||||
|
|
|
@ -7,27 +7,68 @@
|
||||||
<zk xmlns="http://www.zkoss.org/2005/zul">
|
<zk xmlns="http://www.zkoss.org/2005/zul">
|
||||||
<window id="winFiltroRelatorioMensalDAER"
|
<window id="winFiltroRelatorioMensalDAER"
|
||||||
apply="${relatorioMensalDAERController}" contentStyle="overflow:auto"
|
apply="${relatorioMensalDAERController}" contentStyle="overflow:auto"
|
||||||
height="135px" width="550px" border="normal">
|
height="335px" width="550px" border="normal">
|
||||||
|
|
||||||
<grid fixedLayout="true">
|
<grid fixedLayout="true">
|
||||||
<columns>
|
<columns>
|
||||||
<column width="25%" />
|
<column width="25%" />
|
||||||
<column width="75%" />
|
<column width="25%" />
|
||||||
|
<column width="25%" />
|
||||||
|
<column width="25%" />
|
||||||
</columns>
|
</columns>
|
||||||
<rows>
|
<rows>
|
||||||
|
|
||||||
<row id="rowCompetencia" spans="1,3">
|
<row id="rowCompetencia" spans="1,3">
|
||||||
<label
|
<label
|
||||||
value="${c:l('relatorioMensalDAERController.lbCompetenciaLayout.label')}" />
|
value="${c:l('relatorioMensalDAERController.lbCompetencia.label')}" />
|
||||||
<hbox>
|
<hbox>
|
||||||
<textbox id="txtCompetencia" width="100px"
|
<textbox id="txtCompetencia" width="64px"
|
||||||
use="com.rjconsultores.ventaboletos.web.utilerias.MyTextbox" />
|
use="com.rjconsultores.ventaboletos.web.utilerias.MyTextbox" />
|
||||||
<label
|
<label
|
||||||
value="${c:l('relatorioMensalDAERController.lbCompetenciaLayout.label')}" />
|
value="${c:l('relatorioMensalDAERController.lbCompetenciaLayout.label')}" />
|
||||||
</hbox>
|
</hbox>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
|
<row id="enviaEmail" visible="true" spans="1,3">
|
||||||
|
<label
|
||||||
|
value="${c:l('relatorioMensalDAERController.lbEnviaEmail.label')}" />
|
||||||
|
<radiogroup Id="rdEmail">
|
||||||
|
<hbox align="center">
|
||||||
|
<radio Id="rdEmailSim" value="1"
|
||||||
|
label="${c:l('relatorioMensalDAERController.lbSim.value')}" />
|
||||||
|
<radio Id="rdEmailNao"
|
||||||
|
value="2"
|
||||||
|
selected="true"
|
||||||
|
label="${c:l('relatorioMensalDAERController.lbNao.value')}" />
|
||||||
|
</hbox>
|
||||||
|
</radiogroup>
|
||||||
|
</row>
|
||||||
|
|
||||||
|
<row id="rowTipoAnexo" visible="false" spans="1,3">
|
||||||
|
<label
|
||||||
|
value="${c:l('relatorioMensalDAERController.lbTipoAnexo.label')}" />
|
||||||
|
<radiogroup Id="rdTipoAnexo">
|
||||||
|
<hbox align="center">
|
||||||
|
<radio Id="rdTipoAnexoPDF" value="1"
|
||||||
|
selected="true"
|
||||||
|
label="${c:l('relatorioMensalDAERController.lbPDF.value')}" />
|
||||||
|
<radio Id="rdTipoAnexoXLS"
|
||||||
|
value="2"
|
||||||
|
label="${c:l('relatorioMensalDAERController.lbXLS.value')}" />
|
||||||
|
</hbox>
|
||||||
|
</radiogroup>
|
||||||
|
</row>
|
||||||
|
|
||||||
|
<row id="rowSendTo" visible="false" spans="1,3">
|
||||||
|
<label
|
||||||
|
value="${c:l('relatorioMensalDAERController.lbEnviaEmailPara.label')}" />
|
||||||
|
<hbox>
|
||||||
|
<textbox id="txtEmail" width="100%"
|
||||||
|
use="com.rjconsultores.ventaboletos.web.utilerias.MyTextbox" />
|
||||||
|
</hbox>
|
||||||
|
</row>
|
||||||
|
|
||||||
<row>
|
<row spans="1,3">
|
||||||
<label
|
<label
|
||||||
value="${c:l('relatorioMensalDAERController.lbEmpresa.value')}" />
|
value="${c:l('relatorioMensalDAERController.lbEmpresa.value')}" />
|
||||||
<combobox id="cmbEmpresa" width="100%"
|
<combobox id="cmbEmpresa" width="100%"
|
||||||
|
@ -36,19 +77,53 @@
|
||||||
model="@{winFiltroRelatorioMensalDAER$composer.lsEmpresas}" />
|
model="@{winFiltroRelatorioMensalDAER$composer.lsEmpresas}" />
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
|
<row spans="1,3">
|
||||||
|
<label
|
||||||
|
value="${c:l('relatorioMensalDAERController.lbTipoVenta.value')}" />
|
||||||
|
<combobox id="cmbTipoVenta" width="100%"
|
||||||
|
maxlength="60" mold="rounded" buttonVisible="true"
|
||||||
|
use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar"
|
||||||
|
model="@{winFiltroRelatorioMensalDAER$composer.lsTipoVenta}" />
|
||||||
|
</row>
|
||||||
|
|
||||||
</rows>
|
</rows>
|
||||||
</grid>
|
</grid>
|
||||||
<grid fixedLayout="true">
|
<grid fixedLayout="false">
|
||||||
|
<custom-attributes org.zkoss.zul.nativebar="false" />
|
||||||
<columns>
|
<columns>
|
||||||
<column width="100%" />
|
<column width="100%" />
|
||||||
</columns>
|
</columns>
|
||||||
|
<rows>
|
||||||
|
<row>
|
||||||
|
<toolbar>
|
||||||
|
<button id="btnRemoveTipoVenta" height="20"
|
||||||
|
image="/gui/img/remove.png" width="35px"
|
||||||
|
tooltiptext="${c:l('relatorioMensalDAERController.lbRemoveTipoVenta.value')}" />
|
||||||
|
<button id="btnAddTipoVenta" height="20"
|
||||||
|
image="/gui/img/add.png" width="35px"
|
||||||
|
tooltiptext="${c:l('relatorioMensalDAERController.lbAdicionaTipoVenta.value')}" />
|
||||||
|
</toolbar>
|
||||||
|
</row>
|
||||||
|
|
||||||
|
<row>
|
||||||
|
<listbox id="selectedTipoVentaList" mold="paging"
|
||||||
|
use="com.rjconsultores.ventaboletos.web.utilerias.MyListbox"
|
||||||
|
vflex="true" multiple="false" height="60%">
|
||||||
|
<listhead sizable="true">
|
||||||
|
<listheader image="/gui/img/builder.gif"
|
||||||
|
label="${c:l('relatorioMensalDAERController.lbTipoVenta.value')}"
|
||||||
|
width="100%" />
|
||||||
|
</listhead>
|
||||||
|
</listbox>
|
||||||
|
</row>
|
||||||
|
</rows>
|
||||||
</grid>
|
</grid>
|
||||||
<toolbar>
|
<toolbar>
|
||||||
<button id="btnExecutarRelatorio" image="/gui/img/find.png"
|
<button id="btnExecutarRelatorio" image="/gui/img/find.png"
|
||||||
label="${c:l('relatorioMensalDAERController.lbRelatorio.value')}" />
|
label="${c:l('relatorioMensalDAERController.lbRelatorio.value')}" />
|
||||||
<button id="btnEnviarEmailMensalDAER"
|
<button id="btnEnviarEmailMensalDAER"
|
||||||
image="/gui/img/email.png"
|
image="/gui/img/email.png"
|
||||||
|
disabled="true"
|
||||||
label="${c:l('relatorioMensalDAERController.lbEnviarEmailDAER.label')}" />
|
label="${c:l('relatorioMensalDAERController.lbEnviarEmailDAER.label')}" />
|
||||||
</toolbar>
|
</toolbar>
|
||||||
</window>
|
</window>
|
||||||
|
|
Loading…
Reference in New Issue