change - 传感器汇总表格样式处理,数据排列顺序修改

main
wenjy 3 years ago
parent a4da456d05
commit 3356826f3b

@ -3,29 +3,24 @@ package com.ruoyi.web.controller.iot;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
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.json.JsonUtils;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.BaseSensorInfo;
import com.ruoyi.system.domain.BaseSensorType;
import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
import com.ruoyi.system.service.IBaseSensorInfoService;
import com.ruoyi.system.service.IBaseSensorTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
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.concurrent.atomic.AtomicInteger;
/**
*
@ -37,6 +32,9 @@ import java.util.*;
@RequestMapping("/iot/sensorSummary")
public class SensorSummaryController extends BaseController {
@Value("${sensorSummary.hiddenField}")
private String hiddenField;
@Autowired private IBaseSensorTypeService baseSensorTypeService;
@Autowired private IBaseSensorInfoService baseSensorInfoService;
@ -59,6 +57,54 @@ public class SensorSummaryController extends BaseController {
@PostMapping("/getSensorInfo")
@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) {
List<Map<String, Object>> result = new ArrayList<>();
@ -121,4 +167,4 @@ public class SensorSummaryController extends BaseController {
System.out.println("key为" + item + "值为:" + children.get(item));
}
}
}
}

@ -73,7 +73,7 @@ spring:
redis:
port: 6379
password: admin123
host: 127.0.0.1
host: 121.36.58.109
jedis:
pool:
max-active: 8
@ -149,3 +149,7 @@ xss:
swagger:
# 是否开启swagger
enabled: true
#配置传感器汇总页面隐藏字段
sensorSummary:
hiddenField: alias,uid

@ -88,7 +88,7 @@ span{
}
#table{
height: 85%;
/*height: 85%;*/
color: #03A6BE;
table-layout: fixed;
}
@ -133,7 +133,7 @@ span{
}
.bootstrap-table .fixed-table-container .fixed-table-body{
height: 27em;
height: 29em;
overflow-x: auto;
overflow-y: auto;
}

@ -15,26 +15,8 @@ const sensorInfoList = function (sensorTypeId) {
const sensorTypeArray = getparamsFunction(sensorTypeId);
const columnsArray = [];
if(sensorTypeArray.length > 0){
columnsArray.push({field: "id", title: "序号", width: 60, colspan: 1, rowspan: 1, align: "center"});
columnsArray.push({field: "edgeId", title: "边设备ID", width: 160, colspan: 1, rowspan: 1, align: "center"});
columnsArray.push({field: "sensorId", title: "传感器ID", width: 160, colspan: 1, rowspan: 1, align: "center"});
columnsArray.push({
field: "sensorLocation",
title: "监测位置",
width: 145,
colspan: 1,
rowspan: 1,
align: "center"
});
columnsArray.push({
field: "collectTime",
title: "时间",
width: 160,
colspan: 1,
rowspan: 1,
align: "center"
});
columnsArray.push({field: "id", title: "序号", width: 60,height: 60, colspan: 1, rowspan: 1, align: "center"});
columnsArray.push({field: "sensorId", title: "传感器ID", width: 180,height: 60, colspan: 1, rowspan: 1, align: "center"});
if (json.length > 0) {
const jsonObj = Object.keys(json[0]);
@ -45,12 +27,32 @@ const sensorInfoList = function (sensorTypeId) {
columnsArray.push({
field: property,
title: typeof(sensorTypeArray.find(x=>x.paramTitle.includes(property))) == "undefined" ? property : sensorTypeArray.find(x=>x.paramTitle.includes(property)).paramText,
width: property === "imgstr" ? 500 : 160,
align: "center",
width: property == "imgstr" || property == "md5" ? 500 : 180,
align: "center",height: 60
});
}
}
}
columnsArray.push({
field: "sensorLocation",
title: "监测位置",
width: 180,
colspan: 1,
rowspan: 1,
align: "center",height: 60
});
columnsArray.push({
field: "collectTime",
title: "时间",
width: 200,
colspan: 1,
rowspan: 1,
align: "center",height: 60
});
columnsArray.push({field: "edgeId", title: "边设备ID", width: 180,height: 60, colspan: 1, rowspan: 1, align: "center"});
}
$('#table').bootstrapTable('destroy');

Loading…
Cancel
Save