/*
*  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.businessdata.domain;

import com.youchain.base.BaseEntity;
import com.youchain.basicdata.domain.Area;
import com.youchain.basicdata.domain.Item;
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-10-20
**/
@Entity
@Data
@Table(name="data_count_detail")
public class CountDetail  extends BaseEntity implements Serializable {

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

    @OneToOne
    @JoinColumn(name = "`plan_id`")
    @ApiModelProperty(value = "计划")
    private CountPlan plan;

    @OneToOne
    @JoinColumn(name = "`item_id`")
    @ApiModelProperty(value = "物料")
    private Item item;

    @OneToOne
    @JoinColumn(name = "`area_id`")
    @ApiModelProperty(value = "库区")
    private Area area;

    @OneToOne
    @JoinColumn(name = "`warehouse_id`")
    @ApiModelProperty(value = "仓库")
    private Dept warehouse;

    @Column(name = "`inv_id`")
    @ApiModelProperty(value = "库存")
    private Long invId;

    @Column(name = "`plan_qty`")
    @ApiModelProperty(value = "计划数量")
    private Double planQty=0d;

    @Column(name = "`count_qty`")
    @ApiModelProperty(value = "盘点数量")
    private Double countQty=0d;

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

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


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