Example #1
0
  public ValoresAtualizaJob retornaNovosValores(Connection conn, JobLote job) throws SQLException {

    PreparedStatement stmt = null;
    ResultSet rs = null;
    ValoresAtualizaJob obj = null;

    String sql =
        " select sum(qtd_transf) qtd_transf, sum(qtd_sucata) qtd_sucata, sum(hr_tot) hr_tot from joblote\n"
            + " where job = ? and operacao = ? ";

    stmt = conn.prepareStatement(sql);
    stmt.setString(1, job.getJob().trim().replace(".", ""));
    stmt.setInt(2, job.getOperNum());
    rs = stmt.executeQuery();

    if (rs.next()) {

      obj = new ValoresAtualizaJob();
      obj.setQtdTransf(rs.getDouble("qtd_transf"));
      obj.setQtdSucata(rs.getDouble("qtd_sucata"));
      obj.setHoraTotal(rs.getDouble("hr_tot"));
    }

    return obj;
  }
Example #2
0
  public JobProtheus retornaJob(Connection conn, JobLote lote) throws SQLException {

    ResultSet rs = null;
    PreparedStatement stmt = null;
    JobProtheus job = null;

    String sql = "select job , B1_DESC,  operacao , produto,  ";
    sql += " dt_release, job_start_date , qtd_release, setor, qtd_transf ";
    sql += " from job left join  " + DB_PROTHEUS.trim() + ".dbo.SB1000 SB1 ";
    sql += " on(produto collate SQL_Latin1_General_CP1_CI_AS = B1_COD) ";
    sql += " where job = ? and operacao = ? and SB1.D_E_L_E_T_ = '' ";
    sql += " order by dt_release, produto ";

    stmt = conn.prepareStatement(sql);
    stmt.setString(1, lote.getJob().trim());
    stmt.setInt(2, lote.getOperNum());
    rs = stmt.executeQuery();

    while (rs.next()) {

      String nJob = rs.getString("job");
      int operacao = rs.getInt("operacao");
      String produto = rs.getString("produto");
      Date dataEmissao = rs.getDate("dt_release");
      Date dataPrevisaoInicio = rs.getDate("job_start_date");
      String descricaoProduto = rs.getString("B1_DESC");
      double quantidade = rs.getDouble("qtd_release");
      String wc = rs.getString("setor");

      String emissao = dataEmissao != null ? getDateToString(dataEmissao) : "";
      String previsaoInicio = dataPrevisaoInicio != null ? getDateToString(dataPrevisaoInicio) : "";

      job = new JobProtheus();

      job.setStatus("");
      job.setJob(nJob);
      job.setOperacao(operacao);
      job.setProduto(produto.trim());
      job.setDataEmissao(emissao);
      job.setQuantidadeLiberada(quantidade);
      job.setDescricaoProduto(descricaoProduto);
      job.setCentroTrabalho(wc);

      double qtdTotal = retornaQtdTotal(conn, job); // calcula o total transferido para o job
      job.setQuantidadeCompleta(qtdTotal);
      job.setDataPrivisaoInicio(previsaoInicio);
      job.setQuantidadeFaltando(quantidade - qtdTotal); // seta o valor qtd faltando
    }

    return job; // retorna lista de jobs
  }
Example #3
0
  public boolean verificaSeSetorTemLinhaTempo(Connection conn, String setor) throws SQLException {

    PreparedStatement stmt = null;
    ResultSet rs = null;
    String sql = "select linha_tempo from setor where setor = ? and linha_tempo = ? ";

    stmt = conn.prepareStatement(sql);
    stmt.setString(1, setor.trim());
    stmt.setBoolean(2, true);
    rs = stmt.executeQuery();

    if (rs.next()) {
      return true;
    } else {
      return false;
    }
  }
Example #4
0
  public JobIniciado retornaUltimoLote(Connection conn, String job, int operacao)
      throws SQLException {

    String sql =
        " select job, operacao, tripulacao,recurso, max(data_fim) \n"
            + "from joblote where job = ? and operacao = ? \n"
            + "group by job, operacao, tripulacao, recurso ";

    PreparedStatement stmt = null;
    ResultSet rs = null;
    JobIniciado iniciado = null;

    stmt = conn.prepareStatement(sql);
    stmt.setString(1, job.trim().replace(".", ""));
    stmt.setInt(2, operacao);
    rs = stmt.executeQuery();

    if (rs.next()) {

      iniciado = new JobIniciado();
      iniciado.setJob(rs.getString(1));
      iniciado.setOperacao(rs.getInt(2));
      iniciado.setTripulacao(rs.getDouble(3));
      iniciado.setRecurso(rs.getString(4));
      Timestamp data = rs.getTimestamp(5);
      iniciado.setData(Validacoes.getDataHoraString(data));
    }

    return iniciado;
  }
Example #5
0
  public boolean verificarSeJobEstaTabelaIniciado(Connection conn, String job, int operacao)
      throws SQLException {

    PreparedStatement stmt = null;
    ResultSet rs = null;
    String update = "select ativo from jobsiniciados where job = ? and operacao = ?";

    stmt = conn.prepareStatement(update);
    stmt.setString(1, job.trim().replace(".", ""));
    stmt.setInt(2, operacao);
    rs = stmt.executeQuery();

    if (rs.next()) {
      return true;
    }

    return false;
  }
Example #6
0
  public static int retornaQtdTotal(Connection conn, JobProtheus job) throws SQLException {

    PreparedStatement stmt = null;
    ResultSet rs = null;
    int qtdTotal = 0;
    int qtdSucata = 0;

    String sqlVerQtd =
        "select job, sum(qtd_transf), sum(hr_tot), sum(qtd_sucata) from jobLote where job = ? and operacao = ? group by job";
    stmt = conn.prepareStatement(sqlVerQtd);
    stmt.setString(1, job.getJob().trim());
    stmt.setInt(2, job.getOperacao());
    rs = stmt.executeQuery();

    String qtdJob = "";
    double totHora = 0;

    while (rs.next()) {
      qtdJob = rs.getString(1); // numero job
      qtdTotal = rs.getInt(2); // quantidade total
      totHora = rs.getInt(3); // hora total em minutos
      qtdSucata = rs.getInt(4);
    }

    return qtdTotal + qtdSucata;
  }