From 035daf5a09c135fc59a8a5a4310cc62471fb94f3 Mon Sep 17 00:00:00 2001 From: wenjy Date: Thu, 4 Jul 2024 15:35:21 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E6=8E=A5=E5=8F=A3=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HwMonitorPlatformController.java | 14 ++- .../ruoyi/business/domain/BeaconDevice.java | 10 ++ .../ruoyi/business/domain/HwAlarmInfo.java | 23 +++- .../com/ruoyi/business/domain/HwDevice.java | 4 +- .../business/domain/VO/AlarmInfoExportVo.java | 6 +- .../service/impl/HwDeviceServiceImpl.java | 61 +++++----- .../mapper/business/HwAlarmInfoMapper.xml | 37 +++++- .../mapper/business/HwDeviceMapper.xml | 107 ++++++++++++------ 8 files changed, 185 insertions(+), 77 deletions(-) diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorPlatformController.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorPlatformController.java index dbcca22..c6883b1 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorPlatformController.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/controller/HwMonitorPlatformController.java @@ -327,11 +327,15 @@ public class HwMonitorPlatformController extends BaseController { public TableDataInfo selectBeaconDevicesHistory(@RequestParam(required = false) Map map){ // List beaconDevices = hwDeviceService.selectBeaconDevicesHistory(map); List> lists = hwDeviceService.selectBeaconDevicesHistory(map); - long total = Long.valueOf(lists.get(lists.size() - 1).get("total").toString()); - lists.remove(lists.size() - 1); - TableDataInfo dataTable = getDataTable(lists); - dataTable.setTotal(total); - return dataTable; + if(lists != null){ + long total = Long.valueOf(lists.get(lists.size() - 1).get("total").toString()); + lists.remove(lists.size() - 1); + TableDataInfo dataTable = getDataTable(lists); + dataTable.setTotal(total); + return dataTable; + }else { + return null; + } } /** * 根据设备id查询其对应的监控单元 diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/BeaconDevice.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/BeaconDevice.java index d29770f..b637b8c 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/BeaconDevice.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/BeaconDevice.java @@ -25,6 +25,8 @@ public class BeaconDevice { private String ifAlarm; + private String monitorUnitName; + public String getIfAlarm() { return ifAlarm; } @@ -97,6 +99,14 @@ public class BeaconDevice { this.longitude = longitude; } + public String getMonitorUnitName() { + return monitorUnitName; + } + + public void setMonitorUnitName(String monitorUnitName) { + this.monitorUnitName = monitorUnitName; + } + @Override public String toString() { return "BeaconDevice{" + diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwAlarmInfo.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwAlarmInfo.java index fc2ef21..17939c1 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwAlarmInfo.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwAlarmInfo.java @@ -111,8 +111,8 @@ public class HwAlarmInfo extends BaseEntity { /** * 实际报警时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "实际报警时间", width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "实际报警时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date alarmTime; /** @@ -124,6 +124,9 @@ public class HwAlarmInfo extends BaseEntity { private String monitorUnitName; private String alarmLevelName; private String alarmTypeName; + + private String areaName; + private String monitorUnitTypeName; /** * 是否处理该传感器全部报警 * */ @@ -297,6 +300,22 @@ public class HwAlarmInfo extends BaseEntity { this.alarmTypeName = alarmTypeName; } + public String getAreaName() { + return areaName; + } + + public void setAreaName(String areaName) { + this.areaName = areaName; + } + + public String getMonitorUnitTypeName() { + return monitorUnitTypeName; + } + + public void setMonitorUnitTypeName(String monitorUnitTypeName) { + this.monitorUnitTypeName = monitorUnitTypeName; + } + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwDevice.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwDevice.java index 40123d9..7312900 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwDevice.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/HwDevice.java @@ -47,6 +47,8 @@ public class HwDevice extends BaseEntity { @Excel(name = "所属监控单元") private Long monitorUnitId; + private String monitorUnitName; + /** * 设备类型(1:网关设备,2:网关子设备,3:直连设备) */ @@ -189,8 +191,6 @@ public class HwDevice extends BaseEntity { this.functionName = functionName; } - private String monitorUnitName; - private String sceneName; private String deviceModeName; private String tenantName; diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/AlarmInfoExportVo.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/AlarmInfoExportVo.java index 4ff0081..b0f8605 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/AlarmInfoExportVo.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/domain/VO/AlarmInfoExportVo.java @@ -14,9 +14,6 @@ public class AlarmInfoExportVo { @Excel(name = "报警id") private Long alarmInfoId; - @Excel(name = "报警区域") - private String areaName; - @Excel(name = "报警位置") private String monitorUnitName; @@ -38,6 +35,9 @@ public class AlarmInfoExportVo { @Excel(name = "类型") private String monitor_unit_type_name; + @Excel(name = "报警区域") + private String areaName; + public Long getAlarmInfoId() { return alarmInfoId; } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java index d920323..f90b045 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java @@ -1180,6 +1180,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService { beaconDevice.setDeviceLocation(hwDevices.get(i).getDeviceLocation()); beaconDevice.setDeviceLocation("白银市"); beaconDevice.setDeviceModeId(hwDevices.get(i).getDeviceModeId()); + beaconDevice.setMonitorUnitName(hwDevices.get(i).getMonitorUnitName()); //查询是否报警 Long integer = hwDeviceMapper.selectDeviceIfAlarm(hwDevices.get(i).getDeviceId()); String ifAlarm = new String(); @@ -1209,35 +1210,39 @@ public class HwDeviceServiceImpl implements IHwDeviceService { * */ @Override public List> selectBeaconDevicesHistory(Map map) { - TdHistorySelectDto tdHistorySelectDto = new TdHistorySelectDto(); - tdHistorySelectDto.setDatabaseName(TdEngineConstants.PLATFORM_DB_NAME); - tdHistorySelectDto.setTableName(TdEngineConstants.DEFAULT_TABLE_NAME_PREFIX+map.get("deviceId")); - tdHistorySelectDto.setFirstFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME); - if (map.get("pageSize")!=null){ - tdHistorySelectDto.setLimit(Integer.valueOf(map.get("pageSize").toString())); - } - if (map.get("pageSize")!=null&&map.get("pageNum")!=null){ - tdHistorySelectDto.setOffset(Integer.valueOf(map.get("pageSize").toString())*(Integer.valueOf(map.get("pageNum").toString())-1)); - } - tdHistorySelectDto.setOrderByFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME); - tdHistorySelectDto.setSort(TdEngineConstants.DEFAULT_ORDER_BY_MODE); - if (map.containsKey("startTime")&&map.get("startTime")!=null){ - tdHistorySelectDto.setStartTime(Timestamp.valueOf(map.get("startTime").toString()).getTime()); - } - if (map.containsKey("endTime")&&map.get("endTime")!=null){ - tdHistorySelectDto.setEndTime(Timestamp.valueOf(map.get("endTime").toString()).getTime()); - } - R historyData = remoteTdEngineService.getHistoryData(tdHistorySelectDto, SecurityConstants.INNER); - System.out.println("查询历史数据"+map.get("deviceId")); - List> dataList = historyData.getData().dataList; - for (int i = 0; i < dataList.size(); i++){ - dataList.get(i).put("deviceId",map.get("deviceId")); + try{ + TdHistorySelectDto tdHistorySelectDto = new TdHistorySelectDto(); + tdHistorySelectDto.setDatabaseName(TdEngineConstants.PLATFORM_DB_NAME); + tdHistorySelectDto.setTableName(TdEngineConstants.DEFAULT_TABLE_NAME_PREFIX+map.get("deviceId")); + tdHistorySelectDto.setFirstFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME); + if (map.get("pageSize")!=null){ + tdHistorySelectDto.setLimit(Integer.valueOf(map.get("pageSize").toString())); + } + if (map.get("pageSize")!=null&&map.get("pageNum")!=null){ + tdHistorySelectDto.setOffset(Integer.valueOf(map.get("pageSize").toString())*(Integer.valueOf(map.get("pageNum").toString())-1)); + } + tdHistorySelectDto.setOrderByFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME); + tdHistorySelectDto.setSort(TdEngineConstants.DEFAULT_ORDER_BY_MODE); + if (map.containsKey("startTime")&&map.get("startTime")!=null){ + tdHistorySelectDto.setStartTime(Timestamp.valueOf(map.get("startTime").toString()).getTime()); + } + if (map.containsKey("endTime")&&map.get("endTime")!=null){ + tdHistorySelectDto.setEndTime(Timestamp.valueOf(map.get("endTime").toString()).getTime()); + } + R historyData = remoteTdEngineService.getHistoryData(tdHistorySelectDto, SecurityConstants.INNER); + System.out.println("查询历史数据"+map.get("deviceId")); + List> dataList = historyData.getData().dataList; + for (int i = 0; i < dataList.size(); i++){ + dataList.get(i).put("deviceId",map.get("deviceId")); + } + int count = historyData.getData().count; + Map map1 = new HashMap<>(); + map1.put("total",count); + dataList.add(map1); + return dataList; + }catch (Exception ex){ + return null; } - int count = historyData.getData().count; - Map map1 = new HashMap<>(); - map1.put("total",count); - dataList.add(map1); - return dataList; } /** diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmInfoMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmInfoMapper.xml index 4c053c2..a1bb1c2 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmInfoMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmInfoMapper.xml @@ -29,6 +29,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + @@ -55,7 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select hai.alarm_info_id, hai.alarm_info_type, hai.alarm_releated_id, hai.device_id, + /*select hai.alarm_info_id, hai.alarm_info_type, hai.alarm_releated_id, hai.device_id, hai.monitor_unit_id, hai.tenant_id, hai.scene_id, hai.alarm_level_id, hai.alarm_type_id, hai.mode_function_id, hai.function_name, hai.function_identifier, hai.function_value, hai.trigger_status, hai.handle_status, hai.alarm_time, @@ -63,7 +65,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" hmu.monitor_unit_name,hal.alarm_level_name,hat.alarm_type_name from hw_alarm_info hai left join hw_monitor_unit hmu on hai.monitor_unit_id = hmu.monitor_unit_id left join hw_alarm_level hal on hai.alarm_level_id=hal.alarm_level_id - left join hw_alarm_type hat on hai.alarm_type_id=hat.alarm_type_id + left join hw_alarm_type hat on hai.alarm_type_id=hat.alarm_type_id*/ + select hai.alarm_info_id, + hai.alarm_info_type, + hai.alarm_releated_id, + hai.device_id, + hai.monitor_unit_id, + hai.tenant_id, + hai.scene_id, + hai.alarm_level_id, + hai.alarm_type_id, + hai.mode_function_id, + hai.function_name, + hai.function_identifier, + hai.function_value, + hai.trigger_status, + hai.handle_status, + hai.alarm_time, + hai.create_time, + hai.update_by, + hai.update_time, + hai.alarm_info_field, + hmu.monitor_unit_name, + hal.alarm_level_name, + hat.alarm_type_name, + ha.area_name, + hmut.monitor_unit_type_name + from hw_alarm_info hai + left join hw_monitor_unit hmu on hai.monitor_unit_id = hmu.monitor_unit_id + left join hw_alarm_level hal on hai.alarm_level_id = hal.alarm_level_id + left join hw_alarm_type hat on hai.alarm_type_id = hat.alarm_type_id + left join hw_area ha on ha.area_id = hmu.area_id + left join hw_monitor_unit_type hmut on hmu.monitor_unit_type_id = hmut.monitor_unit_type_id and device_status !='9' - and device_code like concat('%', #{deviceCode}, '%') - and device_name like concat('%', #{deviceName}, '%') - and scene_id = #{sceneId} - and monitor_unit_id = #{monitorUnitId} - and device_type = #{deviceType} - and networking_mode = #{networkingMode} - and access_protocol = #{accessProtocol} - and data_format = #{dataFormat} - and releated_device_id = #{releatedDeviceId} - and device_mode_id = #{deviceModeId} - and access_gw_protocol = #{accessGwProtocol} - and active_status = #{activeStatus} - and device_status = #{deviceStatus} - and active_time = #{activeTime} - and device_pic = #{devicePic} - and ip_address = #{ipAddress} - and area_id = #{areaId} - and device_location = #{deviceLocation} - and current_module_version = #{currentModuleVersion} - and current_singlechip_version = #{currentSinglechipVersion} - and device_field = #{deviceField} - and tenant_id = #{tenantId} - and online_status = #{onlineStatus} + and hd.device_code like concat('%', #{deviceCode}, '%') + and hd.device_name like concat('%', #{deviceName}, '%') + and hd.scene_id = #{sceneId} + and hd.monitor_unit_id = #{monitorUnitId} + and hd.device_type = #{deviceType} + and hd.networking_mode = #{networkingMode} + and hd.access_protocol = #{accessProtocol} + and hd.data_format = #{dataFormat} + and hd.releated_device_id = #{releatedDeviceId} + and hd.device_mode_id = #{deviceModeId} + and hd.access_gw_protocol = #{accessGwProtocol} + and hd.active_status = #{activeStatus} + and hd.device_status = #{deviceStatus} + and hd.active_time = #{activeTime} + and hd.device_pic = #{devicePic} + and hd.ip_address = #{ipAddress} + and hd.area_id = #{areaId} + and hd.device_location = #{deviceLocation} + and hd.current_module_version = #{currentModuleVersion} + and hd.current_singlechip_version = #{currentSinglechipVersion} + and hd.device_field = #{deviceField} + and hd.tenant_id = #{tenantId} + and hd.online_status = #{onlineStatus} ${params.tenantDataScope} @@ -131,7 +162,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -305,7 +336,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -328,10 +359,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"