Commit 65e6b8f8ad40e93ee0c0d35010dc7fe93d0b0c25

Authored by Rafael Viva
1 parent 3c2a12a8
Exists in master and in 1 other branch desenv

teste

dto/MdWsSeiAssuntoDTO.php 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +<?php
  2 +
  3 +/**
  4 + * Class MdWsSeiTipoProcedimentoDTO
  5 + * DTO somente para encapsulamento de dados.
  6 + * OBS: Nao estou usando API pois em modulos do SEI o autoload nao carrega as API's.
  7 + */
  8 +class MdWsSeiAssuntoDTO extends InfraDTO{
  9 +
  10 + public function getStrNomeTabela()
  11 + {
  12 + throw new InfraException('DTO nao utilizavel para consulta!');
  13 + }
  14 +
  15 + public function montar(){
  16 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'IdAssunto');
  17 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Filter');
  18 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'Start');
  19 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'Limit');
  20 + }
  21 +
  22 +}
  23 +
... ...
dto/MdWsSeiAtividadeDTO.php 0 → 100644
... ... @@ -0,0 +1,22 @@
  1 +<?
  2 +
  3 +class MdWsSeiAtividadeDTO extends AtividadeDTO{
  4 +
  5 + public function montar(){
  6 + parent::montar();
  7 +
  8 + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_STR,
  9 + 'ProtocoloFormatadoPesquisaProtocolo',
  10 + 'protocolo_formatado_pesquisa',
  11 + 'protocolo');
  12 +
  13 + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_NUM,
  14 + 'IdGrupoAcompanhamentoProcedimento',
  15 + 'id_grupo_acompanhamento',
  16 + 'acompanhamento');
  17 +
  18 +
  19 + $this->configurarFK('IdProtocolo', 'acompanhamento', 'id_protocolo');
  20 + }
  21 +
  22 +}
... ...
dto/MdWsSeiContatoDTO.php 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +<?php
  2 +
  3 +/**
  4 + * Class MdWsSeiTipoProcedimentoDTO
  5 + * DTO somente para encapsulamento de dados.
  6 + * OBS: Nao estou usando API pois em modulos do SEI o autoload nao carrega as API's.
  7 + */
  8 +class MdWsSeiContatoDTO extends InfraDTO{
  9 +
  10 + public function getStrNomeTabela()
  11 + {
  12 + throw new InfraException('DTO nao utilizavel para consulta!');
  13 + }
  14 +
  15 + public function montar(){
  16 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'IdContato');
  17 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Nome');
  18 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Filter');
  19 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'Start');
  20 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'Limit');
  21 + }
  22 +
  23 +}
  24 +
... ...
dto/MdWsSeiDocumentoDTO.php 0 → 100644
... ... @@ -0,0 +1,44 @@
  1 +<?php
  2 +
  3 +/**
  4 + * Class MdWsSeiDocumentoDTO
  5 + * DTO somente para encapsulamento de dados.
  6 + * OBS: Nao estou usando API pois em modulos do SEI o autoload nao carrega as API's.
  7 + */
  8 +class MdWsSeiDocumentoDTO extends InfraDTO{
  9 +
  10 + public function getStrNomeTabela()
  11 + {
  12 + throw new InfraException('DTO nao utilizavel para consulta!');
  13 + }
  14 +
  15 +
  16 +
  17 +
  18 +
  19 + public function montar(){
  20 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'IdProcesso');
  21 + $this->adicionarAtributo(InfraDTO::$PREFIXO_DTA, 'DataGeracaoDocumento');
  22 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Numero');
  23 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'IdTipoDocumento');
  24 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Descricao');
  25 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'NomeArquivo');
  26 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'NivelAcesso');
  27 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'IdHipoteseLegal');
  28 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'GrauSigilo');
  29 + $this->adicionarAtributo(InfraDTO::$PREFIXO_ARR, 'Assuntos');
  30 + $this->adicionarAtributo(InfraDTO::$PREFIXO_ARR, 'Interessados');
  31 + $this->adicionarAtributo(InfraDTO::$PREFIXO_ARR, 'Destinatarios');
  32 + $this->adicionarAtributo(InfraDTO::$PREFIXO_ARR, 'Remetentes');
  33 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'ConteudoDocumento');
  34 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Observacao');
  35 +
  36 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'NomeTipoDocumento');
  37 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Favoritos');
  38 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Aplicabilidade');
  39 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'Start');
  40 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'Limit');
  41 + }
  42 +
  43 +}
  44 +
... ...
dto/MdWsSeiHipoteseLegalDTO.php 0 → 100644
... ... @@ -0,0 +1,25 @@
  1 +<?php
  2 +
  3 +/**
  4 + * Class MdWsSeiHipoteseLegalDTO
  5 + * DTO somente para encapsulamento de dados.
  6 + * OBS: Nao estou usando API pois em modulos do SEI o autoload nao carrega as API's.
  7 + */
  8 +class MdWsSeiHipoteseLegalDTO extends InfraDTO{
  9 +
  10 + public function getStrNomeTabela()
  11 + {
  12 + throw new InfraException('DTO nao utilizavel para consulta!');
  13 + }
  14 +
  15 + public function montar(){
  16 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'IdHipoteseLegal');
  17 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Nome');
  18 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Filter');
  19 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'NivelAcesso');
  20 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'Start');
  21 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'Limit');
  22 + }
  23 +
  24 +}
  25 +
... ...
dto/MdWsSeiPesquisaProtocoloSolrDTO.php 0 → 100644
... ... @@ -0,0 +1,25 @@
  1 +<?
  2 +
  3 +class MdWsSeiPesquisaProtocoloSolrDTO extends InfraDTO{
  4 +
  5 + public function getStrNomeTabela() {
  6 + return null;
  7 + }
  8 +
  9 + public function montar() {
  10 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'PalavrasChave');
  11 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Descricao');
  12 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Observacao');
  13 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'ProtocoloPesquisa');
  14 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'IdTipoProcedimento');
  15 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'IdSerie');
  16 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Numero');
  17 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'StaTipoData');
  18 + $this->adicionarAtributo(InfraDTO::$PREFIXO_DTA, 'Inicio');
  19 + $this->adicionarAtributo(InfraDTO::$PREFIXO_DTA, 'Fim');
  20 + $this->adicionarAtributo(InfraDTO::$PREFIXO_DBL, 'IdProcedimento');
  21 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'IdGrupoAcompanhamentoProcedimento');
  22 + }
  23 +}
  24 +
  25 +?>
0 26 \ No newline at end of file
... ...
dto/MdWsSeiPesquisarPendenciaDTO.php 0 → 100644
... ... @@ -0,0 +1,22 @@
  1 +<?
  2 +
  3 +class MdWsSeiPesquisarPendenciaDTO extends PesquisaPendenciaDTO{
  4 +
  5 + public function montar(){
  6 + parent::montar();
  7 +
  8 + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_STR,
  9 + 'ProtocoloFormatadoPesquisaProtocolo',
  10 + 'protocolo_formatado_pesquisa',
  11 + 'protocolo');
  12 +
  13 + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_NUM,
  14 + 'IdGrupoAcompanhamentoProcedimento',
  15 + 'id_grupo_acompanhamento',
  16 + 'acompanhamento');
  17 +
  18 +
  19 + $this->configurarFK('IdProtocolo', 'acompanhamento', 'id_protocolo');
  20 + }
  21 +
  22 +}
... ...
dto/MdWsSeiProcedimentoDTO.php 0 → 100644
... ... @@ -0,0 +1,31 @@
  1 +<?php
  2 +
  3 +/**
  4 + * Class MdWsSeiProcedimentoDTO
  5 + * DTO somente para encapsulamento de dados.
  6 + * OBS: Nao estou usando API pois em modulos do SEI o autoload nao carrega as API's.
  7 + */
  8 +class MdWsSeiProcedimentoDTO extends InfraDTO{
  9 +
  10 + public function getStrNomeTabela()
  11 + {
  12 + throw new InfraException('DTO nao utilizavel para consulta!');
  13 + }
  14 +
  15 + public function montar(){
  16 +
  17 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'IdProcedimento');
  18 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'IdTipoProcedimento');
  19 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Especificacao');
  20 + $this->adicionarAtributo(InfraDTO::$PREFIXO_ARR, 'ObjAssunto');
  21 + $this->adicionarAtributo(InfraDTO::$PREFIXO_ARR, 'ObjInteressado');
  22 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Observacao');
  23 + // 0 publico
  24 + // 1 restrito
  25 + // 2 sigiloso
  26 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'NivelAcesso');
  27 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'IdHipoteseLegal');
  28 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'StaGrauSigilo');
  29 + }
  30 +
  31 +}
... ...
dto/MdWsSeiProcessoDTO.php 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +<?
  2 +
  3 +/**
  4 + * Class MdWsSeiProcessoDTO
  5 + * DTO somente para encapsulamento de dados.
  6 + * OBS: Nao estou usando API pois em modulos do SEI o autoload nao carrega as API's.
  7 + */
  8 +class MdWsSeiProcessoDTO extends InfraDTO{
  9 +
  10 + public function getStrNomeTabela()
  11 + {
  12 + throw new InfraException('DTO nao utilizavel para consulta!');
  13 + }
  14 +
  15 + public function montar(){
  16 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Template');
  17 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'IdAtividade');
  18 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Valor');
  19 + }
  20 +
  21 +}
... ...
dto/MdWsSeiProtocoloDTO.php 0 → 100644
... ... @@ -0,0 +1,53 @@
  1 +<?
  2 +
  3 +class MdWsSeiProtocoloDTO extends ProtocoloDTO{
  4 + CONST SIN_TIPO_BUSCA_R = 'R';
  5 + CONST SIN_TIPO_BUSCA_G = 'G';
  6 +
  7 + public function montar(){
  8 + parent::montar();
  9 +
  10 + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_NUM,
  11 + 'IdGrupoAcompanhamentoProcedimento',
  12 + 'id_grupo_acompanhamento',
  13 + 'acompanhamento');
  14 +
  15 +
  16 + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_NUM,
  17 + 'IdUsuarioGeradorAcompanhamento',
  18 + 'id_usuario_gerador',
  19 + 'acompanhamento');
  20 +
  21 + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_DTH,
  22 + 'GeracaoAcompanhamento',
  23 + 'dth_geracao',
  24 + 'acompanhamento');
  25 +
  26 + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_NUM,
  27 + 'IdUsuarioAtribuicaoAtividade',
  28 + 'id_usuario_atribuicao',
  29 + 'atividade');
  30 +
  31 + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_STR,
  32 + 'SinCienciaProcedimento',
  33 + 'p2.sin_ciencia',
  34 + 'procedimento p2');
  35 +
  36 + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_DTH,
  37 + 'AberturaAtividade',
  38 + 'dth_abertura',
  39 + 'atividade');
  40 +
  41 + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_NUM,
  42 + 'IdUnidadeAtividade',
  43 + 'id_unidade',
  44 + 'atividade');
  45 +
  46 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'SinTipoBusca');
  47 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'SinApenasMeus');
  48 +
  49 + $this->configurarFK('IdProtocolo', 'procedimento p2', 'p2.id_procedimento', InfraDTO::$TIPO_FK_OBRIGATORIA);
  50 + $this->configurarFK('IdProtocolo', 'acompanhamento', 'id_protocolo');
  51 + }
  52 +
  53 +}
... ...
dto/MdWsSeiRetornoProgramadoDTO.php 0 → 100644
... ... @@ -0,0 +1,19 @@
  1 +<?
  2 +
  3 +class MdWsSeiRetornoProgramadoDTO extends RetornoProgramadoDTO{
  4 +
  5 + public function montar(){
  6 + parent::montar();
  7 +
  8 + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_DBL,
  9 + 'IdProtocolo',
  10 + 'e.id_protocolo',
  11 + 'atividade e');
  12 +
  13 + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_DTH,
  14 + 'Conclusao',
  15 + 'e.dth_conclusao',
  16 + 'atividade e');
  17 + }
  18 +
  19 +}
... ...
dto/MdWsSeiTipoProcedimentoDTO.php 0 → 100644
... ... @@ -0,0 +1,25 @@
  1 +<?php
  2 +
  3 +/**
  4 + * Class MdWsSeiTipoProcedimentoDTO
  5 + * DTO somente para encapsulamento de dados.
  6 + * OBS: Nao estou usando API pois em modulos do SEI o autoload nao carrega as API's.
  7 + */
  8 +class MdWsSeiTipoProcedimentoDTO extends InfraDTO{
  9 +
  10 + public function getStrNomeTabela()
  11 + {
  12 + throw new InfraException('DTO nao utilizavel para consulta!');
  13 + }
  14 +
  15 + public function montar(){
  16 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'IdTipoProcedimento');
  17 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Nome');
  18 +// $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'SinInterno');
  19 + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Favoritos');
  20 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'Start');
  21 + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'Limit');
  22 + }
  23 +
  24 +}
  25 +
... ...
rn/MdWsSeiAcompanhamentoRN.php 0 → 100644
... ... @@ -0,0 +1,50 @@
  1 +<?
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiAcompanhamentoRN extends InfraRN {
  5 +
  6 + protected function inicializarObjInfraIBanco(){
  7 + return BancoSEI::getInstance();
  8 + }
  9 +
  10 + public function encapsulaAcompanhamento(array $post){
  11 + $acompanhamentoDTO = new AcompanhamentoDTO();
  12 +
  13 + if (isset($post['protocolo'])){
  14 + $acompanhamentoDTO->setDblIdProtocolo($post['protocolo']);
  15 + }
  16 + if (isset($post['unidade'])){
  17 + $acompanhamentoDTO->setNumIdUnidade($post['unidade']);
  18 + }else{
  19 + $acompanhamentoDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual());
  20 + }
  21 +
  22 + if (isset($post['grupo'])){
  23 + $acompanhamentoDTO->setNumIdGrupoAcompanhamento($post['grupo']);
  24 + }
  25 + if (isset($post['usuario'])){
  26 + $acompanhamentoDTO->setNumIdUsuarioGerador($post['usuario']);
  27 + }else{
  28 + $acompanhamentoDTO->setNumIdUsuarioGerador(SessaoSEI::getInstance()->getNumIdUsuario());
  29 + }
  30 + if (isset($post['observacao'])){
  31 + $acompanhamentoDTO->setStrObservacao($post['observacao']);
  32 + }
  33 + $acompanhamentoDTO->setDthGeracao(InfraData::getStrDataHoraAtual());
  34 + $acompanhamentoDTO->setNumTipoVisualizacao(AtividadeRN::$TV_VISUALIZADO);
  35 + $acompanhamentoDTO->setNumIdAcompanhamento(null);
  36 +
  37 + return $acompanhamentoDTO;
  38 +
  39 + }
  40 +
  41 + protected function cadastrarAcompanhamentoControlado(AcompanhamentoDTO $acompanhamentoDTO){
  42 + try{
  43 + $acompanhamentoRN = new AcompanhamentoRN();
  44 + $acompanhamentoRN->cadastrar($acompanhamentoDTO);
  45 + return MdWsSeiRest::formataRetornoSucessoREST('Acompanhamento realizado com sucesso!');
  46 + }catch (Exception $e){
  47 + return MdWsSeiRest::formataRetornoErroREST($e);
  48 + }
  49 + }
  50 +}
0 51 \ No newline at end of file
... ...
rn/MdWsSeiAnotacaoRN.php 0 → 100644
... ... @@ -0,0 +1,54 @@
  1 +<?
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiAnotacaoRN extends InfraRN {
  5 +
  6 + protected function inicializarObjInfraIBanco(){
  7 + return BancoSEI::getInstance();
  8 + }
  9 +
  10 + public function encapsulaAnotacao(array $post){
  11 + $anotacaoDTO = new AnotacaoDTO();
  12 + if (isset($post['descricao'])) {
  13 + $anotacaoDTO->setStrDescricao($post['descricao']);
  14 + }
  15 +
  16 + if (isset($post['protocolo'])) {
  17 + $anotacaoDTO->setDblIdProtocolo(array($post['protocolo']));
  18 + }
  19 +
  20 + if (isset($post['unidade'])) {
  21 + $anotacaoDTO->setNumIdUnidade($post['unidade']);
  22 + }
  23 +
  24 + if (isset($post['usuario'])) {
  25 + $anotacaoDTO->setNumIdUsuario($post['usuario']);
  26 + }
  27 +
  28 + $anotacaoDTO->setDthAnotacao(InfraData::getStrDataHoraAtual());
  29 +
  30 + if (isset($post['prioridade']) && in_array($post['prioridade'], array('S', 'N'))) {
  31 + $anotacaoDTO->setStrSinPrioridade($post['prioridade']);
  32 + }else{
  33 + $anotacaoDTO->setStrSinPrioridade('N');
  34 + }
  35 + $anotacaoDTO->setStrStaAnotacao('U');
  36 +
  37 + return $anotacaoDTO;
  38 + }
  39 +
  40 + protected function cadastrarAnotacaoControlado(AnotacaoDTO $anotacaoDTO){
  41 + try{
  42 + $anotacaoRN = new AnotacaoRN();
  43 + if(!$anotacaoDTO->getDblIdProtocolo()){
  44 + throw new InfraException('Protocolo não informado.');
  45 + }
  46 + $anotacaoRN->registrar($anotacaoDTO);
  47 +
  48 + return MdWsSeiRest::formataRetornoSucessoREST('Anotação cadastrada com sucesso!');
  49 + }catch (Exception $e){
  50 + return MdWsSeiRest::formataRetornoErroREST($e);
  51 + }
  52 + }
  53 +
  54 +}
0 55 \ No newline at end of file
... ...
rn/MdWsSeiAssinanteRN.php 0 → 100644
... ... @@ -0,0 +1,53 @@
  1 +<?
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiAssinanteRN extends InfraRN {
  5 +
  6 + protected function inicializarObjInfraIBanco(){
  7 + return BancoSEI::getInstance();
  8 + }
  9 +
  10 + /**
  11 + * Retorna todas as funcoes/cargos cadastrados
  12 + * @param AssinanteDTO $assinanteDTO
  13 + * @return array
  14 + */
  15 + protected function listarAssinanteConectado(AssinanteDTO $assinanteDTOParam){
  16 + try{
  17 + $result = array();
  18 + $assinanteDTOConsulta = new AssinanteDTO();
  19 + if(!$assinanteDTOParam->isSetNumIdUnidade()){
  20 + $assinanteDTOConsulta->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual());
  21 + }else{
  22 + $assinanteDTOConsulta->setNumIdUnidade($assinanteDTOParam->getNumIdUnidade());
  23 + }
  24 + if($assinanteDTOParam->getNumMaxRegistrosRetorno()){
  25 + $assinanteDTOConsulta->setNumMaxRegistrosRetorno($assinanteDTOParam->getNumMaxRegistrosRetorno());
  26 + }else{
  27 + $assinanteDTOConsulta->setNumMaxRegistrosRetorno(10);
  28 + }
  29 + if(!is_null($assinanteDTOParam->getNumPaginaAtual())){
  30 + $assinanteDTOConsulta->setNumPaginaAtual($assinanteDTOParam->getNumPaginaAtual());
  31 + }else{
  32 + $assinanteDTOConsulta->setNumPaginaAtual(0);
  33 + }
  34 + $assinanteDTOConsulta->retNumIdAssinante();
  35 + $assinanteDTOConsulta->retStrCargoFuncao();
  36 + $assinanteDTOConsulta->setOrdStrCargoFuncao(InfraDTO::$TIPO_ORDENACAO_ASC);
  37 + $assinanteRN = new AssinanteRN();
  38 + $ret = $assinanteRN->pesquisar($assinanteDTOConsulta);
  39 + /** @var AssinanteDTO $assinanteDTO */
  40 + foreach($ret as $assinanteDTO){
  41 + $result[] = array(
  42 + 'id' => $assinanteDTO->getNumIdAssinante(),
  43 + 'nome' => $assinanteDTO->getStrCargoFuncao(),
  44 + );
  45 + }
  46 +
  47 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result, $assinanteDTOConsulta->getNumTotalRegistros());
  48 + }catch (Exception $e){
  49 + return MdWsSeiRest::formataRetornoErroREST($e);
  50 + }
  51 + }
  52 +
  53 +}
0 54 \ No newline at end of file
... ...
rn/MdWsSeiAtividadeRN.php 0 → 100644
... ... @@ -0,0 +1,508 @@
  1 +<?
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiAtividadeRN extends AtividadeRN {
  5 +
  6 + protected function inicializarObjInfraIBanco(){
  7 + return BancoSEI::getInstance();
  8 + }
  9 +
  10 + /**
  11 + * Retorna as atividades de um processo
  12 + * @param AtividadeDTO $atividadeDTOParam
  13 + * @return array
  14 + * @throws InfraException
  15 + */
  16 + protected function listarAtividadesProcessoConectado(AtividadeDTO $atividadeDTOParam){
  17 + try{
  18 + $result = array();
  19 + $procedimentoHistoricoDTO = new ProcedimentoHistoricoDTO();
  20 + $procedimentoHistoricoDTO->setStrStaHistorico(ProcedimentoRN::$TH_RESUMIDO);
  21 +
  22 + if(!$atividadeDTOParam->isSetDblIdProtocolo()){
  23 + throw new InfraException('O procedimento deve ser informado!');
  24 + }
  25 + $procedimentoHistoricoDTO->setDblIdProcedimento($atividadeDTOParam->getDblIdProtocolo());
  26 + if(is_null($atividadeDTOParam->getNumPaginaAtual())){
  27 + $procedimentoHistoricoDTO->setNumPaginaAtual(0);
  28 + }else{
  29 + $procedimentoHistoricoDTO->setNumPaginaAtual($atividadeDTOParam->getNumPaginaAtual());
  30 + }
  31 + if($atividadeDTOParam->getNumMaxRegistrosRetorno()){
  32 + $procedimentoHistoricoDTO->setNumMaxRegistrosRetorno($atividadeDTOParam->getNumMaxRegistrosRetorno());
  33 + }else{
  34 + $procedimentoHistoricoDTO->setNumMaxRegistrosRetorno(10);
  35 + }
  36 + $procedimentoRN = new ProcedimentoRN();
  37 + $ret = $procedimentoRN->consultarHistoricoRN1025($procedimentoHistoricoDTO);
  38 +
  39 + /** @var AtividadeDTO $atividadeDTO */
  40 + foreach($ret->getArrObjAtividadeDTO() as $atividadeDTO) {
  41 + $dateTime = explode(' ', $atividadeDTO->getDthAbertura());
  42 + $informacao = null;
  43 + $result[] = [
  44 + "id" => $atividadeDTO->getNumIdAtividade(),
  45 + "atributos" => [
  46 + "idProcesso" => $atividadeDTOParam->getDblIdProtocolo(),
  47 + "usuario" => ($atividadeDTO->getNumIdUsuarioOrigem()) ? $atividadeDTO->getStrSiglaUsuarioOrigem() : null,
  48 + "data" => $dateTime[0],
  49 + "hora" => $dateTime[1],
  50 + "unidade" => $atividadeDTO->getStrSiglaUnidade(),
  51 + "informacao" => strip_tags($atividadeDTO->getStrNomeTarefa())
  52 + ]
  53 + ];
  54 + }
  55 +
  56 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result, $procedimentoHistoricoDTO->getNumTotalRegistros());
  57 + }catch (Exception $e){
  58 + return MdWsSeiRest::formataRetornoErroREST($e);
  59 + }
  60 + }
  61 +
  62 + /**
  63 + * Método que encapsula os dados para o cadastramento do andamento do processo
  64 + * @param array $post
  65 + * @return AtualizarAndamentoDTO
  66 + */
  67 + public function encapsulaLancarAndamentoProcesso(array $data){
  68 + $entradaLancarAndamentoAPI = new EntradaLancarAndamentoAPI();
  69 + $entradaLancarAndamentoAPI->setIdTarefa(TarefaRN::$TI_ATUALIZACAO_ANDAMENTO);
  70 + if($data['protocolo']){
  71 + $entradaLancarAndamentoAPI->setIdProcedimento($data['protocolo']);
  72 + }
  73 +
  74 + if($data['descricao']){
  75 + $atributoAndamentoAPI = new AtributoAndamentoAPI();
  76 + $atributoAndamentoAPI->setNome('DESCRICAO');
  77 + $atributoAndamentoAPI->setValor($data['descricao']);
  78 + $atributoAndamentoAPI->setIdOrigem(null);
  79 + $entradaLancarAndamentoAPI->setAtributos(array($atributoAndamentoAPI));
  80 + }
  81 +
  82 + return $entradaLancarAndamentoAPI;
  83 + }
  84 +
  85 + /**
  86 + * Método que cadastra o andamento manual de um processo
  87 + * @param EntradaLancarAndamentoAPI $entradaLancarAndamentoAPIParam
  88 + * @info usar o método auxiliar encapsulaLancarAndamentoProcesso para faciliar
  89 + * @return array
  90 + */
  91 + protected function lancarAndamentoProcessoControlado(EntradaLancarAndamentoAPI $entradaLancarAndamentoAPIParam){
  92 + try{
  93 + $seiRN = new SeiRN();
  94 + $seiRN->lancarAndamento($entradaLancarAndamentoAPIParam);
  95 +
  96 + return MdWsSeiRest::formataRetornoSucessoREST('Observação cadastrada com sucesso!');
  97 + }catch (Exception $e){
  98 + return MdWsSeiRest::formataRetornoErroREST($e);
  99 + }
  100 + }
  101 +
  102 + /**
  103 + * Método clonado de AtividadeRN::listarPendenciasRN0754Conectado com alterações para pesquisa de processo
  104 + * @param MdWsSeiPesquisarPendenciaDTO $objPesquisaPendenciaDTO
  105 + * @return array
  106 + * @throws InfraException
  107 + */
  108 + protected function listarPendenciasConectado(MdWsSeiPesquisarPendenciaDTO $objPesquisaPendenciaDTO) {
  109 + try {
  110 + if (!$objPesquisaPendenciaDTO->isSetStrStaTipoAtribuicao()) {
  111 + $objPesquisaPendenciaDTO->setStrStaTipoAtribuicao(self::$TA_TODAS);
  112 + }
  113 +
  114 + if (!$objPesquisaPendenciaDTO->isSetNumIdUsuarioAtribuicao()) {
  115 + $objPesquisaPendenciaDTO->setNumIdUsuarioAtribuicao(null);
  116 + }
  117 +
  118 + if (!$objPesquisaPendenciaDTO->isSetStrSinMontandoArvore()) {
  119 + $objPesquisaPendenciaDTO->setStrSinMontandoArvore('N');
  120 + }
  121 +
  122 + if (!$objPesquisaPendenciaDTO->isSetStrSinAnotacoes()) {
  123 + $objPesquisaPendenciaDTO->setStrSinAnotacoes('N');
  124 + }
  125 +
  126 + if (!$objPesquisaPendenciaDTO->isSetStrSinSituacoes()) {
  127 + $objPesquisaPendenciaDTO->setStrSinSituacoes('N');
  128 + }
  129 +
  130 + if (!$objPesquisaPendenciaDTO->isSetStrSinMarcadores()) {
  131 + $objPesquisaPendenciaDTO->setStrSinMarcadores('N');
  132 + }
  133 +
  134 + if (!$objPesquisaPendenciaDTO->isSetStrSinInteressados()) {
  135 + $objPesquisaPendenciaDTO->setStrSinInteressados('N');
  136 + }
  137 +
  138 + if (!$objPesquisaPendenciaDTO->isSetStrSinRetornoProgramado()) {
  139 + $objPesquisaPendenciaDTO->setStrSinRetornoProgramado('N');
  140 + }
  141 +
  142 + if (!$objPesquisaPendenciaDTO->isSetStrSinCredenciais()) {
  143 + $objPesquisaPendenciaDTO->setStrSinCredenciais('N');
  144 + }
  145 +
  146 + if (!$objPesquisaPendenciaDTO->isSetStrSinHoje()) {
  147 + $objPesquisaPendenciaDTO->setStrSinHoje('N');
  148 + }
  149 +
  150 + $objAtividadeDTO = new MdWsSeiAtividadeDTO();
  151 + $objAtividadeDTO->retNumIdAtividade();
  152 + $objAtividadeDTO->retNumIdTarefa();
  153 + $objAtividadeDTO->retNumIdUsuarioAtribuicao();
  154 + $objAtividadeDTO->retNumIdUsuarioVisualizacao();
  155 + $objAtividadeDTO->retNumTipoVisualizacao();
  156 + $objAtividadeDTO->retNumIdUnidade();
  157 + $objAtividadeDTO->retDthConclusao();
  158 + $objAtividadeDTO->retDblIdProtocolo();
  159 + $objAtividadeDTO->retStrSiglaUnidade();
  160 + $objAtividadeDTO->retStrSinInicial();
  161 + $objAtividadeDTO->retNumIdUsuarioAtribuicao();
  162 + $objAtividadeDTO->retStrSiglaUsuarioAtribuicao();
  163 + $objAtividadeDTO->retStrNomeUsuarioAtribuicao();
  164 +
  165 + $objAtividadeDTO->setNumIdUnidade($objPesquisaPendenciaDTO->getNumIdUnidade());
  166 +
  167 + if ($objPesquisaPendenciaDTO->isSetStrProtocoloFormatadoPesquisaProtocolo()) {
  168 + $strProtocoloFormatado = InfraUtil::retirarFormatacao(
  169 + $objPesquisaPendenciaDTO->getStrProtocoloFormatadoPesquisaProtocolo(), false
  170 + );
  171 + $objAtividadeDTO->setStrProtocoloFormatadoPesquisaProtocolo(
  172 + '%'.$strProtocoloFormatado.'%',
  173 + InfraDTO::$OPER_LIKE
  174 + );
  175 + }
  176 + if ($objPesquisaPendenciaDTO->isSetNumIdGrupoAcompanhamentoProcedimento()) {
  177 + $objAtividadeDTO->setNumIdGrupoAcompanhamentoProcedimento($objPesquisaPendenciaDTO->getNumIdGrupoAcompanhamentoProcedimento());
  178 + }
  179 +
  180 + if ($objPesquisaPendenciaDTO->getStrSinHoje() == 'N') {
  181 + $objAtividadeDTO->setDthConclusao(null);
  182 + } else {
  183 + $objAtividadeDTO->adicionarCriterio(array('Conclusao', 'Conclusao'),
  184 + array(InfraDTO::$OPER_IGUAL, InfraDTO::$OPER_MAIOR_IGUAL),
  185 + array(null, InfraData::getStrDataAtual() . ' 00:00:00'),
  186 + array(InfraDTO::$OPER_LOGICO_OR));
  187 + }
  188 +
  189 + $objAtividadeDTO->setStrStaProtocoloProtocolo(ProtocoloRN::$TP_PROCEDIMENTO);
  190 +
  191 + if ($objPesquisaPendenciaDTO->getNumIdUsuario() == null) {
  192 + $objAtividadeDTO->setStrStaNivelAcessoGlobalProtocolo(ProtocoloRN::$NA_SIGILOSO, InfraDTO::$OPER_DIFERENTE);
  193 + } else {
  194 + $objAtividadeDTO->adicionarCriterio(array('StaNivelAcessoGlobalProtocolo', 'IdUsuario'),
  195 + array(InfraDTO::$OPER_DIFERENTE, InfraDTO::$OPER_IGUAL),
  196 + array(ProtocoloRN::$NA_SIGILOSO, $objPesquisaPendenciaDTO->getNumIdUsuario()),
  197 + array(InfraDTO::$OPER_LOGICO_OR));
  198 + }
  199 +
  200 + if ($objPesquisaPendenciaDTO->getStrStaTipoAtribuicao() == self::$TA_MINHAS) {
  201 + $objAtividadeDTO->setNumIdUsuarioAtribuicao($objPesquisaPendenciaDTO->getNumIdUsuario());
  202 + } else if ($objPesquisaPendenciaDTO->getStrStaTipoAtribuicao() == self::$TA_DEFINIDAS) {
  203 + $objAtividadeDTO->setNumIdUsuarioAtribuicao(null, InfraDTO::$OPER_DIFERENTE);
  204 + } else if ($objPesquisaPendenciaDTO->getStrStaTipoAtribuicao() == self::$TA_ESPECIFICAS) {
  205 + $objAtividadeDTO->setNumIdUsuarioAtribuicao($objPesquisaPendenciaDTO->getNumIdUsuarioAtribuicao());
  206 + }
  207 +
  208 + if ($objPesquisaPendenciaDTO->isSetDblIdProtocolo()) {
  209 + if (!is_array($objPesquisaPendenciaDTO->getDblIdProtocolo())) {
  210 + $objAtividadeDTO->setDblIdProtocolo($objPesquisaPendenciaDTO->getDblIdProtocolo());
  211 + } else {
  212 + $objAtividadeDTO->setDblIdProtocolo($objPesquisaPendenciaDTO->getDblIdProtocolo(), InfraDTO::$OPER_IN);
  213 + }
  214 + }
  215 +
  216 + if ($objPesquisaPendenciaDTO->isSetStrStaEstadoProcedimento()) {
  217 + if (is_array($objPesquisaPendenciaDTO->getStrStaEstadoProcedimento())) {
  218 + $objAtividadeDTO->setStrStaEstadoProtocolo($objPesquisaPendenciaDTO->getStrStaEstadoProcedimento(), InfraDTO::$OPER_IN);
  219 + } else {
  220 + $objAtividadeDTO->setStrStaEstadoProtocolo($objPesquisaPendenciaDTO->getStrStaEstadoProcedimento());
  221 + }
  222 + }
  223 +
  224 + if ($objPesquisaPendenciaDTO->isSetStrSinInicial()) {
  225 + $objAtividadeDTO->setStrSinInicial($objPesquisaPendenciaDTO->getStrSinInicial());
  226 + }
  227 +
  228 + if ($objPesquisaPendenciaDTO->isSetNumIdMarcador()) {
  229 + $objAtividadeDTO->setNumTipoFkAndamentoMarcador(InfraDTO::$TIPO_FK_OBRIGATORIA);
  230 + $objAtividadeDTO->setNumIdMarcador($objPesquisaPendenciaDTO->getNumIdMarcador());
  231 + $objAtividadeDTO->setStrSinUltimoAndamentoMarcador('S');
  232 + }
  233 +
  234 + //ordenar pela data de abertura descendente
  235 + //$objAtividadeDTO->setOrdDthAbertura(InfraDTO::$TIPO_ORDENACAO_DESC);
  236 + $objAtividadeDTO->setOrdNumIdAtividade(InfraDTO::$TIPO_ORDENACAO_DESC);
  237 +
  238 +
  239 + //paginação
  240 + $objAtividadeDTO->setNumMaxRegistrosRetorno($objPesquisaPendenciaDTO->getNumMaxRegistrosRetorno());
  241 + $objAtividadeDTO->setNumPaginaAtual($objPesquisaPendenciaDTO->getNumPaginaAtual());
  242 +
  243 + $arrAtividadeDTO = $this->listarRN0036($objAtividadeDTO);
  244 +
  245 + //paginação
  246 + $objPesquisaPendenciaDTO->setNumTotalRegistros($objAtividadeDTO->getNumTotalRegistros());
  247 + $objPesquisaPendenciaDTO->setNumRegistrosPaginaAtual($objAtividadeDTO->getNumRegistrosPaginaAtual());
  248 +
  249 + $arrProcedimentos = array();
  250 +
  251 + //Se encontrou pelo menos um registro
  252 + if (count($arrAtividadeDTO) > 0) {
  253 +
  254 + $objProcedimentoDTO = new ProcedimentoDTO();
  255 +
  256 + $objProcedimentoDTO->retStrDescricaoProtocolo();
  257 +
  258 + $arrProtocolosAtividades = array_unique(InfraArray::converterArrInfraDTO($arrAtividadeDTO, 'IdProtocolo'));
  259 + $objProcedimentoDTO->setDblIdProcedimento($arrProtocolosAtividades, InfraDTO::$OPER_IN);
  260 +
  261 + if ($objPesquisaPendenciaDTO->getStrSinMontandoArvore() == 'S') {
  262 + $objProcedimentoDTO->setStrSinMontandoArvore('S');
  263 + }
  264 +
  265 + if ($objPesquisaPendenciaDTO->getStrSinAnotacoes() == 'S') {
  266 + $objProcedimentoDTO->setStrSinAnotacoes('S');
  267 + }
  268 +
  269 + if ($objPesquisaPendenciaDTO->getStrSinSituacoes() == 'S') {
  270 + $objProcedimentoDTO->setStrSinSituacoes('S');
  271 + }
  272 +
  273 + if ($objPesquisaPendenciaDTO->getStrSinMarcadores() == 'S') {
  274 + $objProcedimentoDTO->setStrSinMarcadores('S');
  275 + }
  276 +
  277 + if ($objPesquisaPendenciaDTO->isSetDblIdDocumento()) {
  278 + $objProcedimentoDTO->setArrDblIdProtocoloAssociado(array($objPesquisaPendenciaDTO->getDblIdDocumento()));
  279 + }
  280 +
  281 + $objProcedimentoRN = new ProcedimentoRN();
  282 +
  283 + $arr = $objProcedimentoRN->listarCompleto($objProcedimentoDTO);
  284 +
  285 + $arrObjParticipanteDTO = null;
  286 + if ($objPesquisaPendenciaDTO->getStrSinInteressados() == 'S') {
  287 +
  288 + $arrObjParticipanteDTO = array();
  289 +
  290 + $objParticipanteDTO = new ParticipanteDTO();
  291 + $objParticipanteDTO->retDblIdProtocolo();
  292 + $objParticipanteDTO->retStrSiglaContato();
  293 + $objParticipanteDTO->retStrNomeContato();
  294 + $objParticipanteDTO->setStrStaParticipacao(ParticipanteRN::$TP_INTERESSADO);
  295 + $objParticipanteDTO->setDblIdProtocolo($arrProtocolosAtividades, InfraDTO::$OPER_IN);
  296 +
  297 + $objParticipanteRN = new ParticipanteRN();
  298 + $arrTemp = $objParticipanteRN->listarRN0189($objParticipanteDTO);
  299 +
  300 + foreach ($arrTemp as $objParticipanteDTO) {
  301 + if (!isset($arrObjParticipanteDTO[$objParticipanteDTO->getDblIdProtocolo()])) {
  302 + $arrObjParticipanteDTO[$objParticipanteDTO->getDblIdProtocolo()] = array($objParticipanteDTO);
  303 + } else {
  304 + $arrObjParticipanteDTO[$objParticipanteDTO->getDblIdProtocolo()][] = $objParticipanteDTO;
  305 + }
  306 + }
  307 + }
  308 +
  309 + $arrObjRetornoProgramadoDTO = null;
  310 + if ($objPesquisaPendenciaDTO->getStrSinRetornoProgramado() == 'S') {
  311 + $objRetornoProgramadoDTO = new RetornoProgramadoDTO();
  312 + $objRetornoProgramadoDTO->retDblIdProtocoloAtividadeEnvio();
  313 + $objRetornoProgramadoDTO->retStrSiglaUnidadeOrigemAtividadeEnvio();
  314 + $objRetornoProgramadoDTO->retDtaProgramada();
  315 + $objRetornoProgramadoDTO->setNumIdUnidadeAtividadeEnvio($objPesquisaPendenciaDTO->getNumIdUnidade());
  316 + $objRetornoProgramadoDTO->setDblIdProtocoloAtividadeEnvio($arrProtocolosAtividades, InfraDTO::$OPER_IN);
  317 + $objRetornoProgramadoDTO->setNumIdAtividadeRetorno(null);
  318 +
  319 + $objRetornoProgramadoRN = new RetornoProgramadoRN();
  320 + $arrObjRetornoProgramadoDTO = InfraArray::indexarArrInfraDTO($objRetornoProgramadoRN->listar($objRetornoProgramadoDTO), 'IdProtocoloAtividadeEnvio', true);
  321 + }
  322 +
  323 +
  324 + //Manter ordem obtida na listagem das atividades
  325 + $arrAdicionados = array();
  326 + $arrIdProcedimentoSigiloso = array();
  327 +
  328 + $arr = InfraArray::indexarArrInfraDTO($arr, 'IdProcedimento');
  329 +
  330 + foreach ($arrAtividadeDTO as $objAtividadeDTO) {
  331 +
  332 + $objProcedimentoDTO = $arr[$objAtividadeDTO->getDblIdProtocolo()];
  333 +
  334 + //pode não existir se o procedimento foi excluído
  335 + if ($objProcedimentoDTO != null) {
  336 +
  337 + $dblIdProcedimento = $objProcedimentoDTO->getDblIdProcedimento();
  338 +
  339 + if ($objProcedimentoDTO->getStrStaNivelAcessoGlobalProtocolo() == ProtocoloRN::$NA_SIGILOSO) {
  340 +
  341 + $objProcedimentoDTO->setStrSinCredencialProcesso('N');
  342 + $objProcedimentoDTO->setStrSinCredencialAssinatura('N');
  343 +
  344 + $arrIdProcedimentoSigiloso[] = $dblIdProcedimento;
  345 + }
  346 +
  347 + if (!isset($arrAdicionados[$dblIdProcedimento])) {
  348 +
  349 + $objProcedimentoDTO->setArrObjAtividadeDTO(array($objAtividadeDTO));
  350 +
  351 + if (is_array($arrObjParticipanteDTO)) {
  352 + if (isset($arrObjParticipanteDTO[$dblIdProcedimento])) {
  353 + $objProcedimentoDTO->setArrObjParticipanteDTO($arrObjParticipanteDTO[$dblIdProcedimento]);
  354 + } else {
  355 + $objProcedimentoDTO->setArrObjParticipanteDTO(null);
  356 + }
  357 + }
  358 +
  359 + if (is_array($arrObjRetornoProgramadoDTO)) {
  360 + if (isset($arrObjRetornoProgramadoDTO[$dblIdProcedimento])) {
  361 + $objProcedimentoDTO->setArrObjRetornoProgramadoDTO($arrObjRetornoProgramadoDTO[$dblIdProcedimento]);
  362 + } else {
  363 + $objProcedimentoDTO->setArrObjRetornoProgramadoDTO(null);
  364 + }
  365 + }
  366 +
  367 + $arrProcedimentos[] = $objProcedimentoDTO;
  368 + $arrAdicionados[$dblIdProcedimento] = 0;
  369 + } else {
  370 + $arrAtividadeDTOProcedimento = $objProcedimentoDTO->getArrObjAtividadeDTO();
  371 + $arrAtividadeDTOProcedimento[] = $objAtividadeDTO;
  372 + $objProcedimentoDTO->setArrObjAtividadeDTO($arrAtividadeDTOProcedimento);
  373 + }
  374 + }
  375 + }
  376 +
  377 +
  378 + if ($objPesquisaPendenciaDTO->getStrSinCredenciais() == 'S' && count($arrIdProcedimentoSigiloso)) {
  379 +
  380 + $objAcessoDTO = new AcessoDTO();
  381 + $objAcessoDTO->retDblIdProtocolo();
  382 + $objAcessoDTO->retStrStaTipo();
  383 + $objAcessoDTO->setNumIdUsuario($objPesquisaPendenciaDTO->getNumIdUsuario());
  384 + $objAcessoDTO->setNumIdUnidade($objPesquisaPendenciaDTO->getNumIdUnidade());
  385 + $objAcessoDTO->setStrStaTipo(array(AcessoRN::$TA_CREDENCIAL_PROCESSO, AcessoRN::$TA_CREDENCIAL_ASSINATURA_PROCESSO), InfraDTO::$OPER_IN);
  386 + $objAcessoDTO->setDblIdProtocolo($arrIdProcedimentoSigiloso, InfraDTO::$OPER_IN);
  387 +
  388 + $objAcessoRN = new AcessoRN();
  389 + $arrObjAcessoDTO = $objAcessoRN->listar($objAcessoDTO);
  390 +
  391 + /*
  392 + foreach($arr as $objProcedimentoDTO){
  393 + $objProcedimentoDTO->setStrSinCredencialProcesso('N');
  394 + $objProcedimentoDTO->setStrSinCredencialAssinatura('N');
  395 + }
  396 + */
  397 +
  398 + foreach ($arrObjAcessoDTO as $objAcessoDTO) {
  399 + if ($objAcessoDTO->getStrStaTipo() == AcessoRN::$TA_CREDENCIAL_PROCESSO) {
  400 + $arr[$objAcessoDTO->getDblIdProtocolo()]->setStrSinCredencialProcesso('S');
  401 + } else if ($objAcessoDTO->getStrStaTipo() == AcessoRN::$TA_CREDENCIAL_ASSINATURA_PROCESSO) {
  402 + $arr[$objAcessoDTO->getDblIdProtocolo()]->setStrSinCredencialAssinatura('S');
  403 + }
  404 + }
  405 +
  406 + }
  407 + }
  408 +
  409 + return $arrProcedimentos;
  410 +
  411 + } catch (Exception $e) {
  412 + throw new InfraException('Erro recuperando processos abertos.', $e);
  413 + }
  414 + }
  415 +
  416 + /**
  417 + * Sobrescrevendo método para colocar paginação
  418 + * @param ProcedimentoDTO $objProcedimentoDTO
  419 + * @return mixed
  420 + * @throws InfraException
  421 + */
  422 + protected function listarCredenciaisConectado(ProcedimentoDTO $objProcedimentoDTO) {
  423 + try{
  424 + $objInfraException = new InfraException();
  425 +
  426 + $objProtocoloDTO = new ProtocoloDTO();
  427 + $objProtocoloDTO->retDblIdProtocolo();
  428 + $objProtocoloDTO->retStrProtocoloFormatado();
  429 + $objProtocoloDTO->retStrStaNivelAcessoGlobal();
  430 + $objProtocoloDTO->setDblIdProtocolo($objProcedimentoDTO->getDblIdProcedimento());
  431 +
  432 + $objProtocoloRN = new ProtocoloRN();
  433 + $objProtocoloDTO = $objProtocoloRN->consultarRN0186($objProtocoloDTO);
  434 +
  435 + $objAcessoDTO = new AcessoDTO();
  436 + $objAcessoDTO->retNumIdAcesso();
  437 + $objAcessoDTO->setDblIdProtocolo($objProtocoloDTO->getDblIdProtocolo());
  438 + $objAcessoDTO->setNumIdUsuario(SessaoSEI::getInstance()->getNumIdUsuario());
  439 + $objAcessoDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual());
  440 + $objAcessoDTO->setStrStaTipo(AcessoRN::$TA_CREDENCIAL_PROCESSO);
  441 + $objAcessoDTO->setNumMaxRegistrosRetorno(1);
  442 +
  443 + $objAcessoRN = new AcessoRN();
  444 +
  445 + if ($objAcessoRN->consultar($objAcessoDTO) == null){
  446 + $objInfraException->adicionarValidacao('Usuário atual não possui credencial de acesso ao processo '.$objProtocoloDTO->getStrProtocoloFormatado().' nesta unidade.');
  447 + }
  448 +
  449 + if ($objProtocoloDTO->getStrStaNivelAcessoGlobal()!=ProtocoloRN::$NA_SIGILOSO){
  450 + $objInfraException->adicionarValidacao('Não é possível listar credenciais de acesso para um processo não sigiloso ('.$objProtocoloDTO->getStrProtocoloFormatado().').');
  451 + }
  452 +
  453 + $objInfraException->lancarValidacoes();
  454 +
  455 + $objAtividadeDTO = new AtividadeDTO();
  456 + $objAtividadeDTO->retNumIdAtividade();
  457 + $objAtividadeDTO->retStrSiglaUsuario();
  458 + $objAtividadeDTO->retStrNomeUsuario();
  459 + $objAtividadeDTO->retStrSiglaUnidade();
  460 + $objAtividadeDTO->retStrDescricaoUnidade();
  461 + $objAtividadeDTO->retDthAbertura();
  462 + $objAtividadeDTO->retNumIdTarefa();
  463 + $objAtividadeDTO->setNumIdUsuarioOrigem(SessaoSEI::getInstance()->getNumIdUsuario());
  464 + $objAtividadeDTO->setDblIdProtocolo($objProtocoloDTO->getDblIdProtocolo());
  465 + $objAtividadeDTO->setNumIdTarefa(array_merge(TarefaRN::getArrTarefasConcessaoCredencial(false), TarefaRN::getArrTarefasCassacaoCredencial(false)), InfraDTO::$OPER_IN);
  466 +
  467 + // INICIO SOBRESCRITA
  468 + if($objProcedimentoDTO->isSetNumMaxRegistrosRetorno()){
  469 + $objAtividadeDTO->setNumMaxRegistrosRetorno($objProcedimentoDTO->getNumMaxRegistrosRetorno());
  470 + }
  471 + if(!is_null($objProcedimentoDTO->getNumPaginaAtual())){
  472 + $objAtividadeDTO->setNumPaginaAtual($objProcedimentoDTO->getNumPaginaAtual());
  473 + }
  474 +
  475 + $objAtividadeDTO->setOrdNumIdAtividade(InfraDTO::$TIPO_ORDENACAO_DESC);
  476 + $arrObjAtividadeDTO = $this->listarRN0036($objAtividadeDTO);
  477 + $objProcedimentoDTO->setNumTotalRegistros($objAtividadeDTO->getNumTotalRegistros());
  478 + // FIM SOBRESCRITA
  479 +
  480 + if (count($arrObjAtividadeDTO)){
  481 +
  482 + $objAtributoAndamentoDTO = new AtributoAndamentoDTO();
  483 + $objAtributoAndamentoDTO->retNumIdAtividade();
  484 + $objAtributoAndamentoDTO->retStrNome();
  485 + $objAtributoAndamentoDTO->retStrValor();
  486 + $objAtributoAndamentoDTO->setNumIdAtividade(InfraArray::converterArrInfraDTO($arrObjAtividadeDTO,'IdAtividade'), InfraDTO::$OPER_IN);
  487 +
  488 + $objAtributoAndamentoRN = new AtributoAndamentoRN();
  489 + $arrObjAtributoAndamentoDTO = InfraArray::indexarArrInfraDTO($objAtributoAndamentoRN->listarRN1367($objAtributoAndamentoDTO),'IdAtividade',true);
  490 +
  491 + foreach($arrObjAtividadeDTO as $objAtividadeDTO){
  492 + if (isset($arrObjAtributoAndamentoDTO[$objAtividadeDTO->getNumIdAtividade()])){
  493 + $objAtividadeDTO->setArrObjAtributoAndamentoDTO($arrObjAtributoAndamentoDTO[$objAtividadeDTO->getNumIdAtividade()]);
  494 + }else{
  495 + $objAtividadeDTO->setArrObjAtributoAndamentoDTO(array());
  496 + }
  497 + }
  498 + }
  499 +
  500 + return $arrObjAtividadeDTO;
  501 +
  502 + }catch(Exception $e){
  503 + throw new InfraException('Erro listando credenciais.',$e);
  504 + }
  505 + }
  506 +
  507 +
  508 +}
