Rev 509 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 508 | blopes | 1 | package br.com.ec.domain.dto; |
| 2 | |||
| 516 | blopes | 3 | import java.util.ArrayList; |
| 508 | blopes | 4 | import java.util.Date; |
| 509 | blopes | 5 | import java.util.List; |
| 516 | blopes | 6 | import java.util.Objects; |
| 508 | blopes | 7 | |
| 516 | blopes | 8 | import br.com.ec.core.util.VerificadorUtil; |
| 9 | import br.com.ec.domain.model.TransferenciaProduto; |
||
| 10 | |||
| 508 | blopes | 11 | public class TransferenciaDTO { |
| 12 | |||
| 13 | private Long sequencial; |
||
| 14 | private LojaDTO lojaSaidaDTO; |
||
| 15 | private LojaDTO lojaEntradaDTO; |
||
| 16 | private Boolean conferido; |
||
| 17 | private Date dataSolicitacao; |
||
| 18 | private Date dataFinalizacao; |
||
| 509 | blopes | 19 | |
| 20 | private List<TransferenciaProdutoDTO> produtosDTO; |
||
| 21 | |||
| 508 | blopes | 22 | // private NotaFiscal notaFiscalRemessa; |
| 23 | // private Date dataHoraInicioTransporte; |
||
| 24 | // private Usuario usuarioTransportador; |
||
| 25 | // private Usuario usuarioReceptor; |
||
| 26 | |||
| 27 | // private List<TransferenciaProduto> listaProdutos; |
||
| 516 | blopes | 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() {} |
||
| 508 | blopes | 40 | |
| 41 | public Long getSequencial() { |
||
| 42 | return sequencial; |
||
| 43 | } |
||
| 44 | public void setSequencial(Long sequencial) { |
||
| 45 | this.sequencial = sequencial; |
||
| 46 | } |
||
| 47 | |||
| 48 | public LojaDTO getLojaSaidaDTO() { |
||
| 49 | return lojaSaidaDTO; |
||
| 50 | } |
||
| 51 | public void setLojaSaidaDTO(LojaDTO lojaSaidaDTO) { |
||
| 52 | this.lojaSaidaDTO = lojaSaidaDTO; |
||
| 53 | } |
||
| 54 | |||
| 55 | public LojaDTO getLojaEntradaDTO() { |
||
| 56 | return lojaEntradaDTO; |
||
| 57 | } |
||
| 58 | public void setLojaEntradaDTO(LojaDTO lojaEntradaDTO) { |
||
| 59 | this.lojaEntradaDTO = lojaEntradaDTO; |
||
| 60 | } |
||
| 61 | |||
| 62 | public Boolean getConferido() { |
||
| 63 | return conferido; |
||
| 64 | } |
||
| 65 | public void setConferido(Boolean conferido) { |
||
| 66 | this.conferido = conferido; |
||
| 67 | } |
||
| 68 | |||
| 69 | public Date getDataSolicitacao() { |
||
| 70 | return dataSolicitacao; |
||
| 71 | } |
||
| 72 | public void setDataSolicitacao(Date dataSolicitacao) { |
||
| 73 | this.dataSolicitacao = dataSolicitacao; |
||
| 74 | } |
||
| 75 | |||
| 76 | public Date getDataFinalizacao() { |
||
| 77 | return dataFinalizacao; |
||
| 78 | } |
||
| 79 | public void setDataFinalizacao(Date dataFinalizacao) { |
||
| 80 | this.dataFinalizacao = dataFinalizacao; |
||
| 81 | } |
||
| 82 | |||
| 509 | blopes | 83 | public List<TransferenciaProdutoDTO> getProdutosDTO() { |
| 84 | return produtosDTO; |
||
| 85 | } |
||
| 86 | public void setProdutosDTO(List<TransferenciaProdutoDTO> produtosDTO) { |
||
| 87 | this.produtosDTO = produtosDTO; |
||
| 88 | } |
||
| 89 | |||
| 516 | blopes | 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); |
||
| 160 | } |
||
| 161 | |||
| 508 | blopes | 162 | } |