Criar serviço para trazer informações para login Agência Digital
bug#16383 dev:trevezani qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@98227 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
41d978ea79
commit
6fca14c38a
|
@ -21,6 +21,8 @@ public interface EstacionDAO extends GenericDAO<Estacion, Integer> {
|
||||||
|
|
||||||
public List<Estacion> buscar(String descMac);
|
public List<Estacion> buscar(String descMac);
|
||||||
|
|
||||||
|
public Estacion buscarPorIMEI(String imei);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hace la búsqueda de las estciones ativas por el numCaja y puntoVenta
|
* Hace la búsqueda de las estciones ativas por el numCaja y puntoVenta
|
||||||
*
|
*
|
||||||
|
@ -46,5 +48,7 @@ public interface EstacionDAO extends GenericDAO<Estacion, Integer> {
|
||||||
* @param estacionId
|
* @param estacionId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Estacion buscarEstacionDuplicada(String descMac, Integer estacionId);
|
public Estacion buscarEstacionDuplicadaPorMAC(String descMac, Integer estacionId);
|
||||||
|
|
||||||
|
public Estacion buscarEstacionDuplicadaPorIMEI(String imei, Integer estacionId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,14 @@ public class EstacionHibernateDAO extends GenericHibernateDAO<Estacion, Integer>
|
||||||
return c.list();
|
return c.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Estacion buscarPorIMEI(String imei) {
|
||||||
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
|
c.add(Restrictions.eq("imei", imei));
|
||||||
|
|
||||||
|
return (Estacion) c.uniqueResult();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Estacion> buscar(Long numCaja, PuntoVenta puntoVenta) {
|
public List<Estacion> buscar(Long numCaja, PuntoVenta puntoVenta) {
|
||||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
|
@ -214,7 +222,7 @@ public class EstacionHibernateDAO extends GenericHibernateDAO<Estacion, Integer>
|
||||||
return c.list();
|
return c.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Estacion buscarEstacionDuplicada(String descMac, Integer estacionId) {
|
public Estacion buscarEstacionDuplicadaPorMAC(String descMac, Integer estacionId) {
|
||||||
StringBuilder sQuery = new StringBuilder();
|
StringBuilder sQuery = new StringBuilder();
|
||||||
sQuery.append("SELECT e ")
|
sQuery.append("SELECT e ")
|
||||||
.append("FROM Estacion e ")
|
.append("FROM Estacion e ")
|
||||||
|
@ -227,12 +235,15 @@ public class EstacionHibernateDAO extends GenericHibernateDAO<Estacion, Integer>
|
||||||
|
|
||||||
Query qr = getSession().createQuery(sQuery.toString());
|
Query qr = getSession().createQuery(sQuery.toString());
|
||||||
qr.setParameter("descmac", descMac);
|
qr.setParameter("descmac", descMac);
|
||||||
|
|
||||||
if(estacionId != null) {
|
if(estacionId != null) {
|
||||||
qr.setParameter("estacionId", estacionId);
|
qr.setParameter("estacionId", estacionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
qr.setMaxResults(1);
|
qr.setMaxResults(1);
|
||||||
|
|
||||||
List<Estacion> lsEstacions = qr.list();
|
List<Estacion> lsEstacions = qr.list();
|
||||||
|
|
||||||
if(lsEstacions != null && !lsEstacions.isEmpty()) {
|
if(lsEstacions != null && !lsEstacions.isEmpty()) {
|
||||||
return lsEstacions.iterator().next();
|
return lsEstacions.iterator().next();
|
||||||
}
|
}
|
||||||
|
@ -240,4 +251,32 @@ public class EstacionHibernateDAO extends GenericHibernateDAO<Estacion, Integer>
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Estacion buscarEstacionDuplicadaPorIMEI(String imei, Integer estacionId) {
|
||||||
|
StringBuilder sQuery = new StringBuilder();
|
||||||
|
sQuery.append("SELECT e ")
|
||||||
|
.append("FROM Estacion e ")
|
||||||
|
.append("WHERE e.activo = 1")
|
||||||
|
.append("AND e.imei = :imei ");
|
||||||
|
|
||||||
|
if(estacionId != null) {
|
||||||
|
sQuery.append("AND e.estacionId <> :estacionId ");
|
||||||
|
}
|
||||||
|
|
||||||
|
Query qr = getSession().createQuery(sQuery.toString());
|
||||||
|
qr.setParameter("imei", imei);
|
||||||
|
|
||||||
|
if(estacionId != null) {
|
||||||
|
qr.setParameter("estacionId", estacionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
qr.setMaxResults(1);
|
||||||
|
|
||||||
|
List<Estacion> lsEstacions = qr.list();
|
||||||
|
|
||||||
|
if(lsEstacions != null && !lsEstacions.isEmpty()) {
|
||||||
|
return lsEstacions.iterator().next();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,8 @@ public class Estacion implements Serializable {
|
||||||
private Integer tipoImpressoraRelatorio;
|
private Integer tipoImpressoraRelatorio;
|
||||||
@Column(name = "INDMAPAVIAGEMIMPTERMICA")
|
@Column(name = "INDMAPAVIAGEMIMPTERMICA")
|
||||||
private Boolean indMapaViagemImpTermica;
|
private Boolean indMapaViagemImpTermica;
|
||||||
|
@Column(name = "IMEI")
|
||||||
|
private String imei;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||||
@Where(clause="activo=1")
|
@Where(clause="activo=1")
|
||||||
|
@ -434,4 +436,11 @@ public class Estacion implements Serializable {
|
||||||
this.indMapaViagemImpTermica = indMapaViagemImpTermica;
|
this.indMapaViagemImpTermica = indMapaViagemImpTermica;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getImei() {
|
||||||
|
return imei;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImei(String imei) {
|
||||||
|
this.imei = imei;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ public interface EstacionService {
|
||||||
|
|
||||||
public List<Estacion> buscar(String descMac);
|
public List<Estacion> buscar(String descMac);
|
||||||
|
|
||||||
|
public Estacion buscarPorIMEI(String imei);
|
||||||
|
|
||||||
public Long getDecimalMAC(String mac);
|
public Long getDecimalMAC(String mac);
|
||||||
|
|
||||||
public List<Estacion> buscarEstaciones(PuntoVenta puntoVenta);
|
public List<Estacion> buscarEstaciones(PuntoVenta puntoVenta);
|
||||||
|
|
|
@ -49,31 +49,13 @@ public class EstacionServiceImpl implements EstacionService {
|
||||||
|
|
||||||
@Transactional(rollbackFor = BusinessException.class)
|
@Transactional(rollbackFor = BusinessException.class)
|
||||||
public Estacion suscribirActualizar(Estacion estacion) throws BusinessException {
|
public Estacion suscribirActualizar(Estacion estacion) throws BusinessException {
|
||||||
String nomeEstacao = "";
|
|
||||||
Long numeroCaixa = 0l;
|
|
||||||
|
|
||||||
validarEstoqueUpdate(estacion);
|
validarEstoqueUpdate(estacion);
|
||||||
|
|
||||||
Boolean esMacDuplicado = Boolean.FALSE;
|
if (estacion.getDescmac() != null && !estacion.getDescmac().isEmpty())
|
||||||
Estacion estacionDuplicada = estacionDAO.buscarEstacionDuplicada(estacion.getDescmac(), estacion.getEstacionId());
|
validarDuplicidade(estacionDAO.buscarEstacionDuplicadaPorMAC(estacion.getDescmac(), estacion.getEstacionId()));
|
||||||
if (estacionDuplicada != null) {
|
|
||||||
nomeEstacao = estacionDuplicada.getDescestacion();
|
|
||||||
numeroCaixa = estacionDuplicada.getNumcaja();
|
|
||||||
esMacDuplicado = Boolean.TRUE;
|
|
||||||
}
|
|
||||||
if (esMacDuplicado) {
|
|
||||||
|
|
||||||
StringBuilder msg = new StringBuilder();
|
if (estacion.getImei() != null && !estacion.getImei().isEmpty())
|
||||||
msg.append( Labels.getLabel("estacionServiceImpl.msg.macDuplicado") );
|
validarDuplicidade(estacionDAO.buscarEstacionDuplicadaPorIMEI(estacion.getImei(), estacion.getEstacionId()));
|
||||||
msg.append( "\n" );
|
|
||||||
msg.append( Labels.getLabel("estacionServiceImpl.msg.macDuplicado.descricaoEstacao") );
|
|
||||||
msg.append( nomeEstacao );
|
|
||||||
msg.append( "\n" );
|
|
||||||
msg.append( Labels.getLabel("estacionServiceImpl.msg.macDuplicado.numeroCaixa") );
|
|
||||||
msg.append( numeroCaixa.toString() );
|
|
||||||
|
|
||||||
throw new BusinessException( msg.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean esCajaDuplicado = false;
|
boolean esCajaDuplicado = false;
|
||||||
List<Estacion> lsEstacion = estacionDAO.buscar(estacion.getNumcaja(), estacion.getPuntoVenta());
|
List<Estacion> lsEstacion = estacionDAO.buscar(estacion.getNumcaja(), estacion.getPuntoVenta());
|
||||||
|
@ -120,6 +102,32 @@ public class EstacionServiceImpl implements EstacionService {
|
||||||
return estacion;
|
return estacion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void validarDuplicidade(Estacion estacionValidacao) throws BusinessException {
|
||||||
|
Boolean esMacDuplicado = Boolean.FALSE;
|
||||||
|
|
||||||
|
String nomeEstacao = "";
|
||||||
|
Long numeroCaixa = 0l;
|
||||||
|
|
||||||
|
if (estacionValidacao != null) {
|
||||||
|
nomeEstacao = estacionValidacao.getDescestacion();
|
||||||
|
numeroCaixa = estacionValidacao.getNumcaja();
|
||||||
|
esMacDuplicado = Boolean.TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (esMacDuplicado) {
|
||||||
|
StringBuilder msg = new StringBuilder();
|
||||||
|
msg.append( Labels.getLabel("estacionServiceImpl.msg.macDuplicado") );
|
||||||
|
msg.append( "\n" );
|
||||||
|
msg.append( Labels.getLabel("estacionServiceImpl.msg.macDuplicado.descricaoEstacao") );
|
||||||
|
msg.append( nomeEstacao );
|
||||||
|
msg.append( "\n" );
|
||||||
|
msg.append( Labels.getLabel("estacionServiceImpl.msg.macDuplicado.numeroCaixa") );
|
||||||
|
msg.append( numeroCaixa.toString() );
|
||||||
|
|
||||||
|
throw new BusinessException( msg.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean validacionNuevaImpressoraFiscal(final Estacion e) {
|
private boolean validacionNuevaImpressoraFiscal(final Estacion e) {
|
||||||
for (EstacionImpresora ei : e.getLsEstacionImpresora()) {
|
for (EstacionImpresora ei : e.getLsEstacionImpresora()) {
|
||||||
if(TipoImpressora.getTipoImpressoraFiscal(ei.getTipoImpressora())!=null && ei.getEstacionImpresoraId() == null){
|
if(TipoImpressora.getTipoImpressoraFiscal(ei.getTipoImpressora())!=null && ei.getEstacionImpresoraId() == null){
|
||||||
|
@ -198,6 +206,10 @@ public class EstacionServiceImpl implements EstacionService {
|
||||||
return estacionDAO.buscar(descMac);
|
return estacionDAO.buscar(descMac);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Estacion buscarPorIMEI(String imei) {
|
||||||
|
return estacionDAO.buscarPorIMEI(imei);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getDecimalMAC(String mac) {
|
public Long getDecimalMAC(String mac) {
|
||||||
mac = mac.trim();
|
mac = mac.trim();
|
||||||
|
|
Loading…
Reference in New Issue