Commit e53207ef179222bbaf25c9f2de0a5a677ecf6eea
Exists in
master
Merge branch 'master' of http://ferramentasgo.centralit.com.br:8080/scm/git/cit-grp-adm-materiais
Showing
7 changed files
with
196 additions
and
46 deletions
Show diff stats
cit-adm-materiais-web/src/main/java/br/com/centralit/controller/ContaContabilController.java
... | ... | @@ -5,16 +5,22 @@ import java.util.List; |
5 | 5 | |
6 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
7 | 7 | import org.springframework.stereotype.Controller; |
8 | +import org.springframework.web.bind.annotation.PathVariable; | |
9 | +import org.springframework.web.bind.annotation.RequestBody; | |
8 | 10 | import org.springframework.web.bind.annotation.RequestMapping; |
9 | 11 | import org.springframework.web.bind.annotation.RequestMethod; |
10 | 12 | import org.springframework.web.bind.annotation.RequestParam; |
11 | 13 | import org.springframework.web.bind.annotation.ResponseBody; |
12 | 14 | |
13 | 15 | import br.com.centralit.api.model.ContaContabil; |
16 | +import br.com.centralit.api.model.MyMensagemRetorno; | |
17 | +import br.com.centralit.api.model.MyRetornoStatus; | |
14 | 18 | import br.com.centralit.api.service.ContaContabilService; |
19 | +import br.com.centralit.api.service.OrganizacaoService; | |
15 | 20 | import br.com.centralit.framework.controller.GenericController; |
16 | 21 | import br.com.centralit.framework.json.ResponseBodyWrapper; |
17 | 22 | import br.com.centralit.framework.json.Views; |
23 | +import br.com.centralit.framework.model.Organizacao; | |
18 | 24 | import br.com.centralit.framework.view.ResultResponseVH; |
19 | 25 | |
20 | 26 | /** |
... | ... | @@ -55,6 +61,9 @@ public class ContaContabilController extends GenericController<ContaContabil> { |
55 | 61 | |
56 | 62 | /** Atributo contaContabilService. */ |
57 | 63 | private ContaContabilService contaContabilService; |
64 | + | |
65 | + @Autowired | |
66 | + private OrganizacaoService organizacaoService; | |
58 | 67 | |
59 | 68 | public ContaContabilController() { |
60 | 69 | super(); |
... | ... | @@ -319,4 +328,68 @@ public class ContaContabilController extends GenericController<ContaContabil> { |
319 | 328 | |
320 | 329 | return responseBody; |
321 | 330 | } |
331 | + | |
332 | + @RequestMapping(method = RequestMethod.POST, value = "") | |
333 | + @ResponseBody | |
334 | + public ResponseBodyWrapper save(@RequestBody ContaContabil entity) throws Exception { | |
335 | + | |
336 | + Organizacao organizacao = this.organizacaoService.find(this.getUsuario().getOrganizacao().getId()); | |
337 | + | |
338 | + if (!organizacao.getEmFechamento()) { | |
339 | + | |
340 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(this.contaContabilService.save(entity), getEditView()); | |
341 | + | |
342 | + return responseBody; | |
343 | + | |
344 | + } else { | |
345 | + MyRetornoStatus retorno = new MyRetornoStatus(); | |
346 | + retorno.data = entity; | |
347 | + retorno.mensagens.add(new MyMensagemRetorno(MyMensagemRetorno.TipoMensagemRetorno.warning, "MSG.ORGANIZACAO_EM_FECHAMENTO_MES")); | |
348 | + | |
349 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(retorno, getEditView()); | |
350 | + | |
351 | + return responseBody; | |
352 | + } | |
353 | + } | |
354 | + | |
355 | + @RequestMapping(method = RequestMethod.POST, value = "/update") | |
356 | + @ResponseBody | |
357 | + public ResponseBodyWrapper update(@RequestBody ContaContabil objeto) { | |
358 | + Organizacao organizacao = this.organizacaoService.find(this.getUsuario().getOrganizacao().getId()); | |
359 | + | |
360 | + if (!organizacao.getEmFechamento()) { | |
361 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(this.contaContabilService.merge(objeto), getEditView()); | |
362 | + | |
363 | + return responseBody; | |
364 | + } else { | |
365 | + MyRetornoStatus retorno = new MyRetornoStatus(); | |
366 | + retorno.data = objeto; | |
367 | + retorno.mensagens.add(new MyMensagemRetorno(MyMensagemRetorno.TipoMensagemRetorno.warning, "MSG.ORGANIZACAO_EM_FECHAMENTO_MES")); | |
368 | + | |
369 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(retorno, getEditView()); | |
370 | + | |
371 | + return responseBody; | |
372 | + } | |
373 | + } | |
374 | + | |
375 | + @RequestMapping(method = RequestMethod.DELETE, value = "/{id}") | |
376 | + @ResponseBody | |
377 | + public ResponseBodyWrapper delete(@PathVariable("id") Long id) { | |
378 | + | |
379 | + Organizacao organizacao = this.organizacaoService.find(this.getUsuario().getOrganizacao().getId()); | |
380 | + | |
381 | + if (!organizacao.getEmFechamento()) { | |
382 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(contaContabilService.removeById(id), getEditView()); | |
383 | + | |
384 | + return responseBody; | |
385 | + } else { | |
386 | + MyRetornoStatus retorno = new MyRetornoStatus(); | |
387 | + retorno.data = id; | |
388 | + retorno.mensagens.add(new MyMensagemRetorno(MyMensagemRetorno.TipoMensagemRetorno.warning, "MSG.ORGANIZACAO_EM_FECHAMENTO_MES")); | |
389 | + | |
390 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(retorno, getEditView()); | |
391 | + | |
392 | + return responseBody; | |
393 | + } | |
394 | + } | |
322 | 395 | } |
323 | 396 | \ No newline at end of file | ... | ... |
cit-adm-materiais-web/src/main/java/br/com/centralit/controller/TransferenciaContaContabilController.java
... | ... | @@ -10,10 +10,14 @@ import org.springframework.web.bind.annotation.RequestMethod; |
10 | 10 | import org.springframework.web.bind.annotation.ResponseBody; |
11 | 11 | |
12 | 12 | import br.com.centralit.api.framework.json.ViewsAdmMateriais; |
13 | +import br.com.centralit.api.model.MyMensagemRetorno; | |
14 | +import br.com.centralit.api.model.MyRetornoStatus; | |
13 | 15 | import br.com.centralit.api.model.TransferenciaContaContabil; |
16 | +import br.com.centralit.api.service.OrganizacaoService; | |
14 | 17 | import br.com.centralit.api.service.TransferenciaContaContabilService; |
15 | 18 | import br.com.centralit.framework.controller.GenericController; |
16 | 19 | import br.com.centralit.framework.json.ResponseBodyWrapper; |
20 | +import br.com.centralit.framework.model.Organizacao; | |
17 | 21 | |
18 | 22 | @Controller |
19 | 23 | @RequestMapping("/rest/transferenciaContaContabil") |
... | ... | @@ -23,6 +27,9 @@ public class TransferenciaContaContabilController extends GenericController<Tran |
23 | 27 | private TransferenciaContaContabilService transferenciaContaContabilService; |
24 | 28 | |
25 | 29 | @Autowired |
30 | + private OrganizacaoService organizacaoService; | |
31 | + | |
32 | + @Autowired | |
26 | 33 | public TransferenciaContaContabilController(TransferenciaContaContabilService transferenciaContaContabilService) { |
27 | 34 | super(transferenciaContaContabilService); |
28 | 35 | } |
... | ... | @@ -60,35 +67,46 @@ public class TransferenciaContaContabilController extends GenericController<Tran |
60 | 67 | @RequestMapping(value = "/realizarTransferencia", method = RequestMethod.POST) |
61 | 68 | @ResponseBody |
62 | 69 | public ResponseBodyWrapper realizarTransferencia(@RequestBody TransferenciaContaContabil transferenciaConta) { |
63 | - | |
70 | + Organizacao organizacao = this.organizacaoService.find(this.getUsuario().getOrganizacao().getId()); | |
64 | 71 | Boolean transferido = false; |
65 | 72 | boolean uniqueConstraintViolate = true; |
66 | - | |
67 | - //TODO Solução temporária para evitar que sejam criados registros com o código duplicado. Alterar solução quando for implementado o cache compartilhado | |
68 | - for(int i = 5; i > 0 && uniqueConstraintViolate; i--){ | |
69 | - try{ | |
70 | - if (transferenciaConta.getMaterial() != null) { | |
71 | - transferido = this.transferenciaContaContabilService.realizaTransferenciaMaterial(SerializationUtils.clone(transferenciaConta)); | |
72 | - } else { | |
73 | - transferido = this.transferenciaContaContabilService.realizaTransferenciaAlmoxarifado(SerializationUtils.clone(transferenciaConta)); | |
74 | - } | |
75 | - uniqueConstraintViolate = false; | |
76 | - }catch(Throwable e){ | |
77 | - if(e.getCause() instanceof ConstraintViolationException){ | |
78 | - ConstraintViolationException ex = (ConstraintViolationException) e.getCause(); | |
79 | - if(ex.getSQLException().getMessage().contains("codigo_unico")){ | |
80 | - uniqueConstraintViolate = true; | |
73 | + | |
74 | + if (!organizacao.getEmFechamento()) { | |
75 | + | |
76 | + //TODO Solução temporária para evitar que sejam criados registros com o código duplicado. Alterar solução quando for implementado o cache compartilhado | |
77 | + for(int i = 5; i > 0 && uniqueConstraintViolate; i--){ | |
78 | + try{ | |
79 | + if (transferenciaConta.getMaterial() != null) { | |
80 | + transferido = this.transferenciaContaContabilService.realizaTransferenciaMaterial(SerializationUtils.clone(transferenciaConta)); | |
81 | + } else { | |
82 | + transferido = this.transferenciaContaContabilService.realizaTransferenciaAlmoxarifado(SerializationUtils.clone(transferenciaConta)); | |
83 | + } | |
84 | + uniqueConstraintViolate = false; | |
85 | + }catch(Throwable e){ | |
86 | + if(e.getCause() instanceof ConstraintViolationException){ | |
87 | + ConstraintViolationException ex = (ConstraintViolationException) e.getCause(); | |
88 | + if(ex.getSQLException().getMessage().contains("codigo_unico")){ | |
89 | + uniqueConstraintViolate = true; | |
90 | + }else{ | |
91 | + throw e; | |
92 | + } | |
81 | 93 | }else{ |
82 | 94 | throw e; |
83 | 95 | } |
84 | - }else{ | |
85 | - throw e; | |
86 | 96 | } |
87 | 97 | } |
88 | - } | |
89 | - | |
90 | - ResponseBodyWrapper responseBody = new ResponseBodyWrapper(transferido, getEditView()); | |
98 | + | |
99 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(transferido, getEditView()); | |
100 | + | |
101 | + return responseBody; | |
102 | + } else { | |
103 | + MyRetornoStatus retorno = new MyRetornoStatus(); | |
104 | + retorno.data = transferido; | |
105 | + retorno.mensagens.add(new MyMensagemRetorno(MyMensagemRetorno.TipoMensagemRetorno.warning, "MSG.ORGANIZACAO_EM_FECHAMENTO_MES")); | |
91 | 106 | |
92 | - return responseBody; | |
107 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(retorno, getEditView()); | |
108 | + | |
109 | + return responseBody; | |
110 | + } | |
93 | 111 | } |
94 | 112 | } | ... | ... |
cit-adm-materiais-web/src/main/webapp/assets/js/angular/custom/controller/ContaContabilController.js
... | ... | @@ -36,14 +36,21 @@ citApp.controller('ContaContabilController', ['$scope', 'ContaContabilRepository |
36 | 36 | $scope.$openModalConfirm({ |
37 | 37 | message: $translate.instant('ADMINISTRACAODEMATERIAIS.MSG.CONFIRMA_EXCLUIR_CONTA_CONTABIL'), |
38 | 38 | callback: function () { |
39 | - ContaContabilRepository.remove(contaContabil).then(function() { | |
40 | - $scope.contaContabil = {}; | |
41 | - | |
42 | - $scope.$modalConfirmInstance.dismiss('cancel'); | |
43 | - $scope.showAlert("success", $translate.instant('ADMINISTRACAODEMATERIAIS.MSG.SUCESSO_CONTA_CONTABIL_EXCLUIDO')); | |
44 | - angular.element('#searchContaContabil').scope().fetchResult(); | |
45 | - | |
46 | - $scope.resetForm(); | |
39 | + ContaContabilRepository.remove(contaContabil).then(function(result) { | |
40 | + if (result.originalElement && result.originalElement.status != undefined && !result.originalElement.status && result.originalElement.mensagens) { | |
41 | + $scope.setLoading(false); | |
42 | + angular.forEach(result.originalElement.mensagens, function (mensagem) { | |
43 | + $scope.showAlert(mensagem.tipoMensagem, $translate.instant(mensagem.mensagem)); | |
44 | + }); | |
45 | + } else { | |
46 | + $scope.contaContabil = {}; | |
47 | + | |
48 | + $scope.$modalConfirmInstance.dismiss('cancel'); | |
49 | + $scope.showAlert("success", $translate.instant('ADMINISTRACAODEMATERIAIS.MSG.SUCESSO_CONTA_CONTABIL_EXCLUIDO')); | |
50 | + angular.element('#searchContaContabil').scope().fetchResult(); | |
51 | + | |
52 | + $scope.resetForm(); | |
53 | + } | |
47 | 54 | }); |
48 | 55 | } |
49 | 56 | }); |
... | ... | @@ -100,10 +107,17 @@ citApp.controller('ContaContabilController', ['$scope', 'ContaContabilRepository |
100 | 107 | } |
101 | 108 | |
102 | 109 | ContaContabilRepository.save($scope.contaContabil).then(function(result) { |
103 | - $scope.contaContabil = result.originalElement; | |
104 | - $scope.showAlert("success", $translate.instant('ADMINISTRACAODEMATERIAIS.MSG.SUCESSO_CONTA_CONTABIL')); | |
105 | - $scope.contaContabilForm.$submitted = false; | |
106 | - $scope.setLoading(false); | |
110 | + if (result.originalElement.status != undefined && !result.originalElement.status && result.originalElement.mensagens) { | |
111 | + $scope.setLoading(false); | |
112 | + angular.forEach(result.originalElement.mensagens, function (mensagem) { | |
113 | + $scope.showAlert(mensagem.tipoMensagem, $translate.instant(mensagem.mensagem)); | |
114 | + }); | |
115 | + } else { | |
116 | + $scope.contaContabil = result.originalElement; | |
117 | + $scope.showAlert("success", $translate.instant('ADMINISTRACAODEMATERIAIS.MSG.SUCESSO_CONTA_CONTABIL')); | |
118 | + $scope.contaContabilForm.$submitted = false; | |
119 | + $scope.setLoading(false); | |
120 | + } | |
107 | 121 | }); |
108 | 122 | |
109 | 123 | }else{ | ... | ... |
cit-adm-materiais-web/src/main/webapp/assets/js/angular/custom/controller/ContaContabilListController.js
... | ... | @@ -58,6 +58,42 @@ citApp.controller('ContaContabilListController', ['$scope', 'ContaContabilReposi |
58 | 58 | $scope.$showPageEditWorkspace($scope.workspace); |
59 | 59 | }; |
60 | 60 | |
61 | + // MODAL DE CONFIRMAÇÃO E REMOÇÃO DO REGISTRO | |
62 | + $scope.remover = function(){ | |
63 | + | |
64 | + var contaContabil = $scope.contaContabilChecked; | |
65 | + | |
66 | + if(contaContabil) { | |
67 | + | |
68 | + $scope.$openModalConfirm({ | |
69 | + message: $translate.instant("MSG.CONFIRMA_EXCLUSAO"), | |
70 | + callback: function () { | |
71 | + $scope.setLoadingRemove(true); | |
72 | + | |
73 | + ContaContabilRepository.remove(contaContabil).then(function(result) { | |
74 | + if (result.originalElement && result.originalElement.status != undefined && !result.originalElement.status && result.originalElement.mensagens) { | |
75 | + $scope.setLoading(false); | |
76 | + angular.forEach(result.originalElement.mensagens, function (mensagem) { | |
77 | + $scope.showAlert(mensagem.tipoMensagem, $translate.instant(mensagem.mensagem)); | |
78 | + }); | |
79 | + } else { | |
80 | + $scope.$modalConfirmInstance.dismiss('cancel'); | |
81 | + $scope.showAlert('success', $translate.instant('MSG.REGISTRO_EXCLUIDO')); | |
82 | + $scope.fetchResult(); | |
83 | + $scope.setLoading(false); | |
84 | + } | |
85 | + }); | |
86 | + | |
87 | + } | |
88 | + }); | |
89 | + | |
90 | + } else { | |
91 | + | |
92 | + $scope.showAlert('warning', $translate.instant('MSG.SELECIONE_UM_ITEM_PARA_SER_REMOVIDO')); | |
93 | + } | |
94 | + | |
95 | + }; | |
96 | + | |
61 | 97 | }]); |
62 | 98 | |
63 | 99 | ... | ... |
cit-adm-materiais-web/src/main/webapp/assets/js/angular/custom/controller/MesReferenciaController.js
1 | 1 | 'use strict'; |
2 | 2 | |
3 | -citApp.controller('MesReferenciaController', ['$scope', 'OrganizacaoRepository', 'DominioRepository', '$filter', '$translate', 'DepreciacaoRepository', 'OrganizacaoPatrimonioRepository', function MesReferenciaController($scope, OrganizacaoRepository, DominioRepository, $filter, $translate, DepreciacaoRepository, OrganizacaoPatrimonioRepository) { | |
3 | +citApp.controller('MesReferenciaController', ['$scope', 'OrganizacaoRepository', 'DominioRepository', '$filter', '$translate', 'DepreciacaoRepository', 'OrganizacaoPatrimonioRepository', | |
4 | + function MesReferenciaController($scope, OrganizacaoRepository, DominioRepository, $filter, $translate, DepreciacaoRepository, | |
5 | + OrganizacaoPatrimonioRepository) { | |
4 | 6 | |
5 | 7 | $scope.setLoadingGet(true); |
6 | 8 | ... | ... |
cit-adm-materiais-web/src/main/webapp/assets/js/angular/custom/controller/TransferenciaContaContabilController.js
... | ... | @@ -66,17 +66,24 @@ citApp.controller('TransferenciaContaContabilController', ['$scope', 'Transferen |
66 | 66 | } |
67 | 67 | |
68 | 68 | TransferenciaContaContabilRepository.realizarTransferencia($scope.transferenciaContaContabil).then(function(result) { |
69 | - if (result) { | |
70 | - $scope.showAlert("success", $translate.instant('ADMINISTRACAODEMATERIAIS.MSG.TRANSFERENCIA_SUCESS')); | |
71 | - $scope.transferenciaContaContabilForm.$submitted = false; | |
72 | - angular.element('#searchTransferenciaContaContabil').scope().fetchResult(); | |
73 | - | |
74 | - $scope.resetForm(); | |
75 | - } else { | |
76 | - $scope.showAlert('error', $translate.instant('ADMINISTRACAODEMATERIAIS.MSG.TRANSFERENCIA_FAIL'), " ", false); | |
77 | - } | |
69 | + if (result.originalElement && result.originalElement.status != undefined && !result.originalElement.status && result.originalElement.mensagens) { | |
70 | + $scope.setLoading(false); | |
71 | + angular.forEach(result.originalElement.mensagens, function (mensagem) { | |
72 | + $scope.showAlert(mensagem.tipoMensagem, $translate.instant(mensagem.mensagem)); | |
73 | + }); | |
74 | + } else { | |
75 | + if (result) { | |
76 | + $scope.showAlert("success", $translate.instant('ADMINISTRACAODEMATERIAIS.MSG.TRANSFERENCIA_SUCESS')); | |
77 | + $scope.transferenciaContaContabilForm.$submitted = false; | |
78 | + angular.element('#searchTransferenciaContaContabil').scope().fetchResult(); | |
79 | + | |
80 | + $scope.resetForm(); | |
81 | + } else { | |
82 | + $scope.showAlert('error', $translate.instant('ADMINISTRACAODEMATERIAIS.MSG.TRANSFERENCIA_FAIL'), " ", false); | |
83 | + } | |
84 | + $scope.setLoading(false); | |
85 | + } | |
78 | 86 | }); |
79 | - $scope.setLoading(false); | |
80 | 87 | }else{ |
81 | 88 | //Mensagem de erro de campos obrigatorios não preenchidos |
82 | 89 | $scope.showAlert('error', $translate.instant('VALIDACAO.ALERTA_OBRIGATORIOS'), " ", false); | ... | ... |
cit-adm-materiais-web/src/main/webapp/html/contaContabil/contaContabilList.html
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | <translate>LABEL.EDITAR</translate> |
18 | 18 | </button> |
19 | 19 | |
20 | - <button title="{{$translate.instant('LABEL.REMOVER')}}" alt="{{$translate.instant('LABEL.REMOVER')}}" class="btn btn-clear" ng-click="remove(contaContabil);"> | |
20 | + <button title="{{$translate.instant('LABEL.REMOVER')}}" alt="{{$translate.instant('LABEL.REMOVER')}}" class="btn btn-clear" ng-click="remover();"> | |
21 | 21 | <i class="fa fa-times red"></i> |
22 | 22 | <translate>LABEL.REMOVER</translate> |
23 | 23 | </button> | ... | ... |