package com.qiyou.mb.android.beans.basic;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;


public class BStatistics {
	public static String TAG ="com.qiyou.beans.Statistics";
    public static String dTAG ="com.qiyou";
    protected long firstTime=0; 
   	protected long lastTime=0; 
   	protected int cnt;
   	protected int userId;
   	protected float sumBurn =0.0f;   //累积消耗卡路里
   	protected float sumeUpDist =0.0f;   //累积上升
   	protected float sumeDownDist =0.0f; //累积下降
   	protected float sumTopSpeed =0.0f;  
   	protected float sumDist =0.0f; 
   	protected long sumPause=0  ;	 
   	protected long sumSportTime =0;
   	protected long sumOffTime =0; //no gps time 
   	protected long sumTotalTime=0 ;
   	protected float sumUpDist=0.0f;
   	protected float maxEle=0.0f;
   	protected float minEle=0.0f;
   	protected long lastGeo=0;
   	protected int lastTrackId=0;
   	protected float sumDownDist=0.0f; 
   	protected HashMap<String,ArrayList<Integer>> categoryList;
   	protected HashMap<Integer,GPItem> gpList; 
   	protected TypeStatistics lastStrack;
   	protected ConcurrentHashMap<Integer,TypeStatistics> statisticsTracks;
   	protected List<CItem > typeUsedLst;
   	protected List<Integer> existedSvrNos;
   	
	public float getSumUpDist() {
		return sumUpDist;
	}

	 
	public float getSumDownDist() {
		return sumDownDist;
	}
  
	

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId  = userId;
	}

	
	public float getSumCost() {
		return sumBurn;
	}

	public void setSumCost(float sumBurn) {
		this.sumBurn += sumBurn;
	}

	public float getSumeUpDist() {
		return sumeUpDist;
	}

	/*public void setSumUpDist(float sumUpDist) {
		this.sumeUpDist += sumUpDist;
	}*/

	public float getSumeDownDist() {
		return sumeDownDist;
	}

	public void setSumDownDist(float sumeDownDist) {
		this.sumeDownDist += sumeDownDist;
	}

	public float getSumTopSpeed() {
		return sumTopSpeed;
	}

	public void setSumTopSpeed(float sumTopSpeed) {
		this.sumTopSpeed += sumTopSpeed;
	}

	public long getSumPause() {
		return sumPause;
	}

	public void setSumPause(long sumPause) {
		this.sumPause += sumPause;
	}

	public long getSumSportTime() {
		return sumSportTime;
	}

	public void setSumSportTime(long sumSportTime) {
		this.sumSportTime += sumSportTime;
	}

	public long getSumOffTime() {
		return sumOffTime;
	}

	public void setSumOffTime(long sumOffTime) {
		this.sumOffTime += sumOffTime;
	}

	public long getSumTotalTime() {
		return sumTotalTime;
	}

	public void setSumTotalTime(long sumTotalTime) {
		this.sumTotalTime += sumTotalTime;
	}

