|
|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.zd.airbottle.api.feign.RemoteAirBottleService;
|
|
|
import com.zd.common.core.redis.RedisService;
|
|
|
import com.zd.common.core.utils.SpringUtils;
|
|
|
+import com.zd.common.core.utils.UUID;
|
|
|
import com.zd.laboratory.api.dto.WarningNoticeLogDto;
|
|
|
import com.zd.laboratory.api.feign.RemoteLaboratoryService;
|
|
|
import com.zd.laboratory.mqtt.service.impl.SubMessageSendManager;
|
|
|
@@ -14,10 +15,7 @@ import com.zd.model.domain.ResultData;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
@@ -39,8 +37,9 @@ public class BeaconMateImpl implements BeaconMate {
|
|
|
private RemoteLaboratoryService remoteLaboratoryService = SpringUtils.getBean(RemoteLaboratoryService.class);
|
|
|
|
|
|
public void sendBeaconMate(String dataStr){
|
|
|
+ String uuid = UUID.fastUUID().toString();
|
|
|
try{
|
|
|
- log.info("1=====================================》上报蓝牙网关编码:"+dataStr);
|
|
|
+ log.info("{} 1=====================================》上报蓝牙网关编码:"+dataStr,uuid);
|
|
|
JSONObject jsonObject=JSONObject.parseObject(dataStr);
|
|
|
String mac = jsonObject.getString("mac");
|
|
|
if(mac!=null && !"".equals(mac)){
|
|
|
@@ -54,19 +53,19 @@ public class BeaconMateImpl implements BeaconMate {
|
|
|
|
|
|
ResultData<Map<String,Object>> resultData = remoteAirBottleService.getSubByMac(mac);
|
|
|
if(resultData.getCode()==200 && resultData.getData() != null){
|
|
|
- // redis存储蓝牙网关mac地址,用于在线离线问题。
|
|
|
- redisService.setCacheObject(BaseConstants.BEACON_MAC+"~"+ mac,mac, 60L, TimeUnit.SECONDS);
|
|
|
- log.info("2=====================================》获取实验室id:"+resultData.getData().get("subId"));
|
|
|
+ // redis存储蓝牙网关mac地址,用于在线离线问题。 更新蓝牙网关缓存过期时间为15分钟
|
|
|
+ redisService.setCacheObject(BaseConstants.BEACON_MAC+"~"+ mac,mac, 15L, TimeUnit.MINUTES);
|
|
|
+ log.info("{} 2=====================================》获取实验室id:"+resultData.getData().get("subId"),uuid);
|
|
|
Long subId = Long.parseLong(resultData.getData().get("subId")+"");
|
|
|
List <Map<String,Object>> beaconList = redisService.getCacheObject(BaseConstants.BEACON_MATE_INFO+"~"+subId);
|
|
|
if(beaconList==null || initFlag){
|
|
|
- log.info("2.1=====================================》初始化实验室信标列表和实验室下的所有信标生命周期");
|
|
|
+ log.info("{} 2.1=====================================》 {} 初始化实验室信标列表和实验室下的所有信标生命周期",uuid,subId);
|
|
|
// 根据实验室id获取蓝牙信标列表
|
|
|
remoteAirBottleService.setBeaconBySubId(subId);
|
|
|
}
|
|
|
|
|
|
if(beaconList!=null){
|
|
|
- log.info("3=====================================》上报信标列表:"+jsonObject.getJSONArray("devices"));
|
|
|
+ log.info("{} 3=====================================》 {} 上报信标列表:"+jsonObject.getJSONArray("devices"),uuid,subId);
|
|
|
JSONArray array = jsonObject.getJSONArray("devices");
|
|
|
|
|
|
// 这里需要查看信标通知列表,移除通知列表对应的信标气瓶数据
|
|
|
@@ -76,33 +75,38 @@ public class BeaconMateImpl implements BeaconMate {
|
|
|
newNoticeList.addAll(beaconNoticeList);
|
|
|
}
|
|
|
StringBuilder beaconTagBuild = new StringBuilder();
|
|
|
- // 循环检查实验室的信标比对上报的信标,将配对好的信标重新设置默认时间
|
|
|
- for(int x=0;x<beaconList.size();x++){
|
|
|
- if(array.size()>0){
|
|
|
- // 这里需要比对redis存储的蓝牙信息列表和上报的列表信息 稍后补全这块
|
|
|
- for(int i=0;i<array.size();i++){
|
|
|
- String beaconStr = array.getString(i);
|
|
|
- //初步过滤只有b5的数据
|
|
|
- if(beaconStr.endsWith("b5")){
|
|
|
- // 这里需要处理信标字符串
|
|
|
- beaconStr = checkBeacon(beaconStr);
|
|
|
- if(beaconList.get(x).get("beaconTag").equals(beaconStr)){
|
|
|
- log.info("4.=====================================》上报的信标处理后返回信标编码:"+beaconStr+";实验室下匹配后的信标:"+beaconList.get(x).get("beaconTag"));
|
|
|
- // redis存储蓝牙信标编码和实验室id和mac地址
|
|
|
- redisService.setCacheObject(BaseConstants.BEACON_MATE_DET+"~"+ beaconStr+"~"+subId+"~"+beaconList.get(x).get("gasName"),beaconStr, 120L, TimeUnit.SECONDS);
|
|
|
- // 循环信标通知,把还回来的气瓶提示移除。
|
|
|
- if(beaconNoticeList != null){
|
|
|
- for(Map notice:beaconNoticeList){
|
|
|
- if(notice.get("beaconTag").equals(beaconStr)){
|
|
|
- log.info("5.=====================================》移除返回来的信标提示语:"+notice);
|
|
|
- newNoticeList.remove(notice);
|
|
|
- beaconTagBuild.append(",");
|
|
|
- beaconTagBuild.append(beaconStr);
|
|
|
+ if(array.size()>0){
|
|
|
+ // 这里需要比对redis存储的蓝牙信息列表和上报的列表信息 稍后补全这块
|
|
|
+ for(int i=0;i<array.size();i++){
|
|
|
+ String beaconStr = array.getString(i);
|
|
|
+ //初步过滤只有b5的数据
|
|
|
+ if(beaconStr.endsWith("b5")){
|
|
|
+ boolean flag = Boolean.FALSE;
|
|
|
+ // 循环检查实验室的信标比对上报的信标,将配对好的信标重新设置默认时间
|
|
|
+ for(int x=0;x<beaconList.size();x++){
|
|
|
+ // 这里需要处理信标字符串
|
|
|
+ beaconStr = checkBeacon(beaconStr);
|
|
|
+ if(beaconList.get(x).get("beaconTag").equals(beaconStr)){
|
|
|
+ log.info("{} 4.=====================================》上报的信标处理后返回信标编码:"+beaconStr+"; {} 实验室下匹配后的信标:"+beaconList.get(x).get("beaconTag"),uuid,subId);
|
|
|
+ flag=Boolean.TRUE;
|
|
|
+ // redis存储蓝牙信标编码和实验室id和mac地址
|
|
|
+ redisService.setCacheObject(BaseConstants.BEACON_MATE_DET+"~"+ beaconStr+"~"+subId+"~"+beaconList.get(x).get("gasName"),beaconStr, 30L, TimeUnit.MINUTES);
|
|
|
+ // 循环信标通知,把还回来的气瓶提示移除。
|
|
|
+ if(beaconNoticeList != null){
|
|
|
+ for(Map notice:beaconNoticeList){
|
|
|
+ if(notice.get("beaconTag").equals(beaconStr)){
|
|
|
+ log.info("{} 5.=====================================》 {} 移除返回来的信标提示语:"+notice,uuid,subId);
|
|
|
+ newNoticeList.remove(notice);
|
|
|
+ beaconTagBuild.append(",");
|
|
|
+ beaconTagBuild.append(beaconStr);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ if(!flag){
|
|
|
+ log.info("{} 4.1蓝牙网关串报,忽略信标.beaconStr:{}",uuid,beaconStr);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -115,7 +119,7 @@ public class BeaconMateImpl implements BeaconMate {
|
|
|
messageSendService.riskPlanTriggerNotice();
|
|
|
//这里需要调用通知修改接口,把离位改成在位
|
|
|
if(beaconTagBuild.length()>0){
|
|
|
- log.info("6.=====================================》带离气瓶归还后需要修改在位"+beaconTagBuild.substring(1));
|
|
|
+ log.info("{} 6.=====================================》 {} 带离气瓶归还后需要修改在位"+beaconTagBuild.substring(1),uuid,subId);
|
|
|
WarningNoticeLogDto warningNoticeLogDto = new WarningNoticeLogDto();
|
|
|
warningNoticeLogDto.setBeaconTag(beaconTagBuild.substring(1));
|
|
|
remoteLaboratoryService.updateLocationState(warningNoticeLogDto);
|