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

/**
* @website https://eladmin.vip
* @description /
* @author baobinglin
* @date 2023-08-18
**/
@Entity
@Data
@Table(name="data_agv_task")
public class AgvTask  extends BaseEntity implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "任务ID")
    private Integer id;

    @Column(name = "`stock_code`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "容器码")
    private String stockCode;

    @Column(name = "`stock_type_code`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "容器类型")
    private String stockTypeCode;

    @Column(name = "`start_slot_code`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "起点位置")
    private String startSlotCode;

    @Column(name = "`end_slot_code`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "终点位置")
    private String endSlotCode;

    @Column(name = "`slot_code`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "容器当前位置")
    private String slotCode;

    @Column(name = "`status`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "任务状态")
    private String status;

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

    @Column(name = "`job_id`")
    @ApiModelProperty(value = "下游任务号")
    private String jobId;

    @Column(name = "`job_type`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "工作类型")
    /**
     * 01：料箱
     */
    private String jobType="01";

    @Column(name = "`job_priority`")
    @ApiModelProperty(value = "优先级")
    private Integer jobPriority=1;

    @Column(name = "`job_priority_type`")
    @ApiModelProperty(value = "强制优先级")
    private Integer jobPriorityType;

    @Column(name = "`job_force`")
    @ApiModelProperty(value = "任务组")
    private String jobForce;

    @Column(name = "`job_force_asc`")
    @ApiModelProperty(value = "任务组执行顺序")
    private Integer jobForceAsc;

    @Column(name = "`job_message`")
    @ApiModelProperty(value = "返回报文")
    private String jobMessage;

    @Column(name = "`job_message_time`")
    @ApiModelProperty(value = "变动时间")
    private Timestamp jobMessageTime;

    @Column(name = "`start_time`")
    @ApiModelProperty(value = "开始时间")
    private Timestamp startTime;

    @Column(name = "`end_time`")
    @ApiModelProperty(value = "完成时间")
    private Timestamp endTime;


    public AgvTask() {

    }

    /**
     * 添加搬运任务
     * @param type 任务类型
     * @param stockCode 容器码，不知道填写虚拟容器吗
     * @param stockTypeCode 容器类型，必填
     * @param startSlotCode 起始位置(取料箱点位;料箱当前放置的货位码;取料箱时之前是否需要
     * 确认)中间用 ; 隔开 例如 9;2-001;false
     * @param endSlotCode 终点位置(放料箱点位;料箱放置的目标货位码;放料箱时之前是否需要
     * 确认)中间用 ; 隔开 例如 14;1-001;false
     * @param slotCode 当前位置 一般填起点位置，随着容器移动更新
     * @param status 任务状态，直接下发还是排队下发
     * @param jobType 工作类型，搬运，解绑，绑定。以及需要控制多种设备时做区分
     */
    public AgvTask(String type,String stockCode,String stockTypeCode,String startSlotCode,String endSlotCode,String slotCode,String status,String jobType){
        this.type=type;
        this.stockCode=stockCode;
        this.stockTypeCode=stockTypeCode;
        this.startSlotCode=startSlotCode;
        this.endSlotCode=endSlotCode;
        this.slotCode=slotCode;
        this.status=status;
        this.jobType=jobType;
    }
    public void copy(AgvTask source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
