package com.prolog.eis.model.outbound;

import com.prolog.eis.enums.base.BaseStatusEnum;
import com.prolog.framework.core.annotation.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * @author zmr
 * @description: 出库任务表
 * @date 2023-07-06 11:36
 */
@Data
@Table("biz_outbound_task")
public class BizOutboundTask {

    @Id
    @AutoKey(type = AutoKey.TYPE_IDENTITY)
    @Column("id")
    @ApiModelProperty("id")
    private Integer id;

    @Column("upper_system_task_id")
    @ApiModelProperty("上游系统任务id")
    private String upperSystemTaskId;

    @Column("wave_no")
    @ApiModelProperty("波次号")
    private String waveNo;

    @Column("eis_wave_no")
    @ApiModelProperty("EIS内部波次")
    private String eisWaveNo;

    @Column("eis_wave_time")
    @ApiModelProperty("eis波次创建时间")
    private LocalDateTime eisWaveTime;

    @Column("bill_no")
    @ApiModelProperty("单据编号")
    private String billNo;

    @Column("wms_bill_type")
    @ApiModelProperty("WMS订单类型")
    private Integer wmsBillType;

    @Column("bill_type")
    @ApiModelProperty("EIS订单类型")
    private Integer billType;

    @Column("pick_order_id")
    @ApiModelProperty("拣选单id")
    private Integer pickOrderId;

    @Column("status")
    @ApiModelProperty("状态(-20 库存不足,-10.取消,0.创建,10.开始 15已复核 ,20.完成,)")
    private Integer status;

    @Column("priority")
    @ApiModelProperty("优先级")
    private Integer priority;

    @Column("wms_warehouse_id")
    @ApiModelProperty("上游仓库id")
    private String wmsWarehouseId;

    @Column("wms_location_code")
    @ApiModelProperty("wms大货位")
    private String wmsLocationCode;

    @Column("business_type")
    @ApiModelProperty("业务类型")
    private String businessType;

    @Column("work_type")
    @ApiModelProperty("任务作业类型（10：入库，20：出库，30：盘点出库，55：合托）")
    private String workType;

    @Column("create_time")
    @ApiModelProperty("创建时间")
    private LocalDateTime createTime;

    @Column("update_time")
    @ApiModelProperty("修改时间")
    private LocalDateTime updateTime;

    @Column("finish_time")
    @ApiModelProperty("完成时间")
    private LocalDateTime finishTime;

    @Column("call_back_time")
    @ApiModelProperty("回告时间")
    private LocalDateTime callBackTime;

    @Column("error_msg")
    @ApiModelProperty("错误消息")
    private String errorMsg;

    @Column("extend_1")
    @ApiModelProperty("拓展字段1")
    private String extend1;

    @Column("extend_2")
    @ApiModelProperty("拓展字段2")
    private String extend2;

    @Column("extend_3")
    @ApiModelProperty("拓展字段3")
    private String extend3;

    @Column("check_store")
    @ApiModelProperty("校验库存（0：未校验，1：已校验库存）")
    private Integer checkStore;

    @Column("is_lock")
    @ApiModelProperty("锁订单0正常  1锁定")
    private Integer isLock;

    @Column("is_print_quality")
    @ApiModelProperty("是否打印首营、质检报告单0不打印  1打印")
    private String isPrintQuality;

    @Column("is_print_invoice")
    @ApiModelProperty("是否打印发票、出库清单0不打印  1打印")
    private String isPrintInvoice;

    @Column("company_id")
    @ApiModelProperty("客户ID")
    private String companyId;

    @Column("company_name")
    @ApiModelProperty("客户名称")
    private String companyName;

    @Column("enterprise_id")
    @ApiModelProperty("企业id")
    private String enterpriseId;


    @Column("is_bind_grid")
    @ApiModelProperty("是否绑定格口（0未绑定  1已绑定）")
    private Integer isBindGrid;
    @Column("bind_time")
    @ApiModelProperty("订单绑定格口时间")
    private Date bindTime;

    @Column("lack_state")
    @ApiModelProperty("0 正常 1：缺货")
    private Integer lackState;

    @Column("bill_count")
    @ApiModelProperty("面单最大能打印次数")
    private Integer billCount;

    @Column("scan_finish")
    @ApiModelProperty("是否扫描完成 0否 1是")
    private Integer scanFinish;

    @Column("check_type")
    @ApiModelProperty("1明盘 2暗盘")
    private Integer checkType;

    @Column("province")
    @ApiModelProperty("省份名称")
    private Integer province;

    @Column("order_create_time")
    @ApiModelProperty("订单销售时间")
    private LocalDateTime orderCreateTime;

    public int isLack() {
        return this.status.equals(BaseStatusEnum.STATUS_NO_STOCK.getCode()) ? 1 : 0;
    }

    @Ignore
    @ApiModelProperty(value = "出库明细集合")
    private List<BizOutboundTaskDetail> subList;
}

