package com.zd.laboratory.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zd.common.core.annotation.Excel;
import com.zd.common.core.domain.hazard.HardwareType;
import com.zd.common.core.enums.HardwareOperate;
import com.zd.common.core.enums.HardwareTypeEnum;
import com.zd.common.core.enums.SenseStateEnum;
import com.zd.common.core.enums.SenseType;
import com.zd.laboratory.domain.LabAbnormal;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.Date;

/**
 * Controller
 *
 * @author cyl
 * @date 2021/9/18
 */
@ApiModel("异常设备表")
public class LabAbnormalVO extends LabAbnormal implements HardwareType {

    @ApiModelProperty("实验室名称")
    @Excel(name = "实验室" ,sort = 4)
    private String subjectName;

    @ApiModelProperty("开始时间")
    private Date beginTime;

    @ApiModelProperty("结束时间")
    private Date endTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("最后异常时间")
    private Date lastAbnormalTime;

    @ApiModelProperty("设备类型，1是硬件设备，2是传感器")
    private Integer equipmentType;

    @ApiModelProperty("根据设备id统计异常信息数量")
    private Integer abnormalCount;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("初次异常时间")
    private Date startAbnormalTime;


    @ApiModelProperty("最近异常时间")
    @Excel(name = "最近异常时间",sort = 6)
    private String lastAbnormalTimeStr;

    @ApiModelProperty("类型名称字符串")
    @Excel(name = "类型",sort = 2)
    private String typeStr;

    @ApiModelProperty("异常设备ids")
    private String[] abnormalIds;

    @ApiModelProperty("设备状态")
    private Integer operate;

    @Excel(name = "状态",sort = 7)
    private String operateName;

    public String getSubjectName() {
        return subjectName;
    }

    public void setSubjectName(String subjectName) {
        this.subjectName = subjectName;
    }

    public Date getBeginTime() {
        return beginTime;
    }

    public void setBeginTime(Date beginTime) {
        this.beginTime = beginTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public Date getLastAbnormalTime() {
        return lastAbnormalTime;
    }

    public void setLastAbnormalTime(Date lastAbnormalTime) {
        this.lastAbnormalTime = lastAbnormalTime;
    }

    public Integer getEquipmentType() {
        return equipmentType;
    }

    public void setEquipmentType(Integer equipmentType) {
        this.equipmentType = equipmentType;
    }

    public Integer getAbnormalCount() {
        return abnormalCount;
    }

    public void setAbnormalCount(Integer abnormalCount) {
        this.abnormalCount = abnormalCount;
    }

    public Date getStartAbnormalTime() {
        return startAbnormalTime;
    }

    public void setStartAbnormalTime(Date startAbnormalTime) {
        this.startAbnormalTime = startAbnormalTime;
    }

    public String getLastAbnormalTimeStr() {
        return lastAbnormalTimeStr;
    }

    public void setLastAbnormalTimeStr(String lastAbnormalTimeStr) {
        this.lastAbnormalTimeStr = lastAbnormalTimeStr;
    }

    public String getTypeStr() {
        return typeStr;
    }

    public void setTypeStr(String typeStr) {
        this.typeStr = typeStr;
    }

    public String[] getAbnormalIds() {
        return abnormalIds;
    }

    public void setAbnormalIds(String[] abnormalIds) {
        this.abnormalIds = abnormalIds;
    }

    public Integer getOperate() {
        return operate;
    }

    public void setOperate(Integer operate) {
        this.operate = operate;
    }

    @Override
    public Integer getHardwareTypeCode() {
        return null;
    }

    @Override
    public String getHardwareTypeName() {
        //1是硬件设备，2是传感器
        if (this.getEquipmentType() != null && this.getEquipmentType().equals(1)) {
            if(this.getType()==null) return null;
            HardwareTypeEnum byCode = HardwareTypeEnum.getByCode(this.getType());
            return byCode.getName();
        } else if (this.getEquipmentType() != null && this.getEquipmentType().equals(2)) {
            if(this.getType()==null) return null;
            SenseType byCode = SenseType.getByCode(this.getType());
            return byCode.getName();
        }
        return null;
    }

    public String getHardwareOperateName() {
        //1是硬件设备，2是传感器
        if (this.getEquipmentType() != null && this.getEquipmentType().equals(1)) {
            if(this.getOperate()==null) return null;
            HardwareOperate byCode = HardwareOperate.getByCode(this.getOperate());
            this.operateName = byCode.getName();
            return byCode.getName();
        } else if (this.getEquipmentType() != null && this.getEquipmentType().equals(2)) {
            if(this.getOperate()==null) return null;
            SenseStateEnum byCode = SenseStateEnum.getByCode(this.getOperate());
            this.operateName = byCode.getName();
            return byCode.getName();
        }
        return null;
    }

    public String getOperateName() {
        return operateName;
    }
}
