0014278: Ativação da Contingência por Estado no módulo ADM

bug#14278
dev:emerson
qua:

Primeira parte

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@94043 d1611594-4594-4d17-8e1d-87c2c4800839
master
valdir 2019-05-31 20:38:25 +00:00
parent 165cb1c361
commit 1c0489e9a8
6 changed files with 235 additions and 0 deletions

View File

@ -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_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_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_RELATORIO_VENDA_EMBARCADA = "COM.RJCONSULTORES.ADMINISTRACION.GUI.RELATORIOS.MENU.RELATORIOVENDAEMBARCADA";
public static final String CLAVE_CONTINGENCIA = "COM.RJCONSULTORES.ADMINISTRACION.GUI.SEGURIDAD.MENU.CONTINGENCIA";

View File

@ -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<LogHistoricoContingencia, Long> {
public List<LogHistoricoContingencia> buscarHistorico(Integer empresaID, Integer estadoID);
}

View File

@ -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<LogHistoricoContingencia, Long> implements LogHistoricoContingenciaDAO {
@Autowired
public LogHistoricoContingenciaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
setSessionFactory(factory);
}
@Override
public List<LogHistoricoContingencia> 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<LogHistoricoContingencia>) query.list();
}
}

View File

@ -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;
}
}

View File

@ -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<LogHistoricoContingencia> buscarHistorico(Integer empresaID, Integer estadoID);
public LogHistoricoContingencia salvarHistoricoContingencia(LogHistoricoContingencia historicoCont) throws BusinessException;
}

View File

@ -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<LogHistoricoContingencia> 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);
}
}