|
|
@@ -29,6 +29,8 @@ import java.util.concurrent.TimeUnit;
|
|
|
import java.util.concurrent.TimeoutException;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static com.xunmei.system.api.enums.ElectricityMeterAttributes.METER_ATTRIBUTES_4;
|
|
|
+
|
|
|
@Service
|
|
|
public class IotBoardServiceImpl implements IotBoardService {
|
|
|
@Autowired
|
|
|
@@ -140,26 +142,25 @@ public class IotBoardServiceImpl implements IotBoardService {
|
|
|
IotAlarmDataService alarmDataService;
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, Object> iotOverview(Long orgId) {
|
|
|
+ public Map<String, Object> iotOverview(Long orgId) {
|
|
|
Map<String, Object> dataMap = new HashMap<>();
|
|
|
- List<Map<String,Object>> resultList = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
SysOrg org = remoteOrgService.selectOrgById(orgId, SecurityConstants.INNER);
|
|
|
- List<IotSensor> list= sensorService.selectSensorListByOrgPath(org.getPath());
|
|
|
- if (ObjectUtil.isEmpty(list)){
|
|
|
+ List<IotSensor> list = sensorService.selectSensorListByOrgPath(org.getPath());
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ dataMap.put("sensor", map);
|
|
|
+ dataMap.put("resultData", resultList);
|
|
|
+ if (ObjectUtil.isEmpty(list)) {
|
|
|
+ map.put("key", "传感器设备");
|
|
|
+ map.put("sensorNums", list.size());
|
|
|
+ map.put("normal", 0);
|
|
|
+ map.put("alarm", 0);
|
|
|
return dataMap;
|
|
|
}
|
|
|
- //默认为正常
|
|
|
- list.forEach(r -> {
|
|
|
- if (ObjectUtil.isNull(r.getState())) {
|
|
|
- r.setState(0);
|
|
|
- }
|
|
|
- });
|
|
|
- HashMap<String, Object> map = new HashMap<>();
|
|
|
map.put("key", "传感器设备");
|
|
|
map.put("sensorNums", list.size());
|
|
|
map.put("normal", 0);
|
|
|
map.put("alarm", 0);
|
|
|
- dataMap.put("sensor",map);
|
|
|
Map<Integer, Long> collect = list.stream().collect(Collectors.groupingBy(IotSensor::getState, Collectors.counting()));
|
|
|
collect.forEach((k, v) -> {
|
|
|
if (ObjectUtil.equal(0, k)) {
|
|
|
@@ -169,21 +170,21 @@ public class IotBoardServiceImpl implements IotBoardService {
|
|
|
map.put("alarm", v.intValue());
|
|
|
}
|
|
|
});
|
|
|
- resultList.add(map);
|
|
|
- List<IotAlarmData> alarmDataList= alarmDataService.selectAlarmDataListByOrgPath(org.getPath(),0);
|
|
|
+ List<IotAlarmData> alarmDataList = alarmDataService.selectAlarmDataListByOrgPath(org.getPath(), 0);
|
|
|
+ //屏蔽红外
|
|
|
+ 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 count = value.stream().filter(d -> ObjectUtil.isNotNull(d.getEndTime())).count();
|
|
|
long unDealAlarm = value.stream().filter(d -> ObjectUtil.isNull(d.getDoTime())).count();
|
|
|
- hashMap.put("key",value.get(0).getSourceTypeDes());
|
|
|
+ hashMap.put("key", value.get(0).getSourceTypeDes());
|
|
|
hashMap.put("historyAlarm", count);
|
|
|
hashMap.put("currentAlarm", value.size() - count);
|
|
|
hashMap.put("unDealAlarm", unDealAlarm);
|
|
|
resultList.add(hashMap);
|
|
|
}
|
|
|
- dataMap.put("resultData",resultList);
|
|
|
return dataMap;
|
|
|
}
|
|
|
}
|