/*
*  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.BigItem;
import com.youchain.basicdata.domain.BillType;
import com.youchain.basicdata.domain.Item;
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 javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.annotations.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @website https://eladmin.vip
* @description /
* @author jiangkun
* @date 2024-01-23
**/
@Entity
@Data
@Table(name="data_plan_pick_detail")
public class PlanPickDetail  extends BaseEntity implements Serializable {

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

    @OneToOne
    @JoinColumn(name = "`big_item_id`")
    @ApiModelProperty(value = "完成品番")
    private BigItem bigItem;

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

    @OneToOne
    @JoinColumn(name = "`zone_id`")
    @ApiModelProperty(value = "收货库区")
    private Area zone;

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

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

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

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

    @Column(name = "`shipped_quantity`")
    @ApiModelProperty(value = "发货数量")
    private Double shippedQuantity=0d;

    @Column(name = "`allocate_time`")
    @ApiModelProperty(value = "出单时间")
    private Timestamp allocateTime;

    @Column(name = "`ship_time`")
    @ApiModelProperty(value = "发货时间")
    private Timestamp shipTime;

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

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

    @Column(name = "`start_no`")
    @ApiModelProperty(value = "开始机号")
    private String startNo;

    @Column(name = "`end_no`")
    @ApiModelProperty(value = "终止机号")
    private String endNo;

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

    @Column(name = "`px_detail_id`")
    @ApiModelProperty(value = "铺线计划明细序号")
    private Long pxDetailId;

    @Column(name = "`is_last`")
    @ApiModelProperty(value = "是否最后一批计划")
    private Boolean isLast=Boolean.FALSE;

    @Column(name = "`batch_time`")
    @ApiModelProperty(value = "分批时段")
    private Timestamp batchTime;

    @Column(name = "`gc_code`")
    @ApiModelProperty(value = "工厂")
    private String gcCode;

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