14685: Tarifa mínima Totalbus
bug#14685 dev:wilian qua:marcelo git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@94702 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
f357f0f860
commit
000002a281
|
@ -99,4 +99,6 @@ public class Constantes {
|
|||
public static final String BPE_ALTERACAO_POLTRONA = "110116";
|
||||
|
||||
public static final String ESTACAO_EMBARCADA = "ESTACAO_EMBARCADA";
|
||||
|
||||
public static final Integer CATEGORIA_NORMAL = 1;
|
||||
}
|
||||
|
|
|
@ -11,4 +11,6 @@ import com.rjconsultores.ventaboletos.entidad.CategoriaDescuento;
|
|||
* @author Administrador
|
||||
*/
|
||||
public interface CategoriaDescuentoDAO extends GenericDAO<CategoriaDescuento, Integer> {
|
||||
|
||||
public CategoriaDescuento pesquisarPorCategoriaEmpresa(Integer categoriaId, Integer empresaId);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import com.rjconsultores.ventaboletos.entidad.OperadorEmbarcada;
|
||||
import com.rjconsultores.ventaboletos.entidad.OperadorEmbarcadaServico;
|
||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||
import com.rjconsultores.ventaboletos.vo.corrida.CorridaVO;
|
||||
|
||||
public interface OperadorEmbarcadaServicoDAO extends GenericDAO<OperadorEmbarcadaServico, Long> {
|
||||
|
@ -12,6 +13,6 @@ public interface OperadorEmbarcadaServicoDAO extends GenericDAO<OperadorEmbarcad
|
|||
public List<OperadorEmbarcadaServico> buscarPorOperador(OperadorEmbarcada operador);
|
||||
// public OperadorEmbarcada buscarOperadorEmbarcadaPorUsuario(Integer idUsuario);
|
||||
|
||||
public List<CorridaVO> getListaCorridaVO(Integer operador, Integer empresa, Date dtIni, Date dtFim);
|
||||
public List<CorridaVO> getListaCorridaVO(Integer operador, Integer empresa, Date dtIni, Date dtFim, PuntoVenta puntoVenta);
|
||||
|
||||
}
|
||||
|
|
|
@ -35,4 +35,16 @@ public class CategoriaDescuentoHibernateDAO
|
|||
|
||||
return c.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CategoriaDescuento pesquisarPorCategoriaEmpresa(Integer categoriaId, Integer empresaId){
|
||||
Criteria c = getSession().createCriteria(getPersistentClass())
|
||||
.createAlias("categoriaCtrl", "ctrl")
|
||||
.createAlias("ctrl.empresa", "e")
|
||||
.add(Restrictions.eq("activo", Boolean.TRUE))
|
||||
.add(Restrictions.eq("e.empresaId", empresaId))
|
||||
.add(Restrictions.eq("categoria.categoriaId", categoriaId));
|
||||
|
||||
return (CategoriaDescuento)c.list().get(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -17,9 +18,17 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.rjconsultores.ventaboletos.constantes.Constantes;
|
||||
import com.rjconsultores.ventaboletos.dao.CategoriaDescuentoDAO;
|
||||
import com.rjconsultores.ventaboletos.dao.MarcaDAO;
|
||||
import com.rjconsultores.ventaboletos.dao.OperadorEmbarcadaServicoDAO;
|
||||
import com.rjconsultores.ventaboletos.dao.util.DBUtil;
|
||||
import com.rjconsultores.ventaboletos.entidad.CategoriaDescuento;
|
||||
import com.rjconsultores.ventaboletos.entidad.Marca;
|
||||
import com.rjconsultores.ventaboletos.entidad.OperadorEmbarcada;
|
||||
import com.rjconsultores.ventaboletos.entidad.OperadorEmbarcadaServico;
|
||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||
import com.rjconsultores.ventaboletos.entidad.TarifaMinima;
|
||||
import com.rjconsultores.ventaboletos.vo.corrida.CorridaVO;
|
||||
import com.rjconsultores.ventaboletos.vo.corrida.TramoSequenciaVO;
|
||||
import com.rjconsultores.ventaboletos.vo.parada.ParadaVO;
|
||||
|
@ -32,6 +41,11 @@ import com.rjconsultores.ventaboletos.vo.via.ViaVO;
|
|||
@Repository("operadorEmbarcadaServicoDAO")
|
||||
public class OperadorEmbarcadaServicoHibernateDAO extends GenericHibernateDAO<OperadorEmbarcadaServico, Long> implements OperadorEmbarcadaServicoDAO {
|
||||
|
||||
@Autowired
|
||||
private CategoriaDescuentoDAO categoriaDescuentoDAO;
|
||||
@Autowired
|
||||
private MarcaDAO marcaDAO;
|
||||
|
||||
@Autowired
|
||||
public OperadorEmbarcadaServicoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||
setSessionFactory(factory);
|
||||
|
@ -47,11 +61,11 @@ public class OperadorEmbarcadaServicoHibernateDAO extends GenericHibernateDAO<Op
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<CorridaVO> getListaCorridaVO(Integer operador, Integer empresa, Date dtIni, Date dtFim) {
|
||||
public List<CorridaVO> getListaCorridaVO(Integer operador, Integer empresa, Date dtIni, Date dtFim, PuntoVenta puntoVenta) {
|
||||
List<CorridaVO> corridas = getCorridas(operador, empresa, dtIni, dtFim);
|
||||
|
||||
for (CorridaVO corrida : corridas) {
|
||||
preencherTramosSequencias(corrida);
|
||||
preencherTramosSequencias(corrida, puntoVenta);
|
||||
preencherSequencias(corrida);
|
||||
}
|
||||
|
||||
|
@ -272,7 +286,7 @@ public class OperadorEmbarcadaServicoHibernateDAO extends GenericHibernateDAO<Op
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void preencherTramosSequencias(CorridaVO corrida) {
|
||||
private void preencherTramosSequencias(CorridaVO corrida, PuntoVenta puntoVenta) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append(" SELECT");
|
||||
|
@ -410,6 +424,11 @@ public class OperadorEmbarcadaServicoHibernateDAO extends GenericHibernateDAO<Op
|
|||
ts.getViaId(),
|
||||
ts.getNomeVia());
|
||||
|
||||
Marca marca = marcaDAO.obtenerID(corrida.getMarcaId().shortValue());
|
||||
CategoriaDescuento catdesc = categoriaDescuentoDAO.pesquisarPorCategoriaEmpresa(Constantes.CATEGORIA_NORMAL, marca.getEmpresa().getEmpresaId());
|
||||
BigDecimal tarifaMinima = obtenerTarifaMinima(corrida.getClaseServicioId(), corrida.getMarcaId(), origem.getParadaId(), destino.getParadaId(),
|
||||
puntoVenta, corrida.getRutaId(), Constantes.CATEGORIA_NORMAL, catdesc.getIndnaoaplicatarifaminima());
|
||||
|
||||
TramoVO tramo = new TramoVO(
|
||||
ts.getTramoId(),
|
||||
ts.getDesctramo(),
|
||||
|
@ -417,7 +436,7 @@ public class OperadorEmbarcadaServicoHibernateDAO extends GenericHibernateDAO<Op
|
|||
destino,
|
||||
via,
|
||||
ts.getSequencia(),
|
||||
ts.getPrecio(),
|
||||
ts.getPrecio().compareTo(tarifaMinima) < 0 ? tarifaMinima : ts.getPrecio(),
|
||||
ts.getImporteTaxaEmbarque(),
|
||||
ts.getImporteSeguro(),
|
||||
ts.getImportePedagio(),
|
||||
|
@ -428,6 +447,77 @@ public class OperadorEmbarcadaServicoHibernateDAO extends GenericHibernateDAO<Op
|
|||
|
||||
corrida.setLsTramoVO(lsTramo);
|
||||
}
|
||||
|
||||
public BigDecimal obtenerTarifaMinima(Integer claseServicioId, Integer marcaId, Integer origenConsultaId,
|
||||
Integer destinoConsultaId, PuntoVenta miPuntoVenta, Integer rutaId, Integer categoriaId, Boolean indnaoaplicatarifaminima) {
|
||||
BigDecimal tarifaMinima = BigDecimal.ZERO;
|
||||
|
||||
/*
|
||||
* Não aplica tarifa minina quando configurado no tipo de passagem
|
||||
* Mantis #10704
|
||||
*/
|
||||
if(indnaoaplicatarifaminima != null && indnaoaplicatarifaminima) {
|
||||
return tarifaMinima;
|
||||
}
|
||||
|
||||
//PuntoVenta miPuntoVenta = PuntoVentaDao.getInstance().findById(puntoVentaId);
|
||||
|
||||
StringBuilder hql = new StringBuilder("select tm from TarifaMinima tm ")
|
||||
.append("left join tm.orgaoConcedente oc ")
|
||||
.append("left join tm.tarifaMinimaCategorias tmc ")
|
||||
.append("left join tm.vigenciaTarifa vige ")
|
||||
.append("left join tm.regionMetropolitana.paradaList ori ")
|
||||
.append("left join tm.regionMetropolitana.paradaList des ")
|
||||
.append("where tm.activo = 1 ").append("and tm.plaza.plazaId in (:plazaId, -1) ")
|
||||
.append("and tm.claseServicio.claseservicioId in (:claseServId, -1) ")
|
||||
.append("and tm.marca.marcaId in (:marcaId, -1) ")
|
||||
.append("and (ori.paradaId in (:origenId, -1) or ori.paradaId is null ) ")
|
||||
.append("and (des.paradaId in (:destinoId,-1) or des.paradaId is null ) ")
|
||||
.append("and (tm.origem.paradaId in (:origenId, -1) or tm.origem.paradaId is null) ")
|
||||
.append("and (tm.destino.paradaId in (:destinoId, -1) or tm.destino.paradaId is null) ");
|
||||
|
||||
if (categoriaId != null) {
|
||||
hql.append("and (tmc is null or tmc.categoria.categoriaId in (:categoriaId, -1)) ");
|
||||
}
|
||||
|
||||
hql.append("and tm.moneda.monedaId = :monedaId ")
|
||||
.append("and (oc is null or oc.orgaoConcedenteId = -1 or oc.orgaoConcedenteId = ")
|
||||
.append("(select distinct r.orgaoConcedente.orgaoConcedenteId from Ruta r")
|
||||
.append(" left join r.rutaCombinacionList rc")
|
||||
.append(" left join rc.tramo tr")
|
||||
.append(" left join tr.lsOrgaoTramo ot")
|
||||
.append(" where rc.ruta.rutaId = :rutaId")
|
||||
.append(" and (tm.coeficienteTarifa.coeficienteId in ")
|
||||
.append(" (ot.coeficienteTarifa1.coeficienteId, ot.coeficienteTarifa2.coeficienteId, ot.coeficienteTarifa3.coeficienteId ) ")
|
||||
.append(" and tr.origem.paradaId = :origenId ")
|
||||
.append(" and tr.destino.paradaId = :destinoId ")
|
||||
.append(" or tm.coeficienteTarifa is null ) )) ")
|
||||
.append(" and " + DBUtil.getInstance().dbSysdate() + " between vige.feciniciovigencia and vige.fecfinvigencia ")
|
||||
|
||||
.append("order by tm.plaza.plazaId desc, tm.origem.paradaId desc, ")
|
||||
.append("tm.destino.paradaId desc, tm.claseServicio.claseservicioId desc, ")
|
||||
.append("tm.marca.marcaId desc");
|
||||
|
||||
Query miQry = getSession().createQuery(hql.toString());
|
||||
miQry.setInteger("plazaId", miPuntoVenta.getColonia().getCiudad().getPlaza().getPlazaId());
|
||||
miQry.setInteger("claseServId", claseServicioId);
|
||||
miQry.setInteger("marcaId", marcaId);
|
||||
miQry.setInteger("origenId", origenConsultaId);
|
||||
miQry.setInteger("destinoId", destinoConsultaId);
|
||||
miQry.setInteger("monedaId", miPuntoVenta.getMoneda().getMonedaId());
|
||||
miQry.setInteger("rutaId", rutaId);
|
||||
|
||||
if (categoriaId != null) {
|
||||
miQry.setInteger("categoriaId", categoriaId);
|
||||
}
|
||||
|
||||
List<TarifaMinima> listTarifaMinima = miQry.list();
|
||||
if (!listTarifaMinima.isEmpty()) {
|
||||
tarifaMinima = listTarifaMinima.get(0).getImportetarifa();
|
||||
}
|
||||
|
||||
return tarifaMinima;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void preencherSequencias(CorridaVO corrida) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
import com.rjconsultores.ventaboletos.entidad.OperadorEmbarcada;
|
||||
import com.rjconsultores.ventaboletos.entidad.OperadorEmbarcadaLinha;
|
||||
import com.rjconsultores.ventaboletos.entidad.OperadorEmbarcadaServico;
|
||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||
import com.rjconsultores.ventaboletos.entidad.PuntoVentaVO;
|
||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||
import com.rjconsultores.ventaboletos.vo.corrida.CorridaVO;
|
||||
|
@ -20,5 +21,5 @@ public interface OperadorEmbarcadaService {
|
|||
|
||||
public PuntoVentaVO getPuntoVentaVO(Integer operador, Integer empresa);
|
||||
|
||||
public List<CorridaVO> getListaCorridaVO(Integer operador, Integer empresa, Date dtIni, Date dtFim);
|
||||
public List<CorridaVO> getListaCorridaVO(Integer operador, Integer empresa, Date dtIni, Date dtFim, PuntoVenta puntoVenta);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.rjconsultores.ventaboletos.dao.OperadorEmbarcadaServicoDAO;
|
|||
import com.rjconsultores.ventaboletos.entidad.OperadorEmbarcada;
|
||||
import com.rjconsultores.ventaboletos.entidad.OperadorEmbarcadaLinha;
|
||||
import com.rjconsultores.ventaboletos.entidad.OperadorEmbarcadaServico;
|
||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||
import com.rjconsultores.ventaboletos.entidad.PuntoVentaVO;
|
||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||
import com.rjconsultores.ventaboletos.service.OperadorEmbarcadaService;
|
||||
|
@ -78,8 +79,8 @@ public class OperadorEmbarcadaServiceImpl implements OperadorEmbarcadaService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<CorridaVO> getListaCorridaVO(Integer operador, Integer empresa, Date dtIni, Date dtFim) {
|
||||
return opServicoDAO.getListaCorridaVO(operador, empresa, dtIni, dtFim);
|
||||
public List<CorridaVO> getListaCorridaVO(Integer operador, Integer empresa, Date dtIni, Date dtFim, PuntoVenta puntoVenta) {
|
||||
return opServicoDAO.getListaCorridaVO(operador, empresa, dtIni, dtFim, puntoVenta);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue