GpsOfflineMonitorThread.java
949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.bsth.vehicle.gpsdata;
import java.util.Collection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.bsth.vehicle.gpsdata.buffer.GpsRealDataBuffer;
import com.bsth.vehicle.gpsdata.entity.GpsRealData;
/**
*
* @ClassName: GpsOfflineMonitorThread
* @Description: TODO(GPS 掉线监控)
* @author PanZhao
* @date 2016年7月29日 上午1:03:29
*
*/
@Component
public class GpsOfflineMonitorThread extends Thread{
Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public void run() {
long t = System.currentTimeMillis();
Collection<GpsRealData> allGps = GpsRealDataBuffer.allGps();
for(GpsRealData gps : allGps){
if(t - gps.getTimestamp()
> GpsRealDataBuffer.OFFLINE_TIME){
gps.setOnline(false);
logger.info("设备:" + gps.getDeviceId() + " 掉线");
}
}
}
}