0 509 \ No newline at end of file
... ...
rn/MdWsSeiBlocoRN.php 0 → 100644
... ... @@ -0,0 +1,301 @@
  1 +<?
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiBlocoRN extends InfraRN {
  5 +
  6 + protected function inicializarObjInfraIBanco(){
  7 + return BancoSEI::getInstance();
  8 + }
  9 +
  10 + /**
  11 + * Método que retorna o bloco de assinatura
  12 + * @param BlocoDTO $blocoDTO
  13 + * @return array
  14 + */
  15 + protected function retornarControlado(BlocoDTO $blocoDTO){
  16 + try{
  17 + if(!$blocoDTO->isSetNumIdBloco()){
  18 + throw new Exception('Bloco não informado!');
  19 + }
  20 + $blocoRN = new BlocoRN();
  21 + $blocoRN->retornar(array($blocoDTO));
  22 +
  23 + return MdWsSeiRest::formataRetornoSucessoREST('Bloco retornado com sucesso!');
  24 + }catch (Exception $e){
  25 + return MdWsSeiRest::formataRetornoErroREST($e);
  26 + }
  27 + }
  28 +
  29 +
  30 + /**
  31 + * Assina todos os documentos do bloco
  32 + * @param $idOrgao
  33 + * @param $strCargoFuncao
  34 + * @param $siglaUsuario
  35 + * @param $senhaUsuario
  36 + * @param $idUsuario
  37 + * @return array
  38 + */
  39 + public function apiAssinarBloco($idBloco, $idOrgao, $strCargoFuncao, $siglaUsuario, $senhaUsuario, $idUsuario)
  40 + {
  41 + try{
  42 + $objRelBlocoProtocoloDTO = new RelBlocoProtocoloDTO();
  43 + $objRelBlocoProtocoloDTO->setNumIdBloco($idBloco);
  44 + $objRelBlocoProtocoloDTO->setOrdNumSequencia(InfraDTO::$TIPO_ORDENACAO_ASC);
  45 +
  46 + $objRelBlocoProtocoloRN = new RelBlocoProtocoloRN();
  47 + $arrIdDocumentos = InfraArray::converterArrInfraDTO($objRelBlocoProtocoloRN->listarProtocolosBloco($objRelBlocoProtocoloDTO),'IdProtocolo');
  48 + if(!$arrIdDocumentos){
  49 + return MdWsSeiRest::formataRetornoSucessoREST('Nenhum documento para ser assinado neste bloco.');
  50 + }
  51 + $assinaturaDTO = new AssinaturaDTO();
  52 + $assinaturaDTO->setStrSiglaUsuario($siglaUsuario);
  53 + $assinaturaDTO->setStrSenhaUsuario($senhaUsuario);
  54 + $assinaturaDTO->setNumIdUsuario($idUsuario);
  55 + $assinaturaDTO->setNumIdOrgaoUsuario($idOrgao);
  56 + $assinaturaDTO->setStrCargoFuncao($strCargoFuncao);
  57 + $assinaturaDTO->setStrStaFormaAutenticacao(AssinaturaRN::$TA_SENHA);
  58 + $assinaturaDTO->setNumIdContextoUsuario(null);
  59 + $assinaturaDTO->setArrObjDocumentoDTO(InfraArray::gerarArrInfraDTO('DocumentoDTO','IdDocumento',$arrIdDocumentos));
  60 + $documentoRN = new DocumentoRN();
  61 + $documentoRN->assinarInterno($assinaturaDTO);
  62 + return MdWsSeiRest::formataRetornoSucessoREST('Documentos em bloco assinados com sucesso.');
  63 + }catch (Exception $e){
  64 + return MdWsSeiRest::formataRetornoErroREST($e);
  65 + }
  66 + }
  67 +
  68 + /**
  69 + * Consultar Blocos
  70 + * @param BlocoDTO $blocoDTO
  71 + * @return array
  72 + */
  73 + protected function listarBlocoConectado(BlocoDTO $blocoDTO){
  74 + try{
  75 + $result = array();
  76 + $blocoRN = new BlocoRN();
  77 + $blocoDTOConsulta = new BlocoDTO();
  78 + if(!$blocoDTO->getNumMaxRegistrosRetorno()){
  79 + $blocoDTOConsulta->setNumMaxRegistrosRetorno(10);
  80 + }else{
  81 + $blocoDTOConsulta->setNumMaxRegistrosRetorno($blocoDTO->getNumMaxRegistrosRetorno());
  82 + }
  83 + if(is_null($blocoDTO->getNumPaginaAtual())){
  84 + $blocoDTOConsulta->setNumPaginaAtual(0);
  85 + }else{
  86 + $blocoDTOConsulta->setNumPaginaAtual($blocoDTO->getNumPaginaAtual());
  87 + }
  88 +
  89 + $blocoDTOConsulta->setStrStaEstado(BlocoRN::$TE_CONCLUIDO,InfraDTO::$OPER_DIFERENTE);
  90 + $blocoDTOConsulta->setStrStaTipo(BlocoRN::$TB_ASSINATURA);
  91 + $blocoDTOConsulta->retNumIdBloco();
  92 + $blocoDTOConsulta->retNumIdUnidade();
  93 + $blocoDTOConsulta->retStrDescricao();
  94 + $blocoDTOConsulta->retStrStaTipo();
  95 + $blocoDTOConsulta->retStrStaEstado();
  96 + $blocoDTOConsulta->retStrStaEstadoDescricao();
  97 + $blocoDTOConsulta->retStrTipoDescricao();
  98 + $blocoDTOConsulta->retStrSiglaUnidade();
  99 + $blocoDTOConsulta->retStrDescricaoUnidade();
  100 + $blocoDTOConsulta->retStrSinVazio();
  101 + $blocoDTOConsulta->retArrObjRelBlocoUnidadeDTO();
  102 + $blocoDTOConsulta->setOrdNumIdBloco(InfraDTO::$TIPO_ORDENACAO_DESC);
  103 +
  104 + $ret = $blocoRN->pesquisar($blocoDTOConsulta);
  105 +
  106 + /** @var BlocoDTO $blocoDTO */
  107 + foreach($ret as $blocoDTO){
  108 + $relBlocoProtocoloRN = new RelBlocoProtocoloRN();
  109 + $relBlocoProtocoloDTOConsulta = new RelBlocoProtocoloDTO();
  110 + $relBlocoProtocoloDTOConsulta->setNumMaxRegistrosRetorno(1);
  111 + $relBlocoProtocoloDTOConsulta->setNumPaginaAtual(0);
  112 + $relBlocoProtocoloDTOConsulta->setNumIdBloco($blocoDTO->getNumIdBloco());
  113 + $relBlocoProtocoloDTOConsulta->setOrdNumIdBloco(InfraDTO::$TIPO_ORDENACAO_DESC);
  114 + $relBlocoProtocoloDTOConsulta->retDblIdProtocolo();
  115 + $relBlocoProtocoloRN->listarRN1291($relBlocoProtocoloDTOConsulta);
  116 + $numeroDocumentos = $relBlocoProtocoloDTOConsulta->getNumTotalRegistros();
  117 +
  118 + $arrUnidades = array();
  119 + /** @var RelBlocoUnidadeDTO $relBlocoUnidadeDTO */
  120 + foreach($blocoDTO->getArrObjRelBlocoUnidadeDTO() as $relBlocoUnidadeDTO){
  121 + $arrUnidades[] = array(
  122 + 'idUnidade' => $relBlocoUnidadeDTO->getNumIdUnidade(),
  123 + 'unidade' => $relBlocoUnidadeDTO->getStrSiglaUnidade()
  124 + );
  125 + }
  126 + $result[] = array(
  127 + 'id' => $blocoDTO->getNumIdBloco(),
  128 + 'atributos' => array(
  129 + 'idBloco' => $blocoDTO->getNumIdBloco(),
  130 + 'idUnidade' => $blocoDTO->getNumIdUnidade(),
  131 + 'siglaUnidade' => $blocoDTO->getStrSiglaUnidade(),
  132 + 'estado' => $blocoDTO->getStrStaEstado(),
  133 + 'descricao' => $blocoDTO->getStrDescricao(),
  134 + 'unidades' => $arrUnidades,
  135 + 'numeroDocumentos' => $numeroDocumentos
  136 + )
  137 + );
  138 + }
  139 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result, $blocoDTOConsulta->getNumTotalRegistros());
  140 + }catch (Exception $e){
  141 + return MdWsSeiRest::formataRetornoErroREST($e);
  142 + }
  143 + }
  144 +
  145 + /**
  146 + * Consultar Documentos por Bloco
  147 + * @param BlocoDTO $blocoDTOConsulta
  148 + * @return array
  149 + */
  150 + protected function listarDocumentosBlocoConectado(BlocoDTO $blocoDTOConsulta){
  151 + try{
  152 + if(!$blocoDTOConsulta->getNumIdBloco()){
  153 + throw new InfraException('Bloco não informado.');
  154 + }
  155 + $relBlocoProtocoloRN = new RelBlocoProtocoloRN();
  156 + $relBlocoProtocoloDTOConsulta = new RelBlocoProtocoloDTO();
  157 + if($blocoDTOConsulta->getNumMaxRegistrosRetorno()){
  158 + $relBlocoProtocoloDTOConsulta->setNumMaxRegistrosRetorno($blocoDTOConsulta->getNumMaxRegistrosRetorno());
  159 + }else{
  160 + $relBlocoProtocoloDTOConsulta->setNumMaxRegistrosRetorno(10);
  161 + }
  162 + if(!is_null($blocoDTOConsulta->getNumPaginaAtual())){
  163 + $relBlocoProtocoloDTOConsulta->setNumPaginaAtual($blocoDTOConsulta->getNumPaginaAtual());
  164 + }else{
  165 + $relBlocoProtocoloDTOConsulta->setNumPaginaAtual(0);
  166 + }
  167 + $result = array();
  168 + $relBlocoProtocoloDTOConsulta->setNumIdBloco($blocoDTOConsulta->getNumIdBloco());
  169 + $relBlocoProtocoloDTOConsulta->setOrdNumIdBloco(InfraDTO::$TIPO_ORDENACAO_DESC);
  170 + $relBlocoProtocoloDTOConsulta->retDblIdProtocolo();
  171 + $relBlocoProtocoloDTOConsulta->retStrAnotacao();
  172 + $relBlocoProtocoloDTOConsulta->retStrProtocoloFormatadoProtocolo();
  173 + $arrRelProtocolo = $relBlocoProtocoloRN->listarRN1291($relBlocoProtocoloDTOConsulta);
  174 + if($arrRelProtocolo){
  175 + $anexoRN = new AnexoRN();
  176 + $assinaturaRN = new AssinaturaRN();
  177 + $protocoloRN = new ProtocoloRN();
  178 + $protocoloProtocoloRN = new RelProtocoloProtocoloRN();
  179 + /** @var RelBlocoProtocoloDTO $relBlocoProtocoloDTO */
  180 + foreach($arrRelProtocolo as $relBlocoProtocoloDTO){
  181 + $relProtocoloProtocoloDTO = new RelProtocoloProtocoloDTO();
  182 + $relProtocoloProtocoloDTO->setDblIdProtocolo2($relBlocoProtocoloDTO->getDblIdProtocolo());
  183 + $relProtocoloProtocoloDTO->retDblIdProtocolo1();
  184 + $relProtocoloProtocoloDTO = $protocoloProtocoloRN->consultarRN0841($relProtocoloProtocoloDTO);
  185 + $arrResultAssinatura = array();
  186 + $protocoloDTO = new ProtocoloDTO();
  187 + $protocoloDTO->setDblIdProtocolo($relProtocoloProtocoloDTO->getDblIdProtocolo1());
  188 + $protocoloDTO->retStrNomeSerieDocumento();
  189 + $protocoloDTO->retStrProtocoloFormatado();
  190 + $protocoloDTO->retDblIdProtocolo();
  191 + $protocoloDTO->retDtaGeracao();
  192 + $protocoloDTO = $protocoloRN->consultarRN0186($protocoloDTO);
  193 +
  194 + $protocoloDTODocumento = new ProtocoloDTO();
  195 + $protocoloDTODocumento->retStrNomeSerieDocumento();
  196 + $protocoloDTODocumento->setDblIdProtocolo($relBlocoProtocoloDTO->getDblIdProtocolo());
  197 + $protocoloDTODocumento = $protocoloRN->consultarRN0186($protocoloDTODocumento);
  198 +
  199 + $assinaturaDTOConsulta = new AssinaturaDTO();
  200 + $assinaturaDTOConsulta->setDblIdDocumento($relBlocoProtocoloDTO->getDblIdProtocolo());
  201 + $assinaturaDTOConsulta->retStrNome();
  202 + $assinaturaDTOConsulta->retStrTratamento();
  203 + $assinaturaDTOConsulta->retNumIdUsuario();
  204 + $arrAssinatura = $assinaturaRN->listarRN1323($assinaturaDTOConsulta);
  205 + /** @var AssinaturaDTO $assinaturaDTO */
  206 + foreach($arrAssinatura as $assinaturaDTO){
  207 + $arrResultAssinatura[] = array(
  208 + 'nome' => $assinaturaDTO->getStrNome(),
  209 + 'cargo' => $assinaturaDTO->getStrTratamento(),
  210 + 'idUsuario' => $assinaturaDTO->getNumIdUsuario(),
  211 + );
  212 + }
  213 + $anexoDTOConsulta = new AnexoDTO();
  214 + $anexoDTOConsulta->retTodos();
  215 + $anexoDTOConsulta->setDblIdProtocolo($protocoloDTO->getDblIdProtocolo());
  216 + $anexoDTOConsulta->setStrSinAtivo('S');
  217 + $anexoDTOConsulta->setNumMaxRegistrosRetorno(1);
  218 + $retAnexo = $anexoRN->listarRN0218($anexoDTOConsulta);
  219 + $mimetype = null;
  220 + if($retAnexo){
  221 + $mimetype = $retAnexo[0]->getStrNome();
  222 + $mimetype = substr($mimetype, strrpos($mimetype, '.')+1);
  223 + }
  224 + $result[] = array(
  225 + 'id' => $protocoloDTO->getDblIdProtocolo(),
  226 + 'atributos' => array(
  227 + 'idDocumento' => $relBlocoProtocoloDTO->getDblIdProtocolo(),
  228 + 'mimeType' => ($mimetype)?$mimetype:'html',
  229 + 'data' => $protocoloDTO->getDtaGeracao(),
  230 + 'numero' => $relBlocoProtocoloDTO->getStrProtocoloFormatadoProtocolo(),
  231 + 'numeroProcesso' => $protocoloDTO->getStrProtocoloFormatado(),
  232 + 'tipo' => $protocoloDTODocumento->getStrNomeSerieDocumento(),
  233 + 'assinaturas' => $arrResultAssinatura
  234 + ),
  235 + 'anotacao' => $relBlocoProtocoloDTO->getStrAnotacao()
  236 + );
  237 + }
  238 + }
  239 +
  240 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result, $relBlocoProtocoloDTOConsulta->getNumTotalRegistros());
  241 + }catch (Exception $e){
  242 + return MdWsSeiRest::formataRetornoErroREST($e);
  243 + }
  244 + }
  245 +
  246 + /**
  247 + * Metodo publico que cadastra a anotacao em um bloco
  248 + * @param array $post
  249 + * @return array
  250 + */
  251 + public function cadastrarAnotacaoBlocoFromRequest(array $post){
  252 + $relBlocoProtocoloDTO = new RelBlocoProtocoloDTO();
  253 + if($post['protocolo']){
  254 + $relBlocoProtocoloDTO->setDblIdProtocolo($post['protocolo']);
  255 + }
  256 + if($post['bloco']){
  257 + $relBlocoProtocoloDTO->setNumIdBloco($post['bloco']);
  258 + }
  259 + if($post['anotacao']){
  260 + $relBlocoProtocoloDTO->setStrAnotacao($post['anotacao']);
  261 + }
  262 +
  263 + return $this->cadastrarAnotacaoBloco($relBlocoProtocoloDTO);
  264 + }
  265 +
  266 + /**
  267 + * Cadastrar Anotacao documento do Bloco
  268 + * @param RelBlocoProtocoloDTO $relBlocoProtocoloDTOParam
  269 + * @return array
  270 + */
  271 + protected function cadastrarAnotacaoBlocoControlado(RelBlocoProtocoloDTO $relBlocoProtocoloDTOParam){
  272 +
  273 + try {
  274 + if (!$relBlocoProtocoloDTOParam->isSetNumIdBloco()) {
  275 + throw new InfraException('O bloco deve ser informado.');
  276 + }
  277 + if (!$relBlocoProtocoloDTOParam->isSetDblIdProtocolo()) {
  278 + throw new InfraException('O protocolo deve ser informado.');
  279 + }
  280 + if (!$relBlocoProtocoloDTOParam->isSetStrAnotacao()) {
  281 + throw new InfraException('A anotação deve ser informada.');
  282 + }
  283 + $relBlocoProtocoloDTO = new RelBlocoProtocoloDTO();
  284 + $relBlocoProtocoloDTO->setNumIdBloco($relBlocoProtocoloDTOParam->getNumIdBloco());
  285 + $relBlocoProtocoloDTO->setDblIdProtocolo($relBlocoProtocoloDTOParam->getDblIdProtocolo());
  286 + $relBlocoProtocoloDTO->retTodos();
  287 + $relBlocoProtocoloRN = new RelBlocoProtocoloRN();
  288 + $relBlocoProtocoloDTO = $relBlocoProtocoloRN->consultarRN1290($relBlocoProtocoloDTO);
  289 + if (!$relBlocoProtocoloDTO) {
  290 + throw new InfraException('Documento não encontrado no bloco informado.');
  291 + }
  292 + $relBlocoProtocoloDTO->setStrAnotacao($relBlocoProtocoloDTOParam->getStrAnotacao());
  293 + $relBlocoProtocoloRN->alterarRN1288($relBlocoProtocoloDTO);
  294 +
  295 + return MdWsSeiRest::formataRetornoSucessoREST('Anotação realizada com sucesso.');
  296 + }catch (Exception $e){
  297 + return MdWsSeiRest::formataRetornoErroREST($e);
  298 + }
  299 + }
  300 +
  301 +}
0 302 \ No newline at end of file
... ...
rn/MdWsSeiContatoRN.php 0 → 100644
... ... @@ -0,0 +1,95 @@
  1 +<?php
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiContatoRN extends InfraRN
  5 +{
  6 +
  7 + protected function inicializarObjInfraIBanco()
  8 + {
  9 + return BancoSEI::getInstance();
  10 + }
  11 +
  12 +
  13 + /**
  14 + * Retorna todos tipos de procedimentos filtrados
  15 + * @param MdWsSeiTipoProcedimentoDTO $objGetMdWsSeiTipoProcedimentoDTO
  16 + * @return array
  17 + */
  18 + protected function listarContatoConectado(MdWsSeiContatoDTO $objGetMdWsSeiContatoDTO)
  19 + {
  20 + try {
  21 +
  22 + $id = $objGetMdWsSeiContatoDTO->getNumIdContato();
  23 + $filter = $objGetMdWsSeiContatoDTO->getStrFilter();
  24 + $start = $objGetMdWsSeiContatoDTO->getNumStart();
  25 + $limit = $objGetMdWsSeiContatoDTO->getNumLimit();
  26 +
  27 + $contatoDTO = new ContatoDTO();
  28 +
  29 + if($id)
  30 + $contatoDTO->setNumIdContato($id);
  31 +
  32 + if($filter)
  33 + $contatoDTO->setStrNome('%'.$filter.'%',InfraDTO::$OPER_LIKE);
  34 +
  35 + IF($limit)
  36 + $contatoDTO->setNumMaxRegistrosRetorno($limit);
  37 +
  38 + IF($start)
  39 + $contatoDTO->setNumPaginaAtual($start);
  40 +
  41 + $contatoDTO->retNumIdContato();
  42 + $contatoDTO->retStrSigla();
  43 + $contatoDTO->retStrNome();
  44 +
  45 + $contatoRN = new ContatoRN();
  46 + $arrContatoDTO = $contatoRN->listarRN0325($contatoDTO);
  47 +
  48 + $arrayRetorno = array();
  49 + if($arrContatoDTO){
  50 + foreach ($arrContatoDTO as $obj) {
  51 + $arrayRetorno[] = array(
  52 + "id" => $obj->getNumIdContato(),
  53 + "sigla" => $obj->getStrSigla(),
  54 + "nome" => $obj->getStrNome()
  55 + );
  56 + }
  57 + }
  58 +
  59 + $total = 0;
  60 + $total = count($arrayRetorno);
  61 +
  62 + return MdWsSeiRest::formataRetornoSucessoREST(null, $arrayRetorno, $total);
  63 + } catch (Exception $e) {
  64 + return MdWsSeiRest::formataRetornoErroREST($e);
  65 + }
  66 + }
  67 +
  68 +
  69 + /**
  70 + * Realiza a inclusão de um contato no SEI.
  71 + * @param MdWsSeiContatoDTO $objGetMdWsSeiContatoDTO
  72 + * @return array
  73 + */
  74 + protected function criarContatoConectado(MdWsSeiContatoDTO $objGetMdWsSeiContatoDTO)
  75 + {
  76 + try {
  77 +
  78 + $nome = $objGetMdWsSeiContatoDTO->getStrNome();
  79 +
  80 + $objContatoDTO = new ContatoDTO();
  81 + $objContatoDTO->setStrNome($nome);
  82 +
  83 + $objContatoRN = new ContatoRN();
  84 + $objContatoDTO = $objContatoRN->cadastrarContextoTemporario($objContatoDTO);
  85 +
  86 + return MdWsSeiRest::formataRetornoSucessoREST(null,array("id"=>$objContatoDTO->getNumIdContato()));
  87 + } catch (Exception $e) {
  88 + return MdWsSeiRest::formataRetornoErroREST($e);
  89 + }
  90 + }
  91 +
  92 +
  93 +
  94 +
  95 +}
0 96 \ No newline at end of file
... ...
rn/MdWsSeiContextoRN.php 0 → 100644
... ... @@ -0,0 +1,45 @@
  1 +<?
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiContextoRN extends InfraRN {
  5 +
  6 + protected function inicializarObjInfraIBanco(){
  7 + return BancoSEI::getInstance();
  8 + }
  9 +
  10 + /**
  11 + * Retorna a lista de contextos por orgao
  12 + * @return array
  13 + */
  14 + protected function listarContextoConectado(OrgaoDTO $orgaoDTO){
  15 + try{
  16 + if(!$orgaoDTO->isSetNumIdOrgao()){
  17 + throw new Exception('O órgão do contexto deve ser informado!');
  18 + }
  19 + $result = array();
  20 + $contextoRN = new ContextoRN();
  21 + $contextDTOConsulta = new ContextoDTO();
  22 + $contextDTOConsulta->retNumIdContexto();
  23 + $contextDTOConsulta->retStrNome();
  24 + $contextDTOConsulta->retStrDescricao();
  25 + $contextDTOConsulta->retStrBaseDnLdap();
  26 + $contextDTOConsulta->setStrSinAtivo('S');
  27 + $contextDTOConsulta->setNumIdOrgao($orgaoDTO->getNumIdOrgao());
  28 + $ret = $contextoRN->listar($contextDTOConsulta);
  29 + /** @var ContextoDTO $contextoDTO */
  30 + foreach($ret as $contextoDTO){
  31 + $result[] = array(
  32 + 'id' => $contextoDTO->getNumIdContexto(),
  33 + 'nome' => $contextoDTO->getStrNome(),
  34 + 'descricao' => $contextoDTO->getStrDescricao(),
  35 + 'base_dn_ldap' => $contextoDTO->getStrBaseDnLdap(),
  36 + );
  37 + }
  38 +
  39 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result);
  40 + }catch (Exception $e){
  41 + return MdWsSeiRest::formataRetornoErroREST($e);
  42 + }
  43 + }
  44 +
  45 +}
0 46 \ No newline at end of file
... ...
rn/MdWsSeiCredenciamentoRN.php 0 → 100644
... ... @@ -0,0 +1,134 @@
  1 +<?
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiCredenciamentoRN extends InfraRN {
  5 +
  6 + protected function inicializarObjInfraIBanco(){
  7 + return BancoSEI::getInstance();
  8 + }
  9 +
  10 + /**
  11 + * Concede a credencial de acesso a um processo sigiloso
  12 + * @param ConcederCredencialDTO $concederCredencialDTO
  13 + * @return array
  14 + */
  15 + protected function concederCredenciamentoControlado(ConcederCredencialDTO $concederCredencialDTO){
  16 + try{
  17 + if(!$concederCredencialDTO->isSetDblIdProcedimento() || !$concederCredencialDTO->getDblIdProcedimento()){
  18 + throw new Exception('Processo não informado!');
  19 + }
  20 + if(!$concederCredencialDTO->isSetNumIdUnidade() || !$concederCredencialDTO->getNumIdUnidade()){
  21 + throw new Exception('Unidade não informada!');
  22 + }
  23 + if(!$concederCredencialDTO->isSetNumIdUsuario() || !$concederCredencialDTO->getNumIdUsuario()){
  24 + throw new Exception('Usuário não informado!');
  25 + }
  26 +
  27 + $atividadeRN = new AtividadeRN();
  28 + $pesquisaPendenciaDTO = new PesquisaPendenciaDTO();
  29 + $pesquisaPendenciaDTO->setDblIdProtocolo($concederCredencialDTO->getDblIdProcedimento());
  30 + $pesquisaPendenciaDTO->setNumIdUsuario(SessaoSEI::getInstance()->getNumIdUsuario());
  31 + $pesquisaPendenciaDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual());
  32 + $arrProcedimentoDTO = $atividadeRN->listarPendenciasRN0754($pesquisaPendenciaDTO);
  33 +
  34 + if (count($arrProcedimentoDTO)==0){
  35 + throw new Exception('Processo não encontrado.');
  36 + }
  37 + $arrAtividadesOrigem = $arrProcedimentoDTO[0]->getArrObjAtividadeDTO();
  38 + $concederCredencialDTO->setArrAtividadesOrigem($arrAtividadesOrigem);
  39 + $atividadeRN->concederCredencial($concederCredencialDTO);
  40 +
  41 + return MdWsSeiRest::formataRetornoSucessoREST("Credencial concedida com sucesso!");
  42 + }catch (Exception $e){
  43 + return MdWsSeiRest::formataRetornoErroREST($e);
  44 + }
  45 + }
  46 +
  47 + /**
  48 + * Remove a credencial de acesso a um processo sigiloso
  49 + * @param AtividadeDTO $atividadeDTO
  50 + * @return array
  51 + */
  52 + protected function cassarCredencialControlado(AtividadeDTO $atividadeDTO){
  53 + try{
  54 + if(!$atividadeDTO->isSetNumIdAtividade() || !$atividadeDTO->getNumIdAtividade()){
  55 + throw new Exception('Atividade não informado!');
  56 + }
  57 +
  58 + $objAtividadeRN = new AtividadeRN();
  59 + $objAtividadeRN->cassarCredenciais(array($atividadeDTO));
  60 + return MdWsSeiRest::formataRetornoSucessoREST("Credencial cassada com sucesso!");
  61 + }catch (Exception $e){
  62 + return MdWsSeiRest::formataRetornoErroREST($e);
  63 + }
  64 + }
  65 +
  66 + /**
  67 + * Lista as credenciais de acesso de um processo sigiloso
  68 + * @param ProcedimentoDTO $procedimentoDTOParam
  69 + * @return array
  70 + */
  71 + protected function listarCredenciaisProcessoConectado(ProcedimentoDTO $procedimentoDTOParam){
  72 + try{
  73 + if(!$procedimentoDTOParam->isSetDblIdProcedimento() || !$procedimentoDTOParam->getDblIdProcedimento()){
  74 + throw new Exception('Atividade não informado!');
  75 + }
  76 + if(is_null($procedimentoDTOParam->getNumPaginaAtual())){
  77 + $procedimentoDTOParam->setNumPaginaAtual(0);
  78 + }
  79 + if (!$procedimentoDTOParam->isSetNumMaxRegistrosRetorno()) {
  80 + $procedimentoDTOParam->setNumMaxRegistrosRetorno(10);
  81 + }
  82 +
  83 + $result = array();
  84 + $objAtividadeRN = new MdWsSeiAtividadeRN();
  85 + $ret = $objAtividadeRN->listarCredenciais($procedimentoDTOParam);
  86 + /** @var AtividadeDTO $atividadeDTO */
  87 + foreach($ret as $atividadeDTO){
  88 + $dataCassacao = null;
  89 + foreach ($atividadeDTO->getArrObjAtributoAndamentoDTO() as $atributoAndamentoDTO) {
  90 + if ($atributoAndamentoDTO->getStrNome() == 'DATA_HORA') {
  91 + $dataCassacao .= substr($atributoAndamentoDTO->getStrValor(), 0, 16);
  92 + }
  93 + }
  94 + $result[] = array(
  95 + 'atividade' => $atividadeDTO->getNumIdAtividade(),
  96 + 'siglaUsuario' => $atividadeDTO->getStrSiglaUsuario(),
  97 + 'siglaUnidade' => $atividadeDTO->getStrSiglaUnidade(),
  98 + 'nomeUsuario' => $atividadeDTO->getStrNomeUsuario(),
  99 + 'descricaoUnidade' => $atividadeDTO->getStrDescricaoUnidade(),
  100 + 'dataAbertura' => substr($atividadeDTO->getDthAbertura(),0,16),
  101 + 'credencialCassada' => in_array($atividadeDTO->getNumIdTarefa(), TarefaRN::getArrTarefasCassacaoCredencial(false)),
  102 + 'dataCassacao' => $dataCassacao,
  103 + );
  104 + }
  105 +
  106 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result, $procedimentoDTOParam->getNumTotalRegistros());
  107 + }catch (Exception $e){
  108 + return MdWsSeiRest::formataRetornoErroREST($e);
  109 + }
  110 + }
  111 +
  112 + /**
  113 + * Método de reununcia de credencial de acesso
  114 + * @param ProcedimentoDTO $procedimentoDTO
  115 + * @return array
  116 + */
  117 + protected function renunciarCredencialControlado(ProcedimentoDTO $procedimentoDTO){
  118 + try{
  119 + $temPermissao = SessaoSEI::getInstance()->verificarPermissao('procedimento_credencial_renunciar');
  120 + if(!$temPermissao){
  121 + throw new Exception("O usuário não tem permissão para renunciar!");
  122 + }
  123 + if(!$procedimentoDTO->isSetDblIdProcedimento()){
  124 + throw new Exception("O processo não foi informado!");
  125 + }
  126 + $atividadeRN = new AtividadeRN();
  127 + $atividadeRN->renunciarCredenciais($procedimentoDTO);
  128 + return MdWsSeiRest::formataRetornoSucessoREST("Credencial renunciada com sucesso!");
  129 + }catch (Exception $e){
  130 + return MdWsSeiRest::formataRetornoErroREST($e);
  131 + }
  132 + }
  133 +
  134 +}
0 135 \ No newline at end of file
... ...
rn/MdWsSeiDebugRN.php 0 → 100644
... ... @@ -0,0 +1,22 @@
  1 +<?
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiDebugRN extends InfraBD {
  5 +
  6 + public function __construct(InfraIBanco $objInfraIBanco){
  7 + parent::__construct($objInfraIBanco);
  8 + }
  9 +
  10 + public function debug(InfraDTO $dto){
  11 + $sql = $this->consultar($dto, true);
  12 + $rs = $this->getObjInfraIBanco()->consultarSql($sql);
  13 + echo "<pre>";
  14 + var_dump($rs);
  15 + }
  16 +
  17 + public function debugAvancado($sql){
  18 + $rs = $this->getObjInfraIBanco()->consultarSql($sql);
  19 + echo "<pre>";
  20 + var_dump($rs);
  21 + }
  22 +}
