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.TAppPickTask;
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 PickTaskVo {
    /**
     * 任务id
     */
    @JsonProperty("pickId")
    private String pickId;
    /**
     * 拣选站台
     */
    @JsonProperty("pickStand")
    private String pickStand;
    /**
     * 载具号
     */
    @JsonProperty("vehicleId")
    private String vehicleId;
    /**
     * 任务状态
     */
    @JsonProperty("pickStatus")
    private Integer pickStatus;
    /**
     * 创建时间
     */
    @JsonProperty("createTime")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    /**
     * 发送时间
     */
    @JsonProperty("sendTime")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime sendTime;
    /**
     * 到达时间
     */
    @JsonProperty("arriveTime")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime arriveTime;
    /**
     * 离开时间
     */
    @JsonProperty("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 PickTaskVo of(TAppPickTask po) {
        if (po == null) {
            return new PickTaskVo();
        }
        return new PickTaskVo(
                po.getPickId(),
                po.getPickStand(),
                po.getVehicleId(),
                po.getPickStatus(),
                po.getCreateTime(),
                po.getSendTime(),
                po.getArriveTime(),
                po.getLeaveTime()
        );
    }
}
