|
|
@ -3,29 +3,24 @@ package com.ruoyi.web.controller.iot;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
|
|
|
|
|
|
import com.ruoyi.common.annotation.Excel;
|
|
|
|
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
import com.ruoyi.common.json.JsonUtils;
|
|
|
|
import com.ruoyi.common.json.JsonUtils;
|
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
|
|
|
|
|
import com.ruoyi.system.domain.BaseSensorInfo;
|
|
|
|
import com.ruoyi.system.domain.BaseSensorInfo;
|
|
|
|
import com.ruoyi.system.domain.BaseSensorType;
|
|
|
|
import com.ruoyi.system.domain.BaseSensorType;
|
|
|
|
import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
|
|
|
|
import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
|
|
|
|
import com.ruoyi.system.service.IBaseSensorInfoService;
|
|
|
|
import com.ruoyi.system.service.IBaseSensorInfoService;
|
|
|
|
import com.ruoyi.system.service.IBaseSensorTypeService;
|
|
|
|
import com.ruoyi.system.service.IBaseSensorTypeService;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 传感器汇总
|
|
|
|
* 传感器汇总
|
|
|
@ -37,6 +32,9 @@ import java.util.*;
|
|
|
|
@RequestMapping("/iot/sensorSummary")
|
|
|
|
@RequestMapping("/iot/sensorSummary")
|
|
|
|
public class SensorSummaryController extends BaseController {
|
|
|
|
public class SensorSummaryController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${sensorSummary.hiddenField}")
|
|
|
|
|
|
|
|
private String hiddenField;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired private IBaseSensorTypeService baseSensorTypeService;
|
|
|
|
@Autowired private IBaseSensorTypeService baseSensorTypeService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired private IBaseSensorInfoService baseSensorInfoService;
|
|
|
|
@Autowired private IBaseSensorInfoService baseSensorInfoService;
|
|
|
@ -59,6 +57,54 @@ public class SensorSummaryController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/getSensorInfo")
|
|
|
|
@PostMapping("/getSensorInfo")
|
|
|
|
@ResponseBody
|
|
|
|
@ResponseBody
|
|
|
|
|
|
|
|
public String getSensorHistoryData(String sensorTypeId) {
|
|
|
|
|
|
|
|
int indexId = 1;
|
|
|
|
|
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
|
|
|
|
|
List<BaseSensorInfoDto> baseSensorInfoDtos =
|
|
|
|
|
|
|
|
baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(sensorTypeId, 0L));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (BaseSensorInfoDto x : baseSensorInfoDtos) {
|
|
|
|
|
|
|
|
Map<String, Object> info = new HashMap<>();
|
|
|
|
|
|
|
|
Object jrm = redisTemplate.opsForHash().get(x.getSensorType(), x.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"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String collectTime = jsonObject.get("collectTime").toString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
info.put(
|
|
|
|
|
|
|
|
"collectTime",
|
|
|
|
|
|
|
|
collectTime.substring(0, collectTime.indexOf(".")).replace("T", " "));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
info.put("id", indexId++);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
info.put("sensorId", x.getSensorId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
info.put("edgeId", x.getEdgeId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
info.put("sensorLocation", x.getSensorLocation());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String[] split = hiddenField.split(",");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String s : split) {
|
|
|
|
|
|
|
|
if(info.containsKey(s)){
|
|
|
|
|
|
|
|
info.remove(s);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.add(info);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String s = JSONArray.toJSONString(result);
|
|
|
|
|
|
|
|
return s;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/getSensorInfo1")
|
|
|
|
|
|
|
|
@ResponseBody
|
|
|
|
public String getSensorInfo(String sensorTypeId) {
|
|
|
|
public String getSensorInfo(String sensorTypeId) {
|
|
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
|