Merge pull request 'fixes bug #AL-3879' (!154) from AL-3873 into master
Reviewed-on: adm/ModelWeb#154 Reviewed-by: fabio <fabio.faria@rjconsultores.com.br>master
commit
4ac7b21d3d
2
pom.xml
2
pom.xml
|
@ -3,7 +3,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>br.com.rjconsultores</groupId>
|
||||
<artifactId>ModelWeb</artifactId>
|
||||
<version>1.40.1</version>
|
||||
<version>1.40.2</version>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
|
|
|
@ -5,13 +5,17 @@
|
|||
package com.rjconsultores.ventaboletos.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.persistence.Transient;
|
||||
|
||||
|
@ -87,8 +91,10 @@ import com.rjconsultores.ventaboletos.utilerias.ActivoUtil;
|
|||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||
import com.rjconsultores.ventaboletos.utilerias.FeriadoCache;
|
||||
import com.rjconsultores.ventaboletos.utilerias.HoraSistema;
|
||||
import com.rjconsultores.ventaboletos.utilerias.LocaleUtil;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UtiliteriasFiscal;
|
||||
import com.rjconsultores.ventaboletos.vo.esquemaoperacional.TarefaGeracaoCorridaVO;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -1157,6 +1163,13 @@ public class CorridaServiceImpl implements CorridaService {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if(fecViaje!=null) {
|
||||
if(!isDiaSemnanaOK(reservaEspecialCliente, fecViaje)) {
|
||||
log.error("Reserva não será realizada. Dia da semana desta corrida não corresponde ao dia da semana configurado na resserva epecial para o clienteId:"
|
||||
+ reservaEspecialCliente.getClienteId() + " reservaEspecialClienteId:" + reservaEspecialCliente.getReservaEspecialClienteId() + " para a corrida:" + corrida.getId().getCorridaId() + "na data" + fecViaje);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(tramo==null) {
|
||||
log.error("Reserva não será realizada. não foi encontrado trecho com Origem:" + unoTerminalOrigenId + " Destino:" +unoTerminalDestinoId + " para a corrida:" + corrida.getId().getCorridaId());
|
||||
|
@ -1206,6 +1219,43 @@ public class CorridaServiceImpl implements CorridaService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Valida se o dia da semana desta corrida está configurado para gerar reserva especial de clientes
|
||||
* @param reservaEspecialCliente
|
||||
* @param fecViaje
|
||||
* @return
|
||||
*/
|
||||
private boolean isDiaSemnanaOK(ReservaEspecialCliente reservaEspecialCliente, Date fecViaje) {
|
||||
int diaSemanaInt = DateUtil.getDiaDaSemana(fecViaje);
|
||||
boolean isDiaSemanaOK = false;
|
||||
switch (diaSemanaInt) {
|
||||
case 1:
|
||||
isDiaSemanaOK = Boolean.TRUE.equals(reservaEspecialCliente.getIndDomingo()) ? true :false ;
|
||||
break;
|
||||
case 2:
|
||||
isDiaSemanaOK = Boolean.TRUE.equals(reservaEspecialCliente.getIndSegunda()) ? true :false ;
|
||||
break;
|
||||
case 3:
|
||||
isDiaSemanaOK = Boolean.TRUE.equals(reservaEspecialCliente.getIndTerca()) ? true :false ;
|
||||
break;
|
||||
case 4:
|
||||
isDiaSemanaOK = Boolean.TRUE.equals(reservaEspecialCliente.getIndQuarta()) ? true :false ;
|
||||
break;
|
||||
case 5:
|
||||
isDiaSemanaOK = Boolean.TRUE.equals(reservaEspecialCliente.getIndQuinta()) ? true :false ;
|
||||
break;
|
||||
case 6:
|
||||
isDiaSemanaOK = Boolean.TRUE.equals(reservaEspecialCliente.getIndSexta()) ? true :false ;
|
||||
break;
|
||||
case 7:
|
||||
isDiaSemanaOK = Boolean.TRUE.equals(reservaEspecialCliente.getIndSabado()) ? true :false ;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return isDiaSemanaOK;
|
||||
}
|
||||
|
||||
private void alterarNumPisoCorridaPisoExtra(Corrida corrida, Corrida corridaPisoExtra, String mensagemLog, Boolean atualizarPisoExtra, boolean isPiso3) {
|
||||
if (corrida != null && corridaPisoExtra != null) {
|
||||
log.info(mensagemLog + "; atualizando as corridas do piso 1 e 2");
|
||||
|
@ -1764,5 +1814,18 @@ public class CorridaServiceImpl implements CorridaService {
|
|||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Date dataInicialFiltroCorridaExistente = new Date();
|
||||
Date dataFinalFiltroCorridaExistente = DateUtil.somarDias(dataInicialFiltroCorridaExistente, 7);
|
||||
|
||||
LocalDate inicioLocalDate = dataInicialFiltroCorridaExistente.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
LocalDate fimLocalDate = dataFinalFiltroCorridaExistente.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().plusDays(1);
|
||||
for (LocalDate date = inicioLocalDate; date.isBefore(fimLocalDate); date = date.plusDays(1)) {
|
||||
Date dataIter = Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
DateFormat formatter = new SimpleDateFormat("EEE", new Locale("pt", "BR"));
|
||||
String dia = formatter.format(dataIter);
|
||||
System.out.println("Teste dia:" + dia);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -866,4 +866,17 @@ public final class DateUtil {
|
|||
return c1.after(c2);
|
||||
}
|
||||
|
||||
/***
|
||||
* retorna dia da semana da data Domingo 1, até sábado 7
|
||||
*
|
||||
* @param dataCobranca
|
||||
* @return
|
||||
*/
|
||||
public static int getDiaDaSemana(Date dataCobranca) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(dataCobranca);
|
||||
|
||||
return cal.get(Calendar.DAY_OF_WEEK);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue