/*
 *  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.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 org.springframework.data.annotation.CreatedBy;

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

/**
 * @author baobinglin
 * @website https://eladmin.vip
 * @description /
 * @date 2024-01-04
 **/
@Entity
@Data
@Table(name = "data_xpp_record")
public class XppRecord extends BaseEntity implements Serializable {

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

    @Column(name = "`type`")
    @ApiModelProperty(value = "采集类型")
    private String type;

    @Column(name = "`ewm`")
    @ApiModelProperty(value = "二维码")
    private String ewm;

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

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

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

    @Column(name = "`nrs`")
    @ApiModelProperty(value = "纳入数")
    private Integer nrs;

    @Column(name = "`ddbh`")
    @ApiModelProperty(value = "订单编号")
    private String ddbh;

    @Column(name = "`zf`")
    @ApiModelProperty(value = "制番")
    private String zf;

    @Column(name = "`fzh`")
    @ApiModelProperty(value = "分支号")
    private String fzh;

    @Column(name = "`nr_date`")
    @ApiModelProperty(value = "纳入指示日")
    private Timestamp nrDate;

    @Column(name = "`sh_quantity`")
    @ApiModelProperty(value = "送货数量")
    private String shQuantity;

    @OneToOne
    @JoinColumn(name = "`asn_detail_id`")
    @ApiModelProperty(value = "入库明细")
    private AsnDetail asnDetailId;

    @CreatedBy
    @Column(name = "`cjr`")
    @ApiModelProperty(value = "采集人")
    private String cjr;

    @CreatedBy
    @Column(name = "`sjr`")
    @ApiModelProperty(value = "上架人")
    private String sjr;

    @Column(name = "`bhr`")
    @ApiModelProperty(value = "备货人")
    private String bhr;

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

    @Column(name = "`jsr`")
    @ApiModelProperty(value = "线边接收人")
    private String jsr;

    @OneToOne
    @JoinColumn(name = "`jskw`")
    @ApiModelProperty(value = "接收库位")
    private Point jskw;

    @Column(name = "`zztlr`")
    @ApiModelProperty(value = "制造投料人")
    private String zztlr;

    @Column(name = "`hctlr`")
    @ApiModelProperty(value = "缓存投料人")
    private String hctlr;

    @OneToOne
    @JoinColumn(name = "`zzkw`")
    @ApiModelProperty(value = "制造投料库位")
    private Point zzkw;

    @Column(name = "`cj_date`")
    @ApiModelProperty(value = "采集时间")
    private Timestamp cjDate;

    @Column(name = "`sj_date`")
    @ApiModelProperty(value = "上架时间")
    private Timestamp sjDate;

    @Column(name = "`bh_date`")
    @ApiModelProperty(value = "备货时间")
    private Timestamp bhDate;

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

    @Column(name = "`js_date`")
    @ApiModelProperty(value = "接收时间")
    private Timestamp jsDate;

    @Column(name = "`zztl_date`")
    @ApiModelProperty(value = "制造投料时间")
    private Timestamp zztlDate;

    @Column(name = "`c_point_code`")
    @ApiModelProperty(value = "材管库位")
    private String cPointCode;

    @Column(name = "`z_point_code`")
    @ApiModelProperty(value = "制造库位")
    private String zPointCode;

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

    @Column(name = "`rela_supplier`")
    @ApiModelProperty(value = "供应商")
    private String relaSupplier;

    @Column(name = "`rela_door`")
    @ApiModelProperty(value = "门号")
    private String relaDoor;

    @Column(name = "`rela_code`")
    @ApiModelProperty(value = "纳入场所")
    private String relaCode;

    @Column(name = "`rela_type`")
    @ApiModelProperty(value = "箱种")
    private String relaType;

    @Column(name = "`rela_quantity`")
    @ApiModelProperty(value = "收容数")
    private Double relaQuantity;

    @Column(name = "`area_code`")
    @ApiModelProperty(value = "品区")
    private String areaCode;

    @Column(name = "`item_code`")
    @ApiModelProperty(value = "品番")
    private String itemCode;

    @Column(name = "`dept_id`")
    @ApiModelProperty(value = "仓库ID")
    private Long deptId;

    @Column(name = "`description`")
    @ApiModelProperty(value = "描述")
    private String description;

    @Column(name = "`enabled`")
    @ApiModelProperty(value = "状态：1启用、0禁用")
    private Boolean enabled=Boolean.TRUE;

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

    @OneToOne
    @JoinColumn(name = "`rk_task_id`")
    @ApiModelProperty(value = "入库任务")
    private Task rkTask;

    @OneToOne
    @JoinColumn(name = "`item_key_id`")
    @ApiModelProperty(value = "物料批次")
    private ItemKey itemKey;

    @OneToOne
    @JoinColumn(name = "`inv_point_id`")
    @ApiModelProperty(value = "库存库位")
    private Point invPoint;

    @OneToOne
    @JoinColumn(name = "`ck_task_log_id`")
    @ApiModelProperty(value = "出库任务日志")
    private TaskLog ckTaskLog;

    @Column(name = "`tf_ly`")
    @ApiModelProperty(value = "是否留样：1启用、0禁用")
    private Boolean tfLy=Boolean.FALSE;

    @Column(name = "`be_fz`")
    @ApiModelProperty(value = "是否复制：1复制、0为复制")
    private Boolean beFz=Boolean.FALSE;

    @Column(name = "`ly_data`")
    @ApiModelProperty(value = "留样日期")
    private Timestamp lyData;

    @Column(name = "`hy_data`")
    @ApiModelProperty(value = "还样日期")
    private Timestamp hyData;

    @Column(name = "`tk_data`")
    @ApiModelProperty(value = "退库日期")
    private Timestamp tkData;

    @Column(name = "`bd_ewm`")
    @ApiModelProperty(value = "补打二维码")
    private String bdEwm;
    @Column(name = "`bd_fzh`")
    @ApiModelProperty(value = "补打分支号")
    private String bdFzh;
    @Column(name = "`bd_nrs`")
    @ApiModelProperty(value = "补打纳入数")
    private int bdNrs=0;

    @Column(name = "`ly_code`")
    @ApiModelProperty(value = "留样出库单")
    private String lyCode;

    @Column(name = "`receipt_code`")
    @ApiModelProperty(value = "收货清单号")
    private String receiptCode;

    @Column(name = "`count_code`")
    @ApiModelProperty(value = "盘点单号")
    private String countCode;

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