package kr.gmtc.tss.data.vo;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.sql.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;

public class AlarmVO implements Comparable<AlarmVO> {

	private boolean inserted=false;
	private String marineAreaId="";
	
	public long timeStamp = LocalDateTime.now().toInstant(ZoneOffset.ofHours(9)).toEpochMilli();
	
	public AlarmVO() {
	}

	protected LocalDateTime dateTime;
	
	@JsonProperty("anals_id")
	private String analsId;
	@JsonProperty("anals_dt")
	private String analsDt;
	@JsonProperty("anals_ty")
	private String analsTy;
	private Area area;
	private Target target1;
	private Target target2;
	@JsonProperty("anals_msg")
	private String analsMsg;
	
	@Override
    public String toString() {
        return "{" +
                "\"anals_id\":\"" + analsId + "\"" +
                ",\"anals_dt\":\"" + analsDt + "\"" +
                ",\"anals_ty\":\"" + analsTy + "\"" +
                ",\"area\":{" + area.toString() + "}" +
                ",\"target1\":" + target1.toString() + 
                ",\"target2\":" + target2.toString() + 
                ",\"anals_msg\":\"" + analsMsg + "\"" +               
                "}";
    }
	
	public String getAnalsId() {
		return analsId;
	}

	public void setAnalsId(String analsId) {
		this.analsId = analsId;
	}

	public String getAnalsDt() {
		return analsDt;
	}

	public void setAnalsDt(String analsDt) {
		this.analsDt = analsDt;
	}

	public String getAnalsTy() {
		return analsTy;
	}

	public void setAnalsTy(String analsTy) {
		this.analsTy = analsTy;
	}

	public Area getArea() {
		return area;
	}

	public void setArea(Area area) {
		this.area = area;
	}

	public Target getTarget1() {
		return target1;
	}

	public void setTarget1(Target target1) {
		this.target1 = target1;
	}

	public Target getTarget2() {
		return target2;
	}

	public void setTarget2(Target target2) {
		this.target2 = target2;
	}

	public String getAnalsMsg() {
		return analsMsg;
	}

	public void setAnalsMsg(String analsMsg) {
		this.analsMsg = analsMsg;
	}

	public boolean isInserted() {
		return inserted;
	}

	public void setInserted(boolean inserted) {
		this.inserted = inserted;
	}

	public String getMarineAreaId() {
		return marineAreaId;
	}

	public void setMarineAreaId(String marineAreaId) {
		this.marineAreaId = marineAreaId;
	}

	public long getTimeStamp() {
		return timeStamp;
	}

	public void setTimeStamp(long timeStamp) {
		this.timeStamp = timeStamp;
	}

	public LocalDateTime getDateTime() {
		return dateTime;
	}

	public void setDateTime(LocalDateTime dateTime) {
		this.dateTime = dateTime;
	}

	public static class Area {
        private String area_type;
        private String area_id;
        
		public String getArea_type() {
			return area_type;
		}
		public void setArea_type(String area_type) {
			this.area_type = area_type;
		}
		public String getArea_id() {
			return area_id;
		}
		public void setArea_id(String area_id) {
			this.area_id = area_id;
		}
		
		@Override
	    public String toString() {
			return "{" +
	                "\"area_type\":\"" + area_type + "\"" +
	                ",\"area_id\":\"" + area_id + "\"" +
                "}";
		}
		
		public String toDataFormat() {
			return area_type+"@"+area_id;
		}
    }
    
    public static class Target {
        private String trgt_ty;
        private String trgt_id;
        
		public String getTrgt_ty() {
			return trgt_ty;
		}
		public void setTrgt_ty(String trgt_ty) {
			this.trgt_ty = trgt_ty;
		}
		public String getTrgt_id() {
			return trgt_id;
		}
		public void setTrgt_id(String trgt_id) {
			this.trgt_id = trgt_id;
		}
		
		@Override
	    public String toString() {
			return "{" +
	                "\"trgt_ty\":\"" + trgt_ty + "\"" +
	                ",\"trgt_id\":\"" + trgt_id + "\"" +
                "}";
		}
		
		public String toDataFormat() {
			return trgt_ty+"@"+trgt_id;
		}
    }
	
	@Override
    public boolean equals(Object obj) {
        //p1.equals(p2)
        if(obj instanceof AlarmVO) {
        	AlarmVO p = (AlarmVO)obj;
            return this.hashCode()==p.hashCode(); 
            
        }
        return false;
    }

	@Override
	public int compareTo(AlarmVO o) {
		return 0;
	}
}
