package com.bonus.material.repair.domain.vo;

import com.bonus.common.biz.domain.BmFileInfo;
import com.bonus.material.repair.domain.RepairPartDetails;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @author : 阮世耀
 * @version : 1.0
 * @CreateTime: 2024-11-15  14:35
 * @Description: 维修设备VO
 */
@Data
@Accessors(chain = true)
public class RepairDeviceVO {

    @ApiModelProperty(value = "主键")
    private Long id;

    @ApiModelProperty(value = "任务ID")
    private Long taskId;

    @ApiModelProperty(value = "任务ID")
    private Long newTaskId;

    @ApiModelProperty(value = "设备表主键id")
    private Long maId;

    @ApiModelProperty(value = "设备类型")
    private String typeName;

    @ApiModelProperty(value = "规格型号")
    private String type;

    @ApiModelProperty(value = "规格型号ID")
    private Long typeId;

    @ApiModelProperty(value = "设备编码")
    private String code;

    @ApiModelProperty(value = "设备单位")
    private String unitName;

    @ApiModelProperty(value = "管理模式")
    private Integer manageType;

    @ApiModelProperty(value = "状态")
    private String status;

    /** 退料ID */
    @ApiModelProperty(value = "退料ID")
    private Long backId;

    @ApiModelProperty(value = "退料编码")
    private String backCode;

    @ApiModelProperty(value = "维修配件信息")
    private String partInfo;

    @ApiModelProperty(value = "维修方式: 1内部 2外部返厂 3报废")
    private Integer repairType;

    @ApiModelProperty(value = "维修人员")
    private String repairer;

    @ApiModelProperty(value = "附件")
    private String fileUrl;

    @ApiModelProperty(value = "维修数量")
    private BigDecimal repairNum;

    @ApiModelProperty(value = "维修合格数量")
    private BigDecimal repairedNum;

    @ApiModelProperty(value = "维修报废数量")
    private BigDecimal scrapNum;

    @ApiModelProperty(value = "维修费用记录条数")
    private Integer totalCostRecords;

    @ApiModelProperty(value = "待修数量")
    private BigDecimal waitRepairNum;

    @ApiModelProperty(value = "维修费用小计计")
    private BigDecimal totalCost;

    @ApiModelProperty(value = "数量--维修人员信息集合")
    private List<RepairPartDetails> repairList;

    private String remark;

    @ApiModelProperty(value = "编码--内部维修配件集合")
    private List<RepairPartDetails> codeInRepairPartList;

    @ApiModelProperty(value = "编码--返厂维修配件集合")
    private List<RepairPartDetails> codeOutRepairPartList;

    @ApiModelProperty(value = "编码--报废维修配件集合")
    private List<RepairPartDetails> codeScrapRepairPartList;

    @ApiModelProperty(value = "数量--内部维修配件集合")
    private List<RepairPartDetails> numberInRepairPartList;

    @ApiModelProperty(value = "数量--返厂维修配件集合")
    private List<RepairPartDetails> numberOutRepairPartList;

    @ApiModelProperty(value = "数量--报废维修配件集合")
    private List<RepairPartDetails> numberScrapRepairPartList;

    @ApiModelProperty(value = "报废附件")
    private List<BmFileInfo> fileList;

    @ApiModelProperty(value = "内部维修附件")
    private List<RepairFileInfo> inRepairList;

    @ApiModelProperty(value = "外部维修附件")
    private List<RepairFileInfo> outRepairList;

    private String createBy;

    @ApiModelProperty(value = "维修拆分层级")
    private String level;

    @ApiModelProperty(value = "维修拆分父级id")
    private Long parentId;

    @ApiModelProperty(value = "一级类型id")
    private Long firstId;

    private String unitValue;

    /**
     * 数据状态  0-未定损，1-已定损  3-修饰后入库驳回
     */
    private String dataStatus;

    /**
     * 原用于计算状态为1的数量
     * 后续值未使用
     */
    private BigDecimal completeNum;

    // 手动覆盖 getter 方法，确保 List 始终被初始化
    public List<RepairPartDetails> getCodeInRepairPartList() {
        if (this.codeInRepairPartList == null) {this.codeInRepairPartList = new ArrayList<>();}
        return this.codeInRepairPartList;
    }

    public List<RepairPartDetails> getCodeOutRepairPartList() {
        if (this.codeOutRepairPartList == null) {this.codeOutRepairPartList = new ArrayList<>();}
        return this.codeOutRepairPartList;
    }

    public List<RepairPartDetails> getCodeScrapRepairPartList() {
        if (this.codeScrapRepairPartList == null) {this.codeScrapRepairPartList = new ArrayList<>();}
        return this.codeScrapRepairPartList;
    }

    public List<RepairPartDetails> getNumberInRepairPartList() {
        if (this.numberInRepairPartList == null) {this.numberInRepairPartList = new ArrayList<>();}
        return this.numberInRepairPartList;
    }

    public List<RepairPartDetails> getNumberOutRepairPartList() {
        if (this.numberOutRepairPartList == null) {this.numberOutRepairPartList = new ArrayList<>();}
        return this.numberOutRepairPartList;
    }

    public List<RepairPartDetails> getNumberScrapRepairPartList() {
        if (this.numberScrapRepairPartList == null) {this.numberScrapRepairPartList = new ArrayList<>();}
        return this.numberScrapRepairPartList;
    }

    // 自定义 clear 方法
    public void clear() {
        this.id = null;
        this.taskId = null;
        this.typeName = null;
        this.type = null;
        this.code = null;
        this.status = null;
        this.partInfo = null;
        this.repairType = null;
        this.fileUrl = null;
        this.codeInRepairPartList.clear();
        this.codeOutRepairPartList.clear();
        this.codeScrapRepairPartList.clear();
        this.numberInRepairPartList.clear();
        this.numberOutRepairPartList.clear();
        this.numberScrapRepairPartList.clear();
    }
}
