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 | 43 | int size = linkedList.size(); |
| 44 | 44 | for(int j = 0; j < size; j++){ |
| 45 | 45 | gps = linkedList.poll(); |
| 46 | + if(gps == null){ | |
| 47 | + log.error("linkedList poll gps is null ???"); | |
| 48 | + } | |
| 46 | 49 | rs.add(gps); |
| 47 | 50 | } |
| 48 | 51 | /*while (true){ | ... | ... |
src/main/java/com/bsth/client/pd/handler/PdClientHandler.java
| ... | ... | @@ -73,11 +73,11 @@ public class PdClientHandler extends IoHandlerAdapter{ |
| 73 | 73 | } |
| 74 | 74 | else if(0x41 == msg.getCommandType()){ |
| 75 | 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 | 78 | else if(0x42 == msg.getCommandType()){ |
| 79 | 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 | 71 | } |
| 72 | 72 | |
| 73 | 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 | 74 | */ |
| 75 | 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 | 103 | byte cacheData = getCacheState(basicInfo.getServiceState()); |
| 80 | 104 | if(cacheData == 1) |
| ... | ... | @@ -93,7 +117,7 @@ public class GpsEntity { |
| 93 | 117 | this.setState((int) getService(basicInfo.getServiceState())); |
| 94 | 118 | this.setVersion(version); |
| 95 | 119 | this.setSource(source); |
| 96 | - } | |
| 120 | + }*/ | |
| 97 | 121 | |
| 98 | 122 | public static byte getCacheState(long serviceState) { |
| 99 | 123 | return (byte)(((serviceState & 0x00100000) == 0x00100000) ? 1 : 0); | ... | ... |