/**
  * Arma la trama de entrada para la transacción LZ80
  *
  * @param trama_entrada
  */
 private void obtenerTramaEntrada(StringBuffer trama_entrada) {
   if (importe.indexOf(".") > -1)
     importe =
         importe.substring(0, importe.indexOf(".")) + importe.substring(importe.indexOf(".") + 1);
   // trama_entrada.append( SantanderUtileriasService.armaCabeceraPS7(canal,"LZ80", "NZ80", 150,
   // "00"));
   trama_entrada.append(SantanderUtileriasService.armaCabeceraPS7("LZ80", "NZ80", 165, "00"));
   trama_entrada.append(SantanderUtileriasService.rellenar(modo_operacion, 1, 'A', 'D'));
   trama_entrada.append(SantanderUtileriasService.rellenar(cta_origen, 23, ' ', 'D'));
   trama_entrada.append(SantanderUtileriasService.rellenar(cve_cargo, 4, ' ', 'I'));
   trama_entrada.append(SantanderUtileriasService.rellenar(cta_destino, 23, ' ', 'D'));
   trama_entrada.append(SantanderUtileriasService.rellenar(cve_abono, 4, ' ', 'I'));
   trama_entrada.append(SantanderUtileriasService.rellenar(importe, 15, '0', 'I'));
   trama_entrada.append(SantanderUtileriasService.rellenar(reference_No, 20, ' ', 'D'));
   trama_entrada.append(SantanderUtileriasService.rellenar(transaction_id, 8, '0', 'I'));
   trama_entrada.append(SantanderUtileriasService.rellenar(folio_o_cheque, 9, ' ', 'I'));
   trama_entrada.append(SantanderUtileriasService.rellenar(" ", 6, ' ', 'I'));
   // trama_entrada.append( SantanderUtileriasService.rellenar(folio_o_cheque , 15, '0', 'I'));
   trama_entrada.append(SantanderUtileriasService.rellenar("", 8, ' ', 'I'));
   trama_entrada.append(SantanderUtileriasService.rellenar("", 25, ' ', 'I'));
   trama_entrada.append(SantanderUtileriasService.rellenar(num_Mov_Cargo, 9, ' ', 'I'));
   trama_entrada.append(SantanderUtileriasService.rellenar(num_Mov_Abono, 9, ' ', 'I'));
   System.out.println("Enviando la trama: [" + trama_entrada.toString().replace(' ', '~') + "]");
 }
  public void ejecuta() {
    String sResp = "";
    String commArea = "";
    boolean cerrarMQ = false;
    try {
      if (daomq == null) {
        daomq = new ServiciosDAOMQ();
        cerrarMQ = true;
      }
      commArea = SantanderUtileriasService.armaCabeceraPS7("LF92", "NF92", 30, "00");
      commArea += SantanderUtileriasService.rellenar(this.empresa, 4, ' ', 'D');
      commArea += SantanderUtileriasService.rellenar(this.numCuenta, 16, ' ', 'D');
      commArea += SantanderUtileriasService.rellenar(this.fchConsulta, 10, ' ', 'D');
      org.apache.log4j.Logger.getLogger(this.getClass())
          .debug("!ENVIA[" + commArea.replace(' ', '~') + "]");

      sResp = daomq.obtenerTrama(commArea);

      if (sResp.trim().equals("")) {
        this.codStatus = 99;
        this.msgStatus =
            "LF92"
                + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
                + " SIN RESPUESTA 390";
      } else if (sResp.indexOf("NO EXISTE  TERMINAL ACTIVO") > -1) {
        this.codStatus = 99;
        this.msgStatus =
            "LF92"
                + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
                + " NO HAY TERMINALES 390 PARA ATENDER LA PETICION";
      } else if (sResp.indexOf("ABEND CICS") > -1 || sResp.indexOf("failed with abend") > -1) {
        this.codStatus = 99;
        this.msgStatus =
            "LF92"
                + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
                + " TRANSACTION WITH ABEND";
      } else if (sResp.indexOf("NO EXISTE CONTRATO BME") > -1) {
        this.codStatus = 94;
        this.msgStatus =
            "LF92"
                + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
                + " NO EXISTE EL CONTRATO BME";
      } else if (sResp.indexOf("NO EXISTEN DATOS A CONSULTAR EN EL PORTAFOLIO DE FONDOS") > -1) {
        this.codStatus = 47;
        this.msgStatus =
            "LF92"
                + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
                + " NO EXISTEN DATOS A CONSULTAR";
      } else if (sResp.indexOf("@DCLF2S920") > -1) {
        ObtenerPosicion(sResp);
        this.codStatus = 0;
        this.msgStatus =
            "LF92"
                + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
                + " CONSULTA SALDOS FONDO INVERSION EFECTUADA";
      }
    } catch (Exception e) {
      this.codStatus = 99;
      this.msgStatus =
          "LF92"
              + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
              + " ERROR CONSULTA SALDOS FONDO INVERSION "
              + e.getMessage();
      SantanderConstantesService.escribeAlLog(
          SantanderConstantesService.NIVEL2,
          "390",
          "LF92",
          this.codStatus,
          this.nombClase,
          "Instanciando Objeto Socket 390",
          this.msgStatus);
      return;
    } finally {
      if (daomq != null && cerrarMQ) {
        daomq.cerrarConexion();
        daomq = null;
      }
    }

    // -------COMENZAR Codigo para desplegar Contrato en Cero-------//
    if (this.detalle.isEmpty() && (this.codStatus == 47 || this.codStatus == 0)) {
      // Inicio modificación CONSYS 13-Mayo-2005//
      String[] saldoFondos = new String[5];
      saldoFondos[0] = ""; // 8 Emisora
      saldoFondos[1] = ""; // 8 Serie
      saldoFondos[2] =
          (new BigDecimal("0")).setScale(0, BigDecimal.ROUND_DOWN).toString(); // 12 Titulos
      saldoFondos[3] = "0"; // 13 Precio
      saldoFondos[4] =
          (new BigDecimal("0")).setScale(2, BigDecimal.ROUND_DOWN).toString(); // 15 Monto
      // Fin modificación CONSYS 13-Mayo-2005//
      detalle.addElement(saldoFondos);
      this.codStatus = 0;
      this.msgStatus =
          "LF92"
              + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
              + " CONSULTA SALDOS FONDO INVERSION EFECTUADA";
    }
    // -------TERMINAR Codigo para desplegar Contrato en Cero-------//
    SantanderConstantesService.escribeAlLog(
        SantanderConstantesService.NIVEL2,
        "390",
        "LF92",
        this.codStatus,
        this.nombClase,
        "Enviando la trama: " + commArea,
        this.msgStatus);
  }
