package com.bocloud.ims.entity.installation;

import com.alibaba.fastjson.JSONObject;
import com.bocloud.common.utils.DateSerializer;
import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreAll;
import com.bocloud.entity.annotations.PK;
import com.bocloud.entity.annotations.Table;
import com.bocloud.entity.meta.PKStrategy;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * 物理装机部分，物理机上任务历史实体类
 * 
 * @author 007
 *
 */
@Table("install_result")
public class InstallResult {

	/**
	 * ID
	 */
	@PK(value = PKStrategy.AUTO)
	private Long id;
	/**
	 * 所属节点ID
	 */
	@Column("node_id")
	private Long nodeId;
	/**
	 * 所属任务的ID
	 */
	@Column("task_id")
	private Long taskId;
	/**
	 * 节点任务名称
	 */
	@Column("name")
	private String name;

	/**
	 * 节点任务类型状态
	 */
	@Column("task_type")
	private String taskType;

	/**
	 * 节点任务状态
	 */
	@Column("status")
	private String status;
	/**
	 * 节点任务结果
	 */
	@Column("result")
	private String result;
	/**
	 * rackhd任务id
	 */
	@Column("rackhd_task_id")
	private String rackhdTaskId;
	/**
     * rackhd任务payload
     */
    @Column("payload")
    private String payload;
    /**
     * 节点任务开始时间
     *
     */
    @Column("gmt_start")
    @JsonSerialize(using = DateSerializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date gmtStart;

	/**
	 * 节点任务结束时间
	 */
	@Column("gmt_finish")
	@JsonSerialize(using = DateSerializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date gmtFinish;

	/**
	 * 用户名、操作人
	 */
	@IgnoreAll
	private String userName;

	/**
	 * 耗时，根据gmtStart、gmtFinish计算得到，字符串类型
	 */
	@IgnoreAll
	private String elapsedTime;
	/**
	 * 镜像名称
	 */
	@IgnoreAll
	private String imageName;
	/**
	 * 装机类型名称
	 */
	@IgnoreAll
	private String typeName;

    public InstallResult() {
		super();
	}

    public InstallResult(Long nodeId, Long taskId, String rackhdTaskId, String name, String status, String taskType,
                         String result, Date gmtStart) {
		super();
		this.nodeId = nodeId;
		this.taskId = taskId;
		this.rackhdTaskId = rackhdTaskId;
		this.name = name;
		this.status = status;
		this.taskType = taskType;
		this.result = result;
		this.gmtStart = gmtStart;
	}

    public InstallResult(Long nodeId, Long taskId, String taskType, String rackhdTaskId, String name, String status,
                         String result, Date gmtStart, Date gmtFinish) {
		super();
		this.nodeId = nodeId;
		this.taskId = taskId;
		this.taskType = taskType;
		this.rackhdTaskId = rackhdTaskId;
		this.name = name;
		this.status = status;
		this.result = result;
		this.gmtStart = gmtStart;
		this.gmtFinish = gmtFinish;
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the nodeId
	 */
	public Long getNodeId() {
		return nodeId;
	}

	/**
	 * @param nodeId
	 *            the nodeId to set
	 */
	public void setNodeId(Long nodeId) {
		this.nodeId = nodeId;
	}

	/**
	 * @return the taskId
	 */
	public Long getTaskId() {
		return taskId;
	}

	/**
	 * @param taskId
	 *            the taskId to set
	 */
	public void setTaskId(Long taskId) {
		this.taskId = taskId;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the taskType
	 */
	public String getTaskType() {
		return taskType;
	}

	/**
	 * @param taskType
	 *            the taskType to set
	 */
	public void setTaskType(String taskType) {
		this.taskType = taskType;
	}

	/**
	 * @return the status
	 */
	public String getStatus() {
		return status;
	}

	/**
	 * @param status
	 *            the status to set
	 */
	public void setStatus(String status) {
		this.status = status;
	}

	/**
	 * @return the result
	 */
	public String getResult() {
		return result;
	}

	/**
	 * @param result
	 *            the result to set
	 */
	public void setResult(String result) {
		this.result = result;
	}

	/**
	 * @return the rackhdTaskId
	 */
	public String getRackhdTaskId() {
		return rackhdTaskId;
	}

	/**
	 * @param rackhdTaskId
	 *            the rackhdTaskId to set
	 */
	public void setRackhdTaskId(String rackhdTaskId) {
		this.rackhdTaskId = rackhdTaskId;
	}

    public String getPayload() {
        return payload;
    }

    public void setPayload(String payload) {
        this.payload = payload;
    }

	/**
	 * @return the gmtStart
	 */
	public Date getGmtStart() {
		return gmtStart;
	}

	/**
	 * @param gmtStart
	 *            the gmtStart to set
	 */
	public void setGmtStart(Date gmtStart) {
		this.gmtStart = gmtStart;
	}

	/**
	 * @return the gmtFinish
	 */
	public Date getGmtFinish() {
		return gmtFinish;
	}

	/**
	 * @param gmtFinish
	 *            the gmtFinish to set
	 */
	public void setGmtFinish(Date gmtFinish) {
		this.gmtFinish = gmtFinish;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getElapsedTime() {
		return elapsedTime;
	}

	public void setElapsedTime(String elapsedTime) {
		this.elapsedTime = elapsedTime;
	}

	/**
	 * @return the imageName
	 */
	public String getImageName() {
		return imageName;
	}

	/**
	 * @param imageName
	 *            the imageName to set
	 */
	public void setImageName(String imageName) {
		this.imageName = imageName;
	}

	/**
	 * @return the typeName
	 */
	public String getTypeName() {
		return typeName;
	}

	/**
	 * @param typeName
	 *            the typeName to set
	 */
	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	@Override
	public String toString() {
		return JSONObject.toJSONString(this);
	}

}
