package com.ruoyi.inventory.domain;

import cn.hutool.json.JSONUtil;
import com.ruoyi.asset.domain.TbAssetInformation;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

/**
 * 资产盘点明细对象 tb_inventory_detail
 * 
 * @author ydl
 * @date 2023-06-01
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class TbInventoryDetail extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 编号 */
    private Long id;

    /** 单据编号 */
    @Excel(name = "单据编号")
    private String orderNumber;

    /** 盘点元数据 */
    @Excel(name = "盘点元数据")
    private String inventoryMetadata;

    /** 盘点状态 -1:异常 0:未盘点 1:已盘点 */
    @Excel(name = "盘点状态 -1:异常 0:未盘点 1:已盘点")
    private Integer inventoryStatus;

    /** 盘点结果 */
    @Excel(name = "盘点结果 -1:盘亏 0:正常 1:盘盈")
    private Integer inventoryResult;

    /** 盘点数量 */
    @Excel(name = "盘点数量")
    private Integer inventoryQuantity;

    /**
     * 未盘点详细
     * @param orderNumber
     * @param assetInformation
     * @return
     */
    public static TbInventoryDetail uncounted(String orderNumber, TbAssetInformation assetInformation) {
        return new TbInventoryDetail(null, orderNumber, JSONUtil.toJsonStr(assetInformation), 0, null, null);
    }

    /**
     * 已盘点详细
     * @param orderNumber
     * @param assetInformation
     * @return
     */
    public static TbInventoryDetail counted(String orderNumber, TbAssetInformation assetInformation) {
        return new TbInventoryDetail(null, orderNumber, JSONUtil.toJsonStr(assetInformation), 1, null, null);
    }

    /**
     * 异常盘点详细
     * @param orderNumber
     * @param assetInformation
     * @return
     */
    public static TbInventoryDetail errCounted(String orderNumber, TbAssetInformation assetInformation) {
        return new TbInventoryDetail(null, orderNumber, JSONUtil.toJsonStr(assetInformation), -1, null, null);
    }
}
