Exemplo n.º 1
0
  public void adicionaOPTelaInicial(Connection conn, JobProtheus jobProtheus, JobLote job)
      throws SQLException {

    if (jobProtheus != null) {

      //  antes de adicionar o job na tela de consultas jobs, verifica
      //  se ja existe, se ja existir remove e adiciona novamente
      int total = modeloConsultaJobs.getRowCount() - 1;
      for (int j = total; j >= 0; j--) {
        JobProtheus jobAtual = modeloConsultaJobs.getJob(j);

        if (jobAtual.getJob().trim().equals(job.getJob().trim())
            && jobAtual.getOperacao() == job.getOperNum()) {
          modeloConsultaJobs.removeJob(j);
        }
      }

      boolean temLinhaTempo =
          verificaSeSetorTemLinhaTempo(conn, jobProtheus.getCentroTrabalho().trim());
      if (temLinhaTempo) {
        if (jobProtheus.getQuantidadeCompleta() == 0) {
          desativaIniciado(
              conn, jobProtheus.getJob().trim().replace(".", ""), jobProtheus.getOperacao());
        } else {

          boolean iniciadoJaExiste =
              verificarSeJobEstaTabelaIniciado(
                  conn, jobProtheus.getJob().trim().replace(".", ""), jobProtheus.getOperacao());

          JobIniciado jobIniciado =
              retornaUltimoLote(
                  conn, jobProtheus.getJob().trim().replace(".", ""), jobProtheus.getOperacao());
          if (!iniciadoJaExiste) {
            incluiIniciado(conn, jobIniciado);
          } else {
            // fazer update jobsiniciados alterando os valores pelo lote mais atual
            alteraIniciado(conn, jobIniciado);
          }
        }
      }

      jLTotalAtrasados.setText(Principal.retornaTotalJobsAtrasados(modeloConsultaJobs));

    } else {

      JOptionPane.showMessageDialog(null, "Job não encontrado na SC2010: " + job);
    }
  }
Exemplo n.º 2
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;
  }