diff --git a/src/com/rjconsultores/ventaboletos/dao/FechamentoParamptovtaDAO.java b/src/com/rjconsultores/ventaboletos/dao/FechamentoParamptovtaDAO.java new file mode 100644 index 000000000..1effcceab --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/FechamentoParamptovtaDAO.java @@ -0,0 +1,13 @@ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.FechamentoParamptovta; + +public interface FechamentoParamptovtaDAO extends GenericDAO { + + public List buscaParametrosPorEmpresas(List empresasId); + public List buscaParametrosPorEmpresa(Integer empresasId); + public FechamentoParamptovta buscaParametrosPorPuntoventa(Integer puntoventaId); + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/FechamentoParamptovtaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/FechamentoParamptovtaHibernateDAO.java new file mode 100644 index 000000000..0ea9fb604 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/FechamentoParamptovtaHibernateDAO.java @@ -0,0 +1,73 @@ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import java.util.Calendar; +import java.util.List; + +import org.hibernate.Criteria; +import org.hibernate.SessionFactory; +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.FechamentoParamptovtaDAO; +import com.rjconsultores.ventaboletos.entidad.FechamentoParamptovta; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@Repository("fechamentoParamptovtaDAO") +public class FechamentoParamptovtaHibernateDAO extends GenericHibernateDAO implements FechamentoParamptovtaDAO { + + + @Autowired + public FechamentoParamptovtaHibernateDAO( + @Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @Override + public List buscaParametrosPorEmpresas(List empresasId) { + Criteria query = getSession().createCriteria(getPersistentClass()); + query.createAlias("empresa", "emp"); + query.add(Restrictions.in("emp.empresaId", empresasId)); + query.add(Restrictions.eq("activo", Boolean.TRUE)); + + return (List)query.list(); + } + + @Override + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + + return (List)c.list(); + } + + @Override + public List buscaParametrosPorEmpresa(Integer empresaId) { + Criteria query = getSession().createCriteria(getPersistentClass()); + query.createAlias("empresa", "emp"); + query.add(Restrictions.eq("emp.empresaId", empresaId)); + query.add(Restrictions.eq("activo", Boolean.TRUE)); + + return (List)query.list(); + } + + @Override + public void borrar(FechamentoParamptovta entity) { + entity.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entity.setFecmodif(Calendar.getInstance().getTime()); + entity.setActivo(Boolean.FALSE); + actualizacion(entity); + } + + @Override + public FechamentoParamptovta buscaParametrosPorPuntoventa(Integer puntoventaId) { + Criteria query = getSession().createCriteria(getPersistentClass()); + query.createAlias("puntoventa", "ptovta"); + query.add(Restrictions.eq("ptovta.puntoventaId", puntoventaId)); + query.add(Restrictions.eq("activo", Boolean.TRUE)); + + return (FechamentoParamptovta)query.uniqueResult(); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/FechamentoParamptovta.java b/src/com/rjconsultores/ventaboletos/entidad/FechamentoParamptovta.java new file mode 100644 index 000000000..3945bd1b0 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/FechamentoParamptovta.java @@ -0,0 +1,122 @@ +package com.rjconsultores.ventaboletos.entidad; + +import java.io.Serializable; +import java.util.Date; + +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.ManyToOne; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name = "FECHAMENTO_PARAMPTOVTA") +public class FechamentoParamptovta implements Serializable { + + private Long fechamentoparamptovtaId; + private PuntoVenta puntoventa; + private Empresa empresa; + private Integer intervalofechamento; + private Date fecmodif; + private Integer usuarioId; + private Boolean activo; + + public FechamentoParamptovta() { + } + + public FechamentoParamptovta( PuntoVenta puntoventa, Empresa empresa, Integer usuarioId) { + this.puntoventa = puntoventa; + this.empresa = empresa; + + this.fecmodif = new Date(); + this.usuarioId = usuarioId; + this.activo = true; + } + + public FechamentoParamptovta( + PuntoVenta puntoventa, Empresa empresa, Integer intervalofechamento, + Date fecmodif, Integer usuarioId, Boolean activo) { + this.puntoventa = puntoventa; + this.empresa = empresa; + this.intervalofechamento = intervalofechamento; + this.fecmodif = fecmodif; + this.usuarioId = usuarioId; + this.activo = activo; + } + + + @SequenceGenerator(name = "FECHAMENTO_PARAMPTOVTA_SEQ", sequenceName = "FECHAMENTO_PARAMPTOVTA_SEQ", allocationSize = 1) + @Id + @GeneratedValue(strategy = GenerationType.AUTO, generator = "FECHAMENTO_PARAMPTOVTA_SEQ") + @Column(name = "FECHAMENTOPARAMPTOVTA_ID", unique = true, nullable = false, precision = 15, scale = 0) + public Long getFechamentoparamptovtaId() { + return this.fechamentoparamptovtaId; + } + + public void setFechamentoparamptovtaId(Long fechamentoparamptovtaId) { + this.fechamentoparamptovtaId = fechamentoparamptovtaId; + } + + public void setIntervalofechamento(Integer intervalofechamento) { + this.intervalofechamento = intervalofechamento; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "FECMODIF", length = 7) + public Date getFecmodif() { + return fecmodif; + } + public void setFecmodif(Date fecmodif) { + this.fecmodif = fecmodif; + } + + @Column(name = "USUARIO_ID", precision = 7, scale = 0) + public Integer getUsuarioId() { + return usuarioId; + } + public void setUsuarioId(Integer usuarioId) { + this.usuarioId = usuarioId; + } + + @Column(name = "ACTIVO", precision = 1, scale = 0) + public Boolean getActivo() { + return activo; + } + public void setActivo(Boolean activo) { + this.activo = activo; + } + + @JoinColumn(name = "PUNTOVENTA_ID") + @ManyToOne + public PuntoVenta getPuntoventa() { + return puntoventa; + } + + public void setPuntoventa(PuntoVenta puntoventa) { + this.puntoventa = puntoventa; + } + + @JoinColumn(name = "EMPRESA_ID") + @ManyToOne + public Empresa getEmpresa() { + return empresa; + } + + public void setEmpresa(Empresa empresa) { + this.empresa = empresa; + } + + @Column(name = "INTERVALOFECHAMENTO", length = 2) + public Integer getIntervalofechamento() { + return intervalofechamento; + } + + + +} diff --git a/src/com/rjconsultores/ventaboletos/service/FechamentoParamgeralService.java b/src/com/rjconsultores/ventaboletos/service/FechamentoParamgeralService.java index e2f06b1cb..cc6f95748 100644 --- a/src/com/rjconsultores/ventaboletos/service/FechamentoParamgeralService.java +++ b/src/com/rjconsultores/ventaboletos/service/FechamentoParamgeralService.java @@ -2,10 +2,9 @@ package com.rjconsultores.ventaboletos.service; import java.util.List; -import com.rjconsultores.ventaboletos.dao.GenericDAO; import com.rjconsultores.ventaboletos.entidad.FechamentoParamgeral; -public interface FechamentoParamgeralService extends GenericDAO { +public interface FechamentoParamgeralService extends GenericService { public List buscaParametrosPorEmpresas(List empresasId); public List buscaParametrosPorEmpresa(Integer empresasId); diff --git a/src/com/rjconsultores/ventaboletos/service/FechamentoParamptovtaService.java b/src/com/rjconsultores/ventaboletos/service/FechamentoParamptovtaService.java new file mode 100644 index 000000000..0725fc141 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/FechamentoParamptovtaService.java @@ -0,0 +1,14 @@ +package com.rjconsultores.ventaboletos.service; + +import java.util.List; + +import com.rjconsultores.ventaboletos.entidad.FechamentoParamptovta; + +public interface FechamentoParamptovtaService extends GenericService { + + public List buscaParametrosPorEmpresas(List empresasId); + public List buscaParametrosPorEmpresa(Integer empresasId); + public FechamentoParamptovta suscribirOrActualizacion(FechamentoParamptovta FechamentoParamptovta); + public FechamentoParamptovta buscaParametrosPorPuntoventa(Integer puntoventaId); + +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/FechamentoParamgeralServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/FechamentoParamgeralServiceImpl.java index b0450e1f6..0e48fc923 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/FechamentoParamgeralServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/FechamentoParamgeralServiceImpl.java @@ -45,7 +45,7 @@ public class FechamentoParamgeralServiceImpl implements FechamentoParamgeralServ fechamentoParamgeralDAO.borrar(entidad); } - @Override + public Long count(String campo, Object o) { return fechamentoParamgeralDAO.count(campo, o); } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/FechamentoParamptovtaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/FechamentoParamptovtaServiceImpl.java new file mode 100644 index 000000000..110b3eabf --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/FechamentoParamptovtaServiceImpl.java @@ -0,0 +1,78 @@ +package com.rjconsultores.ventaboletos.service.impl; + +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.FechamentoParamptovtaDAO; +import com.rjconsultores.ventaboletos.entidad.FechamentoParamptovta; +import com.rjconsultores.ventaboletos.service.FechamentoParamptovtaService; + +@Service("fechamentoParamptovtaService") +public class FechamentoParamptovtaServiceImpl implements FechamentoParamptovtaService { + + @Autowired + private FechamentoParamptovtaDAO fechamentoParamptovtaDAO; + + @Override + public List obtenerTodos() { + return fechamentoParamptovtaDAO.obtenerTodos(); + } + + @Override + public FechamentoParamptovta obtenerID(Long id) { + return fechamentoParamptovtaDAO.obtenerID(id); + } + + @Override + @Transactional + public FechamentoParamptovta suscribir(FechamentoParamptovta entidad) { + return fechamentoParamptovtaDAO.suscribir(entidad); + } + + @Override + @Transactional + public FechamentoParamptovta actualizacion(FechamentoParamptovta entidad) { + return fechamentoParamptovtaDAO.actualizacion(entidad); + } + + @Override + @Transactional + public void borrar(FechamentoParamptovta entidad) { + fechamentoParamptovtaDAO.borrar(entidad); + } + + + public Long count(String campo, Object o) { + return fechamentoParamptovtaDAO.count(campo, o); + } + + @Override + public List buscaParametrosPorEmpresas(List empresasId) { + return fechamentoParamptovtaDAO.buscaParametrosPorEmpresas(empresasId); + } + + @Override + public List buscaParametrosPorEmpresa(Integer empresasId) { + return fechamentoParamptovtaDAO.buscaParametrosPorEmpresa(empresasId); + } + + @Override + @Transactional + public FechamentoParamptovta suscribirOrActualizacion(FechamentoParamptovta FechamentoParamptovta) { + if(FechamentoParamptovta != null && FechamentoParamptovta.getFechamentoparamptovtaId() == null) { + return suscribir(FechamentoParamptovta); + } else if(FechamentoParamptovta != null && FechamentoParamptovta.getFechamentoparamptovtaId() != null) { + return actualizacion(FechamentoParamptovta); + } + return null; + } + + @Override + public FechamentoParamptovta buscaParametrosPorPuntoventa(Integer puntoventaId) { + FechamentoParamptovta params = fechamentoParamptovtaDAO.buscaParametrosPorPuntoventa(puntoventaId); + return params; + } +}