Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package br.com.ec.domain.model; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.time.Duration; |
||
| 5 | import java.time.LocalTime; |
||
| 6 | import java.util.Calendar; |
||
| 7 | import java.util.Date; |
||
| 8 | import java.util.GregorianCalendar; |
||
| 9 | |||
| 10 | import javax.persistence.Column; |
||
| 11 | import javax.persistence.Entity; |
||
| 12 | import javax.persistence.GeneratedValue; |
||
| 13 | import javax.persistence.GenerationType; |
||
| 14 | import javax.persistence.Id; |
||
| 15 | import javax.persistence.JoinColumn; |
||
| 16 | import javax.persistence.ManyToOne; |
||
| 17 | import javax.persistence.Table; |
||
| 18 | import javax.persistence.Transient; |
||
| 19 | import javax.validation.constraints.NotNull; |
||
| 20 | |||
| 21 | import org.hibernate.annotations.ForeignKey; |
||
| 22 | |||
| 23 | import br.edu.cesmac.core.interfaces.Alterar; |
||
| 24 | import br.edu.cesmac.core.interfaces.Cadastrar; |
||
| 25 | import br.edu.cesmac.core.util.DataUtils; |
||
| 26 | import br.edu.cesmac.core.util.StringUtil; |
||
| 27 | import br.edu.cesmac.core.util.VerificadorUtil; |
||
| 28 | |||
| 29 | @Entity |
||
| 30 | @Table(name="sec_ponto", schema="sc_sec") |
||
| 31 | public class Ponto implements Serializable { |
||
| 32 | |||
| 33 | private static final long serialVersionUID = 1L; |
||
| 34 | |||
| 35 | private Long sequencial; |
||
| 36 | private Loja loja; |
||
| 37 | private Pessoa pessoa; |
||
| 38 | private Date dataPonto; |
||
| 39 | private Date dataHoraPontoInicio; |
||
| 40 | private String justificativaPontoInicio; |
||
| 41 | private Date dataHoraPontoFim; |
||
| 42 | private String justificativaPontoFim; |
||
| 43 | private Date dataHoraIntervaloInicio; |
||
| 44 | private String justificativaIntervaloInicio; |
||
| 45 | private Date dataHoraIntervaloFim; |
||
| 46 | private String justificativaIntervaloFim; |
||
| 47 | private String observacao; |
||
| 48 | private Boolean indicadorAtivo = true; |
||
| 49 | |||
| 50 | @Id |
||
| 51 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 52 | @Column(name="seq_ponto", nullable=false) |
||
| 53 | public Long getSequencial() { |
||
| 54 | return sequencial; |
||
| 55 | } |
||
| 56 | public void setSequencial(Long sequencial) { |
||
| 57 | this.sequencial = sequencial; |
||
| 58 | } |
||
| 59 | |||
| 60 | @ManyToOne |
||
| 61 | @ForeignKey(name="fk_ponto_loja") |
||
| 62 | @NotNull(message = "Parâmetro obrigatório não preenchido: Loja", groups = {Cadastrar.class, Alterar.class}) |
||
| 63 | @JoinColumn(name = "seq_loja", referencedColumnName="seq_loja", nullable=false) |
||
| 64 | public Loja getLoja() { |
||
| 65 | return loja; |
||
| 66 | } |
||
| 67 | public void setLoja(Loja loja) { |
||
| 68 | this.loja = loja; |
||
| 69 | } |
||
| 70 | |||
| 71 | @ManyToOne |
||
| 72 | @ForeignKey(name="fk_ponto_pessoa") |
||
| 73 | @NotNull(message = "Parâmetro obrigatório não preenchido: Pessoa", groups = {Cadastrar.class, Alterar.class}) |
||
| 74 | @JoinColumn(name = "seq_pessoa", nullable=false) |
||
| 75 | public Pessoa getPessoa() { |
||
| 76 | return pessoa; |
||
| 77 | } |
||
| 78 | public void setPessoa(Pessoa pessoa) { |
||
| 79 | this.pessoa = pessoa; |
||
| 80 | } |
||
| 81 | |||
| 82 | @Column(name="dat_ponto") |
||
| 83 | public Date getDataPonto() { |
||
| 84 | return dataPonto; |
||
| 85 | } |
||
| 86 | public void setDataPonto(Date dataPonto) { |
||
| 87 | this.dataPonto = dataPonto; |
||
| 88 | } |
||
| 89 | |||
| 90 | @Column(name="dth_ponto_inicio") |
||
| 91 | public Date getDataHoraPontoInicio() { |
||
| 92 | return dataHoraPontoInicio; |
||
| 93 | } |
||
| 94 | public void setDataHoraPontoInicio(Date dataHoraPontoInicio) { |
||
| 95 | this.dataHoraPontoInicio = dataHoraPontoInicio; |
||
| 96 | } |
||
| 97 | |||
| 98 | @Column(name="dsc_ponto_inicio") |
||
| 99 | public String getJustificativaPontoInicio() { |
||
| 100 | return justificativaPontoInicio; |
||
| 101 | } |
||
| 102 | public void setJustificativaPontoInicio(String justificativaPontoInicio) { |
||
| 103 | this.justificativaPontoInicio = StringUtil.setarUpperCase(justificativaPontoInicio); |
||
| 104 | } |
||
| 105 | |||
| 106 | @Column(name="dth_ponto_fim") |
||
| 107 | public Date getDataHoraPontoFim() { |
||
| 108 | return dataHoraPontoFim; |
||
| 109 | } |
||
| 110 | public void setDataHoraPontoFim(Date dataHoraPontoFim) { |
||
| 111 | this.dataHoraPontoFim = dataHoraPontoFim; |
||
| 112 | } |
||
| 113 | |||
| 114 | @Column(name="dsc_ponto_fim") |
||
| 115 | public String getJustificativaPontoFim() { |
||
| 116 | return justificativaPontoFim; |
||
| 117 | } |
||
| 118 | public void setJustificativaPontoFim(String justificativaPontoFim) { |
||
| 119 | this.justificativaPontoFim = StringUtil.setarUpperCase(justificativaPontoFim); |
||
| 120 | } |
||
| 121 | |||
| 122 | @Column(name="dth_intervalo_inicio") |
||
| 123 | public Date getDataHoraIntervaloInicio() { |
||
| 124 | return dataHoraIntervaloInicio; |
||
| 125 | } |
||
| 126 | public void setDataHoraIntervaloInicio(Date dataHoraIntervaloInicio) { |
||
| 127 | this.dataHoraIntervaloInicio = dataHoraIntervaloInicio; |
||
| 128 | } |
||
| 129 | |||
| 130 | @Column(name="dsc_intervalo_inicio") |
||
| 131 | public String getJustificativaIntervaloInicio() { |
||
| 132 | return justificativaIntervaloInicio; |
||
| 133 | } |
||
| 134 | public void setJustificativaIntervaloInicio(String justificativaIntervaloInicio) { |
||
| 135 | this.justificativaIntervaloInicio = StringUtil.setarUpperCase(justificativaIntervaloInicio); |
||
| 136 | } |
||
| 137 | |||
| 138 | @Column(name="dth_intervalo_fim") |
||
| 139 | public Date getDataHoraIntervaloFim() { |
||
| 140 | return dataHoraIntervaloFim; |
||
| 141 | } |
||
| 142 | public void setDataHoraIntervaloFim(Date dataHoraIntervaloFim) { |
||
| 143 | this.dataHoraIntervaloFim = dataHoraIntervaloFim; |
||
| 144 | } |
||
| 145 | |||
| 146 | @Column(name="dsc_intervalo_fim") |
||
| 147 | public String getJustificativaIntervaloFim() { |
||
| 148 | return justificativaIntervaloFim; |
||
| 149 | } |
||
| 150 | public void setJustificativaIntervaloFim(String justificativaIntervaloFim) { |
||
| 151 | this.justificativaIntervaloFim = StringUtil.setarUpperCase(justificativaIntervaloFim); |
||
| 152 | } |
||
| 153 | |||
| 154 | @Column(name="dsc_observacao") |
||
| 155 | public String getObservacao() { |
||
| 156 | return observacao; |
||
| 157 | } |
||
| 158 | public void setObservacao(String observacao) { |
||
| 159 | this.observacao = StringUtil.setarUpperCase(observacao); |
||
| 160 | } |
||
| 161 | |||
| 162 | @Column(name="ind_ativo") |
||
| 163 | public Boolean getIndicadorAtivo() { |
||
| 164 | return indicadorAtivo; |
||
| 165 | } |
||
| 166 | public void setIndicadorAtivo(Boolean indicadorAtivo) { |
||
| 167 | this.indicadorAtivo = indicadorAtivo; |
||
| 168 | } |
||
| 169 | |||
| 170 | @Override |
||
| 171 | public int hashCode() { |
||
| 172 | final int prime = 31; |
||
| 173 | int result = 1; |
||
| 174 | result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 175 | return result; |
||
| 176 | } |
||
| 177 | |||
| 178 | @Override |
||
| 179 | public boolean equals(Object obj) { |
||
| 180 | if (this == obj) |
||
| 181 | return true; |
||
| 182 | if (obj == null) |
||
| 183 | return false; |
||
| 184 | if (getClass() != obj.getClass()) |
||
| 185 | return false; |
||
| 186 | Ponto other = (Ponto) obj; |
||
| 187 | if (sequencial == null) { |
||
| 188 | if (other.sequencial != null) |
||
| 189 | return false; |
||
| 190 | } else if (!sequencial.equals(other.sequencial)) |
||
| 191 | return false; |
||
| 192 | return true; |
||
| 193 | } |
||
| 194 | |||
| 195 | @Transient |
||
| 196 | public Long getSequencialDaLoja() { |
||
| 197 | return VerificadorUtil.naoEstaNulo(loja)? loja.getSequencial() : null; |
||
| 198 | } |
||
| 199 | |||
| 200 | @Transient |
||
| 201 | public String getDescricaoDaLoja() { |
||
| 202 | return VerificadorUtil.naoEstaNulo(loja)? loja.getDescricao() : null; |
||
| 203 | } |
||
| 204 | |||
| 205 | @Transient |
||
| 206 | public Boolean getPontoCompleto() { |
||
| 207 | return VerificadorUtil.naoEstaNulo(getDataHoraPontoInicio()) && |
||
| 208 | VerificadorUtil.naoEstaNulo(getDataHoraPontoFim()) && |
||
| 209 | VerificadorUtil.naoEstaNulo(getDataHoraIntervaloInicio()) && |
||
| 210 | VerificadorUtil.naoEstaNulo(getDataHoraIntervaloFim()); |
||
| 211 | } |
||
| 212 | |||
| 213 | @Transient |
||
| 214 | public String getHorasTrabalhadas() { |
||
| 215 | if (VerificadorUtil.naoEstaNulo(getDataHoraPontoInicio()) && VerificadorUtil.naoEstaNulo(getDataHoraPontoFim())) { |
||
| 216 | return DataUtils.calcularDiferencaEntreDatasRetornandoHorasEeMinutos(getDataHoraPontoInicio(),getDataHoraPontoFim()); |
||
| 217 | } |
||
| 218 | return null; |
||
| 219 | } |
||
| 220 | |||
| 221 | @Transient |
||
| 222 | public String getIntervalo() { |
||
| 223 | if (VerificadorUtil.naoEstaNulo(getDataHoraIntervaloInicio()) && VerificadorUtil.naoEstaNulo(getDataHoraIntervaloFim())) { |
||
| 224 | return DataUtils.calcularDiferencaEntreDatasRetornandoHorasEeMinutos(getDataHoraIntervaloInicio(),getDataHoraIntervaloFim()); |
||
| 225 | } |
||
| 226 | return null; |
||
| 227 | } |
||
| 228 | |||
| 229 | //TODO: FALTA FINALIZAR |
||
| 230 | @Transient |
||
| 231 | public Double getHorasExtras() { |
||
| 232 | if (getPontoCompleto()) { |
||
| 233 | } |
||
| 234 | return 0.0; |
||
| 235 | } |
||
| 236 | |||
| 237 | /*@Transient |
||
| 238 | public Integer getQuantidadeDiasPedido() { |
||
| 239 | return DataUtils.calcularDiferenceEmDiasEntreDuasDatas(DataUtils.getDataAtual(), getDataPedido()); |
||
| 240 | } |
||
| 241 | |||
| 242 | @Transient |
||
| 243 | public String getImagemCronometroPedido() { |
||
| 244 | Integer quantidadeDias = getQuantidadeDiasPedido(); |
||
| 245 | if (quantidadeDias < 15) { |
||
| 246 | return "cronometro_verde_sembg"; |
||
| 247 | } |
||
| 248 | if (quantidadeDias < 30) { |
||
| 249 | return "cronometro_amarelo_sembg"; |
||
| 250 | } |
||
| 251 | return "cronometro_vermelho_sembg"; |
||
| 252 | } |
||
| 253 | |||
| 254 | @Transient |
||
| 255 | public String getCorPedido() { |
||
| 256 | Integer quantidadeDias = getQuantidadeDiasPedido(); |
||
| 257 | if (quantidadeDias < 15) { |
||
| 258 | return "green"; |
||
| 259 | } |
||
| 260 | return "red"; |
||
| 261 | } |
||
| 262 | |||
| 263 | @Transient |
||
| 264 | public String getCorPedidoAtendimento() { |
||
| 265 | Integer quantidadeDias = getQuantidadeDiasAtendimento(); |
||
| 266 | if (quantidadeDias < 15) { |
||
| 267 | return "green"; |
||
| 268 | } |
||
| 269 | return "red"; |
||
| 270 | }*/ |
||
| 271 | |||
| 272 | } |