From 11ea89269f91aac35dc303a41ef910eca3d18292 Mon Sep 17 00:00:00 2001 From: leonardo Date: Fri, 13 Oct 2017 19:17:54 +0000 Subject: [PATCH] fixes bug #9201 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@74776 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../job/MonitoramentoCCFCRZJob.java | 95 +++++++++++++++++++ .../seguridad/PainelEcfController.java | 45 +++++++++ .../ventaboletos/web/utilerias/MyAppInit.java | 36 +++++++ .../item/seguridad/ItemMenuPainelECF.java | 26 +++++ .../utilerias/menu/menu_original.properties | 1 + web/WEB-INF/i3-label_es_MX.label | 16 +++- web/WEB-INF/i3-label_pt_BR.label | 16 +++- web/gui/seguridad/painelEcf.zul | 71 ++++++++++++++ 8 files changed, 304 insertions(+), 2 deletions(-) create mode 100644 src/java/com/rjconsultores/ventaboletos/web/gui/controladores/job/MonitoramentoCCFCRZJob.java create mode 100644 src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/PainelEcfController.java create mode 100644 src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/seguridad/ItemMenuPainelECF.java create mode 100644 web/gui/seguridad/painelEcf.zul diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/job/MonitoramentoCCFCRZJob.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/job/MonitoramentoCCFCRZJob.java new file mode 100644 index 000000000..e0f74001e --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/job/MonitoramentoCCFCRZJob.java @@ -0,0 +1,95 @@ +package com.rjconsultores.ventaboletos.web.gui.controladores.job; + +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; + +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.Estado; +import com.rjconsultores.ventaboletos.entidad.FiscalImpressora; +import com.rjconsultores.ventaboletos.entidad.MonitoramentoCCF; +import com.rjconsultores.ventaboletos.entidad.MonitoramentoCCFR2; +import com.rjconsultores.ventaboletos.entidad.MonitoramentoCRZ; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; +import com.rjconsultores.ventaboletos.entidad.Usuario; +import com.rjconsultores.ventaboletos.service.MonitoramentoCCFService; +import com.rjconsultores.ventaboletos.service.MonitoramentoCRZService; +import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext; + +public class MonitoramentoCCFCRZJob implements Job { + private static Logger log = Logger.getLogger(MonitoramentoCCFCRZJob.class); + + private Calendar inicio; + + @Autowired + private MonitoramentoCCFService monitoramentoCCFService; + @Autowired + private MonitoramentoCRZService monitoramentoCRZService; + + @Override + public void execute(JobExecutionContext arg0) throws JobExecutionException { + log.info("Inicio do job de Monitoramento CCF CRZ..."); + ApplicationContext appContext = AppContext.getApplicationContext(); + monitoramentoCCFService = (MonitoramentoCCFService) appContext.getBean("monitoramentoCCFService"); + monitoramentoCRZService = (MonitoramentoCRZService) appContext.getBean("monitoramentoCRZService"); + + inicio = Calendar.getInstance(); + inicio.add(Calendar.DATE, -1); + inicio.set(Calendar.HOUR, 0); + inicio.set(Calendar.MINUTE, 0); + inicio.set(Calendar.SECOND, 0); + + + for (MonitoramentoCCFR2 r2 : buscaRegistrosR2()){ + Map ccfs = new HashMap(); + for (int i = 0; i < r2.coofim - r2.cooinicio; i++){ + ccfs.put(r2.cooinicio + i, null); + } + for (MonitoramentoCCF m : buscaQuebraCCF(r2)){ + ccfs.put(m.getSequenciaCCFQuebrada(), m); + } + for (Map.Entry entry : ccfs.entrySet()) { + if (entry.getValue() == null){ + MonitoramentoCCF novo = new MonitoramentoCCF(); + novo.setDataMonitoramento(new Date()); + novo.setDataOcorrencia(inicio.getTime()); + novo.setDiasAlertaAberto(new Date()); + novo.setImpressora(new FiscalImpressora(r2.fiscalImpressoraId)); + novo.setEmpresa(new Empresa(r2.empresaId)); + novo.setEstadoInstalacao(new Estado(r2.estadoId)); + novo.setPuntoventa(new PuntoVenta(r2.puntoventaId)); + novo.setSequenciaCCFQuebrada(entry.getKey()); + //novo.setUsuario(new Usuario(r2.u)); + monitoramentoCCFService.suscribir(novo); + } + } + } + + for (MonitoramentoCRZ m : buscaQuebraCRZ()){ + monitoramentoCRZService.suscribir(m); + } + + log.info("Fim do job de Monitoramento CCF CRZ."); + } + + public List buscaRegistrosR2(){ + return monitoramentoCCFService.buscaRegistrosR2(inicio.getTime()); + } + + public List buscaQuebraCCF(MonitoramentoCCFR2 r2){ + return monitoramentoCCFService.buscaQuebraCCF(r2.numserie20, inicio.getTime()); + } + + public List buscaQuebraCRZ(){ + return monitoramentoCRZService.buscaQuebraCRZ(inicio.getTime()); + } +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/PainelEcfController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/PainelEcfController.java new file mode 100644 index 000000000..1e5aa136e --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/PainelEcfController.java @@ -0,0 +1,45 @@ +package com.rjconsultores.ventaboletos.web.gui.controladores.seguridad; + +import java.util.List; + +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Controller; +import org.zkoss.zk.ui.Component; + +import com.rjconsultores.ventaboletos.entidad.MonitoramentoCCF; +import com.rjconsultores.ventaboletos.entidad.MonitoramentoCRZ; +import com.rjconsultores.ventaboletos.service.MonitoramentoCCFService; +import com.rjconsultores.ventaboletos.service.MonitoramentoCRZService; +import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; +import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; + +@Controller("painelEcfController") +@Scope("prototype") +public class PainelEcfController extends MyGenericForwardComposer { + + private static final long serialVersionUID = 1L; + private static Logger log = Logger.getLogger(PainelEcfController.class); + + @Autowired + private MonitoramentoCCFService monitoramentoCCFService; + @Autowired + private MonitoramentoCRZService monitoramentoCRZService; + + private MyListbox monitoramentoCRZList; + private MyListbox monitoramentoCCFList; + + @Override + public void doAfterCompose(Component comp) throws Exception { + List lsCCF = monitoramentoCCFService.obtenerTodos(); + List lsCRZ = monitoramentoCRZService.obtenerTodos(); + + super.doAfterCompose(comp); + + monitoramentoCCFList.setData(lsCCF); + monitoramentoCRZList.setData(lsCRZ); + } + + +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/MyAppInit.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/MyAppInit.java index 84142c6d6..1d48bcbdb 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/utilerias/MyAppInit.java +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/MyAppInit.java @@ -26,6 +26,7 @@ import com.rjconsultores.ventaboletos.entidad.Constante; import com.rjconsultores.ventaboletos.service.ConstanteService; import com.rjconsultores.ventaboletos.web.gui.controladores.job.GeneracionConferenciaMovimentoJob; import com.rjconsultores.ventaboletos.web.gui.controladores.job.GeneracionCorridaJob; +import com.rjconsultores.ventaboletos.web.gui.controladores.job.MonitoramentoCCFCRZJob; import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext; /** @@ -36,6 +37,7 @@ public class MyAppInit implements org.zkoss.zk.ui.util.WebAppInit { private static final String HORA_GENERACION_CORRIDA = "HORA_GENERACION_CORRIDA"; private static final String HORA_EXEC_CONFERENCIA_MOVIMENTO = "HORA_EXEC_CONFERENCIA_MOVIMENTO"; + private static final String HORA_EXEC_MONITORAMENTO_REDUCAOZ = "HORA_EXEC_MONITORAMENTO_REDUCAOZ"; private static Logger log = Logger.getLogger(MyAppInit.class); SchedulerFactory schedFact = new StdSchedulerFactory(); Scheduler sched; @@ -73,6 +75,8 @@ public class MyAppInit implements org.zkoss.zk.ui.util.WebAppInit { //Geração automatíca da conferência de mmovimento. jobGeneracionConferenciaMovimento(); + //Monitoramento automático de Quebra de sequência na Redução Z. + jobMonitoramentoReducaoZ(); } executeFlyway(); @@ -237,6 +241,38 @@ public class MyAppInit implements org.zkoss.zk.ui.util.WebAppInit { log.error(ex); } } + + /** + * Cria job do Quartz para Conferência de Movimento Automática do dia anterior. + */ + private void jobMonitoramentoReducaoZ() { + try { + Integer[] hora = horaExecucion(HORA_EXEC_MONITORAMENTO_REDUCAOZ); + if(hora ==null){ + log.info("Não existe hora cadastrada para o job MonitoramentoCCFCRZJob. Verificar a constante HORA_EXEC_MONITORAMENTO_REDUCAOZ"); + return; + } + log.info("Início cadastro do job MonitoramentoCCFCRZJob"); + sched = schedFact.getScheduler(); + JobDetail jobDetail = new JobDetail("MonitoramentoCCFCRZJob", null, MonitoramentoCCFCRZJob.class); + Trigger trigger = TriggerUtils.makeDailyTrigger("monitoramentoCCFCRZJobTrigger", hora[0], hora[1]); + log.info("MonitoramentoCCFCRZJob hora execucão: " + hora[0] + ":" + hora[1] ); + trigger.setName("monitoramentoCCFCRZJobTrigger"); + JobDetail job = sched.getJobDetail(jobDetail.getName(), jobDetail.getGroup()); + log.info("Job=" + jobDetail.getName() + "." + jobDetail.getGroup()); + if (job != null) { + log.info("Job já existe"); + boolean deleted = sched.deleteJob(job.getName(), Scheduler.DEFAULT_GROUP); + log.info("Deleted=" + deleted); + } + sched.scheduleJob(jobDetail, trigger); + sched.start(); + log.info("Fim cadastro do job MonitoramentoCCFCRZJob"); + } catch (SchedulerException ex) { + log.error(ex); + } + } + private DataSource getDataSoure() { ApplicationContext appContext = AppContext.getApplicationContext(); BeanFactory factory = (BeanFactory) appContext; diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/seguridad/ItemMenuPainelECF.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/seguridad/ItemMenuPainelECF.java new file mode 100644 index 000000000..1eb372dac --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/seguridad/ItemMenuPainelECF.java @@ -0,0 +1,26 @@ +package com.rjconsultores.ventaboletos.web.utilerias.menu.item.seguridad; + +import org.zkoss.util.resource.Labels; + +import com.rjconsultores.ventaboletos.web.utilerias.PantallaUtileria; +import com.rjconsultores.ventaboletos.web.utilerias.menu.DefaultItemMenuSistema; + +public class ItemMenuPainelECF extends DefaultItemMenuSistema { + + public ItemMenuPainelECF() { + super("indexController.mniPainelEcf.label"); + } + + @Override + public String getClaveMenu() { + return "COM.RJCONSULTORES.ADMINISTRACION.GUI.SEGURIDAD.MENU.PAINELECF"; + } + + @Override + public void ejecutar() { + PantallaUtileria.openWindow("/gui/seguridad/painelEcf.zul", + Labels.getLabel("painelEcfController.window.title"), getArgs(), desktop); + + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties index 97a71ec9a..b8a5a3d59 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties @@ -226,6 +226,7 @@ seguridad.usuario=com.rjconsultores.ventaboletos.web.utilerias.menu.item.segurid seguridad.fiscalImpressora=com.rjconsultores.ventaboletos.web.utilerias.menu.item.seguridad.ItemMenuFiscalImpressora seguridad.mensaje=com.rjconsultores.ventaboletos.web.utilerias.menu.item.seguridad.ItemMenuMensaje seguridad.auditoria=com.rjconsultores.ventaboletos.web.utilerias.menu.item.seguridad.ItemMenuAuditoria +seguridad.painelecf=com.rjconsultores.ventaboletos.web.utilerias.menu.item.seguridad.ItemMenuPainelECF pasajerofrecuente=com.rjconsultores.ventaboletos.web.utilerias.menu.item.pasajerofrecuente.MenuPasajeroFrecuente pasajerofrecuente.cliente=com.rjconsultores.ventaboletos.web.utilerias.menu.item.pasajerofrecuente.ItemMenuCliente pasajerofrecuente.importarClientes=com.rjconsultores.ventaboletos.web.utilerias.menu.item.pasajerofrecuente.ItemMenuImportarClientes diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label index e16c3a3d1..cd6238b50 100644 --- a/web/WEB-INF/i3-label_es_MX.label +++ b/web/WEB-INF/i3-label_es_MX.label @@ -163,6 +163,7 @@ indexController.mniConfiguracionServicio.label = Configuración de producto o se indexController.mniPricingEspecifico.label = Pricing específico indexController.mnSeguridad.label = Seguridad indexController.mniPerfil.label = Perfil +indexController.mniPainelEcf.label = Painel ECF indexController.mniPermisos.label = Permiso indexController.mniMenus.label = Menu indexController.mniSistema.label = Sistema @@ -7173,4 +7174,17 @@ relatorioImpressaoPosteriorController.lbTodas.value = Todas relatorioImpressaoPosteriorController.lbTodas.value = Seleccione relatorioImpressaoPosteriorController.lbEmpresa.value = Empresa: relatorioImpressaoPosteriorController.lbVenda.value = Venta -relatorioImpressaoPosteriorController.lbViagem.value = Viaje \ No newline at end of file +relatorioImpressaoPosteriorController.lbViagem.value = Viaje + +# Painel ECF +painelEcfController.window.title = Painel ECF +painelEcfController.btnSalvar.tooltiptext = Guardar +painelEcfController.btnFechar.tooltiptext = Cerrar +painelEcfController.lbEmpresa.value=Empresa +painelEcfController.lbECF.value=ECF +painelEcfController.lbUFInstalacao.value=UF Instalação +painelEcfController.lbDataOcorrencia.value=Data Ocorrência +painelEcfController.lbAgencia.value=Agência +painelEcfController.lbSeqCCFQuebrada.value=Seq. CCF Quebrada +painelEcfController.lbDiasAlertaAberto.value=Dias Alerta Aberto +painelEcfController.lbSeqCRZQuebrada.value=Seq. CRZ Quebrada \ No newline at end of file diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label index e019ef507..e1bf6cb6d 100644 --- a/web/WEB-INF/i3-label_pt_BR.label +++ b/web/WEB-INF/i3-label_pt_BR.label @@ -172,6 +172,7 @@ indexController.mniConfiguracionServicio.label = Configuração de Produto ou Se indexController.mniPricingEspecifico.label = Pricing Específico indexController.mnSeguridad.label = Segurança indexController.mniPerfil.label = Perfil +indexController.mniPainelEcf.label = Painel ECF indexController.mniPermisos.label = Permissão indexController.mniMenus.label = Menu indexController.mniSistema.label = Sistema @@ -7675,4 +7676,17 @@ relatorioImpressaoPosteriorController.lbViagem.value = Viagem relatorioImpressaoPosteriorController.lbCodigo.value = Código relatorioImpressaoPosteriorController.lbDescricao.value = Descrição relatorioImpressaoPosteriorController.btnPesquisar.label =Pesquisar -relatorioImpressaoPosteriorController.btnLimpar.label =Limpar \ No newline at end of file +relatorioImpressaoPosteriorController.btnLimpar.label =Limpar + +# Painel ECF +painelEcfController.window.title = Painel ECF +painelEcfController.btnSalvar.tooltiptext = Guardar +painelEcfController.btnFechar.tooltiptext = Cerrar +painelEcfController.lbEmpresa.value=Empresa +painelEcfController.lbECF.value=ECF +painelEcfController.lbUFInstalacao.value=UF Instalação +painelEcfController.lbDataOcorrencia.value=Data Ocorrência +painelEcfController.lbAgencia.value=Agência +painelEcfController.lbSeqCCFQuebrada.value=Seq. CCF Quebrada +painelEcfController.lbDiasAlertaAberto.value=Dias Alerta Aberto +painelEcfController.lbSeqCRZQuebrada.value=Seq. CRZ Quebrada \ No newline at end of file diff --git a/web/gui/seguridad/painelEcf.zul b/web/gui/seguridad/painelEcf.zul new file mode 100644 index 000000000..f49e8c2fc --- /dev/null +++ b/web/gui/seguridad/painelEcf.zul @@ -0,0 +1,71 @@ + + + + + + + + + + +