Rev 509 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 509 | Rev 516 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | package br.com.ec.domain.dto; |
1 | package br.com.ec.domain.dto; |
| 2 | 2 | ||
| - | 3 | import java.util.ArrayList; |
|
| 3 | import java.util.Date; |
4 | import java.util.Date; |
| 4 | import java.util.List; |
5 | import java.util.List; |
| - | 6 | import java.util.Objects; |
|
| - | 7 | ||
| - | 8 | import br.com.ec.core.util.VerificadorUtil; |
|
| - | 9 | import br.com.ec.domain.model.TransferenciaProduto; |
|
| 5 | 10 | ||
| 6 | public class TransferenciaDTO { |
11 | public class TransferenciaDTO { |
| 7 | 12 | ||
| 8 | private Long sequencial; |
13 | private Long sequencial; |
| 9 | private LojaDTO lojaSaidaDTO; |
14 | private LojaDTO lojaSaidaDTO; |
| Line 18... | Line 23... | ||
| 18 | // private Date dataHoraInicioTransporte;
|
23 | // private Date dataHoraInicioTransporte;
|
| 19 | // private Usuario usuarioTransportador;
|
24 | // private Usuario usuarioTransportador;
|
| 20 | // private Usuario usuarioReceptor;
|
25 | // private Usuario usuarioReceptor;
|
| 21 | 26 | ||
| 22 | // private List<TransferenciaProduto> listaProdutos;
|
27 | // private List<TransferenciaProduto> listaProdutos;
|
| - | 28 | ||
| - | 29 | public static String CONSULTA_DTO_COMPLETO = "e.sequencial, e.lojaSaida.sequencial, e.lojaEntrada.sequencial, e.conferido, e.dataSolicitacao, e.dataFinalizacao"; |
|
| - | 30 | public TransferenciaDTO(Long sequencial, Long sequencialLojaSaida, Long sequencialLojaEntrada, Boolean conferido, Date dataSolicitacao, Date dataFinalizacao) { |
|
| - | 31 | this.sequencial = sequencial; |
|
| - | 32 | this.lojaSaidaDTO = new LojaDTO(sequencialLojaSaida); |
|
| - | 33 | this.lojaEntradaDTO = new LojaDTO(sequencialLojaEntrada); |
|
| - | 34 | this.conferido = conferido; |
|
| - | 35 | this.dataSolicitacao = dataSolicitacao; |
|
| - | 36 | this.dataFinalizacao = dataFinalizacao; |
|
| - | 37 | }
|
|
| - | 38 | ||
| - | 39 | public TransferenciaDTO() {} |
|
| 23 | 40 | ||
| 24 | public Long getSequencial() { |
41 | public Long getSequencial() { |
| 25 | return sequencial; |
42 | return sequencial; |
| 26 | }
|
43 | }
|
| 27 | public void setSequencial(Long sequencial) { |
44 | public void setSequencial(Long sequencial) { |
| Line 66... | Line 83... | ||
| 66 | public List<TransferenciaProdutoDTO> getProdutosDTO() { |
83 | public List<TransferenciaProdutoDTO> getProdutosDTO() { |
| 67 | return produtosDTO; |
84 | return produtosDTO; |
| 68 | }
|
85 | }
|
| 69 | public void setProdutosDTO(List<TransferenciaProdutoDTO> produtosDTO) { |
86 | public void setProdutosDTO(List<TransferenciaProdutoDTO> produtosDTO) { |
| 70 | this.produtosDTO = produtosDTO; |
87 | this.produtosDTO = produtosDTO; |
| - | 88 | }
|
|
| - | 89 | ||
| - | 90 | /*********************************************/
|
|
| - | 91 | ||
| - | 92 | public Long sequencialDaLojaSaida() { |
|
| - | 93 | return VerificadorUtil.naoEstaNulo(getLojaSaidaDTO())? getLojaSaidaDTO().getSequencial() : null; |
|
| - | 94 | }
|
|
| - | 95 | public Long sequencialDaLojaEntrada() { |
|
| - | 96 | return VerificadorUtil.naoEstaNulo(getLojaEntradaDTO())? getLojaEntradaDTO().getSequencial() : null; |
|
| - | 97 | }
|
|
| - | 98 | ||
| - | 99 | public void adicionarProduto(TransferenciaProdutoDTO transferenciaProdutoDTO) { |
|
| - | 100 | if (VerificadorUtil.estaNulo(getProdutosDTO())) { |
|
| - | 101 | setProdutosDTO(new ArrayList<TransferenciaProdutoDTO>()); |
|
| - | 102 | }
|
|
| - | 103 | TransferenciaProdutoDTO transferenciaProdutoNaListaDTO = retornarSeProdutoConstaNaLista(transferenciaProdutoDTO); |
|
| - | 104 | if (VerificadorUtil.estaNulo(transferenciaProdutoNaListaDTO)) { |
|
| - | 105 | getProdutosDTO().add(transferenciaProdutoDTO); |
|
| - | 106 | } else { |
|
| - | 107 | getProdutosDTO().remove(transferenciaProdutoNaListaDTO); |
|
| - | 108 | transferenciaProdutoDTO.setQuantidadeTransferir(transferenciaProdutoNaListaDTO.getQuantidadeTransferir() + transferenciaProdutoDTO.getQuantidadeTransferir()); |
|
| - | 109 | getProdutosDTO().add(transferenciaProdutoDTO); |
|
| - | 110 | }
|
|
| - | 111 | }
|
|
| - | 112 | ||
| - | 113 | public TransferenciaProdutoDTO retornarSeProdutoConstaNaLista(TransferenciaProdutoDTO transferenciaProdutoDTO) { |
|
| - | 114 | if (VerificadorUtil.estaNulo(getProdutosDTO())) { |
|
| - | 115 | setProdutosDTO(new ArrayList<TransferenciaProdutoDTO>()); |
|
| - | 116 | }
|
|
| - | 117 | for (TransferenciaProdutoDTO item : getProdutosDTO()) { |
|
| - | 118 | if (item.getSequencialDoProduto().equals(transferenciaProdutoDTO.getSequencialDoProduto()) && |
|
| - | 119 | item.getTransferenciaDTO().sequencialDaLojaSaida().equals(transferenciaProdutoDTO.getTransferenciaDTO().sequencialDaLojaSaida()) && |
|
| - | 120 | item.getTransferenciaDTO().sequencialDaLojaEntrada().equals(transferenciaProdutoDTO.getTransferenciaDTO().sequencialDaLojaEntrada())) { |
|
| - | 121 | return item; |
|
| - | 122 | }
|
|
| - | 123 | }
|
|
| - | 124 | return null; |
|
| - | 125 | }
|
|
| - | 126 | ||
| - | 127 | public void removerProduto(TransferenciaProdutoDTO transferenciaProdutoDTO) { |
|
| - | 128 | if (!VerificadorUtil.isListaNulaOuVazia(getProdutosDTO())) { |
|
| - | 129 | getProdutosDTO().remove(transferenciaProdutoDTO); |
|
| - | 130 | }
|
|
| - | 131 | }
|
|
| - | 132 | ||
| - | 133 | public boolean verificarSeProdutoJaConstaNaLista(TransferenciaProdutoDTO transferenciaProdutoDTO) { |
|
| - | 134 | if (VerificadorUtil.estaNulo(getProdutosDTO())) { |
|
| - | 135 | setProdutosDTO(new ArrayList<TransferenciaProdutoDTO>()); |
|
| - | 136 | }
|
|
| - | 137 | for (TransferenciaProdutoDTO item : getProdutosDTO()) { |
|
| - | 138 | if (item.equals(transferenciaProdutoDTO)) { |
|
| - | 139 | return true; |
|
| - | 140 | }
|
|
| - | 141 | }
|
|
| - | 142 | return false; |
|
| - | 143 | }
|
|
| - | 144 | ||
| - | 145 | @Override |
|
| - | 146 | public int hashCode() { |
|
| - | 147 | return Objects.hash(sequencial); |
|
| - | 148 | }
|
|
| - | 149 | ||
| - | 150 | @Override |
|
| - | 151 | public boolean equals(Object obj) { |
|
| - | 152 | if (this == obj) |
|
| - | 153 | return true; |
|
| - | 154 | if (obj == null) |
|
| - | 155 | return false; |
|
| - | 156 | if (getClass() != obj.getClass()) |
|
| - | 157 | return false; |
|
| - | 158 | TransferenciaDTO other = (TransferenciaDTO) obj; |
|
| - | 159 | return Objects.equals(sequencial, other.sequencial); |
|
| 71 | }
|
160 | }
|
| 72 | 161 | ||
| 73 | }
|
162 | }
|