@Override
publicDeviceLocationanalysis(Stringtopic,Map<String,Object>
payloadMap){
//读取规则
GPSEntitygpsEntity=getGps();
if(gpsEntity==null)returnnull;
if(Strings.isNullOrEmpty(gpsEntity.getSubject()))returnnull;//主题
为空
if(!topic.equals(gpsEntity.getSubject()))returnnull;//如果主题不匹配
//读取设备id
StringdeviceId="";
deviceId=(String)payloadMap.get(gpsEntity.getSnKey());
if(Strings.isNullOrEmpty(deviceId))returnnull;
//提取gps
Stringlocation="";
if(gpsEntity.getSingleField()){//如果是单字段
location=((String)
payloadMap.get(gpsEntity.getValueKey())).replace(gpsEntity.getSeparation(
),",");
}else{//如果是双字段
location=payloadMap.get(gpsEntity.getLongitude())+","+
payloadMap.get(gpsEntity.getLatitude());
}
//封装返回结果
if(location!=null){
DeviceLocationdeviceLocation=newDeviceLocation();
deviceLocation.setDeviceId(deviceId);
deviceLocation.setLocation(location);
returndeviceLocation;
}else{
returnnull;
}
}