From 0bb1e450a251bb7f6da882d26060f645a504b182 Mon Sep 17 00:00:00 2001 From: wenjy Date: Thu, 31 Mar 2022 14:54:02 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E4=BC=A0=E6=84=9F=E5=99=A8?= =?UTF-8?q?=E6=B1=87=E6=80=BB=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=85=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/SensorSummaryController.java | 32 ++++++++++++------- .../static/js/Iot-ui/sensorTableList.js | 2 +- .../ruoyi/system/domain/SysParamConfig.java | 10 ++++++ 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/SensorSummaryController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/SensorSummaryController.java index b7952b6..d4f7b28 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/SensorSummaryController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/SensorSummaryController.java @@ -7,9 +7,11 @@ import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.json.JsonUtils; import com.ruoyi.system.domain.BaseSensorInfo; import com.ruoyi.system.domain.BaseSensorType; +import com.ruoyi.system.domain.SysParamConfig; import com.ruoyi.system.domain.dto.BaseSensorInfoDto; import com.ruoyi.system.service.IBaseSensorInfoService; import com.ruoyi.system.service.IBaseSensorTypeService; +import com.ruoyi.system.service.ISysParamConfigService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.StringRedisTemplate; @@ -39,6 +41,8 @@ public class SensorSummaryController extends BaseController { @Autowired private IBaseSensorInfoService baseSensorInfoService; + @Autowired private ISysParamConfigService sysParamConfigService; + @Autowired private StringRedisTemplate redisTemplate; @GetMapping() @@ -67,18 +71,30 @@ public class SensorSummaryController extends BaseController { Map info = new HashMap<>(); Object jrm = redisTemplate.opsForHash().get(x.getSensorType(), x.getSensorId()); if (jrm != null) { + List sysParamConfigs = + sysParamConfigService.selectSysParamConfigList( + new SysParamConfig(x.getSensorType(), null, 0L)); + 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 = JsonUtils.JSONObjectToMap(datavalue); + + sysParamConfigs.forEach( + params -> { + info.put(params.getParamTitle(), datavalue.get(params.getParamTitle())); + }); + info.put("datatype", data.get("datatype")); String collectTime = jsonObject.get("collectTime").toString(); - info.put( - "collectTime", - collectTime.substring(0, collectTime.indexOf(".")).replace("T", " ")); + if (collectTime.length() > 19) { + collectTime = collectTime.substring(0, collectTime.indexOf(".")).replace("T", " "); + } + + info.put("collectTime", collectTime); } info.put("id", indexId++); @@ -88,14 +104,6 @@ public class SensorSummaryController extends BaseController { info.put("sensorLocation", x.getSensorLocation()); - String[] split = hiddenField.split(","); - - for (String s : split) { - if(info.containsKey(s)){ - info.remove(s); - } - } - result.add(info); } diff --git a/ruoyi-admin/src/main/resources/static/js/Iot-ui/sensorTableList.js b/ruoyi-admin/src/main/resources/static/js/Iot-ui/sensorTableList.js index 4dce639..24c7513 100644 --- a/ruoyi-admin/src/main/resources/static/js/Iot-ui/sensorTableList.js +++ b/ruoyi-admin/src/main/resources/static/js/Iot-ui/sensorTableList.js @@ -27,7 +27,7 @@ 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" || property == "md5" ? 500 : 180, + width: property == "imgstr" || property == "md5" ? 500 : 140, align: "center",height: 60 }); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysParamConfig.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysParamConfig.java index 9476657..e5efc40 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysParamConfig.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysParamConfig.java @@ -15,6 +15,16 @@ public class SysParamConfig extends BaseEntity { private static final long serialVersionUID = 1L; + + public SysParamConfig() { + } + + public SysParamConfig(String paramType, Integer visibleFlag,Long enableFlag) { + this.paramType = paramType; + this.visibleFlag = visibleFlag; + this.enableFlag = enableFlag; + } + /** 主键标识 */ private Long objId;