package com.inspect.analysis.domain;

import com.alibaba.fastjson.JSONObject;
import com.inspect.analysis.constant.AnalyseConstants;
import com.inspect.base.core.utils.StringUtils;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;

public class AnalyseResPoint implements Serializable {
    private String type;
    private String Value;
    private String value;
    // 辅助值：如避雷器读数值
    private String value2;
    private String code;
    private String resImageUrl;
    private String imageNormalUrlPath;
    private String conf;
    private String desc;
    private List<Pos> pos;

//    public boolean checkSuccess() {
//        return "2000".equals(this.code) && "1".equals(this.value);
//    }
    /**
     * 根据电力57号协议规定：
     * code定义如下
     * 2000 - 正确
     * 2001 - 图像数据错误
     * 2002 - 算法分析失败
     * value定义如下
     * 0 - 无缺陷
     * 1 - 有缺陷
     * @return
     */
    public boolean isDefect() {
        return "2000".equals(this.code) && "1".equals(this.value);
    }

    public String toString() {
        return JSONObject.toJSONString(this);
    }

    public void setValue(String value) {
        this.value = value;
        if (!StringUtils.isEmpty(value)) {
            this.Value = value;
        }

    }

    public String toResultValue(String objectId) {
        return objectId + AnalyseConstants.ANALYSE_SPLIT + this.type;
    }

    public AnalyseResPoint clone() {
        return JSONObject.parseObject(JSONObject.toJSONString(this), AnalyseResPoint.class);
    }

    public String getType() {
        return this.type;
    }

    public String getValue() {
        return this.Value;
    }

    public String getCode() {
        return this.code;
    }

    public String getResImageUrl() {
        return this.resImageUrl;
    }

    public String getImageNormalUrlPath() {
        return this.imageNormalUrlPath;
    }

    public String getConf() {
        return this.conf;
    }

    public String getDesc() {
        return this.desc;
    }

    public List<Pos> getPos() {
        return this.pos;
    }

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

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

    public void setResImageUrl(String resImageUrl) {
        this.resImageUrl = resImageUrl;
    }

    public void setImageNormalUrlPath(String imageNormalUrlPath) {
        this.imageNormalUrlPath = imageNormalUrlPath;
    }

    public void setConf(String conf) {
        this.conf = conf;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public void setPos(List<Pos> pos) {
        this.pos = pos;
    }

    public String getValue2() {
        return this.value2;
    }

    public void setValue2(String value2) {
        this.value2 = value2;
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) return true;
        if (object == null || getClass() != object.getClass()) return false;
        AnalyseResPoint that = (AnalyseResPoint) object;
        return Objects.equals(type, that.type) && Objects.equals(Value, that.Value) && Objects.equals(value, that.value) && Objects.equals(code, that.code) && Objects.equals(resImageUrl, that.resImageUrl) && Objects.equals(imageNormalUrlPath, that.imageNormalUrlPath) && Objects.equals(conf, that.conf) && Objects.equals(desc, that.desc) && Objects.equals(pos, that.pos);
    }

    @Override
    public int hashCode() {
        return Objects.hash(type, Value, value, code, resImageUrl, imageNormalUrlPath, conf, desc, pos);
    }
}
