/*
*  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.Item;
import com.youchain.basicdata.domain.Point;
import com.youchain.basicdata.domain.Stock;
import com.youchain.businessdata.service.dto.ItemKeyDto;
import com.youchain.modules.system.domain.Dept;
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 java.sql.Timestamp;
import java.io.Serializable;

/**
* @website https://eladmin.vip
* @description /
* @author huojin
* @date 2023-08-25
**/
@Entity
@Data
@Table(name="data_task_log")
public class TaskLog  extends BaseEntity implements Serializable {

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

    @OneToOne
    @JoinColumn(name = "`item_id`")
    @ApiModelProperty(value = "物料序号")
    private Item item;

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

    @OneToOne
    @JoinColumn(name = "`task_id`")
    @ApiModelProperty(value = "任务序号")
    private Task task;


    @OneToOne
    @JoinColumn(name = "`src_stock_id`")
    @ApiModelProperty(value = "源容器")
    private Stock srcStock;


    @OneToOne
    @JoinColumn(name = "`dst_stock_id`")
    @ApiModelProperty(value = "目标容器")
    private Stock dstStock;


    @OneToOne
    @JoinColumn(name = "`src_point_id`")
    @ApiModelProperty(value = "源点位")
    private Point srcPoint;

    @OneToOne
    @JoinColumn(name = "`dst_point_id`")
    @ApiModelProperty(value = "目标点位")
    private Point dstPoint;

    @Column(name = "`src_stock_code`")
    @ApiModelProperty(value = "源容器编码")
    private String srcStockCode;

    @Column(name = "`dst_stock_code`")
    @ApiModelProperty(value = "目标容器编码")
    private String dstStockCode;

    @Column(name = "`src_loc_code`")
    @ApiModelProperty(value = "源点位编码")
    private String srcLocCode;

    @Column(name = "`dst_loc_code`")
    @ApiModelProperty(value = "目标点位编码")
    private String dstLocCode;

    @Column(name = "`inv_status`")
    @ApiModelProperty(value = "属性6")
    private String invStatus;

    @Column(name = "`be_back`")
    @ApiModelProperty(value = "退回")
    private Boolean beBack;

    @Column(name = "`move_qty`")
    @ApiModelProperty(value = "拣货数量")
    private Double moveQty;

    @Column(name = "`ship_qty`")
    @ApiModelProperty(value = "发运数量")
    private Double shipQty;

    @Column(name = "`put_code`")
    @ApiModelProperty(value = "上架号")
    private String putCode;

    @Column(name = "`inv_id`")
    @ApiModelProperty(value = "库存ID")
    private Long invId;

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

    @Column(name = "`create_by`")
    @ApiModelProperty(value = "创建人")
    private String createBy;

    @Column(name = "`update_by`")
    @ApiModelProperty(value = "修改人")
    private String updateBy;

    @Column(name = "`ship_by`")
    @ApiModelProperty(value = "发运人")
    private String shipBy;

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

    @Column(name = "`create_time`")
    @ApiModelProperty(value = "创建时间")
    private Timestamp createTime;

    @Column(name = "`update_time`")
    @ApiModelProperty(value = "修改时间")
    private Timestamp updateTime;

    /**
     *
     * @param item
     * @param itemKey
     * @param task
     * @param srcStock
     * @param dstStock
     * @param srcPoint
     * @param dstPoint
     * @param srcStockCode
     * @param dstStockCode
     * @param srcLocCode
     * @param dstLocCode
     * @param invStatus
     * @param beBack
     * @param moveQty
     * @param shipQty
     * @param putCode
     * @param invId
     * @param dept
     */
    public TaskLog(Item item, ItemKey itemKey, Task task, Stock srcStock, Stock dstStock, Point srcPoint, Point dstPoint, String srcStockCode, String dstStockCode, String srcLocCode, String dstLocCode, String invStatus, Boolean beBack, Double moveQty, Double shipQty, String putCode, Long invId, Dept dept) {
        this.item = item;
        this.itemKey = itemKey;
        this.task = task;
        this.srcStock = srcStock;
        this.dstStock = dstStock;
        this.srcPoint = srcPoint;
        this.dstPoint = dstPoint;
        this.srcStockCode = srcStockCode;
        this.dstStockCode = dstStockCode;
        this.srcLocCode = srcLocCode;
        this.dstLocCode = dstLocCode;
        this.invStatus = invStatus;
        this.beBack = beBack;
        this.moveQty = moveQty;
        this.shipQty = shipQty;
        this.putCode = putCode;
        this.invId = invId;
        this.dept = dept;
    }

    public TaskLog() {

    }


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