From e6c841670533ee9032f0c643ba9fa4852297d081 Mon Sep 17 00:00:00 2001 From: wenjy Date: Tue, 3 Jan 2023 21:47:00 +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=E6=95=B0=E6=8D=AE=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/iot/IndexController.java | 117 ++++++++++-------- .../iot/SensorSummaryController.java | 72 ++++++----- .../src/main/resources/application-druid.yml | 4 +- .../src/main/resources/application.yml | 8 +- .../main/resources/static/js/baseStation.js | 3 +- .../templates/section/transformer-detail.html | 3 +- .../resources/templates/system/role/edit.html | 1 - 7 files changed, 112 insertions(+), 96 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/IndexController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/IndexController.java index 9151b0d..2278d4a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/IndexController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/IndexController.java @@ -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 baseSensorInfoDtos = new ArrayList<>(); + List result = new ArrayList<>(); - List baseMonitorunitInfoDtoList = new ArrayList(); + try { + List baseSensorInfoDtos = new ArrayList<>(); - SysUser sysUser = ShiroUtils.getSysUser(); + List baseMonitorunitInfoDtoList = new ArrayList(); - List 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 baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); + List 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 baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); + baseSensorInfoDtos.addAll(baseSensorInfoDtos1); + + BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo(); + baseMonitorunitInfo.setRoleId(sysRole.getRoleId()); + List baseMonitorunitInfoDtos = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); + baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos); + } + }else{ + + List baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(null,0L)); baseSensorInfoDtos.addAll(baseSensorInfoDtos1); - BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo(); - baseMonitorunitInfo.setRoleId(sysRole.getRoleId()); List baseMonitorunitInfoDtos = - baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo()); baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos); } - }else{ - - List baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(null,0L)); - baseSensorInfoDtos.addAll(baseSensorInfoDtos1); - List baseMonitorunitInfoDtos = - baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo()); - baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos); + result = + new ArrayList() { + { + 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 result = - new ArrayList() { - { - 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 info = new ArrayList<>(); - List recordAlarms = new ArrayList<>(); - SysUser sysUser = ShiroUtils.getSysUser(); + try{ + List recordAlarms = new ArrayList<>(); + SysUser sysUser = ShiroUtils.getSysUser(); - List sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId()); - for (SysRole sysRole : sysRoles) { - RecordAlarm recordAlarm = new RecordAlarm(); - recordAlarm.setRoleId(sysRole.getRoleId()); - List recordAlarms1 = recordAlarmService.selectRecordAlarmList(recordAlarm); - recordAlarms.addAll(recordAlarms1); - } + List sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId()); + for (SysRole sysRole : sysRoles) { + RecordAlarm recordAlarm = new RecordAlarm(); + recordAlarm.setRoleId(sysRole.getRoleId()); + List 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); 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 9a9ab49..e36f80a 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 @@ -99,47 +99,51 @@ public class SensorSummaryController extends BaseController { baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(sensorTypeId, 0L));*/ for (BaseSensorInfoDto x : baseSensorInfoDtos) { - 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); - - 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 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); + + 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 baseSensorTypeList = baseSensorTypeService.selectBaseSensorTypeList(new BaseSensorType(sensorTypeId, null, 0L)); + List 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); diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index ed3ae52..03fad0f 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -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: # 从数据源开关/默认关闭 diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 223e8e4..8bef1e9 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -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: diff --git a/ruoyi-admin/src/main/resources/static/js/baseStation.js b/ruoyi-admin/src/main/resources/static/js/baseStation.js index 53da995..07d7699 100644 --- a/ruoyi-admin/src/main/resources/static/js/baseStation.js +++ b/ruoyi-admin/src/main/resources/static/js/baseStation.js @@ -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); }; diff --git a/ruoyi-admin/src/main/resources/templates/section/transformer-detail.html b/ruoyi-admin/src/main/resources/templates/section/transformer-detail.html index 634fcc9..9003d8c 100644 --- a/ruoyi-admin/src/main/resources/templates/section/transformer-detail.html +++ b/ruoyi-admin/src/main/resources/templates/section/transformer-detail.html @@ -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); diff --git a/ruoyi-admin/src/main/resources/templates/system/role/edit.html b/ruoyi-admin/src/main/resources/templates/system/role/edit.html index 2c75bf3..b87c220 100644 --- a/ruoyi-admin/src/main/resources/templates/system/role/edit.html +++ b/ruoyi-admin/src/main/resources/templates/system/role/edit.html @@ -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");