Commit 8a7d1f524af5b89117375e1fbc700485860ec32f
1 parent
cc108c74
Exists in
master
redmine #4169 Implementada funcionalidade que verifica se houve alguma alteracao…
… na entrada, caso tenha ocorrido alguma alteracao e o usuario nao tenha concluido a entrada, a mesma passa a ser considerada como passivel de conclusao. Removida a mensagem que informa ao usuario o sucesso da persistencia de cada passo na entrada de bens.
Showing
6 changed files
with
201 additions
and
34 deletions
Show diff stats
citgrp-patrimonio-api/src/main/java/br/com/centralit/api/service/EntradaService.java
... | ... | @@ -155,4 +155,22 @@ public interface EntradaService extends GenericService<EntradaPatrimonio, Long> |
155 | 155 | */ |
156 | 156 | public boolean verificaExistenciaBensPatrimoniaisEntrada(Long idEntrada); |
157 | 157 | |
158 | + /** | |
159 | + * <p> | |
160 | + * <b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a> | |
161 | + * </p> | |
162 | + * | |
163 | + * <p> | |
164 | + * <b>Regra(s) de negocio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a> | |
165 | + * </p> | |
166 | + * | |
167 | + * Metodo responsavel por verificar se entrada contem bens patrimoniais temporarios | |
168 | + * | |
169 | + * @author thiago.coimbra | |
170 | + * | |
171 | + * @param idEntrada | |
172 | + * | |
173 | + */ | |
174 | + public boolean verificaExistenciaBensPatrimoniaisTemporariosEntrada(Long idEntrada); | |
175 | + | |
158 | 176 | } | ... | ... |
citgrp-patrimonio-api/src/main/java/br/com/centralit/api/service/impl/EntradaServiceImpl.java
... | ... | @@ -643,5 +643,27 @@ public class EntradaServiceImpl extends GenericServiceImpl<EntradaPatrimonio, Lo |
643 | 643 | } |
644 | 644 | } |
645 | 645 | return true; |
646 | + } | |
647 | + | |
648 | + @Override | |
649 | + public boolean verificaExistenciaBensPatrimoniaisTemporariosEntrada(Long idEntrada) { | |
650 | + | |
651 | + EntradaPatrimonio entradaPatrimonio = find(idEntrada); | |
652 | + List<BemPatrimonialTemporario> bensPatrimoniaisTemporarios; | |
653 | + | |
654 | + if(entradaPatrimonio.getEntradasIten() != null) { | |
655 | + | |
656 | + for (EntradaPatrimonioItem entradaPatrimonioItem : entradaPatrimonio.getEntradasIten()) { | |
657 | + | |
658 | + bensPatrimoniaisTemporarios = bemPatrimonialTemporarioService.findAllByEntradaItemId(entradaPatrimonioItem.getId()); | |
659 | + | |
660 | + if(bensPatrimoniaisTemporarios != null && !bensPatrimoniaisTemporarios.isEmpty()) { | |
661 | + return true; | |
662 | + } | |
663 | + | |
664 | + } | |
665 | + } | |
666 | + | |
667 | + return false; | |
646 | 668 | } |
647 | 669 | } | ... | ... |
citgrp-patrimonio-web/src/main/java/br/com/centralit/controller/EntradaController.java
... | ... | @@ -179,5 +179,11 @@ public class EntradaController extends GenericController<EntradaPatrimonio> { |
179 | 179 | return entradaService.verificaExistenciaBensPatrimoniaisEntrada(idEntrada); |
180 | 180 | } |
181 | 181 | |
182 | + @RequestMapping(method = RequestMethod.GET, value = "/verificaExistenciaBemPatrimonialTemporarioEntrada", produces = "application/json") | |
183 | + @ResponseBody | |
184 | + public boolean verificaExistenciaBemPatrimonialTemporario(@RequestParam(value = "idEntrada", required = false) Long idEntrada) { | |
185 | + return entradaService.verificaExistenciaBensPatrimoniaisTemporariosEntrada(idEntrada); | |
186 | + } | |
187 | + | |
182 | 188 | |
183 | 189 | } | ... | ... |
citgrp-patrimonio-web/src/main/webapp/assets/js/angular/custom/controller/EntradaController.js
... | ... | @@ -47,7 +47,9 @@ citApp.controller('EntradaController', ['$scope', '$timeout', 'FileUploader', 'E |
47 | 47 | $scope.entrada = {}; |
48 | 48 | |
49 | 49 | $scope.itensDeEntrada = []; |
50 | - | |
50 | + | |
51 | + $scope.entradaOriginal = {}; | |
52 | + | |
51 | 53 | // recupera data atual |
52 | 54 | $scope.today = new Date(); |
53 | 55 | |
... | ... | @@ -67,9 +69,12 @@ citApp.controller('EntradaController', ['$scope', '$timeout', 'FileUploader', 'E |
67 | 69 | EntradaRepository.get(idEntrada).then(function(result) { |
68 | 70 | |
69 | 71 | $scope.entrada = result.originalElement; |
70 | - | |
72 | + | |
73 | + $scope.entradaOriginal = angular.copy($scope.entrada); | |
74 | + | |
71 | 75 | if ($scope.entrada.fornecedor) { |
72 | 76 | $scope.entrada.fornecedor['pessoa.nome'] = $scope.entrada.fornecedor.pessoa.nome; |
77 | + $scope.entradaOriginal.fornecedor['pessoa.nome'] = $scope.entrada.fornecedor.pessoa.nome; | |
73 | 78 | } |
74 | 79 | |
75 | 80 | $scope.edit = edit; |
... | ... | @@ -1006,12 +1011,121 @@ citApp.controller('EntradaController', ['$scope', '$timeout', 'FileUploader', 'E |
1006 | 1011 | |
1007 | 1012 | $scope.countChecked(); |
1008 | 1013 | }; |
1014 | + | |
1015 | + var getClass = function(val) { | |
1016 | + return Object.prototype.toString.call(val) | |
1017 | + .match(/^\[object\s(.*)\]$/)[1]; | |
1018 | + }; | |
1019 | + | |
1020 | + //Defines the type of the value, extended typeof | |
1021 | + var whatis = function(val) { | |
1022 | + | |
1023 | + if (val === undefined) | |
1024 | + return 'undefined'; | |
1025 | + if (val === null) | |
1026 | + return 'null'; | |
1027 | + | |
1028 | + var type = typeof val; | |
1029 | + | |
1030 | + if (type === 'object') | |
1031 | + type = getClass(val).toLowerCase(); | |
1032 | + | |
1033 | + if (type === 'number') { | |
1034 | + if (val.toString().indexOf('.') > 0) | |
1035 | + return 'float'; | |
1036 | + else | |
1037 | + return 'integer'; | |
1038 | + } | |
1039 | + | |
1040 | + return type; | |
1041 | + }; | |
1009 | 1042 | |
1043 | + var compareObjects = function(a, b) { | |
1044 | + if (a === b) | |
1045 | + return true; | |
1046 | + for (var i in a) { | |
1047 | + if((i !== 'dataEdicao') && (i !== 'version')){ | |
1048 | + if (b.hasOwnProperty(i)) { | |
1049 | + if (!equal(a[i],b[i])) return false; | |
1050 | + } else { | |
1051 | + return false; | |
1052 | + } | |
1053 | + } | |
1054 | + } | |
1055 | + | |
1056 | + for (var i in b) { | |
1057 | + if((i !== 'dataEdicao') && (i !== 'version')){ | |
1058 | + if (!a.hasOwnProperty(i)) { | |
1059 | + return false; | |
1060 | + } | |
1061 | + } | |
1062 | + } | |
1063 | + | |
1064 | + return true; | |
1065 | + }; | |
1066 | + | |
1067 | + var compareArrays = function(a, b) { | |
1068 | + if (a === b) | |
1069 | + return true; | |
1070 | + if (a.length !== b.length) | |
1071 | + return false; | |
1072 | + for (var i = 0; i < a.length; i++){ | |
1073 | + if(!equal(a[i], b[i])) return false; | |
1074 | + }; | |
1075 | + return true; | |
1076 | + }; | |
1077 | + | |
1078 | + var _equal = {}; | |
1079 | + _equal.array = compareArrays; | |
1080 | + _equal.object = compareObjects; | |
1081 | + _equal.date = function(a, b) { | |
1082 | + return a.getTime() === b.getTime(); | |
1083 | + }; | |
1084 | + _equal.regexp = function(a, b) { | |
1085 | + return a.toString() === b.toString(); | |
1086 | + }; | |
1087 | + //uncoment to support function as string compare | |
1088 | + //_equal.fucntion = _equal.regexp; | |
1089 | + | |
1090 | + | |
1091 | + | |
1092 | + /* | |
1093 | + * Are two values equal, deep compare for objects and arrays. | |
1094 | + * @param a {any} | |
1095 | + * @param b {any} | |
1096 | + * @return {boolean} Are equal? | |
1097 | + */ | |
1098 | + var equal = function(a, b) { | |
1099 | + if (a !== b) { | |
1100 | + var atype = whatis(a), btype = whatis(b); | |
1101 | + | |
1102 | + if (atype === btype) | |
1103 | + return _equal.hasOwnProperty(atype) ? _equal[atype](a, b) : a==b; | |
1104 | + | |
1105 | + return false; | |
1106 | + } | |
1107 | + | |
1108 | + return true; | |
1109 | + }; | |
1110 | + | |
1111 | + | |
1112 | + function verificaAlteracaoAtributosEntrada() { | |
1113 | + var deferred = $q.defer(); | |
1114 | + EntradaRepository.verificaExistenciaBemPatrimonialTemporarioEntrada($scope.entrada.id).then(function(result){ | |
1115 | + if(!equal($scope.entrada, $scope.entradaOriginal) || result) { | |
1116 | + $scope.entrada.isEntradaConcluida = false; | |
1117 | + $scope.entradaOriginal.isEntradaConcluida = false; | |
1118 | + } | |
1119 | + return deferred.resolve(); | |
1120 | + }); | |
1121 | + return deferred.promise; | |
1122 | + }; | |
1123 | + | |
1010 | 1124 | //Salva apenas os dados básicos da Entrada (1º passo) |
1011 | 1125 | $scope.saveOrUpdateEntrada = function() { |
1012 | 1126 | // atributo para visualizar os itens obrigatorios na tela |
1013 | 1127 | $scope.dadosEntradaForm.$submitted = true; |
1014 | - | |
1128 | + | |
1015 | 1129 | // verifica formulario valido |
1016 | 1130 | if ($scope.dadosEntradaForm.$valid) { |
1017 | 1131 | |
... | ... | @@ -1020,40 +1134,40 @@ citApp.controller('EntradaController', ['$scope', '$timeout', 'FileUploader', 'E |
1020 | 1134 | var entradaTemp = { |
1021 | 1135 | documentos: [] |
1022 | 1136 | }; |
1137 | + | |
1138 | + verificaAlteracaoAtributosEntrada().then(function() { | |
1139 | + // preencher lista de documentos temporarios para verificacao dos anexos. verificar qual anexo e de qual documento pelo numero do documento | |
1140 | + angular.forEach($scope.entrada.documentos, function(documento, key) { | |
1141 | + if (documento.uploadsDocumento) { | |
1142 | + entradaTemp.documentos.push({ | |
1143 | + uploadsDocumento: clone(documento.uploadsDocumento), | |
1144 | + numero: clone(documento.numero) | |
1145 | + }); | |
1146 | + // deleta esse atributo por causa de um erro de ciclo no json | |
1147 | + delete documento.uploadsDocumento; | |
1148 | + } | |
1149 | + }); | |
1023 | 1150 | |
1024 | - // preencher lista de documentos temporarios para verificacao dos anexos. verificar qual anexo e de qual documento pelo numero do documento | |
1025 | - angular.forEach($scope.entrada.documentos, function(documento, key) { | |
1026 | - if (documento.uploadsDocumento) { | |
1027 | - entradaTemp.documentos.push({ | |
1028 | - uploadsDocumento: clone(documento.uploadsDocumento), | |
1029 | - numero: clone(documento.numero) | |
1030 | - }); | |
1031 | - // deleta esse atributo por causa de um erro de ciclo no json | |
1032 | - delete documento.uploadsDocumento; | |
1033 | - } | |
1034 | - }); | |
1035 | - | |
1036 | - EntradaRepository.save($scope.entrada).then(function(result) { | |
1037 | - | |
1038 | - $scope.entrada = result.originalElement; | |
1151 | + EntradaRepository.save($scope.entrada).then(function(result) { | |
1039 | 1152 | |
1040 | - if ($scope.entrada.fornecedor) { | |
1041 | - $scope.entrada.fornecedor['pessoa.nome'] = $scope.entrada.fornecedor.pessoa.nome; | |
1042 | - } | |
1153 | + $scope.entrada = result.originalElement; | |
1043 | 1154 | |
1044 | - $scope.setLoading(false); | |
1155 | + if ($scope.entrada.fornecedor) { | |
1156 | + $scope.entrada.fornecedor['pessoa.nome'] = $scope.entrada.fornecedor.pessoa.nome; | |
1157 | + } | |
1045 | 1158 | |
1046 | - $scope.showAlert("success", $translate.instant("PATRIMONIO.MSG.SUCESSO_ENTRADA")); | |
1159 | + $scope.setLoading(false); | |
1047 | 1160 | |
1048 | - // depois de salvar a baixa ja tendo uma referencia do id da baixa, esse metodo ira salvar os documentos se existir | |
1049 | - salvarListaDocumentos(entradaTemp); | |
1161 | + // depois de salvar a baixa ja tendo uma referencia do id da baixa, esse metodo ira salvar os documentos se existir | |
1162 | + salvarListaDocumentos(entradaTemp); | |
1050 | 1163 | |
1051 | - EntradaItemRepository.findAllByEntrada($scope.entrada.id).then(function(result) { | |
1052 | - $scope.itensDeEntrada = []; | |
1053 | - for (var i = 0; i < result.length; i++) { | |
1054 | - $scope.itensDeEntrada.push(result[i].originalElement); | |
1055 | - } | |
1056 | - $scope.calcularValorTotal(); | |
1164 | + EntradaItemRepository.findAllByEntrada($scope.entrada.id).then(function(result) { | |
1165 | + $scope.itensDeEntrada = []; | |
1166 | + for (var i = 0; i < result.length; i++) { | |
1167 | + $scope.itensDeEntrada.push(result[i].originalElement); | |
1168 | + } | |
1169 | + $scope.calcularValorTotal(); | |
1170 | + }); | |
1057 | 1171 | }); |
1058 | 1172 | }); |
1059 | 1173 | |
... | ... | @@ -1134,6 +1248,10 @@ citApp.controller('EntradaController', ['$scope', '$timeout', 'FileUploader', 'E |
1134 | 1248 | }; |
1135 | 1249 | |
1136 | 1250 | $scope.saveOrUpdateContabilizar = function(contabilizar) { |
1251 | + | |
1252 | + $scope.entrada.isEntradaConcluida = true; | |
1253 | + $scope.entradaOriginal.isEntradaConcluida = true; | |
1254 | + | |
1137 | 1255 | if ($scope.step == 2 && $scope.entradaItemSelect.bensPatrimoniaisMaterial && $scope.entradaItemSelect.bensPatrimoniaisMaterial.length > 0 && $scope.editBens) { |
1138 | 1256 | var listaBensTemp = angular.copy($scope.entradaItemSelect.bensPatrimoniaisMaterial); |
1139 | 1257 | var listaSalvar = []; |
... | ... | @@ -1898,7 +2016,7 @@ citApp.controller('EntradaController', ['$scope', '$timeout', 'FileUploader', 'E |
1898 | 2016 | $scope.handlePrevious = function() { |
1899 | 2017 | |
1900 | 2018 | $scope.setLoadingGet(true); |
1901 | - | |
2019 | + | |
1902 | 2020 | $scope.step -= ($scope.isFirstStep()) ? 0 : 1; |
1903 | 2021 | |
1904 | 2022 | if ($scope.step == 0) { | ... | ... |
citgrp-patrimonio-web/src/main/webapp/assets/js/angular/custom/controller/EntradaListController.js
... | ... | @@ -39,7 +39,7 @@ citApp.controller('EntradaListController', ['$scope', 'EntradaRepository', '$tra |
39 | 39 | dir : 'asc', |
40 | 40 | sort : 'id', |
41 | 41 | limit : 10, |
42 | - fields: ['id', 'codigo', 'dominioTipoEntrada.descricao', 'dominioTipoRecebimento.descricao', 'fornecedor.pessoa.nome', 'dataContabil'], | |
42 | + fields: ['id', 'codigo', 'dominioTipoEntrada.descricao', 'dominioTipoRecebimento.descricao', 'fornecedor.pessoa.nome', 'dataContabil', 'isEntradaConcluida'], | |
43 | 43 | filters : [{type: 'numeric-range', field: 'codigo'}, |
44 | 44 | {type: 'string', field: 'dominioTipoEntrada.descricao', listaDominio : []}, |
45 | 45 | {type: 'string', field: 'dominioTipoRecebimento.descricao', listaDominio : []}, | ... | ... |
citgrp-patrimonio-web/src/main/webapp/assets/js/angular/custom/repository/EntradaRepository.js
... | ... | @@ -37,7 +37,10 @@ citApp.factory('EntradaRepository', ['RestangularPatrimonio', 'AbstractRepositor |
37 | 37 | this.validaExistenciaBemMaterialEntrada = function(idEntrada) { |
38 | 38 | return restangularPatrimonio.one(this.route + "/validaExistenciaBemMaterialEntrada").get({"idEntrada" : idEntrada}).then(); |
39 | 39 | }; |
40 | - | |
40 | + | |
41 | + this.verificaExistenciaBemPatrimonialTemporarioEntrada = function(idEntrada) { | |
42 | + return restangularPatrimonio.one(this.route + "/verificaExistenciaBemPatrimonialTemporarioEntrada").get({"idEntrada" : idEntrada}).then(); | |
43 | + }; | |
41 | 44 | } |
42 | 45 | |
43 | 46 | AbstractRepository.extend(EntradaRepository); | ... | ... |