From 1c0489e9a8443af4c1e0f769eb198f3ba651acb8 Mon Sep 17 00:00:00 2001 From: valdir Date: Fri, 31 May 2019 20:38:25 +0000 Subject: [PATCH] =?UTF-8?q?0014278:=20Ativa=C3=A7=C3=A3o=20da=20Conting?= =?UTF-8?q?=C3=AAncia=20por=20Estado=20no=20m=C3=B3dulo=20ADM=20bug#14278?= =?UTF-8?q?=20dev:emerson=20qua:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Primeira parte git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@94043 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../constantes/ConstantesFuncionSistema.java | 1 + .../dao/LogHistoricoContingenciaDAO.java | 15 +++ .../LogHistoricoContingenciaHibernateDAO.java | 42 +++++++ .../entidad/LogHistoricoContingencia.java | 113 ++++++++++++++++++ .../service/ContingenciaService.java | 13 ++ .../service/impl/ContingenciaServiceImpl.java | 51 ++++++++ 6 files changed, 235 insertions(+) create mode 100644 src/com/rjconsultores/ventaboletos/dao/LogHistoricoContingenciaDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/dao/hibernate/LogHistoricoContingenciaHibernateDAO.java create mode 100644 src/com/rjconsultores/ventaboletos/entidad/LogHistoricoContingencia.java create mode 100644 src/com/rjconsultores/ventaboletos/service/ContingenciaService.java create mode 100644 src/com/rjconsultores/ventaboletos/service/impl/ContingenciaServiceImpl.java diff --git a/src/com/rjconsultores/ventaboletos/constantes/ConstantesFuncionSistema.java b/src/com/rjconsultores/ventaboletos/constantes/ConstantesFuncionSistema.java index 91cad56ba..60a425ae8 100644 --- a/src/com/rjconsultores/ventaboletos/constantes/ConstantesFuncionSistema.java +++ b/src/com/rjconsultores/ventaboletos/constantes/ConstantesFuncionSistema.java @@ -21,6 +21,7 @@ public class ConstantesFuncionSistema { public static final String CLAVE_TARIFAS_DESABILITAR_BOTAO_EXCLUIR_TODOS = "COM.RJCONSULTORES.VENTABOLETOS.GUI.ADM.PRECO.EXCLUIR.TODAS.PESQUISA"; public static final String CLAVE_CONFIGURACAO_VENDA_EMBARCADA = "COM.RJCONSULTORES.ADMINISTRACION.GUI.ESQUEMAOPERACIONAL.MENU.CONFVENDAEMBARCADA"; public static final String CLAVE_RELATORIO_VENDA_EMBARCADA = "COM.RJCONSULTORES.ADMINISTRACION.GUI.RELATORIOS.MENU.RELATORIOVENDAEMBARCADA"; + public static final String CLAVE_CONTINGENCIA = "COM.RJCONSULTORES.ADMINISTRACION.GUI.SEGURIDAD.MENU.CONTINGENCIA"; diff --git a/src/com/rjconsultores/ventaboletos/dao/LogHistoricoContingenciaDAO.java b/src/com/rjconsultores/ventaboletos/dao/LogHistoricoContingenciaDAO.java new file mode 100644 index 000000000..0674928a2 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/LogHistoricoContingenciaDAO.java @@ -0,0 +1,15 @@ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.LogHistoricoContingencia; + +/** + * @author vjcor + * + */ +public interface LogHistoricoContingenciaDAO extends GenericDAO { + + public List buscarHistorico(Integer empresaID, Integer estadoID); + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/LogHistoricoContingenciaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/LogHistoricoContingenciaHibernateDAO.java new file mode 100644 index 000000000..1b485d9d2 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/LogHistoricoContingenciaHibernateDAO.java @@ -0,0 +1,42 @@ +/** + * + */ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import java.util.List; + +import org.hibernate.Query; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; + +import com.rjconsultores.ventaboletos.dao.LogHistoricoContingenciaDAO; +import com.rjconsultores.ventaboletos.entidad.LogHistoricoContingencia; + +/** + * @author vjcor + * + */ +@Repository("LogHistoricoContingenciaDAO") +@SuppressWarnings("unchecked") +public class LogHistoricoContingenciaHibernateDAO extends GenericHibernateDAO implements LogHistoricoContingenciaDAO { + + @Autowired + public LogHistoricoContingenciaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @Override + public List buscarHistorico(Integer empresaID, Integer estadoID) { + String queryStr = "from LogHistoricoContingencia log where log.empresa.empresaId = :empresaId and log.estado.estadoId = :estadoId"; + + Query query = getSession().createQuery(queryStr); + query.setInteger("empresaId", empresaID); + query.setInteger("estadoId", estadoID); + + return (List) query.list(); + } + + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/LogHistoricoContingencia.java b/src/com/rjconsultores/ventaboletos/entidad/LogHistoricoContingencia.java new file mode 100644 index 000000000..7f6ac08f6 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/LogHistoricoContingencia.java @@ -0,0 +1,113 @@ +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.JoinColumn; +import javax.persistence.OneToOne; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +/** + * @author vjcor + * + */ +@Entity +@Table(name = "LOG_HISTORICO_CONTINGENCIA") +@SequenceGenerator(name = "LOG_HISTORICO_CONTINGENCIA_SEQ", sequenceName = "LOG_HISTORICO_CONTINGENCIA_SEQ", allocationSize = 1) +public class LogHistoricoContingencia implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "LOG_HISTORICO_CONTINGENCIA_SEQ") + @Column(name = "LOGHISTORICOCONTINGENCIA_ID") + private Long LogHistoricoContingenciaId; + + @Column(name = "MOTIVO") + private String motivo; + + @OneToOne + @JoinColumn(name = "USUARIO_ID") + private Usuario usuario; + + @Column(name = "DATAHORA") + @Temporal(TemporalType.TIMESTAMP) + private Date dataHora; + + @OneToOne + @JoinColumn(name = "EMPRESA_ID") + private Empresa empresa; + + @OneToOne + @JoinColumn(name = "ESTADO_ID") + private Estado estado; + + @Column(name = "STATUS") + private String status; + + public Long getLogHistoricoContingenciaId() { + return LogHistoricoContingenciaId; + } + + public void setLogHistoricoContingenciaId(Long logHistoricoContingenciaId) { + LogHistoricoContingenciaId = logHistoricoContingenciaId; + } + + public String getMotivo() { + return motivo; + } + + public void setMotivo(String motivo) { + this.motivo = motivo; + } + + public Usuario getUsuario() { + return usuario; + } + + public void setUsuario(Usuario usuario) { + this.usuario = usuario; + } + + public Date getDataHora() { + return dataHora; + } + + public void setDataHora(Date dataHora) { + this.dataHora = dataHora; + } + + public Empresa getEmpresa() { + return empresa; + } + + public void setEmpresa(Empresa empresa) { + this.empresa = empresa; + } + + public Estado getEstado() { + return estado; + } + + public void setEstado(Estado estado) { + this.estado = estado; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/src/com/rjconsultores/ventaboletos/service/ContingenciaService.java b/src/com/rjconsultores/ventaboletos/service/ContingenciaService.java new file mode 100644 index 000000000..0040b47ff --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/ContingenciaService.java @@ -0,0 +1,13 @@ +package com.rjconsultores.ventaboletos.service; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.LogHistoricoContingencia; +import com.rjconsultores.ventaboletos.exception.BusinessException; + +public interface ContingenciaService { + + public List buscarHistorico(Integer empresaID, Integer estadoID); + + public LogHistoricoContingencia salvarHistoricoContingencia(LogHistoricoContingencia historicoCont) throws BusinessException; +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/ContingenciaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/ContingenciaServiceImpl.java new file mode 100644 index 000000000..5c3c951cb --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/ContingenciaServiceImpl.java @@ -0,0 +1,51 @@ +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.LogHistoricoContingenciaDAO; +import com.rjconsultores.ventaboletos.entidad.LogHistoricoContingencia; +import com.rjconsultores.ventaboletos.exception.BusinessException; +import com.rjconsultores.ventaboletos.service.ContingenciaService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +/** + * @author vjcor + * + */ +@Service("contingenciaService") +public class ContingenciaServiceImpl implements ContingenciaService { + + @Autowired + private LogHistoricoContingenciaDAO histContingenciaDAO; + + public List buscarHistorico(Integer empresaID, Integer estadoID) { + return histContingenciaDAO.buscarHistorico(empresaID, estadoID); + } + + @Transactional + public LogHistoricoContingencia salvarHistoricoContingencia(LogHistoricoContingencia historicoCont) throws BusinessException { + + historicoCont.setUsuario(UsuarioLogado.getUsuarioLogado()); + historicoCont.setDataHora(Calendar.getInstance().getTime()); + + if (historicoCont.getEmpresa() == null) { + throw new BusinessException("Não é possível salvar sem a empresa"); + } + + if (historicoCont.getEstado() == null) { + throw new BusinessException("Não é possível salvar sem o estado referente"); + } + + if (historicoCont.getMotivo() == null) { + throw new BusinessException("Não é possível salvar sem o motivo referente"); + } + + return histContingenciaDAO.suscribir(historicoCont); + } + +}