0 23 \ No newline at end of file
... ...
rn/MdWsSeiDocumentoRN.php 0 → 100644
... ... @@ -0,0 +1,1171 @@
  1 +<?php
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiDocumentoRN extends DocumentoRN {
  5 +
  6 + CONST NOME_ATRIBUTO_ANDAMENTO_DOCUMENTO = 'DOCUMENTO';
  7 +
  8 + protected function inicializarObjInfraIBanco(){
  9 + return BancoSEI::getInstance();
  10 + }
  11 +
  12 + /**
  13 + * Listar Seção do documento
  14 + * @param DocumentoDTO DocumentoDTO
  15 + * @return array
  16 + */
  17 + protected function listarSecaoDocumentoConectado(DocumentoDTO $dto){
  18 + try{
  19 + $id = $dto->getDblIdDocumento();
  20 +
  21 + //Consulta que retorna todas as se
  22 + $objVersaoSecaoDocumentoDTO = new VersaoSecaoDocumentoDTO();
  23 + $objVersaoSecaoDocumentoDTO->retNumIdSecaoModeloSecaoDocumento();
  24 + $objVersaoSecaoDocumentoDTO->retStrSinAssinaturaSecaoDocumento();
  25 + $objVersaoSecaoDocumentoDTO->retStrSinSomenteLeituraSecaoDocumento();
  26 + $objVersaoSecaoDocumentoDTO->retStrConteudo();
  27 + $objVersaoSecaoDocumentoDTO->retNumVersao();
  28 + $objVersaoSecaoDocumentoDTO->retNumIdSecaoDocumento();
  29 + $objVersaoSecaoDocumentoDTO->setDblIdDocumentoSecaoDocumento($id);
  30 + $objVersaoSecaoDocumentoDTO->setNumIdBaseConhecimentoSecaoDocumento(null);
  31 + $objVersaoSecaoDocumentoDTO->setStrSinUltima('S');
  32 + $objVersaoSecaoDocumentoDTO->setOrdNumOrdemSecaoDocumento(InfraDTO::$TIPO_ORDENACAO_ASC);
  33 +
  34 + $objVersaoSecaoDocumentoRN = new VersaoSecaoDocumentoRN();
  35 + $arrObjVersaoSecaoDocumentoDTO = $objVersaoSecaoDocumentoRN->listar($objVersaoSecaoDocumentoDTO);
  36 +
  37 + $dadosSecaoDocumento = array();
  38 + $numVersao = 0;
  39 +
  40 +
  41 + //Monta as seções que precisam ser retornadas e resgata o número da última versão
  42 + $arrayRetorno = array();
  43 + if($arrObjVersaoSecaoDocumentoDTO){
  44 + foreach ($arrObjVersaoSecaoDocumentoDTO as $obj) {
  45 + if ($obj->getStrSinAssinaturaSecaoDocumento() == 'N') {
  46 + $arrayRetorno["secoes"][] = array(
  47 + "id" => $obj->getNumIdSecaoModeloSecaoDocumento(),
  48 + "conteudo" => $obj->getStrConteudo(),
  49 + "someneteLeitura" => $obj->getStrSinSomenteLeituraSecaoDocumento()
  50 + );
  51 + }
  52 +
  53 + if($obj->getNumVersao() > $numVersao){
  54 + $arrayRetorno["ultimaVersaoDocumento"] = $numVersao = $obj->getNumVersao();
  55 + } else {
  56 + $arrayRetorno["ultimaVersaoDocumento"] = $numVersao;
  57 + }
  58 + }
  59 + }
  60 +
  61 + return MdWsSeiRest::formataRetornoSucessoREST(null, $arrayRetorno);
  62 + }catch (Exception $e){
  63 + return MdWsSeiRest::formataRetornoErroREST($e);
  64 + }
  65 + }
  66 +
  67 + /**
  68 + * Realiza a pesquisa dos tipos de documento do SEI.
  69 + * @param MdWsSeiDocumentoDTO $dto
  70 + * @return array
  71 + */
  72 + protected function pesquisarTipoDocumentoConectado(MdWsSeiDocumentoDTO $dto){
  73 + try{
  74 +
  75 + $favoritos = $dto->getStrFavoritos();
  76 + $id = $dto->getNumIdTipoDocumento();
  77 + $nome = $dto->getStrNomeTipoDocumento();
  78 + $aplicabilidade = $dto->getStrAplicabilidade();
  79 + $start = $dto->getNumStart();
  80 + $limit = $dto->getNumLimit();
  81 +//PARÂMETROS DE ENTRADA
  82 +// $ID = 0;
  83 +// $FILTER = '';
  84 +// $START = 0;
  85 +// $LIMIT = 5;
  86 +// $favoritos = 'N';
  87 +
  88 + //REALIZA A BUSCA DE TODOS OS TIPOS DA UNIDADE FILTRANDO APENAS PELOS FAVORITOS. APÓS A BUSCA, OS FILTROS POR ID, NOME E APLICABILIDADE DEVERÃO SER FEITOS PERCORRENDO CADA UM DOS TIPOS.
  89 +
  90 + $serieDTO = new SerieDTO();
  91 + $serieDTO->setStrSinSomenteUtilizados($favoritos);
  92 + $serieDTO->retNumIdSerie();
  93 + $serieDTO->retStrNome();
  94 + $serieDTO->retStrStaAplicabilidade();
  95 +
  96 + $serieRN = new SerieRN();
  97 + $arrObjSerieDTO = $serieRN->listarTiposUnidade($serieDTO);
  98 +
  99 + $arrayRetorno = array();
  100 + //FILTRA NOME, ID e APLICABILIDADE
  101 + if($arrObjSerieDTO){
  102 + foreach ($arrObjSerieDTO as $aux) {
  103 + if(
  104 + ($aux->getNumIdSerie() == $id || !$id)
  105 + &&
  106 + (($nome && strpos(utf8_encode($aux->getStrNome()), $nome) !== false) || !$nome)
  107 + &&
  108 + ($aux->getStrStaAplicabilidade() == $aplicabilidade || !$aplicabilidade)
  109 + ){
  110 + $arrayRetorno[] = array(
  111 + "id" => $aux->getNumIdSerie(),
  112 + "nome" => $aux->getStrNome()
  113 + );
  114 + }
  115 + }
  116 + }
  117 +
  118 + if($start) $arrayRetorno = array_slice($arrayRetorno, ($start-1));
  119 + if($limit) $arrayRetorno = array_slice($arrayRetorno, 0,($limit));
  120 +
  121 + $total = 0;
  122 + $total = count($arrayRetorno);
  123 +
  124 + return MdWsSeiRest::formataRetornoSucessoREST(null, $arrayRetorno, $total);
  125 + }catch (Exception $e){
  126 + return MdWsSeiRest::formataRetornoErroREST($e);
  127 + }
  128 + }
  129 +
  130 +
  131 + /**
  132 + * O serviço de consulta de template de criação de processo informa ao client todas as variações existentes em um fomulário de criação de um documento. Entre essas variações estão: Assuntos Sugeridos , Existência de Destinatários_ e Existência de Interessados_ .
  133 + * @param MdWsSeiDocumentoDTO $dto
  134 + * @return array
  135 + */
  136 + protected function pesquisarTemplateDocumentoConectado(MdWsSeiDocumentoDTO $dto){
  137 + try{
  138 +// $id_tipo_documento = 46;
  139 + $id_tipo_documento = $dto->getNumIdTipoDocumento();
  140 +
  141 + //Consulta os assuntos sugeridos para um tipo de documento
  142 + $relSerieAssuntoDTO = new RelSerieAssuntoDTO();
  143 + $relSerieAssuntoDTO->setNumIdSerie($id_tipo_documento); // FILTRO PELO TIPO DE DOCUMENTO
  144 + $relSerieAssuntoDTO->retNumIdAssuntoProxy(); // ID DO ASSUNTO QUE DEVE SE RETORNADO
  145 + $relSerieAssuntoDTO->retStrCodigoEstruturadoAssunto(); // CÓDIGO DO ASSUNTO QUE DEVE SE RETORNADO
  146 + $relSerieAssuntoDTO->retStrDescricaoAssunto(); // DESCRIÇÃO DO ASSUNTO
  147 +
  148 + $relSerieAssuntoRN = new RelSerieAssuntoRN();
  149 + $arrRelSerieAssuntoDTO = $relSerieAssuntoRN->listar($relSerieAssuntoDTO);
  150 +
  151 + $assuntos = array();
  152 + if($arrRelSerieAssuntoDTO){
  153 + foreach ($arrRelSerieAssuntoDTO as $obj) {
  154 + $assuntos[] = array(
  155 + "id" => $obj->getNumIdAssuntoProxy(),
  156 + "codigo" => $obj->getStrCodigoEstruturadoAssunto(),
  157 + "descricao" => $obj->getStrDescricaoAssunto()
  158 + );
  159 + }
  160 + }
  161 +
  162 + // Consulta se o tipo de documento permite a inclusão de destinatários e interessados
  163 + $serieDTO = new SerieDTO();
  164 + $serieDTO->setNumIdSerie($id_tipo_documento);
  165 + $serieDTO->retStrSinDestinatario();
  166 + $serieDTO->retStrSinInteressado();
  167 +
  168 + $serieRN = new SerieRN();
  169 + $arrSerieDTO = $serieRN->listarRN0646($serieDTO);
  170 +
  171 + $serie = "";
  172 + if($arrSerieDTO) {
  173 + $serie = $arrSerieDTO[0];
  174 + $permiteInteressados = true;
  175 + $permiteDestinatarios = true;
  176 + if($serie->getStrSinInteressado() == "N") $permiteInteressados = false;
  177 + if($serie->getStrSinDestinatario() == "N") $permiteDestinatarios = false;
  178 + }
  179 +
  180 + $arrayRetorno = array(
  181 + "assuntos" => $assuntos,
  182 + "permiteInteressados" => $permiteInteressados,
  183 + "permiteDestinatarios" => $permiteDestinatarios
  184 + );
  185 +
  186 + return MdWsSeiRest::formataRetornoSucessoREST(null, $arrayRetorno);
  187 + }catch (Exception $e){
  188 + return MdWsSeiRest::formataRetornoErroREST($e);
  189 + }
  190 + }
  191 +
  192 +
  193 +
  194 + /**
  195 + * Alterar Seção do documento
  196 + * @param DocumentoDTO DocumentoDTO
  197 + * @return array
  198 + */
  199 + public function alterarSecaoDocumento($dados){
  200 + try{
  201 + $idDocumento = $dados["documento"];
  202 + $numVersao = $dados["versao"];
  203 + $arrSecoes = $dados["secoes"];
  204 +
  205 + // Criação do DTO de editor que realiza a edição das seções.
  206 + $objEditorDTO = new EditorDTO();
  207 +
  208 + $objEditorDTO->setDblIdDocumento($idDocumento); // Informa o id do documento
  209 + $objEditorDTO->setNumVersao($numVersao); // Número da versão
  210 + $objEditorDTO->setNumIdBaseConhecimento(null);
  211 + $objEditorDTO->setStrSinIgnorarNovaVersao('N');
  212 +
  213 + // Percorre as seções do documento alteradas
  214 + $arrObjSecaoDocumentoDTO = array();
  215 + if($arrSecoes){
  216 + foreach ($arrSecoes as $secao) {
  217 + $objSecaoDocumentoDTO = new SecaoDocumentoDTO();
  218 + $objSecaoDocumentoDTO->setNumIdSecaoModelo($secao['id']);
  219 + $objSecaoDocumentoDTO->setStrConteudo($secao['conteudo']);
  220 + $arrObjSecaoDocumentoDTO[] = $objSecaoDocumentoDTO;
  221 + }
  222 + }
  223 +
  224 + $objEditorDTO->setArrObjSecaoDocumentoDTO($arrObjSecaoDocumentoDTO);
  225 +
  226 + // Realiza a alteração das seções.
  227 + $objEditorRN = new EditorRN();
  228 + $numVersao = $objEditorRN->adicionarVersao($objEditorDTO);
  229 +
  230 +
  231 + return MdWsSeiRest::formataRetornoSucessoREST(null, $numVersao);
  232 + }catch (Exception $e){
  233 + return MdWsSeiRest::formataRetornoErroREST($e);
  234 + }
  235 + }
  236 +
  237 +
  238 + /**
  239 + * Alterar Documento Externo
  240 + * @param DocumentoDTO DocumentoDTO
  241 + * @return array
  242 + */
  243 + public function alterarDocumentoExterno($dados){
  244 + try{
  245 + $documento = $dados['documento'];
  246 + $idTipoDocumento = $dados['idTipoDocumento'];
  247 + $numero = $dados['numero'];
  248 + $data = $dados['data'];
  249 + $arrAssuntos = $dados['assuntos'];
  250 + $arrInteressados = $dados['interessados'];
  251 + $arrDestinatarios = $dados['destinatarios'];
  252 + $arrRemetentes = $dados['remetentes'];
  253 + $nivelAcesso = $dados['nivelAcesso'];
  254 + $hipoteseLegal = $dados['hipoteseLegal'];
  255 + $grauSigilo = $dados['grauSigilo'];
  256 + $observacao = $dados['observacao'];
  257 +
  258 +
  259 + //Altera os dados do documento
  260 + $protocoloDTO = new ProtocoloDTO();
  261 + $protocoloDTO->setDblIdProtocolo($documento);
  262 + $protocoloDTO->setDtaGeracao($data);
  263 + $protocoloDTO->setStrNumeroDocumento($numero);
  264 + $protocoloDTO->setStrDescricao($descricao);
  265 + $protocoloDTO->setStrStaNivelAcessoLocal($nivelAcesso);
  266 + $protocoloDTO->setNumIdHipoteseLegal($hipoteseLegal);
  267 + $protocoloDTO->setStrStaGrauSigilo($grauSigilo);
  268 +
  269 + //Altera os Destinatários, Remetentes e Interessados
  270 + $arrParticipantes = array();
  271 +
  272 + $i = 0;
  273 + if($arrInteressados){
  274 + foreach ($arrInteressados as $interessado) {
  275 + $objParticipanteDTO = new ParticipanteDTO();
  276 + $objParticipanteDTO->setNumIdContato($interessado['id']);
  277 + $objParticipanteDTO->setStrStaParticipacao(ParticipanteRN::$TP_INTERESSADO);
  278 + $objParticipanteDTO->setNumSequencia($i);
  279 + $i++;
  280 +
  281 + $arrParticipantes[] = $objParticipanteDTO;
  282 + }
  283 + }
  284 +
  285 + $i = 0;
  286 + if($arrDestinatarios){
  287 + foreach ($arrDestinatarios as $destinatario) {
  288 + $objParticipanteDTO = new ParticipanteDTO();
  289 + $objParticipanteDTO->setNumIdContato($destinatario['id']);
  290 + $objParticipanteDTO->setStrStaParticipacao(ParticipanteRN::$TP_DESTINATARIO);
  291 + $objParticipanteDTO->setNumSequencia($i);
  292 + $i++;
  293 +
  294 + $arrParticipantes[] = $objParticipanteDTO;
  295 + }
  296 + }
  297 +
  298 + $i = 0;
  299 + if($arrRemetentes){
  300 + foreach ($arrRemetentes as $remetente) {
  301 + $objParticipanteDTO = new ParticipanteDTO();
  302 + $objParticipanteDTO->setNumIdContato($remetente['id']);
  303 + $objParticipanteDTO->setStrStaParticipacao(ParticipanteRN::$TP_REMETENTE);
  304 + $objParticipanteDTO->setNumSequencia($i);
  305 + $i++;
  306 +
  307 + $arrParticipantes[] = $objParticipanteDTO;
  308 + }
  309 + }
  310 +
  311 + $protocoloDTO->setArrObjParticipanteDTO($arrParticipantes);
  312 +
  313 + //Altera os assuntos
  314 + $arrRelProtocoloAssuntoDTO = array();
  315 +
  316 + $i = 0;
  317 + if($arrRemetentes){
  318 + foreach($arrAssuntos as $assunto){
  319 + $relProtocoloAssuntoDTO = new RelProtocoloAssuntoDTO();
  320 + $relProtocoloAssuntoDTO->setNumIdAssunto($assunto['id']);
  321 + $relProtocoloAssuntoDTO->setDblIdProtocolo($idDocumento);
  322 + $relProtocoloAssuntoDTO->setNumSequencia($i);
  323 + $arrRelProtocoloAssuntoDTO[] = $relProtocoloAssuntoDTO;
  324 +
  325 + $i++;
  326 + }
  327 + }
  328 +
  329 + $protocoloDTO->setArrObjRelProtocoloAssuntoDTO($arrRelProtocoloAssuntoDTO);
  330 +
  331 + //Edita a observação
  332 + $observacaoDTO = new ObservacaoDTO();
  333 + $observacaoDTO->setStrDescricao($observacao);
  334 + $protocoloDTO->setArrObjObservacaoDTO(array($observacaoDTO));
  335 +
  336 + //Edita o tipo de documento e número
  337 + $documentoDTO = new DocumentoDTO();
  338 + $documentoDTO->setDblIdDocumento($documento);
  339 + $documentoDTO->setNumIdSerie($idTipoDocumento);
  340 + $documentoDTO->setStrNumero($numero);
  341 + $documentoDTO->setObjProtocoloDTO($protocoloDTO);
  342 +
  343 + $documentoRN = new DocumentoRN();
  344 + $documentoRN->alterarRN0004($documentoDTO);
  345 +
  346 +
  347 + return MdWsSeiRest::formataRetornoSucessoREST(nulL);
  348 + }catch (Exception $e){
  349 + return MdWsSeiRest::formataRetornoErroREST($e);
  350 + }
  351 + }
  352 +
  353 +
  354 + /**
  355 + * Alterar Documento Iterno
  356 + * @param DocumentoDTO DocumentoDTO
  357 + * @return array
  358 + */
  359 + public function alterarDocumentoInterno($dados){
  360 + try{
  361 + $documento = $dados['documento'];
  362 + $idTipoDocumento = $dados['idTipoDocumento'];
  363 + $arrAssuntos = $dados['assuntos'];
  364 + $arrInteressados = $dados['interessados'];
  365 + $arrDestinatarios = $dados['destinatarios'];
  366 + $nivelAcesso = $dados['nivelAcesso'];
  367 + $hipoteseLegal = $dados['hipoteseLegal'];
  368 + $grauSigilo = $dados['grauSigilo'];
  369 + $observacao = $dados['observacao'];
  370 +
  371 + //PARÂMETROS DE ENTRADA
  372 +// $documento = 106;
  373 +// $descricao = "DESCRIÇÃO E TESTE";
  374 +// $arrAssuntos = array(array('id' => 2), array('id' => 4));
  375 +// $arrInteressados = array(array('id' => 100000008), array('id' => 100000010), array('id' => 100000002), array('id' => 100000006));
  376 +// $arrDestinatarios = array(array('id' => 100000008));
  377 +// $nivelAcesso = 0;
  378 +// $hipoteseLegal = "";
  379 +// $grauSigilo = "";
  380 +// $observacao = "OBSERVAÇÃO TESTE UM";
  381 +
  382 + //Altera os dados do documento
  383 + $protocoloDTO = new ProtocoloDTO();
  384 + $protocoloDTO->setDblIdProtocolo($documento);
  385 + $protocoloDTO->setStrDescricao("asdadas");
  386 + $protocoloDTO->setStrStaNivelAcessoLocal($nivelAcesso);
  387 + $protocoloDTO->setNumIdHipoteseLegal($hipoteseLegal);
  388 + $protocoloDTO->setStrStaGrauSigilo($grauSigilo);
  389 +
  390 + //Altera os Destinatários e Interessados
  391 + $arrParticipantes = array();
  392 +
  393 + $i = 0;
  394 + foreach ($arrInteressados as $interessado) {
  395 + $objParticipanteDTO = new ParticipanteDTO();
  396 + $objParticipanteDTO->setNumIdContato($interessado['id']);
  397 + $objParticipanteDTO->setStrStaParticipacao(ParticipanteRN::$TP_INTERESSADO);
  398 + $objParticipanteDTO->setNumSequencia($i);
  399 + $i++;
  400 +
  401 + $arrParticipantes[] = $objParticipanteDTO;
  402 + }
  403 +
  404 + $i = 0;
  405 + foreach ($arrDestinatarios as $destinatario) {
  406 + $objParticipanteDTO = new ParticipanteDTO();
  407 + $objParticipanteDTO->setNumIdContato($destinatario['id']);
  408 + $objParticipanteDTO->setStrStaParticipacao(ParticipanteRN::$TP_DESTINATARIO);
  409 + $objParticipanteDTO->setNumSequencia($i);
  410 + $i++;
  411 +
  412 + $arrParticipantes[] = $objParticipanteDTO;
  413 + }
  414 +
  415 + $protocoloDTO->setArrObjParticipanteDTO($arrParticipantes);
  416 +
  417 + //Altera os assuntos
  418 + $arrRelProtocoloAssuntoDTO = array();
  419 +
  420 + $i = 0;
  421 + foreach($arrAssuntos as $assunto){
  422 + $relProtocoloAssuntoDTO = new RelProtocoloAssuntoDTO();
  423 + $relProtocoloAssuntoDTO->setNumIdAssunto($assunto['id']);
  424 + $relProtocoloAssuntoDTO->setDblIdProtocolo($documento);
  425 + $relProtocoloAssuntoDTO->setNumSequencia($i);
  426 + $arrRelProtocoloAssuntoDTO[] = $relProtocoloAssuntoDTO;
  427 +
  428 + $i++;
  429 + }
  430 +
  431 + $protocoloDTO->setArrObjRelProtocoloAssuntoDTO($arrRelProtocoloAssuntoDTO);
  432 +
  433 + //Edita a observação
  434 + $observacaoDTO = new ObservacaoDTO();
  435 + $observacaoDTO->setStrDescricao($observacao);
  436 + $protocoloDTO->setArrObjObservacaoDTO(array($observacaoDTO));
  437 +
  438 + //Edita o tipo de documento e número
  439 + $documentoDTO = new DocumentoDTO();
  440 + $documentoDTO->setDblIdDocumento($documento);
  441 + $documentoDTO->setObjProtocoloDTO($protocoloDTO);
  442 +
  443 + $documentoRN = new DocumentoRN();
  444 + $documentoRN->alterarRN0004($documentoDTO);
  445 +
  446 +
  447 + return MdWsSeiRest::formataRetornoSucessoREST(nulL);
  448 + }catch (Exception $e){
  449 + return MdWsSeiRest::formataRetornoErroREST($e);
  450 + }
  451 + }
  452 +
  453 +
  454 + /**
  455 + * Método que cria um documento interno
  456 + * @param MdWsSeiDocumentoDTO $dto
  457 + * @return array
  458 + */
  459 + protected function documentoInternoCriarConectado(MdWsSeiDocumentoDTO $dto){
  460 + try{
  461 + $idProcesso = $dto->getNumIdProcesso();
  462 + $idTipoDocumento = $dto->getNumIdTipoDocumento();
  463 + $descricao = $dto->getStrDescricao();
  464 + $nivelAcesso = $dto->getStrNivelAcesso();
  465 + $hipoteseLegal = $dto->getNumIdHipoteseLegal();
  466 + $grauSigilo = $dto->getStrGrauSigilo();
  467 + $arrAssuntos = $dto->getArrAssuntos();
  468 + $arrInteressados = $dto->getArrInteressados();
  469 + $arrDestinatarios = $dto->getArrDestinatarios();
  470 + $observacao = $dto->getStrObservacao();
  471 +
  472 +// $idProcesso = 13;
  473 +// $idTipoDocumento = 12;
  474 +// $descricao = 'descrição de teste';
  475 +// $nivelAcesso = 1;
  476 +// $hipoteseLegal = 1;
  477 +// $grauSigilo = '';
  478 +// $arrAssuntos = array(array('id' => 2), array('id' => 4));
  479 +// $arrInteressados = array(array('id' => 100000008), array('id' => 100000010), array('id' => 100000002), array('id' => 100000006));
  480 +// $arrDestinatarios = array(array('id' => 100000008));
  481 +// $observacao = 'teste';
  482 +
  483 + $objDocumentoDTO = new DocumentoDTO();
  484 + $objDocumentoDTO->setDblIdDocumento(null);
  485 + $objDocumentoDTO->setDblIdProcedimento($idProcesso);
  486 +
  487 + $objProtocoloDTO = new ProtocoloDTO();
  488 + $objProtocoloDTO->setDblIdProtocolo(null);
  489 + $objProtocoloDTO->setStrStaProtocolo('G');
  490 + // $objProtocoloDTO->setDtaGeracao($dtaGeracao);
  491 +
  492 + $objDocumentoDTO->setNumIdSerie($idTipoDocumento);
  493 + // $objDocumentoDTO->setStrNomeSerie($nomeTipo);
  494 +
  495 + $objDocumentoDTO->setDblIdDocumentoEdoc(null);
  496 + $objDocumentoDTO->setDblIdDocumentoEdocBase(null);
  497 + $objDocumentoDTO->setNumIdUnidadeResponsavel(SessaoSEI::getInstance()->getNumIdUnidadeAtual());
  498 + $objDocumentoDTO->setNumIdTipoConferencia(null);
  499 + $objDocumentoDTO->setStrNumero('');
  500 + // $objDocumentoDTO->setNumIdTipoConferencia($objDocumentoAPI->getIdTipoConferencia());
  501 +
  502 + $objProtocoloDTO->setStrStaNivelAcessoLocal($nivelAcesso);
  503 + $objProtocoloDTO->setNumIdHipoteseLegal($hipoteseLegal);
  504 + $objProtocoloDTO->setStrDescricao($descricao);
  505 + $objProtocoloDTO->setStrStaGrauSigilo($grauSigilo);
  506 +
  507 + $arrParticipantesDTO = array();
  508 + if($arrInteressados){
  509 + foreach ($arrInteressados as $k => $interessado) {
  510 + $objParticipanteDTO = new ParticipanteDTO();
  511 + $objParticipanteDTO->setNumIdContato($interessado['id']);
  512 + $objParticipanteDTO->setStrStaParticipacao(ParticipanteRN::$TP_INTERESSADO);
  513 + $objParticipanteDTO->setNumSequencia($k);
  514 + $arrParticipantesDTO[] = $objParticipanteDTO;
  515 + }
  516 + }
  517 +
  518 + if($arrDestinatarios){
  519 + foreach ($arrDestinatarios as $k => $destinatario) {
  520 + $objParticipanteDTO = new ParticipanteDTO();
  521 + $objParticipanteDTO->setNumIdContato($destinatario['id']);
  522 + $objParticipanteDTO->setStrStaParticipacao(ParticipanteRN::$TP_DESTINATARIO);
  523 + $objParticipanteDTO->setNumSequencia($k);
  524 + $arrParticipantesDTO[] = $objParticipanteDTO;
  525 + }
  526 + }
  527 + $arrRelProtocoloAssuntoDTO = array();
  528 +
  529 + if($arrAssuntos){
  530 + foreach ($arrAssuntos as $k => $assunto) {
  531 + $relProtocoloAssuntoDTO = new RelProtocoloAssuntoDTO();
  532 + $relProtocoloAssuntoDTO->setNumIdAssunto($assunto['id']);
  533 + $relProtocoloAssuntoDTO->setDblIdProtocolo($idProcesso);
  534 + $relProtocoloAssuntoDTO->setNumSequencia($k);
  535 + $arrRelProtocoloAssuntoDTO[] = $relProtocoloAssuntoDTO;
  536 + }
  537 + }
  538 +
  539 + $objProtocoloDTO->setArrObjParticipanteDTO($arrParticipantesDTO);
  540 + $objProtocoloDTO->setArrObjRelProtocoloAssuntoDTO($arrRelProtocoloAssuntoDTO);
  541 +
  542 + //OBSERVACOES
  543 + $objObservacaoDTO = new ObservacaoDTO();
  544 + $objObservacaoDTO->setStrDescricao($observacao);
  545 + $objProtocoloDTO->setArrObjObservacaoDTO(array($objObservacaoDTO));
  546 +
  547 + $objDocumentoDTO->setObjProtocoloDTO($objProtocoloDTO);
  548 + $objDocumentoDTO->setStrStaDocumento(DocumentoRN::$TD_EDITOR_INTERNO);
  549 +
  550 + $objDocumentoRN = new DocumentoRN();
  551 + $obj = $objDocumentoRN->cadastrarRN0003($objDocumentoDTO);
  552 +
  553 + $arrayRetorno = array();
  554 + if($obj){
  555 + $arrayRetorno = array(
  556 + "IdDocumento" => $obj->getDblIdDocumento(),
  557 + "ProtocoloDocumentoFormatado" => $obj->getStrProtocoloDocumentoFormatado()
  558 + );
  559 + }
  560 +
  561 + return MdWsSeiRest::formataRetornoSucessoREST(null, $arrayRetorno);
  562 + }catch (Exception $e){
  563 + return MdWsSeiRest::formataRetornoErroREST($e);
  564 + }
  565 + }
  566 +
  567 +
  568 + /**
  569 + * Método que cria um documento interno
  570 + * @param MdWsSeiDocumentoDTO $dto
  571 + * @return array
  572 + */
  573 + protected function documentoExternoCriarConectado(MdWsSeiDocumentoDTO $dto){
  574 + try{
  575 + $idProcesso = $dto->getNumIdProcesso();
  576 + $idTipoDocumento = $dto->getNumIdTipoDocumento();
  577 + $dataGeracaoDocumento = $dto->getDtaDataGeracaoDocumento();
  578 + $numero = $dto->getStrNumero();
  579 + $descricao = $dto->getStrDescricao();
  580 + $nomeArquivo = $dto->getStrNomeArquivo();
  581 + $nivelAcesso = $dto->getStrNivelAcesso();
  582 + $hipoteseLegal = $dto->getNumIdHipoteseLegal();
  583 + $grauSigilo = $dto->getStrGrauSigilo();
  584 + $arrAssuntos = $dto->getArrAssuntos();
  585 + $arrInteressados = $dto->getArrInteressados();
  586 + $arrDestinatarios = $dto->getArrDestinatarios();
  587 + $arrRemetentes = $dto->getArrRemetentes();
  588 + $conteudoDocumento = $dto->getStrConteudoDocumento();
  589 + $observacao = $dto->getStrObservacao();
  590 +
  591 +
  592 + //Parâmetros de entrada
  593 +// $idProcesso = 15;
  594 +// $dataGeracaoDocumento = '25/01/2017';
  595 +// $idTipoDocumento = 8;
  596 +// $numero = '598714789156';
  597 +// $descricao = 'descrição de teste';
  598 +// $nome_arquivo = 'teste.pdf';
  599 +// $nivelAcesso = 1;
  600 +// $hipoteseLegal = 1;
  601 +// $grauSigilo = '';
  602 +// $arrAssuntos = array(array('id' => 2), array('id' => 4));
  603 +// $arrInteressados = array(array('id' => 100000008), array('id' => 100000010), array('id' => 100000002), array('id' => 100000006));
  604 +// $arrDestinatarios = array(array('id' => 100000008));
  605 +// $arrRemetentes = array(array('id' => 100000008));
  606 +// $conteudoDocumento = file_get_contents('/opt/sei/web/modulos/mod-wssei/codigo-fonte/mod-wssei/rn/c.pdf'); // DEVE CONTER O BINÁRIO DO ARQUIVO. ESSE FILE_GET_CONTENTS É UM EXEMPLO APENAS
  607 +// $observacao = 'ewefwe';
  608 +
  609 + //Popula os dados do documento para salvamento
  610 + $objDocumentoDTO = new DocumentoDTO();
  611 + $objDocumentoDTO->setDblIdDocumento(null);
  612 + $objDocumentoDTO->setDblIdProcedimento($idProcesso);
  613 + $objDocumentoDTO->setNumIdSerie($idTipoDocumento);
  614 + $objDocumentoDTO->setDblIdDocumentoEdoc(null);
  615 + $objDocumentoDTO->setDblIdDocumentoEdocBase(null);
  616 + $objDocumentoDTO->setNumIdUnidadeResponsavel(SessaoSEI::getInstance()->getNumIdUnidadeAtual());
  617 + $objDocumentoDTO->setNumIdTipoConferencia(null);
  618 + $objDocumentoDTO->setStrNumero($numero);
  619 +
  620 + //Popula os dados do protocolo do documento
  621 + $objProtocoloDTO = new ProtocoloDTO();
  622 + $objProtocoloDTO->setDblIdProtocolo(null);
  623 + $objProtocoloDTO->setStrStaProtocolo('R');
  624 + $objProtocoloDTO->setDtaGeracao($dataGeracaoDocumento);
  625 + $objProtocoloDTO->setStrStaNivelAcessoLocal($nivelAcesso);
  626 + $objProtocoloDTO->setNumIdHipoteseLegal($hipoteseLegal);
  627 + $objProtocoloDTO->setStrDescricao($descricao);
  628 + $objProtocoloDTO->setStrStaGrauSigilo($grauSigilo);
  629 +
  630 + //Popula os remetentes, destinatários e interessados
  631 + $arrParticipantesDTO = array();
  632 + if($arrRemetentes){
  633 + foreach ($arrRemetentes as $k => $remetente) {
  634 + $objParticipanteDTO = new ParticipanteDTO();
  635 + $objParticipanteDTO->setNumIdContato($remetente['id']);
  636 + $objParticipanteDTO->setStrStaParticipacao(ParticipanteRN::$TP_REMETENTE);
  637 + $objParticipanteDTO->setNumSequencia($k);
  638 + $arrParticipantesDTO[] = $objParticipanteDTO;
  639 + }
  640 + }
  641 + if($arrInteressados){
  642 + foreach ($arrInteressados as $k => $interessado) {
  643 + $objParticipanteDTO = new ParticipanteDTO();
  644 + $objParticipanteDTO->setNumIdContato($interessado['id']);
  645 + $objParticipanteDTO->setStrStaParticipacao(ParticipanteRN::$TP_INTERESSADO);
  646 + $objParticipanteDTO->setNumSequencia($k);
  647 + $arrParticipantesDTO[] = $objParticipanteDTO;
  648 + }
  649 + }
  650 + if($arrDestinatarios){
  651 + foreach ($arrDestinatarios as $k => $destinatario) {
  652 + $objParticipanteDTO = new ParticipanteDTO();
  653 + $objParticipanteDTO->setNumIdContato($destinatario['id']);
  654 + $objParticipanteDTO->setStrStaParticipacao(ParticipanteRN::$TP_DESTINATARIO);
  655 + $objParticipanteDTO->setNumSequencia($k);
  656 + $arrParticipantesDTO[] = $objParticipanteDTO;
  657 + }
  658 + }
  659 + //Popula os assuntos
  660 + $arrRelProtocoloAssuntoDTO = array();
  661 + if($arrAssuntos){
  662 + foreach ($arrAssuntos as $k => $assunto) {
  663 + $relProtocoloAssuntoDTO = new RelProtocoloAssuntoDTO();
  664 + $relProtocoloAssuntoDTO->setNumIdAssunto($assunto['id']);
  665 + $relProtocoloAssuntoDTO->setDblIdProtocolo($idProcesso);
  666 + $relProtocoloAssuntoDTO->setNumSequencia($k);
  667 + $arrRelProtocoloAssuntoDTO[] = $relProtocoloAssuntoDTO;
  668 + }
  669 + }
  670 + $objProtocoloDTO->setArrObjParticipanteDTO($arrParticipantesDTO);
  671 + $objProtocoloDTO->setArrObjRelProtocoloAssuntoDTO($arrRelProtocoloAssuntoDTO);
  672 +
  673 + //OBSERVACOES
  674 + $objObservacaoDTO = new ObservacaoDTO();
  675 + $objObservacaoDTO->setStrDescricao($observacao);
  676 + $objProtocoloDTO->setArrObjObservacaoDTO(array($objObservacaoDTO));
  677 +
  678 + $objAnexoDTO = new AnexoDTO();
  679 + $objAnexoDTO->setStrNome($nome_arquivo);
  680 + $objProtocoloDTO->setArrObjAnexoDTO(array($objAnexoDTO));
  681 +
  682 + $objDocumentoDTO->setObjProtocoloDTO($objProtocoloDTO);
  683 + $objDocumentoDTO->setStrConteudo(null);
  684 + $objDocumentoDTO->setStrStaDocumento(DocumentoRN::$TD_EXTERNO);
  685 +
  686 + $arrObjAnexoDTO = $objDocumentoDTO->getObjProtocoloDTO()->getArrObjAnexoDTO();
  687 +
  688 + //Adiciona o anexo
  689 + if (count($arrObjAnexoDTO) == 1) {
  690 +
  691 + if (!$arrObjAnexoDTO[0]->isSetNumIdAnexoOrigem()) {
  692 + $objAnexoRN = new AnexoRN();
  693 + $strNomeArquivoUpload = $objAnexoRN->gerarNomeArquivoTemporario();
  694 +
  695 + $fp = fopen(DIR_SEI_TEMP . '/' . $strNomeArquivoUpload, 'w');
  696 + fwrite($fp, $conteudoDocumento);
  697 + fclose($fp);
  698 +
  699 + $arrObjAnexoDTO[0]->setNumIdAnexo($strNomeArquivoUpload);
  700 + $arrObjAnexoDTO[0]->setDthInclusao(InfraData::getStrDataHoraAtual());
  701 + $arrObjAnexoDTO[0]->setNumTamanho(filesize(DIR_SEI_TEMP . '/' . $strNomeArquivoUpload));
  702 + $arrObjAnexoDTO[0]->setNumIdUsuario(SessaoSEI::getInstance()->getNumIdUsuario());
  703 + }
  704 + }
  705 +
  706 + //Gera o documento
  707 + $objDocumentoRN = new DocumentoRN();
  708 + $objDocumentoDTOGerado = $objDocumentoRN->cadastrarRN0003($objDocumentoDTO);
  709 +
  710 +
  711 +
  712 + $arrayRetorno = array();
  713 + if($obj){
  714 + $arrayRetorno = array(
  715 + "IdDocumento" => $obj->getDblIdDocumento(),
  716 + "ProtocoloDocumentoFormatado" => $obj->getStrProtocoloDocumentoFormatado()
  717 + );
  718 + }
  719 +
  720 + return MdWsSeiRest::formataRetornoSucessoREST(null, $arrayRetorno);
  721 + }catch (Exception $e){
  722 + return MdWsSeiRest::formataRetornoErroREST($e);
  723 + }
  724 + }
  725 +
  726 + /**
  727 + * Método que retorna os documentos de um processo
  728 + * @param DocumentoDTO $documentoDTOParam
  729 + * @return array
  730 + */
  731 + protected function listarDocumentosProcessoConectado(DocumentoDTO $documentoDTOParam){
  732 + try{
  733 + $arrDocHtml = array(
  734 + DocumentoRN::$TD_EDITOR_EDOC,
  735 + DocumentoRN::$TD_FORMULARIO_AUTOMATICO,
  736 + DocumentoRN::$TD_FORMULARIO_GERADO,
  737 + DocumentoRN::$TD_EDITOR_INTERNO
  738 + );
  739 + $result = array();
  740 + $relProtocoloProtocoloDTOConsulta = new RelProtocoloProtocoloDTO();
  741 + if(!$documentoDTOParam->isSetDblIdProcedimento()){
  742 + throw new InfraException('O procedimento deve ser informado.');
  743 + }
  744 + $relProtocoloProtocoloDTOConsulta->setDblIdProtocolo1($documentoDTOParam->getDblIdProcedimento());
  745 + $relProtocoloProtocoloDTOConsulta->setStrStaProtocoloProtocolo2(
  746 + array(ProtocoloRN::$TP_DOCUMENTO_GERADO, ProtocoloRN::$TP_DOCUMENTO_RECEBIDO),
  747 + InfraDTO::$OPER_IN
  748 + );
  749 + $relProtocoloProtocoloDTOConsulta->retStrSinCiencia();
  750 + $relProtocoloProtocoloDTOConsulta->retDblIdProtocolo1();
  751 + $relProtocoloProtocoloDTOConsulta->retDblIdProtocolo2();
  752 + $relProtocoloProtocoloDTOConsulta->retNumSequencia();
  753 + $relProtocoloProtocoloDTOConsulta->setOrdNumSequencia(InfraDTO::$TIPO_ORDENACAO_ASC);
  754 + if($documentoDTOParam->getNumMaxRegistrosRetorno()){
  755 + $relProtocoloProtocoloDTOConsulta->setNumMaxRegistrosRetorno($documentoDTOParam->getNumMaxRegistrosRetorno());
  756 + }else{
  757 + $relProtocoloProtocoloDTOConsulta->setNumMaxRegistrosRetorno(10);
  758 + }
  759 + if(is_null($documentoDTOParam->getNumPaginaAtual())){
  760 + $relProtocoloProtocoloDTOConsulta->setNumPaginaAtual(0);
  761 + }else{
  762 + $relProtocoloProtocoloDTOConsulta->setNumPaginaAtual($documentoDTOParam->getNumPaginaAtual());
  763 + }
  764 +
  765 + $relProtocoloProtocoloRN = new RelProtocoloProtocoloRN();
  766 + $ret = $relProtocoloProtocoloRN->listarRN0187($relProtocoloProtocoloDTOConsulta);
  767 + $arrDocumentos = array();
  768 + if($ret){
  769 + $unidadeDTO = new UnidadeDTO();
  770 + $unidadeDTO->setBolExclusaoLogica(false);
  771 + $unidadeDTO->retStrSinProtocolo();
  772 + $unidadeDTO->retStrSinOuvidoria();
  773 + $unidadeDTO->retStrSinArquivamento();
  774 + $unidadeDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual());
  775 +
  776 + $unidadeRN = new UnidadeRN();
  777 + $unidadeDTO = $unidadeRN->consultarRN0125($unidadeDTO);
  778 + $bolFlagProtocolo = ($unidadeDTO->getStrSinProtocolo() == 'S');
  779 +
  780 + $documentoDTOConsulta = new DocumentoDTO();
  781 + $documentoDTOConsulta->retStrStaNivelAcessoLocalProtocolo();
  782 + $documentoDTOConsulta->retDblIdDocumento();
  783 + $documentoDTOConsulta->retStrStaProtocoloProtocolo();
  784 + $documentoDTOConsulta->retDblIdProcedimento();
  785 + $documentoDTOConsulta->retStrProtocoloDocumentoFormatado();
  786 + $documentoDTOConsulta->retStrNumero();
  787 + $documentoDTOConsulta->retStrStaDocumento();
  788 + $documentoDTOConsulta->retNumIdSerie();
  789 + $documentoDTOConsulta->retStrNomeSerie();
  790 + $documentoDTOConsulta->retStrSiglaUnidadeGeradoraProtocolo();
  791 + $documentoDTOConsulta->retStrSiglaUnidadeGeradoraProtocolo();
  792 + $documentoDTOConsulta->retNumIdUnidadeGeradoraProtocolo();
  793 + $documentoDTOConsulta->retStrCrcAssinatura();
  794 + $documentoDTOConsulta->retStrStaEstadoProtocolo();
  795 + $documentoDTOConsulta->setDblIdDocumento(array_keys(InfraArray::indexarArrInfraDTO($ret,'IdProtocolo2')), InfraDTO::$OPER_IN);
  796 + $documentoBD = new DocumentoBD($this->getObjInfraIBanco());
  797 + $retDocumentos = $documentoBD->listar($documentoDTOConsulta);
  798 + /** @var DocumentoDTO $documentoDTOOrd */
  799 + foreach ($retDocumentos as $documentoDTOOrd){
  800 + $arrDocumentos[$documentoDTOOrd->getDblIdDocumento()] = $documentoDTOOrd;
  801 + }
  802 + }
  803 +
  804 + $anexoRN = new AnexoRN();
  805 + $observacaoRN = new ObservacaoRN();
  806 + $publicacaoRN = new PublicacaoRN();
  807 + /** @var RelProtocoloProtocoloDTO $relProtocoloProtocoloDTO */
  808 + foreach($ret as $relProtocoloProtocoloDTO){
  809 + $documentoDTO = $arrDocumentos[$relProtocoloProtocoloDTO->getDblIdProtocolo2()];
  810 + $mimetype = null;
  811 + $nomeAnexo = null;
  812 + $informacao = null;
  813 + $tamanhoAnexo = null;
  814 + $ciencia = 'N';
  815 + $documentoCancelado = $documentoDTO->getStrStaEstadoProtocolo() == ProtocoloRN::$TE_DOCUMENTO_CANCELADO
  816 + ? 'S' : 'N';
  817 +
  818 + if(!in_array($documentoDTO->getStrStaDocumento(), $arrDocHtml)){
  819 + $anexoDTOConsulta = new AnexoDTO();
  820 + $anexoDTOConsulta->retStrNome();
  821 + $anexoDTOConsulta->retNumTamanho();
  822 + $anexoDTOConsulta->setDblIdProtocolo($documentoDTO->getDblIdDocumento());
  823 + $anexoDTOConsulta->setStrSinAtivo('S');
  824 + $anexoDTOConsulta->setNumMaxRegistrosRetorno(1);
  825 + $resultAnexo = $anexoRN->listarRN0218($anexoDTOConsulta);
  826 + if($resultAnexo){
  827 + /** @var AnexoDTO $anexoDTO */
  828 + $anexoDTO = $resultAnexo[0];
  829 + $mimetype = $anexoDTO->getStrNome();
  830 + $mimetype = substr($mimetype, strrpos($mimetype, '.')+1);
  831 + $nomeAnexo = $anexoDTO->getStrNome();
  832 + $tamanhoAnexo = $anexoDTO->getNumTamanho();
  833 + }
  834 + }
  835 + $observacaoDTOConsulta = new ObservacaoDTO();
  836 + $observacaoDTOConsulta->setNumMaxRegistrosRetorno(1);
  837 + $observacaoDTOConsulta->setOrdNumIdObservacao(InfraDTO::$TIPO_ORDENACAO_DESC);
  838 + $observacaoDTOConsulta->retStrDescricao();
  839 + $resultObservacao = $observacaoRN->listarRN0219($observacaoDTOConsulta);
  840 + if($resultObservacao){
  841 + /** @var ObservacaoDTO $observacaoDTO */
  842 + $observacaoDTO = $resultObservacao[0];
  843 + $informacao = substr($observacaoDTO->getStrDescricao(), 0, 250);
  844 + }
  845 + $publicacaoDTOConsulta = new PublicacaoDTO();
  846 + $publicacaoDTOConsulta->setDblIdDocumento($documentoDTO->getDblIdDocumento());
  847 + $publicacaoDTOConsulta->retDblIdDocumento();
  848 + $publicacaoDTOConsulta->setNumMaxRegistrosRetorno(1);
  849 + $resultPublicacao = $publicacaoRN->listarRN1045($publicacaoDTOConsulta);
  850 + $documentoPublicado = $resultPublicacao ? 'S' : 'N';
  851 + $ciencia = $relProtocoloProtocoloDTO->getStrSinCiencia();
  852 + $podeVisualizarDocumento = $this->podeVisualizarDocumento($documentoDTO, $bolFlagProtocolo);
  853 +
  854 + $result[] = array(
  855 + 'id' => $documentoDTO->getDblIdDocumento(),
  856 + 'atributos' => array(
  857 + 'idProcedimento' => $documentoDTO->getDblIdProcedimento(),
  858 + 'idProtocolo' => $documentoDTO->getDblIdDocumento(),
  859 + 'protocoloFormatado' => $documentoDTO->getStrProtocoloDocumentoFormatado(),
  860 + 'nome' => $nomeAnexo,
  861 + 'titulo' => $documentoDTO->getStrNumero(),
  862 + 'tipo' => $documentoDTO->getStrNomeSerie(),
  863 + 'mimeType' => $mimetype ? $mimetype : 'html',
  864 + 'informacao' => $informacao,
  865 + 'tamanho' => $tamanhoAnexo,
  866 + 'idUnidade' => $documentoDTO->getNumIdUnidadeGeradoraProtocolo(),
  867 + 'siglaUnidade' => $documentoDTO->getStrSiglaUnidadeGeradoraProtocolo(),
  868 + 'status' => array(
  869 + 'sinBloqueado' => $documentoDTO->getStrStaNivelAcessoLocalProtocolo() == 1 ? 'S' : 'N',
  870 + 'documentoSigiloso' => $documentoDTO->getStrStaNivelAcessoLocalProtocolo() == 2 ? 'S' : 'N',
  871 + 'documentoRestrito' => $documentoDTO->getStrStaNivelAcessoLocalProtocolo() == 1 ? 'S' : 'N',
  872 + 'documentoPublicado' => $documentoPublicado,
  873 + 'documentoAssinado' => $documentoDTO->getStrCrcAssinatura() ? 'S' : 'N',
  874 + 'ciencia' => $ciencia,
  875 + 'documentoCancelado' => $documentoCancelado,
  876 + 'podeVisualizarDocumento' => $podeVisualizarDocumento ? 'S' : 'N'
  877 + )
  878 + )
  879 + );
  880 + }
  881 +
  882 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result, $relProtocoloProtocoloDTOConsulta->getNumTotalRegistros());
  883 + }catch (Exception $e){
  884 + return MdWsSeiRest::formataRetornoErroREST($e);
  885 + }
  886 + }
  887 +
  888 + /**
  889 + * Metodo simplificado (abstraido) de assinatura de documentos
  890 + * @param string $arrIdDocumento
  891 + * @param int $idOrgao
  892 + * @param string $strCargoFuncao
  893 + * @param string $siglaUsuario
  894 + * @param string $senhaUsuario
  895 + * @param int $idUsuario
  896 + * @return array
  897 + */
  898 + public function apiAssinarDocumentos($arrIdDocumento, $idOrgao, $strCargoFuncao, $siglaUsuario, $senhaUsuario, $idUsuario){
  899 + //transforma os dados no array
  900 + if(strpos($arrIdDocumento, ',') !== false) {
  901 + $arrDocs = explode(',', $arrIdDocumento);
  902 + } else {
  903 + $arrDocs = array($arrIdDocumento);
  904 + }
  905 +
  906 + foreach($arrDocs as $dblIdDocumento){
  907 + $documentoDTO = new DocumentoDTO();
  908 + $documentoDTO->setDblIdDocumento($dblIdDocumento);
  909 + $arrDocumentoDTO[] = $documentoDTO;
  910 + }
  911 + $assinaturaDTO = new AssinaturaDTO();
  912 + $assinaturaDTO->setStrSiglaUsuario($siglaUsuario);
  913 + $assinaturaDTO->setStrSenhaUsuario($senhaUsuario);
  914 + $assinaturaDTO->setNumIdUsuario($idUsuario);
  915 + $assinaturaDTO->setNumIdOrgaoUsuario($idOrgao);
  916 + $assinaturaDTO->setStrCargoFuncao($strCargoFuncao);
  917 + $assinaturaDTO->setArrObjDocumentoDTO($arrDocumentoDTO);
  918 + return $this->assinarDocumento($assinaturaDTO);
  919 + }
  920 +
  921 + /**
  922 + * Metodo simplificado (abstraido) de assinatura de documento
  923 + * @param array $arrIdDocumento
  924 + * @param $idOrgao
  925 + * @param $strCargoFuncao
  926 + * @param $siglaUsuario
  927 + * @param $senhaUsuario
  928 + * @param $idUsuario
  929 + * @return array
  930 + */
  931 + public function apiAssinarDocumento($idDocumento, $idOrgao, $strCargoFuncao, $siglaUsuario, $senhaUsuario, $idUsuario){
  932 + $arrDocumentoDTO = array();
  933 + $documentoDTO = new DocumentoDTO();
  934 + $documentoDTO->setDblIdDocumento($idDocumento);
  935 + $arrDocumentoDTO[] = $documentoDTO;
  936 + $assinaturaDTO = new AssinaturaDTO();
  937 + $assinaturaDTO->setStrSiglaUsuario($siglaUsuario);
  938 + $assinaturaDTO->setStrSenhaUsuario($senhaUsuario);
  939 + $assinaturaDTO->setNumIdUsuario($idUsuario);
  940 + $assinaturaDTO->setNumIdOrgaoUsuario($idOrgao);
  941 + $assinaturaDTO->setStrCargoFuncao($strCargoFuncao);
  942 + $assinaturaDTO->setArrObjDocumentoDTO($arrDocumentoDTO);
  943 + return $this->assinarDocumento($assinaturaDTO);
  944 + }
  945 +
  946 + /**
  947 + * Realizar Assinatura Eletr?nica
  948 + * @param AssinaturaDTO $assinaturaDTO
  949 + * @return array
  950 + */
  951 + public function assinarDocumentoControlado(AssinaturaDTO $assinaturaDTO){
  952 + try{
  953 + $assinaturaDTO->setStrStaFormaAutenticacao(AssinaturaRN::$TA_SENHA);
  954 + $assinaturaDTO->setNumIdContextoUsuario(null);
  955 + $documentoRN = new DocumentoRN();
  956 + $documentoRN->assinarInterno($assinaturaDTO);
  957 + return MdWsSeiRest::formataRetornoSucessoREST('Documento em bloco assinado com sucesso.');
  958 + }catch (Exception $e){
  959 + return MdWsSeiRest::formataRetornoErroREST($e);
  960 + }
  961 + }
  962 +
  963 + /**
  964 + * @param DocumentoDTO $documentoDTO
  965 + * id documento obrigatorio
  966 + * @return array
  967 + */
  968 + protected function darCienciaControlado(DocumentoDTO $documentoDTO){
  969 + try{
  970 + $documentoRN = new DocumentoRN();
  971 + if(!$documentoDTO->isSetDblIdDocumento()){
  972 + throw new InfraException('O documento não foi informado.');
  973 + }
  974 + $documentoRN->darCiencia($documentoDTO);
  975 + return MdWsSeiRest::formataRetornoSucessoREST('Ciência documento realizado com sucesso.');
  976 + }catch (Exception $e){
  977 + return MdWsSeiRest::formataRetornoErroREST($e);
  978 + }
  979 + }
  980 +
  981 + protected function downloadAnexoConectado(ProtocoloDTO $protocoloDTOParam){
  982 + try{
  983 + if(!$protocoloDTOParam->isSetDblIdProtocolo() || !$protocoloDTOParam->getDblIdProtocolo()){
  984 + throw new InfraException('O protocolo deve ser informado!');
  985 + }
  986 + $documentoDTOConsulta = new DocumentoDTO();
  987 + $documentoDTOConsulta->setDblIdProtocoloProtocolo($protocoloDTOParam->getDblIdProtocolo());
  988 + $documentoDTOConsulta->retDblIdDocumento();
  989 + $documentoDTOConsulta->retStrNomeSerie();
  990 + $documentoDTOConsulta->retStrNumero();
  991 + $documentoDTOConsulta->retStrSiglaUnidadeGeradoraProtocolo();
  992 + $documentoDTOConsulta->retStrProtocoloDocumentoFormatado();
  993 + $documentoDTOConsulta->retStrProtocoloProcedimentoFormatado();
  994 + $documentoDTOConsulta->retStrStaProtocoloProtocolo();
  995 + $documentoDTOConsulta->retStrStaDocumento();
  996 + $documentoDTOConsulta->retDblIdDocumentoEdoc();
  997 + $documentoRN = new DocumentoRN();
  998 + $documentoDTO = $documentoRN->consultarRN0005($documentoDTOConsulta);
  999 +
  1000 + if ($documentoDTO->getStrStaDocumento()==DocumentoRN::$TD_EDITOR_EDOC) {
  1001 + if ($documentoDTO->getDblIdDocumentoEdoc() == null) {
  1002 + throw new InfraException('Documento sem conteúdo!');
  1003 + }
  1004 + $eDocRN = new EDocRN();
  1005 + $html = $eDocRN->consultarHTMLDocumentoRN1204($documentoDTO);
  1006 +
  1007 + return MdWsSeiRest::formataRetornoSucessoREST(null, array('html' => $html));
  1008 + }else if(in_array($documentoDTO->getStrStaDocumento(), array(DocumentoRN::$TD_FORMULARIO_AUTOMATICO, DocumentoRN::$TD_FORMULARIO_GERADO))) {
  1009 + $html = $documentoRN->consultarHtmlFormulario($documentoDTO);
  1010 +
  1011 + return MdWsSeiRest::formataRetornoSucessoREST(null, array('html' => $html));
  1012 + }else if($documentoDTO->getStrStaDocumento() == DocumentoRN::$TD_EDITOR_INTERNO){
  1013 + $editorDTOConsulta = new EditorDTO();
  1014 + $editorDTOConsulta->setDblIdDocumento($documentoDTO->getDblIdDocumento());
  1015 + $editorDTOConsulta->setNumIdBaseConhecimento(null);
  1016 + $editorDTOConsulta->setStrSinCabecalho('S');
  1017 + $editorDTOConsulta->setStrSinRodape('S');
  1018 + $editorDTOConsulta->setStrSinIdentificacaoVersao('S');
  1019 + $editorDTOConsulta->setStrSinProcessarLinks('S');
  1020 +
  1021 + if(MdWsSeiEditorRN::versaoCarimboPublicacaoObrigatorio()){
  1022 + $editorDTOConsulta->setStrSinCarimboPublicacao('N');
  1023 + }
  1024 +
  1025 + $editorRN = new EditorRN();
  1026 + $html = $editorRN->consultarHtmlVersao($editorDTOConsulta);
  1027 +
  1028 + $auditoriaProtocoloDTO = new AuditoriaProtocoloDTO();
  1029 + $auditoriaProtocoloDTO->setStrRecurso('documento_visualizar');
  1030 + $auditoriaProtocoloDTO->setNumIdUsuario(SessaoSEI::getInstance()->getNumIdUsuario());
  1031 + $auditoriaProtocoloDTO->setDblIdProtocolo($documentoDTO->getDblIdDocumento());
  1032 + $auditoriaProtocoloDTO->setNumIdAnexo(null);
  1033 + $auditoriaProtocoloDTO->setDtaAuditoria(InfraData::getStrDataAtual());
  1034 + $auditoriaProtocoloDTO->setNumVersao($editorDTOConsulta->getNumVersao());
  1035 +
  1036 + $auditoriaProtocoloRN = new AuditoriaProtocoloRN();
  1037 + $auditoriaProtocoloRN->auditarVisualizacao($auditoriaProtocoloDTO);
  1038 +
  1039 + return MdWsSeiRest::formataRetornoSucessoREST(null, array('html' => $html));
  1040 + }else{
  1041 + $anexoDTO = new AnexoDTO();
  1042 + $anexoDTO->retNumIdAnexo();
  1043 + $anexoDTO->retDthInclusao();
  1044 + $anexoDTO->retDthInclusao();
  1045 + $anexoDTO->retStrNome();
  1046 + $anexoDTO->retStrHash();
  1047 + $anexoDTO->setDblIdProtocolo($protocoloDTOParam->getDblIdProtocolo());
  1048 + $anexoDTO->setStrSinAtivo('S');
  1049 + $anexoRN = new AnexoRN();
  1050 + $resultAnexo = $anexoRN->listarRN0218($anexoDTO);
  1051 + if(empty($resultAnexo)){
  1052 + throw new InfraException('Documento não encontrado!');
  1053 + }
  1054 + $anexo = $resultAnexo[0];
  1055 + SeiINT::download($anexo);
  1056 + exit;
  1057 + }
  1058 + }catch (Exception $e){
  1059 + return MdWsSeiRest::formataRetornoErroREST($e);
  1060 + }
  1061 + }
  1062 +
  1063 + /**
  1064 + * Listar Ciencias realizadas em um Documento
  1065 + * @param MdWsSeiProcessoDTO $mdWsSeiProcessoDTOParam
  1066 + * *valor = protocoloformatado?
  1067 + * @return array
  1068 + */
  1069 + protected function listarCienciaDocumentoConectado(MdWsSeiProcessoDTO $mdWsSeiProcessoDTOParam){
  1070 + try{
  1071 + if(!$mdWsSeiProcessoDTOParam->isSetStrValor()){
  1072 + throw new InfraException('Número do documento não informado.');
  1073 + }
  1074 +
  1075 + $result = array();
  1076 + $atributoAndamentoDTOConsulta = new AtributoAndamentoDTO();
  1077 + $atributoAndamentoDTOConsulta->retTodos();
  1078 + $atributoAndamentoDTOConsulta->retDthAberturaAtividade();
  1079 + $atributoAndamentoDTOConsulta->retStrSiglaUsuarioOrigemAtividade();
  1080 + $atributoAndamentoDTOConsulta->retStrSiglaUnidadeOrigemAtividade();
  1081 + $atributoAndamentoDTOConsulta->setNumIdTarefaAtividade(TarefaRN::$TI_DOCUMENTO_CIENCIA);
  1082 + $atributoAndamentoDTOConsulta->setStrValor($mdWsSeiProcessoDTOParam->getStrValor());
  1083 + $atributoAndamentoDTOConsulta->setStrNome(self::NOME_ATRIBUTO_ANDAMENTO_DOCUMENTO);
  1084 + $atributoAndamentoRN = new AtributoAndamentoRN();
  1085 + $ret = $atributoAndamentoRN->listarRN1367($atributoAndamentoDTOConsulta);
  1086 + $tarefaDTO = new TarefaDTO();
  1087 + $tarefaDTO->retStrNome();
  1088 + $tarefaDTO->setNumIdTarefa($atributoAndamentoDTOConsulta->getNumIdTarefaAtividade());
  1089 + $tarefaRN = new TarefaRN();
  1090 + $tarefaDTO = $tarefaRN->consultar($tarefaDTO);
  1091 + $mdWsSeiProcessoRN = new MdWsSeiProcessoRN();
  1092 + /** @var AtributoAndamentoDTO $atributoAndamentoDTO */
  1093 + foreach($ret as $atributoAndamentoDTO){
  1094 + $mdWsSeiProcessoDTO = new MdWsSeiProcessoDTO();
  1095 + $mdWsSeiProcessoDTO->setNumIdAtividade($atributoAndamentoDTO->getNumIdAtividade());
  1096 + $mdWsSeiProcessoDTO->setStrTemplate($tarefaDTO->getStrNome());
  1097 + $result[] = array(
  1098 + 'data' => $atributoAndamentoDTO->getDthAberturaAtividade(),
  1099 + 'unidade' => $atributoAndamentoDTO->getStrSiglaUnidadeOrigemAtividade(),
  1100 + 'nome' => $atributoAndamentoDTO->getStrSiglaUsuarioOrigemAtividade(),
  1101 + 'descricao' => $mdWsSeiProcessoRN->traduzirTemplate($mdWsSeiProcessoDTO)
  1102 + );
  1103 + }
  1104 +
  1105 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result);
  1106 + }catch (Exception $e){
  1107 + return MdWsSeiRest::formataRetornoErroREST($e);
  1108 + }
  1109 + }
  1110 +
  1111 + /**
  1112 + * Listar assinaturas do documento
  1113 + * @param DocumentoDTO $documentoDTOParam
  1114 + * @return array
  1115 + */
  1116 + protected function listarAssinaturasDocumentoConectado(DocumentoDTO $documentoDTOParam){
  1117 + try{
  1118 + if(!$documentoDTOParam->isSetDblIdDocumento()){
  1119 + throw new InfraException('O documento não foi informado.');
  1120 + }
  1121 +
  1122 + $result = array();
  1123 + $assinaturaDTOConsulta = new AssinaturaDTO();
  1124 + $assinaturaDTOConsulta->retTodos();
  1125 + $assinaturaDTOConsulta->retStrSiglaUnidade();
  1126 + $assinaturaDTOConsulta->setDblIdDocumento($documentoDTOParam->getDblIdDocumento());
  1127 + $assinaturaRN = new AssinaturaRN();
  1128 + $ret = $assinaturaRN->listarRN1323($assinaturaDTOConsulta);
  1129 + /** @var AssinaturaDTO $assinaturaDTO */
  1130 + foreach($ret as $assinaturaDTO){
  1131 + $result[] = array(
  1132 + 'nome' => $assinaturaDTO->getStrNome(),
  1133 + 'cargo' => $assinaturaDTO->getStrTratamento(),
  1134 + 'unidade' => $assinaturaDTO->getStrSiglaUnidade()
  1135 + );
  1136 + }
  1137 +
  1138 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result);
  1139 + }catch (Exception $e){
  1140 + return MdWsSeiRest::formataRetornoErroREST($e);
  1141 + }
  1142 + }
  1143 +
  1144 + /**
  1145 + * Verifica se o documento pode ser visualizado
  1146 + * @param DocumentoDTO $documentoDTO
  1147 + * @param bool $bolFlagProtocolo
  1148 + * @return bool
  1149 + */
  1150 + protected function podeVisualizarDocumento(DocumentoDTO $documentoDTO, $bolFlagProtocolo = false)
  1151 + {
  1152 + $podeVisualizar = false;
  1153 + $pesquisaProtocoloDTO = new PesquisaProtocoloDTO();
  1154 + $pesquisaProtocoloDTO->setStrStaTipo(ProtocoloRN::$TPP_TODOS);
  1155 + $pesquisaProtocoloDTO->setStrStaAcesso(ProtocoloRN::$TAP_TODOS);
  1156 + $pesquisaProtocoloDTO->setDblIdProtocolo($documentoDTO->getDblIdDocumento());
  1157 + $protocoloRN = new ProtocoloRN();
  1158 + $arrProtocoloDTO = InfraArray::indexarArrInfraDTO($protocoloRN->pesquisarRN0967($pesquisaProtocoloDTO), 'IdProtocolo');
  1159 + $protocoloDTODocumento = $arrProtocoloDTO[$documentoDTO->getDblIdDocumento()];
  1160 +
  1161 + $numCodigoAcesso = $protocoloDTODocumento->getNumCodigoAcesso();
  1162 + if ($numCodigoAcesso > 0 || $bolFlagProtocolo) {
  1163 + $podeVisualizar = true;
  1164 + }
  1165 + if ($documentoDTO->getStrStaEstadoProtocolo() == ProtocoloRN::$TE_DOCUMENTO_CANCELADO) {
  1166 + $podeVisualizar = false;
  1167 + }
  1168 +
  1169 + return $podeVisualizar;
  1170 + }
  1171 +}
0 1172 \ No newline at end of file
... ...
rn/MdWsSeiEditorRN.php 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +<?php
  2 +
  3 +require_once dirname(__FILE__).'/../../../SEI.php';
  4 +
  5 +class MdWsSeiEditorRN extends InfraRN
  6 +{
  7 +
  8 + CONST VERSAO_CARIMBO_PUBLICACAO_OBRIGATORIO = "3.0.7";
  9 +
  10 + protected function inicializarObjInfraIBanco(){
  11 + return BancoSEI::getInstance();
  12 + }
  13 +
  14 + /**
  15 + * Método que verifica o o atributo carimbo publicação é obrigatório na versão atual do SEI
  16 + * @return bool
  17 + */
  18 + public static function versaoCarimboPublicacaoObrigatorio(){
  19 + $numVersaoAtual = intval(str_replace('.', '', SEI_VERSAO));
  20 + $numVersaoCarimboObrigatorio = intval(str_replace('.', '', self::VERSAO_CARIMBO_PUBLICACAO_OBRIGATORIO));
  21 + if($numVersaoAtual >= $numVersaoCarimboObrigatorio){
  22 + return true;
  23 + }
  24 +
  25 + return false;
  26 + }
  27 +
  28 +}
