leonardo 2017-11-28 18:41:05 +00:00
parent 8819fbec65
commit 04e38f5731
8 changed files with 212 additions and 114 deletions

View File

@ -1,11 +1,13 @@
package com.rjconsultores.ventaboletos.web.gui.controladores.job;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import org.apache.log4j.Logger;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
@ -13,14 +15,7 @@ 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;
@ -35,6 +30,7 @@ public class MonitoramentoCCFCRZJob implements Job {
@Autowired
private MonitoramentoCRZService monitoramentoCRZService;
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
log.info("Inicio do job de Monitoramento CCF CRZ...");
@ -46,49 +42,46 @@ public class MonitoramentoCCFCRZJob implements Job {
inicio.add(Calendar.DATE, -1);
inicio.set(Calendar.HOUR, 0);
inicio.set(Calendar.MINUTE, 0);
inicio.set(Calendar.SECOND, 0);
inicio.set(Calendar.SECOND, 0);
for (MonitoramentoCCFR2 r2 : buscaRegistrosR2()){
Map<Integer, MonitoramentoCCF> ccfs = new HashMap<Integer, MonitoramentoCCF>();
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<Integer, MonitoramentoCCF> 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);
}
gravaCCFsQuebrados();
gravaCRZsQuebradas();
log.info("Fim do job de Monitoramento CCF CRZ.");
}
public List<MonitoramentoCCFR2> buscaRegistrosR2(){
return monitoramentoCCFService.buscaRegistrosR2(inicio.getTime());
}
public List<MonitoramentoCCF> buscaQuebraCCF(MonitoramentoCCFR2 r2){
return monitoramentoCCFService.buscaQuebraCCF(r2.numserie20, inicio.getTime());
private void gravaCRZsQuebradas() {
log.info("Gravando CRZs quebradas...");
for (MonitoramentoCRZ m : buscaQuebraCRZ()){
monitoramentoCRZService.suscribir(m);
}
}
private void gravaCCFsQuebrados() {
try{
//con = dataSource.getConnection();
monitoramentoCCFService.openConnection();
/*
* CCF:
* Distinct serie impressora na caja pra pegar somente as que venderam no dia anterior
* ultimo CCF no dia anterior -1 pra pegar o inicial
* join caja com fiscal_r4
* verificar se tem quebra
*/
log.info("Gravando CCFs quebrados...");
Map<String, Integer> impressoras = monitoramentoCCFService.obterImpressorasComCCFInicial(inicio.getTime());
Calendar c = Calendar.getInstance();
c.setTime(inicio.getTime());
c.add(Calendar.DAY_OF_MONTH, -5);
monitoramentoCCFService.gravarListaCCFQuebrados(impressoras, c.getTime());
//con.commit();
monitoramentoCCFService.closeConnection();
} catch (Exception e){
log.error("", e);
}
}
public List<MonitoramentoCRZ> buscaQuebraCRZ(){
return monitoramentoCRZService.buscaQuebraCRZ(inicio.getTime());
}

View File

@ -14,6 +14,8 @@ 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;
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderMonitoramentoCCF;
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderMonitoramentoCRZ;
@Controller("painelEcfController")
@Scope("prototype")
@ -38,7 +40,9 @@ public class PainelEcfController extends MyGenericForwardComposer {
super.doAfterCompose(comp);
monitoramentoCCFList.setData(lsCCF);
monitoramentoCCFList.setItemRenderer(new RenderMonitoramentoCCF());
monitoramentoCRZList.setData(lsCRZ);
monitoramentoCRZList.setItemRenderer(new RenderMonitoramentoCRZ());
}

View File

@ -0,0 +1,41 @@
package com.rjconsultores.ventaboletos.web.utilerias.render;
import java.text.SimpleDateFormat;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.ListitemRenderer;
import com.rjconsultores.ventaboletos.entidad.MonitoramentoCCF;
public class RenderMonitoramentoCCF implements ListitemRenderer {
public void render(Listitem lstm, Object o) throws Exception {
MonitoramentoCCF m = (MonitoramentoCCF) o;
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Listcell lc = new Listcell(m.getEmpresa() != null ? m.getEmpresa().getNombempresa() : "");
lc.setParent(lstm);
lc = new Listcell(m.getImpressora().getNumserie20());
lc.setParent(lstm);
lc = new Listcell(m.getEstadoInstalacao() != null ? m.getEstadoInstalacao().getNombestado() : "");
lc.setParent(lstm);
lc = new Listcell(sdf.format(m.getDataOcorrencia()));
lc.setParent(lstm);
lc = new Listcell(m.getPuntoventa().getNombpuntoventa());
lc.setParent(lstm);
lc = new Listcell(m.getSequenciaCCFQuebrada().toString());
lc.setParent(lstm);
lc = new Listcell(sdf.format(m.getDiasAlertaAberto()));
lc.setParent(lstm);
lstm.setAttribute("data", m);
}
}

View File

@ -0,0 +1,40 @@
package com.rjconsultores.ventaboletos.web.utilerias.render;
import java.text.SimpleDateFormat;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.ListitemRenderer;
import com.rjconsultores.ventaboletos.entidad.MonitoramentoCRZ;
public class RenderMonitoramentoCRZ implements ListitemRenderer {
public void render(Listitem lstm, Object o) throws Exception {
MonitoramentoCRZ m = (MonitoramentoCRZ) o;
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Listcell lc = new Listcell(m.getEmpresa() != null ? m.getEmpresa().getNombempresa() : "");
lc.setParent(lstm);
lc = new Listcell(m.getImpressora().getNumserie20());
lc.setParent(lstm);
lc = new Listcell(m.getEstadoInstalacao() != null ? m.getEstadoInstalacao().getNombestado() : "");
lc.setParent(lstm);
lc = new Listcell(sdf.format(m.getDataReducaoZFaltante()));
lc.setParent(lstm);
lc = new Listcell(m.getPuntoventa().getNombpuntoventa());
lc.setParent(lstm);
lc = new Listcell(m.getSequenciaCRZQuebrada().toString());
lc.setParent(lstm);
lc = new Listcell(sdf.format(m.getDiasAlertaAberto()));
lc.setParent(lstm);
lstm.setAttribute("data", m);
}
}

View File

@ -160,6 +160,8 @@
<value>com.rjconsultores.ventaboletos.entidad.MerchantBancario
</value>
<value>com.rjconsultores.ventaboletos.entidad.Moneda</value>
<value>com.rjconsultores.ventaboletos.entidad.MonitoramentoCRZ</value>
<value>com.rjconsultores.ventaboletos.entidad.MonitoramentoCCF</value>
<value>com.rjconsultores.ventaboletos.entidad.MarcaClaseServicio
</value>
<value>com.rjconsultores.ventaboletos.entidad.MotivoCancelacion</value>

View File

@ -7246,6 +7246,6 @@ 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.lbSeqCCFQuebrada.value=CCF Quebrada
painelEcfController.lbDiasAlertaAberto.value=Dias Alerta Aberto
painelEcfController.lbSeqCRZQuebrada.value=Seq. CRZ Quebrada
painelEcfController.lbSeqCRZQuebrada.value=CRZ Quebrada

View File

@ -7734,6 +7734,6 @@ 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.lbSeqCCFQuebrada.value=CCF Quebrada
painelEcfController.lbDiasAlertaAberto.value=Dias Alerta Aberto
painelEcfController.lbSeqCRZQuebrada.value=Seq. CRZ Quebrada
painelEcfController.lbSeqCRZQuebrada.value=CRZ Quebrada

View File

@ -4,68 +4,86 @@
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="winPainelEcf"?>
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<zk xmlns="http://www.zkoss.org/2005/zul" xmlns:h="http://www.w3.org/1999/xhtml">
<window id="winPainelEcf" border="normal" apply="${painelEcfController}"
width="800px" contentStyle="overflow:auto"
title="${c:l('painelEcfController.window.title')}">
<toolbar>
<hbox spacing="5px" style="padding:1px" align="right">
<button id="btnSalvar" height="20"
image="/gui/img/save.png" width="35px"
tooltiptext="${c:l('painelEcfController.btnSalvar.tooltiptext')}"/>
<button id="btnFechar" height="20"
image="/gui/img/exit.png" width="35px"
onClick="winPainelEcf.detach()"
tooltiptext="${c:l('painelEcfController.btnFechar.tooltiptext')}"/>
</hbox>
</toolbar>
<listbox id="monitoramentoCCFList"
use="com.rjconsultores.ventaboletos.web.utilerias.MyListbox"
vflex="true" multiple="false">
<auxhead>
<auxheader label="Monitor CCF" colspan="7"/>
</auxhead>
<listhead sizable="true">
<listheader id="lhEmpresa" width="10%"
label="${c:l('painelEcfController.lbEmpresa.value')}" />
<listheader id="lhECF" width="10%"
label="${c:l('painelEcfController.lbECF.value')}" />
<listheader id="lhUFInstalacao" width="15%"
label="${c:l('painelEcfController.lbUFInstalacao.value')}" />
<listheader id="lhDataOcorrencia" width="15%"
label="${c:l('painelEcfController.lbDataOcorrencia.value')}" />
<listheader id="lhAgencia" width="10%"
label="${c:l('painelEcfController.lbAgencia.value')}" />
<listheader id="lhSeqCCFQuebrada" width="20%"
label="${c:l('painelEcfController.lbSeqCCFQuebrada.value')}" />
<listheader id="lhDiasAlertaAberto" width="20%"
label="${c:l('painelEcfController.lbDiasAlertaAberto.value')}" />
</listhead>
</listbox>
<h:br /><h:br />
<listbox id="monitoramentoCRZList"
use="com.rjconsultores.ventaboletos.web.utilerias.MyListbox"
vflex="true" multiple="false">
<auxhead>
<auxheader label="Monitor CRZ" colspan="7"/>
</auxhead>
<listhead sizable="true">
<listheader id="lhEmpresaCRZ" width="10%"
label="${c:l('painelEcfController.lbEmpresa.value')}" />
<listheader id="lhECFCRZ" width="10%"
label="${c:l('painelEcfController.lbECF.value')}" />
<listheader id="lhUFInstalacaoCRZ" width="15%"
label="${c:l('painelEcfController.lbUFInstalacao.value')}" />
<listheader id="lhDataOcorrenciaCRZ" width="15%"
label="${c:l('painelEcfController.lbDataOcorrencia.value')}" />
<listheader id="lhAgenciaCRZ" width="10%"
label="${c:l('painelEcfController.lbAgencia.value')}" />
<listheader id="lhSeqCRZQuebrada" width="20%"
label="${c:l('painelEcfController.lbSeqCRZQuebrada.value')}" />
<listheader id="lhDiasAlertaAbertoCRZ" width="20%"
label="${c:l('painelEcfController.lbDiasAlertaAberto.value')}" />
</listhead>
</listbox>
</window>
<zk xmlns="http://www.zkoss.org/2005/zul"
xmlns:h="http://www.w3.org/1999/xhtml">
<window id="winPainelEcf" border="normal"
apply="${painelEcfController}" width="800px" height="600px"
contentStyle="overflow:auto"
title="${c:l('painelEcfController.window.title')}">
<toolbar>
<hbox spacing="5px" style="padding:1px" align="right">
<button id="btnSalvar" height="20"
image="/gui/img/save.png" width="35px"
tooltiptext="${c:l('painelEcfController.btnSalvar.tooltiptext')}" />
<button id="btnFechar" height="20"
image="/gui/img/exit.png" width="35px"
onClick="winPainelEcf.detach()"
tooltiptext="${c:l('painelEcfController.btnFechar.tooltiptext')}" />
</hbox>
</toolbar>
<grid fixedLayout="true">
<columns>
<column />
</columns>
<rows>
<row>
<listbox id="monitoramentoCCFList"
use="com.rjconsultores.ventaboletos.web.utilerias.MyListbox"
multiple="false" height="200px">
<auxhead>
<auxheader label="Monitor CCF" colspan="7" />
</auxhead>
<listhead sizable="true">
<listheader id="lhEmpresa" width="20%"
label="${c:l('painelEcfController.lbEmpresa.value')}" />
<listheader id="lhECF" width="20%"
label="${c:l('painelEcfController.lbECF.value')}" />
<listheader id="lhUFInstalacao" width="10%"
label="${c:l('painelEcfController.lbUFInstalacao.value')}" />
<listheader id="lhDataOcorrencia"
width="10%"
label="${c:l('painelEcfController.lbDataOcorrencia.value')}" />
<listheader id="lhAgencia" width="20%"
label="${c:l('painelEcfController.lbAgencia.value')}" />
<listheader id="lhSeqCCFQuebrada"
width="10%"
label="${c:l('painelEcfController.lbSeqCCFQuebrada.value')}" />
<listheader id="lhDiasAlertaAberto"
width="10%"
label="${c:l('painelEcfController.lbDiasAlertaAberto.value')}" />
</listhead>
</listbox>
</row>
<row>
<listbox id="monitoramentoCRZList"
use="com.rjconsultores.ventaboletos.web.utilerias.MyListbox"
multiple="false" height="200px">
<auxhead>
<auxheader label="Monitor CRZ" colspan="7" />
</auxhead>
<listhead sizable="true">
<listheader id="lhEmpresaCRZ" width="20%"
label="${c:l('painelEcfController.lbEmpresa.value')}" />
<listheader id="lhECFCRZ" width="20%"
label="${c:l('painelEcfController.lbECF.value')}" />
<listheader id="lhUFInstalacaoCRZ"
width="10%"
label="${c:l('painelEcfController.lbUFInstalacao.value')}" />
<listheader id="lhDataOcorrenciaCRZ"
width="10%"
label="${c:l('painelEcfController.lbDataOcorrencia.value')}" />
<listheader id="lhAgenciaCRZ" width="20%"
label="${c:l('painelEcfController.lbAgencia.value')}" />
<listheader id="lhSeqCRZQuebrada"
width="10%"
label="${c:l('painelEcfController.lbSeqCRZQuebrada.value')}" />
<listheader id="lhDiasAlertaAbertoCRZ"
width="20%"
label="${c:l('painelEcfController.lbDiasAlertaAberto.value')}" />
</listhead>
</listbox>
</row>
</rows>
</grid>
</window>
</zk>