|
|
@@ -19,10 +19,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
@@ -154,8 +151,10 @@ public class IotBoardServiceImpl implements IotBoardService {
|
|
|
map.put("sensorNums", list.size());
|
|
|
map.put("normal", 0);
|
|
|
map.put("alarm", 0);
|
|
|
+ List<String> alarmTypeList = new ArrayList<>();
|
|
|
+ Collections.addAll(alarmTypeList,"水浸告警", "温湿度告警", "烟感告警", "燃气告警", "门磁告警", "盗情告警");
|
|
|
if (ObjectUtil.isEmpty(list)) {
|
|
|
- buildEmptyData(map,resultList);
|
|
|
+ buildEmptyData(resultList,alarmTypeList);
|
|
|
return dataMap;
|
|
|
}
|
|
|
Map<Integer, Long> collect = list.stream().collect(Collectors.groupingBy(IotSensor::getState, Collectors.counting()));
|
|
|
@@ -169,33 +168,45 @@ public class IotBoardServiceImpl implements IotBoardService {
|
|
|
});
|
|
|
List<IotAlarmData> alarmDataList = alarmDataService.selectAlarmDataListByOrgPath(org.getPath(), 0);
|
|
|
if (ObjectUtil.isEmpty(alarmDataList)) {
|
|
|
- buildEmptyData(map,resultList);
|
|
|
+ buildEmptyData(resultList,alarmTypeList);
|
|
|
return dataMap;
|
|
|
}
|
|
|
//屏蔽红外
|
|
|
- alarmDataList.removeIf(d ->ObjectUtil.equal(METER_ATTRIBUTES_4.getText(),d.getSourceTypeDes()));
|
|
|
+ alarmDataList.removeIf(d -> ObjectUtil.equal(METER_ATTRIBUTES_4.getText(), d.getSourceTypeDes()));
|
|
|
Map<Object, List<IotAlarmData>> dataList = alarmDataList.stream().collect(Collectors.groupingBy(IotAlarmData::getSourceType));
|
|
|
for (Map.Entry<Object, List<IotAlarmData>> listEntry : dataList.entrySet()) {
|
|
|
List<IotAlarmData> value = listEntry.getValue();
|
|
|
Map<String, Object> hashMap = new HashMap<>();
|
|
|
long currentAlarm = value.stream().filter(d -> ObjectUtil.isNull(d.getEndTime())).count();
|
|
|
long unDealAlarm = value.stream().filter(d -> ObjectUtil.isNull(d.getDoTime())).count();
|
|
|
- long needAlarm = value.stream().anyMatch(d -> ObjectUtil.isNull(d.getEndTime()) && ObjectUtil.isNull(d.getDoTime())) ?1:0;
|
|
|
+ long needAlarm = value.stream().anyMatch(d -> ObjectUtil.isNull(d.getEndTime()) && ObjectUtil.isNull(d.getDoTime())) ? 1 : 0;
|
|
|
|
|
|
hashMap.put("key", value.get(0).getSourceTypeDes());
|
|
|
- hashMap.put("historyAlarm", (int)value.size());
|
|
|
- hashMap.put("currentAlarm",(int) currentAlarm);
|
|
|
- hashMap.put("unDealAlarm", (int)unDealAlarm);
|
|
|
- hashMap.put("needAlarm",(int) needAlarm);
|
|
|
+ hashMap.put("historyAlarm", value.size());
|
|
|
+ hashMap.put("currentAlarm", (int) currentAlarm);
|
|
|
+ hashMap.put("unDealAlarm", (int) unDealAlarm);
|
|
|
+ hashMap.put("needAlarm", (int) needAlarm);
|
|
|
resultList.add(hashMap);
|
|
|
}
|
|
|
+ List<String> keyList = resultList.stream().map(m -> m.get("key")).distinct().map(String::valueOf).collect(Collectors.toList());
|
|
|
+
|
|
|
+ for (String type : alarmTypeList) {
|
|
|
+ if (!keyList.contains(type)){
|
|
|
+ Map<String, Object> hashMap = new HashMap<>();
|
|
|
+ hashMap.put("key", type);
|
|
|
+ hashMap.put("historyAlarm", 0);
|
|
|
+ hashMap.put("currentAlarm", 0);
|
|
|
+ hashMap.put("unDealAlarm", 0);
|
|
|
+ hashMap.put("needAlarm", 0);
|
|
|
+ resultList.add(hashMap);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return dataMap;
|
|
|
}
|
|
|
|
|
|
- private void buildEmptyData(HashMap<String, Object> map,List<Map<String, Object>> resultList){
|
|
|
-
|
|
|
- //水浸告警 温湿度告警 烟感告警 燃气告警 门磁告警 盗情告警
|
|
|
- String[] alarmType = {"水浸告警", "温湿度告警", "烟感告警", "燃气告警", "门磁告警", "盗情告警"};
|
|
|
+ private void buildEmptyData(List<Map<String, Object>> resultList, List<String> alarmType) {
|
|
|
for (String s : alarmType) {
|
|
|
Map<String, Object> hashMap = new HashMap<>();
|
|
|
hashMap.put("key", s);
|
|
|
@@ -205,5 +216,6 @@ public class IotBoardServiceImpl implements IotBoardService {
|
|
|
hashMap.put("needAlarm", 0);
|
|
|
resultList.add(hashMap);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|