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 Estacion buscarPorIMEI(String imei);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @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();
|
||||
}
|
||||
|
||||
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
|
||||
public List<Estacion> buscar(Long numCaja, PuntoVenta puntoVenta) {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
|
@ -214,7 +222,7 @@ public class EstacionHibernateDAO extends GenericHibernateDAO<Estacion, Integer>
|
|||
return c.list();
|
||||
}
|
||||
|
||||
public Estacion buscarEstacionDuplicada(String descMac, Integer estacionId) {
|
||||
public Estacion buscarEstacionDuplicadaPorMAC(String descMac, Integer estacionId) {
|
||||
StringBuilder sQuery = new StringBuilder();
|
||||
sQuery.append("SELECT e ")
|
||||
.append("FROM Estacion e ")
|
||||
|
@ -227,12 +235,15 @@ public class EstacionHibernateDAO extends GenericHibernateDAO<Estacion, Integer>
|
|||
|
||||
Query qr = getSession().createQuery(sQuery.toString());
|
||||
qr.setParameter("descmac", descMac);
|
||||
|
||||
if(estacionId != null) {
|
||||
qr.setParameter("estacionId", estacionId);
|
||||
}
|
||||
|
||||
qr.setMaxResults(1);
|
||||
|
||||
List<Estacion> lsEstacions = qr.list();
|
||||
|
||||
if(lsEstacions != null && !lsEstacions.isEmpty()) {
|
||||
return lsEstacions.iterator().next();
|
||||
}
|
||||
|
@ -240,4 +251,32 @@ public class EstacionHibernateDAO extends GenericHibernateDAO<Estacion, Integer>
|
|||
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;
|
||||
@Column(name = "INDMAPAVIAGEMIMPTERMICA")
|
||||
private Boolean indMapaViagemImpTermica;
|
||||
@Column(name = "IMEI")
|
||||
private String imei;
|
||||
|
||||
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@Where(clause="activo=1")
|
||||
|
@ -434,4 +436,11 @@ public class Estacion implements Serializable {
|
|||
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 Estacion buscarPorIMEI(String imei);
|
||||
|
||||
public Long getDecimalMAC(String mac);
|
||||
|
||||
public List<Estacion> buscarEstaciones(PuntoVenta puntoVenta);
|
||||
|
|
|
@ -49,31 +49,13 @@ public class EstacionServiceImpl implements EstacionService {
|
|||
|
||||
@Transactional(rollbackFor = BusinessException.class)
|
||||
public Estacion suscribirActualizar(Estacion estacion) throws BusinessException {
|
||||
String nomeEstacao = "";
|
||||
Long numeroCaixa = 0l;
|
||||
|
||||
validarEstoqueUpdate(estacion);
|
||||
|
||||
Boolean esMacDuplicado = Boolean.FALSE;
|
||||
Estacion estacionDuplicada = estacionDAO.buscarEstacionDuplicada(estacion.getDescmac(), estacion.getEstacionId());
|
||||
if (estacionDuplicada != null) {
|
||||
nomeEstacao = estacionDuplicada.getDescestacion();
|
||||
numeroCaixa = estacionDuplicada.getNumcaja();
|
||||
esMacDuplicado = Boolean.TRUE;
|
||||
}
|
||||
if (esMacDuplicado) {
|
||||
if (estacion.getDescmac() != null && !estacion.getDescmac().isEmpty())
|
||||
validarDuplicidade(estacionDAO.buscarEstacionDuplicadaPorMAC(estacion.getDescmac(), estacion.getEstacionId()));
|
||||
|
||||
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());
|
||||
}
|
||||
if (estacion.getImei() != null && !estacion.getImei().isEmpty())
|
||||
validarDuplicidade(estacionDAO.buscarEstacionDuplicadaPorIMEI(estacion.getImei(), estacion.getEstacionId()));
|
||||
|
||||
boolean esCajaDuplicado = false;
|
||||
List<Estacion> lsEstacion = estacionDAO.buscar(estacion.getNumcaja(), estacion.getPuntoVenta());
|
||||
|
@ -120,6 +102,32 @@ public class EstacionServiceImpl implements EstacionService {
|
|||
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) {
|
||||
for (EstacionImpresora ei : e.getLsEstacionImpresora()) {
|
||||
if(TipoImpressora.getTipoImpressoraFiscal(ei.getTipoImpressora())!=null && ei.getEstacionImpresoraId() == null){
|
||||
|
@ -198,6 +206,10 @@ public class EstacionServiceImpl implements EstacionService {
|
|||
return estacionDAO.buscar(descMac);
|
||||
}
|
||||
|
||||
public Estacion buscarPorIMEI(String imei) {
|
||||
return estacionDAO.buscarPorIMEI(imei);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getDecimalMAC(String mac) {
|
||||
mac = mac.trim();
|
||||
|
|
Loading…
Reference in New Issue