baixa automática
Automatizar a checagem do folio para empresa que usa impressora fiscal (fixes bug #5785) Tempo: 03 horas git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@39555 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
5071d1dfda
commit
1a6020d1c1
|
@ -3,10 +3,8 @@ package com.rjconsultores.ventaboletos.dao;
|
|||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.AbastoBoleto;
|
||||
import com.rjconsultores.ventaboletos.entidad.AbastoCentral;
|
||||
import com.rjconsultores.ventaboletos.entidad.DetAbastoBoleto;
|
||||
import com.rjconsultores.ventaboletos.entidad.Estacion;
|
||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||
|
||||
public interface DetAbastoBoletoDAO extends GenericDAO<DetAbastoBoleto, Integer> {
|
||||
|
||||
|
@ -17,5 +15,7 @@ public interface DetAbastoBoletoDAO extends GenericDAO<DetAbastoBoleto, Integer>
|
|||
public List<DetAbastoBoleto> buscaDetAbastoBoletos(Estacion origem, String numfolioinicial, String numfoliofinal, String numseriepreimpresa);
|
||||
|
||||
public void desativaDetAbastos(List<DetAbastoBoleto> detAbastoBoletos);
|
||||
|
||||
public List<DetAbastoBoleto> buscabDetAbastoBoletoAutomatico(Estacion estacion, String numseriepreimpresa);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@ package com.rjconsultores.ventaboletos.dao.hibernate;
|
|||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
|
@ -16,7 +14,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import com.rjconsultores.ventaboletos.dao.DetAbastoBoletoDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.AbastoBoleto;
|
||||
import com.rjconsultores.ventaboletos.entidad.AbastoCentral;
|
||||
import com.rjconsultores.ventaboletos.entidad.DetAbastoBoleto;
|
||||
import com.rjconsultores.ventaboletos.entidad.Estacion;
|
||||
|
||||
|
@ -44,53 +41,69 @@ public class DetAbastoBoletoHibernateDAO extends GenericHibernateDAO<DetAbastoBo
|
|||
|
||||
@Override
|
||||
public List<DetAbastoBoleto> buscaDetAbastoBoletos(AbastoBoleto abastoBoleto) {
|
||||
|
||||
|
||||
List<DetAbastoBoleto> detAbastoBoletos = findByCriteria(Restrictions.eq("abastoBoleto", abastoBoleto));
|
||||
return detAbastoBoletos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DetAbastoBoleto> buscaDetAbastoBoletos(Estacion origem, String numfolioinicial, String numfoliofinal, String numseriepreimpresa) {
|
||||
|
||||
|
||||
|
||||
StringBuilder queryString = new StringBuilder("from DetAbastoBoleto det where ")
|
||||
.append(" det.abastoBoleto.estacion.estacionId = :origem")
|
||||
.append(" and det.numseriepreimpresa = :numseriepreimpresa")
|
||||
.append(" and (det.numfolioinicial >= :numfolioinicial and det.numfoliofinal <= :numfoliofinal) ")
|
||||
.append(" order by det.detabastoboletoId");
|
||||
|
||||
.append(" det.abastoBoleto.estacion.estacionId = :origem")
|
||||
.append(" and det.numseriepreimpresa = :numseriepreimpresa")
|
||||
.append(" and (det.numfolioinicial >= :numfolioinicial and det.numfoliofinal <= :numfoliofinal) ")
|
||||
.append(" order by det.detabastoboletoId");
|
||||
|
||||
Query query = getSession().createQuery(queryString.toString());
|
||||
query.setInteger("origem", origem.getEstacionId());
|
||||
query.setString("numseriepreimpresa", numseriepreimpresa);
|
||||
query.setString("numfolioinicial", numfolioinicial);
|
||||
query.setString("numfoliofinal", numfoliofinal);
|
||||
|
||||
|
||||
List<DetAbastoBoleto> detAbastoBoletos = query.list();
|
||||
|
||||
|
||||
return detAbastoBoletos;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void desativaDetAbastos(List<DetAbastoBoleto> detAbastoBoletos) {
|
||||
Session session = getSessionFactory().getCurrentSession();
|
||||
|
||||
Session session = getSessionFactory().getCurrentSession();
|
||||
|
||||
int count = 0;
|
||||
|
||||
for(DetAbastoBoleto det : detAbastoBoletos){
|
||||
|
||||
for (DetAbastoBoleto det : detAbastoBoletos) {
|
||||
det.setActivo(Boolean.FALSE);
|
||||
session.update(det);
|
||||
|
||||
if(++count % 20 == 0){
|
||||
|
||||
if (++count % 20 == 0) {
|
||||
session.flush();
|
||||
session.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
session.flush();
|
||||
session.clear();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DetAbastoBoleto> buscabDetAbastoBoletoAutomatico(Estacion estacion, String numseriepreimpresa) {
|
||||
|
||||
StringBuilder qs = new StringBuilder();
|
||||
qs.append(" from DetAbastoBoleto det ");
|
||||
qs.append(" where det.activo = 1 ");
|
||||
qs.append(" and det.statusoperacion = 1 ");
|
||||
qs.append(" and det.abastoBoleto.estacion.estacionId = :estacion ");
|
||||
qs.append(" and det.numseriepreimpresa = :numseriepreimpresa ");
|
||||
|
||||
Query query = getSession().createQuery(qs.toString());
|
||||
query.setInteger("estacion", estacion.getEstacionId());
|
||||
query.setString("numseriepreimpresa", numseriepreimpresa);
|
||||
|
||||
List<DetAbastoBoleto> detAbastoBoletos = query.list();
|
||||
|
||||
return detAbastoBoletos;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,4 +12,6 @@ public interface AutorizaFolioService {
|
|||
|
||||
public String noChequeFolioPreimpresos(EstacionImpresora estacionImpresora, boolean isImpressoraFiscal);
|
||||
|
||||
public void devolverFoliosAutomaticosImpressoraFiscal(EstacionImpresora ei);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.DetAbastoBoleto;
|
||||
import com.rjconsultores.ventaboletos.entidad.Estacion;
|
||||
|
||||
|
@ -8,7 +10,6 @@ public interface DetAbastoBoletoService extends GenericService<DetAbastoBoleto,
|
|||
public Long getSecuencia();
|
||||
|
||||
public void desabilitaDetAbastos(Estacion origem, String numfolioinicial, String numfoliofinal, String numseriepreimpresa);
|
||||
|
||||
|
||||
|
||||
public List<DetAbastoBoleto> buscabDetAbastoBoletoAutomatico(Estacion estacion, String numseriepreimpresa);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ package com.rjconsultores.ventaboletos.service;
|
|||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.Estacion;
|
||||
import com.rjconsultores.ventaboletos.entidad.EstacionImpresora;
|
||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||
|
||||
|
@ -40,4 +41,6 @@ public interface EstacionService {
|
|||
|
||||
public List<Estacion> buscarEstaciones(PuntoVenta puntoVenta);
|
||||
|
||||
public void devolverFoliosAutomaticosImpressoraFiscal(EstacionImpresora ei);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.rjconsultores.ventaboletos.service.impl;
|
|||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
|
@ -45,6 +46,25 @@ public class AutorizaFolioServiceImpl implements AutorizaFolioService {
|
|||
@Autowired
|
||||
private FolioPreimpresoService folioPreimpresoService;
|
||||
|
||||
@Override
|
||||
public void devolverFoliosAutomaticosImpressoraFiscal(final EstacionImpresora ei) {
|
||||
|
||||
Empresa empresa = ei.getEmpresa();
|
||||
FolioPreimpreso folio = folioPreimpresoService.buscaFolioPreImpressoEstacionImpresora(ei.getEstacion(), empresa);
|
||||
|
||||
if (folio != null) {
|
||||
List<DetAbastoBoleto> lsDetAbasto = detAbastoBoletoService.buscabDetAbastoBoletoAutomatico(ei.getEstacion(), folio.getNumeserie());
|
||||
if (!lsDetAbasto.isEmpty()) {
|
||||
|
||||
DetAbastoBoleto dab = lsDetAbasto.get(0);
|
||||
|
||||
abastoBoletoService.borrar(dab.getAbastoBoleto());
|
||||
detAbastoBoletoService.borrar(dab);
|
||||
folioPreimpresoService.borrar(folio);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean noChequeFolioPreimpresos(Aidf aidf, Estacion origem, Estacion destino, String numfolioinicial, String numfoliofinal, String numseriepreimpresa,
|
||||
Empresa empresaUsuario, TipoMovimentacion tipoMovimentacion) {
|
||||
|
@ -168,7 +188,7 @@ public class AutorizaFolioServiceImpl implements AutorizaFolioService {
|
|||
AbastoBoleto abastoBoleto = geraAbastoBoleto(requisicionBoleto);
|
||||
DetAbastoBoleto detAbastoBoleto = geraDetAbastoBoleto(abastoBoleto);
|
||||
actualizaStatusRequisicion(requisicionBoleto);
|
||||
|
||||
|
||||
FolioPreimpreso folioPreimpreso = geraFolioPreimpreso(detAbastoBoleto);
|
||||
if (folioPreimpreso.getFoliopreimpresoId() == null) {
|
||||
return "MSG.Error";
|
||||
|
|
|
@ -3,13 +3,11 @@ package com.rjconsultores.ventaboletos.service.impl;
|
|||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.DetAbastoBoletoDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.AbastoCentral;
|
||||
import com.rjconsultores.ventaboletos.entidad.DetAbastoBoleto;
|
||||
import com.rjconsultores.ventaboletos.entidad.Estacion;
|
||||
import com.rjconsultores.ventaboletos.service.DetAbastoBoletoService;
|
||||
|
@ -65,22 +63,27 @@ public class DetAbastoBoletoServiceImpl implements DetAbastoBoletoService {
|
|||
|
||||
@Override
|
||||
public void desabilitaDetAbastos(Estacion origem, String numfolioinicial, String numfoliofinal, String numseriepreimpresa) {
|
||||
|
||||
|
||||
List<DetAbastoBoleto> detAbastoBoletos = detAbastoBoletoDAO.buscaDetAbastoBoletos(origem, numfolioinicial, numfoliofinal, numseriepreimpresa);
|
||||
|
||||
if(!detAbastoBoletos.isEmpty()){
|
||||
|
||||
if (!detAbastoBoletos.isEmpty()) {
|
||||
detAbastoBoletoDAO.desativaDetAbastos(detAbastoBoletos);
|
||||
|
||||
DetAbastoBoleto detAbastoBoletoInicial = detAbastoBoletos.get(0);
|
||||
|
||||
DetAbastoBoleto detAbastoBoletoInicial = detAbastoBoletos.get(0);
|
||||
detAbastoBoletoInicial.setNumfoliofinal(numfolioinicial);
|
||||
detAbastoBoletoInicial.setActivo(Boolean.TRUE);
|
||||
detAbastoBoletoDAO.actualizacion(detAbastoBoletoInicial);
|
||||
|
||||
|
||||
DetAbastoBoleto detAbastoBoletoFinal = detAbastoBoletos.get(detAbastoBoletos.size() - 1);
|
||||
detAbastoBoletoFinal.setNumfolioinicial(numfoliofinal);
|
||||
detAbastoBoletoFinal.setActivo(Boolean.TRUE);
|
||||
detAbastoBoletoDAO.actualizacion(detAbastoBoletoFinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DetAbastoBoleto> buscabDetAbastoBoletoAutomatico(Estacion estacion, String numseriepreimpresa) {
|
||||
return detAbastoBoletoDAO.buscabDetAbastoBoletoAutomatico(estacion, numseriepreimpresa);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -111,6 +111,14 @@ public class EstacionServiceImpl implements EstacionService {
|
|||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void devolverFoliosAutomaticosImpressoraFiscal(final EstacionImpresora ei) {
|
||||
|
||||
if (ei.getNombImpresora().equals(BEMATECH_FISCAL)) {
|
||||
autorizaFolioService.devolverFoliosAutomaticosImpressoraFiscal(ei);
|
||||
}
|
||||
}
|
||||
|
||||
private void validarEstoqueUpdate(Estacion estacion) throws BusinessException {
|
||||
|
||||
|
|
Loading…
Reference in New Issue