Cambios de interfaz de contingencia contratos especificos

parent 296bb817
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"
p:concurrent="false" p:concurrent="false"
p:targetObject-ref="exhibicion_DDA" p:targetObject-ref="exhibicion_DDA"
p:targetMethod="ejecutaProceso"> p:targetMethod="ejecuta">
</bean> </bean>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<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/src/mx/com/mx/dda/msjb/service.java</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/dao/IDDAExhibicionDAO.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>
......
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"
p:concurrent="false" p:concurrent="false"
p:targetObject-ref="exhibicion_DDA" p:targetObject-ref="exhibicion_DDA"
p:targetMethod="ejecutaProceso"> p:targetMethod="ejecuta">
</bean> </bean>
......
...@@ -4,6 +4,7 @@ import java.util.List; ...@@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Properties; import java.util.Properties;
import java.util.stream.Collectors;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
...@@ -35,19 +36,22 @@ public class DDAExhibicion implements ApplicationContextAware { ...@@ -35,19 +36,22 @@ public class DDAExhibicion implements ApplicationContextAware {
LOG.error(">Constructor[" + this.getClass().getSimpleName() + "] Ocurrio un error : " + e.getMessage()); LOG.error(">Constructor[" + this.getClass().getSimpleName() + "] Ocurrio un error : " + e.getMessage());
} }
} }
public void ejecuta( List<String> contratosId) {
ejecutaProceso(null);
}
public String ejecutaProceso() { public String ejecutaProceso(String contratosId) {
LOG.info(" "); LOG.info(" ");
LOG.info("<< :::::::::::::::: Inicia Proceso Notifica Exhibicion DDA :::::::::::::::: >>"); LOG.info("<< :::::::::::::::: Inicia Proceso Notifica Exhibicion DDA :::::::::::::::: >>");
String mensaje = "OK"; 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
LOG.info(" [INI]. Paso 1.- Verifica bandera de ejecucion de proceso de Notificacion."); LOG.info(" [INI]. Paso 1.- Verifica bandera de ejecucion de proceso de Notificacion.");
boolean boEjecutandoseProceso = bo.existeProcesoNotificacionEjecutandose(); boolean boEjecutandoseProceso = bo.existeProcesoNotificacionEjecutandose();
LOG.info(" [INI]. Paso 1.- Verifica bandera de ejecucion de proceso de Notificacion. Esta ejecutando?: _" + boEjecutandoseProceso + "_"); LOG.info(" [INI]. Paso 1.- Verifica bandera de ejecucion de proceso de Notificacion. Esta ejecutando?: _" + boEjecutandoseProceso + "_");
List<ContratoDTO> contratos = bo.contratosCandidatos(); List<ContratoDTO> contratos = bo.contratosCandidatos(contratosId);
if (!boEjecutandoseProceso) { if (!boEjecutandoseProceso) {
//-- 2. Verificar si se puede iniciar el proceso //-- 2. Verificar si se puede iniciar el proceso
...@@ -81,17 +85,17 @@ public class DDAExhibicion implements ApplicationContextAware { ...@@ -81,17 +85,17 @@ public class DDAExhibicion implements ApplicationContextAware {
//-- 8. Llamado a la interfaz 10. Creacion de orden de Compra en SAP. //-- 8. Llamado a la interfaz 10. Creacion de orden de Compra en SAP.
LOG.info(" [INI]. Paso 6.- Creacion en SAP de Titulos Recien exhibidos. (Creacion de Orden de Compra)"); LOG.info(" [INI]. Paso 6.- Creacion en SAP de Titulos Recien exhibidos. (Creacion de Orden de Compra)");
ResponseOrdenCompraDTO resCOrdenCompra = bo.creacionTitulosSAP(lstFechaReferencia); ResponseOrdenCompraDTO resCOrdenCompra = bo.creacionTitulosSAP(lstFechaReferencia, contratosId);
LOG.info(" [FIN]. Paso 6.- Creacion en SAP de Titulos Recien exhibidos. Resultado: [" + resCOrdenCompra.getMensaje() + "]"); LOG.info(" [FIN]. Paso 6.- Creacion en SAP de Titulos Recien exhibidos. Resultado: [" + resCOrdenCompra.getMensaje() + "]");
//-- 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, contratosId);
List<DatosCntTituloExhibicionDTO> lobTitulosTC = bo.obtenerContratosRecienExhibidos(lstFechaReferencia); List<DatosCntTituloExhibicionDTO> lobTitulosTC = bo.obtenerContratosRecienExhibidos(lstFechaReferencia, contratosId);
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)");
Map<String,String> respuestaTC = bo.ejecutarTerminosComerciales(lobTitulosTC); Map<String,String> respuestaTC = bo.ejecutarTerminosComerciales(lobTitulosTC, contratosId);
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 (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)
......
...@@ -19,6 +19,8 @@ import com.americamovil.dda._1.f.enviacontenido.DTContenidoRes; ...@@ -19,6 +19,8 @@ import com.americamovil.dda._1.f.enviacontenido.DTContenidoRes;
import com.americamovil.dda._1.f.enviaterminoscomerciales.DTTerminosComerciales; import com.americamovil.dda._1.f.enviaterminoscomerciales.DTTerminosComerciales;
import com.americamovil.dda._1.f.enviaterminoscomerciales.DTTerminosComercialesRes; import com.americamovil.dda._1.f.enviaterminoscomerciales.DTTerminosComercialesRes;
import java.io.IOException; import java.io.IOException;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
...@@ -171,7 +173,7 @@ public class DDAExhibicionBO { ...@@ -171,7 +173,7 @@ public class DDAExhibicionBO {
} }
public ResponseOrdenCompraDTO creacionTitulosSAP(String pstFechaReferencia) throws Exception { public ResponseOrdenCompraDTO creacionTitulosSAP(String pstFechaReferencia, String contratosId) throws Exception {
LOG.debug(" - [" + this.getClass().getSimpleName() + "::creacionTitulosSAP]"); LOG.debug(" - [" + this.getClass().getSimpleName() + "::creacionTitulosSAP]");
ResponseOrdenCompraDTO resultado = new ResponseOrdenCompraDTO(); ResponseOrdenCompraDTO resultado = new ResponseOrdenCompraDTO();
int lnuTotalRegOCSAP_OK = 0; int lnuTotalRegOCSAP_OK = 0;
...@@ -182,8 +184,8 @@ public class DDAExhibicionBO { ...@@ -182,8 +184,8 @@ public class DDAExhibicionBO {
try { try {
//-- Consulta de titulos sin ID de SAP que esten en estatus de Recien Exhibido (Fecha inicio <= hoy) //-- Consulta de titulos sin ID de SAP que esten en estatus de Recien Exhibido (Fecha inicio <= hoy)
LOG.info(" [INI]. Consulta de Titulos sin ID SAP Recien Exhibidos."); LOG.info(" [INI]. Consulta de Titulos sin ID SAP Recien Exhibidos.");
List<ItemActivoFijoDTO> lobTitulosCnt = dao.obtenerTitulosSinIdSAP_RecienExhibidos(pstFechaReferencia); List<ItemActivoFijoDTO> lobTitulosCnt = dao.obtenerTitulosSinIdSAP_RecienExhibidos(pstFechaReferencia, contratosId);
List<ItemActivoFijoDTO> lobContratosCnt = dao.obtenerContratosConTitulosSinIdSAP_RecienExhibidos(pstFechaReferencia); List<ItemActivoFijoDTO> lobContratosCnt = dao.obtenerContratosConTitulosSinIdSAP_RecienExhibidos(pstFechaReferencia, contratosId);
LOG.info(" [FIN]. Consulta de Titulos sin ID SAP Recien Exhibidos. Titulos:_" + lobTitulosCnt.size() + "_"); LOG.info(" [FIN]. Consulta de Titulos sin ID SAP Recien Exhibidos. Titulos:_" + lobTitulosCnt.size() + "_");
if (Objects.nonNull(lobTitulosCnt) && !lobTitulosCnt.isEmpty()) { if (Objects.nonNull(lobTitulosCnt) && !lobTitulosCnt.isEmpty()) {
...@@ -397,7 +399,7 @@ public class DDAExhibicionBO { ...@@ -397,7 +399,7 @@ public class DDAExhibicionBO {
dao.actualizarEstatusSapTitulosByTitulo(faultDesc, idtituloCnt); dao.actualizarEstatusSapTitulosByTitulo(faultDesc, idtituloCnt);
} }
public Map<String,String> ejecutarTerminosComerciales( List<DatosCntTituloExhibicionDTO> titulos ){ public Map<String,String> ejecutarTerminosComerciales( List<DatosCntTituloExhibicionDTO> titulos, String contratosId ){
//--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));
Map<String,String> validaciones = new HashMap<>(); Map<String,String> validaciones = new HashMap<>();
...@@ -413,7 +415,7 @@ public class DDAExhibicionBO { ...@@ -413,7 +415,7 @@ public class DDAExhibicionBO {
map.get(titulo.getNUMERO_CONTRATO()).setCOSTO(suma.toString()); map.get(titulo.getNUMERO_CONTRATO()).setCOSTO(suma.toString());
} }
} }
List<ContratoDTO> contratos = dao.obtenerContratos(); List<ContratoDTO> contratos = dao.obtenerContratos(contratosId);
LOG.info(" Contratos encontrado: " + contratos.size() ); LOG.info(" Contratos encontrado: " + contratos.size() );
for(ContratoDTO contrato : contratos){ for(ContratoDTO contrato : contratos){
if (Objects.nonNull(map.get(contrato.getContratoDDA()))){ if (Objects.nonNull(map.get(contrato.getContratoDDA()))){
...@@ -479,14 +481,14 @@ public class DDAExhibicionBO { ...@@ -479,14 +481,14 @@ public class DDAExhibicionBO {
return validaciones; return validaciones;
} }
public List<DatosCntTituloExhibicionDTO> obtenerContratosRecienExhibidos(String pstFechaReferencia) throws Exception { public List<DatosCntTituloExhibicionDTO> obtenerContratosRecienExhibidos(String pstFechaReferencia, String contratosId) throws Exception {
LOG.debug(" - [" + this.getClass().getSimpleName() + "::obtenerContratosRecienExhibidos]"); LOG.debug(" - [" + this.getClass().getSimpleName() + "::obtenerContratosRecienExhibidos]");
LOG.debug(" - Parametros: _" + pstFechaReferencia + "_"); LOG.debug(" - Parametros: _" + pstFechaReferencia + "_");
List<DatosCntTituloExhibicionDTO> lobResultado = new ArrayList<>(); List<DatosCntTituloExhibicionDTO> lobResultado = new ArrayList<>();
try { try {
lobResultado = dao.obtenerTitulosRecienExhibidos(pstFechaReferencia); lobResultado = dao.obtenerTitulosRecienExhibidos(pstFechaReferencia, contratosId);
} catch (Exception e) { } catch (Exception e) {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::obtenerFechaReferencia]: " + e.getMessage()); LOG.error("Exception[" + this.getClass().getSimpleName() + "::obtenerFechaReferencia]: " + e.getMessage());
throw new Exception(e.getMessage()); throw new Exception(e.getMessage());
...@@ -495,14 +497,20 @@ public class DDAExhibicionBO { ...@@ -495,14 +497,20 @@ public class DDAExhibicionBO {
return lobResultado; return lobResultado;
} }
public List<DatosCntTituloExhibicionDTO> obtenerTitulosRecienExhibidos(String pstFechaReferencia) throws Exception { public List<DatosCntTituloExhibicionDTO> obtenerTitulosRecienExhibidos(String pstFechaReferencia, String contratosId) throws Exception {
LOG.debug(" - [" + this.getClass().getSimpleName() + "::obtenerTitulosRecienExhibidos]"); LOG.debug(" - [" + this.getClass().getSimpleName() + "::obtenerTitulosRecienExhibidos]");
LOG.debug(" - Parametros: _" + pstFechaReferencia + "_"); LOG.debug(" - Parametros: _" + pstFechaReferencia + "_");
List<DatosCntTituloExhibicionDTO> lobResultado = new ArrayList<>(); List<DatosCntTituloExhibicionDTO> lobResultado = new ArrayList<>();
try { try {
lobResultado = dao.obtenerTitulosRecienExhibidos(pstFechaReferencia); lobResultado = dao.obtenerTitulosRecienExhibidos(pstFechaReferencia, contratosId);
Collections.sort(lobResultado, new Comparator<DatosCntTituloExhibicionDTO> (){
@Override
public int compare(DatosCntTituloExhibicionDTO d1, DatosCntTituloExhibicionDTO d2){
return d1.getID_SAP().compareTo(d2.getID_SAP());
}
});
} catch (Exception e) { } catch (Exception e) {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::obtenerFechaReferencia]: " + e.getMessage()); LOG.error("Exception[" + this.getClass().getSimpleName() + "::obtenerFechaReferencia]: " + e.getMessage());
throw new Exception(e.getMessage()); throw new Exception(e.getMessage());
...@@ -688,11 +696,11 @@ public class DDAExhibicionBO { ...@@ -688,11 +696,11 @@ public class DDAExhibicionBO {
return resultado; return resultado;
} }
public List<ContratoDTO> contratosCandidatos(){ public List<ContratoDTO> contratosCandidatos(String contratosId){
LOG.debug(" - [" + this.getClass().getSimpleName() + "::contratosCandidatos]"); LOG.debug(" - [" + this.getClass().getSimpleName() + "::contratosCandidatos]");
List<ContratoDTO> resultado = null; List<ContratoDTO> resultado = null;
try { try {
resultado = dao.obtenerContratosCandidatos(); resultado = dao.obtenerContratosCandidatos(contratosId);
} catch (Exception e) { } catch (Exception e) {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::contratosCandidatos]: " + e.getMessage()); LOG.error("Exception[" + this.getClass().getSimpleName() + "::contratosCandidatos]: " + e.getMessage());
} }
......
...@@ -226,7 +226,7 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO { ...@@ -226,7 +226,7 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
} }
@Override @Override
public List<DatosCntTituloExhibicionDTO> obtenerTitulosRecienExhibidos(String pstFechaReferencia) throws Exception { public List<DatosCntTituloExhibicionDTO> obtenerTitulosRecienExhibidos(String pstFechaReferencia, String contratosId) throws Exception {
List<DatosCntTituloExhibicionDTO> lobResultado = new ArrayList<>(); List<DatosCntTituloExhibicionDTO> lobResultado = new ArrayList<>();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
List<Object> qryParams = new ArrayList<>(); List<Object> qryParams = new ArrayList<>();
...@@ -256,9 +256,14 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO { ...@@ -256,9 +256,14 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
sb.append("and cnttit.SUBNUMERO is not null "); sb.append("and cnttit.SUBNUMERO is not null ");
sb.append("and cnt.ID_ESTATUS = ? "); sb.append("and cnt.ID_ESTATUS = ? ");
sb.append("and cnttit.FECHA_NOTIFSAP is null "); sb.append("and cnttit.FECHA_NOTIFSAP is null ");
if(Objects.nonNull(contratosId)){
sb.append("and cnt.ID_CONTRATO in (");
sb.append(contratosId + ")");
}
sb.append("ORDER BY CNTTIT.FECHA_INICIO DESC) "); sb.append("ORDER BY CNTTIT.FECHA_INICIO DESC) ");
sb.append("WHERE rownum < 901 "); sb.append("WHERE rownum < 901 ");
sb.append("GROUP BY ID_SAP, SUBNUMERO, NUMERO_CONTRATO"); sb.append("GROUP BY ID_SAP, SUBNUMERO, NUMERO_CONTRATO");
sb.append("ORDER BY ID_SAP, SUBNUMERO");
//--Debug //--Debug
LOG.debug(">Sql_D [obtenerTitulosRecienExhibidos]:" + sb.toString()); LOG.debug(">Sql_D [obtenerTitulosRecienExhibidos]:" + sb.toString());
...@@ -276,116 +281,6 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO { ...@@ -276,116 +281,6 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
return lobResultado; 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 : "";
//--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, MIN(SUBNUMERO) AS 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 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, 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;
}
/*
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 = ?";
List<Object> qryParam = new ArrayList<>();
List<Object> qryParams = new ArrayList<>();
try {
String lstIdTituloCntOriginal = (dto.getID_DDA() != null && dto.getID_DDA().length() > 0) ? dto.getID_DDA() : "";
String lstIdSAP = (dto.getID_SAP() != null && dto.getID_SAP().length() > 0) ? dto.getID_SAP() : "";
String lstSubNumero = (dto.getSUBNUMERO() != null && dto.getSUBNUMERO().length() > 0) ? dto.getSUBNUMERO() : "";
qryParam.add(lstIdTituloCntOriginal);
List<TituloDTO> lobResultado = getJdbcTemplate().query(sbCon, qryParam.toArray(), new BeanPropertyRowMapper<>(TituloDTO.class));
int lnuRowsUpdate = 0;
//--Ejecucion
if (Objects.nonNull(lobResultado) && lobResultado.size() > 0) {
if (Objects.isNull(lobResultado.get(0).getTemporada())) {
sb.append("update ");
sb.append("DDA_T_CONTRATO_TITULO ");
sb.append("set ID_SAP = ?, ");
sb.append("SUBNUMERO = ? ");
sb.append("where ");
sb.append("ID_TITULO_CNTORIG = ? ");
qryParams.add(lstIdSAP);
qryParams.add(lstSubNumero);
qryParams.add(lstIdTituloCntOriginal);
LOG.debug(">Sql_D [Actualizacion de un solo titulo]:" + sb.toString());
} else {
sb.append("update ");
sb.append("DDA_T_CONTRATO_TITULO ");
sb.append("set ID_SAP = ?, ");
sb.append("SUBNUMERO = ? ");
sb.append("where ");
sb.append("NOMBRE_UNICO = ? ");
sb.append("AND TEMPORADA = ? ");
qryParams.add(lstIdSAP);
qryParams.add(lstSubNumero);
qryParams.add(lobResultado.get(0).getNombre());
qryParams.add(lobResultado.get(0).getTemporada());
LOG.debug(">Sql_D [Actualizacion de todos los titulos de la serie]:" + sb.toString());
}
LOG.debug(">Sql_D [actualizaIdSAPCntTitulo]:" + sb.toString());
final String lstSQL = sb.toString();
lnuRowsUpdate = jdbcTemplate.update(lstSQL, qryParams.toArray());
}
if (lnuRowsUpdate > 0) {
resultado = Boolean.TRUE;
}
} catch (Exception e) {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::actualizaIdSAPCntTitulo]: " + e.getMessage());
throw new Exception(e.getMessage());
}
return resultado;
*/
@Override @Override
public boolean actualizaFechaNotificacion(ContratoTituloDTO dto) throws Exception { public boolean actualizaFechaNotificacion(ContratoTituloDTO dto) throws Exception {
boolean resultado = Boolean.FALSE; boolean resultado = Boolean.FALSE;
...@@ -495,7 +390,7 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO { ...@@ -495,7 +390,7 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
} }
@Override @Override
public List<ItemActivoFijoDTO> obtenerTitulosSinIdSAP_RecienExhibidos(String pstFechaReferencia) throws Exception { public List<ItemActivoFijoDTO> obtenerTitulosSinIdSAP_RecienExhibidos(String pstFechaReferencia, String contratosId) throws Exception {
List<ItemActivoFijoDTO> lobResultado = new ArrayList<>(); List<ItemActivoFijoDTO> lobResultado = new ArrayList<>();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
List<Object> qryParams = new ArrayList<>(); List<Object> qryParams = new ArrayList<>();
...@@ -531,6 +426,10 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO { ...@@ -531,6 +426,10 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
sb.append("and estudio.ID_SAP is not null "); sb.append("and estudio.ID_SAP is not null ");
sb.append("and contrato.ID_SAP is not null "); sb.append("and contrato.ID_SAP is not null ");
sb.append("and contrato.ID_TIPO_CONTRATO = 1 "); sb.append("and contrato.ID_TIPO_CONTRATO = 1 ");
if(Objects.nonNull(contratosId)){
sb.append("and contrato.ID_CONTRATO in (");
sb.append(contratosId + ")");
}
sb.append("ORDER BY CNTTIT.FECHA_INICIO DESC)"); sb.append("ORDER BY CNTTIT.FECHA_INICIO DESC)");
sb.append("WHERE ROWNUM < 901 AND inicioAmortizacion IS NOT NULL "); sb.append("WHERE ROWNUM < 901 AND inicioAmortizacion IS NOT NULL ");
sb.append("GROUP BY ordenCompra, proveedor, descripcion, centroCosto, contratoDDA, inicioAmortizacion, temporada "); sb.append("GROUP BY ordenCompra, proveedor, descripcion, centroCosto, contratoDDA, inicioAmortizacion, temporada ");
...@@ -553,7 +452,7 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO { ...@@ -553,7 +452,7 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
} }
@Override @Override
public List<ItemActivoFijoDTO> obtenerContratosConTitulosSinIdSAP_RecienExhibidos(String pstFechaReferencia) throws Exception { public List<ItemActivoFijoDTO> obtenerContratosConTitulosSinIdSAP_RecienExhibidos(String pstFechaReferencia, String contratosId) throws Exception {
List<ItemActivoFijoDTO> lobResultado = new ArrayList<>(); List<ItemActivoFijoDTO> lobResultado = new ArrayList<>();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
List<Object> qryParams = new ArrayList<>(); List<Object> qryParams = new ArrayList<>();
...@@ -585,6 +484,10 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO { ...@@ -585,6 +484,10 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
sb.append("and estudio.ID_SAP is not null "); sb.append("and estudio.ID_SAP is not null ");
sb.append("and contrato.ID_SAP is not null "); sb.append("and contrato.ID_SAP is not null ");
sb.append("and contrato.ID_TIPO_CONTRATO = 1 "); sb.append("and contrato.ID_TIPO_CONTRATO = 1 ");
if(Objects.nonNull(contratosId)){
sb.append("and contrato.ID_CONTRATO in (");
sb.append(contratosId + ")");
}
sb.append("GROUP BY contrato.ID_SAP, estudio.ID_SAP, contrato.NUMERO_CONTRATO, contrato.ID_CONTRATO_BV, contrato.NUMERO_CONTRATO "); sb.append("GROUP BY contrato.ID_SAP, estudio.ID_SAP, contrato.NUMERO_CONTRATO, contrato.ID_CONTRATO_BV, contrato.NUMERO_CONTRATO ");
sb.append("ORDER BY ordenCompra, inicioAmortizacion DESC "); sb.append("ORDER BY ordenCompra, inicioAmortizacion DESC ");
...@@ -701,7 +604,7 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO { ...@@ -701,7 +604,7 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
} }
@Override @Override
public List<ContratoDTO> obtenerContratos() throws Exception { public List<ContratoDTO> obtenerContratos(String contratosId) throws Exception {
List<ContratoDTO> lobResultado = new ArrayList<>(); List<ContratoDTO> lobResultado = new ArrayList<>();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
List<Object> qryParams = new ArrayList<>(); List<Object> qryParams = new ArrayList<>();
...@@ -723,6 +626,10 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO { ...@@ -723,6 +626,10 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
sb.append("and cnttit.ID_SAP is not null "); sb.append("and cnttit.ID_SAP is not null ");
sb.append("and cnt.ID_ESTATUS = ? "); sb.append("and cnt.ID_ESTATUS = ? ");
sb.append("and cnttit.FECHA_NOTIFSAP is null "); sb.append("and cnttit.FECHA_NOTIFSAP is null ");
if(Objects.nonNull(contratosId)){
sb.append("and cnt.ID_CONTRATO in (");
sb.append(contratosId + ")");
}
sb.append("GROUP BY cnt.ID_SAP, cnt.ID_CONTRATO, cnt.NUMERO_CONTRATO "); sb.append("GROUP BY cnt.ID_SAP, cnt.ID_CONTRATO, cnt.NUMERO_CONTRATO ");
//--Debug //--Debug
...@@ -740,7 +647,7 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO { ...@@ -740,7 +647,7 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
} }
@Override @Override
public List<ContratoDTO> obtenerContratosCandidatos() throws Exception { public List<ContratoDTO> obtenerContratosCandidatos(String contratosId) throws Exception {
List<ContratoDTO> lobResultado = new ArrayList<>(); List<ContratoDTO> lobResultado = new ArrayList<>();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
List<Object> qryParams = new ArrayList<>(); List<Object> qryParams = new ArrayList<>();
...@@ -760,6 +667,10 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO { ...@@ -760,6 +667,10 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
sb.append("where "); sb.append("where ");
sb.append("cnttit.ID_CONTRATO = cnt.ID_CONTRATO "); sb.append("cnttit.ID_CONTRATO = cnt.ID_CONTRATO ");
sb.append("and cnt.ID_ESTATUS = ? "); sb.append("and cnt.ID_ESTATUS = ? ");
if(Objects.nonNull(contratosId)){
sb.append("and cnt.ID_CONTRATO in (");
sb.append(contratosId + ")");
}
sb.append("and (cnttit.ID_SAP is null "); sb.append("and (cnttit.ID_SAP is null ");
sb.append("or cnttit.FECHA_NOTIFSAP is null )"); sb.append("or cnttit.FECHA_NOTIFSAP is null )");
sb.append("GROUP BY cnt.ID_SAP, cnt.ID_CONTRATO, cnt.NUMERO_CONTRATO "); sb.append("GROUP BY cnt.ID_SAP, cnt.ID_CONTRATO, cnt.NUMERO_CONTRATO ");
......
...@@ -16,16 +16,16 @@ public interface IDDAExhibicionDAO ...@@ -16,16 +16,16 @@ public interface IDDAExhibicionDAO
public boolean puedeIniciarProcesoNotificacion() throws Exception; public boolean puedeIniciarProcesoNotificacion() throws Exception;
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, String contratosId) throws Exception;
public List<DatosCntTituloExhibicionDTO> obtenerContratosRecienExhibidos(String pstFechaReferencia) throws Exception; //public List<DatosCntTituloExhibicionDTO> obtenerContratosRecienExhibidos(String pstFechaReferencia, String contratosId) 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, String contratosId) throws Exception;
public List<ItemActivoFijoDTO> obtenerContratosConTitulosSinIdSAP_RecienExhibidos(String pstFechaReferencia) throws Exception; public List<ItemActivoFijoDTO> obtenerContratosConTitulosSinIdSAP_RecienExhibidos(String pstFechaReferencia, String contratosId) throws Exception;
public boolean actualizaIdSAPCntTitulo(RespSAPActivoFijoDTO dto) throws Exception; public boolean actualizaIdSAPCntTitulo(RespSAPActivoFijoDTO dto) throws Exception;
public boolean ejecutarSPAmortizacionReal() throws Exception; public boolean ejecutarSPAmortizacionReal() throws Exception;
public List<ContratoDTO> obtenerContratos() throws Exception; public List<ContratoDTO> obtenerContratos(String contratosId) throws Exception;
public List<ContratoDTO> obtenerContratosCandidatos() throws Exception; public List<ContratoDTO> obtenerContratosCandidatos(String contratosId) throws Exception;
public boolean eliminarIdSAPCntTitulo(String idcontrato) throws Exception; public boolean eliminarIdSAPCntTitulo(String idcontrato) throws Exception;
public List<ContratoPagoDTO> obtenerCondicionesComerciales(String idContrato) throws Exception; public List<ContratoPagoDTO> obtenerCondicionesComerciales(String idContrato) throws Exception;
public List<ContratoPagoDTO> obtenerAnticipo(String idContrato) throws Exception; public List<ContratoPagoDTO> obtenerAnticipo(String idContrato) throws Exception;
......
...@@ -10,40 +10,53 @@ package mx.com.mx.dda.msjb; ...@@ -10,40 +10,53 @@ package mx.com.mx.dda.msjb;
* @author albarranoi * @author albarranoi
*/ */
import java.io.*; import java.io.*;
import java.util.concurrent.Callable; import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import javax.servlet.*; import javax.servlet.*;
import javax.servlet.annotation.WebServlet; import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*; import javax.servlet.http.*;
import mx.com.amx.mx.dda.crn.DDAExhibicion; import mx.com.amx.mx.dda.crn.DDAExhibicion;
import mx.com.amx.mx.dda.crn.bo.DDAExhibicionBO; import mx.com.amx.mx.dda.crn.bo.DDAExhibicionBO;
import org.apache.log4j.Logger;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;
@WebServlet(name="service", urlPatterns={"/servicio"}) @WebServlet(name="service", urlPatterns={"/servicio"})
public class service extends HttpServlet { public class service extends HttpServlet {
private DDAExhibicion ex; private DDAExhibicion ex;
private DDAExhibicionBO bo; private DDAExhibicionBO bo;
private final Logger LOG = Logger.getLogger(this.getClass().getSimpleName());
@Override @Override
public void doGet(HttpServletRequest request, HttpServletResponse response) public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException { throws IOException, ServletException {
String jsonList = request.getParameter("lista");
ObjectMapper objMapper = new ObjectMapper();
List<String> contratos = objMapper.readValue(jsonList, new TypeReference<List<String>>() {});
response.setContentType("application/json"); response.setContentType("application/json");
PrintWriter out = response.getWriter(); PrintWriter out = response.getWriter();
String msg = ejec(); String msg = ejec(contratos,jsonList);
out.write("{\"rows\":\"" + msg + "\"}"); out.write("{\"rows\":\"" + msg + "\"}");
} }
public String ejec() { public String ejec( List<String> contratos, String jsonList) {
ApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContext.xml"); ApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContext.xml");
setEx((DDAExhibicion) context.getBean("exhibicion_DDA")); setEx((DDAExhibicion) context.getBean("exhibicion_DDA"));
LOG.info(" Ejecutando proceso por solicitud para los contratos: " + jsonList);
getEx().ejecutaProceso(); String cntrts = "";
boolean primero = true;
for (String elemento : contratos) {
if (!primero) {
cntrts += ",";
}
cntrts += elemento;
primero = false;
}
getEx().ejecutaProceso(cntrts);
return "OK"; 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