/** * @param \Core_Dto_Search $dto */ public function searchArtefato($dto) { $sqTipoArtefato = $dto->getSqTipoArtefato(); $nuArtefato = "sgdoce.formata_numero_digital(art.nu_digital) ILIKE '%{$dto->getQuery()}%'"; if ($sqTipoArtefato == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $value = preg_replace('/[^0-9]/', '', $dto->getQuery()); $withOR = "OR TRANSLATE(art.nu_artefato, './-', '') ILIKE '%{$value}%'"; $nuArtefato = "sgdoce.formata_numero_artefato(art.nu_artefato, ap.co_ambito_processo) ILIKE '%{$value}%' {$withOR}"; } $rsm = new \Doctrine\ORM\Query\ResultSetMapping($this->_em); $rsm->addScalarResult('sq_artefato', 'sqArtefato', 'integer'); $rsm->addScalarResult('nu_artefato', 'nuArtefato', 'string'); $rsm->addScalarResult('nu_digital', 'nuDigital', 'string'); $sql = sprintf(' SELECT art.sq_artefato ,formata_numero_artefato(art.nu_artefato, ap.co_ambito_processo) AS nu_artefato ,formata_numero_digital(art.nu_digital) as nu_digital FROM artefato art JOIN artefato art_pai ON obter_vinculo_pai(art.sq_artefato) = art_pai.sq_artefato JOIN sgdoce.tramite_artefato uta ON art_pai.sq_artefato = uta.sq_artefato AND uta.st_ultimo_tramite JOIN tipo_artefato_assunto taa ON taa.sq_tipo_artefato_assunto = art.sq_tipo_artefato_assunto LEFT JOIN artefato_processo ap ON art.sq_artefato = ap.sq_artefato LEFT JOIN artefato_vinculo av ON av.sq_artefato_filho = art.sq_artefato and av.sq_tipo_vinculo_artefato NOT IN(%5$d,%6$d,%7$d) LEFT JOIN artefato_arquivo_setorial aas ON art.sq_artefato = aas.sq_artefato and aas.dt_desarquivamento is null WHERE aas.sq_artefato IS NULL AND uta.sq_pessoa_recebimento = %1$s AND uta.sq_status_tramite <> %2$s AND (%3$s) AND taa.sq_tipo_artefato = %4$s', $dto->getSqPessoa(), \Core_Configuration::getSgdoceStatusTramiteTramitado(), $nuArtefato, $dto->getSqTipoArtefato(), \Core_Configuration::getSgdoceTipoVinculoArtefatoReferencia(), \Core_Configuration::getSgdoceTipoVinculoArtefatoApoio(), \Core_Configuration::getSgdoceTipoVinculoArtefatoDespacho()); try { return $this->_em->createNativeQuery($sql, $rsm)->useResultCache(false)->getScalarResult(); } catch (\Exception $ex) { $this->getMessaging()->addErrorMessage(\Core_Registry::getMessage()->translate('MN180'), 'User'); $this->getMessaging()->dispatchPackets(); return array(); } }
public function isCitacao(\Core_Dto_Search $dto, $sqTipoVinculo = null) { $queryBuilder = $this->_em->createQueryBuilder(); if (!is_null($sqTipoVinculo)) { $sqTipoVinculo = (array) $sqTipoVinculo; } else { $sqTipoVinculo = array(\Core_Configuration::getSgdoceTipoVinculoArtefatoDespacho(), \Core_Configuration::getSgdoceTipoVinculoArtefatoApoio(), \Core_Configuration::getSgdoceTipoVinculoArtefatoReferencia()); } $query = $queryBuilder->select('av')->from('app:ArtefatoVinculo', 'av')->andWhere('av.sqArtefatoFilho = :id')->andWhere($queryBuilder->expr()->In('av.sqTipoVinculoArtefato', $sqTipoVinculo))->setParameter('id', $dto->getSqArtefato()); $result = $query->getQuery()->getOneOrNullResult(); return $result ? true : false; }
public function processDownloadFileRequest($sqArtefato) { try { $dto = \Core_Dto::factoryFromData(array('sqArtefato' => $sqArtefato), 'search'); $arrNotVinculo = array(\Core_Configuration::getSgdoceTipoVinculoArtefatoReferencia(), \Core_Configuration::getSgdoceTipoVinculoArtefatoApoio(), \Core_Configuration::getSgdoceTipoVinculoArtefatoDespacho()); $arrVinculo = $this->getServiceLocator()->getService('ArtefatoVinculo')->findVinculoArtefato($dto, $arrNotVinculo); $entArtefato = $this->_getRepository($this->_entityArtefato)->find($sqArtefato); $sqTipoArtefato = $entArtefato->getSqTipoArtefatoAssunto()->getSqTipoArtefato()->getSqTipoArtefato(); if ($sqTipoArtefato == \Core_Configuration::getSgdoceTipoArtefatoDocumento() && count($arrVinculo) == 0) { //Documento sem Vinculo $arrRetorno = $this->_processDownloadUniqueFile($sqArtefato); } else { //Processo com vinculo além da 1ª Peça //Documento com vinculo $sqPessoa = \Core_Integration_Sica_User::getPersonId(); $configs = \Core_Registry::get('configs'); $mergePdfOptions = $configs['merge_pdf']; $robotMode = (bool) $mergePdfOptions['robotMode']; if (!$robotMode) { $arrRetorno = $this->_processMergeFiles($sqArtefato, $sqPessoa); } else { $txEmailCorporativo = $this->_getEmailCorporativo($sqPessoa); if (!$txEmailCorporativo) { throw new \Core_Exception_ServiceLayer('Email corporativo não localizado. Impossível prosseguir.'); } $entSolicitacaoDownloadImagem = $this->_newEntity('app:SolicitacaoDownloadImagem'); $entSolicitacaoDownloadImagem->setSqArtefato($entArtefato)->setSqPessoa($this->getEntityManager()->getPartialReference('app:VwPessoa', $sqPessoa))->setSqUnidadeOrg($this->getEntityManager()->getPartialReference('app:VwUnidadeOrg', \Core_Integration_Sica_User::getUserUnit()))->setDtSolicitacao(\Zend_Date::now())->setStProcessado(FALSE)->setInTentativa(0)->setTxEmail($txEmailCorporativo); $this->getEntityManager()->persist($entSolicitacaoDownloadImagem); $this->getEntityManager()->flush(); $arrRetorno['success'] = true; $arrRetorno['msg'] = sprintf(\Core_Registry::getMessage()->translate('MN169'), $txEmailCorporativo); $arrRetorno['link'] = ''; $arrRetorno['filesize'] = ''; } } // switch ($sqTipoArtefato) { // //Processo apenas com a 1ª Peça // case \Core_Configuration::getSgdoceTipoArtefatoProcesso() && count($arrVinculo) == 1: // $arrRetorno = $this->_processDownloadUniqueFile($arrVinculo[1]['sqArtefato']); // break; // //Documento sem Vinculo // case \Core_Configuration::getSgdoceTipoArtefatoDocumento() && count($arrVinculo) == 0: // $arrRetorno = $this->_processDownloadUniqueFile($sqArtefato); // break; // //Processo com vinculo além da 1ª Peça // //Documento com vinculo // default: // // $sqPessoa = \Core_Integration_Sica_User::getPersonId(); // $configs = \Core_Registry::get('configs'); // $mergePdfOptions = $configs['merge_pdf']; // $robotMode = (boolean) $mergePdfOptions['robotMode']; // // if (!$robotMode) { // $arrRetorno = $this->_processMergeFiles($sqArtefato, $sqPessoa); // break; // } // // $txEmailCorporativo = $this->_getEmailCorporativo($sqPessoa); // // if (!$txEmailCorporativo) { // throw new \Core_Exception_ServiceLayer('Email corporativo não localizado. Impossível prosseguir.'); // } // // $entSolicitacaoDownloadImagem = $this->_newEntity('app:SolicitacaoDownloadImagem'); // $entSolicitacaoDownloadImagem->setSqArtefato($entArtefato) // ->setSqPessoa($this->getEntityManager()->getPartialReference('app:VwPessoa', $sqPessoa)) // ->setSqUnidadeOrg($this->getEntityManager()->getPartialReference('app:VwUnidadeOrg', \Core_Integration_Sica_User::getUserUnit())) // ->setDtSolicitacao(\Zend_Date::now()) // ->setStProcessado(FALSE) // ->setInTentativa(0) // ->setTxEmail($txEmailCorporativo); // // $this->getEntityManager()->persist($entSolicitacaoDownloadImagem); // $this->getEntityManager()->flush(); // // $arrRetorno['success'] = true; // $arrRetorno['msg'] = sprintf(\Core_Registry::getMessage()->translate('MN169'), $txEmailCorporativo); // $arrRetorno['link'] = ''; // $arrRetorno['filesize'] = ''; // // break; // } } catch (\Exception $e) { $arrRetorno['success'] = false; $arrRetorno['msg'] = $e->getMessage(); $arrRetorno['link'] = ''; } return $arrRetorno; }
/** * @return */ public function findArtefatoResposta($dto, $limit = 10) { $sqTipoArtefato = $dto->getSqTipoArtefato(); $nuArtefato = $dto->getNuArtefato(); $sqArtefatoPrazo = $dto->getSqArtefatoPrazo(); $rsm = new \Doctrine\ORM\Query\ResultSetMapping($this->_em); $rsm->addScalarResult('sq_artefato', 'sqArtefato', 'integer'); $rsm->addScalarResult('nu_artefato', 'nuArtefato', 'string'); $rsm->addScalarResult('nu_digital', 'nuDigital', 'string'); $rsm->addScalarResult('sq_tipo_artefato', 'sqTipoArtefato', 'integer'); $likeNuArtefatoNuDigital = ""; if ($sqTipoArtefato == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $likeNuArtefatoNuDigital = "art.nu_artefato ILIKE '%{$nuArtefato}%'"; } else { $likeNuArtefatoNuDigital = "formata_numero_digital(art.nu_digital) ILIKE '%{$nuArtefato}%'"; } $sql = "SELECT art.sq_artefato,\n formata_numero_artefato(art.nu_artefato, atp.co_ambito_processo) AS nu_artefato,\n formata_numero_digital(art.nu_digital) AS nu_digital,\n ta.sq_tipo_artefato\n FROM sgdoce.artefato art\n INNER JOIN sgdoce.tipo_artefato_assunto tas ON art.sq_tipo_artefato_assunto = tas.sq_tipo_artefato_assunto\n INNER JOIN sgdoce.tipo_artefato ta ON tas.sq_tipo_artefato = ta.sq_tipo_artefato\n LEFT JOIN sgdoce.artefato_processo atp ON art.sq_artefato = atp.sq_artefato\n LEFT JOIN sgdoce.artefato_vinculo av ON art.sq_artefato = av.sq_artefato_filho\n WHERE ta.sq_tipo_artefato = {$sqTipoArtefato}\n AND ((av.sq_artefato_filho IS NULL OR av.sq_tipo_vinculo_artefato IN (\n " . \Core_Configuration::getSgdoceTipoVinculoArtefatoDespacho() . ",\n " . \Core_Configuration::getSgdoceTipoVinculoArtefatoApoio() . ",\n " . \Core_Configuration::getSgdoceTipoVinculoArtefatoReferencia() . "\n )))\n AND ({$likeNuArtefatoNuDigital})\n AND art.sq_artefato <> {$sqArtefatoPrazo} LIMIT {$limit}"; $nativeQuery = $this->_em->createNativeQuery($sql, $rsm); return $nativeQuery->execute(); }