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.TAppStock;
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 StockVo {
    /**
     * 库存ID
     */
    @JsonProperty("stockId")
    private String stockId;
    /**
     * 载具号
     */
    @JsonProperty("vehicleId")
    private String vehicleId;
    /**
     * 库位
     */
    @JsonProperty("locationId")
    private String locationId;
    /**
     * 库存状态
     */
    @JsonProperty("stockStatus")
    private Integer stockStatus;
    /**
     * 初次入库时间
     */
    @JsonProperty("firstInTime")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime firstInTime;
    /**
     * 初次入库用户
     */
    @JsonProperty("firstInUser")
    private String firstInUser;
    /**
     * 上次更新时间
     */
    @JsonProperty("lastUpdateTime")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime lastUpdateTime;
    /**
     * 上次更新用户
     */
    @JsonProperty("lastUpdateUser")
    private String lastUpdateUser;

    /**
     * 库存数据 Po->Vo
     * @param stockPo 库存Po
     * @return 库存Vo
     */
    public static StockVo ofPo(TAppStock stockPo) {
        return new StockVo(
                stockPo.getStockId(),
                stockPo.getVehicleId(),
                stockPo.getLocationId(),
                stockPo.getStockStatus(),
                stockPo.getFirstInTime(),
                stockPo.getFirstInUser(),
                stockPo.getLastUpdateTime(),
                stockPo.getLastUpdateUser()
        );
    }
}
