daniel.zauli 2016-04-19 19:07:15 +00:00
parent c511498e96
commit b6bdb79e57
10 changed files with 115 additions and 58 deletions

View File

@ -16,11 +16,11 @@ public interface TarifaOficialDAO extends GenericDAO<TarifaOficial, Integer>{
* @param orgaoConcedenteId TODO
* @return TODO
*/
public Integer gerarTarifaPorCoeficiente(Integer ruta, Integer usuarioId, Integer orgaoConcedenteId, Integer empresaId);
public Integer gerarTarifaPorCoeficiente(Integer ruta, Integer usuarioId, Integer orgaoConcedenteId, List<Integer> idsEmpresas);
public Integer gerarTarifaArtesp(Integer ruta, Integer usuarioId, Integer orgaoConcedenteId, Integer empresaId);
public Integer gerarTarifaArtesp(Integer ruta, Integer usuarioId, Integer orgaoConcedenteId, List<Integer> idsEmpresas);
public Integer gerarTabelaZerada(Integer ruta, Integer usuarioId, Integer orgaoConcedenteId, Integer empresaId);
public Integer gerarTabelaZerada(Integer ruta, Integer usuarioId, Integer orgaoConcedenteId, List<Integer> idsEmpresas);
/**
* See {@link TarifaOficialService#atualizarTarifaPorCoeficiente(Integer, Integer)}
@ -48,7 +48,7 @@ public interface TarifaOficialDAO extends GenericDAO<TarifaOficial, Integer>{
* @param orgaoConcedenteId TODO
* @param empresaId TODO
*/
public void atualizarTaxaEmbarque(List<Ruta> lsRuta, Integer usuarioId, Integer orgaoConcedenteId, Integer empresaId);
public void atualizarTaxaEmbarque(List<Ruta> lsRuta, Integer usuarioId, Integer orgaoConcedenteId, List<Integer> idsEmpresas);
/**
* See {@link TarifaOficialService#atualizarSeguroPorKm(Integer, Integer, Integer)}

View File

@ -51,9 +51,9 @@ public class EsquemaCorridaHibernateDAO extends GenericHibernateDAO<EsquemaCorri
public List<EsquemaCorrida> buscarPorEmpresaCorrida(Empresa empresa){
StringBuilder sb = new StringBuilder();
sb.append("select * from Esquema_Corrida where empresacorrida_id = :empresaId and activo = 1" );
sb.append("from EsquemaCorrida ec where ec.empresa.empresaId= :empresaId and activo = 1" );
Query qry = getSession().createSQLQuery(sb.toString());
Query qry = getSession().createQuery(sb.toString());
qry.setInteger("empresaId", empresa.getEmpresaId());
return qry.list();

View File

@ -34,9 +34,9 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
}
@Override
public Integer gerarTarifaPorCoeficiente(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId, Integer emrpesaId) {
public Integer gerarTarifaPorCoeficiente(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId, List<Integer> idsEmpresas) {
String sql = sqlBuilder.getSQLGerarTarifaOficial(rutaId, usuarioId, orgaoConcedenteId, emrpesaId);
String sql = sqlBuilder.getSQLGerarTarifaOficial(rutaId, usuarioId, orgaoConcedenteId, idsEmpresas);
int qtd = getSession().createSQLQuery(sql).executeUpdate();
@ -44,9 +44,9 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
}
@Override
public Integer gerarTarifaArtesp(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId, Integer emrpesaId) {
public Integer gerarTarifaArtesp(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId, List<Integer> idsEmpresas) {
String sql = sqlBuilder.getSQLGerarTarifaOficialArtesp(rutaId, usuarioId, orgaoConcedenteId, emrpesaId);
String sql = sqlBuilder.getSQLGerarTarifaOficialArtesp(rutaId, usuarioId, orgaoConcedenteId, idsEmpresas);
int qtd = getSession().createSQLQuery(sql).executeUpdate();
@ -54,9 +54,9 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
}
@Override
public Integer gerarTabelaZerada(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId, Integer emrpesaId) {
public Integer gerarTabelaZerada(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId, List<Integer> idsEmpresas) {
String sql = sqlBuilder.getSQLGerarTabelaZerada(rutaId, usuarioId, orgaoConcedenteId, emrpesaId);
String sql = sqlBuilder.getSQLGerarTabelaZerada(rutaId, usuarioId, orgaoConcedenteId, idsEmpresas);
int qtd = getSession().createSQLQuery(sql).executeUpdate();
@ -135,7 +135,7 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
}
@Override
public void atualizarTaxaEmbarque(List<Ruta> lsRuta, Integer usuarioId, Integer orgaoConcedenteId, Integer empresaId) {
public void atualizarTaxaEmbarque(List<Ruta> lsRuta, Integer usuarioId, Integer orgaoConcedenteId, List<Integer> idsEmpresas) {
int x = 0;
@ -152,15 +152,15 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
}
// Atualizo a taxa de embarque de acordo a parada e km
SQLQuery query = getSession().createSQLQuery(sqlBuilder.getAtualizarTaxaEmbarquePorKmParada(rutaId, usuarioId, orgaoConcedenteId, empresaId));
SQLQuery query = getSession().createSQLQuery(sqlBuilder.getAtualizarTaxaEmbarquePorKmParada(rutaId, usuarioId, orgaoConcedenteId, idsEmpresas));
query.executeUpdate();
// Atualizo a taxa de embarque de acordo a km do orgao
query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTaxaEmbarquePorKmOrgao(rutaId, usuarioId, orgaoConcedenteId, empresaId));
query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTaxaEmbarquePorKmOrgao(rutaId, usuarioId, orgaoConcedenteId, idsEmpresas));
query.executeUpdate();
// Atualizo a taxa de embarque de acordo a parada e valor fixo
query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTaxaEmbarquePorParadaFixo(rutaId, usuarioId, orgaoConcedenteId, empresaId));
query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTaxaEmbarquePorParadaFixo(rutaId, usuarioId, orgaoConcedenteId, idsEmpresas));
query.executeUpdate();
x--;
}while(x > 0);

View File

@ -18,20 +18,20 @@ import com.rjconsultores.ventaboletos.vo.caja.CajaVO;
*/
public interface SQLBuilder {
public String getSQLGerarTarifaOficial(Integer codRuta, Integer usuarioId, Integer orgaoConcedenteId, Integer empresaId);
public String getSQLGerarTarifaOficial(Integer codRuta, Integer usuarioId, Integer orgaoConcedenteId, List<Integer> idsEmpresas);
public String getSQLGerarTabelaZerada(Integer codRuta, Integer usuarioId, Integer orgaoConcedenteId, Integer empresaId);
public String getSQLGerarTabelaZerada(Integer codRuta, Integer usuarioId, Integer orgaoConcedenteId, List<Integer> idsEmpresas);
public String getSQLAtualizarTarifaOficial(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId);
public String getSQLGerarTarifaOficialArtesp( Integer codRuta, Integer usuarioId,
Integer orgaoConcedenteId, Integer empresaId);
Integer orgaoConcedenteId, List<Integer> idsEmpresas);
public String getAtualizarTaxaEmbarquePorKmParada(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId, Integer empresaId);
public String getAtualizarTaxaEmbarquePorKmParada(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId, List<Integer> idsEmpresas);
public String getSQLAtualizarTaxaEmbarquePorKmOrgao(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId, Integer empresaId);
public String getSQLAtualizarTaxaEmbarquePorKmOrgao(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId, List<Integer> idsEmpresas);
public String getSQLAtualizarTaxaEmbarquePorParadaFixo(Integer rutaId, Integer usuarioId,Integer orgaoConcedenteId, Integer empresaId);
public String getSQLAtualizarTaxaEmbarquePorParadaFixo(Integer rutaId, Integer usuarioId,Integer orgaoConcedenteId, List<Integer> idsEmpresas);
public String getSQLAtualizarSeguroPorKm(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId);

View File

@ -2,6 +2,7 @@ package com.rjconsultores.ventaboletos.dao.sqlbuilder.impl;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
import com.rjconsultores.ventaboletos.dao.util.DBUtil;
@ -13,7 +14,7 @@ public class SQLBuilderOracle implements SQLBuilder {
private static final String RED_PAGO_FORMA_PAGO = "CR";
@Override
public String getSQLGerarTabelaZerada(final Integer codRuta, final Integer usuarioId,final Integer orgaoConcedenteId, final Integer empresaId){
public String getSQLGerarTabelaZerada(final Integer codRuta, final Integer usuarioId,final Integer orgaoConcedenteId, final List<Integer> idsEmpresas){
StringBuilder sb = new StringBuilder();
sb.append("INSERT ");
@ -90,8 +91,8 @@ public class SQLBuilderOracle implements SQLBuilder {
sb.append(" and mc.marca_id <> -1 ");
sb.append(" and mc.activo = 1 ");
sb.append(" and re.activo = 1 ");
if (empresaId != null) {
sb.append(" and re.empresa_id = ").append(empresaId);
if (idsEmpresas != null) {
sb.append(" and re.empresa_id in ( ").append(idsEmpresas.toString().substring(1, idsEmpresas.toString().length()-1)).append(" ) ");
}
sb.append(" and m.moneda_id = 1 ");
if (orgaoConcedenteId != null) {
@ -112,7 +113,7 @@ public class SQLBuilderOracle implements SQLBuilder {
@Override
public String getSQLGerarTarifaOficialArtesp(final Integer codRuta, final Integer usuarioId,
final Integer orgaoConcedenteId, final Integer empresaId)
final Integer orgaoConcedenteId, final List<Integer> idsEmpresas)
{
StringBuilder sb = new StringBuilder();
sb.append(" INSERT ");
@ -213,8 +214,8 @@ public class SQLBuilderOracle implements SQLBuilder {
sb.append(" and mc.activo = 1 ");
sb.append(" and re.activo = 1 ");
sb.append(" and r.orgaoconcedente_id = 21 ");
if (empresaId != null) {
sb.append(" and re.empresa_id = ").append(empresaId);
if (idsEmpresas != null) {
sb.append(" and re.empresa_id in ( ").append(idsEmpresas.toString().substring(1, idsEmpresas.toString().length()-1)).append(" ) ");
}
sb.append(" and m.moneda_id = 1 ");
if (orgaoConcedenteId != null) {
@ -235,7 +236,7 @@ public class SQLBuilderOracle implements SQLBuilder {
@Override
public String getSQLGerarTarifaOficial(final Integer codRuta, final Integer usuarioId,
final Integer orgaoConcedenteId, final Integer empresaId) {
final Integer orgaoConcedenteId, final List<Integer> idsEmpresas) {
StringBuilder sb = new StringBuilder();
sb.append(" INSERT ");
@ -332,8 +333,8 @@ public class SQLBuilderOracle implements SQLBuilder {
sb.append(" and mc.activo = 1 ");
sb.append(" and re.activo = 1 ");
sb.append(" and r.orgaoconcedente_id <> 21 ");
if (empresaId != null) {
sb.append(" and re.empresa_id = ").append(empresaId);
if (idsEmpresas != null) {
sb.append(" and re.empresa_id in ( ").append(idsEmpresas.toString().substring(1, idsEmpresas.toString().length()-1)).append(" ) ");
}
sb.append(" and m.moneda_id = 1 ");
if (orgaoConcedenteId != null) {
@ -418,7 +419,7 @@ public class SQLBuilderOracle implements SQLBuilder {
}
@Override
public String getAtualizarTaxaEmbarquePorKmParada(final Integer rutaId, final Integer usuarioId,final Integer orgaoConcedenteId, Integer empresaId) {
public String getAtualizarTaxaEmbarquePorKmParada(final Integer rutaId, final Integer usuarioId,final Integer orgaoConcedenteId, List<Integer> idsEmpresas) {
StringBuilder sb = new StringBuilder("");
sb.append("update tarifa_oficial set IMPORTETAXAEMBARQUE = ");
sb.append("( ");
@ -449,8 +450,8 @@ public class SQLBuilderOracle implements SQLBuilder {
sb.append(" and tao.ruta_id = tarifa_oficial.ruta_id ");
sb.append(" and tao.tramo_id = tarifa_oficial.tramo_id ");
sb.append(" and tepKm.orgaoconcedente_id = tarifa_oficial.orgaoconcedente_id ");
if (empresaId != null) {
sb.append(" and m.empresa_id = ").append(empresaId);
if (idsEmpresas != null) {
sb.append(" and m.empresa_id in ( ").append(idsEmpresas.toString().substring(1, idsEmpresas.toString().length()-1)).append(" ) ");
}
sb.append(") ");
sb.append(", usuario_id = ").append(usuarioId).append(",fecmodif = ").append(DBUtil.getInstance().dbSysdate()).append(" ");
@ -469,7 +470,7 @@ public class SQLBuilderOracle implements SQLBuilder {
}
@Override
public String getSQLAtualizarTaxaEmbarquePorKmOrgao(final Integer rutaId, final Integer usuarioId,final Integer orgaoConcedenteId, Integer empresaId) {
public String getSQLAtualizarTaxaEmbarquePorKmOrgao(final Integer rutaId, final Integer usuarioId,final Integer orgaoConcedenteId, List<Integer> idsEmpresas) {
StringBuilder sb = new StringBuilder("");
sb.append("update tarifa_oficial set IMPORTETAXAEMBARQUE = ");
sb.append("coalesce( ");
@ -502,8 +503,8 @@ public class SQLBuilderOracle implements SQLBuilder {
sb.append(" and tao.ruta_id = tarifa_oficial.ruta_id ");
sb.append(" and tao.tramo_id = tarifa_oficial.tramo_id ");
if (empresaId != null) {
sb.append(" and m.empresa_id = ").append(empresaId);
if (idsEmpresas != null) {
sb.append(" and m.empresa_id in ( ").append(idsEmpresas.toString().substring(1, idsEmpresas.toString().length()-1)).append(" ) ");
}
sb.append("),IMPORTETAXAEMBARQUE) ");
@ -523,7 +524,7 @@ public class SQLBuilderOracle implements SQLBuilder {
}
@Override
public String getSQLAtualizarTaxaEmbarquePorParadaFixo(final Integer rutaId, final Integer usuarioId,final Integer orgaoConcedenteId, Integer empresaId) {
public String getSQLAtualizarTaxaEmbarquePorParadaFixo(final Integer rutaId, final Integer usuarioId,final Integer orgaoConcedenteId, List<Integer> idsEmpresas) {
StringBuilder sb = new StringBuilder("");
sb.append("update tarifa_oficial set IMPORTETAXAEMBARQUE = ");
@ -547,8 +548,8 @@ public class SQLBuilderOracle implements SQLBuilder {
sb.append(" and tao.moneda_id = tarifa_oficial.moneda_id ");
sb.append(" and tao.ruta_id = tarifa_oficial.ruta_id ");
sb.append(" and tao.tramo_id = tarifa_oficial.tramo_id ");
if (empresaId != null) {
sb.append(" and m.empresa_id = ").append(empresaId);
if (idsEmpresas != null) {
sb.append(" and m.empresa_id in ( ").append(idsEmpresas.toString().substring(1, idsEmpresas.toString().length()-1)).append(" ) ");
}
sb.append("),IMPORTETAXAEMBARQUE) ");
sb.append(", usuario_id = ").append(usuarioId).append(",fecmodif = ").append(DBUtil.getInstance().dbSysdate()).append(" ");

View File

@ -33,7 +33,7 @@ import javax.persistence.TemporalType;
@SequenceGenerator(name = "RUTA_SEQ", sequenceName = "RUTA_SEQ", allocationSize = 1)
@org.hibernate.annotations.Entity(dynamicUpdate = true)
@Table(name = "RUTA")
public class Ruta implements Serializable {
public class Ruta implements Serializable, Comparable<Ruta> {
private static final long serialVersionUID = 1L;
@Id
@ -340,5 +340,9 @@ public class Ruta implements Serializable {
@Override
public String toString() {
return this.getDescruta() + " - " + this.getRutaId();
}
}
@Override
public int compareTo(Ruta ruta) {
return this.getRutaId().intValue() - ruta.getRutaId().intValue();
}
}

View File

@ -90,4 +90,6 @@ public interface RutaService {
public List<Ruta> buscarTodosEstos(Integer[] idRutas);
public List<Ruta> buscarRutasPorEmpresas(List<Empresa> lsEmp);
}

View File

@ -3,6 +3,7 @@ package com.rjconsultores.ventaboletos.service;
import java.util.List;
import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.Ruta;
import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
@ -28,7 +29,7 @@ public interface TarifaOficialService {
* @param orgaoConcedenteId
* @return A quantidade de registros afetadas
*/
public Integer gerarTarifaPorCoeficiente(Integer rutaId, Integer orgaoConcedenteId, Integer empresaId);
public Integer gerarTarifaPorCoeficiente(Integer rutaId, Integer orgaoConcedenteId, List<Integer> idsEmpresas);
/**
@ -59,7 +60,7 @@ public interface TarifaOficialService {
* @param empresaId
* @throws BusinessException
*/
public void gerarAtualizarTarifa(List<Ruta> lsRuta, Integer orgaoConcedenteId, Integer empresaId) throws BusinessException ;
public void gerarAtualizarTarifa(List<Ruta> lsRuta, Integer orgaoConcedenteId, List<Empresa> lsEmpresaSelected) throws BusinessException ;
/**
* Copia a tarifa oficial para a tabela de tarifa de acordo com a vigencia especificada.<br/>
@ -88,7 +89,7 @@ public interface TarifaOficialService {
* @param empresaId - Empresa para ser filtrada
* @throws BusinessException
*/
public void atualizarTaxaEmbarque(List<Ruta> lsRuta, Integer orgaoConcedenteId,boolean gerarTabelaZerada, Integer empresaId) throws BusinessException;
public void atualizarTaxaEmbarque(List<Ruta> lsRuta, Integer orgaoConcedenteId,boolean gerarTabelaZerada, List<Empresa> lsEmpresaSelected) throws BusinessException;
/**
@ -130,7 +131,7 @@ public interface TarifaOficialService {
public void borrar(TarifaOficial tarifaOficial);
public void gerarAtualizarTabelaZerada(List<Ruta> lsRuta, Integer orgaoConcedenteId, Integer empresaId) throws BusinessException ;
public void gerarAtualizarTabelaZerada(List<Ruta> lsRuta, Integer orgaoConcedenteId, List<Empresa> lsEmpresaSelected) throws BusinessException ;
public void atualizarPedagio();

View File

@ -6,7 +6,11 @@ package com.rjconsultores.ventaboletos.service.impl;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@ -18,6 +22,7 @@ import com.rjconsultores.ventaboletos.dao.EsquemaCorridaDAO;
import com.rjconsultores.ventaboletos.dao.RutaDAO;
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.EsquemaCorrida;
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
import com.rjconsultores.ventaboletos.entidad.Parada;
import com.rjconsultores.ventaboletos.entidad.ParadaSecuencia;
@ -28,6 +33,7 @@ import com.rjconsultores.ventaboletos.entidad.RutaSecuencia;
import com.rjconsultores.ventaboletos.entidad.Tramo;
import com.rjconsultores.ventaboletos.entidad.Via;
import com.rjconsultores.ventaboletos.exception.BusinessException;
import com.rjconsultores.ventaboletos.service.EsquemaCorridaService;
import com.rjconsultores.ventaboletos.service.RutaCombinacionService;
import com.rjconsultores.ventaboletos.service.RutaSecuenciaService;
import com.rjconsultores.ventaboletos.service.RutaService;
@ -54,6 +60,8 @@ public class RutaServiceImpl implements RutaService {
private CorridaDAO corridaDAO;
@Autowired
private EsquemaCorridaDAO esquemaCorridaDAO;
@Autowired
private EsquemaCorridaService esquemaCorridaService;
private static Logger log = Logger.getLogger(RutaServiceImpl.class);
@ -314,5 +322,29 @@ public class RutaServiceImpl implements RutaService {
public List<Ruta> buscaRutasFromOrgao(OrgaoConcedente orgao){
return rutaDAO.buscaRutasFromOrgao(orgao);
}
@Override
public List<Ruta> buscarRutasPorEmpresas(List<Empresa> lsEmp){
List<EsquemaCorrida> lsEsquemaCorrida = new ArrayList<EsquemaCorrida>();
List<Ruta> lsRutas;
for(Empresa e : lsEmp){
lsEsquemaCorrida.addAll(esquemaCorridaService.buscarPorEmpresaCorrida(e));
}
Set<Ruta> rutaSet = new TreeSet<Ruta>();
for(EsquemaCorrida ec : lsEsquemaCorrida){
rutaSet.add(ec.getRuta());
}
lsRutas = new ArrayList<Ruta>(rutaSet);
Collections.sort(lsRutas, new RutaComparator());
return lsRutas;
}
private class RutaComparator implements Comparator<Ruta> {
@Override
public int compare(Ruta r1, Ruta r2) {
String name1 = r1.getDescruta();
String name2 = r2.getDescruta();
return name1.compareTo(name2);
}
}
}

View File

@ -13,6 +13,7 @@ import com.rjconsultores.ventaboletos.dao.OrgaoConcedenteDAO;
import com.rjconsultores.ventaboletos.dao.SeguroKmDAO;
import com.rjconsultores.ventaboletos.dao.SeguroTarifaDAO;
import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
import com.rjconsultores.ventaboletos.entidad.Ruta;
import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
@ -37,8 +38,8 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
@Override
@Transactional
public Integer gerarTarifaPorCoeficiente(Integer rutaId, Integer orgaoConcedenteId, Integer empresaId) {
return tarifaOficialDAO.gerarTarifaPorCoeficiente(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId, empresaId);
public Integer gerarTarifaPorCoeficiente(Integer rutaId, Integer orgaoConcedenteId, List<Integer> idsEmpresas) {
return tarifaOficialDAO.gerarTarifaPorCoeficiente(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId, idsEmpresas);
}
@Override
@ -55,7 +56,7 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
@Override
@Transactional(rollbackFor = BusinessException.class)
public void gerarAtualizarTarifa(List<Ruta> lsRuta, Integer orgaoConcedenteId, Integer empresaId) throws BusinessException {
public void gerarAtualizarTarifa(List<Ruta> lsRuta, Integer orgaoConcedenteId, List<Empresa> lsEmpresaSelected) throws BusinessException {
// Limpando a tabela de TARIFA_OFICIAL
tarifaOficialDAO.limparTarifasOficiais();
@ -65,6 +66,11 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
x = lsRuta.size();
}
List<Integer> idsEmpresas = new ArrayList<Integer>();
for(Empresa e : lsEmpresaSelected){
idsEmpresas.add(e.getEmpresaId());
}
do{
Integer rutaId = null;
if(lsRuta != null && !lsRuta.isEmpty()){
@ -72,17 +78,17 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
rutaId = r.getRutaId();
}
log.info("gerarAtualizarTarifa= rudaId:"+rutaId+";orgaoConcedenteId:"+orgaoConcedenteId+";empresaId:"+empresaId);
log.info("gerarAtualizarTarifa= rudaId:"+rutaId+";orgaoConcedenteId:"+orgaoConcedenteId+";empresaId:"+idsEmpresas);
//Gerando as tarifas pelo coeficiente
if(orgaoConcedenteId ==null || orgaoConcedenteId != OrgaoConcedente.CODIGO_ARTESP){
Integer qtdTarifaCoeficiente = gerarTarifaPorCoeficiente(rutaId, orgaoConcedenteId, empresaId);
Integer qtdTarifaCoeficiente = gerarTarifaPorCoeficiente(rutaId, orgaoConcedenteId, idsEmpresas);
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);
Integer qtdTarifaArtesp = tarifaOficialDAO.gerarTarifaArtesp(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId, idsEmpresas);
log.info("qtdTarifaArtesp="+qtdTarifaArtesp);
}
x--;
@ -91,7 +97,7 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
@Override
@Transactional(rollbackFor = BusinessException.class)
public void gerarAtualizarTabelaZerada(List<Ruta> lsRuta, Integer orgaoConcedenteId, Integer empresaId) throws BusinessException {
public void gerarAtualizarTabelaZerada(List<Ruta> lsRuta, Integer orgaoConcedenteId, List<Empresa> lsEmpresaSelected) throws BusinessException {
// Limpando a tabela de TARIFA_OFICIAL
tarifaOficialDAO.limparTarifasOficiais();
@ -100,6 +106,11 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
x = lsRuta.size();
}
List<Integer> idsEmpresas = new ArrayList<Integer>();
for(Empresa e : lsEmpresaSelected){
idsEmpresas.add(e.getEmpresaId());
}
do{
Integer rutaId =null;
if(lsRuta != null && !lsRuta.isEmpty()){
@ -107,7 +118,7 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
}
//Gerando as tarifas
tarifaOficialDAO.gerarTabelaZerada(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId, empresaId);
tarifaOficialDAO.gerarTabelaZerada(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId, idsEmpresas);
x--;
}while(x > 0);
@ -115,12 +126,18 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
@Override
@Transactional(rollbackFor = BusinessException.class)
public void atualizarTaxaEmbarque(List<Ruta> lsRuta, Integer orgaoConcedenteId,boolean gerarTabelaZerada, Integer empresaId) throws BusinessException{
public void atualizarTaxaEmbarque(List<Ruta> lsRuta, Integer orgaoConcedenteId,boolean gerarTabelaZerada, List<Empresa> lsEmpresaSelected) throws BusinessException{
if (gerarTabelaZerada){
gerarAtualizarTabelaZerada(lsRuta, orgaoConcedenteId, empresaId);
gerarAtualizarTabelaZerada(lsRuta, orgaoConcedenteId, lsEmpresaSelected);
}
tarifaOficialDAO.atualizarTaxaEmbarque(lsRuta, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId, empresaId);
List<Integer> idsEmpresas = new ArrayList<Integer>();
for(Empresa e : lsEmpresaSelected){
idsEmpresas.add(e.getEmpresaId());
}
tarifaOficialDAO.atualizarTaxaEmbarque(lsRuta, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId, idsEmpresas);
}
@Override