Commit c0b2aad0d699ec4d743c1581cdef2efffb3e71f6

Authored by 潘钊
1 parent bad0b9cb

update...

src/main/java/com/bsth/entity/GpsEntity.java
@@ -79,9 +79,11 @@ public class GpsEntity { @@ -79,9 +79,11 @@ public class GpsEntity {
79 private Long serverTimestamp; 79 private Long serverTimestamp;
80 80
81 public static GpsEntity getInstance(BasicInfo basicInfo, int version, int source){ 81 public static GpsEntity getInstance(BasicInfo basicInfo, int version, int source){
82 - //放弃补发数据 82 + if(StringUtils.isBlank(basicInfo.getDeviceId()))
  83 + return null;
  84 + //接受 5 分钟内的补传数据
83 byte cacheData = getCacheState(basicInfo.getServiceState()); 85 byte cacheData = getCacheState(basicInfo.getServiceState());
84 - if(cacheData == 1 || StringUtils.isBlank(basicInfo.getDeviceId())) 86 + if(cacheData == 1 && Math.abs(basicInfo.getTimestamp() - System.currentTimeMillis()) > 1000 * 60 * 5)
85 return null; 87 return null;
86 88
87 GpsEntity gps = new GpsEntity(); 89 GpsEntity gps = new GpsEntity();
@@ -102,26 +104,6 @@ public class GpsEntity { @@ -102,26 +104,6 @@ public class GpsEntity {
102 gps.setServerTimestamp(System.currentTimeMillis()); 104 gps.setServerTimestamp(System.currentTimeMillis());
103 return gps; 105 return gps;
104 } 106 }
105 -/* public GpsEntity(BasicInfo basicInfo, int version, int source) {  
106 - //放弃补发数据  
107 - byte cacheData = getCacheState(basicInfo.getServiceState());  
108 - if(cacheData == 1)  
109 - return;  
110 -  
111 - this.setDeviceId(basicInfo.getDeviceId());  
112 - this.setTimestamp(basicInfo.getTimestamp());  
113 - this.setLat(basicInfo.getLat());  
114 - this.setLon(basicInfo.getLon());  
115 - this.setDirection((float)basicInfo.getDirection() / 10);  
116 - this.setValid(basicInfo.getGpsValid());  
117 - this.setCompanyCode(basicInfo.getCompanyCode());  
118 - this.setUpDown(basicInfo.getUpOrDown());  
119 - this.setSpeed((float)basicInfo.getSpeedGps() / 10);  
120 - this.setLineId(String.valueOf(basicInfo.getLineId()));  
121 - this.setState((int) getService(basicInfo.getServiceState()));  
122 - this.setVersion(version);  
123 - this.setSource(source);  
124 - }*/  
125 107
126 public static byte getCacheState(long serviceState) { 108 public static byte getCacheState(long serviceState) {
127 return (byte)(((serviceState & 0x00100000) == 0x00100000) ? 1 : 0); 109 return (byte)(((serviceState & 0x00100000) == 0x00100000) ? 1 : 0);