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

main
wenjy 2 years ago
parent d983773edd
commit e6c8416705

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

@ -99,47 +99,51 @@ public class SensorSummaryController extends BaseController {
baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(sensorTypeId, 0L));*/ baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(sensorTypeId, 0L));*/
for (BaseSensorInfoDto x : baseSensorInfoDtos) { for (BaseSensorInfoDto x : baseSensorInfoDtos) {
Map<String, Object> info = new HashMap<>(); try{
Object jrm = redisTemplate.opsForHash().get(x.getSensorType(), x.getSensorId()); Map<String, Object> info = new HashMap<>();
if (jrm != null) { Object jrm = redisTemplate.opsForHash().get(x.getSensorType(), x.getSensorId());
List<SysParamConfig> sysParamConfigs = if (jrm != null) {
sysParamConfigService.selectSysParamConfigList( List<SysParamConfig> sysParamConfigs =
new SysParamConfig(x.getSensorType(), null, 0L)); sysParamConfigService.selectSysParamConfigList(
new SysParamConfig(x.getSensorType(), null, 0L));
JSONObject jsonObject = JSON.parseObject(jrm.toString());
Object param = jsonObject.get("param"); JSONObject jsonObject = JSON.parseObject(jrm.toString());
JSONObject data = JSON.parseObject(param.toString()); Object param = jsonObject.get("param");
JSONObject datavalue = JSON.parseObject(data.get("datavalue").toString()); JSONObject data = JSON.parseObject(param.toString());
// info = JsonUtils.JSONObjectToMap(datavalue); JSONObject datavalue = JSON.parseObject(data.get("datavalue").toString());
// info = JsonUtils.JSONObjectToMap(datavalue);
sysParamConfigs.forEach(
params -> { sysParamConfigs.forEach(
info.put(params.getParamTitle(), datavalue.get(params.getParamTitle())); 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();
if (collectTime.length() > 19) {
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++);
info.put("collectTime", collectTime); info.put("sensorId", x.getSensorId());
}
info.put("id", indexId++);
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); 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 url: jdbc:mysql://121.36.58.109:3306/jrm-intelligent-iot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: Haiwei123456 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 # username: root
# password: root # password: jrmRoot
# 从库数据源 # 从库数据源
slave: slave:
# 从数据源开关/默认关闭 # 从数据源开关/默认关闭

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

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

@ -579,7 +579,8 @@
$.cookie('userID', '0000'); $.cookie('userID', '0000');
var wsImpl = window.WebSocket || window.MozWebSocket; var wsImpl = window.WebSocket || window.MozWebSocket;
console.log("connecting to server .."); 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) { ws.onmessage = function (evt) {
let result = $.parseJSON(evt.data); let result = $.parseJSON(evt.data);
console.log(result); console.log(result);

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

Loading…
Cancel
Save