/*
*  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.annotation.Query;
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 liuxue
* @date 2023-07-28
**/
@Entity
@Data
@Table(name="base_stock")
public class Stock extends BaseEntity implements  Serializable {

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

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

    @Column(name = "`status`")
    @ApiModelProperty(value = "容器状态")
    private String status;

    @Column(name = "`pid`")
    @ApiModelProperty(value = "上级容器ID")
    private Long pid;

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

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

    @Column(name = "`sub_count`")
    @ApiModelProperty(value = "子容器数量")
    private Integer subCount;

    @Column(name = "`name`")
    @NotBlank
    @ApiModelProperty(value = "容器名称")
    private String name;


    @Column(name = "`stock_type`", nullable = false)
    @ApiModelProperty(value = "容器类型")
    private String stockType;


    @Column(name = "`use_weight`")
    @ApiModelProperty(value = "容器使用重量")
    private Double useWeight;

    @Column(name = "`use_size`")
    @ApiModelProperty(value = "容器使用体积")
    private Double useSize;

    @Column(name = "`usage_weight`")
    @ApiModelProperty(value = "容器重量占用率")
    private Double usageWeight;

    @Column(name = "`usage_size`")
    @ApiModelProperty(value = "容器体积占用率")
    private Double usageSize;

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

    @Column(name = "`top_id`")
    @ApiModelProperty(value = "顶级容器ID")
    private Long topId;

    @Column(name = "`line_slot_code`")
    @ApiModelProperty(value = "小件线边点位")
    private String lineSlotCode;



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