package org.nl.acs.device.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.nl.acs.common.base.CommonModel;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;

/**
* @author jiaolm
* @date 2023-05-09
*/
@Data
@Builder
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@TableName("acs_device_extra")
public class DeviceExtra extends CommonModel<DeviceExtra> implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "设备标识")
    @TableId(type= IdType.ASSIGN_ID)
    private String extra_id;

    @ApiModelProperty(value = "字段编码")
    @NotBlank
    private String extra_code;

    @ApiModelProperty(value = "字段名字")
    @NotBlank
    private String extra_name;

    @ApiModelProperty(value = "字段值")
    private String extra_value;

    @ApiModelProperty(value = "扩展值类型")
    private String value_type;

    @ApiModelProperty(value = "扩展字段类型")
    private String filed_type;

    @ApiModelProperty(value = "顺序号")
    @NotNull
    private BigDecimal order_seq;

    @ApiModelProperty(value = "设备标识")
    @NotBlank
    private String device_id;

    @ApiModelProperty(value = "设备编码")
    private String device_code;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "是否启用")
    @NotBlank
    private String is_active;

    @ApiModelProperty(value = "是否删除")
    @NotBlank
    private String is_delete;

    @ApiModelProperty(value = "创建者")
    @NotBlank
    @TableField(fill= FieldFill.INSERT)
    private String create_by;

    @ApiModelProperty(value = "创建时间")
    @NotBlank
    @TableField(fill= FieldFill.INSERT)
    private String create_time;

    @ApiModelProperty(value = "修改者")
    @TableField(fill= FieldFill.INSERT_UPDATE)
    private String update_by;

    @ApiModelProperty(value = "修改时间")
    @TableField(fill= FieldFill.INSERT_UPDATE)
    private String update_time;

    @TableField(exist = false)
    private String device_type;

    @TableField(exist = false)
    private String device_name;

    @TableField(exist = false)
    private String opc_server_id;

    @TableField(exist = false)
    private String opc_code;

    @TableField(exist = false)
    private String plc_code;

    @TableField(exist = false)
    private String driver_code;



    public void copyFrom(DeviceExtra source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
