/*
*  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.BillType;
import com.youchain.basicdata.domain.Item;
import com.youchain.basicdata.domain.Point;
import com.youchain.utils.BizStatus;
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 DengJiangKun
* @date 2024-02-28
**/
@Entity
@Data
@Table(name="data_pick_instruction")
public class PickInstruction  extends BaseEntity implements Serializable {

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

    @Column(name = "`allocation_number`")
    @ApiModelProperty(value = "指示单号")
    private String allocationNumber;

    @Column(name = "`allocation_date`")
    @ApiModelProperty(value = "指示日期")
    private Timestamp allocationDate;

    @OneToOne
    @JoinColumn(name = "`rk_area_id`")
    @ApiModelProperty(value = "入库库区")
    private Area rkArea;

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

    @Column(name = "`ac`")
    @ApiModelProperty(value = "A/C")
    private String ac;

    @Column(name = "`process_content`")
    @ApiModelProperty(value = "加工内容 ")
    private String processContent;

    @Column(name = "`tax_category`")
    @ApiModelProperty(value = "税别")
    private String taxCategory;

    @OneToOne
    @JoinColumn(name = "`out_k_type`")
    @ApiModelProperty(value = "出库类型")
    private BillType outKType;

    @Column(name = "`status`")
    @ApiModelProperty(value = "状态")
    private String status = BizStatus.WCD;

    @Column(name = "`indicated_qty`")
    @ApiModelProperty(value = "指示数量")
    private Double indicatedQty = 0d;

    @Column(name = "`allocated_qty`")
    @ApiModelProperty(value = "出单数量")
    private Double allocatedQty = 0d;

    @Column(name = "`bc_allocated_qty`")
    @ApiModelProperty(value = "本次出单数")
    private Double bcAllocatedQty = 0d;

    @Column(name = "`picked_qty`")
    @ApiModelProperty(value = "备货数量")
    private Double pickedQty = 0d;

    @Column(name = "`zt_qty`")
    @ApiModelProperty(value = "在途数量")
    private Double ztQty = 0d;

    @OneToOne
    @JoinColumn(name = "`zzkw_point_id`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "制造库位")
    private Point zzkwPoint;

    @OneToOne
    @JoinColumn(name = "`ck_area_id`")
    @ApiModelProperty(value = "出库库区")
    private Area ckArea;

    @Column(name = "`kit_number`")
    @ApiModelProperty(value = "成套单号")
    private String kitNumber;

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

    @Column(name = "`bom_id`")
    @ApiModelProperty(value = "BOM序号")
    private Long bomId;

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