package com.zd.laboratory.domain;

import com.zd.common.core.annotation.Excel;
import com.zd.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.Length;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 分级管控管理对象 lab_grade_manage
 *
 * @author liubo
 * @date 2022-02-10
 */
@ApiModel("分级管控管理")
public class LabGradeManage extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 主键id
     */
    @ApiModelProperty(value = "${comment}")
    private Long id;
    /**
     * 分级名称 = 分类名称+分级名称+序号 (变更为文本框输入)
     */
    @ApiModelProperty(value = "分级名称")
    private String name;
    @ApiModelProperty(value = "所属部门名称")
    private String deptName;
    /**
     * 安全分级ID
     */
    @Excel(name = "安全分级ID")
    @ApiModelProperty(value = "安全分级ID")
    private Long level;
    /**
     * 安全分级名称
     */
    @ApiModelProperty(value = "安全分级名称")
    private String levelName;
    /**
     * 安全分类ID
     */
    @Excel(name = "安全分类ID")
    @ApiModelProperty(value = "安全分类ID")
    private Long typeId;
    /**
     * 安全分类名称
     */
    @ApiModelProperty(value = "安全分类名称")
    private String typeName;
    /**
     * 实验室类型ID
     */
    @ApiModelProperty(value = "实验室类型ID")
    private Long moldId;
    /**
     * 实验室类型ID
     */
    @ApiModelProperty(value = "实验室类型名称")
    private String moldName;
    /**
     * 管控规则数
     */
    @ApiModelProperty(value = "管控规则数")
    private Integer ruleNum;
    /**
     * 状态 0 关，1 开
     */
    @ApiModelProperty(value = "状态 0 关，1 开")
    private Integer status;
    /**
     * 适配实验室数
     */
    @ApiModelProperty(value = "适配实验室数")
    private Integer subNum = 0;
    /**
     * 适配实验室多选逗号分隔
     */
    @Excel(name = "适配实验室多选逗号分隔")
    @Length(message = "适配实验室多选逗号分隔长度不能超过255")
    @ApiModelProperty(value = "适配实验室多选逗号分隔")
    private String subIds;

    private List<String> subs = new ArrayList<>();

    private List<LabGradeManageRule> ruleList;

    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setLevel(Long level) {
        this.level = level;
    }

    public Long getLevel() {
        return level;
    }

    public void setTypeId(Long typeId) {
        this.typeId = typeId;
    }

    public Long getTypeId() {
        return typeId;
    }

    public void setSubIds(String subIds) {
        this.subIds = subIds;
        if(StringUtils.isNotBlank(subIds)){
            this.subs = Arrays.asList(subIds.split(","));
        }
    }

    public List<String> getSubs() {
        return subs;
    }

    public void setSubs(List<String> subs) {
        this.subs = subs;
        if(CollectionUtils.isNotEmpty(subs)){
            this.subIds = StringUtils.join(subs, ",");
            this.subNum = subs.size();
        }
    }

    public Integer getRuleNum() {
        return ruleNum;
    }

    public void setRuleNum(Integer ruleNum) {
        this.ruleNum = ruleNum;
    }

    public Integer getSubNum() {
        return this.subs.size();
    }

    public void setSubNum(Integer subNum) {
        this.subNum = subNum;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<LabGradeManageRule> getRuleList() {
        return ruleList;
    }

    public void setRuleList(List<LabGradeManageRule> ruleList) {
        this.ruleList = ruleList;
    }

    @Override
    public String getDeptName() {
        return deptName;
    }

    @Override
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public String getLevelName() {
        return levelName;
    }

    public void setLevelName(String levelName) {
        this.levelName = levelName;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public Long getMoldId() {
        return moldId;
    }

    public void setMoldId(Long moldId) {
        this.moldId = moldId;
    }

    public String getMoldName() {
        return moldName;
    }

    public void setMoldName(String moldName) {
        this.moldName = moldName;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }
}
