git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@20796 d1611594-4594-4d17-8e1d-87c2c4800839
parent
f7454100ad
commit
b4badfc5dd
|
@ -1,7 +1,13 @@
|
|||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
|
||||
|
||||
public interface SeguroKmDAO {
|
||||
|
||||
/**
|
||||
* Indica se existe seguroKm para o orgaoConcedenteId informado
|
||||
*
|
||||
* @param orgaoConcedenteId
|
||||
* @return
|
||||
*/
|
||||
public boolean existe(Integer orgaoConcedenteId);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,5 +2,11 @@ package com.rjconsultores.ventaboletos.dao;
|
|||
|
||||
|
||||
public interface SeguroTarifaDAO {
|
||||
|
||||
/**
|
||||
* Indica se existe seguroTarifa para o orgaoConcedenteId informado
|
||||
*
|
||||
* @param orgaoConcedenteId
|
||||
* @return
|
||||
*/
|
||||
public boolean existe(Integer orgaoConcedenteId);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import org.hibernate.SQLQuery;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.criterion.Projections;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.SeguroKmDAO;
|
||||
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
|
||||
import com.rjconsultores.ventaboletos.entidad.SeguroKm;
|
||||
|
||||
@Repository("seguroKmDAO")
|
||||
|
@ -18,5 +19,16 @@ public class SeguroKmHibernateDAO extends GenericHibernateDAO<SeguroKm, Integer>
|
|||
setSessionFactory(factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existe(Integer orgaoConcedenteId) {
|
||||
Criteria c= makeCriteria();
|
||||
c.add(Restrictions.eq("orgaoconcedente.orgaoConcedenteId", orgaoConcedenteId));
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
c.setProjection(Projections.rowCount());
|
||||
|
||||
|
||||
return HibernateFix.count(c.list()) > 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.criterion.Projections;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
@ -16,4 +19,15 @@ public class SeguroTarifaHibernateDAO extends GenericHibernateDAO<SeguroTarifa,
|
|||
setSessionFactory(factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existe(Integer orgaoConcedenteId) {
|
||||
Criteria c= makeCriteria();
|
||||
c.add(Restrictions.eq("orgaoconcedente.orgaoConcedenteId", orgaoConcedenteId));
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
c.setProjection(Projections.rowCount());
|
||||
|
||||
|
||||
return HibernateFix.count(c.list()) > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ package com.rjconsultores.ventaboletos.entidad;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
@ -15,6 +17,8 @@ import javax.persistence.ManyToOne;
|
|||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
|
@ -31,12 +35,18 @@ public class SeguroKm implements Serializable {
|
|||
private Integer segurokmId;
|
||||
@Column(name = "KMATE")
|
||||
private Integer kmate;
|
||||
// @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
|
||||
@Column(name = "VALORTAXA")
|
||||
private BigDecimal valortaxa;
|
||||
@JoinColumn(name = "ORGAOCONCEDENTE_ID", referencedColumnName = "ORGAOCONCEDENTE_ID")
|
||||
@ManyToOne
|
||||
private OrgaoConcedente orgaoconcedenteId;
|
||||
private OrgaoConcedente orgaoconcedente;
|
||||
@Column(name = "ACTIVO")
|
||||
private Boolean activo;
|
||||
@Column(name = "FECMODIF")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date fecmodif;
|
||||
@Column(name = "USUARIO_ID")
|
||||
private Integer usuarioId;
|
||||
|
||||
public SeguroKm() {
|
||||
}
|
||||
|
@ -69,13 +79,7 @@ public class SeguroKm implements Serializable {
|
|||
this.valortaxa = valortaxa;
|
||||
}
|
||||
|
||||
public OrgaoConcedente getOrgaoconcedenteId() {
|
||||
return orgaoconcedenteId;
|
||||
}
|
||||
|
||||
public void setOrgaoconcedenteId(OrgaoConcedente orgaoconcedenteId) {
|
||||
this.orgaoconcedenteId = orgaoconcedenteId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
@ -102,4 +106,36 @@ public class SeguroKm implements Serializable {
|
|||
return "com.rjconsultores.ventaboletos.entidad.SeguroKm[ segurokmId=" + segurokmId + " ]";
|
||||
}
|
||||
|
||||
public OrgaoConcedente getOrgaoconcedente() {
|
||||
return orgaoconcedente;
|
||||
}
|
||||
|
||||
public void setOrgaoconcedente(OrgaoConcedente orgaoconcedente) {
|
||||
this.orgaoconcedente = orgaoconcedente;
|
||||
}
|
||||
|
||||
public Boolean getActivo() {
|
||||
return activo;
|
||||
}
|
||||
|
||||
public void setActivo(Boolean activo) {
|
||||
this.activo = activo;
|
||||
}
|
||||
|
||||
public Date getFecmodif() {
|
||||
return fecmodif;
|
||||
}
|
||||
|
||||
public void setFecmodif(Date fecmodif) {
|
||||
this.fecmodif = fecmodif;
|
||||
}
|
||||
|
||||
public Integer getUsuarioId() {
|
||||
return usuarioId;
|
||||
}
|
||||
|
||||
public void setUsuarioId(Integer usuarioId) {
|
||||
this.usuarioId = usuarioId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ package com.rjconsultores.ventaboletos.entidad;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
@ -15,6 +17,8 @@ import javax.persistence.ManyToOne;
|
|||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
|
@ -29,14 +33,20 @@ public class SeguroTarifa implements Serializable {
|
|||
@Basic(optional = false)
|
||||
@Column(name = "SEGUROTARIFA_ID")
|
||||
private Integer segurotarifaId;
|
||||
// @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 = "VALORTARIFAATE")
|
||||
private BigDecimal valortarifaate;
|
||||
@JoinColumn(name = "ORGAOCONCEDENTE_ID", referencedColumnName = "ORGAOCONCEDENTE_ID")
|
||||
@ManyToOne
|
||||
private OrgaoConcedente orgaoconcedenteId;
|
||||
private OrgaoConcedente orgaoconcedente;
|
||||
@Column(name = "ACTIVO")
|
||||
private Boolean activo;
|
||||
@Column(name = "FECMODIF")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date fecmodif;
|
||||
@Column(name = "USUARIO_ID")
|
||||
private Integer usuarioId;
|
||||
|
||||
public SeguroTarifa() {
|
||||
}
|
||||
|
@ -62,13 +72,6 @@ public class SeguroTarifa implements Serializable {
|
|||
}
|
||||
|
||||
|
||||
public OrgaoConcedente getOrgaoconcedenteId() {
|
||||
return orgaoconcedenteId;
|
||||
}
|
||||
|
||||
public void setOrgaoconcedenteId(OrgaoConcedente orgaoconcedenteId) {
|
||||
this.orgaoconcedenteId = orgaoconcedenteId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
@ -103,4 +106,36 @@ public class SeguroTarifa implements Serializable {
|
|||
this.valortarifaate = valortarifaate;
|
||||
}
|
||||
|
||||
public OrgaoConcedente getOrgaoconcedente() {
|
||||
return orgaoconcedente;
|
||||
}
|
||||
|
||||
public void setOrgaoconcedente(OrgaoConcedente orgaoconcedente) {
|
||||
this.orgaoconcedente = orgaoconcedente;
|
||||
}
|
||||
|
||||
public Boolean getActivo() {
|
||||
return activo;
|
||||
}
|
||||
|
||||
public void setActivo(Boolean activo) {
|
||||
this.activo = activo;
|
||||
}
|
||||
|
||||
public Date getFecmodif() {
|
||||
return fecmodif;
|
||||
}
|
||||
|
||||
public void setFecmodif(Date fecmodif) {
|
||||
this.fecmodif = fecmodif;
|
||||
}
|
||||
|
||||
public Integer getUsuarioId() {
|
||||
return usuarioId;
|
||||
}
|
||||
|
||||
public void setUsuarioId(Integer usuarioId) {
|
||||
this.usuarioId = usuarioId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.SeguroKmDAO;
|
||||
import com.rjconsultores.ventaboletos.dao.SeguroTarifaDAO;
|
||||
import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||
|
@ -15,6 +17,10 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
|||
|
||||
@Autowired
|
||||
private TarifaOficialDAO tarifaOficialDAO;
|
||||
@Autowired
|
||||
private SeguroKmDAO seguroKmDAO;
|
||||
@Autowired
|
||||
private SeguroTarifaDAO seguroTarifaDAO;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
|
@ -25,7 +31,7 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
|||
@Override
|
||||
@Transactional
|
||||
public Integer atualizarTarifaPorCoeficiente(Integer rutaId, Integer orgaoConcedenteId) {
|
||||
return tarifaOficialDAO.atualizarTarifaCoeficiente(rutaId,UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId);
|
||||
return tarifaOficialDAO.atualizarTarifaCoeficiente(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,10 +41,10 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor=BusinessException.class)
|
||||
public Integer gerarAtualizarTarifaPorCoeficiente(Integer rudaId, Integer orgaoConcedenteId) throws BusinessException {
|
||||
|
||||
if (orgaoConcedenteId == null){
|
||||
if (orgaoConcedenteId == null) {
|
||||
throw new BusinessException("TarifaOficialServiceImpl.msg.validacion.orgaoObligatorio");
|
||||
}
|
||||
|
||||
|
@ -55,10 +61,10 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor=BusinessException.class)
|
||||
public void atualizarSeguroPorKm(Integer rutaId, Integer orgaoId) throws BusinessException {
|
||||
|
||||
if (orgaoId == null){
|
||||
if (orgaoId == null) {
|
||||
throw new BusinessException("TarifaOficialServiceImpl.msg.validacion.orgaoObligatorio");
|
||||
}
|
||||
|
||||
|
@ -67,9 +73,9 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor=BusinessException.class)
|
||||
public void atualizarSeguroPorTarifa(Integer rutaId, Integer orgaoId) throws BusinessException {
|
||||
if (orgaoId == null){
|
||||
if (orgaoId == null) {
|
||||
throw new BusinessException("TarifaOficialServiceImpl.msg.validacion.orgaoObligatorio");
|
||||
}
|
||||
|
||||
|
@ -77,14 +83,17 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor=BusinessException.class)
|
||||
public void atualizarSeguro(Integer rutaId, Integer orgaoId) throws BusinessException {
|
||||
if (orgaoId == null){
|
||||
if (orgaoId == null) {
|
||||
throw new BusinessException("TarifaOficialServiceImpl.msg.validacion.orgaoObligatorio");
|
||||
}
|
||||
|
||||
atualizarSeguroPorKm(rutaId, orgaoId);
|
||||
atualizarSeguroPorTarifa(rutaId, orgaoId);
|
||||
if (seguroKmDAO.existe(orgaoId)) {
|
||||
atualizarSeguroPorKm(rutaId, orgaoId);
|
||||
} else if (seguroTarifaDAO.existe(orgaoId)) {
|
||||
atualizarSeguroPorTarifa(rutaId, orgaoId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue