|
|
|
@ -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>();
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
lsConferenciasTodos.addAll(lsConferencias);
|
|
|
|
|
}
|
|
|
|
|
Collections.sort(lsConferencias);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Collections.sort(lsConferenciasTodos);
|
|
|
|
|
|
|
|
|
|
return lsConferenciasTodos;
|
|
|
|
|
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\", ")
|
|
|
|
@ -811,7 +811,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
.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("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);
|
|
|
|
@ -1234,4 +1235,29 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|