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 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;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.SQLQuery;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.criterion.MatchMode;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.criterion.Projections;
|
||||
import org.hibernate.criterion.Property;
|
||||
|
@ -48,10 +50,20 @@ public class EstacionHibernateDAO extends GenericHibernateDAO<Estacion, Integer>
|
|||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
|
||||
c.add(Restrictions.eq("descestacion", descEstacion));
|
||||
c.add(Restrictions.eq("descmac", descMac));
|
||||
c.add(Restrictions.eq("numcaja", nunCaja));
|
||||
c.add(Restrictions.eq("puntoVenta", pv));
|
||||
if(StringUtils.isNotBlank(descEstacion)) {
|
||||
c.add(Restrictions.like("descestacion", descEstacion, MatchMode.START));
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
@ -70,6 +82,7 @@ public class EstacionHibernateDAO extends GenericHibernateDAO<Estacion, Integer>
|
|||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
c.add(Restrictions.eq("numcaja", numCaja));
|
||||
c.add(Restrictions.eq("puntoVenta", puntoVenta));
|
||||
c.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
|
||||
|
||||
return c.list();
|
||||
}
|
||||
|
@ -200,6 +213,32 @@ public class EstacionHibernateDAO extends GenericHibernateDAO<Estacion, Integer>
|
|||
|
||||
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.TemporalType;
|
||||
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Administrador
|
||||
|
@ -88,17 +90,29 @@ public class Estacion implements Serializable {
|
|||
private String nomeImpressoraBPe;
|
||||
@Column(name = "INDSTOCKCENTRAL")
|
||||
private Boolean indStockCentral;
|
||||
|
||||
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@Where(clause="activo=1")
|
||||
private List<EstacionSitef> estacionSitefList;
|
||||
|
||||
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL)
|
||||
@Where(clause="activo=1")
|
||||
private List<EstacionRioCard> estacionRioCardList;
|
||||
|
||||
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL)
|
||||
@Where(clause="activo=1")
|
||||
private List<EstacionImpresora> lsEstacionImpresora;
|
||||
|
||||
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL)
|
||||
@Where(clause="activo=1")
|
||||
private List<AbastoBoleto> abastoBoletoList;
|
||||
|
||||
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL)
|
||||
@Where(clause="activo=1")
|
||||
private List<RequisicionBoleto> requisicionBoletoList;
|
||||
|
||||
@OneToMany(mappedBy = "estacion", cascade = CascadeType.ALL)
|
||||
@Where(clause="activo=1")
|
||||
private List<FolioPreimpreso> folioPreimpresoList;
|
||||
|
||||
public Estacion() {
|
||||
|
|
|
@ -54,15 +54,11 @@ public class EstacionServiceImpl implements EstacionService {
|
|||
validarEstoqueUpdate(estacion);
|
||||
|
||||
Boolean esMacDuplicado = Boolean.FALSE;
|
||||
List<Estacion> lsEstacionMac = estacionDAO.buscar(estacion.getDescmac());
|
||||
if (!lsEstacionMac.isEmpty()) {
|
||||
for (Estacion est : lsEstacionMac) {
|
||||
if (!est.getEstacionId().equals(estacion.getEstacionId())) {
|
||||
nomeEstacao = est.getDescestacion();
|
||||
numeroCaixa = est.getNumcaja();
|
||||
esMacDuplicado = Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
Estacion estacionDuplicada = estacionDAO.buscarEstacionDuplicada(estacion.getDescmac(), estacion.getEstacionId());
|
||||
if (estacionDuplicada != null) {
|
||||
nomeEstacao = estacionDuplicada.getDescestacion();
|
||||
numeroCaixa = estacionDuplicada.getNumcaja();
|
||||
esMacDuplicado = Boolean.TRUE;
|
||||
}
|
||||
if (esMacDuplicado) {
|
||||
throw new BusinessException(Labels.getLabel("estacionServiceImpl.msg.macDuplicado") + "\n"
|
||||
|
@ -99,11 +95,11 @@ public class EstacionServiceImpl implements EstacionService {
|
|||
|
||||
String errorNoChequeFolio = null;
|
||||
for (EstacionImpresora ei : estacion.getLsEstacionImpresora()) {
|
||||
boolean isImpressoraFiscal = validacionImpressoraFiscal(ei);
|
||||
if (ApplicationProperties.getInstance().generarRotinaFolios()) {
|
||||
errorNoChequeFolio = autorizaFolioService.noChequeFolioPreimpresos(ei, false);
|
||||
} else if (validacionImpressoraFiscal(ei) && isNuevaFiscal) {
|
||||
errorNoChequeFolio = autorizaFolioService.noChequeFolioPreimpresos(ei, true);
|
||||
}else if(estacion.getIndStockCentral() != null && estacion.getIndStockCentral()){
|
||||
} else if ((isImpressoraFiscal && isNuevaFiscal) ||
|
||||
(estacion.getIndStockCentral() != null && estacion.getIndStockCentral() && isImpressoraFiscal)) {
|
||||
errorNoChequeFolio = autorizaFolioService.noChequeFolioPreimpresos(ei, true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue