|
@@ -1,7 +1,6 @@
|
|
|
package com.huaxu.controller;
|
|
|
|
|
|
-import com.huaxu.entity.DeviceParmEntity;
|
|
|
-import com.huaxu.entity.SceneTypeEntity;
|
|
|
+import com.huaxu.entity.*;
|
|
|
import com.huaxu.model.AjaxMessage;
|
|
|
import com.huaxu.model.LoginUser;
|
|
|
import com.huaxu.model.ResultStatus;
|
|
@@ -20,7 +19,6 @@ import org.springframework.ui.ModelMap;
|
|
|
import java.util.*;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-import com.huaxu.entity.MonitorInfoEntity;
|
|
|
import com.huaxu.service.MonitorInfoService;
|
|
|
|
|
|
import javax.jws.Oneway;
|
|
@@ -60,9 +58,22 @@ public class MonitorInfoController {
|
|
|
monitorInfoEntity.setDeviceId(deviceId);
|
|
|
}
|
|
|
List<MonitorInfoEntity> page = monitorInfoService.findList(monitorInfoEntity);
|
|
|
-
|
|
|
- //ByteArrayUtils.bytesToObject(redisUtil.get("sms_water_").getBytes());
|
|
|
-
|
|
|
+ for (MonitorInfoEntity item : page) {
|
|
|
+ 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))//标签
|
|
|
+ {
|
|
|
+ item.setMonitorValue(map.get(item.getAttributeId()).getDataValue() + map.get(item.getAttributeId()).getUnit());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return new AjaxMessage<>(ResultStatus.OK, page);
|
|
|
}
|
|
|
|