Commit 7c5b2197a06dd17a2bdf6b385977e685d1d328d1
Exists in
master
Merge branch 'adm-1.15.0' into tarefa-3943
Showing
31 changed files
with
693 additions
and
247 deletions
Show diff stats
cit-almoxarifado-api/src/main/java/br/com/centralit/api/dao/EnderecoEstoqueDao.java
... | ... | @@ -7,4 +7,6 @@ import br.com.centralit.framework.dao.arquitetura.CitGenericDAO; |
7 | 7 | |
8 | 8 | public interface EnderecoEstoqueDao extends CitGenericDAO { |
9 | 9 | |
10 | - List<EnderecoEstoque> enderecoEstoqueSuperiorVinculado(Long idEnderecoEstoque);} | |
10 | + List<EnderecoEstoque> enderecoEstoqueSuperiorVinculado(Long idEnderecoEstoque); | |
11 | + | |
12 | + List<EnderecoEstoque> listarEnderecosEstoquePorAlmoxarifado(String value, Long idAlmoxarifado);} | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/dao/LocalEstoqueDao.java
... | ... | @@ -1,18 +0,0 @@ |
1 | -package br.com.centralit.api.dao; | |
2 | - | |
3 | -import br.com.centralit.api.model.EstruturaOrganizacional; | |
4 | -import br.com.centralit.api.model.MaterialLocalEstoque; | |
5 | -import br.com.centralit.framework.dao.arquitetura.CitGenericDAO; | |
6 | - | |
7 | -public interface LocalEstoqueDao extends CitGenericDAO { | |
8 | - | |
9 | - /** | |
10 | - * Método responsável por | |
11 | - * | |
12 | - * @author wilker.machado | |
13 | - * | |
14 | - * @param almoxarifado | |
15 | - * @return | |
16 | - */ | |
17 | - MaterialLocalEstoque buscarLocalEstoque(EstruturaOrganizacional almoxarifado); | |
18 | -} |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/dao/MaterialEstoqueDao.java
1 | 1 | package br.com.centralit.api.dao; |
2 | 2 | |
3 | +import br.com.centralit.api.model.MaterialEstoque; | |
3 | 4 | import br.com.centralit.framework.dao.arquitetura.CitGenericDAO; |
4 | 5 | |
5 | 6 | public interface MaterialEstoqueDao extends CitGenericDAO { |
7 | + | |
8 | + MaterialEstoque findByIdMaterial(Long idMaterial); | |
6 | 9 | |
7 | 10 | } | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/dao/MaterialLocalEstoqueDao.java
0 → 100644
... | ... | @@ -0,0 +1,26 @@ |
1 | +package br.com.centralit.api.dao; | |
2 | + | |
3 | +import java.util.List; | |
4 | + | |
5 | +import br.com.centralit.api.model.EstruturaOrganizacional; | |
6 | +import br.com.centralit.api.model.MaterialLocalEstoque; | |
7 | +import br.com.centralit.framework.dao.arquitetura.CitGenericDAO; | |
8 | + | |
9 | +public interface MaterialLocalEstoqueDao extends CitGenericDAO { | |
10 | + | |
11 | + /** | |
12 | + * Método responsável por | |
13 | + * | |
14 | + * @author wilker.machado | |
15 | + * | |
16 | + * @param almoxarifado | |
17 | + * @return | |
18 | + */ | |
19 | + MaterialLocalEstoque buscarLocalEstoque(EstruturaOrganizacional almoxarifado); | |
20 | + | |
21 | + List<MaterialLocalEstoque> buscarLocaisEstoquePorIdMaterial(Long idMaterial); | |
22 | + | |
23 | + List<MaterialLocalEstoque> buscarLocaisEstoquePorIdMaterialIdAlmoxarifado(Long idMaterial, Long idAlmoxarifado); | |
24 | + | |
25 | + Boolean enderecoJaVinculadoAoMaterial(Long idMaterial, Long idEndereco); | |
26 | +} | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/dao/impl/EnderecoEstoqueDaoHibernate.java
... | ... | @@ -38,6 +38,25 @@ public class EnderecoEstoqueDaoHibernate extends CitGenericDAOImpl implements En |
38 | 38 | |
39 | 39 | searchSeven.addFilterEqual("endeEstoqSuperior.id", idEnderecoEstoque); |
40 | 40 | |
41 | + searchSeven.addSortAsc("codigo"); | |
42 | + | |
43 | + return this.search(searchSeven); | |
44 | + } | |
45 | + | |
46 | + @Override | |
47 | + public List<EnderecoEstoque> listarEnderecosEstoquePorAlmoxarifado(String value, Long idAlmoxarifado) { | |
48 | + SearchSeven searchSeven = new SearchSeven(this.persistentClass); | |
49 | + | |
50 | + searchSeven.addFilterILike("codigo", "%" + value + "%"); | |
51 | + | |
52 | + searchSeven.addFilterEqual("acomodaMaterial", Boolean.TRUE); | |
53 | + | |
54 | + if(idAlmoxarifado != null && idAlmoxarifado != 0l){ | |
55 | + searchSeven.addFilterEqual("estoque.almoxarifado.id", idAlmoxarifado); | |
56 | + } | |
57 | + | |
58 | + searchSeven.setMaxResults(10); | |
59 | + | |
41 | 60 | return this.search(searchSeven); |
42 | 61 | } |
43 | 62 | } | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/dao/impl/LocalEstoqueDaoHibernate.java
... | ... | @@ -1,60 +0,0 @@ |
1 | -package br.com.centralit.api.dao.impl; | |
2 | - | |
3 | -import org.springframework.stereotype.Repository; | |
4 | - | |
5 | -import br.com.centralit.api.dao.LocalEstoqueDao; | |
6 | -import br.com.centralit.api.model.EstruturaOrganizacional; | |
7 | -import br.com.centralit.api.model.MaterialLocalEstoque; | |
8 | -import br.com.centralit.framework.dao.arquitetura.CitGenericDAOImpl; | |
9 | -import br.com.centralit.framework.dao.arquitetura.SearchSeven; | |
10 | - | |
11 | -/** | |
12 | - * <p> | |
13 | - * <img src="http://centralit.com.br/images/logo_central.png"> | |
14 | - * </p> | |
15 | - * | |
16 | - * <p> | |
17 | - * <b>Company: </b> Central IT - Governança Corporativa - | |
18 | - * </p> | |
19 | - * | |
20 | - * <p> | |
21 | - * <b>Title: </b> | |
22 | - * </p> | |
23 | - * | |
24 | - * <p> | |
25 | - * <b>Description: </b> | |
26 | - * </p> | |
27 | - * | |
28 | - * @since 02/06/2015 - 18:23:40 | |
29 | - * | |
30 | - * @version 1.0.0 | |
31 | - * | |
32 | - * @author wilker.machado | |
33 | - * | |
34 | - */ | |
35 | -@Repository("localEstoqueDao") | |
36 | -public class LocalEstoqueDaoHibernate extends CitGenericDAOImpl implements LocalEstoqueDao { | |
37 | - | |
38 | - /** | |
39 | - * Responsável pela criação de novas instâncias desta classe. | |
40 | - */ | |
41 | - public LocalEstoqueDaoHibernate() { | |
42 | - | |
43 | - super(MaterialLocalEstoque.class); | |
44 | - } | |
45 | - | |
46 | - /** | |
47 | - * {@inheritDoc} | |
48 | - */ | |
49 | - @Override | |
50 | - public MaterialLocalEstoque buscarLocalEstoque(EstruturaOrganizacional almoxarifado) { | |
51 | - | |
52 | - SearchSeven search = new SearchSeven(); | |
53 | - | |
54 | - search.addFilterEqual("almoxarifado.id", almoxarifado.getId()); | |
55 | - | |
56 | - search.setMaxResults(1); | |
57 | - | |
58 | - return this.searchUnique(search); | |
59 | - } | |
60 | -} |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/dao/impl/MaterialEstoqueDaoHibernate.java
... | ... | @@ -5,6 +5,7 @@ import org.springframework.stereotype.Repository; |
5 | 5 | import br.com.centralit.api.dao.MaterialEstoqueDao; |
6 | 6 | import br.com.centralit.api.model.MaterialEstoque; |
7 | 7 | import br.com.centralit.framework.dao.arquitetura.CitGenericDAOImpl; |
8 | +import br.com.centralit.framework.dao.arquitetura.SearchSeven; | |
8 | 9 | |
9 | 10 | @Repository("materialEstoqueDao") |
10 | 11 | public class MaterialEstoqueDaoHibernate extends CitGenericDAOImpl implements MaterialEstoqueDao { |
... | ... | @@ -12,5 +13,16 @@ public class MaterialEstoqueDaoHibernate extends CitGenericDAOImpl implements Ma |
12 | 13 | public MaterialEstoqueDaoHibernate() { |
13 | 14 | super(MaterialEstoque.class); |
14 | 15 | } |
16 | + | |
17 | + @Override | |
18 | + public MaterialEstoque findByIdMaterial(Long idMaterial) { | |
19 | + SearchSeven search = new SearchSeven(); | |
20 | + | |
21 | + search.addFilterEqual("material.id", idMaterial); | |
22 | + | |
23 | + search.setMaxResults(1); | |
24 | + | |
25 | + return this.searchUnique(search); | |
26 | + } | |
15 | 27 | |
16 | 28 | } | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/dao/impl/MaterialLocalEstoqueDaoHibernate.java
0 → 100644
... | ... | @@ -0,0 +1,93 @@ |
1 | +package br.com.centralit.api.dao.impl; | |
2 | + | |
3 | +import java.util.List; | |
4 | + | |
5 | +import org.springframework.stereotype.Repository; | |
6 | + | |
7 | +import br.com.centralit.api.dao.MaterialLocalEstoqueDao; | |
8 | +import br.com.centralit.api.model.EstruturaOrganizacional; | |
9 | +import br.com.centralit.api.model.MaterialLocalEstoque; | |
10 | +import br.com.centralit.framework.dao.arquitetura.CitGenericDAOImpl; | |
11 | +import br.com.centralit.framework.dao.arquitetura.SearchSeven; | |
12 | + | |
13 | +/** | |
14 | + * <p> | |
15 | + * <img src="http://centralit.com.br/images/logo_central.png"> | |
16 | + * </p> | |
17 | + * | |
18 | + * <p> | |
19 | + * <b>Company: </b> Central IT - Governança Corporativa - | |
20 | + * </p> | |
21 | + * | |
22 | + * <p> | |
23 | + * <b>Title: </b> | |
24 | + * </p> | |
25 | + * | |
26 | + * <p> | |
27 | + * <b>Description: </b> | |
28 | + * </p> | |
29 | + * | |
30 | + * @since 02/06/2015 - 18:23:40 | |
31 | + * | |
32 | + * @version 1.0.0 | |
33 | + * | |
34 | + * @author wilker.machado | |
35 | + * | |
36 | + */ | |
37 | +@Repository("materialLocalEstoqueDao") | |
38 | +public class MaterialLocalEstoqueDaoHibernate extends CitGenericDAOImpl implements MaterialLocalEstoqueDao { | |
39 | + | |
40 | + /** | |
41 | + * Responsável pela criação de novas instâncias desta classe. | |
42 | + */ | |
43 | + public MaterialLocalEstoqueDaoHibernate() { | |
44 | + | |
45 | + super(MaterialLocalEstoque.class); | |
46 | + } | |
47 | + | |
48 | + /** | |
49 | + * {@inheritDoc} | |
50 | + */ | |
51 | + @Override | |
52 | + public MaterialLocalEstoque buscarLocalEstoque(EstruturaOrganizacional almoxarifado) { | |
53 | + | |
54 | + SearchSeven search = new SearchSeven(); | |
55 | + | |
56 | + search.addFilterEqual("almoxarifado.id", almoxarifado.getId()); | |
57 | + | |
58 | + search.setMaxResults(1); | |
59 | + | |
60 | + return this.searchUnique(search); | |
61 | + } | |
62 | + | |
63 | + @Override | |
64 | + public List<MaterialLocalEstoque> buscarLocaisEstoquePorIdMaterial(Long idMaterial) { | |
65 | + SearchSeven search = new SearchSeven(); | |
66 | + search.getFilters().remove(1); | |
67 | + search.addFilterEqual("materialEstoque.material.id", idMaterial); | |
68 | + search.addSortAsc("endereco.codigo"); | |
69 | + return this.search(search); | |
70 | + } | |
71 | + | |
72 | + @Override | |
73 | + public List<MaterialLocalEstoque> buscarLocaisEstoquePorIdMaterialIdAlmoxarifado(Long idMaterial,Long idAlmoxarifado) { | |
74 | + | |
75 | + SearchSeven search = new SearchSeven(); | |
76 | + search.getFilters().remove(1); | |
77 | + search.addFilterEqual("materialEstoque.material.id", idMaterial); | |
78 | + search.addFilterEqual("endereco.estoque.almoxarifado.id", idAlmoxarifado); | |
79 | + | |
80 | + return this.search(search); | |
81 | + } | |
82 | + | |
83 | + @Override | |
84 | + public Boolean enderecoJaVinculadoAoMaterial(Long idMaterial, Long idEndereco) { | |
85 | + | |
86 | + SearchSeven search = new SearchSeven(); | |
87 | + search.getFilters().remove(1); | |
88 | + search.addFilterEqual("materialEstoque.material.id", idMaterial); | |
89 | + search.addFilterEqual("endereco.id", idEndereco); | |
90 | + | |
91 | + return this.count(search) > 0 ? Boolean.TRUE : Boolean.FALSE; | |
92 | + } | |
93 | +} | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/model/EnderecoEstoque.java
... | ... | @@ -70,14 +70,14 @@ public class EnderecoEstoque extends PersistentObjectAuditOrganizacao { |
70 | 70 | |
71 | 71 | /** Atributo entrada. */ |
72 | 72 | @ManyToOne(fetch = FetchType.LAZY, optional = true) |
73 | - @JsonView({ ViewsAdmMateriais.EnderecoEstoqueView.class }) | |
73 | + @JsonView({ ViewsAdmMateriais.EnderecoEstoqueView.class, Views.MaterialLocalEstoqueView.class }) | |
74 | 74 | private Estoque estoque; |
75 | 75 | |
76 | 76 | @ManyToOne(fetch = FetchType.LAZY, optional = true) |
77 | 77 | private Estoque estoqueInativo; |
78 | 78 | |
79 | 79 | @Column(length = 30, nullable = false, updatable = false, unique = true) |
80 | - @JsonView({ ViewsAdmMateriais.EnderecoEstoqueView.class }) | |
80 | + @JsonView({ ViewsAdmMateriais.EnderecoEstoqueView.class, Views.MaterialLocalEstoqueView.class }) | |
81 | 81 | private String codigo; |
82 | 82 | |
83 | 83 | @Column(name = "sigla", length = 30, updatable = true) |
... | ... | @@ -85,7 +85,7 @@ public class EnderecoEstoque extends PersistentObjectAuditOrganizacao { |
85 | 85 | private String sigla; |
86 | 86 | |
87 | 87 | @Column(name = "descricao", length = 400, nullable = false) |
88 | - @JsonView({ ViewsAdmMateriais.EnderecoEstoqueView.class }) | |
88 | + @JsonView({ ViewsAdmMateriais.EnderecoEstoqueView.class, Views.MaterialLocalEstoqueView.class }) | |
89 | 89 | private String descricao; |
90 | 90 | |
91 | 91 | @ManyToOne(fetch = FetchType.LAZY, optional = true) | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/model/Estoque.java
... | ... | @@ -71,7 +71,7 @@ public class Estoque extends PersistentObjectAuditOrganizacao { |
71 | 71 | /** Atributo almoxarifado. */ |
72 | 72 | @OneToOne(fetch = FetchType.LAZY, optional = false) |
73 | 73 | @JsonView({ ViewsAdmMateriais.LocalEstoqueAutoCompleteView.class, |
74 | - ViewsAlmoxarifado.ConfiguracaoRessuprimentoEditView.class, Views.MaterialConsultaInfo.class }) | |
74 | + ViewsAlmoxarifado.ConfiguracaoRessuprimentoEditView.class, Views.MaterialConsultaInfo.class, ViewsAdmMateriais.EnderecoEstoqueView.class, Views.MaterialLocalEstoqueView.class }) | |
75 | 75 | private EstruturaOrganizacional almoxarifado; |
76 | 76 | |
77 | 77 | /** Atributo locais. */ | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/model/MaterialEstoque.java
... | ... | @@ -16,22 +16,37 @@ import javax.persistence.Table; |
16 | 16 | |
17 | 17 | import org.hibernate.envers.Audited; |
18 | 18 | |
19 | +import com.fasterxml.jackson.annotation.JsonView; | |
20 | + | |
21 | +import br.com.centralit.framework.json.Views; | |
19 | 22 | import br.com.centralit.framework.model.arquitetura.PersistentObjectAuditOrganizacao; |
20 | 23 | |
21 | 24 | /** |
22 | 25 | * |
23 | - * <p><img src="http://centralit.com.br/images/logo_central.png"></p> | |
26 | + * <p> | |
27 | + * <img src="http://centralit.com.br/images/logo_central.png"> | |
28 | + * </p> | |
24 | 29 | * |
25 | - * <p><b>Company: </b> Central IT - Governança Corporativa - </p> | |
30 | + * <p> | |
31 | + * <b>Company: </b> Central IT - Governança Corporativa - | |
32 | + * </p> | |
26 | 33 | * |
27 | - * <p><b>Title: </b></p> | |
34 | + * <p> | |
35 | + * <b>Title: </b> | |
36 | + * </p> | |
28 | 37 | * |
29 | - * <p><b>Description: </b></p> | |
38 | + * <p> | |
39 | + * <b>Description: </b> | |
40 | + * </p> | |
30 | 41 | * |
31 | - * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> | |
42 | + * <p> | |
43 | + * <b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a> | |
44 | + * </p> | |
32 | 45 | * |
33 | - * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
34 | - * | |
46 | + * <p> | |
47 | + * <b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a> | |
48 | + * </p> | |
49 | + * | |
35 | 50 | * @since 29/04/2016 - 09:41:49 |
36 | 51 | * |
37 | 52 | * @version 1.0.0 |
... | ... | @@ -46,20 +61,22 @@ public class MaterialEstoque extends PersistentObjectAuditOrganizacao { |
46 | 61 | |
47 | 62 | /** Atributo serialVersionUID. */ |
48 | 63 | private static final long serialVersionUID = 1170228299223134768L; |
49 | - | |
64 | + | |
50 | 65 | /** Atributo id. */ |
51 | 66 | @Id |
52 | 67 | @GeneratedValue(strategy = GenerationType.AUTO) |
68 | + @JsonView({ Views.GenericView.class }) | |
53 | 69 | private Long id; |
54 | - | |
70 | + | |
55 | 71 | /** Atributo material. */ |
56 | 72 | @OneToOne(fetch = FetchType.LAZY, optional = false) |
73 | + @JsonView({ Views.MaterialLocalEstoqueView.class }) | |
57 | 74 | private MaterialConsumo material; |
58 | - | |
75 | + | |
59 | 76 | /** Atributo locaisEstoque. */ |
60 | 77 | @OneToMany(fetch = FetchType.LAZY, mappedBy = "materialEstoque", cascade = CascadeType.ALL) |
61 | 78 | private Collection<MaterialLocalEstoque> locaisEstoque; |
62 | - | |
79 | + | |
63 | 80 | /** Atributo valorUnitarioMedio. */ |
64 | 81 | @Column(precision = 20, scale = 4) |
65 | 82 | private BigDecimal valorUnitarioMedio; |
... | ... | @@ -67,11 +84,11 @@ public class MaterialEstoque extends PersistentObjectAuditOrganizacao { |
67 | 84 | /** Atributo restoMedio. */ |
68 | 85 | @Column(precision = 20, scale = 4) |
69 | 86 | private BigDecimal restoMedio; |
70 | - | |
87 | + | |
71 | 88 | /** Atributo itensFifo. */ |
72 | 89 | @OneToMany(fetch = FetchType.LAZY, mappedBy = "materialEstoque", cascade = CascadeType.ALL) |
73 | 90 | private Collection<MaterialEstoqueFIFOItem> itensFifo; |
74 | - | |
91 | + | |
75 | 92 | /** Atributo movimentos. */ |
76 | 93 | @OneToMany(fetch = FetchType.LAZY, mappedBy = "materialEstoque", cascade = CascadeType.ALL) |
77 | 94 | private Collection<MovimentoEstoque> movimentos; |
... | ... | @@ -96,4 +113,52 @@ public class MaterialEstoque extends PersistentObjectAuditOrganizacao { |
96 | 113 | this.id = id; |
97 | 114 | } |
98 | 115 | |
116 | + public MaterialConsumo getMaterial() { | |
117 | + return material; | |
118 | + } | |
119 | + | |
120 | + public void setMaterial(MaterialConsumo material) { | |
121 | + this.material = material; | |
122 | + } | |
123 | + | |
124 | + public Collection<MaterialLocalEstoque> getLocaisEstoque() { | |
125 | + return locaisEstoque; | |
126 | + } | |
127 | + | |
128 | + public void setLocaisEstoque(Collection<MaterialLocalEstoque> locaisEstoque) { | |
129 | + this.locaisEstoque = locaisEstoque; | |
130 | + } | |
131 | + | |
132 | + public BigDecimal getValorUnitarioMedio() { | |
133 | + return valorUnitarioMedio; | |
134 | + } | |
135 | + | |
136 | + public void setValorUnitarioMedio(BigDecimal valorUnitarioMedio) { | |
137 | + this.valorUnitarioMedio = valorUnitarioMedio; | |
138 | + } | |
139 | + | |
140 | + public BigDecimal getRestoMedio() { | |
141 | + return restoMedio; | |
142 | + } | |
143 | + | |
144 | + public void setRestoMedio(BigDecimal restoMedio) { | |
145 | + this.restoMedio = restoMedio; | |
146 | + } | |
147 | + | |
148 | + public Collection<MaterialEstoqueFIFOItem> getItensFifo() { | |
149 | + return itensFifo; | |
150 | + } | |
151 | + | |
152 | + public void setItensFifo(Collection<MaterialEstoqueFIFOItem> itensFifo) { | |
153 | + this.itensFifo = itensFifo; | |
154 | + } | |
155 | + | |
156 | + public Collection<MovimentoEstoque> getMovimentos() { | |
157 | + return movimentos; | |
158 | + } | |
159 | + | |
160 | + public void setMovimentos(Collection<MovimentoEstoque> movimentos) { | |
161 | + this.movimentos = movimentos; | |
162 | + } | |
163 | + | |
99 | 164 | } | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/model/MaterialLocalEstoque.java
... | ... | @@ -2,36 +2,48 @@ package br.com.centralit.api.model; |
2 | 2 | |
3 | 3 | import java.math.BigDecimal; |
4 | 4 | |
5 | +import javax.persistence.CascadeType; | |
5 | 6 | import javax.persistence.Entity; |
6 | 7 | import javax.persistence.FetchType; |
7 | 8 | import javax.persistence.GeneratedValue; |
8 | 9 | import javax.persistence.GenerationType; |
9 | 10 | import javax.persistence.Id; |
10 | 11 | import javax.persistence.ManyToOne; |
11 | -import javax.persistence.OneToOne; | |
12 | 12 | import javax.persistence.Table; |
13 | 13 | |
14 | 14 | import org.hibernate.envers.Audited; |
15 | 15 | |
16 | +import com.fasterxml.jackson.annotation.JsonView; | |
17 | + | |
16 | 18 | import br.com.centralit.framework.json.Views; |
17 | 19 | import br.com.centralit.framework.model.arquitetura.PersistentObjectAuditOrganizacao; |
18 | 20 | |
19 | -import com.fasterxml.jackson.annotation.JsonView; | |
20 | - | |
21 | 21 | /** |
22 | 22 | * |
23 | - * <p><img src="http://centralit.com.br/images/logo_central.png"></p> | |
23 | + * <p> | |
24 | + * <img src="http://centralit.com.br/images/logo_central.png"> | |
25 | + * </p> | |
24 | 26 | * |
25 | - * <p><b>Company: </b> Central IT - Governança Corporativa - </p> | |
27 | + * <p> | |
28 | + * <b>Company: </b> Central IT - Governança Corporativa - | |
29 | + * </p> | |
26 | 30 | * |
27 | - * <p><b>Title: </b></p> | |
31 | + * <p> | |
32 | + * <b>Title: </b> | |
33 | + * </p> | |
28 | 34 | * |
29 | - * <p><b>Description: </b></p> | |
35 | + * <p> | |
36 | + * <b>Description: </b> | |
37 | + * </p> | |
30 | 38 | * |
31 | - * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> | |
39 | + * <p> | |
40 | + * <b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a> | |
41 | + * </p> | |
32 | 42 | * |
33 | - * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
34 | - * | |
43 | + * <p> | |
44 | + * <b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a> | |
45 | + * </p> | |
46 | + * | |
35 | 47 | * @since 29/04/2016 - 09:06:28 |
36 | 48 | * |
37 | 49 | * @version 1.0.0 |
... | ... | @@ -52,30 +64,36 @@ public class MaterialLocalEstoque extends PersistentObjectAuditOrganizacao { |
52 | 64 | @GeneratedValue(strategy = GenerationType.AUTO) |
53 | 65 | @JsonView({ Views.GenericView.class }) |
54 | 66 | private Long id; |
55 | - | |
67 | + | |
56 | 68 | /** Atributo materialEstoque. */ |
57 | - @OneToOne(fetch = FetchType.LAZY, optional = false) | |
69 | + @ManyToOne(fetch = FetchType.LAZY, optional = false, cascade = CascadeType.PERSIST) | |
70 | + @JsonView({ Views.MaterialLocalEstoqueView.class }) | |
58 | 71 | private MaterialEstoque materialEstoque; |
59 | - | |
72 | + | |
60 | 73 | /** Atributo materialEstoqueInativo. */ |
61 | 74 | @ManyToOne(fetch = FetchType.LAZY, optional = true) |
62 | 75 | private MaterialEstoque materialEstoqueInativo; |
63 | - | |
76 | + | |
64 | 77 | /** Atributo endereco. */ |
65 | - @OneToOne(fetch = FetchType.LAZY, optional = false) | |
78 | + @ManyToOne(fetch = FetchType.LAZY, optional = false) | |
79 | + @JsonView({ Views.MaterialLocalEstoqueView.class }) | |
66 | 80 | private EnderecoEstoque endereco; |
67 | - | |
81 | + | |
68 | 82 | /** Atributo enderecoInativo. */ |
69 | 83 | @ManyToOne(fetch = FetchType.LAZY, optional = true) |
70 | 84 | private EnderecoEstoque enderecoInativo; |
71 | - | |
85 | + | |
72 | 86 | /** Atributo quantidade. */ |
87 | + @JsonView({ Views.MaterialLocalEstoqueView.class }) | |
73 | 88 | private BigDecimal quantidade; |
74 | - | |
89 | + | |
75 | 90 | /** Atributo unidadeMedidaEntrada. */ |
76 | - @ManyToOne(fetch = FetchType.LAZY, optional = false) | |
91 | + @ManyToOne(fetch = FetchType.LAZY, optional = true) | |
77 | 92 | private UnidadeMedida unidadeMedidaEntrada; |
78 | 93 | |
94 | + @JsonView({ Views.MaterialLocalEstoqueView.class }) | |
95 | + private Boolean localPrincipal; | |
96 | + | |
79 | 97 | /** |
80 | 98 | * Retorna o valor do atributo <code>id</code> |
81 | 99 | * |
... | ... | @@ -95,48 +113,44 @@ public class MaterialLocalEstoque extends PersistentObjectAuditOrganizacao { |
95 | 113 | |
96 | 114 | this.id = id; |
97 | 115 | } |
98 | - | |
116 | + | |
99 | 117 | /** |
100 | 118 | * Retorna o valor do atributo <code>endereco</code> |
101 | 119 | * |
102 | 120 | * @return <code>EnderecoEstoque</code> |
103 | 121 | */ |
104 | 122 | public EnderecoEstoque getEndereco() { |
105 | - | |
123 | + | |
106 | 124 | return endereco; |
107 | 125 | } |
108 | 126 | |
109 | - | |
110 | 127 | /** |
111 | 128 | * Define o valor do atributo <code>endereco</code>. |
112 | 129 | * |
113 | - * @param endereco | |
130 | + * @param endereco | |
114 | 131 | */ |
115 | 132 | public void setEndereco(EnderecoEstoque endereco) { |
116 | - | |
133 | + | |
117 | 134 | this.endereco = endereco; |
118 | 135 | } |
119 | 136 | |
120 | - | |
121 | - | |
122 | 137 | /** |
123 | 138 | * Retorna o valor do atributo <code>enderecoInativo</code> |
124 | 139 | * |
125 | 140 | * @return <code>EnderecoEstoque</code> |
126 | 141 | */ |
127 | 142 | public EnderecoEstoque getEnderecoInativo() { |
128 | - | |
143 | + | |
129 | 144 | return enderecoInativo; |
130 | 145 | } |
131 | 146 | |
132 | - | |
133 | 147 | /** |
134 | 148 | * Define o valor do atributo <code>enderecoInativo</code>. |
135 | 149 | * |
136 | - * @param enderecoInativo | |
150 | + * @param enderecoInativo | |
137 | 151 | */ |
138 | 152 | public void setEnderecoInativo(EnderecoEstoque enderecoInativo) { |
139 | - | |
153 | + | |
140 | 154 | this.enderecoInativo = enderecoInativo; |
141 | 155 | } |
142 | 156 | |
... | ... | @@ -146,85 +160,86 @@ public class MaterialLocalEstoque extends PersistentObjectAuditOrganizacao { |
146 | 160 | * @return <code>BigDecimal</code> |
147 | 161 | */ |
148 | 162 | public BigDecimal getQuantidade() { |
149 | - | |
163 | + | |
150 | 164 | return quantidade; |
151 | 165 | } |
152 | 166 | |
153 | - | |
154 | 167 | /** |
155 | 168 | * Define o valor do atributo <code>quantidade</code>. |
156 | 169 | * |
157 | - * @param quantidade | |
170 | + * @param quantidade | |
158 | 171 | */ |
159 | 172 | public void setQuantidade(BigDecimal quantidade) { |
160 | - | |
173 | + | |
161 | 174 | this.quantidade = quantidade; |
162 | 175 | } |
163 | 176 | |
164 | - | |
165 | 177 | /** |
166 | 178 | * Retorna o valor do atributo <code>unidadeMedidaEntrada</code> |
167 | 179 | * |
168 | 180 | * @return <code>UnidadeMedida</code> |
169 | 181 | */ |
170 | 182 | public UnidadeMedida getUnidadeMedidaEntrada() { |
171 | - | |
183 | + | |
172 | 184 | return unidadeMedidaEntrada; |
173 | 185 | } |
174 | 186 | |
175 | - | |
176 | 187 | /** |
177 | 188 | * Define o valor do atributo <code>unidadeMedidaEntrada</code>. |
178 | 189 | * |
179 | - * @param unidadeMedidaEntrada | |
190 | + * @param unidadeMedidaEntrada | |
180 | 191 | */ |
181 | 192 | public void setUnidadeMedidaEntrada(UnidadeMedida unidadeMedidaEntrada) { |
182 | - | |
193 | + | |
183 | 194 | this.unidadeMedidaEntrada = unidadeMedidaEntrada; |
184 | 195 | } |
185 | 196 | |
186 | - | |
187 | 197 | /** |
188 | 198 | * Retorna o valor do atributo <code>materialEstoque</code> |
189 | 199 | * |
190 | 200 | * @return <code>MaterialEstoque</code> |
191 | 201 | */ |
192 | 202 | public MaterialEstoque getMaterialEstoque() { |
193 | - | |
203 | + | |
194 | 204 | return materialEstoque; |
195 | 205 | } |
196 | 206 | |
197 | - | |
198 | 207 | /** |
199 | 208 | * Define o valor do atributo <code>materialEstoque</code>. |
200 | 209 | * |
201 | - * @param materialEstoque | |
210 | + * @param materialEstoque | |
202 | 211 | */ |
203 | 212 | public void setMaterialEstoque(MaterialEstoque materialEstoque) { |
204 | - | |
213 | + | |
205 | 214 | this.materialEstoque = materialEstoque; |
206 | 215 | } |
207 | 216 | |
208 | - | |
209 | 217 | /** |
210 | 218 | * Retorna o valor do atributo <code>materialEstoqueInativo</code> |
211 | 219 | * |
212 | 220 | * @return <code>MaterialEstoque</code> |
213 | 221 | */ |
214 | 222 | public MaterialEstoque getMaterialEstoqueInativo() { |
215 | - | |
223 | + | |
216 | 224 | return materialEstoqueInativo; |
217 | 225 | } |
218 | 226 | |
219 | - | |
220 | 227 | /** |
221 | 228 | * Define o valor do atributo <code>materialEstoqueInativo</code>. |
222 | 229 | * |
223 | - * @param materialEstoqueInativo | |
230 | + * @param materialEstoqueInativo | |
224 | 231 | */ |
225 | 232 | public void setMaterialEstoqueInativo(MaterialEstoque materialEstoqueInativo) { |
226 | - | |
233 | + | |
227 | 234 | this.materialEstoqueInativo = materialEstoqueInativo; |
228 | 235 | } |
229 | 236 | |
237 | + public Boolean getLocalPrincipal() { | |
238 | + return localPrincipal; | |
239 | + } | |
240 | + | |
241 | + public void setLocalPrincipal(Boolean localPrincipal) { | |
242 | + this.localPrincipal = localPrincipal; | |
243 | + } | |
244 | + | |
230 | 245 | } | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/EnderecoEstoqueService.java
... | ... | @@ -9,4 +9,6 @@ public interface EnderecoEstoqueService extends GenericService<EnderecoEstoque, |
9 | 9 | |
10 | 10 | List<EnderecoEstoque> enderecoEstoqueSuperiorVinculado(Long id); |
11 | 11 | |
12 | + List<EnderecoEstoque> listarEnderecosEstoquePorAlmoxarifado(String value, Long idAlmoxarifado); | |
13 | + | |
12 | 14 | } | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/MaterialEstoqueService.java
... | ... | @@ -4,5 +4,7 @@ import br.com.centralit.api.model.MaterialEstoque; |
4 | 4 | import br.com.centralit.framework.service.arquitetura.GenericService; |
5 | 5 | |
6 | 6 | public interface MaterialEstoqueService extends GenericService<MaterialEstoque, Long> { |
7 | + | |
8 | + MaterialEstoque findByIdMaterial(Long idMaterial); | |
7 | 9 | |
8 | 10 | } | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/MaterialLocalEstoqueService.java
1 | 1 | package br.com.centralit.api.service; |
2 | 2 | |
3 | +import java.util.List; | |
4 | + | |
3 | 5 | import br.com.centralit.api.model.EstruturaOrganizacional; |
4 | 6 | import br.com.centralit.api.model.MaterialLocalEstoque; |
5 | 7 | import br.com.centralit.framework.service.arquitetura.GenericService; |
... | ... | @@ -15,4 +17,10 @@ public interface MaterialLocalEstoqueService extends GenericService<MaterialLoca |
15 | 17 | * @return |
16 | 18 | */ |
17 | 19 | MaterialLocalEstoque buscarLocalEstoque(EstruturaOrganizacional almoxarifado); |
20 | + | |
21 | + List<MaterialLocalEstoque> buscarLocaisEstoquePorIdMaterial(Long idMaterial); | |
22 | + | |
23 | + List<MaterialLocalEstoque> buscarLocaisEstoquePorIdMaterialIdAlmoxarifado(Long idMaterial, Long idAlmoxarifado); | |
24 | + | |
25 | + Boolean enderecoJaVinculadoAoMaterial(Long idMaterial, Long idEndereco); | |
18 | 26 | } | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/impl/EnderecoEstoqueServiceImpl.java
1 | 1 | package br.com.centralit.api.service.impl; |
2 | 2 | |
3 | +import java.math.BigDecimal; | |
3 | 4 | import java.util.ArrayList; |
4 | 5 | import java.util.List; |
5 | 6 | |
... | ... | @@ -11,9 +12,15 @@ import org.springframework.validation.Validator; |
11 | 12 | import br.com.centralit.api.dao.EnderecoEstoqueDao; |
12 | 13 | import br.com.centralit.api.model.EnderecoEstoque; |
13 | 14 | import br.com.centralit.api.model.Estoque; |
15 | +import br.com.centralit.api.model.MaterialConsumo; | |
16 | +import br.com.centralit.api.model.MaterialEstoque; | |
17 | +import br.com.centralit.api.model.MaterialLocalEstoque; | |
14 | 18 | import br.com.centralit.api.service.ConfiguracaoParametroSistemaService; |
15 | 19 | import br.com.centralit.api.service.EnderecoEstoqueService; |
16 | 20 | import br.com.centralit.api.service.EstoqueService; |
21 | +import br.com.centralit.api.service.MaterialConsumoService; | |
22 | +import br.com.centralit.api.service.MaterialEstoqueService; | |
23 | +import br.com.centralit.api.service.MaterialLocalEstoqueService; | |
17 | 24 | import br.com.centralit.framework.exception.BusinessException; |
18 | 25 | import br.com.centralit.framework.exception.CodigoErro; |
19 | 26 | import br.com.centralit.framework.model.arquitetura.PersistentObject; |
... | ... | @@ -31,6 +38,15 @@ public class EnderecoEstoqueServiceImpl extends GenericServiceImpl<EnderecoEstoq |
31 | 38 | |
32 | 39 | @Autowired |
33 | 40 | private EstoqueService estoqueService; |
41 | + | |
42 | + @Autowired | |
43 | + private MaterialConsumoService materialConsumoService; | |
44 | + | |
45 | + @Autowired | |
46 | + private MaterialLocalEstoqueService materialLocalEstoqueService; | |
47 | + | |
48 | + @Autowired | |
49 | + private MaterialEstoqueService materialEstoqueService; | |
34 | 50 | |
35 | 51 | @Autowired |
36 | 52 | public EnderecoEstoqueServiceImpl(EnderecoEstoqueDao enderecoEstoqueDao, @Qualifier("enderecoEstoqueValidator") Validator validator) { |
... | ... | @@ -44,7 +60,7 @@ public class EnderecoEstoqueServiceImpl extends GenericServiceImpl<EnderecoEstoq |
44 | 60 | this.validarEntidade(enderecoEstoque, this.validator); |
45 | 61 | montaEnderecoEstoqueObject(enderecoEstoque); |
46 | 62 | this.enderecoEstoqueDao.save(enderecoEstoque); |
47 | - | |
63 | + gerarVinculoTodosMateriaisConsumo(enderecoEstoque); | |
48 | 64 | return enderecoEstoque; |
49 | 65 | } |
50 | 66 | |
... | ... | @@ -97,8 +113,34 @@ public class EnderecoEstoqueServiceImpl extends GenericServiceImpl<EnderecoEstoq |
97 | 113 | |
98 | 114 | this.validarEntidade(enderecoEstoque, this.validator); |
99 | 115 | super.save(enderecoEstoque); |
116 | + | |
117 | + gerarVinculoTodosMateriaisConsumo(enderecoEstoque); | |
118 | + | |
100 | 119 | return enderecoEstoque; |
101 | 120 | } |
121 | + | |
122 | + private void gerarVinculoTodosMateriaisConsumo(EnderecoEstoque enderecoEstoque) { | |
123 | + if(enderecoEstoque.getEnderTodoMaterial()){ | |
124 | + List<MaterialConsumo> materiaisConsumo = this.materialConsumoService.findAll(); | |
125 | + if(!UtilColecao.isVazio(materiaisConsumo)){ | |
126 | + for (MaterialConsumo materialConsumo : materiaisConsumo) { | |
127 | + if(!this.materialLocalEstoqueService.enderecoJaVinculadoAoMaterial(materialConsumo.getId(), enderecoEstoque.getId())){ | |
128 | + MaterialEstoque materialEstoque = this.materialEstoqueService.findByIdMaterial(materialConsumo.getId()); | |
129 | + if(materialEstoque == null){ | |
130 | + materialEstoque = new MaterialEstoque(); | |
131 | + materialEstoque.setMaterial(materialConsumo); | |
132 | + } | |
133 | + MaterialLocalEstoque materialLocalEstoque = new MaterialLocalEstoque(); | |
134 | + materialLocalEstoque.setMaterialEstoque(materialEstoque); | |
135 | + materialLocalEstoque.setEndereco(enderecoEstoque); | |
136 | + materialLocalEstoque.setQuantidade(new BigDecimal("9999999999")); | |
137 | + materialLocalEstoque.setLocalPrincipal(Boolean.TRUE); | |
138 | + this.materialLocalEstoqueService.save(materialLocalEstoque); | |
139 | + } | |
140 | + } | |
141 | + } | |
142 | + } | |
143 | + } | |
102 | 144 | |
103 | 145 | @Override |
104 | 146 | public boolean removeById(Long id) { |
... | ... | @@ -134,5 +176,10 @@ public class EnderecoEstoqueServiceImpl extends GenericServiceImpl<EnderecoEstoq |
134 | 176 | public List<EnderecoEstoque> enderecoEstoqueSuperiorVinculado(Long id) { |
135 | 177 | return this.enderecoEstoqueDao.enderecoEstoqueSuperiorVinculado(id); |
136 | 178 | } |
179 | + | |
180 | + @Override | |
181 | + public List<EnderecoEstoque> listarEnderecosEstoquePorAlmoxarifado(String value, Long idAlmoxarifado) { | |
182 | + return this.enderecoEstoqueDao.listarEnderecosEstoquePorAlmoxarifado(value, idAlmoxarifado); | |
183 | + } | |
137 | 184 | |
138 | 185 | } | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/impl/LocalEstoqueServiceImpl.java
... | ... | @@ -1,57 +0,0 @@ |
1 | -package br.com.centralit.api.service.impl; | |
2 | - | |
3 | -import org.springframework.beans.factory.annotation.Autowired; | |
4 | -import org.springframework.beans.factory.annotation.Qualifier; | |
5 | -import org.springframework.stereotype.Service; | |
6 | -import org.springframework.validation.Validator; | |
7 | - | |
8 | -import br.com.centralit.api.dao.LocalEstoqueDao; | |
9 | -import br.com.centralit.api.model.EstruturaOrganizacional; | |
10 | -import br.com.centralit.api.model.MaterialLocalEstoque; | |
11 | -import br.com.centralit.api.service.EstruturaOrganizacionalService; | |
12 | -import br.com.centralit.api.service.MaterialLocalEstoqueService; | |
13 | -import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; | |
14 | - | |
15 | -@Service("localEstoqueService") | |
16 | -public class LocalEstoqueServiceImpl extends GenericServiceImpl<MaterialLocalEstoque, Long> implements MaterialLocalEstoqueService { | |
17 | - | |
18 | - /** Atributo localEstoqueDao. */ | |
19 | - private LocalEstoqueDao localEstoqueDao; | |
20 | - | |
21 | - /** Atributo estruturaOrganizacionalService. */ | |
22 | - @Autowired | |
23 | - private EstruturaOrganizacionalService estruturaOrganizacionalService; | |
24 | - | |
25 | - @Autowired | |
26 | - public LocalEstoqueServiceImpl(LocalEstoqueDao localEstoqueDao, @Qualifier("localEstoqueValidator") Validator validator) { | |
27 | - this.dao = localEstoqueDao; | |
28 | - this.localEstoqueDao = localEstoqueDao; | |
29 | - this.validator = validator; | |
30 | - } | |
31 | - | |
32 | - @Override | |
33 | - public MaterialLocalEstoque save(MaterialLocalEstoque entity) { | |
34 | - | |
35 | - this.validarEntidade(entity, this.validator); | |
36 | - | |
37 | - return super.save(entity); | |
38 | - } | |
39 | - | |
40 | - @Override | |
41 | - public MaterialLocalEstoque merge(MaterialLocalEstoque entity) { | |
42 | - | |
43 | - this.validarEntidade(entity, this.validator); | |
44 | - | |
45 | - return super.merge(entity); | |
46 | - } | |
47 | - | |
48 | - /** | |
49 | - * {@inheritDoc} | |
50 | - */ | |
51 | - @Override | |
52 | - public MaterialLocalEstoque buscarLocalEstoque(EstruturaOrganizacional almoxarifado) { | |
53 | - | |
54 | - return this.localEstoqueDao.buscarLocalEstoque(almoxarifado); | |
55 | - } | |
56 | - | |
57 | -} |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/impl/MaterialEstoqueServiceImpl.java
... | ... | @@ -21,4 +21,9 @@ public class MaterialEstoqueServiceImpl extends GenericServiceImpl<MaterialEstoq |
21 | 21 | this.materialEstoqueDao = materialEstoqueDao; |
22 | 22 | this.validator = validator; |
23 | 23 | } |
24 | + | |
25 | + @Override | |
26 | + public MaterialEstoque findByIdMaterial(Long idMaterial) { | |
27 | + return this.materialEstoqueDao.findByIdMaterial(idMaterial); | |
28 | + } | |
24 | 29 | } | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/impl/MaterialLocalEstoqueServiceImpl.java
0 → 100644
... | ... | @@ -0,0 +1,128 @@ |
1 | +package br.com.centralit.api.service.impl; | |
2 | + | |
3 | +import java.util.List; | |
4 | + | |
5 | +import org.springframework.beans.factory.annotation.Autowired; | |
6 | +import org.springframework.beans.factory.annotation.Qualifier; | |
7 | +import org.springframework.stereotype.Service; | |
8 | +import org.springframework.validation.Validator; | |
9 | + | |
10 | +import br.com.centralit.api.dao.MaterialLocalEstoqueDao; | |
11 | +import br.com.centralit.api.model.EnderecoEstoque; | |
12 | +import br.com.centralit.api.model.EstruturaOrganizacional; | |
13 | +import br.com.centralit.api.model.MaterialEstoque; | |
14 | +import br.com.centralit.api.model.MaterialLocalEstoque; | |
15 | +import br.com.centralit.api.service.EnderecoEstoqueService; | |
16 | +import br.com.centralit.api.service.MaterialEstoqueService; | |
17 | +import br.com.centralit.api.service.MaterialLocalEstoqueService; | |
18 | +import br.com.centralit.framework.exception.BusinessException; | |
19 | +import br.com.centralit.framework.exception.CodigoErro; | |
20 | +import br.com.centralit.framework.service.arquitetura.GenericServiceImpl; | |
21 | +import br.com.centralit.framework.util.UtilColecao; | |
22 | +import br.com.centralit.framework.util.UtilObjeto; | |
23 | + | |
24 | +@Service("materialLocalEstoqueService") | |
25 | +public class MaterialLocalEstoqueServiceImpl extends GenericServiceImpl<MaterialLocalEstoque, Long> implements MaterialLocalEstoqueService { | |
26 | + | |
27 | + /** Atributo localEstoqueDao. */ | |
28 | + private MaterialLocalEstoqueDao materailLocalEstoqueDao; | |
29 | + | |
30 | + @Autowired | |
31 | + private EnderecoEstoqueService enderecoEstoqueService; | |
32 | + | |
33 | + @Autowired | |
34 | + private MaterialEstoqueService materialEstoqueService; | |
35 | + | |
36 | + @Autowired | |
37 | + public MaterialLocalEstoqueServiceImpl(MaterialLocalEstoqueDao localEstoqueDao, @Qualifier("materialLocalEstoqueValidator") Validator validator) { | |
38 | + this.dao = localEstoqueDao; | |
39 | + this.materailLocalEstoqueDao = localEstoqueDao; | |
40 | + this.validator = validator; | |
41 | + } | |
42 | + | |
43 | + @Override | |
44 | + public MaterialLocalEstoque save(MaterialLocalEstoque entity) { | |
45 | + | |
46 | + if(this.enderecoJaVinculadoAoMaterial(entity.getMaterialEstoque().getMaterial().getId(), entity.getEndereco().getId())){ | |
47 | + throw new BusinessException("ADMINISTRACAODEMATERIAIS.MSG.LOCAL_ESTOQUE_JA_VINCULADO_MATERIAL", CodigoErro.REGRA_NEGOCIO.getValue()); | |
48 | + } | |
49 | + | |
50 | + this.validarEntidade(entity, this.validator); | |
51 | + | |
52 | + setLocalPrincipal(entity); | |
53 | + | |
54 | + MaterialEstoque materialEstoque = this.materialEstoqueService.findByIdMaterial(entity.getMaterialEstoque().getMaterial().getId()); | |
55 | + if(UtilObjeto.isReferencia(materialEstoque)){ | |
56 | + entity.setMaterialEstoque(materialEstoque); | |
57 | + } | |
58 | + | |
59 | + return super.save(entity); | |
60 | + } | |
61 | + | |
62 | + private void setLocalPrincipal(MaterialLocalEstoque entity) { | |
63 | + EnderecoEstoque enderecoEstoque = this.enderecoEstoqueService.find(entity.getEndereco().getId()); | |
64 | + List<MaterialLocalEstoque> locaisParMaterial = this.buscarLocaisEstoquePorIdMaterialIdAlmoxarifado(entity.getMaterialEstoque().getMaterial().getId(), enderecoEstoque.getEstoque().getAlmoxarifado().getId()); | |
65 | + if(UtilColecao.isVazio(locaisParMaterial)){ | |
66 | + entity.setLocalPrincipal(Boolean.TRUE); | |
67 | + }else{ | |
68 | + if(entity.getLocalPrincipal()){ | |
69 | + for (MaterialLocalEstoque materialLocalEstoque : locaisParMaterial) { | |
70 | + materialLocalEstoque.setLocalPrincipal(Boolean.FALSE); | |
71 | + this.merge(materialLocalEstoque); | |
72 | + } | |
73 | + } | |
74 | + } | |
75 | + } | |
76 | + | |
77 | + @Override | |
78 | + public MaterialLocalEstoque merge(MaterialLocalEstoque entity) { | |
79 | + | |
80 | + MaterialLocalEstoque matLocalEstTemp = this.find(entity.getId()); | |
81 | + | |
82 | + if(matLocalEstTemp.getEndereco().getId().intValue() != entity.getEndereco().getId().intValue()){ | |
83 | + if(this.enderecoJaVinculadoAoMaterial(entity.getMaterialEstoque().getMaterial().getId(), entity.getEndereco().getId())){ | |
84 | + throw new BusinessException("ADMINISTRACAODEMATERIAIS.MSG.LOCAL_ESTOQUE_JA_VINCULADO_MATERIAL", CodigoErro.REGRA_NEGOCIO.getValue()); | |
85 | + } | |
86 | + } | |
87 | + | |
88 | + this.validarEntidade(entity, this.validator); | |
89 | + | |
90 | + if(matLocalEstTemp.getLocalPrincipal() && !entity.getLocalPrincipal()){ | |
91 | + List<MaterialLocalEstoque> locaisParMaterial = this.buscarLocaisEstoquePorIdMaterialIdAlmoxarifado(entity.getMaterialEstoque().getMaterial().getId(), entity.getEndereco().getEstoque().getAlmoxarifado().getId()); | |
92 | + if(!UtilColecao.isVazio(locaisParMaterial)){ | |
93 | + throw new BusinessException("ADMINISTRACAODEMATERIAIS.MSG.EDITA_LOCAL_ESTOQUE_MATERIAL_PRINCIPAL", CodigoErro.REGRA_NEGOCIO.getValue()); | |
94 | + } | |
95 | + } | |
96 | + | |
97 | + if(entity.getLocalPrincipal()){ | |
98 | + setLocalPrincipal(entity); | |
99 | + } | |
100 | + | |
101 | + return super.merge(entity); | |
102 | + } | |
103 | + | |
104 | + /** | |
105 | + * {@inheritDoc} | |
106 | + */ | |
107 | + @Override | |
108 | + public MaterialLocalEstoque buscarLocalEstoque(EstruturaOrganizacional almoxarifado) { | |
109 | + | |
110 | + return this.materailLocalEstoqueDao.buscarLocalEstoque(almoxarifado); | |
111 | + } | |
112 | + | |
113 | + @Override | |
114 | + public List<MaterialLocalEstoque> buscarLocaisEstoquePorIdMaterial(Long idMaterial) { | |
115 | + return this.materailLocalEstoqueDao.buscarLocaisEstoquePorIdMaterial(idMaterial); | |
116 | + } | |
117 | + | |
118 | + @Override | |
119 | + public List<MaterialLocalEstoque> buscarLocaisEstoquePorIdMaterialIdAlmoxarifado(Long idMaterial, Long idAlmoxarifado) { | |
120 | + return this.materailLocalEstoqueDao.buscarLocaisEstoquePorIdMaterialIdAlmoxarifado(idMaterial, idAlmoxarifado); | |
121 | + } | |
122 | + | |
123 | + @Override | |
124 | + public Boolean enderecoJaVinculadoAoMaterial(Long idMaterial, Long idEndereco) { | |
125 | + return this.materailLocalEstoqueDao.enderecoJaVinculadoAoMaterial(idMaterial, idEndereco); | |
126 | + } | |
127 | + | |
128 | +} | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/validation/LocalEstoqueValidator.java
... | ... | @@ -1,27 +0,0 @@ |
1 | -package br.com.centralit.api.service.validation; | |
2 | - | |
3 | -import br.com.centralit.api.model.MaterialLocalEstoque; | |
4 | -import org.springframework.stereotype.Component; | |
5 | -import org.springframework.validation.Errors; | |
6 | -import org.springframework.validation.ValidationUtils; | |
7 | -import org.springframework.validation.Validator; | |
8 | - | |
9 | -import br.com.centralit.framework.exception.CodigoErro; | |
10 | - | |
11 | -@Component("localEstoqueValidator") | |
12 | -public class LocalEstoqueValidator implements Validator { | |
13 | - | |
14 | - @Override | |
15 | - public boolean supports(Class<?> clazz) { | |
16 | - | |
17 | - return MaterialLocalEstoque.class.isAssignableFrom(clazz); | |
18 | - } | |
19 | - | |
20 | - @Override | |
21 | - public void validate(Object target, Errors errors) { | |
22 | - | |
23 | - ValidationUtils.rejectIfEmpty(errors, "almoxarifado", CodigoErro.VALIDACAO_CAMPOS_OBRIGATORIOS.getValue().toString(), "ALMOXARIFADO.LABEL.ALMOXARIFADO"); | |
24 | - | |
25 | - } | |
26 | -} | |
27 | - |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/validation/MaterialLocalEstoqueValidator.java
0 → 100644
... | ... | @@ -0,0 +1,29 @@ |
1 | +package br.com.centralit.api.service.validation; | |
2 | + | |
3 | +import br.com.centralit.api.model.MaterialLocalEstoque; | |
4 | +import org.springframework.stereotype.Component; | |
5 | +import org.springframework.validation.Errors; | |
6 | +import org.springframework.validation.ValidationUtils; | |
7 | +import org.springframework.validation.Validator; | |
8 | + | |
9 | +import br.com.centralit.framework.exception.CodigoErro; | |
10 | + | |
11 | +@Component("materialLocalEstoqueValidator") | |
12 | +public class MaterialLocalEstoqueValidator implements Validator { | |
13 | + | |
14 | + @Override | |
15 | + public boolean supports(Class<?> clazz) { | |
16 | + | |
17 | + return MaterialLocalEstoque.class.isAssignableFrom(clazz); | |
18 | + } | |
19 | + | |
20 | + @Override | |
21 | + public void validate(Object target, Errors errors) { | |
22 | + | |
23 | + ValidationUtils.rejectIfEmpty(errors, "endereco", CodigoErro.VALIDACAO_CAMPOS_OBRIGATORIOS.getValue().toString(), "ALMOXARIFADO.LABEL.ENDERECO_ESTOQUE"); | |
24 | + | |
25 | + ValidationUtils.rejectIfEmpty(errors, "quantidade", CodigoErro.VALIDACAO_CAMPOS_OBRIGATORIOS.getValue().toString(), "LABEL.CAPACIDADE"); | |
26 | + | |
27 | + } | |
28 | +} | |
29 | + | ... | ... |
cit-almoxarifado-web/src/main/java/br/com/centralit/controller/EnderecoEstoqueController.java
... | ... | @@ -67,40 +67,55 @@ public class EnderecoEstoqueController extends GenericController<EnderecoEstoque |
67 | 67 | @RequestMapping(value = "/enderecoEstoqueSuperiorEFilhosTemVinculoMaterial", method = RequestMethod.GET, produces = "application/json") |
68 | 68 | @ResponseBody |
69 | 69 | public ResponseBodyWrapper enderecoEstoqueSuperiorEFilhosTemVinculoMaterial(@RequestParam(value = "idEnderecoEstoque") Long idEnderecoEstoque) { |
70 | + boolean naoPermiteRemover = false; | |
70 | 71 | StringBuilder mensagemValidacao = new StringBuilder(); |
71 | - | |
72 | + mensagemValidacao.append("<ul>"); | |
72 | 73 | EnderecoEstoque enderecoEstoque = this.enderecoEstoqueService.find(idEnderecoEstoque); |
73 | 74 | |
74 | 75 | if(!UtilColecao.isVazio(enderecoEstoque.getMateriais())){ |
75 | - mensagemValidacao.append(this.internacionalizacaoService.getTranslate("ALMOXARIFADO.LABEL.ENDERECO_SUPERIOR", this.getIdioma())); | |
76 | - mensagemValidacao.append(": "); | |
77 | - mensagemValidacao.append(enderecoEstoque.getDescricao()); | |
78 | - mensagemValidacao.append("<p>"); | |
76 | + mensagemValidacao.append("<li>"); | |
79 | 77 | mensagemValidacao.append(this.internacionalizacaoService.getTranslate("ALMOXARIFADO.LABEL.MATERAIS_VINCULADOS", this.getIdioma())); |
80 | - mensagemValidacao.append("</p>"); | |
78 | + mensagemValidacao.append("</li>"); | |
79 | + naoPermiteRemover = true; | |
81 | 80 | } |
82 | 81 | |
83 | 82 | List<EnderecoEstoque> vinculos = this.enderecoEstoqueService.enderecoEstoqueSuperiorVinculado(idEnderecoEstoque); |
84 | 83 | if(!UtilColecao.isVazio(vinculos)){ |
85 | 84 | for (EnderecoEstoque enderecoEstoqueFilho : vinculos) { |
86 | 85 | if(!UtilColecao.isVazio(enderecoEstoqueFilho.getMateriais())){ |
86 | + mensagemValidacao.append("<li>"); | |
87 | 87 | mensagemValidacao.append(this.internacionalizacaoService.getTranslate("ALMOXARIFADO.LABEL.ENDERECO_ESTOQUE_VINCULADO_SUPERIOR", this.getIdioma())); |
88 | - mensagemValidacao.append(": "); | |
88 | + mensagemValidacao.append("<b>"); | |
89 | 89 | mensagemValidacao.append(enderecoEstoqueFilho.getDescricao()); |
90 | + mensagemValidacao.append("</b>"); | |
90 | 91 | mensagemValidacao.append("<p>"); |
91 | 92 | mensagemValidacao.append(this.internacionalizacaoService.getTranslate("ALMOXARIFADO.LABEL.MATERAIS_VINCULADOS", this.getIdioma())); |
92 | 93 | mensagemValidacao.append("</p>"); |
94 | + mensagemValidacao.append("</li>"); | |
95 | + naoPermiteRemover = true; | |
93 | 96 | } |
94 | 97 | } |
95 | 98 | } |
96 | - | |
97 | - if(mensagemValidacao.length() > 0){ | |
98 | - mensagemValidacao.insert(0, this.internacionalizacaoService.getTranslate("ALMOXARIFADO.VALIDACAO.REMOVER_ENDERECO_ESTOQUE_NEGADA_MOTIVO", this.getIdioma()) + "<br>"); | |
99 | + mensagemValidacao.append("</ul>"); | |
100 | + if(naoPermiteRemover){ | |
101 | + mensagemValidacao.append(""); | |
102 | + mensagemValidacao.insert(0, "<b>" + this.internacionalizacaoService.getTranslate("ALMOXARIFADO.VALIDACAO.REMOVER_ENDERECO_ESTOQUE_NEGADA_MOTIVO", this.getIdioma()) + "</b><br><br>"); | |
103 | + }else{ | |
104 | + mensagemValidacao = new StringBuilder(); | |
99 | 105 | } |
100 | 106 | |
101 | 107 | return new ResponseBodyWrapper(mensagemValidacao.toString(), getEditView()); |
102 | 108 | } |
103 | 109 | |
110 | + @RequestMapping(value = "/listarEnderecosEstoque", method = RequestMethod.GET, produces = "application/json") | |
111 | + @ResponseBody | |
112 | + public ResponseBodyWrapper listarEnderecosEstoque(@RequestParam(value = "value") String value, @RequestParam(value = "idAlmoxarifado") Long idAlmoxarifado) { | |
113 | + | |
114 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(this.enderecoEstoqueService.listarEnderecosEstoquePorAlmoxarifado(value, idAlmoxarifado), getAutoCompleteView()); | |
115 | + | |
116 | + return responseBody; | |
117 | + } | |
118 | + | |
104 | 119 | @Override |
105 | 120 | public Class<EnderecoEstoqueView> getEditView() { |
106 | 121 | ... | ... |
cit-almoxarifado-web/src/main/java/br/com/centralit/controller/MaterialEnderecoEstoqueController.java
0 → 100644
... | ... | @@ -0,0 +1,25 @@ |
1 | +package br.com.centralit.controller; | |
2 | + | |
3 | +import org.springframework.beans.factory.annotation.Autowired; | |
4 | +import org.springframework.stereotype.Controller; | |
5 | +import org.springframework.web.bind.annotation.RequestMapping; | |
6 | + | |
7 | +import br.com.centralit.api.model.MaterialEstoque; | |
8 | +import br.com.centralit.api.service.MaterialEstoqueService; | |
9 | +import br.com.centralit.framework.controller.GenericController; | |
10 | + | |
11 | +@Controller | |
12 | +@RequestMapping("/rest/materialEnderecoEstoque") | |
13 | +public class MaterialEnderecoEstoqueController extends GenericController<MaterialEstoque>{ | |
14 | + | |
15 | + private MaterialEstoqueService materialEstoqueService; | |
16 | + | |
17 | + | |
18 | + @Autowired | |
19 | + public MaterialEnderecoEstoqueController(MaterialEstoqueService materialEstoqueService) { | |
20 | + super(materialEstoqueService); | |
21 | + this.materialEstoqueService = materialEstoqueService; | |
22 | + } | |
23 | + | |
24 | + | |
25 | +} | ... | ... |
cit-almoxarifado-web/src/main/java/br/com/centralit/controller/MaterialLocalEstoqueController.java
0 → 100644
... | ... | @@ -0,0 +1,61 @@ |
1 | +package br.com.centralit.controller; | |
2 | + | |
3 | +import org.springframework.beans.factory.annotation.Autowired; | |
4 | +import org.springframework.stereotype.Controller; | |
5 | +import org.springframework.web.bind.annotation.RequestMapping; | |
6 | +import org.springframework.web.bind.annotation.RequestMethod; | |
7 | +import org.springframework.web.bind.annotation.RequestParam; | |
8 | +import org.springframework.web.bind.annotation.ResponseBody; | |
9 | + | |
10 | +import br.com.centralit.api.model.MaterialLocalEstoque; | |
11 | +import br.com.centralit.api.service.MaterialLocalEstoqueService; | |
12 | +import br.com.centralit.framework.controller.GenericController; | |
13 | +import br.com.centralit.framework.json.ResponseBodyWrapper; | |
14 | +import br.com.centralit.framework.json.Views; | |
15 | +import br.com.centralit.framework.json.Views.MaterialLocalEstoqueView; | |
16 | + | |
17 | +@Controller | |
18 | +@RequestMapping("/rest/materialLocalEstoque") | |
19 | +public class MaterialLocalEstoqueController extends GenericController<MaterialLocalEstoque>{ | |
20 | + | |
21 | + private MaterialLocalEstoqueService materialLocalEstoqueService; | |
22 | + | |
23 | + | |
24 | + @Autowired | |
25 | + public MaterialLocalEstoqueController(MaterialLocalEstoqueService materialLocalEstoqueService) { | |
26 | + super(materialLocalEstoqueService); | |
27 | + this.materialLocalEstoqueService = materialLocalEstoqueService; | |
28 | + } | |
29 | + | |
30 | + @RequestMapping(value = "/listarMaterialEstoquePorMaterial", method = RequestMethod.GET, produces = "application/json") | |
31 | + @ResponseBody | |
32 | + public ResponseBodyWrapper listarMaterialEstoquePorMaterial(@RequestParam(value = "idMaterial") Long idMaterial) { | |
33 | + | |
34 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(this.materialLocalEstoqueService.buscarLocaisEstoquePorIdMaterial(idMaterial), getEditView()); | |
35 | + | |
36 | + return responseBody; | |
37 | + } | |
38 | + | |
39 | + @RequestMapping(value = "/buscarLocaisEstoquePorIdMaterialIdAlmoxarifado", method = RequestMethod.GET, produces = "application/json") | |
40 | + @ResponseBody | |
41 | + public ResponseBodyWrapper buscarLocaisEstoquePorIdMaterialIdAlmoxarifado(@RequestParam(value = "idMaterial") Long idMaterial, @RequestParam(value = "idAlmoxarifado") Long idAlmoxarifado) { | |
42 | + | |
43 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(this.materialLocalEstoqueService.buscarLocaisEstoquePorIdMaterialIdAlmoxarifado(idMaterial, idAlmoxarifado), getEditView()); | |
44 | + | |
45 | + return responseBody; | |
46 | + } | |
47 | + | |
48 | + @RequestMapping(value = "/enderecoJaVinculadoAoMaterial", method = RequestMethod.GET, produces = "application/json") | |
49 | + @ResponseBody | |
50 | + public Boolean enderecoJaVinculadoAoMaterial(@RequestParam(value = "idMaterial") Long idMaterial, @RequestParam(value = "idEndereco") Long idEndereco) { | |
51 | + | |
52 | + return this.materialLocalEstoqueService.enderecoJaVinculadoAoMaterial(idMaterial, idEndereco); | |
53 | + } | |
54 | + | |
55 | + @Override | |
56 | + public Class<MaterialLocalEstoqueView> getEditView() { | |
57 | + | |
58 | + return Views.MaterialLocalEstoqueView.class; | |
59 | + } | |
60 | + | |
61 | +} | ... | ... |
cit-almoxarifado-web/src/main/java/br/com/centralit/listener/StartupListenerAlmoxarifado.java
... | ... | @@ -298,8 +298,8 @@ public class StartupListenerAlmoxarifado extends UtilStartup implements Applicat |
298 | 298 | internacionalizacaoList.add(new Internacionalizacao("ALMOXARIFADO.LABEL.ENDERECO_SUPERIOR_DESCRICAO", "Desc. endereço superior", dominio, modulo)); |
299 | 299 | internacionalizacaoList.add(new Internacionalizacao("ALMOXARIFADO.LABEL.ACOMODA_MATERIAL", "Acomoda materiais", dominio, modulo)); |
300 | 300 | internacionalizacaoList.add(new Internacionalizacao("ALMOXARIFADO.LABEL.ENDERECO_ESTOQUE_TODOS_MATERIAL", "Adicionar endereço para todos os materiais", dominio, modulo)); |
301 | - internacionalizacaoList.add(new Internacionalizacao("ALMOXARIFADO.LABEL.MATERAIS_VINCULADOS", "Existe materiais vinculados", dominio, modulo)); | |
302 | - internacionalizacaoList.add(new Internacionalizacao("ALMOXARIFADO.LABEL.ENDERECO_ESTOQUE_VINCULADO_SUPERIOR", "Endereço de estoque vinculado ao endereço superior", dominio, modulo)); | |
301 | + internacionalizacaoList.add(new Internacionalizacao("ALMOXARIFADO.LABEL.MATERAIS_VINCULADOS", "Existe materiais vinculados a este endereço", dominio, modulo)); | |
302 | + internacionalizacaoList.add(new Internacionalizacao("ALMOXARIFADO.LABEL.ENDERECO_ESTOQUE_VINCULADO_SUPERIOR", "Endereço de estoque: ", dominio, modulo)); | |
303 | 303 | |
304 | 304 | //Entrada de materiais |
305 | 305 | internacionalizacaoList.add(new Internacionalizacao("ALMOXARIFADO.LABEL.DADOS_ENTRADA", "Dados da entrada", dominio, modulo)); |
... | ... | @@ -329,7 +329,7 @@ public class StartupListenerAlmoxarifado extends UtilStartup implements Applicat |
329 | 329 | internacionalizacaoList.add(new Internacionalizacao("ALMOXARIFADO.VALIDACAO.REMOVER_ENDERECO_ESTOQUE_NEGADA", "O endereço não pode ser removido, pois está vinculado a um material de consumo", dominio, modulo)); |
330 | 330 | internacionalizacaoList.add(new Internacionalizacao("ALMOXARIFADO.VALIDACAO.NAO_PERMITIDO_ENDERECO_ESTOQUE_ACOMODA_MATERIAL", "Não foi permitido atualizar o registro, o endereço em questão é um endereço superior de outros endereços, logo não é possivel indicar o endereço como uma acomodação de materiais.", dominio, modulo)); |
331 | 331 | internacionalizacaoList.add(new Internacionalizacao("ALMOXARIFADO.VALIDACAO.NAO_PERMITIDO_REMOVER_ENDERECO_ESTOQUE_END_SUPERIOR_VINCULO", "Remoção não permitida. O endereço de estoque a ser removido tem vínculo como endereço superior de outros endereços. Para remover este endereço, desvincule primeiramente dos demais endereços.", dominio, modulo)); |
332 | - internacionalizacaoList.add(new Internacionalizacao("ALMOXARIFADO.VALIDACAO.REMOVER_ENDERECO_ESTOQUE_NEGADA_MOTIVO", "Remoção endereço estoque negada, pelos motivos", dominio, modulo)); | |
332 | + internacionalizacaoList.add(new Internacionalizacao("ALMOXARIFADO.VALIDACAO.REMOVER_ENDERECO_ESTOQUE_NEGADA_MOTIVO", "Remoção endereço estoque negada", dominio, modulo)); | |
333 | 333 | internacionalizacaoList.add(new Internacionalizacao("ALMOXARIFADO.VALIDACAO.ENDERECO_ESTOQUE_IS_SUPERIOR_REMOVER", "O endereço de estoque a ser removido, foi vinculado como superior a outros endereço. Caso prossiga com a operação, também será removido todos os endereços vinculados a este. Deseja continuar?", dominio, modulo)); |
334 | 334 | internacionalizacaoList.add(new Internacionalizacao("ALMOXARIFADO.VALIDACAO.ENDERECO_ESTOQUE_TODOS_MATERIAIS", "A definição de endereço de estoque para todos os materias não poderá ser desfeita após salvar o registro. Deseja realmente adicionar este endereço para todos os materiais?", dominio, modulo)); |
335 | 335 | internacionalizacaoList.add(new Internacionalizacao("ALMOXARIFADO.VALIDACAO.ENDERECO_ESTOQUE_VINCULO_CICLICO", "Não é permitido vincular o endereço de estoque superior, pois este endereço tem como endereço superior o registro que está sendo alterado. Favor remover ou escolher outro endereço de estoque superior.", dominio, modulo)); | ... | ... |
cit-almoxarifado-web/src/main/webapp/assets/js/angular/custom/controller/EnderecoEstoqueController.js
... | ... | @@ -131,6 +131,14 @@ citApp.controller('EnderecoEstoqueController', ['$scope', 'EnderecoEstoqueReposi |
131 | 131 | }); |
132 | 132 | }; |
133 | 133 | |
134 | + $scope.validaEnderecoAcomodaMaterial = function(){ | |
135 | + $timeout(function(){ | |
136 | + if(!$scope.enderecoEstoque.acomodaMaterial){ | |
137 | + $scope.enderecoEstoque.enderTodoMaterial = false; | |
138 | + } | |
139 | + }); | |
140 | + }; | |
141 | + | |
134 | 142 | $scope.validaEnderecoTodosMaterial = function(){ |
135 | 143 | $timeout(function(){ |
136 | 144 | if($scope.enderecoEstoque.enderTodoMaterial){ |
... | ... | @@ -152,6 +160,8 @@ citApp.controller('EnderecoEstoqueController', ['$scope', 'EnderecoEstoqueReposi |
152 | 160 | $scope.bloquearAcomodacaoMaterial = true; |
153 | 161 | }else if($scope.enderecoEstoque.materiais && $scope.enderecoEstoque.materiais.length > 0 && $scope.enderecoEstoque.id){ |
154 | 162 | $scope.bloquearAcomodacaoMaterial = true; |
163 | + }else if($scope.enderecoEstoque.enderTodoMaterial){ | |
164 | + $scope.bloquearAcomodacaoMaterial = true; | |
155 | 165 | }else{ |
156 | 166 | $scope.bloquearAcomodacaoMaterial = false; |
157 | 167 | } | ... | ... |
cit-almoxarifado-web/src/main/webapp/assets/js/angular/custom/repository/EnderecoEstoqueRepository.js
... | ... | @@ -12,6 +12,10 @@ citApp.factory('EnderecoEstoqueRepository', ['RestangularAlmoxarifado', 'Abstrac |
12 | 12 | this.enderecoEstoqueSuperiorEFilhosTemVinculoMaterial = function(idEnderecoEstoque) { |
13 | 13 | return restangularAlmoxarifado.one(this.route + "/enderecoEstoqueSuperiorEFilhosTemVinculoMaterial").get({'idEnderecoEstoque': idEnderecoEstoque}).then(); |
14 | 14 | }; |
15 | + | |
16 | + this.listarEnderecosEstoque = function(value, idAlmoxarifado) { | |
17 | + return restangularAlmoxarifado.one(this.route + "/listarEnderecosEstoque").get({"value": value, "idAlmoxarifado" : idAlmoxarifado}).then(); | |
18 | + }; | |
15 | 19 | |
16 | 20 | } |
17 | 21 | ... | ... |
cit-almoxarifado-web/src/main/webapp/assets/js/angular/custom/repository/MaterialEnderecoEstoqueRepository.js
0 → 100644
... | ... | @@ -0,0 +1,12 @@ |
1 | +'use strict'; | |
2 | + | |
3 | +citApp.factory('MaterialEnderecoEstoqueRepository', ['RestangularAlmoxarifado', 'AbstractRepository', function (restangularAlmoxarifado, AbstractRepository) { | |
4 | + | |
5 | + function MaterialEnderecoEstoqueRepository() { | |
6 | + AbstractRepository.call(this, restangularAlmoxarifado, 'rest/materialEnderecoEstoque'); | |
7 | + } | |
8 | + | |
9 | + AbstractRepository.extend(MaterialEnderecoEstoqueRepository); | |
10 | + | |
11 | + return new MaterialEnderecoEstoqueRepository(); | |
12 | +}]); | ... | ... |
cit-almoxarifado-web/src/main/webapp/assets/js/angular/custom/repository/MaterialLocalEstoqueRepository.js
0 → 100644
... | ... | @@ -0,0 +1,25 @@ |
1 | +'use strict'; | |
2 | + | |
3 | +citApp.factory('MaterialLocalEstoqueRepository', ['RestangularAlmoxarifado', 'AbstractRepository', function (restangularAlmoxarifado, AbstractRepository) { | |
4 | + | |
5 | + function MaterialLocalEstoqueRepository() { | |
6 | + | |
7 | + this.listarMaterialEstoquePorMaterial = function(idMaterial) { | |
8 | + return restangularAlmoxarifado.one(this.route + "/listarMaterialEstoquePorMaterial").get({"idMaterial": idMaterial}).then(); | |
9 | + }; | |
10 | + | |
11 | + this.buscarLocaisEstoquePorIdMaterialIdAlmoxarifado = function(idMaterial, idAlmoxarifado) { | |
12 | + return restangularAlmoxarifado.one(this.route + "/buscarLocaisEstoquePorIdMaterialIdAlmoxarifado").get({"idMaterial": idMaterial, "idAlmoxarifado": idAlmoxarifado}).then(); | |
13 | + }; | |
14 | + | |
15 | + this.enderecoJaVinculadoAoMaterial = function(idMaterial, idEndereco) { | |
16 | + return restangularAlmoxarifado.one(this.route + "/enderecoJaVinculadoAoMaterial").get({"idMaterial": idMaterial, "idEndereco": idEndereco}).then(); | |
17 | + }; | |
18 | + | |
19 | + AbstractRepository.call(this, restangularAlmoxarifado, 'rest/materialLocalEstoque'); | |
20 | + } | |
21 | + | |
22 | + AbstractRepository.extend(MaterialLocalEstoqueRepository); | |
23 | + | |
24 | + return new MaterialLocalEstoqueRepository(); | |
25 | +}]); | ... | ... |
cit-almoxarifado-web/src/main/webapp/html/enderecoEstoque/enderecoEstoqueEdit.html
... | ... | @@ -72,11 +72,11 @@ |
72 | 72 | <auto-complete ng-id="enderecoEstoque.endeEstoqSuperior" ng-label="ALMOXARIFADO.LABEL.ENDERECO_SUPERIOR" ng-model="enderecoEstoque.endeEstoqSuperior" form="enderecoEstoqueForm" ng-disabled="!edit" ng-find="findAutoCompleteEnderecoSuperior(value)" ng-item="item.codigo + ' / ' + item.descricao" /> |
73 | 73 | </div> |
74 | 74 | <div class="col-sm-4"> |
75 | - <label-input-checkbox ng-model="enderecoEstoque.acomodaMaterial" ng-disabled="bloquearAcomodacaoMaterial" ng-label="ALMOXARIFADO.LABEL.ACOMODA_MATERIAL" form="enderecoEstoqueForm"/> | |
75 | + <label-input-checkbox ng-model="enderecoEstoque.acomodaMaterial" ng-disabled="bloquearAcomodacaoMaterial" ng-label="ALMOXARIFADO.LABEL.ACOMODA_MATERIAL" form="enderecoEstoqueForm" ng-custom-change="validaEnderecoAcomodaMaterial()"/> | |
76 | 76 | </div> |
77 | 77 | </div> |
78 | 78 | |
79 | - <div class="row"> | |
79 | + <div class="row" ng-show="enderecoEstoque.acomodaMaterial"> | |
80 | 80 | <div class="col-sm-12"> |
81 | 81 | <label-input-checkbox ng-model="enderecoEstoque.enderTodoMaterial" ng-disabled="bloquearEnderecoTotalMaterial" ng-label="ALMOXARIFADO.LABEL.ENDERECO_ESTOQUE_TODOS_MATERIAL" form="enderecoEstoqueForm" ng-custom-change="validaEnderecoTodosMaterial()"/> |
82 | 82 | </div> | ... | ... |
cit-almoxarifado-web/src/test/java/br/com/centralit/controller/impl/LocalEstoqueControllerTest.java
... | ... | @@ -14,7 +14,7 @@ import org.springframework.test.context.web.WebAppConfiguration; |
14 | 14 | import br.com.centralit.framework.model.Filter; |
15 | 15 | import br.com.centralit.framework.model.SearchParams; |
16 | 16 | |
17 | -import br.com.centralit.api.dao.LocalEstoqueDao; | |
17 | +import br.com.centralit.api.dao.MaterialLocalEstoqueDao; | |
18 | 18 | import br.com.centralit.api.model.MaterialLocalEstoque; |
19 | 19 | import br.com.centralit.api.service.MaterialLocalEstoqueService; |
20 | 20 | import br.com.centralit.controller.LocalEstoqueController; |
... | ... | @@ -31,7 +31,7 @@ public class LocalEstoqueControllerTest extends GenericControllerTestImpl<Materi |
31 | 31 | private MaterialLocalEstoqueService localEstoqueService; |
32 | 32 | |
33 | 33 | @Autowired |
34 | - private LocalEstoqueDao localEstoqueDao; | |
34 | + private MaterialLocalEstoqueDao localEstoqueDao; | |
35 | 35 | |
36 | 36 | @Override |
37 | 37 | protected void initMocks() { | ... | ... |