gleimar 2012-08-27 21:46:18 +00:00
parent 909ad4400d
commit 0966d38b5d
10 changed files with 88 additions and 24 deletions

View File

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

View File

@ -3,9 +3,10 @@ package com.rjconsultores.ventaboletos.dao;
public interface TaxaEmbarqueDAO {
/**
* See {@link TaxaEmbarqueServic#atualizarTaxaEmbarque(Integer, Integer)}
* See {@link TaxaEmbarqueServic#atualizarTaxaEmbarque(Integer, Integer, Integer)}
* @param rutaId
* @param usuarioId TODO
* @param orgaoConcedenteId TODO
*/
public void atualizarTaxaEmbarque(Integer rutaId, Integer usuarioId);
public void atualizarTaxaEmbarque(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId);
}

View File

@ -21,17 +21,17 @@ public class TaxaEmbarqueHibernateDAO extends GenericHibernateDAO<Object, Intege
}
@Override
public void atualizarTaxaEmbarque(Integer rutaId, Integer usuarioId) {
public void atualizarTaxaEmbarque(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId) {
// Atualizo a taxa de embarque de acordo a parada e km
SQLQuery query = getSession().createSQLQuery(sqlBuilder.getSQLTaxaEmbarque1(rutaId, usuarioId));
SQLQuery query = getSession().createSQLQuery(sqlBuilder.getSQLTaxaEmbarque1(rutaId, usuarioId, orgaoConcedenteId));
query.executeUpdate();
// Atualizo a taxa de embarque de acordo a km do orgao
query = getSession().createSQLQuery(sqlBuilder.getSQLTaxaEmbarque2(rutaId, usuarioId));
query = getSession().createSQLQuery(sqlBuilder.getSQLTaxaEmbarque2(rutaId, usuarioId, orgaoConcedenteId));
query.executeUpdate();
// Atualizo a taxa de embarque de acordo a parada e valor fixo
query = getSession().createSQLQuery(sqlBuilder.getSQLTaxaEmbarque3(rutaId, usuarioId));
query = getSession().createSQLQuery(sqlBuilder.getSQLTaxaEmbarque3(rutaId, usuarioId, orgaoConcedenteId));
query.executeUpdate();
}

View File

@ -18,8 +18,8 @@ public interface SQLBuilder {
public String getSQLTarifaOficial2(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId);
public String getSQLTaxaEmbarque1(Integer rutaId, Integer usuarioId);
public String getSQLTaxaEmbarque2(Integer rutaId, Integer usuarioId);
public String getSQLTaxaEmbarque3(Integer rutaId, Integer usuarioId);
public String getSQLTaxaEmbarque1(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId);
public String getSQLTaxaEmbarque2(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId);
public String getSQLTaxaEmbarque3(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId);
}

View File

@ -154,7 +154,7 @@ public class SQLBuilderOracle implements SQLBuilder {
}
@Override
public String getSQLTaxaEmbarque1(Integer rutaId, Integer usuarioId) {
public String getSQLTaxaEmbarque1(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId) {
StringBuilder sb = new StringBuilder("");
sb.append("update tarifa_oficial set IMPORTETAXAEMBARQUE = ");
sb.append("( ");
@ -188,12 +188,15 @@ public class SQLBuilderOracle implements SQLBuilder {
if (rutaId != null){
sb.append(" and tarifa_oficial.ruta_id = ").append(rutaId);
}
if (orgaoConcedenteId != null){
sb.append(" and tarifa_oficial.orgaoconcedente_id = ").append(orgaoConcedenteId);
}
return sb.toString();
}
@Override
public String getSQLTaxaEmbarque2(Integer rutaId, Integer usuarioId) {
public String getSQLTaxaEmbarque2(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId) {
StringBuilder sb = new StringBuilder("");
sb.append("update tarifa_oficial set IMPORTETAXAEMBARQUE = ");
sb.append("coalesce( ");
@ -229,11 +232,15 @@ public class SQLBuilderOracle implements SQLBuilder {
if (rutaId != null){
sb.append(" and tarifa_oficial.ruta_id = ").append(rutaId);
}
if (orgaoConcedenteId != null){
sb.append(" and tarifa_oficial.orgaoconcedente_id = ").append(orgaoConcedenteId);
}
return sb.toString();
}
@Override
public String getSQLTaxaEmbarque3(Integer rutaId, Integer usuarioId) {
public String getSQLTaxaEmbarque3(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId) {
StringBuilder sb = new StringBuilder("");
sb.append("update tarifa_oficial set IMPORTETAXAEMBARQUE = ");
@ -261,6 +268,9 @@ public class SQLBuilderOracle implements SQLBuilder {
if (rutaId != null){
sb.append(" and tarifa_oficial.ruta_id = ").append(rutaId);
}
if (orgaoConcedenteId != null){
sb.append(" and tarifa_oficial.orgaoconcedente_id = ").append(orgaoConcedenteId);
}
return sb.toString();
}

View File

@ -32,8 +32,8 @@ public class SeguroTarifa implements Serializable {
// @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
@Column(name = "VALORTARIFA")
private BigDecimal valortarifa;
@Column(name = "VALORTAXA")
private BigDecimal valortaxa;
@Column(name = "VALORTARIFAATE")
private BigDecimal valortarifaate;
@JoinColumn(name = "ORGAOCONCEDENTE_ID", referencedColumnName = "ORGAOCONCEDENTE_ID")
@ManyToOne
private OrgaoConcedente orgaoconcedenteId;
@ -61,13 +61,6 @@ public class SeguroTarifa implements Serializable {
this.valortarifa = valortarifa;
}
public BigDecimal getValortaxa() {
return valortaxa;
}
public void setValortaxa(BigDecimal valortaxa) {
this.valortaxa = valortaxa;
}
public OrgaoConcedente getOrgaoconcedenteId() {
return orgaoconcedenteId;
@ -102,4 +95,12 @@ public class SeguroTarifa implements Serializable {
return "com.rjconsultores.ventaboletos.entidad.SeguroTarifa[ segurotarifaId=" + segurotarifaId + " ]";
}
public BigDecimal getValortarifaate() {
return valortarifaate;
}
public void setValortarifaate(BigDecimal valortarifaate) {
this.valortarifaate = valortarifaate;
}
}

View File

@ -0,0 +1,15 @@
package com.rjconsultores.ventaboletos.service;
import com.rjconsultores.ventaboletos.exception.BusinessException;
public interface SeguroService {
/**
* 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

@ -15,7 +15,8 @@ public interface TaxaEmbarqueService {
* A taxa de embarque mais restritiva fica por último (TAXA_EMBARQUE_PARADA por valor fixo)
*
* @param rutaId - Se informado, será atualizado apenas a taxa de embarque da ruta informada
* @param orgaoConcedenteId TODO
*/
public void atualizarTaxaEmbarque(Integer rutaId);
public void atualizarTaxaEmbarque(Integer rutaId, Integer orgaoConcedenteId);
}

View File

@ -0,0 +1,22 @@
package com.rjconsultores.ventaboletos.service.impl;
import org.springframework.stereotype.Service;
import com.rjconsultores.ventaboletos.exception.BusinessException;
import com.rjconsultores.ventaboletos.service.SeguroService;
@Service("seguroService")
public class SeguroServiceImpl implements SeguroService{
@Override
public void atualizarSeguroPorKm(Integer rutaId, Integer orgaoId) throws BusinessException {
if (orgaoId == null){
throw new BusinessException("SeguroServiceImpl.msg.validacion.orgaoObligatorio");
}
}
}

View File

@ -15,8 +15,8 @@ public class TaxaEmbarqueServiceImpl implements TaxaEmbarqueService{
@Override
@Transactional
public void atualizarTaxaEmbarque(Integer rutaId) {
taxaEmbarqueDAO.atualizarTaxaEmbarque(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId());
public void atualizarTaxaEmbarque(Integer rutaId, Integer orgaoConcedenteId) {
taxaEmbarqueDAO.atualizarTaxaEmbarque(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId);
}
}