0 29 \ No newline at end of file
... ...
rn/MdWsSeiGrupoAcompanhamentoRN.php 0 → 100644
... ... @@ -0,0 +1,53 @@
  1 +<?
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiGrupoAcompanhamentoRN extends InfraRN {
  5 +
  6 + protected function inicializarObjInfraIBanco(){
  7 + return BancoSEI::getInstance();
  8 + }
  9 +
  10 + /**
  11 + * Retorna todos os grupos de acompanhamento
  12 + * @param GrupoAcompanhamentoDTO $grupoAcompanhamentoDTOParam
  13 + * @return array
  14 + */
  15 + protected function listarGrupoAcompanhamentoConectado(GrupoAcompanhamentoDTO $grupoAcompanhamentoDTOParam){
  16 + try{
  17 + $result = array();
  18 + $grupoAcompanhamentoDTOConsulta = new GrupoAcompanhamentoDTO();
  19 + $grupoAcompanhamentoRN = new GrupoAcompanhamentoRN();
  20 + $grupoAcompanhamentoDTOConsulta->retNumIdGrupoAcompanhamento();
  21 + $grupoAcompanhamentoDTOConsulta->retStrNome();
  22 + $grupoAcompanhamentoDTOConsulta->setOrdStrNome(InfraDTO::$TIPO_ORDENACAO_ASC);
  23 + if(!$grupoAcompanhamentoDTOParam->isSetNumIdUnidade()){
  24 + $grupoAcompanhamentoDTOConsulta->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual());
  25 + }else{
  26 + $grupoAcompanhamentoDTOConsulta->setNumIdUnidade($grupoAcompanhamentoDTOParam->getNumIdUnidade());
  27 + }
  28 + if($grupoAcompanhamentoDTOParam->getNumMaxRegistrosRetorno()){
  29 + $grupoAcompanhamentoDTOConsulta->setNumMaxRegistrosRetorno($grupoAcompanhamentoDTOParam->getNumMaxRegistrosRetorno());
  30 + }else{
  31 + $grupoAcompanhamentoDTOConsulta->setNumMaxRegistrosRetorno(10);
  32 + }
  33 + if(!is_null($grupoAcompanhamentoDTOParam->getNumPaginaAtual())){
  34 + $grupoAcompanhamentoDTOConsulta->setNumPaginaAtual($grupoAcompanhamentoDTOParam->getNumPaginaAtual());
  35 + }else{
  36 + $grupoAcompanhamentoDTOConsulta->setNumPaginaAtual(0);
  37 + }
  38 + $ret = $grupoAcompanhamentoRN->listar($grupoAcompanhamentoDTOConsulta);
  39 + /** @var GrupoAcompanhamentoDTO $grupoAcompanhamentoDTO */
  40 + foreach($ret as $grupoAcompanhamentoDTO){
  41 + $result[] = array(
  42 + 'id' => $grupoAcompanhamentoDTO->getNumIdGrupoAcompanhamento(),
  43 + 'nome' => $grupoAcompanhamentoDTO->getStrNome()
  44 + );
  45 + }
  46 +
  47 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result, $grupoAcompanhamentoDTOConsulta->getNumTotalRegistros());
  48 + }catch (Exception $e){
  49 + return MdWsSeiRest::formataRetornoErroREST($e);
  50 + }
  51 + }
  52 +
  53 +}
0 54 \ No newline at end of file
... ...
rn/MdWsSeiHipoteseLegalRN.php 0 → 100644
... ... @@ -0,0 +1,95 @@
  1 +<?php
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiHipoteseLegalRN extends InfraRN
  5 +{
  6 +
  7 + protected function inicializarObjInfraIBanco()
  8 + {
  9 + return BancoSEI::getInstance();
  10 + }
  11 +
  12 +
  13 + /**
  14 + * O serviço realiza a pesquisa das hipóteses legais do SEI.
  15 + * @param MdWsSeiHipoteseLegalDTO $dto
  16 + * @return array
  17 + */
  18 + protected function listarHipoteseLegalConectado(MdWsSeiHipoteseLegalDTO $dto)
  19 + {
  20 + try {
  21 + $id = $dto->getNumIdHipoteseLegal();
  22 + $nivelAcesso = $dto->getNumNivelAcesso();
  23 + $filter = $dto->getStrFilter();
  24 + $start = $dto->getNumStart();
  25 + $limit = $dto->getNumLimit();
  26 +
  27 + $hipoteseLegalDTO = new HipoteseLegalDTO();
  28 +
  29 + if ($id)
  30 + $hipoteseLegalDTO->setNumIdHipoteseLegal($id);
  31 +
  32 + if ($nivelAcesso)
  33 + $hipoteseLegalDTO->setStrStaNivelAcesso($nivelAcesso);
  34 +
  35 + if ($filter)
  36 + $hipoteseLegalDTO->setStrNome('%' . utf8_decode ($filter) . '%', InfraDTO::$OPER_LIKE);
  37 +
  38 + IF ($limit)
  39 + $hipoteseLegalDTO->setNumMaxRegistrosRetorno($limit);
  40 +
  41 + IF ($start)
  42 + $hipoteseLegalDTO->setNumPaginaAtual($start);
  43 +
  44 + $hipoteseLegalDTO->retNumIdHipoteseLegal();
  45 + $hipoteseLegalDTO->retStrNome();
  46 +
  47 + $hipoteseLegalRN = new HipoteseLegalRN();
  48 + $arrHipoteseLegalDTO = $hipoteseLegalRN->listar($hipoteseLegalDTO);
  49 +
  50 + $arrayRetorno = array();
  51 + if($arrHipoteseLegalDTO){
  52 + foreach ($arrHipoteseLegalDTO as $obj) {
  53 + $arrayRetorno[] = array(
  54 + "id" => $obj->getNumIdHipoteseLegal(),
  55 + "nome" => $obj->getStrNome()
  56 + );
  57 + }
  58 + }
  59 +
  60 + $total = count($arrayRetorno);
  61 +
  62 + return MdWsSeiRest::formataRetornoSucessoREST(null, $arrayRetorno, $total);
  63 + } catch (Exception $e) {
  64 + return MdWsSeiRest::formataRetornoErroREST($e);
  65 + }
  66 + }
  67 +
  68 +
  69 + /**
  70 + * Realiza a inclusão de um contato no SEI.
  71 + * @param MdWsSeiContatoDTO $objGetMdWsSeiContatoDTO
  72 + * @return array
  73 + */
  74 + protected function criarContatoConectado(MdWsSeiContatoDTO $objGetMdWsSeiContatoDTO)
  75 + {
  76 + try {
  77 +
  78 + $nome = $objGetMdWsSeiContatoDTO->getStrNome();
  79 +
  80 + $objContatoDTO = new ContatoDTO();
  81 + $objContatoDTO->setStrNome($nome);
  82 +
  83 + $objContatoRN = new ContatoRN();
  84 + $objContatoDTO = $objContatoRN->cadastrarContextoTemporario($objContatoDTO);
  85 +
  86 + return MdWsSeiRest::formataRetornoSucessoREST(null,array("id"=>$objContatoDTO->getNumIdContato()));
  87 + } catch (Exception $e) {
  88 + return MdWsSeiRest::formataRetornoErroREST($e);
  89 + }
  90 + }
  91 +
  92 +
  93 +
  94 +
  95 +}
0 96 \ No newline at end of file
... ...
rn/MdWsSeiObservacaoRN.php 0 → 100644
... ... @@ -0,0 +1,44 @@
  1 +<?
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiObservacaoRN extends InfraRN {
  5 +
  6 + protected function inicializarObjInfraIBanco(){
  7 + return BancoSEI::getInstance();
  8 + }
  9 +
  10 + public function encapsulaObservacao(array $post){
  11 + $observacaoDTO = new ObservacaoDTO();
  12 + $observacaoDTO->setStrIdxObservacao(null);
  13 + if (isset($post['unidade'])) {
  14 + $observacaoDTO->setNumIdUnidade($post['unidade']);
  15 + }
  16 +
  17 + if (isset($post['descricao'])) {
  18 + $observacaoDTO->setStrDescricao($post['descricao']);
  19 + }
  20 +
  21 + if (isset($post['protocolo'])) {
  22 + $observacaoDTO->setDblIdProtocolo($post['protocolo']);
  23 + }
  24 +
  25 + return $observacaoDTO;
  26 + }
  27 +
  28 + /**
  29 + * Metodo que cria uma observacao
  30 + * @param ObservacaoDTO $observacaoDTO
  31 + * @info metodo auxiliar encapsulaObservacao para facilitar encapsulamento
  32 + * @return array
  33 + */
  34 + protected function criarObservacaoControlado(ObservacaoDTO $observacaoDTO){
  35 + try{
  36 + $observacaoRN = new ObservacaoRN();
  37 + $observacaoRN->cadastrarRN0222($observacaoDTO);
  38 +
  39 + return MdWsSeiRest::formataRetornoSucessoREST('Observação cadastrada com sucesso!');
  40 + }catch (Exception $e){
  41 + return MdWsSeiRest::formataRetornoErroREST($e);
  42 + }
  43 + }
  44 +}
0 45 \ No newline at end of file
... ...
rn/MdWsSeiOrgaoRN.php 0 → 100644
... ... @@ -0,0 +1,54 @@
  1 +<?
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiOrgaoRN extends InfraRN {
  5 +
  6 + protected function inicializarObjInfraIBanco(){
  7 + return BancoSEI::getInstance();
  8 + }
  9 +
  10 + /**
  11 + * Retorna todos os orgaos ativos cadastrados
  12 + * @param OrgaoDTO $orgaoDTO
  13 + * @return array
  14 + */
  15 + protected function listarOrgaoConectado(OrgaoDTO $orgaoDTOParam){
  16 + try{
  17 + $result = array();
  18 + $orgaoDTO = new OrgaoDTO();
  19 + $orgaoDTO->retNumIdOrgao();
  20 + $orgaoDTO->retStrSigla();
  21 + $orgaoDTO->retStrDescricao();
  22 + $orgaoDTO->setStrSinAtivo('S');
  23 + $orgaoDTO->setOrdStrSigla(InfraDTO::$TIPO_ORDENACAO_ASC);
  24 +
  25 + if($orgaoDTOParam->getNumMaxRegistrosRetorno()){
  26 + $orgaoDTO->setNumMaxRegistrosRetorno($orgaoDTOParam->getNumMaxRegistrosRetorno());
  27 + }else{
  28 + $orgaoDTO->setNumMaxRegistrosRetorno(10);
  29 + }
  30 + if(!is_null($orgaoDTOParam->getNumPaginaAtual())){
  31 + $orgaoDTO->setNumPaginaAtual($orgaoDTOParam->getNumPaginaAtual());
  32 + }else{
  33 + $orgaoDTO->setNumPaginaAtual(0);
  34 + }
  35 +
  36 + $orgaoBD = new OrgaoBD($this->getObjInfraIBanco());
  37 + $ret = $orgaoBD->listar($orgaoDTO);
  38 +
  39 + /** @var OrgaoDTO $orgDTO */
  40 + foreach($ret as $orgDTO){
  41 + $result[] = array(
  42 + 'id' => $orgDTO->getNumIdOrgao(),
  43 + 'sigla' => $orgDTO->getStrSigla(),
  44 + 'descricao' => $orgDTO->getStrDescricao()
  45 + );
  46 + }
  47 +
  48 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result, $orgaoDTO->getNumTotalRegistros());
  49 + }catch (Exception $e){
  50 + return MdWsSeiRest::formataRetornoErroREST($e);
  51 + }
  52 + }
  53 +
  54 +}
0 55 \ No newline at end of file
... ...
rn/MdWsSeiProcedimentoRN.php 0 → 100644
... ... @@ -0,0 +1,1845 @@
  1 +<?php
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiProcedimentoRN extends InfraRN
  5 +{
  6 +
  7 + protected function inicializarObjInfraIBanco()
  8 + {
  9 + return BancoSEI::getInstance();
  10 + }
  11 +
  12 + /**
  13 + * Consulta o processo pelo protocolo
  14 + * @param $protocolo
  15 + * @return array
  16 + */
  17 + public function apiConsultarProcessoDigitado($protocolo){
  18 + try{
  19 + $result = ProcedimentoINT::pesquisarDigitadoRI1023($protocolo);
  20 +
  21 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result);
  22 + }catch (Exception $e){
  23 + return MdWsSeiRest::formataRetornoErroREST($e);
  24 + }
  25 + }
  26 +
  27 + /**
  28 + * Retorna o total de unidades do processo
  29 + * @param ProtocoloDTO $protocoloDTO
  30 + * @return array
  31 + */
  32 + protected function listarUnidadesProcessoConectado(ProtocoloDTO $protocoloDTO)
  33 + {
  34 + try {
  35 + if (!$protocoloDTO->getDblIdProtocolo()) {
  36 + throw new InfraException('Protocolo não informado.');
  37 + }
  38 + $result = array();
  39 +
  40 + $relProtocoloProtocoloDTOConsulta = new RelProtocoloProtocoloDTO();
  41 + $relProtocoloProtocoloDTOConsulta->setDblIdProtocolo1($protocoloDTO->getDblIdProtocolo());
  42 + $relProtocoloProtocoloDTOConsulta->retDblIdProtocolo1();
  43 + $relProtocoloProtocoloDTOConsulta->setNumMaxRegistrosRetorno(1);
  44 + $relProtocoloProtocoloDTOConsulta->setNumPaginaAtual(0);
  45 + $relProtocoloProtocoloRN = new RelProtocoloProtocoloRN();
  46 + $ret = $relProtocoloProtocoloRN->listarRN0187($relProtocoloProtocoloDTOConsulta);
  47 + if ($ret) {
  48 + /** @var RelProtocoloProtocoloDTO $relProtocoloProtocoloDTO */
  49 + $relProtocoloProtocoloDTO = $ret[0];
  50 + $result['processo'] = $relProtocoloProtocoloDTO->getDblIdProtocolo1();
  51 + $result['unidades'] = $relProtocoloProtocoloDTOConsulta->getNumTotalRegistros();
  52 + }
  53 +
  54 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result);
  55 + } catch (Exception $e) {
  56 + return MdWsSeiRest::formataRetornoErroREST($e);
  57 + }
  58 + }
  59 +
  60 + /**
  61 + * Retorna todos tipos de procedimentos filtrados
  62 + * @param MdWsSeiTipoProcedimentoDTO $objGetMdWsSeiTipoProcedimentoDTO
  63 + * @return array
  64 + */
  65 + protected function listarTipoProcedimentoConectado(MdWsSeiTipoProcedimentoDTO $objGetMdWsSeiTipoProcedimentoDTO)
  66 + {
  67 + try {
  68 +
  69 + $id = $objGetMdWsSeiTipoProcedimentoDTO->getNumIdTipoProcedimento();
  70 + $nome = $objGetMdWsSeiTipoProcedimentoDTO->getStrNome();
  71 +// $interno = $objGetMdWsSeiTipoProcedimentoDTO->getStrSinInterno();
  72 + $favoritos = $objGetMdWsSeiTipoProcedimentoDTO->getStrFavoritos();
  73 + $start = $objGetMdWsSeiTipoProcedimentoDTO->getNumStart();
  74 + $limit = $objGetMdWsSeiTipoProcedimentoDTO->getNumLimit();
  75 +
  76 + // DTO QUE REPRESENTA OS TIPOS DE PROCESSO.
  77 + $objTipoProcedimentoDTO = new TipoProcedimentoDTO();
  78 + $objTipoProcedimentoDTO->setStrSinSomenteUtilizados($favoritos); //Flag de FAVORITOS S (true) / N (false)
  79 +
  80 + //RETORNOS ESPERADOS NOS PARÂMETROS DE SAÍDA
  81 + $objTipoProcedimentoDTO->retNumIdTipoProcedimento();
  82 + $objTipoProcedimentoDTO->retStrNome();
  83 + $objTipoProcedimentoDTO->retStrSinInterno();
  84 +
  85 + //MÉTODO QUE RETORNA A BUSCA DOS TIPOS DE PROCESSO APLICANDO AS REGRAS DE RESTRIÇÃO POR ÓRGÃO, UNIDADE E OUVIDORIA
  86 + $objTipoProcedimentoRN = new TipoProcedimentoRN();
  87 + $arrObjTipoProcedimentoDTO = $objTipoProcedimentoRN->listarTiposUnidade($objTipoProcedimentoDTO); //Lista os tipos de processo
  88 +
  89 + $arrayObjs = array();
  90 + //FILTRA NOME, ID e INTERNO
  91 + if($arrObjTipoProcedimentoDTO){
  92 + foreach ($arrObjTipoProcedimentoDTO as $aux) {
  93 + if(
  94 + ($aux->getNumIdTipoProcedimento() == $id || !$id)
  95 + &&
  96 + (($nome && strpos($aux->getStrNome(), $nome) !== false) || !$nome)
  97 +// &&
  98 +// ($aux->getStrSinInterno() == $interno || !$interno)
  99 + ){
  100 + $arrayObjs[] = array(
  101 + "id" => $aux->getNumIdTipoProcedimento(),
  102 + "nome" => $aux->getStrNome()
  103 + );
  104 + }
  105 + }
  106 + }
  107 +
  108 + $arrayRetorno = array();
  109 + $i = 0;
  110 + //PERMITE SIGILOSO
  111 + if(count($arrayObjs) > 0){
  112 + foreach ($arrayObjs as $aux) {
  113 + $i++;
  114 + $objNivelAcessoPermitidoDTO = new NivelAcessoPermitidoDTO();
  115 + $objNivelAcessoPermitidoDTO->setNumIdTipoProcedimento($aux["id"]); // ID DO TIPO DE PROCESSO
  116 + $objNivelAcessoPermitidoDTO->setStrStaNivelAcesso(ProtocoloRN::$NA_SIGILOSO);
  117 +
  118 + $objNivelAcessoPermitidoRN = new NivelAcessoPermitidoRN();
  119 + $permiteSigiloso = $objNivelAcessoPermitidoRN->contar($objNivelAcessoPermitidoDTO) > 0 ? true : false;
  120 +
  121 +
  122 + $arrayRetorno[$i] = array(
  123 + "id" => $aux["id"],
  124 + "nome" => $aux["nome"],
  125 + "permiteSigiloso" => $permiteSigiloso
  126 + );
  127 + }
  128 + }
  129 +
  130 + if($start) $arrayRetorno = array_slice($arrayRetorno, ($start-1));
  131 + if($limit) $arrayRetorno = array_slice($arrayRetorno, 0,($limit));
  132 +
  133 + $total = 0;
  134 + $total = count($arrayRetorno);
  135 +
  136 + return MdWsSeiRest::formataRetornoSucessoREST(null, $arrayRetorno, $total);
  137 + } catch (Exception $e) {
  138 + return MdWsSeiRest::formataRetornoErroREST($e);
  139 + }
  140 + }
  141 +
  142 +
  143 +
  144 + /**
  145 + * Retorna todos tipos de procedimentos filtrados
  146 + * @param MdWsSeiTipoProcedimentoDTO $objGetMdWsSeiTipoProcedimentoDTO
  147 + * @return array
  148 + */
  149 + protected function buscarTipoTemplateConectado(MdWsSeiTipoProcedimentoDTO $dto)
  150 + {
  151 + try {
  152 +
  153 + $id = $dto->getNumIdTipoProcedimento();
  154 +
  155 + //DTO QUE REPRESENTA A RELAÇÃO ENTRE OS ASSUNTOS E OS TIPOS DE PROCESSO
  156 + $relTipoProcedimentoAssuntoDTO = new RelTipoProcedimentoAssuntoDTO();
  157 + $relTipoProcedimentoAssuntoDTO->setNumIdTipoProcedimento($id); // FILTRO PELO TIPO DE PROCESSO
  158 + $relTipoProcedimentoAssuntoDTO->retNumIdAssunto(); // ID DO ASSUNTO QUE DEVE SE RETORNADO
  159 + $relTipoProcedimentoAssuntoDTO->retStrCodigoEstruturadoAssunto(); // CÓDIGO DO ASSUNTO QUE DEVE SE RETORNADO
  160 + $relTipoProcedimentoAssuntoDTO->retStrDescricaoAssunto(); // DESCRIÇÃO DO ASSUNTO QUE DEVE SER RETORNADA
  161 +
  162 + //CONSULTA QUE LISTA TODOS OS ASSUNTOS SUGERIDOS PARA O TIPO DE PROCESSO
  163 + $relTipoProcedimentoAssuntoRN = new RelTipoProcedimentoAssuntoRN();
  164 + $arrRelTipoProcedimentoAssuntoDTO = $relTipoProcedimentoAssuntoRN->listarRN0192($relTipoProcedimentoAssuntoDTO);
  165 +
  166 + $arrayRetorno = array();
  167 + if($arrRelTipoProcedimentoAssuntoDTO){
  168 + foreach ($arrRelTipoProcedimentoAssuntoDTO as $obj) {
  169 + $arrayRetorno["assuntos"][] = array(
  170 + "id" => $obj->getNumIdAssunto(),
  171 + "codigo" => $obj->getStrCodigoEstruturadoAssunto(),
  172 + "descricao" => $obj->getStrDescricaoAssunto()
  173 + );
  174 + }
  175 + }
  176 +
  177 + //CONSULTA QUE LISTA TODOS OS NÍVES DE ACESSOS PERMITIDOS PARA OS TIPO DE PROCESSO
  178 + $nivelAcessoPermitidoDTO = new NivelAcessoPermitidoDTO();
  179 + $nivelAcessoPermitidoDTO->setNumIdTipoProcedimento($id); // FILTRO PELO TIPO DE PROCESSO
  180 + $nivelAcessoPermitidoDTO->retStrStaNivelAcesso(); // ID DO NÍVEL DE ACESSO - ProtocoloRN::$NA_PUBLICO, ProtocoloRN::$NA_RESTRITO ou ProtocoloRN::$NA_SIGILOSO
  181 +
  182 + // A CONSULTA RETORNARÁ OS NÍVEL DE ACESSO PERMITIDOS PARA O TIPO DE PROCESSO ESPECIFICADO NO DTO. AQUELES QUE NÃO FOREM RETORNADOS NESSA
  183 + $nivelAcessoPermitidoRN = new NivelAcessoPermitidoRN();
  184 + $arrNivelAcessoPermitido = $nivelAcessoPermitidoRN->listar($nivelAcessoPermitidoDTO);
  185 + if($arrNivelAcessoPermitido){
  186 + foreach ($arrNivelAcessoPermitido as $nivel) {
  187 + if($nivel->getStrStaNivelAcesso() == ProtocoloRN::$NA_PUBLICO) $publico = true;
  188 + if($nivel->getStrStaNivelAcesso() == ProtocoloRN::$NA_RESTRITO) $restrito = true;
  189 + if($nivel->getStrStaNivelAcesso() == ProtocoloRN::$NA_SIGILOSO) $sigiloso = true;
  190 + }
  191 + }
  192 + $arrayRetorno["nivelAcessoPermitido"] = array(
  193 + "publico" =>$publico ? $publico : false,
  194 + "restrito" =>$restrito ? $restrito : false,
  195 + "sigiloso" =>$sigiloso ? $sigiloso : false,
  196 + );
  197 +
  198 +
  199 + $tipoProcedimentoDTO = new TipoProcedimentoDTO();
  200 + $tipoProcedimentoDTO->setNumIdTipoProcedimento($id);
  201 + $tipoProcedimentoDTO->retStrStaNivelAcessoSugestao();
  202 + $tipoProcedimentoDTO->retStrStaGrauSigiloSugestao();
  203 + $tipoProcedimentoDTO->retNumIdHipoteseLegalSugestao();
  204 +
  205 + $tipoProcedimentoRN = new TipoProcedimentoRN();
  206 + $tipoProcedimentoDTO = $tipoProcedimentoRN->consultarRN0267($tipoProcedimentoDTO);
  207 +
  208 + $arrayRetorno["nivelAcessoSugerido"] = $tipoProcedimentoDTO ? $tipoProcedimentoDTO->getStrStaNivelAcessoSugestao() : false;
  209 + $arrayRetorno["hipoteseLegalSugerida"] = $tipoProcedimentoDTO ? $tipoProcedimentoDTO->getNumIdHipoteseLegalSugestao() : false;
  210 + $arrayRetorno["grauSigiloSugerido"] = $tipoProcedimentoDTO ? $tipoProcedimentoDTO->getStrStaGrauSigiloSugestao() : false;
  211 +
  212 +
  213 + //CONSULTA NO PARÂMETRO QUE INFORMA SE A HIPÓTESE LEGAL É OBRIGATÓRIO PARA UM TIPO DE PROCESSO
  214 + $objInfraParametro = new InfraParametro(BancoSEI::getInstance());
  215 + $obrigatoriedadeHipoteseLegal = $objInfraParametro->getValor('SEI_HABILITAR_HIPOTESE_LEGAL');
  216 +
  217 + //CONSULTA NO PARÂMETRO QUE INFORMA SE UM GRAU DE SIGILO É OBRIGATÓRIO PARA UM TIPO DE PROCESSO
  218 + $objInfraParametro = new InfraParametro(BancoSEI::getInstance());
  219 + $obrigatoriedadeGrauSigilo = $objInfraParametro->getValor('SEI_HABILITAR_GRAU_SIGILO');
  220 +
  221 + $arrayRetorno["obrigatoriedadeHipoteseLegal"] = $obrigatoriedadeHipoteseLegal;
  222 + $arrayRetorno["obrigatoriedadeGrauSigilo"] = $obrigatoriedadeGrauSigilo;
  223 +
  224 + return MdWsSeiRest::formataRetornoSucessoREST(null, $arrayRetorno);
  225 + } catch (Exception $e) {
  226 + return MdWsSeiRest::formataRetornoErroREST($e);
  227 + }
  228 + }
  229 +
  230 +
  231 +
  232 + /**
  233 + * Retorna todos tipos de procedimentos filtrados
  234 + * @param MdWsSeiTipoProcedimentoDTO $objGetMdWsSeiTipoProcedimentoDTO
  235 + * @return array
  236 + */
  237 + protected function listarAssuntoConectado(MdWsSeiAssuntoDTO $objGetMdWsSeiAssuntoDTO)
  238 + {
  239 + try {
  240 + $id = $objGetMdWsSeiAssuntoDTO->getNumIdAssunto();
  241 + $filter = $objGetMdWsSeiAssuntoDTO->getStrFilter();
  242 + $start = $objGetMdWsSeiAssuntoDTO->getNumStart();
  243 + $limit = $objGetMdWsSeiAssuntoDTO->getNumLimit();
  244 +
  245 + $assuntoDTO = new AssuntoDTO();
  246 + if($id)
  247 + $assuntoDTO->setNumIdAssunto($id);
  248 +
  249 + if($filter) $assuntoDTO->adicionarCriterio(array('CodigoEstruturado','Descricao'),array(InfraDTO::$OPER_LIKE,InfraDTO::$OPER_LIKE),array('%'.utf8_decode($filter).'%','%'.utf8_decode($filter).'%'),InfraDTO::$OPER_LOGICO_OR);
  250 +// $objInfraAgendamentoTarefaDTO->adicionarCriterio(array('SinAtivo','IdInfraAgendamentoTarefa'),array(InfraDTO::$OPER_IGUAL,InfraDTO::$OPER_IGUAL),array('S',$strValorItemSelecionado),InfraDTO::$OPER_LOGICO_OR);
  251 +// $assuntoDTO->setStrCodigoEstruturado('%'.$filter.'%',InfraDTO::$OPER_LIKE);
  252 +
  253 + if($limit)
  254 + $assuntoDTO->setNumMaxRegistrosRetorno($limit);
  255 + if($start)
  256 + $assuntoDTO->setNumPaginaAtual($start);
  257 +
  258 + $assuntoDTO->retNumIdAssunto();
  259 + $assuntoDTO->retStrCodigoEstruturado();
  260 + $assuntoDTO->retStrDescricao();
  261 +
  262 + // REALIZA A CHAMADA DA DE ASSUNTOS
  263 + $assuntoRN = new AssuntoRN();
  264 + $arrAssuntoDTO = $assuntoRN->listarRN0247($assuntoDTO);
  265 +
  266 + $arrayRetorno = array();
  267 + if($arrAssuntoDTO){
  268 + foreach ($arrAssuntoDTO as $obj) {
  269 + $arrayRetorno[] = array(
  270 + "id" => $obj->getNumIdAssunto(),
  271 + "codigo" => $obj->getStrCodigoEstruturado(),
  272 + "descricao" => $obj->getStrDescricao(),
  273 + );
  274 + }
  275 + }
  276 +
  277 +// $arrayRetorno = array();
  278 +// if($start) $arrayRetorno = array_slice($arrayRetorno, ($start-1));
  279 +// if($limit) $arrayRetorno = array_slice($arrayRetorno, 0,($limit));
  280 +
  281 + $total = 0;
  282 + $total = count($arrayRetorno);
  283 +
  284 + return MdWsSeiRest::formataRetornoSucessoREST(null, $arrayRetorno, $total);
  285 + } catch (Exception $e) {
  286 + return MdWsSeiRest::formataRetornoErroREST($e);
  287 + }
  288 + }
  289 +
  290 + /**
  291 + * Realiza a consulta dos metadados de um processo especifico.
  292 + * @param MdWsSeiProcedimentoDTO $dto
  293 + * @return array
  294 + */
  295 + protected function consultarProcessoConectado(MdWsSeiProcedimentoDTO $dto)
  296 + {
  297 + try {
  298 + $arrayRetorno = array();
  299 + $id = $dto->getNumIdProcedimento();
  300 +
  301 + //Id do processo enviado por parâmetro
  302 + $processo = $id;
  303 +
  304 + // Recupera os dados do processo inseridos na tabela de protocolo
  305 + $objProtocoloDTO = new ProtocoloDTO();
  306 + $objProtocoloDTO->setDblIdProtocolo($processo);
  307 + $objProtocoloDTO->retStrDescricao(); // Recupera a especificação do processo
  308 + $objProtocoloDTO->retStrStaNivelAcessoLocal(); // Recupera o nível de acesso do processo
  309 + $objProtocoloDTO->retNumIdHipoteseLegal(); // Recupera o id da hipótese legal
  310 + $objProtocoloDTO->retStrStaGrauSigilo(); // Recupera o grau de sigilo
  311 +
  312 + $protocoloRN = new ProtocoloRN();
  313 + $objProtocoloDTO = $protocoloRN->consultarRN0186($objProtocoloDTO);
  314 +
  315 + // Recupera o tipo de processo da tabela de procedimento
  316 + $objProcedimentoDTO = new ProcedimentoDTO();
  317 + $objProcedimentoDTO->setDblIdProcedimento($processo);
  318 + $objProcedimentoDTO->retNumIdTipoProcedimento();
  319 +
  320 + $objProcedimentoRN = new ProcedimentoRN();
  321 + $objProcedimentoDTO = $objProcedimentoRN->consultarRN0201($objProcedimentoDTO);
  322 +
  323 + // Recupera os assuntos do processo
  324 + $objRelProtocoloAssuntoDTO = new RelProtocoloAssuntoDTO();
  325 + $objRelProtocoloAssuntoDTO->setDblIdProtocolo($processo);
  326 + $objRelProtocoloAssuntoDTO->retStrCodigoEstruturadoAssunto();
  327 + $objRelProtocoloAssuntoDTO->retStrDescricaoAssunto();
  328 + $objRelProtocoloAssuntoDTO->retNumIdAssunto();
  329 +
  330 + $objRelProtocoloAssuntoRN = new RelProtocoloAssuntoRN();
  331 + $objRelProtocoloAssuntoDTO = $objRelProtocoloAssuntoRN->listarRN0188($objRelProtocoloAssuntoDTO);
  332 +
  333 + $assuntos = array();
  334 + if($objRelProtocoloAssuntoDTO){
  335 + foreach ($objRelProtocoloAssuntoDTO as $obj) {
  336 + $assuntos[] = array(
  337 + "id" => $obj->getNumIdAssunto(),
  338 + "codigo" => $obj->getStrCodigoEstruturadoAssunto(),
  339 + "descricao" => $obj->getStrDescricaoAssunto()
  340 + );
  341 + }
  342 + }
  343 +
  344 + //Recupera os interessados do processo
  345 + $objParticipanteDTO = new ParticipanteDTO();
  346 + $objParticipanteDTO->setDblIdProtocolo($processo);
  347 + $objParticipanteDTO->setStrStaParticipacao('I');
  348 + $objParticipanteDTO->retNumIdContato();
  349 + $objParticipanteDTO->retStrNomeContato();
  350 +
  351 + $objParticipanteRN = new ParticipanteRN();
  352 + $objParticipanteDTO = $objParticipanteRN->listarRN0189($objParticipanteDTO);
  353 +
  354 + $interessados = array();
  355 + if($objParticipanteDTO){
  356 + foreach ($objParticipanteDTO as $obj) {
  357 + $interessados[] = array(
  358 + "id" => $obj->getNumIdContato(),
  359 + "nome" => $obj->getStrNomeContato()
  360 + );
  361 + }
  362 + }
  363 +
  364 + //Recupera as observações do process
  365 + $objObservacaoDTO = new ObservacaoDTO();
  366 + $objObservacaoDTO->setDblIdProtocolo($processo);
  367 + $objObservacaoDTO->retStrDescricao();
  368 + $objObservacaoDTO->retNumIdUnidade();
  369 +
  370 + $objObservacaoRN = new ObservacaoRN();
  371 + $objObservacaoDTO = $objObservacaoRN->listarRN0219($objObservacaoDTO);
  372 +
  373 + $observacoes = array();
  374 + if($objObservacaoDTO){
  375 + foreach ($objObservacaoDTO as $obj) {
  376 + $observacoes[] = array(
  377 + "unidade" =>$obj->getNumIdUnidade(),
  378 + "observacao" =>$obj->getStrDescricao()
  379 + );
  380 + }
  381 + }
  382 +
  383 + $arrayRetorno = array(
  384 + "especificacao" => $objProtocoloDTO->getStrDescricao(),
  385 + "tipoProcesso" => $objProcedimentoDTO->getNumIdTipoProcedimento(),
  386 + "assuntos" => $assuntos,
  387 + "interessados" => $interessados,
  388 + "nivelAcesso" => $objProtocoloDTO->getStrStaNivelAcessoLocal(),
  389 + "hipoteseLegal" => $objProtocoloDTO->getNumIdHipoteseLegal(),
  390 + "grauSigilo" => $objProtocoloDTO->getStrStaGrauSigilo(),
  391 + "observacoes" => $observacoes
  392 + );
  393 +
  394 + return MdWsSeiRest::formataRetornoSucessoREST(null, $arrayRetorno);
  395 + } catch (Exception $e) {
  396 + return MdWsSeiRest::formataRetornoErroREST($e);
  397 + }
  398 + }
  399 +
  400 +
  401 +
  402 + /**
  403 + * Gerar Procedimento
  404 + * @param ProtocoloDTO $protocoloDTO
  405 + * @return array
  406 + */
  407 + protected function gerarProcedimentoConectado(MdWsSeiProcedimentoDTO $procedimentoDTO)
  408 + {
  409 + try {
  410 +
  411 +// Assuntos
  412 + $arrayAssuntos = array();
  413 + if($procedimentoDTO->getArrObjAssunto()){
  414 + $i = 0;
  415 + foreach ($procedimentoDTO->getArrObjAssunto() as $assunto) {
  416 + $i++;
  417 + $objRelProtocoloAssuntoDTO = new RelProtocoloAssuntoDTO();
  418 + $objRelProtocoloAssuntoDTO->setNumIdAssunto($assunto['id']);
  419 + $objRelProtocoloAssuntoDTO->setNumSequencia($i);
  420 + $arrayAssuntos[] = $objRelProtocoloAssuntoDTO;
  421 + }
  422 + }
  423 +// Interessados
  424 + $arrayInteressados = array();
  425 + if($procedimentoDTO->getArrObjInteressado()){
  426 + $i = 0;
  427 + foreach ($procedimentoDTO->getArrObjInteressado() as $interessado) {
  428 + $i++;
  429 + $objParticipanteDTO = new ParticipanteDTO();
  430 + $objParticipanteDTO->setNumIdParticipante($interessado['id']);
  431 + $objParticipanteDTO->retTodos();
  432 +
  433 + $participanteRn = new ParticipanteRN();
  434 + $obj = $participanteRn->consultarRN1008($objParticipanteDTO);
  435 + $obj->setNumSequencia($i);
  436 +
  437 + $arrayInteressados[] = $obj;
  438 + }
  439 + }
  440 +
  441 +
  442 +
  443 + $objObservacaoDTO = new ObservacaoDTO();
  444 + $objObservacaoDTO->setStrDescricao($procedimentoDTO->getStrObservacao());
  445 +
  446 + $objProtocoloDTO = new ProtocoloDTO();
  447 + $objProtocoloDTO->setStrDescricao($procedimentoDTO->getStrEspecificacao());
  448 + // $objProtocoloDTO->setStrDescricaoObservacao('praxedes');
  449 + $objProtocoloDTO->setStrStaNivelAcessoLocal($procedimentoDTO->getNumNivelAcesso());
  450 + $objProtocoloDTO->setNumIdHipoteseLegal($procedimentoDTO->getNumIdHipoteseLegal());
  451 +// $objProtocoloDTO->setArrObjRelProtocoloAssuntoDTO(array($objRelProtocoloAssuntoDTO));
  452 + $objProtocoloDTO->setArrObjRelProtocoloAssuntoDTO($arrayAssuntos);
  453 + $objProtocoloDTO->setArrObjParticipanteDTO($arrayInteressados);
  454 + $objProtocoloDTO->setArrObjObservacaoDTO(array($objObservacaoDTO));
  455 + $objProtocoloDTO->setStrStaGrauSigilo($procedimentoDTO->getStrStaGrauSigilo());
  456 +
  457 + $objProcedimentoDTO = new ProcedimentoDTO();
  458 + $objProcedimentoDTO->setNumIdTipoProcedimento($procedimentoDTO->getNumIdTipoProcedimento());
  459 + $objProcedimentoDTO->setObjProtocoloDTO($objProtocoloDTO);
  460 + $objProcedimentoDTO->setStrSinGerarPendencia('S');
  461 +
  462 +
  463 + $objProcedimentoRN = new ProcedimentoRN();
  464 + $objProcedimentoRN->gerarRN0156($objProcedimentoDTO);
  465 +
  466 +
  467 + //ObjParticipanteDTO
  468 + //ObjRelProtocoloAssuntoDTO
  469 +
  470 +
  471 + /* $objProcedimentoAPI = new ProcedimentoAPI();
  472 + $objProcedimentoAPI->setIdTipoProcedimento($procedimentoDTO->getNumIdTipoProcedimento());
  473 + $objProcedimentoAPI->setEspecificacao($procedimentoDTO->getStrEspecificacao());
  474 + $objProcedimentoAPI->setAssuntos($procedimentoDTO->getArrObjAssunto());
  475 + $objProcedimentoAPI->setInteressados($procedimentoDTO->getArrObjInteressado());
  476 + $objProcedimentoAPI->setObservacao($procedimentoDTO->getStrObservacao());
  477 +
  478 + // 0 publico
  479 + // 1 restrito
  480 + // 2 sigiloso
  481 + $objProcedimentoAPI->setNivelAcesso($procedimentoDTO->getNumNivelAcesso());
  482 + $objProcedimentoAPI->setIdHipoteseLegal($procedimentoDTO->getNumIdHipoteseLegal());
  483 +
  484 +
  485 + $objEntradaGerarProcedimentoAPI = new EntradaGerarProcedimentoAPI();
  486 + $objEntradaGerarProcedimentoAPI->setProcedimento($objProcedimentoAPI);
  487 +
  488 + // var_dump($objEntradaGerarProcedimentoAPI); die();
  489 + $objSeiRN = new SeiRN();
  490 + $aux = $objSeiRN->gerarProcedimento($objEntradaGerarProcedimentoAPI);*/
  491 +
  492 + return MdWsSeiRest::formataRetornoSucessoREST(null);
  493 +
  494 + } catch (InfraException $e) {
  495 + //die($e->getStrDescricao());
  496 + return MdWsSeiRest::formataRetornoErroREST($e);
  497 + }
  498 + }
  499 +
  500 +
  501 +
  502 + /**
  503 + * Alterar Procedimento
  504 + * @param ProtocoloDTO $protocoloDTO
  505 + * @return array
  506 + */
  507 + protected function alterarProcedimentoConectado(MdWsSeiProcedimentoDTO $procedimentoDTO)
  508 + {
  509 + try {
  510 +
  511 + $processo = $procedimentoDTO->getNumIdProcedimento();
  512 + $tipoProcesso = $procedimentoDTO->getNumIdTipoProcedimento();
  513 + $especificacao = $procedimentoDTO->getStrEspecificacao();
  514 + $arrAssuntos = $procedimentoDTO->getArrObjAssunto();
  515 + $arrInteressados = $procedimentoDTO->getArrObjInteressado();
  516 + $observacoes = $procedimentoDTO->getStrObservacao();
  517 + $nivelAcesso = $procedimentoDTO->getNumNivelAcesso();
  518 + $hipoteseLegal = $procedimentoDTO->getNumIdHipoteseLegal();
  519 + $grauSigilo = $procedimentoDTO->getStrStaGrauSigilo();
  520 +
  521 + // PARÂMETROS DE ENTRADA
  522 +// $tipoProcesso = 100000349;
  523 +// $especificacao = 'descrição alterada';
  524 +// $arrAssuntos = array(array('id' => 2));
  525 +// $arrInteressados = array(array('id' => 100000003));
  526 +// $observacoes = "observação de teste";
  527 +// $nivelAcesso = 1;
  528 +// $hipoteseLegal = 2;
  529 +// $grauSigilo = '';
  530 +
  531 + // PREENCHE OS ASSUNTOS
  532 + if($arrAssuntos){
  533 + foreach ($arrAssuntos as $k => $assunto) {
  534 + $objRelProtocoloAssuntoDTO = new RelProtocoloAssuntoDTO();
  535 + $objRelProtocoloAssuntoDTO->setNumIdAssunto($assunto['id']);
  536 + $objRelProtocoloAssuntoDTO->setNumSequencia($k);
  537 + $arrayAssuntos[] = $objRelProtocoloAssuntoDTO;
  538 + }
  539 + }
  540 + // PREENCHE OS INTERESSADOS
  541 + if($arrInteressados){
  542 + foreach ($arrInteressados as $k => $interessado) {
  543 + $objParticipanteDTO = new ParticipanteDTO();
  544 + $objParticipanteDTO->setNumIdContato($interessado['id']);
  545 + $objParticipanteDTO->setStrStaParticipacao('I');
  546 + $objParticipanteDTO->setNumSequencia($k);
  547 + $arrayParticipantes[] = $objParticipanteDTO;
  548 + }
  549 + }
  550 +
  551 + // EDITA AS OBSERVAÇÕES
  552 + $objObservacaoDTO = new ObservacaoDTO();
  553 + $objObservacaoDTO->setStrDescricao($observacoes);
  554 +
  555 + // EDITA OS DADOS DO PROCESSO
  556 + $objProtocoloDTO = new ProtocoloDTO();
  557 + $objProtocoloDTO->setDblIdProtocolo($processo);
  558 + $objProtocoloDTO->setStrDescricao($especificacao);
  559 + $objProtocoloDTO->setStrStaNivelAcessoLocal($nivelAcesso);
  560 + $objProtocoloDTO->setNumIdHipoteseLegal($hipoteseLegal);
  561 + $objProtocoloDTO->setArrObjRelProtocoloAssuntoDTO($arrayAssuntos);
  562 + $objProtocoloDTO->setArrObjParticipanteDTO($arrayParticipantes);
  563 + $objProtocoloDTO->setArrObjObservacaoDTO(array($objObservacaoDTO));
  564 + $objProtocoloDTO->setStrStaGrauSigilo($grauSigilo);
  565 +
  566 + $objProcedimentoDTO = new ProcedimentoDTO();
  567 + $objProcedimentoDTO->setDblIdProcedimento($processo);
  568 + $objProcedimentoDTO->setNumIdTipoProcedimento($tipoProcesso);
  569 + $objProcedimentoDTO->setObjProtocoloDTO($objProtocoloDTO);
  570 + $objProcedimentoDTO->setStrSinGerarPendencia('S');
  571 +
  572 + // REALIZA A ALTERAÇÃO DOS DADOS DO PROCESSO
  573 + $objProcedimentoRN = new ProcedimentoRN();
  574 + $objProcedimentoRN->alterarRN0202($objProcedimentoDTO);
  575 +
  576 + return MdWsSeiRest::formataRetornoSucessoREST(null);
  577 +
  578 + } catch (InfraException $e) {
  579 + //die($e->getStrDescricao());
  580 + return MdWsSeiRest::formataRetornoErroREST($e);
  581 + }
  582 + }
  583 +
  584 + /**
  585 + * Método que lista o sobrestamento de um processo
  586 + * @param AtividadeDTO $atividadeDTOParam
  587 + * @return array
  588 + */
  589 + protected function listarSobrestamentoProcessoConectado(AtividadeDTO $atividadeDTOParam)
  590 + {
  591 + try {
  592 + if (!$atividadeDTOParam->isSetDblIdProtocolo()) {
  593 + throw new InfraException('Protocolo não informado.');
  594 + }
  595 + if (!$atividadeDTOParam->isSetNumIdUnidade()) {
  596 + $atividadeDTOParam->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual());
  597 + }
  598 +
  599 + $result = array();
  600 + $atividadeDTOConsulta = new AtividadeDTO();
  601 + $atividadeDTOConsulta->retTodos();
  602 + $atividadeDTOConsulta->setDblIdProtocolo($atividadeDTOParam->getDblIdProtocolo());
  603 + $atividadeDTOConsulta->setDthConclusao(null);
  604 + $atividadeDTOConsulta->setNumIdTarefa(TarefaRN::$TI_SOBRESTAMENTO);
  605 + $atividadeDTOConsulta->setNumMaxRegistrosRetorno(1);
  606 + $atividadeRN = new AtividadeRN();
  607 + $ret = $atividadeRN->listarRN0036($atividadeDTOConsulta);
  608 +
  609 + /** @var AtividadeDTO $atividadeDTO */
  610 + foreach ($ret as $atividadeDTO) {
  611 + $result[] = array(
  612 + 'idAtividade' => $atividadeDTO->getNumIdAtividade(),
  613 + 'idProtocolo' => $atividadeDTO->getDblIdProtocolo(),
  614 + 'dthAbertura' => $atividadeDTO->getDthAbertura(),
  615 + 'sinInicial' => $atividadeDTO->getStrSinInicial(),
  616 + 'dtaPrazo' => $atividadeDTO->getDtaPrazo(),
  617 + 'tipoVisualizacao' => $atividadeDTO->getNumTipoVisualizacao(),
  618 + 'dthConclusao' => $atividadeDTO->getDthConclusao(),
  619 + );
  620 + }
  621 +
  622 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result);
  623 + } catch (Exception $e) {
  624 + return MdWsSeiRest::formataRetornoErroREST($e);
  625 + }
  626 + }
  627 +
  628 + /**
  629 + * Metodo de sobrestamento de processo
  630 + * @param RelProtocoloProtocoloDTO $relProtocoloProtocoloDTO
  631 + * @return array
  632 + */
  633 + protected function sobrestamentoProcessoControlado(RelProtocoloProtocoloDTO $relProtocoloProtocoloDTO)
  634 + {
  635 + try {
  636 + if(!$relProtocoloProtocoloDTO->isSetDblIdProtocolo2()){
  637 + throw new Exception('Processo não informado!');
  638 + }
  639 + if(!$relProtocoloProtocoloDTO->isSetStrMotivo()){
  640 + throw new Exception('Informe o motivo!');
  641 + }
  642 + $procedimentoRN = new ProcedimentoRN();
  643 + $procedimentoRN->sobrestarRN1014(array($relProtocoloProtocoloDTO));
  644 +
  645 + return MdWsSeiRest::formataRetornoSucessoREST('Processo sobrestado com sucesso');
  646 + } catch (Exception $e) {
  647 + return MdWsSeiRest::formataRetornoErroREST($e);
  648 + }
  649 + }
  650 +
  651 + /**
  652 + * @param $protocolo
  653 + * @return array
  654 + */
  655 + protected function removerSobrestamentoProcessoControlado(ProcedimentoDTO $procedimentoDTOParam)
  656 + {
  657 + try {
  658 + if (!$procedimentoDTOParam->getDblIdProcedimento()) {
  659 + throw new InfraException('Procedimento não informado.');
  660 + }
  661 + $seiRN = new SeiRN();
  662 + $entradaRemoverSobrestamentoProcessoAPI = new EntradaRemoverSobrestamentoProcessoAPI();
  663 + $entradaRemoverSobrestamentoProcessoAPI->setIdProcedimento($procedimentoDTOParam->getDblIdProcedimento());
  664 +
  665 + $seiRN->removerSobrestamentoProcesso($entradaRemoverSobrestamentoProcessoAPI);
  666 +
  667 + return MdWsSeiRest::formataRetornoSucessoREST('Sobrestar cancelado com sucesso.');
  668 + } catch (Exception $e) {
  669 + return MdWsSeiRest::formataRetornoErroREST($e);
  670 + }
  671 + }
  672 +
  673 + /**
  674 + * Método que retorna os procedimentos com acompanhamento do usuário
  675 + * @param MdWsSeiProtocoloDTO $mdWsSeiProtocoloDTOConsulta
  676 + * @return array
  677 + */
  678 + protected function listarProcedimentoAcompanhamentoUsuarioConectado(MdWsSeiProtocoloDTO $mdWsSeiProtocoloDTOParam)
  679 + {
  680 + try {
  681 + $usuarioAtribuicaoAtividade = null;
  682 + $mdWsSeiProtocoloDTOConsulta = new MdWsSeiProtocoloDTO();
  683 + if ($mdWsSeiProtocoloDTOParam->isSetNumIdGrupoAcompanhamentoProcedimento()) {
  684 + $mdWsSeiProtocoloDTOConsulta->setNumIdGrupoAcompanhamentoProcedimento($mdWsSeiProtocoloDTOParam->getNumIdGrupoAcompanhamentoProcedimento());
  685 + }
  686 +
  687 + if (!$mdWsSeiProtocoloDTOParam->isSetNumIdUsuarioGeradorAcompanhamento()) {
  688 + $mdWsSeiProtocoloDTOConsulta->setNumIdUsuarioGeradorAcompanhamento(SessaoSEI::getInstance()->getNumIdUsuario());
  689 + } else {
  690 + $mdWsSeiProtocoloDTOConsulta->setNumIdUsuarioGeradorAcompanhamento($mdWsSeiProtocoloDTOParam->getNumIdUsuarioGeradorAcompanhamento());
  691 + }
  692 +
  693 + if (is_null($mdWsSeiProtocoloDTOParam->getNumPaginaAtual())) {
  694 + $mdWsSeiProtocoloDTOConsulta->setNumPaginaAtual(0);
  695 + } else {
  696 + $mdWsSeiProtocoloDTOConsulta->setNumPaginaAtual($mdWsSeiProtocoloDTOParam->getNumPaginaAtual());
  697 + }
  698 +
  699 + if (!$mdWsSeiProtocoloDTOParam->isSetNumMaxRegistrosRetorno()) {
  700 + $mdWsSeiProtocoloDTOConsulta->setNumMaxRegistrosRetorno(10);
  701 + } else {
  702 + $mdWsSeiProtocoloDTOConsulta->setNumMaxRegistrosRetorno($mdWsSeiProtocoloDTOParam->getNumMaxRegistrosRetorno());
  703 + }
  704 +
  705 + $protocoloRN = new ProtocoloRN();
  706 + $mdWsSeiProtocoloDTOConsulta->retTodos();
  707 + $mdWsSeiProtocoloDTOConsulta->retDblIdProtocolo();
  708 + $mdWsSeiProtocoloDTOConsulta->retStrNomeTipoProcedimentoProcedimento();
  709 + $mdWsSeiProtocoloDTOConsulta->retStrSiglaUnidadeGeradora();
  710 + $mdWsSeiProtocoloDTOConsulta->retStrSinCienciaProcedimento();
  711 + $mdWsSeiProtocoloDTOConsulta->setOrdDthGeracaoAcompanhamento(InfraDTO::$TIPO_ORDENACAO_ASC);
  712 + $mdWsSeiProtocoloDTOConsulta->retStrNomeTipoProcedimentoProcedimento();
  713 +
  714 + $ret = $protocoloRN->listarRN0668($mdWsSeiProtocoloDTOConsulta);
  715 + $result = $this->montaRetornoListagemProcessos($ret, $usuarioAtribuicaoAtividade);
  716 +
  717 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result, $mdWsSeiProtocoloDTOConsulta->getNumTotalRegistros());
  718 + } catch (Exception $e) {
  719 + return MdWsSeiRest::formataRetornoErroREST($e);
  720 + }
  721 + }
  722 +
  723 + /**
  724 + * Método que retorna os procedimentos com acompanhamento da unidade
  725 + * @param MdWsSeiProtocoloDTO $mdWsSeiProtocoloDTOConsulta
  726 + * @return array
  727 + */
  728 + protected function listarProcedimentoAcompanhamentoUnidadeConectado(MdWsSeiProtocoloDTO $mdWsSeiProtocoloDTOParam)
  729 + {
  730 + try {
  731 + $acompanhamentoRN = new AcompanhamentoRN();
  732 + $acompanhamentoDTO = new AcompanhamentoDTO();
  733 + $acompanhamentoDTO->setOrdNumIdAcompanhamento(InfraDTO::$TIPO_ORDENACAO_DESC);
  734 + if(!$mdWsSeiProtocoloDTOParam->isSetNumIdGrupoAcompanhamentoProcedimento()){
  735 + throw new Exception('O grupo deve ser informado!');
  736 + }else{
  737 + $acompanhamentoDTO->setNumIdGrupoAcompanhamento($mdWsSeiProtocoloDTOParam->getNumIdGrupoAcompanhamentoProcedimento());
  738 + }
  739 + if (is_null($mdWsSeiProtocoloDTOParam->getNumPaginaAtual())) {
  740 + $acompanhamentoDTO->setNumPaginaAtual(0);
  741 + } else {
  742 + $acompanhamentoDTO->setNumPaginaAtual($mdWsSeiProtocoloDTOParam->getNumPaginaAtual());
  743 + }
  744 +
  745 + if (!$mdWsSeiProtocoloDTOParam->isSetNumMaxRegistrosRetorno()) {
  746 + $acompanhamentoDTO->setNumMaxRegistrosRetorno(10);
  747 + } else {
  748 + $acompanhamentoDTO->setNumMaxRegistrosRetorno($mdWsSeiProtocoloDTOParam->getNumMaxRegistrosRetorno());
  749 + }
  750 +
  751 + $arrAcompanhamentoDTO = $acompanhamentoRN->listarAcompanhamentosUnidade($acompanhamentoDTO);
  752 + $totalRegistros = $acompanhamentoDTO->getNumTotalRegistros() ?: 0;
  753 +
  754 + $ret = array();
  755 + foreach($arrAcompanhamentoDTO as $acompanhamentoDTO){
  756 + $ret[] = $acompanhamentoDTO->getObjProcedimentoDTO();
  757 + }
  758 + $result = $this->montaRetornoListagemProcessos($ret, null);
  759 +
  760 +
  761 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result, $totalRegistros);
  762 + } catch (Exception $e) {
  763 + return MdWsSeiRest::formataRetornoErroREST($e);
  764 + }
  765 + }
  766 +
  767 + /**
  768 + * Método que pesquisa todos o procedimentos em todas as unidades
  769 + * @param MdWsSeiProtocoloDTO $mdWsSeiProtocoloDTOParam
  770 + * @return array
  771 + */
  772 + protected function pesquisarTodosProcessosConectado(MdWsSeiProtocoloDTO $mdWsSeiProtocoloDTOParam)
  773 + {
  774 + try {
  775 + $pesquisaPendenciaDTO = new MdWsSeiPesquisarPendenciaDTO();
  776 +
  777 + $usuarioAtribuicaoAtividade = null;
  778 + if ($mdWsSeiProtocoloDTOParam->isSetNumIdUsuarioAtribuicaoAtividade()) {
  779 + $usuarioAtribuicaoAtividade = $mdWsSeiProtocoloDTOParam->getNumIdUsuarioAtribuicaoAtividade();
  780 + }
  781 +
  782 + if (!is_null($mdWsSeiProtocoloDTOParam->getNumPaginaAtual())) {
  783 + $pesquisaPendenciaDTO->setNumPaginaAtual($mdWsSeiProtocoloDTOParam->getNumPaginaAtual());
  784 + } else {
  785 + $pesquisaPendenciaDTO->setNumPaginaAtual(0);
  786 + }
  787 +
  788 + if ($mdWsSeiProtocoloDTOParam->isSetNumMaxRegistrosRetorno()) {
  789 + $pesquisaPendenciaDTO->setNumMaxRegistrosRetorno($mdWsSeiProtocoloDTOParam->getNumMaxRegistrosRetorno());
  790 + } else {
  791 + $pesquisaPendenciaDTO->setNumMaxRegistrosRetorno(10);
  792 + }
  793 + if ($mdWsSeiProtocoloDTOParam->isSetNumIdGrupoAcompanhamentoProcedimento()) {
  794 + $pesquisaPendenciaDTO->setNumIdGrupoAcompanhamentoProcedimento(
  795 + $mdWsSeiProtocoloDTOParam->getNumIdGrupoAcompanhamentoProcedimento()
  796 + );
  797 + }
  798 + if ($mdWsSeiProtocoloDTOParam->isSetStrProtocoloFormatadoPesquisa()) {
  799 + $strProtocoloFormatado = InfraUtil::retirarFormatacao(
  800 + $mdWsSeiProtocoloDTOParam->getStrProtocoloFormatadoPesquisa(), false
  801 + );
  802 + $pesquisaPendenciaDTO->setStrProtocoloFormatadoPesquisaProtocolo(
  803 + '%' . $strProtocoloFormatado . '%',
  804 + InfraDTO::$OPER_LIKE
  805 + );
  806 + }
  807 +
  808 + $atividadeRN = new MdWsSeiAtividadeRN();
  809 + $pesquisaPendenciaDTO->setStrStaEstadoProcedimento(array(ProtocoloRN::$TE_NORMAL, ProtocoloRN::$TE_PROCEDIMENTO_BLOQUEADO));
  810 + $pesquisaPendenciaDTO->setStrSinAnotacoes('S');
  811 + $pesquisaPendenciaDTO->setStrSinRetornoProgramado('S');
  812 + $pesquisaPendenciaDTO->setStrSinCredenciais('S');
  813 + $pesquisaPendenciaDTO->setStrSinSituacoes('S');
  814 + $pesquisaPendenciaDTO->setStrSinMarcadores('S');
  815 +
  816 + $ret = $atividadeRN->listarPendencias($pesquisaPendenciaDTO);
  817 + $result = $this->montaRetornoListagemProcessos($ret, $usuarioAtribuicaoAtividade);
  818 +
  819 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result, $pesquisaPendenciaDTO->getNumTotalRegistros());
  820 + } catch (Exception $e) {
  821 + return MdWsSeiRest::formataRetornoErroREST($e);
  822 + }
  823 + }
  824 +
  825 + /**
  826 + * Método que retorna os procedimentos com acompanhamento com filtro opcional de grupo de acompanhamento e protocolo
  827 + * formatado
  828 + * @param MdWsSeiProtocoloDTO $mdWsSeiProtocoloDTOParam
  829 + * @return array
  830 + */
  831 + protected function pesquisarProcedimentoConectado(MdWsSeiProtocoloDTO $mdWsSeiProtocoloDTOParam)
  832 + {
  833 + try {
  834 + $pesquisaPendenciaDTO = new MdWsSeiPesquisarPendenciaDTO();
  835 +
  836 + $usuarioAtribuicaoAtividade = null;
  837 + if ($mdWsSeiProtocoloDTOParam->isSetNumIdUsuarioAtribuicaoAtividade()) {
  838 + $usuarioAtribuicaoAtividade = $mdWsSeiProtocoloDTOParam->getNumIdUsuarioAtribuicaoAtividade();
  839 + }
  840 +
  841 + if (!is_null($mdWsSeiProtocoloDTOParam->getNumPaginaAtual())) {
  842 + $pesquisaPendenciaDTO->setNumPaginaAtual($mdWsSeiProtocoloDTOParam->getNumPaginaAtual());
  843 + } else {
  844 + $pesquisaPendenciaDTO->setNumPaginaAtual(0);
  845 + }
  846 +
  847 + if ($mdWsSeiProtocoloDTOParam->isSetNumMaxRegistrosRetorno()) {
  848 + $pesquisaPendenciaDTO->setNumMaxRegistrosRetorno($mdWsSeiProtocoloDTOParam->getNumMaxRegistrosRetorno());
  849 + } else {
  850 + $pesquisaPendenciaDTO->setNumMaxRegistrosRetorno(10);
  851 + }
  852 + if ($mdWsSeiProtocoloDTOParam->isSetNumIdGrupoAcompanhamentoProcedimento()) {
  853 + $pesquisaPendenciaDTO->setNumIdGrupoAcompanhamentoProcedimento(
  854 + $mdWsSeiProtocoloDTOParam->getNumIdGrupoAcompanhamentoProcedimento()
  855 + );
  856 + }
  857 + if ($mdWsSeiProtocoloDTOParam->isSetStrProtocoloFormatadoPesquisa()) {
  858 + $strProtocoloFormatado = InfraUtil::retirarFormatacao(
  859 + $mdWsSeiProtocoloDTOParam->getStrProtocoloFormatadoPesquisa(), false
  860 + );
  861 + $pesquisaPendenciaDTO->setStrProtocoloFormatadoPesquisaProtocolo(
  862 + '%' . $strProtocoloFormatado . '%',
  863 + InfraDTO::$OPER_LIKE
  864 + );
  865 + }
  866 +
  867 + $atividadeRN = new MdWsSeiAtividadeRN();
  868 + $pesquisaPendenciaDTO->setNumIdUsuario(SessaoSEI::getInstance()->getNumIdUsuario());
  869 + $pesquisaPendenciaDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual());
  870 + $pesquisaPendenciaDTO->setStrStaEstadoProcedimento(array(ProtocoloRN::$TE_NORMAL, ProtocoloRN::$TE_PROCEDIMENTO_BLOQUEADO));
  871 + $pesquisaPendenciaDTO->setStrSinAnotacoes('S');
  872 + $pesquisaPendenciaDTO->setStrSinRetornoProgramado('S');
  873 + $pesquisaPendenciaDTO->setStrSinCredenciais('S');
  874 + $pesquisaPendenciaDTO->setStrSinSituacoes('S');
  875 + $pesquisaPendenciaDTO->setStrSinMarcadores('S');
  876 +
  877 + $ret = $atividadeRN->listarPendencias($pesquisaPendenciaDTO);
  878 + $result = $this->montaRetornoListagemProcessos($ret, $usuarioAtribuicaoAtividade);
  879 +
  880 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result, $pesquisaPendenciaDTO->getNumTotalRegistros());
  881 + } catch (Exception $e) {
  882 + return MdWsSeiRest::formataRetornoErroREST($e);
  883 + }
  884 + }
  885 +
  886 + /**
  887 + * Metodo que lista os processos
  888 + * @param MdWsSeiProtocoloDTO $mdWsSeiProtocoloDTO
  889 + * @return array
  890 + */
  891 + protected function listarProcessosConectado(MdWsSeiProtocoloDTO $mdWsSeiProtocoloDTOParam)
  892 + {
  893 + try {
  894 + $pesquisaPendenciaDTO = new MdWsSeiPesquisarPendenciaDTO();
  895 +
  896 + $usuarioAtribuicaoAtividade = null;
  897 + if ($mdWsSeiProtocoloDTOParam->isSetNumIdUsuarioAtribuicaoAtividade()) {
  898 + $usuarioAtribuicaoAtividade = $mdWsSeiProtocoloDTOParam->getNumIdUsuarioAtribuicaoAtividade();
  899 + }
  900 +
  901 + if (!is_null($mdWsSeiProtocoloDTOParam->getNumPaginaAtual())) {
  902 + $pesquisaPendenciaDTO->setNumPaginaAtual($mdWsSeiProtocoloDTOParam->getNumPaginaAtual());
  903 + } else {
  904 + $pesquisaPendenciaDTO->setNumPaginaAtual(0);
  905 + }
  906 +
  907 + if ($mdWsSeiProtocoloDTOParam->isSetNumMaxRegistrosRetorno()) {
  908 + $pesquisaPendenciaDTO->setNumMaxRegistrosRetorno($mdWsSeiProtocoloDTOParam->getNumMaxRegistrosRetorno());
  909 + } else {
  910 + $pesquisaPendenciaDTO->setNumMaxRegistrosRetorno(10);
  911 + }
  912 + if ($mdWsSeiProtocoloDTOParam->getStrSinApenasMeus() == 'S') {
  913 + $pesquisaPendenciaDTO->setStrStaTipoAtribuicao('M');
  914 + }
  915 +
  916 + $atividadeRN = new MdWsSeiAtividadeRN();
  917 + $pesquisaPendenciaDTO->setNumIdUsuario(SessaoSEI::getInstance()->getNumIdUsuario());
  918 + $pesquisaPendenciaDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual());
  919 + $pesquisaPendenciaDTO->setStrStaEstadoProcedimento(array(ProtocoloRN::$TE_NORMAL, ProtocoloRN::$TE_PROCEDIMENTO_BLOQUEADO));
  920 + $pesquisaPendenciaDTO->setStrSinAnotacoes('S');
  921 + $pesquisaPendenciaDTO->setStrSinRetornoProgramado('S');
  922 + $pesquisaPendenciaDTO->setStrSinCredenciais('S');
  923 + $pesquisaPendenciaDTO->setStrSinSituacoes('S');
  924 + $pesquisaPendenciaDTO->setStrSinMarcadores('S');
  925 +
  926 + if ($mdWsSeiProtocoloDTOParam->getStrSinTipoBusca() == MdWsSeiProtocoloDTO::SIN_TIPO_BUSCA_R) {
  927 + $pesquisaPendenciaDTO->setStrSinInicial('N');
  928 + } else if ($mdWsSeiProtocoloDTOParam->getStrSinTipoBusca() == MdWsSeiProtocoloDTO::SIN_TIPO_BUSCA_G) {
  929 + $pesquisaPendenciaDTO->setStrSinInicial('S');
  930 + } else {
  931 + throw new InfraException('O tipo de busca deve ser (R)ecebidos ou (G)erados');
  932 + }
  933 + $ret = $atividadeRN->listarPendencias($pesquisaPendenciaDTO);
  934 + $result = $this->montaRetornoListagemProcessos($ret, $usuarioAtribuicaoAtividade);
  935 +
  936 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result, $pesquisaPendenciaDTO->getNumTotalRegistros());
  937 + } catch (Exception $e) {
  938 + return MdWsSeiRest::formataRetornoErroREST($e);
  939 + }
  940 +
  941 + }
  942 +
  943 + /**
  944 + * Metodo que monta o retorno da listagem do processo com base no retorno da consulta
  945 + * @param array $ret
  946 + * @param null $usuarioAtribuicaoAtividade
  947 + * @return array
  948 + */
  949 + private function montaRetornoListagemProcessos(array $ret, $usuarioAtribuicaoAtividade = null)
  950 + {
  951 + $result = array();
  952 + $protocoloRN = new ProtocoloRN();
  953 + foreach ($ret as $dto) {
  954 + $usuarioAtribuido = null;
  955 + $documentoNovo = 'N';
  956 + $documentoPublicado = 'N';
  957 + $possuiAnotacao = 'N';
  958 + $podeGerenciarCredenciais = 'N';
  959 + $possuiAnotacaoPrioridade = 'N';
  960 + $usuarioVisualizacao = 'N';
  961 + $tipoVisualizacao = 'N';
  962 + $retornoProgramado = 'N';
  963 + $retornoAtrasado = 'N';
  964 + $processoAberto = false;
  965 + $acaoReabrirProcesso = SessaoSEI::getInstance()->verificarPermissao('procedimento_reabrir');
  966 + $acaoRegistrarAnotacao = SessaoSEI::getInstance()->verificarPermissao('anotacao_registrar');
  967 + $processoEmTramitacao = false;
  968 + $processoSobrestado = false;
  969 + $processoAnexado = false;
  970 + $podeReabrirProcesso = false;
  971 + $podeRegistrarAnotacao = false;
  972 + $arrDadosAbertura = array();
  973 + $procedimentoDTO = null;
  974 + $resultAnotacao = array();
  975 + $protocoloDTO = new MdWsSeiProtocoloDTO();
  976 + if ($dto instanceof ProcedimentoDTO) {
  977 + $protocoloDTO = new MdWsSeiProtocoloDTO();
  978 + $protocoloDTO->setDblIdProtocolo($dto->getDblIdProcedimento());
  979 + $protocoloDTO->retDblIdProtocolo();
  980 + $protocoloDTO->retNumIdUnidadeGeradora();
  981 + $protocoloDTO->retStrStaProtocolo();
  982 + $protocoloDTO->retStrProtocoloFormatado();
  983 + $protocoloDTO->retStrNomeTipoProcedimentoProcedimento();
  984 + $protocoloDTO->retStrDescricao();
  985 + $protocoloDTO->retStrSiglaUnidadeGeradora();
  986 + $protocoloDTO->retStrStaGrauSigilo();
  987 + $protocoloDTO->retStrStaNivelAcessoLocal();
  988 + $protocoloDTO->retStrStaNivelAcessoGlobal();
  989 + $protocoloDTO->retStrSinCienciaProcedimento();
  990 + $protocoloDTO->retStrStaEstado();
  991 + $protocoloDTO = $protocoloRN->consultarRN0186($protocoloDTO);
  992 + } else {
  993 + $protocoloDTO = $dto;
  994 + }
  995 +
  996 + $processoBloqueado = $protocoloDTO->getStrStaEstado() == ProtocoloRN::$TE_PROCEDIMENTO_BLOQUEADO ? 'S' : 'N';
  997 + $processoRemocaoSobrestamento = 'N';
  998 + $processoDocumentoIncluidoAssinado = 'N';
  999 + $processoPublicado = 'N';
  1000 +
  1001 + $atividadeRN = new MdWsSeiAtividadeRN();
  1002 + $atividadeDTOConsulta = new AtividadeDTO();
  1003 + $atividadeDTOConsulta->setDblIdProtocolo($protocoloDTO->getDblIdProtocolo());
  1004 + $atividadeDTOConsulta->retDblIdProtocolo();
  1005 + $atividadeDTOConsulta->retNumIdTarefa();
  1006 + $atividadeDTOConsulta->retNumTipoVisualizacao();
  1007 + $atividadeDTOConsulta->retStrNomeUsuarioAtribuicao();
  1008 + $atividadeDTOConsulta->retNumIdUsuarioVisualizacao();
  1009 + $atividadeDTOConsulta->retNumIdAtividade();
  1010 +
  1011 + $atividadeDTOConsulta->setNumMaxRegistrosRetorno(1);
  1012 + $atividadeDTOConsulta->setOrdNumIdAtividade(InfraDTO::$TIPO_ORDENACAO_DESC);
  1013 +
  1014 + $arrAtividades = $atividadeRN->listarRN0036($atividadeDTOConsulta);
  1015 +
  1016 + if ($arrAtividades) {
  1017 + /** @var AtividadeDTO $atividadeDTO */
  1018 + $atividadeDTO = $arrAtividades[0];
  1019 + $documentoNovo = $atividadeDTO->getNumIdTarefa() == 1 ? 'S' : 'N';
  1020 + $usuarioAtribuido = $atividadeDTO->getStrNomeUsuarioAtribuicao();
  1021 + $tipoVisualizacao = $atividadeDTO->getNumTipoVisualizacao() == 0 ? 'S' : 'N';
  1022 + if ($atividadeDTO->getNumIdUsuarioVisualizacao() == $usuarioAtribuicaoAtividade) {
  1023 + $usuarioVisualizacao = 'S';
  1024 + }
  1025 + }
  1026 + $arrAtividadePendenciaDTO = array();
  1027 + if ($dto instanceof ProcedimentoDTO && $dto->isSetArrObjAtividadeDTO()) {
  1028 + $procedimentoDTO = $dto;
  1029 + $arrAtividadePendenciaDTO = $procedimentoDTO->getArrObjAtividadeDTO();
  1030 + } else {
  1031 + $pesquisaPendenciaDTO = new MdWsSeiPesquisarPendenciaDTO();
  1032 + $pesquisaPendenciaDTO->setNumIdUsuario(SessaoSEI::getInstance()->getNumIdUsuario());
  1033 + $pesquisaPendenciaDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual());
  1034 + $pesquisaPendenciaDTO->setStrStaEstadoProcedimento(array(ProtocoloRN::$TE_NORMAL, ProtocoloRN::$TE_PROCEDIMENTO_BLOQUEADO));
  1035 + $pesquisaPendenciaDTO->setStrSinAnotacoes('S');
  1036 + $pesquisaPendenciaDTO->setStrSinRetornoProgramado('S');
  1037 + $pesquisaPendenciaDTO->setStrSinCredenciais('S');
  1038 + $pesquisaPendenciaDTO->setStrSinSituacoes('S');
  1039 + $pesquisaPendenciaDTO->setStrSinMarcadores('S');
  1040 + $pesquisaPendenciaDTO->setDblIdProtocolo($protocoloDTO->getDblIdProtocolo());
  1041 + $arrProcedimentoDTO = $atividadeRN->listarPendencias($pesquisaPendenciaDTO);
  1042 + if ($arrProcedimentoDTO) {
  1043 + $procedimentoDTO = $arrProcedimentoDTO[0];
  1044 + $arrAtividadePendenciaDTO = $procedimentoDTO->getArrObjAtividadeDTO();
  1045 + }
  1046 + }
  1047 + if ($arrAtividadePendenciaDTO) {
  1048 + $atividadePendenciaDTO = $arrAtividadePendenciaDTO[0];
  1049 + if ($atividadePendenciaDTO->getNumTipoVisualizacao() & AtividadeRN::$TV_REMOCAO_SOBRESTAMENTO) {
  1050 + $processoRemocaoSobrestamento = 'S';
  1051 + }
  1052 + if ($atividadePendenciaDTO->getNumTipoVisualizacao() & AtividadeRN::$TV_ATENCAO) {
  1053 + $processoDocumentoIncluidoAssinado = 'S';
  1054 + }
  1055 + if ($atividadePendenciaDTO->getNumTipoVisualizacao() & AtividadeRN::$TV_PUBLICACAO) {
  1056 + $processoPublicado = 'S';
  1057 + }
  1058 + $retornoProgramadoDTOConsulta = new RetornoProgramadoDTO();
  1059 + $retornoProgramadoDTOConsulta->retDblIdProtocoloAtividadeEnvio();
  1060 + $retornoProgramadoDTOConsulta->retStrSiglaUnidadeOrigemAtividadeEnvio();
  1061 + $retornoProgramadoDTOConsulta->retStrSiglaUnidadeAtividadeEnvio();
  1062 + $retornoProgramadoDTOConsulta->retDtaProgramada();
  1063 + $retornoProgramadoDTOConsulta->setNumIdUnidadeAtividadeEnvio(SessaoSEI::getInstance()->getNumIdUnidadeAtual());
  1064 + $retornoProgramadoDTOConsulta->setDblIdProtocoloAtividadeEnvio(array_unique(InfraArray::converterArrInfraDTO($arrAtividadePendenciaDTO, 'IdProtocolo')), InfraDTO::$OPER_IN);
  1065 + $retornoProgramadoDTOConsulta->setNumIdAtividadeRetorno(null);
  1066 + $objRetornoProgramadoRN = new RetornoProgramadoRN();
  1067 + $arrRetornoProgramadoDTO = $objRetornoProgramadoRN->listar($retornoProgramadoDTOConsulta);
  1068 + if ($arrRetornoProgramadoDTO) {
  1069 + $retornoProgramado = 'S';
  1070 + $strDataAtual = InfraData::getStrDataAtual();
  1071 + foreach ($arrRetornoProgramadoDTO as $retornoProgramadoDTO) {
  1072 + $numPrazo = InfraData::compararDatas($strDataAtual, $retornoProgramadoDTO->getDtaProgramada());
  1073 + if ($numPrazo < 0) {
  1074 + $retornoAtrasado = 'S';
  1075 + }
  1076 + $retornoData = array(
  1077 + 'dataProgramada' => $retornoProgramadoDTO->getDtaProgramada(),
  1078 + 'unidade' => $retornoProgramadoDTO->getStrSiglaUnidadeOrigemAtividadeEnvio()
  1079 + );
  1080 + }
  1081 + }
  1082 + }
  1083 + $documentoRN = new DocumentoRN();
  1084 + $documentoDTOConsulta = new DocumentoDTO();
  1085 + $documentoDTOConsulta->setDblIdProcedimento($protocoloDTO->getDblIdProtocolo());
  1086 + $documentoDTOConsulta->retDblIdDocumento();
  1087 + $arrDocumentos = $documentoRN->listarRN0008($documentoDTOConsulta);
  1088 + if ($arrDocumentos) {
  1089 + $arrIdDocumentos = array();
  1090 + /** @var DocumentoDTO $documentoDTO */
  1091 + foreach ($arrDocumentos as $documentoDTO) {
  1092 + $arrIdDocumentos[] = $documentoDTO->getDblIdDocumento();
  1093 + }
  1094 + $publiacaoRN = new PublicacaoRN();
  1095 + $publicacaoDTO = new PublicacaoDTO();
  1096 + $publicacaoDTO->retNumIdPublicacao();
  1097 + $publicacaoDTO->setNumMaxRegistrosRetorno(1);
  1098 + $publicacaoDTO->adicionarCriterio(
  1099 + array('IdDocumento'),
  1100 + array(InfraDTO::$OPER_IN),
  1101 + array($arrIdDocumentos)
  1102 + );
  1103 + $arrPublicacaoDTO = $publiacaoRN->listarRN1045($publicacaoDTO);
  1104 + $documentoPublicado = count($arrPublicacaoDTO) ? 'S' : 'N';
  1105 + }
  1106 + $anotacaoRN = new AnotacaoRN();
  1107 + $anotacaoDTOConsulta = new AnotacaoDTO();
  1108 + $anotacaoDTOConsulta->setNumMaxRegistrosRetorno(1);
  1109 + $anotacaoDTOConsulta->retDblIdProtocolo();
  1110 + $anotacaoDTOConsulta->retStrDescricao();
  1111 + $anotacaoDTOConsulta->retNumIdUnidade();
  1112 + $anotacaoDTOConsulta->retNumIdUsuario();
  1113 + $anotacaoDTOConsulta->retDthAnotacao();
  1114 + $anotacaoDTOConsulta->retStrSinPrioridade();
  1115 + $anotacaoDTOConsulta->retStrStaAnotacao();
  1116 + $anotacaoDTOConsulta->retNumIdAnotacao();
  1117 + $anotacaoDTOConsulta->setDblIdProtocolo($protocoloDTO->getDblIdProtocolo());
  1118 + $anotacaoDTOConsulta->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual());
  1119 + $arrAnotacao = $anotacaoRN->listar($anotacaoDTOConsulta);
  1120 + $possuiAnotacao = count($arrAnotacao) ? 'S' : 'N';
  1121 + foreach ($arrAnotacao as $anotacaoDTO) {
  1122 + if ($anotacaoDTO->getStrSinPrioridade() == 'S') {
  1123 + $possuiAnotacaoPrioridade = 'S';
  1124 + break;
  1125 + }
  1126 + }
  1127 + /** @var AnotacaoDTO $anotacaoDTO */
  1128 + foreach ($arrAnotacao as $anotacaoDTO) {
  1129 + $resultAnotacao[] = array(
  1130 + 'idAnotacao' => $anotacaoDTO->getNumIdAnotacao(),
  1131 + 'idProtocolo' => $anotacaoDTO->getDblIdProtocolo(),
  1132 + 'descricao' => $anotacaoDTO->getStrDescricao(),
  1133 + 'idUnidade' => $anotacaoDTO->getNumIdUnidade(),
  1134 + 'idUsuario' => $anotacaoDTO->getNumIdUsuario(),
  1135 + 'dthAnotacao' => $anotacaoDTO->getDthAnotacao(),
  1136 + 'sinPrioridade' => $anotacaoDTO->getStrSinPrioridade(),
  1137 + 'staAnotacao' => $anotacaoDTO->getStrStaAnotacao()
  1138 + );
  1139 + }
  1140 + if ($protocoloDTO->getStrStaEstado() != ProtocoloRN::$TE_PROCEDIMENTO_ANEXADO) {
  1141 + $procedimentoDTOParam = new ProcedimentoDTO();
  1142 + $procedimentoDTOParam->setDblIdProcedimento($protocoloDTO->getDblIdProtocolo());
  1143 + $procedimentoDTOParam->setStrStaNivelAcessoGlobalProtocolo($protocoloDTO->getStrStaNivelAcessoGlobal());
  1144 + $arrDadosAbertura = $this->listarUnidadeAberturaProcedimento($procedimentoDTOParam);
  1145 + }
  1146 +
  1147 + if($protocoloDTO->getStrStaNivelAcessoGlobal() == ProtocoloRN::$NA_SIGILOSO){
  1148 + $podeGerenciarCredenciais = SessaoSEI::getInstance()->verificarPermissao('procedimento_credencial_gerenciar') ? 'S' : 'N';
  1149 + }
  1150 +
  1151 + $pesquisaPendenciaDTO = new PesquisaPendenciaDTO();
  1152 + $pesquisaPendenciaDTO->setDblIdProtocolo($protocoloDTO->getDblIdProtocolo());
  1153 + $pesquisaPendenciaDTO->setNumIdUsuario(SessaoSEI::getInstance()->getNumIdUsuario());
  1154 + $pesquisaPendenciaDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual());
  1155 + $pesquisaPendenciaDTO->setStrSinMontandoArvore('S');
  1156 + $pesquisaPendenciaDTO->setStrSinRetornoProgramado('S');
  1157 +
  1158 + $processoEmTramitacao = $processoAberto = count($atividadeRN->listarPendenciasRN0754($pesquisaPendenciaDTO)) == 1;
  1159 + if ($protocoloDTO->getNumIdUnidadeGeradora() == SessaoSEI::getInstance()->getNumIdUnidadeAtual()){
  1160 + $processoEmTramitacao = true;
  1161 + }else{
  1162 + $atividadeDTO = new AtividadeDTO();
  1163 + $atividadeDTO->retNumIdAtividade();
  1164 + $atividadeDTO->setNumIdUnidadeOrigem(SessaoSEI::getInstance()->getNumIdUnidadeAtual(),InfraDTO::$OPER_DIFERENTE);
  1165 + $atividadeDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual());
  1166 + $atividadeDTO->setDblIdProtocolo($protocoloDTO->getDblIdProtocolo());
  1167 + $atividadeDTO->setNumMaxRegistrosRetorno(1);
  1168 +
  1169 + if ($atividadeRN->consultarRN0033($atividadeDTO)!=null){
  1170 + $processoEmTramitacao = true;
  1171 + }
  1172 + }
  1173 + if ($protocoloDTO->getStrStaEstado() == ProtocoloRN::$TE_PROCEDIMENTO_SOBRESTADO){
  1174 + if ($processoAberto){
  1175 + $processoAberto = false;
  1176 + }
  1177 + $processoSobrestado = true;
  1178 + }else if($protocoloDTO->getStrStaEstado()==ProtocoloRN::$TE_PROCEDIMENTO_ANEXADO){
  1179 + $processoAnexado = true;
  1180 + }
  1181 + if (!$processoAberto && $acaoReabrirProcesso && $processoEmTramitacao && !$processoSobrestado && !$processoAnexado) {
  1182 + $podeReabrirProcesso = true;
  1183 + }
  1184 + if ($processoEmTramitacao && $acaoRegistrarAnotacao) {
  1185 + $podeRegistrarAnotacao = true;
  1186 + }
  1187 +
  1188 + $objInfraParametro = new InfraParametro(BancoSEI::getInstance());
  1189 +
  1190 + $result[] = array(
  1191 + 'id' => $protocoloDTO->getDblIdProtocolo(),
  1192 + 'status' => $protocoloDTO->getStrStaProtocolo(),
  1193 + 'seiNumMaxDocsPasta' => $objInfraParametro->getValor('SEI_NUM_MAX_DOCS_PASTA'),
  1194 + 'atributos' => array(
  1195 + 'idProcedimento' => $protocoloDTO->getDblIdProtocolo(),
  1196 + 'idProtocolo' => $protocoloDTO->getDblIdProtocolo(),
  1197 + 'numero' => $protocoloDTO->getStrProtocoloFormatado(),
  1198 + 'tipoProcesso' => $protocoloDTO->getStrNomeTipoProcedimentoProcedimento(),
  1199 + 'descricao' => $protocoloDTO->getStrDescricao(),
  1200 + 'usuarioAtribuido' => $usuarioAtribuido,
  1201 + 'unidade' => array(
  1202 + 'idUnidade' => $protocoloDTO->getNumIdUnidadeGeradora(),
  1203 + 'sigla' => $protocoloDTO->getStrSiglaUnidadeGeradora()
  1204 + ),
  1205 + 'dadosAbertura' => $arrDadosAbertura,
  1206 + 'anotacoes' => $resultAnotacao,
  1207 + 'status' => array(
  1208 + 'documentoSigiloso' => $protocoloDTO->getStrStaGrauSigilo(),
  1209 + 'documentoRestrito' => $protocoloDTO->getStrStaNivelAcessoLocal() == 1 ? 'S' : 'N',
  1210 + 'documentoNovo' => $documentoNovo,
  1211 + 'documentoPublicado' => $documentoPublicado,
  1212 + 'anotacao' => $possuiAnotacao,
  1213 + 'anotacaoPrioridade' => $possuiAnotacaoPrioridade,//verificar
  1214 + 'ciencia' => $protocoloDTO->getStrSinCienciaProcedimento(),
  1215 + 'retornoProgramado' => $retornoProgramado,
  1216 + 'retornoData' => $retornoData,
  1217 + 'retornoAtrasado' => $retornoAtrasado,
  1218 + 'processoAcessadoUsuario' => $tipoVisualizacao,
  1219 + 'processoAcessadoUnidade' => $usuarioVisualizacao,
  1220 + 'processoRemocaoSobrestamento' => $processoRemocaoSobrestamento,
  1221 + 'processoBloqueado' => $processoBloqueado,
  1222 + 'processoDocumentoIncluidoAssinado' => $processoDocumentoIncluidoAssinado,
  1223 + 'processoPublicado' => $processoPublicado,
  1224 + 'nivelAcessoGlobal' => $protocoloDTO->getStrStaNivelAcessoGlobal(),
  1225 + 'podeGerenciarCredenciais' => $podeGerenciarCredenciais,
  1226 + 'processoAberto' => $processoAberto ? 'S' : 'N',
  1227 + 'processoEmTramitacao' => $processoEmTramitacao ? 'S' : 'N',
  1228 + 'processoSobrestado' => $processoSobrestado ? 'S' : 'N',
  1229 + 'processoAnexado' => $processoAnexado ? 'S' : 'N',
  1230 + 'podeReabrirProcesso' => $podeReabrirProcesso ? 'S' : 'N',
  1231 + 'podeRegistrarAnotacao' => $podeRegistrarAnotacao ? 'S' : 'N',
  1232 + )
  1233 + )
  1234 + );
  1235 + }
  1236 +
  1237 + return $result;
  1238 + }
  1239 +
  1240 + protected function listarUnidadeAberturaProcedimentoConectado(ProcedimentoDTO $procedimentoDTO)
  1241 + {
  1242 + $result = array();
  1243 + $atividadeRN = new MdWsSeiAtividadeRN();
  1244 + $strStaNivelAcessoGlobal = $procedimentoDTO->getStrStaNivelAcessoGlobalProtocolo();
  1245 + $dblIdProcedimento = $procedimentoDTO->getDblIdProcedimento();
  1246 + $atividadeDTO = new AtividadeDTO();
  1247 + $atividadeDTO->setDistinct(true);
  1248 + $atividadeDTO->retStrSiglaUnidade();
  1249 + $atividadeDTO->retNumIdUnidade();
  1250 + $atividadeDTO->retStrDescricaoUnidade();
  1251 +
  1252 + $atividadeDTO->setOrdStrSiglaUnidade(InfraDTO::$TIPO_ORDENACAO_ASC);
  1253 +
  1254 + if ($strStaNivelAcessoGlobal == ProtocoloRN::$NA_SIGILOSO) {
  1255 + $atividadeDTO->retNumIdUsuario();
  1256 + $atividadeDTO->retStrSiglaUsuario();
  1257 + $atividadeDTO->retStrNomeUsuario();
  1258 + } else {
  1259 + $atividadeDTO->retNumIdUsuarioAtribuicao();
  1260 + $atividadeDTO->retStrSiglaUsuarioAtribuicao();
  1261 + $atividadeDTO->retStrNomeUsuarioAtribuicao();
  1262 +
  1263 + //ordena descendente pois no envio de processo que já existe na unidade e está atribuído ficará com mais de um andamento em aberto
  1264 + //desta forma os andamentos com usuário nulo (envios do processo) serão listados depois
  1265 + $atividadeDTO->setOrdStrSiglaUsuarioAtribuicao(InfraDTO::$TIPO_ORDENACAO_DESC);
  1266 +
  1267 + }
  1268 + $atividadeDTO->setDblIdProtocolo($dblIdProcedimento);
  1269 + $atividadeDTO->setDthConclusao(null);
  1270 +
  1271 + //sigiloso sem credencial nao considera o usuario atual
  1272 + if ($strStaNivelAcessoGlobal == ProtocoloRN::$NA_SIGILOSO) {
  1273 +
  1274 + $acessoDTO = new AcessoDTO();
  1275 + $acessoDTO->setDistinct(true);
  1276 + $acessoDTO->retNumIdUsuario();
  1277 + $acessoDTO->setDblIdProtocolo($dblIdProcedimento);
  1278 + $acessoDTO->setStrStaTipo(AcessoRN::$TA_CREDENCIAL_PROCESSO);
  1279 +
  1280 + $acessoRN = new AcessoRN();
  1281 + $arrAcessoDTO = $acessoRN->listar($acessoDTO);
  1282 +
  1283 + $atividadeDTO->setNumIdUsuario(InfraArray::converterArrInfraDTO($arrAcessoDTO, 'IdUsuario'), InfraDTO::$OPER_IN);
  1284 + }
  1285 + $arrAtividadeDTO = $atividadeRN->listarRN0036($atividadeDTO);
  1286 +
  1287 + if ($strStaNivelAcessoGlobal != ProtocoloRN::$NA_SIGILOSO) {
  1288 + $arrAtividadeDTO = InfraArray::distinctArrInfraDTO($arrAtividadeDTO, 'SiglaUnidade');
  1289 + }
  1290 + if (count($arrAtividadeDTO) == 0) {
  1291 + $result['info'] = 'Processo não possui andamentos abertos.';
  1292 + $result['lista'] = array();
  1293 + $result['unidades'] = array();
  1294 + } else {
  1295 + if (count($arrAtividadeDTO) == 1) {
  1296 + $atividadeDTO = $arrAtividadeDTO[0];
  1297 + if ($strStaNivelAcessoGlobal != ProtocoloRN::$NA_SIGILOSO) {
  1298 + $result['info'] = 'Processo aberto somente na unidade:';
  1299 + $result['unidades'][] = array(
  1300 + 'id' => $atividadeDTO->getNumIdUnidade(),
  1301 + 'nome' => $atividadeDTO->getStrSiglaUnidade()
  1302 + );
  1303 + $result['lista'][] = array(
  1304 + 'sigla' => $atividadeDTO->getStrSiglaUnidade()
  1305 + );
  1306 + } else {
  1307 + $result['info'] = 'Processo aberto com o usuário:';
  1308 + $atividadeDTO = $arrAtividadeDTO[0];
  1309 + $result['unidades'][] = array(
  1310 + 'id' => $atividadeDTO->getNumIdUnidade(),
  1311 + 'nome' => $atividadeDTO->getStrSiglaUnidade()
  1312 + );
  1313 + $result['lista'][] = array(
  1314 + 'sigla' => $atividadeDTO->getStrNomeUsuario()
  1315 + );
  1316 + }
  1317 + } else {
  1318 + if ($strStaNivelAcessoGlobal != ProtocoloRN::$NA_SIGILOSO) {
  1319 + $result['info'] = 'Processo aberto nas unidades:';
  1320 + foreach ($arrAtividadeDTO as $atividadeDTO) {
  1321 + $result['unidades'][] = array(
  1322 + 'id' => $atividadeDTO->getNumIdUnidade(),
  1323 + 'nome' => $atividadeDTO->getStrSiglaUnidade()
  1324 + );
  1325 + $sigla = $atividadeDTO->getStrSiglaUnidade();
  1326 + if ($atividadeDTO->getNumIdUsuarioAtribuicao() != null) {
  1327 + $sigla .= ' (atribuído a ' . $atividadeDTO->getStrNomeUsuarioAtribuicao() . ')';
  1328 + }
  1329 + $result['lista'][] = array(
  1330 + 'sigla' => $sigla
  1331 + );
  1332 + }
  1333 + } else {
  1334 + $result['info'] = 'Processo aberto com os usuários:';
  1335 + foreach ($arrAtividadeDTO as $atividadeDTO) {
  1336 + $result['unidades'][] = array(
  1337 + 'id' => $atividadeDTO->getNumIdUnidade(),
  1338 + 'nome' => $atividadeDTO->getStrSiglaUnidade()
  1339 + );
  1340 + $sigla = $atividadeDTO->getStrNomeUsuario() . ' na unidade ' . $atividadeDTO->getStrSiglaUnidade();
  1341 + $result['lista'][] = array(
  1342 + 'sigla' => $sigla
  1343 + );
  1344 + }
  1345 + }
  1346 + }
  1347 + }
  1348 +
  1349 + return $result;
  1350 + }
  1351 +
  1352 + /**
  1353 + * Metodo que retorna as ciencias nos processos
  1354 + * @param ProtocoloDTO $protocoloDTOParam
  1355 + * @return array
  1356 + */
  1357 + protected function listarCienciaProcessoConectado(ProtocoloDTO $protocoloDTOParam)
  1358 + {
  1359 + try {
  1360 + if (!$protocoloDTOParam->isSetDblIdProtocolo()) {
  1361 + throw new InfraException('Protocolo não informado.');
  1362 + }
  1363 +
  1364 + $result = array();
  1365 + $mdWsSeiProcessoRN = new MdWsSeiProcessoRN();
  1366 + $atividadeDTOConsulta = new AtividadeDTO();
  1367 + $atividadeDTOConsulta->setDblIdProtocolo($protocoloDTOParam->getDblIdProtocolo());
  1368 + $atividadeDTOConsulta->setNumIdTarefa(TarefaRN::$TI_PROCESSO_CIENCIA);
  1369 + $atividadeDTOConsulta->retDthAbertura();
  1370 + $atividadeDTOConsulta->retStrSiglaUnidade();
  1371 + $atividadeDTOConsulta->retStrNomeTarefa();
  1372 + $atividadeDTOConsulta->retStrSiglaUsuarioOrigem();
  1373 + $atividadeDTOConsulta->retNumIdAtividade();
  1374 + $atividadeRN = new AtividadeRN();
  1375 + $ret = $atividadeRN->listarRN0036($atividadeDTOConsulta);
  1376 + /** @var AtividadeDTO $atividadeDTO */
  1377 + foreach ($ret as $atividadeDTO) {
  1378 + $mdWsSeiProcessoDTO = new MdWsSeiProcessoDTO();
  1379 + $mdWsSeiProcessoDTO->setStrTemplate($atividadeDTO->getStrNomeTarefa());
  1380 + $mdWsSeiProcessoDTO->setNumIdAtividade($atividadeDTO->getNumIdAtividade());
  1381 + $result[] = array(
  1382 + 'data' => $atividadeDTO->getDthAbertura(),
  1383 + 'unidade' => $atividadeDTO->getStrSiglaUnidade(),
  1384 + 'nome' => $atividadeDTO->getStrSiglaUsuarioOrigem(),
  1385 + 'descricao' => $mdWsSeiProcessoRN->traduzirTemplate($mdWsSeiProcessoDTO)
  1386 + );
  1387 + }
  1388 +
  1389 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result);
  1390 + } catch (Exception $e) {
  1391 + return MdWsSeiRest::formataRetornoErroREST($e);
  1392 + }
  1393 + }
  1394 +
  1395 +
  1396 + /**
  1397 + * Metodo que da ciencia ao processo/procedimento
  1398 + * @param ProcedimentoDTO $procedimentoDTO
  1399 + * @info E obrigatorio informar o id do procedimento
  1400 + * @return array
  1401 + */
  1402 + protected function darCienciaControlado(ProcedimentoDTO $procedimentoDTOParam)
  1403 + {
  1404 + try {
  1405 + if (!$procedimentoDTOParam->isSetDblIdProcedimento()) {
  1406 + throw new InfraException('E obrigatorio informar o procedimento!');
  1407 + }
  1408 +
  1409 + $procedimentoRN = new ProcedimentoRN();
  1410 + $procedimentoRN->darCiencia($procedimentoDTOParam);
  1411 +
  1412 + return MdWsSeiRest::formataRetornoSucessoREST('Ciência processo realizado com sucesso!');
  1413 + } catch (Exception $e) {
  1414 + return MdWsSeiRest::formataRetornoErroREST($e);
  1415 + }
  1416 + }
  1417 +
  1418 + /**
  1419 + * Metodo que conclui o procedimento/processo
  1420 + * @param EntradaConcluirProcessoAPI $entradaConcluirProcessoAPI
  1421 + * @info ele recebe o número do ProtocoloProcedimentoFormatadoPesquisa da tabela protocolo
  1422 + * @return array
  1423 + */
  1424 + protected function concluirProcessoControlado(EntradaConcluirProcessoAPI $entradaConcluirProcessoAPI)
  1425 + {
  1426 + try {
  1427 + if (!$entradaConcluirProcessoAPI->getProtocoloProcedimento()) {
  1428 + throw new InfraException('E obrigtorio informar o protocolo do procedimento!');
  1429 + }
  1430 +
  1431 + $objSeiRN = new SeiRN();
  1432 + $objSeiRN->concluirProcesso($entradaConcluirProcessoAPI);
  1433 +
  1434 + return MdWsSeiRest::formataRetornoSucessoREST('Processo concluído com sucesso!');
  1435 + } catch (Exception $e) {
  1436 + return MdWsSeiRest::formataRetornoErroREST($e);
  1437 + }
  1438 + }
  1439 +
  1440 + /**
  1441 + * Metodo que reabre o procedimento/processo
  1442 + * @param EntradaReabrirProcessoAPI $entradaReabrirProcessoAPI
  1443 + * @return array
  1444 + */
  1445 + protected function reabrirProcessoControlado(EntradaReabrirProcessoAPI $entradaReabrirProcessoAPI)
  1446 + {
  1447 + try {
  1448 + if (!$entradaReabrirProcessoAPI->getIdProcedimento()) {
  1449 + throw new InfraException('E obrigtorio informar o id do procedimento!');
  1450 + }
  1451 + $objSeiRN = new SeiRN();
  1452 + $objSeiRN->reabrirProcesso($entradaReabrirProcessoAPI);
  1453 +
  1454 + return MdWsSeiRest::formataRetornoSucessoREST('Processo reaberto com sucesso!');
  1455 + } catch (Exception $e) {
  1456 + return MdWsSeiRest::formataRetornoErroREST($e);
  1457 + }
  1458 + }
  1459 +
  1460 + /**
  1461 + * Metodo que atribui o processo a uma pessoa
  1462 + * @param EntradaAtribuirProcessoAPI $entradaAtribuirProcessoAPI
  1463 + * @info Os parametros IdUsuario, ProtocoloProcedimento e SinReabrir sao obrigatorios. O parametro ProtocoloProcedimento
  1464 + * recebe o n?mero do ProtocoloProcedimentoFormatadoPesquisa da tabela protocolo
  1465 + * @return array
  1466 + */
  1467 + protected function atribuirProcessoControlado(EntradaAtribuirProcessoAPI $entradaAtribuirProcessoAPI)
  1468 + {
  1469 + try {
  1470 + if (!$entradaAtribuirProcessoAPI->getProtocoloProcedimento()) {
  1471 + throw new InfraException('E obrigatorio informar o protocolo do processo!');
  1472 + }
  1473 + if (!$entradaAtribuirProcessoAPI->getIdUsuario()) {
  1474 + throw new InfraException('E obrigatorio informar o usu?rio do processo!');
  1475 + }
  1476 +
  1477 + $objSeiRN = new SeiRN();
  1478 + $objSeiRN->atribuirProcesso($entradaAtribuirProcessoAPI);
  1479 +
  1480 + return MdWsSeiRest::formataRetornoSucessoREST('Processo atribuído com sucesso!');
  1481 + } catch (Exception $e) {
  1482 + return MdWsSeiRest::formataRetornoErroREST($e);
  1483 + }
  1484 + }
  1485 +
  1486 + /**
  1487 + * Encapsula o objeto ENtradaEnviarProcessoAPI para o metodo enviarProcesso
  1488 + * @param array $post
  1489 + * @return EntradaEnviarProcessoAPI
  1490 + */
  1491 + public function encapsulaEnviarProcessoEntradaEnviarProcessoAPI(array $post)
  1492 + {
  1493 + $entradaEnviarProcessoAPI = new EntradaEnviarProcessoAPI();
  1494 + if (isset($post['numeroProcesso'])) {
  1495 + $entradaEnviarProcessoAPI->setProtocoloProcedimento($post['numeroProcesso']);
  1496 + }
  1497 + if (isset($post['unidadesDestino'])) {
  1498 + $entradaEnviarProcessoAPI->setUnidadesDestino(explode(',', $post['unidadesDestino']));
  1499 + }
  1500 + if (isset($post['sinManterAbertoUnidade'])) {
  1501 + $entradaEnviarProcessoAPI->setSinManterAbertoUnidade($post['sinManterAbertoUnidade']);
  1502 + }
  1503 + if (isset($post['sinRemoverAnotacao'])) {
  1504 + $entradaEnviarProcessoAPI->setSinRemoverAnotacao($post['sinRemoverAnotacao']);
  1505 + }
  1506 + if (isset($post['sinEnviarEmailNotificacao'])) {
  1507 + $entradaEnviarProcessoAPI->setSinEnviarEmailNotificacao($post['sinEnviarEmailNotificacao']);
  1508 + } else {
  1509 + $entradaEnviarProcessoAPI->setSinEnviarEmailNotificacao('N');
  1510 + }
  1511 + if (isset($post['dataRetornoProgramado'])) {
  1512 + $entradaEnviarProcessoAPI->setDataRetornoProgramado($post['dataRetornoProgramado']);
  1513 + }
  1514 + if (isset($post['diasRetornoProgramado'])) {
  1515 + $entradaEnviarProcessoAPI->setDiasRetornoProgramado($post['diasRetornoProgramado']);
  1516 + }
  1517 + if (isset($post['sinDiasUteisRetornoProgramado'])) {
  1518 + $entradaEnviarProcessoAPI->setSinDiasUteisRetornoProgramado($post['sinDiasUteisRetornoProgramado']);
  1519 + }
  1520 + if (isset($post['sinReabrir'])) {
  1521 + $entradaEnviarProcessoAPI->setSinReabrir($post['sinReabrir']);
  1522 + }
  1523 +
  1524 + return $entradaEnviarProcessoAPI;
  1525 + }
  1526 +
  1527 + /**
  1528 + * Metodo que envia o processo para outra unidade
  1529 + * @param EntradaEnviarProcessoAPI $entradaEnviarProcessoAPI
  1530 + * @info Metodo auxiliar para encapsular dados encapsulaEnviarProcessoEntradaEnviarProcessoAPI
  1531 + * @return array
  1532 + */
  1533 + protected function enviarProcessoControlado(EntradaEnviarProcessoAPI $entradaEnviarProcessoAPI)
  1534 + {
  1535 + try {
  1536 + $objSeiRN = new SeiRN();
  1537 + $objSeiRN->enviarProcesso($entradaEnviarProcessoAPI);
  1538 +
  1539 + return MdWsSeiRest::formataRetornoSucessoREST('Processo enviado com sucesso!');
  1540 + } catch (Exception $e) {
  1541 + return MdWsSeiRest::formataRetornoErroREST($e);
  1542 + }
  1543 + }
  1544 +
  1545 + /**
  1546 + * Método que verifica o acesso a um processo ou documento
  1547 + * @param ProtocoloDTO $protocoloDTOParam
  1548 + * - Se acesso liberado e chamar autenticação for false, o usuário não pode de jeito nenhum visualizar o processo/documento
  1549 + * @return array
  1550 + */
  1551 + protected function verificaAcessoConectado(ProtocoloDTO $protocoloDTOParam)
  1552 + {
  1553 + try {
  1554 + $acessoLiberado = false;
  1555 + $chamarAutenticacao = false;
  1556 + $protocoloRN = new ProtocoloRN();
  1557 + $protocoloDTO = new ProtocoloDTO();
  1558 + $protocoloDTO->setDblIdProtocolo($protocoloDTOParam->getDblIdProtocolo());
  1559 + $protocoloDTO->retStrStaNivelAcessoGlobal();
  1560 + $protocoloDTO->retDblIdProtocolo();
  1561 + $protocoloDTO = $protocoloRN->consultarRN0186($protocoloDTO);
  1562 + if (!$protocoloDTO) {
  1563 + throw new Exception('Processo não encontrado!');
  1564 + }
  1565 + if ($protocoloDTO->getStrStaNivelAcessoGlobal() == ProtocoloRN::$NA_SIGILOSO) {
  1566 + $objPesquisaProtocoloDTO = new PesquisaProtocoloDTO();
  1567 + $objPesquisaProtocoloDTO->setStrStaTipo(ProtocoloRN::$TPP_PROCEDIMENTOS);
  1568 + $objPesquisaProtocoloDTO->setStrStaAcesso(ProtocoloRN::$TAP_AUTORIZADO);
  1569 + $objPesquisaProtocoloDTO->setDblIdProtocolo($protocoloDTO->getDblIdProtocolo());
  1570 +
  1571 + $objProtocoloRN = new ProtocoloRN();
  1572 + $arrProtocoloDTO = $objProtocoloRN->pesquisarRN0967($objPesquisaProtocoloDTO);
  1573 + if ($arrProtocoloDTO) {
  1574 + $chamarAutenticacao = true;
  1575 + }
  1576 + } else {
  1577 + $acessoLiberado = true;
  1578 + $chamarAutenticacao = false;
  1579 + }
  1580 +
  1581 + return MdWsSeiRest::formataRetornoSucessoREST(
  1582 + null,
  1583 + array('acessoLiberado' => $acessoLiberado, 'chamarAutenticacao' => $chamarAutenticacao)
  1584 + );
  1585 +
  1586 + } catch (Exception $e) {
  1587 + return MdWsSeiRest::formataRetornoErroREST($e);
  1588 + }
  1589 + }
  1590 +
  1591 + /**
  1592 + * Identifica o acesso do usuário em um processo
  1593 + * @param UsuarioDTO $usuarioDTO
  1594 + * @param ProtocoloDTO $protocoloDTO
  1595 + * @return array
  1596 + */
  1597 + public function apiIdentificacaoAcesso(UsuarioDTO $usuarioDTO, ProtocoloDTO $protocoloDTO)
  1598 + {
  1599 + try {
  1600 + $objInfraSip = new InfraSip(SessaoSEI::getInstance());
  1601 + $objInfraSip->autenticar(SessaoSEI::getInstance()->getNumIdOrgaoUsuario(), null, SessaoSEI::getInstance()->getStrSiglaUsuario(), $usuarioDTO->getStrSenha());
  1602 + AuditoriaSEI::getInstance()->auditar('usuario_validar_acesso');
  1603 + $ret = $this->verificaAcesso($protocoloDTO);
  1604 + if (!$ret['sucesso']) {
  1605 + return $ret;
  1606 + }
  1607 + $acessoAutorizado = false;
  1608 + if ($ret['data']['acessoLiberado'] || $ret['data']['chamarAutenticacao']) {
  1609 + $acessoAutorizado = true;
  1610 + }
  1611 +
  1612 + return MdWsSeiRest::formataRetornoSucessoREST(null, array('acessoAutorizado' => $acessoAutorizado));
  1613 + } catch (InfraException $e) {
  1614 + $infraValidacaoDTO = $e->getArrObjInfraValidacao()[0];
  1615 + $eAuth = new Exception($infraValidacaoDTO->getStrDescricao(), $e->getCode(), $e);
  1616 + return MdWsSeiRest::formataRetornoErroREST($eAuth);
  1617 + } catch (Exception $e) {
  1618 + return MdWsSeiRest::formataRetornoErroREST($e);
  1619 + }
  1620 + }
  1621 +
  1622 + /**
  1623 + * Método que consulta os processos no Solar
  1624 + * @param MdWsSeiPesquisaProtocoloSolrDTO $pesquisaProtocoloSolrDTO
  1625 + * @return array
  1626 + */
  1627 + protected function pesquisarProcessosSolarConectado(MdWsSeiPesquisaProtocoloSolrDTO $pesquisaProtocoloSolrDTO)
  1628 + {
  1629 + try {
  1630 + $partialfields = '';
  1631 +
  1632 + if ($pesquisaProtocoloSolrDTO->isSetStrDescricao() && $pesquisaProtocoloSolrDTO->getStrDescricao() != null) {
  1633 + if ($partialfields != '') {
  1634 + $partialfields .= ' AND ';
  1635 + }
  1636 + $partialfields .= '(' . SolrUtil::formatarOperadores($pesquisaProtocoloSolrDTO->getStrDescricao(), 'desc') . ')';
  1637 + }
  1638 +
  1639 + if ($pesquisaProtocoloSolrDTO->isSetStrObservacao() && $pesquisaProtocoloSolrDTO->getStrObservacao() != null) {
  1640 + if ($partialfields != '') {
  1641 + $partialfields .= ' AND ';
  1642 + }
  1643 + $partialfields .= '(' . SolrUtil::formatarOperadores($pesquisaProtocoloSolrDTO->getStrObservacao(), 'obs_' . SessaoSEI::getInstance()->getNumIdUnidadeAtual()) . ')';
  1644 + }
  1645 +
  1646 + //o- verificar lógica do solar
  1647 + if ($pesquisaProtocoloSolrDTO->isSetDblIdProcedimento() && $pesquisaProtocoloSolrDTO->getDblIdProcedimento() != null) {
  1648 + if ($partialfields != '') {
  1649 + $partialfields .= ' AND ';
  1650 + }
  1651 +
  1652 + $objRelProtocoloProtocoloDTO = new RelProtocoloProtocoloDTO();
  1653 + $objRelProtocoloProtocoloDTO->retDblIdProtocolo2();
  1654 + $objRelProtocoloProtocoloDTO->setStrStaAssociacao(RelProtocoloProtocoloRN::$TA_PROCEDIMENTO_ANEXADO);
  1655 + $objRelProtocoloProtocoloDTO->setDblIdProtocolo1($pesquisaProtocoloSolrDTO->getDblIdProcedimento());
  1656 +
  1657 + $objRelProtocoloProtocoloRN = new RelProtocoloProtocoloRN();
  1658 + $arrIdProcessosAnexados = InfraArray::converterArrInfraDTO($objRelProtocoloProtocoloRN->listarRN0187($objRelProtocoloProtocoloDTO), 'IdProtocolo2');
  1659 +
  1660 + if (count($arrIdProcessosAnexados) == 0) {
  1661 + $partialfields .= '(id_proc:' . $pesquisaProtocoloSolrDTO->getDblIdProcedimento() . ')';
  1662 + } else {
  1663 +
  1664 + $strProcessos = 'id_proc:' . $pesquisaProtocoloSolrDTO->getDblIdProcedimento();
  1665 + foreach ($arrIdProcessosAnexados as $dblIdProcessoAnexado) {
  1666 + $strProcessos .= ' OR id_proc:' . $dblIdProcessoAnexado;
  1667 + }
  1668 +
  1669 + $partialfields .= '(' . $strProcessos . ')';
  1670 + }
  1671 + }
  1672 +
  1673 + if ($pesquisaProtocoloSolrDTO->isSetStrProtocoloPesquisa() && $pesquisaProtocoloSolrDTO->getStrProtocoloPesquisa() != null) {
  1674 + if ($partialfields != '') {
  1675 + $partialfields .= ' AND ';
  1676 + }
  1677 + $partialfields .= '(prot_pesq:*' . InfraUtil::retirarFormatacao($pesquisaProtocoloSolrDTO->getStrProtocoloPesquisa(), false) . '*)';
  1678 + }
  1679 +
  1680 + if ($pesquisaProtocoloSolrDTO->isSetNumIdTipoProcedimento() && $pesquisaProtocoloSolrDTO->getNumIdTipoProcedimento() != null) {
  1681 + if ($partialfields != '') {
  1682 + $partialfields .= ' AND ';
  1683 + }
  1684 + $partialfields .= '(id_tipo_proc:' . $pesquisaProtocoloSolrDTO->getNumIdTipoProcedimento() . ')';
  1685 + }
  1686 +
  1687 + if ($pesquisaProtocoloSolrDTO->isSetNumIdSerie() && $pesquisaProtocoloSolrDTO->getNumIdSerie() != null) {
  1688 + if ($partialfields != '') {
  1689 + $partialfields .= ' AND ';
  1690 + }
  1691 + $partialfields .= '(id_serie:' . $pesquisaProtocoloSolrDTO->getNumIdSerie() . ')';
  1692 + }
  1693 +
  1694 + if ($pesquisaProtocoloSolrDTO->isSetStrNumero() && $pesquisaProtocoloSolrDTO->getStrNumero() != null) {
  1695 + if ($partialfields != '') {
  1696 + $partialfields .= ' AND ';
  1697 + }
  1698 + $partialfields .= '(numero:*' . $pesquisaProtocoloSolrDTO->getStrNumero() . '*)';
  1699 + }
  1700 +
  1701 + $dtaInicio = null;
  1702 + $dtaFim = null;
  1703 + if($pesquisaProtocoloSolrDTO->isSetStrStaTipoData()){
  1704 + if ($pesquisaProtocoloSolrDTO->getStrStaTipoData() == '0') {
  1705 + $dtaInicio = $pesquisaProtocoloSolrDTO->getDtaInicio();
  1706 + $dtaFim = $pesquisaProtocoloSolrDTO->getDtaFim();
  1707 + } else if ($pesquisaProtocoloSolrDTO->getStrStaTipoData() == '30') {
  1708 + $dtaInicio = InfraData::calcularData(30, InfraData::$UNIDADE_DIAS, InfraData::$SENTIDO_ATRAS);
  1709 + $dtaFim = InfraData::getStrDataAtual();
  1710 + } else if ($pesquisaProtocoloSolrDTO->getStrStaTipoData() == '60') {
  1711 + $dtaInicio = InfraData::calcularData(60, InfraData::$UNIDADE_DIAS, InfraData::$SENTIDO_ATRAS);
  1712 + $dtaFim = InfraData::getStrDataAtual();
  1713 + }
  1714 + }
  1715 +
  1716 + if ($dtaInicio != null && $dtaFim != null) {
  1717 + $dia1 = substr($dtaInicio, 0, 2);
  1718 + $mes1 = substr($dtaInicio, 3, 2);
  1719 + $ano1 = substr($dtaInicio, 6, 4);
  1720 +
  1721 + $dia2 = substr($dtaFim, 0, 2);
  1722 + $mes2 = substr($dtaFim, 3, 2);
  1723 + $ano2 = substr($dtaFim, 6, 4);
  1724 +
  1725 + if ($partialfields != '') {
  1726 + $partialfields .= ' AND ';
  1727 + }
  1728 +
  1729 + $partialfields .= 'dta_ger:[' . $ano1 . '-' . $mes1 . '-' . $dia1 . 'T00:00:00Z TO ' . $ano2 . '-' . $mes2 . '-' . $dia2 . 'T00:00:00Z]';
  1730 + }
  1731 +
  1732 + $objUnidadeDTO = new UnidadeDTO();
  1733 + $objUnidadeDTO->setBolExclusaoLogica(false);
  1734 + $objUnidadeDTO->retStrSinProtocolo();
  1735 + $objUnidadeDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual());
  1736 +
  1737 + $objUnidadeRN = new UnidadeRN();
  1738 + $objUnidadeDTOAtual = $objUnidadeRN->consultarRN0125($objUnidadeDTO);
  1739 +
  1740 + if ($objUnidadeDTOAtual->getStrSinProtocolo() == 'N') {
  1741 +
  1742 + if ($partialfields != '') {
  1743 + $partialfields .= ' AND ';
  1744 + }
  1745 +
  1746 + $partialfields .= '(tipo_aces:P OR id_uni_aces:*;' . SessaoSEI::getInstance()->getNumIdUnidadeAtual() . ';*)';
  1747 + }
  1748 +
  1749 + if($pesquisaProtocoloSolrDTO->isSetNumIdGrupoAcompanhamentoProcedimento() && $pesquisaProtocoloSolrDTO->getNumIdGrupoAcompanhamentoProcedimento()) {
  1750 + $protocoloRN = new ProtocoloRN();
  1751 + $mdWsSeiProtocoloDTO = new MdWsSeiProtocoloDTO();
  1752 + $mdWsSeiProtocoloDTO->setNumIdGrupoAcompanhamentoProcedimento($pesquisaProtocoloSolrDTO->getNumIdGrupoAcompanhamentoProcedimento());
  1753 + $mdWsSeiProtocoloDTO->retDblIdProtocolo();
  1754 +
  1755 + $ret = $protocoloRN->listarRN0668($mdWsSeiProtocoloDTO);
  1756 + if(!$ret){
  1757 + return MdWsSeiRest::formataRetornoSucessoREST(null, array(), 0);
  1758 + }
  1759 + if ($partialfields != '') {
  1760 + $partialfields .= ' AND ';
  1761 + }
  1762 + $arrIdProcessosAcompanhamento = array();
  1763 + /** @var ProtocoloDTO $protocoloDTO */
  1764 + foreach($ret as $protocoloDTO){
  1765 + $arrIdProcessosAcompanhamento[] = 'id_proc:' . $protocoloDTO->getDblIdProtocolo();
  1766 + }
  1767 + $partialfields .= '(' . implode(' OR ', $arrIdProcessosAcompanhamento) . ')';
  1768 + }
  1769 +
  1770 + $parametros = new stdClass();
  1771 + if($pesquisaProtocoloSolrDTO->isSetStrPalavrasChave()){
  1772 + $parametros->q = SolrUtil::formatarOperadores($pesquisaProtocoloSolrDTO->getStrPalavrasChave());
  1773 + }
  1774 +
  1775 + if ($parametros->q != '' && $partialfields != '') {
  1776 + $parametros->q = '(' . $parametros->q . ') AND ' . $partialfields;
  1777 + } else if ($partialfields != '') {
  1778 + $parametros->q = $partialfields;
  1779 + }
  1780 +
  1781 + $parametros->q = utf8_encode($parametros->q);
  1782 + $start = 0;
  1783 + $limit = 100;
  1784 + if($pesquisaProtocoloSolrDTO->getNumPaginaAtual()){
  1785 + $start = $pesquisaProtocoloSolrDTO->getNumPaginaAtual();
  1786 + }
  1787 + if($pesquisaProtocoloSolrDTO->getNumMaxRegistrosRetorno()){
  1788 + $limit = $pesquisaProtocoloSolrDTO->getNumMaxRegistrosRetorno();
  1789 + }
  1790 + $parametros->start = $start;
  1791 + $parametros->rows = $limit;
  1792 + $parametros->sort = 'dta_ger desc, id_prot desc';
  1793 +
  1794 + $urlBusca = ConfiguracaoSEI::getInstance()->getValor('Solr', 'Servidor') . '/' . ConfiguracaoSEI::getInstance()->getValor('Solr', 'CoreProtocolos') . '/select?' . http_build_query($parametros) . '&hl=true&hl.snippets=2&hl.fl=content&hl.fragsize=100&hl.maxAnalyzedChars=1048576&hl.alternateField=content&hl.maxAlternateFieldLength=100&fl=id,id_proc,id_doc,id_tipo_proc,id_serie,id_anexo,id_uni_ger,prot_doc,prot_proc,numero,id_usu_ger,dta_ger';
  1795 +
  1796 + try {
  1797 + $resultados = file_get_contents($urlBusca, false);
  1798 + } catch (Exception $e) {
  1799 + throw new InfraException('Erro realizando pesquisa no Solar.', $e, urldecode($urlBusca), false);
  1800 + }
  1801 +
  1802 + if ($resultados == '') {
  1803 + throw new InfraException('Nenhum retorno encontrado no resultado da pesquisa do Solar, verificar indexação.');
  1804 + }
  1805 +
  1806 + $xml = simplexml_load_string($resultados);
  1807 + $arrRet = $xml->xpath('/response/result/@numFound');
  1808 + $total = array_shift($arrRet)->__toString();
  1809 + $arrIdProcessos = array();
  1810 + $registros = $xml->xpath('/response/result/doc');
  1811 + $numRegistros = sizeof($registros);
  1812 +
  1813 + $result = array();
  1814 + for ($i = 0; $i < $numRegistros; $i++) {
  1815 + $arrIdProcessos[] = SolrUtil::obterTag($registros[$i], 'id_proc', 'long');
  1816 + }
  1817 +
  1818 + if($arrIdProcessos){
  1819 + $protocoloRN = new ProtocoloRN();
  1820 + $protocoloDTO = new MdWsSeiProtocoloDTO();
  1821 + $protocoloDTO->setDblIdProtocolo($arrIdProcessos, InfraDTO::$OPER_IN);
  1822 + $protocoloDTO->retDblIdProtocolo();
  1823 + $protocoloDTO->retNumIdUnidadeGeradora();
  1824 + $protocoloDTO->retStrStaProtocolo();
  1825 + $protocoloDTO->retStrProtocoloFormatado();
  1826 + $protocoloDTO->retStrNomeTipoProcedimentoProcedimento();
  1827 + $protocoloDTO->retStrDescricao();
  1828 + $protocoloDTO->retStrSiglaUnidadeGeradora();
  1829 + $protocoloDTO->retStrStaGrauSigilo();
  1830 + $protocoloDTO->retStrStaNivelAcessoLocal();
  1831 + $protocoloDTO->retStrStaNivelAcessoGlobal();
  1832 + $protocoloDTO->retStrSinCienciaProcedimento();
  1833 + $protocoloDTO->retStrStaEstado();
  1834 + $arrProtocoloDTO = $protocoloRN->listarRN0668($protocoloDTO);
  1835 + $result = $this->montaRetornoListagemProcessos($arrProtocoloDTO, null);
  1836 + }
  1837 +
  1838 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result, $total);
  1839 + } catch (Exception $e) {
  1840 + return MdWsSeiRest::formataRetornoErroREST($e);
  1841 + }
  1842 + }
  1843 +
  1844 +
  1845 +}
