fixes bug#11507
dev:thiago qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@83160 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
46f9a916fc
commit
73a0b33acd
|
@ -39,4 +39,12 @@ public interface EstacionDAO extends GenericDAO<Estacion, Integer> {
|
||||||
public Boolean temEstoque(PuntoVenta puntoVenta, Estacion estacion);
|
public Boolean temEstoque(PuntoVenta puntoVenta, Estacion estacion);
|
||||||
|
|
||||||
public List<Estacion> buscarEstacionesStockCentral(PuntoVenta puntoVenta);
|
public List<Estacion> buscarEstacionesStockCentral(PuntoVenta puntoVenta);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retorna a estação duplicada pelo MAC
|
||||||
|
* @param descMac
|
||||||
|
* @param estacionId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Estacion buscarEstacionDuplicada(String descMac, Integer estacionId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,14 @@
|
||||||
*/
|
*/
|
||||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.hibernate.Criteria;
|
import org.hibernate.Criteria;
|
||||||
|
import org.hibernate.Query;
|
||||||
import org.hibernate.SQLQuery;
|
import org.hibernate.SQLQuery;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.criterion.MatchMode;
|
||||||
import org.hibernate.criterion.Order;
|
import org.hibernate.criterion.Order;
|
||||||
import org.hibernate.criterion.Projections;
|
import org.hibernate.criterion.Projections;
|
||||||
import org.hibernate.criterion.Property;
|
import org.hibernate.criterion.Property;
|
||||||
|
@ -48,10 +50,20 @@ public class EstacionHibernateDAO extends GenericHibernateDAO<Estacion, Integer>
|
||||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
|
|
||||||
c.add(Restrictions.eq("descestacion", descEstacion));
|
if(StringUtils.isNotBlank(descEstacion)) {
|
||||||
c.add(Restrictions.eq("descmac", descMac));
|
c.add(Restrictions.like("descestacion", descEstacion, MatchMode.START));
|
||||||
c.add(Restrictions.eq("numcaja", nunCaja));
|
}
|
||||||
c.add(Restrictions.eq("puntoVenta", pv));
|
if(StringUtils.isNotBlank(descMac)) {
|
||||||
|
c.add(Restrictions.eq("descmac", descMac));
|
||||||
|
}
|
||||||
|
if(nunCaja != null) {
|
||||||
|
c.add(Restrictions.eq("numcaja", nunCaja));
|
||||||
|
}
|
||||||
|
if(pv != null) {
|
||||||
|
c.add(Restrictions.eq("puntoVenta", pv));
|
||||||
|
}
|
||||||
|
|
||||||
|
c.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
|
||||||
|
|
||||||
return c.list();
|
return c.list();
|
||||||
}
|
}
|
||||||
|
@ -70,6 +82,7 @@ public class EstacionHibernateDAO extends GenericHibernateDAO<Estacion, Integer>
|
||||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
c.add(Restrictions.eq("numcaja", numCaja));
|
c.add(Restrictions.eq("numcaja", numCaja));
|
||||||
c.add(Restrictions.eq("puntoVenta", puntoVenta));
|
c.add(Restrictions.eq("puntoVenta", puntoVenta));
|
||||||
|
c.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
|
||||||
|
|
||||||
return c.list();
|
return c.list();
|
||||||
}
|
}
|
||||||
|
@ -200,6 +213,32 @@ public class EstacionHibernateDAO extends GenericHibernateDAO<Estacion, Integer>
|
||||||
|
|
||||||
return c.list();
|
return c.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Estacion buscarEstacionDuplicada(String descMac, Integer estacionId) {
|
||||||
|
StringBuilder sQuery = new StringBuilder();
|
||||||
|
sQuery.append("SELECT e ")
|
||||||
|
.append("FROM Estacion e ")
|
||||||
|
.append("WHERE e.activo = 1")
|
||||||
|
.append("AND e.descmac = :descmac ");
|
||||||
|
|
||||||
|
if(estacionId != null) {
|
||||||
|
sQuery.append("AND e.estacionId <> :estacionId ");
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@ import javax.persistence.Table;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Where;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Administrador
|
* @author Administrador
|
||||||
|
@ -88,17 +90,29 @@ public class Estacion implements Serializable {
|
||||||
private String nomeImpressoraBPe;
|
private String nomeImpressoraBPe;
|
||||||
@Column(name = "INDSTOCKCENTRAL")
|
@Column(name = "INDSTOCKCENTRAL")
|
||||||
private Boolean indStockCentral;
|
private Boolean indStockCentral;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||||
|
@Where(clause="activo=1")
|
||||||
private List<EstacionSitef> estacionSitefList;
|
private List<EstacionSitef> estacionSitefList;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL)
|
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL)
|
||||||
|
@Where(clause="activo=1")
|
||||||
private List<EstacionRioCard> estacionRioCardList;
|
private List<EstacionRioCard> estacionRioCardList;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL)
|
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL)
|
||||||
|
@Where(clause="activo=1")
|
||||||
private List<EstacionImpresora> lsEstacionImpresora;
|
private List<EstacionImpresora> lsEstacionImpresora;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL)
|
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL)
|
||||||
|
@Where(clause="activo=1")
|
||||||
private List<AbastoBoleto> abastoBoletoList;
|
private List<AbastoBoleto> abastoBoletoList;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL)
|
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL)
|
||||||
|
@Where(clause="activo=1")
|
||||||
private List<RequisicionBoleto> requisicionBoletoList;
|
private List<RequisicionBoleto> requisicionBoletoList;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL)
|
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL)
|
||||||
|
@Where(clause="activo=1")
|
||||||
private List<FolioPreimpreso> folioPreimpresoList;
|
private List<FolioPreimpreso> folioPreimpresoList;
|
||||||
|
|
||||||
public Estacion() {
|
public Estacion() {
|
||||||
|
|
|
@ -54,15 +54,11 @@ public class EstacionServiceImpl implements EstacionService {
|
||||||
validarEstoqueUpdate(estacion);
|
validarEstoqueUpdate(estacion);
|
||||||
|
|
||||||
Boolean esMacDuplicado = Boolean.FALSE;
|
Boolean esMacDuplicado = Boolean.FALSE;
|
||||||
List<Estacion> lsEstacionMac = estacionDAO.buscar(estacion.getDescmac());
|
Estacion estacionDuplicada = estacionDAO.buscarEstacionDuplicada(estacion.getDescmac(), estacion.getEstacionId());
|
||||||
if (!lsEstacionMac.isEmpty()) {
|
if (estacionDuplicada != null) {
|
||||||
for (Estacion est : lsEstacionMac) {
|
nomeEstacao = estacionDuplicada.getDescestacion();
|
||||||
if (!est.getEstacionId().equals(estacion.getEstacionId())) {
|
numeroCaixa = estacionDuplicada.getNumcaja();
|
||||||
nomeEstacao = est.getDescestacion();
|
esMacDuplicado = Boolean.TRUE;
|
||||||
numeroCaixa = est.getNumcaja();
|
|
||||||
esMacDuplicado = Boolean.TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (esMacDuplicado) {
|
if (esMacDuplicado) {
|
||||||
throw new BusinessException(Labels.getLabel("estacionServiceImpl.msg.macDuplicado") + "\n"
|
throw new BusinessException(Labels.getLabel("estacionServiceImpl.msg.macDuplicado") + "\n"
|
||||||
|
@ -99,11 +95,11 @@ public class EstacionServiceImpl implements EstacionService {
|
||||||
|
|
||||||
String errorNoChequeFolio = null;
|
String errorNoChequeFolio = null;
|
||||||
for (EstacionImpresora ei : estacion.getLsEstacionImpresora()) {
|
for (EstacionImpresora ei : estacion.getLsEstacionImpresora()) {
|
||||||
|
boolean isImpressoraFiscal = validacionImpressoraFiscal(ei);
|
||||||
if (ApplicationProperties.getInstance().generarRotinaFolios()) {
|
if (ApplicationProperties.getInstance().generarRotinaFolios()) {
|
||||||
errorNoChequeFolio = autorizaFolioService.noChequeFolioPreimpresos(ei, false);
|
errorNoChequeFolio = autorizaFolioService.noChequeFolioPreimpresos(ei, false);
|
||||||
} else if (validacionImpressoraFiscal(ei) && isNuevaFiscal) {
|
} else if ((isImpressoraFiscal && isNuevaFiscal) ||
|
||||||
errorNoChequeFolio = autorizaFolioService.noChequeFolioPreimpresos(ei, true);
|
(estacion.getIndStockCentral() != null && estacion.getIndStockCentral() && isImpressoraFiscal)) {
|
||||||
}else if(estacion.getIndStockCentral() != null && estacion.getIndStockCentral()){
|
|
||||||
errorNoChequeFolio = autorizaFolioService.noChequeFolioPreimpresos(ei, true);
|
errorNoChequeFolio = autorizaFolioService.noChequeFolioPreimpresos(ei, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue