fixes bug#al-1430
qua: dev:Valdevir git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@114671 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
0eef121c78
commit
a58dea88c1
|
@ -0,0 +1,8 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Peaje;
|
||||||
|
|
||||||
|
public interface PeajeDao extends GenericDAO<Peaje, Integer> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,10 @@
|
||||||
package com.rjconsultores.ventaboletos.dao;
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.constantes.TipoSeguro;
|
import com.rjconsultores.ventaboletos.constantes.TipoSeguro;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.CasetaPeaje;
|
||||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Marca;
|
import com.rjconsultores.ventaboletos.entidad.Marca;
|
||||||
|
@ -13,6 +15,7 @@ import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||||
import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
|
import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
|
||||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||||
import com.rjconsultores.ventaboletos.service.TarifaOficialService;
|
import com.rjconsultores.ventaboletos.service.TarifaOficialService;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.comissao.TarifaOficialComComposicaoDoPedagioVo;
|
||||||
import com.rjconsultores.ventaboletos.vo.comissao.TarifaOficialVO;
|
import com.rjconsultores.ventaboletos.vo.comissao.TarifaOficialVO;
|
||||||
|
|
||||||
public interface TarifaOficialDAO extends GenericDAO<TarifaOficial, Integer> {
|
public interface TarifaOficialDAO extends GenericDAO<TarifaOficial, Integer> {
|
||||||
|
@ -98,4 +101,8 @@ public interface TarifaOficialDAO extends GenericDAO<TarifaOficial, Integer> {
|
||||||
public long obtenerCount(List<Empresa> lsEmpresaSelected);
|
public long obtenerCount(List<Empresa> lsEmpresaSelected);
|
||||||
|
|
||||||
public List<TarifaOficialVO> obterTarifaOficialPorFiltroVO(Moneda moneda, Marca marca,List<Marca> lsMarcas,Parada origem, Parada destino, ClaseServicio claseServicio, Ruta ruta, String numRuta, Boolean vende);
|
public List<TarifaOficialVO> obterTarifaOficialPorFiltroVO(Moneda moneda, Marca marca,List<Marca> lsMarcas,Parada origem, Parada destino, ClaseServicio claseServicio, Ruta ruta, String numRuta, Boolean vende);
|
||||||
|
|
||||||
|
public List<TarifaOficialComComposicaoDoPedagioVo> oberTarifaOficialComComposicaoDoPedagioVo();
|
||||||
|
|
||||||
|
public void atualizarPedagioComFiltroDePracaDePedagio(Integer tarifaOficialId, BigDecimal importePedagio, String composicaoPedagio );
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.PeajeDao;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Peaje;
|
||||||
|
|
||||||
|
|
||||||
|
@Repository("peajeDao")
|
||||||
|
public class PeajeHibernateDao extends GenericHibernateDAO<Peaje, Integer> implements PeajeDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public PeajeHibernateDao(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
|
setSessionFactory(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -470,7 +470,7 @@ public class RutaHibernateDAO extends GenericHibernateDAO<Ruta, Integer> impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Ruta> buscarPorOrgaoEcasetaPeaje(OrgaoConcedente orgao, Integer[] listCasetaPeaje){
|
public List<Ruta> buscarPorOrgaoEcasetaPeaje(OrgaoConcedente orgao, Integer[] listCasetaPeaje,Empresa empresa){
|
||||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
c.add(Restrictions.eq("indRutaCancelada", Boolean.FALSE));
|
c.add(Restrictions.eq("indRutaCancelada", Boolean.FALSE));
|
||||||
|
@ -485,6 +485,9 @@ public class RutaHibernateDAO extends GenericHibernateDAO<Ruta, Integer> impleme
|
||||||
crietriaOrgaoConcendente.add(Restrictions.eq("activo", Boolean.TRUE));
|
crietriaOrgaoConcendente.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
crietriaOrgaoConcendente.add(Restrictions.eq("orgaoConcedenteId", orgao.getOrgaoConcedenteId()));
|
crietriaOrgaoConcendente.add(Restrictions.eq("orgaoConcedenteId", orgao.getOrgaoConcedenteId()));
|
||||||
}
|
}
|
||||||
|
if (empresa != null && empresa.getEmpresaId() != -1) {
|
||||||
|
c.createCriteria("lsRutaEmpresa").add(Restrictions.eq("empresa", empresa));
|
||||||
|
}
|
||||||
c.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
|
c.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
|
||||||
return c.list();
|
return c.list();
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -31,6 +33,8 @@ import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
|
||||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties;
|
import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.CustomEnum;
|
import com.rjconsultores.ventaboletos.utilerias.CustomEnum;
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.comissao.TarifaOficialComComposicaoDoPedagioVo;
|
||||||
import com.rjconsultores.ventaboletos.vo.comissao.TarifaOficialVO;
|
import com.rjconsultores.ventaboletos.vo.comissao.TarifaOficialVO;
|
||||||
|
|
||||||
@Repository("tarifaOficialDAO")
|
@Repository("tarifaOficialDAO")
|
||||||
|
@ -369,7 +373,7 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
||||||
sql.append(" when matched then ");
|
sql.append(" when matched then ");
|
||||||
sql.append(" update set ");
|
sql.append(" update set ");
|
||||||
sql.append(" importepedagio = tarifa_importe.soma ");
|
sql.append(" importepedagio = tarifa_importe.soma ");
|
||||||
} else {
|
} else {
|
||||||
sql.append(" merge into tarifa_oficial ");
|
sql.append(" merge into tarifa_oficial ");
|
||||||
sql.append(" using ");
|
sql.append(" using ");
|
||||||
sql.append(" ( ");
|
sql.append(" ( ");
|
||||||
|
@ -381,13 +385,17 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
||||||
sql.append(" p.ORGAOCONCEDENTE_ID = tof.ORGAOCONCEDENTE_ID and p.ruta_id = tof.ruta_id ");
|
sql.append(" p.ORGAOCONCEDENTE_ID = tof.ORGAOCONCEDENTE_ID and p.ruta_id = tof.ruta_id ");
|
||||||
sql.append(" and p.ORIGEN_ID = tof.ORIGEN_ID and p.DESTINO_ID = tof.DESTINO_ID and p.activo = 1 ");
|
sql.append(" and p.ORIGEN_ID = tof.ORIGEN_ID and p.DESTINO_ID = tof.DESTINO_ID and p.activo = 1 ");
|
||||||
sql.append(" ) ");
|
sql.append(" ) ");
|
||||||
sql.append(" select pf.tarifaoficial_id , sum(round(importepeaje,2)) as soma from peaje_tarifas pf Group by pf.tarifaoficial_id ");
|
sql.append(" select pf.tarifaoficial_id , sum(round(importepeaje,2)) as soma,");
|
||||||
|
sql.append(" LISTAGG(casetapeaje_id||';'||peaje_id,',') WITHIN GROUP (ORDER BY casetapeaje_id) as composicaoDoPeaje ");
|
||||||
|
sql.append(" from peaje_tarifas pf Group by pf.tarifaoficial_id ");
|
||||||
sql.append(" ");
|
sql.append(" ");
|
||||||
sql.append(" ) tarifa_importe ");
|
sql.append(" ) tarifa_importe ");
|
||||||
sql.append(" on (tarifa_oficial.tarifaoficial_id = tarifa_importe.tarifaoficial_id) ");
|
sql.append(" on (tarifa_oficial.tarifaoficial_id = tarifa_importe.tarifaoficial_id) ");
|
||||||
sql.append(" when matched then ");
|
sql.append(" when matched then ");
|
||||||
sql.append(" update set ");
|
sql.append(" update set ");
|
||||||
|
sql.append(" composicao_do_peaje = tarifa_importe.composicaoDoPeaje,");
|
||||||
sql.append(" importepedagio = tarifa_importe.soma ");
|
sql.append(" importepedagio = tarifa_importe.soma ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection conn = getSession().connection();
|
Connection conn = getSession().connection();
|
||||||
|
@ -521,4 +529,62 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
||||||
int qtd = query.executeUpdate();
|
int qtd = query.executeUpdate();
|
||||||
log.info("qtd Tarifa Embarcada apagada = " + qtd);
|
log.info("qtd Tarifa Embarcada apagada = " + qtd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TarifaOficialComComposicaoDoPedagioVo> oberTarifaOficialComComposicaoDoPedagioVo() {
|
||||||
|
StringBuilder sql = new StringBuilder(" SELECT ");
|
||||||
|
sql.append(" tof.tarifaoficial_id as tarifaOficialId, ");
|
||||||
|
sql.append(" ta.COMPOSICAO_DO_PEAJE as composicaoDoPedagioNaTarifa, ");
|
||||||
|
sql.append(" LISTAGG(p.casetapeaje_id||';'||p.peaje_id,',')\r\n"
|
||||||
|
+ "WITHIN GROUP (ORDER BY p.casetapeaje_id) as composicaoDoPedagioNaTarifaOficialComPeaje");
|
||||||
|
sql.append(" FROM tarifa_oficial tof ");
|
||||||
|
sql.append(" LEFT join tarifa ta on");
|
||||||
|
sql.append(" ta.origen_id=tof.origen_id and");
|
||||||
|
sql.append(" ta.destino_id=tof.destino_id and ");
|
||||||
|
sql.append( "ta.RUTA_ID=tof.RUTA_ID and ");
|
||||||
|
sql.append(" ta.ORGAOCONCEDENTE_ID=tof.ORGAOCONCEDENTE_ID and");
|
||||||
|
sql.append(" ta.CLASESERVICIO_ID=tof.CLASESERVICIO_ID and");
|
||||||
|
sql.append(" ta.MARCA_ID=tof.MARCA_ID and ");
|
||||||
|
sql.append(" ta.tramo_id=tof.tramo_id ");
|
||||||
|
sql.append(" LEFT JOIN VIGENCIA_TARIFA vg on ta.VIGENCIATARIFA_ID=vg.VIGENCIATARIFA_ID");
|
||||||
|
sql.append(" and vg.FECINICIOVIGENCIA<= TO_DATE(:dataInicial,'DD/MM/YYYY hh24:mi') ");
|
||||||
|
sql.append(" and vg.FECFINVIGENCIA>= TO_DATE(:dataFinal,'DD/MM/YYYY hh24:mi')");
|
||||||
|
sql.append(" INNER JOIN PEAJE p");
|
||||||
|
sql.append(" ON p.ORGAOCONCEDENTE_ID = tof.ORGAOCONCEDENTE_ID");
|
||||||
|
sql.append(" AND p.ruta_id= tof.ruta_id");
|
||||||
|
sql.append(" AND p.ORIGEN_ID = tof.ORIGEN_ID");
|
||||||
|
sql.append(" AND p.DESTINO_ID = tof.DESTINO_ID");
|
||||||
|
sql.append(" AND p.activo = 1");
|
||||||
|
sql.append(" group by ta.tarifa_id,tof.tarifaoficial_id,ta.tarifa_id,ta.COMPOSICAO_DO_PEAJE");
|
||||||
|
|
||||||
|
Query query = getSession().createSQLQuery(sql.toString());
|
||||||
|
|
||||||
|
Query qr = getSession().createSQLQuery(sql.toString()).addScalar("tarifaOficialId", Hibernate.INTEGER).addScalar("composicaoDoPedagioNaTarifa", Hibernate.STRING).addScalar("composicaoDoPedagioNaTarifaOficialComPeaje", Hibernate.STRING).setResultTransformer(Transformers.aliasToBean(TarifaOficialComComposicaoDoPedagioVo.class));
|
||||||
|
|
||||||
|
qr.setParameter("dataInicial", DateUtil.getStringDate(DateUtil.inicioFecha(new Date()), "dd/MM/yyyy HH:mm"));
|
||||||
|
qr.setParameter("dataFinal", DateUtil.getStringDate(DateUtil.fimFecha(new Date()), "dd/MM/yyyy HH:mm"));
|
||||||
|
|
||||||
|
return (List<TarifaOficialComComposicaoDoPedagioVo>) qr.list();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void atualizarPedagioComFiltroDePracaDePedagio(Integer tarifaOficialId, BigDecimal importePedagio, String composicaoPedagio) {
|
||||||
|
StringBuilder sb = new StringBuilder("");
|
||||||
|
sb.append("update tarifa_oficial set IMPORTEPEDAGIO =:importePedagio, ");
|
||||||
|
sb.append("COMPOSICAO_DO_PEAJE =:composicaoDoPedagio ");
|
||||||
|
sb.append("WHERE tarifaoficial_id=:tarifaOficialId");
|
||||||
|
|
||||||
|
Query query = getSession().createSQLQuery(sb.toString());
|
||||||
|
query.setBigDecimal("importePedagio", importePedagio);
|
||||||
|
query.setString("composicaoDoPedagio", composicaoPedagio);
|
||||||
|
query.setInteger("tarifaOficialId", tarifaOficialId);
|
||||||
|
|
||||||
|
query.executeUpdate();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -768,6 +768,7 @@ public class SQLBuilderOracle implements SQLBuilder {
|
||||||
StringBuilder sb = new StringBuilder("");
|
StringBuilder sb = new StringBuilder("");
|
||||||
|
|
||||||
sb.append("SELECT tao.IMPORTEPEDAGIO AS \"taoimportepedagio\", ");
|
sb.append("SELECT tao.IMPORTEPEDAGIO AS \"taoimportepedagio\", ");
|
||||||
|
sb.append(" tao.COMPOSICAO_DO_PEAJE AS \"taocomposicaodopeaje\", ");
|
||||||
sb.append(" tao.PRECIO AS \"taoprecio\", ");
|
sb.append(" tao.PRECIO AS \"taoprecio\", ");
|
||||||
sb.append(" tao.PRECIOORIGINAL AS \"taopreciooriginal\", ");
|
sb.append(" tao.PRECIOORIGINAL AS \"taopreciooriginal\", ");
|
||||||
sb.append(" tao.IMPORTETAXAEMBARQUE AS \"taoimportetaxaembarque\", ");
|
sb.append(" tao.IMPORTETAXAEMBARQUE AS \"taoimportetaxaembarque\", ");
|
||||||
|
@ -809,6 +810,7 @@ public class SQLBuilderOracle implements SQLBuilder {
|
||||||
|
|
||||||
if (calculaPegagio) {
|
if (calculaPegagio) {
|
||||||
sb.append("IMPORTEPEDAGIO=").append(dados.get("taoimportepedagio")).append(",");
|
sb.append("IMPORTEPEDAGIO=").append(dados.get("taoimportepedagio")).append(",");
|
||||||
|
sb.append(" COMPOSICAO_DO_PEAJE='").append(dados.get("taocomposicaodopeaje")).append("',");
|
||||||
}
|
}
|
||||||
if (calculaTarifa) {
|
if (calculaTarifa) {
|
||||||
sb.append("PRECIO=").append(dados.get("taoprecio")).append(",PRECIOORIGINAL=").append(dados.get("taopreciooriginal")).append(",");
|
sb.append("PRECIO=").append(dados.get("taoprecio")).append(",PRECIOORIGINAL=").append(dados.get("taopreciooriginal")).append(",");
|
||||||
|
@ -839,7 +841,7 @@ public class SQLBuilderOracle implements SQLBuilder {
|
||||||
sb.append(" MARCA_ID, CLASESERVICIO_ID, PRECIOORIGINAL, MONEDA_ID, ");
|
sb.append(" MARCA_ID, CLASESERVICIO_ID, PRECIOORIGINAL, MONEDA_ID, ");
|
||||||
sb.append(" VIGENCIATARIFA_ID, STATUSTARIFA, ACTIVO, FECMODIF, ");
|
sb.append(" VIGENCIATARIFA_ID, STATUSTARIFA, ACTIVO, FECMODIF, ");
|
||||||
sb.append(" USUARIO_ID, IMPORTETAXAEMBARQUE, IMPORTEPEDAGIO, IMPORTEOUTROS, ");
|
sb.append(" USUARIO_ID, IMPORTETAXAEMBARQUE, IMPORTEPEDAGIO, IMPORTEOUTROS, ");
|
||||||
sb.append(" IMPORTESEGURO, IMPORTETPP, ORGAOCONCEDENTE_ID, RUTA_ID, ORIGEN_ID, DESTINO_ID ) ");
|
sb.append(" IMPORTESEGURO, IMPORTETPP, ORGAOCONCEDENTE_ID, RUTA_ID, ORIGEN_ID, DESTINO_ID, COMPOSICAO_DO_PEAJE ) ");
|
||||||
sb.append(" select ");
|
sb.append(" select ");
|
||||||
sb.append(" TARIFA_SEQ.nextval, ");
|
sb.append(" TARIFA_SEQ.nextval, ");
|
||||||
sb.append(" tao.PRECIO , ");
|
sb.append(" tao.PRECIO , ");
|
||||||
|
@ -862,7 +864,8 @@ public class SQLBuilderOracle implements SQLBuilder {
|
||||||
sb.append(" tao.ORGAOCONCEDENTE_ID , ");
|
sb.append(" tao.ORGAOCONCEDENTE_ID , ");
|
||||||
sb.append(" tao.RUTA_ID , ");
|
sb.append(" tao.RUTA_ID , ");
|
||||||
sb.append(" tao.ORIGEN_ID , ");
|
sb.append(" tao.ORIGEN_ID , ");
|
||||||
sb.append(" tao.DESTINO_ID ");
|
sb.append(" tao.DESTINO_ID, ");
|
||||||
|
sb.append(" tao.COMPOSICAO_DO_PEAJE ");
|
||||||
sb.append(" from ");
|
sb.append(" from ");
|
||||||
sb.append(" TARIFA_OFICIAL tao, ");
|
sb.append(" TARIFA_OFICIAL tao, ");
|
||||||
sb.append(" VIGENCIA_TARIFA v, ");
|
sb.append(" VIGENCIA_TARIFA v, ");
|
||||||
|
|
|
@ -162,6 +162,11 @@ public class Tarifa implements Serializable, Auditavel<Tarifa>, AuditavelTelaAlt
|
||||||
@Transient
|
@Transient
|
||||||
private String telaAlternativa;
|
private String telaAlternativa;
|
||||||
|
|
||||||
|
|
||||||
|
@Column(name = "COMPOSICAO_DO_PEAJE")
|
||||||
|
@NaoAuditar
|
||||||
|
private String composicaoDoPeaje;
|
||||||
|
|
||||||
public Tarifa() {
|
public Tarifa() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,6 +412,16 @@ public class Tarifa implements Serializable, Auditavel<Tarifa>, AuditavelTelaAlt
|
||||||
public void setImporteseguro(BigDecimal importeseguro) {
|
public void setImporteseguro(BigDecimal importeseguro) {
|
||||||
this.importeseguro = importeseguro;
|
this.importeseguro = importeseguro;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getComposicaoDoPeaje() {
|
||||||
|
return composicaoDoPeaje;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComposicaoDoPeaje(String composicaoDoPeaje) {
|
||||||
|
this.composicaoDoPeaje = composicaoDoPeaje;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clonar() throws CloneNotSupportedException {
|
public void clonar() throws CloneNotSupportedException {
|
||||||
|
|
|
@ -138,6 +138,10 @@ public class TarifaOficial implements Serializable, Auditavel<TarifaOficial> {
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
private Integer empresaId;
|
private Integer empresaId;
|
||||||
|
|
||||||
|
@Column(name = "COMPOSICAO_DO_PEAJE")
|
||||||
|
@NaoAuditar
|
||||||
|
private String composicaoDoPeaje;
|
||||||
|
|
||||||
public TarifaOficial() {
|
public TarifaOficial() {
|
||||||
}
|
}
|
||||||
|
@ -285,6 +289,16 @@ public class TarifaOficial implements Serializable, Auditavel<TarifaOficial> {
|
||||||
public void setDestino(Parada destino) {
|
public void setDestino(Parada destino) {
|
||||||
this.destino = destino;
|
this.destino = destino;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getComposicaoDoPeaje() {
|
||||||
|
return composicaoDoPeaje;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComposicaoDoPeaje(String composicaoDoPeaje) {
|
||||||
|
this.composicaoDoPeaje = composicaoDoPeaje;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.rjconsultores.ventaboletos.service;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Peaje;
|
||||||
|
|
||||||
|
public interface PeajeService {
|
||||||
|
|
||||||
|
public Peaje buscarPeajePorId(Integer peajeId);
|
||||||
|
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.constantes.TipoSeguro;
|
import com.rjconsultores.ventaboletos.constantes.TipoSeguro;
|
||||||
import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO;
|
import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.CasetaPeaje;
|
||||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Marca;
|
import com.rjconsultores.ventaboletos.entidad.Marca;
|
||||||
|
@ -148,5 +149,7 @@ public interface TarifaOficialService {
|
||||||
|
|
||||||
public List<TarifaOficial> obterTarifaOficialPorFiltro(Moneda moneda, Marca marca,List<Marca> lsMarcas,Parada origem, Parada destino, ClaseServicio claseServicio, Ruta ruta, String numRuta, Boolean vende);
|
public List<TarifaOficial> obterTarifaOficialPorFiltro(Moneda moneda, Marca marca,List<Marca> lsMarcas,Parada origem, Parada destino, ClaseServicio claseServicio, Ruta ruta, String numRuta, Boolean vende);
|
||||||
|
|
||||||
|
public void atualizarPedagioPorListaDePracaDePagio(List<CasetaPeaje> lsCasetaPeaje);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.rjconsultores.ventaboletos.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.PeajeDao;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Peaje;
|
||||||
|
import com.rjconsultores.ventaboletos.service.PeajeService;
|
||||||
|
|
||||||
|
@Service("peajeService")
|
||||||
|
public class PeajeServiceImpl implements PeajeService{
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PeajeDao peajeDao;
|
||||||
|
|
||||||
|
|
||||||
|
public Peaje buscarPeajePorId(Integer peajeId) {
|
||||||
|
return peajeDao.obtenerID(peajeId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,12 @@
|
||||||
package com.rjconsultores.ventaboletos.service.impl;
|
package com.rjconsultores.ventaboletos.service.impl;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -14,12 +19,14 @@ import com.rjconsultores.ventaboletos.dao.OrgaoConcedenteDAO;
|
||||||
import com.rjconsultores.ventaboletos.dao.SeguroKmDAO;
|
import com.rjconsultores.ventaboletos.dao.SeguroKmDAO;
|
||||||
import com.rjconsultores.ventaboletos.dao.SeguroTarifaDAO;
|
import com.rjconsultores.ventaboletos.dao.SeguroTarifaDAO;
|
||||||
import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO;
|
import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.CasetaPeaje;
|
||||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Marca;
|
import com.rjconsultores.ventaboletos.entidad.Marca;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Moneda;
|
import com.rjconsultores.ventaboletos.entidad.Moneda;
|
||||||
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Parada;
|
import com.rjconsultores.ventaboletos.entidad.Parada;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Peaje;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||||
import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
|
import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Tramo;
|
import com.rjconsultores.ventaboletos.entidad.Tramo;
|
||||||
|
@ -27,8 +34,10 @@ import com.rjconsultores.ventaboletos.entidad.Via;
|
||||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||||
import com.rjconsultores.ventaboletos.service.LogAuditoriaService;
|
import com.rjconsultores.ventaboletos.service.LogAuditoriaService;
|
||||||
|
import com.rjconsultores.ventaboletos.service.PeajeService;
|
||||||
import com.rjconsultores.ventaboletos.service.TarifaOficialService;
|
import com.rjconsultores.ventaboletos.service.TarifaOficialService;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.comissao.TarifaOficialComComposicaoDoPedagioVo;
|
||||||
import com.rjconsultores.ventaboletos.vo.comissao.TarifaOficialVO;
|
import com.rjconsultores.ventaboletos.vo.comissao.TarifaOficialVO;
|
||||||
|
|
||||||
@Service("tarifaOficialService")
|
@Service("tarifaOficialService")
|
||||||
|
@ -47,6 +56,10 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LogAuditoriaService logAuditoriaService;
|
private LogAuditoriaService logAuditoriaService;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PeajeService peajeService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@ -340,5 +353,118 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
||||||
}
|
}
|
||||||
return lsTarifa;
|
return lsTarifa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void atualizarPedagioPorListaDePracaDePagio(List<CasetaPeaje> lsCasetaPeaje) {
|
||||||
|
try {
|
||||||
|
List<TarifaOficialComComposicaoDoPedagioVo> lsTarifaOficialComComposicaoDoPedagioVo = tarifaOficialDAO.oberTarifaOficialComComposicaoDoPedagioVo();
|
||||||
|
|
||||||
|
if (!lsTarifaOficialComComposicaoDoPedagioVo.isEmpty()) {
|
||||||
|
|
||||||
|
|
||||||
|
for (TarifaOficialComComposicaoDoPedagioVo tarifaOficialComComposicaoDoPedagioVo : lsTarifaOficialComComposicaoDoPedagioVo) {
|
||||||
|
log.info("tarifaOficiald:" + tarifaOficialComComposicaoDoPedagioVo.getTarifaOficialId() + " | composicao do pedágio no cálculo:" + tarifaOficialComComposicaoDoPedagioVo.getComposicaoDoPedagioNaTarifaOficialComPeaje() + " | composicao do pedágio na tarifa:" + tarifaOficialComComposicaoDoPedagioVo.getComposicaoDoPedagioNaTarifa());
|
||||||
|
|
||||||
|
if (tarifaOficialComComposicaoDoPedagioVo.getComposicaoDoPedagioNaTarifa() == null) {
|
||||||
|
HashMap<Integer, Integer> mapComposicaoDoPedagioNaTarifaOficialComPeaje = new HashMap();
|
||||||
|
String[] parDeChavePeajeMaisCasetaPeaje1 = tarifaOficialComComposicaoDoPedagioVo.getComposicaoDoPedagioNaTarifaOficialComPeaje().replace(" ", "").split(",");
|
||||||
|
montaMapComposicao(mapComposicaoDoPedagioNaTarifaOficialComPeaje, parDeChavePeajeMaisCasetaPeaje1);
|
||||||
|
BigDecimal valorPedagio = montarObterValorImportePedagio(mapComposicaoDoPedagioNaTarifaOficialComPeaje);
|
||||||
|
String stringComposicaoDoPedagio = tarifaOficialComComposicaoDoPedagioVo.getComposicaoDoPedagioNaTarifaOficialComPeaje();
|
||||||
|
|
||||||
|
atualizarPedagioComFiltroDePracaDePedagio(tarifaOficialComComposicaoDoPedagioVo, valorPedagio, stringComposicaoDoPedagio);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
HashMap<Integer, Integer> mapComposicaoDoPedagioNaTarifa = new HashMap();
|
||||||
|
String[] parDeChavePeajeMaisCasetaPeaje = tarifaOficialComComposicaoDoPedagioVo.getComposicaoDoPedagioNaTarifa().replace(" ", "").split(",");
|
||||||
|
montaMapComposicao(mapComposicaoDoPedagioNaTarifa, parDeChavePeajeMaisCasetaPeaje);
|
||||||
|
|
||||||
|
HashMap<Integer, Integer> mapComposicaoDoPedagioNaTarifaOficialComPeaje = new HashMap();
|
||||||
|
String[] parDeChavePeajeMaisCasetaPeaje1 = tarifaOficialComComposicaoDoPedagioVo.getComposicaoDoPedagioNaTarifaOficialComPeaje().replace(" ", "").split(",");
|
||||||
|
montaMapComposicao(mapComposicaoDoPedagioNaTarifaOficialComPeaje, parDeChavePeajeMaisCasetaPeaje1);
|
||||||
|
|
||||||
|
atualizarComposicaoDoPedagioNaTarifa(lsCasetaPeaje, mapComposicaoDoPedagioNaTarifa, mapComposicaoDoPedagioNaTarifaOficialComPeaje);
|
||||||
|
|
||||||
|
BigDecimal valorPedagio = montarObterValorImportePedagio(mapComposicaoDoPedagioNaTarifa);
|
||||||
|
|
||||||
|
String stringComposicaoDoPedagio = "";
|
||||||
|
stringComposicaoDoPedagio = remontarAStringDeComposicaoDoPedagio(mapComposicaoDoPedagioNaTarifa, stringComposicaoDoPedagio);
|
||||||
|
|
||||||
|
atualizarPedagioComFiltroDePracaDePedagio(tarifaOficialComComposicaoDoPedagioVo, valorPedagio, stringComposicaoDoPedagio);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.info("Não retornou nenhum registro da consulta oberTarifaOficialComComposicaoDoPedagioVo ");
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
// TODO: handle exception
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void atualizarPedagioComFiltroDePracaDePedagio(TarifaOficialComComposicaoDoPedagioVo tarifaOficialComComposicaoDoPedagioVo, BigDecimal valorPedagio, String stringComposicaoDoPedagio) {
|
||||||
|
log.info("tarifaOficiald:"+tarifaOficialComComposicaoDoPedagioVo.getTarifaOficialId()+" | composicao do pedágio na tarifa oficial:" + tarifaOficialComComposicaoDoPedagioVo.getComposicaoDoPedagioNaTarifaOficialComPeaje() +" | importePedagio:"+valorPedagio);
|
||||||
|
|
||||||
|
tarifaOficialDAO.atualizarPedagioComFiltroDePracaDePedagio(tarifaOficialComComposicaoDoPedagioVo.getTarifaOficialId(), valorPedagio, stringComposicaoDoPedagio);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String remontarAStringDeComposicaoDoPedagio(HashMap<Integer, Integer> mapComposicaoDoPedagioNaTarifa, String stringComposicaoDoPedagio) {
|
||||||
|
Boolean inicio =true;
|
||||||
|
|
||||||
|
for(Entry<Integer, Integer> map : mapComposicaoDoPedagioNaTarifa.entrySet()) {
|
||||||
|
if(!inicio) {
|
||||||
|
stringComposicaoDoPedagio += ",";
|
||||||
|
}
|
||||||
|
stringComposicaoDoPedagio += map.getKey()+";"+map.getValue();
|
||||||
|
inicio=false;
|
||||||
|
}
|
||||||
|
return stringComposicaoDoPedagio;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BigDecimal montarObterValorImportePedagio(HashMap<Integer, Integer> mapComposicaoDoPedagioNaTarifa) {
|
||||||
|
BigDecimal valorPedagio = new BigDecimal("0.0");
|
||||||
|
for(Entry<Integer, Integer> map : mapComposicaoDoPedagioNaTarifa.entrySet()) {
|
||||||
|
Peaje peaje = peajeService.buscarPeajePorId(map.getValue());
|
||||||
|
valorPedagio=valorPedagio.add(peaje.getImportePeaje());
|
||||||
|
|
||||||
|
}
|
||||||
|
return valorPedagio.setScale(2,RoundingMode.HALF_EVEN);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void atualizarComposicaoDoPedagioNaTarifa(List<CasetaPeaje> lsCasetaPeaje, HashMap<Integer, Integer> mapComposicaoDoPedagioNaTarifa, Map<Integer, Integer> mapComposicaoDoPedagioNaTarifaOficialComPeaje) {
|
||||||
|
for(CasetaPeaje casetaPeaje : lsCasetaPeaje) {
|
||||||
|
if(mapComposicaoDoPedagioNaTarifa.containsKey(casetaPeaje.getCasetaPeajeId())) {
|
||||||
|
mapComposicaoDoPedagioNaTarifa.remove(casetaPeaje.getCasetaPeajeId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mapComposicaoDoPedagioNaTarifaOficialComPeaje.containsKey(casetaPeaje.getCasetaPeajeId())) {
|
||||||
|
mapComposicaoDoPedagioNaTarifa.put(casetaPeaje.getCasetaPeajeId(),mapComposicaoDoPedagioNaTarifaOficialComPeaje.get(casetaPeaje.getCasetaPeajeId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void montaMapComposicao(Map<Integer, Integer> mapComposicaoDoPedagioNaTarifa, String[] parDeChavePeajeMaisCasetaPeaje) {
|
||||||
|
for(String chavePeajeMaisCasetaPeaje:parDeChavePeajeMaisCasetaPeaje) {
|
||||||
|
String[] composicao = chavePeajeMaisCasetaPeaje.split(";");
|
||||||
|
Integer casetaPeaje = Integer.parseInt(composicao[0].trim());
|
||||||
|
Integer peaje = Integer.parseInt(composicao[1].trim());
|
||||||
|
mapComposicaoDoPedagioNaTarifa.put(casetaPeaje,peaje);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String teste="284;19004, 284;19005,425;18994";
|
||||||
|
// String testeEspacoReemovido=teste.tri;
|
||||||
|
String[] parDeChavePeajeMaisCasetaPeaje = teste.replace(" ", "").split(",");
|
||||||
|
|
||||||
|
for(String chavePeajeMaisCasetaPeaje:parDeChavePeajeMaisCasetaPeaje) {
|
||||||
|
System.out.println(chavePeajeMaisCasetaPeaje);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.rjconsultores.ventaboletos.vo.comissao;
|
||||||
|
|
||||||
|
public class TarifaOficialComComposicaoDoPedagioVo {
|
||||||
|
private Integer tarifaOficialId;
|
||||||
|
private String composicaoDoPedagioNaTarifa;
|
||||||
|
private String composicaoDoPedagioNaTarifaOficialComPeaje;
|
||||||
|
|
||||||
|
public Integer getTarifaOficialId() {
|
||||||
|
return tarifaOficialId;
|
||||||
|
}
|
||||||
|
public void setTarifaOficialId(Integer tarifaOficialId) {
|
||||||
|
this.tarifaOficialId = tarifaOficialId;
|
||||||
|
}
|
||||||
|
public String getComposicaoDoPedagioNaTarifa() {
|
||||||
|
return composicaoDoPedagioNaTarifa;
|
||||||
|
}
|
||||||
|
public void setComposicaoDoPedagioNaTarifa(String composicaoDoPedagioNaTarifa) {
|
||||||
|
this.composicaoDoPedagioNaTarifa = composicaoDoPedagioNaTarifa;
|
||||||
|
}
|
||||||
|
public String getComposicaoDoPedagioNaTarifaOficialComPeaje() {
|
||||||
|
return composicaoDoPedagioNaTarifaOficialComPeaje;
|
||||||
|
}
|
||||||
|
public void setComposicaoDoPedagioNaTarifaOficialComPeaje(String composicaoDoPedagioNaTarifaOficialComPeaje) {
|
||||||
|
this.composicaoDoPedagioNaTarifaOficialComPeaje = composicaoDoPedagioNaTarifaOficialComPeaje;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue