git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@31586 d1611594-4594-4d17-8e1d-87c2c4800839
parent
29655a0976
commit
8970739612
|
@ -83,4 +83,6 @@ public interface CorridaDAO extends GenericDAO<Corrida, Corrida.Id> {
|
||||||
|
|
||||||
public List<Corrida> buscarPorEstado(Estado estado, Date dataInicial);
|
public List<Corrida> buscarPorEstado(Estado estado, Date dataInicial);
|
||||||
|
|
||||||
|
List<Corrida> buscarPorEstado(Estado estado, Date dataInicial, Integer corridaId);
|
||||||
|
|
||||||
}
|
}
|
|
@ -500,10 +500,10 @@ public class CorridaHibernateDAO extends GenericHibernateDAO<Corrida, Corrida.Id
|
||||||
tiempoHorHusoDestino = Integer.valueOf(objeto[7].toString());
|
tiempoHorHusoDestino = Integer.valueOf(objeto[7].toString());
|
||||||
tiempoHorVeranoDestino = Integer.valueOf(objeto[8].toString());
|
tiempoHorVeranoDestino = Integer.valueOf(objeto[8].toString());
|
||||||
|
|
||||||
if (husoHorVeranoLlegadaAnterior == null){
|
if (husoHorVeranoLlegadaAnterior == null) {
|
||||||
fechorSalidaOriginalUpdate = fechorSalidaOriginal;
|
fechorSalidaOriginalUpdate = fechorSalidaOriginal;
|
||||||
fechorsalidaUpdate = fechorsalida;
|
fechorsalidaUpdate = fechorsalida;
|
||||||
}else{
|
} else {
|
||||||
fechorSalidaOriginalUpdate = husoHorVeranoLlegadaAnterior;
|
fechorSalidaOriginalUpdate = husoHorVeranoLlegadaAnterior;
|
||||||
fechorsalidaUpdate = husoHorVeranoLlegadaAnterior;
|
fechorsalidaUpdate = husoHorVeranoLlegadaAnterior;
|
||||||
}
|
}
|
||||||
|
@ -515,9 +515,9 @@ public class CorridaHibernateDAO extends GenericHibernateDAO<Corrida, Corrida.Id
|
||||||
tiempoHorHusoOrigem + tiempoHorVeranoOrigem,
|
tiempoHorHusoOrigem + tiempoHorVeranoOrigem,
|
||||||
tiempoHorHusoDestino + tiempoHorVeranoDestino);
|
tiempoHorHusoDestino + tiempoHorVeranoDestino);
|
||||||
|
|
||||||
if (husoHorVeranoLlegadaAnterior != null){
|
if (husoHorVeranoLlegadaAnterior != null) {
|
||||||
fechorllegadaUpdate = husoHorVeranoLlegadaAnterior;
|
fechorllegadaUpdate = husoHorVeranoLlegadaAnterior;
|
||||||
}else{
|
} else {
|
||||||
fechorllegadaUpdate = fechorllegada;
|
fechorllegadaUpdate = fechorllegada;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,41 +536,41 @@ public class CorridaHibernateDAO extends GenericHibernateDAO<Corrida, Corrida.Id
|
||||||
|
|
||||||
// Si los tiempos son distintos, hube cambio de huso horario/horario de verano
|
// Si los tiempos son distintos, hube cambio de huso horario/horario de verano
|
||||||
if (tiempoOrigen != tiempoDestino) {
|
if (tiempoOrigen != tiempoDestino) {
|
||||||
long elapsedHoras = DateUtil.getElapsedHoras(fechorsalida,fechorllegada);
|
long elapsedMinutes = DateUtil.getElapsedMinutos(fechorsalida, fechorllegada);
|
||||||
|
|
||||||
horLlegada = Calendar.getInstance();
|
horLlegada = Calendar.getInstance();
|
||||||
horLlegada.setTime(fechorsalidaH);
|
horLlegada.setTime(fechorsalidaH);
|
||||||
|
|
||||||
horLlegada.add(Calendar.HOUR, (int)elapsedHoras);
|
horLlegada.add(Calendar.MINUTE, (int) elapsedMinutes);
|
||||||
horLlegada.add(Calendar.HOUR, difHuso(tiempoOrigen,tiempoDestino));
|
horLlegada.add(Calendar.HOUR, difHuso(tiempoOrigen, tiempoDestino));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (horLlegada == null) ? null : horLlegada.getTime();
|
return (horLlegada == null) ? null : horLlegada.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int difHuso(int a,int b){
|
private int difHuso(int a, int b) {
|
||||||
int mult=0;
|
int mult = 0;
|
||||||
|
|
||||||
if ( (a < b) && (b<=0) ){
|
if ((a < b) && (b <= 0)) {
|
||||||
mult = -1;
|
mult = -1;
|
||||||
}else if ( (a<b) && (a>=0) ){
|
} else if ((a < b) && (a >= 0)) {
|
||||||
mult = -1;
|
mult = -1;
|
||||||
}else if (a> b){
|
} else if (a > b) {
|
||||||
mult = -1;
|
mult = -1;
|
||||||
}else{
|
} else {
|
||||||
mult = 1;
|
mult = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((Math.abs(a)-Math.abs(b)) * mult);
|
return ((Math.abs(a) - Math.abs(b)) * mult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Corrida> buscarPorEstado(final Estado estado, final Date dataInicial) {
|
public List<Corrida> buscarPorEstado(final Estado estado, final Date dataInicial, Integer corridaId) {
|
||||||
StringBuilder hql = new StringBuilder();
|
StringBuilder hql = new StringBuilder();
|
||||||
|
|
||||||
hql.append(" select ");
|
hql.append(" select ");
|
||||||
hql.append(" new com.rjconsultores.ventaboletos.entidad.Corrida").append("(");
|
hql.append(" distinct new com.rjconsultores.ventaboletos.entidad.Corrida").append("(");
|
||||||
hql.append(" ct.corrida.id.corridaId, ");
|
hql.append(" ct.corrida.id.corridaId, ");
|
||||||
hql.append(" ct.corrida.id.feccorrida").append(")");
|
hql.append(" ct.corrida.id.feccorrida").append(")");
|
||||||
hql.append(" from CorridaTramo ct ");
|
hql.append(" from CorridaTramo ct ");
|
||||||
|
@ -580,6 +580,9 @@ public class CorridaHibernateDAO extends GenericHibernateDAO<Corrida, Corrida.Id
|
||||||
hql.append(" and ct.corrida.id.feccorrida >= :feccorrida ");
|
hql.append(" and ct.corrida.id.feccorrida >= :feccorrida ");
|
||||||
hql.append(" and ( eo.estadoId = :estadoId ");
|
hql.append(" and ( eo.estadoId = :estadoId ");
|
||||||
hql.append(" or ed.estadoId = :estadoId )");
|
hql.append(" or ed.estadoId = :estadoId )");
|
||||||
|
if (corridaId != null) {
|
||||||
|
hql.append(" and ct.corrida.id.corridaId = :corridaId )");
|
||||||
|
}
|
||||||
hql.append(" group by ");
|
hql.append(" group by ");
|
||||||
hql.append(" ct.corrida.id.corridaId, ");
|
hql.append(" ct.corrida.id.corridaId, ");
|
||||||
hql.append(" ct.corrida.id.feccorrida ");
|
hql.append(" ct.corrida.id.feccorrida ");
|
||||||
|
@ -589,9 +592,18 @@ public class CorridaHibernateDAO extends GenericHibernateDAO<Corrida, Corrida.Id
|
||||||
query.setDate("feccorrida", dataInicial);
|
query.setDate("feccorrida", dataInicial);
|
||||||
query.setInteger("estadoId", estado.getEstadoId());
|
query.setInteger("estadoId", estado.getEstadoId());
|
||||||
|
|
||||||
|
if (corridaId != null) {
|
||||||
|
query.setInteger("corridaId", corridaId);
|
||||||
|
}
|
||||||
|
|
||||||
return query.list();
|
return query.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Corrida> buscarPorEstado(final Estado estado, final Date dataInicial) {
|
||||||
|
return buscarPorEstado(estado, dataInicial, null);
|
||||||
|
}
|
||||||
|
|
||||||
private List<Object[]> buscarTramosCorrida(final Corrida corrida) {
|
private List<Object[]> buscarTramosCorrida(final Corrida corrida) {
|
||||||
StringBuilder hql = new StringBuilder();
|
StringBuilder hql = new StringBuilder();
|
||||||
|
|
||||||
|
|
|
@ -63,4 +63,6 @@ public interface CorridaService extends GenericService<Corrida, Corrida.Id> {
|
||||||
public List<Corrida> buscarGroupCorrridaId(Integer corridaId, Integer origem, Integer destino, Integer ruta, Integer numRuta, Date dateInicio, Date dateFin);
|
public List<Corrida> buscarGroupCorrridaId(Integer corridaId, Integer origem, Integer destino, Integer ruta, Integer numRuta, Date dateInicio, Date dateFin);
|
||||||
|
|
||||||
public Boolean atualizarCorridaFecHusoFecVerano(Estado estado, Date dataInicial);
|
public Boolean atualizarCorridaFecHusoFecVerano(Estado estado, Date dataInicial);
|
||||||
|
|
||||||
|
Boolean atualizarCorridaFecHusoFecVerano(Estado estado, Date dataInicial, Integer corridaId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -524,7 +524,6 @@ public class CorridaServiceImpl implements CorridaService {
|
||||||
Date horaChegadaAnterior = null;
|
Date horaChegadaAnterior = null;
|
||||||
Date tiempoInstanciaAnterior = null; // indica o tempo de instancia que fica no tramo anterior ao atual
|
Date tiempoInstanciaAnterior = null; // indica o tempo de instancia que fica no tramo anterior ao atual
|
||||||
|
|
||||||
|
|
||||||
Date husoHorVeranoLlegadaAnterior = null;
|
Date husoHorVeranoLlegadaAnterior = null;
|
||||||
|
|
||||||
for (EsquemaTramo esquemaTramo : lsEsquemaTramo) {
|
for (EsquemaTramo esquemaTramo : lsEsquemaTramo) {
|
||||||
|
@ -585,24 +584,23 @@ public class CorridaServiceImpl implements CorridaService {
|
||||||
corridaTramo.setCorrida(corrida);
|
corridaTramo.setCorrida(corrida);
|
||||||
corridaTramo.setFechorSalidaOriginal(fecHorSalida);
|
corridaTramo.setFechorSalidaOriginal(fecHorSalida);
|
||||||
|
|
||||||
if (husoHorVeranoLlegadaAnterior == null){
|
if (husoHorVeranoLlegadaAnterior == null) {
|
||||||
corridaTramo.setFechorsalidaH(corridaTramo.getFechorsalida());
|
corridaTramo.setFechorsalidaH(corridaTramo.getFechorsalida());
|
||||||
}else{
|
} else {
|
||||||
corridaTramo.setFechorsalidaH(husoHorVeranoLlegadaAnterior);
|
corridaTramo.setFechorsalidaH(husoHorVeranoLlegadaAnterior);
|
||||||
}
|
}
|
||||||
|
|
||||||
husoHorVeranoLlegadaAnterior = calcularHusoHorVeranoLlegada(esquemaTramo, corridaTramo);
|
husoHorVeranoLlegadaAnterior = calcularHusoHorVeranoLlegada(esquemaTramo, corridaTramo);
|
||||||
|
|
||||||
if (husoHorVeranoLlegadaAnterior != null){
|
if (husoHorVeranoLlegadaAnterior != null) {
|
||||||
corridaTramo.setFechorllegadaH(husoHorVeranoLlegadaAnterior);
|
corridaTramo.setFechorllegadaH(husoHorVeranoLlegadaAnterior);
|
||||||
corridaTramo.setFechorSalidaOriginalH(husoHorVeranoLlegadaAnterior);
|
corridaTramo.setFechorSalidaOriginalH(husoHorVeranoLlegadaAnterior);
|
||||||
}else{
|
} else {
|
||||||
corridaTramo.setFechorllegadaH(corridaTramo.getFechorllegada());
|
corridaTramo.setFechorllegadaH(corridaTramo.getFechorllegada());
|
||||||
corridaTramo.setFechorSalidaOriginalH(corridaTramo.getFechorSalidaOriginal());
|
corridaTramo.setFechorSalidaOriginalH(corridaTramo.getFechorSalidaOriginal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (numSec == 1) {
|
||||||
if (numSec == 1){
|
|
||||||
corrida.setFechorSalidaOriginalH(corridaTramo.getFechorsalidaH());
|
corrida.setFechorSalidaOriginalH(corridaTramo.getFechorsalidaH());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -690,34 +688,33 @@ public class CorridaServiceImpl implements CorridaService {
|
||||||
Calendar horLlegada = null;
|
Calendar horLlegada = null;
|
||||||
// Si los tiempos son distintos, hube cambio de huso horario/horario de verano
|
// Si los tiempos son distintos, hube cambio de huso horario/horario de verano
|
||||||
if (tiempoOrigen != tiempoDestino) {
|
if (tiempoOrigen != tiempoDestino) {
|
||||||
long elapsedHoras = DateUtil.getElapsedHoras(corridaTramo.getFechorsalida(),corridaTramo.getFechorllegada());
|
long elapsedMinutes = DateUtil.getElapsedMinutos(corridaTramo.getFechorsalida(), corridaTramo.getFechorllegada());
|
||||||
|
|
||||||
horLlegada = Calendar.getInstance();
|
horLlegada = Calendar.getInstance();
|
||||||
horLlegada.setTime(corridaTramo.getFechorsalidaH());
|
horLlegada.setTime(corridaTramo.getFechorsalidaH());
|
||||||
|
|
||||||
horLlegada.add(Calendar.HOUR, (int)elapsedHoras);
|
horLlegada.add(Calendar.MINUTE, (int) elapsedMinutes);
|
||||||
horLlegada.add(Calendar.HOUR, difHuso(tiempoOrigen,tiempoDestino));
|
horLlegada.add(Calendar.HOUR, difHuso(tiempoOrigen, tiempoDestino));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (horLlegada == null) ? null : horLlegada.getTime();
|
return (horLlegada == null) ? null : horLlegada.getTime();
|
||||||
}
|
}
|
||||||
private int difHuso(int a,int b){
|
|
||||||
int mult=0;
|
|
||||||
|
|
||||||
if ( (a < b) && (b<=0) ){
|
private int difHuso(int a, int b) {
|
||||||
|
int mult = 0;
|
||||||
|
|
||||||
|
if ((a < b) && (b <= 0)) {
|
||||||
mult = -1;
|
mult = -1;
|
||||||
}else if ( (a<b) && (a>=0) ){
|
} else if ((a < b) && (a >= 0)) {
|
||||||
mult = -1;
|
mult = -1;
|
||||||
}else if (a> b){
|
} else if (a > b) {
|
||||||
mult = -1;
|
mult = -1;
|
||||||
}else{
|
} else {
|
||||||
mult = 1;
|
mult = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ((Math.abs(a) - Math.abs(b)) * mult);
|
||||||
|
|
||||||
return ((Math.abs(a)-Math.abs(b)) * mult);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generarCorrida(Date dataGeracao, List<EsquemaCorrida> lsEsquemaCorrida) {
|
private void generarCorrida(Date dataGeracao, List<EsquemaCorrida> lsEsquemaCorrida) {
|
||||||
|
@ -1123,7 +1120,7 @@ public class CorridaServiceImpl implements CorridaService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean atualizarCorridaFecHusoFecVerano(Estado estado, Date dataInicial) {
|
public Boolean atualizarCorridaFecHusoFecVerano(Estado estado, Date dataInicial, Integer corridaId) {
|
||||||
try {
|
try {
|
||||||
List<Corrida> corridas = corridaDAO.buscarPorEstado(estado, dataInicial);
|
List<Corrida> corridas = corridaDAO.buscarPorEstado(estado, dataInicial);
|
||||||
corridaDAO.actualizaFecHusoFecVerano(corridas);
|
corridaDAO.actualizaFecHusoFecVerano(corridas);
|
||||||
|
@ -1135,4 +1132,9 @@ public class CorridaServiceImpl implements CorridaService {
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean atualizarCorridaFecHusoFecVerano(Estado estado, Date dataInicial) {
|
||||||
|
return atualizarCorridaFecHusoFecVerano(estado, dataInicial, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue