package com.zd.laboratory.domain;

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zd.common.core.annotation.Excel;
import com.zd.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 安全准入审批记录对象 lab_approval
 *
 * @author zd
 * @date 2021-08-31
 */
@ApiModel("安全准入审批管理类")
public class LabApproval extends BaseEntity {
    private static final long serialVersionUID = 1L;
    /**
     * 主键id
     */
    private Long id;

    /**
     * 关联实验室id
     */
    @ApiModelProperty("关联实验室id")
    @NotNull(message = "实验室ID不能为空！")
    private Long subjectId;

    /**
     * 关联安全准入配置id
     */
    @ApiModelProperty("关联安全准入配置id")
    @NotNull(message = "安全准入配置ID不能为空！")
    private Long securityGroupId;

    /**
     * 准入资格名称
     */
    private String configureName;
    /**
     * 关联用户表id
     */
    @ApiModelProperty("关联用户表id")
    @Excel(name = "关联用户表id")
//    @NotNull(message = "用户ID不能为空！")
    private Long joinUserId;

    /**
     * 审核状态 只有 0 1 2， 3=即将过期,4=已过期 通过失效时间 表现
     */
    @ApiModelProperty("审核状态 0=未通过,1=已办理,2=待审核,")
    @Excel(name = "审核状态", readConverterExp = "0=未通过,1=已办理,2=待审核")
    private Integer recordContent;

    /**
     * 部门id
     */
    @ApiModelProperty("部门id")
    @Excel(name = "部门id")
    @NotNull(message = "院系ID 不能为空！")
    private Long deptId;

    @ApiModelProperty("部门楼栋")
    @Excel(name = "部门楼栋")
    @NotNull(message = "楼栋ID 不能为空！")
    private Long buildId;

    /**
     * 部门名称
     */
    @ApiModelProperty("部门名称")
    @Excel(name = "部门名称")
    private String deptName;

    /**
     * 通过时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("通过时间")
    @Excel(name = "通过时间")
    private Date passedDate;

    public Date getPassedDate() {
        return passedDate;
    }

    public void setPassedDate(Date passedDate) {
        this.passedDate = passedDate;
    }

    /**
     * 未通过时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("未通过时间")
    @Excel(name = "未通过时间")
    private Date failedDate;

    public Date getFailedDate() {
        return failedDate;
    }

    public void setFailedDate(Date failedDate) {
        this.failedDate = failedDate;
    }

    /**
     * 失效时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("失效时间")
    @Excel(name = "失效时间")
    private Date expirationDate;

    public Date getExpirationDate() {
        return expirationDate;
    }

    public Integer getRecordOther() {
        Integer recordOther = null;
        if (this.expirationDate != null && this.recordContent == 1) {
            long d = DateUtil.between(new Date(), this.expirationDate, DateUnit.DAY, false);
            if (d < 0) {
                recordOther = 4;
            } else if (d < 30) {
                recordOther = 3;
            }else{
                recordOther = 1;
            }
        }
        return recordOther;
    }


    public void setExpirationDate(Date expirationDate) {
        this.expirationDate = expirationDate;
    }

    /**
     * 未通过原因
     */
    @ApiModelProperty("未通过原因")
    @Excel(name = "未通过原因")
    private String failedReason;

    public String getFailedReason() {
        return failedReason;
    }

    public void setFailedReason(String failedReason) {
        this.failedReason = failedReason;
    }

    /**
     * 创建人（用于数据权限）
     */
    @ApiModelProperty("创建人（用于数据权限）")
    @Excel(name = "创建人", readConverterExp = "用=于数据权限")
    private Long userId;

    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setJoinUserId(Long joinUserId) {
        this.joinUserId = joinUserId;
    }

    public Long getJoinUserId() {
        return joinUserId;
    }

    public void setRecordContent(Integer recordContent) {
        this.recordContent = recordContent;
    }

    public Integer getRecordContent() {
        return recordContent;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    public Long getDeptId() {
        return deptId;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getUserId() {
        return userId;
    }

    public Long getSubjectId() {
        return subjectId;
    }

    public void setSubjectId(Long subjectId) {
        this.subjectId = subjectId;
    }

    public Long getSecurityGroupId() {
        return securityGroupId;
    }

    public void setSecurityGroupId(Long securityGroupId) {
        this.securityGroupId = securityGroupId;
    }

    public String getConfigureName() {
        return configureName;
    }

    public void setConfigureName(String configureName) {
        this.configureName = configureName;
    }

    public Long getBuildId() {
        return buildId;
    }

    public void setBuildId(Long buildId) {
        this.buildId = buildId;
    }

}
