|
@@ -133,59 +133,83 @@ public class MonitorInfoController {
|
|
|
}
|
|
|
List<MonitorInfoEntity> page = monitorInfoService.findList(monitorInfoEntity);
|
|
|
for (MonitorInfoEntity item : page) {
|
|
|
- if (item.getMonitorType().equals(0L)) {
|
|
|
- //查询报警信息
|
|
|
- List<AlarmDetailsDto> alarmDetailsDtos = alarmDetailsService.selectByDeviceId(id,item.getDeviceId().intValue());
|
|
|
- Map<Integer, AlarmDetailsDto> mapAlarm = new HashMap<>();
|
|
|
- //将缓存中的实时数据放到map中方便进行遍历
|
|
|
- for (AlarmDetailsDto alarmDetailsDto : alarmDetailsDtos) {
|
|
|
- mapAlarm.put(alarmDetailsDto.getAttributeId(), alarmDetailsDto);
|
|
|
- }
|
|
|
- byte[] bytes = redisUtil.get(("sms_water_" + item.getDeviceCode()).getBytes());
|
|
|
- if (bytes != null && bytes.length > 0) {
|
|
|
- MonitorDataEntity monitorDataEntity = (MonitorDataEntity) ByteArrayUtils.bytesToObject(bytes).get();
|
|
|
- Map<Long, MonitorDataValueEntity> map = new HashMap<>();
|
|
|
- //将缓存中的实时数据放到map中方便进行遍历
|
|
|
- for (MonitorDataValueEntity dateValue : monitorDataEntity.getDataValues()) {
|
|
|
- map.put(dateValue.getAttributeId(), dateValue);
|
|
|
- }
|
|
|
- //判断如果是标签则进行map中取值
|
|
|
- if (item.getMonitorType().equals(0L))//标签
|
|
|
- {
|
|
|
- //按属性ID查询标签值
|
|
|
- DeviceAttributeSpecsEntity deviceAttributeSpecsEntity = new DeviceAttributeSpecsEntity();
|
|
|
- deviceAttributeSpecsEntity.setAttributeId(item.getAttributeId());
|
|
|
- List<DeviceAttributeSpecsEntity> deviceAttributeSpecsEntities = deviceAttributeSpecsService.findList(deviceAttributeSpecsEntity);
|
|
|
- if (map.containsKey(item.getAttributeId())) {
|
|
|
- Double value = map.get(item.getAttributeId()).getDataValue();
|
|
|
- if (value != null) {
|
|
|
- if (deviceAttributeSpecsEntities.size() > 0) {
|
|
|
- for (DeviceAttributeSpecsEntity specsEntity : deviceAttributeSpecsEntities)
|
|
|
- if (Integer.valueOf(specsEntity.getSpecsValue()) == value.intValue()) {
|
|
|
- item.setMonitorValue(specsEntity.getSpecsName());
|
|
|
- }
|
|
|
+ switch (item.getMonitorType().intValue()) {
|
|
|
+ case 0:
|
|
|
+ getMonitorInfo(id, item);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ case 4:
|
|
|
+ case 5:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, page);
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
- DeviceAttributeEntity deviceAttributeEntity = deviceAttributeService.getById(item.getAttributeId());
|
|
|
- String unit = "";
|
|
|
- if (deviceAttributeEntity != null && deviceAttributeEntity.getUnit() != null)
|
|
|
- unit = deviceAttributeEntity.getUnit();
|
|
|
- item.setMonitorValue(String.format("%.3f", map.get(item.getAttributeId()).getDataValue()) + unit);
|
|
|
+ /**
|
|
|
+ * 更新指令状态
|
|
|
+ * @param sceneId
|
|
|
+ * @param item
|
|
|
+ */
|
|
|
+ public void updateCommonState(Long sceneId,MonitorInfoEntity item) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新标签值
|
|
|
+ * @param sceneId
|
|
|
+ * @param item
|
|
|
+ */
|
|
|
+ public void getMonitorInfo(Long sceneId,MonitorInfoEntity item) {
|
|
|
+ //查询报警信息
|
|
|
+ List<AlarmDetailsDto> alarmDetailsDtos = alarmDetailsService.selectByDeviceId(sceneId, item.getDeviceId().intValue());
|
|
|
+ Map<Integer, AlarmDetailsDto> mapAlarm = new HashMap<>();
|
|
|
+ //将缓存中的实时数据放到map中方便进行遍历
|
|
|
+ for (AlarmDetailsDto alarmDetailsDto : alarmDetailsDtos) {
|
|
|
+ mapAlarm.put(alarmDetailsDto.getAttributeId(), alarmDetailsDto);
|
|
|
+ }
|
|
|
+ byte[] bytes = redisUtil.get(("sms_water_" + item.getDeviceCode()).getBytes());
|
|
|
+ if (bytes != null && bytes.length > 0) {
|
|
|
+ MonitorDataEntity monitorDataEntity = (MonitorDataEntity) ByteArrayUtils.bytesToObject(bytes).get();
|
|
|
+ Map<Long, MonitorDataValueEntity> map = new HashMap<>();
|
|
|
+ //将缓存中的实时数据放到map中方便进行遍历
|
|
|
+ for (MonitorDataValueEntity dateValue : monitorDataEntity.getDataValues()) {
|
|
|
+ map.put(dateValue.getAttributeId(), dateValue);
|
|
|
+ }
|
|
|
+ //判断如果是标签则进行map中取值
|
|
|
+ if (item.getMonitorType().equals(0L))//标签
|
|
|
+ {
|
|
|
+ //按属性ID查询标签值
|
|
|
+ DeviceAttributeSpecsEntity deviceAttributeSpecsEntity = new DeviceAttributeSpecsEntity();
|
|
|
+ deviceAttributeSpecsEntity.setAttributeId(item.getAttributeId());
|
|
|
+ List<DeviceAttributeSpecsEntity> deviceAttributeSpecsEntities = deviceAttributeSpecsService.findList(deviceAttributeSpecsEntity);
|
|
|
+ if (map.containsKey(item.getAttributeId())) {
|
|
|
+ Double value = map.get(item.getAttributeId()).getDataValue();
|
|
|
+ if (value != null) {
|
|
|
+ if (deviceAttributeSpecsEntities.size() > 0) {
|
|
|
+ for (DeviceAttributeSpecsEntity specsEntity : deviceAttributeSpecsEntities)
|
|
|
+ if (Integer.valueOf(specsEntity.getSpecsValue()) == value.intValue()) {
|
|
|
+ item.setMonitorValue(specsEntity.getSpecsName());
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- //判断是否报警
|
|
|
- if (mapAlarm.containsKey(item.getAttributeId().intValue())){
|
|
|
- item.setIsAlarm(1);
|
|
|
- item.setMonitorValue(item.getMonitorValue()+"("+mapAlarm.get(item.getAttributeId().intValue()).getAlarmRange()+")");
|
|
|
- }else{
|
|
|
- item.setIsAlarm(0);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ DeviceAttributeEntity deviceAttributeEntity = deviceAttributeService.getById(item.getAttributeId());
|
|
|
+ String unit = "";
|
|
|
+ if (deviceAttributeEntity != null && deviceAttributeEntity.getUnit() != null)
|
|
|
+ unit = deviceAttributeEntity.getUnit();
|
|
|
+ item.setMonitorValue(String.format("%.3f", map.get(item.getAttributeId()).getDataValue()) + unit);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //判断是否报警
|
|
|
+ if (mapAlarm.containsKey(item.getAttributeId().intValue())) {
|
|
|
+ item.setIsAlarm(1);
|
|
|
+ item.setMonitorValue(item.getMonitorValue() + "(" + mapAlarm.get(item.getAttributeId().intValue()).getAlarmRange() + ")");
|
|
|
+ } else {
|
|
|
+ item.setIsAlarm(0);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- return new AjaxMessage<>(ResultStatus.OK, page);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value="getDeviceParmByDeviceId" , method = RequestMethod.GET)
|
|
@@ -268,4 +292,15 @@ public class MonitorInfoController {
|
|
|
int result = monitorInfoService.delMonitorInfoByIds(ids) ? 1 : 0;
|
|
|
return new AjaxMessage<>(ResultStatus.OK, result);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 操作标签--查询设备属性
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "操作标签--查询设备属性")
|
|
|
+ @RequestMapping(value = "/getSceneParmBySceneId", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public AjaxMessage<List<DeviceParmEntity>> getSceneParmBySceneId(@ApiParam(value = "场景类型ID", required = true) Long id) {
|
|
|
+ List<DeviceParmEntity> deviceParmEntities = deviceParmService.selectByScendId(id.intValue());
|
|
|
+ return new AjaxMessage<>(ResultStatus.OK, deviceParmEntities);
|
|
|
+ }
|
|
|
+
|
|
|
}
|