package cn.pluss.platform.entity;

import cn.pluss.platform.util.DateUtils;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

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

/**
 * <p>
 * 设备划拨记录表
 * </p>
 *
 * @author crystal
 * @since 2022-03-31
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("tb_pluss_device_transfer")
@NoArgsConstructor
public class DeviceTransfer implements Serializable {

    private static final long serialVersionUID = 1L;

    public static final String STAY_ACCEPT = "00";

    public static final String ALREADY_ACCEPT = "01";

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;


    /**
     * 划拨人用户Id
     */
    @TableField("userId")
    private Long userId;


    /**
     * 接收人用户ID
     */
    @TableField("acceptUserId")
    private Long acceptUserId;


    /**
     * 状态00:待接收 01：已接收
     */
    @TableField("status")
    private String status;


    /**
     * 划拨时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @TableField("transferTime")
    private Date transferTime;

    /**
     * 划拨时间 开始时间
     */
    @TableField(exist = false, condition = "transferTime &gt; #{%s}")
    private Date transferTimeStart;

    /**
     * 划拨时间 截止时间
     */
    @TableField(exist = false, condition = "transferTime &lt; #{%s}")
    private Date transferTimeEnd;

    /**
     * 接收时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @TableField("acceptTime")
    private Date acceptTime;

    /**
     * 接收时间 开始时间
     */
    @TableField(exist = false, condition = "acceptTime &gt; #{%s}")
    private Date acceptTimeStart;

    /**
     * 接收时间 截止时间
     */
    @TableField(exist = false, condition = "acceptTime &lt; #{%s}")
    private Date acceptTimeEnd;

    /**
     * 划拨批次号
     */
    @TableField("batchNo")
    private String batchNo;


    /**
     * 备注
     */
    @TableField("remark")
    private String remark;


    public DeviceTransfer(Long userId, Long acceptUserId,String batchNo,String status,Date accpetTime,String remark) {
        this.userId = userId;
        this.acceptUserId = acceptUserId;
        this.transferTime = DateUtils.currentDate();
        this.acceptTime = accpetTime;
        this.batchNo = batchNo;
        this.remark = remark;
        this.status = status;
    }
}