/*
 * Copyright ©2023 CJB-CNIT Team. All rights reserved
 */
package com.openhis.web.materialmanage.dto;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.openhis.common.annotation.Dict;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * 单据详细信息
 *
 * @author  yuxj
 * @date 2025-07-22
 */
@Data
@Accessors(chain = true)
public class MaterialDetailDto implements Serializable {

    /** ID */
    @TableId(type = IdType.ASSIGN_ID)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /** 单据号 */
    private String busNo;

    /** 再生成单据号 */
    private String originalBusNo;

    /** 药品编码 */
    private String itemBusNo;

    /** 物品id */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long itemId;

    /** 物品名称 */
    private String itemName;

    /** 规格 */
    private String totalVolume;

    /** 选择单位 */
    @Dict(dictCode = "unit_code")
    private String unitCode;
    private String unitCode_dictText;

    /** 常规单位 */
    @Dict(dictCode = "unit_code")
    private String maxUnitCode;
    private String maxUnitCode_dictText;

    /** 最小单位 */
    @Dict(dictCode = "unit_code")
    private String minUnitCode;
    private String minUnitCode_dictText;

    /** 拆零比 */
    private String partPercent;

    /** 数量 */
    private BigDecimal itemQuantity;

    /** 合计数量 */
    private BigDecimal totalQuantity;

    /** 单价 */
    private BigDecimal price;

    /** 总价 */
    private BigDecimal totalPrice;

    /** 零售价 */
    private BigDecimal retailPrice;

    /** 零价金额 */
    private BigDecimal totalRetailPrice;

    /** 厂家/产地 */
    private String manufacturerText;

    /** 批准文号 */
    private String approvalNumber;

    /** 批次库存 */
    private BigDecimal batchInventory;
    /** 规格库存 */
    private BigDecimal specificationInventory;

    /** 备注 */
    private String remake;

    /** 理由类型 */
    private String  reasonCode;

    /** 摘要（理由） */
    private String  reason;

    /** 供应商 */
    @JsonSerialize(using = ToStringSerializer.class)
    @Dict(dictCode = "id", dictText = "name", dictTable = "adm_supplier")
    private Long supplierId;
    private String supplierId_dictText;

    /** 源仓库类型 */
    private Integer sourceTypeEnum;
    /** 源仓库 */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long sourceLocationId;

    /** 目的仓库类型 */
    private Integer purposeTypeEnum;
    /** 目的仓库 */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long purposeLocationId;

    /** 采购员 */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long applicantId;

    /** 审批人 */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long approverId;
    /** 审批时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date approvalTime;

    /** 申请时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date applyTime;

    /** 状态 */
    private Integer statusEnum;
    private String statusEnum_enumText;

    /** 类型 */
    private Integer typeEnum;
    private String typeEnum_enumText;

    /** 单据分类 */
    private Integer categoryEnum;
    private String categoryEnum_enumText;

    /** 供应商联系人 */
    private String phone;

    /** 仓库员 */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long  practitionerId;

    /** 发票号 */
    private String invoiceNo;

    /** 产品批号 */
    private String lotNumber;

    /** 生产日期 */
    private Date startTime;

    /** 失效日期 */
    private Date endTime;

    /** 追溯码*/
    private String traceNo;

    /** 追溯码单位 */
    @Dict(dictCode = "unit_code")
    private String traceNoUnitCode;
    private String traceNoUnitCode_dictText;

    /** 包装情况 */
    private Integer packagingConditionEnum;
    private String packagingConditionEnum_enumText;

    /** 验收结果 */
    private Integer acceptanceResultEnum;
    private String acceptanceResultEnum_enumText;

    /** 禁用日期 */
    private Date occurrenceTime;

    /**
     * 单位列表
     */
    private List<Option> unitList;

    @Data
    public static class Option {
        @Dict(dictCode = "unit_code")
        private String value;
        private String value_dictText;
        public Option(String value, String value_dictText) {
            this.value = value;
            this.value_dictText = value_dictText;
        }
        public Option() {
        }
    }

}
