Commit 771a531c536cc26d7b6232683408fb2f0a95ff1d

Authored by maycon.silva
1 parent c0fe18cc
Exists in master

Redmine #4393 Correção da história de anexar processo

cit-ecm-api/src/main/java/br/com/centralit/api/dao/AnexarProcessoDao.java
... ... @@ -100,7 +100,7 @@ public interface AnexarProcessoDao extends CitGenericDAO {
100 100 Collection<AnexoProcesso> findByIdAnexoProcesso(Long id);
101 101  
102 102  
103   - AnexoProcesso verificarUnicidadeAnexoProcesso(Long idProcessoAnexado);
  103 + boolean isExisteAnexoProcesso(Long idProcessoAnexado);
104 104  
105 105  
106 106 }
... ...
cit-ecm-api/src/main/java/br/com/centralit/api/dao/impl/AnexarProcessoDaoHibernate.java
... ... @@ -11,6 +11,7 @@ import br.com.centralit.api.dao.AnexarProcessoDao;
11 11 import br.com.centralit.api.model.AnexoProcesso;
12 12 import br.com.centralit.framework.dao.arquitetura.CitGenericDAOImpl;
13 13 import br.com.centralit.framework.dao.arquitetura.SearchSeven;
  14 +import br.com.centralit.framework.util.UtilColecao;
14 15  
15 16 /**
16 17 *
... ... @@ -103,15 +104,14 @@ public class AnexarProcessoDaoHibernate extends CitGenericDAOImpl implements Ane
103 104  
104 105  
105 106 @Override
106   - public AnexoProcesso verificarUnicidadeAnexoProcesso(Long idProcessoAnexado) {
107   -
108   - SearchSeven search = new SearchSeven(persistentClass);
109   -
110   - search.addFilterEqual("processoAnexado.id", idProcessoAnexado);
111   -
112   - search(search, AnexoProcesso.class);
113   -
114   - return searchUnique(search);
  107 + public boolean isExisteAnexoProcesso(Long idProcessoAnexado) {
  108 +
  109 + SearchSeven searchSeven = new SearchSeven();
  110 +
  111 + searchSeven.addFilterEqual("processoAnexado.id", idProcessoAnexado);
  112 +
  113 + return !UtilColecao.isVazio(this.search(searchSeven));
  114 +
115 115 }
116 116  
117 117 }
... ...
cit-ecm-api/src/main/java/br/com/centralit/api/model/Processo.java
... ... @@ -26,6 +26,7 @@ import br.com.centralit.framework.json.JsonCalendarSimpleDateDeserializer;
26 26 import br.com.centralit.framework.json.JsonCalendarSimpleDateSerializer;
27 27 import br.com.centralit.framework.json.Views;
28 28 import br.com.centralit.framework.model.Dominio;
  29 +import br.com.centralit.framework.util.UtilColecao;
29 30  
30 31 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
31 32 import com.fasterxml.jackson.annotation.JsonView;
... ... @@ -217,6 +218,10 @@ public class Processo extends PersistentObjectUnidade {
217 218 @OneToMany(fetch = FetchType.LAZY, mappedBy = "processo", cascade = CascadeType.ALL)
218 219 private Collection<CredencialProcesso> credenciais;
219 220  
  221 + /** Atributo unidadesProcesso. */
  222 + @OneToMany(fetch = FetchType.LAZY, mappedBy = "processo", cascade = CascadeType.ALL)
  223 + private Collection<UnidadeProcesso> unidadesProcesso;
  224 +
220 225 /**
221 226 * Retorna o valor do atributo <code>id</code>
222 227 *
... ... @@ -822,4 +827,41 @@ public class Processo extends PersistentObjectUnidade {
822 827 this.aprovado = aprovado;
823 828 }
824 829  
  830 + /**
  831 + * Retorna o valor do atributo <code>unidadesProcesso</code>
  832 + *
  833 + * @return <code>Collection<UnidadeProcesso></code>
  834 + */
  835 + public Collection<UnidadeProcesso> getUnidadesProcesso() {
  836 +
  837 + return unidadesProcesso;
  838 + }
  839 +
  840 + /**
  841 + * Define o valor do atributo <code>unidadesProcesso</code>.
  842 + *
  843 + * @param unidadesProcesso
  844 + */
  845 + public void setUnidadesProcesso(Collection<UnidadeProcesso> unidadesProcesso) {
  846 +
  847 + this.unidadesProcesso = unidadesProcesso;
  848 + }
  849 +
  850 + /**
  851 + * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p>
  852 + *
  853 + * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p>
  854 + *
  855 + * Verifica se o processo foi tramitado. Levando em consideração a unidadeProcesso criada apartir da criação do processo.
  856 + *
  857 + * @author maycon.silva
  858 + *
  859 + * @return boolean
  860 + */
  861 + /*@JsonView({ Views.ProcessoEdit.class })*/
  862 + public boolean isTramitado() {
  863 +
  864 + return !UtilColecao.isVazio(this.getUnidadesProcesso()) && this.getUnidadesProcesso().size() > 1;
  865 + }
  866 +
