wilian 2016-06-21 20:51:22 +00:00
parent 504e512ed5
commit 302b52fa74
1 changed files with 16 additions and 23 deletions

View File

@ -145,7 +145,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void carregarConferenciasRegistradas(List<ConferenciaComissaoVO> lsConferencias, String competencia, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException { private void carregarConferenciasRegistradas(List<ConferenciaComissaoVO> lsConferencias, String competencia, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException {
try { try {
Map<String, Object> parametros = carregarParametros(competencia, empresa, puntoVenta); Map<String, Object> parametros = carregarParametros(competencia, empresa, puntoVenta, null);
StringBuilder sQuery = new StringBuilder("SELECT co FROM Conferencia co "); StringBuilder sQuery = new StringBuilder("SELECT co FROM Conferencia co ");
sQuery.append("JOIN co.empresa em ") sQuery.append("JOIN co.empresa em ")
.append("JOIN co.puntoVenta pv ") .append("JOIN co.puntoVenta pv ")
@ -178,8 +178,6 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
qr.setParameterList(parametro.getKey(), (Collection) parametro.getValue()); 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()); qr.setParameterList(parametro.getKey(), (List) parametro.getValue());
} else if(parametro.getValue() instanceof Date) {
qr.setDate(parametro.getKey(), (Date) parametro.getValue());
} else { } else {
qr.setParameter(parametro.getKey(), parametro.getValue()); qr.setParameter(parametro.getKey(), parametro.getValue());
} }
@ -191,7 +189,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
ResultSet rset = null; ResultSet rset = null;
try { try {
Map<String, Object> parametros = carregarParametros(competencia, empresa, puntoVenta); Map<String, Object> parametros = carregarParametros(competencia, empresa, puntoVenta, null);
StringBuilder sQuery = new StringBuilder("SELECT PV.PUNTOVENTA_ID AS \"puntoventaId\", PV.NUMPUNTOVENTA as \"numPuntoVenta\", PV.NOMBPUNTOVENTA as \"nombpuntoventa\", TO_DATE(B.FECHORVENTA, 'DD/MM/YY') as \"datamovimento\" "); StringBuilder sQuery = new StringBuilder("SELECT PV.PUNTOVENTA_ID AS \"puntoventaId\", PV.NUMPUNTOVENTA as \"numPuntoVenta\", PV.NOMBPUNTOVENTA as \"nombpuntoventa\", TO_DATE(B.FECHORVENTA, 'DD/MM/YY') as \"datamovimento\" ");
sQuery.append("FROM BOLETO B ") sQuery.append("FROM BOLETO B ")
.append("INNER JOIN PUNTO_VENTA PV ON B.PUNTOVENTA_ID = PV.PUNTOVENTA_ID ") .append("INNER JOIN PUNTO_VENTA PV ON B.PUNTOVENTA_ID = PV.PUNTOVENTA_ID ")
@ -361,7 +359,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
} }
} }
private Map<String, Object> carregarParametros(String competencia, Empresa empresa, PuntoVenta puntoVenta) throws ParseException { private Map<String, Object> carregarParametros(String competencia, Empresa empresa, PuntoVenta puntoVenta, Date datamovimento) throws ParseException {
Map<String, Object> parametros = new HashMap<String, Object>(); Map<String, Object> parametros = new HashMap<String, Object>();
if(empresa != null) { if(empresa != null) {
parametros.put("empresaId", empresa.getEmpresaId()); parametros.put("empresaId", empresa.getEmpresaId());
@ -370,6 +368,11 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
parametros.put("puntoventaId", puntoVenta.getPuntoventaId()); parametros.put("puntoventaId", puntoVenta.getPuntoventaId());
} }
if(datamovimento != null) {
parametros.put("dataMovimentoInicial", DateUtil.getStringDate(DateUtil.inicioFecha(datamovimento), "dd/MM/yyyy HH:mm"));
parametros.put("dataMovimentoFinal", DateUtil.getStringDate(DateUtil.fimFecha(datamovimento), "dd/MM/yyyy HH:mm"));
}
if(StringUtils.isNotBlank(competencia)) { if(StringUtils.isNotBlank(competencia)) {
String[] vetCompetencia = competencia.split("/"); String[] vetCompetencia = competencia.split("/");
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
@ -438,7 +441,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
private boolean isMovimentoDiarioBoletoGerado(Conferencia conferencia) throws BusinessException { private boolean isMovimentoDiarioBoletoGerado(Conferencia conferencia) throws BusinessException {
try { try {
Map<String, Object> parametros = carregarParametros(null, conferencia.getEmpresa(), conferencia.getPuntoVenta()); Map<String, Object> parametros = carregarParametros(null, conferencia.getEmpresa(), conferencia.getPuntoVenta(), null);
StringBuilder sQuery = new StringBuilder(); StringBuilder sQuery = new StringBuilder();
sQuery.append("SELECT FECHAMENTOCNTCORRENTE_ID ") sQuery.append("SELECT FECHAMENTOCNTCORRENTE_ID ")
.append("FROM FECHAMENTO_CNTCORRENTE ") .append("FROM FECHAMENTO_CNTCORRENTE ")
@ -478,7 +481,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
@SuppressWarnings({ "unchecked", "deprecation" }) @SuppressWarnings({ "unchecked", "deprecation" })
public List<EventosFinanceirosVO> carregarEventosFinanceiros(Conferencia conferencia) throws BusinessException { public List<EventosFinanceirosVO> carregarEventosFinanceiros(Conferencia conferencia) throws BusinessException {
try { try {
Map<String, Object> parametros = carregarParametros(null, conferencia.getEmpresa(), conferencia.getPuntoVenta()); Map<String, Object> parametros = carregarParametros(null, conferencia.getEmpresa(), conferencia.getPuntoVenta(), conferencia.getDatamovimento());
StringBuilder sQuery = new StringBuilder(); StringBuilder sQuery = new StringBuilder();
sQuery.append("SELECT EE.EVENTOEXTRA_ID AS \"eventoextraId\", EE.NUMDOCUMENTO AS \"numdocumento\", ") sQuery.append("SELECT EE.EVENTOEXTRA_ID AS \"eventoextraId\", EE.NUMDOCUMENTO AS \"numdocumento\", ")
.append("EE.IMPINGRESO AS \"impingreso\", TEE.DESCTIPOEVENTO AS \"desctipoevento\", EE.DESCINFO AS \"descinfo\", ") .append("EE.IMPINGRESO AS \"impingreso\", TEE.DESCTIPOEVENTO AS \"desctipoevento\", EE.DESCINFO AS \"descinfo\", ")
@ -495,11 +498,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
.append("LEFT JOIN COM_EMP_FORMAPAGO COMFP ON COMFP.FORMAPAGO_ID = FP.FORMAPAGO_ID AND COMFP.EMPRESA_ID = EE.EMPRESA_ID AND COMFP.ACTIVO = 1 ") .append("LEFT JOIN COM_EMP_FORMAPAGO COMFP ON COMFP.FORMAPAGO_ID = FP.FORMAPAGO_ID AND COMFP.EMPRESA_ID = EE.EMPRESA_ID AND COMFP.ACTIVO = 1 ")
.append("LEFT JOIN COM_EMP_TIPOEVENTOEXTRA COMTEE ON COMTEE.TIPOEVENTOEXTRA_ID = TEE.TIPOEVENTOEXTRA_ID AND COMTEE.EMPRESA_ID = EE.EMPRESA_ID AND COMTEE.ACTIVO = 1 ") .append("LEFT JOIN COM_EMP_TIPOEVENTOEXTRA COMTEE ON COMTEE.TIPOEVENTOEXTRA_ID = TEE.TIPOEVENTOEXTRA_ID AND COMTEE.EMPRESA_ID = EE.EMPRESA_ID AND COMTEE.ACTIVO = 1 ")
.append("WHERE EE.ACTIVO = 1 ") .append("WHERE EE.ACTIVO = 1 ")
.append("AND EE.FECHORINGRESO BETWEEN :dataMovimentoInicial AND :dataMovimentoFinal "); .append("AND EE.FECHORINGRESO BETWEEN TO_DATE(:dataMovimentoInicial, 'DD/MM/YYYY HH24:MI') AND TO_DATE(:dataMovimentoFinal, 'DD/MM/YYYY HH24:MI') ");
parametros.put("dataMovimentoInicial", DateUtil.inicioFecha(conferencia.getDatamovimento()));
parametros.put("dataMovimentoFinal", DateUtil.fimFecha(conferencia.getDatamovimento()));
if(parametros.containsKey("empresaId")) { if(parametros.containsKey("empresaId")) {
sQuery.append("AND EE.EMPRESA_ID = :empresaId "); sQuery.append("AND EE.EMPRESA_ID = :empresaId ");
@ -633,7 +632,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
@SuppressWarnings({ "unchecked", "deprecation" }) @SuppressWarnings({ "unchecked", "deprecation" })
public List<BoletoComissao> carregarBilhetesComissao(Conferencia conferencia) throws BusinessException { public List<BoletoComissao> carregarBilhetesComissao(Conferencia conferencia) throws BusinessException {
try { try {
Map<String, Object> parametros = carregarParametros(null, conferencia.getEmpresa(), conferencia.getPuntoVenta()); Map<String, Object> parametros = carregarParametros(null, conferencia.getEmpresa(), conferencia.getPuntoVenta(), conferencia.getDatamovimento());
StringBuilder sQuery = new StringBuilder(); StringBuilder sQuery = new StringBuilder();
sQuery.append("SELECT B.BOLETO_ID AS \"boletoId\", B.NUMASIENTO AS \"numAsiento\", B.NUMASIENTOVINCULADO AS \"numAsientoVinculado\", ") sQuery.append("SELECT B.BOLETO_ID AS \"boletoId\", B.NUMASIENTO AS \"numAsiento\", B.NUMASIENTOVINCULADO AS \"numAsientoVinculado\", ")
@ -665,10 +664,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
.append("LEFT JOIN COM_EMP_FORMAPAGO COMFP ON COMFP.FORMAPAGO_ID = FP.FORMAPAGO_ID AND COMFP.EMPRESA_ID = B.EMPRESACORRIDA_ID AND COMFP.ACTIVO = 1 ") .append("LEFT JOIN COM_EMP_FORMAPAGO COMFP ON COMFP.FORMAPAGO_ID = FP.FORMAPAGO_ID AND COMFP.EMPRESA_ID = B.EMPRESACORRIDA_ID AND COMFP.ACTIVO = 1 ")
.append("LEFT JOIN COM_EMP_CATEGORIA COMCAT ON COMCAT.CATEGORIA_ID = B.CATEGORIA_ID AND COMCAT.EMPRESA_ID = B.EMPRESACORRIDA_ID AND COMCAT.ACTIVO = 1 ") .append("LEFT JOIN COM_EMP_CATEGORIA COMCAT ON COMCAT.CATEGORIA_ID = B.CATEGORIA_ID AND COMCAT.EMPRESA_ID = B.EMPRESACORRIDA_ID AND COMCAT.ACTIVO = 1 ")
.append("WHERE B.ACTIVO = 1 ") .append("WHERE B.ACTIVO = 1 ")
.append("AND B.FECHORVENTA BETWEEN :dataMovimentoInicial AND :dataMovimentoFinal "); .append("AND B.FECHORVENTA BETWEEN TO_DATE(:dataMovimentoInicial, 'DD/MM/YYYY HH24:MI') AND TO_DATE(:dataMovimentoFinal, 'DD/MM/YYYY HH24:MI') ");
parametros.put("dataMovimentoInicial", DateUtil.inicioFecha(conferencia.getDatamovimento()));
parametros.put("dataMovimentoFinal", DateUtil.fimFecha(conferencia.getDatamovimento()));
if(parametros.containsKey("empresaId")) { if(parametros.containsKey("empresaId")) {
sQuery.append("AND B.MARCA_ID = :empresaId "); sQuery.append("AND B.MARCA_ID = :empresaId ");
@ -754,7 +750,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
@SuppressWarnings({ "unchecked", "deprecation" }) @SuppressWarnings({ "unchecked", "deprecation" })
public List<OcdVO> carregarOcds(Conferencia conferencia) throws BusinessException { public List<OcdVO> carregarOcds(Conferencia conferencia) throws BusinessException {
try { try {
Map<String, Object> parametros = carregarParametros(null, conferencia.getEmpresa(), conferencia.getPuntoVenta()); Map<String, Object> parametros = carregarParametros(null, conferencia.getEmpresa(), conferencia.getPuntoVenta(), conferencia.getDatamovimento());
StringBuilder sQuery = new StringBuilder(); StringBuilder sQuery = new StringBuilder();
sQuery.append("SELECT DISTINCT O.OCD_ID AS \"ocdId\", O.NUMOPERACION AS \"numoperacion\", O.FECINC AS \"fecinc\", O.FECPAGAR AS \"fecpagar\", O.FECPAGO AS \"fecpago\", ") sQuery.append("SELECT DISTINCT O.OCD_ID AS \"ocdId\", O.NUMOPERACION AS \"numoperacion\", O.FECINC AS \"fecinc\", O.FECPAGAR AS \"fecpagar\", O.FECPAGO AS \"fecpago\", ")
@ -767,12 +763,9 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
.append("INNER JOIN USUARIO U ON O.USUARIOPAGO_ID = U.USUARIO_ID ") .append("INNER JOIN USUARIO U ON O.USUARIOPAGO_ID = U.USUARIO_ID ")
.append("LEFT JOIN COM_EMP_CONFERENCIA CEC ON CEC.EMPRESA_ID = B.EMPRESACORRIDA_ID AND CEC.ACTIVO = 1 ") .append("LEFT JOIN COM_EMP_CONFERENCIA CEC ON CEC.EMPRESA_ID = B.EMPRESACORRIDA_ID AND CEC.ACTIVO = 1 ")
.append("WHERE O.ACTIVO = 1 ") .append("WHERE O.ACTIVO = 1 ")
.append("AND O.FECPAGO BETWEEN :dataMovimentoInicial AND :dataMovimentoFinal ") .append("AND O.FECPAGO BETWEEN TO_DATE(:dataMovimentoInicial, 'DD/MM/YYYY HH24:MI') AND TO_DATE(:dataMovimentoFinal, 'DD/MM/YYYY HH24:MI') ")
.append("AND O.INDPAGO = 1 "); .append("AND O.INDPAGO = 1 ");
parametros.put("dataMovimentoInicial", DateUtil.inicioFecha(conferencia.getDatamovimento()));
parametros.put("dataMovimentoFinal", DateUtil.fimFecha(conferencia.getDatamovimento()));
if(parametros.containsKey("empresaId")) { if(parametros.containsKey("empresaId")) {
sQuery.append("AND B.EMPRESACORRIDA_ID = :empresaId "); sQuery.append("AND B.EMPRESACORRIDA_ID = :empresaId ");
} }
@ -937,7 +930,7 @@ public class ConferenciaComissaoHibernateDAO extends GenericHibernateDAO<Confere
public DiaConferenciaComissaoVO carregarConferenciaRegistrada(Date datamovimento, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException { public DiaConferenciaComissaoVO carregarConferenciaRegistrada(Date datamovimento, Empresa empresa, PuntoVenta puntoVenta) throws BusinessException {
try { try {
String competencia = DateUtil.getStringDate(datamovimento, "MM/yyyy"); String competencia = DateUtil.getStringDate(datamovimento, "MM/yyyy");
Map<String, Object> parametros = carregarParametros(competencia, empresa, puntoVenta); Map<String, Object> parametros = carregarParametros(competencia, empresa, puntoVenta, null);
StringBuilder sQuery = new StringBuilder("SELECT co FROM Conferencia co "); StringBuilder sQuery = new StringBuilder("SELECT co FROM Conferencia co ");
sQuery.append("JOIN co.empresa em ") sQuery.append("JOIN co.empresa em ")
.append("JOIN co.puntoVenta pv ") .append("JOIN co.puntoVenta pv ")