git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@24588 d1611594-4594-4d17-8e1d-87c2c4800839
parent
636e7db222
commit
4b38ff1eb8
|
@ -55,6 +55,7 @@ import com.rjconsultores.ventaboletos.service.FeriadoService;
|
||||||
import com.rjconsultores.ventaboletos.service.RutaService;
|
import com.rjconsultores.ventaboletos.service.RutaService;
|
||||||
import com.rjconsultores.ventaboletos.service.TramoServicioService;
|
import com.rjconsultores.ventaboletos.service.TramoServicioService;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.HoraSistema;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -260,13 +261,10 @@ public class CorridaServiceImpl implements CorridaService {
|
||||||
gHoraChegada.setTime(horaChegada);
|
gHoraChegada.setTime(horaChegada);
|
||||||
|
|
||||||
for (TramoServicio ts : lsTramoServicio) {
|
for (TramoServicio ts : lsTramoServicio) {
|
||||||
|
HoraSistema hs = new HoraSistema(ts.getTiemporecorrido());
|
||||||
GregorianCalendar gTiemporecorrido = new GregorianCalendar();
|
|
||||||
gTiemporecorrido.setTime(ts.getTiemporecorrido());
|
gHoraChegada.add(Calendar.HOUR_OF_DAY, hs.getHora());
|
||||||
|
gHoraChegada.add(Calendar.MINUTE, hs.getMinuto());
|
||||||
gHoraChegada.set(Calendar.HOUR_OF_DAY, gHoraChegada.get(Calendar.HOUR_OF_DAY) + gTiemporecorrido.get(Calendar.HOUR_OF_DAY));
|
|
||||||
|
|
||||||
gHoraChegada.set(Calendar.MINUTE, gHoraChegada.get(Calendar.MINUTE) + gTiemporecorrido.get(Calendar.MINUTE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return gHoraChegada.getTime();
|
return gHoraChegada.getTime();
|
||||||
|
@ -285,9 +283,11 @@ public class CorridaServiceImpl implements CorridaService {
|
||||||
log.debug("Tempo Recorrido : " + sdf.format(gHoraSaidaProximo.getTime()));
|
log.debug("Tempo Recorrido : " + sdf.format(gHoraSaidaProximo.getTime()));
|
||||||
|
|
||||||
if (tiempoEstanciaAnterior != null) {
|
if (tiempoEstanciaAnterior != null) {
|
||||||
|
|
||||||
gHoraSaidaProximo.add(Calendar.MINUTE, tiempoEstanciaAnterior.getMinutes());
|
gHoraSaidaProximo.add(Calendar.MINUTE, tiempoEstanciaAnterior.getMinutes());
|
||||||
gHoraSaidaProximo.add(Calendar.HOUR_OF_DAY, tiempoEstanciaAnterior.getHours());
|
gHoraSaidaProximo.add(Calendar.HOUR_OF_DAY, tiempoEstanciaAnterior.getHours());
|
||||||
System.out.println("Tempo Recorrido + Estancia: " + sdf.format(gHoraSaidaProximo.getTime()));
|
|
||||||
|
log.debug("Tempo Recorrido + Estancia: " + sdf.format(gHoraSaidaProximo.getTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
horaSaida = gHoraSaidaProximo.getTime();
|
horaSaida = gHoraSaidaProximo.getTime();
|
||||||
|
|
|
@ -28,7 +28,7 @@ import com.rjconsultores.ventaboletos.service.RutaService;
|
||||||
import com.rjconsultores.ventaboletos.service.TramoRutaService;
|
import com.rjconsultores.ventaboletos.service.TramoRutaService;
|
||||||
import com.rjconsultores.ventaboletos.service.TramoService;
|
import com.rjconsultores.ventaboletos.service.TramoService;
|
||||||
import com.rjconsultores.ventaboletos.service.TramoServicioService;
|
import com.rjconsultores.ventaboletos.service.TramoServicioService;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil.Hora;
|
import com.rjconsultores.ventaboletos.utilerias.HoraSistema;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
import com.rjconsultores.ventaboletos.vo.esquemaoperacional.RutaTramoVO;
|
import com.rjconsultores.ventaboletos.vo.esquemaoperacional.RutaTramoVO;
|
||||||
import com.rjconsultores.ventaboletos.vo.esquemaoperacional.SecuenciaRutaTramoVO;
|
import com.rjconsultores.ventaboletos.vo.esquemaoperacional.SecuenciaRutaTramoVO;
|
||||||
|
@ -259,7 +259,7 @@ public class TramoRutaServiceImpl implements TramoRutaService {
|
||||||
SecuenciaRutaTramoVO secuenciaInicial = lsSecuenciaRutaTramoVO.get(i);
|
SecuenciaRutaTramoVO secuenciaInicial = lsSecuenciaRutaTramoVO.get(i);
|
||||||
Parada origen = secuenciaInicial.getOrigen();
|
Parada origen = secuenciaInicial.getOrigen();
|
||||||
BigDecimal totalKmsReal = secuenciaInicial.getKmReal();
|
BigDecimal totalKmsReal = secuenciaInicial.getKmReal();
|
||||||
Hora totalTiempoRecorrido = secuenciaInicial.getTiempoRecorrido();
|
HoraSistema totalTiempoRecorrido = secuenciaInicial.getTiempoRecorrido();
|
||||||
boolean primeraCombinacion = true;
|
boolean primeraCombinacion = true;
|
||||||
int j = i + 1;
|
int j = i + 1;
|
||||||
for (; j < (qtdTramos); j++) {
|
for (; j < (qtdTramos); j++) {
|
||||||
|
@ -279,7 +279,7 @@ public class TramoRutaServiceImpl implements TramoRutaService {
|
||||||
log.debug("TRAMO EXISTE");
|
log.debug("TRAMO EXISTE");
|
||||||
|
|
||||||
nuevaSecuencia.setKmReal(tramoServicio.getTramo().getKmReal());
|
nuevaSecuencia.setKmReal(tramoServicio.getTramo().getKmReal());
|
||||||
nuevaSecuencia.setTiempoRecorrido(new Hora(tramoServicio.getTiemporecorrido()));
|
nuevaSecuencia.setTiempoRecorrido(new HoraSistema(tramoServicio.getTiemporecorrido()));
|
||||||
nuevaSecuencia.setTramoId(tramoServicio.getTramo().getTramoId());
|
nuevaSecuencia.setTramoId(tramoServicio.getTramo().getTramoId());
|
||||||
nuevaSecuencia.setTramoServicioId(tramoServicio.getTramoservicioId());
|
nuevaSecuencia.setTramoServicioId(tramoServicio.getTramoservicioId());
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ public class TramoRutaServiceImpl implements TramoRutaService {
|
||||||
log.debug("TRAMO EXISTE");
|
log.debug("TRAMO EXISTE");
|
||||||
|
|
||||||
nuevaSecuencia.setKmReal(tramoServicio.getTramo().getKmReal());
|
nuevaSecuencia.setKmReal(tramoServicio.getTramo().getKmReal());
|
||||||
nuevaSecuencia.setTiempoRecorrido(new Hora(tramoServicio.getTiemporecorrido()));
|
nuevaSecuencia.setTiempoRecorrido(new HoraSistema(tramoServicio.getTiemporecorrido()));
|
||||||
nuevaSecuencia.setTramoId(tramoServicio.getTramo().getTramoId());
|
nuevaSecuencia.setTramoId(tramoServicio.getTramo().getTramoId());
|
||||||
nuevaSecuencia.setTramoServicioId(tramoServicio.getTramoservicioId());
|
nuevaSecuencia.setTramoServicioId(tramoServicio.getTramoservicioId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,8 +388,8 @@ public final class DateUtil {
|
||||||
* @param dtFim
|
* @param dtFim
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Hora getHorasMinutosByInicio(Date dtFim) {
|
public static HoraSistema getHorasMinutosByInicio(Date dtFim) {
|
||||||
return new Hora(dtFim);
|
return new HoraSistema(dtFim);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -503,77 +503,4 @@ public final class DateUtil {
|
||||||
|
|
||||||
return gcalendar.getTime();
|
return gcalendar.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Hora {
|
|
||||||
private Integer hora;
|
|
||||||
private Integer minuto;
|
|
||||||
|
|
||||||
public Hora() {
|
|
||||||
this.hora = 0;
|
|
||||||
this.minuto = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Hora(Date fecha) {
|
|
||||||
conf(fecha);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void conf(Date fecha) {
|
|
||||||
Long tempo = DateUtil.getElapsedMinutos(DateUtil.getFecInicio().getTime(), fecha);
|
|
||||||
|
|
||||||
long minutos = (tempo % 60);
|
|
||||||
int horas = (tempo.intValue() / 60);
|
|
||||||
|
|
||||||
hora = horas;
|
|
||||||
minuto = (int) minutos;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
|
|
||||||
return (hora + ":" + ((String.valueOf(minuto).length() < 2) ? "0" + minuto : minuto));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getHora() {
|
|
||||||
return hora;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getMinuto() {
|
|
||||||
return minuto;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMinuto(Integer minuto) {
|
|
||||||
this.minuto = minuto;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHora(Integer hora) {
|
|
||||||
this.hora = hora;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getFecha() {
|
|
||||||
Calendar c = getFecInicio();
|
|
||||||
c.add(Calendar.HOUR_OF_DAY, hora);
|
|
||||||
c.add(Calendar.MINUTE, minuto);
|
|
||||||
|
|
||||||
return c.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Hora sumar(Hora horaAdicao) {
|
|
||||||
Calendar horaAtual = Calendar.getInstance();
|
|
||||||
horaAtual.setTime(getFecha());
|
|
||||||
|
|
||||||
Calendar horaSomar = Calendar.getInstance();
|
|
||||||
horaSomar.setTime(horaAdicao.getFecha());
|
|
||||||
|
|
||||||
int horaTotal = horaAtual.get(Calendar.HOUR_OF_DAY) + horaSomar.get(Calendar.HOUR_OF_DAY);
|
|
||||||
int minutoTotal = horaAtual.get(Calendar.MINUTE) + horaSomar.get(Calendar.MINUTE);
|
|
||||||
|
|
||||||
Calendar fecInicio = getFecInicio();
|
|
||||||
fecInicio.add(Calendar.HOUR_OF_DAY, horaTotal);
|
|
||||||
fecInicio.add(Calendar.MINUTE, minutoTotal);
|
|
||||||
|
|
||||||
return new Hora(fecInicio.getTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
package com.rjconsultores.ventaboletos.utilerias;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classe criada para realizar operações sobre a hora inicial do sistema.<br/>
|
||||||
|
*
|
||||||
|
* A hora inicial do sistema pode ser obtida pelo método DateUtil.getFecInicio() e retorna : YEAR, 1970; DAY_OF_MONTH, 1; MONTH, 0; HOUR_OF_DAY, 0;MINUTE, 0; <br/>
|
||||||
|
* MILLISECOND, 0; SECOND, 0. <br/>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Assim é possível armazenar e somar tempos como 24:30 + 36:00 = 60 horas e 30 minutos
|
||||||
|
*
|
||||||
|
* @author gleimar
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class HoraSistema {
|
||||||
|
private Integer hora;
|
||||||
|
private Integer minuto;
|
||||||
|
|
||||||
|
public HoraSistema() {
|
||||||
|
this.hora = 0;
|
||||||
|
this.minuto = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HoraSistema(Date fecha) {
|
||||||
|
conf(fecha);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void conf(Date fecha) {
|
||||||
|
Long tempo = DateUtil.getElapsedMinutos(DateUtil.getFecInicio().getTime(), fecha);
|
||||||
|
|
||||||
|
long minutos = (tempo % 60);
|
||||||
|
int horas = (tempo.intValue() / 60);
|
||||||
|
|
||||||
|
hora = horas;
|
||||||
|
minuto = (int) minutos;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
|
||||||
|
return (hora + ":" + ((String.valueOf(minuto).length() < 2) ? "0" + minuto : minuto));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getHora() {
|
||||||
|
return hora;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getMinuto() {
|
||||||
|
return minuto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinuto(Integer minuto) {
|
||||||
|
this.minuto = minuto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHora(Integer hora) {
|
||||||
|
this.hora = hora;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getFecha() {
|
||||||
|
Calendar c = DateUtil.getFecInicio();
|
||||||
|
c.add(Calendar.HOUR_OF_DAY, hora);
|
||||||
|
c.add(Calendar.MINUTE, minuto);
|
||||||
|
|
||||||
|
return c.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Realiza a soma da hora/minuto atual com o informado no parametro
|
||||||
|
*
|
||||||
|
* @param horaAdicao
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public HoraSistema sumar(HoraSistema horaAdicao) {
|
||||||
|
Calendar horaAtual = Calendar.getInstance();
|
||||||
|
horaAtual.setTime(getFecha());
|
||||||
|
|
||||||
|
Calendar horaSomar = Calendar.getInstance();
|
||||||
|
horaSomar.setTime(horaAdicao.getFecha());
|
||||||
|
|
||||||
|
int horaTotal = horaAtual.get(Calendar.HOUR_OF_DAY) + horaSomar.get(Calendar.HOUR_OF_DAY);
|
||||||
|
int minutoTotal = horaAtual.get(Calendar.MINUTE) + horaSomar.get(Calendar.MINUTE);
|
||||||
|
|
||||||
|
int cantDiasAtual = DateUtil.getElapsedDias(DateUtil.getFecInicio().getTime(), horaAtual.getTime());
|
||||||
|
int cantDiasSumar = DateUtil.getElapsedDias(DateUtil.getFecInicio().getTime(), horaSomar.getTime());
|
||||||
|
|
||||||
|
Calendar fecInicio = DateUtil.getFecInicio();
|
||||||
|
fecInicio.add(Calendar.HOUR_OF_DAY, horaTotal);
|
||||||
|
fecInicio.add(Calendar.MINUTE, minutoTotal);
|
||||||
|
|
||||||
|
fecInicio.add(Calendar.DATE, cantDiasAtual);
|
||||||
|
fecInicio.add(Calendar.DATE, cantDiasSumar);
|
||||||
|
|
||||||
|
return new HoraSistema(fecInicio.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ import java.math.BigDecimal;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Via;
|
import com.rjconsultores.ventaboletos.entidad.Via;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil.Hora;
|
import com.rjconsultores.ventaboletos.utilerias.HoraSistema;
|
||||||
|
|
||||||
public class SecuenciaRutaTramoVO {
|
public class SecuenciaRutaTramoVO {
|
||||||
|
|
||||||
|
@ -13,12 +13,12 @@ public class SecuenciaRutaTramoVO {
|
||||||
private Via via;
|
private Via via;
|
||||||
private Integer secuencia;
|
private Integer secuencia;
|
||||||
private BigDecimal kmReal;
|
private BigDecimal kmReal;
|
||||||
private Hora tiempoRecorrido;
|
private HoraSistema tiempoRecorrido;
|
||||||
private Integer tramoId;
|
private Integer tramoId;
|
||||||
private Integer tramoServicioId;
|
private Integer tramoServicioId;
|
||||||
|
|
||||||
public SecuenciaRutaTramoVO(Parada origen, Parada destino, Via via, Integer secuencia, BigDecimal kmReal,
|
public SecuenciaRutaTramoVO(Parada origen, Parada destino, Via via, Integer secuencia, BigDecimal kmReal,
|
||||||
Hora tiempoRecorrido) {
|
HoraSistema tiempoRecorrido) {
|
||||||
super();
|
super();
|
||||||
this.origen = origen;
|
this.origen = origen;
|
||||||
this.destino = destino;
|
this.destino = destino;
|
||||||
|
@ -38,7 +38,7 @@ public class SecuenciaRutaTramoVO {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SecuenciaRutaTramoVO(Parada origen, Parada destino, Via via, Integer secuencia, BigDecimal kmReal,
|
public SecuenciaRutaTramoVO(Parada origen, Parada destino, Via via, Integer secuencia, BigDecimal kmReal,
|
||||||
Hora tiempoRecorrido, Integer tramoId, Integer tramoServicioId) {
|
HoraSistema tiempoRecorrido, Integer tramoId, Integer tramoServicioId) {
|
||||||
super();
|
super();
|
||||||
this.origen = origen;
|
this.origen = origen;
|
||||||
this.destino = destino;
|
this.destino = destino;
|
||||||
|
@ -62,13 +62,13 @@ public class SecuenciaRutaTramoVO {
|
||||||
return destino;
|
return destino;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hora getTiempoRecorrido() {
|
public HoraSistema getTiempoRecorrido() {
|
||||||
return tiempoRecorrido;
|
return tiempoRecorrido;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTiempoRecorrido(Hora tiempoRecorrido) {
|
public void setTiempoRecorrido(HoraSistema tiempoRecorrido) {
|
||||||
if (tiempoRecorrido == null) {
|
if (tiempoRecorrido == null) {
|
||||||
tiempoRecorrido = new Hora();
|
tiempoRecorrido = new HoraSistema();
|
||||||
}
|
}
|
||||||
this.tiempoRecorrido = tiempoRecorrido;
|
this.tiempoRecorrido = tiempoRecorrido;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public class SecuenciaRutaTramoVO {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
Hora hora = getTiempoRecorrido();
|
HoraSistema hora = getTiempoRecorrido();
|
||||||
|
|
||||||
return secuencia + ";" + origen + ";" + destino + ";" + via + ";" + kmReal + ";"
|
return secuencia + ";" + origen + ";" + destino + ";" + via + ";" + kmReal + ";"
|
||||||
+ ((hora != null) ? hora.getHora() : "-") + ";" + ((hora != null) ? hora.getMinuto() : "-");
|
+ ((hora != null) ? hora.getHora() : "-") + ";" + ((hora != null) ? hora.getMinuto() : "-");
|
||||||
|
|
Loading…
Reference in New Issue