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;