From e8cfdede24f5cca872405485943e0d99cc476469 Mon Sep 17 00:00:00 2001 From: "bruno.neves" Date: Fri, 2 Dec 2016 18:03:42 +0000 Subject: [PATCH] =?UTF-8?q?fixed=20bug=20#0008306=20-=20Criado=20o=20CRUD?= =?UTF-8?q?=20do=20MotivoCancelVendaPacote=20fixed=20bug=20#0008313=20-=20?= =?UTF-8?q?Adicionada=20a=20coluna=20percentual=20de=20devolu=C3=A7=C3=A3o?= =?UTF-8?q?.=20percmulta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@63146 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../dao/MotivoCancelVendaPacoteDAO.java | 22 +++ .../MotivoCancelVendaPacotelHibernateDAO.java | 67 ++++++++ .../entidad/MotivoCancelVendaPacote.java | 149 ++++++++++++++++++ .../MotivoCancelVendaPacoteService.java | 25 +++ .../MotivoCancelVendaPacoteServiceImpl.java | 84 ++++++++++ 5 files changed, 347 insertions(+) create mode 100644 src/com/rjconsultores/ventaboletos/dao/MotivoCancelVendaPacoteDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/MotivoCancelVendaPacotelHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/MotivoCancelVendaPacote.java create mode 100644 src/com/rjconsultores/ventaboletos/service/MotivoCancelVendaPacoteService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/MotivoCancelVendaPacoteServiceImpl.java diff --git a/src/com/rjconsultores/ventaboletos/dao/MotivoCancelVendaPacoteDAO.java b/src/com/rjconsultores/ventaboletos/dao/MotivoCancelVendaPacoteDAO.java new file mode 100644 index 000000000..64a4d2c39 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/MotivoCancelVendaPacoteDAO.java @@ -0,0 +1,22 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.MotivoCancelVendaPacote; + +/** + * + * @author Bruno + */ +public interface MotivoCancelVendaPacoteDAO extends GenericDAO { + + public List buscar(String descmotivocancel, String tipomotivocancel); + + public List obtenerTodosTipoMotivoCancel(); + + public List obtenerTodosEspecificos(Integer[] motivos); +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/MotivoCancelVendaPacotelHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/MotivoCancelVendaPacotelHibernateDAO.java new file mode 100644 index 000000000..3b0b2b23f --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/MotivoCancelVendaPacotelHibernateDAO.java @@ -0,0 +1,67 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import java.util.List; + +import org.hibernate.Criteria; +import org.hibernate.SessionFactory; +import org.hibernate.criterion.Order; +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.MotivoCancelVendaPacoteDAO; +import com.rjconsultores.ventaboletos.entidad.MotivoCancelVendaPacote; + +/** + * + * @author Bruno + */ +@Repository("motivoCancelacionVendaPacoteDAO") +public class MotivoCancelVendaPacotelHibernateDAO extends GenericHibernateDAO + implements MotivoCancelVendaPacoteDAO { + + @Autowired + public MotivoCancelVendaPacotelHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @Override + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.addOrder(Order.asc("descmotivocancel")); + + return c.list(); + } + + public List buscar(String descmotivocancel, String tipomotivocancel) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("descmotivocancel", descmotivocancel)); + c.add(Restrictions.eq("tipomotivocancel", tipomotivocancel)); + + return c.list(); + } + + public List obtenerTodosTipoMotivoCancel() { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.addOrder(Order.asc("descmotivocancel")); + + return c.list(); + } + + public List obtenerTodosEspecificos(Integer[] motivos) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.in("motivocancelacionId", motivos)); + c.addOrder(Order.asc("descmotivocancel")); + + return c.list(); + } +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/MotivoCancelVendaPacote.java b/src/com/rjconsultores/ventaboletos/entidad/MotivoCancelVendaPacote.java new file mode 100644 index 000000000..d47c71c03 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/MotivoCancelVendaPacote.java @@ -0,0 +1,149 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +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; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.SequenceGenerator; + +/** + * + * @author Bruno + */ +@Entity +@SequenceGenerator(name = "MOTIVO_CANCEL_VENDA_PACOTE_SEQ", sequenceName = "MOTIVO_CANCEL_VENDA_PACOTE_SEQ", allocationSize = 1) +@Table(name = "MOTIVO_CANCEL_VENDA_PACOTE") +public class MotivoCancelVendaPacote implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "MOTIVO_CANCEL_VENDA_PACOTE_SEQ") + @Column(name = "MOTIVOCANCELVENDAPACOTE_ID") + private Integer motivocancelvendapacoteId; + @Column(name = "DESCMOTIVOCANCEL") + private String descmotivocancel; + @Column(name = "ACTIVO") + private Boolean activo; + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + @Column(name = "USUARIO_ID") + private Integer usuarioId; + @Column(name = "TIPOMOTIVOCANCEL") + private String tipomotivocancel; + + @Column(name="PORCMULTA") + private BigDecimal porcmulta; + + + public MotivoCancelVendaPacote() { + } + + + public Integer getMotivocancelvendapacoteId() { + return motivocancelvendapacoteId; + } + + + public void setMotivocancelvendapacoteId(Integer motivocancelvendapacoteId) { + this.motivocancelvendapacoteId = motivocancelvendapacoteId; + } + + + public String getDescmotivocancel() { + return descmotivocancel; + } + + + public void setDescmotivocancel(String descmotivocancel) { + this.descmotivocancel = descmotivocancel; + } + + + 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; + } + + + public String getTipomotivocancel() { + return tipomotivocancel; + } + + + public void setTipomotivocancel(String tipomotivocancel) { + this.tipomotivocancel = tipomotivocancel; + } + + public BigDecimal getPorcmulta() { + return porcmulta; + } + + + public void setPorcmulta(BigDecimal porcmulta) { + this.porcmulta = porcmulta; + } + + + @Override + public int hashCode() { + int hash = 0; + hash += (motivocancelvendapacoteId != null ? motivocancelvendapacoteId.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 MotivoCancelVendaPacote)) { + return false; + } + MotivoCancelVendaPacote other = (MotivoCancelVendaPacote) object; + if ((this.motivocancelvendapacoteId == null && other.motivocancelvendapacoteId != null) || (this.motivocancelvendapacoteId != null && !this.motivocancelvendapacoteId.equals(other.motivocancelvendapacoteId))) { + return false; + } + return true; + } + + @Override + public String toString() { + return this.getDescmotivocancel(); + } +} diff --git a/src/com/rjconsultores/ventaboletos/service/MotivoCancelVendaPacoteService.java b/src/com/rjconsultores/ventaboletos/service/MotivoCancelVendaPacoteService.java new file mode 100644 index 000000000..28345bea5 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/MotivoCancelVendaPacoteService.java @@ -0,0 +1,25 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.service; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.MotivoCancelVendaPacote; + +/** + * + * @author Bruno + * + */ +public interface MotivoCancelVendaPacoteService extends GenericService { + + public List buscar(String descmotivocancel, String tipomotivocancel); + + public List obtenerTodosTipoMotivoCancel(); + + public List obtenerTodosEspecificos(Integer[] motivos); + + public boolean validaMotivoCancelVendaPacoteConstante(MotivoCancelVendaPacote motivoCancelVendaPacote); +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/MotivoCancelVendaPacoteServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/MotivoCancelVendaPacoteServiceImpl.java new file mode 100644 index 000000000..78942eee6 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/MotivoCancelVendaPacoteServiceImpl.java @@ -0,0 +1,84 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.service.impl; + +import java.util.Calendar; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.rjconsultores.ventaboletos.dao.MotivoCancelVendaPacoteDAO; +import com.rjconsultores.ventaboletos.entidad.MotivoCancelVendaPacote; +import com.rjconsultores.ventaboletos.service.MotivoCancelVendaPacoteService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +/** + * + * @author Bruno + */ +@Service("motivoCancelVendaPacoteService") +public class MotivoCancelVendaPacoteServiceImpl implements MotivoCancelVendaPacoteService { + + @Autowired + private MotivoCancelVendaPacoteDAO motivoCancelVendaPacoteDAO; + public static final Integer MAX_CONS_MOV_CANCEL = Integer.valueOf(35); + + public List obtenerTodos() { + return motivoCancelVendaPacoteDAO.obtenerTodos(); + } + + public MotivoCancelVendaPacote obtenerID(Integer id) { + return motivoCancelVendaPacoteDAO.obtenerID(id); + } + + @Transactional + public MotivoCancelVendaPacote suscribir(MotivoCancelVendaPacote entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return motivoCancelVendaPacoteDAO.suscribir(entidad); + } + + @Transactional + public MotivoCancelVendaPacote actualizacion(MotivoCancelVendaPacote entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return motivoCancelVendaPacoteDAO.actualizacion(entidad); + } + + @Transactional + public void borrar(MotivoCancelVendaPacote entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + motivoCancelVendaPacoteDAO.actualizacion(entidad); + } + + public List buscar(String descmotivocancel, String tipomotivocancel) { + return motivoCancelVendaPacoteDAO.buscar(descmotivocancel, tipomotivocancel); + } + + public List obtenerTodosTipoMotivoCancel() { + return motivoCancelVendaPacoteDAO.obtenerTodosTipoMotivoCancel(); + } + + public List obtenerTodosEspecificos(Integer[] motivos) { + return motivoCancelVendaPacoteDAO.obtenerTodosEspecificos(motivos); + } + + public boolean validaMotivoCancelVendaPacoteConstante(MotivoCancelVendaPacote motivoCancelVendaPacote) { + if (motivoCancelVendaPacote.getMotivocancelvendapacoteId() <= MAX_CONS_MOV_CANCEL) + return false; + else + return true; + } + +}