/*
*  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 lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @website https://eladmin.vip
* @description /
* @author JiangKun
* @date 2024-01-09
**/
@Entity
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Table(name="data_asn")
public class Asn  extends BaseEntity implements Serializable {

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

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

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

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

    @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`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "订单日期")
    private Timestamp orderDate;

    @Column(name = "`estimate_date`")
    @ApiModelProperty(value = "预计到货日期")
    private Timestamp estimateDate;

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

    @Column(name = "`from_name`")
    @ApiModelProperty(value = "发货方")
    private String fromName;

    @Column(name = "`from_address`")
    @ApiModelProperty(value = "发货地址")
    private String fromAddress;

    @Column(name = "`from_man`")
    @ApiModelProperty(value = "发货联系人")
    private String fromMan;

    @Column(name = "`from_tel`")
    @ApiModelProperty(value = "发货电话")
    private String fromTel;

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

    @Column(name = "`received_quantity`")
    @ApiModelProperty(value = "收货数量")
    private Double receivedQuantity;

    @Column(name = "`putaway_quantity`")
    @ApiModelProperty(value = "上架数量")
    private Double putawayQuantity;

    @Column(name = "`vehicle`")
    @ApiModelProperty(value = "车牌号")
    private String vehicle;

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

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

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

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