fixed bug #7797
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@58857 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
fa8b4a6617
commit
3464537754
|
@ -3,11 +3,14 @@ package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
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.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.hibernate.SQLQuery;
|
import org.hibernate.SQLQuery;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.transform.Transformers;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -17,7 +20,8 @@ import org.springframework.stereotype.Repository;
|
||||||
import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO;
|
import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO;
|
||||||
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
|
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;import com.rjconsultores.ventaboletos.entidad.Ruta;
|
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@ -161,14 +165,18 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
||||||
SQLQuery querySQL = getSession().createSQLQuery(sqlBuilder.getSQLInserirTarifaPelaTarifaOficial(vigenciaTarifa.getVigenciatarifaId(), usuarioId, empresa, orgaoConcedente));
|
SQLQuery querySQL = getSession().createSQLQuery(sqlBuilder.getSQLInserirTarifaPelaTarifaOficial(vigenciaTarifa.getVigenciatarifaId(), usuarioId, empresa, orgaoConcedente));
|
||||||
querySQL.executeUpdate();
|
querySQL.executeUpdate();
|
||||||
// Atualizo o preço e o componente dos preços que já existem
|
// Atualizo o preço e o componente dos preços que já existem
|
||||||
querySQL = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTarifaPorTarifaOfical(vigenciaTarifa.getVigenciatarifaId(), usuarioId, calculaPegagio, calculaTarifa, calculaTaxaEmbarque, calculaSeguro, empresa, orgaoConcedente));
|
querySQL = getSession().createSQLQuery(sqlBuilder.getSQLSelecionarTarifaPorTarifaOficalParaAtualizar(vigenciaTarifa.getVigenciatarifaId(), empresa, orgaoConcedente));
|
||||||
|
querySQL.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
|
||||||
|
List<Map<String, Object>> dados = querySQL.list();
|
||||||
|
for (Map<String, Object> dado : dados) {
|
||||||
|
querySQL = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTarifaPorTarifaOfical(dado, usuarioId, calculaPegagio, calculaTarifa, calculaTaxaEmbarque, calculaSeguro));
|
||||||
querySQL.executeUpdate();
|
querySQL.executeUpdate();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void atualizarTaxaEmbarque(List<Ruta> lsRuta, Integer usuarioId, Integer orgaoConcedenteId, List<Integer> idsEmpresas) {
|
public void atualizarTaxaEmbarque(List<Ruta> lsRuta, Integer usuarioId, Integer orgaoConcedenteId, List<Integer> idsEmpresas) {
|
||||||
|
|
||||||
|
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
|
||||||
if (lsRuta != null && !lsRuta.isEmpty()) {
|
if (lsRuta != null && !lsRuta.isEmpty()) {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.rjconsultores.ventaboletos.dao.sqlbuilder;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||||
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||||
|
@ -39,7 +40,9 @@ public interface SQLBuilder {
|
||||||
|
|
||||||
public String getSQLAtualizarSeguroPorTarifa(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId);
|
public String getSQLAtualizarSeguroPorTarifa(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId);
|
||||||
|
|
||||||
public String getSQLAtualizarTarifaPorTarifaOfical(Integer vigenciaTarifaId, Integer usuarioId, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Empresa empresa, OrgaoConcedente orgao);
|
public String getSQLSelecionarTarifaPorTarifaOficalParaAtualizar(Integer vigenciaTarifaId, Empresa empresa, OrgaoConcedente orgao);
|
||||||
|
|
||||||
|
public String getSQLAtualizarTarifaPorTarifaOfical(Map<String,Object> dados, Integer usuarioId, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro);
|
||||||
|
|
||||||
public String getSQLInserirTarifaPelaTarifaOficial(Integer vigenciaTarifaId, Integer usuarioId, Empresa empresa, OrgaoConcedente orgao);
|
public String getSQLInserirTarifaPelaTarifaOficial(Integer vigenciaTarifaId, Integer usuarioId, Empresa empresa, OrgaoConcedente orgao);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.rjconsultores.ventaboletos.dao.sqlbuilder.impl;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
|
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
|
||||||
import com.rjconsultores.ventaboletos.dao.util.DBUtil;
|
import com.rjconsultores.ventaboletos.dao.util.DBUtil;
|
||||||
|
@ -659,58 +660,63 @@ public class SQLBuilderOracle implements SQLBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSQLAtualizarTarifaPorTarifaOfical(final Integer vigenciaTarifaId, final Integer usuarioId, final Boolean calculaPegagio, final Boolean calculaTarifa, final Boolean calculaTaxaEmbarque, final Boolean calculaSeguro, Empresa empresa, OrgaoConcedente orgao) {
|
public String getSQLSelecionarTarifaPorTarifaOficalParaAtualizar(final Integer vigenciaTarifaId, Empresa empresa, OrgaoConcedente orgao) {
|
||||||
StringBuilder sb = new StringBuilder("");
|
StringBuilder sb = new StringBuilder("");
|
||||||
sb.append("update ( ");
|
|
||||||
sb.append(" ");
|
sb.append("SELECT tao.IMPORTEPEDAGIO AS \"taoimportepedagio\", ");
|
||||||
sb.append("select ");
|
sb.append(" tao.PRECIO AS \"taoprecio\", ");
|
||||||
sb.append(" ta.precio as taprecio, ");
|
sb.append(" tao.PRECIOORIGINAL AS \"taopreciooriginal\", ");
|
||||||
sb.append(" ta.preciooriginal as tapreciooriginal, ");
|
sb.append(" tao.IMPORTETAXAEMBARQUE AS \"taoimportetaxaembarque\", ");
|
||||||
sb.append(" ta.importetaxaembarque as taimportetaxaembarque, ");
|
sb.append(" tao.IMPORTESEGURO AS \"taoimporteseguro\", ");
|
||||||
sb.append(" ta.importepedagio as taimportepedagio, ");
|
sb.append(" tao.IMPORTEOUTROS AS \"taoimporteoutros\", ");
|
||||||
sb.append(" ta.importeoutros as taimporteoutros, ");
|
sb.append(" ta.TARIFA_ID AS \"tarifaId\" ");
|
||||||
sb.append(" ta.importeseguro as taimporteseguro, ");
|
|
||||||
sb.append(" tao.precio as taoprecio, ");
|
sb.append("FROM TARIFA_OFICIAL tao " );
|
||||||
sb.append(" tao.preciooriginal as taopreciooriginal, ");
|
sb.append("INNER JOIN TARIFA ta ON (tao.MARCA_ID = ta.MARCA_ID ");
|
||||||
sb.append(" tao.importetaxaembarque as taoimportetaxaembarque, ");
|
sb.append(" AND tao.CLASESERVICIO_ID = ta.CLASESERVICIO_ID ");
|
||||||
sb.append(" tao.importepedagio as taoimportepedagio, ");
|
sb.append(" AND tao.TRAMO_ID = ta.TRAMO_ID ");
|
||||||
sb.append(" tao.importeoutros as taoimporteoutros, ");
|
sb.append(" AND tao.MONEDA_ID = ta.MONEDA_ID ");
|
||||||
sb.append(" tao.importeseguro as taoimporteseguro, ");
|
sb.append(" AND tao.RUTA_ID = ta.RUTA_ID ");
|
||||||
sb.append(" ta.fecmodif as tafecmodif,ta.usuario_id as tausuario_id ");
|
sb.append(" AND tao.ORGAOCONCEDENTE_ID = ta.ORGAOCONCEDENTE_ID ");
|
||||||
sb.append("from ");
|
sb.append(" )");
|
||||||
sb.append(" tarifa_oficial tao ");
|
sb.append("INNER JOIN MARCA mTa ON tao.MARCA_ID = mTa.MARCA_ID ");
|
||||||
sb.append(" inner join tarifa ta on ");
|
sb.append("INNER JOIN MARCA mTao ON ta.MARCA_ID = mTao.MARCA_ID ");
|
||||||
sb.append(" tao.marca_id = ta.marca_id ");
|
|
||||||
sb.append(" and tao.claseservicio_id = ta.claseservicio_id ");
|
sb.append("WHERE ta.VIGENCIATARIFA_ID = ").append(vigenciaTarifaId);
|
||||||
sb.append(" and tao.tramo_id = ta.tramo_id ");
|
|
||||||
sb.append(" and tao.moneda_id = ta.moneda_id ");
|
|
||||||
sb.append(" and tao.ruta_id = ta.ruta_id ");
|
|
||||||
sb.append(" and tao.orgaoconcedente_id = ta.orgaoconcedente_id ");
|
|
||||||
sb.append(" inner join marca m ON tao.marca_id = m.marca_id ");
|
|
||||||
sb.append("where ");
|
|
||||||
sb.append(" ta.vigenciatarifa_id = ").append(vigenciaTarifaId);
|
|
||||||
if(orgao != null){
|
if(orgao != null){
|
||||||
sb.append(" and tao.orgaoconcedente_id = ").append(orgao.getOrgaoConcedenteId());
|
sb.append(" AND tao.ORGAOCONCEDENTE_ID = ").append(orgao.getOrgaoConcedenteId());
|
||||||
}
|
}
|
||||||
if(empresa != null){
|
if(empresa != null){
|
||||||
sb.append(" and m.empresa_id = ").append(empresa.getEmpresaId());
|
sb.append(" AND mTa.EMPRESA_ID = ").append(empresa.getEmpresaId());
|
||||||
|
sb.append(" AND mTao.EMPRESA_ID = ").append(empresa.getEmpresaId());
|
||||||
}
|
}
|
||||||
sb.append(" ) set ");
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSQLAtualizarTarifaPorTarifaOfical(Map<String,Object> dados, Integer usuarioId, Boolean calculaPegagio,
|
||||||
|
Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro){
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder("");
|
||||||
|
sb.append("UPDATE TARIFA SET ");
|
||||||
|
|
||||||
if(calculaPegagio){
|
if(calculaPegagio){
|
||||||
sb.append(" taimportepedagio = taoimportepedagio,");
|
sb.append("IMPORTEPEDAGIO=").append(dados.get("taimportepedagio")).append(",");
|
||||||
}
|
}
|
||||||
if(calculaTarifa){
|
if(calculaTarifa){
|
||||||
sb.append(" taprecio = taoprecio, ");
|
sb.append("PRECIO=").append(dados.get("taoprecio")).append(",PRECIOORIGINAL=").append(dados.get("taopreciooriginal")).append(",");
|
||||||
sb.append(" tapreciooriginal = taopreciooriginal, ");
|
|
||||||
}
|
}
|
||||||
if(calculaTaxaEmbarque){
|
if(calculaTaxaEmbarque){
|
||||||
sb.append(" taimportetaxaembarque = taoimportetaxaembarque, ");
|
sb.append("IMPORTETAXAEMBARQUE=").append(dados.get("taoimportetaxaembarque")).append(",");
|
||||||
}
|
}
|
||||||
if(calculaSeguro){
|
if(calculaSeguro){
|
||||||
sb.append(" taimporteseguro = taoimporteseguro, ");
|
sb.append("IMPORTESEGURO=").append(dados.get("taoimporteseguro")).append(",");
|
||||||
}
|
}
|
||||||
sb.append(" taimporteoutros = taoimporteoutros, ");
|
sb.append("IMPORTEOUTROS=").append(dados.get("taoimporteoutros")).append(",");
|
||||||
sb.append(" tafecmodif = current_timestamp, tausuario_id = ").append(usuarioId);
|
sb.append("FECMODIF= current_timestamp, USUARIO_ID=").append(usuarioId);
|
||||||
|
sb.append(" WHERE TARIFA_ID = ").append(dados.get("tarifaId"));
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue