/*
 *  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.modules.system.domain.Dept;
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.Time;
import java.sql.Timestamp;
import java.io.Serializable;

/**
 * @author JiangKun
 * @website https://eladmin.vip
 * @description /
 * @date 2024-01-11
 **/
@Entity
@Data
@Table(name = "data_pick_ticket")
public class PickTicket extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "ID")
    private Long id;
    @OneToOne
    @JoinColumn(name = "`area`")
    @ApiModelProperty(value = "出库库区")
    private Area area;

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

    @Column(name = "`code`", nullable = false)
    @NotBlank
    @ApiModelProperty(value = "单号")
    private String code;

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

    @Column(name = "`cus_code`")
    @ApiModelProperty(value = "客户订单号")
    private String cusCode;

    @Column(name = "`related_bill1`")
    @ApiModelProperty(value = "相关单号1")
    private String relatedBill1;

    @Column(name = "`related_bill2`")
    @ApiModelProperty(value = "相关单号2")
    private String relatedBill2;

    @Column(name = "`related_bill3`")
    @ApiModelProperty(value = "相关单号3")
    private String relatedBill3;

    @Column(name = "`order_date`")
    @ApiModelProperty(value = "订单日期")
    private Timestamp orderDate;

    @Column(name = "`ship_date`")
    @ApiModelProperty(value = "发货日期")
    private Timestamp shipDate;

    @Column(name = "`fh_by`")
    @ApiModelProperty(value = "发货人")
    private String fhBy;

    @Column(name = "`received_date`")
    @ApiModelProperty(value = "到达日期")
    private Timestamp receivedDate;

    @Column(name = "`sl_by`")
    @ApiModelProperty(value = "接收人")
    private String slBy;

    @Column(name = "`sl_qty`")
    @ApiModelProperty(value = "收料数量")
    private Double slQty=0d;

    @Column(name = "`sl_date`")
    @ApiModelProperty(value = "接收日期")
    private Timestamp slDate;

    @Column(name = "`tl_date`")
    @ApiModelProperty(value = "投料日期")
    private Timestamp tlDate;

    @Column(name = "`tl_by`")
    @ApiModelProperty(value = "投料人")
    private String tlBy;

    @Column(name = "`tl_qty`")
    @ApiModelProperty(value = "投料数量")
    private Double tlQty=0d;

    @Column(name = "`ship_to_name`")
    @ApiModelProperty(value = "收货方")
    private String shipToName;

    @Column(name = "`ship_address`")
    @ApiModelProperty(value = "收货地址")
    private String shipAddress;

    @Column(name = "`ship_man`")
    @ApiModelProperty(value = "收货联系人")
    private String shipMan;

    @Column(name = "`ship_tel`")
    @ApiModelProperty(value = "收货电话")
    private String shipTel;

    @Column(name = "`xq_qty`")
    @ApiModelProperty(value = "需求数量")
    private Double xqQty=0d;

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

    @Column(name = "`bh_qty`")
    @ApiModelProperty(value = "备货数量")
    private Double bhQty=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 = "`xb_qty`")
    @ApiModelProperty(value = "线边数量")
    private Double xbQty=0d;

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

    @Column(name = "`vehicle`")
    @ApiModelProperty(value = "车牌号")
    private String vehicle;
    @OneToOne
    @JoinColumn(name = "`bill_type`", unique = true)
    @ApiModelProperty(value = "单据类型")
    private BillType billType;

    @Column(name = "`bp_type`")
    @ApiModelProperty(value = "部品种类")
    private String bpType;
    @OneToOne
    @JoinColumn(name = "`dept_id`")
    @ApiModelProperty(value = "仓库ID")
    private Dept dept;

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

    @Column(name = "`pure_req_qty`")
    @ApiModelProperty(value = "纯需求数量")
    private Double pureReqQty = 0d;

    @Column(name = "`prep_re`")
    @ApiModelProperty(value = "备货需求数量")
    private Double prepRe = 0d;

    @Column(name = "`out_order_date`")
    @ApiModelProperty(value = "出单日期")
    private Timestamp outOrderDate;

    @Column(name = "`stocking_date`")
    @ApiModelProperty(value = "备货日期")
    private Timestamp stockingDate;

    @Column(name = "`bc_qty`")
    @ApiModelProperty(value = "波次补货数量")
    private Double bcQty=0d;

    @Column(name = "`pc`")
    @ApiModelProperty(value = "分批批次")
    private String pc;

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

    @Column(name = "`gc_code`")
    @ApiModelProperty(value = "工厂")
    private String gcCode;
    public void copy(PickTicket source) {
        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
