Пример #1
0
  @Override
  public void load(DocumentHTML document, HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    UsuarioDTO usuario = WebUtil.getUsuario(request);
    if (usuario == null) {
      document.alert(UtilI18N.internacionaliza(request, "citcorpore.comum.sessaoExpirada"));
      document.executeScript(
          "window.location = '"
              + Constantes.getValue("SERVER_ADDRESS")
              + request.getContextPath()
              + "'");
      return;
    }
    HTMLForm form = document.getForm("form");
    form.clear();
    SolicitacaoServicoDTO solicitacaoServicoDto = (SolicitacaoServicoDTO) document.getBean();
    SolicitacaoServicoService solicitacaoServicoService =
        (SolicitacaoServicoService)
            ServiceLocator.getInstance()
                .getService(SolicitacaoServicoService.class, WebUtil.getUsuarioSistema(request));
    CalendarioService calendarioService =
        (CalendarioService) ServiceLocator.getInstance().getService(CalendarioService.class, null);
    JustificativaSolicitacaoService justificativaService =
        (JustificativaSolicitacaoService)
            ServiceLocator.getInstance().getService(JustificativaSolicitacaoService.class, null);
    solicitacaoServicoDto =
        solicitacaoServicoService.restoreAll(solicitacaoServicoDto.getIdSolicitacaoServico());
    request.setAttribute("dataHoraSolicitacao", solicitacaoServicoDto.getDataHoraSolicitacaoStr());

    HTMLSelect slaACombinar = (HTMLSelect) document.getSelectById("slaACombinar");
    slaACombinar.addOption(
        "S", "-- " + UtilI18N.internacionaliza(request, "citcorpore.comum.acombinar") + " --");
    slaACombinar.addOption(
        "N", UtilI18N.internacionaliza(request, "citcorpore.comum.definirtempo"));

    Collection colJustificativas = justificativaService.listAtivasParaSuspensao();
    document.getSelectById("idJustificativa").removeAllOptions();
    document
        .getSelectById("idJustificativa")
        .addOption("", UtilI18N.internacionaliza(request, "citcorpore.comum.selecione"));
    if (colJustificativas != null) {
      document
          .getSelectById("idJustificativa")
          .addOptions(colJustificativas, "idJustificativa", "descricaoJustificativa", null);
    }

    Collection colCalendarios = calendarioService.list();
    document.getSelectById("idCalendario").removeAllOptions();
    document
        .getSelectById("idCalendario")
        .addOption("", UtilI18N.internacionaliza(request, "citcorpore.comum.selecione"));
    if (colCalendarios != null) {
      document
          .getSelectById("idCalendario")
          .addOptions(colCalendarios, "idCalendario", "descricao", null);
    }
    form.setValues(solicitacaoServicoDto);
    document.executeScript("verificaMudarTipoSLA()");
  }
