package com.inspect.metadata.patrolpointmnt.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.inspect.metadata.threshold.domain.BasedataThresholdModification;
import com.inspect.base.core.annotation.Excel;
import com.inspect.base.core.utils.StringUtils;
import com.inspect.base.core.web.domain.BaseEntity;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

@Setter
@Getter
@ToString
public class BasedataPatrolPoint extends BaseEntity {
    private static final long serialVersionUID = 1L;
    @JsonProperty("patrolpointId")
    private Long patrolPointId;
    @JsonProperty("patrolpointCode")
    @Excel(
            name = "点位编码"
    )
    private String patrolPointCode;
    @JsonProperty("patrolpointName")
    @Excel(
            name = "点位名称"
    )
    private String patrolPointName;
    private String patrolpointName;
    @Excel(
            name = "主设备类型ID"
    )
    @JsonProperty("devicetypeId")
    private Long deviceTypeId;
    @Excel(
            name = "主设备id"
    )
    private Long mainDeviceId;

    private Long relationMainDeviceId;
    @Excel(
            name = "设备id，真正配置点位的主设备id或者部件id"
    )
    private Long deviceId;

    private Long relationDeviceId;
    private String deviceName;
    @Excel(
            name = "巡检内容"
    )
    private String patrolContent;
    @Excel(
            name = "用途"
    )
    private String purpose;
    @Excel(
            name = "删除标志，0：正常；2：删除"
    )
    private String deleteFlag;
    @Excel(
            name = "标准巡检点位ID"
    )
    @JsonProperty("stdparolPointId")
    private Long stdParolPointId;
    private Long areaId;
    private String areaName;
    private Long relationAreaId;
    private String patrolTypeId;
    private String pointImptLevel;
    private String alarmThreshold;
    private String algSubtypeId;
    private String algSubtypeName;
    @Excel(
            name = "识别下限"
    )
    private String lowerValue;
    @Excel(
            name = "识别上限"
    )
    private String upperValue;
    private String positionX;
    private String positionY;
    private String positionZ;
    @Excel(
            name = "算法id，逗号隔开"
    )
    private String algSubtypeIds;
    @Excel(
            name = "上传原有算法id，逗号分割"
    )
    private String originalAlgSubtypeIds;
    @Excel(
            name = "上传原有生产设备编号"
    )
    private String originalDeviceId;
    @Excel(
            name = "判别基准图片路径"
    )
    private String disRefPicturePath;
    @Excel(
            name = "源上传主设备编号"
    )
    private String originalMainDeviceId;
    @Excel(
            name = "表计类型"
    )
    private String meterType;
    private List<BasedataThresholdModification> subTypeDOList;
    private BasedataThresholdModification subTypeDO;

    /**
     * 点位设备类型和点位设备编码
     */
    private String pointTypeName;
    private String pointTypeCode;

    private String parentName;

    List<Long> algTypeCodeList;

    private String allowedSubtypeIds;

    public void setPatrolpointName(String patrolpointName) {
        this.patrolpointName = patrolpointName;
        this.patrolPointName = patrolpointName;
    }

    public void setPatrolPointName(String patrolPointName) {
        this.patrolPointName = patrolPointName;
        this.patrolpointName = patrolPointName;
    }

    public Long getRelationMainDeviceId() {
        return relationMainDeviceId;
    }

    public void setRelationMainDeviceId(Long relationMainDeviceId) {
        this.relationMainDeviceId = relationMainDeviceId;
    }

    public Long getRelationDeviceId() {
        return relationDeviceId;
    }

    public void setRelationDeviceId(Long relationDeviceId) {
        this.relationDeviceId = relationDeviceId;
    }

    public Long getRelationAreaId() {
        return relationAreaId;
    }

    public void setRelationAreaId(Long relationAreaId) {
        this.relationAreaId = relationAreaId;
    }

    public String getPointTypeName() {
        return pointTypeName;
    }

    public void setPointTypeName(String pointTypeName) {
        this.pointTypeName = pointTypeName;
    }

    public void loadAlgSubtypeName1(Map<String, String> algSubtypeMap) {
        StringBuffer sb = new StringBuffer();
        if (!StringUtils.isEmpty(this.algSubtypeIds)) {
            String[] var3 = this.algSubtypeIds.split(",");
            int var4 = var3.length;

            for (int var5 = 0; var5 < var4; ++var5) {
                String str = var3[var5];
                sb.append((String) algSubtypeMap.get(str)).append(",");
            }

            this.algSubtypeName = sb.substring(0, sb.length() - 1);
        }

    }

    public void loadAlgSubtypeName(Map<String, String> algSubtypeMap) {
        if (!StringUtils.isEmpty(this.algSubtypeIds)) {
            String[] ids = this.algSubtypeIds.split(",");
            this.algSubtypeName = java.util.Arrays.stream(ids)
                    .map(algSubtypeMap::get)
                    .collect(Collectors.joining(","));
        }
    }
}
