From 7c5ea938e53461dbde77b4ae3fdd28a9ea5b5137 Mon Sep 17 00:00:00 2001 From: frederico Date: Wed, 19 Oct 2016 12:18:03 +0000 Subject: [PATCH] fixed bug #7907 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@61757 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../dao/TipoInformativoComissaoDAO.java | 8 ++ .../ConferenciaComissaoHibernateDAO.java | 11 +- .../TipoInformativoComissaoHibernateDAO.java | 45 ++++++++ .../ventaboletos/entidad/LogConferencia.java | 23 +++- .../entidad/TipoInformativoComissao.java | 101 ++++++++++++++++++ .../TipoInformativoComissaoService.java | 8 ++ .../TipoInformativoComissaoServiceImpl.java | 63 +++++++++++ .../vo/comissao/LogConferenciaVO.java | 37 ++++--- 8 files changed, 275 insertions(+), 21 deletions(-) create mode 100644 src/com/rjconsultores/ventaboletos/dao/TipoInformativoComissaoDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/TipoInformativoComissaoHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/TipoInformativoComissao.java create mode 100644 src/com/rjconsultores/ventaboletos/service/TipoInformativoComissaoService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/TipoInformativoComissaoServiceImpl.java diff --git a/src/com/rjconsultores/ventaboletos/dao/TipoInformativoComissaoDAO.java b/src/com/rjconsultores/ventaboletos/dao/TipoInformativoComissaoDAO.java new file mode 100644 index 000000000..fb00117d7 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/TipoInformativoComissaoDAO.java @@ -0,0 +1,8 @@ +package com.rjconsultores.ventaboletos.dao; + +import com.rjconsultores.ventaboletos.entidad.TipoInformativoComissao; + +public interface TipoInformativoComissaoDAO extends GenericDAO { + + Boolean existeTipoInformativo(TipoInformativoComissao tipo); +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/ConferenciaComissaoHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConferenciaComissaoHibernateDAO.java index c7d57ad4e..370853062 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/ConferenciaComissaoHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/ConferenciaComissaoHibernateDAO.java @@ -566,12 +566,13 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO + implements TipoInformativoComissaoDAO { + + @Autowired + public TipoInformativoComissaoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @SuppressWarnings("unchecked") + @Override + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + + return c.list(); + } + + @Override + public Boolean existeTipoInformativo(TipoInformativoComissao tipo) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("desctipo", tipo.getDesctipo())); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + + if (tipo.getTipoinformativoId() != null) { + c.add(Restrictions.ne("tipoinformativoId", tipo.getTipoinformativoId())); + } + + return c.list().isEmpty(); + } +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/LogConferencia.java b/src/com/rjconsultores/ventaboletos/entidad/LogConferencia.java index b2fffe958..2ab0c1248 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/LogConferencia.java +++ b/src/com/rjconsultores/ventaboletos/entidad/LogConferencia.java @@ -79,7 +79,11 @@ public class LogConferencia implements Serializable { private ContaCorrentePtoVta contaCorrentePtoVta; @Column(name = "INDCREDITO") - private boolean indcredito; + private Short indcredito; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "TIPOINFORMATIVOCOMISSAO_ID") + private TipoInformativoComissao tipoInformativoComissao; public Long getLogconferenciaId() { return logconferenciaId; @@ -208,12 +212,25 @@ public class LogConferencia implements Serializable { this.contaCorrentePtoVta = contaCorrentePtoVta; } - public boolean isIndcredito() { + /* + * 0 - Débito + * 1 - Crédito + * 2 - Informativo + */ + public Short isIndcredito() { return indcredito; } - public void setIndcredito(boolean indcredito) { + public void setIndcredito(Short indcredito) { this.indcredito = indcredito; } + public TipoInformativoComissao getTipoInformativoComissao() { + return tipoInformativoComissao; + } + + public void setTipoInformativoComissao(TipoInformativoComissao tipoInformativoComissao) { + this.tipoInformativoComissao = tipoInformativoComissao; + } + } diff --git a/src/com/rjconsultores/ventaboletos/entidad/TipoInformativoComissao.java b/src/com/rjconsultores/ventaboletos/entidad/TipoInformativoComissao.java new file mode 100644 index 000000000..3cedd8da4 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/TipoInformativoComissao.java @@ -0,0 +1,101 @@ +package com.rjconsultores.ventaboletos.entidad; + +import java.io.Serializable; +import java.util.Date; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@SequenceGenerator(name = "TIPO_INFORMATIVO_SEQ", sequenceName = "TIPO_INFORMATIVO_SEQ", allocationSize = 1) +@Table(name = "TIPO_INFORMATIVO") +public class TipoInformativoComissao implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "TIPO_INFORMATIVO_SEQ") + @Column(name = "TIPOINFORMATIVO_ID") + private Short tipoinformativoId; + @Column(name = "DESCTIPO") + private String desctipo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + @Column(name = "ACTIVO") + private Boolean activo; + + public Short getTipoinformativoId() { + return tipoinformativoId; + } + + public void setTipoinformativoId(Short tipoinformativoId) { + this.tipoinformativoId = tipoinformativoId; + } + + public String getDesctipo() { + return desctipo; + } + + public void setDesctipo(String desctipo) { + this.desctipo = desctipo; + } + + 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; + } + + public Boolean getActivo() { + return activo; + } + + public void setActivo(Boolean activo) { + this.activo = activo; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (tipoinformativoId != null ? tipoinformativoId.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof TipoInformativoComissao)) { + return false; + } + TipoInformativoComissao other = (TipoInformativoComissao) object; + if ((this.tipoinformativoId == null && other.tipoinformativoId != null) || (this.tipoinformativoId != null && !this.tipoinformativoId.equals(other.tipoinformativoId))) { + return false; + } + return true; + } + + @Override + public String toString() { + return desctipo; + } +} diff --git a/src/com/rjconsultores/ventaboletos/service/TipoInformativoComissaoService.java b/src/com/rjconsultores/ventaboletos/service/TipoInformativoComissaoService.java new file mode 100644 index 000000000..961645a91 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/TipoInformativoComissaoService.java @@ -0,0 +1,8 @@ +package com.rjconsultores.ventaboletos.service; + +import com.rjconsultores.ventaboletos.entidad.TipoInformativoComissao; + +public interface TipoInformativoComissaoService extends GenericService { + + Boolean existeTipoInformativo(TipoInformativoComissao tipo); +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/TipoInformativoComissaoServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/TipoInformativoComissaoServiceImpl.java new file mode 100644 index 000000000..f4891c55b --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/TipoInformativoComissaoServiceImpl.java @@ -0,0 +1,63 @@ +package com.rjconsultores.ventaboletos.service.impl; + +import java.util.Calendar; +import java.util.List; + +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.rjconsultores.ventaboletos.dao.TipoInformativoComissaoDAO; +import com.rjconsultores.ventaboletos.entidad.TipoInformativoComissao; +import com.rjconsultores.ventaboletos.service.TipoInformativoComissaoService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Service("tipoInformativoComissaoService") +public class TipoInformativoComissaoServiceImpl implements TipoInformativoComissaoService { + + @Autowired + private TipoInformativoComissaoDAO tipoInformativoComissaoDAO; + + public List obtenerTodos() { + return tipoInformativoComissaoDAO.obtenerTodos(); + } + + public TipoInformativoComissao obtenerID(Integer id) { + return tipoInformativoComissaoDAO.obtenerID(id); + } + + @Transactional + public TipoInformativoComissao suscribir(TipoInformativoComissao entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return tipoInformativoComissaoDAO.suscribir(entidad); + } + + @Transactional + public TipoInformativoComissao actualizacion(TipoInformativoComissao entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return tipoInformativoComissaoDAO.actualizacion(entidad); + } + + @Transactional + public void borrar(TipoInformativoComissao entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + tipoInformativoComissaoDAO.actualizacion(entidad); + } + + @Override + public Boolean existeTipoInformativo(TipoInformativoComissao tipo) { + return tipoInformativoComissaoDAO.existeTipoInformativo(tipo); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/vo/comissao/LogConferenciaVO.java b/src/com/rjconsultores/ventaboletos/vo/comissao/LogConferenciaVO.java index 51e59259f..acb326d4a 100644 --- a/src/com/rjconsultores/ventaboletos/vo/comissao/LogConferenciaVO.java +++ b/src/com/rjconsultores/ventaboletos/vo/comissao/LogConferenciaVO.java @@ -22,18 +22,19 @@ public class LogConferenciaVO { private String desctipoevento; private String nombusuario; private Date fecmodif; - private boolean indcredito; + private Short indcredito; private String nombempresa; private String nombpuntoventa; private Date datamovimento; private String desccategoria; private Integer tipoventa; private String descinfoevento; - + private String desctipoinformativo; + public LogConferenciaVO() { super(); } - + public LogConferenciaVO(Long logconferenciaId, String observacao, BigDecimal preco, Integer status, String numfoliosistema) { this(); this.logconferenciaId = logconferenciaId; @@ -87,10 +88,10 @@ public class LogConferenciaVO { public void setNumfoliosistema(String numfoliosistema) { this.numfoliosistema = numfoliosistema; } - + public String getStatusDescricao() { StatusLogConferencia statusLogConferencia = StatusLogConferencia.getStatusLogConferencia(status); - if(statusLogConferencia != null) { + if (statusLogConferencia != null) { return statusLogConferencia.toString(); } return ""; @@ -119,10 +120,10 @@ public class LogConferenciaVO { public void setTipo(Integer tipo) { this.tipo = tipo; } - + public String getTipoDescricao() { TipoLogConferencia tipoLogConferencia = TipoLogConferencia.getTipoLogConferencia(tipo); - if(tipoLogConferencia != null) { + if (tipoLogConferencia != null) { return tipoLogConferencia.toString(); } return ""; @@ -191,11 +192,11 @@ public class LogConferenciaVO { return true; } - public boolean isIndcredito() { + public Short isIndcredito() { return indcredito; } - public void setIndcredito(boolean indcredito) { + public void setIndcredito(Short indcredito) { this.indcredito = indcredito; } @@ -230,9 +231,9 @@ public class LogConferenciaVO { public void setDesccategoria(String desccategoria) { this.desccategoria = desccategoria; } - + public String getDebitoCredito() { - return isIndcredito() ? "C" : "D"; + return isIndcredito().equals((short) 0) ? "D" : isIndcredito().equals((short) 1) ? "C" : "I"; } public Integer getTipoventa() { @@ -250,13 +251,21 @@ public class LogConferenciaVO { public void setDescinfoevento(String descinfoevento) { this.descinfoevento = descinfoevento; } - + public String getDescricaoTipoventa() { return DescricaoTipoVenta.getDescricaoTipoVenta(getTipoventa()); } - + public String getDescdebitocredito() { - return isIndcredito() ? "C" : "D"; + return isIndcredito().equals((short) 0) ? "D" : isIndcredito().equals((short) 1) ? "C" : "I"; } + public String getDesctipoinformativo() { + return desctipoinformativo; + } + + public void setDesctipoinformativo(String desctipoinformativo) { + this.desctipoinformativo = desctipoinformativo; + } + }