package com.gyee.wisdom.dao.sql.Windturbine.entity;

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

import javax.persistence.*;

@Data
@NoArgsConstructor
@ToString
@EqualsAndHashCode()
@Entity
@Table(name = "windpowerstation")
public class PowerStationEntity implements ToData<PowerStation> {
    
//      `ID` varchar(50) NOT NULL,
//  `CODE` varchar(50) DEFAULT NULL,
//  `NAME` varchar(50) NOT NULL,
//  `ADDRESS` varchar(200) DEFAULT NULL,
//  `TELEPHONE` varchar(50) DEFAULT NULL,
//  `CAPACITY` float(18,2) DEFAULT NULL,
//  `CAPACITYUNIT` varchar(50) DEFAULT NULL,
//  `QUANTITY` int(11) DEFAULT NULL,
//  `ANAME` varchar(50) DEFAULT NULL,
//  `LONGITUDE` float(18,2) DEFAULT NULL,
//  `LATITUDE` float(18,2) DEFAULT NULL,
//  `PHOTO` varchar(50) DEFAULT NULL,
//  `COMPANYID` varchar(50) DEFAULT NULL,
//  `SYSTEMMANUFACT` varchar(100) DEFAULT NULL,
//  `HEADFARM` varchar(50) DEFAULT NULL,
//  `HEADFARMPHONE` varchar(50) DEFAULT NULL,
//  `MODEL` varchar(100) DEFAULT NULL,
//  `ORDERNUM` int(11) DEFAULT NULL,
//  `ALTITUDE` float(18,2) DEFAULT NULL,
    
    
    /**
     * 主键ID
     */
    @Id
    @Column(name = "ID")
    private String id;

    /**
     * 场站编码
     */
    @Column(name = "CODE")
    private String code;

    /**
     * 场站名称
     */
    @Column(name = "NAME")
    private String stationName;

    /**
     * 场站地址
     */
    @Column(name = "ADDRESS")
    private String adress;

    /**
     * 电话
     */
    @Column(name = "TELEPHONE")
    private String telephone;

    /**
     * 装机容量
     */
    @Column(name = "CAPACITY")
    private double capacity;

    /**
     * 容量单位
     */
    @Column(name = "CAPACITYUNIT")
    private String capacityUnit;

    /**
     * 装机数量
     */
    @Column(name = "QUANTITY")
    private int quantity;

    /**
     * 简称
     */
    @Column(name = "ANAME")
    private String shortName;

    /**
     * 经度
     */
    @Column(name = "LONGITUDE")
    private double longitude;

    /**
     * 纬度
     */
    @Column(name = "LATITUDE")
    private double latitude;

    /**
     * 公司编码
     */
    @Column(name = "COMPANYID")
    private String companyId;

    /**
     * 系统厂家
     */
    @Column(name = "SYSTEMMANUFACT")
    private String systemManuFact;

    /**
     * 场长
     */
    @Column(name = "HEADFARM")
    private String headFarm;

    /**
     * 场长电话
     */
    @Column(name = "HEADFARMPHONE")
    private String headFarmPhone;

    /**
     * 机型
     */
    @Column(name = "MODEL")
    private String model;

    /**
     * 编号
     */
    @Column(name = "ORDERNUM")
    private int orderNum;

    /**
     * 海拔高度
     */
    @Column(name = "ALTITUDE")
    private double height;


/*    @OneToMany(mappedBy="ID_,cascade = {CascadeType.MERGE,CascadeType.REFRESH},fetch=FetchType.EAGER)
     private List<ProjectEntity> listprojetentity;*/

    public PowerStationEntity(PowerStation station) {
        this.id=station.getId();
        this.code = station.getCode();
        this.stationName = station.getStationName();
        this.adress = station.getAddress();
        this.telephone = station.getTelephone();
        this.capacity = station.getCapacity();
        this.capacityUnit = station.getCapacityUnit();
        this.quantity = station.getQuantity();
        this.shortName = station.getShortName();
        this.longitude = station.getLongitude();
        this.latitude = station.getLatitude();
        this.companyId = station.getCompanyId();
        this.systemManuFact = station.getSystemManuFact();
        this.headFarm = station.getHeadFarm();
        this.headFarmPhone = station.getHeadFarmPhone();
        this.model = station.getModel();
        this.orderNum = station.getOrderNum();
        this.height = station.getHeight();

    }

    @Override
    public PowerStation toData() {
        if(this!=null) {
            PowerStation station = new PowerStation();
            station.setId(this.id);
            station.setCode(this.code);
            station.setStationName(this.stationName);
            station.setAddress(this.adress);
            station.setTelephone(this.telephone);
            station.setCapacity(this.capacity);
            station.setCapacityUnit(this.capacityUnit);
            station.setQuantity(this.quantity);
            station.setShortName(this.shortName);
            station.setStationName(this.stationName);
            station.setLongitude(this.longitude);
            station.setLatitude(this.latitude);
            station.setCompanyId(this.companyId);
            station.setSystemManuFact(this.systemManuFact);
            station.setHeadFarm(this.headFarm);
            station.setHeadFarmPhone(this.headFarmPhone);
            station.setModel(this.model);
            station.setOrderNum(this.orderNum);
            station.setHeight(this.height);
            /*station.setListproject(DataUtil.convertDataList(this.listprojetentity));*/
            return station;
        }else{
            return null;
        }
    }

}
