gleimar 2012-08-28 17:27:41 +00:00
parent 9d0b54f20e
commit 3c146731ef
12 changed files with 98 additions and 76 deletions

View File

@ -1,14 +1,7 @@
package com.rjconsultores.ventaboletos.dao; package com.rjconsultores.ventaboletos.dao;
import com.rjconsultores.ventaboletos.service.SeguroKmService;
public interface SeguroKmDAO { public interface SeguroKmDAO {
/**
* See {@link SeguroKmService#atualizarSeguroPorKm(Integer, Integer, Integer)}
* @param rutaId
* @param orgaoId
* @param usuarioId
*/
public void atualizarSeguroPorKm(Integer rutaId,Integer orgaoId,Integer usuarioId) ;
} }

View File

@ -1,13 +1,6 @@
package com.rjconsultores.ventaboletos.dao; package com.rjconsultores.ventaboletos.dao;
import com.rjconsultores.ventaboletos.entidad.SeguroTarifa;
public interface SeguroTarifaDAO { public interface SeguroTarifaDAO {
/**
* See {@link SeguroTarifa#atualizarSeguroPorTarifa(Integer, Integer, Integer)}
* @param rutaId
* @param orgaoId
* @param usuarioId
*/
public void atualizarSeguroPorTarifa(Integer rutaId, Integer orgaoId,Integer usuarioId);
} }

View File

@ -1,6 +1,8 @@
package com.rjconsultores.ventaboletos.dao; package com.rjconsultores.ventaboletos.dao;
import com.rjconsultores.ventaboletos.entidad.SeguroTarifa;
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa; import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
import com.rjconsultores.ventaboletos.service.SeguroKmService;
import com.rjconsultores.ventaboletos.service.TarifaOficialService; import com.rjconsultores.ventaboletos.service.TarifaOficialService;
@ -37,4 +39,20 @@ public interface TarifaOficialDAO {
* @param orgaoConcedenteId TODO * @param orgaoConcedenteId TODO
*/ */
public void atualizarTaxaEmbarque(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId); public void atualizarTaxaEmbarque(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId);
/**
* See {@link TarifaOficialService#atualizarSeguroPorKm(Integer, Integer, Integer)}
* @param rutaId
* @param orgaoId
* @param usuarioId
*/
public void atualizarSeguroPorKm(Integer rutaId,Integer orgaoId,Integer usuarioId) ;
/**
* See {@link TarifaOficialService#atualizarSeguroPorTarifa(Integer, Integer, Integer)}
* @param rutaId
* @param orgaoId
* @param usuarioId
*/
public void atualizarSeguroPorTarifa(Integer rutaId, Integer orgaoId,Integer usuarioId);
} }

View File

@ -13,18 +13,10 @@ import com.rjconsultores.ventaboletos.entidad.SeguroKm;
@Repository("seguroKmDAO") @Repository("seguroKmDAO")
public class SeguroKmHibernateDAO extends GenericHibernateDAO<SeguroKm, Integer> implements SeguroKmDAO { public class SeguroKmHibernateDAO extends GenericHibernateDAO<SeguroKm, Integer> implements SeguroKmDAO {
@Autowired
private SQLBuilder sqlBuilder;
@Autowired @Autowired
public SeguroKmHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { public SeguroKmHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
setSessionFactory(factory); setSessionFactory(factory);
} }
@Override
public void atualizarSeguroPorKm(Integer rutaId, Integer orgaoId, Integer usuarioId) {
SQLQuery query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarSeguroPorKm(rutaId, usuarioId, orgaoId));
query.executeUpdate();
}
} }

View File

