コード例 #1
0
 public static void start() {
   List<File> arquivosLog = MetodosComuns.buscaArquivosLog();
   File buscaListaCarregamentos = MetodosComuns.buscaListaCarregamentos();
   List<String> registrosLidos = MetodosComuns.lerArquivoTxt(buscaListaCarregamentos);
   BuscaManutencoes.realizaCruzamentoDeDados(arquivosLog, registrosLidos);
   jProgressBar.setString("PARADO");
   jProgressBar.setValue(0);
 }
コード例 #2
0
  /**
   * Cruzamento de dados
   *
   * @param arquivosLog
   */
  public static void realizaCruzamentoDeDados(List<File> arquivosLog, List<String> registrosLidos) {

    jProgressBar.setMaximum(arquivosLog.size() + 1);
    String carregamentos = "";
    int n = 0;
    for (File file : arquivosLog) {
      jProgressBar.setValue(++n);
      jProgressBar.setString("PROCESSANDO ARQUIVO:" + file.getName().toUpperCase());
      jProgressBar.repaint();
      if (!file.getName().contains(".err")
          && !file.getName().contains("-painel.log")
          && !file.getName().contains("performance-cte.log")) {

        // Se for do tipo .gz descompacta
        while (file.getName().contains(".gz")) {
          jProgressBar.setString("DESCOMPACTANDO ARQUIVO:" + file.getName().toUpperCase());
          file = MetodosComuns.descompactarArquivos(file.getAbsolutePath());
          jProgressBar.setString("PROCESSANDO ARQUIVO:" + file.getName().toUpperCase());
        }

        try {
          // instancia do arquivo que vou ler
          FileReader reader = new FileReader(file);
          BufferedReader leitor = new BufferedReader(reader);
          String linhaLida = null;
          while ((linhaLida = leitor.readLine()) != null) {
            for (String string : registrosLidos) {
              String[] serie_numero = string.split("-");
              // Se encontrar nestas condições printa o XML
              if (
              /*linhaLida.contains("OperationType>2")
              && */ linhaLida.contains("LoadingSeries>" + serie_numero[0] + "</")
                  && linhaLida.contains("LoadingNumber>" + serie_numero[1].trim() + "</")
                  && !carregamentos.contains(string)) {
                carregamentos += string + ";";
                System.out.println("[" + string + "]" + linhaLida);
                System.out.println("[" + string + "]" + file.getAbsolutePath());
              }
            }
          }

          leitor.close();
          reader.close();

        } catch (Exception e) {
          System.out.println(e.getMessage());
        }
      }
    }
  }