/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.third.doordevice.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.math.NumberUtils;
import org.springblade.common.constant.Instruct;
import org.springblade.core.mp.base.BaseEntity;

import java.time.LocalDateTime;
import java.util.Date;

import lombok.Data;
import lombok.EqualsAndHashCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springblade.device.entity.DoorDevice;

/**
 * 指令推送记录实体类
 *
 * @author BladeX
 * @since 2021-04-27
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("third_instruct_publish_log")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "InstructPublishLog对象", description = "指令推送记录")
public class InstructPublishLog extends BaseEntity {

	private static final long serialVersionUID = 1L;

	/**
	* 设备序列号
	*/
		@ApiModelProperty(value = "设备序列号")
		private String serialNumber;
	/**
	* 指令
	*/
		@ApiModelProperty(value = "指令")
		private String instructCode;
	/**
	* 交换机名称
	*/
		@ApiModelProperty(value = "交换机名称")
		private String exchangeName;
	/**
	* 指令描述
	*/
		@ApiModelProperty(value = "指令描述")
		private String instructDescribe;
	/**
	* 发布数据
	*/
		@ApiModelProperty(value = "发布数据")
		private String publishData;
	/**
	* 错误信息
	*/
		@ApiModelProperty(value = "错误信息")
		private String errorMsg;
	/**
	* 最后修改时间
	*/
		@ApiModelProperty(value = "最后修改时间")
		private Date lastModifyTime;
	/**
	* 最近重发时间
	*/
		@ApiModelProperty(value = "最近重发时间")
		private LocalDateTime lastResendTime;
	/**
	* 设备业务阶段性状态，比如：	在线升级：可能有待下载，已下载，更新中，已更新状态。		在线重启：可能有待重启，已重启状态		其他
	*/
		@ApiModelProperty(value = "设备业务阶段性状态，比如：	在线升级：可能有待下载，已下载，更新中，已更新状态。		在线重启：可能有待重启，已重启状态		其他")
		private Integer bizStatus;
	/**
	* 门禁卡号
	*/
		@ApiModelProperty(value = "门禁卡号")
		private String cardNo;
	/**
	* 小区名称
	*/
		@ApiModelProperty(value = "小区名称")
		private String xqName;
	/**
	* 业务数据（用于列表展示）
	*/
		@ApiModelProperty(value = "业务数据（用于列表展示）")
		private String showContent;
	/**
	* 设置指令处理状态：1待处理、2已处理，3处理失败
	*/
		@ApiModelProperty(value = "设置指令处理状态：1待处理、2已处理，3处理失败")
		private Integer handleStatus;
	/**
	* 人脸图片地址
	*/
		@ApiModelProperty(value = "人脸图片地址")
		private String imgSrc;
	/**
	* 用户名称
	*/
		@ApiModelProperty(value = "用户名称")
		private String userName;
	/**
	* 单元名称
	*/
		@ApiModelProperty(value = "单元名称")
		private String unitName;
	/**
	* 房间名称
	*/
		@ApiModelProperty(value = "房间名称")
		private String roomName;

	public InstructPublishLog(long id, DoorDevice device, Instruct instruct, String data){
		super.setId(id);
		this.serialNumber = device.getSerialNum();
		this.instructCode = instruct.getCode();
		this.exchangeName = instruct.getExchangeName();
		this.instructDescribe = instruct.getDescribe();
		this.publishData = data;
		this.handleStatus = NumberUtils.INTEGER_ONE;
	}
}