@ -1,30 +1,19 @@
package com.rjconsultores.ventaboletos.dao.hibernate; package com.rjconsultores.ventaboletos.dao.hibernate;
import org.hibernate.SQLQuery;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.rjconsultores.ventaboletos.dao.SeguroTarifaDAO; import com.rjconsultores.ventaboletos.dao.SeguroTarifaDAO;
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
import com.rjconsultores.ventaboletos.entidad.SeguroTarifa; import com.rjconsultores.ventaboletos.entidad.SeguroTarifa;
@Repository("seguroTarifaDAO") @Repository("seguroTarifaDAO")
public class SeguroTarifaHibernateDAO extends GenericHibernateDAO<SeguroTarifa, Integer> implements SeguroTarifaDAO { public class SeguroTarifaHibernateDAO extends GenericHibernateDAO<SeguroTarifa, Integer> implements SeguroTarifaDAO {
@Autowired
private SQLBuilder sqlBuilder;
@Autowired @Autowired
public SeguroTarifaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { public SeguroTarifaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
setSessionFactory(factory); setSessionFactory(factory);
} }
@Override
public void atualizarSeguroPorTarifa(Integer rutaId, Integer orgaoId, Integer usuarioId) {
SQLQuery query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarSeguroPorTarifa(rutaId, usuarioId, orgaoId));
query.executeUpdate();
}
} }

View File

@ -128,4 +128,16 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTaxaEmbarquePorParadaFixo(rutaId, usuarioId, orgaoConcedenteId)); query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTaxaEmbarquePorParadaFixo(rutaId, usuarioId, orgaoConcedenteId));
query.executeUpdate(); query.executeUpdate();
} }
@Override
public void atualizarSeguroPorKm(Integer rutaId, Integer orgaoId, Integer usuarioId) {
SQLQuery query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarSeguroPorKm(rutaId, usuarioId, orgaoId));
query.executeUpdate();
}
@Override
public void atualizarSeguroPorTarifa(Integer rutaId, Integer orgaoId, Integer usuarioId) {
SQLQuery query = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarSeguroPorTarifa(rutaId, usuarioId, orgaoId));
query.executeUpdate();
}
} }

View File

@ -1,15 +1,6 @@
package com.rjconsultores.ventaboletos.service; package com.rjconsultores.ventaboletos.service;
import com.rjconsultores.ventaboletos.exception.BusinessException;
public interface SeguroKmService { public interface SeguroKmService {
/**
* Atualiza o seguro de acordo a kilometragem do trecho
*
* @param rutaId - Se informado, será filtrado pela ruta
* @param orgaoId -Campo obrigatório
*/
public void atualizarSeguroPorKm(Integer rutaId,Integer orgaoId) throws BusinessException;
} }

View File

@ -4,13 +4,4 @@ import com.rjconsultores.ventaboletos.exception.BusinessException;
public interface SeguroTarifaService { public interface SeguroTarifaService {
/**
* Atualiza o seguro de acordo o valor da tarifa
*
* @param rutaId - Se informado, será filtrado pela ruta
* @param orgaoId -Campo obrigatório
*
*/
public void atualizarSeguroPorTarifa(Integer rutaId, Integer orgaoId) throws BusinessException;
} }

View File

@ -1,6 +1,7 @@
package com.rjconsultores.ventaboletos.service; package com.rjconsultores.ventaboletos.service;
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa; import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
import com.rjconsultores.ventaboletos.exception.BusinessException;
public interface TarifaOficialService { public interface TarifaOficialService {
@ -66,5 +67,35 @@ public interface TarifaOficialService {
* @param orgaoConcedenteId TODO * @param orgaoConcedenteId TODO
*/ */
public void atualizarTaxaEmbarque(Integer rutaId, Integer orgaoConcedenteId); public void atualizarTaxaEmbarque(Integer rutaId, Integer orgaoConcedenteId);
/**
* Atualiza o seguro de acordo a kilometragem do trecho
*
* @param rutaId - Se informado, será filtrado pela ruta
* @param orgaoId -Campo obrigatório
*/
public void atualizarSeguroPorKm(Integer rutaId,Integer orgaoId) throws BusinessException;
/**
* Atualiza o seguro de acordo o valor da tarifa
*
* @param rutaId - Se informado, será filtrado pela ruta
* @param orgaoId -Campo obrigatório
*
*/
public void atualizarSeguroPorTarifa(Integer rutaId, Integer orgaoId) throws BusinessException;
/**
* Executa tanto o {@link #atualizarSeguroPorKm(Integer, Integer)} quanto {@link #atualizarSeguroPorTarifa(Integer, Integer)}
*
* @param rutaId
* @param orgaoId
* @throws BusinessException
*/
public void atualizarSeguro(Integer rutaId, Integer orgaoId) throws BusinessException;
} }

View File

@ -14,17 +14,4 @@ public class SeguroServiceKmImpl implements SeguroKmService{
@Autowired @Autowired
private SeguroKmDAO seguroKmDAO; private SeguroKmDAO seguroKmDAO;
@Override
@Transactional
public void atualizarSeguroPorKm(Integer rutaId, Integer orgaoId) throws BusinessException {
if (orgaoId == null){
throw new BusinessException("SeguroServiceImpl.msg.validacion.orgaoObligatorio");
}
seguroKmDAO.atualizarSeguroPorKm(rutaId, orgaoId, UsuarioLogado.getUsuarioLogado().getUsuarioId());
}
} }

