|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
package com.ruoyi.web.controller.iot;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.ruoyi.common.json.JsonUtils;
|
|
|
|
|
import com.ruoyi.system.domain.BaseMonitorunitInfo;
|
|
|
|
|
import com.ruoyi.system.domain.BaseSensorInfo;
|
|
|
|
|
import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto;
|
|
|
|
@ -9,13 +12,16 @@ import com.ruoyi.system.service.IBaseMonitorunitInfoService;
|
|
|
|
|
import com.ruoyi.system.service.IBaseSensorInfoService;
|
|
|
|
|
import lombok.Data;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -32,6 +38,8 @@ public class DeviceMonitorController {
|
|
|
|
|
|
|
|
|
|
@Autowired private IBaseSensorInfoService baseSensorInfoService;
|
|
|
|
|
|
|
|
|
|
@Autowired private StringRedisTemplate redisTemplate;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取监控单元列表
|
|
|
|
|
*
|
|
|
|
@ -107,7 +115,8 @@ public class DeviceMonitorController {
|
|
|
|
|
@GetMapping("/getSensorInfo")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public String getSensorInfo(String monitorunitId) {
|
|
|
|
|
List<BaseSensorInfoDto> baseSensorInfoDtos = new ArrayList<>();
|
|
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
|
|
//List<BaseSensorInfoDto> baseSensorInfoDtos = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
|
|
|
|
|
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(
|
|
|
|
@ -115,26 +124,48 @@ public class DeviceMonitorController {
|
|
|
|
|
|
|
|
|
|
baseMonitorunitInfoDtos.forEach(
|
|
|
|
|
x -> {
|
|
|
|
|
/*if(x.getParentId().isEmpty()){
|
|
|
|
|
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
|
|
|
|
|
baseMonitorunitInfo.setParentId(x.getMonitorunitId());
|
|
|
|
|
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos1 = baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
|
|
|
|
|
baseMonitorunitInfoDtos1.forEach(y->{
|
|
|
|
|
List<BaseSensorInfoDto> baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(null, null, null, y.getMonitorunitId()));
|
|
|
|
|
baseSensorInfoDtos.addAll(baseSensorInfoDtos1);
|
|
|
|
|
});
|
|
|
|
|
}else{
|
|
|
|
|
List<BaseSensorInfoDto> baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(null, null, null, x.getMonitorunitId()));
|
|
|
|
|
baseSensorInfoDtos.addAll(baseSensorInfoDtos1);
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
List<BaseSensorInfoDto> baseSensorInfoDtos1 =
|
|
|
|
|
baseSensorInfoService.selectBaseSensorInfoList(
|
|
|
|
|
new BaseSensorInfo(null, null, null, x.getMonitorunitId()));
|
|
|
|
|
baseSensorInfoDtos.addAll(baseSensorInfoDtos1);
|
|
|
|
|
List<BaseSensorInfoDto> baseSensorInfoDtos =
|
|
|
|
|
baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(null, null, null, x.getMonitorunitId()));
|
|
|
|
|
|
|
|
|
|
baseSensorInfoDtos.forEach(y -> {
|
|
|
|
|
Map<String, Object> info = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
Object jrm = redisTemplate.opsForHash().get(y.getSensorType(), y.getSensorId());
|
|
|
|
|
|
|
|
|
|
if (jrm != null) {
|
|
|
|
|
JSONObject jsonObject = JSON.parseObject(jrm.toString());
|
|
|
|
|
|
|
|
|
|
Object param = jsonObject.get("param");
|
|
|
|
|
|
|
|
|
|
JSONObject data = JSON.parseObject(param.toString());
|
|
|
|
|
|
|
|
|
|
JSONObject datavalue = JSON.parseObject(data.get("datavalue").toString());
|
|
|
|
|
|
|
|
|
|
info = JsonUtils.JSONObjectToMap(datavalue);
|
|
|
|
|
|
|
|
|
|
info.put("datatype", data.get("datatype"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info.put("datatype",y.getSensorType());
|
|
|
|
|
|
|
|
|
|
info.put("id", 1);
|
|
|
|
|
|
|
|
|
|
info.put("sensorId", y.getSensorId());
|
|
|
|
|
|
|
|
|
|
info.put("edgeId", y.getEdgeId());
|
|
|
|
|
|
|
|
|
|
info.put("sensorLocation", y.getSensorLocation());
|
|
|
|
|
|
|
|
|
|
result.add(info);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return JSONArray.toJSONString(baseSensorInfoDtos);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String s = JSONArray.toJSONString(result);
|
|
|
|
|
System.out.println("传感器数据展示" + s);
|
|
|
|
|
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|