|
@@ -33,17 +33,17 @@ public class PushDataSevice {
|
|
|
|
|
|
@Resource
|
|
|
private WebSocketBt webSocketBt;
|
|
|
- public void pushWtData(AlarmTag po) throws EncodeException, IOException {
|
|
|
+
|
|
|
+ public void pushWtData(AlarmTag po) throws EncodeException, IOException {
|
|
|
ConcurrentHashMap<String, WebSocket> webSocketPushMap = WebSocket.webSocketMap;
|
|
|
ConcurrentHashMap<String, PushParams> webSocketPushParamsMap = WebSocket.webSocketParamsMap;
|
|
|
|
|
|
- if(!webSocketPushMap.isEmpty()){
|
|
|
- for(String key : webSocketPushMap.keySet()){
|
|
|
+ if (!webSocketPushMap.isEmpty()) {
|
|
|
+ for (String key : webSocketPushMap.keySet()) {
|
|
|
// 根据ws连接用户ID获取推送参数
|
|
|
|
|
|
|
|
|
- synchronized(po.getId())
|
|
|
- {
|
|
|
+ synchronized (po.getId()) {
|
|
|
// if(webSocketPushParamsMap.contains(po.getId()))
|
|
|
// {
|
|
|
// PushParams pp=webSocketPushParamsMap.get(po.getId());
|
|
@@ -71,9 +71,8 @@ public class PushDataSevice {
|
|
|
//
|
|
|
// }
|
|
|
|
|
|
- if(checkWtId(key,po.getDeviceId()))
|
|
|
- {
|
|
|
- webSocket.sendMessageByUserId(key,po);
|
|
|
+ if (checkWtId(key, po.getDeviceId())) {
|
|
|
+ webSocket.sendMessageByUserId(key, po);
|
|
|
|
|
|
|
|
|
}
|
|
@@ -84,83 +83,95 @@ public class PushDataSevice {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public void pushBtData(AlarmTag po) throws EncodeException, IOException {
|
|
|
+ public void pushBtData(AlarmTag po) throws EncodeException, IOException {
|
|
|
ConcurrentHashMap<String, WebSocket> webSocketPushMap = WebSocket.webSocketMap;
|
|
|
ConcurrentHashMap<String, WebSocketBt> webSocketPushBtMap = WebSocketBt.webSocketBtMap;
|
|
|
ConcurrentHashMap<String, PushParams> webSocketPushParamsMap = WebSocket.webSocketParamsMap;
|
|
|
|
|
|
ConcurrentHashMap<String, List<String>> btParamsMap = WebSocketBt.btParamsMap;
|
|
|
|
|
|
- if(!webSocketPushMap.isEmpty()){
|
|
|
- for(String key : webSocketPushMap.keySet()){
|
|
|
+ if (!webSocketPushMap.isEmpty()) {
|
|
|
+ for (String key : webSocketPushMap.keySet()) {
|
|
|
// 根据ws连接用户ID获取推送参数
|
|
|
// PushParams pushParams = webSocketPushParamsMap.get(key);
|
|
|
- synchronized(po.getId())
|
|
|
- {
|
|
|
- if(checkBtId(key,po.getWpId()))
|
|
|
- {
|
|
|
- webSocket.sendMessageByUserId(key,po);
|
|
|
+ synchronized (po.getId()) {
|
|
|
+ if (checkBtId(key, po.getWpId())) {
|
|
|
+ webSocket.sendMessageByUserId(key, po);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(!webSocketPushBtMap.isEmpty()){
|
|
|
- for(String key : webSocketPushBtMap.keySet()){
|
|
|
- // 根据ws连接用户ID获取推送参数
|
|
|
-// PushParams pushParams = webSocketPushParamsMap.get(key);
|
|
|
+ if (!webSocketPushBtMap.isEmpty()) {
|
|
|
+
|
|
|
+ synchronized (po.getId()) {
|
|
|
+
|
|
|
+
|
|
|
+ if (po.getRank() > 3) {
|
|
|
+
|
|
|
+ if (btParamsMap.containsKey(po.getWpId())) {
|
|
|
+
|
|
|
+ List<String> btls = btParamsMap.get(po.getWpId());
|
|
|
|
|
|
+ if (btls.contains(po.getAlarmId())) {
|
|
|
+ btls.remove(po.getAlarmId());
|
|
|
+ } else {
|
|
|
+ btls.add(po.getAlarmId());
|
|
|
+ }
|
|
|
+ if (btls.isEmpty()) {
|
|
|
+ for (String key : webSocketPushBtMap.keySet()) {
|
|
|
|
|
|
- synchronized(po.getId())
|
|
|
- {
|
|
|
- if(checkBtId(key,po.getWpId()))
|
|
|
- {
|
|
|
- if(po.getRank()>3)
|
|
|
- {
|
|
|
- if(btParamsMap.containsKey(po.getWpId()))
|
|
|
- {
|
|
|
- List<String> btls=btParamsMap.get(po.getWpId());
|
|
|
-
|
|
|
- if(btls.contains(po.getAlarmId()))
|
|
|
- {
|
|
|
- btls.remove(po.getAlarmId());
|
|
|
- }else
|
|
|
- {
|
|
|
- btls.add(po.getAlarmId());
|
|
|
+ if (checkBtId(key, po.getWpId())) {
|
|
|
+ Map<String, Boolean> map = new HashMap<>();
|
|
|
+ map.put(po.getWpId(), false);
|
|
|
+ webSocketBt.sendMessageByUserId(key, map);
|
|
|
}
|
|
|
- if(btls.isEmpty())
|
|
|
- {
|
|
|
- Map<String,Boolean> map=new HashMap<>();
|
|
|
- map.put(po.getWpId(),false);
|
|
|
- webSocketBt.sendMessageByUserId(key,map);
|
|
|
- }else
|
|
|
- {
|
|
|
- Map<String,Boolean> map=new HashMap<>();
|
|
|
- map.put(po.getWpId(),true);
|
|
|
- webSocketBt.sendMessageByUserId(key,map);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ for (String key : webSocketPushBtMap.keySet()) {
|
|
|
+
|
|
|
+ if (checkBtId(key, po.getWpId())) {
|
|
|
+ Map<String, Boolean> map = new HashMap<>();
|
|
|
+ map.put(po.getWpId(), true);
|
|
|
+ webSocketBt.sendMessageByUserId(key, map);
|
|
|
}
|
|
|
- }else
|
|
|
- {
|
|
|
- List<String> btls=new ArrayList<>();
|
|
|
-
|
|
|
- btls.add(po.getAlarmId());
|
|
|
- btParamsMap.put(po.getWpId(),btls);
|
|
|
- Map<String,Boolean> map=new HashMap<>();
|
|
|
- if(StringUtils.empty(po.getIsClose()))
|
|
|
- {
|
|
|
- map.put(po.getWpId(),false);
|
|
|
- webSocketBt.sendMessageByUserId(key,map);
|
|
|
- }else
|
|
|
- {
|
|
|
- map.put(po.getWpId(),true);
|
|
|
- webSocketBt.sendMessageByUserId(key,map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ List<String> btls = new ArrayList<>();
|
|
|
+
|
|
|
+ btls.add(po.getAlarmId());
|
|
|
+
|
|
|
+ btParamsMap.put(po.getWpId(), btls);
|
|
|
+
|
|
|
+ if (StringUtils.empty(po.getIsClose())) {
|
|
|
+ for (String key : webSocketPushBtMap.keySet()) {
|
|
|
+
|
|
|
+
|
|
|
+ if (checkBtId(key, po.getWpId())) {
|
|
|
+ Map<String, Boolean> map = new HashMap<>();
|
|
|
+ map.put(po.getWpId(), false);
|
|
|
+ webSocketBt.sendMessageByUserId(key, map);
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ for (String key : webSocketPushBtMap.keySet()) {
|
|
|
|
|
|
+
|
|
|
+ if (checkBtId(key, po.getWpId())) {
|
|
|
+ Map<String, Boolean> map = new HashMap<>();
|
|
|
+ map.put(po.getWpId(), true);
|
|
|
+ webSocketBt.sendMessageByUserId(key, map);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -168,63 +179,61 @@ public class PushDataSevice {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private boolean checkWtId(String userId,String wtId) {
|
|
|
+ private boolean checkWtId(String userId, String wtId) {
|
|
|
|
|
|
|
|
|
- boolean result=false;
|
|
|
- List<String> depls = sysUserService.getUserByuserId(Long.valueOf(userId));
|
|
|
- if (!depls.isEmpty()) {
|
|
|
- String depId = depls.get(0);
|
|
|
+ boolean result = false;
|
|
|
|
|
|
- if (CacheContext.wpwtmap.containsKey(depId)) {
|
|
|
+ if (StringUtils.notEmp(userId)) {
|
|
|
+ String[] str = userId.split("_");
|
|
|
+ if (str.length == 2) {
|
|
|
+ List<String> depls = sysUserService.getUserByuserId(Long.valueOf(str[0]));
|
|
|
+ if (!depls.isEmpty()) {
|
|
|
+ String depId = depls.get(0);
|
|
|
|
|
|
- List<ProBasicEquipment> wtls=CacheContext.wpwtmap.get(depId);
|
|
|
- for(ProBasicEquipment wt:wtls)
|
|
|
- {
|
|
|
- if(wt.getId().equals(wtId))
|
|
|
- {
|
|
|
- result=true;
|
|
|
- break;
|
|
|
- }
|
|
|
+ if (CacheContext.wpwtmap.containsKey(depId)) {
|
|
|
|
|
|
- }
|
|
|
+ List<ProBasicEquipment> wtls = CacheContext.wpwtmap.get(depId);
|
|
|
+ for (ProBasicEquipment wt : wtls) {
|
|
|
+ if (wt.getId().equals(wtId)) {
|
|
|
+ result = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- } else if (CacheContext.cmwtlsmap.containsKey(depId)) {
|
|
|
+ }
|
|
|
|
|
|
- List<ProBasicEquipment> wtls=CacheContext.cmwtlsmap.get(depId);
|
|
|
- for(ProBasicEquipment wt:wtls)
|
|
|
- {
|
|
|
- if( wt.getId().equals(wtId))
|
|
|
- {
|
|
|
- result=true;
|
|
|
- break;
|
|
|
- }
|
|
|
+ } else if (CacheContext.cmwtlsmap.containsKey(depId)) {
|
|
|
|
|
|
- }
|
|
|
+ List<ProBasicEquipment> wtls = CacheContext.cmwtlsmap.get(depId);
|
|
|
+ for (ProBasicEquipment wt : wtls) {
|
|
|
+ if (wt.getId().equals(wtId)) {
|
|
|
+ result = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- } else if (CacheContext.rgwtlsmap.containsKey(depId)) {
|
|
|
+ }
|
|
|
|
|
|
- List<ProBasicEquipment> wtls=CacheContext.rgwtlsmap.get(depId);
|
|
|
- for(ProBasicEquipment wt:wtls)
|
|
|
- {
|
|
|
- if( wt.getId().equals(wtId))
|
|
|
- {
|
|
|
- result=true;
|
|
|
- break;
|
|
|
- }
|
|
|
+ } else if (CacheContext.rgwtlsmap.containsKey(depId)) {
|
|
|
|
|
|
- }
|
|
|
+ List<ProBasicEquipment> wtls = CacheContext.rgwtlsmap.get(depId);
|
|
|
+ for (ProBasicEquipment wt : wtls) {
|
|
|
+ if (wt.getId().equals(wtId)) {
|
|
|
+ result = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- }else if(depId.equals("0"))
|
|
|
- {
|
|
|
- for(ProBasicEquipment wt:CacheContext.wtls)
|
|
|
- {
|
|
|
- if( wt.getId().equals(wtId))
|
|
|
- {
|
|
|
- result=true;
|
|
|
- break;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
+ } else if (depId.equals("0")) {
|
|
|
+ for (ProBasicEquipment wt : CacheContext.wtls) {
|
|
|
+ if (wt.getId().equals(wtId)) {
|
|
|
+ result = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -234,68 +243,66 @@ public class PushDataSevice {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private boolean checkBtId(String userId,String btId) {
|
|
|
+ private boolean checkBtId(String userId, String btId) {
|
|
|
|
|
|
|
|
|
- boolean result=false;
|
|
|
- List<String> depls = sysUserService.getUserByuserId(Long.valueOf(userId));
|
|
|
- if (!depls.isEmpty()) {
|
|
|
- String depId = depls.get(0);
|
|
|
+ boolean result = false;
|
|
|
|
|
|
- if (CacheContext.wpmap.containsKey(depId)) {
|
|
|
+ if (StringUtils.notEmp(userId)) {
|
|
|
+ String[] str = userId.split("_");
|
|
|
+ if (str.length == 2) {
|
|
|
+ List<String> depls = sysUserService.getUserByuserId(Long.valueOf(str[0]));
|
|
|
+ if (!depls.isEmpty()) {
|
|
|
+ String depId = depls.get(0);
|
|
|
|
|
|
- ProBasicPowerstation wp=CacheContext.wpmap.get(depId);
|
|
|
+ if (CacheContext.wpmap.containsKey(depId)) {
|
|
|
|
|
|
- if(CacheContext.subwpmap.containsKey(btId))
|
|
|
- {
|
|
|
- ProBasicSubStation sub= CacheContext.subwpmap.get(btId);
|
|
|
- if(sub.getWindpowerstationId().equals(wp.getId()))
|
|
|
- {
|
|
|
- result=true;
|
|
|
- }
|
|
|
- }
|
|
|
+ ProBasicPowerstation wp = CacheContext.wpmap.get(depId);
|
|
|
|
|
|
- } else if (CacheContext.cpwpmap.containsKey(depId)) {
|
|
|
-
|
|
|
- List<ProBasicPowerstation> wpls=CacheContext.cpwpmap.get(depId);
|
|
|
- for(ProBasicPowerstation wp:wpls)
|
|
|
- {
|
|
|
- if(CacheContext.subwpmap.containsKey(btId))
|
|
|
- {
|
|
|
- ProBasicSubStation sub= CacheContext.subwpmap.get(btId);
|
|
|
- if(sub.getWindpowerstationId().equals(wp.getId()))
|
|
|
- {
|
|
|
- result=true;
|
|
|
- break;
|
|
|
+ if (CacheContext.subwpmap.containsKey(btId)) {
|
|
|
+ ProBasicSubStation sub = CacheContext.subwpmap.get(btId);
|
|
|
+ if (sub.getWindpowerstationId().equals(wp.getId())) {
|
|
|
+ result = true;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
+ } else if (CacheContext.cpwpmap.containsKey(depId)) {
|
|
|
+
|
|
|
+ List<ProBasicPowerstation> wpls = CacheContext.cpwpmap.get(depId);
|
|
|
+ for (ProBasicPowerstation wp : wpls) {
|
|
|
+ if (CacheContext.subwpmap.containsKey(btId)) {
|
|
|
+ ProBasicSubStation sub = CacheContext.subwpmap.get(btId);
|
|
|
+ if (sub.getWindpowerstationId().equals(wp.getId())) {
|
|
|
+ result = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- } else if (CacheContext.rgwpmap.containsKey(depId)) {
|
|
|
-
|
|
|
- List<ProBasicPowerstation> wpls=CacheContext.rgwpmap.get(depId);
|
|
|
- for(ProBasicPowerstation wp:wpls)
|
|
|
- {
|
|
|
- if(CacheContext.subwpmap.containsKey(btId))
|
|
|
- {
|
|
|
- ProBasicSubStation sub= CacheContext.subwpmap.get(btId);
|
|
|
- if(sub.getWindpowerstationId().equals(wp.getId()))
|
|
|
- {
|
|
|
- result=true;
|
|
|
- break;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
+ } else if (CacheContext.rgwpmap.containsKey(depId)) {
|
|
|
|
|
|
- }else if(depId.equals("0"))
|
|
|
- {
|
|
|
- result=true;
|
|
|
+ List<ProBasicPowerstation> wpls = CacheContext.rgwpmap.get(depId);
|
|
|
+ for (ProBasicPowerstation wp : wpls) {
|
|
|
+ if (CacheContext.subwpmap.containsKey(btId)) {
|
|
|
+ ProBasicSubStation sub = CacheContext.subwpmap.get(btId);
|
|
|
+ if (sub.getWindpowerstationId().equals(wp.getId())) {
|
|
|
+ result = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (depId.equals("0")) {
|
|
|
+ result = true;
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
}
|