/*
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.youchain.basicdata.domain;

import com.youchain.base.BaseEntity;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
 * @author dengjiangkun
 * @website https://eladmin.vip
 * @description /
 * @date 2023-12-15
 **/
@Entity
@Data
@Table(name = "base_zcjxb")
public class Zcjxb extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "id")
    private Long id;

    @Column(name = "`code`", nullable = false)
    @NotNull
    @ApiModelProperty(value = "机械臂机台号")
    private Integer code;

    @Column(name = "`ip`", nullable = false)
    @NotBlank
    @ApiModelProperty(value = "ip地址")
    private String ip;

    @Column(name = "`port`", nullable = false)
    @NotNull
    @ApiModelProperty(value = "端口号")
    private Integer port;

    @Column(name = "`communication_type`", nullable = false)
    @NotBlank
    @ApiModelProperty(value = "通信类型")
    private String communicationType;

    @Column(name = "`address`", nullable = false)
    @NotNull
    @ApiModelProperty(value = "DB地址")
    private Integer address;

    @Column(name = "`data_length`")
    @ApiModelProperty(value = "数据长度")
    private Integer dataLength;

    @Column(name = "`offset_a1`")
    @ApiModelProperty(value = "偏移量-A返回空车")
    private Integer offsetA1;

    @Column(name = "`offset_b1`")
    @ApiModelProperty(value = "偏移量-B返回空车")
    private Integer offsetB1;

    @Column(name = "`offset_a2`")
    @ApiModelProperty(value = "偏移量-A叫料")
    private Integer offsetA2;

    @Column(name = "`offset_b2`")
    @ApiModelProperty(value = "偏移量-B叫料")
    private Integer offsetB2;

    @Column(name = "`offset_a3`")
    @ApiModelProperty(value = "偏移量-A车有料")
    private Integer offsetA3;

    @Column(name = "`offset_b3`")
    @ApiModelProperty(value = "偏移量-B车有料")
    private Integer offsetB3;

    @Column(name = "`point_a1`")
    @ApiModelProperty(value = "A车的地标点")
    private String pointA1;

    @Column(name = "`point_b1`")
    @ApiModelProperty(value = "B车的地标点")
    private String pointB1;

    @Column(name = "`item_a1`")
    @ApiModelProperty(value = "A车的物料")
    private String itemA1;

    @Column(name = "`item_b1`")
    @ApiModelProperty(value = "B车的物料")
    private String itemB1;

    @Column(name = "`enabled`")
    @ApiModelProperty(value = "是否启用")
    private Boolean enabled;

    @Column(name = "`modbus_tcp_task_finish`")
    @ApiModelProperty(value = "Modbus-tcp的任务是否结束")
    private Boolean modbusTcpTaskFinish;

    @Column(name = "`modbus_tcp_point`")
    @ApiModelProperty(value = "Modbus-tcp对应的地标点")
    private String modbusTcpPoint;

    @Column(name = "`modbus_tcp_item`")
    @ApiModelProperty(value = "Modbus-tcp对应的物料")
    private String modbusTcpItem;

    @Column(name = "`task_off_on_a`")
    @ApiModelProperty(value = "a车点位是否有任务")
    private Boolean taskOffOnA;

    @Column(name = "`task_off_on_b`")
    @ApiModelProperty(value = "b车点位是否有任务")
    private Boolean taskOffOnB;

    @Column(name = "`modbus_tcp_slave_id`")
    @ApiModelProperty(value = "从机ID")
    private Integer modbusTcpSlaveid;

    @Column(name = "`task_name`")
    @ApiModelProperty(value = "任务名称")
    private String taskName;
    @Column(name = "`read_value`")
    @ApiModelProperty(value = "读取的值")
    private Integer readValue;

    @Column(name = "`error_txt`")
    @ApiModelProperty(value = "异常日志")
    private String errorTxt;

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