change - 传感器汇总修改,根据参数配置显示数据

main
wenjy 3 years ago
parent 3356826f3b
commit 0bb1e450a2

@ -7,9 +7,11 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.json.JsonUtils; import com.ruoyi.common.json.JsonUtils;
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.SysParamConfig;
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 com.ruoyi.system.service.ISysParamConfigService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
@ -39,6 +41,8 @@ public class SensorSummaryController extends BaseController {
@Autowired private IBaseSensorInfoService baseSensorInfoService; @Autowired private IBaseSensorInfoService baseSensorInfoService;
@Autowired private ISysParamConfigService sysParamConfigService;
@Autowired private StringRedisTemplate redisTemplate; @Autowired private StringRedisTemplate redisTemplate;
@GetMapping() @GetMapping()
@ -67,18 +71,30 @@ public class SensorSummaryController extends BaseController {
Map<String, Object> info = new HashMap<>(); Map<String, Object> info = new HashMap<>();
Object jrm = redisTemplate.opsForHash().get(x.getSensorType(), x.getSensorId()); Object jrm = redisTemplate.opsForHash().get(x.getSensorType(), x.getSensorId());
if (jrm != null) { if (jrm != null) {
List<SysParamConfig> sysParamConfigs =
sysParamConfigService.selectSysParamConfigList(
new SysParamConfig(x.getSensorType(), null, 0L));
JSONObject jsonObject = JSON.parseObject(jrm.toString()); JSONObject jsonObject = JSON.parseObject(jrm.toString());
Object param = jsonObject.get("param"); Object param = jsonObject.get("param");
JSONObject data = JSON.parseObject(param.toString()); JSONObject data = JSON.parseObject(param.toString());
JSONObject datavalue = JSON.parseObject(data.get("datavalue").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")); info.put("datatype", data.get("datatype"));
String collectTime = jsonObject.get("collectTime").toString(); String collectTime = jsonObject.get("collectTime").toString();
info.put( if (collectTime.length() > 19) {
"collectTime", collectTime = collectTime.substring(0, collectTime.indexOf(".")).replace("T", " ");
collectTime.substring(0, collectTime.indexOf(".")).replace("T", " ")); }
info.put("collectTime", collectTime);
} }
info.put("id", indexId++); info.put("id", indexId++);
@ -88,14 +104,6 @@ public class SensorSummaryController extends BaseController {
info.put("sensorLocation", x.getSensorLocation()); info.put("sensorLocation", x.getSensorLocation());
String[] split = hiddenField.split(",");
for (String s : split) {
if(info.containsKey(s)){
info.remove(s);
}
}
result.add(info); result.add(info);
} }

@ -27,7 +27,7 @@ const sensorInfoList = function (sensorTypeId) {
columnsArray.push({ columnsArray.push({
field: property, field: property,
title: typeof(sensorTypeArray.find(x=>x.paramTitle.includes(property))) == "undefined" ? property : sensorTypeArray.find(x=>x.paramTitle.includes(property)).paramText, 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 align: "center",height: 60
}); });
} }

@ -15,6 +15,16 @@ public class SysParamConfig extends BaseEntity
{ {
private static final long serialVersionUID = 1L; 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; private Long objId;

Loading…
Cancel
Save