Commit 3f23f994843652c8d6dd5970b727276b0ce497dd
1 parent
e58bdb3b
update...
Showing
4 changed files
with
32 additions
and
5 deletions
src/main/java/com/bsth/client/GpsBeforeBuffer.java
| @@ -43,6 +43,9 @@ public class GpsBeforeBuffer implements CommandLineRunner{ | @@ -43,6 +43,9 @@ public class GpsBeforeBuffer implements CommandLineRunner{ | ||
| 43 | int size = linkedList.size(); | 43 | int size = linkedList.size(); |
| 44 | for(int j = 0; j < size; j++){ | 44 | for(int j = 0; j < size; j++){ |
| 45 | gps = linkedList.poll(); | 45 | gps = linkedList.poll(); |
| 46 | + if(gps == null){ | ||
| 47 | + log.error("linkedList poll gps is null ???"); | ||
| 48 | + } | ||
| 46 | rs.add(gps); | 49 | rs.add(gps); |
| 47 | } | 50 | } |
| 48 | /*while (true){ | 51 | /*while (true){ |
src/main/java/com/bsth/client/pd/handler/PdClientHandler.java
| @@ -73,11 +73,11 @@ public class PdClientHandler extends IoHandlerAdapter{ | @@ -73,11 +73,11 @@ public class PdClientHandler extends IoHandlerAdapter{ | ||
| 73 | } | 73 | } |
| 74 | else if(0x41 == msg.getCommandType()){ | 74 | else if(0x41 == msg.getCommandType()){ |
| 75 | Pd_41_0 pd41 = (Pd_41_0)msg.getMessageBody(); | 75 | Pd_41_0 pd41 = (Pd_41_0)msg.getMessageBody(); |
| 76 | - gpsBeforeBuffer.put(new GpsEntity(pd41.getInfo(), msg.getVersion(), 1)); | 76 | + gpsBeforeBuffer.put(GpsEntity.getInstance(pd41.getInfo(), msg.getVersion(), 1)); |
| 77 | } | 77 | } |
| 78 | else if(0x42 == msg.getCommandType()){ | 78 | else if(0x42 == msg.getCommandType()){ |
| 79 | Pd_42_0 pd42 = (Pd_42_0)msg.getMessageBody(); | 79 | Pd_42_0 pd42 = (Pd_42_0)msg.getMessageBody(); |
| 80 | - gpsBeforeBuffer.put(new GpsEntity(pd42.getInfo(), msg.getVersion(), 1)); | 80 | + gpsBeforeBuffer.put(GpsEntity.getInstance(pd42.getInfo(), msg.getVersion(), 1)); |
| 81 | } | 81 | } |
| 82 | } | 82 | } |
| 83 | } | 83 | } |
src/main/java/com/bsth/client/pf/handler/PfClientHandler.java
| @@ -71,7 +71,7 @@ public class PfClientHandler extends IoHandlerAdapter{ | @@ -71,7 +71,7 @@ public class PfClientHandler extends IoHandlerAdapter{ | ||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | BasicInfo info = Protocol2BizUtil.getBasicInfoFromMsg(msg); | 73 | BasicInfo info = Protocol2BizUtil.getBasicInfoFromMsg(msg); |
| 74 | - gpsBeforeBuffer.put(new GpsEntity(info, msg.getVersion(), 0)); | 74 | + gpsBeforeBuffer.put(GpsEntity.getInstance(info, msg.getVersion(), 0)); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | } | 77 | } |
src/main/java/com/bsth/entity/GpsEntity.java
| @@ -74,7 +74,31 @@ public class GpsEntity { | @@ -74,7 +74,31 @@ public class GpsEntity { | ||
| 74 | */ | 74 | */ |
| 75 | private int source; | 75 | private int source; |
| 76 | 76 | ||
| 77 | - public GpsEntity(BasicInfo basicInfo, int version, int source) { | 77 | + public static GpsEntity getInstance(BasicInfo basicInfo, int version, int source){ |
| 78 | + //放弃补发数据 | ||
| 79 | + byte cacheData = getCacheState(basicInfo.getServiceState()); | ||
| 80 | + if(cacheData == 1) | ||
| 81 | + return null; | ||
| 82 | + | ||
| 83 | + GpsEntity gps = new GpsEntity(); | ||
| 84 | + | ||
| 85 | + gps.setDeviceId(basicInfo.getDeviceId()); | ||
| 86 | + gps.setTimestamp(basicInfo.getTimestamp()); | ||
| 87 | + gps.setLat(basicInfo.getLat()); | ||
| 88 | + gps.setLon(basicInfo.getLon()); | ||
| 89 | + gps.setDirection((float)basicInfo.getDirection() / 10); | ||
| 90 | + gps.setValid(basicInfo.getGpsValid()); | ||
| 91 | + gps.setCompanyCode(basicInfo.getCompanyCode()); | ||
| 92 | + gps.setUpDown(basicInfo.getUpOrDown()); | ||
| 93 | + gps.setSpeed((float)basicInfo.getSpeedGps() / 10); | ||
| 94 | + gps.setLineId(String.valueOf(basicInfo.getLineId())); | ||
| 95 | + gps.setState((int) getService(basicInfo.getServiceState())); | ||
| 96 | + gps.setVersion(version); | ||
| 97 | + gps.setSource(source); | ||
| 98 | + | ||
| 99 | + return gps; | ||
| 100 | + } | ||
| 101 | +/* public GpsEntity(BasicInfo basicInfo, int version, int source) { | ||
| 78 | //放弃补发数据 | 102 | //放弃补发数据 |
| 79 | byte cacheData = getCacheState(basicInfo.getServiceState()); | 103 | byte cacheData = getCacheState(basicInfo.getServiceState()); |
| 80 | if(cacheData == 1) | 104 | if(cacheData == 1) |
| @@ -93,7 +117,7 @@ public class GpsEntity { | @@ -93,7 +117,7 @@ public class GpsEntity { | ||
| 93 | this.setState((int) getService(basicInfo.getServiceState())); | 117 | this.setState((int) getService(basicInfo.getServiceState())); |
| 94 | this.setVersion(version); | 118 | this.setVersion(version); |
| 95 | this.setSource(source); | 119 | this.setSource(source); |
| 96 | - } | 120 | + }*/ |
| 97 | 121 | ||
| 98 | public static byte getCacheState(long serviceState) { | 122 | public static byte getCacheState(long serviceState) { |
| 99 | return (byte)(((serviceState & 0x00100000) == 0x00100000) ? 1 : 0); | 123 | return (byte)(((serviceState & 0x00100000) == 0x00100000) ? 1 : 0); |