cambios para sap contratos originales y adendums

parent 5b739a79
......@@ -3,6 +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/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>
......
......@@ -9,6 +9,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import mx.com.amx.mx.dda.crn.bo.DDAExhibicionBO;
import mx.com.amx.mx.dda.crn.dto.ContratoDTO;
import mx.com.amx.mx.dda.crn.dto.ContratoTituloDTO;
import mx.com.amx.mx.dda.crn.dto.DatosCntTituloExhibicionDTO;
import mx.com.amx.mx.dda.crn.dto.RespSAPNotificaAFijoDTO;
......@@ -44,6 +45,7 @@ public class DDAExhibicion implements ApplicationContextAware {
LOG.info(" [INI]. Paso 1.- Verifica bandera de ejecucion de proceso de Notificacion.");
boolean boEjecutandoseProceso = bo.existeProcesoNotificacionEjecutandose();
LOG.info(" [INI]. Paso 1.- Verifica bandera de ejecucion de proceso de Notificacion. Esta ejecutando?: _" + boEjecutandoseProceso + "_");
List<ContratoDTO> contratos = bo.contratosCandidatos();
if (!boEjecutandoseProceso) {
//-- 2. Verificar si se puede iniciar el proceso
......@@ -86,9 +88,9 @@ public class DDAExhibicion implements ApplicationContextAware {
LOG.info(" [FIN]. Paso 7.- Obtener Titulos recien exhibidos con base a fecha referencia. Titulos:_" + lobTitulos.size() + "_");
LOG.info(" [INI]. Paso 8.- Envío de terminos comerciales de los contratos. (Creacion de Terminos Comerciales)");
bo.ejecutarTerminosComerciales(lobTitulos);
String respuestaTC = bo.ejecutarTerminosComerciales(lobTitulos);
LOG.info(" [FIN]. Paso 8.- Envío 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.");
......@@ -197,6 +199,14 @@ public class DDAExhibicion implements ApplicationContextAware {
bo.actualizarEjecutandoProcesoNotificacion("0");
LOG.info("Apaga bandera de proceso Notifica.[Else_lobTitulos_null]");
}
}
else {
LOG.error("DDA-NOT-012: Falla en terminos comerciales.");
bo.actualizarEjecutandoProcesoNotificacion("0");
updateTitulos(contratos, respuestaTC);
LOG.info("Apaga bandera de proceso Notifica.[Else_lobTitulos_null]");
}
//-- 9. Sos 22Ago17 Generación de la amortización real de los titulos
LOG.info(" [INI]. Paso 10.- Llamado a SP Amortizacion Real.");
......@@ -206,21 +216,21 @@ 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");
updateTitulos(contratos, "NO SE LOGRO OBTENER LA FECHA DE REFERENCIA");
bo.actualizarEjecutandoProcesoNotificacion("0");
LOG.info("Apaga bandera de proceso Notifica.[Else_lstFechaReferencia_trim()_length()]");
}
}// Ends if(!lstValorDiaNotificacion.equals("-1"))
else {
LOG.error("DDA-NOT-004: No se pudo obtener el valor de referencia");
updateTitulos(contratos, "NO SE LOGRO OBTENER VALOR DE REFERENCIA");
bo.actualizarEjecutandoProcesoNotificacion("0");
LOG.info("Apaga bandera de proceso Notifica.[Else_boActualizarBanderaIniciaProceso]");
}
}//Ends if(boActualizarBanderaIniciaProceso)
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");
bo.actualizarEjecutandoProcesoNotificacion("0");
LOG.info("Apaga bandera de proceso Notifica.[Else_boActualizarBanderaIniciaProceso]");
......@@ -228,10 +238,14 @@ public class DDAExhibicion implements ApplicationContextAware {
}//Ends if(boIniciar)
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");
bo.actualizarEjecutandoProcesoNotificacion("0");
}
}//Ends if(!boEjecutandoseProceso)
else {
LOG.error("DDA-NOT-001: Es probable que se haya iniciado este proceso previamente.");
updateTitulos(contratos, "PROCESO DE SAP INICIADO PREVIAMENTE");
bo.actualizarEjecutandoProcesoNotificacion("0");
}
} catch (Exception e) {
......@@ -242,6 +256,12 @@ public class DDAExhibicion implements ApplicationContextAware {
LOG.info(" ");
}
private void updateTitulos(List<ContratoDTO> contratos, String mensaje){
for (ContratoDTO contrato : contratos){
bo.actualizarEstatusSapTitulosContrato(mensaje, contrato.getIdcontratoDDA());
}
}
@Override
public void setApplicationContext(ApplicationContext arg0) throws BeansException {
LOG.info("Entering to the application Context...");
......
......@@ -449,8 +449,6 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
try {
String lstFechaReferencia = (pstFechaReferencia != null && pstFechaReferencia.length() > 0) ? pstFechaReferencia : "";
//--Ejecucion
sb.append("SELECT ordenCompra,proveedor,descripcion,MIN(codigoDDA) as codigoDDA,centroCosto,");
sb.append("MIN(programID) as programID, contratoDDA, inicioAmortizacion, temporada, SUM(costo) as costo FROM (");
......@@ -501,6 +499,58 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
return lobResultado;
}
@Override
public List<ItemActivoFijoDTO> obtenerContratosConTitulosSinIdSAP_RecienExhibidos(String pstFechaReferencia) throws Exception {
List<ItemActivoFijoDTO> lobResultado = new ArrayList<>();
StringBuilder sb = new StringBuilder();
List<Object> qryParams = new ArrayList<>();
try {
//--Ejecucion
sb.append("select ");
sb.append("contrato.ID_SAP as ordenCompra, ");
sb.append("estudio.ID_SAP as proveedor, ");
sb.append("'ACTIVO PRINCIPAL' as descripcion, ");
sb.append("MIN(cnttit.ID_TITULO_CNTORIG) as codigoDDA, ");
sb.append("'");
sb.append(CENTRO_COSTO);
sb.append("' as centroCosto, ");
sb.append("MIN(cnttit.ID_BV) as programID, ");
sb.append("contrato.NUMERO_CONTRATO AS contratoDDA, ");
sb.append("REPLACE(to_char(MIN(cnttit.FECHA_INICIO),'yyyy-mm-dd') ,'-','') AS inicioAmortizacion, ");
sb.append("SUM(cnttit.COSTO) AS costo ");
sb.append("from ");
sb.append("DDA_T_CONTRATO_TITULO cnttit, ");
sb.append("DDA_T_CONTRATO contrato, ");
sb.append("DDA_C_ESTUDIO estudio ");
sb.append("where ");
sb.append("cnttit.ID_CONTRATO = contrato.ID_CONTRATO ");
sb.append("and contrato.ID_ESTUDIO = estudio.ID_ESTUDIO ");
sb.append("and cnttit.ID_SAP is null ");
sb.append("and contrato.ID_ESTATUS = ? ");
sb.append("and estudio.ID_SAP is not null ");
sb.append("and contrato.ID_SAP is not null ");
sb.append("and contrato.ID_TIPO_CONTRATO = 1 ");
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 ");
//--Debug
LOG.debug(">Sql_D [obtenerTitulosSinIdSAP_RecienExhibidos]:" + sb.toString());
final String lstSQL = sb.toString();
qryParams.add(ESTATUS_VIGENTE);
//qryParams.add(lstFechaReferencia);
lobResultado = getJdbcTemplate().query(lstSQL, qryParams.toArray(), new BeanPropertyRowMapper<>(ItemActivoFijoDTO.class));
} catch (Exception e) {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::obtenerTitulosRecienExhibidos]: " + e.getMessage());
throw new Exception(e.getMessage());
}
return lobResultado;
}
@Override
public boolean actualizaIdSAPCntTitulo(RespSAPActivoFijoDTO dto) throws Exception {
boolean resultado = Boolean.FALSE;
......@@ -636,6 +686,45 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
return lobResultado;
}
@Override
public List<ContratoDTO> obtenerContratosCandidatos() throws Exception {
List<ContratoDTO> lobResultado = new ArrayList<>();
StringBuilder sb = new StringBuilder();
List<Object> qryParams = new ArrayList<>();
try {
//--Ejecucion
sb.append("select ");
sb.append("cnt.ID_SAP AS ordenCompra, ");
sb.append("cnt.ID_CONTRATO AS idcontratoDDA, ");
sb.append("cnt.NUMERO_CONTRATO AS contratoDDA, ");
sb.append("ROUND(SUM(cnttit.COSTO),2) AS valorcondicion, ");
sb.append("REPLACE(to_char(MIN(cnt.FECHA_FIN),'yyyy-mm-dd') ,'-','') AS fechavencimiento ");
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 cnt.ID_ESTATUS = ? ");
sb.append("and (cnttit.ID_SAP is null ");
sb.append("or cnttit.FECHA_NOTIFSAP is null )");
sb.append("GROUP BY cnt.ID_SAP, cnt.ID_CONTRATO, cnt.NUMERO_CONTRATO ");
//--Debug
LOG.debug(">Sql_D [obtenerContratos]:" + sb.toString());
final String lstSQL = sb.toString();
qryParams.add(ESTATUS_VIGENTE);
lobResultado = (ArrayList<ContratoDTO>) getJdbcTemplate().query(lstSQL, qryParams.toArray(), new BeanPropertyRowMapper<>(ContratoDTO.class));
} catch (Exception e) {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::obtenerTitulosRecienExhibidos]: " + e.getMessage());
throw new Exception(e.getMessage());
}
return lobResultado;
}
public List<ContratoPagoDTO> obtenerCondicionesComerciales(String idContrato) throws Exception{
List<ContratoPagoDTO> lobResultado = new ArrayList<>();
StringBuilder sb = new StringBuilder();
......@@ -720,4 +809,65 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
return resultado;
}
@Override
public void actualizarEstatusSapTitulosByContrato(String mensaje, String idContrato) {
StringBuffer sb = new StringBuffer();
StringBuffer sbD = new StringBuffer();
List<Object> qryParams = new ArrayList<Object>();
try {
//--Debug
sbD.append("UPDATE DDA_T_CONTRATO_TITULO SET ESTATUS_SAP =' ");
sbD.append(mensaje);
sbD.append("' WHERE ID_CONTRATO = ");
sbD.append(idContrato);
LOG.debug(">Sql_D [actualizarEstatusSapTitulosByContrato]:" + sbD.toString());
//--Ejecucion
sb.append("UPDATE DDA_T_CONTRATO_TITULO SET ESTATUS_SAP =' ");
sb.append(mensaje);
sb.append("' WHERE ID_CONTRATO = ");
sb.append(idContrato);
final String lstSQL = sb.toString();
jdbcTemplate.update(lstSQL, qryParams.toArray());
} catch (Exception e) {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::actualizarEstatusSapTitulosByContrato]: " + e.getMessage());
}
}
@Override
public void actualizarEstatusSapTitulosByTitulo(String mensaje, String idtitulo) {
StringBuffer sb = new StringBuffer();
StringBuffer sbD = new StringBuffer();
List<Object> qryParams = new ArrayList<Object>();
try {
//--Debug
sbD.append("UPDATE DDA_T_CONTRATO_TITULO SET ESTATUS_SAP =' ");
sbD.append(mensaje);
sbD.append("' WHERE ID_TITULO_CNT = ");
sbD.append(idtitulo);
LOG.debug(">Sql_D [actualizarEstatusSapTitulos]:" + sbD.toString());
//--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();
qryParams.add(mensaje);
qryParams.add(idtitulo);
jdbcTemplate.update(lstSQL, qryParams.toArray());
} catch (Exception e) {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::ejecutarSPAmortizacionAjustada]: " + e.getMessage());
}
}
}
......@@ -20,10 +20,14 @@ public interface IDDAExhibicionDAO
public boolean actualizaFechaNotificacion(ContratoTituloDTO dto) throws Exception;
public boolean insertarRegistroSubnum(String pstIdTituloCnt) throws Exception;
public List<ItemActivoFijoDTO> obtenerTitulosSinIdSAP_RecienExhibidos(String pstFechaReferencia) throws Exception;
public List<ItemActivoFijoDTO> obtenerContratosConTitulosSinIdSAP_RecienExhibidos(String pstFechaReferencia) throws Exception;
public boolean actualizaIdSAPCntTitulo(RespSAPActivoFijoDTO dto) throws Exception;
public boolean ejecutarSPAmortizacionReal() throws Exception;
public List<ContratoDTO> obtenerContratos() throws Exception;
public List<ContratoDTO> obtenerContratosCandidatos() throws Exception;
public boolean eliminarIdSAPCntTitulo(String idcontrato) throws Exception;
public List<ContratoPagoDTO> obtenerCondicionesComerciales(String idContrato) throws Exception;
public List<ContratoPagoDTO> obtenerAnticipo(String idContrato) throws Exception;
public void actualizarEstatusSapTitulosByContrato(String mensaje, String idContrato);
public void actualizarEstatusSapTitulosByTitulo(String mensaje, String idContrato);
}
......@@ -11,6 +11,7 @@ public class ParamActivoFijoDTO implements Serializable
{
private static final long serialVersionUID = 1L;
private List<ItemActivoFijoDTO> titulos;
private List<ItemActivoFijoDTO> contratos;
public List<ItemActivoFijoDTO> getTitulos() {
return titulos;
......@@ -19,6 +20,14 @@ public class ParamActivoFijoDTO implements Serializable
this.titulos = titulos;
}
public List<ItemActivoFijoDTO> getContratos() {
return contratos;
}
public void setContratos(List<ItemActivoFijoDTO> contratos) {
this.contratos = contratos;
}
public String toString()
{
StringBuilder result = new StringBuilder();
......
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