Rev 355 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 353 | espaco | 1 | package br.com.ec.domain.model; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.Date; |
||
| 5 | |||
| 6 | import javax.persistence.Column; |
||
| 7 | import javax.persistence.Entity; |
||
| 8 | import javax.persistence.GeneratedValue; |
||
| 9 | import javax.persistence.GenerationType; |
||
| 10 | import javax.persistence.Id; |
||
| 11 | import javax.persistence.JoinColumn; |
||
| 12 | import javax.persistence.ManyToOne; |
||
| 13 | import javax.persistence.SequenceGenerator; |
||
| 14 | import javax.persistence.Table; |
||
| 15 | import javax.persistence.Transient; |
||
| 16 | import javax.validation.constraints.NotNull; |
||
| 17 | import javax.validation.constraints.Size; |
||
| 18 | |||
| 19 | import org.hibernate.annotations.ForeignKey; |
||
| 20 | |||
| 21 | import br.com.ec.core.interfaces.Alterar; |
||
| 22 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 23 | import br.com.ec.core.util.DataUtils; |
||
| 24 | import br.com.ec.core.util.StringUtil; |
||
| 25 | import br.com.ec.core.util.VerificadorUtil; |
||
| 26 | |||
| 27 | @Entity |
||
| 28 | @Table(name="sec_ponto", schema="sc_sec") |
||
| 29 | public class Ponto implements Serializable { |
||
| 30 | |||
| 31 | private static final long serialVersionUID = 1L; |
||
| 32 | |||
| 33 | private Long sequencial; |
||
| 34 | private Loja loja; |
||
| 35 | private Pessoa pessoa; |
||
| 36 | private Date dataPonto; |
||
| 574 | blopes | 37 | |
| 353 | espaco | 38 | private Date dataHoraPontoInicio; |
| 39 | private String justificativaPontoInicio; |
||
| 574 | blopes | 40 | private String ipPontoInicio; |
| 41 | |||
| 353 | espaco | 42 | private Date dataHoraPontoFim; |
| 43 | private String justificativaPontoFim; |
||
| 574 | blopes | 44 | private String ipPontoFim; |
| 45 | |||
| 353 | espaco | 46 | private Date dataHoraIntervaloInicio; |
| 47 | private String justificativaIntervaloInicio; |
||
| 574 | blopes | 48 | private String ipPontoIntervaloInicio; |
| 49 | |||
| 353 | espaco | 50 | private Date dataHoraIntervaloFim; |
| 51 | private String justificativaIntervaloFim; |
||
| 574 | blopes | 52 | private String ipPontoIntervaloFim; |
| 53 | |||
| 353 | espaco | 54 | private String observacao; |
| 55 | private String tipoSituacao; |
||
| 56 | private Boolean indicadorValidadoRh = false; |
||
| 57 | private Boolean indicadorAtivo = true; |
||
| 58 | |||
| 59 | @Id |
||
| 60 | @SequenceGenerator(name = "sq_ponto") |
||
| 61 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 62 | @Column(name="seq_ponto", nullable=false) |
||
| 63 | public Long getSequencial() { |
||
| 64 | return sequencial; |
||
| 65 | } |
||
| 66 | public void setSequencial(Long sequencial) { |
||
| 67 | this.sequencial = sequencial; |
||
| 68 | } |
||
| 69 | |||
| 70 | @ManyToOne |
||
| 71 | @ForeignKey(name="fk_ponto_loja") |
||
| 72 | @NotNull(message = "Parâmetro obrigatório não preenchido: Loja", groups = {Cadastrar.class, Alterar.class}) |
||
| 73 | @JoinColumn(name = "seq_loja", referencedColumnName="seq_loja", nullable=false) |
||
| 74 | public Loja getLoja() { |
||
| 75 | return loja; |
||
| 76 | } |
||
| 77 | public void setLoja(Loja loja) { |
||
| 78 | this.loja = loja; |
||
| 79 | } |
||
| 80 | |||
| 81 | @ManyToOne |
||
| 82 | @ForeignKey(name="fk_ponto_pessoa") |
||
| 83 | @NotNull(message = "Parâmetro obrigatório não preenchido: Pessoa", groups = {Cadastrar.class, Alterar.class}) |
||
| 84 | @JoinColumn(name = "seq_pessoa", nullable=false) |
||
| 85 | public Pessoa getPessoa() { |
||
| 86 | return pessoa; |
||
| 87 | } |
||
| 88 | public void setPessoa(Pessoa pessoa) { |
||
| 89 | this.pessoa = pessoa; |
||
| 90 | } |
||
| 91 | |||
| 92 | @Column(name="dat_ponto") |
||
| 93 | public Date getDataPonto() { |
||
| 94 | return dataPonto; |
||
| 95 | } |
||
| 96 | public void setDataPonto(Date dataPonto) { |
||
| 97 | this.dataPonto = dataPonto; |
||
| 98 | } |
||
| 99 | |||
| 100 | @Column(name="dth_ponto_inicio") |
||
| 101 | public Date getDataHoraPontoInicio() { |
||
| 102 | return dataHoraPontoInicio; |
||
| 103 | } |
||
| 104 | public void setDataHoraPontoInicio(Date dataHoraPontoInicio) { |
||
| 105 | this.dataHoraPontoInicio = dataHoraPontoInicio; |
||
| 106 | } |
||
| 107 | |||
| 108 | @Column(name="dsc_ponto_inicio") |
||
| 109 | @Size(max = 150, message = "Limite de caracteres ultrapassado: Justificativa do Início do Ponto") |
||
| 110 | public String getJustificativaPontoInicio() { |
||
| 111 | return justificativaPontoInicio; |
||
| 112 | } |
||
| 113 | public void setJustificativaPontoInicio(String justificativaPontoInicio) { |
||
| 114 | this.justificativaPontoInicio = StringUtil.setarUpperCaseComTrim(justificativaPontoInicio); |
||
| 115 | } |
||
| 116 | |||
| 574 | blopes | 117 | @Column(name="dsc_ip_ponto_inicio") |
| 118 | public String getIpPontoInicio() { |
||
| 119 | return ipPontoInicio; |
||
| 120 | } |
||
| 121 | public void setIpPontoInicio(String ipPontoInicio) { |
||
| 122 | this.ipPontoInicio = ipPontoInicio; |
||
| 123 | } |
||
| 124 | |||
| 353 | espaco | 125 | @Column(name="dth_ponto_fim") |
| 126 | public Date getDataHoraPontoFim() { |
||
| 127 | return dataHoraPontoFim; |
||
| 128 | } |
||
| 129 | public void setDataHoraPontoFim(Date dataHoraPontoFim) { |
||
| 130 | this.dataHoraPontoFim = dataHoraPontoFim; |
||
| 131 | } |
||
| 132 | |||
| 133 | @Column(name="dsc_ponto_fim") |
||
| 134 | @Size(max = 150, message = "Limite de caracteres ultrapassado: Justificativa do Final do Ponto") |
||
| 135 | public String getJustificativaPontoFim() { |
||
| 136 | return justificativaPontoFim; |
||
| 137 | } |
||
| 138 | public void setJustificativaPontoFim(String justificativaPontoFim) { |
||
| 139 | this.justificativaPontoFim = StringUtil.setarUpperCaseComTrim(justificativaPontoFim); |
||
| 140 | } |
||
| 141 | |||
| 574 | blopes | 142 | @Column(name="dsc_ip_ponto_fim") |
| 143 | public String getIpPontoFim() { |
||
| 144 | return ipPontoFim; |
||
| 145 | } |
||
| 146 | public void setIpPontoFim(String ipPontoFim) { |
||
| 147 | this.ipPontoFim = ipPontoFim; |
||
| 148 | } |
||
| 149 | |||
| 353 | espaco | 150 | @Column(name="dth_intervalo_inicio") |
| 151 | public Date getDataHoraIntervaloInicio() { |
||
| 152 | return dataHoraIntervaloInicio; |
||
| 153 | } |
||
| 154 | public void setDataHoraIntervaloInicio(Date dataHoraIntervaloInicio) { |
||
| 155 | this.dataHoraIntervaloInicio = dataHoraIntervaloInicio; |
||
| 156 | } |
||
| 157 | |||
| 158 | @Column(name="dsc_intervalo_inicio") |
||
| 159 | @Size(max = 150, message = "Limite de caracteres ultrapassado: Justificativa do Início do Intervalo") |
||
| 160 | public String getJustificativaIntervaloInicio() { |
||
| 161 | return justificativaIntervaloInicio; |
||
| 162 | } |
||
| 163 | public void setJustificativaIntervaloInicio(String justificativaIntervaloInicio) { |
||
| 164 | this.justificativaIntervaloInicio = StringUtil.setarUpperCaseComTrim(justificativaIntervaloInicio); |
||
| 165 | } |
||
| 166 | |||
| 574 | blopes | 167 | @Column(name="dsc_ip_intervalo_inicio") |
| 168 | public String getIpPontoIntervaloInicio() { |
||
| 169 | return ipPontoIntervaloInicio; |
||
| 170 | } |
||
| 171 | public void setIpPontoIntervaloInicio(String ipPontoIntervaloInicio) { |
||
| 172 | this.ipPontoIntervaloInicio = ipPontoIntervaloInicio; |
||
| 173 | } |
||
| 174 | |||
| 353 | espaco | 175 | @Column(name="dth_intervalo_fim") |
| 176 | public Date getDataHoraIntervaloFim() { |
||
| 177 | return dataHoraIntervaloFim; |
||
| 178 | } |
||
| 179 | public void setDataHoraIntervaloFim(Date dataHoraIntervaloFim) { |
||
| 180 | this.dataHoraIntervaloFim = dataHoraIntervaloFim; |
||
| 181 | } |
||
| 182 | |||
| 183 | @Column(name="dsc_intervalo_fim") |
||
| 184 | @Size(max = 150, message = "Limite de caracteres ultrapassado: Justificativa do Final do Intervalo") |
||
| 185 | public String getJustificativaIntervaloFim() { |
||
| 186 | return justificativaIntervaloFim; |
||
| 187 | } |
||
| 188 | public void setJustificativaIntervaloFim(String justificativaIntervaloFim) { |
||
| 189 | this.justificativaIntervaloFim = StringUtil.setarUpperCaseComTrim(justificativaIntervaloFim); |
||
| 190 | } |
||
| 191 | |||
| 574 | blopes | 192 | @Column(name="dsc_ip_intervalo_fim") |
| 193 | public String getIpPontoIntervaloFim() { |
||
| 194 | return ipPontoIntervaloFim; |
||
| 195 | } |
||
| 196 | public void setIpPontoIntervaloFim(String ipPontoIntervaloFim) { |
||
| 197 | this.ipPontoIntervaloFim = ipPontoIntervaloFim; |
||
| 198 | } |
||
| 199 | |||
| 353 | espaco | 200 | @Column(name="dsc_observacao") |
| 201 | @Size(max = 250, message = "Limite de caracteres ultrapassado: Observação") |
||
| 202 | public String getObservacao() { |
||
| 203 | return observacao; |
||
| 204 | } |
||
| 205 | public void setObservacao(String observacao) { |
||
| 206 | this.observacao = StringUtil.setarUpperCaseComTrim(observacao); |
||
| 207 | } |
||
| 208 | |||
| 209 | @Column(name="ind_validado_rh") |
||
| 210 | public Boolean getIndicadorValidadoRh() { |
||
| 211 | return indicadorValidadoRh; |
||
| 212 | } |
||
| 213 | public void setIndicadorValidadoRh(Boolean indicadorValidadoRh) { |
||
| 214 | this.indicadorValidadoRh = indicadorValidadoRh; |
||
| 215 | } |
||
| 216 | |||
| 217 | @Column(name="ind_ativo") |
||
| 218 | public Boolean getIndicadorAtivo() { |
||
| 219 | return indicadorAtivo; |
||
| 220 | } |
||
| 221 | public void setIndicadorAtivo(Boolean indicadorAtivo) { |
||
| 222 | this.indicadorAtivo = indicadorAtivo; |
||
| 223 | } |
||
| 224 | |||
| 225 | @Transient |
||
| 226 | public String getTipoSituacao() { |
||
| 227 | return tipoSituacao; |
||
| 228 | } |
||
| 229 | public void setTipoSituacao(String tipoSituacao) { |
||
| 230 | this.tipoSituacao = tipoSituacao; |
||
| 231 | } |
||
| 232 | |||
| 233 | @Override |
||
| 234 | public int hashCode() { |
||
| 235 | final int prime = 31; |
||
| 236 | int result = 1; |
||
| 237 | result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 238 | return result; |
||
| 239 | } |
||
| 240 | |||
| 241 | @Override |
||
| 242 | public boolean equals(Object obj) { |
||
| 243 | if (this == obj) |
||
| 244 | return true; |
||
| 245 | if (obj == null) |
||
| 246 | return false; |
||
| 247 | if (getClass() != obj.getClass()) |
||
| 248 | return false; |
||
| 249 | Ponto other = (Ponto) obj; |
||
| 250 | if (sequencial == null) { |
||
| 251 | if (other.sequencial != null) |
||
| 252 | return false; |
||
| 253 | } else if (!sequencial.equals(other.sequencial)) |
||
| 254 | return false; |
||
| 255 | return true; |
||
| 256 | } |
||
| 257 | |||
| 258 | @Transient |
||
| 259 | public Long getSequencialDaLoja() { |
||
| 260 | return VerificadorUtil.naoEstaNulo(loja)? loja.getSequencial() : null; |
||
| 261 | } |
||
| 262 | |||
| 263 | @Transient |
||
| 264 | public String getDescricaoDaLoja() { |
||
| 265 | return VerificadorUtil.naoEstaNulo(loja)? loja.getDescricao() : null; |
||
| 266 | } |
||
| 267 | |||
| 268 | @Transient |
||
| 269 | public Boolean getPontoCompleto() { |
||
| 270 | return VerificadorUtil.naoEstaNulo(getDataHoraPontoInicio()) && |
||
| 271 | VerificadorUtil.naoEstaNulo(getDataHoraPontoFim()) && |
||
| 272 | VerificadorUtil.naoEstaNulo(getDataHoraIntervaloInicio()) && |
||
| 273 | VerificadorUtil.naoEstaNulo(getDataHoraIntervaloFim()); |
||
| 274 | } |
||
| 275 | |||
| 276 | @Transient |
||
| 277 | public String getHorasTrabalhadas() { |
||
| 278 | if (VerificadorUtil.naoEstaNulo(getDataHoraPontoInicio()) && VerificadorUtil.naoEstaNulo(getDataHoraPontoFim())) { |
||
| 279 | return DataUtils.calcularDiferencaEntreDatasRetornandoHorasEeMinutos(getDataHoraPontoInicio(),getDataHoraPontoFim()); |
||
| 280 | } |
||
| 281 | return null; |
||
| 282 | } |
||
| 283 | |||
| 284 | @Transient |
||
| 285 | public String getIntervalo() { |
||
| 286 | if (VerificadorUtil.naoEstaNulo(getDataHoraIntervaloInicio()) && VerificadorUtil.naoEstaNulo(getDataHoraIntervaloFim())) { |
||
| 287 | return DataUtils.calcularDiferencaEntreDatasRetornandoHorasEeMinutos(getDataHoraIntervaloInicio(),getDataHoraIntervaloFim()); |
||
| 288 | } |
||
| 289 | return null; |
||
| 290 | } |
||
| 291 | |||
| 292 | @Transient |
||
| 355 | espaco | 293 | public String getPeriodoTrabalhado() { |
| 294 | StringBuilder periodoTrabalhado = new StringBuilder(""); |
||
| 295 | if (VerificadorUtil.naoEstaNulo(getDataHoraPontoInicio())) { |
||
| 296 | periodoTrabalhado.append(DataUtils.converterDataParaStringNoFormato(getDataHoraPontoInicio(), "HH:mm:ss")); |
||
| 297 | } |
||
| 298 | if (VerificadorUtil.naoEstaNulo(getDataHoraPontoFim())) { |
||
| 299 | periodoTrabalhado.append(" - "); |
||
| 300 | periodoTrabalhado.append(DataUtils.converterDataParaStringNoFormato(getDataHoraPontoFim(), "HH:mm:ss")); |
||
| 301 | } |
||
| 302 | return periodoTrabalhado.toString(); |
||
| 303 | } |
||
| 304 | |||
| 305 | @Transient |
||
| 306 | public String getPeriodoIntervaloTrabalhado() { |
||
| 307 | StringBuilder periodoTrabalhado = new StringBuilder(""); |
||
| 308 | if (VerificadorUtil.naoEstaNulo(getDataHoraIntervaloInicio())) { |
||
| 309 | periodoTrabalhado.append(DataUtils.converterDataParaStringNoFormato(getDataHoraIntervaloInicio(), "HH:mm:ss")); |
||
| 310 | } |
||
| 311 | if (VerificadorUtil.naoEstaNulo(getDataHoraIntervaloFim())) { |
||
| 312 | periodoTrabalhado.append(" - "); |
||
| 313 | periodoTrabalhado.append(DataUtils.converterDataParaStringNoFormato(getDataHoraIntervaloFim(), "HH:mm:ss")); |
||
| 314 | } |
||
| 315 | return periodoTrabalhado.toString(); |
||
| 316 | } |
||
| 317 | |||
| 318 | @Transient |
||
| 319 | public String getInicioPonto() { |
||
| 320 | if (VerificadorUtil.naoEstaNulo(getDataHoraPontoInicio())) { |
||
| 321 | return DataUtils.converterDataParaStringNoFormato(getDataHoraPontoInicio(), "HH:mm"); |
||
| 322 | } |
||
| 323 | return "-"; |
||
| 324 | } |
||
| 325 | |||
| 326 | @Transient |
||
| 327 | public String getJustificativas() { |
||
| 328 | StringBuilder justificativas = new StringBuilder(""); |
||
| 329 | if (!getJustificativaPontoInicio().isEmpty()) { |
||
| 330 | justificativas.append(getJustificativaPontoInicio()); |
||
| 331 | } |
||
| 332 | if (!getJustificativaPontoFim().isEmpty()) { |
||
| 333 | justificativas.append(" : "); |
||
| 334 | justificativas.append(getJustificativaPontoFim()); |
||
| 335 | } |
||
| 336 | if (!getJustificativaIntervaloInicio().isEmpty()) { |
||
| 337 | justificativas.append(" : "); |
||
| 338 | justificativas.append(getJustificativaIntervaloInicio()); |
||
| 339 | } |
||
| 340 | if (!getJustificativaIntervaloFim().isEmpty()) { |
||
| 341 | justificativas.append(" : "); |
||
| 342 | justificativas.append(getJustificativaIntervaloFim()); |
||
| 343 | } |
||
| 344 | return justificativas.toString(); |
||
| 345 | } |
||
| 346 | |||
| 347 | @Transient |
||
| 353 | espaco | 348 | public String getNomeDaPessoa() { |
| 349 | return VerificadorUtil.naoEstaNulo(getPessoa())? getPessoa().getNome() : null; |
||
| 350 | } |
||
| 351 | |||
| 352 | //TODO: FALTA FINALIZAR |
||
| 353 | @Transient |
||
| 354 | public Double getHorasExtras() { |
||
| 355 | if (getPontoCompleto()) { |
||
| 356 | } |
||
| 357 | return 0.0; |
||
| 358 | } |
||
| 359 | |||
| 360 | /*@Transient |
||
| 361 | public Integer getQuantidadeDiasPedido() { |
||
| 362 | return DataUtils.calcularDiferenceEmDiasEntreDuasDatas(DataUtils.getDataAtual(), getDataPedido()); |
||
| 363 | } |
||
| 364 | |||
| 365 | @Transient |
||
| 366 | public String getImagemCronometroPedido() { |
||
| 367 | Integer quantidadeDias = getQuantidadeDiasPedido(); |
||
| 368 | if (quantidadeDias < 15) { |
||
| 369 | return "cronometro_verde_sembg"; |
||
| 370 | } |
||
| 371 | if (quantidadeDias < 30) { |
||
| 372 | return "cronometro_amarelo_sembg"; |
||
| 373 | } |
||
| 374 | return "cronometro_vermelho_sembg"; |
||
| 375 | } |
||
| 376 | |||
| 377 | @Transient |
||
| 378 | public String getCorPedido() { |
||
| 379 | Integer quantidadeDias = getQuantidadeDiasPedido(); |
||
| 380 | if (quantidadeDias < 15) { |
||
| 381 | return "green"; |
||
| 382 | } |
||
| 383 | return "red"; |
||
| 384 | } |
||
| 385 | |||
| 386 | @Transient |
||
| 387 | public String getCorPedidoAtendimento() { |
||
| 388 | Integer quantidadeDias = getQuantidadeDiasAtendimento(); |
||
| 389 | if (quantidadeDias < 15) { |
||
| 390 | return "green"; |
||
| 391 | } |
||
| 392 | return "red"; |
||
| 393 | }*/ |
||
| 394 | |||
| 395 | } |