|
|
|
@ -67,7 +67,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private DataSource dataSource;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
public ConferenciaComissaoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
|
|
|
|
setSessionFactory(factory);
|
|
|
|
@ -90,24 +90,20 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
Collections.sort(lsConferencias);
|
|
|
|
|
|
|
|
|
|
return lsConferencias;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
finally {
|
|
|
|
|
} finally {
|
|
|
|
|
try {
|
|
|
|
|
if (con != null && !con.isClosed()) {
|
|
|
|
|
con.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (SQLException e) {
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<ConferenciaComissaoVO> carregarConferenciaComissao(Date dataInicial, Date dataFinal,
|
|
|
|
|
Empresa empresa, PuntoVenta puntoVenta, Date dataMovimento) throws BusinessException {
|
|
|
|
|
Connection con = null;
|
|
|
|
@ -116,15 +112,15 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
|
|
|
|
|
List<ConferenciaComissaoVO> lsConferencias = new ArrayList<ConferenciaComissaoVO>();
|
|
|
|
|
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, dataMovimento, parametros);
|
|
|
|
|
carregarMovimentoVendas(con, lsConferencias, null, empresa, puntoVenta, dataMovimento, dataInicial, dataFinal);
|
|
|
|
|
carregarDiasSemMovimento(lsConferencias, competencia, empresa, puntoVenta, dataMovimento);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return lsConferencias;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
@ -139,12 +135,11 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void carregarPuntoVentas(List<ConferenciaComissaoVO> lsConferencias, Date dataInicial, Date dataFinal,
|
|
|
|
|
Empresa empresa, PuntoVenta puntoVenta, Date dataMovimento) throws BusinessException {
|
|
|
|
|
|
|
|
|
|
Set<Integer> diasSemMovimentos = DateUtil.carregarDiasCompetencia(dataInicial, dataFinal, dataMovimento);
|
|
|
|
|
|
|
|
|
|
Set<Integer> diasSemMovimentos = DateUtil.carregarDiasCompetencia(dataInicial, dataFinal, dataMovimento);
|
|
|
|
|
ConferenciaComissaoVO conferenciaComissao = new ConferenciaComissaoVO();
|
|
|
|
|
conferenciaComissao.setPuntoventaId(puntoVenta.getPuntoventaId());
|
|
|
|
|
conferenciaComissao.setNombpuntoventa(puntoVenta.getNombpuntoventa());
|
|
|
|
@ -153,16 +148,16 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
conferenciaComissao.setDataFinal(dataFinal);
|
|
|
|
|
conferenciaComissao.setDiasSemMovimentos(diasSemMovimentos);
|
|
|
|
|
lsConferencias.add(conferenciaComissao);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
private void carregarPuntoVentas(List<ConferenciaComissaoVO> lsConferencias, String competencia,
|
|
|
|
|
Empresa empresa, PuntoVenta puntoVenta, Date dataMovimento) throws BusinessException {
|
|
|
|
|
try {
|
|
|
|
|
if (puntoVenta != null && puntoVenta.getPuntoventaId() > -1) {
|
|
|
|
|
Set<Integer> diasSemMovimentos = DateUtil.carregarDiasCompetencia(competencia, dataMovimento);
|
|
|
|
|
Set<Integer> diasSemMovimentos = DateUtil.carregarDiasCompetencia(competencia, dataMovimento);
|
|
|
|
|
ConferenciaComissaoVO conferenciaComissao = new ConferenciaComissaoVO();
|
|
|
|
|
conferenciaComissao.setPuntoventaId(puntoVenta.getPuntoventaId());
|
|
|
|
|
conferenciaComissao.setNombpuntoventa(puntoVenta.getNombpuntoventa());
|
|
|
|
@ -198,25 +193,24 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
setParametros(qr, parametros);
|
|
|
|
|
|
|
|
|
|
processarQueryConferenciaComissao(qr.list(), lsConferencias, competencia, dataMovimento, null, null);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
private void carregarConferenciasRegistradas(List<ConferenciaComissaoVO> lsConferencias,
|
|
|
|
|
String competencia, Empresa empresa, PuntoVenta puntoVenta, Date dataMovimento, Map<String, Object> parametros) throws BusinessException {
|
|
|
|
|
try {
|
|
|
|
|
if(parametros == null){
|
|
|
|
|
if (parametros == null) {
|
|
|
|
|
parametros = carregarParametros(null, null, competencia, empresa, puntoVenta, dataMovimento, false);
|
|
|
|
|
}
|
|
|
|
|
StringBuilder sQuery = new StringBuilder("SELECT co FROM Conferencia co ");
|
|
|
|
|
sQuery.append("JOIN co.empresa em ")
|
|
|
|
|
.append("JOIN co.puntoVenta pv ")
|
|
|
|
|
.append("WHERE co.activo = 1 ")
|
|
|
|
|
.append("AND co.datamovimento BETWEEN TO_DATE(:dataInicial,'DD/MM/YYYY HH24:MI') AND TO_DATE(:dataFinal,'DD/MM/YYYY HH24:MI') ");
|
|
|
|
|
.append("JOIN co.puntoVenta pv ")
|
|
|
|
|
.append("WHERE co.activo = 1 ")
|
|
|
|
|
.append("AND co.datamovimento BETWEEN TO_DATE(:dataInicial,'DD/MM/YYYY HH24:MI') AND TO_DATE(:dataFinal,'DD/MM/YYYY HH24:MI') ");
|
|
|
|
|
|
|
|
|
|
if (parametros.containsKey("empresaId")) {
|
|
|
|
|
sQuery.append("AND em.empresaId = :empresaId ");
|
|
|
|
@ -230,8 +224,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
Date dataInicial = parametros.get("dataInicial") != null ? DateUtil.getDateFromString(parametros.get("dataInicial").toString(), "dd/MM/yyyy HH:mm") : null;
|
|
|
|
|
Date dataFinal = parametros.get("dataFinal") != null ? DateUtil.getDateFromString(parametros.get("dataFinal").toString(), "dd/MM/yyyy HH:mm") : null;
|
|
|
|
|
processarQueryConferencia(qr.list(), lsConferencias, competencia, dataMovimento, dataInicial, dataFinal);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
@ -242,11 +235,9 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
for (Entry<String, Object> parametro : parametros.entrySet()) {
|
|
|
|
|
if (parametro.getValue() instanceof Collection) {
|
|
|
|
|
qr.setParameterList(parametro.getKey(), (Collection) parametro.getValue());
|
|
|
|
|
}
|
|
|
|
|
else if (parametro.getValue() instanceof List) {
|
|
|
|
|
} else if (parametro.getValue() instanceof List) {
|
|
|
|
|
qr.setParameterList(parametro.getKey(), (List) parametro.getValue());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
qr.setParameter(parametro.getKey(), parametro.getValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -258,9 +249,9 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
|
ResultSet rset = null;
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
Map<String, Object> parametros = carregarParametros(dataInicialDate, dataFinalDate, competencia, empresa, puntoVenta, dataMovimento, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> parametros = carregarParametros(dataInicialDate, dataFinalDate, competencia, empresa, puntoVenta, dataMovimento, false);
|
|
|
|
|
|
|
|
|
|
StringBuilder sQuery = new StringBuilder()
|
|
|
|
|
.append("SELECT PV.PUNTOVENTA_ID AS \"puntoventaId\", PV.NUMPUNTOVENTA as \"numPuntoVenta\", ")
|
|
|
|
|
.append("PV.NOMBPUNTOVENTA as \"nombpuntoventa\", TO_DATE(C.FECHORVENTA, 'DD/MM/YY') as \"datamovimento\" ")
|
|
|
|
@ -283,7 +274,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
stmt = con.prepareStatement(sQuery.toString());
|
|
|
|
|
String dataIncial = (String) parametros.get("dataInicial");
|
|
|
|
|
String dataFinal = (String) parametros.get("dataFinal");
|
|
|
|
|
stmt.setString(idxParametro++, dataIncial );
|
|
|
|
|
stmt.setString(idxParametro++, dataIncial);
|
|
|
|
|
stmt.setString(idxParametro++, dataFinal);
|
|
|
|
|
if (parametros.containsKey("empresaId")) {
|
|
|
|
|
stmt.setInt(idxParametro++, (Integer) parametros.get("empresaId"));
|
|
|
|
@ -305,12 +296,10 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
processarQueryConferenciaComissao(movimentos, lsConferencias, competencia, dataMovimento, dataInicialDate, dataFinalDate);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
finally {
|
|
|
|
|
} finally {
|
|
|
|
|
if (rset != null && !rset.isClosed()) {
|
|
|
|
|
rset.close();
|
|
|
|
|
}
|
|
|
|
@ -321,8 +310,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Carrega a {@link ConferenciaComissaoVO} a partir de uma consulta com sql nativo,
|
|
|
|
|
* transformando o resultado em uma coleção de {@link ConferenciaComissaoVO}
|
|
|
|
|
* Carrega a {@link ConferenciaComissaoVO} a partir de uma consulta com sql nativo, transformando o resultado em uma coleção de {@link ConferenciaComissaoVO}
|
|
|
|
|
*
|
|
|
|
|
* @param lsQuery
|
|
|
|
|
* @param lsConferencias
|
|
|
|
@ -332,8 +320,8 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
*/
|
|
|
|
|
private void processarQueryConferenciaComissao(List<ConferenciaComissaoVO> lsQuery,
|
|
|
|
|
List<ConferenciaComissaoVO> lsConferencias, String competencia, Date dataMovimento, Date dataInicial, Date dataFinal) throws ParseException {
|
|
|
|
|
|
|
|
|
|
Set<Integer> diasSemMovimentos = new TreeSet<Integer>() ;
|
|
|
|
|
|
|
|
|
|
Set<Integer> diasSemMovimentos = new TreeSet<Integer>();
|
|
|
|
|
if (dataMovimento != null) {
|
|
|
|
|
DateUtil.carregarDiasCompetencia(competencia, dataMovimento);
|
|
|
|
|
}
|
|
|
|
@ -358,9 +346,9 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
|
|
|
|
|
DiaConferenciaComissaoVO diaConferenciaComissao = new DiaConferenciaComissaoVO();
|
|
|
|
|
diaConferenciaComissao.setDia(dia);
|
|
|
|
|
if(competencia!=null){
|
|
|
|
|
diaConferenciaComissao.setData(DateUtil.getDateFromString(dia + "/" + competencia, "dd/MM/yyyy"));
|
|
|
|
|
}else{
|
|
|
|
|
if (competencia != null) {
|
|
|
|
|
diaConferenciaComissao.setData(DateUtil.getDateFromString(dia + "/" + competencia, "dd/MM/yyyy"));
|
|
|
|
|
} else {
|
|
|
|
|
diaConferenciaComissao.setData(dataMovimento);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -467,9 +455,9 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
private Map<String, Object> carregarParametros(Date dataInicial, Date dataFinal, String competencia, Empresa empresa,
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String formatoData = (formatoDataSemHora ? "dd/MM/yyyy" : "dd/MM/yyyy HH:mm");
|
|
|
|
|
|
|
|
|
|
if (empresa != null) {
|
|
|
|
|
parametros.put("empresaId", empresa.getEmpresaId());
|
|
|
|
|
}
|
|
|
|
@ -486,8 +474,8 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
parametros.put("dataInicial", DateUtil.getStringDate(DateUtil.inicioFecha(DateUtil.getDataInicialCompetencia(competencia)), formatoData));
|
|
|
|
|
parametros.put("dataFinal", DateUtil.getStringDate(DateUtil.fimFecha(DateUtil.getDataFinalCompetencia(competencia)), formatoData));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(parametros.get("dataInicial") == null && dataInicial != null){
|
|
|
|
|
|
|
|
|
|
if (parametros.get("dataInicial") == null && dataInicial != null) {
|
|
|
|
|
parametros.put("dataInicial", DateUtil.getStringDate(dataInicial, formatoData));
|
|
|
|
|
parametros.put("dataFinal", DateUtil.getStringDate(dataFinal, formatoData));
|
|
|
|
|
}
|
|
|
|
@ -504,13 +492,12 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
return encerrarMovimentoDiario(conferencia);
|
|
|
|
|
}
|
|
|
|
|
return suscribirOrActualizacion(conferencia);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public Conferencia cancelarChegadaMalote(Conferencia conferencia) {
|
|
|
|
@ -523,8 +510,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
public Conferencia suscribirOrActualizacion(Conferencia entidad) {
|
|
|
|
|
if (entidad.getConferenciaId() == null) {
|
|
|
|
|
return suscribir(entidad);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
return actualizacion(entidad);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -539,8 +525,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
|
|
|
|
|
gerarLancamentoContaCorrente(conferencia);
|
|
|
|
|
return suscribirOrActualizacion(conferencia);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
@ -552,8 +537,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
try {
|
|
|
|
|
conferencia.setIndconferido(Boolean.FALSE);
|
|
|
|
|
return suscribirOrActualizacion(conferencia);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
@ -581,8 +565,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
setParametros(qr, parametros);
|
|
|
|
|
|
|
|
|
|
return !qr.list().isEmpty();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
@ -631,8 +614,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
.append("LEFT JOIN EMPRESA E ON E.EMPRESA_ID = M.EMPRESA_ID ")
|
|
|
|
|
.append("LEFT JOIN EMPRESA_IMPOSTO EI ON (EI.ESTADO_ID = EST.ESTADO_ID AND EI.EMPRESA_ID = E.EMPRESA_ID AND EI.ACTIVO = 1) ")
|
|
|
|
|
.append("WHERE EE.ACTIVO = 1 ")
|
|
|
|
|
.append("AND CD.FECCORTE BETWEEN TO_DATE(:dataInicial, 'DD/MM/YYYY') AND TO_DATE(:dataFinal, 'DD/MM/YYYY') ")
|
|
|
|
|
;
|
|
|
|
|
.append("AND CD.FECCORTE BETWEEN TO_DATE(:dataInicial, 'DD/MM/YYYY') AND TO_DATE(:dataFinal, 'DD/MM/YYYY') ");
|
|
|
|
|
|
|
|
|
|
if (parametros.containsKey("empresaId")) {
|
|
|
|
|
sQuery.append("AND EE.EMPRESA_ID = :empresaId ");
|
|
|
|
@ -669,14 +651,13 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
setParametros(qr, parametros);
|
|
|
|
|
|
|
|
|
|
List<EventosFinanceirosVO> result = qr.list();
|
|
|
|
|
|
|
|
|
|
for(EventosFinanceirosVO e : result){
|
|
|
|
|
|
|
|
|
|
for (EventosFinanceirosVO e : result) {
|
|
|
|
|
e.setConferencia(conferencia);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
@ -712,7 +693,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
.addScalar("logconferenciaId", Hibernate.LONG)
|
|
|
|
|
.addScalar("observacao", Hibernate.STRING)
|
|
|
|
|
.addScalar("preco", Hibernate.BIG_DECIMAL)
|
|
|
|
|
.addScalar("descComportamentoData",Hibernate.STRING)
|
|
|
|
|
.addScalar("descComportamentoData", Hibernate.STRING)
|
|
|
|
|
.addScalar("status", Hibernate.INTEGER)
|
|
|
|
|
.addScalar("numfoliosistema", Hibernate.STRING)
|
|
|
|
|
.addScalar("tipo", Hibernate.INTEGER)
|
|
|
|
@ -732,15 +713,14 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
qr.setParameter("conferenciaId", conferencia.getConferenciaId());
|
|
|
|
|
|
|
|
|
|
List<LogConferenciaVO> result = qr.list();
|
|
|
|
|
|
|
|
|
|
for(LogConferenciaVO l : result){
|
|
|
|
|
|
|
|
|
|
for (LogConferenciaVO l : result) {
|
|
|
|
|
l.setConferencia(conferencia);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
@ -759,8 +739,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
|
|
|
|
|
getSession().save(logConferencia);
|
|
|
|
|
return logConferencia;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
@ -779,8 +758,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
contaCorrenteAgenciaDAO.actualizacion(contaCorrentePtoVta);
|
|
|
|
|
}
|
|
|
|
|
getSession().merge(logConferencia);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
@ -790,8 +768,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
public LogConferencia obtenerLogConferenciaID(Long logconferenciaId) {
|
|
|
|
|
try {
|
|
|
|
|
return (LogConferencia) this.getHibernateTemplate().get(LogConferencia.class.getName(), logconferenciaId);
|
|
|
|
|
}
|
|
|
|
|
catch (final HibernateException ex) {
|
|
|
|
|
} catch (final HibernateException ex) {
|
|
|
|
|
throw convertHibernateAccessException(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -814,7 +791,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
.append("(select max(COMEMPCATEGORIA_ID) from COM_EMP_CATEGORIA where CATEGORIA_ID = C.CATEGORIA_ID AND EMPRESA_ID = M.EMPRESA_ID AND ACTIVO = 1) AS \"comempcategoriaId\", C.NOMBPASAJERO AS \"nombpasajero\", ")
|
|
|
|
|
.append("E.INDCARBOLETOSDEVOLVIDOSCONF AS \"indcarboletosdevolvidosconf\", C.FECCORRIDA AS \"feccorrida\", C.CORRIDA_ID \"corridaId\", ")
|
|
|
|
|
.append("NVL(T.PRECIO,0) + NVL(T.IMPORTEPEDAGIO,0) + NVL(T.IMPORTETAXAEMBARQUE,0) + NVL(T.IMPORTESEGURO,0) + NVL(T.IMPORTEOUTROS,0) AS \"valorTabela\", ")
|
|
|
|
|
.append("C.INDCANCELACION AS \"indCancelacion\", C.INDREIMPRESION AS \"indreimpresion\", C.FECCORTE AS \"feccorte\", ")
|
|
|
|
|
.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("FROM CAJA C ")
|
|
|
|
@ -836,7 +813,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
.append("WHERE C.ACTIVO = 1 ")
|
|
|
|
|
.append("AND C.FECCORTE BETWEEN TO_DATE(:dataInicial, 'DD/MM/YYYY') AND TO_DATE(:dataFinal, 'DD/MM/YYYY') ")
|
|
|
|
|
.append("AND C.FECHORVENTA BETWEEN VT.FECINICIOVIGENCIA AND VT.FECFINVIGENCIA ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isCalculoComissao) {
|
|
|
|
|
sQuery.append("AND ((C.INDSTATUSBOLETO = 'E' AND C.INDREIMPRESION = 1) OR C.INDREIMPRESION = 0 OR C.MOTIVOCANCELACION_ID = 99) ");
|
|
|
|
|
} else {
|
|
|
|
@ -868,6 +845,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
|
Query qr = getSession().createSQLQuery(sQuery.toString())
|
|
|
|
|
.addScalar("cajaId", Hibernate.LONG)
|
|
|
|
|
.addScalar("transacaoOriginalId", Hibernate.LONG)
|
|
|
|
|
.addScalar("numAsiento", Hibernate.STRING)
|
|
|
|
|
.addScalar("numAsientoVinculado", Hibernate.STRING)
|
|
|
|
|
.addScalar("numFolioSistema", Hibernate.STRING)
|
|
|
|
@ -915,7 +893,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
boletoComissao.setFormapagos(new ArrayList<FormapagoVO>());
|
|
|
|
|
boletoComissao.setConferencia(conferencia);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (lsBoletoComissao.contains(boletoComissao)) {
|
|
|
|
|
int indice = lsBoletoComissao.indexOf(boletoComissao);
|
|
|
|
|
BoletoComissao aux = lsBoletoComissao.get(indice);
|
|
|
|
@ -923,13 +901,13 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
? boletoComissao.getComempcategoriaId() : aux.getComempcategoriaId());
|
|
|
|
|
aux.setComempformapagoId(boletoComissao.getComempformapagoId() != null
|
|
|
|
|
? boletoComissao.getComempformapagoId() : aux.getComempformapagoId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FormapagoVO formapagoVO = new FormapagoVO(boletoComissao.getFormapagoId(),
|
|
|
|
|
boletoComissao.getDescpago(),
|
|
|
|
|
boletoComissao.getIndconferenciafisicacomissao(),
|
|
|
|
|
boletoComissao.getImporteFp());
|
|
|
|
|
|
|
|
|
|
if(aux.getFormapagos().contains(formapagoVO)) {
|
|
|
|
|
boletoComissao.getDescpago(),
|
|
|
|
|
boletoComissao.getIndconferenciafisicacomissao(),
|
|
|
|
|
boletoComissao.getImporteFp());
|
|
|
|
|
|
|
|
|
|
if (aux.getFormapagos().contains(formapagoVO)) {
|
|
|
|
|
formapagoVO = aux.getFormapagos().get(aux.getFormapagos().indexOf(formapagoVO));
|
|
|
|
|
formapagoVO.add(boletoComissao.getImporteFp());
|
|
|
|
|
} else {
|
|
|
|
@ -946,8 +924,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return lsBoletoComissao;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
@ -1003,14 +980,13 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
setParametros(qr, parametros);
|
|
|
|
|
|
|
|
|
|
List<OcdVO> result = qr.list();
|
|
|
|
|
|
|
|
|
|
for(OcdVO ocd : result){
|
|
|
|
|
|
|
|
|
|
for (OcdVO ocd : result) {
|
|
|
|
|
ocd.setConferencia(conferencia);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
@ -1033,8 +1009,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
qr.setMaxResults(1);
|
|
|
|
|
return (Conferencia) qr.uniqueResult();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
@ -1043,20 +1018,20 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
@Transactional
|
|
|
|
|
private void gerarLancamentoContaCorrente(Conferencia conferencia) throws BusinessException {
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Calendar calHoje = Calendar.getInstance();
|
|
|
|
|
Calendar calAmanha = Calendar.getInstance();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
calAmanha.add(Calendar.DAY_OF_MONTH, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<LogConferencia> lsLogConferencia = carregarLogConferencia(conferencia.getConferenciaId());
|
|
|
|
|
String sDataMovimento = DateUtil.getStringDate(conferencia.getDatamovimento(), "dd/MM/yyyy");
|
|
|
|
|
String descOperacion = "CONFERENCIA MOVIMENTO DIA - " + sDataMovimento;
|
|
|
|
|
|
|
|
|
|
for (LogConferencia logConferencia : lsLogConferencia) {
|
|
|
|
|
Calendar cal =calHoje;
|
|
|
|
|
|
|
|
|
|
if(!Boolean.TRUE.equals(logConferencia.getIndmesmodia())){
|
|
|
|
|
Calendar cal = calHoje;
|
|
|
|
|
|
|
|
|
|
if (!Boolean.TRUE.equals(logConferencia.getIndmesmodia())) {
|
|
|
|
|
cal = calAmanha;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1066,14 +1041,14 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
&& logConferencia.getContaCorrentePtoVta().getActivo()))
|
|
|
|
|
|| (logConferencia.getPreco() == null
|
|
|
|
|
|| logConferencia.getPreco().doubleValue() == 0d)
|
|
|
|
|
|| logConferencia.isIndcredito().equals((short) 2)) {
|
|
|
|
|
|| logConferencia.isIndcredito().equals((short) 2)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ContaCorrentePtoVta contaCorrentePtoVta = contaCorrenteAgenciaDAO
|
|
|
|
|
.gravarContaCorrente(conferencia.getPuntoVenta().getPuntoventaId(),
|
|
|
|
|
descOperacion, cal.getTime(), conferencia.getUsuarioId(),
|
|
|
|
|
logConferencia.isIndcredito().equals((short)1) ? Constantes.TIPO_OPERACION_CC_PAGO : Constantes.TIPO_OPERACION_CC_LQ,
|
|
|
|
|
logConferencia.isIndcredito().equals((short) 1) ? Constantes.TIPO_OPERACION_CC_PAGO : Constantes.TIPO_OPERACION_CC_LQ,
|
|
|
|
|
conferencia.getEmpresa().getEmpresaId(),
|
|
|
|
|
Constantes.TURNO_AUTOMATICO, BigDecimal.ZERO, BigDecimal.ZERO,
|
|
|
|
|
BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO,
|
|
|
|
@ -1083,8 +1058,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
logConferencia.setContaCorrentePtoVta(contaCorrentePtoVta);
|
|
|
|
|
suscribirLogConferencia(logConferencia);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
@ -1102,8 +1076,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
Query qr = getSession().createQuery(sQuery.toString());
|
|
|
|
|
qr.setParameter("conferenciaId", conferenciaId);
|
|
|
|
|
return qr.list();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
@ -1127,8 +1100,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
@ -1186,8 +1158,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
|
throw new BusinessException(e.getMessage(), e);
|
|
|
|
|
}
|
|
|
|
@ -1195,15 +1166,36 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Recupera a conexão conforme parametrização em application.properties
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
* @throws SQLException
|
|
|
|
|
*/
|
|
|
|
|
public Connection getConnection() throws SQLException {
|
|
|
|
|
if(ApplicationProperties.getInstance().isDataSourceComissaoBancoProducao()) {
|
|
|
|
|
if (ApplicationProperties.getInstance().isDataSourceComissaoBancoProducao()) {
|
|
|
|
|
return dataSource.getConnection();
|
|
|
|
|
} else {
|
|
|
|
|
return dataSourceRead.getConnection();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isConferidoVenta(BoletoComissao boletoComissao) {
|
|
|
|
|
|
|
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
sql.append("SELECT * FROM caja c ");
|
|
|
|
|
sql.append("INNER JOIN log_conferencia lc ON (c.CAJA_ID = lc.CAJA_ID) ");
|
|
|
|
|
sql.append("WHERE c.EMPRESACORRIDA_ID = 10 ");
|
|
|
|
|
sql.append(" AND c.INDSTATUSBOLETO LIKE 'V' ");
|
|
|
|
|
sql.append(" AND lc.ACTIVO = 1 ");
|
|
|
|
|
sql.append(" AND c.TRANSACAOORIGINAL_ID =:cajaId ");
|
|
|
|
|
sql.append(" AND c.TIPOVENTA_ID IN (5,12,18,81,41) ");
|
|
|
|
|
|
|
|
|
|
Query qr = getSession().createSQLQuery(sql.toString());
|
|
|
|
|
qr.setParameter("cajaId", boletoComissao.getTransacaoOriginalId());
|
|
|
|
|
|
|
|
|
|
return !qr.list().isEmpty();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|