Correcciones por pruebas de SAP

parent 0839533e
......@@ -3,7 +3,7 @@
<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">
<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/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>
......
package mx.com.amx.mx.dda.crn;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
......@@ -35,10 +36,11 @@ public class DDAExhibicion implements ApplicationContextAware {
}
}
public void ejecutaProceso() {
public String ejecutaProceso() {
LOG.info(" ");
LOG.info("<< :::::::::::::::: Inicia Proceso Notifica Exhibicion DDA :::::::::::::::: >>");
String mensaje = "OK";
try {
//-- 1. Verifica que no se este ejecutando ya un proceso de Notificacion
......@@ -85,22 +87,22 @@ public class DDAExhibicion implements ApplicationContextAware {
//-- 7. Obtener los titulos recien exhibidos para notificarlos a SAP
LOG.info(" [INI]. Paso 7.- Obtener Titulos recien exhibidos con base a fecha referencia.");
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(" [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.");
if (respuestaTC.isEmpty()){
if (Objects.nonNull(lobTitulos) && !lobTitulos.isEmpty()) {
//-- 8. LLamado a WS para notificar Activo Fijo (Titulos recien exhibidos)
LOG.info(" [INI]. Paso 9.- Llamado a WS SAP. Interfaz 12.");
ResultadoNotificacionDTO rWS_Notifica = bo.notificarAFijoWS(lobTitulos);
ResultadoNotificacionDTO rWS_Notifica = bo.notificarAFijoWS(lobTitulos, respuestaTC);
LOG.info(" [FIN]. Paso 9.- Llamado a WS SAP. Interfaz 12. Resultado: _" + 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
//-- Si se enviaron 3, mismos 3 que debera regresar
if (rWS_Notifica.getNotificaciones().size() == lobTitulos.size()) {
if (rWS_Notifica.getNotificaciones().size() == rWS_Notifica.getTitulosEnviados()) {
//-- Recorrer la respuesta en busqueda de los titulos notificados en SAP correctamente
int lnuTitulosNotificados = rWS_Notifica.getNotificaciones().size();
int lnuNotificadosSAP_OK = 0;
......@@ -180,7 +182,7 @@ public class DDAExhibicion implements ApplicationContextAware {
}//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.]");
}
......@@ -188,6 +190,7 @@ public class DDAExhibicion implements ApplicationContextAware {
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");
LOG.info("Apaga bandera de proceso Notifica.[Caso TransFault]");
......@@ -195,16 +198,8 @@ public class DDAExhibicion implements ApplicationContextAware {
}//Ends if(lobTitulos != null && lobTitulos.size() > 0)
else {
LOG.error("DDA-NOT-006: No se encontraron registros de titulos recien exhibidos.");
bo.actualizarEjecutandoProcesoNotificacion("0");
LOG.info("Apaga bandera de proceso Notifica.[Else_lobTitulos_null]");
}
}
else {
LOG.error("DDA-NOT-012: Falla en terminos comerciales.");
mensaje = "Error: DDA-NOT-006";
bo.actualizarEjecutandoProcesoNotificacion("0");
updateTitulos(contratos, respuestaTC);
LOG.info("Apaga bandera de proceso Notifica.[Else_lobTitulos_null]");
}
......@@ -216,6 +211,7 @@ public class DDAExhibicion implements ApplicationContextAware {
}//Ends if(lstFechaReferencia.trim().length() > 0)
else {
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");
bo.actualizarEjecutandoProcesoNotificacion("0");
LOG.info("Apaga bandera de proceso Notifica.[Else_lstFechaReferencia_trim()_length()]");
......@@ -224,6 +220,7 @@ public class DDAExhibicion implements ApplicationContextAware {
else {
LOG.error("DDA-NOT-004: No se pudo obtener el valor de referencia");
updateTitulos(contratos, "NO SE LOGRO OBTENER VALOR DE REFERENCIA");
mensaje = "Error: DDA-NOT-004";
bo.actualizarEjecutandoProcesoNotificacion("0");
LOG.info("Apaga bandera de proceso Notifica.[Else_boActualizarBanderaIniciaProceso]");
}
......@@ -231,6 +228,7 @@ public class DDAExhibicion implements ApplicationContextAware {
else {
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");
mensaje = "Error: DDA-NOT-003";
bo.actualizarEjecutandoProcesoNotificacion("0");
LOG.info("Apaga bandera de proceso Notifica.[Else_boActualizarBanderaIniciaProceso]");
......@@ -239,21 +237,25 @@ public class DDAExhibicion implements ApplicationContextAware {
else {
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");
mensaje = "Error: DDA-NOT-002";
bo.actualizarEjecutandoProcesoNotificacion("0");
}
}//Ends if(!boEjecutandoseProceso)
else {
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");
bo.actualizarEjecutandoProcesoNotificacion("0");
}
} catch (Exception e) {
LOG.error("Ocurrio un error en ejecutaProceso::DDAExhibicion: " + e.getMessage());
mensaje = "Error: DDA-NOT-013";
}
LOG.info("<< :::::::::::::::: Finaliza Proceso Notifica Exhibicion DDA :::::::::::::::: >>");
LOG.info(" ");
return mensaje;
}
private void updateTitulos(List<ContratoDTO> contratos, String mensaje){
......
......@@ -265,11 +265,13 @@ public class DDAExhibicionBO {
TransactionFaultDTO tf = resultado.getTransFault();
List<RespSAPActivoFijoDTO> afs = resultado.getActivosFijos();
String method = "crearActivoFijoWS";
Map<String,String> contratosIdSap = new HashMap<>();
try {
DTActivoFijo params = new DTActivoFijo();
for (ItemActivoFijoDTO titulo : dto.getContratos()) {
String idSap = dao.validarIdSap(titulo.getContratoDDA());
if(idSap.isEmpty()){
DTActivoFijo.Registro tituloAF = new DTActivoFijo.Registro();
tituloAF.setCentroCoste((Objects.nonNull(titulo.getCentroCosto()) && !titulo.getCentroCosto().isEmpty()) ? titulo.getCentroCosto() : "");
tituloAF.setCodigoDDA((Objects.nonNull(titulo.getCodigoDDA()) && !titulo.getCodigoDDA().isEmpty()) ? titulo.getCodigoDDA() : "");
......@@ -281,14 +283,19 @@ public class DDAExhibicionBO {
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.
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 (Objects.nonNull(responseActivoFijo) && Objects.nonNull(responseActivoFijo.getRespuesta()) && !responseActivoFijo.getRespuesta().isEmpty()) {
if (!contratosIdSap.isEmpty() || (Objects.nonNull(responseActivoFijo) && Objects.nonNull(responseActivoFijo.getRespuesta()) && !responseActivoFijo.getRespuesta().isEmpty())) {
int lnuTitulosActualizados = responseActivoFijo.getRespuesta().size();
LOG.info(" Total titulos procesados SAP primer llamado: " + lnuTitulosActualizados);
......@@ -316,11 +323,15 @@ public class DDAExhibicionBO {
tituloAF.setProgramID((Objects.nonNull(titulo.getProgramID()) && !titulo.getProgramID().isEmpty()) ? titulo.getProgramID() : "");
tituloAF.setContratoDDA((Objects.nonNull(titulo.getContratoDDA()) && !titulo.getContratoDDA().isEmpty()) ? titulo.getContratoDDA() : "" );
tituloAF.setInicioAmortizacion((Objects.nonNull(titulo.getInicioAmortizacion()) && !titulo.getInicioAmortizacion().isEmpty()) ? titulo.getInicioAmortizacion() : "" );
if(Objects.nonNull(contratosIdSap.get(tituloAF.getContratoDDA()))){
tituloAF.setCodigoSAP((contratosIdSap.get(tituloAF.getContratoDDA())));
} 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);
}
......@@ -386,10 +397,10 @@ public class DDAExhibicionBO {
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
LOG.info(" Url Srv. Activo Fijo primer llamado: " + this.getUrlServicio(TERMINOS));
String respuesta = "";
Map<String,String> validaciones = new HashMap<>();
try {
Map<String,DatosCntTituloExhibicionDTO> map = new HashMap<>();
LOG.info(" Entrando try: " );
......@@ -450,9 +461,11 @@ public class DDAExhibicionBO {
DTTerminosComercialesRes response = (DTTerminosComercialesRes) wsNotificaAFijoSAP.marshalSendAndReceive(this.getUrlServicio(TERMINOS), params);
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.");
respuesta = response.getEstatus();
//respuesta = response.getEstatus();
validaciones.put(contrato.getContratoDDA(), response.getEstatus());
} else {
LOG.info(" Respuesta OK del servicio ESTPROC: " + response.getESTPROC() + " con Estatus: " + response.getEstatus());
validaciones.put(contrato.getContratoDDA(), response.getESTPROC());
}
}
}
......@@ -461,9 +474,25 @@ public class DDAExhibicionBO {
LOG.info(ex);
ex.printStackTrace();
java.util.logging.Logger.getLogger(DDAExhibicionBO.class.getName()).log(Level.SEVERE, null, ex);
respuesta = "ERROR DE PROCESO";
//respuesta = "ERROR DE PROCESO";
}
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 respuesta;
return lobResultado;
}
public List<DatosCntTituloExhibicionDTO> obtenerTitulosRecienExhibidos(String pstFechaReferencia) throws Exception {
......@@ -482,7 +511,7 @@ public class DDAExhibicionBO {
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(" - Parametros: _" + dto.size() + " Titulos._");
......@@ -495,6 +524,7 @@ public class DDAExhibicionBO {
DTContenido params = new DTContenido();
int xNotifica = 1;
for (DatosCntTituloExhibicionDTO dtoEx : dto) {
if(respuestaTC.get(dtoEx.getNUMERO_CONTRATO()).equals("OK")){
String lstCodigoSAP = (Objects.nonNull(dtoEx.getID_SAP()) && !dtoEx.getID_SAP().trim().isEmpty()) ? dtoEx.getID_SAP() : "";
String lstFechaContabilizacionBD = (Objects.nonNull(dtoEx.getFECHA_CONTABILIZACION()) && !dtoEx.getFECHA_CONTABILIZACION().trim().isEmpty()) ? dtoEx.getFECHA_CONTABILIZACION() : "";
String lstFechaInicio = (Objects.nonNull(dtoEx.getFECHA_INICIO()) && !dtoEx.getFECHA_INICIO().trim().isEmpty()) ? dtoEx.getFECHA_INICIO() : "";
......@@ -530,12 +560,21 @@ public class DDAExhibicionBO {
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());
}
}
//--Llamado a WS de SAP. Interfaz 12
LOG.debug(" Url Srv. Notifica Activo Fijo: " + this.getUrlServicio(TWELVE));
//-- 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()) {
int lnuTitulosNotificados = responseNotifica.getRespuesta().size();
......
......@@ -231,6 +231,57 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
StringBuilder sb = new StringBuilder();
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 {
//String lstFechaReferencia = (pstFechaReferencia != null && pstFechaReferencia.length() > 0) ? pstFechaReferencia : "";
......@@ -339,7 +390,7 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
public boolean actualizaFechaNotificacion(ContratoTituloDTO dto) throws Exception {
boolean resultado = Boolean.FALSE;
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> qryParams = new ArrayList<>();
......@@ -366,8 +417,10 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
sb.append("WHERE ");
sb.append("NOMBRE_UNICO = ? ");
sb.append("AND TEMPORADA = ? ");
sb.append("AND ID_CONTRATO = ? ");
qryParams.add(lobResultado.get(0).getNombre());
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());
}
}
......@@ -844,6 +897,12 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
StringBuffer sbD = new StringBuffer();
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 {
//--Debug
sbD.append("UPDATE DDA_T_CONTRATO_TITULO SET ESTATUS_SAP =' ");
......@@ -852,14 +911,29 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
sbD.append(idtitulo);
LOG.debug(">Sql_D [actualizarEstatusSapTitulos]:" + sbD.toString());
//--Ejecucion
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 = ? ");
sb.append(idtitulo);
final String lstSQL = sb.toString();
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
final String lstSQL = sb.toString();
jdbcTemplate.update(lstSQL, qryParams.toArray());
......@@ -868,6 +942,34 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
}
}
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
public boolean verificaEjecutandoseProcesoNotificacion() throws Exception;
public boolean updateEjecutandoseProcesoNotificacion(String pstValor) 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 insertarRegistroSubnum(String pstIdTituloCnt) throws Exception;
public List<ItemActivoFijoDTO> obtenerTitulosSinIdSAP_RecienExhibidos(String pstFechaReferencia) throws Exception;
......
......@@ -5,19 +5,30 @@ import java.util.ArrayList;
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).
* considerando los posibles escenarios de exito y error.
* Si el objeto TransactionFaultDTO tiene valores, entonces ocurrio alguna excepcion en el llamado.
* Si la lista de 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.
* Representa el manejo interno que se le dara al llamado del WS a SAP para
* Notificar Activos Fijos (Titulos recien exhibidos). considerando los posibles
* escenarios de exito y error. Si el objeto TransactionFaultDTO tiene valores,
* entonces ocurrio alguna excepcion en el llamado. Si la lista de
* 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 List<RespSAPNotificaAFijoDTO> notificaciones = new ArrayList<RespSAPNotificaAFijoDTO>();
private TransactionFaultDTO transFault = new TransactionFaultDTO();
private Integer titulosEnviados;
private boolean resultado;
public Integer getTitulosEnviados() {
return titulosEnviados;
}
public void setTitulosEnviados(Integer titulosEnviados) {
this.titulosEnviados = titulosEnviados;
}
public List<RespSAPNotificaAFijoDTO> getNotificaciones() {
return notificaciones;
}
......@@ -42,8 +53,7 @@ public class ResultadoNotificacionDTO implements Serializable
this.resultado = resultado;
}
public String toString()
{
public String toString() {
StringBuilder result = new StringBuilder();
String NEW_LINE = System.getProperty("line.separator");
result.append(" [Begin of Class] " + NEW_LINE);
......@@ -51,6 +61,7 @@ public class ResultadoNotificacionDTO implements Serializable
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;
......
......@@ -13,6 +13,7 @@ public class TituloDTO {
private String nombre;
private String temporada;
private String contrato;
public String getNombre() {
return nombre;
......@@ -30,4 +31,12 @@ public class TituloDTO {
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 {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html");
response.setContentType("application/json");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
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();
String msg = ejec();
out.write("{\"rows\":\"" + msg + "\"}");
}
public void ejec() {
ScheduledExecutorService se = Executors.newScheduledThreadPool(5);
ScheduledFuture sf = se.schedule(new Callable() {
@Override
public Object call() throws Exception {
// System.out.println("##################################_______________AQUI_______________");
public String ejec() {
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();
return "OK";
}
/**
......
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