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...");
......
......@@ -183,11 +183,13 @@ public class DDAExhibicionBO {
//-- 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.");
List<ItemActivoFijoDTO> lobTitulosCnt = dao.obtenerTitulosSinIdSAP_RecienExhibidos(pstFechaReferencia);
List<ItemActivoFijoDTO> lobContratosCnt = dao.obtenerContratosConTitulosSinIdSAP_RecienExhibidos(pstFechaReferencia);
LOG.info(" [FIN]. Consulta de Titulos sin ID SAP Recien Exhibidos. Titulos:_" + lobTitulosCnt.size() + "_");
if (Objects.nonNull(lobTitulosCnt) && !lobTitulosCnt.isEmpty()) {
ParamActivoFijoDTO afDTO = new ParamActivoFijoDTO();
afDTO.setTitulos(lobTitulosCnt);
afDTO.setContratos(lobContratosCnt);
//--Llamado al WS SAP para registrar los Activos Fijos (Titulos)
LOG.info(" [INI]. Llamado a WS SAP. Interfaz 10.");
......@@ -262,11 +264,12 @@ public class DDAExhibicionBO {
ResultadoCrearActivoFijoDTO resultado = new ResultadoCrearActivoFijoDTO();
TransactionFaultDTO tf = resultado.getTransFault();
List<RespSAPActivoFijoDTO> afs = resultado.getActivosFijos();
String method = "crearActivoFijoWS";
try {
DTActivoFijo params = new DTActivoFijo();
for (ItemActivoFijoDTO titulo : dto.getTitulos()) {
for (ItemActivoFijoDTO titulo : dto.getContratos()) {
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() : "");
......@@ -298,14 +301,34 @@ public class DDAExhibicionBO {
LOG.info("IDDDA devuelto por sap: " + respuesta.getIDDDA() + " codigo DDA en parametros: " + registro.getCodigoDDA());
registro.setCodigoSAP((Objects.nonNull(respuesta.getIDSAP()) && !respuesta.getIDSAP().isEmpty()) ? respuesta.getIDSAP() : "");
}
actualizarEstatusSapTitulosContrato("PRIMER LLAMADO: " + respuesta.getExcepcion(), registro.getContratoDDA());
}
}
DTActivoFijo paramsSeg = new DTActivoFijo();
for (ItemActivoFijoDTO titulo : dto.getTitulos()) {
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() : "");
tituloAF.setDescripcion(strManager.extraerPrimerosCaracteres(
(Objects.nonNull(titulo.getDescripcion())&& !titulo.getDescripcion().isEmpty()) ? titulo.getDescripcion() : "", 45));
tituloAF.setOrdenCompra((Objects.nonNull(titulo.getOrdenCompra()) && !titulo.getOrdenCompra().isEmpty()) ? titulo.getOrdenCompra() : "");
tituloAF.setProveedor((Objects.nonNull(titulo.getProveedor()) && !titulo.getProveedor().isEmpty()) ? titulo.getProveedor() : "");
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() : "" );
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);
}
LOG.info(" [FIN] Detalle respuesta devuelta por SAP [CrearActivoFijo]primer llamado:");
LOG.info(" ");
LOG.debug(" Url Srv. Activo Fijo primer llamado segundo llamado: " + this.getUrlServicio(TEN));
responseActivoFijo = (DTActivoFijoRes) wsNotificaAFijoSAP.marshalSendAndReceive(this.getUrlServicio(TEN), params);
responseActivoFijo = (DTActivoFijoRes) wsNotificaAFijoSAP.marshalSendAndReceive(this.getUrlServicio(TEN), paramsSeg);
LOG.info(" ");
LOG.info(" [INI] Detalle respuesta devuelta por SAP [CrearActivoFijo] segundo llamado:");
......@@ -318,52 +341,55 @@ public class DDAExhibicionBO {
LOG.info(" <IDDDA:[" + respuesta.getIDDDA() + "], IDSAP:[" + respuesta.getIDSAP() + "], Excepcion:["
+ respuesta.getExcepcion() + "]>");
afs.add(respActivoFijo);
dao.actualizarEstatusSapTitulosByTitulo("SEGUNDO LLAMADO: " + respuesta.getExcepcion(), respuesta.getIDDDA());
}
LOG.info(" [FIN] Detalle respuesta devuelta por SAP [CrearActivoFijo] segundo llamado:");
LOG.info(" ");
resultado.setResultado(Boolean.TRUE);
} else {
tf.setInternalCode("DDA-AF-004");
tf.setComponent(COMPONENTE);
tf.setFaultDescription(ERROR_COMUNICACION_SAP);
tf.setFaultMessage("El servicio web se ejecuto, pero la respuesta es NULL");
tf.setMethod("crearActivoFijoWS");
for (ItemActivoFijoDTO titulo : dto.getContratos()) {
writeResponse(tf, "DDA-AF-004", ERROR_COMUNICACION_SAP, "El servicio web se ejecuto, pero la respuesta es NULL", method, titulo.getContratoDDA());
}
resultado.setResultado(Boolean.FALSE);
}
return resultado;
} catch (WebServiceException c) {
tf.setInternalCode("DDA-AF-001");
tf.setComponent(COMPONENTE);
tf.setFaultDescription(ERROR_COMUNICACION_SAP);
tf.setFaultMessage(c.getMessage());
tf.setMethod("crearActivoFijoWS");
for (ItemActivoFijoDTO titulo : dto.getContratos()) {
writeResponse(tf, "DDA-AF-001", ERROR_COMUNICACION_SAP, c.getMessage(), method, titulo.getContratoDDA());
}
resultado.setResultado(Boolean.FALSE);
return resultado;
} catch (SoapFaultClientException se) {
tf.setInternalCode("DDA-AF-002");
tf.setComponent(COMPONENTE);
tf.setFaultDescription(ERROR_INTERNO_SAP);
tf.setFaultMessage(se.getMessage());
tf.setMethod("crearActivoFijoWS");
for (ItemActivoFijoDTO titulo : dto.getContratos()) {
writeResponse(tf, "DDA-AF-002", ERROR_INTERNO_SAP, se.getMessage(), method, titulo.getContratoDDA());
}
resultado.setResultado(Boolean.FALSE);
return resultado;
} catch (Exception e) {
tf.setInternalCode("DDA-AF-003");
tf.setComponent(COMPONENTE);
tf.setFaultDescription(ERROR_PROCESO);
tf.setFaultMessage(e.getMessage());
tf.setMethod("crearActivoFijoWS");
for (ItemActivoFijoDTO titulo : dto.getContratos()) {
writeResponse(tf, "DDA-AF-002", ERROR_PROCESO, e.getMessage(), method, titulo.getContratoDDA());
}
resultado.setResultado(Boolean.FALSE);
return resultado;
}
}
public void ejecutarTerminosComerciales( List<DatosCntTituloExhibicionDTO> titulos ){
private void writeResponse(TransactionFaultDTO tf, String intCode, String faultDesc, String message, String method, String idtituloCnt){
tf.setInternalCode(intCode);
tf.setComponent(COMPONENTE);
tf.setFaultDescription(faultDesc);
tf.setFaultMessage(message);
tf.setMethod(method);
dao.actualizarEstatusSapTitulosByTitulo(faultDesc, idtituloCnt);
}
public 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 = "";
try {
Map<String,DatosCntTituloExhibicionDTO> map = new HashMap<>();
LOG.info(" Entrando try: " );
......@@ -424,8 +450,7 @@ 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.");
//dao.eliminarIdSAPCntTitulo(contrato.getIdcontratoDDA());
LOG.info(" Se quitaron todos los Id_SAP de los titulos con el id de contrato: " + contrato.getIdcontratoDDA());
respuesta = response.getEstatus();
} else {
LOG.info(" Respuesta OK del servicio ESTPROC: " + response.getESTPROC() + " con Estatus: " + response.getEstatus());
}
......@@ -436,7 +461,9 @@ 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";
}
return respuesta;
}
public List<DatosCntTituloExhibicionDTO> obtenerTitulosRecienExhibidos(String pstFechaReferencia) throws Exception {
......@@ -463,7 +490,7 @@ public class DDAExhibicionBO {
TransactionFaultDTO tf = resultado.getTransFault();
List<RespSAPNotificaAFijoDTO> not = resultado.getNotificaciones();
Map<String, List<RespSAPNotificaAFijoDTO>> mapNot = new HashMap<>();
String method = "notificarAFijoWS";
try {
DTContenido params = new DTContenido();
int xNotifica = 1;
......@@ -526,44 +553,42 @@ public class DDAExhibicionBO {
not.add(respNotificaAFijo);
mapNot.put(respuesta.getCodigoDDA(), new ArrayList());
}
if(respuesta.getStatus().equals("OK")){
dao.actualizarEstatusSapTitulosByTitulo(respuesta.getStatus(), respuesta.getCodigoDDA());
}
else{
dao.actualizarEstatusSapTitulosByTitulo(respuesta.getMensaje(), respuesta.getCodigoDDA());
}
}
LOG.info(" [FIN] Detalle respuesta devuelta por SAP [Notificados]:");
LOG.info(" ");
resultado.setResultado(Boolean.TRUE);
} else {
tf.setInternalCode("DDA-NOT-010");
tf.setComponent(COMPONENTE);
tf.setFaultDescription(ERROR_COMUNICACION_SAP);
tf.setFaultMessage("El servicio web se ejecuto, pero la respuesta es NULL");
tf.setMethod("notificarAFijoWS");
for (DatosCntTituloExhibicionDTO dtoEx : dto) {
writeResponse(tf, "DDA-AF-010", ERROR_COMUNICACION_SAP, "El servicio web se ejecuto, pero la respuesta es NULL", method, dtoEx.getID_TITULO_CNTORIG());
}
resultado.setResultado(Boolean.FALSE);
}
return resultado;
} catch (WebServiceException c) {
tf.setInternalCode("DDA-NOT-007");
tf.setComponent(COMPONENTE);
tf.setFaultDescription(ERROR_COMUNICACION_SAP);
tf.setFaultMessage(c.getMessage());
tf.setMethod("notificarAFijoWS");
for (DatosCntTituloExhibicionDTO dtoEx : dto) {
writeResponse(tf, "DDA-AF-007", ERROR_COMUNICACION_SAP, c.getMessage(), method, dtoEx.getID_TITULO_CNTORIG());
}
resultado.setResultado(Boolean.FALSE);
return resultado;
} catch (SoapFaultClientException se) {
tf.setInternalCode("DDA-NOT-008");
tf.setComponent(COMPONENTE);
tf.setFaultDescription(ERROR_INTERNO_SAP);
tf.setFaultMessage(se.getMessage());
tf.setMethod("notificarAFijoWS");
for (DatosCntTituloExhibicionDTO dtoEx : dto) {
writeResponse(tf, "DDA-AF-008", ERROR_INTERNO_SAP, se.getMessage(), method, dtoEx.getID_TITULO_CNTORIG());
}
resultado.setResultado(Boolean.FALSE);
return resultado;
} catch (Exception e) {
tf.setInternalCode("DDA-NOT-009");
tf.setComponent(COMPONENTE);
tf.setFaultDescription(ERROR_PROCESO);
tf.setFaultMessage(e.getMessage());
tf.setMethod("notificarAFijoWS");
for (DatosCntTituloExhibicionDTO dtoEx : dto) {
writeResponse(tf, "DDA-AF-009", ERROR_PROCESO, e.getMessage(), method, dtoEx.getID_TITULO_CNTORIG());
}
resultado.setResultado(Boolean.FALSE);
return resultado;
}
......@@ -624,4 +649,26 @@ public class DDAExhibicionBO {
return resultado;
}
public List<ContratoDTO> contratosCandidatos(){
LOG.debug(" - [" + this.getClass().getSimpleName() + "::contratosCandidatos]");
List<ContratoDTO> resultado = null;
try {
resultado = dao.obtenerContratosCandidatos();
} catch (Exception e) {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::contratosCandidatos]: " + e.getMessage());
}
return resultado;
}
public void actualizarEstatusSapTitulosContrato(String mensaje, String idContrato){
LOG.debug(" - ["+this.getClass().getSimpleName()+"::actualizarEstatusSapTitulo]");
try
{
dao.actualizarEstatusSapTitulosByContrato(mensaje,idContrato);
}
catch(Exception e)
{
LOG.error("Exception["+this.getClass().getSimpleName()+"::ejecutarSPAmortizacionAjustada]: "+e.getMessage() );
}
}
}
......@@ -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