package com.zd.laboratory.domain.dto;

import cn.hutool.core.util.StrUtil;
import com.zd.common.core.domain.qc.QCInterface;
import com.zd.common.core.enums.HazardTypeEnum;
import com.zd.common.core.valid.ValidGroup;
import com.zd.common.core.web.domain.BaseEntity;
import com.zd.laboratory.domain.LabHazardSubjectRelation;
import com.zd.laboratory.interfaces.SysProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotNull;
import java.util.List;

@ApiModel(value = "危险源列表", description = "危险源和压力容器")
public class LabHazardDTO extends BaseEntity implements QCInterface {

    @ApiModelProperty(value = "危化品id")
    @NotNull(groups = ValidGroup.Crud.Update.class, message = "危化品ID不能为空")
    private Long hazardId;

    @ApiModelProperty(value = "压力容器id")
    private Long containerId;
    /**
     * 因为这一版删除了容器,所以这里必须是危险品
     */
    @NotNull(groups = ValidGroup.Crud.Update.class, message = "危险源类型不能为空")
    @ApiModelProperty(value = "危险源类型")
    private HazardTypeEnum hazardType;

    @ApiModelProperty(value = "关联实验室ID")
    private Long subjectId;

    /**
     * 1 危化品， 2 压力容器
     */
    @ApiModelProperty(value = "危险源类型")
    private Integer type;

    @ApiModelProperty(value = "危险源名称")
    private String name;

    @ApiModelProperty(value = "编号")
    private String code;

    @ApiModelProperty(value = "查看次数")
    private Integer scanCount = 0;
    /**
     * 实验室危险源占比为：所有分配了危险源的房间数/该危险源分配的房间数
     */
    @ApiModelProperty(value = "实验室危险源占比")
    private Integer labScale = 0;

    /**
     * 发生事故占比为：发生事故次数/该危险源涉及事故次数
     */
    @ApiModelProperty(value = "发生事故占比")
    private Integer faultScale = 0;

    /**
     * 关联预案占比为：总预案数/该危险源关联预案数
     */
    @ApiModelProperty(value = "关联预案占比")
    private Integer planScale = 0;

    /**
     * 二维码地址
     */
    @ApiModelProperty(value = "二维码地址")
    private String qrCodeUrl;

    public Long getSubjectId() {
        return subjectId;
    }

    public void setSubjectId(Long subjectId) {
        this.subjectId = subjectId;
    }

    /**
     * 危险源关联的实验室
     */
    List<LabHazardSubjectRelation> hazardSubjectList;

    public Long getHazardId() {
        return hazardId;
    }

    public void setHazardId(Long hazardId) {
        this.hazardId = hazardId;
    }

    public Long getContainerId() {
        return containerId;
    }

    public void setContainerId(Long containerId) {
        this.containerId = containerId;
    }


    public HazardTypeEnum getHazardType() {
        return hazardType;
    }

    public void setHazardType(HazardTypeEnum hazardType) {
        this.hazardType = hazardType;
    }

    public String getName() {
        return name;
    }

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

    public List<LabHazardSubjectRelation> getHazardSubjectList() {
        return hazardSubjectList;
    }

    public void setHazardSubjectList(List<LabHazardSubjectRelation> hazardSubjectList) {
        this.hazardSubjectList = hazardSubjectList;
    }

    public Integer getLabScale() {
        return labScale;
    }

    public void setLabScale(Integer labScale) {
        this.labScale = labScale;
    }

    public Integer getFaultScale() {
        return faultScale;
    }

    public void setFaultScale(Integer faultScale) {
        this.faultScale = faultScale;
    }

    public Integer getPlanScale() {
        return planScale;
    }

    public void setPlanScale(Integer planScale) {
        this.planScale = planScale;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Integer getScanCount() {
        return scanCount;
    }

    public void setScanCount(Integer scanCount) {
        this.scanCount = scanCount;
    }

    @Override
    public String getQrCodeUrl() {
        return StrUtil.format(SysProperties.getQrcodeFormat(),hazardId, 3) ;
    }
}
