package com.wms_main.model.vo.wms;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.wms_main.model.po.TAppPickTaskBak;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

/**
 * 拣选记录Vo
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PickTaskBakVo {
    /**
     * 任务id
     */
    @JsonProperty(value = "pickId")
    private String pickId;
    /**
     * 拣选站台
     */
    @JsonProperty(value = "pickStand")
    private String pickStand;
    /**
     * 载具号
     */
    @JsonProperty(value = "vehicleId")
    private String vehicleId;
    /**
     * 任务状态
     */
    @JsonProperty(value = "pickStatus")
    private Integer pickStatus;
    /**
     * 创建时间
     */
    @JsonProperty(value = "createTime")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    /**
     * 发送时间
     */
    @JsonProperty(value = "sendTime")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime sendTime;
    /**
     * 到达时间
     */
    @JsonProperty(value = "arriveTime")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime arriveTime;
    /**
     * 离开时间
     */
    @JsonProperty(value = "leaveTime")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime leaveTime;

    /**
     * 将Po转化为Vo
     * @param po 数据库实体
     * @return 转化结果
     */
    public static PickTaskBakVo of(TAppPickTaskBak po) {
        if (po == null) {
            return new PickTaskBakVo();
        }
        return new PickTaskBakVo(
                po.getPickId(),
                po.getPickStand(),
                po.getVehicleId(),
                po.getPickStatus(),
                po.getCreateTime(),
                po.getSendTime(),
                po.getArriveTime(),
                po.getLeaveTime()
        );
    }
}
