bug#10822

dev:valdevir
qua:

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@81073 d1611594-4594-4d17-8e1d-87c2c4800839
master
valdevir 2018-04-17 20:55:28 +00:00
parent 46a14cd76f
commit ec5b7c8876
10 changed files with 464 additions and 329 deletions

View File

@ -5,6 +5,9 @@ import java.util.List;
import java.util.Map;
import com.rjconsultores.ventaboletos.entidad.Caja;
import com.rjconsultores.ventaboletos.entidad.Marca;
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
import com.rjconsultores.ventaboletos.exception.BusinessException;
import com.rjconsultores.ventaboletos.exception.VendaEmbarcadaBoletoException;
import com.rjconsultores.ventaboletos.exception.VendaEmbarcadaBoletoFormapagoException;
import com.rjconsultores.ventaboletos.exception.VendaEmbarcadaCajaException;
@ -27,4 +30,6 @@ public interface CajaDAO {
Map<String, List<Caja>> buscarCajaYTarjeta(String... numoperacion);
public Integer atualizaCajasIntegracaoTotvs(Marca marca, Date dataIncial, Date dataFinal, PuntoVenta puntoVenta) throws BusinessException;
}

View File

@ -24,4 +24,6 @@ public interface MarcaDAO extends GenericDAO<Marca, Short> {
public List<Marca> buscarMarcaPorEmpresa(List<Empresa> empresa);
public Marca buscarMarcaPorEmpresa(Empresa empresa);
}

View File

@ -19,7 +19,6 @@ import com.rjconsultores.ventaboletos.entidad.PuntoVentaVO;
*/
public interface PuntoVentaDAO extends GenericDAO<PuntoVenta, Integer> {
public List<PuntoVenta> buscaLike(String strEstacion, boolean sinTodos);
public List<PuntoVenta> busca(String nomPuntoVenta, String numPuntoVenta);
@ -39,4 +38,6 @@ public interface PuntoVentaDAO extends GenericDAO<PuntoVenta, Integer> {
public List<String> quantidadeECFPorPuntoVenta(Conferencia conferencia);
public List<PuntoVenta> buscarPuntoVentaPtoVtaComissao(List<Integer> empresas);
public List<PuntoVenta> buscaPuntoVentaEmpresa(Empresa empresa);
}

View File

@ -2,7 +2,6 @@ package com.rjconsultores.ventaboletos.dao.hibernate;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -28,8 +27,10 @@ import org.springframework.transaction.annotation.Transactional;
import com.rjconsultores.ventaboletos.dao.CajaDAO;
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
import com.rjconsultores.ventaboletos.enums.TipoFormapago;
import com.rjconsultores.ventaboletos.entidad.Caja;
import com.rjconsultores.ventaboletos.entidad.Marca;
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
import com.rjconsultores.ventaboletos.enums.TipoFormapago;
import com.rjconsultores.ventaboletos.exception.BusinessException;
import com.rjconsultores.ventaboletos.exception.VendaEmbarcadaBoletoException;
import com.rjconsultores.ventaboletos.exception.VendaEmbarcadaBoletoFormapagoException;
@ -117,6 +118,7 @@ public class CajaHibernateDAO extends GenericHibernateDAO<Object, Long> implemen
return list;
}
@Override
public List<CajaDetalleVO> buscarDetalleCaja(Date fechaDesde, Date fechaHasta, Boolean sembilhetesPacote) {
@ -188,7 +190,7 @@ public class CajaHibernateDAO extends GenericHibernateDAO<Object, Long> implemen
sql.setResultTransformer(new AliasToBeanResultTransformer(CajaDetalleVO.class));
@SuppressWarnings("unchecked")
List<CajaDetalleVO> lsBusca = (List<CajaDetalleVO>)sql.list();
List<CajaDetalleVO> lsBusca = sql.list();
List<CajaDetalleVO> lsResultado = new ArrayList<CajaDetalleVO>();
@ -216,7 +218,6 @@ public class CajaHibernateDAO extends GenericHibernateDAO<Object, Long> implemen
pagamentoVO.setIdentificacaoEmpresa(cd.getCvesecretaria());
pagamentoVO.setRazaoSocial(cd.getDescsecretaria());
if (cd.getNotacreditovendapacoteId() != null) {
NotaCreditoVendaPacoteVO notacredito = new NotaCreditoVendaPacoteVO();
notacredito.setVouchernotacredito(cd.getNotacreditovendapacoteId().toString());
@ -280,6 +281,7 @@ public class CajaHibernateDAO extends GenericHibernateDAO<Object, Long> implemen
return false;
}
@Override
public List<UsuarioVO> buscarCajaCerrado(Date fecha, String cveusuario, String turnoid) {
return buscarCajaCerrado(fecha, cveusuario, turnoid, false);
}
@ -351,7 +353,7 @@ public class CajaHibernateDAO extends GenericHibernateDAO<Object, Long> implemen
.addScalar("precio", BigDecimalType.INSTANCE)
.addScalar("tipoEvento", StringType.INSTANCE);
sql.setResultTransformer(new AliasToBeanResultTransformer(ReceitaDespesaVO.class));
u.setDiversos((List<ReceitaDespesaVO>) sql.list());
u.setDiversos(sql.list());
}
return usuarios;
} catch (Exception e) {
@ -617,4 +619,28 @@ public class CajaHibernateDAO extends GenericHibernateDAO<Object, Long> implemen
}
@Override
@Transactional(rollbackFor = { BusinessException.class })
public Integer atualizaCajasIntegracaoTotvs(Marca marca, Date dataIncial, Date dataFinal, PuntoVenta puntoVenta) throws BusinessException {
// update caja set integradototvs = 0 where PUNTOVENTA_ID = 269 and FECHORVENTA >= '30/03/2018' and FECHORVENTA <= '01/04/2018';
StringBuilder sb = new StringBuilder();
sb.append(" update caja set integradototvs = 0 ");
sb.append(" where FECHORVENTA >= :fechorInicial ");
sb.append(" and FECHORVENTA <= :fechorFinal ");
sb.append(" and PUNTOVENTA_ID = :puntoVentaId ");
if (marca != null) {
sb.append(" and MARCA_ID = :marcaId ");
}
SQLQuery query = getSession().createSQLQuery(sb.toString());
if (marca != null) {
query.setInteger("marcaId", marca.getMarcaId());
}
query.setInteger("puntoVentaId", puntoVenta.getPuntoventaId());
query.setTimestamp("fechorInicial", dataIncial);
query.setTimestamp("fechorFinal", dataFinal);
Integer result = query.executeUpdate();
return result;
}
}

View File

@ -49,6 +49,7 @@ public class MarcaHibernateDAO extends GenericHibernateDAO<Marca, Short>
}
@Override
public List<Marca> buscarPorNome(String nomeMarca) {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
@ -57,6 +58,7 @@ public class MarcaHibernateDAO extends GenericHibernateDAO<Marca, Short>
return c.list();
}
@Override
public List<Marca> buscarTodosExceto(Usuario usuario, Integer... idMarca) {
String hql = " select new com.rjconsultores.ventaboletos.entidad.Marca(marca.marcaId, marca.descmarca) from Marca marca, UsuarioEmpresa ue" +
" where marca.empresa = ue.empresa and ue.usuarioLog = :usuarioId ";
@ -78,6 +80,7 @@ public class MarcaHibernateDAO extends GenericHibernateDAO<Marca, Short>
return lsMarca;
}
@Override
public List<Marca> buscarMarcaPorEmpresa(List<Empresa> empresa) {
if ((empresa == null) || (empresa.isEmpty())) {
return Collections.emptyList();
@ -98,4 +101,16 @@ public class MarcaHibernateDAO extends GenericHibernateDAO<Marca, Short>
return c.list();
}
@Override
public Marca buscarMarcaPorEmpresa(Empresa empresa) {
Criteria c = makeCriteria();
c.add(Restrictions.eq("activo", true));
c.add(Restrictions.eq("empresa", empresa));
List<Marca> marcas = c.list();
if (marcas != null && !marcas.isEmpty()) {
return marcas.get(0);
}
return null;
}
}

View File

