- correção na geração de corridas: Validação para não permitir gerar serviço que não tenha vigência válida
- melhoria nos logs de debug durante a geração - remoção de classe/zul que não é mais usado git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@25694 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
01f15358bf
commit
26e15bd192
|
@ -1,167 +0,0 @@
|
||||||
/*
|
|
||||||
* To change this template, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package com.rjconsultores.ventaboletos.web.gui.controladores.esquemaoperacional;
|
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.Constante;
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.EsquemaOperacional;
|
|
||||||
import com.rjconsultores.ventaboletos.service.ConstanteService;
|
|
||||||
import com.rjconsultores.ventaboletos.service.CorridaService;
|
|
||||||
import com.rjconsultores.ventaboletos.service.EsquemaCorridaService;
|
|
||||||
import com.rjconsultores.ventaboletos.service.EsquemaOperacionalService;
|
|
||||||
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
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.util.resource.Labels;
|
|
||||||
import org.zkoss.zk.ui.Component;
|
|
||||||
import org.zkoss.zul.Datebox;
|
|
||||||
import org.zkoss.zul.Messagebox;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Rafius
|
|
||||||
*/
|
|
||||||
@Controller("geracionCorridaController")
|
|
||||||
@Scope("prototype")
|
|
||||||
public class GeracionCorridaController extends MyGenericForwardComposer {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
@Autowired
|
|
||||||
private CorridaService corridaService;
|
|
||||||
@Autowired
|
|
||||||
private EsquemaOperacionalService esquemaOperacionalService;
|
|
||||||
@Autowired
|
|
||||||
private EsquemaCorridaService esquemaCorridaService;
|
|
||||||
@Autowired
|
|
||||||
private ConstanteService constanteService;
|
|
||||||
private Datebox fec;
|
|
||||||
private static Logger log = Logger.getLogger(GeracionCorridaController.class);
|
|
||||||
|
|
||||||
public Datebox getFec() {
|
|
||||||
return fec;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFec(Datebox fec) {
|
|
||||||
this.fec = fec;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doAfterCompose(Component comp) throws Exception {
|
|
||||||
super.doAfterCompose(comp);
|
|
||||||
|
|
||||||
Constante constante = constanteService.buscarPorNomeConstante("CANT_DIAS_GENERACION_CORRIDA");
|
|
||||||
try {
|
|
||||||
Integer.parseInt(constante.getValorconstante());
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(" Generacion de corrida" + e);
|
|
||||||
Messagebox.show(
|
|
||||||
Labels.getLabel("geracionCorridaController.MSG.qtdDias", new Object[] { constante.getValorconstante() }),
|
|
||||||
Labels.getLabel("geracionCorridaController.window.title"),
|
|
||||||
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
||||||
closeWindow();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleDateFormat sdfData = new SimpleDateFormat("dd/MM/yyyy");
|
|
||||||
int resp = Messagebox.show(
|
|
||||||
Labels.getLabel("geracionCorridaController.MSG.gerarPergunta", new Object[] { sdfData.format(calcularDataFinal()) }),
|
|
||||||
Labels.getLabel("geracionCorridaController.window.title"),
|
|
||||||
Messagebox.YES | Messagebox.NO, Messagebox.QUESTION);
|
|
||||||
|
|
||||||
if (resp == Messagebox.YES) {
|
|
||||||
generarCorridasAutomatica();
|
|
||||||
}
|
|
||||||
|
|
||||||
closeWindow();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date calcularDataFinal() throws InterruptedException {
|
|
||||||
Date dataDe = new Date();
|
|
||||||
Constante constante = constanteService.buscarPorNomeConstante("CANT_DIAS_GENERACION_CORRIDA");
|
|
||||||
Calendar calendarData = Calendar.getInstance();
|
|
||||||
calendarData.setTime(dataDe);
|
|
||||||
calendarData.add(Calendar.DATE, Integer.parseInt(constante.getValorconstante()));
|
|
||||||
Date dataAte = calendarData.getTime();
|
|
||||||
|
|
||||||
return dataAte;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void generarCorridasAutomatica() throws InterruptedException {
|
|
||||||
|
|
||||||
SimpleDateFormat sdfData = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
|
||||||
|
|
||||||
Date dataDe = new Date();
|
|
||||||
// Date dataDe = null;
|
|
||||||
// try {
|
|
||||||
// dataDe = new SimpleDateFormat("dd/MM/yyyy").parse("7/08/2012");
|
|
||||||
// } catch (ParseException ex) {
|
|
||||||
// ex.printStackTrace();
|
|
||||||
// }
|
|
||||||
// Date dataAte = calcularDataFinal();
|
|
||||||
Date dataAte = calcularDataFinal();
|
|
||||||
dataDe.setSeconds(0);
|
|
||||||
dataAte.setSeconds(0);
|
|
||||||
|
|
||||||
log.info("** Data De: " + sdfData.format(dataDe) + " **Data Até: " + sdfData.format(dataAte));
|
|
||||||
|
|
||||||
Calendar calendarData = Calendar.getInstance();
|
|
||||||
calendarData.setTime(dataAte);
|
|
||||||
calendarData.add(Calendar.DATE, 1);
|
|
||||||
dataAte = calendarData.getTime();
|
|
||||||
try {
|
|
||||||
while (dataDe.before(dataAte)) {
|
|
||||||
|
|
||||||
log.debug("*** Data: " + sdfData.format(dataDe));
|
|
||||||
|
|
||||||
List<EsquemaOperacional> lsEsquemaOperacional =
|
|
||||||
esquemaOperacionalService.dentroVigenciaEsquemaOperacional(
|
|
||||||
dataDe);
|
|
||||||
|
|
||||||
List<EsquemaCorrida> lsEsquemaCorrida = new ArrayList<EsquemaCorrida>();
|
|
||||||
for (EsquemaOperacional eo : lsEsquemaOperacional) {
|
|
||||||
lsEsquemaCorrida.addAll(esquemaCorridaService.buscarPorEsquemaOperacional(eo));
|
|
||||||
}
|
|
||||||
|
|
||||||
Boolean dentroVigenciaEsquemaOperacional = !lsEsquemaCorrida.isEmpty();
|
|
||||||
if (dentroVigenciaEsquemaOperacional) {
|
|
||||||
corridaService.generarCorrida(dataDe, lsEsquemaCorrida);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
Messagebox.show(
|
|
||||||
Labels.getLabel("geracionCorridaController.MSG.ForaVigencia"),
|
|
||||||
Labels.getLabel("geracionCorridaController.window.title"),
|
|
||||||
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
||||||
} catch (InterruptedException ex) {
|
|
||||||
log.error(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
calendarData.setTime(dataDe);
|
|
||||||
calendarData.add(Calendar.DATE, 1);
|
|
||||||
dataDe = calendarData.getTime();
|
|
||||||
}
|
|
||||||
log.debug("*** Corrida gerada com sucesso: ");
|
|
||||||
|
|
||||||
Messagebox.show(
|
|
||||||
Labels.getLabel("geracionCorridaController.MSG.ok"),
|
|
||||||
Labels.getLabel("geracionCorridaController.window.title"),
|
|
||||||
Messagebox.OK, Messagebox.INFORMATION);
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
|
||||||
log.error("Erro ao gerar corridas: " + ex);
|
|
||||||
Messagebox.show(
|
|
||||||
Labels.getLabel("MSG.Error").concat(" \n\n ").concat(ex.toString()),
|
|
||||||
Labels.getLabel("editarPuntoVentaController.window.title"),
|
|
||||||
Messagebox.OK, Messagebox.ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,7 +7,7 @@
|
||||||
# <controler>. <id>. <propiedade> = XXX
|
# <controler>. <id>. <propiedade> = XXX
|
||||||
|
|
||||||
#Versao do VentaBoleto:
|
#Versao do VentaBoleto:
|
||||||
versao = ADM_20130408_1RC140
|
versao = ADM_20130411_1RC141
|
||||||
|
|
||||||
# MSG Defaut:
|
# MSG Defaut:
|
||||||
MSG.CONSTRAINT.PORCENTAGEM = Os valores devem estar entre 0 e 100
|
MSG.CONSTRAINT.PORCENTAGEM = Os valores devem estar entre 0 e 100
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<?page contentType="text/html;charset=UTF-8"?>
|
|
||||||
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
|
|
||||||
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="winGeracionCorrida"?>
|
|
||||||
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
|
|
||||||
<zk xmlns="http://www.zkoss.org/2005/zul">
|
|
||||||
<window id="winGeracionCorrida" title="${c:l('geracionCorridaController.window.title')}"
|
|
||||||
apply="${geracionCorridaController}" contentStyle="overflow:auto"
|
|
||||||
border="normal" xmlns:h="http://www.w3.org/1999/xhtml" width="400px">
|
|
||||||
|
|
||||||
<toolbar>
|
|
||||||
<button id="btnCerrar" onClick="winGeracionCorrida.detach()" image="/gui/img/exit.png" width="35px"
|
|
||||||
tooltiptext="${c:l('busquedaConfiguracionCorridaController.btnCerrar.tooltiptext')}"/>
|
|
||||||
</toolbar>
|
|
||||||
|
|
||||||
<grid>
|
|
||||||
<!--rows >
|
|
||||||
<row spans="2" align="center">
|
|
||||||
<hbox align="center">
|
|
||||||
<button id="btnGerar" image="/gui/img/enginer.png"
|
|
||||||
label="${c:l('geracionCorridaController.lhGerar.label')}"/>
|
|
||||||
</hbox>
|
|
||||||
</row>
|
|
||||||
</rows-->
|
|
||||||
</grid>
|
|
||||||
</window>
|
|
||||||
</zk>
|
|
Loading…
Reference in New Issue