/*
 *  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 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.io.Serializable;
import java.sql.Timestamp;

/**
 * @author huojin
 * @website https://eladmin.vip
 * @description /
 * @date 2024-04-08
 **/
@Entity
@Data
@Table(name = "data_order")
public class Order extends BaseEntity implements Serializable {

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

    @Column(name = "`delivery_header_id`")
    @ApiModelProperty(value = "送货单头ID和003接口关联")
    private Integer deliveryHeaderId;

    @Column(name = "`delivery_line_id`")
    @ApiModelProperty(value = "送货单行ID")
    private Integer deliveryLineId;

    @Column(name = "`delivery_notify_line_id`")
    @ApiModelProperty(value = "送货通知单行ID")
    private Integer deliveryNotifyLineId;

    @Column(name = "`delivery_number`")
    @ApiModelProperty(value = "送货单号")
    private String deliveryNumber;

    @Column(name = "`barcode_number`", unique = true)
    @NotBlank
    @ApiModelProperty(value = "送货单条码号")
    private String barcodeNumber;

    @Column(name = "`delivery_status`")
    @ApiModelProperty(value = "送货单状态")
    private String deliveryStatus;

    @Column(name = "`received_inv_code`")
    @ApiModelProperty(value = "mls接收子库编码")
    private String receivedInvCode;

    @Column(name = "`received_inv_name`")
    @ApiModelProperty(value = "mls接收子库名称")
    private String receivedInvName;

    @Column(name = "`received_area_code`")
    @ApiModelProperty(value = "mls接收货区编码")
    private String receivedAreaCode;

    @Column(name = "`received_area_name`")
    @ApiModelProperty(value = "mls接收货区名称")
    private String receivedAreaName;

    @Column(name = "`received_location_code`")
    @ApiModelProperty(value = "mls货位编码")
    private String receivedLocationCode;

    @Column(name = "`received_location_name`")
    @ApiModelProperty(value = "mls货位名称")
    private String receivedLocationName;

    @Column(name = "`item_code`")
    @ApiModelProperty(value = "物料编码")
    private String itemCode;

    @Column(name = "`delivery_qty`")
    @ApiModelProperty(value = "计划数量")
    private Double deliveryQty;

    @Column(name = "`in_inspector`")
    @ApiModelProperty(value = "检验员")
    private String inInspector;

    @Column(name = "`received_qty`")
    @ApiModelProperty(value = "实际接收数量")
    private Double receivedQty;

    @Column(name = "`is_iqc_inspected`")
    @ApiModelProperty(value = "Y-已检验N-未检验")
    private String isIqcInspected;

    @Column(name = "`iqc_result`")
    @ApiModelProperty(value = "检验结果(不合格：REJECT，合格：ACCEPT)")
    private String iqcResult;

    @Column(name = "`is_created_label`")
    @ApiModelProperty(value = "是否已生成标签")
    private String isCreatedLabel;

    @Column(name = "`supplier_code`")
    @ApiModelProperty(value = "供应商编码")
    private String supplierCode;

    @Column(name = "`supplier_name`")
    @ApiModelProperty(value = "供应商名称")
    private String supplierName;

    @Column(name = "`mls_update_time`")
    @ApiModelProperty(value = "MLS修改时间")
    private Timestamp mlsUpdateTime;

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

    public Order() {

    }

    public Order(Integer deliveryHeaderId, Integer deliveryLineId, Integer deliveryNotifyLineId, String deliveryNumber, String barcodeNumber, String deliveryStatus, String receivedInvCode, String receivedInvName, String receivedAreaCode, String receivedAreaName, String receivedLocationCode, String receivedLocationName, String itemCode, Double deliveryQty, String inInspector, Double receivedQty, String isIqcInspected, String iqcResult, String isCreatedLabel, String supplierCode, String supplierName, Timestamp mlsUpdateTime) {
        this.deliveryHeaderId = deliveryHeaderId;
        this.deliveryLineId = deliveryLineId;
        this.deliveryNotifyLineId = deliveryNotifyLineId;
        this.deliveryNumber = deliveryNumber;
        this.barcodeNumber = barcodeNumber;
        this.deliveryStatus = deliveryStatus;
        this.receivedInvCode = receivedInvCode;
        this.receivedInvName = receivedInvName;
        this.receivedAreaCode = receivedAreaCode;
        this.receivedAreaName = receivedAreaName;
        this.receivedLocationCode = receivedLocationCode;
        this.receivedLocationName = receivedLocationName;
        this.itemCode = itemCode;
        this.deliveryQty = deliveryQty;
        this.inInspector = inInspector;
        this.receivedQty = receivedQty;
        this.isIqcInspected = isIqcInspected;
        this.iqcResult = iqcResult;
        this.isCreatedLabel = isCreatedLabel;
        this.supplierCode = supplierCode;
        this.supplierName = supplierName;
        this.mlsUpdateTime = mlsUpdateTime;
    }
}