@ -61,6 +61,7 @@ public class PuntoVentaHibernateDAO extends GenericHibernateDAO<PuntoVenta, Inte
return c.list();
}
@Override
public List<PuntoVenta> buscaLike(String strEstacion, boolean sinTodos) {
Criteria c = getSession().createCriteria(getPersistentClass());
@ -85,6 +86,7 @@ public class PuntoVentaHibernateDAO extends GenericHibernateDAO<PuntoVenta, Inte
return c.list();
}
@Override
public List<PuntoVenta> busca(String nomPuntoVenta, String numPuntoVenta) {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
@ -95,6 +97,7 @@ public class PuntoVentaHibernateDAO extends GenericHibernateDAO<PuntoVenta, Inte
return c.list();
}
@Override
public List<PuntoVenta> buscaPuntoVenta(String numPuntoVenta) {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
@ -103,6 +106,16 @@ public class PuntoVentaHibernateDAO extends GenericHibernateDAO<PuntoVenta, Inte
return c.list();
}
@Override
public List<PuntoVenta> buscaPuntoVentaEmpresa(Empresa empresa) {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
c.add(Restrictions.eq("empresa", empresa));
return c.list();
}
@Override
public List<PuntoVenta> buscaPuntoVentaParada(Parada parada) {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
@ -112,6 +125,7 @@ public class PuntoVentaHibernateDAO extends GenericHibernateDAO<PuntoVenta, Inte
return c.list();
}
@Override
public List<PuntoVentaVO> buscaPuntoVentaEmpresaSemECF(Empresa empresa) {
StringBuilder sb = new StringBuilder();
sb.append(" select ");
@ -188,6 +202,7 @@ public class PuntoVentaHibernateDAO extends GenericHibernateDAO<PuntoVenta, Inte
return puntosVenta;
}
@Override
public List<PuntoVenta> buscarPuntoVentaPorTipoEstoque(PtovtaTipoEstoque tipoEstoque) {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("ptovtaTipoEstoque", tipoEstoque));
@ -261,8 +276,8 @@ public class PuntoVentaHibernateDAO extends GenericHibernateDAO<PuntoVenta, Inte
q.setInteger("puntoVentaId", conferencia.getPuntoVenta().getPuntoventaId());
q.setInteger("empresaId", conferencia.getEmpresa().getEmpresaId());
q.setTimestamp("dataInicio", DateUtil.inicioFecha((java.util.Date) conferencia.getDatamovimento()));
q.setTimestamp("dataFim", DateUtil.fimFecha((java.util.Date) conferencia.getDatamovimento()));
q.setTimestamp("dataInicio", DateUtil.inicioFecha(conferencia.getDatamovimento()));
q.setTimestamp("dataFim", DateUtil.fimFecha(conferencia.getDatamovimento()));
return q.list();
}

View File

@ -0,0 +1,5 @@
package com.rjconsultores.ventaboletos.entidad;
public class IntegracaoTotvs {
}

View File

@ -0,0 +1,15 @@
package com.rjconsultores.ventaboletos.service;
import java.util.Date;
import java.util.List;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
import com.rjconsultores.ventaboletos.exception.BusinessException;
public interface IntegracaoTotvsService {
public Integer atualizaStstausBilhetesIntegrar(Empresa empresa, Date dataIncial, Date dataFinal, PuntoVenta puntoVenta) throws BusinessException;
public List<PuntoVenta> buscaPuntoVentaEmpresa(Empresa empresa) throws Exception;
}

View File

@ -11,7 +11,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@ -230,7 +230,6 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
return retorno;
}
@Override
public List<BoletoComissao> carregarBilhetesComissao(List<BoletoComissao> boletoComissaos, Conferencia conferencia, BoletoStatusComissao boletoStatusComissao, boolean carregarDadosFaltantes) throws BusinessException {
if (boletoComissaos == null) {
@ -536,6 +535,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
/**
* Calcula o total de deposito
*
* @param resumoComissao
* @param boletoComissaos
* @param lsEventosFinanceiros
@ -590,6 +590,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
* Totaliza os valores conforme o forma pago, apenas do bilhetes que geraram registros em caixa<br>
* (+) Abas: Bilhetes Manual, Bilhetes, Gap Venda<br>
* (-) Abas: Bilhetes Cancelados, Bilhetes Devolvidos, Gap Cancelados, Gap Devolvidos<br>
*
* @param resumoComissao
* @param boletoComissaos
* @param lsEventosFinanceiros
@ -775,6 +776,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
}
}
@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public void generacionAutomaticaConferencia() {
List<PuntoVentaVO> lsPuntoVenta;
@ -804,8 +806,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
conferencia.setEmpresa(empresa);
conferencia.setPuntoVenta(new PuntoVenta(puntoVentaVO.getPuntoventaId()));
conferencia.setDatamovimento(DateUtil.getYesterdayDate());
}
else{
} else {
// Se existe a conferência com status conferido para esta empresa e ponto de venda no dia de ontem, aborta.
if (Boolean.TRUE == conferencia.getIndconferido()) {
log.info("Já existe conferência com status conferido para o Ponto de Venda " + puntoVentaVO.getNombpuntoventa() + " da empresa " + empresa.getNombempresa() + " no dia " + DateUtil.getYesterdayDateString());
@ -892,6 +893,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
return true;
}
}
private boolean validaBilhetesVendidos(List<BoletoComissao> boletosComissaos, Conferencia conferencia) throws BusinessException {
List<BoletoComissao> lsBilhetes = carregarBilhetesComissao(boletosComissaos, conferencia, BoletoStatusComissao.BOLETOS_VENDIDOS, false);
if (!CollectionUtils.isEmpty(lsBilhetes) && isBilhetesSemConferencia(lsBilhetes)) {
@ -901,6 +903,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
return true;
}
}
private boolean validaBilhetesCancelados(List<BoletoComissao> boletosComissaos, Conferencia conferencia) throws BusinessException {
List<BoletoComissao> lsBilhetesCancelados = carregarBilhetesComissao(boletosComissaos, conferencia, BoletoStatusComissao.BOLETO_CANCELADO, false);
if (!CollectionUtils.isEmpty(lsBilhetesCancelados) && isBilhetesSemConferencia(lsBilhetesCancelados)) {
@ -909,6 +912,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
return true;
}
}
private boolean validaBilhetesDevolvidos(List<BoletoComissao> boletosComissaos, Conferencia conferencia) throws BusinessException {
List<BoletoComissao> lsBilhetesDevolvidos = carregarBilhetesComissao(boletosComissaos, conferencia, BoletoStatusComissao.BOLETO_DEVOLVIDO, false);
if (!CollectionUtils.isEmpty(lsBilhetesDevolvidos) && isBilhetesSemConferencia(lsBilhetesDevolvidos)) {
@ -917,6 +921,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
return true;
}
}
private boolean validaBilhetesGap(List<BoletoComissao> boletosComissaos, Conferencia conferencia) throws BusinessException {
List<BoletoComissao> lsBilhetesGap = carregarBilhetesComissao(boletosComissaos, conferencia, BoletoStatusComissao.GAP_VENDIDOS, false);
if (!CollectionUtils.isEmpty(lsBilhetesGap) && isBilhetesSemConferencia(lsBilhetesGap)) {
@ -925,6 +930,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
return true;
}
}
private boolean validaBilhetesGapCancelados(List<BoletoComissao> boletosComissaos, Conferencia conferencia) throws BusinessException {
List<BoletoComissao> lsBilhetesGapCancelados = carregarBilhetesComissao(boletosComissaos, conferencia, BoletoStatusComissao.GAP_CANCELADO, false);
if (!CollectionUtils.isEmpty(lsBilhetesGapCancelados) && isBilhetesSemConferencia(lsBilhetesGapCancelados)) {
@ -951,6 +957,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
return true;
}
}
private boolean validaOcds(Conferencia conferencia) throws BusinessException {
List<OcdVO> lsOcds = carregarOcds(conferencia);
if (!CollectionUtils.isEmpty(lsOcds) && isOcdSemConferencia(lsOcds)) {

View File

@ -0,0 +1,44 @@
package com.rjconsultores.ventaboletos.service.impl;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.rjconsultores.ventaboletos.dao.CajaDAO;
import com.rjconsultores.ventaboletos.dao.MarcaDAO;
import com.rjconsultores.ventaboletos.dao.PuntoVentaDAO;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.Marca;
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
import com.rjconsultores.ventaboletos.exception.BusinessException;
import com.rjconsultores.ventaboletos.service.IntegracaoTotvsService;
@Service("integracaoTotvsService")
public class IntegracaoTotvsServiceImpl implements IntegracaoTotvsService {
@Autowired
CajaDAO cajaDao;
@Autowired
PuntoVentaDAO puntoVentaDao;
@Autowired
MarcaDAO marcaDao;
@Override
public Integer atualizaStstausBilhetesIntegrar(Empresa empresa, Date dataIncial, Date dataFinal, PuntoVenta puntoVenta) throws BusinessException {
Marca marca = null;
if (empresa != null) {
marca = marcaDao.buscarMarcaPorEmpresa(empresa);
}
return cajaDao.atualizaCajasIntegracaoTotvs(marca, dataIncial, dataFinal, puntoVenta);
}
@Override
public List<PuntoVenta> buscaPuntoVentaEmpresa(Empresa empresa) {
return puntoVentaDao.buscaPuntoVentaEmpresa(empresa);
}
}