Commit cf31755739c7a1489a29f46175649fcfc8358aef
1 parent
dd1a4b77
Exists in
master
[Redmine Atendimento #4206]Alteração mascara ordem fornecimento
Showing
11 changed files
with
104 additions
and
78 deletions
Show diff stats
cit-contratos-api/src/main/java/br/com/centralit/api/dao/CronogramaExecucaoDao.java
... | ... | @@ -5,6 +5,6 @@ import br.com.centralit.framework.dao.arquitetura.CitGenericDAO; |
5 | 5 | |
6 | 6 | public interface CronogramaExecucaoDao extends CitGenericDAO { |
7 | 7 | |
8 | - CronogramaExecucao buscarUltimoRegistro(String property, Long idOrganizacao); | |
9 | - | |
8 | + CronogramaExecucao buscarUltimoRegistroAno(String property, int ano, Long idOrganizacao); | |
9 | + | |
10 | 10 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/dao/impl/CronogramaExecucaoDaoHibernate.java
... | ... | @@ -16,7 +16,7 @@ public class CronogramaExecucaoDaoHibernate extends CitGenericDAOImpl implements |
16 | 16 | } |
17 | 17 | |
18 | 18 | @Override |
19 | - public CronogramaExecucao buscarUltimoRegistro(String property, Long idOrganizacao) { | |
19 | + public CronogramaExecucao buscarUltimoRegistroAno(String property, int ano, Long idOrganizacao) { | |
20 | 20 | |
21 | 21 | Search search = new Search(); |
22 | 22 | search.addFilterNotNull(property); |
... | ... | @@ -26,5 +26,5 @@ public class CronogramaExecucaoDaoHibernate extends CitGenericDAOImpl implements |
26 | 26 | return searchUnique(search); |
27 | 27 | } |
28 | 28 | |
29 | - | |
29 | + | |
30 | 30 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/model/OrdemFornecimento.java
... | ... | @@ -61,7 +61,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
61 | 61 | * |
62 | 62 | */ |
63 | 63 | @Entity |
64 | -@Table(name="cnt_ordemfornecimento") | |
64 | +@Table(name = "cnt_ordemfornecimento") | |
65 | 65 | public class OrdemFornecimento extends PersistentObjectAuditOrganizacao { |
66 | 66 | |
67 | 67 | /** Atributo serialVersionUID. */ |
... | ... | @@ -70,26 +70,30 @@ public class OrdemFornecimento extends PersistentObjectAuditOrganizacao { |
70 | 70 | /** Atributo id. */ |
71 | 71 | @Id |
72 | 72 | @GeneratedValue(strategy = GenerationType.AUTO) |
73 | - @JsonView({ Views.GenericView.class, ViewsContrato.OrdemFornecimentoEditView.class }) | |
73 | + @JsonView({ Views.GenericView.class, | |
74 | + ViewsContrato.OrdemFornecimentoEditView.class }) | |
74 | 75 | private Long id; |
75 | 76 | |
76 | 77 | /** Atributo numOrdemFornecimento. */ |
77 | - @Column(nullable = false) | |
78 | - @JsonView({ ViewsContrato.OrdemFornecimentoListView.class, ViewsContrato.RegistroOcorrenciaEditView.class, ViewsContrato.EventoLiberacaoPagamentoView.class }) | |
79 | - private Long numOrdemFornecimento; | |
78 | + @Column(name = "numOrdemFornecimento", length = 20, nullable = false) | |
79 | + @JsonView({ ViewsContrato.OrdemFornecimentoListView.class, | |
80 | + ViewsContrato.RegistroOcorrenciaEditView.class, | |
81 | + ViewsContrato.EventoLiberacaoPagamentoView.class }) | |
82 | + private String numOrdemFornecimento; | |
80 | 83 | |
81 | 84 | /** Atributo dataEmissao. */ |
82 | 85 | @Column(nullable = false) |
83 | 86 | @Temporal(TemporalType.TIMESTAMP) |
84 | 87 | @JsonSerialize(using = JsonCalendarSimpleDateSerializer.class) |
85 | 88 | @JsonDeserialize(using = JsonCalendarSimpleDateDeserializer.class) |
86 | - @JsonView({ ViewsContrato.OrdemFornecimentoListView.class, ViewsContrato.EventoLiberacaoPagamentoView.class }) | |
89 | + @JsonView({ ViewsContrato.OrdemFornecimentoListView.class, | |
90 | + ViewsContrato.EventoLiberacaoPagamentoView.class }) | |
87 | 91 | private Calendar dataEmissao; |
88 | 92 | |
89 | 93 | /** Atributo dominioSituacao. */ |
90 | 94 | @ManyToOne(fetch = FetchType.EAGER, optional = true) |
91 | - @JsonView({ ViewsContrato.OrdemFornecimentoEditView.class }) | |
92 | - private Dominio dominioSituacao; | |
95 | + @JsonView({ ViewsContrato.OrdemFornecimentoEditView.class }) | |
96 | + private Dominio dominioSituacao; | |
93 | 97 | |
94 | 98 | /** Atributo contrato. */ |
95 | 99 | @ManyToOne(fetch = FetchType.EAGER, optional = false) |
... | ... | @@ -116,7 +120,6 @@ public class OrdemFornecimento extends PersistentObjectAuditOrganizacao { |
116 | 120 | @JsonView({ ViewsContrato.OrdemFornecimentoEditView.class }) |
117 | 121 | private Collection<OrdemFornecimentoObservacao> observacoes; |
118 | 122 | |
119 | - | |
120 | 123 | /** |
121 | 124 | * Retorna o valor do atributo <code>id</code> |
122 | 125 | * |
... | ... | @@ -127,7 +130,6 @@ public class OrdemFornecimento extends PersistentObjectAuditOrganizacao { |
127 | 130 | return id; |
128 | 131 | } |
129 | 132 | |
130 | - | |
131 | 133 | /** |
132 | 134 | * Define o valor do atributo <code>id</code>. |
133 | 135 | * |
... | ... | @@ -138,29 +140,14 @@ public class OrdemFornecimento extends PersistentObjectAuditOrganizacao { |
138 | 140 | this.id = id; |
139 | 141 | } |
140 | 142 | |
141 | - | |
142 | - /** | |
143 | - * Retorna o valor do atributo <code>numOrdemFornecimento</code> | |
144 | - * | |
145 | - * @return <code>Long</code> | |
146 | - */ | |
147 | - public Long getNumOrdemFornecimento() { | |
148 | - | |
143 | + public String getNumOrdemFornecimento() { | |
149 | 144 | return numOrdemFornecimento; |
150 | 145 | } |
151 | 146 | |
152 | - | |
153 | - /** | |
154 | - * Define o valor do atributo <code>numOrdemFornecimento</code>. | |
155 | - * | |
156 | - * @param numOrdemFornecimento | |
157 | - */ | |
158 | - public void setNumOrdemFornecimento(Long numOrdemFornecimento) { | |
159 | - | |
147 | + public void setNumOrdemFornecimento(String numOrdemFornecimento) { | |
160 | 148 | this.numOrdemFornecimento = numOrdemFornecimento; |
161 | 149 | } |
162 | 150 | |
163 | - | |
164 | 151 | /** |
165 | 152 | * Retorna o valor do atributo <code>dataEmissao</code> |
166 | 153 | * |
... | ... | @@ -171,7 +158,6 @@ public class OrdemFornecimento extends PersistentObjectAuditOrganizacao { |
171 | 158 | return dataEmissao; |
172 | 159 | } |
173 | 160 | |
174 | - | |
175 | 161 | /** |
176 | 162 | * Define o valor do atributo <code>dataEmissao</code>. |
177 | 163 | * |
... | ... | @@ -182,7 +168,6 @@ public class OrdemFornecimento extends PersistentObjectAuditOrganizacao { |
182 | 168 | this.dataEmissao = dataEmissao; |
183 | 169 | } |
184 | 170 | |
185 | - | |
186 | 171 | /** |
187 | 172 | * Retorna o valor do atributo <code>dominioSituacao</code> |
188 | 173 | * |
... | ... | @@ -193,7 +178,6 @@ public class OrdemFornecimento extends PersistentObjectAuditOrganizacao { |
193 | 178 | return dominioSituacao; |
194 | 179 | } |
195 | 180 | |
196 | - | |
197 | 181 | /** |
198 | 182 | * Define o valor do atributo <code>dominioSituacao</code>. |
199 | 183 | * |
... | ... | @@ -204,7 +188,6 @@ public class OrdemFornecimento extends PersistentObjectAuditOrganizacao { |
204 | 188 | this.dominioSituacao = dominioSituacao; |
205 | 189 | } |
206 | 190 | |
207 | - | |
208 | 191 | /** |
209 | 192 | * Retorna o valor do atributo <code>contrato</code> |
210 | 193 | * |
... | ... | @@ -215,7 +198,6 @@ public class OrdemFornecimento extends PersistentObjectAuditOrganizacao { |
215 | 198 | return contrato; |
216 | 199 | } |
217 | 200 | |
218 | - | |
219 | 201 | /** |
220 | 202 | * Define o valor do atributo <code>contrato</code>. |
221 | 203 | * |
... | ... | @@ -226,7 +208,6 @@ public class OrdemFornecimento extends PersistentObjectAuditOrganizacao { |
226 | 208 | this.contrato = contrato; |
227 | 209 | } |
228 | 210 | |
229 | - | |
230 | 211 | /** |
231 | 212 | * Retorna o valor do atributo <code>localPrestacaoServico</code> |
232 | 213 | * |
... | ... | @@ -237,7 +218,6 @@ public class OrdemFornecimento extends PersistentObjectAuditOrganizacao { |
237 | 218 | return localPrestacaoServico; |
238 | 219 | } |
239 | 220 | |
240 | - | |
241 | 221 | /** |
242 | 222 | * Define o valor do atributo <code>localPrestacaoServico</code>. |
243 | 223 | * |
... | ... | @@ -248,7 +228,6 @@ public class OrdemFornecimento extends PersistentObjectAuditOrganizacao { |
248 | 228 | this.localPrestacaoServico = localPrestacaoServico; |
249 | 229 | } |
250 | 230 | |
251 | - | |
252 | 231 | /** |
253 | 232 | * Retorna o valor do atributo <code>itensBensServicos</code> |
254 | 233 | * |
... | ... | @@ -259,18 +238,17 @@ public class OrdemFornecimento extends PersistentObjectAuditOrganizacao { |
259 | 238 | return itensBensServicos; |
260 | 239 | } |
261 | 240 | |
262 | - | |
263 | 241 | /** |
264 | 242 | * Define o valor do atributo <code>itensBensServicos</code>. |
265 | 243 | * |
266 | 244 | * @param itensBensServicos |
267 | 245 | */ |
268 | - public void setItensBensServicos(Collection<OrdemFornecimentoItem> itensBensServicos) { | |
246 | + public void setItensBensServicos( | |
247 | + Collection<OrdemFornecimentoItem> itensBensServicos) { | |
269 | 248 | |
270 | 249 | this.itensBensServicos = itensBensServicos; |
271 | 250 | } |
272 | 251 | |
273 | - | |
274 | 252 | /** |
275 | 253 | * Retorna o valor do atributo <code>documentos</code> |
276 | 254 | * |
... | ... | @@ -281,7 +259,6 @@ public class OrdemFornecimento extends PersistentObjectAuditOrganizacao { |
281 | 259 | return documentos; |
282 | 260 | } |
283 | 261 | |
284 | - | |
285 | 262 | /** |
286 | 263 | * Define o valor do atributo <code>documentos</code>. |
287 | 264 | * |
... | ... | @@ -292,7 +269,6 @@ public class OrdemFornecimento extends PersistentObjectAuditOrganizacao { |
292 | 269 | this.documentos = documentos; |
293 | 270 | } |
294 | 271 | |
295 | - | |
296 | 272 | /** |
297 | 273 | * Retorna o valor do atributo <code>observacoes</code> |
298 | 274 | * |
... | ... | @@ -303,13 +279,13 @@ public class OrdemFornecimento extends PersistentObjectAuditOrganizacao { |
303 | 279 | return observacoes; |
304 | 280 | } |
305 | 281 | |
306 | - | |
307 | 282 | /** |
308 | 283 | * Define o valor do atributo <code>observacoes</code>. |
309 | 284 | * |
310 | 285 | * @param observacoes |
311 | 286 | */ |
312 | - public void setObservacoes(Collection<OrdemFornecimentoObservacao> observacoes) { | |
287 | + public void setObservacoes( | |
288 | + Collection<OrdemFornecimentoObservacao> observacoes) { | |
313 | 289 | |
314 | 290 | this.observacoes = observacoes; |
315 | 291 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/CronogramaExecucaoServiceImpl.java
... | ... | @@ -49,6 +49,7 @@ import br.com.centralit.framework.model.Usuario; |
49 | 49 | import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; |
50 | 50 | import br.com.centralit.framework.util.UtilColecao; |
51 | 51 | import br.com.centralit.framework.util.UtilDataBase; |
52 | +import br.com.centralit.framework.util.UtilDate; | |
52 | 53 | import br.com.centralit.framework.util.UtilObjeto; |
53 | 54 | |
54 | 55 | @Service("cronogramaExecucaoService") |
... | ... | @@ -215,12 +216,14 @@ public class CronogramaExecucaoServiceImpl extends GenericServiceImpl<Cronograma |
215 | 216 | * @param entity |
216 | 217 | */ |
217 | 218 | private void configurarCodigo(CronogramaExecucao entity) { |
219 | + Usuario usuarioLogado = (Usuario) usuarioService.find(( (Usuario) SecurityContextHolder.getContext().getAuthentication().getPrincipal() ).getId()); | |
220 | + String ano = UtilDate.getAnoAtual(); | |
218 | 221 | |
219 | 222 | if (!UtilObjeto.isReferencia(entity.getOrganizacao())) { |
220 | 223 | entity.setOrganizacao(this.getUsuario().getOrganizacao()); |
221 | 224 | } |
222 | 225 | |
223 | - CronogramaExecucao ultimoRegistro = (CronogramaExecucao) cronogramaExecucaoDao.buscarUltimoRegistro("codigo", entity.getOrganizacao().getId()); | |
226 | + CronogramaExecucao ultimoRegistro = (CronogramaExecucao) cronogramaExecucaoDao.buscarUltimoAnoRegistroComOrdenadoParametrizada("codigo", ano, usuarioLogado.getOrganizacao().getId()); | |
224 | 227 | |
225 | 228 | Long sequencial = 0L; |
226 | 229 | if (UtilObjeto.isReferencia(ultimoRegistro)) { | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/NotificacaoContratoServiceImpl.java
... | ... | @@ -158,7 +158,7 @@ public class NotificacaoContratoServiceImpl extends GenericServiceImpl<Notificac |
158 | 158 | UtilDataBase.closeResources(conn, input, inputSub, baos); |
159 | 159 | } |
160 | 160 | } |
161 | - | |
161 | + | |
162 | 162 | private void montarNotificacaoContrato(NotificacaoContrato notificacaoContrato) { |
163 | 163 | this.montarDocsObsNotificacaoContrato(notificacaoContrato); |
164 | 164 | atualizaOcorrenciaComNotificacao(notificacaoContrato); |
... | ... | @@ -231,9 +231,9 @@ public class NotificacaoContratoServiceImpl extends GenericServiceImpl<Notificac |
231 | 231 | } |
232 | 232 | |
233 | 233 | private void configurarCodigo(NotificacaoContrato entitySaved) { |
234 | - | |
234 | + Usuario usuarioLogado = (Usuario) usuarioService.find(( (Usuario) SecurityContextHolder.getContext().getAuthentication().getPrincipal() ).getId()); | |
235 | 235 | String ano = UtilDate.getAnoAtual(); |
236 | - NotificacaoContrato ultimoRegistro = (NotificacaoContrato) this.notificacaoContratoDao.buscarUltimoAnoRegistroComOrdenadoParametrizada(CAMPO_BUSCA_PARAMETRIZADA_ULTIMO_REGISTRO, ano); | |
236 | + NotificacaoContrato ultimoRegistro = (NotificacaoContrato) this.notificacaoContratoDao.buscarUltimoAnoRegistroComOrdenadoParametrizada(CAMPO_BUSCA_PARAMETRIZADA_ULTIMO_REGISTRO, ano, usuarioLogado.getOrganizacao().getId()); | |
237 | 237 | Long sequencial = null; |
238 | 238 | |
239 | 239 | if (UtilObjeto.isReferencia(ultimoRegistro)) { | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/OrdemFornecimentoServiceImpl.java
... | ... | @@ -4,6 +4,7 @@ import java.util.ArrayList; |
4 | 4 | import java.util.Collection; |
5 | 5 | import java.util.List; |
6 | 6 | |
7 | +import org.apache.commons.lang.StringUtils; | |
7 | 8 | import org.springframework.beans.factory.annotation.Autowired; |
8 | 9 | import org.springframework.beans.factory.annotation.Qualifier; |
9 | 10 | import org.springframework.security.core.context.SecurityContextHolder; |
... | ... | @@ -26,6 +27,7 @@ import br.com.centralit.api.service.UsuarioService; |
26 | 27 | import br.com.centralit.framework.model.Usuario; |
27 | 28 | import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; |
28 | 29 | import br.com.centralit.framework.util.UtilColecao; |
30 | +import br.com.centralit.framework.util.UtilDate; | |
29 | 31 | import br.com.centralit.framework.util.UtilObjeto; |
30 | 32 | |
31 | 33 | /** |
... | ... | @@ -54,22 +56,22 @@ public class OrdemFornecimentoServiceImpl extends GenericServiceImpl<OrdemFornec |
54 | 56 | |
55 | 57 | /** Atributo ordemFornecimentoDao. */ |
56 | 58 | private OrdemFornecimentoDao ordemFornecimentoDao; |
57 | - | |
59 | + | |
58 | 60 | @Autowired |
59 | 61 | private DominioService dominioService; |
60 | - | |
62 | + | |
61 | 63 | @Autowired |
62 | 64 | private ContratoService contratoService; |
63 | - | |
65 | + | |
64 | 66 | @Autowired |
65 | 67 | private ContratoItemService contratoItemService; |
66 | - | |
68 | + | |
67 | 69 | @Autowired |
68 | 70 | private UsuarioService usuarioService; |
69 | - | |
71 | + | |
70 | 72 | @Autowired |
71 | 73 | private ParceiroService parceiroService; |
72 | - | |
74 | + | |
73 | 75 | @Autowired |
74 | 76 | private AnexoService anexoService; |
75 | 77 | |
... | ... | @@ -84,7 +86,7 @@ public class OrdemFornecimentoServiceImpl extends GenericServiceImpl<OrdemFornec |
84 | 86 | this.ordemFornecimentoDao = ordemFornecimentoDao; |
85 | 87 | this.validator = validator; |
86 | 88 | } |
87 | - | |
89 | + | |
88 | 90 | /** |
89 | 91 | * Método responsável por salvar todas as informações informadas na tela de cadastro |
90 | 92 | * montar objeto da ordem de fornecimento removendo possíveis problemas de transient |
... | ... | @@ -96,15 +98,18 @@ public class OrdemFornecimentoServiceImpl extends GenericServiceImpl<OrdemFornec |
96 | 98 | */ |
97 | 99 | @Override |
98 | 100 | public OrdemFornecimento save(OrdemFornecimento ordemFornecimento) { |
101 | + | |
102 | + configurarCodigo(ordemFornecimento); | |
103 | + | |
99 | 104 | // monta objeto ordemFornecimento com todas as suas listas e objetos transients |
100 | 105 | this.montarObjetoOrdemFornecimento(ordemFornecimento); |
101 | - | |
106 | + | |
102 | 107 | // realiza a validação do objeto com a classe OrdemFornecimentoValidator.java |
103 | 108 | this.validarEntidade(ordemFornecimento, this.validator); |
104 | - | |
109 | + | |
105 | 110 | return super.save(ordemFornecimento); |
106 | 111 | } |
107 | - | |
112 | + | |
108 | 113 | /** |
109 | 114 | * Método responsável por atualizar todas as informações informadas na tela de cadastro |
110 | 115 | * montar objeto da ordem de fornecimento removendo possíveis problemas de transient |
... | ... | @@ -117,15 +122,19 @@ public class OrdemFornecimentoServiceImpl extends GenericServiceImpl<OrdemFornec |
117 | 122 | @Override |
118 | 123 | public OrdemFornecimento merge(OrdemFornecimento ordemFornecimento) { |
119 | 124 | |
125 | + if (!UtilObjeto.isReferencia(ordemFornecimento.getNumOrdemFornecimento())) { | |
126 | + configurarCodigo(ordemFornecimento); | |
127 | + } | |
128 | + | |
120 | 129 | // monta objeto ordemFornecimento com todas as suas listas e objetos transients |
121 | 130 | this.montarObjetoOrdemFornecimento(ordemFornecimento); |
122 | - | |
131 | + | |
123 | 132 | // realiza a validação do objeto com a classe OrdemFornecimentoValidator.java |
124 | 133 | this.validarEntidade(ordemFornecimento, this.validator); |
125 | 134 | |
126 | 135 | return super.save(ordemFornecimento); |
127 | 136 | } |
128 | - | |
137 | + | |
129 | 138 | /** |
130 | 139 | * Método responsável por resolver os transients da ordem de fornecimento |
131 | 140 | * |
... | ... | @@ -138,16 +147,16 @@ public class OrdemFornecimentoServiceImpl extends GenericServiceImpl<OrdemFornec |
138 | 147 | if (UtilObjeto.isReferencia(ordemFornecimento.getDominioSituacao())) { |
139 | 148 | ordemFornecimento.setDominioSituacao(this.dominioService.find(ordemFornecimento.getDominioSituacao().getId())); |
140 | 149 | } |
141 | - | |
150 | + | |
142 | 151 | if (UtilObjeto.isReferencia(ordemFornecimento.getContrato())) { |
143 | 152 | ordemFornecimento.setContrato(this.contratoService.find(ordemFornecimento.getContrato().getId())); |
144 | 153 | } |
145 | - | |
154 | + | |
146 | 155 | for (OrdemFornecimentoItem ordemFornItem : ordemFornecimento.getItensBensServicos()) { |
147 | 156 | ordemFornItem.setItemBemServico(this.contratoItemService.find(ordemFornItem.getItemBemServico().getId())); |
148 | 157 | ordemFornItem.setOrdemFornecimento(ordemFornecimento); |
149 | 158 | } |
150 | - | |
159 | + | |
151 | 160 | // cria vinculo da ordem de fornecimento com as Observacoes |
152 | 161 | if (!UtilColecao.isVazio(ordemFornecimento.getObservacoes())) { |
153 | 162 | for (OrdemFornecimentoObservacao ordemFornecimentoObservacao : ordemFornecimento.getObservacoes()) { |
... | ... | @@ -194,4 +203,25 @@ public class OrdemFornecimentoServiceImpl extends GenericServiceImpl<OrdemFornec |
194 | 203 | return this.ordemFornecimentoDao.findOrdemFornecimentoPorContrato(idContrato); |
195 | 204 | } |
196 | 205 | |
206 | + private void configurarCodigo(OrdemFornecimento entity) { | |
207 | + Usuario usuarioLogado = (Usuario) usuarioService.find(( (Usuario) SecurityContextHolder.getContext().getAuthentication().getPrincipal() ).getId()); | |
208 | + String ano = UtilDate.getAnoAtual(); | |
209 | + | |
210 | + if (!UtilObjeto.isReferencia(entity.getOrganizacao())) { | |
211 | + entity.setOrganizacao(this.getUsuario().getOrganizacao()); | |
212 | + } | |
213 | + | |
214 | + OrdemFornecimento ultimoRegistro = (OrdemFornecimento) ordemFornecimentoDao.buscarUltimoAnoRegistroComOrdenadoParametrizada("numOrdemFornecimento", ano, usuarioLogado.getOrganizacao().getId()); | |
215 | + | |
216 | + Long sequencial = 0L; | |
217 | + if (UtilObjeto.isReferencia(ultimoRegistro)) { | |
218 | + sequencial = ultimoRegistro.getNumOrdemFornecimento().replace(ano, "") == null ? null : Long.parseLong(ultimoRegistro.getNumOrdemFornecimento().replace(ano, "") ); | |
219 | + }else{ | |
220 | + sequencial = 0l; | |
221 | + } | |
222 | + | |
223 | + entity.setNumOrdemFornecimento(StringUtils.leftPad((Long.valueOf(sequencial + 1)).toString(), 5, "0") + ano); | |
224 | + | |
225 | + } | |
226 | + | |
197 | 227 | } | ... | ... |
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/TermoReferenciaServiceImpl.java
... | ... | @@ -256,6 +256,7 @@ public class TermoReferenciaServiceImpl extends GenericServiceImpl<TermoReferenc |
256 | 256 | |
257 | 257 | private void configurarCodigo(TermoReferencia entity) { |
258 | 258 | |
259 | + Usuario usuarioLogado = (Usuario) usuarioService.find(( (Usuario) SecurityContextHolder.getContext().getAuthentication().getPrincipal() ).getId()); | |
259 | 260 | if (!UtilObjeto.isReferencia(entity.getOrganizacao())) { |
260 | 261 | entity.setOrganizacao(this.getUsuario().getOrganizacao()); |
261 | 262 | } |
... | ... | @@ -263,7 +264,7 @@ public class TermoReferenciaServiceImpl extends GenericServiceImpl<TermoReferenc |
263 | 264 | Integer ano = Calendar.getInstance().get(Calendar.YEAR); |
264 | 265 | |
265 | 266 | TermoReferencia ultimoRegistro = |
266 | - (TermoReferencia) termoReferenciaDao.buscarUltimoAnoRegistroComOrdenadoParametrizada("codigo", ano.toString()); | |
267 | + (TermoReferencia) termoReferenciaDao.buscarUltimoAnoRegistroComOrdenadoParametrizada("codigo", ano.toString(), usuarioLogado.getOrganizacao().getId()); | |
267 | 268 | |
268 | 269 | Long sequencial = null; |
269 | 270 | if (ultimoRegistro != null) { | ... | ... |
cit-contratos-api/src/main/resources/script-bd/v1.0.0-alpha10/01-cit-contratos-1.0.0-ALFA-10-postgres.sql
... | ... | @@ -50,5 +50,21 @@ BEGIN |
50 | 50 | END$$; |
51 | 51 | |
52 | 52 | |
53 | +ALTER TABLE cnt_ordemfornecimento ALTER COLUMN numordemfornecimento TYPE VARCHAR(20); | |
54 | + | |
55 | +DO $$ | |
56 | +DECLARE | |
57 | + r RECORD; | |
58 | +BEGIN | |
59 | + FOR r IN | |
60 | + SELECT | |
61 | + lpad(CAST(concat(CAST(row_number() over() AS VARCHAR), CAST(date_part('Year', (SELECT CURRENT_TIMESTAMP)) AS VARCHAR)) AS VARCHAR),9,'0') AS SEQUENCIALANO, ID as ID | |
62 | + FROM cnt_ordemfornecimento ORDER BY ID | |
63 | + LOOP | |
64 | + UPDATE cnt_ordemfornecimento SET numordemfornecimento = r.SEQUENCIALANO WHERE ID = r.ID; | |
65 | + END LOOP; | |
66 | +END$$; | |
67 | + | |
68 | + | |
53 | 69 | -- ERICK FIM 31/03/2016 |
54 | 70 | ... | ... |
cit-contratos-web/src/main/resources/reports/ordemFornecimento.jrxml
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="ordemFornecimento" pageWidth="554" pageHeight="802" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="554" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="2a9bde7e-349d-4f0b-b96c-98310606be6f"> |
3 | 3 | <property name="ireport.zoom" value="1.5"/> |
4 | 4 | <property name="ireport.x" value="0"/> |
5 | - <property name="ireport.y" value="33"/> | |
5 | + <property name="ireport.y" value="0"/> | |
6 | 6 | <style name="table"> |
7 | 7 | <box> |
8 | 8 | <pen lineWidth="1.0" lineColor="#000000"/> |
... | ... | @@ -75,7 +75,7 @@ |
75 | 75 | LEFT JOIN pessoa pesPreposto ON pesPreposto.id = parPreposto.pessoa_id |
76 | 76 | WHERE ordemf.id = $P{ORDEM_FORNECIMENTO_ID};]]> |
77 | 77 | </queryString> |
78 | - <field name="numordemfornecimento" class="java.lang.Long"/> | |
78 | + <field name="numordemfornecimento" class="java.lang.String"/> | |
79 | 79 | <field name="dataemissao" class="java.sql.Timestamp"/> |
80 | 80 | <field name="situacao" class="java.lang.String"/> |
81 | 81 | <field name="numanocontrato" class="java.lang.String"/> |
... | ... | @@ -129,7 +129,7 @@ |
129 | 129 | <rightPen lineWidth="1.0"/> |
130 | 130 | </box> |
131 | 131 | <textElement textAlignment="Left" verticalAlignment="Middle"/> |
132 | - <textFieldExpression><![CDATA[$F{numordemfornecimento}]]></textFieldExpression> | |
132 | + <textFieldExpression><![CDATA[$F{numordemfornecimento}.substring(0,5) + "/" + $F{numordemfornecimento}.substring(5,9)]]></textFieldExpression> | |
133 | 133 | </textField> |
134 | 134 | </frame> |
135 | 135 | <frame> | ... | ... |
cit-contratos-web/src/main/webapp/assets/js/angular/custom/controller/OrdemFornecimentoListController.js
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | |
3 | 3 | citApp.controller('OrdemFornecimentoListController', ['$scope', 'OrdemFornecimentoRepository', '$translate', 'DominioRepository', |
4 | 4 | function OrdemFornecimentoListController($scope, OrdemFornecimentoRepository, $translate, DominioRepository) { |
5 | - | |
5 | + | |
6 | 6 | $scope.resetForm = function(){ |
7 | 7 | angular.element("#editOrdemFornecimento").scope().resetForm(); |
8 | 8 | }; |
... | ... | @@ -12,7 +12,7 @@ citApp.controller('OrdemFornecimentoListController', ['$scope', 'OrdemFornecimen |
12 | 12 | }; |
13 | 13 | |
14 | 14 | $scope.headers = [ |
15 | - { title : $translate.instant('LABEL.NUM_ORDEM_FORNECIMENTO'), value : 'numOrdemFornecimento' }, | |
15 | + { title : $translate.instant('LABEL.NUM_ORDEM_FORNECIMENTO'), value : 'numOrdemFornecimento', mask : [new RegExp(/(\d{3})(\d{1,4})$/), '$1/$2'] }, | |
16 | 16 | { title : $translate.instant('LABEL.DATA_EMISSAO'), value : 'dataEmissao', filter : 'dateBR' }, |
17 | 17 | { title : $translate.instant('LABEL.SITUACAO'), value : 'dominioSituacao.descricao' }, |
18 | 18 | { title : $translate.instant('LABEL.NUMERO_ANO_CONTRATO'), value : 'contrato.numeroAnoContrato', filter : 'maskContrato' }]; |
... | ... | @@ -29,11 +29,11 @@ citApp.controller('OrdemFornecimentoListController', ['$scope', 'OrdemFornecimen |
29 | 29 | { type : 'string', field : 'dominioSituacao.descricao', listaDominio : [] } , |
30 | 30 | { type : 'numeric-range', field : 'contrato.numeroAnoContrato' }] |
31 | 31 | }; |
32 | - | |
32 | + | |
33 | 33 | DominioRepository.findAllDominio('tipoSituacaoOrdemFornecimento').then(function(result) { |
34 | 34 | $scope.filterCriteria.filters[2].listaDominio = result; |
35 | 35 | }); |
36 | - | |
36 | + | |
37 | 37 | // abrir uma OrdemFornecimento para visualizar ou editar dependendo do parametro edit |
38 | 38 | $scope.abrirOrdemFornecimento = function(edit){ |
39 | 39 | // recupera a OrdemFornecimento selecionada |
... | ... | @@ -56,7 +56,7 @@ citApp.controller('OrdemFornecimentoListController', ['$scope', 'OrdemFornecimen |
56 | 56 | $scope.cadastrarNovaOrdemFornecimento = function(){ |
57 | 57 | angular.element("#editOrdemFornecimento").scope().resetForm(); |
58 | 58 | }; |
59 | - | |
59 | + | |
60 | 60 | //INICIO DE METODOS REFERENTES AOS RELATORIOS |
61 | 61 | |
62 | 62 | $scope.gerarRelatorioOrdemFornecimento = function() { |
... | ... | @@ -67,9 +67,9 @@ citApp.controller('OrdemFornecimentoListController', ['$scope', 'OrdemFornecimen |
67 | 67 | $scope.url = '/cit-contratos-web/rest/ordemFornecimento/gerarOrdemFornecimento?idOrdemFornecimento='+ $scope.ordemFornecimentoChecked.id; |
68 | 68 | $scope.visualizarRelatorio($scope.url, $translate.instant("LABEL.TITULO_ORDEM_FORNECIMENTO")); |
69 | 69 | } |
70 | - | |
70 | + | |
71 | 71 | }; |
72 | - | |
72 | + | |
73 | 73 | }]); |
74 | 74 | |
75 | 75 | ... | ... |
cit-contratos-web/src/main/webapp/html/ordemFornecimento/ordemFornecimentoEdit.html
... | ... | @@ -59,8 +59,8 @@ |
59 | 59 | |
60 | 60 | <div class="row"> |
61 | 61 | <div class="col-sm-3"> |
62 | - <label-input-number ng-id="ordemFornecimento.numOrdemFornecimento" ng-custom-maxlength="10" ng-label="LABEL.NUM_ORDEM_FORNECIMENTO" | |
63 | - ng-disabled="!edit || ordemFornecimento.id" ng-obrigatorio="edit" ng-model="ordemFornecimento.numOrdemFornecimento" form="ordemFornecimentoForm"/> | |
62 | + <label-input ng-id="ordemFornecimento.numOrdemFornecimento" ng-mask="99999/9999" ng-label="LABEL.NUM_ORDEM_FORNECIMENTO" | |
63 | + ng-disabled="true" ng-obrigatorio="false" ng-model="ordemFornecimento.numOrdemFornecimento" form="ordemFornecimentoForm"/> | |
64 | 64 | </div><!-- .col-sm-4 --> |
65 | 65 | <div class="col-sm-3"> |
66 | 66 | <label-input-data ng-id="ordemFornecimento.dataEmissao" ng-label="LABEL.DATA_EMISSAO" ng-model="ordemFornecimento.dataEmissao" | ... | ... |