Correcciones por pruebas de SAP

parent 0839533e
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group> <group>
<file>file:/C:/Users/jfmj_/Documents/DDA/Githg/DDA_CRN_Exhibicion/resources/general.properties</file> <file>file:/C:/Users/jfmj_/Documents/DDA/Githg/DDA_CRN_Exhibicion/src/mx/com/mx/dda/msjb/service.java</file>
<file>file:/C:/Users/jfmj_/Documents/DDA/Githg/DDA_CRN_Exhibicion/src/mx/com/amx/mx/dda/crn/DDAExhibicion.java</file> <file>file:/C:/Users/jfmj_/Documents/DDA/Githg/DDA_CRN_Exhibicion/src/mx/com/amx/mx/dda/crn/DDAExhibicion.java</file>
<file>file:/C:/Users/jfmj_/Documents/DDA/Githg/DDA_CRN_Exhibicion/src/mx/com/amx/mx/dda/crn/bo/DDAExhibicionBO.java</file> <file>file:/C:/Users/jfmj_/Documents/DDA/Githg/DDA_CRN_Exhibicion/src/mx/com/amx/mx/dda/crn/bo/DDAExhibicionBO.java</file>
<file>file:/C:/Users/jfmj_/Documents/DDA/Githg/DDA_CRN_Exhibicion/src/mx/com/amx/mx/dda/crn/dao/DDAExhibicionDAO.java</file> <file>file:/C:/Users/jfmj_/Documents/DDA/Githg/DDA_CRN_Exhibicion/src/mx/com/amx/mx/dda/crn/dao/DDAExhibicionDAO.java</file>
......
package mx.com.amx.mx.dda.crn; package mx.com.amx.mx.dda.crn;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Properties; import java.util.Properties;
...@@ -35,10 +36,11 @@ public class DDAExhibicion implements ApplicationContextAware { ...@@ -35,10 +36,11 @@ public class DDAExhibicion implements ApplicationContextAware {
} }
} }
public void ejecutaProceso() { public String ejecutaProceso() {
LOG.info(" "); LOG.info(" ");
LOG.info("<< :::::::::::::::: Inicia Proceso Notifica Exhibicion DDA :::::::::::::::: >>"); LOG.info("<< :::::::::::::::: Inicia Proceso Notifica Exhibicion DDA :::::::::::::::: >>");
String mensaje = "OK";
try { try {
//-- 1. Verifica que no se este ejecutando ya un proceso de Notificacion //-- 1. Verifica que no se este ejecutando ya un proceso de Notificacion
...@@ -85,126 +87,119 @@ public class DDAExhibicion implements ApplicationContextAware { ...@@ -85,126 +87,119 @@ public class DDAExhibicion implements ApplicationContextAware {
//-- 7. Obtener los titulos recien exhibidos para notificarlos a SAP //-- 7. Obtener los titulos recien exhibidos para notificarlos a SAP
LOG.info(" [INI]. Paso 7.- Obtener Titulos recien exhibidos con base a fecha referencia."); LOG.info(" [INI]. Paso 7.- Obtener Titulos recien exhibidos con base a fecha referencia.");
List<DatosCntTituloExhibicionDTO> lobTitulos = bo.obtenerTitulosRecienExhibidos(lstFechaReferencia); List<DatosCntTituloExhibicionDTO> lobTitulos = bo.obtenerTitulosRecienExhibidos(lstFechaReferencia);
List<DatosCntTituloExhibicionDTO> lobTitulosTC = bo.obtenerContratosRecienExhibidos(lstFechaReferencia);
LOG.info(" [FIN]. Paso 7.- Obtener Titulos recien exhibidos con base a fecha referencia. Titulos:_" + lobTitulos.size() + "_"); LOG.info(" [FIN]. Paso 7.- Obtener Titulos recien exhibidos con base a fecha referencia. Titulos:_" + lobTitulos.size() + "_");
LOG.info(" [INI]. Paso 8.- Envo de terminos comerciales de los contratos. (Creacion de Terminos Comerciales)"); LOG.info(" [INI]. Paso 8.- Envo de terminos comerciales de los contratos. (Creacion de Terminos Comerciales)");
String respuestaTC = bo.ejecutarTerminosComerciales(lobTitulos); Map<String,String> respuestaTC = bo.ejecutarTerminosComerciales(lobTitulosTC);
LOG.info(" [FIN]. Paso 8.- Envo de terminos comerciales de los contratos."); LOG.info(" [FIN]. Paso 8.- Envo de terminos comerciales de los contratos.");
if (respuestaTC.isEmpty()){ if (Objects.nonNull(lobTitulos) && !lobTitulos.isEmpty()) {
if (Objects.nonNull(lobTitulos) && !lobTitulos.isEmpty()) { //-- 8. LLamado a WS para notificar Activo Fijo (Titulos recien exhibidos)
//-- 8. LLamado a WS para notificar Activo Fijo (Titulos recien exhibidos) LOG.info(" [INI]. Paso 9.- Llamado a WS SAP. Interfaz 12.");
LOG.info(" [INI]. Paso 9.- Llamado a WS SAP. Interfaz 12."); ResultadoNotificacionDTO rWS_Notifica = bo.notificarAFijoWS(lobTitulos, respuestaTC);
ResultadoNotificacionDTO rWS_Notifica = bo.notificarAFijoWS(lobTitulos); LOG.info(" [FIN]. Paso 9.- Llamado a WS SAP. Interfaz 12. Resultado: _" + rWS_Notifica.getResultado() + "_");
LOG.info(" [FIN]. Paso 9.- Llamado a WS SAP. Interfaz 12. Resultado: _" + rWS_Notifica.getResultado() + "_");
if (Objects.nonNull(rWS_Notifica.getNotificaciones()) && rWS_Notifica.getResultado()) {
if (Objects.nonNull(rWS_Notifica.getNotificaciones()) && rWS_Notifica.getResultado()) { //-- Verifica que los enviados sean igual a los procesados(notificados) por parte de SAP
//-- Verifica que los enviados sean igual a los procesados(notificados) por parte de SAP //-- Si se enviaron 3, mismos 3 que debera regresar
//-- Si se enviaron 3, mismos 3 que debería regresar if (rWS_Notifica.getNotificaciones().size() == rWS_Notifica.getTitulosEnviados()) {
if (rWS_Notifica.getNotificaciones().size() == lobTitulos.size()) { //-- Recorrer la respuesta en busqueda de los titulos notificados en SAP correctamente
//-- Recorrer la respuesta en busqueda de los titulos notificados en SAP correctamente int lnuTitulosNotificados = rWS_Notifica.getNotificaciones().size();
int lnuTitulosNotificados = rWS_Notifica.getNotificaciones().size(); int lnuNotificadosSAP_OK = 0;
int lnuNotificadosSAP_OK = 0; int lnuNotificadosSAP_NOOK = 0;
int lnuNotificadosSAP_NOOK = 0; int lnuUpdFechaNotifica_OK = 0;
int lnuUpdFechaNotifica_OK = 0; int lnuUpdFechaNotifica_NOOK = 0;
int lnuUpdFechaNotifica_NOOK = 0; int lnuInsSubNum_OK = 0;
int lnuInsSubNum_OK = 0; int lnuInsSubNum_NOOK = 0;
int lnuInsSubNum_NOOK = 0;
//-- 9. Proceso de la respuesta de SAP y actualiza fecha de notificacion para aquellos que se notificaron correctamente en SAP
//-- 9. Proceso de la respuesta de SAP y actualiza fecha de notificacion para aquellos que se notificaron correctamente en SAP LOG.info(" [INI]. Paso 10.- Revision de la respuesta de SAP para actualizar fecha notificacion SAP a los titulos notificados correctamente.");
LOG.info(" [INI]. Paso 10.- Revision de la respuesta de SAP para actualizar fecha notificacion SAP a los titulos notificados correctamente."); for (RespSAPNotificaAFijoDTO notificacion : rWS_Notifica.getNotificaciones() ) {
for (RespSAPNotificaAFijoDTO notificacion : rWS_Notifica.getNotificaciones() ) { if (notificacion.getStatus().equalsIgnoreCase("OK")) {
if (notificacion.getStatus().equalsIgnoreCase("OK")) { lnuNotificadosSAP_OK++;
lnuNotificadosSAP_OK++;
//-- Actualiza fecha de notificacion en los registros notificados correctamente en SAP
//-- Actualiza fecha de notificacion en los registros notificados correctamente en SAP ContratoTituloDTO cntTitulo = new ContratoTituloDTO();
ContratoTituloDTO cntTitulo = new ContratoTituloDTO(); cntTitulo.setID_TITULO_CNTORIG(notificacion.getCodigoDDA());
cntTitulo.setID_TITULO_CNTORIG(notificacion.getCodigoDDA()); boolean lboActFechaNotifica = bo.actualizaFechaNotificacion(cntTitulo);
boolean lboActFechaNotifica = bo.actualizaFechaNotificacion(cntTitulo); LOG.info(" Actualiza fecha notificacion SAP. Titulo CNT con ID [" + notificacion.getCodigoDDA() + "]. Resultado: _" + lboActFechaNotifica + "_");
LOG.info(" Actualiza fecha notificacion SAP. Titulo CNT con ID [" + notificacion.getCodigoDDA() + "]. Resultado: _" + lboActFechaNotifica + "_");
if (lboActFechaNotifica) {
if (lboActFechaNotifica) { lnuUpdFechaNotifica_OK++;
lnuUpdFechaNotifica_OK++;
//--Insercion de registro en tabla de Aumentos/Disminucion y Subnumero
//--Insercion de registro en tabla de Aumentos/Disminucion y Subnumero boolean lboRegistroSubNum = bo.insertarRegistroSubNumero(notificacion.getCodigoDDA());
boolean lboRegistroSubNum = bo.insertarRegistroSubNumero(notificacion.getCodigoDDA()); if (lboRegistroSubNum) {
if (lboRegistroSubNum) { lnuInsSubNum_OK++;
lnuInsSubNum_OK++; } else {
} else { lnuInsSubNum_NOOK++;
lnuInsSubNum_NOOK++;
}
}//Ends if(lboActFechaNotifica)
else {
lnuUpdFechaNotifica_NOOK++;
} }
} else {
lnuNotificadosSAP_NOOK++;
}
}//Ends if(lboActFechaNotifica)
else {
lnuUpdFechaNotifica_NOOK++;
}
} else {
lnuNotificadosSAP_NOOK++;
} }
LOG.info(" [FIN]. Paso 10.- Revision de la respuesta de SAP para actualizar fecha notificacion SAP a los titulos notificados correctamente.");
LOG.info("------------------------------------------------------------------------- ");
LOG.info("- Resumen de proceso: ");
LOG.info("------------------------------------------------------------------------- ");
LOG.info("CREACION ORDEN DE COMPRA(i10) ");
LOG.info("============================= ");
LOG.info(" ");
LOG.info("Total de registros enviados para Orden de Compra:[" + resCOrdenCompra.getLnuTotalRegOCSAP_Envio() + "]");
LOG.info("Total de registros retornados por SAP de Orden de Compra:[" + resCOrdenCompra.getLnuTotalRegOCSAP_Regreso() + "]");
LOG.info(" ");
LOG.info("Total de registrados Orden de Compra correctamente:[" + resCOrdenCompra.getLnuTotalRegOCSAP_OK() + "]");
LOG.info("Total de registrados Orden de Compra incorrectamente:[" + resCOrdenCompra.getLnuTotalRegOCSAP_NOOK() + "]");
LOG.info(" ");
LOG.info("Total de registros actualizados Id SAP:[" + resCOrdenCompra.getLnuTotalUpdIdSAP_OK() + "]");
LOG.info("Total de registros no se pudo actualizar Id SAP :[" + resCOrdenCompra.getLnuTotalUpdIdSAP_NOOK() + "]");
LOG.info(" ");
LOG.info("NOTIFICACION TITULOS SAP(i12) ");
LOG.info("============================= ");
LOG.info("Total de registros enviados: [" + lobTitulos.size() + "]");
LOG.info("Total de registros retornados por SAP: [" + lnuTitulosNotificados + "]");
LOG.info(" ");
LOG.info("Total de registros notificados satisfactoriamente en SAP: [" + lnuNotificadosSAP_OK + "] *");
LOG.info("Total de registros notificados incorrectamente en SAP: [" + lnuNotificadosSAP_NOOK + "]");
LOG.info(" ");
LOG.info("* Total de registros actualizados en fecha notificacion: [" + lnuUpdFechaNotifica_OK + "]");
LOG.info("* Total de registros no se pudo actualizar fecha notificacion: [" + lnuUpdFechaNotifica_NOOK + "]");
LOG.info(" ");
LOG.info("* Total de registros subnumero insertados correctamente: [" + lnuInsSubNum_OK + "]");
LOG.info("* Total de registros subnumero no se pudo insertar: [" + lnuInsSubNum_NOOK + "]");
LOG.info("------------------------------------------------------------------------- ");
bo.actualizarEjecutandoProcesoNotificacion("0");
LOG.info("Apaga bandera de proceso Notifica.[Caso Revision respuesta SAP y Actualizacion Fecha.]");
}//Ends if(rWS_Notifica.getNotificaciones().size() == lobTitulos.size())
else {
LOG.error("DDA-NOT-011: El numero de titulos procesados fueron distintos al numero de titulos enviado.");
bo.actualizarEjecutandoProcesoNotificacion("0");
LOG.info("Apaga bandera de proceso Notifica.[Caso Enviados y procesados distinto total.]");
} }
}// Ends if(rWS_Notifica.getNotificaciones() != null && rWS_Notifica.getResultado()) LOG.info(" [FIN]. Paso 10.- Revision de la respuesta de SAP para actualizar fecha notificacion SAP a los titulos notificados correctamente.");
else if (Objects.nonNull(rWS_Notifica.getTransFault()) && !rWS_Notifica.getResultado()) {
//-- Tracking LOG.info("------------------------------------------------------------------------- ");
LOG.error("Error al llamar el WS Notifica Activo Fijo: " + rWS_Notifica.getTransFault().toString()); LOG.info("- Resumen de proceso: ");
LOG.error("Datos recibidos de la interfaz 12: " + rWS_Notifica.getNotificaciones().size() + " Datos enviados a la interfaz 12 " + lobTitulos.size()); LOG.info("------------------------------------------------------------------------- ");
LOG.info("CREACION ORDEN DE COMPRA(i10) ");
LOG.info("============================= ");
LOG.info(" ");
LOG.info("Total de registros enviados para Orden de Compra:[" + resCOrdenCompra.getLnuTotalRegOCSAP_Envio() + "]");
LOG.info("Total de registros retornados por SAP de Orden de Compra:[" + resCOrdenCompra.getLnuTotalRegOCSAP_Regreso() + "]");
LOG.info(" ");
LOG.info("Total de registrados Orden de Compra correctamente:[" + resCOrdenCompra.getLnuTotalRegOCSAP_OK() + "]");
LOG.info("Total de registrados Orden de Compra incorrectamente:[" + resCOrdenCompra.getLnuTotalRegOCSAP_NOOK() + "]");
LOG.info(" ");
LOG.info("Total de registros actualizados Id SAP:[" + resCOrdenCompra.getLnuTotalUpdIdSAP_OK() + "]");
LOG.info("Total de registros no se pudo actualizar Id SAP :[" + resCOrdenCompra.getLnuTotalUpdIdSAP_NOOK() + "]");
LOG.info(" ");
LOG.info("NOTIFICACION TITULOS SAP(i12) ");
LOG.info("============================= ");
LOG.info("Total de registros enviados: [" + lobTitulos.size() + "]");
LOG.info("Total de registros retornados por SAP: [" + lnuTitulosNotificados + "]");
LOG.info(" ");
LOG.info("Total de registros notificados satisfactoriamente en SAP: [" + lnuNotificadosSAP_OK + "] *");
LOG.info("Total de registros notificados incorrectamente en SAP: [" + lnuNotificadosSAP_NOOK + "]");
LOG.info(" ");
LOG.info("* Total de registros actualizados en fecha notificacion: [" + lnuUpdFechaNotifica_OK + "]");
LOG.info("* Total de registros no se pudo actualizar fecha notificacion: [" + lnuUpdFechaNotifica_NOOK + "]");
LOG.info(" ");
LOG.info("* Total de registros subnumero insertados correctamente: [" + lnuInsSubNum_OK + "]");
LOG.info("* Total de registros subnumero no se pudo insertar: [" + lnuInsSubNum_NOOK + "]");
LOG.info("------------------------------------------------------------------------- ");
bo.actualizarEjecutandoProcesoNotificacion("0"); bo.actualizarEjecutandoProcesoNotificacion("0");
LOG.info("Apaga bandera de proceso Notifica.[Caso TransFault]"); LOG.info("Apaga bandera de proceso Notifica.[Caso Revision respuesta SAP y Actualizacion Fecha.]");
}
}//Ends if(lobTitulos != null && lobTitulos.size() > 0)
else {
LOG.error("DDA-NOT-006: No se encontraron registros de titulos recien exhibidos.");
}//Ends if(rWS_Notifica.getNotificaciones().size() == lobTitulos.size())
else {
LOG.error("DDA-NOT-011: El numero de titulos procesados fueron distintos al numero de titulos enviado.");
mensaje = "Error: DDA-NOT-011";
bo.actualizarEjecutandoProcesoNotificacion("0");
LOG.info("Apaga bandera de proceso Notifica.[Caso Enviados y procesados distinto total.]");
}
}// Ends if(rWS_Notifica.getNotificaciones() != null && rWS_Notifica.getResultado())
else if (Objects.nonNull(rWS_Notifica.getTransFault()) && !rWS_Notifica.getResultado()) {
//-- Tracking
LOG.error("Error al llamar el WS Notifica Activo Fijo: " + rWS_Notifica.getTransFault().toString());
mensaje = "Error: DDA-NOT-012";
LOG.error("Datos recibidos de la interfaz 12: " + rWS_Notifica.getNotificaciones().size() + " Datos enviados a la interfaz 12 " + lobTitulos.size());
bo.actualizarEjecutandoProcesoNotificacion("0"); bo.actualizarEjecutandoProcesoNotificacion("0");
LOG.info("Apaga bandera de proceso Notifica.[Else_lobTitulos_null]"); LOG.info("Apaga bandera de proceso Notifica.[Caso TransFault]");
} }
} }//Ends if(lobTitulos != null && lobTitulos.size() > 0)
else { else {
LOG.error("DDA-NOT-012: Falla en terminos comerciales."); LOG.error("DDA-NOT-006: No se encontraron registros de titulos recien exhibidos.");
mensaje = "Error: DDA-NOT-006";
bo.actualizarEjecutandoProcesoNotificacion("0"); bo.actualizarEjecutandoProcesoNotificacion("0");
updateTitulos(contratos, respuestaTC);
LOG.info("Apaga bandera de proceso Notifica.[Else_lobTitulos_null]"); LOG.info("Apaga bandera de proceso Notifica.[Else_lobTitulos_null]");
} }
...@@ -216,6 +211,7 @@ public class DDAExhibicion implements ApplicationContextAware { ...@@ -216,6 +211,7 @@ public class DDAExhibicion implements ApplicationContextAware {
}//Ends if(lstFechaReferencia.trim().length() > 0) }//Ends if(lstFechaReferencia.trim().length() > 0)
else { else {
LOG.error("DDA-NOT-005: No se pudo obtener la fecha de referencia"); LOG.error("DDA-NOT-005: No se pudo obtener la fecha de referencia");
mensaje = "Error: DDA-NOT-005";
updateTitulos(contratos, "NO SE LOGRO OBTENER LA FECHA DE REFERENCIA"); updateTitulos(contratos, "NO SE LOGRO OBTENER LA FECHA DE REFERENCIA");
bo.actualizarEjecutandoProcesoNotificacion("0"); bo.actualizarEjecutandoProcesoNotificacion("0");
LOG.info("Apaga bandera de proceso Notifica.[Else_lstFechaReferencia_trim()_length()]"); LOG.info("Apaga bandera de proceso Notifica.[Else_lstFechaReferencia_trim()_length()]");
...@@ -224,6 +220,7 @@ public class DDAExhibicion implements ApplicationContextAware { ...@@ -224,6 +220,7 @@ public class DDAExhibicion implements ApplicationContextAware {
else { else {
LOG.error("DDA-NOT-004: No se pudo obtener el valor de referencia"); LOG.error("DDA-NOT-004: No se pudo obtener el valor de referencia");
updateTitulos(contratos, "NO SE LOGRO OBTENER VALOR DE REFERENCIA"); updateTitulos(contratos, "NO SE LOGRO OBTENER VALOR DE REFERENCIA");
mensaje = "Error: DDA-NOT-004";
bo.actualizarEjecutandoProcesoNotificacion("0"); bo.actualizarEjecutandoProcesoNotificacion("0");
LOG.info("Apaga bandera de proceso Notifica.[Else_boActualizarBanderaIniciaProceso]"); LOG.info("Apaga bandera de proceso Notifica.[Else_boActualizarBanderaIniciaProceso]");
} }
...@@ -231,6 +228,7 @@ public class DDAExhibicion implements ApplicationContextAware { ...@@ -231,6 +228,7 @@ public class DDAExhibicion implements ApplicationContextAware {
else { else {
LOG.error("DDA-NOT-003: No se pudo actualizar la bandera de inicio de proceso."); LOG.error("DDA-NOT-003: No se pudo actualizar la bandera de inicio de proceso.");
updateTitulos(contratos, "NO SE LOGRO ACTUALIZAR LA BANDERA DE INICIO"); updateTitulos(contratos, "NO SE LOGRO ACTUALIZAR LA BANDERA DE INICIO");
mensaje = "Error: DDA-NOT-003";
bo.actualizarEjecutandoProcesoNotificacion("0"); bo.actualizarEjecutandoProcesoNotificacion("0");
LOG.info("Apaga bandera de proceso Notifica.[Else_boActualizarBanderaIniciaProceso]"); LOG.info("Apaga bandera de proceso Notifica.[Else_boActualizarBanderaIniciaProceso]");
...@@ -239,21 +237,25 @@ public class DDAExhibicion implements ApplicationContextAware { ...@@ -239,21 +237,25 @@ public class DDAExhibicion implements ApplicationContextAware {
else { else {
LOG.error("DDA-NOT-002: No se han otorgado los permisos para poder iniciar el proceso."); LOG.error("DDA-NOT-002: No se han otorgado los permisos para poder iniciar el proceso.");
updateTitulos(contratos, "SIN PERMISOS PARA INICIAR PROCESOS A SAP"); updateTitulos(contratos, "SIN PERMISOS PARA INICIAR PROCESOS A SAP");
mensaje = "Error: DDA-NOT-002";
bo.actualizarEjecutandoProcesoNotificacion("0"); bo.actualizarEjecutandoProcesoNotificacion("0");
} }
}//Ends if(!boEjecutandoseProceso) }//Ends if(!boEjecutandoseProceso)
else { else {
LOG.error("DDA-NOT-001: Es probable que se haya iniciado este proceso previamente."); LOG.error("DDA-NOT-001: Es probable que se haya iniciado este proceso previamente.");
mensaje = "Error: DDA-NOT-001";
updateTitulos(contratos, "PROCESO DE SAP INICIADO PREVIAMENTE"); updateTitulos(contratos, "PROCESO DE SAP INICIADO PREVIAMENTE");
bo.actualizarEjecutandoProcesoNotificacion("0"); bo.actualizarEjecutandoProcesoNotificacion("0");
} }
} catch (Exception e) { } catch (Exception e) {
LOG.error("Ocurrio un error en ejecutaProceso::DDAExhibicion: " + e.getMessage()); LOG.error("Ocurrio un error en ejecutaProceso::DDAExhibicion: " + e.getMessage());
mensaje = "Error: DDA-NOT-013";
} }
LOG.info("<< :::::::::::::::: Finaliza Proceso Notifica Exhibicion DDA :::::::::::::::: >>"); LOG.info("<< :::::::::::::::: Finaliza Proceso Notifica Exhibicion DDA :::::::::::::::: >>");
LOG.info(" "); LOG.info(" ");
return mensaje;
} }
private void updateTitulos(List<ContratoDTO> contratos, String mensaje){ private void updateTitulos(List<ContratoDTO> contratos, String mensaje){
......
...@@ -265,30 +265,37 @@ public class DDAExhibicionBO { ...@@ -265,30 +265,37 @@ public class DDAExhibicionBO {
TransactionFaultDTO tf = resultado.getTransFault(); TransactionFaultDTO tf = resultado.getTransFault();
List<RespSAPActivoFijoDTO> afs = resultado.getActivosFijos(); List<RespSAPActivoFijoDTO> afs = resultado.getActivosFijos();
String method = "crearActivoFijoWS"; String method = "crearActivoFijoWS";
Map<String,String> contratosIdSap = new HashMap<>();
try { try {
DTActivoFijo params = new DTActivoFijo(); DTActivoFijo params = new DTActivoFijo();
for (ItemActivoFijoDTO titulo : dto.getContratos()) { for (ItemActivoFijoDTO titulo : dto.getContratos()) {
DTActivoFijo.Registro tituloAF = new DTActivoFijo.Registro(); String idSap = dao.validarIdSap(titulo.getContratoDDA());
tituloAF.setCentroCoste((Objects.nonNull(titulo.getCentroCosto()) && !titulo.getCentroCosto().isEmpty()) ? titulo.getCentroCosto() : ""); if(idSap.isEmpty()){
tituloAF.setCodigoDDA((Objects.nonNull(titulo.getCodigoDDA()) && !titulo.getCodigoDDA().isEmpty()) ? titulo.getCodigoDDA() : ""); DTActivoFijo.Registro tituloAF = new DTActivoFijo.Registro();
tituloAF.setDescripcion(strManager.extraerPrimerosCaracteres( tituloAF.setCentroCoste((Objects.nonNull(titulo.getCentroCosto()) && !titulo.getCentroCosto().isEmpty()) ? titulo.getCentroCosto() : "");
(Objects.nonNull(titulo.getDescripcion())&& !titulo.getDescripcion().isEmpty()) ? titulo.getDescripcion() : "", 45)); tituloAF.setCodigoDDA((Objects.nonNull(titulo.getCodigoDDA()) && !titulo.getCodigoDDA().isEmpty()) ? titulo.getCodigoDDA() : "");
tituloAF.setOrdenCompra((Objects.nonNull(titulo.getOrdenCompra()) && !titulo.getOrdenCompra().isEmpty()) ? titulo.getOrdenCompra() : ""); tituloAF.setDescripcion(strManager.extraerPrimerosCaracteres(
tituloAF.setProveedor((Objects.nonNull(titulo.getProveedor()) && !titulo.getProveedor().isEmpty()) ? titulo.getProveedor() : ""); (Objects.nonNull(titulo.getDescripcion())&& !titulo.getDescripcion().isEmpty()) ? titulo.getDescripcion() : "", 45));
tituloAF.setProgramID((Objects.nonNull(titulo.getProgramID()) && !titulo.getProgramID().isEmpty()) ? titulo.getProgramID() : ""); tituloAF.setOrdenCompra((Objects.nonNull(titulo.getOrdenCompra()) && !titulo.getOrdenCompra().isEmpty()) ? titulo.getOrdenCompra() : "");
tituloAF.setContratoDDA((Objects.nonNull(titulo.getContratoDDA()) && !titulo.getContratoDDA().isEmpty()) ? titulo.getContratoDDA() : "" ); tituloAF.setProveedor((Objects.nonNull(titulo.getProveedor()) && !titulo.getProveedor().isEmpty()) ? titulo.getProveedor() : "");
tituloAF.setInicioAmortizacion((Objects.nonNull(titulo.getInicioAmortizacion()) && !titulo.getInicioAmortizacion().isEmpty()) ? titulo.getInicioAmortizacion() : "" ); tituloAF.setProgramID((Objects.nonNull(titulo.getProgramID()) && !titulo.getProgramID().isEmpty()) ? titulo.getProgramID() : "");
params.getRegistro().add(tituloAF); tituloAF.setContratoDDA((Objects.nonNull(titulo.getContratoDDA()) && !titulo.getContratoDDA().isEmpty()) ? titulo.getContratoDDA() : "" );
tituloAF.setInicioAmortizacion((Objects.nonNull(titulo.getInicioAmortizacion()) && !titulo.getInicioAmortizacion().isEmpty()) ? titulo.getInicioAmortizacion() : "" );
params.getRegistro().add(tituloAF);
} else{
contratosIdSap.put(titulo.getContratoDDA(), idSap);
}
} }
//--Llamado al WS de SAP. Interfaz 10. //--Llamado al WS de SAP. Interfaz 10.
LOG.debug(" Url Srv. Activo Fijo primer llamado: " + this.getUrlServicio(TEN)); LOG.debug(" Url Srv. Activo Fijo primer llamado: " + this.getUrlServicio(TEN));
DTActivoFijoRes responseActivoFijo = null;
if(params.getRegistro().size() > 0){
responseActivoFijo = (DTActivoFijoRes) wsNotificaAFijoSAP.marshalSendAndReceive(this.getUrlServicio(TEN), params);
}
DTActivoFijoRes responseActivoFijo = (DTActivoFijoRes) wsNotificaAFijoSAP.marshalSendAndReceive(this.getUrlServicio(TEN), params); if (!contratosIdSap.isEmpty() || (Objects.nonNull(responseActivoFijo) && Objects.nonNull(responseActivoFijo.getRespuesta()) && !responseActivoFijo.getRespuesta().isEmpty())) {
if (Objects.nonNull(responseActivoFijo) && Objects.nonNull(responseActivoFijo.getRespuesta()) && !responseActivoFijo.getRespuesta().isEmpty()) {
int lnuTitulosActualizados = responseActivoFijo.getRespuesta().size(); int lnuTitulosActualizados = responseActivoFijo.getRespuesta().size();
LOG.info(" Total titulos procesados SAP primer llamado: " + lnuTitulosActualizados); LOG.info(" Total titulos procesados SAP primer llamado: " + lnuTitulosActualizados);
...@@ -316,10 +323,14 @@ public class DDAExhibicionBO { ...@@ -316,10 +323,14 @@ public class DDAExhibicionBO {
tituloAF.setProgramID((Objects.nonNull(titulo.getProgramID()) && !titulo.getProgramID().isEmpty()) ? titulo.getProgramID() : ""); tituloAF.setProgramID((Objects.nonNull(titulo.getProgramID()) && !titulo.getProgramID().isEmpty()) ? titulo.getProgramID() : "");
tituloAF.setContratoDDA((Objects.nonNull(titulo.getContratoDDA()) && !titulo.getContratoDDA().isEmpty()) ? titulo.getContratoDDA() : "" ); tituloAF.setContratoDDA((Objects.nonNull(titulo.getContratoDDA()) && !titulo.getContratoDDA().isEmpty()) ? titulo.getContratoDDA() : "" );
tituloAF.setInicioAmortizacion((Objects.nonNull(titulo.getInicioAmortizacion()) && !titulo.getInicioAmortizacion().isEmpty()) ? titulo.getInicioAmortizacion() : "" ); tituloAF.setInicioAmortizacion((Objects.nonNull(titulo.getInicioAmortizacion()) && !titulo.getInicioAmortizacion().isEmpty()) ? titulo.getInicioAmortizacion() : "" );
for (DTActivoFijo.Registro registro : params.getRegistro()){ if(Objects.nonNull(contratosIdSap.get(tituloAF.getContratoDDA()))){
if (tituloAF.getContratoDDA().equals(registro.getContratoDDA())){ tituloAF.setCodigoSAP((contratosIdSap.get(tituloAF.getContratoDDA())));
tituloAF.setCodigoSAP((Objects.nonNull(registro.getCodigoSAP()) && !registro.getCodigoSAP().isEmpty()) ? registro.getCodigoSAP() : ""); } else {
} for (DTActivoFijo.Registro registro : params.getRegistro()){
if (tituloAF.getContratoDDA().equals(registro.getContratoDDA())){
tituloAF.setCodigoSAP((Objects.nonNull(registro.getCodigoSAP()) && !registro.getCodigoSAP().isEmpty()) ? registro.getCodigoSAP() : "");
}
}
} }
paramsSeg.getRegistro().add(tituloAF); paramsSeg.getRegistro().add(tituloAF);
} }
...@@ -386,10 +397,10 @@ public class DDAExhibicionBO { ...@@ -386,10 +397,10 @@ public class DDAExhibicionBO {
dao.actualizarEstatusSapTitulosByTitulo(faultDesc, idtituloCnt); dao.actualizarEstatusSapTitulosByTitulo(faultDesc, idtituloCnt);
} }
public String ejecutarTerminosComerciales( List<DatosCntTituloExhibicionDTO> titulos ){ public Map<String,String> ejecutarTerminosComerciales( List<DatosCntTituloExhibicionDTO> titulos ){
//--Llamado al WS de SAP. Interfaz 99. Terminos Comerciales //--Llamado al WS de SAP. Interfaz 99. Terminos Comerciales
LOG.info(" Url Srv. Activo Fijo primer llamado: " + this.getUrlServicio(TERMINOS)); LOG.info(" Url Srv. Activo Fijo primer llamado: " + this.getUrlServicio(TERMINOS));
String respuesta = ""; Map<String,String> validaciones = new HashMap<>();
try { try {
Map<String,DatosCntTituloExhibicionDTO> map = new HashMap<>(); Map<String,DatosCntTituloExhibicionDTO> map = new HashMap<>();
LOG.info(" Entrando try: " ); LOG.info(" Entrando try: " );
...@@ -450,9 +461,11 @@ public class DDAExhibicionBO { ...@@ -450,9 +461,11 @@ public class DDAExhibicionBO {
DTTerminosComercialesRes response = (DTTerminosComercialesRes) wsNotificaAFijoSAP.marshalSendAndReceive(this.getUrlServicio(TERMINOS), params); DTTerminosComercialesRes response = (DTTerminosComercialesRes) wsNotificaAFijoSAP.marshalSendAndReceive(this.getUrlServicio(TERMINOS), params);
if(!response.getESTPROC().equals("OK")){ if(!response.getESTPROC().equals("OK")){
LOG.info(" Fallo el contrato " + contrato.getContratoDDA() + " al enviarlo a " + this.getUrlServicio(TERMINOS) + " se daran de baja los titulos en la BD."); LOG.info(" Fallo el contrato " + contrato.getContratoDDA() + " al enviarlo a " + this.getUrlServicio(TERMINOS) + " se daran de baja los titulos en la BD.");
respuesta = response.getEstatus(); //respuesta = response.getEstatus();
validaciones.put(contrato.getContratoDDA(), response.getEstatus());
} else { } else {
LOG.info(" Respuesta OK del servicio ESTPROC: " + response.getESTPROC() + " con Estatus: " + response.getEstatus()); LOG.info(" Respuesta OK del servicio ESTPROC: " + response.getESTPROC() + " con Estatus: " + response.getEstatus());
validaciones.put(contrato.getContratoDDA(), response.getESTPROC());
} }
} }
} }
...@@ -461,11 +474,27 @@ public class DDAExhibicionBO { ...@@ -461,11 +474,27 @@ public class DDAExhibicionBO {
LOG.info(ex); LOG.info(ex);
ex.printStackTrace(); ex.printStackTrace();
java.util.logging.Logger.getLogger(DDAExhibicionBO.class.getName()).log(Level.SEVERE, null, ex); java.util.logging.Logger.getLogger(DDAExhibicionBO.class.getName()).log(Level.SEVERE, null, ex);
respuesta = "ERROR DE PROCESO"; //respuesta = "ERROR DE PROCESO";
} }
return respuesta; return validaciones;
} }
public List<DatosCntTituloExhibicionDTO> obtenerContratosRecienExhibidos(String pstFechaReferencia) throws Exception {
LOG.debug(" - [" + this.getClass().getSimpleName() + "::obtenerContratosRecienExhibidos]");
LOG.debug(" - Parametros: _" + pstFechaReferencia + "_");
List<DatosCntTituloExhibicionDTO> lobResultado = new ArrayList<>();
try {
lobResultado = dao.obtenerTitulosRecienExhibidos(pstFechaReferencia);
} catch (Exception e) {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::obtenerFechaReferencia]: " + e.getMessage());
throw new Exception(e.getMessage());
}
return lobResultado;
}
public List<DatosCntTituloExhibicionDTO> obtenerTitulosRecienExhibidos(String pstFechaReferencia) throws Exception { public List<DatosCntTituloExhibicionDTO> obtenerTitulosRecienExhibidos(String pstFechaReferencia) throws Exception {
LOG.debug(" - [" + this.getClass().getSimpleName() + "::obtenerTitulosRecienExhibidos]"); LOG.debug(" - [" + this.getClass().getSimpleName() + "::obtenerTitulosRecienExhibidos]");
LOG.debug(" - Parametros: _" + pstFechaReferencia + "_"); LOG.debug(" - Parametros: _" + pstFechaReferencia + "_");
...@@ -482,7 +511,7 @@ public class DDAExhibicionBO { ...@@ -482,7 +511,7 @@ public class DDAExhibicionBO {
return lobResultado; return lobResultado;
} }
public ResultadoNotificacionDTO notificarAFijoWS(List<DatosCntTituloExhibicionDTO> dto) { public ResultadoNotificacionDTO notificarAFijoWS(List<DatosCntTituloExhibicionDTO> dto, Map<String,String> respuestaTC) {
LOG.debug(" - [" + this.getClass().getSimpleName() + "::notificarAFijoWS]"); LOG.debug(" - [" + this.getClass().getSimpleName() + "::notificarAFijoWS]");
LOG.debug(" - Parametros: _" + dto.size() + " Titulos._"); LOG.debug(" - Parametros: _" + dto.size() + " Titulos._");
...@@ -495,47 +524,57 @@ public class DDAExhibicionBO { ...@@ -495,47 +524,57 @@ public class DDAExhibicionBO {
DTContenido params = new DTContenido(); DTContenido params = new DTContenido();
int xNotifica = 1; int xNotifica = 1;
for (DatosCntTituloExhibicionDTO dtoEx : dto) { for (DatosCntTituloExhibicionDTO dtoEx : dto) {
String lstCodigoSAP = (Objects.nonNull(dtoEx.getID_SAP()) && !dtoEx.getID_SAP().trim().isEmpty()) ? dtoEx.getID_SAP() : ""; if(respuestaTC.get(dtoEx.getNUMERO_CONTRATO()).equals("OK")){
String lstFechaContabilizacionBD = (Objects.nonNull(dtoEx.getFECHA_CONTABILIZACION()) && !dtoEx.getFECHA_CONTABILIZACION().trim().isEmpty()) ? dtoEx.getFECHA_CONTABILIZACION() : ""; String lstCodigoSAP = (Objects.nonNull(dtoEx.getID_SAP()) && !dtoEx.getID_SAP().trim().isEmpty()) ? dtoEx.getID_SAP() : "";
String lstFechaInicio = (Objects.nonNull(dtoEx.getFECHA_INICIO()) && !dtoEx.getFECHA_INICIO().trim().isEmpty()) ? dtoEx.getFECHA_INICIO() : ""; String lstFechaContabilizacionBD = (Objects.nonNull(dtoEx.getFECHA_CONTABILIZACION()) && !dtoEx.getFECHA_CONTABILIZACION().trim().isEmpty()) ? dtoEx.getFECHA_CONTABILIZACION() : "";
String lstValor = (Objects.nonNull(dtoEx.getCOSTO()) && !dtoEx.getCOSTO().trim().isEmpty()) ? dtoEx.getCOSTO() : ""; String lstFechaInicio = (Objects.nonNull(dtoEx.getFECHA_INICIO()) && !dtoEx.getFECHA_INICIO().trim().isEmpty()) ? dtoEx.getFECHA_INICIO() : "";
String lstVidaUtil = (Objects.nonNull(dtoEx.getVIDA_UTIL()) && !dtoEx.getVIDA_UTIL().trim().isEmpty()) ? dtoEx.getVIDA_UTIL() : ""; String lstValor = (Objects.nonNull(dtoEx.getCOSTO()) && !dtoEx.getCOSTO().trim().isEmpty()) ? dtoEx.getCOSTO() : "";
String lstIdTituloCntOrig = (Objects.nonNull(dtoEx.getID_TITULO_CNTORIG()) && !dtoEx.getID_TITULO_CNTORIG().trim().isEmpty()) ? dtoEx.getID_TITULO_CNTORIG() : ""; String lstVidaUtil = (Objects.nonNull(dtoEx.getVIDA_UTIL()) && !dtoEx.getVIDA_UTIL().trim().isEmpty()) ? dtoEx.getVIDA_UTIL() : "";
String lstSubNumero = (Objects.nonNull(dtoEx.getSUBNUMERO()) && !dtoEx.getSUBNUMERO().trim().isEmpty()) ? dtoEx.getSUBNUMERO() : ""; String lstIdTituloCntOrig = (Objects.nonNull(dtoEx.getID_TITULO_CNTORIG()) && !dtoEx.getID_TITULO_CNTORIG().trim().isEmpty()) ? dtoEx.getID_TITULO_CNTORIG() : "";
String lstVUAA = ""; String lstSubNumero = (Objects.nonNull(dtoEx.getSUBNUMERO()) && !dtoEx.getSUBNUMERO().trim().isEmpty()) ? dtoEx.getSUBNUMERO() : "";
String lstVUMM = ""; String lstVUAA = "";
String lstVUMM = "";
if (lstVidaUtil.length() == 4) {
lstVUAA = lstVidaUtil.substring(0, 2); if (lstVidaUtil.length() == 4) {
lstVUMM = lstVidaUtil.substring(2); lstVUAA = lstVidaUtil.substring(0, 2);
} lstVUMM = lstVidaUtil.substring(2);
}
LOG.info(" <Registro: [" + xNotifica++ + "], IdTituloCnt:[" + lstIdTituloCntOrig + "],CodigoSAP:[" + lstCodigoSAP + "],FechaContabilizacion:[" + lstFechaContabilizacionBD + "], FechaInicio:[" + lstFechaInicio + "], Valor:[" + lstValor + "], VU:[" + lstVidaUtil + "]>, vuAA:[" + lstVUAA + "], vuMM[" + lstVUMM + "]"); LOG.info(" <Registro: [" + xNotifica++ + "], IdTituloCnt:[" + lstIdTituloCntOrig + "],CodigoSAP:[" + lstCodigoSAP + "],FechaContabilizacion:[" + lstFechaContabilizacionBD + "], FechaInicio:[" + lstFechaInicio + "], Valor:[" + lstValor + "], VU:[" + lstVidaUtil + "]>, vuAA:[" + lstVUAA + "], vuMM[" + lstVUMM + "]");
//--Determinacion de la fecha de contabilizacion con referencia a la fecha actual //--Determinacion de la fecha de contabilizacion con referencia a la fecha actual
String lstFechaContabilizacion = dateManager.obtenerFechaMayorVsActual(lstFechaContabilizacionBD, "yyyyMMdd"); String lstFechaContabilizacion = dateManager.obtenerFechaMayorVsActual(lstFechaContabilizacionBD, "yyyyMMdd");
LOG.debug("Fecha contabilizacin: [" + lstFechaContabilizacion + "]"); LOG.debug("Fecha contabilizacin: [" + lstFechaContabilizacion + "]");
DTContenido.Registro titulo = new DTContenido.Registro(); DTContenido.Registro titulo = new DTContenido.Registro();
titulo.setCodigoSAP(lstCodigoSAP); titulo.setCodigoSAP(lstCodigoSAP);
titulo.setFechaContabilizacion(lstFechaContabilizacion); titulo.setFechaContabilizacion(lstFechaContabilizacion);
titulo.setFechaInicio(lstFechaInicio); titulo.setFechaInicio(lstFechaInicio);
if (Integer.parseInt(lstSubNumero) == 0){ if (Integer.parseInt(lstSubNumero) == 0){
titulo.setValor("1"); titulo.setValor("1");
} else { } else {
titulo.setValor(lstValor); titulo.setValor(lstValor);
}
titulo.setVUAA(lstVUAA);
titulo.setVUMM(lstVUMM);
titulo.setSubNumero(lstSubNumero);
params.getRegistro().add(titulo);
}
else {
LOG.error("DDA-NOT-012: Falla en terminos comerciales.");
dao.actualizarEstatusSapTitulosByTitulo(respuestaTC.get(dtoEx.getNUMERO_CONTRATO()), dtoEx.getID_TITULO_CNTORIG());
} }
titulo.setVUAA(lstVUAA);
titulo.setVUMM(lstVUMM);
titulo.setSubNumero(lstSubNumero);
params.getRegistro().add(titulo);
} }
//--Llamado a WS de SAP. Interfaz 12 //--Llamado a WS de SAP. Interfaz 12
LOG.debug(" Url Srv. Notifica Activo Fijo: " + this.getUrlServicio(TWELVE)); LOG.debug(" Url Srv. Notifica Activo Fijo: " + this.getUrlServicio(TWELVE));
//-- REAL CODE //-- REAL CODE
DTContenidoRes responseNotifica = (DTContenidoRes) wsNotificaAFijoSAP.marshalSendAndReceive(this.getUrlServicio(TWELVE), params); DTContenidoRes responseNotifica = null;
resultado.setTitulosEnviados(params.getRegistro().size());
if(!params.getRegistro().isEmpty()){
responseNotifica = (DTContenidoRes) wsNotificaAFijoSAP.marshalSendAndReceive(this.getUrlServicio(TWELVE), params);
}
if (Objects.nonNull(responseNotifica) && Objects.nonNull(responseNotifica.getRespuesta()) && !responseNotifica.getRespuesta().isEmpty()) { if (Objects.nonNull(responseNotifica) && Objects.nonNull(responseNotifica.getRespuesta()) && !responseNotifica.getRespuesta().isEmpty()) {
int lnuTitulosNotificados = responseNotifica.getRespuesta().size(); int lnuTitulosNotificados = responseNotifica.getRespuesta().size();
......
...@@ -231,6 +231,57 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO { ...@@ -231,6 +231,57 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
List<Object> qryParams = new ArrayList<>(); List<Object> qryParams = new ArrayList<>();
try {
//String lstFechaReferencia = (pstFechaReferencia != null && pstFechaReferencia.length() > 0) ? pstFechaReferencia : "";
//--Ejecucion
sb.append("SELECT ID_SAP,SUM(COSTO) AS COSTO,MIN(FECHA_INICIO) AS FECHA_INICIO ,MAX(VIDA_UTIL) AS VIDA_UTIL,MIN(FECHA_CONTABILIZACION) AS FECHA_CONTABILIZACION, ");
sb.append("MIN(ID_TITULO_CNTORIG) AS ID_TITULO_CNTORIG, SUBNUMERO, NUMERO_CONTRATO, MAX(FECHA_VENCIMIENTO) AS FECHA_VENCIMIENTO FROM ( ");
sb.append("select ");
sb.append("cnttit.ID_SAP, ");
sb.append("trunc(cnttit.COSTO,2) as COSTO, ");
sb.append("to_char(cnttit.FECHA_INICIO,'YYYYMMDD') as FECHA_INICIO, ");
sb.append("cnttit.VIDA_UTIL, ");
sb.append("to_char(cnttit.FECHA_INICIO,'DD/MM/YYYY') as FECHA_CONTABILIZACION, ");
sb.append("cnttit.ID_TITULO_CNTORIG, ");
sb.append("cnttit.SUBNUMERO, ");
sb.append("cnt.NUMERO_CONTRATO, ");
sb.append("to_char(cnt.FECHA_INICIO,'YYYYMMDD') AS FECHA_VENCIMIENTO ");
sb.append("from ");
sb.append("DDA_T_CONTRATO_TITULO cnttit, ");
sb.append("DDA_T_CONTRATO cnt ");
sb.append("where ");
sb.append("cnttit.ID_CONTRATO = cnt.ID_CONTRATO ");
sb.append("and cnttit.ID_SAP is not null ");
sb.append("and cnttit.SUBNUMERO is not null ");
sb.append("and cnt.ID_ESTATUS = ? ");
sb.append("and cnttit.FECHA_NOTIFSAP is null ");
sb.append("ORDER BY CNTTIT.FECHA_INICIO DESC) ");
sb.append("WHERE rownum < 901 ");
sb.append("GROUP BY ID_SAP, SUBNUMERO, NUMERO_CONTRATO");
//--Debug
LOG.debug(">Sql_D [obtenerTitulosRecienExhibidos]:" + sb.toString());
final String lstSQL = sb.toString();
qryParams.add(ESTATUS_VIGENTE);
//qryParams.add(lstFechaReferencia);
lobResultado = (ArrayList<DatosCntTituloExhibicionDTO>) getJdbcTemplate().query(lstSQL, qryParams.toArray(), new BeanPropertyRowMapper<>(DatosCntTituloExhibicionDTO.class));
} catch (Exception e) {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::obtenerTitulosRecienExhibidos]: " + e.getMessage());
throw new Exception(e.getMessage());
}
return lobResultado;
}
@Override
public List<DatosCntTituloExhibicionDTO> obtenerContratosRecienExhibidos(String pstFechaReferencia) throws Exception {
List<DatosCntTituloExhibicionDTO> lobResultado = new ArrayList<>();
StringBuilder sb = new StringBuilder();
List<Object> qryParams = new ArrayList<>();
try { try {
//String lstFechaReferencia = (pstFechaReferencia != null && pstFechaReferencia.length() > 0) ? pstFechaReferencia : ""; //String lstFechaReferencia = (pstFechaReferencia != null && pstFechaReferencia.length() > 0) ? pstFechaReferencia : "";
...@@ -339,7 +390,7 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO { ...@@ -339,7 +390,7 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
public boolean actualizaFechaNotificacion(ContratoTituloDTO dto) throws Exception { public boolean actualizaFechaNotificacion(ContratoTituloDTO dto) throws Exception {
boolean resultado = Boolean.FALSE; boolean resultado = Boolean.FALSE;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
final String sbCon = "SELECT NOMBRE_UNICO AS nombre, TEMPORADA AS temporada FROM DDA_T_CONTRATO_TITULO WHERE ID_TITULO_CNTORIG = ?"; final String sbCon = "SELECT NOMBRE_UNICO AS nombre, TEMPORADA AS temporada, ID_CONTRATO AS contrato FROM DDA_T_CONTRATO_TITULO WHERE ID_TITULO_CNTORIG = ?";
List<Object> qryParam = new ArrayList<>(); List<Object> qryParam = new ArrayList<>();
List<Object> qryParams = new ArrayList<>(); List<Object> qryParams = new ArrayList<>();
...@@ -366,8 +417,10 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO { ...@@ -366,8 +417,10 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
sb.append("WHERE "); sb.append("WHERE ");
sb.append("NOMBRE_UNICO = ? "); sb.append("NOMBRE_UNICO = ? ");
sb.append("AND TEMPORADA = ? "); sb.append("AND TEMPORADA = ? ");
sb.append("AND ID_CONTRATO = ? ");
qryParams.add(lobResultado.get(0).getNombre()); qryParams.add(lobResultado.get(0).getNombre());
qryParams.add(lobResultado.get(0).getTemporada()); qryParams.add(lobResultado.get(0).getTemporada());
qryParams.add(lobResultado.get(0).getContrato());
LOG.debug(">Sql_D [Actualizacion de todos los titulos de la serie]:" + sb.toString()); LOG.debug(">Sql_D [Actualizacion de todos los titulos de la serie]:" + sb.toString());
} }
} }
...@@ -843,6 +896,12 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO { ...@@ -843,6 +896,12 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
StringBuffer sbD = new StringBuffer(); StringBuffer sbD = new StringBuffer();
List<Object> qryParams = new ArrayList<Object>(); List<Object> qryParams = new ArrayList<Object>();
final String sbCon = "SELECT NOMBRE_UNICO AS nombre, TEMPORADA AS temporada, ID_CONTRATO AS contrato FROM DDA_T_CONTRATO_TITULO WHERE ID_TITULO_CNTORIG = ?";
List<Object> qryParam = new ArrayList<>();
qryParam.add(idtitulo);
try { try {
//--Debug //--Debug
...@@ -851,15 +910,30 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO { ...@@ -851,15 +910,30 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
sbD.append("' WHERE ID_TITULO_CNT = "); sbD.append("' WHERE ID_TITULO_CNT = ");
sbD.append(idtitulo); sbD.append(idtitulo);
LOG.debug(">Sql_D [actualizarEstatusSapTitulos]:" + sbD.toString()); LOG.debug(">Sql_D [actualizarEstatusSapTitulos]:" + sbD.toString());
List<TituloDTO> lobResultado = getJdbcTemplate().query(sbCon, qryParam.toArray(), new BeanPropertyRowMapper<>(TituloDTO.class));
if (Objects.nonNull(lobResultado) && lobResultado.size() > 0) {
if (Objects.isNull(lobResultado.get(0).getTemporada())) {
sb.append("UPDATE DDA_T_CONTRATO_TITULO SET ESTATUS_SAP = ? ");
sb.append(" WHERE ID_TITULO_CNT = ? ");
qryParams.add(mensaje);
qryParams.add(idtitulo);
} else {
sb.append("UPDATE DDA_T_CONTRATO_TITULO SET ESTATUS_SAP = ? ");
sb.append("WHERE ");
sb.append("NOMBRE_UNICO = ? ");
sb.append("AND TEMPORADA = ? ");
sb.append("AND ID_CONTRATO = ? ");
qryParams.add(mensaje);
qryParams.add(lobResultado.get(0).getNombre());
qryParams.add(lobResultado.get(0).getTemporada());
qryParams.add(lobResultado.get(0).getContrato());
}
}
//--Ejecucion //--Ejecucion
sb.append("UPDATE DDA_T_CONTRATO_TITULO SET ESTATUS_SAP = ? ");
sb.append(" WHERE ID_TITULO_CNT = ? ");
sb.append(idtitulo);
final String lstSQL = sb.toString(); final String lstSQL = sb.toString();
qryParams.add(mensaje);
qryParams.add(idtitulo);
jdbcTemplate.update(lstSQL, qryParams.toArray()); jdbcTemplate.update(lstSQL, qryParams.toArray());
...@@ -867,6 +941,34 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO { ...@@ -867,6 +941,34 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::ejecutarSPAmortizacionAjustada]: " + e.getMessage()); LOG.error("Exception[" + this.getClass().getSimpleName() + "::ejecutarSPAmortizacionAjustada]: " + e.getMessage());
} }
} }
public String validarIdSap(String numeroContrato){
StringBuilder sb = new StringBuilder();
List<Object> qryParams = new ArrayList<>();
String lstValor = "";
try {
sb.append("SELECT tit.ID_SAP AS ID_SAP FROM DDA_T_CONTRATO cnt inner join DDA_T_CONTRATO_TITULO tit on cnt.ID_CONTRATO = tit.ID_CONTRATO ");
sb.append("WHERE cnt.NUMERO_CONTRATO = '" + numeroContrato + "' AND tit.ID_SAP IS NOT NULL GROUP BY tit.ID_SAP ");
LOG.debug(">Sql_D [verificaEjecutandoseProcesoNotificacion]:" + sb.toString());
final String lstSQL = sb.toString();
lstValor = (String) jdbcTemplate.queryForObject(lstSQL, qryParams.toArray(), String.class);
if (Objects.nonNull(lstValor) && !lstValor.isEmpty()) {
lstValor = "";
}
} catch (EmptyResultDataAccessException er) {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::verificaEjecutandoseProcesoNotificacion]: No se encontraron registros coincidentes con la clave especificada. " + er.getMessage());
} catch (Exception e) {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::verificaEjecutandoseProcesoNotificacion]: " + e.getMessage());
}
return lstValor;
}
......
...@@ -17,6 +17,7 @@ public interface IDDAExhibicionDAO ...@@ -17,6 +17,7 @@ public interface IDDAExhibicionDAO
public boolean verificaEjecutandoseProcesoNotificacion() throws Exception; public boolean verificaEjecutandoseProcesoNotificacion() throws Exception;
public boolean updateEjecutandoseProcesoNotificacion(String pstValor) throws Exception; public boolean updateEjecutandoseProcesoNotificacion(String pstValor) throws Exception;
public List<DatosCntTituloExhibicionDTO> obtenerTitulosRecienExhibidos(String pstFechaReferencia) throws Exception; public List<DatosCntTituloExhibicionDTO> obtenerTitulosRecienExhibidos(String pstFechaReferencia) throws Exception;
public List<DatosCntTituloExhibicionDTO> obtenerContratosRecienExhibidos(String pstFechaReferencia) throws Exception;
public boolean actualizaFechaNotificacion(ContratoTituloDTO dto) throws Exception; public boolean actualizaFechaNotificacion(ContratoTituloDTO dto) throws Exception;
public boolean insertarRegistroSubnum(String pstIdTituloCnt) throws Exception; public boolean insertarRegistroSubnum(String pstIdTituloCnt) throws Exception;
public List<ItemActivoFijoDTO> obtenerTitulosSinIdSAP_RecienExhibidos(String pstFechaReferencia) throws Exception; public List<ItemActivoFijoDTO> obtenerTitulosSinIdSAP_RecienExhibidos(String pstFechaReferencia) throws Exception;
......
...@@ -5,56 +5,67 @@ import java.util.ArrayList; ...@@ -5,56 +5,67 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* Representa el manejo interno que se le dara al llamado del WS a SAP para Notificar Activos Fijos (Titulos recien exhibidos). * Representa el manejo interno que se le dara al llamado del WS a SAP para
* considerando los posibles escenarios de exito y error. * Notificar Activos Fijos (Titulos recien exhibidos). considerando los posibles
* Si el objeto TransactionFaultDTO tiene valores, entonces ocurrio alguna excepcion en el llamado. * escenarios de exito y error. Si el objeto TransactionFaultDTO tiene valores,
* Si la lista de RespSAPNotificaAFijoDTO tiene valores entonces la conexion al servicio se realizo satisfactoriamente. * entonces ocurrio alguna excepcion en el llamado. Si la lista de
* En resumen, ambos objetos deben ser mutuamente excluyentes, indicando el exito o el error segun haya sucedido. * RespSAPNotificaAFijoDTO tiene valores entonces la conexion al servicio se
* realizo satisfactoriamente. En resumen, ambos objetos deben ser mutuamente
* excluyentes, indicando el exito o el error segun haya sucedido.
*/ */
public class ResultadoNotificacionDTO implements Serializable public class ResultadoNotificacionDTO implements Serializable {
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private List<RespSAPNotificaAFijoDTO> notificaciones = new ArrayList<RespSAPNotificaAFijoDTO>(); private List<RespSAPNotificaAFijoDTO> notificaciones = new ArrayList<RespSAPNotificaAFijoDTO>();
private TransactionFaultDTO transFault = new TransactionFaultDTO(); private TransactionFaultDTO transFault = new TransactionFaultDTO();
private boolean resultado; private Integer titulosEnviados;
private boolean resultado;
public List<RespSAPNotificaAFijoDTO> getNotificaciones() {
return notificaciones; public Integer getTitulosEnviados() {
} return titulosEnviados;
}
public void setNotificaciones(List<RespSAPNotificaAFijoDTO> notificaciones) {
this.notificaciones = notificaciones; public void setTitulosEnviados(Integer titulosEnviados) {
} this.titulosEnviados = titulosEnviados;
}
public TransactionFaultDTO getTransFault() {
return transFault; public List<RespSAPNotificaAFijoDTO> getNotificaciones() {
} return notificaciones;
}
public void setTransFault(TransactionFaultDTO transFault) {
this.transFault = transFault; public void setNotificaciones(List<RespSAPNotificaAFijoDTO> notificaciones) {
} this.notificaciones = notificaciones;
}
public boolean getResultado() {
return resultado; public TransactionFaultDTO getTransFault() {
} return transFault;
}
public void setResultado(boolean resultado) {
this.resultado = resultado; public void setTransFault(TransactionFaultDTO transFault) {
} this.transFault = transFault;
}
public String toString()
{ public boolean getResultado() {
StringBuilder result = new StringBuilder(); return resultado;
String NEW_LINE = System.getProperty("line.separator"); }
result.append(" [Begin of Class] " + NEW_LINE);
result.append(this.getClass().getSimpleName() + " Object {" + NEW_LINE); public void setResultado(boolean resultado) {
result.append(" notificaciones: _" + this.getNotificaciones().size() + "_" + NEW_LINE); this.resultado = resultado;
result.append(" tFault: _" + this.getTransFault().toString() + "_" + NEW_LINE); }
result.append(" resultado: _" + this.getResultado() + "_" + NEW_LINE);
result.append(" [End of Class] " + NEW_LINE); public String toString() {
result.append("}"); StringBuilder result = new StringBuilder();
NEW_LINE = null; String NEW_LINE = System.getProperty("line.separator");
result.append(" [Begin of Class] " + NEW_LINE);
return result.toString(); result.append(this.getClass().getSimpleName() + " Object {" + NEW_LINE);
} result.append(" notificaciones: _" + this.getNotificaciones().size() + "_" + NEW_LINE);
result.append(" tFault: _" + this.getTransFault().toString() + "_" + NEW_LINE);
result.append(" resultado: _" + this.getResultado() + "_" + NEW_LINE);
result.append(" titulosEnviados: _" + this.getTitulosEnviados() + "_" + NEW_LINE);
result.append(" [End of Class] " + NEW_LINE);
result.append("}");
NEW_LINE = null;
return result.toString();
}
} }
...@@ -13,6 +13,7 @@ public class TituloDTO { ...@@ -13,6 +13,7 @@ public class TituloDTO {
private String nombre; private String nombre;
private String temporada; private String temporada;
private String contrato;
public String getNombre() { public String getNombre() {
return nombre; return nombre;
...@@ -29,5 +30,13 @@ public class TituloDTO { ...@@ -29,5 +30,13 @@ public class TituloDTO {
public void setTemporada(String temporada) { public void setTemporada(String temporada) {
this.temporada = temporada; this.temporada = temporada;
} }
public String getContrato() {
return contrato;
}
public void setContrato(String contrato) {
this.contrato = contrato;
}
} }
...@@ -32,40 +32,19 @@ public class service extends HttpServlet { ...@@ -32,40 +32,19 @@ public class service extends HttpServlet {
@Override @Override
public void doGet(HttpServletRequest request, HttpServletResponse response) public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException { throws IOException, ServletException {
response.setContentType("text/html"); response.setContentType("application/json");
PrintWriter out = response.getWriter(); PrintWriter out = response.getWriter();
out.println("<html>"); String msg = ejec();
out.println("<head>"); out.write("{\"rows\":\"" + msg + "\"}");
out.println("<title>Ejecucion Notificacion SAP</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Ejecucion Notificacion SAP<</h1>");
out.println("</body>");
out.println("</html>");
ejec();
} }
public void ejec() { public String ejec() {
ScheduledExecutorService se = Executors.newScheduledThreadPool(5); ApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContext.xml");
ScheduledFuture sf = se.schedule(new Callable() { setEx((DDAExhibicion) context.getBean("exhibicion_DDA"));
@Override getEx().ejecutaProceso();
public Object call() throws Exception { return "OK";
// System.out.println("##################################_______________AQUI_______________");
ApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContext.xml");
setEx((DDAExhibicion) context.getBean("exhibicion_DDA"));
getEx().ejecutaProceso();
// System.out.println("##################################_______________AQUI2_______________");
return "Done";
}
}, 1, TimeUnit.SECONDS);//Retrazo de tiempo
// System.out.println("Result of ScheduledFuture: " );
se.shutdown();
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment