package com.jpsoft.shinestar.modules.business.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jpsoft.shinestar.modules.common.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.Transient;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 描述:business_work_attendance的实体类
 */
@Data
@ApiModel(value = "business_work_attendance的实体类")
public class WorkAttendance implements Serializable {
    /**
     * 缺卡
     */
    public static final String MISSING = "0";

    /**
     * 正常打卡
     */
    public static final String SUCCESS = "1";

    /**
     * 迟到
     */
    public static final String LATE = "2";

    /**
     * 早退
     */
    public static final String LEAVE_EARLY = "3";

    /**
     * 请假
     */
    public static final String REST  = "4";

    /**
     * 主键
     */
    @ApiModelProperty(value = "主键")
    private String id;
    /**
     * 考勤设置编号
     */
    @ApiModelProperty(value = "考勤设置编号")
    private String alarmConfigId;
    /**
     * 0-缺卡，1-正常，2-迟到，3-早退
     */
    @ApiModelProperty(value = "0-缺卡，1-正常，2-迟到，3-早退,4-请假")
    private String result;

    public String getResultN(){
        String text = "";

        if("0".equals(result)){
            text = "缺卡";
        }
        else if("1".equals(result)){
            text = "正常";
        }
        else if("2".equals(result)){
            text = "迟到";
        }
        else if("3".equals(result)){
            text = "早退";
        }
        else if("4".equals(result)){
            text = "请假";
        }


        return text;
    }

    /**
     * 创建人
     */
    @ApiModelProperty(value = "创建人")
    private String createBy;
    /**
     * 创建时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
    /**
     * 更新人
     */
    @ApiModelProperty(value = "更新人")
    private String updateBy;
    /**
     * 更新时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    @ApiModelProperty(value = "更新时间")
    private Date updateTime;
    /**
     * 是否删除
     */
    @ApiModelProperty(value = "是否删除")
    private Boolean delFlag;

    /**
     * 人员编号
     */
    @ApiModelProperty(value = "人员编号")
    private Long personId;

    /**
     * 记录时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    @ApiModelProperty(value = "记录时间")
    private Date recordTime;


    /**
     * 记录温度
     */
    @ApiModelProperty(value = "记录温度")
    private BigDecimal temperature;

    @ApiModelProperty(value = "上班-1,下班-2")
    private Integer classifier;

    /**
     * 考勤类型（1：设备打卡，2：人工填报）
     */
    private String sources;

    /**
     * 申请类型:（1：外勤打卡、2：补卡）
     */
    private String type;

    public String getRemark(){
        String text = "";

        if (StringUtils.isEmpty(this.remark)) {
            if ("1".equals(sources)) {
                text = "设备打卡";
            } else {
                if ("1".equals(type)) {
                    text = "外勤打卡";
                } else if ("2".equals(type)) {
                    text = "补卡";
                }
            }
        }
        else{
            text = this.remark;
        }

        return text;
    }

    @ApiModelProperty(value = "工作状态")
    private String workStatus;

    public String getWorkStatusN(){
        String text = "";

        if("1".equals(workStatus)){
            text = "工作";
        }
        else if("2".equals(workStatus)){
            text = "外出";
        }
        else if("3".equals(workStatus)){
            text = "出差";
        }
        else if("4".equals(workStatus)){
            text = "休假";
        }
        return text;
    }

    @Transient
    @ApiModelProperty(value = "外勤备注")
    private String workOutRemark;

    @ApiModelProperty(value = "备注")
    private String remark;
}