/*
 *  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 com.youchain.modules.system.domain.Dept;
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;

/**
 * @website https://eladmin.vip
 * @description /
 * @author houjianlan
 * @date 2023-08-07
 **/
@Entity
@Data
@Table(name="base_item")
public class Item extends BaseEntity implements Serializable {

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

    @Column(name = "`code`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "代码")
    private String code;

    @Column(name = "`name`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "名称")
    private String name;

    @Column(name = "`specs`")
    @ApiModelProperty(value = "规格")
    private String specs;

    @Column(name = "`structure_id`")
    @ApiModelProperty(value = "客户ID")
    private Long structureId;

    @Column(name = "`description`")
    @ApiModelProperty(value = "描述")
    private String description;

    @Column(name = "`enabled`")
    @ApiModelProperty(value = "状态")
    private Boolean enabled=true;

    @Column(name = "`valid_period`")
    @ApiModelProperty(value = "保质期")
    private Integer validPeriod;

    @Column(name = "`alert_leading_days`")
    @ApiModelProperty(value = "预警天数")
    private Integer alertLeadingDays;

    @Column(name = "`large_class`")
    @ApiModelProperty(value = "大类")
    private String largeClass;

    @Column(name = "`center_class`")
    @ApiModelProperty(value = "中类")
    private String centerClass;

    @Column(name = "`small_class`")
    @ApiModelProperty(value = "小类")
    private String smallClass;

    @Column(name = "`good_type`")
    @ApiModelProperty(value = "物料类型")
    private String goodType;

    @Column(name = "`length`")
    @ApiModelProperty(value = "长")
    private Double length=0d;

    @Column(name = "`width`")
    @ApiModelProperty(value = "宽")
    private Double width=0d;

    @Column(name = "`height`")
    @ApiModelProperty(value = "高")
    private Double height=0d;

    @Column(name = "`weight`")
    @ApiModelProperty(value = "重量")
    private Double weight=0d;

    @Column(name = "`volume`")
    @ApiModelProperty(value = "体积")
    private Double volume=0d;

    @Column(name = "`unit`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "单位")
    private String unit;

    @Column(name = "`master_unit`")
    @ApiModelProperty(value = "大单位")
    private String masterUnit;

    @Column(name = "`pack_number`")
    @ApiModelProperty(value = "包装系数")
    private Integer packNumber;

    @Column(name = "`bar_code`")
    @ApiModelProperty(value = "条码")
    private String barCode;

    @OneToOne
    @JoinColumn(name = "dept_id")
    @ApiModelProperty(value = "仓库")
    private Dept dept;

    @Column(name = "`source_name`")
    @ApiModelProperty(value = "来源名称")
    private String sourceName;

    @Column(name = "`source_id`")
    @ApiModelProperty(value = "来源序号")
    private Long sourceId;

    @OneToOne
    @JoinColumn(name = "stock_type")
    @ApiModelProperty(value = "料箱类型")
    private StockType stockType;

    @Column(name = "`extend_d1`")
    @ApiModelProperty(value = "扩展小数1")
    private Double extendD1=0d;

    @Column(name = "`extend_d2`")
    @ApiModelProperty(value = "扩展小数2")
    private Double extendD2=0d;

    @Column(name = "`extend_d3`")
    @ApiModelProperty(value = "扩展小数3")
    private Double extendD3=0d;

    @Column(name = "`extend_d4`")
    @ApiModelProperty(value = "扩展小数4")
    private Double extendD4=0d;

    @Column(name = "`extend_d5`")
    @ApiModelProperty(value = "扩展小数5")
    private Double extendD5=0d;

    @Column(name = "`extend_num1`")
    @ApiModelProperty(value = "扩展整型1")
    private Long extendNum1;

    @Column(name = "`extend_num2`")
    @ApiModelProperty(value = "扩展整型2")
    private Long extendNum2;

    @Column(name = "`extend_num3`")
    @ApiModelProperty(value = "扩展整型3")
    private Long extendNum3;

    @Column(name = "`extend_num4`")
    @ApiModelProperty(value = "扩展整型4")
    private Long extendNum4;

    @Column(name = "`extend_num5`")
    @ApiModelProperty(value = "扩展整型5")
    private Long extendNum5;

    @Column(name = "`extend_str1`")
    @ApiModelProperty(value = "扩展字符1")
    private String extendStr1;

    @Column(name = "`extend_str2`")
    @ApiModelProperty(value = "扩展字符2")
    private String extendStr2;

    @Column(name = "`extend_str3`")
    @ApiModelProperty(value = "扩展字符3")
    private String extendStr3;

    @Column(name = "`extend_str4`")
    @ApiModelProperty(value = "扩展字符4")
    private String extendStr4;

    @Column(name = "`extend_str5`")
    @ApiModelProperty(value = "扩展字符5")
    private String extendStr5;

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