|
|
@@ -29,8 +29,10 @@ import com.xunmei.iot.vo.alarmData.AppAlarmDataPageVo;
|
|
|
import com.xunmei.iot.vo.board.IotBoardOverviewItemVo;
|
|
|
import com.xunmei.iot.vo.board.IotBoardOverviewVo;
|
|
|
import com.xunmei.iot.vo.board.IotBoardTotalData;
|
|
|
+import com.xunmei.iot.vo.deviceInfo.DeviceDetailInfoVo;
|
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
+import com.xunmei.system.api.domain.SysRole;
|
|
|
import com.xunmei.system.api.domain.SysUser;
|
|
|
import com.xunmei.system.api.model.LoginUser;
|
|
|
import com.xunmei.system.api.vo.SysOrgVO;
|
|
|
@@ -78,6 +80,9 @@ public class IotBoardServiceImpl implements IotBoardService {
|
|
|
@Resource
|
|
|
ICoreNoticeRuleItemService coreNoticeRuleItemService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ IIotDeviceInfoService deviceInfoService;
|
|
|
+
|
|
|
private final Long TIMEOUT = 3L;
|
|
|
|
|
|
@Override
|
|
|
@@ -176,6 +181,7 @@ 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");
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
Map<String, Object> dataMap = new HashMap<>();
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
@@ -184,7 +190,8 @@ public class IotBoardServiceImpl implements IotBoardService {
|
|
|
throw new ServiceException("当前机构信息不存在");
|
|
|
}
|
|
|
SysOrgVO org = optional.get();
|
|
|
- List<IotSensor> list = sensorService.selectSensorListByOrgPath(org.getPath());
|
|
|
+ List<DeviceDetailInfoVo> list = deviceInfoService.getByProductTypes(productTypeList, org.getPath());
|
|
|
+ //List<IotSensor> list = sensorService.selectSensorListByOrgPath(org.getPath());
|
|
|
dataMap.put("sensor", map);
|
|
|
dataMap.put("resultData", resultList);
|
|
|
map.put("key", "传感器设备");
|
|
|
@@ -195,7 +202,7 @@ public class IotBoardServiceImpl implements IotBoardService {
|
|
|
buildEmptyData(resultList, alarmTypeList);
|
|
|
return dataMap;
|
|
|
}
|
|
|
- Map<Integer, Long> collect = list.stream().collect(Collectors.groupingBy(IotSensor::getState, Collectors.counting()));
|
|
|
+ Map<Integer, Long> collect = list.stream().collect(Collectors.groupingBy(DeviceDetailInfoVo::getState, Collectors.counting()));
|
|
|
collect.forEach((k, v) -> {
|
|
|
if (ObjectUtil.equal(0, k)) {
|
|
|
map.put("normal", v.intValue());
|
|
|
@@ -216,10 +223,10 @@ public class IotBoardServiceImpl implements IotBoardService {
|
|
|
|
|
|
//查询当前登录用户需要通知的告警类型
|
|
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
|
- List<String> roleIds = null;
|
|
|
- Set<String> roles = loginUser.getRoles();
|
|
|
- if (roles != null && !roles.isEmpty()){
|
|
|
- roleIds = new ArrayList<>(roles);
|
|
|
+ List<Long> roleIds = null;
|
|
|
+ List<SysRole> sysRoles= loginUser.getSysUser().getRoles();
|
|
|
+ if (sysRoles != null && !sysRoles.isEmpty()){
|
|
|
+ roleIds = sysRoles.stream().map(SysRole::getId).collect(Collectors.toList());
|
|
|
}
|
|
|
List<String> productTypes = coreNoticeRuleItemService.getNoticeProductTypesByUser(roleIds, orgId, loginUser.getUserid());
|
|
|
|
|
|
@@ -236,7 +243,7 @@ public class IotBoardServiceImpl implements IotBoardService {
|
|
|
hashMap.put("currentAlarm", (int) currentAlarm);
|
|
|
hashMap.put("unDealAlarm", (int) unDealAlarm);
|
|
|
hashMap.put("needAlarm", (int) needAlarm);
|
|
|
- hashMap.put("currentAlarmData", getAlarmDataList(value, Integer.parseInt(listEntry.getKey().toString()), cacheList));
|
|
|
+ hashMap.put("currentAlarmData", getAlarmDataList(value, listEntry.getKey().toString(), cacheList));
|
|
|
hashMap.put("needNotice", productTypes.contains(value.get(0).getSourceType()) ? 1 : 0);
|
|
|
|
|
|
resultList.add(hashMap);
|
|
|
@@ -260,7 +267,7 @@ public class IotBoardServiceImpl implements IotBoardService {
|
|
|
return dataMap;
|
|
|
}
|
|
|
|
|
|
- private List<AppAlarmDataPageVo> getAlarmDataList(List<IotAlarmData> dataList, Integer sourceType, List<SysOrgVO> cacheList) {
|
|
|
+ private List<AppAlarmDataPageVo> getAlarmDataList(List<IotAlarmData> dataList, String sourceType, List<SysOrgVO> cacheList) {
|
|
|
List<IotAlarmData> list = dataList.stream()
|
|
|
.filter(d -> ObjectUtil.equal(d.getSourceType(), sourceType))
|
|
|
.filter(d -> ObjectUtil.isNull(d.getEndTime()))
|