Implementação geração serviço dia sim dia não.
bug 7243 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@54072 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
46e36f28c9
commit
f4060d260c
|
@ -1,7 +1,3 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.entidad;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -126,7 +122,8 @@ public class EsquemaCorrida implements Serializable {
|
|||
private String infoCorrida;
|
||||
@Column(name = "INDCORRIDAEXTRA")
|
||||
private Boolean indCorridaExtra;
|
||||
|
||||
@Column(name = "INDDIASIMDIANAO")
|
||||
private Boolean indDiaSimDiaNao;
|
||||
public enum GerarFeriado {
|
||||
// Declaração dos enum
|
||||
GERARSEMPRE("GERAR SEMPRE", "S"),
|
||||
|
@ -473,6 +470,14 @@ public class EsquemaCorrida implements Serializable {
|
|||
this.indCorridaExtra = indCorridaExtra;
|
||||
}
|
||||
|
||||
public Boolean getIndDiaSimDiaNao() {
|
||||
return indDiaSimDiaNao;
|
||||
}
|
||||
|
||||
public void setIndDiaSimDiaNao(Boolean indDiaSimDiaNao) {
|
||||
this.indDiaSimDiaNao = indDiaSimDiaNao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 0;
|
||||
|
|
|
@ -410,6 +410,7 @@ public class CorridaServiceImpl implements CorridaService {
|
|||
* @return - La corrida generada o null si no fue generada.
|
||||
*/
|
||||
private Corrida generarCorrida(EsquemaCorrida esquemaCorrida, Date dataGeracao, boolean isPisoExtra, Boolean isFeriado) {
|
||||
|
||||
GregorianCalendar calendario = new GregorianCalendar();
|
||||
calendario.setTime(dataGeracao);
|
||||
|
||||
|
@ -428,20 +429,20 @@ public class CorridaServiceImpl implements CorridaService {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (!temCorridaDiaSemana(diaSemana, esquemaCorrida, isFeriado)) {
|
||||
log.info("dia semana no valido=" + diaSemana);
|
||||
|
||||
return null;
|
||||
if (esquemaCorrida.getIndDiaSimDiaNao() == null || esquemaCorrida.getIndDiaSimDiaNao() == Boolean.FALSE) {
|
||||
if (!temCorridaDiaSemana(diaSemana, esquemaCorrida, isFeriado)) {
|
||||
log.info("dia semana no valido=" + diaSemana);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!tramoServicioService.existenTiemposTramosEsquema(esquemaCorrida.getEsquemacorridaId())) {
|
||||
log.info("nao foi cadastrado o tempo de todos os trechos do esquema corrida=" + esquemaCorrida.getEsquemacorridaId());
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Ruta ruta = esquemaCorrida.getRuta();
|
||||
ClaseServicio claseServicio = esquemaCorrida.getClaseServicio();
|
||||
Marca marca = esquemaCorrida.getMarca();
|
||||
|
@ -454,6 +455,22 @@ public class CorridaServiceImpl implements CorridaService {
|
|||
id.setCorridaId(numCorrida);
|
||||
id.setFeccorrida(DateUtil.normalizarToFecha(dataGeracao));
|
||||
|
||||
if(esquemaCorrida.getIndDiaSimDiaNao()) {
|
||||
Calendar calendarData = Calendar.getInstance();
|
||||
calendarData.setTime(dataGeracao);
|
||||
calendarData.add(Calendar.DATE, -1);
|
||||
|
||||
Corrida.Id corridaOntem = new Corrida.Id();
|
||||
|
||||
corridaOntem.setCorridaId(numCorrida);
|
||||
corridaOntem.setFeccorrida(DateUtil.normalizarToFecha(calendarData.getTime()));
|
||||
|
||||
if (corridaDAO.existe(corridaOntem)) {
|
||||
log.info("Esquema configurado para gerar dia sim dia não e já possui corrida gerado no dia anterior, por isso não está data: " + DateUtil.getStringDate(dataGeracao));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (corridaDAO.existe(id)) {
|
||||
log.info("corrida existe = " + numCorrida + ";" + ruta.getDescruta() + ";" + DateUtil.getStringDate(dataGeracao) + ";" + DateUtil.getStringDate(horario, "HH:mm") + ";" + claseServicio.getDescclase() + ";" + marca.getDescmarca() + " Piso: " + isPisoExtra);
|
||||
return null;
|
||||
|
@ -781,6 +798,7 @@ public class CorridaServiceImpl implements CorridaService {
|
|||
}
|
||||
|
||||
private void generarCorrida(Date dataGeracao, List<EsquemaCorrida> lsEsquemaCorrida) {
|
||||
|
||||
DefaultTransactionDefinition def = new DefaultTransactionDefinition(DefaultTransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
||||
|
||||
// TODO: Melhorar o tratamento às transações manuais em caso de erro,etc
|
||||
|
@ -788,7 +806,9 @@ public class CorridaServiceImpl implements CorridaService {
|
|||
cantCorridaGenerada = 0;
|
||||
cantCorridaCommit = 1;
|
||||
java.sql.Date data = new java.sql.Date(dataGeracao.getTime());
|
||||
|
||||
try {
|
||||
|
||||
for (EsquemaCorrida esquemaCorrida : lsEsquemaCorrida) {
|
||||
Boolean isFeriado = this.isFeriado(data, esquemaCorrida);
|
||||
|
||||
|
@ -843,7 +863,6 @@ public class CorridaServiceImpl implements CorridaService {
|
|||
|
||||
Corrida corridaRebote = generarCorrida(esquemaCorrida.getEsquemaCorridaRebote(), dataGeracao, false, isFeriado);
|
||||
Corrida corridaPisoExtraRebote = null;
|
||||
|
||||
boolean generaReboteDiaSeguinte = false;
|
||||
|
||||
if (corridaRebote != null) {
|
||||
|
@ -927,7 +946,6 @@ public class CorridaServiceImpl implements CorridaService {
|
|||
transactionManager.commit(status);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue