/*
 *  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.basicdata.domain;

import com.youchain.base.BaseEntity;
import com.youchain.basicdata.service.dto.PointDto;
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 javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;
import java.util.Set;

/**
 * @author HJL
 * @website https://eladmin.vip
 * @description /
 * @date 2023-08-14
 **/
@Entity
@Data
@Table(name = "base_area")
public class Area extends BaseEntity implements Serializable {

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

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

    @Column(name = "`name`", nullable = false)
    @NotBlank
    @ApiModelProperty(value = "库区名称")
    private String name;

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

    @Column(name = "`enabled`", nullable = false)
    @NotNull
    @ApiModelProperty(value = "状态：1启用、0禁用")
    private Boolean enabled;

    @Column(name = "`heat`")
    @ApiModelProperty(value = "热度值")
    private Double heat=0d;

    @Column(name = "`pos_x`")
    @ApiModelProperty(value = "坐标X,更改成排序号")
    private Double posX=0d;

    @Column(name = "`pos_y`")
    @ApiModelProperty(value = "坐标Y")
    private Double posY=0d;

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


    @Column(name = "`sequence_no`")
    @ApiModelProperty(value = "序列号")
    private String sequenceNo;

    @Column(name = "`org_code`")
    @ApiModelProperty(value = "org编号")
    private String orgCode;

    @Column(name = "`gc_code`")
    @ApiModelProperty(value = "工厂")
    private String gcCode;

    @Column(name = "`working_station`",nullable = true)
    @ApiModelProperty(value = "所属工位")
    private String workingStation;

//    @OneToOne(mappedBy = "area")
//    @JoinColumn(name = "point_id")
//    @ApiModelProperty(value = "缓存库位")
//    private Point point;

    @Column(name = "`point_id`")
    @ApiModelProperty(value = "缓存库位ID")
    private Long pointId;
    @Column(name = "`point_code`")
    @ApiModelProperty(value = "缓存库位Code")
    private String pointCode;

    @Column(name = "`bexb`")
    @ApiModelProperty(value = "线边接收")
    private Boolean bexb;

    @Column(name = "`besh`")
    @ApiModelProperty(value = "收货仓库")
    private Boolean besh;

    @Column(name = "`bezz`")
    @ApiModelProperty(value = "制造库位耗用")
    private Boolean bezz;

    @Column(name = "`betc`")
    @ApiModelProperty(value = "台车库区")
    private Boolean betc=false;

    @Column(name = "`shdd`")
    @ApiModelProperty(value = "收货担当")
    private String shdd;

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