package com.xydl.cac.entity;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "zsb")
@ApiModel("主设备表")
public class Zsb {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    @NotBlank(message = "名称不能为空")
    @Size(max = 50, message = "名称长度不能超过50个字符")
    @ApiModelProperty("名称")
    @Column(name = "mc")
    private String mc;

    @NotNull(message = "区域id不能为空")
    @ApiModelProperty("区域id")
    @Column(name = "jgid")
    private Integer jgid;

    @NotNull(message = "类型id不能为空")
    @ApiModelProperty("类型id")
    @Column(name = "lxid")
    private Integer lxid;

    @Column(name = "deviceip")
    private String deviceip;

    @Column(name = "deviceport")
    private String deviceport;

    @Column(name = "deviceusername")
    private String deviceusername;

    @Column(name = "devicepasswd")
    private String devicepasswd;

    @ApiModelProperty("变电站id")
    @Column(name = "bdzid")
    private Integer bdzid;

    @Column(name = "address")
    private BigDecimal address;

    @Column(name = "frequency")
    private BigDecimal frequency;

    @Column(name = "portname")
    private String portname;

    @Column(name = "venderid")
    private String venderid;

    @Column(name = "transcount")
    private BigDecimal transcount;

    @Column(name = "vendercode")
    private String vendercode;

    @Column(name = "xh")
    private BigDecimal xh;

    @Column(name = "enable")
    private BigDecimal enable;

    @Column(name = "sbbm")
    private String sbbm;

    @Column(name = "yxbh")
    private String yxbh;

    @Column(name = "zcxz")
    private String zcxz;

    @Column(name = "zcdw")
    private String zcdw;

    @Column(name = "xs")
    private String xs;

    @Column(name = "jb")
    private String jb;

    @Column(name = "xb")
    private String xb;

    @Column(name = "eddy")
    private String eddy;

    @Column(name = "eddl")
    private String eddl;

    @Column(name = "edpl")
    private String edpl;

    @Column(name = "edxh")
    private String edxh;

    @Column(name = "sccj")
    private String sccj;

    @Column(name = "ccbh")
    private String ccbh;

    @Column(name = "ccdh")
    private String ccdh;

    @Column(name = "zzgj")
    private String zzgj;

    @Column(name = "ccrq")
    private String ccrq;

    @Column(name = "tcrq")
    private String tcrq;

    @Column(name = "syhj")
    private String syhj;

    @Column(name = "fwdj")
    private String fwdj;

    @Column(name = "zcbh")
    private String zcbh;

    @Column(name = "yt")
    private BigDecimal yt;

    @Column(name = "whbz")
    private String whbz;

    @Column(name = "sbzr")
    private String sbzr;

    @Column(name = "ywdw")
    private String ywdw;

    @Column(name = "gcbh")
    private String gcbh;

    @Column(name = "gcmc")
    private String gcmc;

    @Column(name = "sbid")
    private String sbid;

    @Column(name = "zxmc")
    private String zxmc;

    @Column(name = "sbcz")
    private String sbcz;

    @Column(name = "zyfl")
    private String zyfl;

    @Column(name = "pmbm")
    private String pmbm;

    @Column(name = "gnwz")
    private String gnwz;

    @Column(name = "sblxbm")
    private String sblxbm;

    @Column(name = "zfid")
    private String zfid;

    @Column(name = "zjtyrq")
    private String zjtyrq;

    @Column(name = "sbzjfs")
    private String sbzjfs;

    @Column(name = "zcyjqcid")
    private String zcyjqcid;

    @Column(name = "dqmpyxkid")
    private String dqmpyxkid;

    @Column(name = "ssdzdydj")
    private String ssdzdydj;

    @Column(name = "djsj")
    private String djsj;

    @Column(name = "sssj")
    private String sssj;

    @ApiModelProperty("变电站名称")
    @Transient
    private String bdzName;

    @ApiModelProperty("区域名称")
    @Transient
    private String jgName;

    @ApiModelProperty("类型名称")
    @Transient
    private String lxName;

    @Transient
    private List<NSensor> children;

    public void addChild(NSensor child) {
        if (children == null) {
            children = new ArrayList<>();
        }
        children.add(child);
    }

}