From 51a9ac0eaa65d214b338685b7cb83c21a5a32589 Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Thu, 28 Jun 2018 16:34:46 +0800
Subject: [PATCH] 刷新redis 里设备信息 添加 versionNum.并保持多处调用一致。
---
src/main/java/com/moral/controller/ScreenController.java | 60 +++++++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 41 insertions(+), 19 deletions(-)
diff --git a/src/main/java/com/moral/controller/ScreenController.java b/src/main/java/com/moral/controller/ScreenController.java
index 5320d6c..e549d66 100644
--- a/src/main/java/com/moral/controller/ScreenController.java
+++ b/src/main/java/com/moral/controller/ScreenController.java
@@ -15,6 +15,8 @@
import com.moral.entity.alarm.AlarmConfig;
import com.moral.entity.alarm.AlarmConfigValue;
import com.moral.entity.charts.DataSortCondition;
+import com.moral.entity.layout.RealTimeDeviceLayout;
+import com.moral.service.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.log4j.Logger;
@@ -45,16 +47,6 @@
import com.moral.common.util.ValidateUtil;
import com.moral.common.xml.Version;
import com.moral.entity.alarm.AlarmSensorLevel;
-import com.moral.service.AccountService;
-import com.moral.service.AlarmConfigService;
-import com.moral.service.AlarmDailyService;
-import com.moral.service.AreaService;
-import com.moral.service.DeviceService;
-import com.moral.service.HistoryMinutelyService;
-import com.moral.service.HistoryService;
-import com.moral.service.MachineActivateService;
-import com.moral.service.MonitorPointService;
-import com.moral.service.SensorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -80,6 +72,8 @@
SensorService sensorService;
@Resource
MonitorPointService monitorPointService;
+ @Resource
+ DeviceVersionService deviceVersionService;
/** The screen service. */
@Resource
@@ -112,6 +106,10 @@
@Resource
private AlarmDailyService alarmDailyService;
+ @Resource
+ private OrganizationLayoutService orgLayoutService;
+ @Resource
+ private DeviceVersionService dviceVersionService;
/**
* Screen login. ������������
*
@@ -155,7 +153,7 @@
* @return the alarm levels
*/
@GetMapping("alarm-levels")
- public Object getAlarmLevels(HttpServletRequest request, Optional<Integer> orgId, Optional<Integer> mpId) {
+ public Object getAlarmLevels(HttpServletRequest request, Optional<Integer> orgId, Optional<Integer> mpId,Optional<String> mac) {
List<Map<String,Object>> sensorAlarmList = null;
try {
AlarmConfig alarmConfig = null;
@@ -163,6 +161,8 @@
alarmConfig = alarmConfigService.queryValueByOrganizationId(orgId.get()).get();
}else if(mpId.isPresent()){
alarmConfig = alarmConfigService.queryByMonitorPointId(mpId.get()).get();
+ } else if(mac.isPresent() ){
+ alarmConfig = alarmConfigService.queryByDeviceMac(mac.get()).get();
}
//���������������
if(alarmConfig.getValue()!=null&&alarmConfig.getValue().getAlarmLevels()!=null){
@@ -582,15 +582,37 @@
})
@GetMapping("rtm-layout")
public ResultBean realTimeMonitorLayout(String primaryKey,String type){
- InputStreamReader reader = null;
- Map<String,Object> map = null;
- try {
- reader = new InputStreamReader(resource.getInputStream());
- map = new JSONReader(reader).readObject(new TypeReference<Map<String,Object>>() {});
- } catch (IOException e) {
- e.printStackTrace();
+ RealTimeDeviceLayout rtdLayout = null;
+ if(type != null && type.equals("device")) {
+ Device device = deviceService.getDeviceByMac(primaryKey,false);
+ if(device!= null
+ && device.getOrganizationIds()!=null
+ && device.getOrganizationIds().size() >0
+ && device.getDeviceVersionId()!=null) {
+ Integer orgId = device.getOrganizationIds().get(0);
+ DeviceVersion deviceVersion = deviceVersionService.queryVersionById(device.getDeviceVersionId());
+ rtdLayout = orgLayoutService.queryRtdLayoutWithUnit(orgId,deviceVersion.getVersion());
+ }else {
+ return ResultBean.fail();
+ }
+
+ } else {
+ MonitorPoint monitorPoint = monitorPointService.queryMonitorPointById(Integer.parseInt(primaryKey));
+ List<DeviceVersion> versionList = deviceVersionService.queryByOrgId(monitorPoint.getOrganizationId());
+ if(versionList.size() > 0) {
+ List<Integer> versionNolist = versionList.stream().map(item -> {
+ return item.getVersion();
+ }).collect(Collectors.toList());
+ rtdLayout = orgLayoutService.queryRtdLayoutWithUnit(monitorPoint.getOrganizationId(),versionNolist);
+ if(rtdLayout == null) {
+ return ResultBean.fail();
+ }
+ }
}
- return new ResultBean(map);
+ if(rtdLayout.getDefaultMonitorItems().size() == 0 ) {
+ rtdLayout.getDefaultMonitorItems().addAll(rtdLayout.getCoreMonitorItems());
+ }
+ return new ResultBean(rtdLayout);
}
}
--
Gitblit v1.8.0