0 1846 \ No newline at end of file
... ...
rn/MdWsSeiProcessoRN.php 0 → 100644
... ... @@ -0,0 +1,73 @@
  1 +<?
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiProcessoRN extends InfraRN {
  5 +
  6 + protected function inicializarObjInfraIBanco(){
  7 + return BancoSEI::getInstance();
  8 + }
  9 +
  10 + /**
  11 + * Metodo que traduz o template pelo id da atividade e a string do template
  12 + * @param MdWsSeiProcessoDTO $mdWsSeiProcessoDTO
  13 + * @return string
  14 + */
  15 + protected function traduzirTemplateConectado(MdWsSeiProcessoDTO $mdWsSeiProcessoDTO){
  16 + $strTemplate = $mdWsSeiProcessoDTO->getStrTemplate();
  17 + if ($strTemplate) {
  18 + $atributoAndamentoRN = new AtributoAndamentoRN();
  19 + $atributoAndamentoDTOConsulta = new AtributoAndamentoDTO();
  20 + $atributoAndamentoDTOConsulta->retTodos();
  21 + $atributoAndamentoDTOConsulta->setNumIdAtividade($mdWsSeiProcessoDTO->getNumIdAtividade());
  22 + $ret = $atributoAndamentoRN->listarRN1367($atributoAndamentoDTOConsulta);
  23 + $atividadeDTO = new AtividadeDTO();
  24 + $atividadeDTO->setNumIdAtividade($mdWsSeiProcessoDTO->getNumIdAtividade());
  25 + $atividadeDTO->retDblIdProtocolo();
  26 + $atividadeDTO->retStrNomeTarefa();
  27 + $atividadeRN = new AtividadeRN();
  28 + $atividadeDTO = $atividadeRN->consultarRN0033($atividadeDTO);
  29 + $protocoloDTO = new ProtocoloDTO();
  30 + $protocoloDTO->retStrStaGrauSigilo();
  31 + $protocoloDTO->setDblIdProtocolo($atividadeDTO->getDblIdProtocolo());
  32 + $protocoloRN = new ProtocoloRN();
  33 + $protocoloDTO = $protocoloRN->consultarRN0186($protocoloDTO);
  34 +
  35 + if ($ret) {
  36 + /** @var AtributoAndamentoDTO $atributoAndamentoDTO */
  37 + foreach($ret as $atributoAndamentoDTO) {
  38 + $valor = $atributoAndamentoDTO->getStrValor();
  39 +
  40 +
  41 + if (strripos($valor, '¥')) {
  42 + $valor = str_replace('¥', ' - ', $atributoAndamentoDTO->getStrValor());
  43 + }
  44 +
  45 + $strTemplate = str_replace('@' . $atributoAndamentoDTO->getStrNome() . '@', $valor, $strTemplate);
  46 +
  47 + $sigilo = ($protocoloDTO->getStrStaGrauSigilo())? 'sigiloso': 'nao sigiloso';
  48 +
  49 + $strTemplate = str_replace('@GRAU_SIGILO@', $sigilo, $strTemplate);
  50 + $strTemplate = str_replace('@HIPOTESE_LEGAL@', '', $strTemplate);
  51 + }
  52 + }
  53 + //O Core do SEI faz esta limpeza...
  54 + $strTemplate = str_replace(
  55 + array(
  56 + '@NIVEL_ACESSO@',
  57 + '@GRAU_SIGILO@',
  58 + '@TIPO_CONFERENCIA@',
  59 + '@DATA_AUTUACAO@',
  60 + '@HIPOTESE_LEGAL@',
  61 + '@VISUALIZACAO@'
  62 + ),
  63 + '',
  64 + $strTemplate
  65 + );
  66 +
  67 + $strTemplate = str_replace('¥', ' - ', $strTemplate);
  68 + }
  69 +
  70 + return $strTemplate;
  71 + }
  72 +
  73 +}