825 867 }
... ...
cit-ecm-api/src/main/java/br/com/centralit/api/service/AnexoGedService.java
... ... @@ -3,6 +3,7 @@ package br.com.centralit.api.service;
3 3 import org.springframework.web.multipart.MultipartFile;
4 4  
5 5 import br.com.centralit.api.model.AnexoGed;
  6 +
6 7 import br.com.centralit.framework.service.arquitetura.GenericService;
7 8  
8 9 /**
... ... @@ -55,7 +56,7 @@ public interface AnexoGedService extends GenericService&lt;AnexoGed, Long&gt; {
55 56 * @param file
56 57 * @param idDocumento
57 58 */
58   - void saveAnexo(MultipartFile file, Long idDocumento);
  59 + void saveAnexo(MultipartFile file, Long idDocumentoGed);
59 60  
60 61 /**
61 62 * <p>
... ...
cit-ecm-api/src/main/java/br/com/centralit/api/service/DocumentoGedService.java
... ... @@ -39,7 +39,7 @@ public interface DocumentoGedService extends GenericService&lt;DocumentoGed, Long&gt;
39 39 */
40 40 void saveIconeDocumento(DocumentoGed documentoGed, Dominio tipoAnexo);
41 41  
42   - void anexarDocumento(Processo processoOrigem, AnexarProcessoVH anexarProcessoVH);
  42 + void anexarDocumento(Processo processoDestinoAnexo, Processo processoOrigem);
43 43  
44 44 Collection<DocumentoGed> findByProcessoSigilo(Long idProcesso);
45 45  
... ...
cit-ecm-api/src/main/java/br/com/centralit/api/service/impl/AnexarProcessoServiceImpl.java
... ... @@ -128,33 +128,35 @@ public class AnexarProcessoServiceImpl extends GenericServiceImpl&lt;AnexoProcesso,
128 128  
129 129 Processo processoFilho = this.processoService.getReference(anexoProcesso.getProcessoAnexado().getId());
130 130  
131   - if (!UtilDate.isDataMenor(processoPai.getDataCriacao().getTime(), processoFilho.getDataCriacao().getTime())) {
  131 + if (UtilDate.diferencaHoras(processoPai.getDataCriacao().getTime(), processoFilho.getDataCriacao().getTime()) < 0) {
  132 +
132 133 listProcesso.add(processoFilho);
133   - }
134   -
135   - if (!listProcesso.isEmpty()) {
  134 +
  135 + }else{
  136 +
  137 + // Vincula o processo filho ao pai
  138 + this.vincularProcesso(processoPai, processoFilho);
  139 +
  140 + // Realiza o vinculo inverso, o pai vira filho e o filho vira pai.
  141 + this.vincularProcesso(processoFilho, processoPai);
  142 +
  143 +
136 144 if (!UtilColecao.isVazio(processoFilho.getDocumentos())) {
137   - // Vincula o processo filho ao pai
138   - this.vincularProcesso(processoPai, processoFilho);
139   -
140   - // Realiza o vinculo inverso, o pai vira filho e o filho vira pai.
141   - this.vincularProcesso(processoFilho, processoPai);
142   -
143   - documentoGedService.anexarDocumento(processoFilho, anexarProcessoVH);
144   -
  145 + documentoGedService.anexarDocumento(processoPai, processoFilho);
145 146 }
  147 +
  148 + this.finalizeProcesso("FINALIZAR_PROCESSO_SIGAD", false, processoFilho.getIdProcessInstance());
  149 + this.processoService.atualizarTemporalidadeProcessoAnexado(processoPai, processoFilho);
146 150 }
147   -
148   - this.finalizeProcesso("FINALIZAR_PROCESSO_SIGAD", false, processoFilho.getIdProcessInstance());
149   - this.processoService.atualizarTemporalidadeProcessoAnexado(processoPai, processoFilho);
150   -
151 151 }
  152 +
