|
|
@@ -181,8 +181,8 @@ public class IotBoardServiceImpl implements IotBoardService {
|
|
|
public Map<String, Object> iotOverview(Long orgId) {
|
|
|
List<SysOrgVO> cacheList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
|
|
|
|
|
|
- List<String> alarmTypeList = Lists.newArrayList("水浸告警", "温湿度告警", "烟感告警", "燃气告警", "门磁告警", "防盗告警");
|
|
|
- List<String> productTypeList = Lists.newArrayList("FSU_Water", "FSU_TemperatureAndHumidity", "FSU_Smoke", "FSU_Gas", "FSU_DoorMagnetic", "FSU_Theft");
|
|
|
+ List<String> alarmTypeList = Lists.newArrayList("水浸告警", "温湿度告警", "烟感告警", "燃气告警", "门磁告警", "防盗告警","8小时回路告警","24小时回路告警");
|
|
|
+ List<String> productTypeList = Lists.newArrayList("FSU_Water", "FSU_TemperatureAndHumidity", "FSU_Smoke", "FSU_Gas", "FSU_DoorMagnetic", "FSU_Theft","FSU_DoPowerCollection8Hour","FSU_DoPowerCollection24Hour");
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
Map<String, Object> dataMap = new HashMap<>();
|
|
|
@@ -239,13 +239,14 @@ public class IotBoardServiceImpl implements IotBoardService {
|
|
|
long currentAlarm = value.stream().filter(d -> ObjectUtil.isNull(d.getEndTime())).count();
|
|
|
long unDealAlarm = value.stream().filter(d -> ObjectUtil.isNull(d.getDoTime())).count();
|
|
|
int needAlarm = value.stream().anyMatch(d -> ObjectUtil.isNull(d.getEndTime()) && ObjectUtil.isNull(d.getDoTime())) ? 1 : 0;
|
|
|
+ needAlarm = (needAlarm == 1 && productTypes.contains(value.get(0).getSourceType())) ? 1 : 0;
|
|
|
|
|
|
hashMap.put("key", value.get(0).getSourceTypeDes());
|
|
|
hashMap.put("historyAlarm", value.size());
|
|
|
hashMap.put("currentAlarm", (int) currentAlarm);
|
|
|
hashMap.put("unDealAlarm", (int) unDealAlarm);
|
|
|
- hashMap.put("needAlarm", (needAlarm == 1 && productTypes.contains(value.get(0).getSourceType())) ? 1 : 0);
|
|
|
- hashMap.put("currentAlarmData", getAlarmDataList(value, listEntry.getKey().toString(), cacheList));
|
|
|
+ hashMap.put("needAlarm", needAlarm);
|
|
|
+ hashMap.put("currentAlarmData", getAlarmDataList(value, listEntry.getKey().toString(), cacheList,needAlarm));
|
|
|
|
|
|
resultList.add(hashMap);
|
|
|
}
|
|
|
@@ -264,10 +265,16 @@ public class IotBoardServiceImpl implements IotBoardService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //查询通知规则中通知机构为当前机构的数据
|
|
|
+ List<Long> orgIdList = coreNoticeRuleItemService.getOrgIdsByNoticeOrgId(orgId);
|
|
|
+ if (orgIdList != null && orgIdList.size() > 0) {
|
|
|
+ handleOtherData(orgIdList,dataMap,roleIds,loginUser,cacheList);
|
|
|
+ }
|
|
|
+
|
|
|
return dataMap;
|
|
|
}
|
|
|
|
|
|
- private List<AppAlarmDataPageVo> getAlarmDataList(List<IotAlarmData> dataList, String sourceType, List<SysOrgVO> cacheList) {
|
|
|
+ private List<AppAlarmDataPageVo> getAlarmDataList(List<IotAlarmData> dataList, String sourceType, List<SysOrgVO> cacheList,Integer needAlarm) {
|
|
|
List<IotAlarmData> list = dataList.stream()
|
|
|
.filter(d -> ObjectUtil.equal(d.getSourceType(), sourceType))
|
|
|
.filter(d -> ObjectUtil.isNull(d.getEndTime()))
|
|
|
@@ -294,6 +301,7 @@ public class IotBoardServiceImpl implements IotBoardService {
|
|
|
vo.setDoByUser(alarmData.getDoByUser());
|
|
|
vo.setDoType(alarmData.getDoType());
|
|
|
vo.setDoContent(alarmData.getDoContent());
|
|
|
+ vo.setNeedAlarm(needAlarm);
|
|
|
arrayList.add(vo);
|
|
|
|
|
|
}
|
|
|
@@ -497,4 +505,83 @@ public class IotBoardServiceImpl implements IotBoardService {
|
|
|
videoInspection.setHardDiskExceptionRate(String.format("%.2f", ((dvrDiskList.size() - count1) * 100.0 / dvrDiskList.size())) + "%");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param orgIdList
|
|
|
+ * @param dataMap
|
|
|
+ * @param roleIds
|
|
|
+ * @param loginUser
|
|
|
+ */
|
|
|
+ private void handleOtherData(List<Long> orgIdList, Map<String, Object> dataMap,List<Long> roleIds,LoginUser loginUser,List<SysOrgVO> cacheList) {
|
|
|
+ //查询其他机构的数据
|
|
|
+ for (Long orgId : orgIdList) {
|
|
|
+ //根据用户ID和角色查询其他机构需要通知的类型
|
|
|
+ List<String> productTypes = coreNoticeRuleItemService.getNoticeProductTypesByNoticeUser(roleIds, orgId, loginUser.getOrgId(),loginUser.getUserid());
|
|
|
+ if (!(productTypes != null && productTypes.size() > 0)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<DeviceDetailInfoVo> list = deviceInfoService.getByProductTypesAndOrgId(productTypes, orgId);
|
|
|
+ if (!(list != null && list.size() > 0)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<Integer, Long> otherCollect = list.stream().collect(Collectors.groupingBy(DeviceDetailInfoVo::getState, Collectors.counting()));
|
|
|
+ int normalCount = otherCollect.getOrDefault(0, 0L).intValue();
|
|
|
+ int alarmCount = otherCollect.getOrDefault(1, 0L).intValue();
|
|
|
+
|
|
|
+ Map<String,Object> sensorMap = (Map<String, Object>) dataMap.get("sensor");
|
|
|
+ sensorMap.put("sensorNums",(int)sensorMap.get("sensorNums") + list.size());
|
|
|
+ sensorMap.put("normal",(int)sensorMap.get("normal") + normalCount);
|
|
|
+ sensorMap.put("alarm",(int)sensorMap.get("alarm") + alarmCount);
|
|
|
+ dataMap.put("sensor", sensorMap);
|
|
|
+
|
|
|
+ List<IotAlarmData> alarmDataList = alarmDataService.getByProductTypesAndOrgId(productTypes,orgId, 0);
|
|
|
+ if (!(alarmDataList != null && alarmDataList.size() > 0)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> resultList = (List<Map<String, Object>>) dataMap.get("resultData");
|
|
|
+
|
|
|
+ //屏蔽红外
|
|
|
+ alarmDataList.removeIf(d -> ObjectUtil.equal(METER_ATTRIBUTES_4.getText(), d.getSourceTypeDes()));
|
|
|
+ Map<Object, List<IotAlarmData>> otherDataList = alarmDataList.stream().collect(Collectors.groupingBy(IotAlarmData::getSourceType));
|
|
|
+ for (Map.Entry<Object, List<IotAlarmData>> listEntry : otherDataList.entrySet()) {
|
|
|
+ List<IotAlarmData> value = listEntry.getValue();
|
|
|
+ long unDealAlarm = value.stream().filter(d -> ObjectUtil.isNull(d.getDoTime())).count();
|
|
|
+ long currentAlarm = value.stream().filter(d -> ObjectUtil.isNull(d.getEndTime())).count();
|
|
|
+ int needAlarm = value.stream().anyMatch(d -> ObjectUtil.isNull(d.getEndTime()) && ObjectUtil.isNull(d.getDoTime())) ? 1 : 0;
|
|
|
+ needAlarm = (needAlarm == 1 && productTypes.contains(value.get(0).getSourceType())) ? 1 : 0;
|
|
|
+
|
|
|
+
|
|
|
+ Optional<Map<String, Object>> optional = resultList.stream().filter(d -> d.get("key").equals(listEntry.getValue().get(0).getSourceTypeDes())).findFirst();
|
|
|
+ if (!optional.isPresent()){
|
|
|
+ Map<String, Object> hashMap = new HashMap<>();
|
|
|
+ hashMap.put("key", value.get(0).getSourceTypeDes());
|
|
|
+ hashMap.put("historyAlarm", value.size());
|
|
|
+ hashMap.put("unDealAlarm", (int) unDealAlarm);
|
|
|
+ hashMap.put("currentAlarm", (int) currentAlarm);
|
|
|
+ hashMap.put("needAlarm", needAlarm);
|
|
|
+ hashMap.put("currentAlarmData", getAlarmDataList(value, listEntry.getKey().toString(), cacheList,needAlarm));
|
|
|
+
|
|
|
+ resultList.add(hashMap);
|
|
|
+ }else {
|
|
|
+ Map<String, Object> objectMap = optional.get();
|
|
|
+ int index = resultList.indexOf(objectMap);
|
|
|
+ objectMap.put("historyAlarm", (int) objectMap.get("historyAlarm") + value.size());
|
|
|
+ objectMap.put("currentAlarm", (int) objectMap.get("currentAlarm") + currentAlarm);
|
|
|
+ objectMap.put("unDealAlarm", (int) objectMap.get("unDealAlarm") + unDealAlarm);
|
|
|
+
|
|
|
+ List<AppAlarmDataPageVo> dataList = (List<AppAlarmDataPageVo>) objectMap.get("currentAlarmData");
|
|
|
+ dataList.addAll(getAlarmDataList(value, listEntry.getKey().toString(), cacheList, needAlarm));
|
|
|
+ objectMap.put("currentAlarmData", dataList);
|
|
|
+
|
|
|
+ needAlarm = ((int) objectMap.get("needAlarm") == 1 && needAlarm == 1) ? 1 : 0;
|
|
|
+ objectMap.put("needAlarm", needAlarm);
|
|
|
+
|
|
|
+ resultList.set(index,objectMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dataMap.put("resultData", resultList);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|