package com.wms.utils.excel.vo;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.wms.entity.table.Stock;
import lombok.Data;

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

@Data
public class StockExcelVo {
    /**
     * 库存编号
     */
    @ExcelProperty("库存编号")
    private String stockId;
    /**
     * 库位ID
     */
    @ExcelProperty("库位")
    private String locationId;
    /**
     * 托盘号
     */
    @ExcelProperty("箱号")
    private String vehicleId;
    /**
     * 重量
     */
    @ExcelProperty("重量")
    private BigDecimal weight;
    /**
     * 库存状态
     * 正常、出库中、锁定 等
     */
    @ExcelProperty("库存状态")
    private Integer stockStatus;
    /**
     * 创建时间
     */
    @ExcelProperty("入库时间")
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    /**
     * 最后更新时间
     */
    @ExcelProperty("最近使用时间")
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    private LocalDateTime lastUpdateTime;
    /**
     * 最后更新用户
     */
    @ExcelProperty("最近更新用户")
    private String lastUpdateUser;
    /**
     * 是否盘点
     */
    @ExcelProperty("是否盘点")
    private Integer isInventory;
    /**
     * 盘点任务号   盘点出库和盘点入库同样
     */
    @ExcelProperty("盘点任务号")
    private String inventoryTaskId;
    /**
     * 呆滞天数
     */
    @ExcelProperty("未使用天数")
    private Integer noUseDays;
    /**
     * 物料编号
     */
    @ExcelProperty("料号")
    private String goodsId;
    /**
     * 物料名称
     */
    @ExcelProperty("物料描述")
    private String goodsName;
    /**
     * 物料状态
     */
    @ExcelProperty("物料状态")
    private Integer goodsStatus;
    /**
     * 剩余数量
     */
    @ExcelProperty("剩余数量")
    private BigDecimal remainNum;
    /**
     * 入库库存总数
     */
    @ExcelProperty("入库数量")
    private BigDecimal totalNum;

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