diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioErrosIntegracaoBGMController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioErrosIntegracaoBGMController.java new file mode 100644 index 000000000..1fb8a4e8a --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioErrosIntegracaoBGMController.java @@ -0,0 +1,185 @@ +package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.text.SimpleDateFormat; +import java.util.List; + +import javax.activation.MimetypesFileTypeMap; +import javax.sql.DataSource; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.PropertyException; + +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.Combobox; +import org.zkoss.zul.Datebox; +import org.zkoss.zul.Filedownload; + +import com.rjconsultores.hstcajservice.ws.BilheteService; +import com.rjconsultores.hstcajservice.ws.BilheteServiceService; +import com.rjconsultores.hstcajservice.ws.Bilhetes; +import com.rjconsultores.hstcajservice.ws.ExportaIntegracaoWS; +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; +import com.rjconsultores.ventaboletos.service.ConstanteService; +import com.rjconsultores.ventaboletos.service.EmpresaService; +import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar; +import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; +import com.rjconsultores.ventaboletos.web.utilerias.MyTextbox; + +@Controller("relatorioErrosIntegracaoBGMController") +@Scope("prototype") +public class RelatorioErrosIntegracaoBGMController extends MyGenericForwardComposer { + + private static final long serialVersionUID = 1L; + + private Datebox dataInicial; + private Datebox dataFinal; + private MyComboboxEstandar cmbEmpresa; + private Combobox cmbPuntoVentaInicial; + private Combobox cmbPuntoVentaFinal; + private List lsEmpresa; + private MyTextbox txtNombrePuntoVentaInicial; + + private BilheteService bilheteService; + + + @Autowired + private EmpresaService empresaService; + @Autowired + private ConstanteService constanteService; + @Autowired + private DataSource dataSourceRead; + + + @Override + public void doAfterCompose(Component comp) throws Exception { + lsEmpresa = empresaService.obtenerTodos(); + super.doAfterCompose(comp); + } + + /** + * @throws Exception + * + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + private void executarRelatorio() throws Exception { + + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + final Integer COD_EMPRESA_GRUPO = 1; + + dataInicial.getValue(); + dataFinal.getValue(); + cmbEmpresa.getValue(); + cmbPuntoVentaInicial.getValue(); + cmbPuntoVentaFinal.getValue(); + + String dataInicio= format.format(dataInicial.getValue()); + String dataFim = format.format(dataFinal.getValue()); + String puntoVentaInicial = ((PuntoVenta)cmbPuntoVentaInicial.getSelectedItem().getValue()).getNumPuntoVenta(); + String puntoVentaFinal= ((PuntoVenta)cmbPuntoVentaFinal.getSelectedItem().getValue()).getNumPuntoVenta(); + String empresa= ((Empresa)cmbEmpresa.getSelectedItem().getValue()).getEmpresaId().toString(); + + BilheteServiceService b = new BilheteServiceService(); + bilheteService = b.getBilheteServicePort(); + Bilhetes bilhetesInconsistentes = new Bilhetes(); + List bilhesteInconsistentesWebService = bilheteService.buscarBilhetesInconsistente(dataInicio, dataFim, + puntoVentaInicial, puntoVentaFinal, COD_EMPRESA_GRUPO, empresa, ""); + if(bilhesteInconsistentesWebService != null && bilhesteInconsistentesWebService.get(bilhesteInconsistentesWebService.size()-1).getRegistros() > 0){ + bilhetesInconsistentes.setBilhetes(bilhesteInconsistentesWebService); + String fileName = gerarArquivoXML(bilhetesInconsistentes); + baixarArquivo(fileName); + }else{ + try { + Messagebox.show(Labels.getLabel("MSG.ningunRegistro"), + Labels.getLabel("relatorioErrosIntegracaoBGMController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); + } catch (InterruptedException ex) { + ex.printStackTrace(); + } + } + + } + + private void baixarArquivo(String fileName) throws FileNotFoundException { + FileInputStream inputStream; + File filez = new File(fileName); + if (filez.exists()) { + inputStream = new FileInputStream(filez); + Filedownload.save(inputStream, new MimetypesFileTypeMap().getContentType(filez), filez.getName()); + } + filez.delete(); + } + + private String gerarArquivoXML(Bilhetes bilhetesInconsistentes) throws JAXBException, PropertyException { + JAXBContext jaxbContext = JAXBContext.newInstance(Bilhetes.class); + String BILHETES_INCONSISTENTES = "Bilhetes Inconsistentes.xml"; + Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); + jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + String diretorio = System.getProperty("jboss.server.log.dir"); + String fileName = diretorio + File.separator + " " + BILHETES_INCONSISTENTES; + jaxbMarshaller.marshal(bilhetesInconsistentes, new File(fileName)); + return fileName; + } + + public void onClick$btnExecutarRelatorio(Event ev) throws Exception{ + executarRelatorio(); + } + + private void executarPesquisa() { + + } + + public void onClick$btnPesquisa(Event ev) { + executarPesquisa(); + } + + public List getLsEmpresa() { + return lsEmpresa; + } + + public void setLsEmpresa(List lsEmpresa) { + this.lsEmpresa = lsEmpresa; + } + + public MyComboboxEstandar getCmbEmpresa() { + return cmbEmpresa; + } + + public void setCmbEmpresa(MyComboboxEstandar cmbEmpresa) { + this.cmbEmpresa = cmbEmpresa; + } + + public Combobox getCmbPuntoVentaInicial() { + return cmbPuntoVentaInicial; + } + + public void setCmbPuntoVentaInicial(Combobox cmbPuntoVentaInicial) { + this.cmbPuntoVentaInicial = cmbPuntoVentaInicial; + } + + public Combobox getCmbPuntoVentaFinal() { + return cmbPuntoVentaFinal; + } + + public void setCmbPuntoVentaFinal(Combobox cmbPuntoVentaFinal) { + this.cmbPuntoVentaFinal = cmbPuntoVentaFinal; + } + + public MyTextbox getTxtNombrePuntoVentaInicial() { + return txtNombrePuntoVentaInicial; + } + + public void setTxtNombrePuntoVentaInicial(MyTextbox txtNombrePuntoVentaInicial) { + this.txtNombrePuntoVentaInicial = txtNombrePuntoVentaInicial; + } +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/ItemMenuRelatorioErrosIntegracaoBGM.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/ItemMenuRelatorioErrosIntegracaoBGM.java new file mode 100644 index 000000000..f66ba7bb8 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/ItemMenuRelatorioErrosIntegracaoBGM.java @@ -0,0 +1,25 @@ +package com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios; + +import org.zkoss.util.resource.Labels; + +import com.rjconsultores.ventaboletos.web.utilerias.PantallaUtileria; +import com.rjconsultores.ventaboletos.web.utilerias.menu.DefaultItemMenuSistema; + +public class ItemMenuRelatorioErrosIntegracaoBGM extends DefaultItemMenuSistema { + + public ItemMenuRelatorioErrosIntegracaoBGM() { + super("indexController.mniRelatorioErrosIntegracaoBGMController.label"); + } + + @Override + public String getClaveMenu() { + return "COM.RJCONSULTORES.ADMINISTRACION.GUI.ERROS.BGM"; + } + + @Override + public void ejecutar() { + PantallaUtileria.openWindow("/gui/relatorios/filtroRelatorioErrosIntegracaoBGM.zul", + Labels.getLabel("relatorioErrosIntegracaoBGMController.window.title"), getArgs(), desktop); + + } +} diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label index b6bb4ac59..eccfa5e2f 100644 --- a/web/WEB-INF/i3-label_es_MX.label +++ b/web/WEB-INF/i3-label_es_MX.label @@ -270,6 +270,7 @@ indexController.mniRelatorioObservacaoBilhetes.label = Reporte Observación Pasa indexController.mniRelatorioObservacaoEventosFinanceiros.label = Reporte Observación Eventos Financieros indexController.mniRecebimentoMalote.label = Recebimento Malote indexController.mniRelatorioObservacaoConferenciaMovimento.label = Reporte Observación Conferencia Movimientos +indexController.mniRelatorioErrosIntegracaoBGMController.label = Listar Erros BGM indexController.mnSubMenuImpressaoFiscal.label=Impresión Fiscal indexController.mnSubMenuRelatorioImpressaoFiscal.label=Importação Fiscal @@ -6542,3 +6543,14 @@ relatorioConferenciaFormularioFisicoController.lbPuntoVenta.value = Agencia relatorioConferenciaFormularioFisicoController.msg.erro.puntoventa = El Campo Agencia es Obligatório! relatorioConferenciaFormularioFisicoController.msg.erro.empresa = El Campo Empresa es Obligatório +# Relatorio(XML - Erros ws integração bgm) +relatorioErrosIntegracaoBGMController.window.title = Erros ws integração bgm +relatorioErrosIntegracaoBGMController.datainicial.value = Data Inicial +relatorioErrosIntegracaoBGMController.dataFinal.value = Data Final +relatorioErrosIntegracaoBGMController.lbPuntoVentaInicial.value = Agência Inicial +relatorioErrosIntegracaoBGMController.lbPuntoVentaFinal.value = Agência Final +relatorioErrosIntegracaoBGMController.lbEmpresa.value = Empresa +relatorioErrosIntegracaoBGMController.btnPesquisa.label = Buscar +relatorioErrosIntegracaoBGMController.btnLimpar.label = Limpar +relatorioErrosIntegracaoBGMController.lbNumero.value = Número Agência + diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label index 599f68bec..f7975a043 100644 --- a/web/WEB-INF/i3-label_pt_BR.label +++ b/web/WEB-INF/i3-label_pt_BR.label @@ -275,6 +275,7 @@ indexController.mniRelatorioObservacaoBilhetes.label = Relatório Observação B indexController.mniRelatorioObservacaoEventosFinanceiros.label = Relatório Observação Eventos Financeiros indexController.mniRecebimentoMalote.label = Recebimento Malote indexController.mniRelatorioObservacaoConferenciaMovimento.label = Relatório Observação Conferência Movimentos +indexController.mniRelatorioErrosIntegracaoBGMController.label = Listar Erros BGM indexController.mnSubMenuImpressaoFiscal.label=Impressão Fiscal indexController.mnSubMenuRelatorioImpressaoFiscal.label=Importação Fiscal @@ -6678,4 +6679,18 @@ relatorioReceitaEmbarcadaServicoController.lbCidadeOrigem.value = Localidade Ori relatorioReceitaEmbarcadaServicoController.lbCidadeDestino.value = Localidade Destino relatorioReceitaEmbarcadaServicoController.lbEmpresa.value = Empresa relatorioReceitaEmbarcadaServicoController.lbClase.value = Classe -relatorioReceitaEmbarcadaServicoController.lbServico.value = N. Serviço \ No newline at end of file +relatorioReceitaEmbarcadaServicoController.lbServico.value = N. Serviço + +# Relatorio(XML - Erros ws integração bgm) +relatorioErrosIntegracaoBGMController.window.title = Erros ws integração bgm +relatorioErrosIntegracaoBGMController.datainicial.value = Data Inicial +relatorioErrosIntegracaoBGMController.dataFinal.value = Data Final +relatorioErrosIntegracaoBGMController.lbPuntoVentaInicial.value = Agência Inicial +relatorioErrosIntegracaoBGMController.lbPuntoVentaFinal.value = Agência Final +relatorioErrosIntegracaoBGMController.lbEmpresa.value = Empresa +relatorioErrosIntegracaoBGMController.btnPesquisa.label = Buscar +relatorioErrosIntegracaoBGMController.btnLimpar.label = Limpar +relatorioErrosIntegracaoBGMController.lbNumero.value = Número Agência + + + diff --git a/web/gui/relatorios/filtroRelatorioErrosIntegracaoBGM.zul b/web/gui/relatorios/filtroRelatorioErrosIntegracaoBGM.zul new file mode 100644 index 000000000..c61fedc74 --- /dev/null +++ b/web/gui/relatorios/filtroRelatorioErrosIntegracaoBGM.zul @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +