/*
 *  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 = "`package_type`")
    @ApiModelProperty(value = "包装类型")
    private String packageType;

    @Column(name = "`spec_quantity`")
    @ApiModelProperty(value = "规格数量")
    private Double specQuantity=0D;

    @Column(name = "`spec_weight`")
    @ApiModelProperty(value = "规格重量")
    private Double specWeight=0D;

    @Column(name = "`gross_weight`")
    @ApiModelProperty(value = "毛重")
    private Double grossWeight=0D;

    @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 = "`volume`")
    @ApiModelProperty(value = "体积")
    private Double volume=0D;

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

    @OneToOne
    @JoinColumn(name = "`rec_storage_area_id`")
    @ApiModelProperty(value = "推荐库区")
    private Area recStorageArea;

    @Column(name = "`type`")
    @ApiModelProperty(value = "类型")
    private String type;

    @Column(name = "`value_grade`")
    @ApiModelProperty(value = "物料价值等级")
    private String valueGrade;

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

    @Column(name = "`alert_days`")
    @ApiModelProperty(value = "预警天数")
    private Integer alertDays=0;

    @Column(name = "`is_batch`")
    @ApiModelProperty(value = "是否批次")
    private Boolean isBatch=false;

    @Column(name = "`is_serial`")
    @ApiModelProperty(value = "是否序列号")
    private Boolean isSerial=false;

    @Column(name = "`is_valid_period`")
    @ApiModelProperty(value = "是否有效期")
    private Boolean isValidPeriod=false;

    @Column(name = "`is_hazardous`")
    @ApiModelProperty(value = "是否危化品")
    private Boolean isHazardous=false;

    @Column(name = "`is_inv_available`")
    @ApiModelProperty(value = "是否有库存")
    private Boolean isInvAvailable=false;

    @Column(name = "`is_sap_material`")
    @ApiModelProperty(value = "是否SAP料号")
    private Boolean isSapMaterial=false;

    @Column(name = "`is_inspection`")
    @ApiModelProperty(value = "是否质检")
    private Boolean isInspection=false;

    @Column(name = "`heat_value`")
    @ApiModelProperty(value = "热度值")
    private Integer heatValue=0;

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

    @Column(name = "`enabled`")
    @ApiModelProperty(value = "是否失效")
    private Boolean enabled=true;

    @OneToOne
    @JoinColumn(name = "`point_id`")
    @ApiModelProperty(value = "库位")
    private Point point;

    @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;

    @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_str2`")
    @ApiModelProperty(value = "扩展字符2")
    private String extendStr2;


    @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));
    }
}
