frederico 2016-07-28 17:05:39 +00:00
parent 7859fc79d6
commit 3e239a2c1b
3 changed files with 18 additions and 10 deletions

View File

@ -8,8 +8,6 @@ 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;
public interface TarifaOficialDAO extends GenericDAO<TarifaOficial, Integer>{ public interface TarifaOficialDAO extends GenericDAO<TarifaOficial, Integer>{
/** /**
* See {@link TarifaOficialService#gerarTarifaPorCoeficiente(Integer, Integer)} * See {@link TarifaOficialService#gerarTarifaPorCoeficiente(Integer, Integer)}
@ -84,7 +82,7 @@ public interface TarifaOficialDAO extends GenericDAO<TarifaOficial, Integer>{
*/ */
public void aplicarArredondamentoTarifa(Integer orgaoConcedenteId, Integer usuarioId, Boolean taxaEmbarque); public void aplicarArredondamentoTarifa(Integer orgaoConcedenteId, Integer usuarioId, Boolean taxaEmbarque);
public void limparTarifasOficiais(); public void limparTarifasOficiais(List<Empresa> lsEmpresaSelected);
public void atualizarPedagio(); public void atualizarPedagio();

View File

@ -17,8 +17,7 @@ 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.OrgaoConcedente;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.VigenciaTarifa; import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
@ -75,9 +74,20 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
return qtd; return qtd;
} }
public void limparTarifasOficiais() { public void limparTarifasOficiais(List<Empresa> lsEmpresaSelected) {
Query query = getSession().createQuery("DELETE FROM TarifaOficial");
query.executeUpdate(); String query = "DELETE FROM TarifaOficial ";
if (lsEmpresaSelected != null && !lsEmpresaSelected.isEmpty()) {
query += "WHERE tarifaOficialId IN ( ";
query += " SELECT t.tarifaOficialId FROM TarifaOficial t WHERE t.marca.empresa.empresaId IN (";
for (Empresa e : lsEmpresaSelected) {
query += e.getEmpresaId() + ",";
}
query = query.substring(0, query.length() - 1);
query += "))";
}
Query q = getSession().createQuery(query);
q.executeUpdate();
} }
private void apagarTarifasInativas(VigenciaTarifa vigenciaTarifa, Empresa empresa, OrgaoConcedente orgao) { private void apagarTarifasInativas(VigenciaTarifa vigenciaTarifa, Empresa empresa, OrgaoConcedente orgao) {

View File

@ -60,7 +60,7 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
public void gerarAtualizarTarifa(List<Ruta> lsRuta, Integer orgaoConcedenteId, List<Empresa> lsEmpresaSelected) throws BusinessException { public void gerarAtualizarTarifa(List<Ruta> lsRuta, Integer orgaoConcedenteId, List<Empresa> lsEmpresaSelected) throws BusinessException {
// Limpando a tabela de TARIFA_OFICIAL // Limpando a tabela de TARIFA_OFICIAL
tarifaOficialDAO.limparTarifasOficiais(); tarifaOficialDAO.limparTarifasOficiais(lsEmpresaSelected);
int x = 0; int x = 0;
if(lsRuta != null && !lsRuta.isEmpty()){ if(lsRuta != null && !lsRuta.isEmpty()){
@ -100,7 +100,7 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
@Transactional(rollbackFor = BusinessException.class) @Transactional(rollbackFor = BusinessException.class)
public void gerarAtualizarTabelaZerada(List<Ruta> lsRuta, Integer orgaoConcedenteId, List<Empresa> lsEmpresaSelected) throws BusinessException { public void gerarAtualizarTabelaZerada(List<Ruta> lsRuta, Integer orgaoConcedenteId, List<Empresa> lsEmpresaSelected) throws BusinessException {
// Limpando a tabela de TARIFA_OFICIAL // Limpando a tabela de TARIFA_OFICIAL
tarifaOficialDAO.limparTarifasOficiais(); tarifaOficialDAO.limparTarifasOficiais(lsEmpresaSelected);
int x =0; int x =0;
if(lsRuta != null && !lsRuta.isEmpty()){ if(lsRuta != null && !lsRuta.isEmpty()){