152 153 if (!UtilColecao.isVazio(listProcesso)) {
153 154 this.validarTempoCriacaoProcesso(listProcesso, processoPai);
154 155 return null;
155 156 }
156 157  
157 158 }
  159 +
158 160 return anexarProcessoVH;
159 161 }
160 162  
... ... @@ -194,7 +196,7 @@ public class AnexarProcessoServiceImpl extends GenericServiceImpl&lt;AnexoProcesso,
194 196 * <b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a>
195 197 * </p>
196 198 *
197   - * Método responsável por criar o vinculo do processo com processoRelacionado
  199 + * Método responsável por criar o vinculo do processo com
198 200 *
199 201 *
200 202 * @param processoPrincipal
... ... @@ -346,10 +348,11 @@ public class AnexarProcessoServiceImpl extends GenericServiceImpl&lt;AnexoProcesso,
346 348  
347 349 for (AnexoProcesso processoAnexado : anexarProcessoVH.getListaProcessoAnexado()) {
348 350  
349   - AnexoProcesso anexoProcesso = this.anexarProcessoDao.verificarUnicidadeAnexoProcesso(processoAnexado.getProcessoAnexado().getId());
  351 + /*AnexoProcesso anexoProcesso = this.anexarProcessoDao.verificarUnicidadeAnexoProcesso(processoAnexado.getProcessoAnexado().getId());*/
  352 +
350 353  
351   - if (anexoProcesso != null && anexoProcesso.getAnexado()) {
352   - mensagem.append(anexoProcesso.getProcessoAnexado().getNup()).append(",");
  354 + if (this.anexarProcessoDao.isExisteAnexoProcesso(processoAnexado.getProcessoAnexado().getId())) {
  355 + mensagem.append(processoAnexado.getProcessoAnexado().getNup()).append(",");
353 356 }
354 357  
355 358 }
... ...
cit-ecm-api/src/main/java/br/com/centralit/api/service/impl/AnexoGedServiceImpl.java
... ... @@ -91,7 +91,7 @@ public class AnexoGedServiceImpl extends GenericServiceImpl&lt;AnexoGed, Long&gt; impl
91 91  
92 92 if (UtilObjeto.isReferencia(multipartFile)) {
93 93  
94   - DocumentoGed documentoGed = this.documentoGedService.getReference(idDocumento);
  94 + DocumentoGed documentoGed = this.documentoGedService.find(idDocumento);
95 95  
96 96 StringBuilder sb = new StringBuilder();
97 97  
... ...
cit-ecm-api/src/main/java/br/com/centralit/api/service/impl/DocumentoGedServiceImpl.java
... ... @@ -5,6 +5,7 @@ import java.io.FileInputStream;
5 5 import java.security.Key;
6 6 import java.util.Calendar;
7 7 import java.util.Collection;
  8 +import java.util.LinkedList;
8 9 import java.util.List;
9 10  
10 11 import javax.crypto.Cipher;
... ... @@ -33,7 +34,6 @@ import br.com.centralit.api.service.ProcessoService;
33 34 import br.com.centralit.api.service.SigiloService;
34 35 import br.com.centralit.api.service.SolrService;
35 36 import br.com.centralit.api.service.TipoDocumentoService;
36   -import br.com.centralit.api.viewHelper.AnexarProcessoVH;
37 37 import br.com.centralit.framework.exception.BusinessException;
38 38 import br.com.centralit.framework.exception.CodigoErro;
39 39 import br.com.centralit.framework.model.Dominio;
... ... @@ -572,6 +572,7 @@ public class DocumentoGedServiceImpl extends GenericServiceImpl&lt;DocumentoGed, Lo
572 572  
573 573 this.validarEntidade(entity, this.validator);
574 574 AnexoGed anexo = null;
  575 +
575 576 if (entity.getAnexo() != null) {
576 577 anexo = this.anexoGedService.getReference(entity.getAnexo().getId());
577 578 }
... ... @@ -770,12 +771,12 @@ public class DocumentoGedServiceImpl extends GenericServiceImpl&lt;DocumentoGed, Lo
770 771 * @param anexarProcessoVH
771 772 */
772 773 @Override
773   - public void anexarDocumento(Processo processoOrigem, AnexarProcessoVH anexarProcessoVH) {
  774 + public void anexarDocumento(Processo processoDestinoAnexo, Processo processoOrigem) {
774 775  
775 776 if (!UtilColecao.isVazio(processoOrigem.getDocumentos())) {
776 777  
777 778 for (DocumentoGed documentoGedOrigem : processoOrigem.getDocumentos()) {
778   - vincularAnexo(documentoGedOrigem, anexarProcessoVH, processoOrigem);
  779 + vincularAnexo(documentoGedOrigem, processoDestinoAnexo, processoOrigem);
779 780 }
780 781 }
781 782  
... ... @@ -836,19 +837,12 @@ public class DocumentoGedServiceImpl extends GenericServiceImpl&lt;DocumentoGed, Lo
836 837 * @param documentoGedOrigem
837 838 * @param anexarProcessoVH
838 839 */
839   - private void vincularAnexo(DocumentoGed documentoGedOrigem, AnexarProcessoVH anexarProcessoVH, Processo processoOrigem) {
  840 + private void vincularAnexo(DocumentoGed documentoGedOrigem, Processo processoDestinoAnexo, Processo processoOrigem) {
840 841  
841   - Processo processoDestinoAnexo = this.processoService.getReference(anexarProcessoVH.getProcesso().getId());
  842 +/* Processo processoDestinoAnexo = this.processoService.getReference(anexarProcessoVH.getProcesso().getId());*/
842 843  
843   - AnexoGed anexo = null;
844   -
845   - if (documentoGedOrigem.getFormaCriacao() != null && !documentoGedOrigem.getFormaCriacao().getCodigo().equals(1L)) {
846   -
847   - if (documentoGedOrigem.getAnexo() != null) {
848   - anexo = this.anexoGedService.getReference(documentoGedOrigem.getAnexo().getId());
849   - }
  844 + AnexoGed anexoDocumentoOrigem = null;
850 845  
851   - }
852 846  
853 847 DocumentoGed documentoGed = new DocumentoGed();
854 848  
... ... @@ -859,20 +853,36 @@ public class DocumentoGedServiceImpl extends GenericServiceImpl&lt;DocumentoGed, Lo
859 853 documentoGed.setAnexo(null);
860 854 documentoGed.setId(null);
861 855  
862   - if (UtilColecao.isVazio(documentoGed.getInteressados())) {
  856 + if (!UtilColecao.isVazio(documentoGedOrigem.getInteressados())) {
863 857  
864   - documentoGed.setInteressados(null);
  858 + documentoGed.setInteressados(new LinkedList<InteressadoDocumento>());
865 859  
  860 + //Monta os dados do novo interessado para o novo documento.
  861 + for(InteressadoDocumento interessadoDocumento : documentoGedOrigem.getInteressados()){
  862 +
  863 + InteressadoDocumento interessadoDocumentoDestino = new InteressadoDocumento();
  864 + interessadoDocumentoDestino.setInteressado(interessadoDocumento.getInteressado());
  865 + interessadoDocumentoDestino.setDocumentoGed(documentoGed);
  866 + documentoGed.getInteressados().add(interessadoDocumentoDestino);
  867 + }
  868 +
866 869 }
867 870  
868 871 documentoGed = super.save(documentoGed);
869 872  
  873 + if (documentoGedOrigem.getFormaCriacao() != null && !documentoGedOrigem.getFormaCriacao().getCodigo().equals(1L)) {
  874 +
  875 + if (documentoGedOrigem.getAnexo() != null) {
  876 + anexoDocumentoOrigem = this.anexoGedService.getReference(documentoGedOrigem.getAnexo().getId());
  877 + }
  878 + }
  879 +
870 880 try {
871   - if (anexo != null) {
872   - File file = this.gedFileService.restoreFile(anexo);
  881 + if (anexoDocumentoOrigem != null) {
  882 + File file = this.gedFileService.restoreFile(anexoDocumentoOrigem);
873 883 file.length();
874 884 FileInputStream input = new FileInputStream(file);
875   - MultipartFile multipartFile = new MockMultipartFile("file", anexo.getDescricao(), "text/plain", IOUtils.toByteArray(input));
  885 + MultipartFile multipartFile = new MockMultipartFile("file", anexoDocumentoOrigem.getDescricao(), "text/plain", IOUtils.toByteArray(input));
876 886  
877 887 this.anexoGedService.saveAnexo(multipartFile, documentoGed.getId());
878 888 }
... ...
cit-ecm-api/src/main/java/br/com/centralit/api/viewHelper/AnexarProcessoVH.java
... ... @@ -55,7 +55,7 @@ public class AnexarProcessoVH implements Serializable {
55 55 @JsonView({ Views.AnexarProcesso.class })
56 56 private Collection<AnexoProcesso> listRemoverAnexado;
57 57  
58   - /** Atributo Proceso. */
  58 + /** Atributo Proceso Pai */
59 59 @JsonView({ Views.AnexarProcesso.class })
60 60 private Processo processo;
61 61  
... ...
cit-ecm-web/src/main/webapp/assets/js/angular/custom/controller/AnexarProcessoController.js
... ... @@ -59,7 +59,8 @@ citApp.controller(&#39;AnexarProcessoController&#39;, [&#39;$scope&#39;, &#39;UnidadeProcessoReposit
59 59 //Buscar processo através do nup
60 60 $scope.findAutoCompleteProcesso = function(value){
61 61 return ProcessoRepository.findAutoComplete('nup', value).then(function(result) {
62   - return $filter('idNotEqualProcessoAnexadoAndProcessoPai')(result, $scope.anexarProcessoVH.listaProcessoAnexado, $scope.$parent.$parent.processo);
  62 +
  63 + return $filter('idNotEqualProcessoAnexadoAndProcessoPai')(result, $scope.anexarProcessoVH.listaProcessoAnexado, $scope.$parent.$parent.processo);
63 64 });
64 65 };
65 66  
... ...
cit-ecm-web/src/main/webapp/assets/js/angular/custom/controller/GerenciarProcessoController.js
... ... @@ -455,15 +455,10 @@ citApp.controller(&#39;GerenciarProcessoController&#39;, [ &#39;$scope&#39;, &#39;$translate&#39;, &#39;$tim
455 455 };
456 456  
457 457 $scope.tratimitado = function () {
458   - UnidadeProcessoRepository.existeVinculo( {
459   - 'joinClass' : 'processo.id',
460   - 'id' : $scope.processo.id
461   - } ).then( function ( result ) {
  458 + UnidadeProcessoRepository.existeVinculo( { 'joinClass' : 'processo.id', 'id' : $scope.processo.id } ).then( function ( result ) {
462 459 if ( result ) {
463 460 $scope.isTramitado = true;
464   - } else {
465   - $scope.isTramitado = false;
466   - }
  461 + }
467 462 } );
468 463 };
469 464  
... ...
cit-ecm-web/src/main/webapp/html/anexarProcesso/anexarProcesso.html
... ... @@ -89,47 +89,6 @@
89 89 </div>
90 90 </fieldset>
91 91  
92   - <!-- <fieldset>
93   -
94   - <legend>
95   - <translate>LABEL.HISTORICO_DE_ANEXACOES</translate>
96   - </legend>
97   -
98   - <div class="col-md-12">
99   - <div class="row">
100   - <div class="col-sm-12">
101   - <div class="panel panel-default">
102   - <div class="panel-heading clearfix"></div>
103   - <table class="table table-striped table-bordered table-hover">
104   - <thead>
105   - <tr>
106   - <th class="text-center"><translate>LABEL.PROCESSO</translate></th>
107   - <th class="text-center"><translate>LABEL.USUARIO</translate></th>
108   - <th class="text-center"><translate>LABEL.UNIDADE</translate></th>
109   - <th class="text-center"><translate>LABEL.DATACRIACAO</translate></th>
110   - </tr>
111   - </thead>
112   - <tbody>
113   - <tr ng-repeat="historico in listaHistoricos">
114   -
115   - <td class="text-center">{{historico.processoAnexado.nup}}</td>
116   - <td class="text-center">{{historico.unidade.nome}}</td>
117   - <td class="text-center">{{historico.autor.username}}</td>
118   - <td class="text-center">{{historico.dataCriacao | date: 'dd/MM/yyyy HH:mm:ss' }}</td>
119   -
120   - </tr>
121   - <tr ng-hide="listaHistorico.length > 0">
122   - <td colspan="3" class="text-center"><translate>LABEL.TABELA_VAZIA</translate></td>
123   - </tr>
124   - </tbody>
125   - </table>
126   - </div>
127   - </div>
128   - </div>
129   - </div>
130   -
131   - </fieldset> -->
132   -
133 92 <div class="row">
134 93 <div class="col-md-12">
135 94 <button class="btn btn-sm btn-primary" ng-click="saveOrUpdate()" type="button">
... ...