0 74 \ No newline at end of file
... ...
rn/MdWsSeiRetornoProgramadoRN.php 0 → 100644
... ... @@ -0,0 +1,51 @@
  1 +<?
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiRetornoProgramadoRN extends InfraRN {
  5 +
  6 + protected function inicializarObjInfraIBanco(){
  7 + return BancoSEI::getInstance();
  8 + }
  9 +
  10 + public function encapsulaRetornoProgramado(array $post){
  11 + $retornoProgramadoDTO = new RetornoProgramadoDTO();
  12 + $retornoProgramadoDTO->setNumIdRetornoProgramado(null);
  13 + $retornoProgramadoDTO->setDthAlteracao(null);
  14 + if (isset($post['usuario'])) {
  15 + $retornoProgramadoDTO->setNumIdUsuario($post['usuario']);
  16 + }else{
  17 + $retornoProgramadoDTO->setNumIdUsuario(SessaoSEI::getInstance()->getNumIdUsuario());
  18 + }
  19 +
  20 + if (isset($post['atividadeEnvio'])) {
  21 + $retornoProgramadoDTO->setNumIdAtividadeEnvio($post['atividadeEnvio']);
  22 + }
  23 +
  24 + if (isset($post['unidade'])) {
  25 + $retornoProgramadoDTO->setNumIdUnidade($post['unidade']);
  26 + }
  27 +
  28 + if (isset($post['dtProgramada'])) {
  29 + $retornoProgramadoDTO->setDtaProgramada($post['dtProgramada']);
  30 + }
  31 +
  32 + return $retornoProgramadoDTO;
  33 + }
  34 +
  35 + /**
  36 + * Metodo que agenda um retorno programado
  37 + * @param RetornoProgramadoDTO $retornoProgramadoDTO
  38 + * @info metodo auxiliar encapsulaRetornoProgramado para facilitar encapsulamento
  39 + * @return array
  40 + */
  41 + protected function agendarRetornoProgramadoControlado(RetornoProgramadoDTO $retornoProgramadoDTO){
  42 + try{
  43 + $retornoProgramadoRN = new RetornoProgramadoRN();
  44 + $retornoProgramadoRN->cadastrar($retornoProgramadoDTO);
  45 +
  46 + return MdWsSeiRest::formataRetornoSucessoREST('Retorno Programado agendado com sucesso!');
  47 + }catch (Exception $e){
  48 + return MdWsSeiRest::formataRetornoErroREST($e);
  49 + }
  50 + }
  51 +}
0 52 \ No newline at end of file
... ...
rn/MdWsSeiUnidadeRN.php 0 → 100644
... ... @@ -0,0 +1,60 @@
  1 +<?
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +class MdWsSeiUnidadeRN extends InfraRN {
  5 +
  6 + protected function inicializarObjInfraIBanco(){
  7 + return BancoSEI::getInstance();
  8 + }
  9 +
  10 + /**
  11 + * Pesquisa as unidades pela sigla
  12 + */
  13 + protected function pesquisarUnidadeConectado(UnidadeDTO $unidadeDTOParam){
  14 + try{
  15 + $unidadeRN = new UnidadeRN();
  16 + $unidadeDTO = new UnidadeDTO();
  17 + if($unidadeDTOParam->getNumMaxRegistrosRetorno()){
  18 + $unidadeDTO->setNumMaxRegistrosRetorno($unidadeDTOParam->getNumMaxRegistrosRetorno());
  19 + }else{
  20 + $unidadeDTO->setNumMaxRegistrosRetorno(10);
  21 + }
  22 + if(!is_null($unidadeDTOParam->getNumPaginaAtual())){
  23 + $unidadeDTO->setNumPaginaAtual($unidadeDTOParam->getNumPaginaAtual());
  24 + }else{
  25 + $unidadeDTO->setNumPaginaAtual(0);
  26 + }
  27 + if($unidadeDTOParam->isSetStrSigla()){
  28 + $filter = '%'.$unidadeDTOParam->getStrSigla().'%';
  29 +
  30 + $unidadeDTO->adicionarCriterio(
  31 + array('Sigla', 'Descricao'),
  32 + array(InfraDTO::$OPER_LIKE, InfraDTO::$OPER_LIKE),
  33 + array($filter, $filter),
  34 + InfraDTO::$OPER_LOGICO_OR
  35 + );
  36 + }
  37 + $unidadeDTO->setStrSinAtivo('S');
  38 + $unidadeDTO->setStrSinEnvioProcesso('S');
  39 + $unidadeDTO->retNumIdUnidade();
  40 + $unidadeDTO->retStrSigla();
  41 + $unidadeDTO->retStrDescricao();
  42 + $unidadeDTO->setOrdStrSigla(InfraDTO::$TIPO_ORDENACAO_ASC);
  43 + $ret = $unidadeRN->listarRN0127($unidadeDTO);
  44 + $result = array();
  45 + /** @var UnidadeDTO $unDTO */
  46 + foreach($ret as $unDTO){
  47 + $result[] = array(
  48 + 'id' => $unDTO->getNumIdUnidade(),
  49 + 'sigla' => $unDTO->getStrSigla(),
  50 + 'descricao' => $unDTO->getStrDescricao()
  51 + );
  52 + }
  53 +
  54 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result, $unidadeDTO->getNumTotalRegistros());
  55 + }catch (Exception $e){
  56 + return MdWsSeiRest::formataRetornoErroREST($e);
  57 + }
  58 + }
  59 +
  60 +}
0 61 \ No newline at end of file
... ...
rn/MdWsSeiUsuarioRN.php 0 → 100644
... ... @@ -0,0 +1,378 @@
  1 +<?php
  2 +require_once dirname(__FILE__).'/../../../SEI.php';
  3 +
  4 +
  5 +class MdWsSeiUsuarioRN extends InfraRN {
  6 +
  7 + CONST TOKEN_SECRET = '<!RWR1YXJkbyBSb23Do28!>';
  8 +
  9 + protected function inicializarObjInfraIBanco(){
  10 + return BancoSEI::getInstance();
  11 + }
  12 +
  13 + /**
  14 + * Metodo que retorna o servico SOAP do SIP
  15 + * @return SoapClient
  16 + * @throws InfraException
  17 + */
  18 + private function retornaServicoSip(){
  19 + $strWSDL = ConfiguracaoSEI::getInstance()->getValor('SessaoSEI', 'SipWsdl');
  20 + try{
  21 + if (!InfraUtil::isBolUrlValida($strWSDL)){
  22 + if(!@file_get_contents($strWSDL)) {
  23 + throw new InfraException('Arquivo WSDL '.$strWSDL.' nao encontrado.');
  24 + }
  25 + }
  26 + }catch(Exception $e){
  27 + throw new InfraException('Falha na conexção com o Sistema de Permissões.',$e);
  28 + }
  29 +
  30 + try{
  31 + $objSipWS = new SoapClient(
  32 + $strWSDL,
  33 + array(
  34 + 'encoding' => 'ISO-8859-1',
  35 + 'exceptions' => true
  36 + )
  37 + );
  38 + return $objSipWS;
  39 + }catch(Exception $e){
  40 + throw new InfraException('Erro acessando o Sistema de Permissões.');
  41 + }
  42 + }
  43 +
  44 + /**
  45 + * M?todo que descriptografa o token
  46 + * @param $token
  47 + * @return string
  48 + */
  49 + public function tokenDecode($token){
  50 + $fase1 = base64_decode($token);
  51 + $fase2 = str_replace($this->getSecret(), '', $fase1);
  52 + $fase3 = base64_decode($fase2);
  53 + $tokenData = explode('||', $fase3);
  54 + if(count($tokenData) != 4){
  55 + return null;
  56 + }
  57 + $tokenData[0] = $this->decriptaSenha($tokenData[0]);
  58 + $tokenData[1] = $this->decriptaSenha($tokenData[1]);
  59 +
  60 + return $tokenData;
  61 + }
  62 +
  63 + /**
  64 + * Método que criptografa o token
  65 + * @param $sigla
  66 + * @param $senha
  67 + * @param null $orgao
  68 + * @param null $contexto
  69 + * @return string
  70 + */
  71 + public function tokenEncode($sigla, $senha, $orgao = null, $contexto = null){
  72 + $token = base64_encode(
  73 + $this->getSecret()
  74 + .base64_encode(
  75 + $this->encriptaSenha($sigla)
  76 + .'||'.$this->encriptaSenha($senha)
  77 + .'||'.$orgao
  78 + .'||'.$contexto
  79 + )
  80 + );
  81 +
  82 + return $token;
  83 + }
  84 +
  85 + /**
  86 + * Retorna a chave da criptografia
  87 + * @return string
  88 + */
  89 + private function getSecret(){
  90 + $data = new DateTime();
  91 + $strData = $data->format('Ymd');
  92 + $secret = sha1(self::TOKEN_SECRET.$strData);
  93 + return $secret;
  94 + }
  95 +
  96 + /**
  97 + * Go horse para autenticar usuario... Nao ha como instanciar o SessaoSEI por metodos convencionais.
  98 + * @param stdClass $loginData
  99 + */
  100 + private function setaVariaveisAutenticacao(array $loginData){
  101 + $_GET['id_login'] = $loginData['IdLogin'];
  102 + $_GET['id_sistema'] = $loginData['IdSistema'];
  103 + $_GET['id_usuario'] = $loginData['IdUsuario'];
  104 + $_GET['hash_agente'] = SessaoSEI::gerarHashAgente();
  105 + $_GET['infra_sip'] = true;
  106 + $_GET['id_contexto'] = $loginData['IdContexto'];;
  107 + }
  108 +
  109 + /**
  110 + * Metodo que autentica o usuario pelo token
  111 + * @param $token
  112 + * @return bool
  113 + * @throws InfraException
  114 + */
  115 + public function autenticarToken($token){
  116 + try{
  117 +
  118 + $tokenData = $this->tokenDecode($token);
  119 + if(!$tokenData){
  120 + throw new InfraException('Token inválido!');
  121 + }
  122 + $usuarioDTO = new UsuarioDTO();
  123 + $usuarioDTO->setStrSigla($tokenData[0]);
  124 + $usuarioDTO->setStrSenha($tokenData[1]);
  125 + $orgaoDTO = new OrgaoDTO();
  126 + $orgaoDTO->setNumIdOrgao($tokenData[2]);
  127 + $contextoDTO = new ContextoDTO();
  128 + $contextoDTO->setNumIdContexto($tokenData[3]);
  129 + $result = $this->apiAutenticar($usuarioDTO, $contextoDTO, $orgaoDTO);
  130 + if(!$result['sucesso']){
  131 + return $result;
  132 + }
  133 + $this->setaVariaveisAutenticacao($result['data']['loginData']);
  134 +
  135 + return $result;
  136 + }catch (Exception $e){
  137 + return MdWsSeiRest::formataRetornoErroREST($e);
  138 + }
  139 + }
  140 +
  141 + /**
  142 + * Metodo de autenticacao de usuarios usando SIP
  143 + * @param UsuarioDTO $usuarioDTO
  144 + * @param ContextoDTO $contextoDTO
  145 + * @param OrgaoDTO $orgaoDTO
  146 + * @return array
  147 + */
  148 + public function apiAutenticar(UsuarioDTO $usuarioDTO, ContextoDTO $contextoDTO, OrgaoDTO $orgaoDTO){
  149 + try{
  150 + $contexto = $contextoDTO->getNumIdContexto();
  151 + $orgao = $orgaoDTO->getNumIdOrgao();
  152 + $siglaOrgao = ConfiguracaoSEI::getInstance()->getValor('SessaoSEI', 'SiglaOrgaoSistema');
  153 +
  154 + $orgaoRN = new OrgaoRN();
  155 +
  156 + if(is_null($orgao)){
  157 + $objOrgaoDTO = new OrgaoDTO();
  158 + $objOrgaoDTO->setBolExclusaoLogica(false);
  159 + $objOrgaoDTO->retNumIdOrgao();
  160 + $objOrgaoDTO->retStrSigla();
  161 + $objOrgaoDTO->setStrSigla($siglaOrgao);
  162 + /**
  163 + * @var $orgaoCarregdo OrgaoDTO
  164 + * Orgao da sessao do sistema
  165 + */
  166 + $orgaoCarregdo = $orgaoRN->consultarRN1352($objOrgaoDTO);
  167 + $orgao = $orgaoCarregdo->getNumIdOrgao();
  168 + }
  169 +
  170 + $objSipWs = $this->retornaServicoSip();
  171 + $ret = $objSipWs->autenticarCompleto(
  172 + $orgao,
  173 + $contexto,
  174 + $usuarioDTO->getStrSigla(),
  175 + $this->encriptaSenha($usuarioDTO->getStrSenha()),
  176 + ConfiguracaoSEI::getInstance()->getValor('SessaoSEI', 'SiglaSistema'),
  177 + $siglaOrgao
  178 + );
  179 +
  180 + if(!$ret){
  181 + throw new InfraException('Usuário ou senha inválido!');
  182 + }
  183 + $this->setaVariaveisAutenticacao(get_object_vars($ret));
  184 +
  185 + //dados usuário
  186 + $ret->IdUnidadeAtual = SessaoSEI::getInstance()->getNumIdUnidadeAtual();
  187 + $ret->sigla = $usuarioDTO->getStrSigla();
  188 + $ret->nome = SessaoSEI::getInstance()->getStrNomeUsuario();
  189 +
  190 + $token = $this->tokenEncode($usuarioDTO->getStrSigla(), $usuarioDTO->getStrSenha(), $orgao, $contexto);
  191 +
  192 + $arrUnidades = array();
  193 + foreach(SessaoSEI::getInstance()->getArrUnidades() as $unidade){
  194 + $arrUnidades[] = array(
  195 + 'id' => $unidade[0],
  196 + 'sigla' => $unidade[1],
  197 + 'descricao' => $unidade[2]
  198 + );
  199 + }
  200 +
  201 + $arrPerfis = array();
  202 + $retPerfis = $this->listarPerfisUsuario($ret->IdSistema, $ret->IdUsuario);
  203 + if($retPerfis && $retPerfis['data']){
  204 + $arrPerfis = $retPerfis['data'];
  205 + }
  206 +
  207 + return MdWsSeiRest::formataRetornoSucessoREST(
  208 + null,
  209 + array(
  210 + 'loginData'=> $ret,
  211 + 'perfis' => $arrPerfis,
  212 + 'unidades' => $arrUnidades,
  213 + 'token' => $token
  214 + )
  215 + );
  216 + }catch (Exception $e){
  217 + return MdWsSeiRest::formataRetornoErroREST($e);
  218 + }
  219 +
  220 + }
  221 +
  222 + /**
  223 + * Método que retorna os perfis do usuário
  224 + * @param $idSistema
  225 + * @param $idUsuario
  226 + * @return array
  227 + */
  228 + private function listarPerfisUsuario($idSistema, $idUsuario){
  229 + try{
  230 + $arrPerfis = array();
  231 + $objSipWs = $this->retornaServicoSip();
  232 + $ret = $objSipWs->carregarPerfis(
  233 + $idSistema,
  234 + $idUsuario
  235 + );
  236 + $arrPerfis = array();
  237 + foreach ($ret as $perfil) {
  238 + $arrPerfis[] = array(
  239 + 'idPerfil' => $perfil[0],
  240 + 'nome' => $perfil[1],
  241 + 'stAtivo' => $perfil[3]
  242 + );
  243 + }
  244 +
  245 + return MdWsSeiRest::formataRetornoSucessoREST(null, $arrPerfis);
  246 +
  247 + }catch (Exception $e){
  248 + return MdWsSeiRest::formataRetornoErroREST($e);
  249 + }
  250 + }
  251 +
  252 + /**
  253 + * Retorna a lista de usuarios por unidade
  254 + * @param UnidadeDTO $unidadeDTOParam
  255 + * @return array
  256 + */
  257 + protected function listarUsuariosConectado(UnidadeDTO $unidadeDTOParam){
  258 + try{
  259 + $idUnidade = null;
  260 + $limit = 10;
  261 + $start = 0;
  262 + if($unidadeDTOParam->isSetNumMaxRegistrosRetorno()){
  263 + $limit = $unidadeDTOParam->getNumMaxRegistrosRetorno();
  264 + }
  265 + if(!is_null($unidadeDTOParam->getNumPaginaAtual())){
  266 + $start = $unidadeDTOParam->getNumPaginaAtual();
  267 + }
  268 + if($unidadeDTOParam->isSetNumIdUnidade()){
  269 + $idUnidade = $unidadeDTOParam->getNumIdUnidade();
  270 + }
  271 + $result = array();
  272 + $unidadeDTO = new UnidadeDTO();
  273 + $unidadeDTO->setNumIdUnidade($idUnidade);
  274 + $usuarioRN = new UsuarioRN();
  275 + $arrUsuarioDTO = $usuarioRN->listarPorUnidadeRN0812($unidadeDTO);
  276 +
  277 + //Paginação lógica pois o SIP não retorna os usuários paginados...
  278 + $total = count($arrUsuarioDTO);
  279 + $paginado = array_slice($arrUsuarioDTO, ($limit*$start), $limit);
  280 + /** @var UsuarioDTO $usuarioDTO */
  281 + foreach ($paginado as $usuarioDTO){
  282 + $result[] = array(
  283 + 'id_usuario' => $usuarioDTO->getNumIdUsuario(),
  284 + 'sigla' => $usuarioDTO->getStrSigla(),
  285 + 'nome' => $usuarioDTO->getStrNome(),
  286 + );
  287 + }
  288 +
  289 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result, $total);
  290 + }catch (Exception $e){
  291 + return MdWsSeiRest::formataRetornoErroREST($e);
  292 + }
  293 + }
  294 +
  295 + private function decriptaSenha($senha){
  296 + $decoded = base64_decode($senha);
  297 + for($i = 0; $i < strlen($decoded); $i++){
  298 + $decoded[$i] = ~$decoded[$i];
  299 + }
  300 +
  301 + return $decoded;
  302 + }
  303 +
  304 + private function encriptaSenha($senha){
  305 + for($i = 0; $i < strlen($senha); $i++){
  306 + $senha[$i] = ~$senha[$i];
  307 + }
  308 +
  309 + return base64_encode($senha);
  310 + }
  311 +
  312 + /**
  313 + * Altera a unidade atual do Usuário
  314 + * @param $idUnidade
  315 + */
  316 + public function alterarUnidadeAtual($idUnidade){
  317 + try{
  318 + $_POST['selInfraUnidades'] = $idUnidade;
  319 + SessaoSEI::getInstance()->trocarUnidadeAtual();
  320 + return MdWsSeiRest::formataRetornoSucessoREST('Unidade alterada com sucesso!');
  321 + }catch (Exception $e){
  322 + return MdWsSeiRest::formataRetornoErroREST($e);
  323 + }
  324 + }
  325 +
  326 + /**
  327 + * Retorna as unidades do usuário
  328 + * @param UsuarioDTO $usuarioDTO
  329 + */
  330 + public function listarUnidadesUsuarioConectado(UsuarioDTO $usuarioDTO){
  331 + try{
  332 + $objInfraSip = new InfraSip(SessaoSEI::getInstance());
  333 + $ret = array_values($objInfraSip->carregarUnidades(SessaoSEI::getInstance()->getNumIdSistema(), $usuarioDTO->getNumIdUsuario()));
  334 + InfraArray::ordenarArray($ret,InfraSip::$WS_UNIDADE_SIGLA,InfraArray::$TIPO_ORDENACAO_ASC);
  335 + $result = array();
  336 + foreach($ret as $uni){
  337 + //somente unidades ativas, todas as unidades de outros usuários, se for o usuário atual não mostra a unidade atual
  338 + if ($uni[InfraSip::$WS_UNIDADE_SIN_ATIVO]=='S' && ($usuarioDTO->getNumIdUsuario() != SessaoSEI::getInstance()->getNumIdUsuario() ||$uni[InfraSip::$WS_UNIDADE_ID] != SessaoSEI::getInstance()->getNumIdUnidadeAtual())){
  339 + $result[] = array(
  340 + 'id' => $uni[InfraSip::$WS_UNIDADE_ID],
  341 + 'sigla' => $uni[InfraSip::$WS_UNIDADE_SIGLA],
  342 + 'nome' => $uni[InfraSip::$WS_UNIDADE_DESCRICAO]
  343 + );
  344 + }
  345 + }
  346 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result);
  347 + }catch (Exception $e){
  348 + return MdWsSeiRest::formataRetornoErroREST($e);
  349 + }
  350 + }
  351 +
  352 + /**
  353 + * Pesquisa o usuário pelo nome
  354 + * @param $palavrachave
  355 + * @param null $orgao
  356 + * @return array
  357 + */
  358 + public function apiPesquisarUsuario($palavrachave, $orgao = null){
  359 + try{
  360 + $result = array();
  361 + $arrUsuarioDTO = UsuarioINT::autoCompletarUsuarios($orgao,$palavrachave,false,false,true,false);
  362 + /** @var UsuarioDTO $usuarioDTO */
  363 + foreach($arrUsuarioDTO as $usuarioDTO){
  364 + $result[] = array(
  365 + 'id_contato' => $usuarioDTO->getNumIdContato(),
  366 + 'id_usuario' => $usuarioDTO->getNumIdUsuario(),
  367 + 'sigla' => $usuarioDTO->getStrSigla(),
  368 + 'nome' => $usuarioDTO->getStrNome()
  369 + );
  370 + }
  371 +
  372 + return MdWsSeiRest::formataRetornoSucessoREST(null, $result);
  373 + }catch (Exception $e){
  374 + return MdWsSeiRest::formataRetornoErroREST($e);
  375 + }
  376 + }
  377 +
  378 +}
0 379 \ No newline at end of file
... ...
rn/c.pdf 0 → 100644
No preview for this file type