change - 传感器汇总数据不显示问题处理

main
wenjy 2 years ago
parent d983773edd
commit e6c8416705

@ -91,7 +91,7 @@ public class IndexController {
baseMonitorunitInfoDtoList.stream()
.filter(
y ->
!y.getParentId().isEmpty()
y.getParentId()!=null
&& y.getMonitorunitType().equals(x.getMonitorunittypeId()))
.collect(Collectors.toList());
BaseMonitorunitInfoDto info = new BaseMonitorunitInfoDto();
@ -396,50 +396,57 @@ public class IndexController {
@GetMapping("/quantityStatistics")
@ResponseBody
public String quantityStatistics() {
List<BaseSensorInfoDto> baseSensorInfoDtos = new ArrayList<>();
List<Integer> result = new ArrayList<>();
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtoList = new ArrayList<BaseMonitorunitInfoDto>();
try {
List<BaseSensorInfoDto> baseSensorInfoDtos = new ArrayList<>();
SysUser sysUser = ShiroUtils.getSysUser();
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtoList = new ArrayList<BaseMonitorunitInfoDto>();
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
SysUser sysUser = ShiroUtils.getSysUser();
if(!ShiroUtils.getLoginName().equals("admin")){
for (SysRole sysRole : sysRoles) {
//
BaseSensorInfo baseSensorInfo = new BaseSensorInfo();
baseSensorInfo.setEnableFlag(0L);
baseSensorInfo.setRoleId(sysRole.getRoleId());
List<BaseSensorInfoDto> baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo);
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
if(!ShiroUtils.getLoginName().equals("admin")){
for (SysRole sysRole : sysRoles) {
//
BaseSensorInfo baseSensorInfo = new BaseSensorInfo();
baseSensorInfo.setEnableFlag(0L);
baseSensorInfo.setRoleId(sysRole.getRoleId());
List<BaseSensorInfoDto> baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo);
baseSensorInfoDtos.addAll(baseSensorInfoDtos1);
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
baseMonitorunitInfo.setRoleId(sysRole.getRoleId());
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos);
}
}else{
List<BaseSensorInfoDto> baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(null,0L));
baseSensorInfoDtos.addAll(baseSensorInfoDtos1);
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
baseMonitorunitInfo.setRoleId(sysRole.getRoleId());
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo());
baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos);
}
}else{
List<BaseSensorInfoDto> baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(null,0L));
baseSensorInfoDtos.addAll(baseSensorInfoDtos1);
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo());
baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos);
result =
new ArrayList<Integer>() {
{
this.add(baseSensorInfoDtos.size());
this.add(
baseMonitorunitInfoDtoList.stream()
.filter(x -> x.getParentId() != null && x.getEnableFlag() == 0L)
.collect(Collectors.toList())
.size());
}
};
}catch (Exception ex) {
System.out.println(ex.getMessage());
}
List<Integer> result =
new ArrayList<Integer>() {
{
this.add(baseSensorInfoDtos.size());
this.add(
baseMonitorunitInfoDtoList.stream()
.filter(x -> !x.getParentId().isEmpty() && x.getEnableFlag() == 0L)
.collect(Collectors.toList())
.size());
}
};
return JSONArray.toJSONString(result);
}
@ -454,30 +461,34 @@ public class IndexController {
@ResponseBody
public String getAlarmAmount() {
List<String> info = new ArrayList<>();
List<RecordAlarm> recordAlarms = new ArrayList<>();
SysUser sysUser = ShiroUtils.getSysUser();
try{
List<RecordAlarm> recordAlarms = new ArrayList<>();
SysUser sysUser = ShiroUtils.getSysUser();
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
for (SysRole sysRole : sysRoles) {
RecordAlarm recordAlarm = new RecordAlarm();
recordAlarm.setRoleId(sysRole.getRoleId());
List<RecordAlarm> recordAlarms1 = recordAlarmService.selectRecordAlarmList(recordAlarm);
recordAlarms.addAll(recordAlarms1);
}
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
for (SysRole sysRole : sysRoles) {
RecordAlarm recordAlarm = new RecordAlarm();
recordAlarm.setRoleId(sysRole.getRoleId());
List<RecordAlarm> recordAlarms1 = recordAlarmService.selectRecordAlarmList(recordAlarm);
recordAlarms.addAll(recordAlarms1);
}
if (recordAlarms.size() > 0) {
int size =
recordAlarms.stream()
.filter(x -> x.getDisposeFlag() == 0L)
.collect(Collectors.toList())
.size();
if (recordAlarms.size() > 0) {
int size =
recordAlarms.stream()
.filter(x -> x.getDisposeFlag() == 0L)
.collect(Collectors.toList())
.size();
info.add(size + "");
info.add(recordAlarms.size() + "");
info.add(size + "");
info.add(recordAlarms.size() + "");
} else {
info.add("--");
info.add("--");
} else {
info.add("--");
info.add("--");
}
}catch (Exception ex) {
System.out.println(ex.getMessage());
}
return JSONArray.toJSONString(info);

@ -99,47 +99,51 @@ public class SensorSummaryController extends BaseController {
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) {
List<SysParamConfig> 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);
sysParamConfigs.forEach(
params -> {
info.put(params.getParamTitle(), datavalue.get(params.getParamTitle()));
});
info.put("datatype", data.get("datatype"));
String collectTime = jsonObject.get("collectTime").toString();
if (collectTime.length() > 19) {
collectTime = collectTime.substring(0, collectTime.indexOf(".")).replace("T", " ");
try{
Map<String, Object> info = new HashMap<>();
Object jrm = redisTemplate.opsForHash().get(x.getSensorType(), x.getSensorId());
if (jrm != null) {
List<SysParamConfig> 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);
sysParamConfigs.forEach(
params -> {
info.put(params.getParamTitle(), datavalue.get(params.getParamTitle()));
});
info.put("datatype", data.get("datatype"));
String collectTime = jsonObject.get("collectTime").toString();
if (collectTime.length() > 19) {
collectTime = collectTime.substring(0, collectTime.indexOf(".")).replace("T", " ");
}
info.put("collectTime", collectTime);
}
info.put("id", indexId++);
info.put("collectTime", collectTime);
}
info.put("id", indexId++);
info.put("sensorId", x.getSensorId());
info.put("sensorId", x.getSensorId());
info.put("edgeId", x.getEdgeId());
info.put("edgeId", x.getEdgeId());
info.put("sensorLocation", x.getSensorLocation());
info.put("sensorLocation", x.getSensorLocation());
List<BaseSensorType> baseSensorTypeList = baseSensorTypeService.selectBaseSensorTypeList(new BaseSensorType(sensorTypeId, null, 0L));
List<BaseSensorType> baseSensorTypeList = baseSensorTypeService.selectBaseSensorTypeList(new BaseSensorType(sensorTypeId, null, 0L));
info.put("sensorType", baseSensorTypeList.get(0).getSensortypeName());
info.put("sensorType", baseSensorTypeList.get(0).getSensortypeName());
result.add(info);
result.add(info);
}catch (Exception ex) {
System.out.println("异常:"+ex.getMessage());
}
}
String s = JSONArray.toJSONString(result);

@ -9,9 +9,9 @@ spring:
url: jdbc:mysql://121.36.58.109:3306/jrm-intelligent-iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: Haiwei123456
# url: jdbc:mysql://localhost:3306/jrm-intelligent-iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# url: jdbc:mysql://47.122.6.3:6001/jrm-intelligent-iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&failOverReadOnly=false
# username: root
# password: root
# password: jrmRoot
# 从库数据源
slave:
# 从数据源开关/默认关闭

@ -71,16 +71,16 @@ spring:
enabled: true
#Redis配置
redis:
port: 6379
password: admin123
host: 121.36.58.109
port: 6379
password:
timeout: 12000ms
jedis:
pool:
max-active: 8
max-active: 300
max-wait: -1ms
max-idle: 8
min-idle: 0
timeout: 5000ms
# MyBatis
mybatis:

@ -2,7 +2,8 @@ $(document).ready(function () {
//$.cookie('userID', '0001');
var wsImpl = window.WebSocket || window.MozWebSocket;
console.log("connecting to server ..");
window.ws = new wsImpl('ws://121.36.58.109:7181');
//window.ws = new wsImpl('ws://121.36.58.109:7181');
window.ws = new wsImpl('ws://47.122.6.3:7181');
ws.onmessage = function (evt) {
let result = $.parseJSON(evt.data);
};

@ -579,7 +579,8 @@
$.cookie('userID', '0000');
var wsImpl = window.WebSocket || window.MozWebSocket;
console.log("connecting to server ..");
window.ws = new wsImpl('ws://121.36.58.109:7181');
//window.ws = new wsImpl('ws://121.36.58.109:7181');
window.ws = new wsImpl('ws://47.122.6.3:7181');
ws.onmessage = function (evt) {
let result = $.parseJSON(evt.data);
console.log(result);

@ -178,7 +178,6 @@
var roleSort = $("input[name='roleSort']").val();
var status = $("input[id='status']").is(':checked') == true ? 0 : 1;
var remark = $("input[name='remark']").val();
//var menuIds = $.tree.getCheckedNodes();
var menuIds = getCheckedNodes("menuTrees");
var monitorunits = getCheckedNodes("menuTreess");

Loading…
Cancel
Save