Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 200 | 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; |
||
| 37 | private Date dataHoraPontoInicio; |
||
| 38 | private String justificativaPontoInicio; |
||
| 39 | private Date dataHoraPontoFim; |
||
| 40 | private String justificativaPontoFim; |
||
| 41 | private Date dataHoraIntervaloInicio; |
||
| 42 | private String justificativaIntervaloInicio; |
||
| 43 | private Date dataHoraIntervaloFim; |
||
| 44 | private String justificativaIntervaloFim; |
||
| 45 | private String observacao; |
||
| 46 | private String tipoSituacao; |
||
| 47 | private Boolean indicadorAtivo = true; |
||
| 48 | |||
| 49 | @Id |
||
| 50 | @SequenceGenerator(name = "sq_ponto") |
||
| 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 | @Size(max = 150, message = "Limite de caracteres ultrapassado: Justificativa do Início do Ponto") |
||
| 100 | public String getJustificativaPontoInicio() { |
||
| 101 | return justificativaPontoInicio; |
||
| 102 | } |
||
| 103 | public void setJustificativaPontoInicio(String justificativaPontoInicio) { |
||
| 104 | this.justificativaPontoInicio = StringUtil.setarUpperCaseComTrim(justificativaPontoInicio); |
||
| 105 | } |
||
| 106 | |||
| 107 | @Column(name="dth_ponto_fim") |
||
| 108 | public Date getDataHoraPontoFim() { |
||
| 109 | return dataHoraPontoFim; |
||
| 110 | } |
||
| 111 | public void setDataHoraPontoFim(Date dataHoraPontoFim) { |
||
| 112 | this.dataHoraPontoFim = dataHoraPontoFim; |
||
| 113 | } |
||
| 114 | |||
| 115 | @Column(name="dsc_ponto_fim") |
||
| 116 | @Size(max = 150, message = "Limite de caracteres ultrapassado: Justificativa do Final do Ponto") |
||
| 117 | public String getJustificativaPontoFim() { |
||
| 118 | return justificativaPontoFim; |
||
| 119 | } |
||
| 120 | public void setJustificativaPontoFim(String justificativaPontoFim) { |
||
| 121 | this.justificativaPontoFim = StringUtil.setarUpperCaseComTrim(justificativaPontoFim); |
||
| 122 | } |
||
| 123 | |||
| 124 | @Column(name="dth_intervalo_inicio") |
||
| 125 | public Date getDataHoraIntervaloInicio() { |
||
| 126 | return dataHoraIntervaloInicio; |
||
| 127 | } |
||
| 128 | public void setDataHoraIntervaloInicio(Date dataHoraIntervaloInicio) { |
||
| 129 | this.dataHoraIntervaloInicio = dataHoraIntervaloInicio; |
||
| 130 | } |
||
| 131 | |||
| 132 | @Column(name="dsc_intervalo_inicio") |
||
| 133 | @Size(max = 150, message = "Limite de caracteres ultrapassado: Justificativa do Início do Intervalo") |
||
| 134 | public String getJustificativaIntervaloInicio() { |
||
| 135 | return justificativaIntervaloInicio; |
||
| 136 | } |
||
| 137 | public void setJustificativaIntervaloInicio(String justificativaIntervaloInicio) { |
||
| 138 | this.justificativaIntervaloInicio = StringUtil.setarUpperCaseComTrim(justificativaIntervaloInicio); |
||
| 139 | } |
||
| 140 | |||
| 141 | @Column(name="dth_intervalo_fim") |
||
| 142 | public Date getDataHoraIntervaloFim() { |
||
| 143 | return dataHoraIntervaloFim; |
||
| 144 | } |
||
| 145 | public void setDataHoraIntervaloFim(Date dataHoraIntervaloFim) { |
||
| 146 | this.dataHoraIntervaloFim = dataHoraIntervaloFim; |
||
| 147 | } |
||
| 148 | |||
| 149 | @Column(name="dsc_intervalo_fim") |
||
| 150 | @Size(max = 150, message = "Limite de caracteres ultrapassado: Justificativa do Final do Intervalo") |
||
| 151 | public String getJustificativaIntervaloFim() { |
||
| 152 | return justificativaIntervaloFim; |
||
| 153 | } |
||
| 154 | public void setJustificativaIntervaloFim(String justificativaIntervaloFim) { |
||
| 155 | this.justificativaIntervaloFim = StringUtil.setarUpperCaseComTrim(justificativaIntervaloFim); |
||
| 156 | } |
||
| 157 | |||
| 158 | @Column(name="dsc_observacao") |
||
| 159 | @Size(max = 250, message = "Limite de caracteres ultrapassado: Observação") |
||
| 160 | public String getObservacao() { |
||
| 161 | return observacao; |
||
| 162 | } |
||
| 163 | public void setObservacao(String observacao) { |
||
| 164 | this.observacao = StringUtil.setarUpperCaseComTrim(observacao); |
||
| 165 | } |
||
| 166 | |||
| 167 | @Column(name="ind_ativo") |
||
| 168 | public Boolean getIndicadorAtivo() { |
||
| 169 | return indicadorAtivo; |
||
| 170 | } |
||
| 171 | public void setIndicadorAtivo(Boolean indicadorAtivo) { |
||
| 172 | this.indicadorAtivo = indicadorAtivo; |
||
| 173 | } |
||
| 174 | |||
| 175 | @Transient |
||
| 176 | public String getTipoSituacao() { |
||
| 177 | return tipoSituacao; |
||
| 178 | } |
||
| 179 | public void setTipoSituacao(String tipoSituacao) { |
||
| 180 | this.tipoSituacao = tipoSituacao; |
||
| 181 | } |
||
| 182 | |||
| 183 | @Override |
||
| 184 | public int hashCode() { |
||
| 185 | final int prime = 31; |
||
| 186 | int result = 1; |
||
| 187 | result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 188 | return result; |
||
| 189 | } |
||
| 190 | |||
| 191 | @Override |
||
| 192 | public boolean equals(Object obj) { |
||
| 193 | if (this == obj) |
||
| 194 | return true; |
||
| 195 | if (obj == null) |
||
| 196 | return false; |
||
| 197 | if (getClass() != obj.getClass()) |
||
| 198 | return false; |
||
| 199 | Ponto other = (Ponto) obj; |
||
| 200 | if (sequencial == null) { |
||
| 201 | if (other.sequencial != null) |
||
| 202 | return false; |
||
| 203 | } else if (!sequencial.equals(other.sequencial)) |
||
| 204 | return false; |
||
| 205 | return true; |
||
| 206 | } |
||
| 207 | |||
| 208 | @Transient |
||
| 209 | public Long getSequencialDaLoja() { |
||
| 210 | return VerificadorUtil.naoEstaNulo(loja)? loja.getSequencial() : null; |
||
| 211 | } |
||
| 212 | |||
| 213 | @Transient |
||
| 214 | public String getDescricaoDaLoja() { |
||
| 215 | return VerificadorUtil.naoEstaNulo(loja)? loja.getDescricao() : null; |
||
| 216 | } |
||
| 217 | |||
| 218 | @Transient |
||
| 219 | public Boolean getPontoCompleto() { |
||
| 220 | return VerificadorUtil.naoEstaNulo(getDataHoraPontoInicio()) && |
||
| 221 | VerificadorUtil.naoEstaNulo(getDataHoraPontoFim()) && |
||
| 222 | VerificadorUtil.naoEstaNulo(getDataHoraIntervaloInicio()) && |
||
| 223 | VerificadorUtil.naoEstaNulo(getDataHoraIntervaloFim()); |
||
| 224 | } |
||
| 225 | |||
| 226 | @Transient |
||
| 227 | public String getHorasTrabalhadas() { |
||
| 228 | if (VerificadorUtil.naoEstaNulo(getDataHoraPontoInicio()) && VerificadorUtil.naoEstaNulo(getDataHoraPontoFim())) { |
||
| 229 | return DataUtils.calcularDiferencaEntreDatasRetornandoHorasEeMinutos(getDataHoraPontoInicio(),getDataHoraPontoFim()); |
||
| 230 | } |
||
| 231 | return null; |
||
| 232 | } |
||
| 233 | |||
| 234 | @Transient |
||
| 235 | public String getIntervalo() { |
||
| 236 | if (VerificadorUtil.naoEstaNulo(getDataHoraIntervaloInicio()) && VerificadorUtil.naoEstaNulo(getDataHoraIntervaloFim())) { |
||
| 237 | return DataUtils.calcularDiferencaEntreDatasRetornandoHorasEeMinutos(getDataHoraIntervaloInicio(),getDataHoraIntervaloFim()); |
||
| 238 | } |
||
| 239 | return null; |
||
| 240 | } |
||
| 241 | |||
| 242 | //TODO: FALTA FINALIZAR |
||
| 243 | @Transient |
||
| 244 | public Double getHorasExtras() { |
||
| 245 | if (getPontoCompleto()) { |
||
| 246 | } |
||
| 247 | return 0.0; |
||
| 248 | } |
||
| 249 | |||
| 250 | /*@Transient |
||
| 251 | public Integer getQuantidadeDiasPedido() { |
||
| 252 | return DataUtils.calcularDiferenceEmDiasEntreDuasDatas(DataUtils.getDataAtual(), getDataPedido()); |
||
| 253 | } |
||
| 254 | |||
| 255 | @Transient |
||
| 256 | public String getImagemCronometroPedido() { |
||
| 257 | Integer quantidadeDias = getQuantidadeDiasPedido(); |
||
| 258 | if (quantidadeDias < 15) { |
||
| 259 | return "cronometro_verde_sembg"; |
||
| 260 | } |
||
| 261 | if (quantidadeDias < 30) { |
||
| 262 | return "cronometro_amarelo_sembg"; |
||
| 263 | } |
||
| 264 | return "cronometro_vermelho_sembg"; |
||
| 265 | } |
||
| 266 | |||
| 267 | @Transient |
||
| 268 | public String getCorPedido() { |
||
| 269 | Integer quantidadeDias = getQuantidadeDiasPedido(); |
||
| 270 | if (quantidadeDias < 15) { |
||
| 271 | return "green"; |
||
| 272 | } |
||
| 273 | return "red"; |
||
| 274 | } |
||
| 275 | |||
| 276 | @Transient |
||
| 277 | public String getCorPedidoAtendimento() { |
||
| 278 | Integer quantidadeDias = getQuantidadeDiasAtendimento(); |
||
| 279 | if (quantidadeDias < 15) { |
||
| 280 | return "green"; |
||
| 281 | } |
||
| 282 | return "red"; |
||
| 283 | }*/ |
||
| 284 | |||
| 285 | } |