ADM_20121217_1RC90
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@23218 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
ff42d2b4fb
commit
7d700e00a9
|
@ -5,16 +5,21 @@
|
||||||
package com.rjconsultores.ventaboletos.entidad;
|
package com.rjconsultores.ventaboletos.entidad;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.Basic;
|
import javax.persistence.Basic;
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.OneToOne;
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
@ -70,13 +75,12 @@ public class Estacion implements Serializable {
|
||||||
private String nomeArquivoLayout;
|
private String nomeArquivoLayout;
|
||||||
@Column(name = "NOMEIMPRESSORARELATORIO")
|
@Column(name = "NOMEIMPRESSORARELATORIO")
|
||||||
private String nomeImpressoraRelatorio;
|
private String nomeImpressoraRelatorio;
|
||||||
|
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL,fetch=FetchType.EAGER)
|
||||||
|
private List<EstacionSitef> estacionSitefList;
|
||||||
|
|
||||||
@JoinColumn(name = "ESTACIONSITEF_ID")
|
|
||||||
@ManyToOne(cascade=CascadeType.ALL)
|
|
||||||
private EstacionSitef estacionSitefId;
|
|
||||||
|
|
||||||
public Estacion() {
|
public Estacion() {
|
||||||
this.estacionSitefId = new EstacionSitef();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Estacion(Integer estacionId) {
|
public Estacion(Integer estacionId) {
|
||||||
|
@ -197,14 +201,6 @@ public class Estacion implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public EstacionSitef getEstacionSitefId() {
|
|
||||||
return estacionSitefId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEstacionSitefId(EstacionSitef estacionSitefId) {
|
|
||||||
this.estacionSitefId = estacionSitefId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hash = 0;
|
int hash = 0;
|
||||||
|
@ -228,4 +224,21 @@ public class Estacion implements Serializable {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "com.rjconsultores.ventaboletos.entidad.Estacion[estacionId=" + estacionId + "]";
|
return "com.rjconsultores.ventaboletos.entidad.Estacion[estacionId=" + estacionId + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<EstacionSitef> getEstacionSitefList() {
|
||||||
|
List<EstacionSitef> tmp = new ArrayList<EstacionSitef>();
|
||||||
|
|
||||||
|
if(estacionSitefList != null){
|
||||||
|
for(EstacionSitef es:estacionSitefList){
|
||||||
|
if (es.getActivo()){
|
||||||
|
tmp.add(es);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEstacionSitefList(List<EstacionSitef> estacionSitefList) {
|
||||||
|
this.estacionSitefList = estacionSitefList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,20 +9,18 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.Basic;
|
import javax.persistence.Basic;
|
||||||
import javax.persistence.CascadeType;
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.NamedQueries;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.NamedQuery;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.SequenceGenerator;
|
import javax.persistence.SequenceGenerator;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -45,6 +43,12 @@ public class EstacionSitef implements Serializable {
|
||||||
private Integer numfilial;
|
private Integer numfilial;
|
||||||
@Column(name = "NUMPDV")
|
@Column(name = "NUMPDV")
|
||||||
private Integer numpdv;
|
private Integer numpdv;
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "EMPRESA_ID")
|
||||||
|
private Empresa empresa;
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "ESTACION_ID", referencedColumnName = "ESTACION_ID")
|
||||||
|
private Estacion estacion;
|
||||||
@Column(name = "USUARIO_ID")
|
@Column(name = "USUARIO_ID")
|
||||||
private Integer usuarioId;
|
private Integer usuarioId;
|
||||||
@Column(name = "ACTIVO")
|
@Column(name = "ACTIVO")
|
||||||
|
@ -53,8 +57,6 @@ public class EstacionSitef implements Serializable {
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date fecmodif;
|
private Date fecmodif;
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "estacionSitefId")
|
|
||||||
private List<Estacion> estacionList;
|
|
||||||
|
|
||||||
public EstacionSitef() {
|
public EstacionSitef() {
|
||||||
}
|
}
|
||||||
|
@ -120,14 +122,6 @@ public class EstacionSitef implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Estacion> getEstacionList() {
|
|
||||||
return estacionList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEstacionList(List<Estacion> estacionList) {
|
|
||||||
this.estacionList = estacionList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hash = 0;
|
int hash = 0;
|
||||||
|
@ -153,4 +147,20 @@ public class EstacionSitef implements Serializable {
|
||||||
return "com.rjconsultores.ventaboletos.entidad.EstacionSitef[ estacionsitefId=" + estacionsitefId + " ]";
|
return "com.rjconsultores.ventaboletos.entidad.EstacionSitef[ estacionsitefId=" + estacionsitefId + " ]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Empresa getEmpresa() {
|
||||||
|
return empresa;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmpresa(Empresa empresa) {
|
||||||
|
this.empresa = empresa;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Estacion getEstacion() {
|
||||||
|
return estacion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEstacion(Estacion estacion) {
|
||||||
|
this.estacion = estacion;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.EstacionDAO;
|
import com.rjconsultores.ventaboletos.dao.EstacionDAO;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Estacion;
|
import com.rjconsultores.ventaboletos.entidad.Estacion;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.EstacionSitef;
|
||||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||||
import com.rjconsultores.ventaboletos.service.EstacionService;
|
import com.rjconsultores.ventaboletos.service.EstacionService;
|
||||||
|
@ -25,89 +26,77 @@ import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
@Service("estacionService")
|
@Service("estacionService")
|
||||||
public class EstacionServiceImpl implements EstacionService {
|
public class EstacionServiceImpl implements EstacionService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EstacionDAO estacionDAO;
|
private EstacionDAO estacionDAO;
|
||||||
|
|
||||||
public List<Estacion> obtenerTodos() {
|
public List<Estacion> obtenerTodos() {
|
||||||
return estacionDAO.obtenerTodos();
|
return estacionDAO.obtenerTodos();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Estacion obtenerID(Integer id) {
|
public Estacion obtenerID(Integer id) {
|
||||||
return estacionDAO.obtenerID(id);
|
return estacionDAO.obtenerID(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor=BusinessException.class)
|
@Transactional(rollbackFor = BusinessException.class)
|
||||||
public Estacion suscribirActualizar(Estacion estacion) throws BusinessException {
|
public Estacion suscribirActualizar(Estacion estacion) throws BusinessException {
|
||||||
List<Estacion> lsEstacion = estacionDAO.buscar(estacion.getDescmac());
|
List<Estacion> lsEstacion = estacionDAO.buscar(estacion.getDescmac());
|
||||||
boolean esDuplicado = false;
|
|
||||||
|
|
||||||
if (!lsEstacion.isEmpty()) {
|
boolean esCajaDuplicado = false;
|
||||||
if (estacion.getEstacionId() == null) {
|
lsEstacion = estacionDAO.buscar(estacion.getNumcaja(), estacion.getPuntoVenta());
|
||||||
esDuplicado = true;
|
|
||||||
} else {
|
|
||||||
esDuplicado = !lsEstacion.get(0).getEstacionId().equals(estacion.getEstacionId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (esDuplicado) {
|
if (!lsEstacion.isEmpty()) {
|
||||||
throw new BusinessException("MSG.Registro.Existe");
|
if (estacion.getEstacionId() == null) {
|
||||||
}
|
esCajaDuplicado = true;
|
||||||
|
} else {
|
||||||
|
esCajaDuplicado = !lsEstacion.get(0).getEstacionId().equals(estacion.getEstacionId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean esCajaDuplicado = false;
|
if (esCajaDuplicado) {
|
||||||
lsEstacion = estacionDAO.buscar(estacion.getNumcaja(), estacion.getPuntoVenta());
|
throw new BusinessException("estacionServiceImpl.msg.cajaDuplicado");
|
||||||
|
}
|
||||||
|
|
||||||
if (!lsEstacion.isEmpty()) {
|
estacion.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
if (estacion.getEstacionId() == null) {
|
estacion.setFecmodif(Calendar.getInstance().getTime());
|
||||||
esCajaDuplicado = true;
|
estacion.setActivo(Boolean.TRUE);
|
||||||
} else {
|
|
||||||
esCajaDuplicado = !lsEstacion.get(0).getEstacionId().equals(estacion.getEstacionId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (estacion.getEstacionId() == null) {
|
||||||
|
return estacionDAO.suscribir(estacion);
|
||||||
|
} else {
|
||||||
|
|
||||||
if (esCajaDuplicado) {
|
return estacionDAO.actualizacion(estacion);
|
||||||
throw new BusinessException("estacionServiceImpl.msg.cajaDuplicado");
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
estacion.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
@Transactional
|
||||||
estacion.setFecmodif(Calendar.getInstance().getTime());
|
public void borrar(Estacion entidad) {
|
||||||
estacion.setActivo(Boolean.TRUE);
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
entidad.setActivo(Boolean.FALSE);
|
||||||
|
|
||||||
if (estacion.getEstacionId() == null) {
|
if (entidad.getEstacionSitefList() != null) {
|
||||||
return estacionDAO.suscribir(estacion);
|
for (EstacionSitef es : entidad.getEstacionSitefList()) {
|
||||||
} else {
|
es.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
es.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
es.setActivo(Boolean.FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return estacionDAO.actualizacion(estacion);
|
estacionDAO.actualizacion(entidad);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
public List<Estacion> buscar(String descEstacion, String descMac, Long nunCaja, PuntoVenta pv) {
|
||||||
public void borrar(Estacion entidad) {
|
return estacionDAO.buscar(descEstacion, descMac, nunCaja, pv);
|
||||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
}
|
||||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
|
||||||
entidad.setActivo(Boolean.FALSE);
|
|
||||||
|
|
||||||
if(entidad.getEstacionSitefId() != null){
|
public List<Estacion> buscar(String descMac) {
|
||||||
entidad.getEstacionSitefId().setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
return estacionDAO.buscar(descMac);
|
||||||
entidad.getEstacionSitefId().setFecmodif(Calendar.getInstance().getTime());
|
}
|
||||||
entidad.getEstacionSitefId().setActivo(Boolean.FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
estacionDAO.actualizacion(entidad);
|
@Override
|
||||||
}
|
public Long getDecimalMAC(String mac) {
|
||||||
|
mac = mac.trim();
|
||||||
public List<Estacion> buscar(String descEstacion, String descMac, Long nunCaja, PuntoVenta pv) {
|
mac = mac.replace("-", "");
|
||||||
return estacionDAO.buscar(descEstacion, descMac, nunCaja, pv);
|
return Long.parseLong(mac, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Estacion> buscar(String descMac) {
|
|
||||||
return estacionDAO.buscar(descMac);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long getDecimalMAC(String mac) {
|
|
||||||
mac = mac.trim();
|
|
||||||
mac = mac.replace("-", "");
|
|
||||||
return Long.parseLong(mac, 16);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue