wilian 2018-01-22 18:17:46 +00:00
parent af2238ed59
commit bda057d9c0
5 changed files with 86 additions and 48 deletions

View File

@ -48,14 +48,16 @@ public interface ConferenciaComissaoDAO extends GenericDAO<Conferencia, Long> {
public List<LogConferencia> carregarLogConferencia(Long conferenciaId) throws BusinessException;
public boolean isConferenciaCompetenciaEncerrada(String competencia, Empresa empresa, Integer puntoVenta) throws BusinessException;
public boolean isConferenciaCompetenciaEncerrada(String competencia, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException;
public BigDecimal carregarValorDepositoContaCorrente(Integer empresaId, Integer puntoventaId, Date datamovimento);
public DiaConferenciaComissaoVO carregarConferenciaRegistrada(Date datamovimento, Empresa empresa, Integer puntoVenta) throws BusinessException;
public DiaConferenciaComissaoVO carregarConferenciaRegistrada(Date datamovimento, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException;
public Conferencia cancelarChegadaMalote(Conferencia conferencia);
public boolean isConferidoVenta(BoletoComissao boletoComissao);
public void borrarLogConferenciaTransacaoId(Long transacaoId) throws BusinessException;
}

View File

@ -46,6 +46,7 @@ import com.rjconsultores.ventaboletos.enums.comissao.StatusLogConferencia;
import com.rjconsultores.ventaboletos.exception.BusinessException;
import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties;
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
import com.rjconsultores.ventaboletos.vo.comissao.BoletoComissao;
import com.rjconsultores.ventaboletos.vo.comissao.ConferenciaComissaoVO;
import com.rjconsultores.ventaboletos.vo.comissao.DiaConferenciaComissaoVO;
@ -81,26 +82,16 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
try {
con = getConnection();
List<ConferenciaComissaoVO> lsConferenciasFiltro = new ArrayList<ConferenciaComissaoVO>();
carregarPuntoVentas(lsConferenciasFiltro, competencia, empresa, puntoVenta, dataMovimento);
List<ConferenciaComissaoVO> lsConferenciasTodos = new ArrayList<ConferenciaComissaoVO>();
List<ConferenciaComissaoVO> lsConferencias = new ArrayList<ConferenciaComissaoVO>();
for (ConferenciaComissaoVO lsConferenciasTmp : lsConferenciasFiltro) {
List<ConferenciaComissaoVO> lsConferencias = new ArrayList<ConferenciaComissaoVO>();
lsConferencias.add(lsConferenciasTmp);
ConferenciaComissaoVO vo = lsConferencias.get(0);
carregarConferenciasRegistradas(lsConferencias, competencia, empresa, vo.getPuntoventaId(), dataMovimento, null);
carregarMovimentoVendas(con, lsConferencias, competencia, empresa, vo.getPuntoventaId(), dataMovimento, null, null);
carregarDiasSemMovimento(lsConferencias, competencia, empresa, vo.getPuntoventaId(), dataMovimento);
lsConferenciasTodos.addAll(lsConferencias);
}
Collections.sort(lsConferenciasTodos);
carregarPuntoVentas(lsConferencias, competencia, empresa, puntoVenta, dataMovimento);
carregarConferenciasRegistradas(lsConferencias, competencia, empresa, puntoVenta, dataMovimento, null);
carregarMovimentoVendas(con, lsConferencias, competencia, empresa, puntoVenta, dataMovimento, null, null);
carregarDiasSemMovimento(lsConferencias, competencia, empresa, puntoVenta, dataMovimento);
return lsConferenciasTodos;
Collections.sort(lsConferencias);
return lsConferencias;
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new BusinessException(e.getMessage(), e);
@ -122,15 +113,15 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
con = getConnection();
List<ConferenciaComissaoVO> lsConferencias = new ArrayList<ConferenciaComissaoVO>();
Map<String, Object> parametros = carregarParametros(dataInicial, dataFinal, null, empresa, puntoVenta.getPuntoventaId(), dataMovimento, false);
Map<String, Object> parametros = carregarParametros(dataInicial, dataFinal, null, empresa, puntoVenta, dataMovimento, false);
SimpleDateFormat format = new SimpleDateFormat("MM/yyyy");
String competencia = format.format(dataInicial);
carregarPuntoVentas(lsConferencias, dataInicial, dataFinal, empresa, puntoVenta, dataMovimento);
carregarConferenciasRegistradas(lsConferencias, null, empresa, puntoVenta.getPuntoventaId(), dataMovimento, parametros);
carregarMovimentoVendas(con, lsConferencias, null, empresa, puntoVenta.getPuntoventaId(), dataMovimento, dataInicial, dataFinal);
carregarDiasSemMovimento(lsConferencias, competencia, empresa, puntoVenta.getPuntoventaId(), dataMovimento);
carregarConferenciasRegistradas(lsConferencias, null, empresa, puntoVenta, dataMovimento, parametros);
carregarMovimentoVendas(con, lsConferencias, null, empresa, puntoVenta, dataMovimento, dataInicial, dataFinal);
carregarDiasSemMovimento(lsConferencias, competencia, empresa, puntoVenta, dataMovimento);
return lsConferencias;
} catch (Exception e) {
@ -212,7 +203,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
@SuppressWarnings("unchecked")
private void carregarConferenciasRegistradas(List<ConferenciaComissaoVO> lsConferencias,
String competencia, Empresa empresa, Integer puntoVenta, Date dataMovimento, Map<String, Object> parametros) throws BusinessException {
String competencia, Empresa empresa, PuntoVenta puntoVenta, Date dataMovimento, Map<String, Object> parametros) throws BusinessException {
try {
if (parametros == null) {
parametros = carregarParametros(null, null, competencia, empresa, puntoVenta, dataMovimento, false);
@ -255,7 +246,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
}
private void carregarMovimentoVendas(Connection con, List<ConferenciaComissaoVO> lsConferencias,
String competencia, Empresa empresa, Integer puntoVenta, Date dataMovimento, Date dataInicialDate, Date dataFinalDate)
String competencia, Empresa empresa, PuntoVenta puntoVenta, Date dataMovimento, Date dataInicialDate, Date dataFinalDate)
throws BusinessException, SQLException {
PreparedStatement stmt = null;
ResultSet rset = null;
@ -448,7 +439,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
}
private void carregarDiasSemMovimento(List<ConferenciaComissaoVO> lsConferencias,
String competencia, Empresa empresa, Integer puntoVenta, Date dataMovimento) throws ParseException {
String competencia, Empresa empresa, PuntoVenta puntoVenta, Date dataMovimento) throws ParseException {
for (ConferenciaComissaoVO conferenciaComissao : lsConferencias) {
for (Integer diaSemMovimento : conferenciaComissao.getDiasSemMovimentos()) {
DiaConferenciaComissaoVO diaConferenciaComissao = new DiaConferenciaComissaoVO();
@ -470,7 +461,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
}
private Map<String, Object> carregarParametros(Date dataInicial, Date dataFinal, String competencia, Empresa empresa,
Integer puntoVenta, Date datamovimento, boolean formatoDataSemHora) throws ParseException {
PuntoVenta puntoVenta, Date datamovimento, boolean formatoDataSemHora) throws ParseException {
Map<String, Object> parametros = new HashMap<String, Object>();
String formatoData = (formatoDataSemHora ? "dd/MM/yyyy" : "dd/MM/yyyy HH:mm");
@ -478,8 +469,8 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
if (empresa != null) {
parametros.put("empresaId", empresa.getEmpresaId());
}
if (puntoVenta != null && puntoVenta > -1) {
parametros.put("puntoventaId", puntoVenta);
if (puntoVenta != null && puntoVenta.getPuntoventaId() > -1) {
parametros.put("puntoventaId", puntoVenta.getPuntoventaId());
}
if (datamovimento != null) {
@ -563,7 +554,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
private boolean isMovimentoDiarioBoletoGerado(Conferencia conferencia)
throws BusinessException {
try {
Map<String, Object> parametros = carregarParametros(null, null, null, conferencia.getEmpresa(), conferencia.getPuntoVenta().getPuntoventaId(), null, false);
Map<String, Object> parametros = carregarParametros(null, null, null, conferencia.getEmpresa(), conferencia.getPuntoVenta(), null, false);
StringBuilder sQuery = new StringBuilder()
.append("SELECT FECHAMENTOCNTCORRENTE_ID ")
.append("FROM FECHAMENTO_CNTCORRENTE ")
@ -602,7 +593,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
throws BusinessException {
try {
Map<String, Object> parametros = carregarParametros(null, null, conferencia.getCompetencia(), conferencia.getEmpresa(),
conferencia.getPuntoVenta().getPuntoventaId(), conferencia.getDatamovimento(), true);
conferencia.getPuntoVenta(), conferencia.getDatamovimento(), true);
StringBuilder sQuery = new StringBuilder()
.append("SELECT EE.BOLETO_ID AS \"boletoId\", EE.EVENTOEXTRA_ID AS \"eventoextraId\", EE.NUMDOCUMENTO AS \"numdocumento\", ")
.append("CFP.IMPORTE AS \"impingreso\", TEE.DESCTIPOEVENTO AS \"desctipoevento\", EE.DESCINFO AS \"descinfo\", ")
@ -750,6 +741,10 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
public LogConferencia suscribirLogConferencia(LogConferencia logConferencia)
throws BusinessException {
try {
logConferencia.setActivo(Boolean.TRUE);
logConferencia.setUsuario(UsuarioLogado.getUsuarioLogado());
logConferencia.setFecmodif(new Date());
if (logConferencia.getConferencia().getConferenciaId() == null) {
logConferencia.setConferencia(suscribir(logConferencia.getConferencia()));
}
@ -774,6 +769,11 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
contaCorrenteAgenciaDAO.actualizacion(contaCorrentePtoVta);
}
logConferencia.setActivo(Boolean.FALSE);
logConferencia.setUsuario(UsuarioLogado.getUsuarioLogado());
logConferencia.setFecmodif(new Date());
getSession().merge(logConferencia);
} catch (Exception e) {
log.error(e.getMessage(), e);
@ -796,7 +796,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
throws BusinessException {
try {
Map<String, Object> parametros = carregarParametros(null, null, conferencia.getCompetencia(), conferencia.getEmpresa(),
conferencia.getPuntoVenta().getPuntoventaId(), conferencia.getDatamovimento(), true);
conferencia.getPuntoVenta(), conferencia.getDatamovimento(), true);
StringBuilder sQuery = new StringBuilder()
.append("SELECT C.CAJA_ID AS \"cajaId\", C.NUMASIENTO AS \"numAsiento\", C.NUMASIENTOVINCULADO AS \"numAsientoVinculado\", C.NUMOPERACION AS \"numoperacion\", C.NUMFOLIOSISTEMA AS \"numFolioSistema\", ")
@ -810,8 +810,8 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
.append("NVL(C.PRECIOPAGADO,0) + NVL(C.IMPORTEPEDAGIO,0) + NVL(C.IMPORTETAXAEMBARQUE,0) + NVL(C.IMPORTESEGURO,0) + NVL(C.IMPORTEOUTROS,0) AS \"valorTabela\", ")
.append("C.INDCANCELACION AS \"indCancelacion\", C.INDREIMPRESION AS \"indreimpresion\", C.FECCORTE AS \"feccorte\", C.TRANSACAOORIGINAL_ID AS \"transacaoOriginalId\", ")
.append("EI.ICMS as \"icmsBase\", EST.ESTADO_ID as \"estadoId\", ")
.append("CASE WHEN C.PTOVTAVENTA_ID = C.PUNTOVENTA_ID OR C.PTOVTAVENTA_ID IS NULL THEN 1 ELSE 0 END AS ptoVtaOrigem, ")
.append(" M.EMPRESA_ID AS empresaId ")
.append("CASE WHEN C.PTOVTAVENTA_ID = C.PUNTOVENTA_ID OR C.PTOVTAVENTA_ID IS NULL THEN 1 ELSE 0 END AS ptoVtaOrigem, ")
.append("M.EMPRESA_ID AS empresaId, C.TRANSACAO_ID AS \"transacaoId\" ")
.append("FROM CAJA C ")
.append("LEFT JOIN PARADA ORI ON ORI.PARADA_ID = C.ORIGEN_ID ")
.append("LEFT JOIN CIUDAD CID ON CID.CIUDAD_ID = ORI.CIUDAD_ID ")
@ -905,6 +905,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
.addScalar("ptoVtaOrigem", Hibernate.BOOLEAN)
.addScalar("valorbase", Hibernate.BIG_DECIMAL)
.addScalar("empresaId", Hibernate.INTEGER)
.addScalar("transacaoId", Hibernate.LONG)
.setResultTransformer(Transformers.aliasToBean(BoletoComissao.class));
parametros.put("motivoCancelacionGeracaoOcd", Constantes.MVO_CANCEL_GERACAO_OCD.intValue());
@ -972,7 +973,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
public List<OcdVO> carregarOcds(Conferencia conferencia) throws BusinessException {
try {
Map<String, Object> parametros = carregarParametros(null, null, null, conferencia.getEmpresa(),
conferencia.getPuntoVenta().getPuntoventaId(), conferencia.getDatamovimento(), false);
conferencia.getPuntoVenta(), conferencia.getDatamovimento(), false);
StringBuilder sQuery = new StringBuilder()
.append("SELECT DISTINCT O.OCD_ID AS \"ocdId\", O.NUMOPERACION AS \"numoperacion\", O.FECINC AS \"fecinc\", O.FECPAGAR AS \"fecpagar\", O.FECPAGO AS \"fecpago\", ")
@ -1121,7 +1122,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
@Override
public boolean isConferenciaCompetenciaEncerrada(String competencia, Empresa empresa,
Integer puntoVenta) throws BusinessException {
PuntoVenta puntoVenta) throws BusinessException {
try {
List<ConferenciaComissaoVO> lsConferencias = new ArrayList<ConferenciaComissaoVO>();
@ -1163,7 +1164,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
@Override
@SuppressWarnings("unchecked")
public DiaConferenciaComissaoVO carregarConferenciaRegistrada(Date datamovimento,
Empresa empresa, Integer puntoVenta) throws BusinessException {
Empresa empresa, PuntoVenta puntoVenta) throws BusinessException {
try {
String competencia = DateUtil.getStringDate(datamovimento, "MM/yyyy");
Map<String, Object> parametros = carregarParametros(null, null, competencia, empresa, puntoVenta, datamovimento, false);
@ -1233,5 +1234,30 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
return !qr.list().isEmpty();
}
@Override
@SuppressWarnings("unchecked")
@Transactional
public void borrarLogConferenciaTransacaoId(Long transacaoId) throws BusinessException {
try {
StringBuilder sql = new StringBuilder();
sql.append("SELECT log ")
.append("FROM LogConferencia log ")
.append("WHERE log.activo = 1 ")
.append("AND log.transacaoOriginalId =:transacaoId ");
Query qr = getSession().createQuery(sql.toString());
qr.setParameter("transacaoId", transacaoId);
List<LogConferencia> logConferencias = qr.list();
for (LogConferencia logConferencia : logConferencias) {
borrarLogConferencia(logConferencia);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new BusinessException(e.getMessage(), e);
}
}
}

View File

@ -89,5 +89,7 @@ public interface ConferenciaComissaoService extends GenericService<Conferencia,
public void generacionAutomaticaConferencia();
public boolean isConferidoVenta(BoletoComissao boletoComissao);
public void borrarLogConferenciaTransacaoId(Long transacaoId) throws BusinessException;
}

View File

@ -158,17 +158,11 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
@Override
public LogConferencia suscribirLogConferencia(LogConferencia logConferencia) throws BusinessException {
logConferencia.setActivo(Boolean.TRUE);
logConferencia.setUsuario(UsuarioLogado.getUsuarioLogado());
logConferencia.setFecmodif(new Date());
return conferenciaComissaoDAO.suscribirLogConferencia(logConferencia);
}
@Override
public void borrarLogConferencia(LogConferencia logConferencia) throws BusinessException {
logConferencia.setActivo(Boolean.FALSE);
logConferencia.setUsuario(UsuarioLogado.getUsuarioLogado());
logConferencia.setFecmodif(new Date());
conferenciaComissaoDAO.borrarLogConferencia(logConferencia);
}
@ -177,8 +171,6 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
return conferenciaComissaoDAO.obtenerLogConferenciaID(logconferenciaId);
}
@Override
public List<BoletoComissao> carregarBilhetesComissao(List<BoletoComissao> boletoComissaos, List<Conferencia> conferencias, BoletoStatusComissao boletoStatusComissao, boolean carregarDadosFaltantes) throws BusinessException {
@ -730,7 +722,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
@Override
public boolean isConferenciaCompetenciaEncerrada(String competencia, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException {
return conferenciaComissaoDAO.isConferenciaCompetenciaEncerrada(competencia, empresa, puntoVenta.getPuntoventaId());
return conferenciaComissaoDAO.isConferenciaCompetenciaEncerrada(competencia, empresa, puntoVenta);
}
@Override
@ -745,7 +737,7 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
@Override
public DiaConferenciaComissaoVO carregarConferenciaRegistrada(Date datamovimento, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException {
return conferenciaComissaoDAO.carregarConferenciaRegistrada(datamovimento, empresa, puntoVenta.getPuntoventaId());
return conferenciaComissaoDAO.carregarConferenciaRegistrada(datamovimento, empresa, puntoVenta);
}
@Override
@ -977,4 +969,10 @@ public class ConferenciaComissaoServiceImpl implements ConferenciaComissaoServic
public boolean isConferidoVenta(BoletoComissao boletoComissao) {
return conferenciaComissaoDAO.isConferidoVenta(boletoComissao);
}
@Override
public void borrarLogConferenciaTransacaoId(Long transacaoId) throws BusinessException {
conferenciaComissaoDAO.borrarLogConferenciaTransacaoId(transacaoId);
}
}

View File

@ -89,6 +89,8 @@ public class BoletoComissao {
private Conferencia conferencia;
private Date feccorte;
private Long transacaoId;
public Integer getEmpresaId() {
return empresaId;
@ -1050,4 +1052,12 @@ public class BoletoComissao {
this.valorbase = valorbase;
}
public Long getTransacaoId() {
return transacaoId;
}
public void setTransacaoId(Long transacaoId) {
this.transacaoId = transacaoId;
}
}