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