Commit 08a67320bcb1b083f5c3de736e64cc73718a87bc
1 parent
57c82ac3
Exists in
master
and in
1 other branch
[Refact] Refazendo novamente o sistema de download agora com mescla do antigo com o novo.
Showing
1 changed file
with
45 additions
and
81 deletions
Show diff stats
rn/MdWsSeiDocumentoRN.php
@@ -249,108 +249,72 @@ class MdWsSeiDocumentoRN extends DocumentoRN { | @@ -249,108 +249,72 @@ class MdWsSeiDocumentoRN extends DocumentoRN { | ||
249 | if(!$protocoloDTOParam->isSetDblIdProtocolo() || !$protocoloDTOParam->getDblIdProtocolo()){ | 249 | if(!$protocoloDTOParam->isSetDblIdProtocolo() || !$protocoloDTOParam->getDblIdProtocolo()){ |
250 | throw new InfraException('O protocolo deve ser informado!'); | 250 | throw new InfraException('O protocolo deve ser informado!'); |
251 | } | 251 | } |
252 | - $strContentDisposition = 'attachment'; | ||
253 | - $documentoDTO = new DocumentoDTO(); | ||
254 | - $documentoDTO->retDblIdDocumento(); | ||
255 | - $documentoDTO->retStrNomeSerie(); | ||
256 | - $documentoDTO->retStrNumero(); | ||
257 | - $documentoDTO->retStrSiglaUnidadeGeradoraProtocolo(); | ||
258 | - $documentoDTO->retStrProtocoloDocumentoFormatado(); | ||
259 | - $documentoDTO->retStrStaProtocoloProtocolo(); | ||
260 | - $documentoDTO->retStrStaDocumento(); | ||
261 | - $documentoDTO->retDblIdDocumentoEdoc(); | ||
262 | - $documentoDTO->setDblIdDocumento($protocoloDTOParam->getDblIdProtocolo()); | 252 | + $documentoDTOConsulta = new DocumentoDTO(); |
253 | + $documentoDTOConsulta->setDblIdProtocoloProtocolo($protocoloDTOParam->getDblIdProtocolo()); | ||
254 | + $documentoDTOConsulta->retDblIdDocumento(); | ||
255 | + $documentoDTOConsulta->retStrNomeSerie(); | ||
256 | + $documentoDTOConsulta->retStrNumero(); | ||
257 | + $documentoDTOConsulta->retStrSiglaUnidadeGeradoraProtocolo(); | ||
258 | + $documentoDTOConsulta->retStrProtocoloDocumentoFormatado(); | ||
259 | + $documentoDTOConsulta->retStrStaProtocoloProtocolo(); | ||
260 | + $documentoDTOConsulta->retStrStaDocumento(); | ||
261 | + $documentoDTOConsulta->retDblIdDocumentoEdoc(); | ||
262 | + $documentoBD = new DocumentoRN(); | ||
263 | + $documentoDTO = $documentoBD->consultarRN0005($documentoDTOConsulta); | ||
263 | 264 | ||
264 | - $documentoRN = new DocumentoRN(); | ||
265 | - $documentoDTO = $documentoRN->consultarRN0005($documentoDTO); | ||
266 | - if(!$documentoDTO){ | ||
267 | - throw new InfraException('Documento não encontrado!'); | ||
268 | - } | ||
269 | if ($documentoDTO->getStrStaDocumento()==DocumentoRN::$TD_EDITOR_EDOC) { | 265 | if ($documentoDTO->getStrStaDocumento()==DocumentoRN::$TD_EDITOR_EDOC) { |
270 | if ($documentoDTO->getDblIdDocumentoEdoc() == null) { | 266 | if ($documentoDTO->getDblIdDocumentoEdoc() == null) { |
271 | throw new InfraException('Documento sem conteúdo!'); | 267 | throw new InfraException('Documento sem conteúdo!'); |
272 | } | 268 | } |
273 | - $objEDocRN = new EDocRN(); | ||
274 | - $html = $objEDocRN->consultarHTMLDocumentoRN1204($documentoDTO); | 269 | + $eDocRN = new EDocRN(); |
270 | + $html = $eDocRN->consultarHTMLDocumentoRN1204($documentoDTO); | ||
275 | 271 | ||
276 | return MdWsSeiRest::formataRetornoSucessoREST(null, array('html' => $html)); | 272 | return MdWsSeiRest::formataRetornoSucessoREST(null, array('html' => $html)); |
277 | - }else if ($documentoDTO->getStrStaDocumento() == DocumentoRN::$TD_EDITOR_INTERNO){ | ||
278 | - $editorDTO = new EditorDTO(); | ||
279 | - $editorDTO->setDblIdDocumento($documentoDTO->getDblIdDocumento()); | ||
280 | - $editorDTO->setNumIdBaseConhecimento(null); | ||
281 | - $editorDTO->setStrSinCabecalho('S'); | ||
282 | - $editorDTO->setStrSinRodape('S'); | ||
283 | - $editorDTO->setStrSinCarimboPublicacao('S'); | ||
284 | - $editorDTO->setStrSinIdentificacaoVersao('S'); | ||
285 | - $editorDTO->setStrSinProcessarLinks('S'); | 273 | + }else if($documentoDTO->getStrStaDocumento() == DocumentoRN::$TD_EDITOR_INTERNO){ |
274 | + $editorDTOConsulta = new EditorDTO(); | ||
275 | + $editorDTOConsulta->setDblIdDocumento($documentoDTO->getDblIdDocumento()); | ||
276 | + $editorDTOConsulta->setNumIdBaseConhecimento(null); | ||
277 | + $editorDTOConsulta->setStrSinCabecalho('S'); | ||
278 | + $editorDTOConsulta->setStrSinRodape('S'); | ||
279 | + $editorDTOConsulta->setStrSinIdentificacaoVersao('S'); | ||
280 | + $editorDTOConsulta->setStrSinProcessarLinks('S'); | ||
281 | + | ||
282 | + if(MdWsSeiEditorRN::versaoCarimboPublicacaoObrigatorio()){ | ||
283 | + $editorDTOConsulta->setStrSinCarimboPublicacao('N'); | ||
284 | + } | ||
285 | + | ||
286 | $editorRN = new EditorRN(); | 286 | $editorRN = new EditorRN(); |
287 | - $html = $editorRN->consultarHtmlVersao($editorDTO); | 287 | + $html = $editorRN->consultarHtmlVersao($editorDTOConsulta); |
288 | 288 | ||
289 | $auditoriaProtocoloDTO = new AuditoriaProtocoloDTO(); | 289 | $auditoriaProtocoloDTO = new AuditoriaProtocoloDTO(); |
290 | - $auditoriaProtocoloDTO->setStrRecurso('visualizar_documento'); | 290 | + $auditoriaProtocoloDTO->setStrRecurso('documento_visualizar'); |
291 | $auditoriaProtocoloDTO->setNumIdUsuario(SessaoSEI::getInstance()->getNumIdUsuario()); | 291 | $auditoriaProtocoloDTO->setNumIdUsuario(SessaoSEI::getInstance()->getNumIdUsuario()); |
292 | - $auditoriaProtocoloDTO->setDblIdProtocolo($protocoloDTOParam->getDblIdProtocolo()); | 292 | + $auditoriaProtocoloDTO->setDblIdProtocolo($documentoDTO->getDblIdDocumento()); |
293 | $auditoriaProtocoloDTO->setNumIdAnexo(null); | 293 | $auditoriaProtocoloDTO->setNumIdAnexo(null); |
294 | $auditoriaProtocoloDTO->setDtaAuditoria(InfraData::getStrDataAtual()); | 294 | $auditoriaProtocoloDTO->setDtaAuditoria(InfraData::getStrDataAtual()); |
295 | - $auditoriaProtocoloDTO->setNumVersao($editorDTO->getNumVersao()); | 295 | + $auditoriaProtocoloDTO->setNumVersao($editorDTOConsulta->getNumVersao()); |
296 | 296 | ||
297 | $auditoriaProtocoloRN = new AuditoriaProtocoloRN(); | 297 | $auditoriaProtocoloRN = new AuditoriaProtocoloRN(); |
298 | $auditoriaProtocoloRN->auditarVisualizacao($auditoriaProtocoloDTO); | 298 | $auditoriaProtocoloRN->auditarVisualizacao($auditoriaProtocoloDTO); |
299 | 299 | ||
300 | - $anexoDTO = new AnexoDTO(); | ||
301 | - $anexoDTO->retTodos(); | ||
302 | - $anexoDTO->setDblIdProtocolo($documentoDTO->getDblIdDocumento()); | ||
303 | - | ||
304 | - $anexoRN = new AnexoRN(); | ||
305 | - $arrAnexoDTO = $anexoRN->listarRN0218($anexoDTO); | ||
306 | - | ||
307 | - if (count($arrAnexoDTO)) { | ||
308 | - SeiINT::download($arrAnexoDTO[0], null, null, $strContentDisposition); | ||
309 | - }else{ | ||
310 | - return MdWsSeiRest::formataRetornoSucessoREST(null, array('html' => $html)); | ||
311 | - } | ||
312 | - }else if ($documentoDTO->getStrStaProtocoloProtocolo() == ProtocoloRN::$TP_DOCUMENTO_RECEBIDO){ | ||
313 | - $anexoDTO = new AnexoDTO(); | ||
314 | - $anexoDTO->retTodos(); | ||
315 | - $anexoDTO->setDblIdProtocolo($documentoDTO->getDblIdDocumento()); | ||
316 | - | ||
317 | - $anexoRN = new AnexoRN(); | ||
318 | - $arrAnexoDTO = $anexoRN->listarRN0218($anexoDTO); | ||
319 | - if (count($arrAnexoDTO)){ | ||
320 | - SeiINT::download($arrAnexoDTO[0], null, null, $strContentDisposition); | ||
321 | - }else{ | ||
322 | - throw new InfraException('Documento sem conteúdo!'); | ||
323 | - } | 300 | + return MdWsSeiRest::formataRetornoSucessoREST(null, array('html' => $html)); |
324 | }else{ | 301 | }else{ |
325 | - $documentoDTO = new DocumentoDTO(); | ||
326 | - $documentoDTO->setDblIdDocumento($protocoloDTOParam->getDblIdProtocolo()); | ||
327 | - $documentoDTO->setObjInfraSessao(SessaoSEI::getInstance()); | ||
328 | - $documentoDTO->setStrLinkDownload('controlador.php?acao=documento_download_anexo'); | ||
329 | - | ||
330 | - $html = $documentoRN->consultarHtmlFormulario($documentoDTO); | ||
331 | - | ||
332 | - $aditoriaProtocoloDTO = new AuditoriaProtocoloDTO(); | ||
333 | - $aditoriaProtocoloDTO->setStrRecurso('visualizar_documento'); | ||
334 | - $aditoriaProtocoloDTO->setNumIdUsuario(SessaoSEI::getInstance()->getNumIdUsuario()); | ||
335 | - $aditoriaProtocoloDTO->setDblIdProtocolo($protocoloDTOParam->getDblIdProtocolo()); | ||
336 | - $aditoriaProtocoloDTO->setNumIdAnexo(null); | ||
337 | - $aditoriaProtocoloDTO->setDtaAuditoria(InfraData::getStrDataAtual()); | ||
338 | - $aditoriaProtocoloDTO->setNumVersao(null); | ||
339 | - | ||
340 | - $aditoriaProtocoloRN = new AuditoriaProtocoloRN(); | ||
341 | - $aditoriaProtocoloRN->auditarVisualizacao($aditoriaProtocoloDTO); | ||
342 | - | ||
343 | $anexoDTO = new AnexoDTO(); | 302 | $anexoDTO = new AnexoDTO(); |
344 | - $anexoDTO->retTodos(); | ||
345 | - $anexoDTO->setDblIdProtocolo($documentoDTO->getDblIdDocumento()); | ||
346 | - | 303 | + $anexoDTO->retNumIdAnexo(); |
304 | + $anexoDTO->retDthInclusao(); | ||
305 | + $anexoDTO->retDthInclusao(); | ||
306 | + $anexoDTO->retStrNome(); | ||
307 | + $anexoDTO->retStrHash(); | ||
308 | + $anexoDTO->setDblIdProtocolo($protocoloDTOParam->getDblIdProtocolo()); | ||
309 | + $anexoDTO->setStrSinAtivo('S'); | ||
347 | $anexoRN = new AnexoRN(); | 310 | $anexoRN = new AnexoRN(); |
348 | - $arrAnexoDTO = $anexoRN->listarRN0218($anexoDTO); | ||
349 | - if (count($arrAnexoDTO)) { | ||
350 | - SeiINT::download($arrAnexoDTO[0], null, null, $strContentDisposition); | ||
351 | - }else{ | ||
352 | - return MdWsSeiRest::formataRetornoSucessoREST(null, array('html' => $html)); | 311 | + $resultAnexo = $anexoRN->listarRN0218($anexoDTO); |
312 | + if(empty($resultAnexo)){ | ||
313 | + throw new InfraException('Documento não encontrado!'); | ||
353 | } | 314 | } |
315 | + $anexo = $resultAnexo[0]; | ||
316 | + SeiINT::download($anexo); | ||
317 | + exit; | ||
354 | } | 318 | } |
355 | }catch (Exception $e){ | 319 | }catch (Exception $e){ |
356 | return MdWsSeiRest::formataRetornoErroREST($e); | 320 | return MdWsSeiRest::formataRetornoErroREST($e); |