package jnpf.model.attendance.vo;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

/**
 * 规则和打卡记录
 *
 * @author yanwenfu
 * @create 2023-12-08
 */
@Getter
@Setter
@NoArgsConstructor
public class RuleAndClockVo {

    /** 规则id */
    private String ruleId;

    /** 打卡类型(1: 上班, 2: 下班) */
    private Integer clockInType;

    /** 出勤类型(1: 班, 2: 休, 3: 请假) */
    private Integer ruleType;

    /** 工作时间 */
    private String workTime;

    /** 打卡id */
    private String clockInId;

    /** 打卡结果id */
    private String clockInResultId;

    /** 打卡时间 */
    private Date clockInTime;

    /** 打卡状态(-1: 缺卡, 0: 未开始, 1: 正常, 2: 迟到, 3: 早退, 4: 旷工) */
    private Integer clockInStatus;

    /** 是否旷工(1: 是, 0: 否) */
    private Integer absence;

    /** 审批状态(0: 通过, 1: 审批中, 2: 拒绝) */
    private Integer approvalStatus;

    public RuleAndClockVo(Integer ruleType, String ruleId, Integer clockInType, String workTime) {
        this.ruleType = ruleType;
        this.ruleId = ruleId;
        this.clockInType = clockInType;
        this.workTime = StringUtils.isEmpty(workTime) ? "/" : workTime;
    }

    public void setClockInInfo(ClockInVo clockIn) {

        this.clockInResultId = clockIn.getId();
        this.clockInId = clockIn.getClockInId();
        this.clockInTime = clockIn.getClockInTime();
        this.clockInStatus = clockIn.getClockInStatus();
        this.absence = clockIn.getAbsence();
        this.approvalStatus = clockIn.getApprovalStatus();
    }
}
