예제 #1
0
  /**
   * Devuelve los Pycks en el Excel que estan por definirse.
   *
   * @throws IOException
   */
  public List<PyckBO> getPyckPorDefinir(Boolean calcularMaps) throws XLSException {

    if (pycksPorDefinir != null && pycksPorDefinir.size() > 0 && !calcularMaps) {
      return pycksPorDefinir;
    }

    FileInputStream fileInputStream;
    try {
      fileInputStream = new FileInputStream(RUTA_ARCHIVO + "\\Rendimiento.xls");
    } catch (FileNotFoundException e) {
      return pycksPorDefinir;
    }

    HSSFWorkbook workbook;
    try {
      workbook = new HSSFWorkbook(fileInputStream);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      throw new XLSException();
    }

    HSSFSheet worksheet = workbook.getSheet(PESTANA);

    HSSFRow row = worksheet.getRow(1);
    HSSFCell celdag2 = row.getCell(convert('g'));

    System.out.println("IMPL celdaF2 = " + celdag2.getNumericCellValue());

    Integer cantidadPycks;
    cantidadPycks = ((Double) celdag2.getNumericCellValue()).intValue();

    System.out.println("IMPL cantidadPycks = " + cantidadPycks);

    HSSFCell celdaC2 = row.getCell(convert('c'));

    // Buscar en F2, la cantidad total de Pycks
    rendimiento = celdaC2.getNumericCellValue();

    String estadoPyck;
    String resultBuscado;
    PyckBO bo;
    ResultadoPartidoBO resulP;
    CurrentPOddsPortal parOP;
    HSSFRow rowPicks;
    int stake;
    String gameOP;
    String country;
    String liga;
    String fecha;
    double odds;

    pycksPorDefinir = new ArrayList<PyckBO>();
    mapPycksPorDefinir = new HashMap<PyckBO, Integer>();

    System.out.println("IMPL justo antes del for " + cantidadPycks);

    // Leer el Excel que contiene los juegos pendientes
    // Proceder a leer cada registro
    for (int i = 0; i < cantidadPycks; i++) {
      System.out.println("Entro al for i " + i);

      rowPicks = worksheet.getRow(startRow + i - 1);

      estadoPyck = rowPicks.getCell(convert('f')).getStringCellValue();

      System.out.println(
          "iteracion = " + i + "  es " + estadoPyck + "   startrow+i " + (startRow + i));
      // Si el registro está por Definir
      if (estadoPyck.equals("PDF")) {

        resultBuscado = rowPicks.getCell(convert('e')).getStringCellValue();
        stake = ((Double) rowPicks.getCell(convert('c')).getNumericCellValue()).intValue();
        gameOP = rowPicks.getCell(convert('i')).getStringCellValue();
        country = rowPicks.getCell(convert('h')).getStringCellValue();
        liga = rowPicks.getCell(convert('k')).getStringCellValue();
        fecha = rowPicks.getCell(convert('g')).getStringCellValue();
        odds = rowPicks.getCell(convert('d')).getNumericCellValue();

        System.out.println(
            "iteracion = "
                + i
                + "  es "
                + estadoPyck
                + "   startrow+i "
                + (startRow + i)
                + "  GAMEOP = "
                + gameOP);

        // Crear un objeto PyckBO equivalente
        bo = new PyckBO();
        parOP = new CurrentPOddsPortal();

        parOP.setEquipos(gameOP);
        parOP.setCountry(country);
        parOP.setLeague(liga);
        parOP.setFecha(fecha);

        resulP = ResultadoPartidoBO.getObjFromAbrev(resultBuscado);

        bo.setAcierto(null);
        bo.setPyck(resulP);
        bo.setStake(stake);
        bo.setPartido(parOP);
        bo.setOdds(odds);

        // Agregarlo a la lista
        pycksPorDefinir.add(bo);
        Integer aux = startRow + i - 1;
        mapPycksPorDefinir.put(bo, aux);

        System.out.println("Se inserto en el map en aux = " + aux);
        System.out.println("Se inserto en el map con bo = " + bo.toString());
      }
    }

    try {
      fileInputStream.close();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    // Devolver la lista
    return pycksPorDefinir;
  }