daniel.zauli 2016-03-18 12:18:59 +00:00
parent d6e7f419ed
commit 5d15d6c332
4 changed files with 107 additions and 42 deletions

View File

@ -1,5 +1,8 @@
package com.rjconsultores.ventaboletos.dao;
import java.util.List;
import com.rjconsultores.ventaboletos.entidad.Ruta;
import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
import com.rjconsultores.ventaboletos.service.TarifaOficialService;
@ -45,7 +48,7 @@ public interface TarifaOficialDAO extends GenericDAO<TarifaOficial, Integer>{
* @param orgaoConcedenteId TODO
* @param empresaId TODO
*/
public void atualizarTaxaEmbarque(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId, Integer empresaId);
public void atualizarTaxaEmbarque(List<Ruta> lsRuta, Integer usuarioId, Integer orgaoConcedenteId, Integer empresaId);
/**
* See {@link TarifaOficialService#atualizarSeguroPorKm(Integer, Integer, Integer)}

View File

@ -16,6 +16,7 @@ import org.springframework.stereotype.Repository;
import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO;
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
import com.rjconsultores.ventaboletos.entidad.Ruta;
import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
@ -136,19 +137,35 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
}
@Override
public void atualizarTaxaEmbarque(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId, Integer empresaId) {
public void atualizarTaxaEmbarque(List<Ruta> lsRuta, Integer usuarioId, Integer orgaoConcedenteId, Integer empresaId) {
// Atualizo a taxa de embarque de acordo a parada e km
SQLQuery query = getSession().createSQLQuery(sqlBuilder.getAtualizarTaxaEmbarquePorKmParada(rutaId, usuarioId, orgaoConcedenteId, empresaId));
query.executeUpdate();
// Atualizo a taxa de embarque de acordo a km do orgao
query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTaxaEmbarquePorKmOrgao(rutaId, usuarioId, orgaoConcedenteId, empresaId));
query.executeUpdate();
int x = 0;
// Atualizo a taxa de embarque de acordo a parada e valor fixo
query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTaxaEmbarquePorParadaFixo(rutaId, usuarioId, orgaoConcedenteId, empresaId));
query.executeUpdate();
if(lsRuta != null && !lsRuta.isEmpty()){
x=lsRuta.size();
}
do{
Integer rutaId = null ;
if(lsRuta != null && !lsRuta.isEmpty()){
rutaId = lsRuta.get(x-1).getRutaId();
}
// Atualizo a taxa de embarque de acordo a parada e km
SQLQuery query = getSession().createSQLQuery(sqlBuilder.getAtualizarTaxaEmbarquePorKmParada(rutaId, usuarioId, orgaoConcedenteId, empresaId));
query.executeUpdate();
// Atualizo a taxa de embarque de acordo a km do orgao
query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTaxaEmbarquePorKmOrgao(rutaId, usuarioId, orgaoConcedenteId, empresaId));
query.executeUpdate();
// Atualizo a taxa de embarque de acordo a parada e valor fixo
query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTaxaEmbarquePorParadaFixo(rutaId, usuarioId, orgaoConcedenteId, empresaId));
query.executeUpdate();
x--;
}while(x > 0);
}
@Override

View File

@ -1,6 +1,9 @@
package com.rjconsultores.ventaboletos.service;
import java.util.List;
import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO;
import com.rjconsultores.ventaboletos.entidad.Ruta;
import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
import com.rjconsultores.ventaboletos.exception.BusinessException;
@ -56,7 +59,7 @@ public interface TarifaOficialService {
* @param empresaId
* @throws BusinessException
*/
public void gerarAtualizarTarifa(Integer rudaId, Integer orgaoConcedenteId, Integer empresaId) throws BusinessException ;
public void gerarAtualizarTarifa(List<Ruta> lsRuta, Integer orgaoConcedenteId, Integer empresaId) throws BusinessException ;
/**
* Copia a tarifa oficial para a tabela de tarifa de acordo com a vigencia especificada.<br/>
@ -85,7 +88,7 @@ public interface TarifaOficialService {
* @param empresaId - Empresa para ser filtrada
* @throws BusinessException
*/
public void atualizarTaxaEmbarque(Integer rutaId, Integer orgaoConcedenteId,boolean gerarTabelaZerada, Integer empresaId) throws BusinessException;
public void atualizarTaxaEmbarque(List<Ruta> lsRuta, Integer orgaoConcedenteId,boolean gerarTabelaZerada, Integer empresaId) throws BusinessException;
/**
@ -113,7 +116,7 @@ public interface TarifaOficialService {
* @param orgaoId-Se informado, será filtrado pelo orgão
* @throws BusinessException
*/
public void atualizarSeguro(Integer rutaId, Integer orgaoId) throws BusinessException;
public void atualizarSeguro(List<Ruta> lsRuta, Integer orgaoId) throws BusinessException;
/**
* See {@link TarifaOficialDAO#aplicarArredondamentoTarifa(Integer, Integer)}
@ -127,7 +130,7 @@ public interface TarifaOficialService {
public void borrar(TarifaOficial tarifaOficial);
public void gerarAtualizarTabelaZerada(Integer rudaId, Integer orgaoConcedenteId, Integer empresaId) throws BusinessException ;
public void gerarAtualizarTabelaZerada(List<Ruta> lsRuta, Integer orgaoConcedenteId, Integer empresaId) throws BusinessException ;
public void atualizarPedagio();

View File

@ -14,6 +14,7 @@ import com.rjconsultores.ventaboletos.dao.SeguroKmDAO;
import com.rjconsultores.ventaboletos.dao.SeguroTarifaDAO;
import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO;
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
import com.rjconsultores.ventaboletos.entidad.Ruta;
import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
import com.rjconsultores.ventaboletos.exception.BusinessException;
@ -54,43 +55,72 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
@Override
@Transactional(rollbackFor = BusinessException.class)
public void gerarAtualizarTarifa(Integer rutaId, Integer orgaoConcedenteId, Integer empresaId) throws BusinessException {
log.info("gerarAtualizarTarifa= rudaId:"+rutaId+";orgaoConcedenteId:"+orgaoConcedenteId+";empresaId:"+empresaId);
public void gerarAtualizarTarifa(List<Ruta> lsRuta, Integer orgaoConcedenteId, Integer empresaId) throws BusinessException {
// Limpando a tabela de TARIFA_OFICIAL
tarifaOficialDAO.limparTarifasOficiais();
//Gerando as tarifas pelo coeficiente
if(orgaoConcedenteId ==null || orgaoConcedenteId != OrgaoConcedente.CODIGO_ARTESP){
Integer qtdTarifaCoeficiente = gerarTarifaPorCoeficiente(rutaId, orgaoConcedenteId, empresaId);
log.info("qtdTarifaCoeficiente="+qtdTarifaCoeficiente);
int x = 0;
if(lsRuta != null && !lsRuta.isEmpty()){
x = lsRuta.size();
}
//Gerando as tarifas para ARTESP
if(orgaoConcedenteId ==null || orgaoConcedenteId == OrgaoConcedente.CODIGO_ARTESP ){
Integer qtdTarifaArtesp = tarifaOficialDAO.gerarTarifaArtesp(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId, empresaId);
log.info("qtdTarifaArtesp="+qtdTarifaArtesp);
}
do{
Integer rutaId = null;
if(lsRuta != null && !lsRuta.isEmpty()){
Ruta r = lsRuta.get(x-1);
rutaId = r.getRutaId();
}
log.info("gerarAtualizarTarifa= rudaId:"+rutaId+";orgaoConcedenteId:"+orgaoConcedenteId+";empresaId:"+empresaId);
//Gerando as tarifas pelo coeficiente
if(orgaoConcedenteId ==null || orgaoConcedenteId != OrgaoConcedente.CODIGO_ARTESP){
Integer qtdTarifaCoeficiente = gerarTarifaPorCoeficiente(rutaId, orgaoConcedenteId, empresaId);
log.info("qtdTarifaCoeficiente="+qtdTarifaCoeficiente);
}
//Gerando as tarifas para ARTESP
if(orgaoConcedenteId ==null || orgaoConcedenteId == OrgaoConcedente.CODIGO_ARTESP ){
Integer qtdTarifaArtesp = tarifaOficialDAO.gerarTarifaArtesp(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId, empresaId);
log.info("qtdTarifaArtesp="+qtdTarifaArtesp);
}
x--;
}while(x > 0);
}
@Override
@Transactional(rollbackFor = BusinessException.class)
public void gerarAtualizarTabelaZerada(Integer rutaId, Integer orgaoConcedenteId, Integer empresaId) throws BusinessException {
public void gerarAtualizarTabelaZerada(List<Ruta> lsRuta, Integer orgaoConcedenteId, Integer empresaId) throws BusinessException {
// Limpando a tabela de TARIFA_OFICIAL
tarifaOficialDAO.limparTarifasOficiais();
//Gerando as tarifas
tarifaOficialDAO.gerarTabelaZerada(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId, empresaId);
int x =0;
if(lsRuta != null && !lsRuta.isEmpty()){
x = lsRuta.size();
}
do{
Integer rutaId =null;
if(lsRuta != null && !lsRuta.isEmpty()){
rutaId = lsRuta.get(x-1).getRutaId();
}
//Gerando as tarifas
tarifaOficialDAO.gerarTabelaZerada(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId, empresaId);
x--;
}while(x > 0);
}
@Override
@Transactional(rollbackFor = BusinessException.class)
public void atualizarTaxaEmbarque(Integer rutaId, Integer orgaoConcedenteId,boolean gerarTabelaZerada, Integer empresaId) throws BusinessException{
public void atualizarTaxaEmbarque(List<Ruta> lsRuta, Integer orgaoConcedenteId,boolean gerarTabelaZerada, Integer empresaId) throws BusinessException{
if (gerarTabelaZerada){
gerarAtualizarTabelaZerada(rutaId, orgaoConcedenteId, empresaId);
gerarAtualizarTabelaZerada(lsRuta, orgaoConcedenteId, empresaId);
}
tarifaOficialDAO.atualizarTaxaEmbarque(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId, empresaId);
tarifaOficialDAO.atualizarTaxaEmbarque(lsRuta, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId, empresaId);
}
@Override
@ -109,7 +139,7 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
@Override
@Transactional(rollbackFor = BusinessException.class)
public void atualizarSeguro(Integer rutaId, Integer orgaoId) throws BusinessException {
public void atualizarSeguro(List<Ruta> lsRuta, Integer orgaoId) throws BusinessException {
List<Integer> lsOrgaoId = new ArrayList<Integer>();
@ -119,14 +149,26 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
lsOrgaoId.add(orgaoId);
}
//O seguro por km é preferencial em relação ao por tarifa.
for (Integer orgaoConcedenteId : lsOrgaoId) {
if (seguroKmDAO.existe(orgaoConcedenteId)) {
atualizarSeguroPorKm(rutaId, orgaoConcedenteId);
} else if (seguroTarifaDAO.existe(orgaoConcedenteId)) {
atualizarSeguroPorTarifa(rutaId, orgaoConcedenteId);
}
int x = 0;
if(lsRuta != null && !lsRuta.isEmpty()){
x = lsRuta.size();
}
do{
Integer rutaId = null;
if(lsRuta != null && !lsRuta.isEmpty()){
rutaId = lsRuta.get(x-1).getRutaId();
}
//O seguro por km é preferencial em relação ao por tarifa.
for (Integer orgaoConcedenteId : lsOrgaoId) {
if (seguroKmDAO.existe(orgaoConcedenteId)) {
atualizarSeguroPorKm(rutaId, orgaoConcedenteId);
} else if (seguroTarifaDAO.existe(orgaoConcedenteId)) {
atualizarSeguroPorTarifa(rutaId, orgaoConcedenteId);
}
}
x--;
}while(x > 0);
}
@Override