View File

@ -4,9 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.rjconsultores.ventaboletos.dao.SeguroTarifaDAO; import com.rjconsultores.ventaboletos.dao.SeguroTarifaDAO;
import com.rjconsultores.ventaboletos.exception.BusinessException;
import com.rjconsultores.ventaboletos.service.SeguroTarifaService; import com.rjconsultores.ventaboletos.service.SeguroTarifaService;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
@Service("seguroTarifaService") @Service("seguroTarifaService")
public class SeguroTarifaServiceImpl implements SeguroTarifaService { public class SeguroTarifaServiceImpl implements SeguroTarifaService {
@ -14,13 +12,6 @@ public class SeguroTarifaServiceImpl implements SeguroTarifaService {
@Autowired @Autowired
private SeguroTarifaDAO seguroTarifaDAO; private SeguroTarifaDAO seguroTarifaDAO;
@Override
public void atualizarSeguroPorTarifa(Integer rutaId, Integer orgaoId) throws BusinessException {
if (orgaoId == null){
throw new BusinessException("SeguroServiceImpl.msg.validacion.orgaoObligatorio");
}
seguroTarifaDAO.atualizarSeguroPorTarifa(rutaId, orgaoId, UsuarioLogado.getUsuarioLogado().getUsuarioId());
}
} }

View File

@ -6,6 +6,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO; import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO;
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa; import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
import com.rjconsultores.ventaboletos.exception.BusinessException;
import com.rjconsultores.ventaboletos.service.TarifaOficialService; import com.rjconsultores.ventaboletos.service.TarifaOficialService;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
@ -48,5 +49,38 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
public void atualizarTaxaEmbarque(Integer rutaId, Integer orgaoConcedenteId) { public void atualizarTaxaEmbarque(Integer rutaId, Integer orgaoConcedenteId) {
tarifaOficialDAO.atualizarTaxaEmbarque(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId); tarifaOficialDAO.atualizarTaxaEmbarque(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId);
} }
@Override
@Transactional
public void atualizarSeguroPorKm(Integer rutaId, Integer orgaoId) throws BusinessException {
if (orgaoId == null){
throw new BusinessException("TarifaOficialServiceImpl.msg.validacion.orgaoObligatorio");
}
tarifaOficialDAO.atualizarSeguroPorKm(rutaId, orgaoId, UsuarioLogado.getUsuarioLogado().getUsuarioId());
}
@Override
@Transactional
public void atualizarSeguroPorTarifa(Integer rutaId, Integer orgaoId) throws BusinessException {
if (orgaoId == null){
throw new BusinessException("TarifaOficialServiceImpl.msg.validacion.orgaoObligatorio");
}
tarifaOficialDAO.atualizarSeguroPorTarifa(rutaId, orgaoId, UsuarioLogado.getUsuarioLogado().getUsuarioId());
}
@Override
@Transactional
public void atualizarSeguro(Integer rutaId, Integer orgaoId) throws BusinessException {
if (orgaoId == null){
throw new BusinessException("TarifaOficialServiceImpl.msg.validacion.orgaoObligatorio");
}
atualizarSeguroPorKm(rutaId, orgaoId);
atualizarSeguroPorTarifa(rutaId, orgaoId);
}
} }