Merge pull request 'AL-2734' (!87) from AL-2734 into master
Reviewed-on: http://18.235.188.113:3000/adm/ModelWeb/pulls/87 Reviewed-by: Gleison da Cruz <gleison.cruz@totvs.com.br>master
commit
06d4dbec9f
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.8.0</version>
|
||||
<version>1.8.1</version>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>rj-releases</id>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.Boleto;
|
||||
|
@ -22,5 +23,6 @@ public interface BoletoDAO extends GenericDAO<Boleto, Long> {
|
|||
public String getSequenciaBoletoId();
|
||||
public String getSequenciaNumOperacion();
|
||||
public String getSequenciaNumReservacion();
|
||||
void insertBoletoRserva(Boleto miBoletoTemporal);
|
||||
void insertBoletoReserva(Boleto miBoletoTemporal);
|
||||
public boolean isExisteBoletoPorCorrida(Integer corridaId, Date fecCorrida);
|
||||
}
|
||||
|
|
|
@ -109,5 +109,7 @@ public interface CorridaDAO extends GenericDAO<Corrida, Corrida.Id> {
|
|||
public Integer buscarOcupacaoCorrida(Corrida corrida);
|
||||
|
||||
public List<Corrida> buscarCorridas(Parada ori, Parada des, Date dataInicio, Date dataFinal, ClaseServicio cs,
|
||||
Ruta linha, Empresa empresa);
|
||||
Ruta linha, Empresa empresa);
|
||||
|
||||
public Corrida buscarCorridaAtivaPorId(Id id);
|
||||
}
|
|
@ -41,4 +41,5 @@ public interface PuntoVentaDAO extends GenericDAO<PuntoVenta, Integer> {
|
|||
|
||||
public List<PuntoVenta> buscaPuntoVentaEmpresa(Empresa empresa);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,9 +4,13 @@
|
|||
*/
|
||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.SQLQuery;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.criterion.Order;
|
||||
|
@ -20,6 +24,9 @@ import org.springframework.stereotype.Repository;
|
|||
|
||||
import com.rjconsultores.ventaboletos.dao.BoletoDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.Boleto;
|
||||
import com.rjconsultores.ventaboletos.utilerias.ActivoUtil;
|
||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||
import com.rjconsultores.ventaboletos.utilerias.MoneyHelper;
|
||||
import com.rjconsultores.ventaboletos.vo.embarcada.PtoVtaUsuarioUltimaVendaDispositivoVO;
|
||||
|
||||
/**
|
||||
|
@ -28,7 +35,7 @@ import com.rjconsultores.ventaboletos.vo.embarcada.PtoVtaUsuarioUltimaVendaDispo
|
|||
*/
|
||||
@Repository("boletoDAO")
|
||||
public class BoletoHibernateDAO extends GenericHibernateDAO<Boleto, Long> implements BoletoDAO {
|
||||
|
||||
private static Logger log = Logger.getLogger(BoletoHibernateDAO.class);
|
||||
@Autowired
|
||||
public BoletoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||
setSessionFactory(factory);
|
||||
|
@ -65,6 +72,27 @@ public class BoletoHibernateDAO extends GenericHibernateDAO<Boleto, Long> implem
|
|||
return (Boleto) c.uniqueResult();
|
||||
}
|
||||
|
||||
public boolean isExisteBoletoPorCorrida(Integer corridaId, Date fecCorrida) {
|
||||
try {
|
||||
|
||||
StringBuilder hql = new StringBuilder();
|
||||
hql.append(" select ");
|
||||
hql.append(" count(*) from boleto b where " );
|
||||
hql.append(" b.corrida_id = :corridaId and b.feccorrida = :feccorrida and ROWNUM = 1 and b.activo = :isActivo");
|
||||
Query query = getSession().createSQLQuery(hql.toString());
|
||||
query.setInteger("isActivo", ActivoUtil.ATIVO);
|
||||
query.setDate("feccorrida", fecCorrida);
|
||||
query.setInteger("corridaId", corridaId);
|
||||
|
||||
BigDecimal qtde = (BigDecimal) query.uniqueResult();
|
||||
return qtde !=null && MoneyHelper.isMaior(qtde, BigDecimal.ZERO) ;
|
||||
}catch(Exception e) {
|
||||
log.error("Erro buscar Bole to por corrida para corrida=" + corridaId + "data:" + DateUtil.getStringDate(fecCorrida), e);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getSequenciaBoletoId(){
|
||||
String sql = "SELECT BOLETO_SEQ.nextval FROM DUAL";
|
||||
Object o = this.getSession().createSQLQuery(sql).uniqueResult();
|
||||
|
@ -84,7 +112,7 @@ public class BoletoHibernateDAO extends GenericHibernateDAO<Boleto, Long> implem
|
|||
}
|
||||
|
||||
@Override
|
||||
public void insertBoletoRserva(Boleto miBoletoTemporal){
|
||||
public void insertBoletoReserva(Boleto miBoletoTemporal){
|
||||
SQLQuery query = getSession().createSQLQuery(getSqlInsertBoletoRserva());
|
||||
|
||||
query.setLong("boletoId", miBoletoTemporal.getBoletoId());
|
||||
|
@ -130,7 +158,7 @@ public class BoletoHibernateDAO extends GenericHibernateDAO<Boleto, Long> implem
|
|||
query.setBigDecimal("preciopagado", miBoletoTemporal.getPreciopagado());
|
||||
query.setBigDecimal("preciobase", miBoletoTemporal.getPreciobase());
|
||||
query.setInteger("ptovtaventaId", miBoletoTemporal.getPtovtaventaId());
|
||||
query.setInteger("puntoventaId", miBoletoTemporal.getPuntoVenta().getPuntoventaId());
|
||||
query.setInteger("puntoventaId", miBoletoTemporal.getPuntoVentaId());
|
||||
query.setInteger("rutaId", miBoletoTemporal.getRutaId());
|
||||
query.setInteger("temporeservafidelidade", miBoletoTemporal.getTemporeservafidelidade());
|
||||
query.setInteger("tipoventaId", miBoletoTemporal.getTipoventaId());
|
||||
|
|
|
@ -819,6 +819,30 @@ public class CorridaHibernateDAO extends GenericHibernateDAO<Corrida, Corrida.Id
|
|||
query.setMaxResults(1);
|
||||
return (Corrida)query.uniqueResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Corrida buscarCorridaAtivaPorId(Id id) {
|
||||
|
||||
StringBuilder hql = new StringBuilder();
|
||||
|
||||
hql.append(" from Corrida corrida ");
|
||||
hql.append(" where corrida.id.feccorrida = :feccorrida ");
|
||||
hql.append(" and corrida.id.corridaId = :corridaId )");
|
||||
hql.append(" and corrida.activo = 1 )");
|
||||
|
||||
Query query = getSession().createQuery(hql.toString());
|
||||
query.setDate("feccorrida", id.getFeccorrida());
|
||||
query.setInteger("corridaId", id.getCorridaId());
|
||||
|
||||
query.setMaxResults(1);
|
||||
return (Corrida)query.uniqueResult();
|
||||
}
|
||||
|
||||
private List<Corrida> buscaCorridaFutura(){
|
||||
List<Corrida> corridaList = new ArrayList<Corrida>();
|
||||
|
||||
return corridaList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Corrida> buscarCorridaRelAproveitamento(Parada origem, Parada destino,
|
||||
|
|
|
@ -290,5 +290,6 @@ public class PuntoVentaHibernateDAO extends GenericHibernateDAO<PuntoVenta, Inte
|
|||
|
||||
return qr.list();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -47,9 +47,8 @@ public class Boleto implements java.io.Serializable {
|
|||
@Column(name = "DESTINO_ID", precision = 7, scale = 0)
|
||||
private Integer destinoId;
|
||||
|
||||
@JoinColumn(name = "PUNTOVENTA_ID", referencedColumnName = "PUNTOVENTA_ID")
|
||||
@ManyToOne
|
||||
private PuntoVenta puntoVenta;
|
||||
@Column(name = "PUNTOVENTA_ID")
|
||||
private Integer puntoVentaId;
|
||||
|
||||
@Column(name = "CORRIDA_ID", precision = 7, scale = 0)
|
||||
private Integer corridaId;
|
||||
|
@ -338,7 +337,7 @@ public class Boleto implements java.io.Serializable {
|
|||
}
|
||||
|
||||
public Boleto(long boletoId, String numasiento, Integer categoriaId, String numfoliosistema, Byte claseservicioId,
|
||||
Short marcaId, Integer origenId, Integer destinoId, PuntoVenta puntoVenta, Integer corridaId,
|
||||
Short marcaId, Integer origenId, Integer destinoId, Integer puntoVentaId, Integer corridaId,
|
||||
Date feccorrida, String nombpasajero, BigDecimal preciobase, BigDecimal preciopagado,
|
||||
BigDecimal descuentoamparado, Byte tipoventaId, String numseriepreimpresa, String numfoliopreimpreso,
|
||||
Date fechorviaje, Date fechorventa, BigDecimal numkmviaje, String numoperacion, String indstatusoperacion,
|
||||
|
@ -367,7 +366,7 @@ public class Boleto implements java.io.Serializable {
|
|||
this.marcaId = marcaId;
|
||||
this.origenId = origenId;
|
||||
this.destinoId = destinoId;
|
||||
this.puntoVenta = puntoVenta;
|
||||
this.puntoVentaId = puntoVentaId;
|
||||
this.corridaId = corridaId;
|
||||
this.feccorrida = feccorrida;
|
||||
this.nombpasajero = nombpasajero;
|
||||
|
@ -521,14 +520,6 @@ public class Boleto implements java.io.Serializable {
|
|||
this.destinoId = destinoId;
|
||||
}
|
||||
|
||||
public PuntoVenta getPuntoVenta() {
|
||||
return puntoVenta;
|
||||
}
|
||||
|
||||
public void setPuntoVenta(PuntoVenta puntoVenta) {
|
||||
this.puntoVenta = puntoVenta;
|
||||
}
|
||||
|
||||
public Integer getCorridaId() {
|
||||
return this.corridaId;
|
||||
}
|
||||
|
@ -1249,4 +1240,12 @@ public class Boleto implements java.io.Serializable {
|
|||
public void setFechorventaH(Date fechorventaH) {
|
||||
this.fechorventaH = fechorventaH;
|
||||
}
|
||||
|
||||
public Integer getPuntoVentaId() {
|
||||
return puntoVentaId;
|
||||
}
|
||||
|
||||
public void setPuntoVentaId(Integer puntoVentaId) {
|
||||
this.puntoVentaId = puntoVentaId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,4 +25,5 @@ public interface BoletoService {
|
|||
String numFidelidade, Integer claseservicioId, Short marcaId, Date fecViaje, Integer empresaCorridaId, String nombPassageiro,
|
||||
BigDecimal valorSeguro, BigDecimal valorTaxaEmbarque, BigDecimal valorPedagio) throws Exception;
|
||||
|
||||
public boolean isExisteBoletoPorCorrida(Integer corridaId, Date fecCorrida);
|
||||
}
|
|
@ -14,6 +14,7 @@ import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
|
|||
import com.rjconsultores.ventaboletos.entidad.Estado;
|
||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||
import com.rjconsultores.ventaboletos.entidad.Corrida.Id;
|
||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||
|
||||
/**
|
||||
|
@ -80,4 +81,10 @@ public interface CorridaService extends GenericService<Corrida, Corrida.Id> {
|
|||
public Boolean existeCorrida(Long id);
|
||||
|
||||
public Integer buscarOcupacaoCorrida(Corrida corrida);
|
||||
|
||||
public Boolean generarCorrida(Date dataGeracao, List<EsquemaCorrida> lsEsquemaCorrida, boolean isGeracaoAutomaticaCorrida);
|
||||
|
||||
public Corrida buscarPorId(Corrida.Id id);
|
||||
|
||||
public Corrida buscarCorridaAtivaPorId(Id id);
|
||||
}
|
||||
|
|
|
@ -48,4 +48,5 @@ public interface PuntoVentaService {
|
|||
public List<PuntoVentaVO> buscaPuntoVentaEmpresaSemECF(Empresa empresa);
|
||||
|
||||
List<PuntoVenta> buscarPuntoVentaPtoVtaComissao(List<Empresa> empresas);
|
||||
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ public class BoletoServiceImpl implements BoletoService {
|
|||
miBoletoTemporal.setOrigenId(unoTerminalOrigenId);
|
||||
miBoletoTemporal.setPreciopricing(BigDecimal.ZERO);
|
||||
miBoletoTemporal.setPorccategoria(null);
|
||||
miBoletoTemporal.setPuntoVenta(miPuntoVenta);
|
||||
miBoletoTemporal.setPuntoVentaId(unPuntoVenta.intValue());
|
||||
miBoletoTemporal.setPtovtaventaId(miPuntoVenta.getPuntoventaId());
|
||||
miBoletoTemporal.setRutaId(rutaId);
|
||||
miBoletoTemporal.setTemporeservafidelidade(tempoReserva!=null ? tempoReserva.intValue() : 0);
|
||||
|
@ -118,7 +118,7 @@ public class BoletoServiceImpl implements BoletoService {
|
|||
miBoletoTemporal.setUsuario(usuario);
|
||||
miBoletoTemporal.setActivo(true);
|
||||
// Cria boleto de reserva
|
||||
boletoDAO.insertBoletoRserva(miBoletoTemporal);
|
||||
boletoDAO.insertBoletoReserva(miBoletoTemporal);
|
||||
|
||||
}
|
||||
|
||||
|
@ -191,6 +191,10 @@ public class BoletoServiceImpl implements BoletoService {
|
|||
return "01" + (String.format("%010d", Integer.valueOf(numReservacopnSeq).intValue()));
|
||||
}
|
||||
|
||||
public boolean isExisteBoletoPorCorrida(Integer corridaId, Date fecCorrida) {
|
||||
return boletoDAO.isExisteBoletoPorCorrida(corridaId, fecCorrida);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -197,13 +197,10 @@ public class CorridaServiceImpl implements CorridaService {
|
|||
return corridaDAO.actualizacion(entidad);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void borrar(Corrida entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(ActivoUtil.ATIVO);
|
||||
|
||||
corridaDAO.actualizacion(entidad);
|
||||
corridaDAO.borrar(entidad);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -915,7 +912,7 @@ public class CorridaServiceImpl implements CorridaService {
|
|||
return b - a;
|
||||
}
|
||||
|
||||
private Boolean generarCorrida(Date dataGeracao, List<EsquemaCorrida> lsEsquemaCorrida, boolean isGeracaoAutomaticaCorrida) {
|
||||
public Boolean generarCorrida(Date dataGeracao, List<EsquemaCorrida> lsEsquemaCorrida, boolean isGeracaoAutomaticaCorrida) {
|
||||
|
||||
DefaultTransactionDefinition def = new DefaultTransactionDefinition(DefaultTransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
||||
|
||||
|
@ -1027,12 +1024,15 @@ public class CorridaServiceImpl implements CorridaService {
|
|||
}
|
||||
|
||||
}
|
||||
} finally {
|
||||
}catch (Exception e) {
|
||||
log.error("Erro ao gerar corrida", e );
|
||||
}
|
||||
finally {
|
||||
if ((status != null) && (!status.isCompleted())) {
|
||||
transactionManager.commit(status);
|
||||
}
|
||||
}
|
||||
//Valida se existe configuração de reserva para o cliente e crria Cria reserva
|
||||
//Valida se existe configuração de reserva para o cliente e cria Cria reserva
|
||||
if(corrida !=null) {
|
||||
if(unUsuarioId!=null && unPuntoVenta!=null && estacionId!=null) {
|
||||
validaCriaReservaCliente(corrida, unUsuarioId, unPuntoVenta, estacionId);
|
||||
|
@ -1715,5 +1715,18 @@ public class CorridaServiceImpl implements CorridaService {
|
|||
public Integer buscarOcupacaoCorrida(Corrida corrida) {
|
||||
return corridaDAO.buscarOcupacaoCorrida(corrida);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Corrida buscarPorId(Id id) {
|
||||
// TODO Auto-generated method stub
|
||||
return corridaDAO.buscarPorId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Corrida buscarCorridaAtivaPorId(Id id) {
|
||||
return corridaDAO.buscarCorridaAtivaPorId(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -188,6 +188,7 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
|
|||
return entidad;
|
||||
}
|
||||
|
||||
|
||||
private void integraAG(PuntoVenta entidad) throws IntegracionException{
|
||||
Connection connection = null;
|
||||
try {
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package com.rjconsultores.ventaboletos.vo.esquemaoperacional;
|
||||
|
||||
public class TarefaGeracaoCorridaVO {
|
||||
|
||||
private String tarefa;
|
||||
private String status;
|
||||
private String codStatus;
|
||||
|
||||
public TarefaGeracaoCorridaVO() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public TarefaGeracaoCorridaVO(String tarefa, String status, String codStatus) {
|
||||
super();
|
||||
this.tarefa = tarefa;
|
||||
this.status = status;
|
||||
this.codStatus = codStatus;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getTarefa() {
|
||||
return tarefa;
|
||||
}
|
||||
|
||||
public void setTarefa(String tarefa) {
|
||||
this.tarefa = tarefa;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getCodStatus() {
|
||||
return codStatus;
|
||||
}
|
||||
|
||||
public void setCodStatus(String codStatus) {
|
||||
this.codStatus = codStatus;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue