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;
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface SeguroKmDAO {
|
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 {
|
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;
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
import org.hibernate.SQLQuery;
|
import org.hibernate.Criteria;
|
||||||
import org.hibernate.SessionFactory;
|
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.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.SeguroKmDAO;
|
import com.rjconsultores.ventaboletos.dao.SeguroKmDAO;
|
||||||
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.SeguroKm;
|
import com.rjconsultores.ventaboletos.entidad.SeguroKm;
|
||||||
|
|
||||||
@Repository("seguroKmDAO")
|
@Repository("seguroKmDAO")
|
||||||
|
@ -18,5 +19,16 @@ public class SeguroKmHibernateDAO extends GenericHibernateDAO<SeguroKm, Integer>
|
||||||
setSessionFactory(factory);
|
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;
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
|
import org.hibernate.Criteria;
|
||||||
import org.hibernate.SessionFactory;
|
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.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;
|
||||||
|
@ -16,4 +19,15 @@ public class SeguroTarifaHibernateDAO extends GenericHibernateDAO<SeguroTarifa,
|
||||||
setSessionFactory(factory);
|
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.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.persistence.Basic;
|
import javax.persistence.Basic;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
@ -15,6 +17,8 @@ import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.NamedQueries;
|
import javax.persistence.NamedQueries;
|
||||||
import javax.persistence.NamedQuery;
|
import javax.persistence.NamedQuery;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Temporal;
|
||||||
|
import javax.persistence.TemporalType;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,12 +35,18 @@ public class SeguroKm implements Serializable {
|
||||||
private Integer segurokmId;
|
private Integer segurokmId;
|
||||||
@Column(name = "KMATE")
|
@Column(name = "KMATE")
|
||||||
private Integer 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")
|
@Column(name = "VALORTAXA")
|
||||||
private BigDecimal valortaxa;
|
private BigDecimal valortaxa;
|
||||||
@JoinColumn(name = "ORGAOCONCEDENTE_ID", referencedColumnName = "ORGAOCONCEDENTE_ID")
|
@JoinColumn(name = "ORGAOCONCEDENTE_ID", referencedColumnName = "ORGAOCONCEDENTE_ID")
|
||||||
@ManyToOne
|
@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() {
|
public SeguroKm() {
|
||||||
}
|
}
|
||||||
|
@ -69,13 +79,7 @@ public class SeguroKm implements Serializable {
|
||||||
this.valortaxa = valortaxa;
|
this.valortaxa = valortaxa;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrgaoConcedente getOrgaoconcedenteId() {
|
|
||||||
return orgaoconcedenteId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrgaoconcedenteId(OrgaoConcedente orgaoconcedenteId) {
|
|
||||||
this.orgaoconcedenteId = orgaoconcedenteId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -102,4 +106,36 @@ public class SeguroKm implements Serializable {
|
||||||
return "com.rjconsultores.ventaboletos.entidad.SeguroKm[ segurokmId=" + segurokmId + " ]";
|
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.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.persistence.Basic;
|
import javax.persistence.Basic;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
@ -15,6 +17,8 @@ import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.NamedQueries;
|
import javax.persistence.NamedQueries;
|
||||||
import javax.persistence.NamedQuery;
|
import javax.persistence.NamedQuery;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Temporal;
|
||||||
|
import javax.persistence.TemporalType;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,14 +33,20 @@ public class SeguroTarifa implements Serializable {
|
||||||
@Basic(optional = false)
|
@Basic(optional = false)
|
||||||
@Column(name = "SEGUROTARIFA_ID")
|
@Column(name = "SEGUROTARIFA_ID")
|
||||||
private Integer segurotarifaId;
|
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")
|
@Column(name = "VALORTARIFA")
|
||||||
private BigDecimal valortarifa;
|
private BigDecimal valortarifa;
|
||||||
@Column(name = "VALORTARIFAATE")
|
@Column(name = "VALORTARIFAATE")
|
||||||
private BigDecimal valortarifaate;
|
private BigDecimal valortarifaate;
|
||||||
@JoinColumn(name = "ORGAOCONCEDENTE_ID", referencedColumnName = "ORGAOCONCEDENTE_ID")
|
@JoinColumn(name = "ORGAOCONCEDENTE_ID", referencedColumnName = "ORGAOCONCEDENTE_ID")
|
||||||
@ManyToOne
|
@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() {
|
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
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -103,4 +106,36 @@ public class SeguroTarifa implements Serializable {
|
||||||
this.valortarifaate = valortarifaate;
|
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.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
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.dao.TarifaOficialDAO;
|
||||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||||
|
@ -15,6 +17,10 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TarifaOficialDAO tarifaOficialDAO;
|
private TarifaOficialDAO tarifaOficialDAO;
|
||||||
|
@Autowired
|
||||||
|
private SeguroKmDAO seguroKmDAO;
|
||||||
|
@Autowired
|
||||||
|
private SeguroTarifaDAO seguroTarifaDAO;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@ -25,7 +31,7 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Integer atualizarTarifaPorCoeficiente(Integer rutaId, Integer orgaoConcedenteId) {
|
public Integer atualizarTarifaPorCoeficiente(Integer rutaId, Integer orgaoConcedenteId) {
|
||||||
return tarifaOficialDAO.atualizarTarifaCoeficiente(rutaId,UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId);
|
return tarifaOficialDAO.atualizarTarifaCoeficiente(rutaId, UsuarioLogado.getUsuarioLogado().getUsuarioId(), orgaoConcedenteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,10 +41,10 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional(rollbackFor=BusinessException.class)
|
||||||
public Integer gerarAtualizarTarifaPorCoeficiente(Integer rudaId, Integer orgaoConcedenteId) throws BusinessException {
|
public Integer gerarAtualizarTarifaPorCoeficiente(Integer rudaId, Integer orgaoConcedenteId) throws BusinessException {
|
||||||
|
|
||||||
if (orgaoConcedenteId == null){
|
if (orgaoConcedenteId == null) {
|
||||||
throw new BusinessException("TarifaOficialServiceImpl.msg.validacion.orgaoObligatorio");
|
throw new BusinessException("TarifaOficialServiceImpl.msg.validacion.orgaoObligatorio");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,10 +61,10 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional(rollbackFor=BusinessException.class)
|
||||||
public void atualizarSeguroPorKm(Integer rutaId, Integer orgaoId) throws BusinessException {
|
public void atualizarSeguroPorKm(Integer rutaId, Integer orgaoId) throws BusinessException {
|
||||||
|
|
||||||
if (orgaoId == null){
|
if (orgaoId == null) {
|
||||||
throw new BusinessException("TarifaOficialServiceImpl.msg.validacion.orgaoObligatorio");
|
throw new BusinessException("TarifaOficialServiceImpl.msg.validacion.orgaoObligatorio");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,9 +73,9 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional(rollbackFor=BusinessException.class)
|
||||||
public void atualizarSeguroPorTarifa(Integer rutaId, Integer orgaoId) throws BusinessException {
|
public void atualizarSeguroPorTarifa(Integer rutaId, Integer orgaoId) throws BusinessException {
|
||||||
if (orgaoId == null){
|
if (orgaoId == null) {
|
||||||
throw new BusinessException("TarifaOficialServiceImpl.msg.validacion.orgaoObligatorio");
|
throw new BusinessException("TarifaOficialServiceImpl.msg.validacion.orgaoObligatorio");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,14 +83,17 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional(rollbackFor=BusinessException.class)
|
||||||
public void atualizarSeguro(Integer rutaId, Integer orgaoId) throws BusinessException {
|
public void atualizarSeguro(Integer rutaId, Integer orgaoId) throws BusinessException {
|
||||||
if (orgaoId == null){
|
if (orgaoId == null) {
|
||||||
throw new BusinessException("TarifaOficialServiceImpl.msg.validacion.orgaoObligatorio");
|
throw new BusinessException("TarifaOficialServiceImpl.msg.validacion.orgaoObligatorio");
|
||||||
}
|
}
|
||||||
|
|
||||||
atualizarSeguroPorKm(rutaId, orgaoId);
|
if (seguroKmDAO.existe(orgaoId)) {
|
||||||
atualizarSeguroPorTarifa(rutaId, orgaoId);
|
atualizarSeguroPorKm(rutaId, orgaoId);
|
||||||
|
} else if (seguroTarifaDAO.existe(orgaoId)) {
|
||||||
|
atualizarSeguroPorTarifa(rutaId, orgaoId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue