package com.wms.entity.app.vo;

import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.wms.entity.table.Stock;
import com.wms.utils.excel.vo.StockExcelVo;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
public class StockVo {
    /**
     * 库存编号
     */
    @JsonProperty("stockId")
    private String stockId;
    /**
     * 库位ID
     */
    @JsonProperty("locationId")
    private String locationId;
    /**
     * 托盘号
     */
    @JsonProperty("vehicleId")
    private String vehicleId;
    /**
     * 重量
     */
    @JsonProperty("weight")
    private BigDecimal weight;
    /**
     * 库存状态
     * 正常、出库中、锁定 等
     */
    @JsonProperty("stockStatus")
    private Integer stockStatus;
    /**
     * 创建时间
     */
    @JsonProperty("createTime")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    /**
     * 最后更新时间
     */
    @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;
    /**
     * 是否盘点
     */
    @JsonProperty("isInventory")
    private Integer isInventory;
    /**
     * 盘点任务号   盘点出库和盘点入库同样
     */
    @JsonProperty("inventoryTaskId")
    private String inventoryTaskId;
    /**
     * 呆滞天数
     */
    @JsonProperty("noUseDays")
    private Integer noUseDays;
    /**
     * 物料编号
     */
    @JsonProperty("goodsId")
    private String goodsId;
    /**
     * 物料名称
     */
    @JsonProperty("goodsName")
    private String goodsName;
    /**
     * 物料状态
     */
    @JsonProperty("goodsStatus")
    private Integer goodsStatus;
    /**
     * 剩余数量
     */
    @JsonProperty("remainNum")
    private BigDecimal remainNum;
    /**
     * 入库库存总数
     */
    @JsonProperty("totalNum")
    private BigDecimal totalNum;

    /**
     * 从数据库实体转换为前端显示
     * @param stockPo 数据库实体
     * @return excel对象
     */
    public static StockVo of(Stock stockPo) {
        StockVo stockVo = new StockVo();
        stockVo.setStockId(stockPo.getStockId());
        stockVo.setLocationId(stockPo.getLocationId());
        stockVo.setVehicleId(stockPo.getVehicleId());
        stockVo.setWeight(stockPo.getWeight());
        stockVo.setStockStatus(stockPo.getStockStatus());
        stockVo.setCreateTime(stockPo.getCreateTime());
        stockVo.setLastUpdateTime(stockPo.getLastUpdateTime());
        stockVo.setLastUpdateUser(stockPo.getLastUpdateUser());
        stockVo.setIsInventory(stockPo.getIsInventory());
        stockVo.setInventoryTaskId(stockPo.getInventoryTaskId());
        stockVo.setNoUseDays(stockPo.getNoUseDays());
        stockVo.setGoodsId(stockPo.getGoodsRelated().getGoodsId());
        stockVo.setGoodsName(stockPo.getGoodsRelated().getGoodsName());
        stockVo.setGoodsStatus(stockPo.getGoodsRelated().getGoodsStatus());
        stockVo.setRemainNum(stockPo.getGoodsRelated().getRemainNum());
        stockVo.setTotalNum(stockPo.getGoodsRelated().getTotalNum());
        return stockVo;
    }
}
