package com.gyee.wisdom.dao.sql.alarm.Entity;

import com.gyee.wisdom.common.data.ToData;
import com.gyee.wisdom.common.data.alarm.GyeeProject;
import com.gyee.wisdom.common.data.windturbine.Project;
import com.gyee.wisdom.dao.sql.ModelConstants;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;


@Data
@NoArgsConstructor
@ToString
@EqualsAndHashCode()
@Entity
@Table(name = "project")
public class GyeeProjectEntity implements ToData<GyeeProject> {
    /** 主键ID */
    @Id
    @Column(name = "id")
    private String id;
    /** 编码 */
    @Column(name = "code")
    private String code;
    /** 名称 */
    @Column(name = "name")
    private String name;
    /** 地址*/
    @Column(name = "aname")
    private String aname;
    /** 风机id */
    @Column(name = "windpowerstationid")
    private String stationId;
    /** 装机容量*/
    @Column(name = "capacity")
    private Double capacity;
    /*装机单位*/
    @Column(name = "capacityunit")
    private String capacityUnit;
    /*装机数量*/
    @Column(name = "quantity")
    private Integer quantity;
    /*模型*/
    @Column(name = "model")
    private String model;
    /*投产日期*/
    @Column(name = "commissiondate")
    private Date commissionDate;
    /*主控电话*/
    @Column(name = "masterphone")
    private String masterPhone;
    /*执长*/
    @Column(name = "shiftforeman")
    private String shiftForman;
    /*执长电话*/
    @Column(name = "shiftforemanphone")
    private String shiftFormanPhone;
    /*顺序*/
    @Column(name = "ordernum")
    private Integer orderNum;

    public GyeeProjectEntity(GyeeProject project) {
        this.id = project.getId();
        this.code = project.getCode();
        this.name = project.getName();
        this.aname = project.getAname();
        this.stationId = project.getWindpowerstationid();
        this.capacity = project.getCapacity();
        this.capacityUnit = project.getCapacityUnit();
        this.quantity = project.getQuantity();
        this.model = project.getModel();
        this.commissionDate=project.getCommissionDate();
        this.masterPhone=project.getMasterPhone();
        this.shiftFormanPhone=project.getShiftForemanPhone();
        this.shiftForman=project.getShiftForeman();
        this.orderNum=project.getOrderNum();
    }

    @Override
    public GyeeProject toData() {
        if(this!=null) {
            GyeeProject project = new GyeeProject();
            project.setId(this.id);
            project.setCode(this.code);
            project.setName(this.name);
            project.setAname(this.aname);
            project.setWindpowerstationid(this.stationId);
            project.setCapacity(this.capacity);
            project.setCapacityUnit(this.getCapacityUnit());
            project.setQuantity(this.getQuantity());
            project.setModel(this.getModel());
            project.setCommissionDate(this.commissionDate);
            project.setMasterPhone(this.masterPhone);
            project.setShiftForeman(this.shiftFormanPhone);
            project.setShiftForemanPhone(this.shiftFormanPhone);
            project.setOrderNum(this.orderNum);
            return project;
        }else{
            return null;
        }
    }
}
