package com.persagy.dmp.rwd.iot.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

/**
 * 查询实时数据Model类
 */
@Getter
@Setter
public class CurrentDataModel {

	/** 对象ID */
	private String objectId;
	/** 信息点 */
	private String infoCode;
	/** 信息点值 */
	private String infoValue;
	/** 分精度数据时间点 */
	private String time;
	/** iot数据 */
	private Object data;
	/** 错误信息 */
	private String error;

	@JsonIgnore
	private String[] infoValueArr;


	public CurrentDataModel() {
	}

	public CurrentDataModel(String objectId, String infoCode) {
		this.objectId = objectId;
		this.infoCode = infoCode;
	}

	public String getMeter() {
		if (this.infoValue == null) {
			return null;
		}
		if (this.infoValueArr == null) {
			this.infoValueArr = this.infoValue.split("-");
		}
		if (this.infoValueArr.length == 0) {
			return null;
		} else {
			return this.infoValueArr[0];
		}
	}

	public String getFunction() {
		if (this.infoValue == null) {
			return null;
		}
		if (this.infoValueArr == null) {
			this.infoValueArr = this.infoValue.split("-");
		}
		if (this.infoValueArr.length < 2) {
			return null;
		} else {
			return this.infoValueArr[1];
		}
	}
}