Esempio n. 3
0
  public boolean ObtenerDatos() {
    String sResp = "";
    String commArea = "";
    boolean bandera = false;
    try {
      if (daomq == null) {
        daomq = new ServiciosDAOMQ();
        cerrarMQ = true;
      }
      commArea = SantanderUtileriasService.armaCabeceraPS7("LB44", "NB44", 56, "00");
      commArea = commArea + SantanderUtileriasService.rellenar(stBine, 6, ' ', 'D');
      org.apache.log4j.Logger.getLogger(this.getClass())
          .debug("!ENVIA[" + commArea.replace(' ', '~') + "]");

      sResp = daomq.obtenerTrama(commArea);

      if (sResp.trim().equals("")) {
        codStatus = 99;
        msgStatus =
            "LB44"
                + SantanderUtileriasService.rellenar(String.valueOf(codStatus), 4, '0', 'I')
                + " SIN RESPUESTA 390";
        SantanderConstantesService.escribeAlLog(
            SantanderConstantesService.NIVEL2,
            "390",
            "LB44",
            codStatus,
            nombClase,
            "Enviando la trama: " + commArea,
            msgStatus);
        return false;
      }

      if (sResp.indexOf("NO EXISTE  TERMINAL ACTIVO") > -1) {
        codStatus = 99;
        msgStatus =
            "LB44"
                + SantanderUtileriasService.rellenar(String.valueOf(codStatus), 4, '0', 'I')
                + " NO HAY TERMINALES 390 PARA ATENDER LA PETICION";
        SantanderConstantesService.escribeAlLog(
            SantanderConstantesService.NIVEL2,
            "390",
            "LB44",
            codStatus,
            nombClase,
            "Enviando la trama: " + commArea,
            msgStatus);
        return false;
      }

      if (sResp.indexOf("ABEND CICS") > -1 || sResp.indexOf("failed with abend") > -1) {
        codStatus = 99;
        msgStatus =
            "LB44"
                + SantanderUtileriasService.rellenar(String.valueOf(codStatus), 4, '0', 'I')
                + " TRANSACTION WITH ABEND";
        SantanderConstantesService.escribeAlLog(
            SantanderConstantesService.NIVEL2,
            "390",
            "LB44",
            codStatus,
            nombClase,
            "Enviando la trama: " + commArea,
            msgStatus);
        return false;
      }

      if (sResp.indexOf("ERROR") > -1) {
        codStatus = 99;
        msgStatus =
            "LB44"
                + SantanderUtileriasService.rellenar(String.valueOf(codStatus), 4, '0', 'I')
                + " ERROR EN ACCESO A LA TABLA";
        SantanderConstantesService.escribeAlLog(
            SantanderConstantesService.NIVEL2,
            "390",
            "LB44",
            codStatus,
            nombClase,
            "Enviando la trama: " + commArea,
            msgStatus);
        return false;
      }

      if (sResp.indexOf("NO EXISTE") > -1) {
        codStatus = 5092;
        msgStatus =
            "LB44"
                + SantanderUtileriasService.rellenar(String.valueOf(codStatus), 4, '0', 'I')
                + " NO EXISTEN FONDOS A OPERAR";
        SantanderConstantesService.escribeAlLog(
            SantanderConstantesService.NIVEL2,
            "390",
            "LB44",
            codStatus,
            nombClase,
            "Enviando la trama: " + commArea,
            msgStatus);
        return false;
      }

      if (sResp.indexOf("EXISTEN MAS DATOS") > -1) bandera = true;
      else if (sResp.indexOf("FIN DE DATOS") > -1) bandera = false;

      if (sResp.indexOf("DCLBM0044") > -1) {
        int posIni = 0;

        posIni = sResp.indexOf("@DCLBM0044");

        try {
          org.apache.log4j.Logger.getLogger(this.getClass()).debug("°°°Transaccion OK °°°");
          // Desentramar datos
          // org.apache.log4j.Logger.getLogger(this.getClass()).debug("°°°°Posision inicial:" +
          // posIni + "°°°");
          String stTemp = sResp.substring(posIni);
          // org.apache.log4j.Logger.getLogger(this.getClass()).debug("°°°°Cadena recibida:\n°°°°" +
          // stTemp + "°°°");
          // org.apache.log4j.Logger.getLogger(this.getClass()).debug("°°°°Longitud de la cadena:" +
          // stTemp.length() + "°°°");
          stDescripcion = stTemp.substring(18);
          stDescripcion = stDescripcion.trim();
          // org.apache.log4j.Logger.getLogger(this.getClass()).debug("Descripcion:" +
          // stDescripcion);
          codStatus = 0;

        } catch (Exception _ex) {
          org.apache.log4j.Logger.getLogger(this.getClass()).debug(_ex.getMessage());
          _ex.printStackTrace();
          codStatus = 99;
        }
      }
    } catch (Exception e) {

      codStatus = 99;
      msgStatus =
          "LB44"
              + SantanderUtileriasService.rellenar(String.valueOf(codStatus), 4, '0', 'I')
              + " ERROR AL EJECUTAR SERVICIO:"
              + e.getMessage();
      SantanderConstantesService.escribeAlLog(
          SantanderConstantesService.NIVEL2,
          "390",
          "LB44",
          codStatus,
          nombClase,
          "Instanciando Objeto Socket 390",
          msgStatus);
      return false;
    }
    return bandera;
  }
  private boolean ObtenerDatos() {
    String commArea = null;
    String sResp = null;
    String tramaResp = null;
    boolean bandera = false;
    String canal = ""; // art52 24-01-2007
    try {

      canal = ConfiguracionMQ.getInstance().getCANAL();
      /* Revisamos si el canal por el cual se esta invocando la peticion */
      if (canal.equals("MQ")) {

        if (daomq == null) {

          daomq = new ServiciosDAOMQ();
          cerrarMQ = true;
        }

        /* Se arma trama de envio con los parametros de entrada, en la cabecesa se considera
         * 01 como tecla de funcion para Bloqueos */
        commArea =
            SantanderUtileriasService.armaCabeceraPS7(canal, "LB54", "NB54", 10, this.teclaFunc);
        commArea += SantanderUtileriasService.rellenar(this.cliente, 8, ' ', 'I');
        commArea += SantanderUtileriasService.rellenar(this.estatusToken, 2, '0', 'I');
        org.apache.log4j.Logger.getLogger(this.getClass()).debug("TRAMA ENVIA [" + commArea + "]");
        sResp = daomq.obtenerTrama(commArea);
        tramaResp = sResp;

      } else {
        if (!envia.connect()) {
          this.codStatus = envia.getCodigoEstatus();
          this.msgStatus =
              "LB54"
                  + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
                  + " "
                  + envia.getMensajeEstatus();
          SantanderConstantesService.escribeAlLog(
              SantanderConstantesService.NIVEL2,
              "390",
              "LB54",
              this.codStatus,
              this.nombreClase,
              "Enviando la trama: " + commArea,
              this.msgStatus);
          return false;
        }
        commArea = SantanderUtileriasService.armaCabeceraPS7(canal, "LB54", "NB54", 10, "00");
        commArea += SantanderUtileriasService.rellenar(this.cliente, 8, ' ', 'I');
        commArea += SantanderUtileriasService.rellenar(this.estatusToken, 2, '0', 'I');
        org.apache.log4j.Logger.getLogger(this.getClass()).debug("TRAMA ENVIA [" + commArea + "]");
        envia.setStrIn(commArea);
        if (!envia.send()) {
          this.codStatus = envia.getCodigoEstatus();
          this.msgStatus =
              "LB54 "
                  + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
                  + " "
                  + envia.getMensajeEstatus();
          SantanderConstantesService.escribeAlLog(
              SantanderConstantesService.NIVEL2,
              "390",
              "LB54",
              this.codStatus,
              this.nombreClase,
              "Enviando la trama: " + commArea,
              this.msgStatus);
          return false;
        }
        sResp = (envia.getStrOut() == null) ? "" : envia.getStrOut();
        tramaResp = sResp;
      }

      org.apache.log4j.Logger.getLogger(this.getClass()).debug("TRAMA RECIBE [" + sResp + "]");
      if (sResp.trim().equals("")) {
        this.codStatus = 99;
        this.msgStatus =
            "LB54 "
                + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
                + " SIN RESPUESTA 390";
        SantanderConstantesService.escribeAlLog(
            SantanderConstantesService.NIVEL2,
            "390",
            "LB54",
            this.codStatus,
            this.nombreClase,
            "Enviando la trama: " + commArea,
            this.msgStatus);
        return false;
      } else if (sResp.indexOf("NO EXISTE  TERMINAL ACTIVO") > -1) {
        this.codStatus = 99;
        this.msgStatus =
            "LB54 "
                + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
                + " NO HAY TERMINALES 390 PARA ATENDER LA PETICION";
        SantanderConstantesService.escribeAlLog(
            SantanderConstantesService.NIVEL2,
            "390",
            "LB54",
            this.codStatus,
            this.nombreClase,
            "Enviando la trama: " + commArea,
            this.msgStatus);
        return false;
      } else if (sResp.indexOf("ABEND CICS") > -1 || sResp.indexOf("failed with abend") > -1) {
        this.codStatus = 99;
        this.msgStatus =
            "LB54 "
                + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
                + " TRANSACTION WITH ABEND";
        SantanderConstantesService.escribeAlLog(
            SantanderConstantesService.NIVEL2,
            "390",
            "LB54",
            this.codStatus,
            this.nombreClase,
            "Enviando la trama: " + commArea,
            this.msgStatus);
        return false;
      } else if (sResp.indexOf("NO EXISTEN DATOS PARA LA CONSULTA SOLICITADA") > -1) {
        this.codStatus = 99;
        this.msgStatus =
            "LB54 "
                + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
                + " NO EXISTEN DATOS PARA LA CONSULTA SOLICITADA";
        SantanderConstantesService.escribeAlLog(
            SantanderConstantesService.NIVEL2,
            "390",
            "LB54",
            this.codStatus,
            this.nombreClase,
            "Enviando la trama: " + commArea,
            this.msgStatus);
        return false;
      } else if (sResp.indexOf("NO HAY MOVIMIENTOS") > -1) {
        this.codStatus = 97;
        this.msgStatus =
            "LB54 "
                + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
                + " NO HAY MOVIMIENTOS";
        SantanderConstantesService.escribeAlLog(
            SantanderConstantesService.NIVEL2,
            "390",
            "LB54",
            this.codStatus,
            this.nombreClase,
            "Enviando la trama: " + commArea,
            this.msgStatus);
        return false;
      } else if (sResp.indexOf("Transaction '' is not recognized") > -1) {
        this.codStatus = 99;
        this.msgStatus =
            "LB54 "
                + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
                + " NO HAY MOVIMIENTOS";
        SantanderConstantesService.escribeAlLog(
            SantanderConstantesService.NIVEL2,
            "390",
            "LB54",
            this.codStatus,
            this.nombreClase,
            "Enviando la trama: " + commArea,
            this.msgStatus);
        return false;
      } else if (sResp.indexOf("MENSAJE RECIBIDO DEL PS7 ES ERRONEA") > -1) {
        this.codStatus = 99;
        this.msgStatus =
            "LB54 "
                + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
                + " FORMATO PS7 INCORRECTO PARA REALIZAR CONSULTA";
        SantanderConstantesService.escribeAlLog(
            SantanderConstantesService.NIVEL2,
            "390",
            "LB54",
            this.codStatus,
            this.nombreClase,
            "Enviando la trama: " + commArea,
            this.msgStatus);
        return false;
      } else if (sResp.indexOf("@AVLBA") > -1) {
        org.apache.log4j.Logger.getLogger(this.getClass())
            .debug(
                "---------------------------------------------------------------------------------");
        org.apache.log4j.Logger.getLogger(this.getClass())
            .debug("ESTA ES LA TRAMA DE RESPUESTA DESDE 390 <<<" + sResp + ">>>");
        try {
          sResp = sResp.substring(sResp.indexOf("P") + 1);
        } catch (Exception e) {
        }
        org.apache.log4j.Logger.getLogger(this.getClass())
            .debug("ESTA ES LA TRAMA DE RESPUESTA DESDE 390 DESPUES DEL SUBS <<<" + sResp + ">>>");
        org.apache.log4j.Logger.getLogger(this.getClass())
            .debug(
                "---------------------------------------------------------------------------------");

        this.codStatus = 0;
        bandera = true;
        this.msgStatus =
            "LB54"
                + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
                + " "
                + SantanderConstantesService.RESPUESTA_SOCKET;
      } else {
        this.codStatus = 99;
        this.msgStatus =
            "LB54 "
                + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
                + " ERROR DESCONOCIDO";
        SantanderConstantesService.escribeAlLog(
            SantanderConstantesService.NIVEL2,
            "390",
            "LB54",
            this.codStatus,
            this.nombreClase,
            "Enviando la trama: " + commArea,
            this.msgStatus);
        return false;
      }
      SantanderConstantesService.escribeAlLog(
          SantanderConstantesService.NIVEL2,
          "390",
          "LB54",
          this.codStatus,
          this.nombreClase,
          "Enviando la trama: " + commArea,
          this.msgStatus);
    } catch (Exception e) {
      this.codStatus = 99;
      this.msgStatus =
          "LB54"
              + SantanderUtileriasService.rellenar("" + this.codStatus, 4, '0', 'I')
              + " ERROR AL EJECUTAR SERVICIO: "
              + e.getMessage();
      SantanderConstantesService.escribeAlLog(
          SantanderConstantesService.NIVEL2,
          "390",
          "LB54",
          this.codStatus,
          this.nombreClase,
          "Enviando la trama: " + commArea,
          "ERROR AL EJECUTAR SERVICIO: " + e.getMessage());
      return false;
    }
    if (this.codStatus == -1) {
      this.codStatus = 99;
      SantanderConstantesService.escribeAlLog(
          SantanderConstantesService.NIVEL2,
          "390",
          "LB54",
          this.codStatus,
          this.nombreClase,
          "Enviando la trama: " + commArea,
          this.msgStatus);
    }
    return bandera;
  }