//	private SparseArray<TypeStatistics> StatisticsTracks;
 
 
	public List<CItem > getTypeUsedLst() {
		if(typeUsedLst==null)typeUsedLst =new  ArrayList<CItem >();
		return typeUsedLst;
	}

	public void setTypeUsedLst(List<CItem > typeUsedLst) {
		this.typeUsedLst = typeUsedLst;
	}

	public long getLastTime() {
		return lastTime;
	}

	public void setLastTime(long lTime) { 
		lastTime = lastTime<lTime?lTime:lastTime;
	}

	public long getFirstTime() {
		return firstTime;
	}

	public void setFirstTime(long stime) {
		 firstTime =firstTime==0?stime:( firstTime>stime?stime:firstTime);
	}

	public ConcurrentHashMap<Integer,TypeStatistics> getStatisticsTracks() {
		if(  statisticsTracks==null) statisticsTracks =new ConcurrentHashMap<Integer,TypeStatistics>();
		return statisticsTracks;
	}

	public void setStatisticsTracks(ConcurrentHashMap<Integer,TypeStatistics> _statisticsTracks) {
		statisticsTracks = _statisticsTracks;
	}

	public int getCnt() {
		return cnt;
	}

	public void setCnt(int cnt) {
		this.cnt = cnt;
	} 
 
	public void setMaxAvStat(StatTrack maxAvTrack){
		if(maxAvTrack==null)return;
		
		TypeStatistics stt= getStatisticsTracks().get(Integer.valueOf(maxAvTrack.getType()));
		StatTrack st;
		if(stt!=null &&stt.getStatTrack()!=null){
			st =stt.getStatTrack();
			  sumBurn -=st.getSumBurn();   //累积消耗卡路里
			  sumeUpDist -=st.getSumEup();   //累积上升
			  sumeDownDist -=st.getSumEdown(); //累积下降 
			  sumPause -=  st.getSumPause();	 
			  sumSportTime -=st.getSumSportTime();
			  sumOffTime -=st.getSumOff(); //no gps time 
			  sumTotalTime -=st.getSumTotalTime() ;
			  sumDist -=st.getSumDist();  
			  sumUpDist-=st.getSumUpDist();
			  sumDownDist-=st.getSumDownDist();
//			  cnt--;
		}
		
		  sumBurn +=maxAvTrack.getSumBurn();   //累积消耗卡路里
		  sumeUpDist +=maxAvTrack.getSumEup();   //累积上升
		  sumeDownDist +=maxAvTrack.getSumEdown(); //累积下降 
		  sumPause +=  maxAvTrack.getSumPause();	 
		  sumSportTime +=maxAvTrack.getSumSportTime();
		  sumOffTime +=maxAvTrack.getSumOff(); //no gps time 
		  sumTotalTime +=maxAvTrack.getSumTotalTime() ;
		  sumDist +=maxAvTrack.getSumDist();
		  sumUpDist +=maxAvTrack.getSumUpDist() ;
		  sumDownDist +=maxAvTrack.getSumDownDist();
//		  cnt++;
	}

	public float getSumDist() {
		return sumDist;
	}

	public void setSumDist(float sumDist) {
		this.sumDist = sumDist;
	}
	
	 

public TypeStatistics getLastStrack() {
	if(lastStrack==null)lastStrack= new TypeStatistics();
	return lastStrack;
}

public void setLastStrack(TypeStatistics lastStrack) {
	this.lastStrack = lastStrack;
}

public HashMap<String,ArrayList<Integer>> getCategoryList() {
	if(categoryList==null)categoryList= new HashMap<String,ArrayList<Integer>> ();
	return categoryList;
}
public void setCategoryList(HashMap<String,ArrayList<Integer>> categoryList) {
	this.categoryList = categoryList;
}
 
public HashMap<Integer,GPItem> getGpList() {
	if(gpList==null)gpList=new HashMap<Integer,GPItem>();
	return gpList;
}
 

public void setGpList(HashMap<Integer,GPItem> gpList) {
	this.gpList = gpList;
}

//	ArrayList<Integer> mergedTracks =new ArrayList<Integer>(); 
//	HashMap<Integer,Track_bean> mergedTracks =new HashMap<Integer,Track_bean>();
 	
/*
 * km/h
 */
 public float getAVS(){
	 return getSumSportTime()>0? 3600*getSumDist()/ getSumSportTime():0; 
 }

public List<Integer> getExistedSvrNos() {
	if(existedSvrNos==null)existedSvrNos =new  ArrayList<Integer>();
	return existedSvrNos;
}

public void setExistedSvrNos(List<Integer> existedSvrNos) {
	this.existedSvrNos = existedSvrNos;
}

public float getMaxEle() {
	return maxEle;
}

public void setMaxEle(float maxEle) {
	this.maxEle = maxEle;
}

public float getMinEle() {
	return minEle;
}

public void setMinEle(float minEle) {
	this.minEle = minEle;
}

public long getLastGeo() {
	return lastGeo;
}

public void setLastGeo(long lastGeo) {
	this.lastGeo = lastGeo;
}

public int getLastTrackId() {
	return lastTrackId;
}

public void setLastTrackId(int lastTrackId) {
	this.lastTrackId = lastTrackId>this.lastTrackId?lastTrackId:this.lastTrackId;
}
 
}