Пример #2
0
  /**
   * Salva a Mudança de SLA da Solicitação.
   *
   * @param document
   * @param request
   * @param response
   * @throws Exception
   * @author valdoilo.damasceno Data: 25/10/2013 - Horário: 16:03. Chamada
   *     parent.pesquisarItensFiltro()
   */
  public void save(DocumentHTML document, HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    UsuarioDTO usuario = WebUtil.getUsuario(request);
    if (usuario == null) {
      document.alert(UtilI18N.internacionaliza(request, "citcorpore.comum.sessaoExpirada"));
      document.executeScript(
          "window.location = '"
              + Constantes.getValue("SERVER_ADDRESS")
              + request.getContextPath()
              + "'");
      return;
    }

    SolicitacaoServicoDTO solicitacaoServicoDto = (SolicitacaoServicoDTO) document.getBean();
    SolicitacaoServicoService solicitacaoServicoService =
        (SolicitacaoServicoService)
            ServiceLocator.getInstance()
                .getService(SolicitacaoServicoService.class, WebUtil.getUsuarioSistema(request));
    SolicitacaoServicoDTO solicitacaoServicoAux =
        solicitacaoServicoService.restoreAll(solicitacaoServicoDto.getIdSolicitacaoServico());
    solicitacaoServicoDto.setIdSolicitante(solicitacaoServicoAux.getIdSolicitante());
    solicitacaoServicoDto.setDataInicio(solicitacaoServicoAux.getDataInicio());
    solicitacaoServicoDto.setDataHoraSolicitacao(solicitacaoServicoAux.getDataHoraSolicitacao());
    solicitacaoServicoDto.setUsuarioDto(usuario);
    solicitacaoServicoDto.setRegistradoPor(usuario.getNomeUsuario());
    solicitacaoServicoDto.setHouveMudanca("S");
    solicitacaoServicoDto.setSituacao(solicitacaoServicoAux.getSituacao());
    solicitacaoServicoDto.setPrazohhAnterior(solicitacaoServicoAux.getPrazoHH());
    solicitacaoServicoDto.setPrazommAnterior(solicitacaoServicoAux.getPrazoMM());
    solicitacaoServicoDto.setTempoDecorridoHH(solicitacaoServicoAux.getTempoDecorridoHH());
    solicitacaoServicoDto.setTempoDecorridoMM(solicitacaoServicoAux.getTempoDecorridoMM());

    if (solicitacaoServicoDto.getSlaACombinar().equalsIgnoreCase("S")) {
      solicitacaoServicoDto.setPrazoCapturaHH(0);
      solicitacaoServicoDto.setPrazoCapturaMM(0);
      solicitacaoServicoDto.setPrazoHH(0);
      solicitacaoServicoDto.setPrazoMM(0);
    }
    solicitacaoServicoService.updateSLA(solicitacaoServicoDto);

    document.executeScript("parent.refreshTelaGerenciamento();");
  }
  public static void receberEmailImap() throws Exception {
    ArrayList<Item> results = null;
    EmailMessage email = null;

    ClienteEmailCentralServicoDao clienteEmailCentralServicoDao =
        new ClienteEmailCentralServicoDao();
    results = clienteEmailCentralServicoDao.getMails();

    System.out.println("IMAP... LENDO EMAILS");
    System.out.println();

    try {
      for (Item item : results) {
        ItemId itemId = item.getId();
        email = EmailMessage.bind(item.getService(), itemId);

        String texto = email.getBody().toString();
        Source source = new Source(email.getBody().toString());
        String textoFormatado = source.getTextExtractor().toString();
        System.out.println("Mensagem : \n" + texto + " \nFIM da Mensagem ------------");
        DateFormat dateFormat = DateFormat.getTimeInstance();
        Locale br = new Locale("pt", "BR");
        SimpleDateFormat formatarHora = new SimpleDateFormat("hh:mm", br);
        String solicitacao = email.getSubject();
        String corpoEmail = email.getBody().toString(); //

        boolean encontrar = solicitacao.matches(".*Solicitação.*");
        if (encontrar) {
          encontrar = solicitacao.matches(".*[0-9].*");
          if (encontrar) {
            solicitacao = solicitacao.replaceAll("[^0-9]", "");

            SolicitacaoServicoService solicitacaoServicoService =
                (SolicitacaoServicoService)
                    ServiceLocator.getInstance().getService(SolicitacaoServicoService.class, null);
            SolicitacaoServicoDTO solicitacaoDto = new SolicitacaoServicoDTO();
            solicitacaoDto.setIdSolicitacaoServico(Integer.parseInt(solicitacao));

            boolean existeSolicitacao =
                solicitacaoServicoService.existeSolicitacaoServico(solicitacaoDto);
            if (existeSolicitacao) {
              OcorrenciaSolicitacaoDTO ocorrenciaDto = new OcorrenciaSolicitacaoDTO();
              OcorrenciaSolicitacaoService ocorrenciaService =
                  (OcorrenciaSolicitacaoService)
                      ServiceLocator.getInstance()
                          .getService(OcorrenciaSolicitacaoService.class, null);
              ocorrenciaDto.setIdSolicitacaoServico(Integer.parseInt(solicitacao));

              Calendar calendar = Calendar.getInstance();
              int hora = calendar.get(Calendar.HOUR_OF_DAY);
              int minuto = calendar.get(Calendar.MINUTE);
              ocorrenciaDto.setDataregistro(UtilDatas.getSqlDate(new java.util.Date()));
              ocorrenciaDto.setHoraregistro(hora + ":" + minuto);
              ocorrenciaDto.setRegistradopor("Email - Automatico");
              ocorrenciaDto.setDescricao(email.getSubject());
              ocorrenciaDto.setOcorrencia(texto);
              ocorrenciaService.create(ocorrenciaDto);
            }
          }
        }
        email.setIsRead(true);
        email.update(ConflictResolutionMode.AlwaysOverwrite);
      }
    } catch (EWSHttpException ex) {
      System.out.println("Teste");
    }

    System.out.println("LEITURA CONCLUIDA");
    System.out.println();

    try {

    } catch (Exception e) {
      e.printStackTrace();
    }
  }